Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 335: Repair cost as defined in .ini #391

Merged

Conversation

Shiniri
Copy link
Contributor

@Shiniri Shiniri commented Jan 25, 2024

Fixed the issue that the original issue described.

Copy link
Member

@oliverpechey oliverpechey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the submission! In addition to the comments could we:

  1. Fix the SonarCloud issue thats popped up
  2. Link the issue this resolves in the PR
  3. Take a look at my comment about the get_ship_repair_cost() function, since this could make things much simpler.

CHANGELOG.md Outdated
@@ -10,6 +10,9 @@
## 4.0.17
- Provided configs for 0x86AEC, 0x84018, 0xD3D6E and 0x58F46 in server.dll in crash catcher. These offsets were hardcoding several values that are often changed by mods manually relating to NPC spawn and scanner range. 0 values disables each respective hook.

## 4.0.17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be put at the top of the changelog and the version incremented please


if (valid)
{
global->repairCosts.insert(std::pair<uint, int>(baseNickname, repairCost));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this be inside the else if and remove the need of the valid variable? It's been a while since I looked at any INI parsing stuff admittedly

@@ -50,6 +50,14 @@ namespace Plugins::Autobuy
R"(..\data\equipment\weapon_equip.ini)",
R"(..\data\equipment\prop_equip.ini)"
};

//paths to inis which should be read for repair cost
std::vector<std::string> baseIniPaths
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't the admin need to add every single base ini if we did it this way? Could we not loop through the SYSTEMS folder and pull out any .ini thats ends in "base"? Wouldnt need to have this configurable variable then

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might have found a better way. There is a "get_ship_repair_cost" function in the BaseData class in FLCoreCommon.h, I wonder if we could use that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested this but I think you could do:

float cost = BaseDataList_get()->get_base_data(baseId)->get_ship_repair_cost();

That would make this code much simpler since you wouldnt need to parse INIs or keep a map of ship repair costs. You could just call this whenever you need to calculate a ship repair cost.

@@ -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);
auto repairCost = static_cast<uint>((1-Players[client].fRelativeHealth) * Archetype::GetShip(Players[client].shipArchetype)->fHitPoints * 0.33);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're calculating this value even if its gonna get overwritten by the assignment in the if check. Could we put this in an "else" after the if check?

@Shiniri Shiniri changed the title Issue 335: Repair cost reads from .ini Issue 335: Repair cost as defined in .ini Feb 8, 2024
@oliverpechey oliverpechey merged commit 4832a27 into TheStarport:master Feb 8, 2024
2 checks passed
Copy link

sonarcloud bot commented Feb 8, 2024

@Shiniri Shiniri deleted the autobuy-repaircost branch February 24, 2024 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants