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

[Trigger] Remove stored handles in hashtable

Status
Not open for further replies.
Level 28
Joined
Jan 26, 2007
Messages
4,789
thats what i have but a mod says i need to remove locations before this..?

Ohh, but that's just simple leak fixing...
If you are using hashtables to store locations, you'd better store the coördinates...

I'll give you an example:


  • Actions
    • Hashtable - Save Handle Of(Center of (Playable map area)) as 0 of (Key (Triggering unit)) in (Last created hashtable)

OR:


  • Actions
    • Set Location = (Center of (Playable map area))
    • Hashtable - Save Handle OfLocation as 0 of (Key (Triggering unit)) in (Last created hashtable)
Well, in any case: you can't remove that location since you store it.
From the moment you remove the location, the stored location will also be removed, thus the entire spell (or whatever it is you are doing) fails.
However, reals aren't removed when a location is removed, thus it's best to do something like this:


  • Actions
    • Set Location = (Center of (Playable map area))
    • Hashtable - Save (X of Location) as 0 of (Key (Triggering unit)) in (Last created hashtable)
    • Hashtable - Save (Y of Location) as 1 of (Key (Triggering unit)) in (Last created hashtable)
    • Custom script: call RemoveLocation(udg_Location)
Now it removes the leak caused by the handle (in this case the location), while the stored data still remains.

To recall the data, simply do something like this:

  • Actions
    • Set Location = (Point((Load 0 of (Key (Picked unit)) from (Last created hashtable)), (Load 1 of (Key (Picked unit)) from (Last created hashtable))))
(this can be done with the "Convert coördinates to point" function).

(If you did not know about removing leaks yet, leaks are the main cause of lag and may slow down the game or even make it crash.
Read this post to see what leaks and how to fix it).


If I am completely wrong, please explain a bit further ^^
 
Status
Not open for further replies.
Top