private function UpdateCacheO_Condition takes nothing returns boolean
if GetIssuedOrderId() >= 852002 and GetIssuedOrderId() <= 852007 then
return true
endif
return false
endfunction
private function WhichSlot takes unit wu, item wi returns integer
local integer i=0
local item it
loop
exitwhen i==6
if wi == UnitItemInSlot(wu,i) then
return i
set i=5
endif
set i=i+1
endloop
return 7
endfunction
private function UpdateCacheO takes nothing returns nothing
local integer Slot1 //Destination
local integer Slot2 //Source
local integer Medium //Medium
local unit OrderedUnit = GetOrderedUnit()
local item OrderedItem = GetOrderTargetItem()
local integer OwningPlayer = GetPlayerId(GetOwningPlayer(OrderedUnit))
set Slot1 = GetIssuedOrderId() - 852002
set Slot2 = WhichSlot(OrderedUnit,OrderedItem)
set Medium = SlotCache[OwningPlayer][Slot1]
set SlotCache[OwningPlayer][Slot1] = SlotCache[OwningPlayer][Slot2]
set SlotCache[OwningPlayer][Slot2] = Medium
set OrderedUnit = null
set OrderedItem = null
endfunction