- Joined
- Nov 30, 2007
- Messages
- 1,202
Can someone for the low of god teach me (show me) how to make a double linked list?
I just don't understand how to index and deindex them. :<
Here is one example of a unit group i'd like replaced:
Here is another:
I just don't understand how to index and deindex them. :<
Here is one example of a unit group i'd like replaced:
JASS:
private function OnIndex takes nothing returns boolean
if GetUnitAbilityLevel(udg_UDexLastUnit, HUNGERS) > 0 then
call GroupAddUnit(playerHungryUnits[GetPlayerId(GetOwningPlayer(udg_UDexLastUnit))], udg_UDexLastUnit)
endif
return false
endfunction
Here is another:
JASS:
// This loop can be optimized to only loop through those that actually have income if you index them
private function GiveIncome takes nothing returns boolean
local integer i = 1
loop
if city[i].incFood > 0 then
call SetUnitState(city[i].u, UNIT_STATE_MANA, GetUnitState(city[i].u, UNIT_STATE_MANA) + city[i].incFood)
endif
set i = i + 1
exitwhen i > City.count
endloop
return false
endfunction