project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/JnaFrontlib.java
changeset 7342 0e29eec2df5c
parent 7332 3f2e130f9715
child 7358 57a508884052
equal deleted inserted replaced
7340:62043f5f7c67 7342:0e29eec2df5c
     1 package org.hedgewars.hedgeroid.netplay;
     1 package org.hedgewars.hedgeroid.netplay;
     2 import java.nio.Buffer;
     2 import java.nio.Buffer;
     3 import java.util.Collections;
     3 import java.util.Collections;
       
     4 
       
     5 import android.util.Log;
     4 
     6 
     5 import com.sun.jna.Callback;
     7 import com.sun.jna.Callback;
     6 import com.sun.jna.Library;
     8 import com.sun.jna.Library;
     7 import com.sun.jna.Native;
     9 import com.sun.jna.Native;
     8 import com.sun.jna.NativeLong;
    10 import com.sun.jna.NativeLong;
    13 class Flib {
    15 class Flib {
    14 	static {
    16 	static {
    15 		System.loadLibrary("SDL_net");
    17 		System.loadLibrary("SDL_net");
    16 	}
    18 	}
    17 	public static final JnaFrontlib INSTANCE = (JnaFrontlib)Native.loadLibrary("frontlib", JnaFrontlib.class, Collections.singletonMap(Library.OPTION_TYPE_MAPPER, FrontlibTypeMapper.INSTANCE));
    19 	public static final JnaFrontlib INSTANCE = (JnaFrontlib)Native.loadLibrary("frontlib", JnaFrontlib.class, Collections.singletonMap(Library.OPTION_TYPE_MAPPER, FrontlibTypeMapper.INSTANCE));
       
    20 	
       
    21 	// Hook frontlib logging into Android logging
       
    22 	private static final JnaFrontlib.LogCallback logCb = new JnaFrontlib.LogCallback() {
       
    23 		public void callback(int level, String message) {
       
    24 			if(level >= JnaFrontlib.FLIB_LOGLEVEL_ERROR) {
       
    25 				Log.e("Frontlib", message);
       
    26 			} else if(level == JnaFrontlib.FLIB_LOGLEVEL_WARNING){
       
    27 				Log.w("Frontlib", message);
       
    28 			} else if(level == JnaFrontlib.FLIB_LOGLEVEL_INFO){
       
    29 				Log.i("Frontlib", message);
       
    30 			} else if(level <= JnaFrontlib.FLIB_LOGLEVEL_DEBUG){
       
    31 				Log.d("Frontlib", message);
       
    32 			}
       
    33 		}
       
    34 	};
       
    35 	static {
       
    36 		INSTANCE.flib_log_setLevel(JnaFrontlib.FLIB_LOGLEVEL_WARNING);
       
    37 		INSTANCE.flib_log_setCallback(logCb);
       
    38 	}
    18 }
    39 }
    19 
    40 
    20 public interface JnaFrontlib extends Library {
    41 public interface JnaFrontlib extends Library {
    21 	static final int NETCONN_STATE_CONNECTING = 0;
    42 	static final int NETCONN_STATE_CONNECTING = 0;
    22 	static final int NETCONN_STATE_LOBBY = 1;
    43 	static final int NETCONN_STATE_LOBBY = 1;
    54 	
    75 	
    55 	static class NetconnPtr extends PointerType { }
    76 	static class NetconnPtr extends PointerType { }
    56 	static class MapconnPtr extends PointerType { }
    77 	static class MapconnPtr extends PointerType { }
    57 	static class GameconnPtr extends PointerType { }
    78 	static class GameconnPtr extends PointerType { }
    58 	static class MetaschemePtr extends PointerType { }
    79 	static class MetaschemePtr extends PointerType { }
    59 	static class RoomlistPtr extends PointerType { }
    80 	
    60 	static class RoomPtr extends PointerType { }
    81 	static class RoomArrayPtr extends PointerType { 
       
    82 		/**
       
    83 		 * Returns the (native-owned) rooms in this list
       
    84 		 */
       
    85 		public RoomPtr[] getRooms(int count) {
       
    86 			Pointer ptr = getPointer();
       
    87 			if(ptr == null) {
       
    88 				return new RoomPtr[0];
       
    89 			}
       
    90 			Pointer[] untypedPtrs = ptr.getPointerArray(0, count);
       
    91 			RoomPtr[] typedPtrs = new RoomPtr[count];
       
    92 			for(int i=0; i<count; i++) {
       
    93 				typedPtrs[i] = new RoomPtr(untypedPtrs[i]);
       
    94 			}
       
    95 			return typedPtrs;
       
    96 		}
       
    97 	}
       
    98 	
       
    99 	static class RoomPtr extends PointerType {
       
   100 		public RoomPtr() { super(); }
       
   101 		public RoomPtr(Pointer ptr) { super(ptr); }
       
   102 		
       
   103 		public Room deref() {
       
   104 			Room result = new Room(getPointer());
       
   105 			result.read();
       
   106 			return result;
       
   107 		}
       
   108 	}
       
   109 	
    61 	static class TeamPtr extends PointerType { }
   110 	static class TeamPtr extends PointerType { }
    62 	static class WeaponsetPtr extends PointerType { }
   111 	static class WeaponsetPtr extends PointerType { }
    63 	static class MapRecipePtr extends PointerType { }
   112 	static class MapRecipePtr extends PointerType { }
    64 	static class SchemePtr extends PointerType { }
   113 	static class SchemePtr extends PointerType { }
    65 	static class GameSetupPtr extends PointerType { }
   114 	static class GameSetupPtr extends PointerType { }
    66 	
   115 	
       
   116 	static class Room extends Structure {
       
   117 		public static class byVal extends Room implements Structure.ByValue {}
       
   118 		public static class byRef extends Room implements Structure.ByReference {}
       
   119 		private static String[] FIELD_ORDER = new String[] {"inProgress", "name", "playerCount", "teamCount", "owner", "map", "scheme", "weapons"};
       
   120 		
       
   121 		public Room() { super(); setFieldOrder(FIELD_ORDER); }
       
   122 		public Room(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); }
       
   123 		
       
   124 	    public boolean inProgress;
       
   125 	    public String name;
       
   126 	    public int playerCount;
       
   127 	    public int teamCount;
       
   128 	    public String owner;
       
   129 	    public String map;
       
   130 	    public String scheme;
       
   131 	    public String weapons;
       
   132 	}
       
   133 	
    67 	public static interface VoidCallback extends Callback {
   134 	public static interface VoidCallback extends Callback {
    68 		void callback(Pointer context);
   135 		void callback(Pointer context);
    69 	}
   136 	}
    70 	
   137 	
    71 	public static interface StrCallback extends Callback {
   138 	public static interface StrCallback extends Callback {
    87 	public static interface StrStrCallback extends Callback {
   154 	public static interface StrStrCallback extends Callback {
    88 		void callback(Pointer context, String arg1, String arg2);
   155 		void callback(Pointer context, String arg1, String arg2);
    89 	}
   156 	}
    90 	
   157 	
    91 	public static interface RoomCallback extends Callback {
   158 	public static interface RoomCallback extends Callback {
    92 		void callback(Pointer context, JnaFrontlib.RoomPtr arg1);
   159 		void callback(Pointer context, RoomPtr arg1);
       
   160 	}
       
   161 	
       
   162 	public static interface RoomListCallback extends Callback {
       
   163 		void callback(Pointer context, RoomArrayPtr arg1, int count);
    93 	}
   164 	}
    94 	
   165 	
    95 	public static interface StrRoomCallback extends Callback {
   166 	public static interface StrRoomCallback extends Callback {
    96 		void callback(Pointer context, String arg1, JnaFrontlib.RoomPtr arg2);
   167 		void callback(Pointer context, String arg1, RoomPtr arg2);
    97 	}
   168 	}
    98 	
   169 	
    99 	public static interface BoolCallback extends Callback {
   170 	public static interface BoolCallback extends Callback {
   100 		void callback(Pointer context, boolean arg1);
   171 		void callback(Pointer context, boolean arg1);
   101 	}
   172 	}
   103 	public static interface StrBoolCallback extends Callback {
   174 	public static interface StrBoolCallback extends Callback {
   104 		void callback(Pointer context, String arg1, boolean arg2);
   175 		void callback(Pointer context, String arg1, boolean arg2);
   105 	}
   176 	}
   106 	
   177 	
   107 	public static interface TeamCallback extends Callback {
   178 	public static interface TeamCallback extends Callback {
   108 		void callback(Pointer context, JnaFrontlib.TeamPtr arg1);
   179 		void callback(Pointer context, TeamPtr arg1);
   109 	}
   180 	}
   110 	
   181 	
   111 	public static interface BytesCallback extends Callback {
   182 	public static interface BytesCallback extends Callback {
   112 		void callback(Pointer context, Pointer buffer, NativeLong size);
   183 		void callback(Pointer context, Pointer buffer, NativeLong size);
   113 	}
   184 	}
   115 	public static interface BytesBoolCallback extends Callback {
   186 	public static interface BytesBoolCallback extends Callback {
   116 		void callback(Pointer context, Pointer buffer, NativeLong size, boolean arg3);
   187 		void callback(Pointer context, Pointer buffer, NativeLong size, boolean arg3);
   117 	}
   188 	}
   118 	
   189 	
   119 	public static interface SchemeCallback extends Callback {
   190 	public static interface SchemeCallback extends Callback {
   120 		void callback(Pointer context, JnaFrontlib.SchemePtr arg1);
   191 		void callback(Pointer context, SchemePtr arg1);
   121 	}
   192 	}
   122 	
   193 	
   123 	public static interface MapIntCallback extends Callback {
   194 	public static interface MapIntCallback extends Callback {
   124 		void callback(Pointer context, JnaFrontlib.MapRecipePtr arg1, int arg2);
   195 		void callback(Pointer context, MapRecipePtr arg1, int arg2);
   125 	}
   196 	}
   126 	
   197 	
   127 	public static interface WeaponsetCallback extends Callback {
   198 	public static interface WeaponsetCallback extends Callback {
   128 		void callback(Pointer context, JnaFrontlib.WeaponsetPtr arg1);
   199 		void callback(Pointer context, WeaponsetPtr arg1);
   129 	}
   200 	}
   130 	
   201 	
   131 	public static interface MapimageCallback extends Callback {
   202 	public static interface MapimageCallback extends Callback {
   132 		void callback(Pointer context, Pointer buffer, int hedgehogCount);
   203 		void callback(Pointer context, Pointer buffer, int hedgehogCount);
   133 	}
   204 	}
   134 	
   205 	
       
   206 	public static interface LogCallback extends Callback {
       
   207 		void callback(int level, String logMessage);
       
   208 	}
       
   209 	
   135     int flib_init();
   210     int flib_init();
   136     void flib_quit();
   211     void flib_quit();
   137 	
   212 	
   138 	JnaFrontlib.NetconnPtr flib_netconn_create(String playerName, JnaFrontlib.MetaschemePtr meta, String dataDirPath, String host, int port);
   213 	NetconnPtr flib_netconn_create(String playerName, MetaschemePtr meta, String dataDirPath, String host, int port);
   139 	void flib_netconn_destroy(JnaFrontlib.NetconnPtr conn);
   214 	void flib_netconn_destroy(NetconnPtr conn);
   140 
   215 
   141 	void flib_netconn_tick(JnaFrontlib.NetconnPtr conn);
   216 	void flib_netconn_tick(NetconnPtr conn);
   142 	JnaFrontlib.RoomlistPtr flib_netconn_get_roomlist(JnaFrontlib.NetconnPtr conn);
   217 	boolean flib_netconn_is_chief(NetconnPtr conn);
   143 	boolean flib_netconn_is_chief(JnaFrontlib.NetconnPtr conn);
   218 	boolean flib_netconn_is_in_room_context(NetconnPtr conn);
   144 	boolean flib_netconn_is_in_room_context(JnaFrontlib.NetconnPtr conn);
   219 	String flib_netconn_get_playername(NetconnPtr conn);
   145 	JnaFrontlib.GameSetupPtr flib_netconn_create_gamesetup(JnaFrontlib.NetconnPtr conn);
   220 	GameSetupPtr flib_netconn_create_gamesetup(NetconnPtr conn);
   146 	int flib_netconn_send_quit(JnaFrontlib.NetconnPtr conn, String quitmsg);
   221 	int flib_netconn_send_quit(NetconnPtr conn, String quitmsg);
   147 	int flib_netconn_send_chat(JnaFrontlib.NetconnPtr conn, String chat);
   222 	int flib_netconn_send_chat(NetconnPtr conn, String chat);
   148 	int flib_netconn_send_teamchat(JnaFrontlib.NetconnPtr conn, String msg);
   223 	int flib_netconn_send_teamchat(NetconnPtr conn, String msg);
   149 	int flib_netconn_send_password(JnaFrontlib.NetconnPtr conn, String passwd);
   224 	int flib_netconn_send_password(NetconnPtr conn, String passwd);
   150 	int flib_netconn_send_nick(JnaFrontlib.NetconnPtr conn, String nick);
   225 	int flib_netconn_send_nick(NetconnPtr conn, String nick);
   151 	int flib_netconn_send_joinRoom(JnaFrontlib.NetconnPtr conn, String room);
   226 	int flib_netconn_send_request_roomlist(NetconnPtr conn);
   152 	int flib_netconn_send_createRoom(JnaFrontlib.NetconnPtr conn, String room);
   227 	int flib_netconn_send_joinRoom(NetconnPtr conn, String room);
   153 	int flib_netconn_send_renameRoom(JnaFrontlib.NetconnPtr conn, String roomName);
   228 	int flib_netconn_send_createRoom(NetconnPtr conn, String room);
   154 	int flib_netconn_send_leaveRoom(JnaFrontlib.NetconnPtr conn, String msg);
   229 	int flib_netconn_send_renameRoom(NetconnPtr conn, String roomName);
   155 	int flib_netconn_send_toggleReady(JnaFrontlib.NetconnPtr conn);
   230 	int flib_netconn_send_leaveRoom(NetconnPtr conn, String msg);
   156 	int flib_netconn_send_addTeam(JnaFrontlib.NetconnPtr conn, JnaFrontlib.TeamPtr team);
   231 	int flib_netconn_send_toggleReady(NetconnPtr conn);
   157 	int flib_netconn_send_removeTeam(JnaFrontlib.NetconnPtr conn, String teamname);
   232 	int flib_netconn_send_addTeam(NetconnPtr conn, TeamPtr team);
   158 	int flib_netconn_send_engineMessage(JnaFrontlib.NetconnPtr conn, Buffer message, NativeLong size); // TODO check if NativeLong==size_t
   233 	int flib_netconn_send_removeTeam(NetconnPtr conn, String teamname);
   159 	int flib_netconn_send_teamHogCount(JnaFrontlib.NetconnPtr conn, String teamname, int hogcount);
   234 	int flib_netconn_send_engineMessage(NetconnPtr conn, Buffer message, NativeLong size); // TODO check if NativeLong==size_t
   160 	int flib_netconn_send_teamColor(JnaFrontlib.NetconnPtr conn, String teamname, int colorIndex);
   235 	int flib_netconn_send_teamHogCount(NetconnPtr conn, String teamname, int hogcount);
   161 	int flib_netconn_send_weaponset(JnaFrontlib.NetconnPtr conn, JnaFrontlib.WeaponsetPtr weaponset);
   236 	int flib_netconn_send_teamColor(NetconnPtr conn, String teamname, int colorIndex);
   162 	int flib_netconn_send_map(JnaFrontlib.NetconnPtr conn, JnaFrontlib.MapRecipePtr map);
   237 	int flib_netconn_send_weaponset(NetconnPtr conn, WeaponsetPtr weaponset);
   163 	int flib_netconn_send_mapName(JnaFrontlib.NetconnPtr conn, String mapName);
   238 	int flib_netconn_send_map(NetconnPtr conn, MapRecipePtr map);
   164 	int flib_netconn_send_mapGen(JnaFrontlib.NetconnPtr conn, int mapGen);
   239 	int flib_netconn_send_mapName(NetconnPtr conn, String mapName);
   165 	int flib_netconn_send_mapTemplate(JnaFrontlib.NetconnPtr conn, int templateFilter);
   240 	int flib_netconn_send_mapGen(NetconnPtr conn, int mapGen);
   166 	int flib_netconn_send_mapMazeSize(JnaFrontlib.NetconnPtr conn, int mazeSize);
   241 	int flib_netconn_send_mapTemplate(NetconnPtr conn, int templateFilter);
   167 	int flib_netconn_send_mapSeed(JnaFrontlib.NetconnPtr conn, String seed);
   242 	int flib_netconn_send_mapMazeSize(NetconnPtr conn, int mazeSize);
   168 	int flib_netconn_send_mapTheme(JnaFrontlib.NetconnPtr conn, String theme);
   243 	int flib_netconn_send_mapSeed(NetconnPtr conn, String seed);
   169 	int flib_netconn_send_mapDrawdata(JnaFrontlib.NetconnPtr conn, Buffer drawData, NativeLong size);
   244 	int flib_netconn_send_mapTheme(NetconnPtr conn, String theme);
   170 	int flib_netconn_send_script(JnaFrontlib.NetconnPtr conn, String scriptName);
   245 	int flib_netconn_send_mapDrawdata(NetconnPtr conn, Buffer drawData, NativeLong size);
   171 	int flib_netconn_send_scheme(JnaFrontlib.NetconnPtr conn, JnaFrontlib.SchemePtr scheme);
   246 	int flib_netconn_send_script(NetconnPtr conn, String scriptName);
   172 	int flib_netconn_send_roundfinished(JnaFrontlib.NetconnPtr conn, boolean withoutError);
   247 	int flib_netconn_send_scheme(NetconnPtr conn, SchemePtr scheme);
   173 	int flib_netconn_send_ban(JnaFrontlib.NetconnPtr conn, String playerName);
   248 	int flib_netconn_send_roundfinished(NetconnPtr conn, boolean withoutError);
   174 	int flib_netconn_send_kick(JnaFrontlib.NetconnPtr conn, String playerName);
   249 	int flib_netconn_send_ban(NetconnPtr conn, String playerName);
   175 	int flib_netconn_send_playerInfo(JnaFrontlib.NetconnPtr conn, String playerName);
   250 	int flib_netconn_send_kick(NetconnPtr conn, String playerName);
   176 	int flib_netconn_send_playerFollow(JnaFrontlib.NetconnPtr conn, String playerName);
   251 	int flib_netconn_send_playerInfo(NetconnPtr conn, String playerName);
   177 	int flib_netconn_send_startGame(JnaFrontlib.NetconnPtr conn);
   252 	int flib_netconn_send_playerFollow(NetconnPtr conn, String playerName);
   178 	int flib_netconn_send_toggleRestrictJoins(JnaFrontlib.NetconnPtr conn);
   253 	int flib_netconn_send_startGame(NetconnPtr conn);
   179 	int flib_netconn_send_toggleRestrictTeams(JnaFrontlib.NetconnPtr conn);
   254 	int flib_netconn_send_toggleRestrictJoins(NetconnPtr conn);
   180 	int flib_netconn_send_clearAccountsCache(JnaFrontlib.NetconnPtr conn);
   255 	int flib_netconn_send_toggleRestrictTeams(NetconnPtr conn);
   181 	int flib_netconn_send_setServerVar(JnaFrontlib.NetconnPtr conn, String name, String value);
   256 	int flib_netconn_send_clearAccountsCache(NetconnPtr conn);
   182 	int flib_netconn_send_getServerVars(JnaFrontlib.NetconnPtr conn);
   257 	int flib_netconn_send_setServerVar(NetconnPtr conn, String name, String value);
   183 	
   258 	int flib_netconn_send_getServerVars(NetconnPtr conn);
   184 	void flib_netconn_onMessage(JnaFrontlib.NetconnPtr conn, JnaFrontlib.IntStrCallback callback, Pointer context);
   259 	
   185 	void flib_netconn_onChat(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrStrCallback callback, Pointer context);
   260 	void flib_netconn_onMessage(NetconnPtr conn, IntStrCallback callback, Pointer context);
   186 	void flib_netconn_onConnected(JnaFrontlib.NetconnPtr conn, JnaFrontlib.VoidCallback callback, Pointer context);
   261 	void flib_netconn_onChat(NetconnPtr conn, StrStrCallback callback, Pointer context);
   187 	void flib_netconn_onDisconnected(JnaFrontlib.NetconnPtr conn, JnaFrontlib.IntStrCallback callback, Pointer context);
   262 	void flib_netconn_onConnected(NetconnPtr conn, VoidCallback callback, Pointer context);
   188 	void flib_netconn_onRoomAdd(JnaFrontlib.NetconnPtr conn, JnaFrontlib.RoomCallback callback, Pointer context);
   263 	void flib_netconn_onDisconnected(NetconnPtr conn, IntStrCallback callback, Pointer context);
   189 	void flib_netconn_onRoomDelete(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
   264 	void flib_netconn_onRoomlist(NetconnPtr conn, RoomListCallback callback, Pointer context);
   190 	void flib_netconn_onRoomUpdate(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrRoomCallback callback, Pointer context);
   265 	void flib_netconn_onRoomAdd(NetconnPtr conn, RoomCallback callback, Pointer context);
   191 	void flib_netconn_onLobbyJoin(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
   266 	void flib_netconn_onRoomDelete(NetconnPtr conn, StrCallback callback, Pointer context);
   192 	void flib_netconn_onLobbyLeave(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrStrCallback callback, Pointer context);
   267 	void flib_netconn_onRoomUpdate(NetconnPtr conn, StrRoomCallback callback, Pointer context);
   193 	void flib_netconn_onNickTaken(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
   268 	void flib_netconn_onLobbyJoin(NetconnPtr conn, StrCallback callback, Pointer context);
   194 	void flib_netconn_onPasswordRequest(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
   269 	void flib_netconn_onLobbyLeave(NetconnPtr conn, StrStrCallback callback, Pointer context);
   195 	void flib_netconn_onEnterRoom(JnaFrontlib.NetconnPtr conn, JnaFrontlib.BoolCallback callback, Pointer context);
   270 	void flib_netconn_onNickTaken(NetconnPtr conn, StrCallback callback, Pointer context);
   196 	void flib_netconn_onRoomChiefStatus(JnaFrontlib.NetconnPtr conn, JnaFrontlib.BoolCallback callback, Pointer context);
   271 	void flib_netconn_onPasswordRequest(NetconnPtr conn, StrCallback callback, Pointer context);
   197 	void flib_netconn_onReadyState(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrBoolCallback callback, Pointer context);
   272 	void flib_netconn_onEnterRoom(NetconnPtr conn, BoolCallback callback, Pointer context);
   198 	void flib_netconn_onLeaveRoom(JnaFrontlib.NetconnPtr conn, JnaFrontlib.IntStrCallback callback, Pointer context);
   273 	void flib_netconn_onRoomChiefStatus(NetconnPtr conn, BoolCallback callback, Pointer context);
   199 	void flib_netconn_onTeamAdd(JnaFrontlib.NetconnPtr conn, JnaFrontlib.TeamCallback callback, Pointer context);
   274 	void flib_netconn_onReadyState(NetconnPtr conn, StrBoolCallback callback, Pointer context);
   200 	void flib_netconn_onTeamDelete(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
   275 	void flib_netconn_onLeaveRoom(NetconnPtr conn, IntStrCallback callback, Pointer context);
   201 	void flib_netconn_onRoomJoin(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
   276 	void flib_netconn_onTeamAdd(NetconnPtr conn, TeamCallback callback, Pointer context);
   202 	void flib_netconn_onRoomLeave(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrStrCallback callback, Pointer context);
   277 	void flib_netconn_onTeamDelete(NetconnPtr conn, StrCallback callback, Pointer context);
   203 	void flib_netconn_onRunGame(JnaFrontlib.NetconnPtr conn, JnaFrontlib.VoidCallback callback, Pointer context);
   278 	void flib_netconn_onRoomJoin(NetconnPtr conn, StrCallback callback, Pointer context);
   204 	void flib_netconn_onTeamAccepted(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
   279 	void flib_netconn_onRoomLeave(NetconnPtr conn, StrStrCallback callback, Pointer context);
   205 	void flib_netconn_onHogCountChanged(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrIntCallback callback, Pointer context);
   280 	void flib_netconn_onRunGame(NetconnPtr conn, VoidCallback callback, Pointer context);
   206 	void flib_netconn_onTeamColorChanged(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrIntCallback callback, Pointer context);
   281 	void flib_netconn_onTeamAccepted(NetconnPtr conn, StrCallback callback, Pointer context);
   207 	void flib_netconn_onEngineMessage(JnaFrontlib.NetconnPtr conn, JnaFrontlib.BytesCallback callback, Pointer context);
   282 	void flib_netconn_onHogCountChanged(NetconnPtr conn, StrIntCallback callback, Pointer context);
   208 	void flib_netconn_onCfgScheme(JnaFrontlib.NetconnPtr conn, JnaFrontlib.SchemeCallback callback, Pointer context);
   283 	void flib_netconn_onTeamColorChanged(NetconnPtr conn, StrIntCallback callback, Pointer context);
   209 	void flib_netconn_onMapChanged(JnaFrontlib.NetconnPtr conn, JnaFrontlib.MapIntCallback callback, Pointer context);
   284 	void flib_netconn_onEngineMessage(NetconnPtr conn, BytesCallback callback, Pointer context);
   210 	void flib_netconn_onScriptChanged(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
   285 	void flib_netconn_onCfgScheme(NetconnPtr conn, SchemeCallback callback, Pointer context);
   211 	void flib_netconn_onWeaponsetChanged(JnaFrontlib.NetconnPtr conn, JnaFrontlib.WeaponsetCallback callback, Pointer context);
   286 	void flib_netconn_onMapChanged(NetconnPtr conn, MapIntCallback callback, Pointer context);
   212 	void flib_netconn_onAdminAccess(JnaFrontlib.NetconnPtr conn, JnaFrontlib.VoidCallback callback, Pointer context);
   287 	void flib_netconn_onScriptChanged(NetconnPtr conn, StrCallback callback, Pointer context);
   213 	void flib_netconn_onServerVar(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrStrCallback callback, Pointer context);
   288 	void flib_netconn_onWeaponsetChanged(NetconnPtr conn, WeaponsetCallback callback, Pointer context);
       
   289 	void flib_netconn_onAdminAccess(NetconnPtr conn, VoidCallback callback, Pointer context);
       
   290 	void flib_netconn_onServerVar(NetconnPtr conn, StrStrCallback callback, Pointer context);
   214 
   291 
   215 	// Gameconn
   292 	// Gameconn
   216 	JnaFrontlib.GameconnPtr flib_gameconn_create(String playerName, JnaFrontlib.GameSetupPtr setup, boolean netgame);
   293 	GameconnPtr flib_gameconn_create(String playerName, GameSetupPtr setup, boolean netgame);
   217 	JnaFrontlib.GameconnPtr flib_gameconn_create_playdemo(Buffer demo, NativeLong size);
   294 	GameconnPtr flib_gameconn_create_playdemo(Buffer demo, NativeLong size);
   218 	JnaFrontlib.GameconnPtr flib_gameconn_create_loadgame(String playerName, Buffer save, NativeLong size);
   295 	GameconnPtr flib_gameconn_create_loadgame(String playerName, Buffer save, NativeLong size);
   219 	JnaFrontlib.GameconnPtr flib_gameconn_create_campaign(String playerName, String seed, String script);
   296 	GameconnPtr flib_gameconn_create_campaign(String playerName, String seed, String script);
   220 
   297 
   221 	void flib_gameconn_destroy(JnaFrontlib.GameconnPtr conn);
   298 	void flib_gameconn_destroy(GameconnPtr conn);
   222 	int flib_gameconn_getport(JnaFrontlib.GameconnPtr conn);
   299 	int flib_gameconn_getport(GameconnPtr conn);
   223 	void flib_gameconn_tick(JnaFrontlib.GameconnPtr conn);
   300 	void flib_gameconn_tick(GameconnPtr conn);
   224 
   301 
   225 	int flib_gameconn_send_enginemsg(JnaFrontlib.GameconnPtr conn, Buffer data, NativeLong len);
   302 	int flib_gameconn_send_enginemsg(GameconnPtr conn, Buffer data, NativeLong len);
   226 	int flib_gameconn_send_textmsg(JnaFrontlib.GameconnPtr conn, int msgtype, String msg);
   303 	int flib_gameconn_send_textmsg(GameconnPtr conn, int msgtype, String msg);
   227 	int flib_gameconn_send_chatmsg(JnaFrontlib.GameconnPtr conn, String playername, String msg);
   304 	int flib_gameconn_send_chatmsg(GameconnPtr conn, String playername, String msg);
   228 	
   305 	
   229 	void flib_gameconn_onConnect(JnaFrontlib.GameconnPtr conn, JnaFrontlib.VoidCallback callback, Pointer context);
   306 	void flib_gameconn_onConnect(GameconnPtr conn, VoidCallback callback, Pointer context);
   230 	void flib_gameconn_onDisconnect(JnaFrontlib.GameconnPtr conn, JnaFrontlib.IntCallback callback, Pointer context);
   307 	void flib_gameconn_onDisconnect(GameconnPtr conn, IntCallback callback, Pointer context);
   231 	void flib_gameconn_onErrorMessage(JnaFrontlib.GameconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
   308 	void flib_gameconn_onErrorMessage(GameconnPtr conn, StrCallback callback, Pointer context);
   232 	void flib_gameconn_onChat(JnaFrontlib.GameconnPtr conn, JnaFrontlib.StrBoolCallback callback, Pointer context);
   309 	void flib_gameconn_onChat(GameconnPtr conn, StrBoolCallback callback, Pointer context);
   233 	void flib_gameconn_onGameRecorded(JnaFrontlib.GameconnPtr conn, JnaFrontlib.BytesBoolCallback callback, Pointer context);
   310 	void flib_gameconn_onGameRecorded(GameconnPtr conn, BytesBoolCallback callback, Pointer context);
   234 	void flib_gameconn_onEngineMessage(JnaFrontlib.GameconnPtr conn, JnaFrontlib.BytesCallback callback, Pointer context);
   311 	void flib_gameconn_onEngineMessage(GameconnPtr conn, BytesCallback callback, Pointer context);
   235 	
   312 	
   236 	// MapConn
   313 	// MapConn
   237 	JnaFrontlib.MapconnPtr flib_mapconn_create(JnaFrontlib.MapRecipePtr mapdesc);
   314 	MapconnPtr flib_mapconn_create(MapRecipePtr mapdesc);
   238 	void flib_mapconn_destroy(JnaFrontlib.MapconnPtr conn);
   315 	void flib_mapconn_destroy(MapconnPtr conn);
   239 	int flib_mapconn_getport(JnaFrontlib.MapconnPtr conn);
   316 	int flib_mapconn_getport(MapconnPtr conn);
   240 	void flib_mapconn_onSuccess(JnaFrontlib.MapconnPtr conn, JnaFrontlib.MapimageCallback callback, Pointer context);
   317 	void flib_mapconn_onSuccess(MapconnPtr conn, MapimageCallback callback, Pointer context);
   241 	void flib_mapconn_onFailure(JnaFrontlib.MapconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
   318 	void flib_mapconn_onFailure(MapconnPtr conn, StrCallback callback, Pointer context);
   242 	void flib_mapconn_tick(JnaFrontlib.MapconnPtr conn);
   319 	void flib_mapconn_tick(MapconnPtr conn);
   243 	
   320 	
   244 	// GameSetup
   321 	// GameSetup
   245 	void flib_gamesetup_destroy(JnaFrontlib.GameSetupPtr gamesetup);
   322 	void flib_gamesetup_destroy(GameSetupPtr gamesetup);
   246 	JnaFrontlib.GameSetupPtr flib_gamesetup_copy(JnaFrontlib.GameSetupPtr gamesetup);
   323 	GameSetupPtr flib_gamesetup_copy(GameSetupPtr gamesetup);
   247 	
   324 	
   248 	// MapRecipe
   325 	// MapRecipe
   249 	public static final int MAPGEN_REGULAR = 0;
   326 	public static final int MAPGEN_REGULAR = 0;
   250 	public static final int MAPGEN_MAZE = 1;
   327 	public static final int MAPGEN_MAZE = 1;
   251 	public static final int MAPGEN_DRAWN = 2;
   328 	public static final int MAPGEN_DRAWN = 2;
   263 	public static final int MAZE_SIZE_LARGE_TUNNELS = 2;
   340 	public static final int MAZE_SIZE_LARGE_TUNNELS = 2;
   264 	public static final int MAZE_SIZE_SMALL_ISLANDS = 3;
   341 	public static final int MAZE_SIZE_SMALL_ISLANDS = 3;
   265 	public static final int MAZE_SIZE_MEDIUM_ISLANDS = 4;
   342 	public static final int MAZE_SIZE_MEDIUM_ISLANDS = 4;
   266 	public static final int MAZE_SIZE_LARGE_ISLANDS = 5;
   343 	public static final int MAZE_SIZE_LARGE_ISLANDS = 5;
   267 	
   344 	
   268 	JnaFrontlib.MapRecipePtr flib_map_create_regular(String seed, String theme, int templateFilter);
   345 	MapRecipePtr flib_map_create_regular(String seed, String theme, int templateFilter);
   269 	JnaFrontlib.MapRecipePtr flib_map_create_maze(String seed, String theme, int mazeSize);
   346 	MapRecipePtr flib_map_create_maze(String seed, String theme, int mazeSize);
   270 	JnaFrontlib.MapRecipePtr flib_map_create_named(String seed, String name);
   347 	MapRecipePtr flib_map_create_named(String seed, String name);
   271 	JnaFrontlib.MapRecipePtr flib_map_create_drawn(String seed, String theme, Buffer drawData, NativeLong drawDataSize);
   348 	MapRecipePtr flib_map_create_drawn(String seed, String theme, Buffer drawData, NativeLong drawDataSize);
   272 	JnaFrontlib.MapRecipePtr flib_map_copy(JnaFrontlib.MapRecipePtr map);
   349 	MapRecipePtr flib_map_copy(MapRecipePtr map);
   273 	JnaFrontlib.MapRecipePtr flib_map_retain(JnaFrontlib.MapRecipePtr map);
   350 	MapRecipePtr flib_map_retain(MapRecipePtr map);
   274 	void flib_map_release(JnaFrontlib.MapRecipePtr map);
   351 	void flib_map_release(MapRecipePtr map);
   275 	
   352 	
   276 	// Metascheme
   353 	// Metascheme
   277 	JnaFrontlib.MetaschemePtr flib_metascheme_from_ini(String filename);
   354 	MetaschemePtr flib_metascheme_from_ini(String filename);
   278 	JnaFrontlib.MetaschemePtr flib_metascheme_retain(JnaFrontlib.MetaschemePtr metainfo);
   355 	MetaschemePtr flib_metascheme_retain(MetaschemePtr metainfo);
   279 	void flib_metascheme_release(JnaFrontlib.MetaschemePtr metainfo);
   356 	void flib_metascheme_release(MetaschemePtr metainfo);
       
   357 	
       
   358 	public static final int FLIB_LOGLEVEL_ALL = -100;
       
   359 	public static final int FLIB_LOGLEVEL_DEBUG = -1;
       
   360 	public static final int FLIB_LOGLEVEL_INFO = 0;
       
   361 	public static final int FLIB_LOGLEVEL_WARNING = 1;
       
   362 	public static final int FLIB_LOGLEVEL_ERROR = 2;
       
   363 	public static final int FLIB_LOGLEVEL_NONE = 100;
   280 	
   364 	
   281     void flib_log_setLevel(int level);
   365     void flib_log_setLevel(int level);
       
   366     void flib_log_setCallback(LogCallback callback);
   282 }
   367 }