aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-08-29 20:54:58 +0200
committer hop311 <hop3114@gmail.com>2024-08-29 20:54:58 +0200
commit172ad2fcc34b567eab9eca1f907cd99574fa031e (patch)
treebedfa97590a31eb5f2871b7921e48423d1ddabde /src
parent5813948cd3ed6432de374664650d68afbff71915 (diff)
Remove unnecessary asserts + make `vec2_t(T val)` constructor explicitremove-asserts
Diffstat (limited to 'src')
-rw-r--r--src/openvic-simulation/economy/GoodDefinition.cpp26
-rw-r--r--src/openvic-simulation/map/Mapmode.cpp12
-rw-r--r--src/openvic-simulation/map/ProvinceDefinition.cpp24
-rw-r--r--src/openvic-simulation/pop/Pop.cpp10
-rw-r--r--src/openvic-simulation/pop/Religion.cpp15
-rw-r--r--src/openvic-simulation/types/Vector.hpp2
6 files changed, 52 insertions, 37 deletions
diff --git a/src/openvic-simulation/economy/GoodDefinition.cpp b/src/openvic-simulation/economy/GoodDefinition.cpp
index 104764b..892592d 100644
--- a/src/openvic-simulation/economy/GoodDefinition.cpp
+++ b/src/openvic-simulation/economy/GoodDefinition.cpp
@@ -1,20 +1,28 @@
#include "GoodDefinition.hpp"
-#include <cassert>
-
using namespace OpenVic;
using namespace OpenVic::NodeTools;
GoodCategory::GoodCategory(std::string_view new_identifier) : HasIdentifier { new_identifier } {}
GoodDefinition::GoodDefinition(
- std::string_view new_identifier, colour_t new_colour, index_t new_index, GoodCategory const& new_category,
- price_t new_base_price, bool new_available_from_start, bool new_tradeable, bool new_money, bool new_overseas_penalty
-) : HasIdentifierAndColour { new_identifier, new_colour, false }, HasIndex { new_index }, category { new_category },
- base_price { new_base_price }, available_from_start { new_available_from_start }, tradeable { new_tradeable },
- money { new_money }, overseas_penalty { new_overseas_penalty } {
- assert(base_price > NULL_PRICE);
-}
+ std::string_view new_identifier,
+ colour_t new_colour,
+ index_t new_index,
+ GoodCategory const& new_category,
+ price_t new_base_price,
+ bool new_available_from_start,
+ bool new_tradeable,
+ bool new_money,
+ bool new_overseas_penalty
+) : HasIdentifierAndColour { new_identifier, new_colour, false },
+ HasIndex { new_index },
+ category { new_category },
+ base_price { new_base_price },
+ available_from_start { new_available_from_start },
+ tradeable { new_tradeable },
+ money { new_money },
+ overseas_penalty { new_overseas_penalty } {}
bool GoodDefinitionManager::add_good_category(std::string_view identifier) {
if (identifier.empty()) {
diff --git a/src/openvic-simulation/map/Mapmode.cpp b/src/openvic-simulation/map/Mapmode.cpp
index cab67d1..f951a05 100644
--- a/src/openvic-simulation/map/Mapmode.cpp
+++ b/src/openvic-simulation/map/Mapmode.cpp
@@ -1,7 +1,5 @@
#include "Mapmode.hpp"
-#include <cassert>
-
#include "openvic-simulation/country/CountryInstance.hpp"
#include "openvic-simulation/map/MapDefinition.hpp"
#include "openvic-simulation/map/MapInstance.hpp"
@@ -13,10 +11,12 @@ using namespace OpenVic;
using namespace OpenVic::colour_literals;
Mapmode::Mapmode(
- std::string_view new_identifier, index_t new_index, colour_func_t new_colour_func
-) : HasIdentifier { new_identifier }, HasIndex { new_index }, colour_func { new_colour_func } {
- assert(colour_func != nullptr);
-}
+ std::string_view new_identifier,
+ index_t new_index,
+ colour_func_t new_colour_func
+) : HasIdentifier { new_identifier },
+ HasIndex { new_index },
+ colour_func { new_colour_func } {}
const Mapmode Mapmode::ERROR_MAPMODE {
"mapmode_error", 0, [](MapInstance const&, ProvinceInstance const& province) -> base_stripe_t {
diff --git a/src/openvic-simulation/map/ProvinceDefinition.cpp b/src/openvic-simulation/map/ProvinceDefinition.cpp
index 4f34c1e..14828e8 100644
--- a/src/openvic-simulation/map/ProvinceDefinition.cpp
+++ b/src/openvic-simulation/map/ProvinceDefinition.cpp
@@ -8,13 +8,23 @@ using namespace OpenVic;
using namespace OpenVic::NodeTools;
ProvinceDefinition::ProvinceDefinition(
- std::string_view new_identifier, colour_t new_colour, index_t new_index
-) : HasIdentifierAndColour { new_identifier, new_colour, true }, HasIndex { new_index }, region { nullptr },
- climate { nullptr }, continent { nullptr }, on_map { false }, water { false }, coastal { false },
- port { false }, port_adjacent_province { nullptr }, default_terrain_type { nullptr }, adjacencies {}, centre {},
- positions {} {
- assert(index != NULL_INDEX);
-}
+ std::string_view new_identifier,
+ colour_t new_colour,
+ index_t new_index
+) : HasIdentifierAndColour { new_identifier, new_colour, true },
+ HasIndex { new_index },
+ region { nullptr },
+ climate { nullptr },
+ continent { nullptr },
+ on_map { false },
+ water { false },
+ coastal { false },
+ port { false },
+ port_adjacent_province { nullptr },
+ default_terrain_type { nullptr },
+ adjacencies {},
+ centre {},
+ positions {} {}
bool ProvinceDefinition::operator==(ProvinceDefinition const& other) const {
return this == &other;
diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp
index c421de3..6dd0d1f 100644
--- a/src/openvic-simulation/pop/Pop.cpp
+++ b/src/openvic-simulation/pop/Pop.cpp
@@ -40,9 +40,7 @@ Pop::Pop(PopBase const& pop_base, decltype(ideologies)::keys_t const& ideology_k
savings { 0 },
life_needs_fulfilled { 0 },
everyday_needs_fulfilled { 0 },
- luxury_needs_fulfilled { 0 } {
- assert(size > 0);
-}
+ luxury_needs_fulfilled { 0 } {}
void Pop::setup_pop_test_values(IssueManager const& issue_manager) {
/* Returns +/- range% of size. */
@@ -198,11 +196,7 @@ PopType::PopType(
migration_target { std::move(new_migration_target) },
promote_to { std::move(new_promote_to) },
ideologies { std::move(new_ideologies) },
- issues { std::move(new_issues) } {
- assert(sprite > 0);
- assert(max_size >= 0);
- assert(merge_max_size >= 0);
-}
+ issues { std::move(new_issues) } {}
bool PopType::parse_scripts(DefinitionManager const& definition_manager) {
bool ret = true;
diff --git a/src/openvic-simulation/pop/Religion.cpp b/src/openvic-simulation/pop/Religion.cpp
index 3fa81bf..2283821 100644
--- a/src/openvic-simulation/pop/Religion.cpp
+++ b/src/openvic-simulation/pop/Religion.cpp
@@ -1,7 +1,5 @@
#include "Religion.hpp"
-#include <cassert>
-
#include "openvic-simulation/types/Colour.hpp"
using namespace OpenVic;
@@ -10,10 +8,15 @@ using namespace OpenVic::NodeTools;
ReligionGroup::ReligionGroup(std::string_view new_identifier) : HasIdentifier { new_identifier } {}
Religion::Religion(
- std::string_view new_identifier, colour_t new_colour, ReligionGroup const& new_group, icon_t new_icon, bool new_pagan
-) : HasIdentifierAndColour { new_identifier, new_colour, false }, group { new_group }, icon { new_icon }, pagan { new_pagan } {
- assert(icon > 0);
-}
+ std::string_view new_identifier,
+ colour_t new_colour,
+ ReligionGroup const& new_group,
+ icon_t new_icon,
+ bool new_pagan
+) : HasIdentifierAndColour { new_identifier, new_colour, false },
+ group { new_group },
+ icon { new_icon },
+ pagan { new_pagan } {}
bool ReligionManager::add_religion_group(std::string_view identifier) {
if (identifier.empty()) {
diff --git a/src/openvic-simulation/types/Vector.hpp b/src/openvic-simulation/types/Vector.hpp
index 7ed952a..d318c2f 100644
--- a/src/openvic-simulation/types/Vector.hpp
+++ b/src/openvic-simulation/types/Vector.hpp
@@ -14,7 +14,7 @@ namespace OpenVic {
T x, y;
constexpr vec2_t() = default;
- constexpr vec2_t(T new_val) : x { new_val }, y { new_val } {}
+ explicit constexpr vec2_t(T new_val) : x { new_val }, y { new_val } {}
constexpr vec2_t(T new_x, T new_y) : x { new_x }, y { new_y } {}
constexpr vec2_t(vec2_t const&) = default;