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

[Solved] Special Effects at Hashtables: leak?

Status
Not open for further replies.
Level 5
Joined
Dec 12, 2011
Messages
116
This is my first use of hashtables.
1. I used hashtables correctly here?
2. Are there any leaks?

  • MySkill Hashtable Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set MySkillHashTable = (Last created hashtable)
  • MySkill Activate
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to MySkill Turn On
    • Actions
      • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\Other\Drain\DrainCaster.mdl
      • Hashtable - Save Handle Of(Last created special effect) as 0 of (Key (Triggering unit)) in MySkillHashTable
  • MySkill Deactivate
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to MySkill Turn Off
    • Actions
      • Special Effect - Destroy (Load 0 of (Key (Triggering unit)) in MySkillHashTable)
      • Hashtable - Clear all child hashtables of child (Key (Triggering unit)) in MySkillHashTable
PS: Obviously, my triggers do other things, not only adding / removing a special effect, but I removed them because they're not part of the discussion here...

hamsterpellet
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
That is the correct way to use them.

If your turn on ability can be casted again before the ability is deactivated, then that can cause the first efect to not be destroyed. You could check Boolean - value (handle) exists. Check whether the effect is stored and destroy it before creating a new one.
 
Level 5
Joined
Dec 12, 2011
Messages
116
Yeah, but at the moment I cast my Turn On skill, it is removed and the Turn Off is added... Also, both abilities have cooldown to avoid possible problems due to double-clicks.
So, nothing is leaking, right ?
 
Status
Not open for further replies.
Top