Skip to content

Commit

Permalink
Merge pull request #1886 from ineveraskedforthis/main
Browse files Browse the repository at this point in the history
Fix bug related to new state creation, update dcon tag, add global keyword
  • Loading branch information
schombert authored Jan 30, 2025
2 parents c71e105 + eebe164 commit f6d8356
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dependencies/DataContainerGenerator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ message(STATUS "Fetching DataContainer...")
FetchContent_Declare(
DataContainer
GIT_REPOSITORY https://github.com/schombert/DataContainer
GIT_TAG f1ddfd3
GIT_TAG 538d55c
GIT_SHALLOW 1
GIT_PROGRESS TRUE
)
Expand Down
2 changes: 2 additions & 0 deletions src/gamestate/dcon_generated.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
global{no-conversions}

include{<array>}
include{"constants.hpp"}
include{"modifiers.hpp"}
Expand Down
1 change: 0 additions & 1 deletion src/launcher/launcher_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "gui_production_window.cpp"
#include "gui_province_window.cpp"
#include "gui_population_window.cpp"
#include "gui_budget_window.cpp"
#include "immediate_mode.cpp"
#include "economy_viewer.cpp"
#include "gui_technology_window.cpp"
Expand Down
26 changes: 22 additions & 4 deletions src/provinces/province.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "math_fns.hpp"
#include "prng.hpp"
#include "triggers.hpp"
#include "economy_stats.hpp"
#include <set>

namespace province {
Expand Down Expand Up @@ -770,10 +771,27 @@ void change_province_owner(sys::state& state, dcon::province_id id, dcon::nation
auto new_market = state.world.create_market();

// set prices to something to avoid infinite demand:

state.world.for_each_commodity([&](auto cid){
state.world.market_set_price(new_market, cid, state.world.market_get_price(old_market, cid));
});
if(old_market) {
state.world.for_each_commodity([&](auto cid){
state.world.market_set_price(new_market, cid, state.world.market_get_price(old_market, cid));
});
for(auto index = 0; index < economy::labor::total; index++) {
state.world.market_set_labor_price(new_market, index, state.world.market_get_labor_price(old_market, index));
}
for(auto index = 0; index < economy::pop_labor::total; index++) {
state.world.market_set_pop_labor_distribution(new_market, index, state.world.market_get_pop_labor_distribution(old_market, index));
}
} else {
state.world.for_each_commodity([&](auto cid) {
state.world.market_set_price(new_market, cid, economy::median_price(state, cid));
});
for(auto index = 0; index < economy::labor::total; index++) {
state.world.market_set_labor_price(new_market, index, 1.f);
}
for(auto index = 0; index < economy::pop_labor::total; index++) {
state.world.market_set_pop_labor_distribution(new_market, index, 0.f);
}
}

auto new_local_market = state.world.force_create_local_market(new_market, new_si);

Expand Down

0 comments on commit f6d8356

Please sign in to comment.