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

Patch 1.23b, JASS, GUI, and Gaming

Status
Not open for further replies.
Level 40
Joined
Dec 14, 2005
Messages
10,532
For those of you who haven't seen, some very important changes are happening recently with JASSing in WarCraft which will break backwards compatibility by fixing the return bug. To compensate, GetHandleId (H2I) and StringHash (s2i) have been added, as well as a host of new fairly fast hashtable lookup functions which support most handle types.

GUI has included these natives as well, meaning multiinstanceability should be much easier to achieve in future GUI scripting.

For those of you who do not code but are avid gamers, this could mean a lot of older JASSed maps which are no longer maintained will break as of a full 1.23b release.

Finally, this return bug fix will remove all threat of the exploit which has been circulating recently with regards to infected maps.

The full post can be found here.

EDIT:
JASS:
type hashtable				extends     handle


native  GetHandleId			takes handle h returns integer

native  StringHash			takes string s returns integer



native  InitHashtable			takes nothing returns hashtable



native  SaveInteger			takes hashtable table, integer parentKey, integer childKey, integer value returns nothing

native  SaveReal			takes hashtable table, integer parentKey, integer childKey, real value returns nothing

native  SaveBoolean			takes hashtable table, integer parentKey, integer childKey, boolean value returns nothing

native  SaveStr				takes hashtable table, integer parentKey, integer childKey, string value returns boolean

native  SavePlayerHandle		takes hashtable table, integer parentKey, integer childKey, player whichPlayer returns boolean

native  SaveWidgetHandle		takes hashtable table, integer parentKey, integer childKey, widget whichWidget returns boolean

native  SaveDestructableHandle		takes hashtable table, integer parentKey, integer childKey, destructable whichDestructable returns boolean

native  SaveItemHandle			takes hashtable table, integer parentKey, integer childKey, item whichItem returns boolean

native  SaveUnitHandle			takes hashtable table, integer parentKey, integer childKey, unit whichUnit returns boolean

native  SaveAbilityHandle		takes hashtable table, integer parentKey, integer childKey, ability whichAbility returns boolean

native  SaveTimerHandle			takes hashtable table, integer parentKey, integer childKey, timer whichTimer returns boolean

native  SaveTriggerHandle		takes hashtable table, integer parentKey, integer childKey, trigger whichTrigger returns boolean

native  SaveTriggerConditionHandle	takes hashtable table, integer parentKey, integer childKey, triggercondition whichTriggercondition returns boolean

native  SaveTriggerActionHandle		takes hashtable table, integer parentKey, integer childKey, triggeraction whichTriggeraction returns boolean

native  SaveTriggerEventHandle		takes hashtable table, integer parentKey, integer childKey, event whichEvent returns boolean

native  SaveForceHandle			takes hashtable table, integer parentKey, integer childKey, force whichForce returns boolean

native  SaveGroupHandle			takes hashtable table, integer parentKey, integer childKey, group whichGroup returns boolean

native  SaveLocationHandle		takes hashtable table, integer parentKey, integer childKey, location whichLocation returns boolean

native  SaveRectHandle			takes hashtable table, integer parentKey, integer childKey, rect whichRect returns boolean

native  SaveBooleanExprHandle		takes hashtable table, integer parentKey, integer childKey, boolexpr whichBoolexpr returns boolean

native  SaveSoundHandle			takes hashtable table, integer parentKey, integer childKey, sound whichSound returns boolean

native  SaveEffectHandle		takes hashtable table, integer parentKey, integer childKey, effect whichEffect returns boolean

native  SaveUnitPoolHandle		takes hashtable table, integer parentKey, integer childKey, unitpool whichUnitpool returns boolean

native  SaveItemPoolHandle		takes hashtable table, integer parentKey, integer childKey, itempool whichItempool returns boolean

native  SaveQuestHandle			takes hashtable table, integer parentKey, integer childKey, quest whichQuest returns boolean

