• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[vJASS] Issue with nested loops, possible bug

Status
Not open for further replies.
Level 19
Joined
Aug 16, 2007
Messages
881
I'm currently having a massive issue with a nested loop, see code (some irrelevant code removed):

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.
WC3ScrnShot_080319_233109_02.png

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:
Level 19
Joined
Aug 16, 2007
Messages
881
In what way? I changed my np++ settings so I can use tab == 2 spaces and I have no formatting issues (but maybe that's not what bothers you).
Encoding is wrong and I haven't figured out what I should use; when I copy and paste I get characters as 仰࿆턀ᛔ in my code.

I'm also for some reason unable to modify the vJass language in Notepad++. Tab are not spaces, which gives me a lot of whitespace in world editor after pasting.
 
Level 39
Joined
Feb 27, 2007
Messages
5,013
Encoding is wrong and I haven't figured out what I should use; when I copy and paste I get characters as 仰࿆턀ᛔ in my code.
If you paste into a trigger with text you get this encoding. If you paste into a blank trigger it comes out correct. I delete the whole trigger and paste, no problems.
I'm also for some reason unable to modify the vJass language in Notepad++. Tab are not spaces, which gives me a lot of whitespace in world editor after pasting.
I changed this in the main np++ format settings, not in vJASS language settings. Google it if you can’t find it.
 
Status
Not open for further replies.
Top