Project Alice
Loading...
Searching...
No Matches
economy.cpp File Reference
#include "economy.hpp"
#include "economy_templates.hpp"
#include "demographics.hpp"
#include "dcon_generated.hpp"
#include "ai.hpp"
#include "system_state.hpp"
#include "prng.hpp"
#include "math_fns.hpp"
#include "nations_templates.hpp"
#include "province_templates.hpp"
#include "triggers.hpp"
Include dependency graph for economy.cpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  economy::commodity_profit_holder
 
struct  economy::profit_distribution
 

Namespaces

namespace  economy
 

Enumerations

enum class  economy::economy_reason {
  economy::pop , economy::factory , economy::rgo , economy::artisan ,
  economy::construction , economy::nation , economy::stockpile , economy::overseas_penalty
}
 

Functions

void economy::register_demand (sys::state &state, dcon::nation_id n, dcon::commodity_id commodity_type, float amount, economy_reason reason)
 
void economy::register_intermediate_demand (sys::state &state, dcon::nation_id n, dcon::commodity_id commodity_type, float amount, economy_reason reason)
 
void economy::register_construction_demand (sys::state &state, dcon::nation_id n, dcon::commodity_id commodity_type, float amount)
 
void economy::register_domestic_supply (sys::state &state, dcon::nation_id n, dcon::commodity_id commodity_type, float amount, economy_reason reason)
 
template void economy::for_each_new_factory< std::function< void(new_factory)> > (sys::state &, dcon::state_instance_id, std::function< void(new_factory)> &&)
 
template void economy::for_each_upgraded_factory< std::function< void(upgraded_factory)> > (sys::state &, dcon::state_instance_id, std::function< void(upgraded_factory)> &&)
 
bool economy::can_take_loans (sys::state &state, dcon::nation_id n)
 
float economy::interest_payment (sys::state &state, dcon::nation_id n)
 
float economy::max_loan (sys::state &state, dcon::nation_id n)
 
int32_t economy::most_recent_price_record_index (sys::state &state)
 
int32_t economy::previous_price_record_index (sys::state &state)
 
int32_t economy::most_recent_gdp_record_index (sys::state &state)
 
int32_t economy::previous_gdp_record_index (sys::state &state)
 
float economy::ideal_pound_conversion_rate (sys::state &state, dcon::nation_id n)
 
float economy::gdp_adjusted (sys::state &state, dcon::nation_id n)
 
float economy::full_spending_cost (sys::state &state, dcon::nation_id n)
 
void economy::populate_army_consumption (sys::state &state)
 
void economy::populate_navy_consumption (sys::state &state)
 
void economy::populate_construction_consumption (sys::state &state)
 
float economy::commodity_daily_production_amount (sys::state &state, dcon::commodity_id c)
 
float economy::stockpile_commodity_daily_increase (sys::state &state, dcon::commodity_id c, dcon::nation_id n)
 
float economy::global_market_commodity_daily_increase (sys::state &state, dcon::commodity_id c)
 
bool economy::has_factory (sys::state const &state, dcon::state_instance_id si)
 
void economy::initialize_artisan_distribution (sys::state &state)
 
void economy::initialize_needs_weights (sys::state &state, dcon::nation_id n)
 
float economy::need_weight (sys::state &state, dcon::nation_id n, dcon::commodity_id c)
 
void economy::rebalance_needs_weights (sys::state &state, dcon::nation_id n)
 
void economy::convert_commodities_into_ingredients (sys::state &state, std::vector< float > &buffer_commodities, std::vector< float > &buffer_ingredients, std::vector< float > &buffer_weights)
 
void economy::presimulate (sys::state &state)
 
bool economy::has_building (sys::state const &state, dcon::state_instance_id si, dcon::factory_type_id fac)
 
bool economy::is_bankrupt_debtor_to (sys::state &state, dcon::nation_id debt_holder, dcon::nation_id debtor)
 
bool economy::nation_is_constructing_factories (sys::state &state, dcon::nation_id n)
 
bool economy::nation_has_closed_factories (sys::state &state, dcon::nation_id n)
 
float economy::base_artisan_profit (sys::state &state, dcon::nation_id n, dcon::commodity_id c)
 
float economy::artisan_scale_limit (sys::state &state, dcon::nation_id n, dcon::commodity_id c)
 
bool economy::valid_artisan_good (sys::state &state, dcon::nation_id n, dcon::commodity_id cid)
 
float economy::pseudo_exp_for_negative (float f)
 