native  SaveQuestItemHandle		takes hashtable table, integer parentKey, integer childKey, questitem whichQuestitem returns boolean

native  SaveDefeatConditionHandle	takes hashtable table, integer parentKey, integer childKey, defeatcondition whichDefeatcondition returns boolean

native  SaveTimerDialogHandle		takes hashtable table, integer parentKey, integer childKey, timerdialog whichTimerdialog returns boolean

native  SaveLeaderboardHandle		takes hashtable table, integer parentKey, integer childKey, leaderboard whichLeaderboard returns boolean

native  SaveMultiboardHandle		takes hashtable table, integer parentKey, integer childKey, multiboard whichMultiboard returns boolean

native  SaveMultiboardItemHandle	takes hashtable table, integer parentKey, integer childKey, multiboarditem whichMultiboarditem returns boolean

native  SaveTrackableHandle		takes hashtable table, integer parentKey, integer childKey, trackable whichTrackable returns boolean

native  SaveDialogHandle		takes hashtable table, integer parentKey, integer childKey, dialog whichDialog returns boolean

native  SaveButtonHandle		takes hashtable table, integer parentKey, integer childKey, button whichButton returns boolean

native  SaveTextTagHandle		takes hashtable table, integer parentKey, integer childKey, texttag whichTexttag returns boolean

native  SaveLightningHandle		takes hashtable table, integer parentKey, integer childKey, lightning whichLightning returns boolean

native  SaveImageHandle			takes hashtable table, integer parentKey, integer childKey, image whichImage returns boolean

native  SaveUbersplatHandle		takes hashtable table, integer parentKey, integer childKey, ubersplat whichUbersplat returns boolean

native  SaveRegionHandle		takes hashtable table, integer parentKey, integer childKey, region whichRegion returns boolean

native  SaveFogStateHandle		takes hashtable table, integer parentKey, integer childKey, fogstate whichFogState returns boolean

native  SaveFogModifierHandle		takes hashtable table, integer parentKey, integer childKey, fogmodifier whichFogModifier returns boolean



native  LoadInteger			takes hashtable table, integer parentKey, integer childKey returns integer

native  LoadReal			takes hashtable table, integer parentKey, integer childKey returns real

native  LoadBoolean			takes hashtable table, integer parentKey, integer childKey returns boolean

native  LoadStr				takes hashtable table, integer parentKey, integer childKey returns string

native  LoadPlayerHandle		takes hashtable table, integer parentKey, integer childKey returns player

native  LoadWidgetHandle		takes hashtable table, integer parentKey, integer childKey returns widget

native  LoadDestructableHandle		takes hashtable table, integer parentKey, integer childKey returns destructable

native  LoadItemHandle			takes hashtable table, integer parentKey, integer childKey returns item

native  LoadUnitHandle			takes hashtable table, integer parentKey, integer childKey returns unit

native  LoadAbilityHandle		takes hashtable table, integer parentKey, integer childKey returns ability

native  LoadTimerHandle			takes hashtable table, integer parentKey, integer childKey returns timer

native  LoadTriggerHandle		takes hashtable table, integer parentKey, integer childKey returns trigger

native  LoadTriggerConditionHandle	takes hashtable table, integer parentKey, integer childKey returns triggercondition

native  LoadTriggerActionHandle		takes hashtable table, integer parentKey, integer childKey returns triggeraction

native  LoadTriggerEventHandle		takes hashtable table, integer parentKey, integer childKey returns event

native  LoadForceHandle			takes hashtable table, integer parentKey, integer childKey returns force

native  LoadGroupHandle			takes hashtable table, integer parentKey, integer childKey returns group

native  LoadLocationHandle		takes hashtable table, integer parentKey, integer childKey returns location

native  LoadRectHandle			takes hashtable table, integer parentKey, integer childKey returns rect

native  LoadBooleanExprHandle		takes hashtable table, integer parentKey, integer childKey returns boolexpr

