- Joined
- Aug 16, 2007
- Messages
- 884
I'm currently having a massive issue with a nested loop, see code (some irrelevant code removed):
When this function runs the game freezes a couple of seconds and then displays "93635" and the thread crashes.

How is it even possible when it should loop at maximum 15 times?
What am I missing? Is it something the library does in the backend?
JASS:
library JustAnotherLibrary initializer Init
globals
//...
private constant integer PLAYER_MAX_CELLS_ROW = 3 // Max cells up/down
private constant integer PLAYER_MAX_CELLS_COL = 5 // Max cells left/right
//...
endglobals
//... irrelevant code here
private function Init takes nothing returns nothing
local integer i = 0
local integer cX = 0
local integer cY = 0
//...
set battleCellUniqueID = 0
set i = 0
loop
exitwhen(i > 24)
// Player init stuff
if (GetPlayerController(Player(i)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING) then
// Setup player battle cells
set playerBattleAreaX[i] = -450.0 //temp
set playerBattleAreaY[i] = -700.0
set cX = 0
loop
loop
set battleCellUniqueID = battleCellUniqueID + 1
call DisplayTextToPlayer( GetLocalPlayer(), 0, 0, I2S(battleCellUniqueID ) )
//set playerBattleCell[battleCellUniqueID] = PlayerBattleCell.create(battleCellUniqueID, UNIT_CELL_RAW_CODE, i, playerBattleAreaX[i] + (CELL_SIZE * cX), playerBattleAreaY[i] + (CELL_SIZE * cY))
set cY = cY + cY
exitwhen(cY > PLAYER_MAX_CELLS_ROW)
endloop
set cY = 0
set cX = cX + cX
exitwhen(cX > PLAYER_MAX_CELLS_COL)
endloop
endif
set i = i + 1
endloop
endfunction
//...
endlibrary
When this function runs the game freezes a couple of seconds and then displays "93635" and the thread crashes.

How is it even possible when it should loop at maximum 15 times?
PLAYER_MAX_CELLS_ROW * PLAYER_MAX_CELLS_COL = 15
What am I missing? Is it something the library does in the backend?
Last edited: