AMAI
AMAI copied to clipboard
ChooseExpansion
function ChooseExpansion takes nothing returns nothing
local integer i = 0
local integer exp_chosen = 0
set exp_number = 0
set first_expansion_chosen = true
loop
exitwhen i >= expansion_list_length
if GetResourceAmount(expansion_list[i]) > 2 * GetUnitGoldCost2(racial_expansion) and not CheckExpansionTaken(expansion_list[i]) then
call add_exp(expansion_list[i], expansion_dist[i], expansion_ancient[i], expansion_creeps[i])
endif
set i = i + 1
endloop
if TownCountDone(neutral_zeppelin) > 0 then
set i = 0
loop
exitwhen i >= water_expansion_list_length
if not CheckExpansionTaken(water_expansion_list[i]) then
call add_exp(water_expansion_list[i], 60, expansion_ancient[i], expansion_creeps[i])
endif
set i = i + 1
endloop
endif
call add_exp_rp()
if exp_number == 0 then
set current_expansion = null
call Trace("No valid expansions")
else
set exp_chosen = ChooseExp()
set current_expansion = exp_unit[exp_chosen]
set ancient_exp_loc = exp_ancient[exp_chosen]
set current_expansion_creeps = exp_creeps[exp_chosen]
endif
endfunction
search ancient_exp_loc and current_expansion_creeps they no RemoveLocation and DestroyGroup function add_exp, seems that it will only increase exp_ancient[exp_number] and exp_creeps[exp_number] so I suspect that no subtraction was done here or repeatedly assigning values to the same variable ,like ancient_exp_loc Causes the leakage
some values , have a code , I understand it as an excretory mechanism ,but add_exp donot have RemoveLocation and DestroyGroup, only set exp_unit[i] = exp_unit[i + 1]
function CopyArmy takes integer from, integer to returns nothing
set army_owner[to] = army_owner[from]
set army_loc[to] = army_loc[from]
set army_dir[to] = army_dir[from]
set army_future[to] = army_future[from]
set army_strength[to] = army_strength[from]
set army_group[to] = army_group[from]
set army_count[to] = army_count[from]
endfunction