• 🏆 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!

about the index 8191 of an array and saved game

Status
Not open for further replies.
Level 17
Joined
Apr 27, 2008
Messages
2,455
I'm just wondering if this also crash a saved game.

Just save your map with this script, start the map, save the game (the local variable will already be dead) and then try to load the saved game.

JASS:
scope Test initializer init

    private function init takes nothing returns nothing
        local integer array tab
        set tab[8191] = 1
    endfunction

endscope

Anyone would like to test it ?
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Didn't crash.

EDIT: attached map+savefile (unzip)
 

Attachments

  • saveTest.w3m
    10.4 KB · Views: 66
  • savegame.zip
    179 KB · Views: 51
Level 17
Joined
Apr 27, 2008
Messages
2,455
Ok that makes sense.

And what about that one ?

JASS:
scope Test initializer init

    private function init takes nothing returns nothing
        local unit array tab
        set tab[8191] = CreateUnit(Player(0),'hpea',0,0,0)
        // call RemoveUnit(tab[8191])
        // there will be a "leak", so maybe it could still crash
    endfunction

endscope
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Didn't crash;
Test A - create unit
Test B - create unit - remove unit

attached map + savedata (zipped again)
 

Attachments

  • 8191_array_test.w3m
    11.8 KB · Views: 44
  • savegame.zip
    361.2 KB · Views: 44
Level 17
Joined
Apr 27, 2008
Messages
2,455
Thx for the tests.

Now, to keep on subject, let's create a vJass resource.

JASS:
library SaveHandler initializer init

    globals
        private integer I = 0
    endglobals

    function HandleSaveForPlayer takes player which_player, boolean enable returns nothing
        if GetLocalPlayer() == whichPlayer then
            if enable then
                set I = 0
            else
                set I = 8191
            endif
        endif
    endfunction

    function HandleSave takes boolean enable returns nothing
        if enable then
            set I = 0
        else
            set I = 8191
        endif
    endfunction

    private function init takes nothing returns nothing
        local boolean array tab
        set tab[I] = true
        call TriggerSleepAction(0)
        call TriggerExecute(GetTriggeringTrigger()) // not sure about that one, don't remember how the init is generated in jass, maybe ExecuteFunc instead ?
    endfunction

endlibrary
Ofc, you can also create a trigger/trigger action inside the vJass initializer and then you will be able to use TriggerExecute, regardless how vJass initializers are created in jass.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
I don't know how to test that one? Do I run it on initialization? The trigger execute shouldn't be needed, I'm also rusty at vjass so I'm not really sure.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Troll-Brain wants to test the 8191th index of a local array, he must be looking for a bug. I don't know how to test for the bug though.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Oh I see...

EDIT: the map + screenshot
attachment.php


Nothing new, since this was found out long ago. I wonder why he needed to test it though.
 

Attachments

  • trolololol.w3m
    12.1 KB · Views: 45
  • output.JPG
    output.JPG
    17.6 KB · Views: 190
Level 17
Joined
Apr 27, 2008
Messages
2,455
Nothing new indeed, i was not sure about the locals variables when they are "deleted", that's all.
I thought the point of the library was obvious, allow a player to save when you (the map maker) want it, you know checkpoints, that sort of stuff.

Example, you want to not allow the save for all players :

call HandleSave(false)

Now, you want them to allow save :

call HandleSave(true).

Ofc it will not be instant because of the TriggerSleepAction, but it's needed, because we need to use a local and not a global variable, else the save disabling would be permanent.

Or maybe if you give the "null" type of the index 8191 of a global array variable it won't crash on loading of a saved game ?

Now it's not something really useful, i just have fun :)

Also instead of HandleSave, EnableSave is probably a better name.

I know TriggerHappy's solution, and yes it's much more neat.
But i don't think it will work if you have already a dialog displayed, if it also work then yes this resource is 100 % useless.
Anyway as said i'm just playing there, nothing serious. I like to do stuff with jass bugs and understand how they work, as simple as that.
Especially now, as they are not going to be fixed, ever.
 
Last edited:
I know TriggerHappy's solution, and yes it's much more neat.
But i don't think it will work if you have already a dialog displayed, if it also work then yes this resource is 100 % useless.
Anyway as said i'm just playing there, nothing serious. I like to do stuff with jass bugs and understand how they work, as simple as that.
Especially now, as they are not going to be fixed, ever.

You can't use the in-game menu when a dialog is being displayed.

EDIT: Oh, if another player saves when you have a dialog open. Let me test.
EDIT 2: The script still works even if another player has a dialog already open.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Eh, never said it was useless, it could be an alternative, a very harsh one at that. TriggerHappy's solution works by not allowing you to save, your version allows one to save, but doesn't allow you to load the game you saved.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Well, i prefer a transparent way, like TriggerHappy's solution.
Plus, in a multiplayer game, saving can cause some lag.

But if it's somewhat useful, maybe TriggerHappy could include this in his library, vJass is enough powerfull to support both ways within the same library, and then let the map maker choice what he prefers.
Thx to "static if" and constant boolean/integer.

I don't think it worths a library alone, your thoughts about that guys ?
 
Status
Not open for further replies.
Top