add findShipDef/findModuleDef/findRecipeDef to config structs
Ships/Modules/RecipesConfig now carry lookup helpers mirroring BuildingsConfig::findBuildingDef. The hand-rolled linear scans in BuildingSystem, ShipSystem, ShipStatsCalculator, ThreatCostCalculator, ShipLayoutDialog, SelectedBuildingPanel and SchematicChoiceDialog now call them instead. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GH8ZMRY3vhxxXcaUxBqxkk
This commit is contained in:
@@ -335,15 +335,7 @@ double calculateShipThreatCost(const ThreatCostTable& table,
|
||||
const std::string& shipId,
|
||||
const std::vector<PlacedModule>& modules)
|
||||
{
|
||||
const ShipDef* shipDef = nullptr;
|
||||
for (const ShipDef& d : config.ships.ships)
|
||||
{
|
||||
if (d.id == shipId)
|
||||
{
|
||||
shipDef = &d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const ShipDef* shipDef = config.ships.findShipDef(shipId);
|
||||
if (shipDef == nullptr)
|
||||
{
|
||||
return 0.0;
|
||||
@@ -357,15 +349,7 @@ double calculateShipThreatCost(const ThreatCostTable& table,
|
||||
// Add module production times and material threats.
|
||||
for (const PlacedModule& pm : modules)
|
||||
{
|
||||
const ModuleDef* moduleDef = nullptr;
|
||||
for (const ModuleDef& d : config.modules.modules)
|
||||
{
|
||||
if (d.id == pm.moduleId)
|
||||
{
|
||||
moduleDef = &d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const ModuleDef* moduleDef = config.modules.findModuleDef(pm.moduleId);
|
||||
if (moduleDef == nullptr)
|
||||
{
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user