- Joined
- Jul 12, 2021
- Messages
- 97
I have a problem with the next 2 triggers. In the trigger CreateUnits I use a hashtable to save a location. The problem is that when the custom script removes TempPoint[1] the hashtable (unwantedly) also gets updated and deletes its location.
Do my next trigger have leaks? I think there is a location leak in the custom script. If it doesn't leak, then here is the solution to my first question!
Do my next functions have leaks?
-
CreateUnits
-
Events
-
Unit - A unit Sells a unit
-
-
Conditions
-
Actions
-
Set VariableSet TempPoint[1] = ((Center of Region) offset by (0.00, (-1.00 x DistanceBetweenTheFourUnits)))
-
Hashtable - Save Handle OfTempPoint[1] as 200 of PNumberOfOwnerOfUnit in Hashtable.
-
Custom script: call RemoveLocation(udg_TempPoint[1])
-
-
-
UnitPicksAnItem
-
Events
-
Unit - A unit Acquires an item
-
-
Conditions
-
Actions
-
Unit - Create 1 Circle of Power for (Owner of (Triggering unit)) at (Load 200 of PNumberOfOwnerOfUnit in Hashtable.) facing Default building facing degrees
-
-
Do my next trigger have leaks? I think there is a location leak in the custom script. If it doesn't leak, then here is the solution to my first question!
-
Set VariableSet MoonwalkingTempPoint[10] = ((Center of Region) offset by (0.00, (-1.00 x DistanceBetweenTheFourUnits)))
-
Set VariableSet PreventPointLeak[0] = (X of MoonwalkingTempPoint[10])
-
Set VariableSet PreventPointLeak[1] = (Y of MoownalkingTempPoint[10])
-
Custom script: call SaveLocationHandle(udg_Hashtable, udg_PNumberOfOwnerOfUnit, 200, Location (udg_PreventPointLeak[0], udg_PreventPointLeak[1]))
-
Custom script: call RemoveLocation(udg_MoonwalkingTempPoint[10])
Do my next functions have leaks?
JASS:
function TriggerToMove takes unit u1, unit u2, unit u3, unit u4 returns nothing
local integer value = 100
// WalkLeft
call IssuePointOrder( u2, "move", GetUnitX(u2) - value, GetUnitY (u2))
// WalkDown
call IssuePointOrder( u3, "move", GetUnitX(u3), GetUnitY (u3) - value)
// WalkRight
call IssuePointOrder( u4, "move", GetUnitX(u4) + value, GetUnitY (u4))
// WalkUp
call IssuePointOrder( u1, "move", GetUnitX(u1), GetUnitY (u1) + value)
endfunction
function TriggerMovementRight takes unit source returns nothing
local timer t = CreateTimer()
local integer id = GetHandleId(t)
local integer idunit = GetHandleId(source)
local player owner = GetOwningPlayer(source)
local integer idowner = GetPlayerId(owner)
call SaveUnitHandle(udg_Hashtable, id, 0, source)
call SaveUnitHandle(udg_Hashtable, idowner, 400, source)
call SaveTimerHandle(udg_Hashtable, idunit, 1, t)
call TimerStart(t, 0.01, true, function TriggerMovementRight_Expire)
set t = null
endfunction
function TriggerMovementRight_Expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local real speed = 3.2
local unit source = LoadUnitHandle(udg_Hashtable, id, 0)
call SetUnitX(source, GetUnitX(source) + speed)
set t = null
endfunction
Last edited: