Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/headless/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ static bool run_headless(fs::path const& root, memory::vector<memory::string>& m
SPDLOG_INFO("===== Ranking system test... =====");
if (game_manager.get_instance_manager()) {
const auto print_ranking_list = [ //
](std::string_view title, OpenVic::utility::forwardable_span<CountryInstance* const> countries) -> void {
](std::string_view title, OpenVic::forwardable_span<CountryInstance* const> countries) -> void {
memory::string countries_str;
for (CountryInstance* country : countries) {
countries_str += fmt::format(
Expand All @@ -278,7 +278,7 @@ static bool run_headless(fs::path const& root, memory::vector<memory::string>& m
CountryInstanceManager const& country_instance_manager =
game_manager.get_instance_manager()->get_country_instance_manager();

OpenVic::utility::forwardable_span<CountryInstance* const> great_powers = country_instance_manager.get_great_powers();
OpenVic::forwardable_span<CountryInstance* const> great_powers = country_instance_manager.get_great_powers();
print_ranking_list("Great Powers", great_powers);
print_ranking_list("Secondary Powers", country_instance_manager.get_secondary_powers());
print_ranking_list("All countries", country_instance_manager.get_total_ranking());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#include <ranges>
#include <type_traits>

#include "openvic-simulation/types/BasicIterator.hpp"
#include "openvic-simulation/core/Typedefs.hpp"
#include "openvic-simulation/types/BasicIterator.hpp"

namespace OpenVic::utility::_detail::forwardable_span {
namespace OpenVic::_detail::forwardable_span {
static constexpr std::size_t dynamic_extent = std::numeric_limits<std::size_t>::max();

template<class T, std::size_t Extent = dynamic_extent>
Expand Down Expand Up @@ -347,7 +347,7 @@ namespace OpenVic::utility::_detail::forwardable_span {
span(Range&&) -> span<std::remove_reference_t<std::ranges::range_reference_t<Range&>>>;
}

namespace OpenVic::utility {
namespace OpenVic {
static constexpr std::size_t dynamic_extent = _detail::forwardable_span::dynamic_extent;

template<class T, std::size_t Extent = dynamic_extent>
Expand All @@ -357,37 +357,37 @@ namespace OpenVic::utility {
namespace std {
namespace ranges {
template<typename T, std::size_t Extent>
inline constexpr bool enable_borrowed_range<OpenVic::utility::forwardable_span<T, Extent>> = true;
inline constexpr bool enable_borrowed_range<OpenVic::forwardable_span<T, Extent>> = true;

template<typename T, std::size_t Extent>
inline constexpr bool enable_view<OpenVic::utility::forwardable_span<T, Extent>> = true;
inline constexpr bool enable_view<OpenVic::forwardable_span<T, Extent>> = true;
}

template<typename T, size_t Extent>
[[nodiscard]] inline OpenVic::utility::forwardable_span<
[[nodiscard]] inline OpenVic::forwardable_span<
const std::byte, Extent == dynamic_extent ? dynamic_extent : Extent * sizeof(T)>
as_bytes(OpenVic::utility::forwardable_span<T, Extent> sp) {
as_bytes(OpenVic::forwardable_span<T, Extent> sp) {
auto data = reinterpret_cast<const std::byte*>(sp.data());
auto size = sp.size_bytes();
constexpr std::size_t extent = Extent == dynamic_extent ? dynamic_extent : Extent * sizeof(T);
return OpenVic::utility::forwardable_span<const std::byte, extent> { data, size };
return OpenVic::forwardable_span<const std::byte, extent> { data, size };
}

template<typename T, size_t Extent>
requires(!std::is_const_v<T>)
inline OpenVic::utility::forwardable_span<std::byte, Extent == dynamic_extent ? dynamic_extent : Extent * sizeof(T)>
as_writable_bytes [[nodiscard]] (OpenVic::utility::forwardable_span<T, Extent> sp) {
inline OpenVic::forwardable_span<std::byte, Extent == dynamic_extent ? dynamic_extent : Extent * sizeof(T)>
as_writable_bytes [[nodiscard]] (OpenVic::forwardable_span<T, Extent> sp) {
auto data = reinterpret_cast<std::byte*>(sp.data());
auto size = sp.size_bytes();
constexpr std::size_t extent = Extent == dynamic_extent ? dynamic_extent : Extent * sizeof(T);
return OpenVic::utility::forwardable_span<std::byte, extent> { data, size };
return OpenVic::forwardable_span<std::byte, extent> { data, size };
}
}

#else
#include <span>

namespace OpenVic::utility {
namespace OpenVic {
template<class T, std::size_t Extent = std::dynamic_extent>
using forwardable_span = std::span<T, Extent>;
}
Expand Down
4 changes: 2 additions & 2 deletions src/openvic-simulation/country/CountryInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,7 @@ void CountryInstance::after_sell(void* actor, SellResult const& sell_result, mem

void CountryInstance::country_tick_before_map(
IndexedFlatMap<GoodDefinition, char>& reusable_goods_mask,
utility::forwardable_span<
forwardable_span<
memory::vector<fixed_point_t>,
VECTORS_FOR_COUNTRY_TICK
> reusable_vectors,
Expand Down Expand Up @@ -2048,7 +2048,7 @@ void CountryInstance::calculate_government_good_needs() {

void CountryInstance::manage_national_stockpile(
IndexedFlatMap<GoodDefinition, char>& reusable_goods_mask,
utility::forwardable_span<
forwardable_span<
memory::vector<fixed_point_t>,
VECTORS_FOR_COUNTRY_TICK
> reusable_vectors,
Expand Down
4 changes: 2 additions & 2 deletions src/openvic-simulation/country/CountryInstance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ namespace OpenVic {

void manage_national_stockpile(
IndexedFlatMap<GoodDefinition, char>& reusable_goods_mask,
utility::forwardable_span<
forwardable_span<
memory::vector<fixed_point_t>,
VECTORS_FOR_COUNTRY_TICK
> reusable_vectors,
Expand Down Expand Up @@ -661,7 +661,7 @@ namespace OpenVic {
void update_gamestate(const Date today, MapInstance& map_instance);
void country_tick_before_map(
IndexedFlatMap<GoodDefinition, char>& reusable_goods_mask,
utility::forwardable_span<
forwardable_span<
memory::vector<fixed_point_t>,
VECTORS_FOR_COUNTRY_TICK
> reusable_vectors,
Expand Down
26 changes: 13 additions & 13 deletions src/openvic-simulation/country/CountryInstanceDeps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "openvic-simulation/types/Date.hpp"
#include "openvic-simulation/types/UnitBranchType.hpp"
#include "openvic-simulation/utility/ForwardableSpan.hpp"
#include "openvic-simulation/core/portable/ForwardableSpan.hpp"

namespace OpenVic {
struct BuildingType;
Expand All @@ -27,28 +27,28 @@ namespace OpenVic {
struct UnitTypeManager;

struct CountryInstanceDeps {
utility::forwardable_span<const BuildingType> building_types;
forwardable_span<const BuildingType> building_types;
CountryDefines const& country_defines;
CountryRelationManager& country_relations_manager;
utility::forwardable_span<const Crime> crimes;
forwardable_span<const Crime> crimes;
Date fallback_date_for_never_completing_research;
DiplomacyDefines const& diplomacy_defines;
EconomyDefines const& economy_defines;
utility::forwardable_span<const Invention> inventions;
utility::forwardable_span<const Ideology> ideologies;
forwardable_span<const Invention> inventions;
forwardable_span<const Ideology> ideologies;
GameRulesManager const& game_rules_manager;
utility::forwardable_span<const GoodInstance> good_instances;
forwardable_span<const GoodInstance> good_instances;
GoodInstanceManager& good_instance_manager;
utility::forwardable_span<const GovernmentType> government_types;
forwardable_span<const GovernmentType> government_types;
MarketInstance& market_instance;
MilitaryDefines const& military_defines;
ModifierEffectCache const& modifier_effect_cache;
utility::forwardable_span<const PopType> pop_types;
utility::forwardable_span<const ReformGroup> reforms;
utility::forwardable_span<const RegimentType> regiment_types;
utility::forwardable_span<const ShipType> ship_types;
utility::forwardable_span<const Strata> stratas;
utility::forwardable_span<const Technology> technologies;
forwardable_span<const PopType> pop_types;
forwardable_span<const ReformGroup> reforms;
forwardable_span<const RegimentType> regiment_types;
forwardable_span<const ShipType> ship_types;
forwardable_span<const Strata> stratas;
forwardable_span<const Technology> technologies;
UnitTypeManager const& unit_type_manager;
};
}
2 changes: 1 addition & 1 deletion src/openvic-simulation/country/CountryInstanceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CountryInstanceManager::CountryInstanceManager(
CountryInstanceDeps const& country_instance_deps,
GoodInstanceManager const& new_good_instance_manager,
PopsDefines const& new_pop_defines,
utility::forwardable_span<const PopType> pop_type_keys,
forwardable_span<const PopType> pop_type_keys,
ThreadPool& new_thread_pool
) : thread_pool { new_thread_pool },
country_definition_manager { new_country_definition_manager },
Expand Down
2 changes: 1 addition & 1 deletion src/openvic-simulation/country/CountryInstanceManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace OpenVic {
CountryInstanceDeps const& country_instance_deps,
GoodInstanceManager const& new_good_instance_manager,
PopsDefines const& new_pop_defines,
utility::forwardable_span<const PopType> pop_type_keys,
forwardable_span<const PopType> pop_type_keys,
ThreadPool& new_thread_pool
);

Expand Down
4 changes: 2 additions & 2 deletions src/openvic-simulation/economy/GoodInstance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ namespace OpenVic {
GameRulesManager const& game_rules_manager
);

constexpr OpenVic::utility::forwardable_span<GoodInstance> get_good_instances() {
constexpr forwardable_span<GoodInstance> get_good_instances() {
return good_instance_by_definition.get_values();
}

constexpr OpenVic::utility::forwardable_span<const GoodInstance> get_good_instances() const {
constexpr forwardable_span<const GoodInstance> get_good_instances() const {
return good_instance_by_definition.get_values();
}
GoodInstance* get_good_instance_by_identifier(std::string_view identifier);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "openvic-simulation/utility/ForwardableSpan.hpp"
#include "openvic-simulation/core/portable/ForwardableSpan.hpp"

namespace OpenVic {
struct EconomyDefines;
Expand All @@ -9,7 +9,7 @@ namespace OpenVic {

struct ArtisanalProducerDeps {
EconomyDefines const& economy_defines;
utility::forwardable_span<const GoodDefinition> good_keys;
forwardable_span<const GoodDefinition> good_keys;
ModifierEffectCache const& modifier_effect_cache;
};
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "openvic-simulation/utility/ForwardableSpan.hpp"
#include "openvic-simulation/core/portable/ForwardableSpan.hpp"

namespace OpenVic {
struct MarketInstance;
Expand All @@ -10,6 +10,6 @@ namespace OpenVic {
struct ResourceGatheringOperationDeps {
MarketInstance& market_instance;
ModifierEffectCache const& modifier_effect_cache;
utility::forwardable_span<const PopType> pop_type_keys;
forwardable_span<const PopType> pop_type_keys;
};
}
4 changes: 2 additions & 2 deletions src/openvic-simulation/map/MapInstance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ namespace OpenVic {
return map_definition;
}

constexpr OpenVic::utility::forwardable_span<ProvinceInstance> get_province_instances() {
constexpr forwardable_span<ProvinceInstance> get_province_instances() {
return province_instance_by_definition.get_values();
}

constexpr OpenVic::utility::forwardable_span<const ProvinceInstance> get_province_instances() const {
constexpr forwardable_span<const ProvinceInstance> get_province_instances() const {
return province_instance_by_definition.get_values();
}
ProvinceInstance* get_province_instance_by_identifier(std::string_view identifier);
Expand Down
4 changes: 2 additions & 2 deletions src/openvic-simulation/map/ProvinceInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ void ProvinceInstance::province_tick(
PopValuesFromProvince& reusable_pop_values,
RandomU32& random_number_generator,
IndexedFlatMap<GoodDefinition, char>& reusable_goods_mask,
utility::forwardable_span<
forwardable_span<
memory::vector<fixed_point_t>,
VECTORS_FOR_PROVINCE_TICK
> reusable_vectors
Expand Down Expand Up @@ -521,7 +521,7 @@ void ProvinceInstance::initialise_for_new_game(
PopValuesFromProvince& reusable_pop_values,
RandomU32& random_number_generator,
IndexedFlatMap<GoodDefinition, char>& reusable_goods_mask,
utility::forwardable_span<
forwardable_span<
memory::vector<fixed_point_t>,
VECTORS_FOR_PROVINCE_TICK
> reusable_vectors
Expand Down
6 changes: 3 additions & 3 deletions src/openvic-simulation/map/ProvinceInstance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "openvic-simulation/types/TypedIndices.hpp"
#include "openvic-simulation/types/UnitBranchType.hpp"
#include "openvic-simulation/utility/Containers.hpp"
#include "openvic-simulation/utility/ForwardableSpan.hpp"
#include "openvic-simulation/core/portable/ForwardableSpan.hpp"

namespace OpenVic {
struct BaseIssue;
Expand Down Expand Up @@ -192,7 +192,7 @@ namespace OpenVic {
PopValuesFromProvince& reusable_pop_values,
RandomU32& random_number_generator,
IndexedFlatMap<GoodDefinition, char>& reusable_goods_mask,
utility::forwardable_span<
forwardable_span<
memory::vector<fixed_point_t>,
VECTORS_FOR_PROVINCE_TICK
> reusable_vectors
Expand All @@ -202,7 +202,7 @@ namespace OpenVic {
PopValuesFromProvince& reusable_pop_values,
RandomU32& random_number_generator,
IndexedFlatMap<GoodDefinition, char>& reusable_goods_mask,
utility::forwardable_span<
forwardable_span<
memory::vector<fixed_point_t>,
VECTORS_FOR_PROVINCE_TICK
> reusable_vectors
Expand Down
8 changes: 4 additions & 4 deletions src/openvic-simulation/map/ProvinceInstanceDeps.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "openvic-simulation/utility/ForwardableSpan.hpp"
#include "openvic-simulation/core/portable/ForwardableSpan.hpp"

namespace OpenVic {
struct BuildingTypeManager;
Expand All @@ -13,9 +13,9 @@ namespace OpenVic {
struct ProvinceInstanceDeps {
BuildingTypeManager const& building_type_manager;
GameRulesManager const& game_rules_manager;
utility::forwardable_span<const Ideology> ideologies;
utility::forwardable_span<const PopType> pop_types;
forwardable_span<const Ideology> ideologies;
forwardable_span<const PopType> pop_types;
ResourceGatheringOperationDeps const& rgo_deps;
utility::forwardable_span<const Strata> stratas;
forwardable_span<const Strata> stratas;
};
}
18 changes: 9 additions & 9 deletions src/openvic-simulation/map/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ State::State(
ProvinceInstance* new_capital,
memory::vector<ProvinceInstance*>&& new_provinces,
colony_status_t new_colony_status,
utility::forwardable_span<const Strata> strata_keys,
utility::forwardable_span<const PopType> pop_type_keys,
utility::forwardable_span<const Ideology> ideology_keys
forwardable_span<const Strata> strata_keys,
forwardable_span<const PopType> pop_type_keys,
forwardable_span<const Ideology> ideology_keys
) : PopsAggregate { strata_keys, pop_type_keys, ideology_keys },
state_set { new_state_set },
capital { new_capital },
Expand Down Expand Up @@ -134,9 +134,9 @@ void StateSet::update_gamestate() {

bool StateManager::add_state_set(
MapInstance& map_instance, Region const& region,
utility::forwardable_span<const Strata> strata_keys,
utility::forwardable_span<const PopType> pop_type_keys,
utility::forwardable_span<const Ideology> ideology_keys
forwardable_span<const Strata> strata_keys,
forwardable_span<const PopType> pop_type_keys,
forwardable_span<const Ideology> ideology_keys
) {
OV_ERR_FAIL_COND_V_MSG(region.is_meta, false, memory::fmt::format("Cannot use meta region \"{}\" as state template!", region));
OV_ERR_FAIL_COND_V_MSG(region.empty(), false, memory::fmt::format("Cannot use empty region \"{}\" as state template!", region));
Expand Down Expand Up @@ -192,9 +192,9 @@ bool StateManager::add_state_set(
bool StateManager::generate_states(
MapDefinition const& map_definition,
MapInstance& map_instance,
utility::forwardable_span<const Strata> strata_keys,
utility::forwardable_span<const PopType> pop_type_keys,
utility::forwardable_span<const Ideology> ideology_keys
forwardable_span<const Strata> strata_keys,
forwardable_span<const PopType> pop_type_keys,
forwardable_span<const Ideology> ideology_keys
) {
state_sets.clear();
state_sets.reserve(map_definition.get_region_count());
Expand Down
Loading