wierd problem with hashtable storage with reals

polo2005

Wana start playing LoL? http://tinyurl.com/369as27
Reaction score
97
Code:
For each (Integer A) from 1 to 2, do (Actions)
    Loop - Actions
        Hashtable - Save (Load 0 of (Player number of mCS_Player[(Integer A)]) from mCS_SetupCombat_Temp_Hashtable) as (Integer A) of (Custom value of Location_unit) in mCS_Zone_hashtable[0]
        Set temp_point[1] = (temp_point[0] offset by 300.00 towards (90.00 + (180.00 x (-1.00 + (Real((Integer A)))))) degrees)
        Set temp_point[2] = (temp_point[1] offset by ((100.00 x (3.00 + (Real((Integer A))))) / 2.00) towards 0.00 degrees)
        For each (Integer B) from 1 to (Load (Integer A) of (Custom value of Location_unit) from mCS_Zone_hashtable[0]), do (Actions)
            Loop - Actions
                Set temp_unit[0] = (Load (Integer B) of (Player number of mCS_Player[(Integer A)]) in mCS_SetupCombat_Temp_Hashtable)
                Hashtable - Save Handle Oftemp_unit[0] as (Integer B) of (Custom value of Location_unit) in mCS_Zone_hashtable[(Integer A)]
                Set temp_point[3] = (temp_point[2] offset by (100.00 x (Real((Integer B)))) towards 180.00 degrees)
                Unit - Move temp_unit[0] instantly to temp_point[3]
                Custom script:   call SaveReal(udg_mCS_Zone_Points_X_hashtable[GetForLoopIndexA()],GetForLoopIndexB(),GetUnitUserData(udg_Location_unit), GetLocationX(udg_temp_point[3]))
                Custom script:   call SaveReal(udg_mCS_Zone_Points_Y_hashtable[GetForLoopIndexA()],GetForLoopIndexB(),GetUnitUserData(udg_Location_unit), GetLocationY(udg_temp_point[3]))
                Custom script:   call RemoveLocation(udg_temp_point[3])
        Custom script:   call RemoveLocation(udg_temp_point[1])
        Custom script:   call RemoveLocation(udg_temp_point[2])


Code:
For each (Integer A) from 1 to 2, do (Actions)
    Loop - Actions
        For each (Integer B) from 1 to (Load (Integer A) of (Custom value of Location_unit) from mCS_Zone_hashtable[0]), do (Actions)
            Loop - Actions
                Set unit[0] = (Load (Integer B) of (Custom value of Location_unit) in mCS_Zone_hashtable[(Integer A)])
                Set mCS_Reals[0] = (Load (Integer B) of (Custom value of Location_unit) from mCS_Zone_Points_X_hashtable[(Integer A)])
                Set mCS_Reals[1] = (Load (Integer B) of (Custom value of Location_unit) from mCS_Zone_Points_Y_hashtable[(Integer A)])
                Custom script:   set udg_p[0] = Location(udg_mCS_Reals[0],udg_mCS_Reals[1])
                Unit - Create 1 Footman for Player 1 (Red) at p[0] facing Default building facing degrees
                Cinematic - Ping minimap for (All players) at p[0] for 5.00 seconds
                Unit - Kill unit[0]
                Custom script:   call RemoveLocation(udg_p[0])

This is my 2 triggers, the second one is for testing purpos only, however i'm encounting a problem...
of some reason its the x and y location is only saved for 2 out of 6 units that i'm using, anyone that can point out the error?

