80 |
80 |
81 static class RoomArrayPtr extends PointerType { |
81 static class RoomArrayPtr extends PointerType { |
82 /** |
82 /** |
83 * Returns the (native-owned) rooms in this list |
83 * Returns the (native-owned) rooms in this list |
84 */ |
84 */ |
85 public RoomPtr[] getRooms(int count) { |
85 public Room[] getRooms(int count) { |
86 Pointer ptr = getPointer(); |
86 Pointer ptr = getPointer(); |
87 if(ptr == null) { |
87 if(ptr == null) { |
88 return new RoomPtr[0]; |
88 return new Room[0]; |
89 } |
89 } |
90 Pointer[] untypedPtrs = ptr.getPointerArray(0, count); |
90 Pointer[] untypedPtrs = ptr.getPointerArray(0, count); |
91 RoomPtr[] typedPtrs = new RoomPtr[count]; |
91 Room[] result = new Room[count]; |
92 for(int i=0; i<count; i++) { |
92 for(int i=0; i<count; i++) { |
93 typedPtrs[i] = new RoomPtr(untypedPtrs[i]); |
93 result[i] = RoomPtr.deref(untypedPtrs[i]); |
94 } |
94 } |
95 return typedPtrs; |
95 return result; |
96 } |
96 } |
97 } |
97 } |
98 |
98 |
99 static class RoomPtr extends PointerType { |
99 static class RoomPtr extends PointerType { |
100 public RoomPtr() { super(); } |
100 public RoomPtr() { super(); } |
101 public RoomPtr(Pointer ptr) { super(ptr); } |
101 public RoomPtr(Pointer ptr) { super(ptr); } |
102 |
102 |
103 public Room deref() { |
103 public Room deref() { |
104 Room result = new Room(getPointer()); |
104 return deref(getPointer()); |
105 result.read(); |
105 } |
106 return result; |
106 |
|
107 public static Room deref(Pointer p) { |
|
108 RoomStruct r = new RoomStruct(p); |
|
109 r.read(); |
|
110 return new Room(r.name, r.map, r.scheme, r.weapons, r.owner, r.playerCount, r.teamCount, r.inProgress); |
107 } |
111 } |
108 } |
112 } |
109 |
113 |
110 static class TeamPtr extends PointerType { } |
114 static class TeamPtr extends PointerType { } |
111 static class WeaponsetPtr extends PointerType { } |
115 static class WeaponsetPtr extends PointerType { } |
112 static class MapRecipePtr extends PointerType { } |
116 static class MapRecipePtr extends PointerType { } |
113 static class SchemePtr extends PointerType { } |
117 static class SchemePtr extends PointerType { } |
114 static class GameSetupPtr extends PointerType { } |
118 static class GameSetupPtr extends PointerType { } |
115 |
119 |
116 static class Room extends Structure { |
120 static class RoomStruct extends Structure { |
117 public static class byVal extends Room implements Structure.ByValue {} |
121 public static class byVal extends RoomStruct implements Structure.ByValue {} |
118 public static class byRef extends Room implements Structure.ByReference {} |
122 public static class byRef extends RoomStruct implements Structure.ByReference {} |
119 private static String[] FIELD_ORDER = new String[] {"inProgress", "name", "playerCount", "teamCount", "owner", "map", "scheme", "weapons"}; |
123 private static String[] FIELD_ORDER = new String[] {"inProgress", "name", "playerCount", "teamCount", "owner", "map", "scheme", "weapons"}; |
120 |
124 |
121 public Room() { super(); setFieldOrder(FIELD_ORDER); } |
125 public RoomStruct() { super(); setFieldOrder(FIELD_ORDER); } |
122 public Room(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
126 public RoomStruct(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
123 |
127 |
124 public boolean inProgress; |
128 public boolean inProgress; |
125 public String name; |
129 public String name; |
126 public int playerCount; |
130 public int playerCount; |
127 public int teamCount; |
131 public int teamCount; |