aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/Province.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/map/Province.cpp')
-rw-r--r--src/openvic-simulation/map/Province.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/openvic-simulation/map/Province.cpp b/src/openvic-simulation/map/Province.cpp
index d1183f5..eb23759 100644
--- a/src/openvic-simulation/map/Province.cpp
+++ b/src/openvic-simulation/map/Province.cpp
@@ -1,6 +1,7 @@
#include "Province.hpp"
#include "openvic-simulation/history/ProvinceHistory.hpp"
+#include "openvic-simulation/military/UnitInstance.hpp"
using namespace OpenVic;
using namespace OpenVic::NodeTools;
@@ -181,6 +182,42 @@ fvec2_t Province::get_unit_position() const {
return positions.unit.value_or(positions.centre);
}
+bool Province::add_army(ArmyInstance& army) {
+ if (armies.emplace(&army).second) {
+ return true;
+ } else {
+ Logger::error("Trying to add already-existing army ", army.get_name(), " to province ", get_identifier());
+ return false;
+ }
+}
+
+bool Province::remove_army(ArmyInstance& army) {
+ if (armies.erase(&army) > 0) {
+ return true;
+ } else {
+ Logger::error("Trying to remove non-existent army ", army.get_name(), " from province ", get_identifier());
+ return false;
+ }
+}
+
+bool Province::add_navy(NavyInstance& navy) {
+ if (navies.emplace(&navy).second) {
+ return true;
+ } else {
+ Logger::error("Trying to add already-existing navy ", navy.get_name(), " to province ", get_identifier());
+ return false;
+ }
+}
+
+bool Province::remove_navy(NavyInstance& navy) {
+ if (navies.erase(&navy) > 0) {
+ return true;
+ } else {
+ Logger::error("Trying to remove non-existent navy ", navy.get_name(), " from province ", get_identifier());
+ return false;
+ }
+}
+
bool Province::reset(BuildingTypeManager const& building_type_manager) {
terrain_type = default_terrain_type;
life_rating = 0;