float economy::get_artisans_multiplier (sys::state &state, dcon::nation_id n)
 
float economy::max_artisan_score (sys::state &state, dcon::nation_id n, float multiplier)
 
float economy::total_artisan_exp_score (sys::state &state, dcon::nation_id n, float multiplier, float max_score)
 
float economy::get_artisan_distribution_fast (sys::state &state, dcon::nation_id n, dcon::commodity_id c, float max_score, float total_score, float multiplier)
 
float economy::get_artisan_distribution_slow (sys::state &state, dcon::nation_id n, dcon::commodity_id c)
 
void economy::adjust_artisan_balance (sys::state &state, dcon::nation_id n)
 
void economy::initialize (sys::state &state)
 
float economy::sphere_leader_share_factor (sys::state &state, dcon::nation_id sphere_leader, dcon::nation_id sphere_member)
 
void economy::absorb_sphere_member_production (sys::state &state, dcon::nation_id n)
 
void economy::give_sphere_leader_production (sys::state &state, dcon::nation_id n)
 
float economy::effective_tariff_rate (sys::state &state, dcon::nation_id n)
 
float economy::global_market_price_multiplier (sys::state &state, dcon::nation_id n)
 
void economy::update_factory_triggered_modifiers (sys::state &state)
 
float economy::subsistence_size (sys::state const &state, dcon::province_id p)
 
float economy::rgo_effective_size (sys::state const &state, dcon::nation_id n, dcon::province_id p, dcon::commodity_id c)
 
float economy::rgo_total_effective_size (sys::state &state, dcon::nation_id n, dcon::province_id p)
 
float economy::subsistence_max_pseudoemployment (sys::state &state, dcon::nation_id n, dcon::province_id p)
 
float economy::rgo_total_employment (sys::state &state, dcon::nation_id n, dcon::province_id p)
 
float economy::rgo_max_employment (sys::state &state, dcon::nation_id n, dcon::province_id p, dcon::commodity_id c)
 
float economy::rgo_total_max_employment (sys::state &state, dcon::nation_id n, dcon::province_id p)
 
void economy::update_local_subsistence_factor (sys::state &state)
 
float economy::adjusted_subsistence_score (sys::state &state, dcon::province_id p)
 
void economy::update_land_ownership (sys::state &state)
 
int32_t economy::factory_priority (sys::state const &state, dcon::factory_id f)
 
void economy::set_factory_priority (sys::state &state, dcon::factory_id f, int32_t priority)
 
bool economy::factory_is_profitable (sys::state const &state, dcon::factory_id f)
 
void economy::update_rgo_employment (sys::state &state)
 
float economy::factory_max_employment (sys::state const &state, dcon::factory_id f)
 
float economy::factory_primary_employment (sys::state const &state, dcon::factory_id f)
 
float economy::factory_secondary_employment (sys::state const &state, dcon::factory_id f)
 
float economy::factory_total_employment (sys::state const &state, dcon::factory_id f)
 
void economy::update_factory_employment (sys::state &state)
 
float economy::factory_full_production_quantity (sys::state const &state, dcon::factory_id f, dcon::nation_id n, float mobilization_impact)
 
float economy::rgo_efficiency (sys::state &state, dcon::nation_id n, dcon::province_id p, dcon::commodity_id c)
 
float economy::rgo_full_production_quantity (sys::state &state, dcon::nation_id n, dcon::province_id p, dcon::commodity_id c)
 
float economy::factory_min_input_available (sys::state &state, dcon::nation_id n, dcon::factory_type_fat_id fac_type)
 
float economy::factory_input_total_cost (sys::state &state, dcon::nation_id n, dcon::factory_type_fat_id fac_type)
 
float economy::factory_min_e_input_available (sys::state &state, dcon::nation_id n, dcon::factory_type_fat_id fac_type)
 
float economy::factory_e_input_total_cost (sys::state &state, dcon::nation_id n, dcon::factory_type_fat_id fac_type)
 
float economy::nation_factory_input_multiplier (sys::state &state, dcon::nation_id n)
 
float economy::nation_factory_output_multiplier (sys::state &state, dcon::factory_type_id fac_type, dcon::nation_id n)
 
float economy::factory_input_multiplier (sys::state &state, dcon::factory_fat_id fac, dcon::nation_id n, dcon::province_id p, dcon::state_instance_id s)
 
float economy::factory_throughput_multiplier (sys::state &state, dcon::factory_type_fat_id fac_type, dcon::nation_id n, dcon::province_id p, dcon::state_instance_id s)
 
