From a1b630048c4c802fda3d4a8eb677918c4a871c99 Mon Sep 17 00:00:00 2001 From: Roy Falk Date: Thu, 28 Nov 2024 23:13:11 +0200 Subject: [PATCH] Fix bug 909 (#911) --- engine/src/cmd/unit_csv_factory.h | 2 +- engine/src/components/drive.cpp | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/engine/src/cmd/unit_csv_factory.h b/engine/src/cmd/unit_csv_factory.h index 5dcc613cd..1e822f4cf 100644 --- a/engine/src/cmd/unit_csv_factory.h +++ b/engine/src/cmd/unit_csv_factory.h @@ -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" }; diff --git a/engine/src/components/drive.cpp b/engine/src/components/drive.cpp index 57d838645..36a9eba92 100644 --- a/engine/src/components/drive.cpp +++ b/engine/src/components/drive.cpp @@ -84,16 +84,23 @@ void Drive::Load(std::string upgrade_key, retro = Resource(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(accel_string, game_accel_speed, minimal_drive_functionality); + vertical = Resource(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(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(vertical_accel_string, game_accel_speed, minimal_drive_functionality); + const std::string lateral_accel_string = std::to_string(lateral_accel); + lateral = Resource(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(vertical_accel_string, game_accel_speed, minimal_drive_functionality); + } + speed = Resource(UnitCSVFactory::GetVariable(unit_key, "Default_Speed_Governor", std::string("0.0")), game_speed, minimal_drive_functionality); }