project_files/frontlib/extra/jnacontrol.c
changeset 7580 c92596feac0d
parent 7497 7e1d72fc03c7
child 7588 27e5857da6af
equal deleted inserted replaced
7578:d5c880e6d772 7580:c92596feac0d
    63 
    63 
    64 typedef flib_room *RoomPtr;
    64 typedef flib_room *RoomPtr;
    65 typedef flib_team *TeamPtr;
    65 typedef flib_team *TeamPtr;
    66 typedef flib_gamesetup *GameSetupPtr;
    66 typedef flib_gamesetup *GameSetupPtr;
    67 typedef bool boolean;
    67 typedef bool boolean;
    68 typedef size_t NativeLong;
    68 typedef size_t NativeSizeT;
    69 typedef void *Pointer;
    69 typedef void *Pointer;
    70 typedef char *String;
    70 typedef char *String;
    71 typedef uint8_t *Buffer;
       
    72 
    71 
    73 /*
    72 /*
    74  * Mapping callback types
    73  * Mapping callback types
    75  */
    74  */
    76 typedef void (*VoidCallback)(Pointer context);
    75 typedef void (*VoidCallback)(Pointer context);
    83 typedef void (*RoomListCallback)(Pointer context, RoomArrayPtr arg1, int arg2);
    82 typedef void (*RoomListCallback)(Pointer context, RoomArrayPtr arg1, int arg2);
    84 typedef void (*StrRoomCallback)(Pointer context, String arg1, RoomPtr arg2);
    83 typedef void (*StrRoomCallback)(Pointer context, String arg1, RoomPtr arg2);
    85 typedef void (*BoolCallback)(Pointer context, boolean arg1);
    84 typedef void (*BoolCallback)(Pointer context, boolean arg1);
    86 typedef void (*StrBoolCallback)(Pointer context, String arg1, boolean arg2);
    85 typedef void (*StrBoolCallback)(Pointer context, String arg1, boolean arg2);
    87 typedef void (*TeamCallback)(Pointer context, TeamPtr arg1);
    86 typedef void (*TeamCallback)(Pointer context, TeamPtr arg1);
    88 typedef void (*BytesCallback)(Pointer context, const uint8_t *buffer, NativeLong size);
    87 typedef void (*BytesCallback)(Pointer context, const uint8_t *buffer, NativeSizeT size);
    89 typedef void (*BytesBoolCallback)(Pointer context, const uint8_t *buffer, NativeLong size, boolean arg3);
    88 typedef void (*BytesBoolCallback)(Pointer context, const uint8_t *buffer, NativeSizeT size, boolean arg3);
    90 typedef void (*SchemeCallback)(Pointer context, SchemePtr arg1);
    89 typedef void (*SchemeCallback)(Pointer context, SchemePtr arg1);
    91 typedef void (*MapIntCallback)(Pointer context, MapRecipePtr arg1, int arg2);
    90 typedef void (*MapIntCallback)(Pointer context, MapRecipePtr arg1, int arg2);
    92 typedef void (*WeaponsetCallback)(Pointer context, WeaponsetPtr arg1);
    91 typedef void (*WeaponsetCallback)(Pointer context, WeaponsetPtr arg1);
    93 typedef void (*MapimageCallback)(Pointer context, const uint8_t *mapimage, int hogs);
    92 typedef void (*MapimageCallback)(Pointer context, const uint8_t *mapimage, int hogs);
    94 typedef void (*LogCallback)(int arg1, String arg2);
    93 typedef void (*LogCallback)(int arg1, String arg2);
    96 /*
    95 /*
    97  * Below here are the copypasted method declarations from the JNA bindings
    96  * Below here are the copypasted method declarations from the JNA bindings
    98  */
    97  */
    99 
    98 
   100 // frontlib.h
    99 // frontlib.h
   101 int flib_init();
   100     int flib_init();
   102 void flib_quit();
   101     void flib_quit();
   103 
   102 
   104 // hwconsts.h
   103     // hwconsts.h
   105 int flib_get_teamcolor_count();
   104     int flib_get_teamcolor_count();
   106 int flib_get_hedgehogs_per_team();
   105     int flib_get_hedgehogs_per_team();
   107 int flib_get_weapons_count();
   106     int flib_get_weapons_count();
   108 
   107 	MetaschemePtr flib_get_metascheme();
   109 // net/netconn.h
   108 
   110 NetconnPtr flib_netconn_create(String playerName, String dataDirPath, String host, int port);
   109     // net/netconn.h
   111 void flib_netconn_destroy(NetconnPtr conn);
   110 	NetconnPtr flib_netconn_create(String playerName, String dataDirPath, String host, int port);
   112 
   111 	void flib_netconn_destroy(NetconnPtr conn);
   113 void flib_netconn_tick(NetconnPtr conn);
   112 
   114 boolean flib_netconn_is_chief(NetconnPtr conn);
   113 	void flib_netconn_tick(NetconnPtr conn);
   115 String flib_netconn_get_playername(NetconnPtr conn);
   114 	boolean flib_netconn_is_chief(NetconnPtr conn);
   116 GameSetupPtr flib_netconn_create_gamesetup(NetconnPtr conn);
   115 	String flib_netconn_get_playername(NetconnPtr conn);
   117 int flib_netconn_send_quit(NetconnPtr conn, String quitmsg);
   116 	GameSetupPtr flib_netconn_create_gamesetup(NetconnPtr conn);
   118 int flib_netconn_send_chat(NetconnPtr conn, String chat);
   117 	int flib_netconn_send_quit(NetconnPtr conn, String quitmsg);
   119 int flib_netconn_send_teamchat(NetconnPtr conn, String msg);
   118 	int flib_netconn_send_chat(NetconnPtr conn, String chat);
   120 int flib_netconn_send_password(NetconnPtr conn, String passwd);
   119 	int flib_netconn_send_teamchat(NetconnPtr conn, String msg);
   121 int flib_netconn_send_nick(NetconnPtr conn, String nick);
   120 	int flib_netconn_send_password(NetconnPtr conn, String passwd);
   122 int flib_netconn_send_request_roomlist(NetconnPtr conn);
   121 	int flib_netconn_send_nick(NetconnPtr conn, String nick);
   123 int flib_netconn_send_joinRoom(NetconnPtr conn, String room);
   122 	int flib_netconn_send_request_roomlist(NetconnPtr conn);
   124 int flib_netconn_send_createRoom(NetconnPtr conn, String room);
   123 	int flib_netconn_send_joinRoom(NetconnPtr conn, String room);
   125 int flib_netconn_send_renameRoom(NetconnPtr conn, String roomName);
   124 	int flib_netconn_send_createRoom(NetconnPtr conn, String room);
   126 int flib_netconn_send_leaveRoom(NetconnPtr conn, String msg);
   125 	int flib_netconn_send_renameRoom(NetconnPtr conn, String roomName);
   127 int flib_netconn_send_toggleReady(NetconnPtr conn);
   126 	int flib_netconn_send_leaveRoom(NetconnPtr conn, String msg);
   128 int flib_netconn_send_addTeam(NetconnPtr conn, TeamPtr team);
   127 	int flib_netconn_send_toggleReady(NetconnPtr conn);
   129 int flib_netconn_send_removeTeam(NetconnPtr conn, String teamname);
   128 	int flib_netconn_send_addTeam(NetconnPtr conn, TeamPtr team);
   130 int flib_netconn_send_teamHogCount(NetconnPtr conn, String teamname, int hogcount);
   129 	int flib_netconn_send_removeTeam(NetconnPtr conn, String teamname);
   131 int flib_netconn_send_teamColor(NetconnPtr conn, String teamname, int colorIndex);
   130 	int flib_netconn_send_teamHogCount(NetconnPtr conn, String teamname, int hogcount);
   132 int flib_netconn_send_weaponset(NetconnPtr conn, WeaponsetPtr weaponset);
   131 	int flib_netconn_send_teamColor(NetconnPtr conn, String teamname, int colorIndex);
   133 int flib_netconn_send_map(NetconnPtr conn, MapRecipePtr map);
   132 	int flib_netconn_send_weaponset(NetconnPtr conn, WeaponsetPtr weaponset);
   134 int flib_netconn_send_mapName(NetconnPtr conn, String mapName);
   133 	int flib_netconn_send_map(NetconnPtr conn, MapRecipePtr map);
   135 int flib_netconn_send_mapGen(NetconnPtr conn, int mapGen);
   134 	int flib_netconn_send_mapName(NetconnPtr conn, String mapName);
   136 int flib_netconn_send_mapTemplate(NetconnPtr conn, int templateFilter);
   135 	int flib_netconn_send_mapGen(NetconnPtr conn, int mapGen);
   137 int flib_netconn_send_mapMazeSize(NetconnPtr conn, int mazeSize);
   136 	int flib_netconn_send_mapTemplate(NetconnPtr conn, int templateFilter);
   138 int flib_netconn_send_mapSeed(NetconnPtr conn, String seed);
   137 	int flib_netconn_send_mapMazeSize(NetconnPtr conn, int mazeSize);
   139 int flib_netconn_send_mapTheme(NetconnPtr conn, String theme);
   138 	int flib_netconn_send_mapSeed(NetconnPtr conn, String seed);
   140 int flib_netconn_send_script(NetconnPtr conn, String scriptName);
   139 	int flib_netconn_send_mapTheme(NetconnPtr conn, String theme);
   141 int flib_netconn_send_scheme(NetconnPtr conn, SchemePtr scheme);
   140 	int flib_netconn_send_script(NetconnPtr conn, String scriptName);
   142 int flib_netconn_send_roundfinished(NetconnPtr conn, boolean withoutError);
   141 	int flib_netconn_send_scheme(NetconnPtr conn, SchemePtr scheme);
   143 int flib_netconn_send_ban(NetconnPtr conn, String playerName);
   142 	int flib_netconn_send_roundfinished(NetconnPtr conn, boolean withoutError);
   144 int flib_netconn_send_kick(NetconnPtr conn, String playerName);
   143 	int flib_netconn_send_ban(NetconnPtr conn, String playerName);
   145 int flib_netconn_send_playerInfo(NetconnPtr conn, String playerName);
   144 	int flib_netconn_send_kick(NetconnPtr conn, String playerName);
   146 int flib_netconn_send_playerFollow(NetconnPtr conn, String playerName);
   145 	int flib_netconn_send_playerInfo(NetconnPtr conn, String playerName);
   147 int flib_netconn_send_startGame(NetconnPtr conn);
   146 	int flib_netconn_send_playerFollow(NetconnPtr conn, String playerName);
   148 int flib_netconn_send_toggleRestrictJoins(NetconnPtr conn);
   147 	int flib_netconn_send_startGame(NetconnPtr conn);
   149 int flib_netconn_send_toggleRestrictTeams(NetconnPtr conn);
   148 	int flib_netconn_send_toggleRestrictJoins(NetconnPtr conn);
   150 int flib_netconn_send_clearAccountsCache(NetconnPtr conn);
   149 	int flib_netconn_send_toggleRestrictTeams(NetconnPtr conn);
   151 int flib_netconn_send_setServerVar(NetconnPtr conn, String name, String value);
   150 	int flib_netconn_send_clearAccountsCache(NetconnPtr conn);
   152 int flib_netconn_send_getServerVars(NetconnPtr conn);
   151 	int flib_netconn_send_setServerVar(NetconnPtr conn, String name, String value);
   153 
   152 	int flib_netconn_send_getServerVars(NetconnPtr conn);
   154 void flib_netconn_onMessage(NetconnPtr conn, IntStrCallback callback, Pointer context);
   153 
   155 void flib_netconn_onChat(NetconnPtr conn, StrStrCallback callback, Pointer context);
   154 	void flib_netconn_onMessage(NetconnPtr conn, IntStrCallback callback, Pointer context);
   156 void flib_netconn_onConnected(NetconnPtr conn, VoidCallback callback, Pointer context);
   155 	void flib_netconn_onChat(NetconnPtr conn, StrStrCallback callback, Pointer context);
   157 void flib_netconn_onDisconnected(NetconnPtr conn, IntStrCallback callback, Pointer context);
   156 	void flib_netconn_onConnected(NetconnPtr conn, VoidCallback callback, Pointer context);
   158 void flib_netconn_onRoomlist(NetconnPtr conn, RoomListCallback callback, Pointer context);
   157 	void flib_netconn_onDisconnected(NetconnPtr conn, IntStrCallback callback, Pointer context);
   159 void flib_netconn_onRoomAdd(NetconnPtr conn, RoomCallback callback, Pointer context);
   158 	void flib_netconn_onRoomlist(NetconnPtr conn, RoomListCallback callback, Pointer context);
   160 void flib_netconn_onRoomDelete(NetconnPtr conn, StrCallback callback, Pointer context);
   159 	void flib_netconn_onRoomAdd(NetconnPtr conn, RoomCallback callback, Pointer context);
   161 void flib_netconn_onRoomUpdate(NetconnPtr conn, StrRoomCallback callback, Pointer context);
   160 	void flib_netconn_onRoomDelete(NetconnPtr conn, StrCallback callback, Pointer context);
   162 void flib_netconn_onLobbyJoin(NetconnPtr conn, StrCallback callback, Pointer context);
   161 	void flib_netconn_onRoomUpdate(NetconnPtr conn, StrRoomCallback callback, Pointer context);
   163 void flib_netconn_onLobbyLeave(NetconnPtr conn, StrStrCallback callback, Pointer context);
   162 	void flib_netconn_onLobbyJoin(NetconnPtr conn, StrCallback callback, Pointer context);
   164 void flib_netconn_onNickTaken(NetconnPtr conn, StrCallback callback, Pointer context);
   163 	void flib_netconn_onLobbyLeave(NetconnPtr conn, StrStrCallback callback, Pointer context);
   165 void flib_netconn_onPasswordRequest(NetconnPtr conn, StrCallback callback, Pointer context);
   164 	void flib_netconn_onNickTaken(NetconnPtr conn, StrCallback callback, Pointer context);
   166 void flib_netconn_onEnterRoom(NetconnPtr conn, BoolCallback callback, Pointer context);
   165 	void flib_netconn_onPasswordRequest(NetconnPtr conn, StrCallback callback, Pointer context);
   167 void flib_netconn_onRoomChiefStatus(NetconnPtr conn, BoolCallback callback, Pointer context);
   166 	void flib_netconn_onEnterRoom(NetconnPtr conn, BoolCallback callback, Pointer context);
   168 void flib_netconn_onReadyState(NetconnPtr conn, StrBoolCallback callback, Pointer context);
   167 	void flib_netconn_onRoomChiefStatus(NetconnPtr conn, BoolCallback callback, Pointer context);
   169 void flib_netconn_onLeaveRoom(NetconnPtr conn, IntStrCallback callback, Pointer context);
   168 	void flib_netconn_onReadyState(NetconnPtr conn, StrBoolCallback callback, Pointer context);
   170 void flib_netconn_onTeamAdd(NetconnPtr conn, TeamCallback callback, Pointer context);
   169 	void flib_netconn_onLeaveRoom(NetconnPtr conn, IntStrCallback callback, Pointer context);
   171 void flib_netconn_onTeamDelete(NetconnPtr conn, StrCallback callback, Pointer context);
   170 	void flib_netconn_onTeamAdd(NetconnPtr conn, TeamCallback callback, Pointer context);
   172 void flib_netconn_onRoomJoin(NetconnPtr conn, StrCallback callback, Pointer context);
   171 	void flib_netconn_onTeamDelete(NetconnPtr conn, StrCallback callback, Pointer context);
   173 void flib_netconn_onRoomLeave(NetconnPtr conn, StrStrCallback callback, Pointer context);
   172 	void flib_netconn_onRoomJoin(NetconnPtr conn, StrCallback callback, Pointer context);
   174 void flib_netconn_onRunGame(NetconnPtr conn, VoidCallback callback, Pointer context);
   173 	void flib_netconn_onRoomLeave(NetconnPtr conn, StrStrCallback callback, Pointer context);
   175 void flib_netconn_onTeamAccepted(NetconnPtr conn, StrCallback callback, Pointer context);
   174 	void flib_netconn_onRunGame(NetconnPtr conn, VoidCallback callback, Pointer context);
   176 void flib_netconn_onHogCountChanged(NetconnPtr conn, StrIntCallback callback, Pointer context);
   175 	void flib_netconn_onTeamAccepted(NetconnPtr conn, StrCallback callback, Pointer context);
   177 void flib_netconn_onTeamColorChanged(NetconnPtr conn, StrIntCallback callback, Pointer context);
   176 	void flib_netconn_onHogCountChanged(NetconnPtr conn, StrIntCallback callback, Pointer context);
   178 void flib_netconn_onEngineMessage(NetconnPtr conn, BytesCallback callback, Pointer context);
   177 	void flib_netconn_onTeamColorChanged(NetconnPtr conn, StrIntCallback callback, Pointer context);
   179 void flib_netconn_onCfgScheme(NetconnPtr conn, SchemeCallback callback, Pointer context);
   178 	void flib_netconn_onEngineMessage(NetconnPtr conn, BytesCallback callback, Pointer context);
   180 void flib_netconn_onMapChanged(NetconnPtr conn, MapIntCallback callback, Pointer context);
   179 	void flib_netconn_onSchemeChanged(NetconnPtr conn, SchemeCallback callback, Pointer context);
   181 void flib_netconn_onScriptChanged(NetconnPtr conn, StrCallback callback, Pointer context);
   180 	void flib_netconn_onMapChanged(NetconnPtr conn, MapIntCallback callback, Pointer context);
   182 void flib_netconn_onWeaponsetChanged(NetconnPtr conn, WeaponsetCallback callback, Pointer context);
   181 	void flib_netconn_onScriptChanged(NetconnPtr conn, StrCallback callback, Pointer context);
   183 void flib_netconn_onAdminAccess(NetconnPtr conn, VoidCallback callback, Pointer context);
   182 	void flib_netconn_onWeaponsetChanged(NetconnPtr conn, WeaponsetCallback callback, Pointer context);
   184 void flib_netconn_onServerVar(NetconnPtr conn, StrStrCallback callback, Pointer context);
   183 	void flib_netconn_onAdminAccess(NetconnPtr conn, VoidCallback callback, Pointer context);
   185 
   184 	void flib_netconn_onServerVar(NetconnPtr conn, StrStrCallback callback, Pointer context);
   186 // ipc/gameconn.h
   185 
   187 GameconnPtr flib_gameconn_create(String playerName, GameSetupPtr setup, boolean netgame);
   186 	// ipc/gameconn.h
   188 GameconnPtr flib_gameconn_create_playdemo(Buffer demo, NativeLong size);
   187 	GameconnPtr flib_gameconn_create(String playerName, GameSetupPtr setup, boolean netgame);
   189 GameconnPtr flib_gameconn_create_loadgame(String playerName, Buffer save, NativeLong size);
   188 	GameconnPtr flib_gameconn_create_campaign(String playerName, String seed, String script);
   190 GameconnPtr flib_gameconn_create_campaign(String playerName, String seed, String script);
   189 
   191 
   190 	void flib_gameconn_destroy(GameconnPtr conn);
   192 void flib_gameconn_destroy(GameconnPtr conn);
   191 	int flib_gameconn_getport(GameconnPtr conn);
   193 int flib_gameconn_getport(GameconnPtr conn);
   192 	void flib_gameconn_tick(GameconnPtr conn);
   194 void flib_gameconn_tick(GameconnPtr conn);
   193 
   195 
   194 	int flib_gameconn_send_textmsg(GameconnPtr conn, int msgtype, String msg);
   196 int flib_gameconn_send_textmsg(GameconnPtr conn, int msgtype, String msg);
   195 	int flib_gameconn_send_chatmsg(GameconnPtr conn, String playername, String msg);
   197 int flib_gameconn_send_chatmsg(GameconnPtr conn, String playername, String msg);
   196 	int flib_gameconn_send_quit(GameconnPtr conn);
   198 int flib_gameconn_send_quit(GameconnPtr conn);
   197 	int flib_gameconn_send_cmd(GameconnPtr conn, String cmdString);
   199 
   198 
   200 void flib_gameconn_onConnect(GameconnPtr conn, VoidCallback callback, Pointer context);
   199 	void flib_gameconn_onConnect(GameconnPtr conn, VoidCallback callback, Pointer context);
   201 void flib_gameconn_onDisconnect(GameconnPtr conn, IntCallback callback, Pointer context);
   200 	void flib_gameconn_onDisconnect(GameconnPtr conn, IntCallback callback, Pointer context);
   202 void flib_gameconn_onErrorMessage(GameconnPtr conn, StrCallback callback, Pointer context);
   201 	void flib_gameconn_onErrorMessage(GameconnPtr conn, StrCallback callback, Pointer context);
   203 void flib_gameconn_onChat(GameconnPtr conn, StrBoolCallback callback, Pointer context);
   202 	void flib_gameconn_onChat(GameconnPtr conn, StrBoolCallback callback, Pointer context);
   204 void flib_gameconn_onGameRecorded(GameconnPtr conn, BytesBoolCallback callback, Pointer context);
   203 	void flib_gameconn_onGameRecorded(GameconnPtr conn, BytesBoolCallback callback, Pointer context);
   205 void flib_gameconn_onEngineMessage(GameconnPtr conn, BytesCallback callback, Pointer context);
   204 	void flib_gameconn_onEngineMessage(GameconnPtr conn, BytesCallback callback, Pointer context);
   206 
   205 
   207 // ipc/mapconn.h
   206 	// ipc/mapconn.h
   208 MapconnPtr flib_mapconn_create(MapRecipePtr mapdesc);
   207 	MapconnPtr flib_mapconn_create(MapRecipePtr mapdesc);
   209 void flib_mapconn_destroy(MapconnPtr conn);
   208 	void flib_mapconn_destroy(MapconnPtr conn);
   210 int flib_mapconn_getport(MapconnPtr conn);
   209 	int flib_mapconn_getport(MapconnPtr conn);
   211 void flib_mapconn_onSuccess(MapconnPtr conn, MapimageCallback callback, Pointer context);
   210 	void flib_mapconn_onSuccess(MapconnPtr conn, MapimageCallback callback, Pointer context);
   212 void flib_mapconn_onFailure(MapconnPtr conn, StrCallback callback, Pointer context);
   211 	void flib_mapconn_onFailure(MapconnPtr conn, StrCallback callback, Pointer context);
   213 void flib_mapconn_tick(MapconnPtr conn);
   212 	void flib_mapconn_tick(MapconnPtr conn);
   214 
   213 
   215 MetaschemePtr flib_get_metascheme();
   214 	// model/schemelist.h
   216 
   215 	SchemelistPtr flib_schemelist_from_ini(String filename);
   217 // model/schemelist.h
   216 	int flib_schemelist_to_ini(String filename, SchemelistPtr list);
   218 SchemelistPtr flib_schemelist_from_ini(String filename);
   217 	void flib_schemelist_destroy(SchemelistPtr list);
   219 int flib_schemelist_to_ini(String filename, SchemelistPtr list);
   218 
   220 void flib_schemelist_destroy(SchemelistPtr list);
   219 	// model/team.h
   221 
   220 	TeamPtr flib_team_from_ini(String filename);
   222 // model/team.h
   221 	int flib_team_to_ini(String filename, TeamPtr team);
   223 TeamPtr flib_team_from_ini(String filename);
   222 	void flib_team_destroy(TeamPtr team);
   224 int flib_team_to_ini(String filename, TeamPtr team);
   223 
   225 void flib_team_destroy(TeamPtr team);
   224 	// model/weapon.h
   226 
   225 	WeaponsetListPtr flib_weaponsetlist_from_ini(String filename);
   227 // model/weapon.h
   226 	int flib_weaponsetlist_to_ini(String filename, WeaponsetListPtr weaponsets);
   228 WeaponsetListPtr flib_weaponsetlist_from_ini(String filename);
   227 	void flib_weaponsetlist_destroy(WeaponsetListPtr list);
   229 int flib_weaponsetlist_to_ini(String filename, WeaponsetListPtr weaponsets);
   228 
   230 void flib_weaponsetlist_destroy(WeaponsetListPtr list);
   229 	// model/gamesetup.h
   231 
   230 	void flib_gamesetup_destroy(GameSetupPtr gamesetup);
   232 // model/gamesetup.h
   231 
   233 void flib_gamesetup_destroy(GameSetupPtr gamesetup);
   232     void flib_log_setLevel(int level);
   234 
   233     void flib_log_setCallback(LogCallback callback);
   235 // util/logging.h
       
   236 void flib_log_setLevel(int level);
       
   237 void flib_log_setCallback(LogCallback callback);