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

[Solved] Saving Locations using Hashtables

Status
Not open for further replies.
Level 7
Joined
Oct 3, 2008
Messages
183
I'm working on a simple projectile spell. First trigger creates projectile, stores destination using the projectile as a key in a hashtable, second trigger is responsible for the actual moving.

Something seems to be going wrong though and when trying to load the location in the second trigger it seems to default to the center of map. Saving and loading X and Y instead seems to work without issues though oddly enough.
 
Last edited by a moderator:
I'm working on a simple projectile spell. First trigger creates projectile, stores destination using the projectile as a key in a hashtable, second trigger is responsible for the actual moving.

Something seems to be going wrong though and when trying to load the location in the second trigger it seems to default to the center of map. Saving and loading X and Y instead seems to work without issues though oddly enough.

I'm guessing you removed the location after you saved it in the hashtable.

Keep in mind that hashtables behave sort of like pointers. If you save one object under some keys, it doesn't copy the object into memory and store it in the hash. It likely just points to the address in memory. Thus, if you remove the object that you saved, then the hashtable will point to that slot in memory which will have been removed. Basically:

save hashtable key 0, 1 -> location "X"
RemoveLocation(X)
load hashtable key 0, 1 -> that handle is destroyed

So it will point to (0, 0) in the coordinates.

Then again, I can't be sure if that is the reason unless you post your code. ;)
 
Status
Not open for further replies.
Top