extract loadStations into ConfigLoaderStations.cpp
Continues the ConfigLoader.cpp domain split. Pure move of loadStations; no domain-specific helpers to relocate here. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YHcUerKAZKWNvSKJxYKbnG
This commit is contained in:
@@ -25,6 +25,7 @@ SET(SRCS
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/ConfigLoaderBuildings.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/ConfigLoaderBuildings.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/ConfigLoaderRecipes.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/ConfigLoaderRecipes.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/ConfigLoaderShips.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/ConfigLoaderShips.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ConfigLoaderStations.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/SurfaceMask.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/SurfaceMask.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/BlueprintSerializer.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/BlueprintSerializer.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/ShipLayoutBlueprintSerializer.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/ShipLayoutBlueprintSerializer.cpp
|
||||||
|
|||||||
@@ -13,46 +13,6 @@
|
|||||||
|
|
||||||
// --- Per-file loaders -----------------------------------------------------
|
// --- Per-file loaders -----------------------------------------------------
|
||||||
|
|
||||||
StationsConfig ConfigLoader::loadStations(const std::string& path)
|
|
||||||
{
|
|
||||||
const std::string file = "stations.toml";
|
|
||||||
toml::table tbl = parseFile(path, file);
|
|
||||||
|
|
||||||
StationsConfig cfg;
|
|
||||||
|
|
||||||
// HQ
|
|
||||||
{
|
|
||||||
const std::string p = "hq";
|
|
||||||
cfg.hq.surfaceMask = requireStringArray(tbl[p]["surface_mask"], file, p + ".surface_mask");
|
|
||||||
cfg.hq.hpFormula = requireFormula(tbl[p]["hp_formula"], file, p + ".hp_formula");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Player station
|
|
||||||
{
|
|
||||||
const std::string p = "player_station";
|
|
||||||
cfg.playerStation.surfaceMask = requireStringArray(tbl[p]["surface_mask"], file, p + ".surface_mask");
|
|
||||||
cfg.playerStation.level = static_cast<int>(requireInt(tbl[p]["level"], file, p + ".level"));
|
|
||||||
cfg.playerStation.hpFormula = requireFormula(tbl[p]["hp_formula"], file, p + ".hp_formula");
|
|
||||||
cfg.playerStation.damageFormula = requireFormula(tbl[p]["damage_formula"], file, p + ".damage_formula");
|
|
||||||
cfg.playerStation.rangeFormula = requireFormula(tbl[p]["range_m_formula"], file, p + ".range_m_formula");
|
|
||||||
cfg.playerStation.fireRateFormula = requireFormula(tbl[p]["fire_rate_hz_formula"], file, p + ".fire_rate_hz_formula");
|
|
||||||
cfg.playerStation.scrapDropFormula = requireFormula(tbl[p]["scrap_drop_formula"], file, p + ".scrap_drop_formula");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enemy station
|
|
||||||
{
|
|
||||||
const std::string p = "enemy_station";
|
|
||||||
cfg.enemyStation.surfaceMask = requireStringArray(tbl[p]["surface_mask"], file, p + ".surface_mask");
|
|
||||||
cfg.enemyStation.hpFormula = requireFormula(tbl[p]["hp_formula"], file, p + ".hp_formula");
|
|
||||||
cfg.enemyStation.damageFormula = requireFormula(tbl[p]["damage_formula"], file, p + ".damage_formula");
|
|
||||||
cfg.enemyStation.rangeFormula = requireFormula(tbl[p]["range_m_formula"], file, p + ".range_m_formula");
|
|
||||||
cfg.enemyStation.fireRateFormula = requireFormula(tbl[p]["fire_rate_hz_formula"], file, p + ".fire_rate_hz_formula");
|
|
||||||
cfg.enemyStation.scrapDropFormula = requireFormula(tbl[p]["scrap_drop_formula"], file, p + ".scrap_drop_formula");
|
|
||||||
}
|
|
||||||
|
|
||||||
return cfg;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Known category→stat mappings for module stat modifier discovery.
|
// Known category→stat mappings for module stat modifier discovery.
|
||||||
// addedKeySuffix: unit suffix appended before "_formula" for additive modifier keys only.
|
// addedKeySuffix: unit suffix appended before "_formula" for additive modifier keys only.
|
||||||
// Multiplicative modifier keys are always dimensionless and carry no suffix.
|
// Multiplicative modifier keys are always dimensionless and carry no suffix.
|
||||||
|
|||||||
47
src/lib/config/ConfigLoaderStations.cpp
Normal file
47
src/lib/config/ConfigLoaderStations.cpp
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#include "ConfigLoader.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "toml.hpp"
|
||||||
|
|
||||||
|
#include "TomlHelpers.h"
|
||||||
|
|
||||||
|
StationsConfig ConfigLoader::loadStations(const std::string& path)
|
||||||
|
{
|
||||||
|
const std::string file = "stations.toml";
|
||||||
|
toml::table tbl = parseFile(path, file);
|
||||||
|
|
||||||
|
StationsConfig cfg;
|
||||||
|
|
||||||
|
// HQ
|
||||||
|
{
|
||||||
|
const std::string p = "hq";
|
||||||
|
cfg.hq.surfaceMask = requireStringArray(tbl[p]["surface_mask"], file, p + ".surface_mask");
|
||||||
|
cfg.hq.hpFormula = requireFormula(tbl[p]["hp_formula"], file, p + ".hp_formula");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Player station
|
||||||
|
{
|
||||||
|
const std::string p = "player_station";
|
||||||
|
cfg.playerStation.surfaceMask = requireStringArray(tbl[p]["surface_mask"], file, p + ".surface_mask");
|
||||||
|
cfg.playerStation.level = static_cast<int>(requireInt(tbl[p]["level"], file, p + ".level"));
|
||||||
|
cfg.playerStation.hpFormula = requireFormula(tbl[p]["hp_formula"], file, p + ".hp_formula");
|
||||||
|
cfg.playerStation.damageFormula = requireFormula(tbl[p]["damage_formula"], file, p + ".damage_formula");
|
||||||
|
cfg.playerStation.rangeFormula = requireFormula(tbl[p]["range_m_formula"], file, p + ".range_m_formula");
|
||||||
|
cfg.playerStation.fireRateFormula = requireFormula(tbl[p]["fire_rate_hz_formula"], file, p + ".fire_rate_hz_formula");
|
||||||
|
cfg.playerStation.scrapDropFormula = requireFormula(tbl[p]["scrap_drop_formula"], file, p + ".scrap_drop_formula");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enemy station
|
||||||
|
{
|
||||||
|
const std::string p = "enemy_station";
|
||||||
|
cfg.enemyStation.surfaceMask = requireStringArray(tbl[p]["surface_mask"], file, p + ".surface_mask");
|
||||||
|
cfg.enemyStation.hpFormula = requireFormula(tbl[p]["hp_formula"], file, p + ".hp_formula");
|
||||||
|
cfg.enemyStation.damageFormula = requireFormula(tbl[p]["damage_formula"], file, p + ".damage_formula");
|
||||||
|
cfg.enemyStation.rangeFormula = requireFormula(tbl[p]["range_m_formula"], file, p + ".range_m_formula");
|
||||||
|
cfg.enemyStation.fireRateFormula = requireFormula(tbl[p]["fire_rate_hz_formula"], file, p + ".fire_rate_hz_formula");
|
||||||
|
cfg.enemyStation.scrapDropFormula = requireFormula(tbl[p]["scrap_drop_formula"], file, p + ".scrap_drop_formula");
|
||||||
|
}
|
||||||
|
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user