| 09-22-2010, 07:24 PM | #1 |
I encountered an error that i cannot resolve while writing up a system to handle neutral camps in a map i am working on. I have a struct that contains 2 lists and a pool. In the create method of the Camp struct I initialize the two lists and pool. The pathing list and intpool both throw no error but the building list does. The Camp and BuildingList libraries follow the error. Message: Line 7991: BuildingList is not of a type that allows . syntax://library NeutralCamps: struct NeutralCamps___Camp //! pragma implicitthis PathList patrol BuildingList structures intpool patrolPool private static method anon__0 takes nothing returns nothing call KillUnit(GetEnumUnit()) endmethod static method NeutralCamps___PatrolEndCB takes group g returns boolean local boolean ret=true call ForGroup(g,function thistype.anon__0) return ret endmethod static method create takes group g returns thistype //pass in a group of units that will be the base of the camp local NeutralCamps___Camp c=NeutralCamps___Camp.allocate() set c.patrolPool=intpool.create() set c.patrol=PathList.create(NeutralCamps___Camp.NeutralCamps___PatrolEndCB) set c.structures=BuildingList.create() return c endmethod[/jass] Camp library://! zinc library NeutralCamps requires GroupUtils, PathingList, Pool, StructureList { struct Camp { PathList patrol; BuildingList structures; intpool patrolPool; static method PatrolEndCB(group g) -> boolean { boolean ret = true; ForGroup(g, function() { KillUnit(GetEnumUnit()); }); return ret; } //pass in a group of units that will be the base of the camp static method create(group g) -> thistype { Camp c = Camp.allocate(); c.patrolPool = intpool.create(); c.patrol = PathList.create(Camp.PatrolEndCB); c.structures = BuildingList.create(); return c; } } function PatrolEndCB(group g) -> boolean { boolean ret = true; ForGroup(g, function() { KillUnit(GetEnumUnit()); }); return ret; } function onInit() { //bottom left nelf camp //center point -9728.3, -10239.2 //radius 1024.0 } } //! endzinc BuildingList library://! zinc library StructureList { //save a list of where each structure is. struct OriginalPosition { integer unitId; real x; real y; static method create(integer id, real x, real y) -> thistype { OriginalPosition o = OriginalPosition.allocate(); o.unitId = id; o.x = x; o.y = y; return o; } } struct Building { OriginalPosition origPos; unit u; unit wisp = null; Building next = 0; static method create(unit u) -> Building { Building b = Building.allocate(); b.origPos = OriginalPosition.create(GetUnitTypeId(u), GetUnitX(u), GetUnitY(u)); b.u = u; return b; } } struct BuildingList { Building first = 0; Building current = 0; method add(unit u) { Building b = Building.create(u); Building g = current; //start wherever the current item is so we can skip iterating over the first items if (first == 0) { first = b; current = b; } else { while (g.next != 0) { g = g.next; } //we found the last item of the list g.next = b; } } method next() -> Building { Building ret = current; if (current != 0) { current = current.next; } return ret; } method peek() -> Building { return current; } method reset() { current = first; } } } //! endzinc Any help would be appreciated. As a side note all of the various libraries are imported in file that is a list of imports which is then singly imported into the map. |
| 09-22-2010, 07:55 PM | #2 |
In Zinc, all library members are private by default. You should make the BuildingList struct public. |
| 09-22-2010, 08:20 PM | #3 |
Oh yeah! Thanks. Must re read the zinc doc. |
