HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Mac Issue with Faux Handle Vars

09-24-2009, 09:37 PM#1
ShadowDestroyer
Collapse JASS:
/*******************************************************************************************
 Faux Handle Vars
 ----------------
    Do not use these functions for new stuff, it is just not the right thing to do...

    The intention of Faux Handle Vars is to be a patch fix for a map's migration to
  patch 1.24 This library might not cover all uses of handle vars, some of them are just
  impossible with the new rules set in patches 1.23b and 1.24, but they should work for
  most of the cases....

    All of them but the SetHandle*** ones are inline friendly. I follow the interface
  in official Kattana's handle vars from wc3jass.com, if your handle vars functions
  look different, then you were not using handle vars but another thing...

*******************************************************************************************/

//==========================================================================================
library HandleVars initializer init

 globals
    private hashtable ht
 endglobals
 
    // too bad the Handle vars' old functionality forces me to make these things
    // inline-unfriendly
    function SetHandleHandle takes agent subject,  string label, agent value returns nothing
        if(value==null) then
            call RemoveSavedHandle( ht, GetHandleId(subject), StringHash(label))
        else
            call SaveAgentHandle( ht, GetHandleId(subject), StringHash(label), value)
        endif
    endfunction

    function SetHandleInt takes agent subject, string label, integer value returns nothing
        if value==0 then
            call RemoveSavedInteger(ht, GetHandleId(subject), StringHash(label))
        else
            call SaveInteger(ht, GetHandleId(subject), StringHash(label), value)
        endif        
    endfunction

    function SetHandleBoolean takes agent subject, string label, boolean value returns nothing
        if (value == false) then
            call RemoveSavedBoolean(ht, GetHandleId(subject), StringHash(label))
        else
            call SaveBoolean(ht, GetHandleId(subject), StringHash(label), value)
        endif
    endfunction

    function SetHandleReal takes agent subject, string label, real value returns nothing
        if (value == 0.0) then
            call RemoveSavedReal(ht, GetHandleId(subject), StringHash(label))
        else
            call SaveReal(ht, GetHandleId(subject), StringHash(label), value)
        endif
    endfunction

    function SetHandleString takes agent subject, string label, string value returns nothing
        if ((value=="") or (value==null)) then
            call RemoveSavedString(ht, GetHandleId(subject), StringHash(label)) 
        else
            call SaveStr(ht, GetHandleId(subject), StringHash(label), value) //yay for blizz' consistent naming scheme...
        endif
    endfunction

    function GetHandleHandle takes agent subject, string label returns agent
        debug call BJDebugMsg("[debug] What the heck? Why would you call HandleHandle I guess this was caused by a search and replace mistake")
        return null
    endfunction

    // these are inline friendly, ok, maybe they aren't because jasshelper does not recognize
    // GetHandleId as non-state changing. But they will be once I fix jasshelper...

    function GetHandleInt takes agent subject, string label returns integer
        return LoadInteger(ht, GetHandleId(subject), StringHash(label))
    endfunction

    function GetHandleBoolean takes agent subject, string label returns boolean
        return LoadBoolean(ht, GetHandleId(subject), StringHash(label))
    endfunction

    function GetHandleString takes agent subject, string label returns string
        return LoadStr(ht, GetHandleId(subject), StringHash(label))
    endfunction

    function GetHandleReal takes agent subject, string label returns real
        return LoadReal(ht, GetHandleId(subject), StringHash(label))
    endfunction

    // got bored so I now use a textmacro...
    //! textmacro FAUX_HANDLE_VARS_GetHandleHandle takes NAME, TYPE
         function SetHandle$NAME$ takes agent subject,  string label, $TYPE$ value returns nothing
             if(value==null) then
                call RemoveSavedHandle( ht, GetHandleId(subject), StringHash(label))
             else
                call Save$NAME$Handle( ht, GetHandleId(subject), StringHash(label), value)
             endif
         endfunction

         function GetHandle$NAME$ takes agent subject, string label returns $TYPE$
             return Load$NAME$Handle( ht, GetHandleId(subject), StringHash(label))
         endfunction
    //! endtextmacro
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Player","player")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Widget","widget")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Destructable","destructable")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Item","item")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Unit","unit")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Ability","ability")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Timer","timer")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Trigger","trigger")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerCondition","triggercondition")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerAction","triggeraction")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerEvent","event")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Force","force")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Group","group")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Location","location")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Rect","rect")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("BooleanExpr","boolexpr")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Sound","sound")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Effect","effect")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("UnitPool","unitpool")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("ItemPool","itempool")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Quest","quest")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("QuestItem","questitem")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("DefeatCondition","defeatcondition")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TimerDialog","timerdialog")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Leaderboard","leaderboard")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Multiboard","multiboard")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("MultiboardItem","multiboarditem")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Trackable","trackable")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Dialog","dialog")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Button","button")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TextTag","texttag")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Lightning","lightning")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Image","image")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Ubersplat","ubersplat")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Region","region")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("FogState","fogstate")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("FogModifier","fogmodifier")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Hashtable","hashtable")


    function FlushHandleVars takes agent subject returns nothing
        call FlushChildHashtable(ht, GetHandleId(subject))
    endfunction
    function FlushHandleLocals takes agent subject returns nothing
        call FlushHandleVars(subject)
    endfunction


    private function init takes nothing returns nothing
        set ht=InitHashtable()
    endfunction