float economy::factory_output_multiplier (sys::state &state, dcon::factory_fat_id fac, dcon::nation_id n, dcon::province_id p)
 
float economy::factory_max_production_scale_non_modified (sys::state &state, dcon::factory_fat_id fac)
 
float economy::factory_max_production_scale (sys::state &state, dcon::factory_fat_id fac, float mobilization_impact, bool occupied)
 
float economy::update_factory_scale (sys::state &state, dcon::factory_fat_id fac, float max_production_scale, float raw_profit, float desired_raw_profit)
 
float economy::factory_desired_raw_profit (dcon::factory_fat_id fac, float spendings)
 
void economy::update_single_factory_consumption (sys::state &state, dcon::factory_id f, dcon::nation_id n, dcon::province_id p, dcon::state_instance_id s, float mobilization_impact, float expected_min_wage, bool occupied)
 
void economy::update_single_factory_production (sys::state &state, dcon::factory_id f, dcon::nation_id n, float expected_min_wage)
 
rgo_workers_breakdown economy::rgo_relevant_population (sys::state &state, dcon::province_id p, dcon::nation_id n)
 
float economy::rgo_desired_worker_norm_profit (sys::state &state, dcon::province_id p, dcon::nation_id n, float min_wage, float total_relevant_population)
 
float economy::rgo_expected_worker_norm_profit (sys::state &state, dcon::province_id p, dcon::nation_id n, dcon::commodity_id c)
 
float economy::convex_function (float x)
 
void economy::update_province_rgo_consumption (sys::state &state, dcon::province_id p, dcon::nation_id n, float mobilization_impact, float expected_min_wage, bool occupied)
 
void economy::update_province_rgo_production (sys::state &state, dcon::province_id p, dcon::nation_id n)
 
void economy::update_national_artisan_consumption (sys::state &state, dcon::nation_id n, float expected_min_wage, float mobilization_impact)
 
void economy::update_national_artisan_production (sys::state &state, dcon::nation_id n)
 
float economy::global_non_factory_construction_time_modifier (sys::state &state)
 
float economy::global_factory_construction_time_modifier (sys::state &state)
 
void economy::populate_private_construction_consumption (sys::state &state)
 
float economy::estimate_stockpile_filling_spending (sys::state &state, dcon::nation_id n)
 
float economy::estimate_overseas_penalty_spending (sys::state &state, dcon::nation_id n)
 
float economy::full_private_investment_cost (sys::state &state, dcon::nation_id n)
 
void economy::update_national_consumption (sys::state &state, dcon::nation_id n, float spending_scale, float private_investment_scale)
 
void economy::update_pop_consumption (sys::state &state, dcon::nation_id n, float base_demand, float invention_factor)
 
void economy::populate_needs_costs (sys::state &state, dcon::nation_id n, float base_demand, float invention_factor)
 
void economy::advance_construction (sys::state &state, dcon::nation_id n)
 
float economy::pop_min_wage_factor (sys::state &state, dcon::nation_id n)
 
float economy::pop_farmer_min_wage (sys::state &state, dcon::nation_id n, float min_wage_factor)
 
float economy::pop_laborer_min_wage (sys::state &state, dcon::nation_id n, float min_wage_factor)
 
float economy::pop_factory_min_wage (sys::state &state, dcon::nation_id n, float min_wage_factor)
 
void economy::populate_effective_prices (sys::state &state, dcon::nation_id n)
 
profit_distribution economy::distribute_factory_profit (sys::state const &state, dcon::state_instance_const_fat_id s, float min_wage, float total_profit)
 
void economy::emulate_construction_demand (sys::state &state, dcon::nation_id n)
 
void economy::daily_update (sys::state &state, bool initiate_buildings)
 
void economy::regenerate_unsaved_values (sys::state &state)
 
float economy::government_consumption (sys::state &state, dcon::nation_id n, dcon::commodity_id c)
 
float economy::factory_type_build_cost (sys::state &state, dcon::nation_id n, dcon::factory_type_id factory_type)
 
float economy::factory_type_output_cost (sys::state &state, dcon::nation_id n, dcon::factory_type_id factory_type)
 
float economy::factory_type_input_cost (sys::state &state, dcon::nation_id n, dcon::factory_type_id factory_type)
 
float economy::nation_factory_consumption (sys::state &state, dcon::nation_id n, dcon::commodity_id c)
 
float economy::nation_pop_consumption (sys::state &state, dcon::nation_id n, dcon::commodity_id c)
 
