1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[vJASS] Issue with nested loops, possible bug

Discussion in 'Triggers & Scripts' started by lolreported, Aug 3, 2019.

  1. lolreported

    lolreported

    Joined:
    Aug 16, 2007
    Messages:
    750
    Resources:
    12
    Tools:
    1
    Maps:
    5
    Spells:
    6
    Resources:
    12
    I'm currently having a massive issue with a nested loop, see code (some irrelevant code removed):

    Code (vJASS):

    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: Aug 3, 2019
  2. lolreported

    lolreported

    Joined:
    Aug 16, 2007
    Messages:
    750
    Resources:
    12
    Tools:
    1
    Maps:
    5
    Spells:
    6
    Resources:
    12
    ...and just as I posted this I saw the issue.

    set cY = cY + cY
    and
    set cX = cX + cX


    I love the World Editor text editor with 0 syntax highlight...
     
  3. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,077
    Resources:
    0
    Resources:
    0
    I would suggest either use a separate editor for coding, or use old newgen editor.
     
  4. lolreported

    lolreported

    Joined:
    Aug 16, 2007
    Messages:
    750
    Resources:
    12
    Tools:
    1
    Maps:
    5
    Spells:
    6
    Resources:
    12
    I do have a vJASS add-on for Notepad++, but I rarely use it as formatting becomes an issue. Guess using another world editor with syntax highlight could be a good idea and avoid silly mistakes like these, thanks. :)
     
  5. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,040
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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).
     
  6. lolreported

    lolreported

    Joined:
    Aug 16, 2007
    Messages:
    750
    Resources:
    12
    Tools:
    1
    Maps:
    5
    Spells:
    6
    Resources:
    12
    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.
     
  7. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,040
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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 changed this in the main np++ format settings, not in vJASS language settings. Google it if you can’t find it.