[Solved] Saving Locations using Hashtables

Status
Not open for further replies.
Level 8
Joined
Oct 3, 2008
Messages
189
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.
Back
Top