Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug related to new state creation, update dcon tag, add global keyword #1886

Merged
merged 4 commits into from
Jan 30, 2025
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
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