native  LoadSoundHandle			takes hashtable table, integer parentKey, integer childKey returns sound

native  LoadEffectHandle		takes hashtable table, integer parentKey, integer childKey returns effect

native  LoadUnitPoolHandle		takes hashtable table, integer parentKey, integer childKey returns unitpool

native  LoadItemPoolHandle		takes hashtable table, integer parentKey, integer childKey returns itempool

native  LoadQuestHandle			takes hashtable table, integer parentKey, integer childKey returns quest

native  LoadQuestItemHandle		takes hashtable table, integer parentKey, integer childKey returns questitem

native  LoadDefeatConditionHandle	takes hashtable table, integer parentKey, integer childKey returns defeatcondition

native  LoadTimerDialogHandle		takes hashtable table, integer parentKey, integer childKey returns timerdialog

native  LoadLeaderboardHandle		takes hashtable table, integer parentKey, integer childKey returns leaderboard

native  LoadMultiboardHandle		takes hashtable table, integer parentKey, integer childKey returns multiboard

native  LoadMultiboardItemHandle	takes hashtable table, integer parentKey, integer childKey returns multiboarditem

native  LoadTrackableHandle		takes hashtable table, integer parentKey, integer childKey returns trackable

native  LoadDialogHandle		takes hashtable table, integer parentKey, integer childKey returns dialog

native  LoadButtonHandle		takes hashtable table, integer parentKey, integer childKey returns button

native  LoadTextTagHandle		takes hashtable table, integer parentKey, integer childKey returns texttag

native  LoadLightningHandle		takes hashtable table, integer parentKey, integer childKey returns lightning

native  LoadImageHandle			takes hashtable table, integer parentKey, integer childKey returns image

native  LoadUbersplatHandle		takes hashtable table, integer parentKey, integer childKey returns ubersplat

native  LoadRegionHandle		takes hashtable table, integer parentKey, integer childKey returns region

native  LoadFogStateHandle		takes hashtable table, integer parentKey, integer childKey returns fogstate

native  LoadFogModifierHandle		takes hashtable table, integer parentKey, integer childKey returns fogmodifier



native  HaveSavedInteger		takes hashtable table, integer parentKey, integer childKey returns boolean

native  HaveSavedReal			takes hashtable table, integer parentKey, integer childKey returns boolean

native  HaveSavedBoolean		takes hashtable table, integer parentKey, integer childKey returns boolean

native  HaveSavedString			takes hashtable table, integer parentKey, integer childKey returns boolean

native  HaveSavedHandle			takes hashtable table, integer parentKey, integer childKey returns boolean



native  RemoveSavedInteger		takes hashtable table, integer parentKey, integer childKey returns nothing

native  RemoveSavedReal			takes hashtable table, integer parentKey, integer childKey returns nothing

native  RemoveSavedBoolean		takes hashtable table, integer parentKey, integer childKey returns nothing

native  RemoveSavedString		takes hashtable table, integer parentKey, integer childKey returns nothing

native  RemoveSavedHandle		takes hashtable table, integer parentKey, integer childKey returns nothing



native  FlushParentHashtable		takes hashtable table returns nothing

native  FlushChildHashtable		takes hashtable table, integer parentKey returns nothing

EDIT2: A lot of people have been asking about the return bug and its use, so here's an explanation:

In the old JASS compiler, a function with multiple returns was only type-safe on the last return. That is to say

JASS:
function A takes handle h returns integer
    return h
endfunction

Would break, as h is not an integer. However,

JASS:
function B takes handle h returns integer
    return h
    return 0
endfunction

Would compile fine, as 0 is an integer and only the last return is type-safe. As functions exit after they hit a return, this allowed JASSers to "convert" types, such as getting an integer index of a handle via the above function B (called H2I).

However, this could also be exploited with functions to convert code to and from integers, allowing people to write and execute arbitrary bytecode. As a side effect, you could do a buffer overflow attack on the VM, allowing arbitrary machine code to be executed, obviously posing a significant security threat.

