Skip to content

Commit

Permalink
Change: Optimized save/load functions (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
F1rrel authored May 12, 2024
1 parent a596448 commit 30ca3f2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion info.nut
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MainClass extends GSInfo
function GetURL() { return "https://www.tt-forums.net/viewtopic.php?f=65&t=87052"; }
function GetVersion() { return SELF_VERSION; }
function GetDate() { return SELF_DATE; }
function GetAPIVersion() { return "1.10"; }
function GetAPIVersion() { return "12"; }
function MinVersionToLoad() { return SELF_MINLOADVERSION; }
function CreateInstance() { return "MainClass"; }
function GetSettings() {
Expand Down
1 change: 1 addition & 0 deletions main.nut
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ function MainClass::Init()
this.towns = this.CreateTownList();
if (this.towns.len() > SELF_MAX_TOWNS)
return InitError.TOWN_NUMBER;
Log.Info("Setup " + this.towns.len() + " towns", Log.LVL_INFO);

// Run industry stabilizer
Log.Info("Prospecting raw industries ... (can take a while on large maps)", Log.LVL_INFO);
Expand Down
10 changes: 4 additions & 6 deletions town.nut
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ class GoalTown
this.town_supplied_cat = ::TownDataTable[this.id].town_supplied_cat;
this.town_stockpiled_cat = ::TownDataTable[this.id].town_stockpiled_cat;
this.tgr_array = ::TownDataTable[this.id].tgr_array;
this.limit_transported = (::TownDataTable[this.id].limit_transported_upper + 0x7FFFFFFF << 32) | (::TownDataTable[this.id].limit_transported_lower + 0X7FFFFFFF);
this.limit_transported = ::TownDataTable[this.id].limit_transported;
this.limit_delay = ::TownDataTable[this.id].limit_delay;
this.cargo_hash = (::TownDataTable[this.id].cargo_hash_upper + 0x7FFFFFFF << 32) | (::TownDataTable[this.id].cargo_hash_lower + 0X7FFFFFFF);
this.cargo_hash = ::TownDataTable[this.id].cargo_hash;
if (::SettingsTable.randomization == Randomization.INDUSTRY_DESC
|| ::SettingsTable.randomization == Randomization.INDUSTRY_ASC)
this.town_cargo_cat = GetCargoCatFromIndustryCat(GetIndustryTable(this.cargo_hash));
Expand Down Expand Up @@ -127,11 +127,9 @@ function GoalTown::SavingTownData()
town_data.town_supplied_cat <- this.town_supplied_cat;
town_data.town_stockpiled_cat <- this.town_stockpiled_cat;
town_data.tgr_array <- this.tgr_array;
town_data.limit_transported_upper <- ((this.limit_transported >> 32) - 0X7FFFFFFF);
town_data.limit_transported_lower <- ((this.limit_transported & 0xFFFFFFFF) - 0X7FFFFFFF);
town_data.limit_transported <- this.limit_transported;
town_data.limit_delay <- this.limit_delay;
town_data.cargo_hash_upper <- ((this.cargo_hash >> 32) - 0X7FFFFFFF);
town_data.cargo_hash_lower <- ((this.cargo_hash & 0xFFFFFFFF) - 0X7FFFFFFF);
town_data.cargo_hash <- this.cargo_hash;
return town_data;
}

Expand Down
2 changes: 1 addition & 1 deletion version.nut
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ SELF_MINLOADVERSION <- 90 // minimum integer version of GS that can load t
SELF_MAJORVERSION <- 9 // main version of the GS, releases with same major version should be saveload compatible
SELF_MINORVERSION <- 3 // minor version of the GS, incremental subreleases of the major version, saveload compatible
SELF_DATE <- "2023-12-03" // release date
SELF_MAX_TOWNS <- 1400 // maximum number of towns that can be successfully saved in this release
SELF_MAX_TOWNS <- 2000 // maximum number of towns that can be successfully saved in this release

0 comments on commit 30ca3f2

Please sign in to comment.