- Joined
- Nov 30, 2007
- Messages
- 1,202
Scroll down to the this:
Ther other code is just to provide a bigger picture.
The error I get is this: BuildingLib_bTypeCount is not a member of Main
Ther Main Struct is in another library...
I don't understand why it complains in Struct 1.
JASS:
// HERE *************************************************************************************
Ther other code is just to provide a bigger picture.
The error I get is this: BuildingLib_bTypeCount is not a member of Main
JASS:
library BuildingLib initializer Init
globals
//constant integer MAX_B_REQ = 5
constant integer BUILDING_REQ_SIZE = 6
constant integer BUILDING_TYPES_SIZE = 50
constant integer INC_PER_GRANARY = 1000
constant integer INC_PER_FARM = 100
constant integer NONE = -1
hashtable bHash = InitHashtable()
private integer bReqCount = 0
private integer bTypCount = 0
Building array building
BuildingReq array req
endglobals
struct Building
boolean array limited[12]
integer array reqPoint[8]
integer count = 0
integer id
integer limit
static method create takes integer bId, integer n returns Building
local thistype tmp = .allocate()
set tmp.id = bId
set tmp.limit = n
return tmp
endmethod
method addReq takes integer reqIndex returns nothing
set .reqPoint[count] = reqIndex
set .count = .count + 1
endmethod
method onConstruction takes nothing returns nothing
local integer i = 0
loop
exitwhen i == count
// loop through pointers!
set i = i + 1
endloop
endmethod
endstruct
function GetBuildIndexByUnitId takes integer uId returns integer
return LoadInteger(bHash, uId, 1)
endfunction
function GetBuildIndexByUnit takes unit u returns integer
return LoadInteger(bHash, GetUnitTypeId(u), 1)
endfunction
function GetBuildIndexByOrder takes integer id returns integer
return LoadInteger(bHash, id, 0)
endfunction
struct BuildingReq
unit array dummyUnit[12]
integer dummmyId
integer amount
integer bIndex
static method create takes integer dumId, integer bId, integer amount returns BuildingReq
local thistype tmp = .allocate()
set tmp.dummmyId = dumId
set tmp.bIndex = GetBuildIndexByUnitId(bId)
set tmp.amount = amount
return tmp
endmethod
// HERE *************************************************************************************
method update takes integer pId returns nothing
local integer c = curSelectedCity[pId]
if city[c].bTypCount[.bIndex] >= .amount and .dummyUnit[pId] == null then // BuildingLib_bTypeCount is not a member of Main
set .dummyUnit[pId] = CreateUnit(Player(pId),.dummyId,0,0,0)
elseif city[c].bTypCount[.bIndex] < .amount and .dummyUnit[pId] != null then
call KillUnit(.dummyUnit[pId])
set .dummyUnit[pId] = null
endif
endmethod
endstruct
// ********************************************************************************************
function InitializeBuildingTypes takes string s, integer id returns nothing
set bTypCount = bTypCount + 1
call SaveInteger(bHash, String2OrderIdBJ(s), 0, id)
call SaveInteger(bHash, id, 1, bTypCount)
endfunction
function InitializeBuildingRequirments takes integer dumId, integer bId, integer n returns nothing
set bReqCount = bReqCount + 1
endfunction
function UnitUnderConstruction takes unit u returns boolean
return IsUnitInGroup(u, gConstruction) == true
endfunction
private function Init takes nothing returns nothing
endfunction
endlibrary
Ther Main Struct is in another library...
JASS:
library CityLib initializer Init
//===========================================================================
globals
constant integer CITY_ID_T1 = 'htow'
constant integer CITY_ID_T2 = 'htow'
constant integer CITY_ID_T3 = 'htow'
constant integer BUILD_BLOCKER = 'h005'
constant integer CITY_CONTROL1 = 'bld0' // City Menu
constant integer CITY_CONTROL2 = 'h004' // Defense Menu
constant integer CITY_BR_T1 = 800
constant integer CITY_BR_T2 = 800
constant integer CITY_BR_T3 = 800
constant real CAPTURE_LIFE = 400.
integer cityCount = 0
Main array city
endglobals
struct Main
string name
unit main
player owner
boolean capital
integer array bTypCount[BUILDING_TYPES_SIZE]
integer buildRadius
boolean foodAutoFeed
boolean foodProdOn
integer foodInc = 0
integer foodCur = 0
integer foodMax = 0
group gBuildings
group gSupplyDest
group gSupplyHome
//------------------------------------------------------
method init_bTypCount takes nothing returns nothing
local integer i = 0
loop
set .bTypCount[i] = 0
set i = i + 1
exitwhen i == BUILDING_TYPES_SIZE
endloop
endmethod
method inc_bTypCount takes integer i returns nothing
set .bTypCount[i] = .bTypCount[i] + 1
endmethod
method dec_bTypCount takes integer i returns nothing
set .bTypCount[i] = .bTypCount[i] - 1
endmethod
//------------------------------------------------------
method add_foodMax takes integer amount returns nothing
set .foodMax = .foodMax + amount
endmethod
//------------------------------------------------------
static method create takes nothing returns Main
local thistype tmp = .allocate()
call tmp.init_bTypCount()
return tmp
endmethod
method insideCity takes real dx, real dy returns boolean
return SquareRoot(dx*dx + dy*dy) <= .buildRadius
endmethod
method updateAutoFeed takes player p returns nothing
if .foodAutoFeed == true then
call SetPlayerAbilityAvailable(p, FOOD_OFF, true)
call SetPlayerAbilityAvailable(p, FOOD_ON, false)
else
call SetPlayerAbilityAvailable(p, FOOD_OFF, false)
call SetPlayerAbilityAvailable(p, FOOD_ON, true)
endif
endmethod
method changeOwner takes player p returns nothing
local group g = CreateGroup()
local unit u
set .owner = p
call SetUnitOwner(.main, p, true)
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g, u)
call SetUnitOwner(u, p, true)
endloop
call DestroyGroup(g)
set u = null
endmethod
endstruct
endlibrary
I don't understand why it complains in Struct 1.
Last edited: