• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Stack

Status
Not open for further replies.
Level 31
Joined
May 3, 2008
Messages
3,155
I was quite interesting at how stack work out at JASS. I notice JASS shares a lot of similiarity with other programming language.

I was wondering how does it work.

By the way, why some bj are consider to be harmless at new patch? As far as my memory recall, an bj are function to called the natives in order for it to work with GUI (something like that). So it isn't efficient if it was called twice.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Well both a linked-list and an array can be considered "stacks", and they both work similar to how they would in other programming languages.

JASS:
module Stack
    static thistype array stack
    static integer stacksize = 0
    integer stackindex

    method onDestroy takes nothing returns nothing
        set thistype.stacksize = thistype.stacksize - 1
        set thistype.stack[stackindex] = thistype.stack[thistype.stacksize]
        set thistype.stack[stackindex].stackindex = stackindex
    endmethod

    method onCreate takes nothing returns nothing
        set thistype.stack[thistype.stacksize] = this
        set stackindex =thistype.stacksize
        set thistype.stacksize = thistype.stacksize + 1
    endmethod
endmodule
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
so something like an storage with 2 values multiple by 2 each time they stack?

"So something like a storage with two values multiplied by two each time they stack?"

I don't know what you're saying. Are you talking about a stack of data, or a stacking effect within Warcraft III?
 
By the way, why some bj are consider to be harmless at new patch? As far as my memory recall, an bj are function to called the natives in order for it to work with GUI (something like that). So it isn't efficient if it was called twice.

Uhm.. All BJ's are harmless. :) (or well, some might desync but that is only about 1 or 2 of them) They are just slower than executing the native equivalents. Example:
JASS:
function SetUnitAbilityLevelSwapped takes integer abilcode, unit whichUnit, integer level returns integer
    return SetUnitAbilityLevel(whichUnit, abilcode, level)
endfunction
Instead of using that function, just directly use:
JASS:
call SetUnitAbilityLevel(whichUnit,abilcode,level)

Some BJ's are fine though, where they do the tedious things that would be normally annoying to do.
 
Level 31
Joined
May 3, 2008
Messages
3,155
Uhm.. All BJ's are harmless. :) (or well, some might desync but that is only about 1 or 2 of them) They are just slower than executing the native equivalents. Example:

I know majority of them are harmless, but I heard a few which are problematic was fix at the new patch. My question is, which bj they are refer to? Sorry if my question was rather confusing.

They are just slower than executing the native equivalents. Example:

Yeah, I know about that. But pardon me cause I forgot to elaborate further about it.

If I am not mistaken, bj are about 40% slower than native?
 
It depends on the function. Normally, it is just an extra function call. Percentages can mislead sometimes, it is really only a difference of nanoseconds. ;)

I know majority of them are harmless, but I heard a few which are problematic was fix at the new patch. My question is, which bj they are refer to? Sorry if my question was rather confusing.

Which new patch? 1.24e?
- Fixed an exploit rendering buildings non-interactable ("tower hack").
- Fixed an exploit allowing a player to bypass a summon ability's cooldown ("summon/cooldown hack").
- Fixed a client crash related to workers failing to build in an unintended way ("new crash hack").
- Fixed an exploit allowing the Blood Mages's Phoenix to be resurrected instantly ("phoenix hack").
- Fixed a bug allowing players to select an invalid matchmaking race resulting in all the player's units and buildings becoming sheep ("sheep hack").

I'm not sure, I don't think they made any changes with the BJ functions. :)
 
Status
Not open for further replies.
Top