- Joined
- Nov 30, 2007
- Messages
- 1,202
I have this struct:
then when I increase the count in another function...
The city.buildingCount_wip is constantly 120 in one city, 30 in another and so on. Its supposed to count buildings but the buildingCount don't change. Don't get it.
Removed most parts that are not relevant to the question.
JASS:
struct City
integer array buildingCount_tot[BUILDING_TYPES_MAX]
integer array buildingCount_wip[BUILDING_TYPES_MAX]
Menu menu
static integer count = 1
static method create takes string s, rect r returns City
local thistype c = .allocate()
local integer i = 0
set c.menu = Menu.create(c)
set City.count = City.count + 1
loop // Here they are initialized to 0!
set c.buildingCount_tot[i] = 0
set c.buildingCount_wip[i] = 0
set i = i + 1
exitwhen i == BUILDING_TYPES_MAX
endloop
// Add To Damage Trigger
return c
endmethod
method addBuildingCountTot takes integer building, integer amount returns nothing
set .buildingCount_tot[building] = .buildingCount_tot[building] + amount
endmethod
method addBuildingCountWip takes integer building, integer amount returns nothing
set .buildingCount_wip[building] = .buildingCount_wip[building] + amount
endmethod
then when I increase the count in another function...
JASS:
private function OnConstructionStart takes nothing returns boolean
local unit u = GetTriggerUnit()
local integer uid = GetUnitUserData(u)
local integer pid = GetPlayerId(GetOwningPlayer(u))
local integer b = BT.getBuildingIndexByUnit(u)
local integer i = curSelection[pid]
set owningCity[uid] = i
call city[i].addBuildingCountWip(b, 1)
call city[i].addBuildingCountTot(b, 1)
// refresh this building
call BJDebugMsg(I2S(b))
call BJDebugMsg("Wip: " + I2S(city[i].buildingCount_wip))
call BJDebugMsg("Tot: " + I2S(city[i].buildingCount_tot))
set u = null
return false
endfunction
The city.buildingCount_wip is constantly 120 in one city, 30 in another and so on. Its supposed to count buildings but the buildingCount don't change. Don't get it.
Removed most parts that are not relevant to the question.