HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

What is an agent?

12-09-2009, 10:27 PM#1
The_AwaKening
So I'm trying to fix my map since 1.24. I haven't worked on it in 2 years and really feel out of the loop now. I tried replacing all my HandleVars with some new functions using hashtables, which I don't fully understand yet, but some things aren't working now.

I'm really thinking it has something to do with SetHandleHandle. I noticed it is now taking an agent instead of handle. How do I get the agent of a unit, or do I just send the unit?
12-09-2009, 10:45 PM#2
Fledermaus
Everything that extends agent is able to be stored with SaveAgentHandle

Hidden information:
//============================================================================
// Native types. All native functions take extended handle types when
// possible to help prevent passing bad values to native functions
//
type agent extends handle // all reference counted objects
type event extends agent // a reference to an event registration
type player extends agent // a single player reference
type widget extends agent // an interactive game object with life
type unit extends widget // a single unit reference
type destructable extends widget
type item extends widget
type ability extends agent
type buff extends ability
type force extends agent
type group extends agent
type trigger extends agent
type triggercondition extends agent
type triggeraction extends handle
type timer extends agent
type location extends agent
type region extends agent
type rect extends agent
type boolexpr extends agent
type sound extends agent
type conditionfunc extends boolexpr
type filterfunc extends boolexpr
type unitpool extends handle
type itempool extends handle
type race extends handle
type alliancetype extends handle
type racepreference extends handle
type gamestate extends handle
type igamestate extends gamestate
type fgamestate extends gamestate
type playerstate extends handle
type playerscore extends handle
type playergameresult extends handle
type unitstate extends handle
type aidifficulty extends handle

type eventid extends handle
type gameevent extends eventid
type playerevent extends eventid
type playerunitevent extends eventid
type unitevent extends eventid
type limitop extends eventid
type widgetevent extends eventid
type dialogevent extends eventid
type unittype extends handle

type gamespeed extends handle
type gamedifficulty extends handle
type gametype extends handle
type mapflag extends handle
type mapvisibility extends handle
type mapsetting extends handle
type mapdensity extends handle
type mapcontrol extends handle
type playerslotstate extends handle
type volumegroup extends handle
type camerafield extends handle
type camerasetup extends handle
type playercolor extends handle
type placement extends handle
type startlocprio extends handle
type raritycontrol extends handle
type blendmode extends handle
type texmapflags extends handle
type effect extends agent
type effecttype extends handle
type weathereffect extends handle
type terraindeformation extends handle
type fogstate extends handle
type fogmodifier extends agent
type dialog extends agent
type button extends agent
type quest extends agent
type questitem extends agent
type defeatcondition extends agent
type timerdialog extends agent
type leaderboard extends agent
type multiboard extends agent
type multiboarditem extends agent
type trackable extends agent
type gamecache extends agent
type version extends handle
type itemtype extends handle
type texttag extends handle
type attacktype extends handle
type damagetype extends handle
type weapontype extends handle
type soundtype extends handle
type lightning extends handle
type pathingtype extends handle
type image extends handle
type ubersplat extends handle
type hashtable extends agent
12-09-2009, 11:30 PM#3
The_AwaKening
So a unit or a widget should work. I tried both, but neither seem to be working.

local timer t = CreateTimer()
local unit u = GetTriggerUnit()

call SetHandleHandle(t,"u",u)

function SetHandleHandle takes agent subject, string name, agent value returns nothing
call SaveAgentHandle( udg_ht, GetHandleId(subject), StringHash(name), value)
endfunction


It's on a .01 timer to move the unit, but it isn't moving the unit now. It was working with the old handlevars
12-09-2009, 11:48 PM#4
Fledermaus
Did you initialize the Hashtable?
12-10-2009, 12:49 AM#5
The_AwaKening
I did in the map initialization, unless it shouldn't be done there.
12-10-2009, 01:06 AM#6
weaaddar
If you don't mind the fogstate bug (return bug 2.0)
You can use this new version of SaveHandleHandle...
Collapse JASS:
function SaveHandleHandle takes hashtable ht, integer pk,integer ck,handle h returns nothing
call SaveFogStateHandle(ht,pk,ck,ConvertFogState(GetHandleId(h)))
endfunction

Then you don't have to care about it. This actually performs only slightly worse then SaveAgentHandle once inlined. Once you use this you can use any type so update your fuax handle vars . You can also initialize a hashtable at map init.

This is perfectly fine::
Collapse JASS:
globals
 hashtable table = InitHashtable()
endglobals
12-10-2009, 01:32 AM#7
The_AwaKening
What arguments are pk and ck? HandleId of timer and ?
12-10-2009, 01:35 AM#8
weaaddar
This function basically can be used in any place you are currently using SaveAgentHandle. pk is the parentkey, ck is the childkey. The hashtable type is a 2d associative array after all.

Instead of limiting yourself to only agents you can expand your functions to take any handle.
12-10-2009, 01:46 AM#9
Rising_Dusk
I would really appreciate you not try to tell everyone and their brother to use that return bug. There is no telling if Blizzard will turn around and fix it with it being so prolific.
12-10-2009, 01:54 AM#10
The_AwaKening
Well, it works for me. I couldn't get it to work before, and I don't have a lot of time to work on this map anymore, so I just needed a bandaid. Thanks weaaddar. Tested and works.
12-10-2009, 04:50 AM#11
ToukoAozaki
I'm not going to persuade anyone from using the aforementioned method. However, just be warned: abusing type safety can lead to silent, yet deadly consequences, like the original return bug did.