diff --git a/src/economy/economy.cpp b/src/economy/economy.cpp index fee36a108..598575311 100644 --- a/src/economy/economy.cpp +++ b/src/economy/economy.cpp @@ -1072,7 +1072,7 @@ void update_province_rgo_production(sys::state& state, dcon::province_id p, dcon assert(amount * state.world.commodity_get_current_price(c) >= 0); state.world.province_set_rgo_full_profit(p, amount * state.world.commodity_get_current_price(c)); - if(c == money) { + if(c.get_money_rgo()) { assert(std::isfinite(amount * state.defines.gold_to_cash_rate) && amount * state.defines.gold_to_cash_rate >= 0.0f); state.world.nation_get_stockpiles(n, money) += amount * state.defines.gold_to_cash_rate; } @@ -2804,6 +2804,9 @@ void daily_update(sys::state& state) { concurrency::parallel_for(uint32_t(1), total_commodities, [&](uint32_t k) { dcon::commodity_id cid{dcon::commodity_id::value_base_t(k)}; + if(state.world.commodity_get_rgo_amount(cid)) + return; + float total_r_demand = 0.0f; float total_consumption = 0.0f; float total_production = 0.0f; @@ -3220,7 +3223,7 @@ float estimate_gold_income(sys::state& state, dcon::nation_id n) { auto amount = 0.f; for(auto poid : state.world.nation_get_province_ownership_as_nation(n)) { auto prov = poid.get_province(); - if(prov.get_rgo().id == economy::money) { + if(prov.get_rgo().get_money_rgo()) { amount += province::rgo_production_quantity(state, prov.id); } } diff --git a/src/gamestate/dcon_generated.txt b/src/gamestate/dcon_generated.txt index e81b3bd00..a3f880487 100644 --- a/src/gamestate/dcon_generated.txt +++ b/src/gamestate/dcon_generated.txt @@ -316,6 +316,11 @@ object { type{ bitfield } tag{ scenario } } + property{ + name{ money_rgo } + type{ bitfield } + tag{ scenario } + } property{ name{ is_mine } type{ bitfield } diff --git a/src/parsing/parsers_declarations.cpp b/src/parsing/parsers_declarations.cpp index 4869d2722..47ca2bd87 100644 --- a/src/parsing/parsers_declarations.cpp +++ b/src/parsing/parsers_declarations.cpp @@ -60,25 +60,31 @@ void culture_group::union_tag(association_type, uint32_t v, error_handler& err, void good::money(association_type, bool v, error_handler& err, int32_t line, good_context& context) { if(v) { - context.outer_context.state.world.commodity_set_color(economy::money, - context.outer_context.state.world.commodity_get_color(context.id)); - context.outer_context.state.world.commodity_set_cost(economy::money, - context.outer_context.state.world.commodity_get_cost(context.id)); - context.outer_context.state.world.commodity_set_commodity_group(economy::money, - context.outer_context.state.world.commodity_get_commodity_group(context.id)); - context.outer_context.state.world.commodity_set_name(economy::money, - context.outer_context.state.world.commodity_get_name(context.id)); - context.outer_context.state.world.commodity_set_is_available_from_start(economy::money, - context.outer_context.state.world.commodity_get_is_available_from_start(context.id)); - - for(auto& pr : context.outer_context.map_of_commodity_names) { - if(pr.second == context.id) { - pr.second = economy::money; - break; + if(context.outer_context.money_set) { + context.outer_context.state.world.commodity_set_money_rgo(context.id, true); + } else { + context.outer_context.state.world.commodity_set_color(economy::money, + context.outer_context.state.world.commodity_get_color(context.id)); + context.outer_context.state.world.commodity_set_cost(economy::money, + context.outer_context.state.world.commodity_get_cost(context.id)); + context.outer_context.state.world.commodity_set_commodity_group(economy::money, + context.outer_context.state.world.commodity_get_commodity_group(context.id)); + context.outer_context.state.world.commodity_set_name(economy::money, + context.outer_context.state.world.commodity_get_name(context.id)); + context.outer_context.state.world.commodity_set_is_available_from_start(economy::money, + context.outer_context.state.world.commodity_get_is_available_from_start(context.id)); + context.outer_context.state.world.commodity_set_money_rgo(economy::money, true); + + for(auto& pr : context.outer_context.map_of_commodity_names) { + if(pr.second == context.id) { + pr.second = economy::money; + break; + } } + context.id = economy::money; + context.outer_context.state.world.pop_back_commodity(); + context.outer_context.money_set = true; } - context.id = economy::money; - context.outer_context.state.world.pop_back_commodity(); } } diff --git a/src/parsing/parsers_declarations.hpp b/src/parsing/parsers_declarations.hpp index 1f4761429..3b09da900 100644 --- a/src/parsing/parsers_declarations.hpp +++ b/src/parsing/parsers_declarations.hpp @@ -398,6 +398,7 @@ struct scenario_building_context { int32_t number_of_commodities_seen = 0; int32_t number_of_national_values_seen = 0; bool new_maps = false; + bool money_set = false; }; struct national_identity_file {