| 12-09-2009, 10:27 PM | #1 |
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 | |
Everything that extends agent is able to be stored with SaveAgentHandle
|
| 12-09-2009, 11:30 PM | #3 |
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 |
Did you initialize the Hashtable? |
| 12-10-2009, 12:49 AM | #5 |
I did in the map initialization, unless it shouldn't be done there. |
| 12-10-2009, 01:06 AM | #6 |
If you don't mind the fogstate bug (return bug 2.0) You can use this new version of SaveHandleHandle... 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:: JASS:globals hashtable table = InitHashtable() endglobals |
| 12-10-2009, 01:32 AM | #7 |
What arguments are pk and ck? HandleId of timer and ? |
| 12-10-2009, 01:35 AM | #8 |
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 |
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 |
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 |
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. |
