aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic2
diff options
context:
space:
mode:
author Spartan322 <Megacake1234@gmail.com>2023-04-24 05:36:42 +0200
committer Spartan322 <Megacake1234@gmail.com>2023-05-02 00:50:24 +0200
commit112de0ac9c7ce26bd75d06e4cd3bc91adee716e3 (patch)
tree8c2376ce06c164e10fe815723e5601f2a7bebf02 /extension/src/openvic2
parentb1e985e0774598b3add22069be50f891e981fd79 (diff)
Support features up to clang-format 14
Add .editorconfig Update C++ files within `extension/src` to follow .clang-format
Diffstat (limited to 'extension/src/openvic2')
-rw-r--r--extension/src/openvic2/Date.cpp20
-rw-r--r--extension/src/openvic2/Date.hpp10
-rw-r--r--extension/src/openvic2/GameAdvancementHook.cpp17
-rw-r--r--extension/src/openvic2/GameAdvancementHook.hpp14
-rw-r--r--extension/src/openvic2/GameManager.cpp3
-rw-r--r--extension/src/openvic2/GameManager.hpp2
-rw-r--r--extension/src/openvic2/Good.hpp29
-rw-r--r--extension/src/openvic2/Logger.hpp46
-rw-r--r--extension/src/openvic2/Types.cpp4
-rw-r--r--extension/src/openvic2/Types.hpp9
-rw-r--r--extension/src/openvic2/map/Building.cpp10
-rw-r--r--extension/src/openvic2/map/Building.hpp14
-rw-r--r--extension/src/openvic2/map/Map.cpp12
-rw-r--r--extension/src/openvic2/map/Map.hpp9
-rw-r--r--extension/src/openvic2/map/Province.cpp9
-rw-r--r--extension/src/openvic2/map/Province.hpp1
-rw-r--r--extension/src/openvic2/map/Region.cpp2
-rw-r--r--extension/src/openvic2/map/Region.hpp3
18 files changed, 132 insertions, 82 deletions
diff --git a/extension/src/openvic2/Date.cpp b/extension/src/openvic2/Date.cpp
index ed800d5..11e4b36 100644
--- a/extension/src/openvic2/Date.cpp
+++ b/extension/src/openvic2/Date.cpp
@@ -1,13 +1,13 @@
#include "Date.hpp"
-#include <cctype>
#include <algorithm>
+#include <cctype>
#include "Logger.hpp"
using namespace OpenVic2;
-Timespan::Timespan(day_t value) : days{value} {}
+Timespan::Timespan(day_t value) : days { value } {}
bool Timespan::operator<(Timespan other) const { return days < other.days; };
bool Timespan::operator>(Timespan other) const { return days > other.days; };
@@ -67,14 +67,14 @@ Timespan Date::_dateToTimespan(year_t year, month_t month, day_t day) {
return year * DAYS_IN_YEAR + DAYS_UP_TO_MONTH[month - 1] + day - 1;
}
-Date::Date(Timespan total_days) : timespan{ total_days } {
+Date::Date(Timespan total_days) : timespan { total_days } {
if (timespan < 0) {
Logger::error("Invalid timespan for date: ", timespan, " (cannot be negative)");
timespan = 0;
}
}
-Date::Date(year_t year, month_t month, day_t day) : timespan{ _dateToTimespan(year, month, day) } {}
+Date::Date(year_t year, month_t month, day_t day) : timespan { _dateToTimespan(year, month, day) } {}
Date::year_t Date::getYear() const {
return static_cast<Timespan::day_t>(timespan) / DAYS_IN_YEAR;
@@ -89,7 +89,6 @@ Date::day_t Date::getDay() const {
return days_in_year - DAYS_UP_TO_MONTH[days_in_year / 32] + 1;
}
-
bool Date::operator<(Date other) const { return timespan < other.timespan; };
bool Date::operator>(Date other) const { return timespan > other.timespan; };
bool Date::operator<=(Date other) const { return timespan <= other.timespan; };
@@ -129,7 +128,7 @@ Date::operator std::string() const {
}
std::ostream& OpenVic2::operator<<(std::ostream& out, Date date) {
- return out << (int) date.getYear() << '.' << (int) date.getMonth() << '.' << (int) date.getDay();
+ return out << (int)date.getYear() << '.' << (int)date.getMonth() << '.' << (int)date.getDay();
}
// Parsed from string of the form YYYY.MM.DD
@@ -139,17 +138,20 @@ Date Date::from_string(std::string const& date) {
day_t day = 1;
size_t first_pos = 0;
- while (first_pos < date.length() && std::isdigit(date[first_pos++]));
+ while (first_pos < date.length() && std::isdigit(date[first_pos++]))
+ ;
year = atoi(date.substr(0, first_pos).c_str());
if (first_pos < date.length()) {
if (date[first_pos] == '.') {
size_t second_pos = first_pos + 1;
- while (second_pos < date.length() && std::isdigit(date[second_pos++]));
+ while (second_pos < date.length() && std::isdigit(date[second_pos++]))
+ ;
month = atoi(date.substr(first_pos, second_pos - first_pos).c_str());
if (second_pos < date.length()) {
if (date[second_pos] == '.') {
size_t third_pos = second_pos + 1;
- while (third_pos < date.length() && std::isdigit(date[third_pos++]));
+ while (third_pos < date.length() && std::isdigit(date[third_pos++]))
+ ;
day = atoi(date.substr(second_pos, third_pos - second_pos).c_str());
if (third_pos < date.length())
Logger::error("Unexpected string \"", date.substr(third_pos), "\" at the end of date ", date);
diff --git a/extension/src/openvic2/Date.hpp b/extension/src/openvic2/Date.hpp
index b19602b..b7b45a3 100644
--- a/extension/src/openvic2/Date.hpp
+++ b/extension/src/openvic2/Date.hpp
@@ -1,15 +1,17 @@
#pragma once
#include <cstdint>
-#include <string>
#include <ostream>
+#include <string>
namespace OpenVic2 {
// A relative period between points in time, measured in days
struct Timespan {
using day_t = int64_t;
+
private:
day_t days;
+
public:
Timespan(day_t value = 0);
@@ -33,7 +35,7 @@ namespace OpenVic2 {
explicit operator double() const;
explicit operator std::string() const;
};
- std::ostream& operator<< (std::ostream& out, Timespan timespan);
+ std::ostream& operator<<(std::ostream& out, Timespan timespan);
// Represents an in-game date
// Note: Current implementation does not account for leap-years, or dates before Year 0
@@ -46,11 +48,13 @@ namespace OpenVic2 {
static constexpr Timespan::day_t DAYS_IN_YEAR = 365;
static constexpr Timespan::day_t DAYS_IN_MONTH[MONTHS_IN_YEAR] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
static constexpr Timespan::day_t DAYS_UP_TO_MONTH[MONTHS_IN_YEAR] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
+
private:
// Number of days since Jan 1st, Year 0
Timespan timespan;
static Timespan _dateToTimespan(year_t year, month_t month, day_t day);
+
public:
// The Timespan is considered to be the number of days since Jan 1st, Year 0
Date(Timespan total_days);
@@ -79,5 +83,5 @@ namespace OpenVic2 {
// Parsed from string of the form YYYY.MM.DD
static Date from_string(std::string const& date);
};
- std::ostream& operator<< (std::ostream& out, Date date);
+ std::ostream& operator<<(std::ostream& out, Date date);
}
diff --git a/extension/src/openvic2/GameAdvancementHook.cpp b/extension/src/openvic2/GameAdvancementHook.cpp
index d90b7b1..a68f55c 100644
--- a/extension/src/openvic2/GameAdvancementHook.cpp
+++ b/extension/src/openvic2/GameAdvancementHook.cpp
@@ -3,15 +3,18 @@
using namespace OpenVic2;
const std::vector<std::chrono::milliseconds> GameAdvancementHook::GAME_SPEEDS = {
- std::chrono::milliseconds{ 4000 },
- std::chrono::milliseconds{ 3000 },
- std::chrono::milliseconds{ 2000 },
- std::chrono::milliseconds{ 1000 },
- std::chrono::milliseconds{ 100 },
- std::chrono::milliseconds{ 1 } };
+ std::chrono::milliseconds { 4000 },
+ std::chrono::milliseconds { 3000 },
+ std::chrono::milliseconds { 2000 },
+ std::chrono::milliseconds { 1000 },
+ std::chrono::milliseconds { 100 },
+ std::chrono::milliseconds { 1 }
+};
GameAdvancementHook::GameAdvancementHook(AdvancementFunction tickFunction, RefreshFunction updateFunction, bool startPaused, speed_t startingSpeed)
- : triggerFunction{ tickFunction }, refreshFunction{ updateFunction }, isPaused{ startPaused } {
+ : triggerFunction { tickFunction },
+ refreshFunction { updateFunction },
+ isPaused { startPaused } {
lastPolledTime = std::chrono::high_resolution_clock::now();
setSimulationSpeed(startingSpeed);
}
diff --git a/extension/src/openvic2/GameAdvancementHook.hpp b/extension/src/openvic2/GameAdvancementHook.hpp
index 07f8414..1fe7737 100644
--- a/extension/src/openvic2/GameAdvancementHook.hpp
+++ b/extension/src/openvic2/GameAdvancementHook.hpp
@@ -5,25 +5,25 @@
#include <vector>
namespace OpenVic2 {
- //Conditionally advances game with provided behaviour
- //Class governs game speed and pause state
+ // Conditionally advances game with provided behaviour
+ // Class governs game speed and pause state
class GameAdvancementHook {
- public:
+ public:
using AdvancementFunction = std::function<void()>;
using RefreshFunction = std::function<void()>;
using speed_t = int8_t;
- //Minimum number of miliseconds before the simulation advances
+ // Minimum number of miliseconds before the simulation advances
static const std::vector<std::chrono::milliseconds> GAME_SPEEDS;
- private:
+ private:
std::chrono::time_point<std::chrono::high_resolution_clock> lastPolledTime;
- //A function pointer that advances the simulation, intended to be a capturing lambda or something similar. May need to be reworked later
+ // A function pointer that advances the simulation, intended to be a capturing lambda or something similar. May need to be reworked later
AdvancementFunction triggerFunction;
RefreshFunction refreshFunction;
speed_t currentSpeed;
- public:
+ public:
bool isPaused;
GameAdvancementHook(AdvancementFunction tickFunction, RefreshFunction updateFunction, bool startPaused = true, speed_t startingSpeed = 0);
diff --git a/extension/src/openvic2/GameManager.cpp b/extension/src/openvic2/GameManager.cpp
index 58e40bb..036e610 100644
--- a/extension/src/openvic2/GameManager.cpp
+++ b/extension/src/openvic2/GameManager.cpp
@@ -5,7 +5,8 @@
using namespace OpenVic2;
GameManager::GameManager(state_updated_func_t state_updated_callback)
- : clock{ [this]() { tick(); }, [this]() { update_state(); } }, state_updated{ state_updated_callback } {}
+ : clock { [this]() { tick(); }, [this]() { update_state(); } },
+ state_updated { state_updated_callback } {}
void GameManager::set_needs_update() {
needs_update = true;
diff --git a/extension/src/openvic2/GameManager.hpp b/extension/src/openvic2/GameManager.hpp
index 70e98bd..32183e3 100644
--- a/extension/src/openvic2/GameManager.hpp
+++ b/extension/src/openvic2/GameManager.hpp
@@ -10,6 +10,7 @@ namespace OpenVic2 {
Map map;
BuildingManager building_manager;
GameAdvancementHook clock;
+
private:
Date today;
state_updated_func_t state_updated;
@@ -18,6 +19,7 @@ namespace OpenVic2 {
void set_needs_update();
void update_state();
void tick();
+
public:
GameManager(state_updated_func_t state_updated_callback);
diff --git a/extension/src/openvic2/Good.hpp b/extension/src/openvic2/Good.hpp
index 378bbc4..1e2bd5e 100644
--- a/extension/src/openvic2/Good.hpp
+++ b/extension/src/openvic2/Good.hpp
@@ -4,18 +4,23 @@
namespace OpenVic2 {
class Good : HasIdentifier {
- public:
- std::string category;
- price_t cost;
- std::string colour;
- bool isAvailable;
- bool isTradable;
- bool isMoney;
- bool hasOverseasPenalty;
+ public:
+ std::string category;
+ price_t cost;
+ std::string colour;
+ bool isAvailable;
+ bool isTradable;
+ bool isMoney;
+ bool hasOverseasPenalty;
- Good(Good&&) = default;
- Good(std::string const& identifier,std::string const& category, price_t cost, std::string const& colour,
- bool isAvailable, bool isTradable, bool isMoney, bool hasOverseasPenalty) : HasIdentifier(identifier),
- category(category), cost(cost), colour(colour), isAvailable(isAvailable), isMoney(isMoney), hasOverseasPenalty(hasOverseasPenalty) {};
+ Good(Good&&) = default;
+ Good(std::string const& identifier, std::string const& category, price_t cost, std::string const& colour,
+ bool isAvailable, bool isTradable, bool isMoney, bool hasOverseasPenalty) : HasIdentifier(identifier),
+ category(category),
+ cost(cost),
+ colour(colour),
+ isAvailable(isAvailable),
+ isMoney(isMoney),
+ hasOverseasPenalty(hasOverseasPenalty) {};
};
}
diff --git a/extension/src/openvic2/Logger.hpp b/extension/src/openvic2/Logger.hpp
index 624df29..d097cc6 100644
--- a/extension/src/openvic2/Logger.hpp
+++ b/extension/src/openvic2/Logger.hpp
@@ -8,76 +8,80 @@
namespace OpenVic2 {
- #ifndef __cpp_lib_source_location
- #include <string>
- //Implementation of std::source_location for compilers that do not support it
- //Note: uses non-standard extensions that are supported by Clang, GCC, and MSVC
- //https://clang.llvm.org/docs/LanguageExtensions.html#source-location-builtins
- //https://stackoverflow.com/a/67970107
+#ifndef __cpp_lib_source_location
+#include <string>
+ // Implementation of std::source_location for compilers that do not support it
+ // Note: uses non-standard extensions that are supported by Clang, GCC, and MSVC
+ // https://clang.llvm.org/docs/LanguageExtensions.html#source-location-builtins
+ // https://stackoverflow.com/a/67970107
class source_location {
std::string _file;
int _line;
std::string _function;
- public:
- source_location(std::string f, int l, std::string n) : _file(f), _line(l), _function(n) {}
+ public:
+ source_location(std::string f, int l, std::string n) : _file(f),
+ _line(l),
+ _function(n) {}
static source_location current(std::string f = __builtin_FILE(), int l = __builtin_LINE(), std::string n = __builtin_FUNCTION()) {
return source_location(f, l, n);
}
inline char const* file_name() const { return _file.c_str(); }
- inline int line() const {return _line; }
+ inline int line() const { return _line; }
inline char const* function_name() const { return _function.c_str(); }
};
- #endif
+#endif
class Logger {
using log_func_t = std::function<void(std::string&&)>;
- #ifdef __cpp_lib_source_location
+#ifdef __cpp_lib_source_location
using source_location = std::source_location;
- #else
+#else
using source_location = OpenVic2::source_location;
- #endif
+#endif
static log_func_t info_func, error_func;
static char const* get_filename(char const* filepath);
- template <typename... Ts>
+ template<typename... Ts>
struct log {
log(log_func_t log_func, Ts&&... ts, const source_location& location) {
if (log_func) {
std::stringstream stream;
- stream << std::endl << get_filename(location.file_name()) << "(" << location.line() << ") `" << location.function_name() << "`: ";
+ stream << std::endl
+ << get_filename(location.file_name()) << "(" << location.line() << ") `" << location.function_name() << "`: ";
((stream << std::forward<Ts>(ts)), ...);
stream << std::endl;
log_func(stream.str());
}
}
};
+
public:
static void set_info_func(log_func_t log_func);
static void set_error_func(log_func_t log_func);
- template <typename... Ts>
+ template<typename... Ts>
struct info {
info(Ts&&... ts, const source_location& location = source_location::current()) {
- log<Ts...>{ info_func, std::forward<Ts>(ts)..., location };
+ log<Ts...> { info_func, std::forward<Ts>(ts)..., location };
}
};
- template <typename... Ts>
+ template<typename... Ts>
info(Ts&&...) -> info<Ts...>;
- template <typename... Ts>
+ template<typename... Ts>
struct error {
error(Ts&&... ts, const source_location& location = source_location::current()) {
- log<Ts...>{ error_func, std::forward<Ts>(ts)..., location };
+ log<Ts...> { error_func, std::forward<Ts>(ts)..., location };
}
};
- template <typename... Ts>
+ template<typename... Ts>
error(Ts&&...) -> error<Ts...>;
};
}
diff --git a/extension/src/openvic2/Types.cpp b/extension/src/openvic2/Types.cpp
index f51ad7c..58fee7b 100644
--- a/extension/src/openvic2/Types.cpp
+++ b/extension/src/openvic2/Types.cpp
@@ -1,12 +1,12 @@
#include "Types.hpp"
#include <cassert>
-#include <sstream>
#include <iomanip>
+#include <sstream>
using namespace OpenVic2;
-HasIdentifier::HasIdentifier(std::string const& new_identifier) : identifier{ new_identifier } {
+HasIdentifier::HasIdentifier(std::string const& new_identifier) : identifier { new_identifier } {
assert(!identifier.empty());
}
diff --git a/extension/src/openvic2/Types.hpp b/extension/src/openvic2/Types.hpp
index e4a0e2d..a01bae4 100644
--- a/extension/src/openvic2/Types.hpp
+++ b/extension/src/openvic2/Types.hpp
@@ -1,9 +1,9 @@
#pragma once
-#include <vector>
-#include <cstdint>
#include <algorithm>
+#include <cstdint>
#include <map>
+#include <vector>
#include "Logger.hpp"
@@ -37,8 +37,10 @@ namespace OpenVic2 {
*/
class HasIdentifier {
const std::string identifier;
+
protected:
HasIdentifier(std::string const& new_identifier);
+
public:
HasIdentifier(HasIdentifier const&) = delete;
HasIdentifier(HasIdentifier&&) = default;
@@ -53,8 +55,10 @@ namespace OpenVic2 {
*/
class HasColour {
const colour_t colour;
+
protected:
HasColour(colour_t const new_colour);
+
public:
HasColour(HasColour const&) = delete;
HasColour(HasColour&&) = default;
@@ -80,6 +84,7 @@ namespace OpenVic2 {
std::vector<T> items;
bool locked = false;
identifier_index_map_t identifier_index_map;
+
public:
IdentifierRegistry(std::string const& new_name) : name(new_name) {}
return_t add_item(T&& item) {
diff --git a/extension/src/openvic2/map/Building.cpp b/extension/src/openvic2/map/Building.cpp
index 1e26873..a2694b9 100644
--- a/extension/src/openvic2/map/Building.cpp
+++ b/extension/src/openvic2/map/Building.cpp
@@ -7,7 +7,8 @@
using namespace OpenVic2;
-Building::Building(BuildingType const& new_type) : HasIdentifier{ new_type.get_identifier() }, type{ new_type } {}
+Building::Building(BuildingType const& new_type) : HasIdentifier { new_type.get_identifier() },
+ type { new_type } {}
bool Building::_can_expand() const {
return level < type.get_max_level();
@@ -74,8 +75,9 @@ void Building::tick(Date const& today) {
}
}
-BuildingType::BuildingType(std::string const& new_identifier, Building::level_t new_max_level, Timespan new_build_time) :
- HasIdentifier{ new_identifier }, max_level{ new_max_level }, build_time{ new_build_time } {
+BuildingType::BuildingType(std::string const& new_identifier, Building::level_t new_max_level, Timespan new_build_time) : HasIdentifier { new_identifier },
+ max_level { new_max_level },
+ build_time { new_build_time } {
assert(new_max_level >= 0);
assert(build_time >= 0);
}
@@ -88,7 +90,7 @@ Timespan BuildingType::get_build_time() const {
return build_time;
}
-BuildingManager::BuildingManager() : building_types{ "building types" } {}
+BuildingManager::BuildingManager() : building_types { "building types" } {}
return_t BuildingManager::add_building_type(std::string const& identifier, Building::level_t max_level, Timespan build_time) {
if (identifier.empty()) {
diff --git a/extension/src/openvic2/map/Building.hpp b/extension/src/openvic2/map/Building.hpp
index 78d08ae..492cbc6 100644
--- a/extension/src/openvic2/map/Building.hpp
+++ b/extension/src/openvic2/map/Building.hpp
@@ -2,8 +2,8 @@
#include <vector>
-#include "../Types.hpp"
#include "../Date.hpp"
+#include "../Types.hpp"
namespace OpenVic2 {
struct Province;
@@ -19,7 +19,13 @@ namespace OpenVic2 {
using level_t = int8_t;
- enum class ExpansionState { CannotExpand, CanExpand, Preparing, Expanding };
+ enum class ExpansionState {
+ CannotExpand,
+ CanExpand,
+ Preparing,
+ Expanding
+ };
+
private:
BuildingType const& type;
level_t level = 0;
@@ -30,6 +36,7 @@ namespace OpenVic2 {
Building(BuildingType const& new_type);
bool _can_expand() const;
+
public:
Building(Building&&) = default;
@@ -49,11 +56,13 @@ namespace OpenVic2 {
struct BuildingType : HasIdentifier {
friend struct BuildingManager;
+
private:
const Building::level_t max_level;
const Timespan build_time;
BuildingType(std::string const& new_identifier, Building::level_t new_max_level, Timespan new_build_time);
+
public:
BuildingType(BuildingType&&) = default;
@@ -64,6 +73,7 @@ namespace OpenVic2 {
struct BuildingManager {
private:
IdentifierRegistry<BuildingType> building_types;
+
public:
BuildingManager();
diff --git a/extension/src/openvic2/map/Map.cpp b/extension/src/openvic2/map/Map.cpp
index 1f44c43..f920ccc 100644
--- a/extension/src/openvic2/map/Map.cpp
+++ b/extension/src/openvic2/map/Map.cpp
@@ -8,7 +8,9 @@
using namespace OpenVic2;
Mapmode::Mapmode(index_t new_index, std::string const& new_identifier, colour_func_t new_colour_func)
- : HasIdentifier{ new_identifier }, index{ new_index }, colour_func{ new_colour_func } {
+ : HasIdentifier { new_identifier },
+ index { new_index },
+ colour_func { new_colour_func } {
assert(colour_func != nullptr);
}
@@ -20,7 +22,9 @@ colour_t Mapmode::get_colour(Map const& map, Province const& province) const {
return colour_func ? colour_func(map, province) : NULL_COLOUR;
}
-Map::Map() : provinces{ "provinces" }, regions{ "regions" }, mapmodes{ "mapmodes" } {}
+Map::Map() : provinces { "provinces" },
+ regions { "regions" },
+ mapmodes { "mapmodes" } {}
return_t Map::add_province(std::string const& identifier, colour_t colour) {
if (provinces.get_item_count() >= MAX_INDEX) {
@@ -35,7 +39,7 @@ return_t Map::add_province(std::string const& identifier, colour_t colour) {
Logger::error("Invalid province colour: ", Province::colour_to_hex_string(colour));
return FAILURE;
}
- Province new_province{ static_cast<index_t>(provinces.get_item_count() + 1), identifier, colour };
+ Province new_province { static_cast<index_t>(provinces.get_item_count() + 1), identifier, colour };
const index_t index = get_index_from_colour(colour);
if (index != NULL_INDEX) {
Logger::error("Duplicate province colours: ", get_province_by_index(index)->to_string(), " and ", new_province.to_string());
@@ -78,7 +82,7 @@ return_t Map::add_region(std::string const& identifier, std::vector<std::string>
Logger::error("Invalid region identifier - empty!");
return FAILURE;
}
- Region new_region{ identifier };
+ Region new_region { identifier };
return_t ret = SUCCESS;
for (std::string const& province_identifier : province_identifiers) {
Province* province = get_province_by_identifier(province_identifier);
diff --git a/extension/src/openvic2/map/Map.hpp b/extension/src/openvic2/map/Map.hpp
index cb8dcb1..4fc97c9 100644
--- a/extension/src/openvic2/map/Map.hpp
+++ b/extension/src/openvic2/map/Map.hpp
@@ -9,13 +9,15 @@ namespace OpenVic2 {
struct Mapmode : HasIdentifier {
friend struct Map;
- using colour_func_t = std::function<colour_t (Map const&, Province const&)>;
+ using colour_func_t = std::function<colour_t(Map const&, Province const&)>;
using index_t = size_t;
+
private:
const index_t index;
const colour_func_t colour_func;
Mapmode(index_t new_index, std::string const& new_identifier, colour_func_t new_colour_func);
+
public:
index_t get_index() const;
colour_t get_colour(Map const& map, Province const& province) const;
@@ -28,12 +30,12 @@ namespace OpenVic2 {
using terrain_t = uint8_t;
using terrain_variant_map_t = std::map<colour_t, terrain_t>;
- #pragma pack(push, 1)
+#pragma pack(push, 1)
struct shape_pixel_t {
index_t index;
terrain_t terrain;
};
- #pragma pack(pop)
+#pragma pack(pop)
private:
using colour_index_map_t = std::map<colour_t, index_t>;
@@ -48,6 +50,7 @@ namespace OpenVic2 {
colour_index_map_t colour_index_map;
index_t get_index_from_colour(colour_t colour) const;
+
public:
Map();
diff --git a/extension/src/openvic2/map/Province.cpp b/extension/src/openvic2/map/Province.cpp
index b3d455b..79f3ddd 100644
--- a/extension/src/openvic2/map/Province.cpp
+++ b/extension/src/openvic2/map/Province.cpp
@@ -1,13 +1,15 @@
#include "Province.hpp"
#include <cassert>
-#include <sstream>
#include <iomanip>
+#include <sstream>
using namespace OpenVic2;
-Province::Province(index_t new_index, std::string const& new_identifier, colour_t new_colour) :
- HasIdentifier{ new_identifier }, HasColour{ new_colour }, index{ new_index }, buildings{ "buildings" } {
+Province::Province(index_t new_index, std::string const& new_identifier, colour_t new_colour) : HasIdentifier { new_identifier },
+ HasColour { new_colour },
+ index { new_index },
+ buildings { "buildings" } {
assert(index != NULL_INDEX);
assert(new_colour != NULL_COLOUR);
}
@@ -59,7 +61,6 @@ std::string Province::to_string() const {
void Province::update_state(Date const& today) {
for (Building& building : buildings.get_items())
building.update_state(today);
-
}
void Province::tick(Date const& today) {
diff --git a/extension/src/openvic2/map/Province.hpp b/extension/src/openvic2/map/Province.hpp
index 9b07fc1..dd1742c 100644
--- a/extension/src/openvic2/map/Province.hpp
+++ b/extension/src/openvic2/map/Province.hpp
@@ -22,6 +22,7 @@ namespace OpenVic2 {
IdentifierRegistry<Building> buildings;
Province(index_t new_index, std::string const& new_identifier, colour_t new_colour);
+
public:
Province(Province&&) = default;
diff --git a/extension/src/openvic2/map/Region.cpp b/extension/src/openvic2/map/Region.cpp
index da0dfdd..bd87479 100644
--- a/extension/src/openvic2/map/Region.cpp
+++ b/extension/src/openvic2/map/Region.cpp
@@ -16,7 +16,7 @@ std::set<Province*> const& ProvinceSet::get_provinces() const {
return provinces;
}
-Region::Region(std::string const& new_identifier) : HasIdentifier{ new_identifier } {}
+Region::Region(std::string const& new_identifier) : HasIdentifier { new_identifier } {}
colour_t Region::get_colour() const {
if (provinces.empty()) return 0xFF0000;
diff --git a/extension/src/openvic2/map/Region.hpp b/extension/src/openvic2/map/Region.hpp
index 3920dfc..8f1af70 100644
--- a/extension/src/openvic2/map/Region.hpp
+++ b/extension/src/openvic2/map/Region.hpp
@@ -9,6 +9,7 @@ namespace OpenVic2 {
struct ProvinceSet {
protected:
std::set<Province*> provinces;
+
public:
size_t get_province_count() const;
bool contains_province(Province const* province) const;
@@ -20,8 +21,10 @@ namespace OpenVic2 {
*/
struct Region : HasIdentifier, ProvinceSet {
friend struct Map;
+
private:
Region(std::string const& new_identifier);
+
public:
Region(Region&&) = default;