author | Medo <smaxein@googlemail.com> |
Sat, 18 Aug 2012 00:47:51 +0200 | |
changeset 7508 | 763d3961400b |
parent 7485 | 0481bd74267c |
child 7558 | 983ff426f91e |
permissions | -rw-r--r-- |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1 |
package org.hedgewars.hedgeroid.frontlib; |
7485 | 2 |
import java.io.UnsupportedEncodingException; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
3 |
import java.nio.Buffer; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
4 |
import java.util.ArrayList; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
5 |
import java.util.HashMap; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
6 |
import java.util.List; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
7 |
import java.util.Map; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
8 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
9 |
import org.hedgewars.hedgeroid.Datastructures.Hog; |
7485 | 10 |
import org.hedgewars.hedgeroid.Datastructures.MapRecipe; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
11 |
import org.hedgewars.hedgeroid.Datastructures.MetaScheme; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
12 |
import org.hedgewars.hedgeroid.Datastructures.MetaScheme.Mod; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
13 |
import org.hedgewars.hedgeroid.Datastructures.MetaScheme.Setting; |
7485 | 14 |
import org.hedgewars.hedgeroid.Datastructures.GameConfig; |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
15 |
import org.hedgewars.hedgeroid.Datastructures.Room; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
16 |
import org.hedgewars.hedgeroid.Datastructures.Scheme; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
17 |
import org.hedgewars.hedgeroid.Datastructures.Team; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
18 |
import org.hedgewars.hedgeroid.Datastructures.TeamInGame; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
19 |
import org.hedgewars.hedgeroid.Datastructures.TeamIngameAttributes; |
7485 | 20 |
import org.hedgewars.hedgeroid.Datastructures.Weaponset; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
21 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
22 |
import com.sun.jna.Callback; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
23 |
import com.sun.jna.Library; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
24 |
import com.sun.jna.Memory; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
25 |
import com.sun.jna.NativeLong; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
26 |
import com.sun.jna.Pointer; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
27 |
import com.sun.jna.PointerType; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
28 |
import com.sun.jna.Structure; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
29 |
|
7485 | 30 |
/** |
31 |
* Here is an introduction to the most important aspects of the JNA code. |
|
32 |
* |
|
33 |
* This interface permits access to the Hedgewars frontend library (frontlib) |
|
34 |
* from Java. Each function directly contained in the Frontlib interface |
|
35 |
* represents a mapped C function. The Structure classes (ending in -Struct) are |
|
36 |
* mappings of C structs, and the PointerType classes (ending in -Ptr) represent |
|
37 |
* pointers to structs. |
|
38 |
* |
|
39 |
* Quick notes for USING these classes from outside this package: |
|
40 |
* |
|
41 |
* Usage should be fairly straightforward, but there are a few surprising |
|
42 |
* gotchas. First, when you implement callbacks, YOU are responsible for |
|
43 |
* ensuring that the callback objects are not garbage-collected while they might |
|
44 |
* still be called! So make sure you keep them in member variables or similar, |
|
45 |
* because Java will not know if there are still native references to them. |
|
46 |
* |
|
47 |
* When using Frontlib from outside its package, you only interact with structs |
|
48 |
* via the PointerType classes. They allow you to get at the data of the struct |
|
49 |
* with a function called deref(), which creates a plain normal Java object |
|
50 |
* representing the data (e.g. SchemePtr.deref() will give you a Scheme object). |
|
51 |
* |
|
52 |
* Remember that you usually have to destroy structs that you receive from the |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
53 |
* library, because they are owned by the native code, not Java. The recommended |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
54 |
* pattern for most cases is to call deref() on the pointer to get a Java object |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
55 |
* (that you can keep as long as you like), and then immediately destroy the |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
56 |
* struct if it needs destroying. To find out whether and how the struct needs |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
57 |
* to be destroyed, see the library's documentation of the function that you got |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
58 |
* the struct from. |
7485 | 59 |
* |
60 |
* To pass new structs to the library, you can use the static createJavaOwned() |
|
61 |
* function in each PointerType, which creates a new struct from the Java object |
|
62 |
* you provide, and returns a pointer to that struct that you can pass to |
|
63 |
* library functions. This new structure's memory is owned and managed by Java |
|
64 |
* code, so do not destroy it with frontlib functions! |
|
65 |
* |
|
66 |
* There is a slight mismatch between the data model for the game setup. The |
|
67 |
* frontlib supports setting initial health and weaponset per-hog, because the |
|
68 |
* engine allows for that, but currently neither the networking protocol nor the |
|
69 |
* PC frontend support this feature, so the Android version does not take |
|
70 |
* advantage of it either and treats both as per-game settings. The initial |
|
71 |
* health is contained in the game scheme, the weaponset is explicitly part of |
|
72 |
* the GameConfig. When converting GameConfig to a native flib_gamesetup, both |
|
73 |
* are automatically copied to all hogs in the game, and for the reverse |
|
74 |
* conversion the weaponset of the first hog of the first team is used as the |
|
75 |
* GameConfig weaponset. This means that GameConfig.weaponset will be null if |
|
76 |
* there are no teams in the game. |
|
77 |
* |
|
78 |
* When starting a network game, you only need to query the GameSetupPtr from |
|
79 |
* the netconn and use it to create the gameconn - this is preferable to using |
|
80 |
* your own recreation of the game setup, because that way the same piece of |
|
81 |
* code is used to determine the game setup on all platforms. |
|
82 |
* |
|
83 |
* The "context" parameter of the callbacks is never needed here because JNA |
|
84 |
* generates function code for each callback object. Don't worry about it, just |
|
85 |
* pass null for context and ignore the context parameter in the callbacks. |
|
86 |
* |
|
87 |
* Finally, the library functions are documented in the actual library, not |
|
88 |
* here, so check the docs there to find out what exactly each function does! |
|
89 |
* |
|
90 |
* Notes about the structure of this class (for the next one who has to touch |
|
91 |
* this...): |
|
92 |
* |
|
93 |
* Java/C interop is quite fiddly and error-prone, so as long as things work, |
|
94 |
* try to stick to the established patterns. |
|
95 |
* |
|
96 |
* Structure types should always be hidden from the outside world, because they |
|
97 |
* can be misused too easily. For example, if you get a Structure from the |
|
98 |
* library, change a String value in there and pass it back, JNA will re-write |
|
99 |
* that string using Java-owned memory without freeing the old native-owned |
|
100 |
* string, which causes a memory leak and possibly a double-free or other Bad |
|
101 |
* Things (tm). To avoid problems like this, Structure types are only used |
|
102 |
* internally, to map existing structures to Java types (without modifying them) |
|
103 |
* or to create brand-new, Java-owned structures. Both operations are exposed to |
|
104 |
* the outside through the PointerType classes corresponding to the structures |
|
105 |
* in question. |
|
106 |
* |
|
107 |
* Since all of the struct mapping happens in Java, it is never checked against |
|
108 |
* the actual struct declarations in the library. That means strange things can |
|
109 |
* start happening at runtime if the frontlib structs are modified without |
|
110 |
* changing the mappings here to match. This also applies to the function |
|
111 |
* signatures: JNA checks whether the functions actually exist when loading the |
|
112 |
* library, but it has no way of knowing whether the signatures are correct. If |
|
113 |
* the signatures here deviate from those in the frontlib, you might get stack |
|
114 |
* corruption. |
|
115 |
* |
|
116 |
* In order to check at least the function signatures, take a look at the file |
|
117 |
* extra/jnacontrol.c in the frontlib sources. You can validate whether the |
|
118 |
* function signatures are still correct by copy-pasting them into jnaControl.c |
|
119 |
* and compiling it against the frontlib headers. The typedefs and #defines in |
|
120 |
* that file will make the compiler see the Java method signatures as C function |
|
121 |
* declarations. Since the same functions are already declared in the frontlib |
|
122 |
* headers, the compiler will give you errors if the signatures don't match. |
|
123 |
*/ |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
124 |
public interface Frontlib extends Library { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
125 |
static final int NATIVE_INT_SIZE = 4; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
126 |
static final int NATIVE_BOOL_SIZE = 1; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
127 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
128 |
public static class NetconnPtr extends PointerType { } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
129 |
public static class MapconnPtr extends PointerType { } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
130 |
public static class GameconnPtr extends PointerType { } |
7485 | 131 |
|
132 |
// TODO avoid code duplication in the pointer types |
|
133 |
public static class MetaschemePtr extends PointerType { |
|
134 |
public MetaScheme deref() { |
|
135 |
return deref(getPointer()); |
|
136 |
} |
|
137 |
||
138 |
public static MetaScheme deref(Pointer p) { |
|
139 |
MetaschemeStruct struct = new MetaschemeStruct(p); |
|
140 |
struct.read(); |
|
141 |
return struct.toMetaScheme(); |
|
142 |
} |
|
143 |
} |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
144 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
145 |
public static class RoomArrayPtr extends PointerType { |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
146 |
public Room[] getRooms(int count) { |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
147 |
Pointer ptr = getPointer(); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
148 |
if(ptr == null) { |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
149 |
return new Room[0]; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
150 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
151 |
Pointer[] untypedPtrs = ptr.getPointerArray(0, count); |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
152 |
Room[] result = new Room[count]; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
153 |
for(int i=0; i<count; i++) { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
154 |
result[i] = RoomPtr.deref(untypedPtrs[i]); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
155 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
156 |
return result; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
157 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
158 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
159 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
160 |
public static class RoomPtr extends PointerType { |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
161 |
public Room deref() { |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
162 |
return deref(getPointer()); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
163 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
164 |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
165 |
public static Room deref(Pointer p) { |
7485 | 166 |
RoomStruct struct = new RoomStruct(p); |
167 |
struct.read(); |
|
168 |
return struct.toRoomlistRoom(); |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
169 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
170 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
171 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
172 |
public static class TeamPtr extends PointerType { |
7485 | 173 |
private TeamStruct javaOwnedInstance; |
174 |
||
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
175 |
public TeamInGame deref() { |
7485 | 176 |
TeamStruct struct = new TeamStruct(getPointer()); |
177 |
struct.read(); |
|
178 |
return struct.toTeamInGame(); |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
179 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
180 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
181 |
public static TeamPtr createJavaOwned(Team t) { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
182 |
return createJavaOwned(new TeamInGame(t, null)); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
183 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
184 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
185 |
public static TeamPtr createJavaOwned(TeamInGame ingameTeam) { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
186 |
TeamPtr result = new TeamPtr(); |
7485 | 187 |
result.javaOwnedInstance = new TeamStruct(); |
188 |
result.javaOwnedInstance.fillFrom(ingameTeam.team, ingameTeam.ingameAttribs); |
|
189 |
result.javaOwnedInstance.autoWrite(); |
|
190 |
result.setPointer(result.javaOwnedInstance.getPointer()); |
|
191 |
return result; |
|
192 |
} |
|
193 |
} |
|
194 |
||
195 |
public static class WeaponsetPtr extends PointerType { |
|
196 |
private WeaponsetStruct javaOwnedInstance; |
|
197 |
||
198 |
public Weaponset deref() { |
|
199 |
WeaponsetStruct struct = new WeaponsetStruct(getPointer()); |
|
200 |
struct.read(); |
|
201 |
return struct.toWeaponset(); |
|
202 |
} |
|
203 |
||
204 |
public static WeaponsetPtr createJavaOwned(Weaponset weaponset) { |
|
205 |
WeaponsetPtr result = new WeaponsetPtr(); |
|
206 |
result.javaOwnedInstance = new WeaponsetStruct(); |
|
207 |
result.javaOwnedInstance.fillFrom(weaponset); |
|
208 |
result.javaOwnedInstance.autoWrite(); |
|
209 |
result.setPointer(result.javaOwnedInstance.getPointer()); |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
210 |
return result; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
211 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
212 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
213 |
|
7485 | 214 |
public static class WeaponsetListPtr extends PointerType { |
215 |
private WeaponsetListStruct javaOwnedInstance; |
|
216 |
||
217 |
public List<Weaponset> deref() { |
|
218 |
WeaponsetListStruct struct = new WeaponsetListStruct(getPointer()); |
|
219 |
struct.read(); |
|
220 |
return struct.toWeaponsetList(); |
|
221 |
} |
|
222 |
||
223 |
public static WeaponsetListPtr createJavaOwned(List<Weaponset> list) { |
|
224 |
WeaponsetListPtr result = new WeaponsetListPtr(); |
|
225 |
result.javaOwnedInstance = new WeaponsetListStruct(); |
|
226 |
result.javaOwnedInstance.fillFrom(list); |
|
227 |
result.javaOwnedInstance.autoWrite(); |
|
228 |
result.setPointer(result.javaOwnedInstance.getPointer()); |
|
229 |
return result; |
|
230 |
} |
|
231 |
} |
|
232 |
||
233 |
public static class MapRecipePtr extends PointerType { |
|
234 |
private MapRecipeStruct javaOwnedInstance; |
|
235 |
||
236 |
public MapRecipe deref() { |
|
237 |
MapRecipeStruct struct = new MapRecipeStruct(getPointer()); |
|
238 |
struct.read(); |
|
239 |
return struct.toMapRecipe(); |
|
240 |
} |
|
241 |
||
242 |
public static MapRecipePtr createJavaOwned(MapRecipe recipe) { |
|
243 |
MapRecipePtr result = new MapRecipePtr(); |
|
244 |
result.javaOwnedInstance = new MapRecipeStruct(); |
|
245 |
result.javaOwnedInstance.fillFrom(recipe); |
|
246 |
result.javaOwnedInstance.autoWrite(); |
|
247 |
result.setPointer(result.javaOwnedInstance.getPointer()); |
|
248 |
return result; |
|
249 |
} |
|
250 |
} |
|
251 |
||
252 |
public static class SchemePtr extends PointerType { |
|
253 |
private SchemeStruct javaOwnedInstance; |
|
254 |
||
255 |
public Scheme deref() { |
|
256 |
SchemeStruct struct = new SchemeStruct(getPointer()); |
|
257 |
struct.read(); |
|
258 |
return struct.toScheme(); |
|
259 |
} |
|
260 |
||
261 |
public static SchemePtr createJavaOwned(Scheme scheme) { |
|
262 |
SchemePtr result = new SchemePtr(); |
|
263 |
result.javaOwnedInstance = new SchemeStruct(); |
|
264 |
result.javaOwnedInstance.fillFrom(scheme); |
|
265 |
result.javaOwnedInstance.autoWrite(); |
|
266 |
result.setPointer(result.javaOwnedInstance.getPointer()); |
|
267 |
return result; |
|
268 |
} |
|
269 |
} |
|
270 |
||
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
271 |
public static class SchemelistPtr extends PointerType { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
272 |
private SchemelistStruct javaOwnedInstance; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
273 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
274 |
public List<Scheme> deref() { |
7485 | 275 |
SchemelistStruct struct = new SchemelistStruct(getPointer()); |
276 |
struct.read(); |
|
277 |
return struct.toSchemeList(); |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
278 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
279 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
280 |
public static SchemelistPtr createJavaOwned(List<Scheme> schemes) { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
281 |
SchemelistPtr result = new SchemelistPtr(); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
282 |
result.javaOwnedInstance = new SchemelistStruct(); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
283 |
result.javaOwnedInstance.fillFrom(schemes); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
284 |
result.javaOwnedInstance.autoWrite(); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
285 |
result.setPointer(result.javaOwnedInstance.getPointer()); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
286 |
return result; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
287 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
288 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
289 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
290 |
public static class GameSetupPtr extends PointerType { |
7485 | 291 |
private GameSetupStruct javaOwnedInstance; |
292 |
||
293 |
public GameConfig deref() { |
|
294 |
GameSetupStruct struct = new GameSetupStruct(getPointer()); |
|
295 |
struct.read(); |
|
296 |
return struct.toGameConfig(); |
|
297 |
} |
|
298 |
||
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
299 |
public static GameSetupPtr createJavaOwned(GameConfig conf) { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
300 |
GameSetupPtr result = new GameSetupPtr(); |
7485 | 301 |
result.javaOwnedInstance = new GameSetupStruct(); |
302 |
result.javaOwnedInstance.fillFrom(conf); |
|
303 |
result.javaOwnedInstance.autoWrite(); |
|
304 |
result.setPointer(result.javaOwnedInstance.getPointer()); |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
305 |
return result; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
306 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
307 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
308 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
309 |
static class HogStruct extends Structure { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
310 |
public static class ByVal extends HogStruct implements Structure.ByValue {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
311 |
public static class ByRef extends HogStruct implements Structure.ByReference {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
312 |
private static String[] FIELD_ORDER = new String[] {"name", "hat", "rounds", "kills", "deaths", "suicides", "difficulty", "initialHealth", "weaponset"}; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
313 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
314 |
public HogStruct() { super(); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
315 |
public HogStruct(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
316 |
|
7485 | 317 |
public void fillFrom(Hog hog) { |
318 |
difficulty = hog.level; |
|
319 |
hat = hog.hat; |
|
320 |
name = hog.name; |
|
321 |
} |
|
322 |
||
323 |
public Hog toHog() { |
|
324 |
return new Hog(name, hat, difficulty); |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
325 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
326 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
327 |
public String name; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
328 |
public String hat; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
329 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
330 |
public int rounds; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
331 |
public int kills; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
332 |
public int deaths; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
333 |
public int suicides; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
334 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
335 |
public int difficulty; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
336 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
337 |
public int initialHealth; |
7485 | 338 |
public WeaponsetStruct.ByRef weaponset; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
339 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
340 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
341 |
static class TeamStruct extends Structure { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
342 |
public static class ByVal extends TeamStruct implements Structure.ByValue {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
343 |
public static class ByRef extends TeamStruct implements Structure.ByReference {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
344 |
private static String[] FIELD_ORDER = new String[] {"hogs", "name", "grave", "fort", "voicepack", "flag", "bindings", "bindingCount", "rounds", "wins", "campaignProgress", "colorIndex", "hogsInGame", "remoteDriven", "ownerName"}; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
345 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
346 |
public TeamStruct() { super(); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
347 |
public TeamStruct(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
348 |
|
7485 | 349 |
public void fillFrom(Team team, TeamIngameAttributes attrs) { |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
350 |
if(team != null) { |
7485 | 351 |
name = team.name; |
352 |
grave = team.grave; |
|
353 |
flag = team.flag; |
|
354 |
voicepack = team.voice; |
|
355 |
fort = team.fort; |
|
356 |
if(team.hogs.size() != Team.HEDGEHOGS_PER_TEAM) { |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
357 |
throw new IllegalArgumentException(); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
358 |
} |
7485 | 359 |
for(int i=0; i<hogs.length; i++) { |
360 |
hogs[i] = new HogStruct(); |
|
361 |
hogs[i].fillFrom(team.hogs.get(i)); |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
362 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
363 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
364 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
365 |
if(attrs != null) { |
7485 | 366 |
hogsInGame = attrs.hogCount; |
367 |
ownerName = attrs.ownerName; |
|
368 |
colorIndex = attrs.colorIndex; |
|
369 |
remoteDriven = attrs.remoteDriven; |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
370 |
} |
7485 | 371 |
} |
372 |
||
373 |
public void fillFrom(TeamInGame team, WeaponsetStruct.ByRef weaponset, int initialHealth) { |
|
374 |
fillFrom(team.team, team.ingameAttribs); |
|
375 |
for(int i=0; i<hogs.length; i++) { |
|
376 |
hogs[i].initialHealth = initialHealth; |
|
377 |
hogs[i].weaponset = weaponset; |
|
378 |
} |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
379 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
380 |
|
7485 | 381 |
public Team toTeam() { |
382 |
List<Hog> hogList = new ArrayList<Hog>(); |
|
383 |
for(int i=0; i<hogs.length; i++) { |
|
384 |
hogList.add(hogs[i].toHog()); |
|
385 |
} |
|
386 |
return new Team(name, grave, flag, voicepack, fort, hogList); |
|
387 |
} |
|
388 |
||
389 |
public TeamIngameAttributes toTeamIngameAttributes() { |
|
390 |
return new TeamIngameAttributes(ownerName, colorIndex, hogsInGame, remoteDriven); |
|
391 |
} |
|
392 |
||
393 |
public TeamInGame toTeamInGame() { |
|
394 |
return new TeamInGame(toTeam(), toTeamIngameAttributes()); |
|
395 |
} |
|
396 |
||
397 |
public HogStruct[] hogs = new HogStruct[Team.HEDGEHOGS_PER_TEAM]; |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
398 |
public String name; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
399 |
public String grave; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
400 |
public String fort; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
401 |
public String voicepack; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
402 |
public String flag; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
403 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
404 |
public Pointer bindings; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
405 |
public int bindingCount; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
406 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
407 |
public int rounds; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
408 |
public int wins; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
409 |
public int campaignProgress; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
410 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
411 |
public int colorIndex; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
412 |
public int hogsInGame; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
413 |
public boolean remoteDriven; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
414 |
public String ownerName; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
415 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
416 |
|
7485 | 417 |
static class WeaponsetStruct extends Structure { |
418 |
public static class ByVal extends WeaponsetStruct implements Structure.ByValue {} |
|
419 |
public static class ByRef extends WeaponsetStruct implements Structure.ByReference {} |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
420 |
private static String[] FIELD_ORDER = new String[] {"loadout", "crateprob", "crateammo", "delay", "name"}; |
7485 | 421 |
|
422 |
public WeaponsetStruct() { super(); setFieldOrder(FIELD_ORDER); } |
|
423 |
public WeaponsetStruct(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
|
424 |
||
425 |
public void fillFrom(Weaponset weaponset) { |
|
426 |
fillWeaponInfo(loadout, weaponset.loadout); |
|
427 |
fillWeaponInfo(crateprob, weaponset.crateProb); |
|
428 |
fillWeaponInfo(crateammo, weaponset.crateAmmo); |
|
429 |
fillWeaponInfo(delay, weaponset.delay); |
|
430 |
name = weaponset.name; |
|
431 |
} |
|
432 |
||
433 |
private static void fillWeaponInfo(byte[] array, String str) { |
|
434 |
for(int i=0; i<array.length-1; i++) { |
|
435 |
array[i] = (byte) (i<str.length() ? str.charAt(i) : '0'); |
|
436 |
} |
|
437 |
array[array.length-1] = (byte)0; |
|
438 |
} |
|
439 |
||
440 |
public Weaponset toWeaponset() { |
|
441 |
return new Weaponset(name, weaponInfoToString(loadout), weaponInfoToString(crateprob), weaponInfoToString(crateammo), weaponInfoToString(delay)); |
|
442 |
} |
|
443 |
||
444 |
private static String weaponInfoToString(byte[] array) { |
|
445 |
try { |
|
446 |
return new String(array, 0, array.length-1, "ASCII"); |
|
447 |
} catch (UnsupportedEncodingException e) { |
|
448 |
throw new AssertionError(); |
|
449 |
} |
|
450 |
} |
|
451 |
||
452 |
public byte[] loadout = new byte[Weaponset.WEAPONS_COUNT+1]; |
|
453 |
public byte[] crateprob = new byte[Weaponset.WEAPONS_COUNT+1]; |
|
454 |
public byte[] crateammo = new byte[Weaponset.WEAPONS_COUNT+1]; |
|
455 |
public byte[] delay = new byte[Weaponset.WEAPONS_COUNT+1]; |
|
456 |
public String name; |
|
457 |
} |
|
458 |
||
459 |
/** |
|
460 |
* Represents a flib_weaponset*, for use as part of a flib_weaponset** |
|
461 |
*/ |
|
462 |
static class WeaponsetPointerByReference extends Structure implements Structure.ByReference { |
|
463 |
private static String[] FIELD_ORDER = new String[] {"weaponset"}; |
|
464 |
||
465 |
public WeaponsetPointerByReference() { super(); setFieldOrder(FIELD_ORDER); } |
|
466 |
public WeaponsetPointerByReference(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
|
467 |
||
468 |
public WeaponsetStruct.ByRef weaponset; |
|
469 |
} |
|
470 |
||
471 |
static class WeaponsetListStruct extends Structure { |
|
472 |
public static class ByVal extends WeaponsetListStruct implements Structure.ByValue {} |
|
473 |
public static class ByRef extends WeaponsetListStruct implements Structure.ByReference {} |
|
474 |
private static String[] FIELD_ORDER = new String[] {"weaponsetCount", "weaponsets"}; |
|
475 |
||
476 |
public WeaponsetListStruct() { super(); setFieldOrder(FIELD_ORDER); } |
|
477 |
public WeaponsetListStruct(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
|
478 |
||
479 |
public void fillFrom(List<Weaponset> list) { |
|
480 |
weaponsetCount = list.size(); |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
481 |
if(weaponsetCount<=0) { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
482 |
weaponsets = null; |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
483 |
} else { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
484 |
weaponsets = new WeaponsetPointerByReference(); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
485 |
Structure[] structs = weaponsets.toArray(weaponsetCount); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
486 |
|
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
487 |
for(int i=0; i<weaponsetCount; i++) { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
488 |
WeaponsetPointerByReference pstruct = (WeaponsetPointerByReference)structs[i]; |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
489 |
pstruct.weaponset = new WeaponsetStruct.ByRef(); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
490 |
pstruct.weaponset.fillFrom(list.get(i)); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
491 |
} |
7485 | 492 |
} |
493 |
} |
|
494 |
||
495 |
/** |
|
496 |
* Only use on native-owned structs! |
|
497 |
* Calling this method on a Java-owned struct could cause garbage collection of referenced |
|
498 |
* structures. |
|
499 |
*/ |
|
500 |
public List<Weaponset> toWeaponsetList() { |
|
501 |
if(weaponsetCount<=0) { |
|
502 |
return new ArrayList<Weaponset>(); |
|
503 |
} else { |
|
504 |
List<Weaponset> list = new ArrayList<Weaponset>(weaponsetCount); |
|
505 |
Structure[] structs = weaponsets.toArray(weaponsetCount); |
|
506 |
||
507 |
for(int i=0; i<weaponsetCount; i++) { |
|
508 |
WeaponsetPointerByReference pstruct = (WeaponsetPointerByReference)structs[i]; |
|
509 |
list.add(pstruct.weaponset.toWeaponset()); |
|
510 |
} |
|
511 |
return list; |
|
512 |
} |
|
513 |
} |
|
514 |
||
515 |
public int weaponsetCount; |
|
516 |
public WeaponsetPointerByReference weaponsets; |
|
517 |
} |
|
518 |
||
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
519 |
static class RoomStruct extends Structure { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
520 |
public static class ByVal extends RoomStruct implements Structure.ByValue {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
521 |
public static class ByRef extends RoomStruct implements Structure.ByReference {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
522 |
private static String[] FIELD_ORDER = new String[] {"inProgress", "name", "playerCount", "teamCount", "owner", "map", "scheme", "weapons"}; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
523 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
524 |
public RoomStruct() { super(); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
525 |
public RoomStruct(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
7485 | 526 |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
527 |
public Room toRoomlistRoom() { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
528 |
return new Room(name, map, scheme, weapons, owner, playerCount, teamCount, inProgress); |
7485 | 529 |
} |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
530 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
531 |
public boolean inProgress; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
532 |
public String name; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
533 |
public int playerCount; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
534 |
public int teamCount; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
535 |
public String owner; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
536 |
public String map; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
537 |
public String scheme; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
538 |
public String weapons; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
539 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
540 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
541 |
static class MapRecipeStruct extends Structure { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
542 |
public static class ByVal extends MapRecipeStruct implements Structure.ByValue {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
543 |
public static class ByRef extends MapRecipeStruct implements Structure.ByReference {} |
7485 | 544 |
private static String[] FIELD_ORDER = new String[] {"mapgen", "name", "seed", "theme", "drawData", "drawDataSize", "templateFilter", "mazeSize"}; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
545 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
546 |
public MapRecipeStruct() { super(); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
547 |
public MapRecipeStruct(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
548 |
|
7485 | 549 |
public void fillFrom(MapRecipe map) { |
550 |
mapgen = map.mapgen; |
|
551 |
name = map.name; |
|
552 |
seed = map.seed; |
|
553 |
theme = map.theme; |
|
554 |
byte[] buf = map.getDrawData(); |
|
555 |
if(buf != null) { |
|
556 |
drawData = new Memory(buf.length); |
|
557 |
drawData.write(0, buf, 0, buf.length); |
|
558 |
drawDataSize = new NativeLong(buf.length); |
|
559 |
} else { |
|
560 |
drawData = null; |
|
561 |
drawDataSize = new NativeLong(0); |
|
562 |
} |
|
563 |
templateFilter = map.templateFilter; |
|
564 |
mazeSize = map.mazeSize; |
|
565 |
} |
|
566 |
||
567 |
public MapRecipe toMapRecipe() { |
|
568 |
byte[] buf = null; |
|
569 |
if(drawData != null && drawDataSize.intValue()>0) { |
|
570 |
buf = new byte[drawDataSize.intValue()]; |
|
571 |
drawData.read(0, buf, 0, drawDataSize.intValue()); |
|
572 |
} |
|
573 |
return new MapRecipe(mapgen, templateFilter, mazeSize, name, seed, theme, buf); |
|
574 |
} |
|
575 |
||
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
576 |
public int mapgen; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
577 |
public String name; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
578 |
public String seed; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
579 |
public String theme; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
580 |
public Pointer drawData; |
7485 | 581 |
public NativeLong drawDataSize; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
582 |
public int templateFilter; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
583 |
public int mazeSize; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
584 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
585 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
586 |
static class MetaschemeSettingStruct extends Structure { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
587 |
public static class ByVal extends MetaschemeSettingStruct implements Structure.ByValue {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
588 |
public static class ByRef extends MetaschemeSettingStruct implements Structure.ByReference {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
589 |
private static String[] FIELD_ORDER = new String[] {"name", "engineCommand", "maxMeansInfinity", "times1000", "min", "max", "def"}; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
590 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
591 |
public MetaschemeSettingStruct() { super(); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
592 |
public MetaschemeSettingStruct(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
593 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
594 |
public void fillFrom(Setting setting) { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
595 |
name = setting.name; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
596 |
engineCommand = setting.engineCommand; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
597 |
maxMeansInfinity = setting.maxMeansInfinity; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
598 |
times1000 = setting.times1000; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
599 |
min = setting.min; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
600 |
max = setting.max; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
601 |
def = setting.def; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
602 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
603 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
604 |
public MetaScheme.Setting toMetaSchemeSetting() { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
605 |
return new MetaScheme.Setting(name, engineCommand, maxMeansInfinity, times1000, min, max, def); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
606 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
607 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
608 |
public String name; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
609 |
public String engineCommand; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
610 |
public boolean maxMeansInfinity; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
611 |
public boolean times1000; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
612 |
public int min; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
613 |
public int max; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
614 |
public int def; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
615 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
616 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
617 |
static class MetaschemeModStruct extends Structure { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
618 |
public static class ByVal extends MetaschemeModStruct implements Structure.ByValue {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
619 |
public static class ByRef extends MetaschemeModStruct implements Structure.ByReference {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
620 |
private static String[] FIELD_ORDER = new String[] {"name", "bitmaskIndex"}; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
621 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
622 |
public MetaschemeModStruct() { super(); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
623 |
public MetaschemeModStruct(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
624 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
625 |
public void fillFrom(Mod mod) { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
626 |
name = mod.name; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
627 |
bitmaskIndex = mod.bitmaskIndex; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
628 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
629 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
630 |
public MetaScheme.Mod toMetaSchemeMod() { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
631 |
return new MetaScheme.Mod(name, bitmaskIndex); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
632 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
633 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
634 |
public String name; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
635 |
public int bitmaskIndex; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
636 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
637 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
638 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
639 |
static class MetaschemeStruct extends Structure { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
640 |
public static class ByVal extends MetaschemeStruct implements Structure.ByValue {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
641 |
public static class ByRef extends MetaschemeStruct implements Structure.ByReference {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
642 |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
643 |
private static String[] FIELD_ORDER = new String[] {"settingCount", "modCount", "settings", "mods"}; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
644 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
645 |
public MetaschemeStruct() { super(); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
646 |
public MetaschemeStruct(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
647 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
648 |
/** |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
649 |
* Only use on native-owned structs! |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
650 |
* Calling this method on a Java-owned struct could cause garbage collection of referenced |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
651 |
* structures. |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
652 |
*/ |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
653 |
public MetaScheme toMetaScheme() { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
654 |
List<MetaScheme.Setting> settingList = new ArrayList<MetaScheme.Setting>(settingCount); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
655 |
List<MetaScheme.Mod> modList = new ArrayList<MetaScheme.Mod>(modCount); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
656 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
657 |
Structure[] settingStructs = settings.toArray(settingCount); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
658 |
Structure[] modStructs = mods.toArray(modCount); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
659 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
660 |
for(int i=0; i<settingCount; i++) { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
661 |
MetaschemeSettingStruct mss = (MetaschemeSettingStruct)settingStructs[i]; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
662 |
settingList.add(mss.toMetaSchemeSetting()); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
663 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
664 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
665 |
for(int i=0; i<modCount; i++) { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
666 |
MetaschemeModStruct mms = (MetaschemeModStruct)modStructs[i]; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
667 |
modList.add(mms.toMetaSchemeMod()); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
668 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
669 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
670 |
return new MetaScheme(modList, settingList); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
671 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
672 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
673 |
public int settingCount; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
674 |
public int modCount; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
675 |
public MetaschemeSettingStruct.ByRef settings; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
676 |
public MetaschemeModStruct.ByRef mods; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
677 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
678 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
679 |
static class SchemeStruct extends Structure { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
680 |
public static class ByVal extends SchemeStruct implements Structure.ByValue {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
681 |
public static class ByRef extends SchemeStruct implements Structure.ByReference {} |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
682 |
private static String[] FIELD_ORDER = new String[] {"name", "settings", "mod"}; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
683 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
684 |
public SchemeStruct() { super(); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
685 |
public SchemeStruct(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
686 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
687 |
public void fillFrom(Scheme scheme) { |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
688 |
MetaScheme meta = MetaScheme.INSTANCE; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
689 |
name = scheme.name; |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
690 |
settings = new Memory(NATIVE_INT_SIZE * meta.settings.size()); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
691 |
for(int i=0; i<meta.settings.size(); i++) { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
692 |
Integer value = scheme.settings.get(meta.settings.get(i).name); |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
693 |
settings.setInt(NATIVE_INT_SIZE*i, value); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
694 |
} |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
695 |
mods = new Memory(NATIVE_BOOL_SIZE * meta.mods.size()); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
696 |
for(int i=0; i<meta.mods.size(); i++) { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
697 |
Boolean value = scheme.mods.get(meta.mods.get(i).name); |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
698 |
mods.setByte(NATIVE_BOOL_SIZE*i, (byte)(value ? 1 : 0)); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
699 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
700 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
701 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
702 |
public Scheme toScheme() { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
703 |
Map<String, Integer> settingsMap = new HashMap<String, Integer>(); |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
704 |
MetaScheme meta = MetaScheme.INSTANCE; |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
705 |
for(int i=0; i<meta.settings.size(); i++) { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
706 |
settingsMap.put(meta.settings.get(i).name, settings.getInt(NATIVE_INT_SIZE*i)); |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
707 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
708 |
Map<String, Boolean> modsMap = new HashMap<String, Boolean>(); |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
709 |
for(int i=0; i<meta.mods.size(); i++) { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
710 |
modsMap.put(meta.mods.get(i).name, mods.getByte(i) != 0 ? Boolean.TRUE : Boolean.FALSE); |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
711 |
} |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
712 |
return new Scheme(name, settingsMap, modsMap); |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
713 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
714 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
715 |
public String name; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
716 |
public Pointer settings; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
717 |
public Pointer mods; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
718 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
719 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
720 |
/** |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
721 |
* Represents a flib_scheme*, for use as part of a flib_scheme** |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
722 |
*/ |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
723 |
static class SchemePointerByReference extends Structure implements Structure.ByReference { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
724 |
private static String[] FIELD_ORDER = new String[] {"scheme"}; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
725 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
726 |
public SchemePointerByReference() { super(); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
727 |
public SchemePointerByReference(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
728 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
729 |
public SchemeStruct.ByRef scheme; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
730 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
731 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
732 |
static class SchemelistStruct extends Structure { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
733 |
public static class ByVal extends SchemelistStruct implements Structure.ByValue {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
734 |
public static class ByRef extends SchemelistStruct implements Structure.ByReference {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
735 |
private static String[] FIELD_ORDER = new String[] {"schemeCount", "schemes"}; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
736 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
737 |
public SchemelistStruct() { super(); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
738 |
public SchemelistStruct(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
739 |
|
7485 | 740 |
public void fillFrom(List<Scheme> schemeList) { |
741 |
schemeCount = schemeList.size(); |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
742 |
if(schemeCount<=0) { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
743 |
schemes = null; |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
744 |
} else { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
745 |
schemes = new SchemePointerByReference(); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
746 |
Structure[] schemePtrStructs = schemes.toArray(schemeCount); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
747 |
|
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
748 |
for(int i=0; i<this.schemeCount; i++) { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
749 |
SchemePointerByReference spbr = (SchemePointerByReference)schemePtrStructs[i]; |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
750 |
spbr.scheme = new SchemeStruct.ByRef(); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
751 |
spbr.scheme.fillFrom(schemeList.get(i)); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
752 |
} |
7485 | 753 |
} |
754 |
} |
|
755 |
||
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
756 |
/** |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
757 |
* Only use on native-owned structs! |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
758 |
* Calling this method on a Java-owned struct could cause garbage collection of referenced |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
759 |
* structures. |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
760 |
*/ |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
761 |
public List<Scheme> toSchemeList() { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
762 |
if(schemeCount<=0) { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
763 |
return new ArrayList<Scheme>(); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
764 |
} else { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
765 |
List<Scheme> schemeList = new ArrayList<Scheme>(schemeCount); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
766 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
767 |
Structure[] schemePtrStructs = schemes.toArray(schemeCount); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
768 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
769 |
for(int i=0; i<schemeCount; i++) { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
770 |
SchemePointerByReference spbr2 = (SchemePointerByReference)schemePtrStructs[i]; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
771 |
schemeList.add(spbr2.scheme.toScheme()); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
772 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
773 |
return schemeList; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
774 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
775 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
776 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
777 |
public int schemeCount; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
778 |
public SchemePointerByReference schemes; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
779 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
780 |
|
7485 | 781 |
/** |
782 |
* Represents a flib_team*, for use as part of a flib_team** |
|
783 |
*/ |
|
784 |
static class TeamPointerByReference extends Structure implements Structure.ByReference { |
|
785 |
private static String[] FIELD_ORDER = new String[] {"team"}; |
|
786 |
||
787 |
public TeamPointerByReference() { super(); setFieldOrder(FIELD_ORDER); } |
|
788 |
public TeamPointerByReference(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
|
789 |
||
790 |
public TeamStruct.ByRef team; |
|
791 |
} |
|
792 |
||
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
793 |
static class TeamlistStruct extends Structure { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
794 |
public static class ByVal extends TeamlistStruct implements Structure.ByValue {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
795 |
public static class ByRef extends TeamlistStruct implements Structure.ByReference {} |
7485 | 796 |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
797 |
private static String[] FIELD_ORDER = new String[] {"teamCount", "teams"}; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
798 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
799 |
public TeamlistStruct() { super(); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
800 |
public TeamlistStruct(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
801 |
|
7485 | 802 |
public void fillFrom(List<TeamInGame> teamList, WeaponsetStruct.ByRef weaponset, int initialHealth) { |
803 |
teamCount = teamList.size(); |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
804 |
if(teamCount <= 0) { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
805 |
teams = null; |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
806 |
} else { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
807 |
teams = new TeamPointerByReference(); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
808 |
Structure[] teamPtrStructs = teams.toArray(teamCount); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
809 |
|
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
810 |
for(int i=0; i<this.teamCount; i++) { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
811 |
TeamPointerByReference tpbr = (TeamPointerByReference)teamPtrStructs[i]; |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
812 |
tpbr.team = new TeamStruct.ByRef(); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
813 |
tpbr.team.fillFrom(teamList.get(i), weaponset, initialHealth); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
814 |
} |
7485 | 815 |
} |
816 |
} |
|
817 |
||
818 |
public List<TeamInGame> toTeamInGameList() { |
|
819 |
if(teamCount<=0) { |
|
820 |
return new ArrayList<TeamInGame>(); |
|
821 |
} else { |
|
822 |
List<TeamInGame> result = new ArrayList<TeamInGame>(teamCount); |
|
823 |
Structure[] structs = teams.toArray(teamCount); |
|
824 |
||
825 |
for(int i=0; i<teamCount; i++) { |
|
826 |
TeamPointerByReference struct = (TeamPointerByReference)structs[i]; |
|
827 |
result.add(struct.team.toTeamInGame()); |
|
828 |
} |
|
829 |
return result; |
|
830 |
} |
|
831 |
} |
|
832 |
||
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
833 |
public int teamCount; |
7485 | 834 |
public TeamPointerByReference teams; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
835 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
836 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
837 |
static class GameSetupStruct extends Structure { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
838 |
public static class ByVal extends GameSetupStruct implements Structure.ByValue {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
839 |
public static class ByRef extends GameSetupStruct implements Structure.ByReference {} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
840 |
private static String[] FIELD_ORDER = new String[] {"script", "gamescheme", "map", "teamlist"}; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
841 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
842 |
public GameSetupStruct() { super(); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
843 |
public GameSetupStruct(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); } |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
844 |
|
7485 | 845 |
public void fillFrom(GameConfig conf) { |
846 |
script = conf.style; |
|
847 |
gamescheme = new SchemeStruct.ByRef(); |
|
848 |
gamescheme.fillFrom(conf.scheme); |
|
849 |
map = new MapRecipeStruct.ByRef(); |
|
850 |
map.fillFrom(conf.map); |
|
851 |
||
852 |
/* |
|
853 |
* At this point we deviate from the usual copying pattern because the frontlib |
|
854 |
* expects per-hog weapons and initial health, but the UI models them as per- |
|
855 |
* game, so we extract them from the config here and pass them on to be included |
|
856 |
* in each hog. |
|
857 |
*/ |
|
858 |
WeaponsetStruct.ByRef wss = new WeaponsetStruct.ByRef(); |
|
859 |
wss.fillFrom(conf.weaponset); |
|
860 |
int initialHealth = conf.scheme.getHealth(); |
|
861 |
||
862 |
teamlist = new TeamlistStruct.ByRef(); |
|
863 |
teamlist.fillFrom(conf.teams, wss, initialHealth); |
|
864 |
} |
|
865 |
||
866 |
public GameConfig toGameConfig() { |
|
867 |
Scheme scheme = gamescheme != null ? gamescheme.toScheme() : null; |
|
868 |
MapRecipe mapRecipe = map != null ? map.toMapRecipe() : null; |
|
869 |
List<TeamInGame> teams = teamlist != null ? teamlist.toTeamInGameList() : null; |
|
870 |
||
871 |
WeaponsetStruct weaponsetStruct = teamlist != null && teamlist.teamCount>0 ? teamlist.teams.team.hogs[0].weaponset : null; |
|
872 |
Weaponset weaponset = weaponsetStruct != null ? weaponsetStruct.toWeaponset() : null; |
|
873 |
return new GameConfig(script, scheme, mapRecipe, teams, weaponset); |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
874 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
875 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
876 |
public String script; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
877 |
public SchemeStruct.ByRef gamescheme; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
878 |
public MapRecipeStruct.ByRef map; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
879 |
public TeamlistStruct.ByRef teamlist; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
880 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
881 |
|
7485 | 882 |
/* |
883 |
* Callback interfaces. The context parameter is never needed here and |
|
884 |
* should always be ignored. Be sure to keep a reference to each callback |
|
885 |
* for as long as they might be called by native code, to avoid premature |
|
886 |
* garbage collection. |
|
887 |
*/ |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
888 |
public static interface VoidCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
889 |
void callback(Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
890 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
891 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
892 |
public static interface StrCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
893 |
void callback(Pointer context, String arg1); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
894 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
895 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
896 |
public static interface IntCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
897 |
void callback(Pointer context, int arg1); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
898 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
899 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
900 |
public static interface IntStrCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
901 |
void callback(Pointer context, int arg1, String arg2); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
902 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
903 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
904 |
public static interface StrIntCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
905 |
void callback(Pointer context, String arg1, int arg2); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
906 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
907 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
908 |
public static interface StrStrCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
909 |
void callback(Pointer context, String arg1, String arg2); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
910 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
911 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
912 |
public static interface RoomCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
913 |
void callback(Pointer context, RoomPtr arg1); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
914 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
915 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
916 |
public static interface RoomListCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
917 |
void callback(Pointer context, RoomArrayPtr arg1, int count); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
918 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
919 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
920 |
public static interface StrRoomCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
921 |
void callback(Pointer context, String arg1, RoomPtr arg2); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
922 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
923 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
924 |
public static interface BoolCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
925 |
void callback(Pointer context, boolean arg1); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
926 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
927 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
928 |
public static interface StrBoolCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
929 |
void callback(Pointer context, String arg1, boolean arg2); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
930 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
931 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
932 |
public static interface TeamCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
933 |
void callback(Pointer context, TeamPtr arg1); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
934 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
935 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
936 |
public static interface BytesCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
937 |
void callback(Pointer context, Pointer buffer, NativeLong size); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
938 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
939 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
940 |
public static interface BytesBoolCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
941 |
void callback(Pointer context, Pointer buffer, NativeLong size, boolean arg3); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
942 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
943 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
944 |
public static interface SchemeCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
945 |
void callback(Pointer context, SchemePtr arg1); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
946 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
947 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
948 |
public static interface MapIntCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
949 |
void callback(Pointer context, MapRecipePtr arg1, int arg2); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
950 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
951 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
952 |
public static interface WeaponsetCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
953 |
void callback(Pointer context, WeaponsetPtr arg1); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
954 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
955 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
956 |
public static interface MapimageCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
957 |
void callback(Pointer context, Pointer buffer, int hedgehogCount); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
958 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
959 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
960 |
public static interface LogCallback extends Callback { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
961 |
void callback(int level, String logMessage); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
962 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
963 |
|
7485 | 964 |
// frontlib.h |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
965 |
int flib_init(); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
966 |
void flib_quit(); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
967 |
|
7485 | 968 |
// hwconsts.h |
969 |
int flib_get_teamcolor(int colorIndex); |
|
970 |
int flib_get_teamcolor_count(); |
|
971 |
int flib_get_hedgehogs_per_team(); |
|
972 |
int flib_get_weapons_count(); |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
973 |
MetaschemePtr flib_get_metascheme(); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
974 |
|
7485 | 975 |
// net/netconn.h |
976 |
static final int NETCONN_STATE_CONNECTING = 0; |
|
977 |
static final int NETCONN_STATE_LOBBY = 1; |
|
978 |
static final int NETCONN_STATE_ROOM = 2; |
|
979 |
static final int NETCONN_STATE_DISCONNECTED = 10; |
|
980 |
||
981 |
static final int NETCONN_DISCONNECT_NORMAL = 0; |
|
982 |
static final int NETCONN_DISCONNECT_SERVER_TOO_OLD = 1; |
|
983 |
static final int NETCONN_DISCONNECT_AUTH_FAILED = 2; |
|
984 |
static final int NETCONN_DISCONNECT_CONNLOST = 3; |
|
985 |
static final int NETCONN_DISCONNECT_INTERNAL_ERROR = 100; |
|
986 |
||
987 |
static final int NETCONN_ROOMLEAVE_ABANDONED = 0; |
|
988 |
static final int NETCONN_ROOMLEAVE_KICKED = 1; |
|
989 |
||
990 |
static final int NETCONN_MSG_TYPE_PLAYERINFO = 0; |
|
991 |
static final int NETCONN_MSG_TYPE_SERVERMESSAGE = 1; |
|
992 |
static final int NETCONN_MSG_TYPE_WARNING = 2; |
|
993 |
static final int NETCONN_MSG_TYPE_ERROR = 3; |
|
994 |
||
995 |
static final int NETCONN_MAPCHANGE_FULL = 0; |
|
996 |
static final int NETCONN_MAPCHANGE_MAP = 1; |
|
997 |
static final int NETCONN_MAPCHANGE_MAPGEN = 2; |
|
998 |
static final int NETCONN_MAPCHANGE_DRAWNMAP = 3; |
|
999 |
static final int NETCONN_MAPCHANGE_MAZE_SIZE = 4; |
|
1000 |
static final int NETCONN_MAPCHANGE_TEMPLATE = 5; |
|
1001 |
static final int NETCONN_MAPCHANGE_THEME = 6; |
|
1002 |
static final int NETCONN_MAPCHANGE_SEED = 7; |
|
1003 |
||
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
1004 |
NetconnPtr flib_netconn_create(String playerName, String dataDirPath, String host, int port); |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1005 |
void flib_netconn_destroy(NetconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1006 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1007 |
void flib_netconn_tick(NetconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1008 |
boolean flib_netconn_is_chief(NetconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1009 |
String flib_netconn_get_playername(NetconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1010 |
GameSetupPtr flib_netconn_create_gamesetup(NetconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1011 |
int flib_netconn_send_quit(NetconnPtr conn, String quitmsg); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1012 |
int flib_netconn_send_chat(NetconnPtr conn, String chat); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1013 |
int flib_netconn_send_teamchat(NetconnPtr conn, String msg); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1014 |
int flib_netconn_send_password(NetconnPtr conn, String passwd); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1015 |
int flib_netconn_send_nick(NetconnPtr conn, String nick); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1016 |
int flib_netconn_send_request_roomlist(NetconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1017 |
int flib_netconn_send_joinRoom(NetconnPtr conn, String room); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1018 |
int flib_netconn_send_createRoom(NetconnPtr conn, String room); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1019 |
int flib_netconn_send_renameRoom(NetconnPtr conn, String roomName); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1020 |
int flib_netconn_send_leaveRoom(NetconnPtr conn, String msg); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1021 |
int flib_netconn_send_toggleReady(NetconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1022 |
int flib_netconn_send_addTeam(NetconnPtr conn, TeamPtr team); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1023 |
int flib_netconn_send_removeTeam(NetconnPtr conn, String teamname); |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
1024 |
int flib_netconn_send_engineMessage(NetconnPtr conn, Pointer message, NativeLong size); |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1025 |
int flib_netconn_send_teamHogCount(NetconnPtr conn, String teamname, int hogcount); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1026 |
int flib_netconn_send_teamColor(NetconnPtr conn, String teamname, int colorIndex); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1027 |
int flib_netconn_send_weaponset(NetconnPtr conn, WeaponsetPtr weaponset); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1028 |
int flib_netconn_send_map(NetconnPtr conn, MapRecipePtr map); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1029 |
int flib_netconn_send_mapName(NetconnPtr conn, String mapName); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1030 |
int flib_netconn_send_mapGen(NetconnPtr conn, int mapGen); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1031 |
int flib_netconn_send_mapTemplate(NetconnPtr conn, int templateFilter); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1032 |
int flib_netconn_send_mapMazeSize(NetconnPtr conn, int mazeSize); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1033 |
int flib_netconn_send_mapSeed(NetconnPtr conn, String seed); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1034 |
int flib_netconn_send_mapTheme(NetconnPtr conn, String theme); |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
1035 |
int flib_netconn_send_mapDrawdata(NetconnPtr conn, Pointer drawData, NativeLong size); |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1036 |
int flib_netconn_send_script(NetconnPtr conn, String scriptName); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1037 |
int flib_netconn_send_scheme(NetconnPtr conn, SchemePtr scheme); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1038 |
int flib_netconn_send_roundfinished(NetconnPtr conn, boolean withoutError); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1039 |
int flib_netconn_send_ban(NetconnPtr conn, String playerName); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1040 |
int flib_netconn_send_kick(NetconnPtr conn, String playerName); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1041 |
int flib_netconn_send_playerInfo(NetconnPtr conn, String playerName); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1042 |
int flib_netconn_send_playerFollow(NetconnPtr conn, String playerName); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1043 |
int flib_netconn_send_startGame(NetconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1044 |
int flib_netconn_send_toggleRestrictJoins(NetconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1045 |
int flib_netconn_send_toggleRestrictTeams(NetconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1046 |
int flib_netconn_send_clearAccountsCache(NetconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1047 |
int flib_netconn_send_setServerVar(NetconnPtr conn, String name, String value); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1048 |
int flib_netconn_send_getServerVars(NetconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1049 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1050 |
void flib_netconn_onMessage(NetconnPtr conn, IntStrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1051 |
void flib_netconn_onChat(NetconnPtr conn, StrStrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1052 |
void flib_netconn_onConnected(NetconnPtr conn, VoidCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1053 |
void flib_netconn_onDisconnected(NetconnPtr conn, IntStrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1054 |
void flib_netconn_onRoomlist(NetconnPtr conn, RoomListCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1055 |
void flib_netconn_onRoomAdd(NetconnPtr conn, RoomCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1056 |
void flib_netconn_onRoomDelete(NetconnPtr conn, StrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1057 |
void flib_netconn_onRoomUpdate(NetconnPtr conn, StrRoomCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1058 |
void flib_netconn_onLobbyJoin(NetconnPtr conn, StrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1059 |
void flib_netconn_onLobbyLeave(NetconnPtr conn, StrStrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1060 |
void flib_netconn_onNickTaken(NetconnPtr conn, StrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1061 |
void flib_netconn_onPasswordRequest(NetconnPtr conn, StrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1062 |
void flib_netconn_onEnterRoom(NetconnPtr conn, BoolCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1063 |
void flib_netconn_onRoomChiefStatus(NetconnPtr conn, BoolCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1064 |
void flib_netconn_onReadyState(NetconnPtr conn, StrBoolCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1065 |
void flib_netconn_onLeaveRoom(NetconnPtr conn, IntStrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1066 |
void flib_netconn_onTeamAdd(NetconnPtr conn, TeamCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1067 |
void flib_netconn_onTeamDelete(NetconnPtr conn, StrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1068 |
void flib_netconn_onRoomJoin(NetconnPtr conn, StrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1069 |
void flib_netconn_onRoomLeave(NetconnPtr conn, StrStrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1070 |
void flib_netconn_onRunGame(NetconnPtr conn, VoidCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1071 |
void flib_netconn_onTeamAccepted(NetconnPtr conn, StrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1072 |
void flib_netconn_onHogCountChanged(NetconnPtr conn, StrIntCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1073 |
void flib_netconn_onTeamColorChanged(NetconnPtr conn, StrIntCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1074 |
void flib_netconn_onEngineMessage(NetconnPtr conn, BytesCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1075 |
void flib_netconn_onCfgScheme(NetconnPtr conn, SchemeCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1076 |
void flib_netconn_onMapChanged(NetconnPtr conn, MapIntCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1077 |
void flib_netconn_onScriptChanged(NetconnPtr conn, StrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1078 |
void flib_netconn_onWeaponsetChanged(NetconnPtr conn, WeaponsetCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1079 |
void flib_netconn_onAdminAccess(NetconnPtr conn, VoidCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1080 |
void flib_netconn_onServerVar(NetconnPtr conn, StrStrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1081 |
|
7485 | 1082 |
// ipc/gameconn.h |
1083 |
static final int GAME_END_FINISHED = 0; |
|
1084 |
static final int GAME_END_INTERRUPTED = 1; |
|
1085 |
static final int GAME_END_HALTED = 2; |
|
1086 |
static final int GAME_END_ERROR = 3; |
|
1087 |
||
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1088 |
GameconnPtr flib_gameconn_create(String playerName, GameSetupPtr setup, boolean netgame); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1089 |
GameconnPtr flib_gameconn_create_playdemo(Buffer demo, NativeLong size); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1090 |
GameconnPtr flib_gameconn_create_loadgame(String playerName, Buffer save, NativeLong size); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1091 |
GameconnPtr flib_gameconn_create_campaign(String playerName, String seed, String script); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1092 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1093 |
void flib_gameconn_destroy(GameconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1094 |
int flib_gameconn_getport(GameconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1095 |
void flib_gameconn_tick(GameconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1096 |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
1097 |
int flib_gameconn_send_enginemsg(GameconnPtr conn, Pointer data, NativeLong len); |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1098 |
int flib_gameconn_send_textmsg(GameconnPtr conn, int msgtype, String msg); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1099 |
int flib_gameconn_send_chatmsg(GameconnPtr conn, String playername, String msg); |
7485 | 1100 |
int flib_gameconn_send_quit(GameconnPtr conn); |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1101 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1102 |
void flib_gameconn_onConnect(GameconnPtr conn, VoidCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1103 |
void flib_gameconn_onDisconnect(GameconnPtr conn, IntCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1104 |
void flib_gameconn_onErrorMessage(GameconnPtr conn, StrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1105 |
void flib_gameconn_onChat(GameconnPtr conn, StrBoolCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1106 |
void flib_gameconn_onGameRecorded(GameconnPtr conn, BytesBoolCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1107 |
void flib_gameconn_onEngineMessage(GameconnPtr conn, BytesCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1108 |
|
7485 | 1109 |
// ipc/mapconn.h |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
1110 |
public static final int MAPIMAGE_WIDTH = 256; |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
1111 |
public static final int MAPIMAGE_HEIGHT = 128; |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
1112 |
public static final int MAPIMAGE_BYTES = (MAPIMAGE_WIDTH/8*MAPIMAGE_HEIGHT); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
1113 |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1114 |
MapconnPtr flib_mapconn_create(MapRecipePtr mapdesc); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1115 |
void flib_mapconn_destroy(MapconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1116 |
int flib_mapconn_getport(MapconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1117 |
void flib_mapconn_onSuccess(MapconnPtr conn, MapimageCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1118 |
void flib_mapconn_onFailure(MapconnPtr conn, StrCallback callback, Pointer context); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1119 |
void flib_mapconn_tick(MapconnPtr conn); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1120 |
|
7485 | 1121 |
// model/map.h |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1122 |
public static final int MAPGEN_REGULAR = 0; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1123 |
public static final int MAPGEN_MAZE = 1; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1124 |
public static final int MAPGEN_DRAWN = 2; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1125 |
public static final int MAPGEN_NAMED = 3; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1126 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1127 |
public static final int TEMPLATEFILTER_ALL = 0; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1128 |
public static final int TEMPLATEFILTER_SMALL = 1; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1129 |
public static final int TEMPLATEFILTER_MEDIUM = 2; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1130 |
public static final int TEMPLATEFILTER_LARGE = 3; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1131 |
public static final int TEMPLATEFILTER_CAVERN = 4; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1132 |
public static final int TEMPLATEFILTER_WACKY = 5; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1133 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1134 |
public static final int MAZE_SIZE_SMALL_TUNNELS = 0; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1135 |
public static final int MAZE_SIZE_MEDIUM_TUNNELS = 1; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1136 |
public static final int MAZE_SIZE_LARGE_TUNNELS = 2; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1137 |
public static final int MAZE_SIZE_SMALL_ISLANDS = 3; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1138 |
public static final int MAZE_SIZE_MEDIUM_ISLANDS = 4; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1139 |
public static final int MAZE_SIZE_LARGE_ISLANDS = 5; |
7485 | 1140 |
|
1141 |
// model/schemelist.h |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
1142 |
SchemelistPtr flib_schemelist_from_ini(String filename); |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1143 |
int flib_schemelist_to_ini(String filename, SchemelistPtr list); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1144 |
void flib_schemelist_destroy(SchemelistPtr list); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1145 |
|
7485 | 1146 |
// model/team.h |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1147 |
TeamPtr flib_team_from_ini(String filename); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1148 |
int flib_team_to_ini(String filename, TeamPtr team); |
7485 | 1149 |
void flib_team_destroy(TeamPtr team); |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1150 |
|
7485 | 1151 |
// model/weapon.h |
1152 |
WeaponsetListPtr flib_weaponsetlist_from_ini(String filename); |
|
1153 |
int flib_weaponsetlist_to_ini(String filename, WeaponsetListPtr weaponsets); |
|
1154 |
void flib_weaponsetlist_destroy(WeaponsetListPtr list); |
|
1155 |
||
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
1156 |
// model/gamesetup.h |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
1157 |
void flib_gamesetup_destroy(GameSetupPtr gamesetup); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
1158 |
|
7485 | 1159 |
// util/logging.h |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1160 |
public static final int FLIB_LOGLEVEL_ALL = -100; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1161 |
public static final int FLIB_LOGLEVEL_DEBUG = -1; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1162 |
public static final int FLIB_LOGLEVEL_INFO = 0; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1163 |
public static final int FLIB_LOGLEVEL_WARNING = 1; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1164 |
public static final int FLIB_LOGLEVEL_ERROR = 2; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1165 |
public static final int FLIB_LOGLEVEL_NONE = 100; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1166 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1167 |
void flib_log_setLevel(int level); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1168 |
void flib_log_setCallback(LogCallback callback); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1169 |
} |