float economy::nation_total_imports (sys::state &state, dcon::nation_id n)
 
float economy::pop_income (sys::state &state, dcon::pop_id p)
 
float economy::estimate_gold_income (sys::state &state, dcon::nation_id n)
 
float economy::estimate_tariff_income (sys::state &state, dcon::nation_id n)
 
float economy::estimate_social_spending (sys::state &state, dcon::nation_id n)
 
float economy::estimate_pop_payouts_by_income_type (sys::state &state, dcon::nation_id n, culture::income_type in)
 
float economy::estimate_tax_income_by_strata (sys::state &state, dcon::nation_id n, culture::pop_strata ps)
 
float economy::estimate_subsidy_spending (sys::state &state, dcon::nation_id n)
 
float economy::estimate_war_subsidies_income (sys::state &state, dcon::nation_id n)
 
float economy::estimate_reparations_income (sys::state &state, dcon::nation_id n)
 
float economy::estimate_war_subsidies_spending (sys::state &state, dcon::nation_id n)
 
float economy::estimate_reparations_spending (sys::state &state, dcon::nation_id n)
 
float economy::estimate_diplomatic_balance (sys::state &state, dcon::nation_id n)
 
float economy::estimate_domestic_investment (sys::state &state, dcon::nation_id n)
 
float economy::estimate_land_spending (sys::state &state, dcon::nation_id n)
 
float economy::estimate_naval_spending (sys::state &state, dcon::nation_id n)
 
float economy::estimate_construction_spending (sys::state &state, dcon::nation_id n)
 
float economy::estimate_war_subsidies (sys::state &state, dcon::nation_id n)
 
construction_status economy::province_building_construction (sys::state &state, dcon::province_id p, province_building_type t)
 
construction_status economy::factory_upgrade (sys::state &state, dcon::factory_id f)
 
bool economy::state_contains_constructed_factory (sys::state &state, dcon::state_instance_id s, dcon::factory_type_id ft)
 
bool economy::state_contains_factory (sys::state &state, dcon::state_instance_id s, dcon::factory_type_id ft)
 
int32_t economy::state_factory_count (sys::state &state, dcon::state_instance_id sid, dcon::nation_id n)
 
float economy::unit_construction_progress (sys::state &state, dcon::province_land_construction_id c)
 
float economy::unit_construction_progress (sys::state &state, dcon::province_naval_construction_id c)
 
void economy::add_factory_level_to_state (sys::state &state, dcon::state_instance_id s, dcon::factory_type_id t, bool is_upgrade)
 
void economy::resolve_constructions (sys::state &state)
 
float economy::estimate_daily_income (sys::state &state, dcon::nation_id n)
 
void economy::try_add_factory_to_state (sys::state &state, dcon::state_instance_id s, dcon::factory_type_id t)
 
void economy::bound_budget_settings (sys::state &state, dcon::nation_id n)
 
void economy::prune_factories (sys::state &state)
 
dcon::modifier_id economy::get_province_selector_modifier (sys::state &state)
 
dcon::modifier_id economy::get_province_immigrator_modifier (sys::state &state)
 
void economy::go_bankrupt (sys::state &state, dcon::nation_id n)
 
commodity_production_type economy::get_commodity_production_type (sys::state &state, dcon::commodity_id c)
 

Variables

constexpr float economy::ln_2 = 0.30103f
 
constexpr float economy::artisan_baseline_score = 5.f
 
constexpr float economy::day_1_build_time_modifier_non_factory = 2.f
 
constexpr float economy::day_inf_build_time_modifier_non_factory = 0.5f
 
constexpr float economy::day_1_derivative_non_factory = -0.2f
 
constexpr float economy::diff_non_factory = day_1_build_time_modifier_non_factory - day_inf_build_time_modifier_non_factory
 
constexpr float economy::shift_non_factory = - diff_non_factory / day_1_derivative_non_factory
 
constexpr float economy::slope_non_factory = diff_non_factory * shift_non_factory
 
constexpr float economy::day_1_build_time_modifier_factory = 0.9f
 
constexpr float economy::day_inf_build_time_modifier_factory = 0.75f
 
constexpr float economy::day_1_derivative_factory = -0.01f
 
constexpr float economy::diff_factory = day_1_build_time_modifier_factory - day_inf_build_time_modifier_factory
 
constexpr float economy::shift_factory = -diff_factory / day_1_derivative_factory
 
constexpr float economy::slope_factory = diff_factory * shift_factory