Skip to content

Commit

Permalink
Issue 335: Repair cost as defined in .ini (#391)
Browse files Browse the repository at this point in the history
* 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 <olliezeta9@gmail.com>
  • Loading branch information
Shiniri and oliverpechey authored Feb 8, 2024
1 parent 1c8b742 commit 4832a27
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion FLHookSDK
18 changes: 13 additions & 5 deletions plugins/autobuy/Autobuy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ namespace Plugins::Autobuy

void handleRepairs(ClientId& client)
{
auto repairCost = static_cast<uint>(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<uint>((1 - Players[client].fRelativeHealth) * Archetype::GetShip(Players[client].shipArchetype)->fHitPoints * baseCost);

std::set<short> eqToFix;

Expand Down Expand Up @@ -530,8 +538,8 @@ namespace Plugins::Autobuy
auto config = Serializer::JsonToObject<Config>();
global->config = std::make_unique<Config>(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))
Expand Down Expand Up @@ -563,7 +571,7 @@ namespace Plugins::Autobuy

if (valid)
{
global->ammoLimits[itemname] = itemlimit;
global->ammoLimits.insert(std::pair<uint, int>(itemname, itemlimit));
}
}
}
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion plugins/autobuy/Autobuy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> iniPaths
std::vector<std::string> ammoIniPaths
{
R"(..\data\equipment\light_equip.ini)",
R"(..\data\equipment\select_equip.ini)",
Expand Down
4 changes: 2 additions & 2 deletions plugins/cargo_drop/CargoDrop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(snd.lastTimestamp);
updateInfo.dTimestamp = snd.lastTimestamp;
updateInfo.cState = 0;
updateInfo.fThrottle = 0;
updateInfo.vPos = snd.lastPosition;
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/condata/Condata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ namespace Plugins::ConData
return; // ??? 8[

const mstime timeNow = Hk::Time::GetUnixMiliseconds();
const auto timestamp = static_cast<mstime>(ui.fTimestamp * 1000);
const auto timestamp = static_cast<mstime>(ui.dTimestamp * 1000);

auto& con = global->connections[client];

Expand Down

0 comments on commit 4832a27

Please sign in to comment.