diff options
author | Hop311 <Hop3114@gmail.com> | 2024-06-06 21:29:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-06 21:29:15 +0200 |
commit | f5d173e88a49a1a9556860063aef1aa287925cfd (patch) | |
tree | f3a9a107f1bd4b6b6d8035a96ac659bcc15f176b /src/openvic-simulation/military/UnitInstance.cpp | |
parent | e286cfef29d7c431ba33cd77283e838e6fba05d2 (diff) | |
parent | 37cdd775ac738b2a1264e32471385376e5a34f3a (diff) |
Merge pull request #161 from OpenVicProject/const-mutable
Province const/mutable separation + State cleanup
Diffstat (limited to 'src/openvic-simulation/military/UnitInstance.cpp')
-rw-r--r-- | src/openvic-simulation/military/UnitInstance.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/openvic-simulation/military/UnitInstance.cpp b/src/openvic-simulation/military/UnitInstance.cpp index fcb9e3b..1cd0813 100644 --- a/src/openvic-simulation/military/UnitInstance.cpp +++ b/src/openvic-simulation/military/UnitInstance.cpp @@ -4,7 +4,8 @@ #include "openvic-simulation/country/CountryInstance.hpp" #include "openvic-simulation/map/Map.hpp" -#include "openvic-simulation/military/UnitType.hpp" +#include "openvic-simulation/map/ProvinceInstance.hpp" +#include "openvic-simulation/military/Deployment.hpp" using namespace OpenVic; @@ -17,7 +18,7 @@ ShipInstance::ShipInstance(std::string_view new_name, ShipType const& new_ship_t MovementInfo::MovementInfo() : path {}, movement_progress {} {} //TODO: pathfinding logic -MovementInfo::MovementInfo(Province const* starting_province, Province const* target_province) +MovementInfo::MovementInfo(ProvinceInstance const* starting_province, ProvinceInstance const* target_province) : path { starting_province, target_province }, movement_progress { 0 } {} ArmyInstance::ArmyInstance( @@ -27,7 +28,7 @@ ArmyInstance::ArmyInstance( CountryInstance* new_country ) : UnitInstanceGroup { new_name, UnitType::branch_t::LAND, std::move(new_units), new_leader, new_country } {} -void ArmyInstance::set_position(Province* new_position) { +void ArmyInstance::set_position(ProvinceInstance* new_position) { if (position != new_position) { if (position != nullptr) { position->remove_army(*this); @@ -46,7 +47,7 @@ NavyInstance::NavyInstance( CountryInstance* new_country ) : UnitInstanceGroup { new_name, UnitType::branch_t::NAVAL, std::move(new_units), new_leader, new_country } {} -void NavyInstance::set_position(Province* new_position) { +void NavyInstance::set_position(ProvinceInstance* new_position) { if (position != new_position) { if (position != nullptr) { position->remove_navy(*this); @@ -116,7 +117,7 @@ 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.remove_province_const(army_deployment.get_location())); + armies.back().set_position(map.get_province_instance_from_const(army_deployment.get_location())); return ret; } @@ -162,7 +163,7 @@ 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.remove_province_const(navy_deployment.get_location())); + navies.back().set_position(map.get_province_instance_from_const(navy_deployment.get_location())); return ret; } |