From 2931886438c6c0739a27dca3d9283ebab9ce4ef6 Mon Sep 17 00:00:00 2001 From: Julius Michaelis Date: Mon, 8 Jan 2018 23:12:49 +0100 Subject: [PATCH] Limit the number of times Cloud->Place retries. Initialization did not terminate in planet/System.ocg/Template.ocg/DefaultWorld.ocs/. --- planet/Objects.ocd/Environment.ocd/Cloud.ocd/Script.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/planet/Objects.ocd/Environment.ocd/Cloud.ocd/Script.c b/planet/Objects.ocd/Environment.ocd/Cloud.ocd/Script.c index ab71ef095..215d8ec3e 100644 --- a/planet/Objects.ocd/Environment.ocd/Cloud.ocd/Script.c +++ b/planet/Objects.ocd/Environment.ocd/Cloud.ocd/Script.c @@ -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.