Skip to content

Commit

Permalink
Fix several issues
Browse files Browse the repository at this point in the history
- Duplicate FTL consumption
- Save original figures without factors
- Make FTL capacitor factor 1.0 and FTL drive factor 0.1. That's also contributed to the SPEC issue.
  • Loading branch information
royfalk committed Nov 13, 2024
1 parent c8c1eb1 commit 39f6eb5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
3 changes: 1 addition & 2 deletions engine/src/cmd/jump_capable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ bool JumpCapable::AutoPilotToErrorMessage(const Unit *target,
failuremessage = configuration()->graphics_config.hud.already_near_message;
return false;
}
unit->ftl_energy.Deplete(true, static_cast<double>(totpercent) * unit->ftl_drive.GetAtomConsumption());
// TODO: figure out to do unit->ftl_drive.Consume() instead

if (unsafe == false && totpercent == 0) {
end = endne;
}
Expand Down
17 changes: 16 additions & 1 deletion engine/src/components/energy_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,22 @@ void EnergyContainer::Load(std::string upgrade_key, std::string unit_key) {
}

void EnergyContainer::SaveToCSV(std::map<std::string, std::string>& unit) const {
unit[FUEL_CAPACITY] = std::to_string(MaxLevel());
switch(type) {
case ComponentType::Fuel:
unit[FUEL_CAPACITY] = std::to_string(MaxLevel() / configuration()->fuel.fuel_factor);
break;

case ComponentType::Capacitor:
unit[FUEL_CAPACITY] = std::to_string(MaxLevel() / configuration()->fuel.energy_factor);
break;

case ComponentType::FtlCapacitor:
unit[FUEL_CAPACITY] = std::to_string(MaxLevel() / configuration()->fuel.ftl_energy_factor);
break;

default: // This really can't happen
abort();
}
}


Expand Down
6 changes: 2 additions & 4 deletions engine/src/components/ftl_drive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,15 @@ void FtlDrive::Load(std::string upgrade_key,
std::string unit_key) {
Component::Load(upgrade_key, unit_key);

const double ftl_drive_factor = configuration()->fuel.ftl_drive_factor;

// Consumer
double energy = UnitCSVFactory::GetVariable(unit_key, "Warp_Usage_Cost", 0.0f);
SetConsumption(energy * ftl_drive_factor);
SetConsumption(energy * configuration()->fuel.ftl_drive_factor);

// FTL Drive
}

void FtlDrive::SaveToCSV(std::map<std::string, std::string>& unit) const {
unit["Warp_Usage_Cost"] = std::to_string(consumption);
unit["Warp_Usage_Cost"] = std::to_string(consumption / configuration()->fuel.ftl_drive_factor);
}

// FTL drive is integrated and so cannot be upgraded/downgraded
Expand Down
6 changes: 2 additions & 4 deletions engine/src/components/jump_drive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,10 @@ bool JumpDrive::Enabled() const {
void JumpDrive::Load(std::string upgrade_key, std::string unit_key) {
Component::Load(upgrade_key, unit_key);

const double jump_drive_factor = configuration()->fuel.jump_drive_factor;

// Consumer
double energy = UnitCSVFactory::GetVariable(unit_key, "Outsystem_Jump_Cost", 0.0f);
// Jump drive is unique - consumption and atom_consumption are identical
atom_consumption = consumption = energy * jump_drive_factor;
atom_consumption = consumption = energy * configuration()->fuel.jump_drive_factor;


// Jump Drive
Expand All @@ -98,7 +96,7 @@ void JumpDrive::Load(std::string upgrade_key, std::string unit_key) {
void JumpDrive::SaveToCSV(std::map<std::string, std::string>& unit) const {
unit["Jump_Drive_Present"] = std::to_string(Installed());
unit["Jump_Drive_Delay"] = std::to_string(delay);
unit["Outsystem_Jump_Cost"] = std::to_string(consumption);
unit["Outsystem_Jump_Cost"] = std::to_string(consumption / configuration()->fuel.jump_drive_factor);
}

bool JumpDrive::CanDowngrade() const {
Expand Down
2 changes: 1 addition & 1 deletion engine/src/components/reactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void Reactor::Load(std::string upgrade_key, std::string unit_key) {

void Reactor::SaveToCSV(std::map<std::string, std::string>& unit) const {
// TODO: This won't record damage to recharge
unit[REACTOR_RECHARGE] = std::to_string(capacity.MaxValue());
unit[REACTOR_RECHARGE] = std::to_string(capacity.MaxValue() / configuration()->fuel.reactor_factor);
}


Expand Down
4 changes: 2 additions & 2 deletions engine/src/configuration/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ struct Fuel {

double fuel_factor{60.0}; // Multiply fuel by this to get fuel by minutes
double energy_factor{1.0};
double ftl_energy_factor{0.1};
double ftl_energy_factor{1.0};

double reactor_factor{1.0};

double ftl_drive_factor{1.0};
double ftl_drive_factor{0.1};
double jump_drive_factor{1.0};

// 0 infinite, 1 fuel, 2 energy, 3 ftl_energy, 4 disabled
Expand Down

0 comments on commit 39f6eb5

Please sign in to comment.