Skip to content

Commit

Permalink
Regions grow (#40)
Browse files Browse the repository at this point in the history
* Move economics after production to check correctly activity

* Remove logs

* Version up

* Do not process non visited

* grow half
  • Loading branch information
artyomtrityak authored Sep 5, 2019
1 parent 53609cd commit 1a36d8b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
9 changes: 8 additions & 1 deletion economy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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?
Expand Down
5 changes: 4 additions & 1 deletion game.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions neworigins/rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
18 changes: 16 additions & 2 deletions runorders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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...");
Expand Down Expand Up @@ -1171,8 +1174,6 @@ void Game::MidProcessTurn()
forlist(&regions) {
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) {
Expand All @@ -1183,6 +1184,19 @@ void Game::MidProcessTurn()
}
}

void Game::ProcessEconomics()
{
if (!(Globals->DYNAMIC_POPULATION || Globals->REGIONS_ECONOMY)) return;

forlist(&regions) {
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()
Expand Down

0 comments on commit 1a36d8b

Please sign in to comment.