Rather than fixing the buffer overflow problem, Blizzard decided to instead fix the return bug. This may seem minor, but the return bug was key to attaching information to objects; you could get an object's ID via H2I and then use a gamecache to store things to it. Additionally, you could also pass around objects as integers and convert them back via a reverse I2H function.

As a solution for the demand for this kind of function but still feeling the need to close the return bug, Blizzard introduced the hashtables and StringHash/GetHandleId functions above. While for most things they will suffice or even be better, this means that all maps using the old system need to be recoded to support them or they will not work.


EDIT3: The adventure continues.

The return bug is still out there, and is exploitable by a simple change. Hopefully Blizzard will either fix the buffer overflow attack or just fix the return bug properly this time.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
Tested hashes out. So people know they basically work like gamecaches did with handlevars, but this time you just have to pass them integers. The natives for string and integer conversion do exactly what they always have with the type casting bug.

Still have to check if it is leak free though.
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
That was both good and bad.
Many spells use the H2I function, and now all of them need to switch to GetHandleId().
But since it's a native it might be faster than the original H2I.
 
Wait can someone clarify what the "return bug" means?

That information is pretty critical to me. I may be using it without realizing.

Typecasting.

JASS:
function h2i takes handle h returns integer
    return h
    return 0
endfunction

That used to convert a handle to an integer, it could be used with any types.

If you have something like that in your map, change it.
 
Level 8
Joined
Aug 6, 2008
Messages
451
Probably 80% of jassers have/use that function
.

More like everybody expect Jesus4Lyf..

Well, this is pretty good news for GUI users I guess..
We are gonna get Table 3.0 which uses hashtable natives and is fast.

Its just sad that it breakes nearly all Jass maps, spells and systems.
 
Level 8
Joined
Aug 6, 2008
Messages
451
Well, its sad that it will indeed break many maps.

Its not problem for those maps which are still updated, but many old classics will be lost forever.
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
I am kinda confused over the Return bug. It is the bug that you return a different 'type' (integer instead of handle) but it still works?

And does hashtable work as gamecache, over games? Like in Campaigns, you transfer data with GameCache, does this also work with Hashtable? And does it maybe also work in MP this time? =O,, cuz that would be awesome! Then you could save Mutli Player data in HashTable =O

Is it already updated or it still needs to be updated?

@ Anachron: They probably just changed some GUI functions, by replacing their BJ function with a native,,
 
Level 9
Joined
May 10, 2009
Messages
542
...With JASS functions, which does not help newbs to WE, semi-newbs, or those confused by JASS and does use JASS sometimes when stated in a tutorial (me, Slaydon, etc)
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Anyone knows some other problems? And how are you able to use natives in GUI?
How not? AFAIK a few GUI actions already directly used natives. And EGUI doesn't modify anything to world edit, it only changes GUI to be using natives.

And does hashtable work as gamecache, over games? Like in Campaigns, you transfer data with GameCache, does this also work with Hashtable? And does it maybe also work in MP this time? =O,, cuz that would be awesome! Then you could save Mutli Player data in HashTable =O
Ofcourse not. hashtable is not a replacement for the gamecache. It just allows people to do what they've been doing with the gamecache for years now but natively supported without bugs.

...With JASS functions, which does not help newbs to WE, semi-newbs, or those confused by JASS and does use JASS sometimes when stated in a tutorial (me, Slaydon, etc)
So? Since they're finally making some changes to WE, they could add GUI support later. Besides, for jass users not a lot changes. Instead of having to abuse bugs and slower systems, they finally added native support which should have been done a lot earlier...

I wanna kill some blizzard employees.
Why? For breaking many jass maps or for not implementing hashtables natively a lot earlier?

