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