From 4832a27845693883f1e7a86597c0a93436177097 Mon Sep 17 00:00:00 2001 From: Marie Bauer <83022833+Shiniri@users.noreply.github.com> Date: Thu, 8 Feb 2024 19:08:56 +0100 Subject: [PATCH] Issue 335: Repair cost as defined in .ini (#391) * Fixed issue where repair cost was not fetched from base inis. * Fixed CargoDrop and Condata that wouldn't compile as a result of a breaking SDK change. --------- Co-authored-by: oliverpechey --- CHANGELOG.md | 4 ++++ FLHookSDK | 2 +- plugins/autobuy/Autobuy.cpp | 18 +++++++++++++----- plugins/autobuy/Autobuy.h | 2 +- plugins/cargo_drop/CargoDrop.cpp | 4 ++-- plugins/condata/Condata.cpp | 2 +- 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0a1b9376..f226dd251 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Changelog +## 4.0.20 +- Fixed issue where repair cost was not fetched from base inis. +- Fixed CargoDrop and Condata that wouldn't compile as a result of a breaking SDK change. + ## 4.0.19 - Updated the SonarScan to use version 17 of Java, as 11 is no longer working and causes the pipeline to fail. - Updated SonarScan to 5.0.1.3006 diff --git a/FLHookSDK b/FLHookSDK index 2ab9634b7..32e6322fb 160000 --- a/FLHookSDK +++ b/FLHookSDK @@ -1 +1 @@ -Subproject commit 2ab9634b7a4a7b45a74470713aa422a9705e880d +Subproject commit 32e6322fbf8c9ac3d863680c2d0feeb31be1a87c diff --git a/plugins/autobuy/Autobuy.cpp b/plugins/autobuy/Autobuy.cpp index fe242564e..3ff277de2 100644 --- a/plugins/autobuy/Autobuy.cpp +++ b/plugins/autobuy/Autobuy.cpp @@ -67,7 +67,15 @@ namespace Plugins::Autobuy void handleRepairs(ClientId& client) { - auto repairCost = static_cast(Archetype::GetShip(Players[client].shipArchetype)->fHitPoints * (1 - Players[client].fRelativeHealth) / 3); + auto base = Hk::Player::GetCurrentBase(client); + + // If there is no error with finding the base the correct repair cost can be calculated + auto baseCost = 0.33; + if (base.has_value()) + { + baseCost = BaseDataList_get()->get_base_data(base.value())->get_ship_repair_cost(); + } + auto repairCost = static_cast((1 - Players[client].fRelativeHealth) * Archetype::GetShip(Players[client].shipArchetype)->fHitPoints * baseCost); std::set eqToFix; @@ -530,8 +538,8 @@ namespace Plugins::Autobuy auto config = Serializer::JsonToObject(); global->config = std::make_unique(config); - // Get ammo limit - for (const auto& iniPath : global->config->iniPaths) + // Get ammo limits + for (const auto& iniPath : global->config->ammoIniPaths) { INI_Reader ini; if (!ini.open(iniPath.c_str(), false)) @@ -563,7 +571,7 @@ namespace Plugins::Autobuy if (valid) { - global->ammoLimits[itemname] = itemlimit; + global->ammoLimits.insert(std::pair(itemname, itemlimit)); } } } @@ -573,7 +581,7 @@ namespace Plugins::Autobuy using namespace Plugins::Autobuy; -REFL_AUTO(type(Config), field(nanobot_nickname), field(shield_battery_nickname), field(iniPaths)) +REFL_AUTO(type(Config), field(nanobot_nickname), field(shield_battery_nickname), field(ammoIniPaths)) DefaultDllMainSettings(LoadSettings); diff --git a/plugins/autobuy/Autobuy.h b/plugins/autobuy/Autobuy.h index 57754072b..2cdd0c299 100644 --- a/plugins/autobuy/Autobuy.h +++ b/plugins/autobuy/Autobuy.h @@ -40,7 +40,7 @@ namespace Plugins::Autobuy std::string shield_battery_nickname = "ge_s_battery_01"; // paths to inis which should be read for ammo limits - std::vector iniPaths + std::vector ammoIniPaths { R"(..\data\equipment\light_equip.ini)", R"(..\data\equipment\select_equip.ini)", diff --git a/plugins/cargo_drop/CargoDrop.cpp b/plugins/cargo_drop/CargoDrop.cpp index c1be27393..647994bd4 100644 --- a/plugins/cargo_drop/CargoDrop.cpp +++ b/plugins/cargo_drop/CargoDrop.cpp @@ -85,7 +85,7 @@ namespace Plugins::CargoDrop // Simulate an obj update to stop the ship in space. SSPObjUpdateInfo updateInfo {}; snd.lastTimestamp += 1.0; - updateInfo.fTimestamp = static_cast(snd.lastTimestamp); + updateInfo.dTimestamp = snd.lastTimestamp; updateInfo.cState = 0; updateInfo.fThrottle = 0; updateInfo.vPos = snd.lastPosition; @@ -201,7 +201,7 @@ namespace Plugins::CargoDrop */ void SPObjUpdate(struct SSPObjUpdateInfo const& ui, ClientId& client) { - global->info[client].lastTimestamp = ui.fTimestamp; + global->info[client].lastTimestamp = ui.dTimestamp; global->info[client].lastPosition = ui.vPos; global->info[client].lastDirection = ui.vDir; } diff --git a/plugins/condata/Condata.cpp b/plugins/condata/Condata.cpp index 6e398e0c8..f1496ca4c 100644 --- a/plugins/condata/Condata.cpp +++ b/plugins/condata/Condata.cpp @@ -265,7 +265,7 @@ namespace Plugins::ConData return; // ??? 8[ const mstime timeNow = Hk::Time::GetUnixMiliseconds(); - const auto timestamp = static_cast(ui.fTimestamp * 1000); + const auto timestamp = static_cast(ui.dTimestamp * 1000); auto& con = global->connections[client];