All handle objects saved or removed from a hashtable are automatically reference-counted (with the exception of TextTag, Lightning, Image, Ubersplat, and FogState). This allows handle objects to be saved in the hashtable without risk of the object’s being prematurely memory freed. The reference counts are updated when an object is either added to, flushed, or overwritten in a hashtable.
Does this mean they're also considering to fix the other reference count bugs?
 
How not? AFAIK a few GUI actions already directly used natives. And EGUI doesn't modify anything to world edit, it only changes GUI to be using natives.
Ah good to know. But its to late, I already am a Jasser.


Ofcourse not. hashtable is not a replacement for the gamecache. It just allows people to do what they've been doing with the gamecache for years now but natively supported without bugs.
Not that they could've done this years earlier.
So? Since they're finally making some changes to WE, they could add GUI support later. Besides, for jass users not a lot changes. Instead of having to abuse bugs and slower systems, they finally added native support which should have been done a lot earlier...
So true man. QTF

Why? For breaking many jass maps or for not implementing hashtables natively a lot earlier?
Implementing hashtables.

Does this mean they're also considering to fix the other reference count bugs?
Would be so lovely. Vex ftw
 
Level 14
Joined
Nov 18, 2007
Messages
816
Why? For breaking many jass maps or for not implementing hashtables natively a lot earlier?
For breaking backwards compat, fixing unrelated bugs (Pipedream said that the problem was caused by a buffer overflow, which i think is harder to fix but a LOT cleaner), and not providing full workarounds for the problems theyve created (like providing a function for CodeToInt, BooleanToInt and RealToInt).
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
May I remind you that these hash tables are usable in GUI...
Thus if I see any more shit complex GUI spells for MUI which do not use hashes, I will probably have to ignore them as they are over complicated now.

Anyway, they work beautifully and efficently. I still have to check for leaks though. Anyway, you GUI spell makers will absoulty love them, as they allows for easy MUI spells. Also the H2I function is now part of GUI, so remember to use it.
 
Level 6
Joined
Sep 17, 2004
Messages
277
I'm glad they are finally addressing the exploit problem. That had me worried. How long do you think it'll be before battle.net is cleaned up of possible infectious maps?
 
Level 11
Joined
Mar 6, 2008
Messages
898
hiho,

i think the new patch is great.
well when the map makers have to recode too much,
i could lost Guilds of Hyppos RPG,
because i use the return bug nearly everywhere in the map,
but i can life with it...

well finally the new option will be better than the handle systems, leak free and also faster.^^

but what will happen to all the dota nerds? xD

does icefrog also uses the returnbug in his map!?
that would be very evil. XD

Robbepop
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
BUG REPORT - It seems that the native "HaveSavedReal" is broken and does nothing. I tried using it to test if a real entry existed and all it returned was false, no matter what index it was presented with, even when a real was most clearly present. I tried other natives and none of them return true for a real index. Thus I have come to the conclusion it is broken and does not work.

This bug is a real pain as flushing reals and integers does not remove their value. Thus the only way to tell if a real or integer does not exist is by setting it to 0 after use so that it looks unused. Blizzard really fucked up this one. On the other hand, the "HaveSavedHandle" works perfectly, and returns false on flushed handles, returns true when a handle is present and returns false on an empty location. I do so hope these bugs are fixed by the time it is mandatory.

Fixing the reference bugs for locals would be nice as well as allowing strings to be recycled. I am sure this would boost map performance by quite a bit.
 
The bug still exists..

JASS:
    private function C2I2 takes code c returns integer
        return c
        call DoNothing()
        return 0
    endfunction
    
    function C2I takes code c returns integer
        return S2I(I2S(C2I2(c)))
    endfunction
    
    private function I2CH takes integer i returns code
        return i
        call DoNothing()
        return null
    endfunction

    private function C2C takes code c returns code
        return c
        call DoNothing()
        return null
    endfunction
    
    function I2C takes integer i returns code
        return C2C(I2CH(i))
        call DoNothing()
        return null
    endfunction
 
Status
Not open for further replies.
Top