Commit 780438d3 authored by Max Maton's avatar Max Maton

Log less if not explicitly enabled

Fixes #1
parent f30b772b
Pipeline #80070667 passed with stage
in 1 minute and 1 second
......@@ -18,6 +18,7 @@ class EconomyManager {
gridSize = 32;
minPopularity = 3000;
populationMultiplier = 10;
reservePopulation = 0;
function Initialize() {
if (isInitialized)
......@@ -65,7 +66,8 @@ class EconomyManager {
foreach(i, industryId in gridIndustries[grid]) {
local destPoints = _getIndustryEntrypoints(GSIndustry.GetLocation(industryId));
if (destPoints.len() == 0) {
GSLog.Info("Unable to find industry entry points.");
if (GSController.GetSetting("log_level") >= 2)
GSLog.Warning("Unable to find industry entry points.");
break;
}
......@@ -188,8 +190,10 @@ class EconomyManager {
// Grow one of the cities in this grid
local towns = gridTowns[gridId];
yield "Expanding " + gridId;
GSTown.ExpandTown(towns[GSBase.RandRange(towns.len())], 1)
local chosenTown = towns[GSBase.RandRange(towns.len())];
GSTown.ExpandTown(chosenTown, 1)
foreach(output in _reducePopulation(10)) { yield output; }
GSLog.Info("Moving 10 people to " + GSTown.GetName(chosenTown));
continue;
}
......@@ -203,6 +207,7 @@ class EconomyManager {
local offset = GSMap.GetTileIndex(GSBase.RandRange(gridSize), GSBase.RandRange(gridSize));
pos = gridId + offset;
success = GSTown.FoundTown(pos, GSTown.TOWN_SIZE_SMALL, false, GSTown.ROAD_LAYOUT_BETTER_ROADS, null)
GSLog.Info("Creating new town with a migration of 150");
if (success)
break;
}
......@@ -217,7 +222,7 @@ class EconomyManager {
foreach(_, industryId in gridIndustries[gridId]) {
local destPoints = _getIndustryEntrypoints(GSIndustry.GetLocation(industryId));
if (destPoints.len() == 0) {
GSLog.Info("Unable to find industry entry points.");
GSLog.Warning("Unable to find industry entry points.");
break;
}
......@@ -231,10 +236,15 @@ class EconomyManager {
}
function _reducePopulation(amount) {
local reserveUsed = min(reservePopulation, amount);
amount -= reserveUsed;
reservePopulation -= reserveUsed;
while (amount > 0) {
amount -= _removeBuilding();
yield "Population removal, " + amount + " left"
}
reservePopulation -= amount;
}
function _removeBuilding() {
......@@ -252,8 +262,10 @@ class EconomyManager {
}
}
if (currentChoice == null)
return 10000; // No valid towns found, assume people are immigrating :)
if (currentChoice == null) {
GSLog.Info("People are starting to immigrate.");
return 100; // No valid towns found, assume people are immigrating :)
}
local prevPop = GSTown.GetPopulation(currentChoice);
......@@ -278,7 +290,6 @@ class EconomyManager {
foreach(tileId, _ in tiles) {
local result = GSTile.DemolishTile(tileId);
GSLog.Info("demolish " + tileId + " = " + result + " ... " + GSError.GetLastErrorString());
local delta = prevPop - GSTown.GetPopulation(currentChoice);
if (delta > 0)
return delta;
......@@ -321,7 +332,8 @@ class EconomyManager {
}
if (path == null) {
GSLog.Info("Path failed from " + from + ", to " + to + ".");
if (GSController.GetSetting("log_level") >= 2)
GSLog.Info("Path failed from " + from + ", to " + to + ".");
}
while (path != null) {
......
......@@ -12,7 +12,12 @@ class MigrationScript extends GSController {
}
function Start();
function FindSomethingToDo()
function FindSomethingToDo();
function Save() {
return {
unused = 0,
}
}
function QueueAction(func);
}
......@@ -34,7 +39,7 @@ function MigrationScript::Start() {
local output = resume workItem;
if (workItem.getstatus() != "dead")
workQueue.push(workItem)
if (output != null)
if (output != null && MigrationScript.GetSetting("log_level") == 3)
GSLog.Info(this.GetTick() + "(" + this.GetOpsTillSuspend() + "): " + output)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment