7482
|
1 |
/*
|
|
2 |
* Hedgewars, a free turn based strategy game
|
|
3 |
* Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or
|
|
6 |
* modify it under the terms of the GNU General Public License
|
|
7 |
* as published by the Free Software Foundation; either version 2
|
|
8 |
* of the License, or (at your option) any later version.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
18 |
*/
|
|
19 |
|
|
20 |
/*
|
|
21 |
* This file is not directly part of the frontlib and is not required to build it.
|
|
22 |
* However, it is recommended to include it in compilation when building for Android. The purpose of this file
|
|
23 |
* is to ensure consistency between the function signatures of the JNA Java bindings of the Android port and the
|
|
24 |
* frontlib functions.
|
|
25 |
*
|
|
26 |
* This file, in essence, consists only of function declarations. They are duplicates of function declarations
|
|
27 |
* from the frontlib headers that are referenced from JNA bindings. If the signature of one of these functions
|
|
28 |
* changes in the frontlib, it will no longer match the signature in this file, and the compiler will show an error.
|
|
29 |
* If that happens, you need to update the JNA bindings in Hedgeroid to match the new function signature, and then
|
|
30 |
* update this file.
|
|
31 |
*
|
|
32 |
* The reason for all this is that JNA does not actually know the function signatures of the functions it binds,
|
|
33 |
* it derives them from Java method declarations. If those do not match the actual function signatures, you will
|
|
34 |
* only notice when you suddenly get strange (and possibly hard to track down) problems at runtime. This file is
|
|
35 |
* an attempt to detect these problems at compile time instead. Notice that it will NOT detect changes to structs
|
|
36 |
* or constants though, which also require updates to the JNA bindings.
|
|
37 |
*/
|
|
38 |
|
|
39 |
/*
|
|
40 |
* Before we include the frontlib headers, we define away the const keyword. This is necessary because there is no
|
|
41 |
* distinction between const and non-const types on the JNA side, and we don't want the compiler to complain because
|
|
42 |
* of bad constness.
|
|
43 |
*
|
|
44 |
* This is so evil, but it works...
|
|
45 |
*/
|
|
46 |
#define const
|
|
47 |
|
|
48 |
#include "../frontlib.h"
|
|
49 |
|
|
50 |
/*
|
|
51 |
* Now we map the Java types to the corresponding C types...
|
|
52 |
*/
|
|
53 |
typedef flib_netconn *NetconnPtr;
|
|
54 |
typedef flib_gameconn *GameconnPtr;
|
|
55 |
typedef flib_mapconn *MapconnPtr;
|
|
56 |
typedef flib_metascheme *MetaschemePtr;
|
|
57 |
typedef flib_room **RoomArrayPtr;
|
|
58 |
typedef flib_weaponset *WeaponsetPtr;
|
|
59 |
typedef flib_weaponsetlist *WeaponsetListPtr;
|
|
60 |
typedef flib_map *MapRecipePtr;
|
|
61 |
typedef flib_scheme *SchemePtr;
|
|
62 |
typedef flib_schemelist *SchemelistPtr;
|
|
63 |
|
|
64 |
typedef flib_room *RoomPtr;
|
|
65 |
typedef flib_team *TeamPtr;
|
|
66 |
typedef flib_gamesetup *GameSetupPtr;
|
|
67 |
typedef bool boolean;
|
|
68 |
typedef size_t NativeLong;
|
|
69 |
typedef void *Pointer;
|
|
70 |
typedef char *String;
|
|
71 |
typedef uint8_t *Buffer;
|
|
72 |
|
|
73 |
/*
|
|
74 |
* Mapping callback types
|
|
75 |
*/
|
|
76 |
typedef void (*VoidCallback)(Pointer context);
|
|
77 |
typedef void (*StrCallback)(Pointer context, String arg1);
|
|
78 |
typedef void (*IntCallback)(Pointer context, int arg1);
|
|
79 |
typedef void (*IntStrCallback)(Pointer context, int arg1, String arg2);
|
|
80 |
typedef void (*StrIntCallback)(Pointer context, String arg1, int arg2);
|
|
81 |
typedef void (*StrStrCallback)(Pointer context, String arg1, String arg2);
|
|
82 |
typedef void (*RoomCallback)(Pointer context, RoomPtr arg1);
|
|
83 |
typedef void (*RoomListCallback)(Pointer context, RoomArrayPtr arg1, int arg2);
|
|
84 |
typedef void (*StrRoomCallback)(Pointer context, String arg1, RoomPtr arg2);
|
|
85 |
typedef void (*BoolCallback)(Pointer context, boolean arg1);
|
|
86 |
typedef void (*StrBoolCallback)(Pointer context, String arg1, boolean arg2);
|
|
87 |
typedef void (*TeamCallback)(Pointer context, TeamPtr arg1);
|
|
88 |
typedef void (*BytesCallback)(Pointer context, const uint8_t *buffer, NativeLong size);
|
|
89 |
typedef void (*BytesBoolCallback)(Pointer context, const uint8_t *buffer, NativeLong size, boolean arg3);
|
|
90 |
typedef void (*SchemeCallback)(Pointer context, SchemePtr arg1);
|
|
91 |
typedef void (*MapIntCallback)(Pointer context, MapRecipePtr arg1, int arg2);
|
|
92 |
typedef void (*WeaponsetCallback)(Pointer context, WeaponsetPtr arg1);
|
|
93 |
typedef void (*MapimageCallback)(Pointer context, const uint8_t *mapimage, int hogs);
|
|
94 |
typedef void (*LogCallback)(int arg1, String arg2);
|
|
95 |
|
|
96 |
/*
|
|
97 |
* Below here are the copypasted method declarations from the JNA bindings
|
|
98 |
*/
|
|
99 |
|
|
100 |
// frontlib.h
|
|
101 |
int flib_init();
|
|
102 |
void flib_quit();
|
|
103 |
|
7497
|
104 |
// hwconsts.h
|
|
105 |
int flib_get_teamcolor_count();
|
|
106 |
int flib_get_hedgehogs_per_team();
|
|
107 |
int flib_get_weapons_count();
|
|
108 |
|
7482
|
109 |
// net/netconn.h
|
7497
|
110 |
NetconnPtr flib_netconn_create(String playerName, String dataDirPath, String host, int port);
|
7482
|
111 |
void flib_netconn_destroy(NetconnPtr conn);
|
|
112 |
|
|
113 |
void flib_netconn_tick(NetconnPtr conn);
|
|
114 |
boolean flib_netconn_is_chief(NetconnPtr conn);
|
|
115 |
String flib_netconn_get_playername(NetconnPtr conn);
|
|
116 |
GameSetupPtr flib_netconn_create_gamesetup(NetconnPtr conn);
|
|
117 |
int flib_netconn_send_quit(NetconnPtr conn, String quitmsg);
|
|
118 |
int flib_netconn_send_chat(NetconnPtr conn, String chat);
|
|
119 |
int flib_netconn_send_teamchat(NetconnPtr conn, String msg);
|
|
120 |
int flib_netconn_send_password(NetconnPtr conn, String passwd);
|
|
121 |
int flib_netconn_send_nick(NetconnPtr conn, String nick);
|
|
122 |
int flib_netconn_send_request_roomlist(NetconnPtr conn);
|
|
123 |
int flib_netconn_send_joinRoom(NetconnPtr conn, String room);
|
|
124 |
int flib_netconn_send_createRoom(NetconnPtr conn, String room);
|
|
125 |
int flib_netconn_send_renameRoom(NetconnPtr conn, String roomName);
|
|
126 |
int flib_netconn_send_leaveRoom(NetconnPtr conn, String msg);
|
|
127 |
int flib_netconn_send_toggleReady(NetconnPtr conn);
|
|
128 |
int flib_netconn_send_addTeam(NetconnPtr conn, TeamPtr team);
|
|
129 |
int flib_netconn_send_removeTeam(NetconnPtr conn, String teamname);
|
|
130 |
int flib_netconn_send_teamHogCount(NetconnPtr conn, String teamname, int hogcount);
|
|
131 |
int flib_netconn_send_teamColor(NetconnPtr conn, String teamname, int colorIndex);
|
|
132 |
int flib_netconn_send_weaponset(NetconnPtr conn, WeaponsetPtr weaponset);
|
|
133 |
int flib_netconn_send_map(NetconnPtr conn, MapRecipePtr map);
|
|
134 |
int flib_netconn_send_mapName(NetconnPtr conn, String mapName);
|
|
135 |
int flib_netconn_send_mapGen(NetconnPtr conn, int mapGen);
|
|
136 |
int flib_netconn_send_mapTemplate(NetconnPtr conn, int templateFilter);
|
|
137 |
int flib_netconn_send_mapMazeSize(NetconnPtr conn, int mazeSize);
|
|
138 |
int flib_netconn_send_mapSeed(NetconnPtr conn, String seed);
|
|
139 |
int flib_netconn_send_mapTheme(NetconnPtr conn, String theme);
|
|
140 |
int flib_netconn_send_script(NetconnPtr conn, String scriptName);
|
|
141 |
int flib_netconn_send_scheme(NetconnPtr conn, SchemePtr scheme);
|
|
142 |
int flib_netconn_send_roundfinished(NetconnPtr conn, boolean withoutError);
|
|
143 |
int flib_netconn_send_ban(NetconnPtr conn, String playerName);
|
|
144 |
int flib_netconn_send_kick(NetconnPtr conn, String playerName);
|
|
145 |
int flib_netconn_send_playerInfo(NetconnPtr conn, String playerName);
|
|
146 |
int flib_netconn_send_playerFollow(NetconnPtr conn, String playerName);
|
|
147 |
int flib_netconn_send_startGame(NetconnPtr conn);
|
|
148 |
int flib_netconn_send_toggleRestrictJoins(NetconnPtr conn);
|
|
149 |
int flib_netconn_send_toggleRestrictTeams(NetconnPtr conn);
|
|
150 |
int flib_netconn_send_clearAccountsCache(NetconnPtr conn);
|
|
151 |
int flib_netconn_send_setServerVar(NetconnPtr conn, String name, String value);
|
|
152 |
int flib_netconn_send_getServerVars(NetconnPtr conn);
|
|
153 |
|
|
154 |
void flib_netconn_onMessage(NetconnPtr conn, IntStrCallback callback, Pointer context);
|
|
155 |
void flib_netconn_onChat(NetconnPtr conn, StrStrCallback callback, Pointer context);
|
|
156 |
void flib_netconn_onConnected(NetconnPtr conn, VoidCallback callback, Pointer context);
|
|
157 |
void flib_netconn_onDisconnected(NetconnPtr conn, IntStrCallback callback, Pointer context);
|
|
158 |
void flib_netconn_onRoomlist(NetconnPtr conn, RoomListCallback callback, Pointer context);
|
|
159 |
void flib_netconn_onRoomAdd(NetconnPtr conn, RoomCallback callback, Pointer context);
|
|
160 |
void flib_netconn_onRoomDelete(NetconnPtr conn, StrCallback callback, Pointer context);
|
|
161 |
void flib_netconn_onRoomUpdate(NetconnPtr conn, StrRoomCallback callback, Pointer context);
|
|
162 |
void flib_netconn_onLobbyJoin(NetconnPtr conn, StrCallback callback, Pointer context);
|
|
163 |
void flib_netconn_onLobbyLeave(NetconnPtr conn, StrStrCallback callback, Pointer context);
|
|
164 |
void flib_netconn_onNickTaken(NetconnPtr conn, StrCallback callback, Pointer context);
|
|
165 |
void flib_netconn_onPasswordRequest(NetconnPtr conn, StrCallback callback, Pointer context);
|
|
166 |
void flib_netconn_onEnterRoom(NetconnPtr conn, BoolCallback callback, Pointer context);
|
|
167 |
void flib_netconn_onRoomChiefStatus(NetconnPtr conn, BoolCallback callback, Pointer context);
|
|
168 |
void flib_netconn_onReadyState(NetconnPtr conn, StrBoolCallback callback, Pointer context);
|
|
169 |
void flib_netconn_onLeaveRoom(NetconnPtr conn, IntStrCallback callback, Pointer context);
|
|
170 |
void flib_netconn_onTeamAdd(NetconnPtr conn, TeamCallback callback, Pointer context);
|
|
171 |
void flib_netconn_onTeamDelete(NetconnPtr conn, StrCallback callback, Pointer context);
|
|
172 |
void flib_netconn_onRoomJoin(NetconnPtr conn, StrCallback callback, Pointer context);
|
|
173 |
void flib_netconn_onRoomLeave(NetconnPtr conn, StrStrCallback callback, Pointer context);
|
|
174 |
void flib_netconn_onRunGame(NetconnPtr conn, VoidCallback callback, Pointer context);
|
|
175 |
void flib_netconn_onTeamAccepted(NetconnPtr conn, StrCallback callback, Pointer context);
|
|
176 |
void flib_netconn_onHogCountChanged(NetconnPtr conn, StrIntCallback callback, Pointer context);
|
|
177 |
void flib_netconn_onTeamColorChanged(NetconnPtr conn, StrIntCallback callback, Pointer context);
|
|
178 |
void flib_netconn_onEngineMessage(NetconnPtr conn, BytesCallback callback, Pointer context);
|
|
179 |
void flib_netconn_onCfgScheme(NetconnPtr conn, SchemeCallback callback, Pointer context);
|
|
180 |
void flib_netconn_onMapChanged(NetconnPtr conn, MapIntCallback callback, Pointer context);
|
|
181 |
void flib_netconn_onScriptChanged(NetconnPtr conn, StrCallback callback, Pointer context);
|
|
182 |
void flib_netconn_onWeaponsetChanged(NetconnPtr conn, WeaponsetCallback callback, Pointer context);
|
|
183 |
void flib_netconn_onAdminAccess(NetconnPtr conn, VoidCallback callback, Pointer context);
|
|
184 |
void flib_netconn_onServerVar(NetconnPtr conn, StrStrCallback callback, Pointer context);
|
|
185 |
|
|
186 |
// ipc/gameconn.h
|
|
187 |
GameconnPtr flib_gameconn_create(String playerName, GameSetupPtr setup, boolean netgame);
|
|
188 |
GameconnPtr flib_gameconn_create_playdemo(Buffer demo, NativeLong size);
|
|
189 |
GameconnPtr flib_gameconn_create_loadgame(String playerName, Buffer save, NativeLong size);
|
|
190 |
GameconnPtr flib_gameconn_create_campaign(String playerName, String seed, String script);
|
|
191 |
|
|
192 |
void flib_gameconn_destroy(GameconnPtr conn);
|
|
193 |
int flib_gameconn_getport(GameconnPtr conn);
|
|
194 |
void flib_gameconn_tick(GameconnPtr conn);
|
|
195 |
|
|
196 |
int flib_gameconn_send_textmsg(GameconnPtr conn, int msgtype, String msg);
|
|
197 |
int flib_gameconn_send_chatmsg(GameconnPtr conn, String playername, String msg);
|
|
198 |
int flib_gameconn_send_quit(GameconnPtr conn);
|
|
199 |
|
|
200 |
void flib_gameconn_onConnect(GameconnPtr conn, VoidCallback callback, Pointer context);
|
|
201 |
void flib_gameconn_onDisconnect(GameconnPtr conn, IntCallback callback, Pointer context);
|
|
202 |
void flib_gameconn_onErrorMessage(GameconnPtr conn, StrCallback callback, Pointer context);
|
|
203 |
void flib_gameconn_onChat(GameconnPtr conn, StrBoolCallback callback, Pointer context);
|
|
204 |
void flib_gameconn_onGameRecorded(GameconnPtr conn, BytesBoolCallback callback, Pointer context);
|
|
205 |
void flib_gameconn_onEngineMessage(GameconnPtr conn, BytesCallback callback, Pointer context);
|
|
206 |
|
|
207 |
// ipc/mapconn.h
|
|
208 |
MapconnPtr flib_mapconn_create(MapRecipePtr mapdesc);
|
|
209 |
void flib_mapconn_destroy(MapconnPtr conn);
|
|
210 |
int flib_mapconn_getport(MapconnPtr conn);
|
|
211 |
void flib_mapconn_onSuccess(MapconnPtr conn, MapimageCallback callback, Pointer context);
|
|
212 |
void flib_mapconn_onFailure(MapconnPtr conn, StrCallback callback, Pointer context);
|
|
213 |
void flib_mapconn_tick(MapconnPtr conn);
|
|
214 |
|
7497
|
215 |
MetaschemePtr flib_get_metascheme();
|
7482
|
216 |
|
|
217 |
// model/schemelist.h
|
7497
|
218 |
SchemelistPtr flib_schemelist_from_ini(String filename);
|
7482
|
219 |
int flib_schemelist_to_ini(String filename, SchemelistPtr list);
|
|
220 |
void flib_schemelist_destroy(SchemelistPtr list);
|
|
221 |
|
|
222 |
// model/team.h
|
|
223 |
TeamPtr flib_team_from_ini(String filename);
|
|
224 |
int flib_team_to_ini(String filename, TeamPtr team);
|
|
225 |
void flib_team_destroy(TeamPtr team);
|
|
226 |
|
|
227 |
// model/weapon.h
|
|
228 |
WeaponsetListPtr flib_weaponsetlist_from_ini(String filename);
|
|
229 |
int flib_weaponsetlist_to_ini(String filename, WeaponsetListPtr weaponsets);
|
|
230 |
void flib_weaponsetlist_destroy(WeaponsetListPtr list);
|
|
231 |
|
7497
|
232 |
// model/gamesetup.h
|
|
233 |
void flib_gamesetup_destroy(GameSetupPtr gamesetup);
|
|
234 |
|
7482
|
235 |
// util/logging.h
|
|
236 |
void flib_log_setLevel(int level);
|
|
237 |
void flib_log_setCallback(LogCallback callback);
|