• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Can a loop occur more than 8000 times?

Status
Not open for further replies.
Level 12
Joined
Apr 27, 2008
Messages
1,228
Infinite loops are not ones that have more than 8k executions. This is a very varing thing.
Put simply if wc3 executes too much code between frame rendering(i.e. in one function(thread) without triggersleepaction calls) it will just crash. Grimmore has a nice feature war3err which tracks how much code has been executed in between frames and if it is too much, it terminates the code, keeping wc3 stable and telling you where the error is(Reached OP limit in function blah)(this is only for map testing).
There is almost no point in doing that(i<7999) - 8k will do only if the loop is empty(for instance) and it is just simpler not to make infinite/long loops.
 
Last edited:
Infinite loops crash depending on how much memory wc3 uses. Once it's got some certain amount, it crashes. When you infinite loop, you make the processor lag more and more, to the point where it is unberable, and it crashes... so it varies. It is also important WHAT is in the loop, if it is just set i = i + 1 than you'd need MANYMANY loops to crash, if you create unit each time, you won't need more than 10000 loops before crash.
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Infinite loops crash depending on how much memory wc3 uses. Once it's got some certain amount, it crashes. When you infinite loop, you make the processor lag more and more, to the point where it is unberable, and it crashes... so it varies. It is also important WHAT is in the loop, if it is just set i = i + 1 than you'd need MANYMANY loops to crash, if you create unit each time, you won't need more than 10000 loops before crash.

I doubt it. When the OP limit is reached, the thread is halted. When you have a loop creating a unit each time, the OP limit will be reached faster and it still will not crash.
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
An infinite loop creating a new unit each time would crash the game due to excessive units long before the op limit of 300,000 op calls was reached.

I've actually done this. Well, not an infinite loop, but a loop from 1 to 32k creating 1 unit per iteration. Warcraft 3 didn't crash, only a few thousand units were actually created before the OP limit was reached and the thread was halted. Then I've added sleep actions every 1000 iterations and 32K units were created, without any crash. Granted, it was pretty laggy, but that's not to the point.
 
Status
Not open for further replies.
Top