OpenTTD

Tasklist

FS#3124 - Valuating tile list and removing the very tile freezs OpenTTD

Attached to Project: OpenTTD
Opened by LordAzamath (LordAzamath) - Saturday, 15 August 2009, 18:44 GMT
Last edited by Remko Bijker (Rubidium) - Saturday, 15 August 2009, 20:34 GMT
Type Bug
Category Script → NoAI
Status Closed
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version 0.7.2
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

When valuating in a tile list and doing area.RemoveTile(tileID) OpenTTD freezes.

function lordyAI::chooseGrowingCity() /* called from Start*/
{
local townList = AITownList();
townList.Valuate(AITown.GetPopulation);
townList.Sort(AIAbstractList.SORT_BY_VALUE,true);
local townID = townList.Begin();
local townLoc = AITown.GetLocation(townID)
local townRoadTiles = AITileList()
/* create rectangle */
local area = AITileList();
area.AddRectangle(townLoc - AIMap.GetTileIndex(5, 5), townLoc + AIMap.GetTileIndex(5, 5));
area.Valuate(getRoads,area)
}
function lordyAI::getRoads(tileID,area)
{
local boolean = AIRoad.IsRoadTile(tileID)
if (!boolean)
{
area.RemoveTile(tileID) /* this part freezes */
}
return boolean;
}
This task depends upon

Closed by  Remko Bijker (Rubidium)
Saturday, 15 August 2009, 20:34 GMT
Reason for closing:  Fixed
Additional comments about closing:  r17193
Comment by LordAzamath (LordAzamath) - Saturday, 15 August 2009, 19:18 GMT
Added a testing AI which will nicely freeze your OpenTTD.
However, I tested it with just removing the tile inside the valuator and it didn't freeze..

Currently it freezes as you start it. If you comment out line 52 in main.nut, it won't freeze.
Comment by Remko Bijker (Rubidium) - Saturday, 15 August 2009, 19:26 GMT
  • Field changed: Status (New → Confirmed)
The famous... stl doesn't like you removing stuff when it's being iterated.

Loading...