note about the trigger:
all hashtables are preset
Location_unit's custome value = 1
For each (Integer B) from 1 to (Load (Integer A) of (Custom value of Loc... it will loop 3 times x 2(integerA loop)

What happens:

All 6 test units are killed correctly, so the unit storage works perfect, BUT there is only created a unit on the first loopB unit, and the 2 and 3 is creaded in 2 gropus(depending on what loopA that is currently running) in the middle of the map,

My question is why doesn't the hashtable store the unit 2-3 x and y real?
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
are you doing anything where you will need x/y at all? because with GUI using x/y gets sticky, just like using locals, i would recommend using a normal location or starting with jass, which based on your custom scripts you are more than capable of learning
 

polo2005

Wana start playing LoL? http://tinyurl.com/369as27
Reaction score
97
i dont rly need the x and y, but i need to store 2-12 points per unitX and unitX can depend between 2-16 units, and it would be much easier if they all could be stored starting from array 1 instead of 1-12 unitX[1] and 13-24... etc etc
and since it didn't work to store location in that way in hashtable, x and y reals seems like my only choice.

And i cant makeit in jass, since its a request of a system for a friend, he doesn't want it in JASS
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
try this:
Trigger:
  • Hashtable - Save Point X as (Key UnitX) of (whatever number 1-12) in HashtableX
 

polo2005

Wana start playing LoL? http://tinyurl.com/369as27
Reaction score
97
tried that before this, but the point isn't saved after i remove it to avoid leaks
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
you dont remove the point when you want to use it again
it "destroys" the pointer on that location

basically a point is like a unit, that is named for its x/y that is at that position
when you remove it it just destroys that point
so with hashtable points just save them like this:
Trigger:
  • Using points in hashtables
    • Set PointVar = Load Point in X of Y in HashtableX
    • Hashtable - Save NewPoint as X of Y in HashtableX
    • Custom Script: call RemoveLocation(udg_PointVar)
 

polo2005

Wana start playing LoL? http://tinyurl.com/369as27
Reaction score
97
well i cant use it like this, since my trigger is storing 2-12 points per unittypeX and i got atleast 4 unittypeX at the same time.
therefor i'm looping it for every unit of typeX so it would overwrite the point and cause a leak.
so i need a system that allows me to store a point unique to a unit, which i tried to store the x and y for the points instead.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
you dont seem to be explaining it very well because i dont quite get what you are doing or see how doing it with my method would prevent you from being successful
 

polo2005

Wana start playing LoL? http://tinyurl.com/369as27
Reaction score
97
will try to expain better then,
lets say i have 10 farms on my map. i will call them unittypeX
for every unittypeX when my event goes on i want to store 2-12 points based on how many units player x and player y have.
therefor i looped it in my trigger

like

Code:
unitgroup pick every unit type unittypeX
  loop 1-2 (player 1-2)
     loop 1-12 (based on units for player 1 and 2)
         set point = positon of unit
         hashtable save pos...

if i dont remove the pos it would leak, and i would need some kind of index system for storing 1-12 pos for every farm on the map

which would make the rest of my system way harder to work with.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
if i dont remove the pos it would leak, and i would need some kind of index system for storing 1-12 pos for every farm on the map

Wrong...

You can store as many pieces of information as you want if you use (Key Unit) as the parent because that refers to that specific unit
and as long as you still reference a point somewhere, through a variable, hashtable, or otherwise, it is not a leak, once you no longer reference that same location it becomes a leak because how are you going to destroy something if you cant pick it?
 

polo2005

Wana start playing LoL? http://tinyurl.com/369as27
Reaction score
97
Trigger:
  • Action
    • Set PointVar = Load Point in X of Y in HashtableX
    • Hashtable - Save NewPoint as X of Y in HashtableX
    • Custom Script: call RemoveLocation(udg_PointVar)


when you remove the udg_PointVar
the hashtable point is also destroyed, atleast thats what happene to me when i tired it

edit: or am i missing something? :/
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
Here, i did an example of it for you... and its leak free

Trigger:
  • Save 12 Points Per Unit
    • Events
      • Some event
    • Conditions
      • Some conditions
    • Actions
      • Set Temp_Group = Units in Playable Map Area matching ((Unit Type of Matching unit is equal to (your farm)) and ((Owner of Matching Unit is equal to Player 1 (red)) or (Owner of Matching Unit is equal to Player 2 (blue))))
      • Unit Group - Pick Every unit in Temp_Group and do actions
        • Loop - Actions
          • For every Integer A from 1-12 do actions
            • Loop - Actions
              • Set Temp_Unit = Picked Unit
              • Custom Script: call RemoveLocation(LoadLocationHandle(udg_SomeHashtable, GetHandleId(udg_Temp_Unit), bj_forLoopAIndex)
              • Hashtable - Save some_point as (Key Picked Unit) of Integer A in SomeHashtable
      • Custom Script: call DestroyGroup(udg_Temp_Group)
 

polo2005

Wana start playing LoL? http://tinyurl.com/369as27
Reaction score
97
must confess that i find it very hard for this to work, but i will test it asap as i'm home.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top