From 1a36d8b5ca6ba249fbb0c759509120970f173f56 Mon Sep 17 00:00:00 2001 From: Artem Trytiak Date: Wed, 4 Sep 2019 23:59:31 -0700 Subject: [PATCH] Regions grow (#40) * Move economics after production to check correctly activity * Remove logs * Version up * Do not process non visited * grow half --- economy.cpp | 9 ++++++++- game.h | 5 ++++- neworigins/rules.cpp | 4 ++-- runorders.cpp | 18 ++++++++++++++++-- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/economy.cpp b/economy.cpp index a4740db2..b5f3a53e 100644 --- a/economy.cpp +++ b/economy.cpp @@ -1337,6 +1337,7 @@ void ARegion::Grow() // / (5 * (long int) ((long int) habitat + 3 * (long int) abs(diff))); if (diff < 0) growpop -= (int) dgrow; if (diff > 0) growpop += (int) dgrow; + /* Awrite(AString("growpop = ") + growpop); Awrite(AString("grow2 = ") + (unsigned int) grow2); @@ -1355,7 +1356,13 @@ void ARegion::Grow() // less growth of towns in DYNAMIC_POPULATION // to balance town creation and population dynamics // through migration - if (Globals->DYNAMIC_POPULATION) tgrowth = tgrowth / 4; + if (Globals->DYNAMIC_POPULATION) { + tgrowth = tgrowth / 4; + } else { + // With roads can increase wages we need to + // reduce settlement growth + tgrowth = tgrowth / 2; + } // Dampen growth curve at high population levels // Ant: maybe this formula could be broken up a bit? // also, is (2 * town->hab - town->pop) correct? diff --git a/game.h b/game.h index 6c704f5d..d9f13e24 100644 --- a/game.h +++ b/game.h @@ -34,7 +34,7 @@ class Game; #include "production.h" #include "object.h" -#define CURRENT_ATL_VER MAKE_ATL_VER(5, 2, 1) +#define CURRENT_ATL_VER MAKE_ATL_VER(5, 2, 2) class OrdersCheck { @@ -470,6 +470,9 @@ class Game void MidProcessTurn(); void PostProcessUnitExtra(ARegion *, Unit *); void PostProcessTurn(); + + // Processing regions grow after production phase + void ProcessEconomics(); // Migration effects for alternate player-driven economy void ProcessMigration(); diff --git a/neworigins/rules.cpp b/neworigins/rules.cpp index 09209eb2..90651b13 100644 --- a/neworigins/rules.cpp +++ b/neworigins/rules.cpp @@ -60,7 +60,7 @@ int allowedTacticiansSize = sizeof(ag) / sizeof(ag[0]); static GameDefs g = { "NewOrigins", // RULESET_NAME - MAKE_ATL_VER( 1, 0, 8 ), // RULESET_VERSION + MAKE_ATL_VER( 1, 0, 9 ), // RULESET_VERSION 8, /* MAX_SPEED */ 7, /* PHASED_MOVE_OFFSET */ @@ -237,7 +237,7 @@ static GameDefs g = { 0, // HARDER_ASSASSINATION 1, // DISPERSE_GATE_NUMBERS 33, // UNDEATH_CONTAGION - 0 // REGIONS_ECONOMY + 1 // REGIONS_ECONOMY }; GameDefs *Globals = &g; diff --git a/runorders.cpp b/runorders.cpp index 2ed3b14e..fba2c972 100644 --- a/runorders.cpp +++ b/runorders.cpp @@ -94,6 +94,9 @@ void Game::RunOrders() RunTeachOrders(); Awrite("Running Month-long Orders..."); RunMonthOrders(); + Awrite("Running Economics..."); + ProcessEconomics(); + Awrite("Running Teleport Orders..."); RunTeleportOrders(); if (Globals->TRANSPORT & GameDefs::ALLOW_TRANSPORT) { Awrite("Running Transport Orders..."); @@ -1171,8 +1174,6 @@ void Game::MidProcessTurn() forlist(®ions) { ARegion *r = (ARegion *)elem; // r->MidTurn(); // Not yet implemented - /* regional population dynamics */ - if (Globals->DYNAMIC_POPULATION || Globals->REGIONS_ECONOMY) r->Grow(); forlist(&r->objects) { Object *o = (Object *)elem; forlist(&o->units) { @@ -1183,6 +1184,19 @@ void Game::MidProcessTurn() } } +void Game::ProcessEconomics() +{ + if (!(Globals->DYNAMIC_POPULATION || Globals->REGIONS_ECONOMY)) return; + + forlist(®ions) { + ARegion *r = (ARegion *)elem; + // Do not process not visited regions + if (!r->visited) continue; + /* regional population dynamics */ + r->Grow(); + } +} + /* Process Migration if DYNAMIC_POPULATION * is set. */ void Game::ProcessMigration()