endlibrary

If this is included in a map, a Mac will NOT be able to run the file. Player slots will not appear.
09-24-2009, 11:05 PM#2
Vexorian
Collapse JASS:
/*******************************************************************************************
 Faux Handle Vars
 ----------------
    Do not use these functions for new stuff, it is just not the right thing to do...

    The intention of Faux Handle Vars is to be a patch fix for a map's migration to
  patch 1.24 This library might not cover all uses of handle vars, some of them are just
  impossible with the new rules set in patches 1.23b and 1.24, but they should work for
  most of the cases....

    All of them but the SetHandle*** ones are inline friendly. I follow the interface
  in official Kattana's handle vars from wc3jass.com, if your handle vars functions
  look different, then you were not using handle vars but another thing...

*******************************************************************************************/

//==========================================================================================
library HandleVars initializer init
 
    // too bad the Handle vars' old functionality forces me to make these things
    // inline-unfriendly
    function SetHandleHandle takes agent subject,  string label, agent value returns nothing
    endfunction

    function SetHandleInt takes agent subject, string label, integer value returns nothing
    endfunction

    function SetHandleBoolean takes agent subject, string label, boolean value returns nothing
    endfunction

    function SetHandleReal takes agent subject, string label, real value returns nothing
    endfunction

    function SetHandleString takes agent subject, string label, string value returns nothing
    endfunction

    function GetHandleHandle takes agent subject, string label returns agent
        return null
    endfunction

    // these are inline friendly, ok, maybe they aren't because jasshelper does not recognize
    // GetHandleId as non-state changing. But they will be once I fix jasshelper...

    function GetHandleInt takes agent subject, string label returns integer
        return 0
    endfunction

    function GetHandleBoolean takes agent subject, string label returns boolean
        return false
    endfunction

    function GetHandleString takes agent subject, string label returns string
        return ""
    endfunction

    function GetHandleReal takes agent subject, string label returns real
        return 0.0
    endfunction

    // got bored so I now use a textmacro...
    //! textmacro FAUX_HANDLE_VARS_GetHandleHandle takes NAME, TYPE
         function SetHandle$NAME$ takes agent subject,  string label, $TYPE$ value returns nothing
         endfunction

         function GetHandle$NAME$ takes agent subject, string label returns $TYPE$
             return null
         endfunction
    //! endtextmacro
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Player","player")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Widget","widget")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Destructable","destructable")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Item","item")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Unit","unit")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Ability","ability")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Timer","timer")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Trigger","trigger")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerCondition","triggercondition")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerAction","triggeraction")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerEvent","event")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Force","force")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Group","group")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Location","location")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Rect","rect")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("BooleanExpr","boolexpr")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Sound","sound")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Effect","effect")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("UnitPool","unitpool")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("ItemPool","itempool")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Quest","quest")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("QuestItem","questitem")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("DefeatCondition","defeatcondition")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TimerDialog","timerdialog")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Leaderboard","leaderboard")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Multiboard","multiboard")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("MultiboardItem","multiboarditem")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Trackable","trackable")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Dialog","dialog")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Button","button")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TextTag","texttag")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Lightning","lightning")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Image","image")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Ubersplat","ubersplat")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Region","region")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("FogState","fogstate")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("FogModifier","fogmodifier")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Hashtable","hashtable")


    function FlushHandleVars takes agent subject returns nothing
    endfunction
    function FlushHandleLocals takes agent subject returns nothing
    endfunction


    private function init takes nothing returns nothing
    endfunction

