Skip to content

Commit

Permalink
Fix bug with scenario editor
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkimber committed Jun 14, 2016
1 parent d9f0378 commit 80e5048
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
3 changes: 0 additions & 3 deletions industries.nut
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ class Industries
{
this.AddIndustry(i);
}

// GSLog.Info("(Re-)built industry list for " + industry_list.len() + " industries");

}

function AddIndustry(industry_id)
Expand Down
4 changes: 2 additions & 2 deletions info.nut
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SELF_VERSION <- 8;
SELF_DATE <- "2016-05-22";
SELF_VERSION <- 9;
SELF_DATE <- "2016-06-14";

class VillagesIsVillages extends GSInfo {
function GetAuthor() { return "Timberwolf"; }
Expand Down
4 changes: 3 additions & 1 deletion main.nut
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function VillagesIsVillages::Start()
{
GSLog.Info("Initialising towns");
this.towns = Towns(cargoes);
this.towns.Initialise();
this.towns.UpdateTownList();
}

GSLog.Info("Number of towns managed: " + this.towns.Count());
Expand Down Expand Up @@ -84,6 +84,7 @@ function VillagesIsVillages::Start()
if(this.total_towns_processed >= town_count) {
this.total_towns_processed = 0;
// GSLog.Info("All towns have been processed - sleeping for 10 days");
this.towns.UpdateTownList();
this.Sleep(10 * 74);
}
else
Expand Down Expand Up @@ -125,6 +126,7 @@ function VillagesIsVillages::Load(version, data)

if(data.rawin("towns")) {
townData = data.rawget("towns");

this.towns = Towns(cargoes);
towns.InitialiseWithData(townData);

Expand Down
27 changes: 15 additions & 12 deletions towns.nut
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class Towns
{
town_list = [];
handled_towns = {};
current_town = 0;
cargoes = null;

Expand All @@ -21,6 +22,7 @@ class Towns
local town = Town(t.id, this.cargoes);
town.InitialiseWithSize(t.max_population);
this.town_list.append(town);
this.handled_towns[t.id] <- true;
}
}

Expand All @@ -29,23 +31,14 @@ class Towns
return this.town_list;
}

function Initialise()
{
local towns = GSTownList();

foreach(t, _ in towns)
{
this.AddTown(t);
}

// GSLog.Info("Added " + town_list.len() + " towns.");
}

function AddTown(town_id)
{
if(town_id in this.handled_towns) return;

local town = Town(town_id, this.cargoes);
town.Initialise();
this.town_list.append(town);
this.handled_towns[town_id] <- true;
}

function ProcessNextTown()
Expand All @@ -55,4 +48,14 @@ class Towns

current_town = (current_town + 1) % this.town_list.len();
}

function UpdateTownList()
{
local towns = GSTownList();

foreach(t, _ in towns)
{
this.AddTown(t);
}
}
}

0 comments on commit 80e5048

Please sign in to comment.