Skip to content

Commit

Permalink
Fix bug 909 (#911)
Browse files Browse the repository at this point in the history
  • Loading branch information
royfalk authored Nov 28, 2024
1 parent aaeb622 commit a1b6300
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion engine/src/cmd/unit_csv_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const std::string keys[] = {"Key", "Directory", "Name", "Object_Type",
"FaceCamera", "Unit_Role", "Attack_Preference", "Hidden_Hold_Volume", "Equipment_Space",

// New stuff
"armor", "shield_strength", "shield_facets"
"armor", "shield_strength", "shield_facets", "accel"

};

Expand Down
23 changes: 15 additions & 8 deletions engine/src/components/drive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,23 @@ void Drive::Load(std::string upgrade_key,
retro = Resource<double>(UnitCSVFactory::GetVariable(unit_key, "Retro_Accel", std::string("0.0")),
game_accel_speed, minimal_drive_functionality);

const double lateral_accel = 0.5 * UnitCSVFactory::GetVariable(unit_key, "Left_Accel", 0.0) +
double accel = UnitCSVFactory::GetVariable(unit_key, "accel", -1.0f);
if(accel != -1.0f) {
const std::string accel_string = std::to_string(accel);
lateral = Resource<double>(accel_string, game_accel_speed, minimal_drive_functionality);
vertical = Resource<double>(accel_string, game_accel_speed, minimal_drive_functionality);
} else {
const double lateral_accel = 0.5 * UnitCSVFactory::GetVariable(unit_key, "Left_Accel", 0.0) +
0.5 * UnitCSVFactory::GetVariable(unit_key, "Right_Accel", 0.0);
const std::string lateral_accel_string = std::to_string(lateral_accel);
lateral = Resource<double>(lateral_accel_string, game_accel_speed, minimal_drive_functionality);

const double vertical_accel = 0.5 * UnitCSVFactory::GetVariable(unit_key, "Top_Accel", 0.0) +
0.5 * UnitCSVFactory::GetVariable(unit_key, "Bottom_Accel", 0.0);
const std::string vertical_accel_string = std::to_string(vertical_accel);
vertical = Resource<double>(vertical_accel_string, game_accel_speed, minimal_drive_functionality);
const std::string lateral_accel_string = std::to_string(lateral_accel);
lateral = Resource<double>(lateral_accel_string, game_accel_speed, minimal_drive_functionality);

const double vertical_accel = 0.5 * UnitCSVFactory::GetVariable(unit_key, "Top_Accel", 0.0) +
0.5 * UnitCSVFactory::GetVariable(unit_key, "Bottom_Accel", 0.0);
const std::string vertical_accel_string = std::to_string(vertical_accel);
vertical = Resource<double>(vertical_accel_string, game_accel_speed, minimal_drive_functionality);
}

speed = Resource<double>(UnitCSVFactory::GetVariable(unit_key, "Default_Speed_Governor", std::string("0.0")),
game_speed, minimal_drive_functionality);
}
Expand Down

0 comments on commit a1b6300

Please sign in to comment.