Not sure if this should go here or in the AI thread, but this is opened already so...
So 2 things, first and most importantly I managed to freeze/cause heavy and continuous lag in OpenTTD with my GS using this new function. It works ok for small maps but on a 1024 x 1024 the game becomes unresponsive. This is the function in my GS which is doing this, let me know if the whole GS will be easier to test:
Code: Select all
// Function call to build towns
function IndustryConstructor::BuildTown() {
// Check GS continue, to exit
if(CONTINUE_GS == false) return;
// Display status msg
Log.Info("+==============================+", Log.LVL_INFO);
Log.Info("Building towns...", Log.LVL_INFO);
// Check initiaized
if (this.INIT_PERFORMED == false){
// Display error msg
Log.Error(">IndustryConstructor.BuildTown: Script uninitialized!", Log.LVL_INFO);
return;
}
// Loop for number of towns modified by map size, not including initial 1
local MAX_TOWNS = GSController.GetSetting("DENSITY_TOWN_TOTAL") * MAP_SCALE;
local CITY_COUNT = 0;
for(local i = 1; i < MAX_TOWNS; i++){
// Random build
local BUILD_TRIES = 2000;
local TILE_ID;
local TOWN_SIZE;
local IS_CITY = false;
// Loop until correct tile
while(BUILD_TRIES > 0){
// Get a random tile
TILE_ID = Tile.GetRandomTile();
// Get a random size
TOWN_SIZE = GSBase.RandRange(4);
// Set city
if(CITY_COUNT < GSGameSettings.GetValue("larger_towns"))
{
IS_CITY = true;
CITY_COUNT++;
}
local BUILT_TOWN = GSTown.FoundTown(TILE_ID, TOWN_SIZE, IS_CITY, GSGameSettings.GetValue("town_layout"), null);
// Try build
if(BUILT_TOWN == true){
// Multiply size if city
if(IS_CITY == true)
{
// - Get town id
local TOWN_ID = GSTile.GetTownAuthority(TILE_ID);
// - Get house count
local TOWN_HOUSES = GSTown.GetHouseCount(TOWN_ID);
// Loop till size
for(local j = 0; j < GSGameSettings.GetValue("initial_city_size"); j++)
GSTown.ExpandTown(TOWN_ID, TOWN_HOUSES);
}
break;
}
BUILD_TRIES--;
}
// Display error msg
if(BUILD_TRIES == 0)
Log.Error(">IndustryConstructor.BuildTown: Failed to build town!", Log.LVL_INFO);
}
// Display status msg
local MAP_TOWNS = GSTown.GetTownCount();
Log.Info("Built " + (MAP_TOWNS - CITY_COUNT) + " towns and " + CITY_COUNT + " cities, for a total of " +
MAP_TOWNS + " / " + MAX_TOWNS, Log.LVL_INFO);
}
Yes I know there is lots of inefficient code, but this was just a test

Also I am using a clean version of r25785.
Secondly, calling this function (specifically the GSTown.FoundTown) after map generation causes the GS to "skip" its 2500 tick quota...why is this?