The names are generic (makeError, requireInt, parseFile), and at global scope with external linkage they would form an overload set with the same-named anonymous-namespace helpers in VisualsLoader.cpp and BalancingConfig.cpp the moment either file includes TomlHelpers.h — silently, since the signatures differ. Namespacing keeps that door shut. Call sites are qualified explicitly rather than pulled in with a using directive, matching how utility::getRandomInt and friends are already called. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YHcUerKAZKWNvSKJxYKbnG
48 lines
2.4 KiB
C++
48 lines
2.4 KiB
C++
#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 = utility::parseFile(path, file);
|
|
|
|
StationsConfig cfg;
|
|
|
|
// HQ
|
|
{
|
|
const std::string p = "hq";
|
|
cfg.hq.surfaceMask = utility::requireStringArray(tbl[p]["surface_mask"], file, p + ".surface_mask");
|
|
cfg.hq.hpFormula = utility::requireFormula(tbl[p]["hp_formula"], file, p + ".hp_formula");
|
|
}
|
|
|
|
// Player station
|
|
{
|
|
const std::string p = "player_station";
|
|
cfg.playerStation.surfaceMask = utility::requireStringArray(tbl[p]["surface_mask"], file, p + ".surface_mask");
|
|
cfg.playerStation.level = static_cast<int>(utility::requireInt(tbl[p]["level"], file, p + ".level"));
|
|
cfg.playerStation.hpFormula = utility::requireFormula(tbl[p]["hp_formula"], file, p + ".hp_formula");
|
|
cfg.playerStation.damageFormula = utility::requireFormula(tbl[p]["damage_formula"], file, p + ".damage_formula");
|
|
cfg.playerStation.rangeFormula = utility::requireFormula(tbl[p]["range_m_formula"], file, p + ".range_m_formula");
|
|
cfg.playerStation.fireRateFormula = utility::requireFormula(tbl[p]["fire_rate_hz_formula"], file, p + ".fire_rate_hz_formula");
|
|
cfg.playerStation.scrapDropFormula = utility::requireFormula(tbl[p]["scrap_drop_formula"], file, p + ".scrap_drop_formula");
|
|
}
|
|
|
|
// Enemy station
|
|
{
|
|
const std::string p = "enemy_station";
|
|
cfg.enemyStation.surfaceMask = utility::requireStringArray(tbl[p]["surface_mask"], file, p + ".surface_mask");
|
|
cfg.enemyStation.hpFormula = utility::requireFormula(tbl[p]["hp_formula"], file, p + ".hp_formula");
|
|
cfg.enemyStation.damageFormula = utility::requireFormula(tbl[p]["damage_formula"], file, p + ".damage_formula");
|
|
cfg.enemyStation.rangeFormula = utility::requireFormula(tbl[p]["range_m_formula"], file, p + ".range_m_formula");
|
|
cfg.enemyStation.fireRateFormula = utility::requireFormula(tbl[p]["fire_rate_hz_formula"], file, p + ".fire_rate_hz_formula");
|
|
cfg.enemyStation.scrapDropFormula = utility::requireFormula(tbl[p]["scrap_drop_formula"], file, p + ".scrap_drop_formula");
|
|
}
|
|
|
|
return cfg;
|
|
}
|