endlibrary

Try it with this.
09-25-2009, 12:28 AM#3
ShadowDestroyer
No such luck. :(
09-25-2009, 12:43 AM#4
Vexorian
that wasn't supposed to fix it...

You were supposed to explain me what happens after doing that...
09-25-2009, 04:32 AM#5
ShadowDestroyer
What happens to my map?

Well, as far as I can tell, it is acting the same. The maps saves, but will not run on Macs.

Were you wanting me to remake that Blizzard.j file after making those changes? You think the WE crash was pertaining to Faux Handle Vars?
09-25-2009, 01:04 PM#6
Vexorian
Is FauxHandleVars the only vJass library you have in the map?
09-25-2009, 01:36 PM#7
ShadowDestroyer
Yes, Tropical Tag used zero vJass before 4.0. I implemented this to replace the old "Handle Vars" system for compatibility.

If I stick this code in a blank map, it will not run on a Mac.
09-25-2009, 01:40 PM#8
Vexorian
This is non-sense.

Disable the library and put this on the custom script section:
Collapse JASS:
    // too bad the Handle vars' old functionality forces me to make these things
    // inline-unfriendly
    function SetHandleHandle takes agent subject,  string label, agent value returns nothing
    endfunction

    function SetHandleInt takes agent subject, string label, integer value returns nothing
    endfunction

    function SetHandleBoolean takes agent subject, string label, boolean value returns nothing
    endfunction

    function SetHandleReal takes agent subject, string label, real value returns nothing
    endfunction

    function SetHandleString takes agent subject, string label, string value returns nothing
    endfunction

    function GetHandleHandle takes agent subject, string label returns agent
        return null
    endfunction

    // these are inline friendly, ok, maybe they aren't because jasshelper does not recognize
    // GetHandleId as non-state changing. But they will be once I fix jasshelper...

    function GetHandleInt takes agent subject, string label returns integer
        return 0
    endfunction

    function GetHandleBoolean takes agent subject, string label returns boolean
        return false
    endfunction

    function GetHandleString takes agent subject, string label returns string
        return ""
    endfunction

    function GetHandleReal takes agent subject, string label returns real
        return 0.0
    endfunction

    // got bored so I now use a textmacro...
    //! textmacro FAUX_HANDLE_VARS_GetHandleHandle takes NAME, TYPE
         function SetHandle$NAME$ takes agent subject,  string label, $TYPE$ value returns nothing
         endfunction

         function GetHandle$NAME$ takes agent subject, string label returns $TYPE$
             return null
         endfunction
    //! endtextmacro
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Player","player")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Widget","widget")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Destructable","destructable")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Item","item")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Unit","unit")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Ability","ability")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Timer","timer")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Trigger","trigger")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerCondition","triggercondition")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerAction","triggeraction")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerEvent","event")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Force","force")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Group","group")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Location","location")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Rect","rect")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("BooleanExpr","boolexpr")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Sound","sound")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Effect","effect")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("UnitPool","unitpool")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("ItemPool","itempool")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Quest","quest")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("QuestItem","questitem")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("DefeatCondition","defeatcondition")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TimerDialog","timerdialog")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Leaderboard","leaderboard")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Multiboard","multiboard")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("MultiboardItem","multiboarditem")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Trackable","trackable")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Dialog","dialog")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Button","button")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TextTag","texttag")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Lightning","lightning")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Image","image")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Ubersplat","ubersplat")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Region","region")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("FogState","fogstate")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("FogModifier","fogmodifier")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Hashtable","hashtable")


    function FlushHandleVars takes agent subject returns nothing
    endfunction
    function FlushHandleLocals takes agent subject returns nothing
    endfunction

09-25-2009, 01:52 PM#9
ShadowDestroyer
Unfortunately, still no luck. I am testing this on a blank map, not TT, to control other factors.
09-25-2009, 01:55 PM#10
Vexorian
ah ok.

Report your bug to blizzard. it is their fault 100%. Something about using agents as arguments or return values is causing the problem with macs.

(There's the possibility that the other guy's wc3 has something odd not specific to being a mac though, make sure to filter that out)
09-25-2009, 01:59 PM#11
ShadowDestroyer
Ok, but where would I report it and would they actually listen?

Unfortunately, unless I want to recode TT entirely, I am probably going to have to make it Mac-Incompatible. Hopefully you can lobby for a fix if they ever plan on another patch. :)