diff options
author | Hop311 <hop3114@gmail.com> | 2023-09-08 18:12:22 +0200 |
---|---|---|
committer | Hop311 <hop3114@gmail.com> | 2023-09-08 18:12:22 +0200 |
commit | 7772f8871348b7b52cb0a478bb76df68d8799a07 (patch) | |
tree | fd8c4626b2cee69a9fe9250365af6b18eea63c70 /src/openvic/map/Region.cpp | |
parent | 7f9a9a8241ba81be9213e6606b8be4a48f1cbaab (diff) |
More refactoring and duplicate code removal
Diffstat (limited to 'src/openvic/map/Region.cpp')
-rw-r--r-- | src/openvic/map/Region.cpp | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/src/openvic/map/Region.cpp b/src/openvic/map/Region.cpp deleted file mode 100644 index 33092c5..0000000 --- a/src/openvic/map/Region.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "Region.hpp" - -using namespace OpenVic; - -bool ProvinceSet::add_province(Province* province) { - if (locked) { - Logger::error("Cannot add province to province set - locked!"); - return false; - } - if (province == nullptr) { - Logger::error("Cannot add province to province set - null province!"); - return false; - } - if (contains_province(province)) { - Logger::error("Cannot add province ", province->get_identifier(), " to province set - already in the set!"); - return false; - } - provinces.push_back(province); - return true; -} - -void ProvinceSet::lock(bool log) { - if (locked) { - Logger::error("Failed to lock province set - already locked!"); - } else { - locked = true; - if (log) Logger::info("Locked province set with ", size(), " provinces"); - } -} - -bool ProvinceSet::is_locked() const { - return locked; -} - -void ProvinceSet::reset() { - provinces.clear(); - locked = false; -} - -bool ProvinceSet::empty() const { - return provinces.empty(); -} - -size_t ProvinceSet::size() const { - return provinces.size(); -} - -void ProvinceSet::reserve(size_t size) { - if (locked) { - Logger::error("Failed to reserve space for ", size, " items in province set - already locked!"); - } else { - provinces.reserve(size); - } -} - -bool ProvinceSet::contains_province(Province const* province) const { - return province && std::find(provinces.begin(), provinces.end(), province) != provinces.end(); -} - -std::vector<Province*> const& ProvinceSet::get_provinces() const { - return provinces; -} - -Region::Region(const std::string_view new_identifier) : HasIdentifier { new_identifier } {} - -colour_t Region::get_colour() const { - if (provinces.empty()) return FULL_COLOUR << 16; - return provinces.front()->get_colour(); -} |