Limit the number of times Cloud->Place retries.

Initialization did not terminate in planet/System.ocg/Template.ocg/DefaultWorld.ocs/.
install-platforms
Julius Michaelis 2018-01-08 23:12:49 +01:00
parent 6e52963828
commit 2931886438
1 changed files with 5 additions and 3 deletions

View File

@ -99,20 +99,22 @@ protected func Destruction()
/*-- Definition call interface --*/
// Id call: Creates the indicated number of clouds.
// May fail and will indicate the number of placed clouds.
public func Place(int count)
{
if (this != Cloud)
return;
while (count > 0)
var max_tries = count * 500;
for (var i = 0; i < count && max_tries > 0; max_tries--)
{
var pos;
if ((pos = FindPosInMat("Sky", 0, 0, LandscapeWidth(), LandscapeHeight())) && MaterialDepthCheck(pos[0], pos[1], "Sky", 200))
{
CreateObjectAbove(Cloud, pos[0], pos[1], NO_OWNER);
count--;
i++;
}
}
return;
return i;
}
// Changes the precipitation type of this cloud.