diff options
author | hop311 <hop3114@gmail.com> | 2024-06-07 00:20:58 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-06-07 12:28:16 +0200 |
commit | 1198a780916e65cae048dd3478f614c1d18db846 (patch) | |
tree | f681dd2e76d489ba6e7beea44ae6ebd59e9d51f3 /src/openvic-simulation/military/UnitInstance.cpp | |
parent | c94a06477fc3930e8f8f2e5f971fc4b5b838ea0d (diff) |
Separated MapDefinition and MapInstancemap-instance
Diffstat (limited to 'src/openvic-simulation/military/UnitInstance.cpp')
-rw-r--r-- | src/openvic-simulation/military/UnitInstance.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/openvic-simulation/military/UnitInstance.cpp b/src/openvic-simulation/military/UnitInstance.cpp index 1cd0813..ac9c194 100644 --- a/src/openvic-simulation/military/UnitInstance.cpp +++ b/src/openvic-simulation/military/UnitInstance.cpp @@ -3,7 +3,7 @@ #include <vector> #include "openvic-simulation/country/CountryInstance.hpp" -#include "openvic-simulation/map/Map.hpp" +#include "openvic-simulation/map/MapInstance.hpp" #include "openvic-simulation/map/ProvinceInstance.hpp" #include "openvic-simulation/military/Deployment.hpp" @@ -76,7 +76,9 @@ bool UnitInstanceManager::generate_ship(ShipDeployment const& ship_deployment, S return true; } -bool UnitInstanceManager::generate_army(Map& map, CountryInstance& country, ArmyDeployment const& army_deployment) { +bool UnitInstanceManager::generate_army( + MapInstance& map_instance, CountryInstance& country, ArmyDeployment const& army_deployment +) { if (army_deployment.get_regiments().empty()) { Logger::error( "Trying to generate army \"", army_deployment.get_name(), "\" with no regiments for country \"", @@ -117,12 +119,14 @@ bool UnitInstanceManager::generate_army(Map& map, CountryInstance& country, Army armies.push_back({ army_deployment.get_name(), std::move(army_regiments), nullptr, &country }); - armies.back().set_position(map.get_province_instance_from_const(army_deployment.get_location())); + armies.back().set_position(map_instance.get_province_instance_from_const(army_deployment.get_location())); return ret; } -bool UnitInstanceManager::generate_navy(Map& map, CountryInstance& country, NavyDeployment const& navy_deployment) { +bool UnitInstanceManager::generate_navy( + MapInstance& map_instance, CountryInstance& country, NavyDeployment const& navy_deployment +) { if (navy_deployment.get_ships().empty()) { Logger::error( "Trying to generate navy \"", navy_deployment.get_name(), "\" with no ships for country \"", @@ -163,12 +167,14 @@ bool UnitInstanceManager::generate_navy(Map& map, CountryInstance& country, Navy navies.push_back({ navy_deployment.get_name(), std::move(navy_ships), nullptr, &country }); - navies.back().set_position(map.get_province_instance_from_const(navy_deployment.get_location())); + navies.back().set_position(map_instance.get_province_instance_from_const(navy_deployment.get_location())); return ret; } -bool UnitInstanceManager::generate_deployment(Map& map, CountryInstance& country, Deployment const* deployment) { +bool UnitInstanceManager::generate_deployment( + MapInstance& map_instance, CountryInstance& country, Deployment const* deployment +) { if (deployment == nullptr) { Logger::error("Trying to generate null deployment for ", country.get_identifier()); return false; @@ -179,11 +185,11 @@ bool UnitInstanceManager::generate_deployment(Map& map, CountryInstance& country bool ret = true; for (ArmyDeployment const& army_deployment : deployment->get_armies()) { - ret &= generate_army(map, country, army_deployment); + ret &= generate_army(map_instance, country, army_deployment); } for (NavyDeployment const& navy_deployment : deployment->get_navies()) { - ret &= generate_navy(map, country, navy_deployment); + ret &= generate_navy(map_instance, country, navy_deployment); } return ret; |