project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/JnaFrontlib.java
changeset 7342 0e29eec2df5c
parent 7332 3f2e130f9715
child 7358 57a508884052
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/JnaFrontlib.java	Thu Jul 19 18:31:58 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/JnaFrontlib.java	Thu Jul 19 18:58:18 2012 +0200
@@ -2,6 +2,8 @@
 import java.nio.Buffer;
 import java.util.Collections;
 
+import android.util.Log;
+
 import com.sun.jna.Callback;
 import com.sun.jna.Library;
 import com.sun.jna.Native;
@@ -15,6 +17,25 @@
 		System.loadLibrary("SDL_net");
 	}
 	public static final JnaFrontlib INSTANCE = (JnaFrontlib)Native.loadLibrary("frontlib", JnaFrontlib.class, Collections.singletonMap(Library.OPTION_TYPE_MAPPER, FrontlibTypeMapper.INSTANCE));
+	
+	// Hook frontlib logging into Android logging
+	private static final JnaFrontlib.LogCallback logCb = new JnaFrontlib.LogCallback() {
+		public void callback(int level, String message) {
+			if(level >= JnaFrontlib.FLIB_LOGLEVEL_ERROR) {
+				Log.e("Frontlib", message);
+			} else if(level == JnaFrontlib.FLIB_LOGLEVEL_WARNING){
+				Log.w("Frontlib", message);
+			} else if(level == JnaFrontlib.FLIB_LOGLEVEL_INFO){
+				Log.i("Frontlib", message);
+			} else if(level <= JnaFrontlib.FLIB_LOGLEVEL_DEBUG){
+				Log.d("Frontlib", message);
+			}
+		}
+	};
+	static {
+		INSTANCE.flib_log_setLevel(JnaFrontlib.FLIB_LOGLEVEL_WARNING);
+		INSTANCE.flib_log_setCallback(logCb);
+	}
 }
 
 public interface JnaFrontlib extends Library {
@@ -56,14 +77,60 @@
 	static class MapconnPtr extends PointerType { }
 	static class GameconnPtr extends PointerType { }
 	static class MetaschemePtr extends PointerType { }
-	static class RoomlistPtr extends PointerType { }
-	static class RoomPtr extends PointerType { }
+	
+	static class RoomArrayPtr extends PointerType { 
+		/**
+		 * Returns the (native-owned) rooms in this list
+		 */
+		public RoomPtr[] getRooms(int count) {
+			Pointer ptr = getPointer();
+			if(ptr == null) {
+				return new RoomPtr[0];
+			}
+			Pointer[] untypedPtrs = ptr.getPointerArray(0, count);
+			RoomPtr[] typedPtrs = new RoomPtr[count];
+			for(int i=0; i<count; i++) {
+				typedPtrs[i] = new RoomPtr(untypedPtrs[i]);
+			}
+			return typedPtrs;
+		}
+	}
+	
+	static class RoomPtr extends PointerType {
+		public RoomPtr() { super(); }
+		public RoomPtr(Pointer ptr) { super(ptr); }
+		
+		public Room deref() {
+			Room result = new Room(getPointer());
+			result.read();
+			return result;
+		}
+	}
+	
 	static class TeamPtr extends PointerType { }
 	static class WeaponsetPtr extends PointerType { }
 	static class MapRecipePtr extends PointerType { }
 	static class SchemePtr extends PointerType { }
 	static class GameSetupPtr extends PointerType { }
 	
+	static class Room extends Structure {
+		public static class byVal extends Room implements Structure.ByValue {}
+		public static class byRef extends Room implements Structure.ByReference {}
+		private static String[] FIELD_ORDER = new String[] {"inProgress", "name", "playerCount", "teamCount", "owner", "map", "scheme", "weapons"};
+		
+		public Room() { super(); setFieldOrder(FIELD_ORDER); }
+		public Room(Pointer ptr) { super(ptr); setFieldOrder(FIELD_ORDER); }
+		
+	    public boolean inProgress;
+	    public String name;
+	    public int playerCount;
+	    public int teamCount;
+	    public String owner;
+	    public String map;
+	    public String scheme;
+	    public String weapons;
+	}
+	
 	public static interface VoidCallback extends Callback {
 		void callback(Pointer context);
 	}
@@ -89,11 +156,15 @@
 	}
 	
 	public static interface RoomCallback extends Callback {
-		void callback(Pointer context, JnaFrontlib.RoomPtr arg1);
+		void callback(Pointer context, RoomPtr arg1);
+	}
+	
+	public static interface RoomListCallback extends Callback {
+		void callback(Pointer context, RoomArrayPtr arg1, int count);
 	}
 	
 	public static interface StrRoomCallback extends Callback {
-		void callback(Pointer context, String arg1, JnaFrontlib.RoomPtr arg2);
+		void callback(Pointer context, String arg1, RoomPtr arg2);
 	}
 	
 	public static interface BoolCallback extends Callback {
@@ -105,7 +176,7 @@
 	}
 	
 	public static interface TeamCallback extends Callback {
-		void callback(Pointer context, JnaFrontlib.TeamPtr arg1);
+		void callback(Pointer context, TeamPtr arg1);
 	}
 	
 	public static interface BytesCallback extends Callback {
@@ -117,133 +188,139 @@
 	}
 	
 	public static interface SchemeCallback extends Callback {
-		void callback(Pointer context, JnaFrontlib.SchemePtr arg1);
+		void callback(Pointer context, SchemePtr arg1);
 	}
 	
 	public static interface MapIntCallback extends Callback {
-		void callback(Pointer context, JnaFrontlib.MapRecipePtr arg1, int arg2);
+		void callback(Pointer context, MapRecipePtr arg1, int arg2);
 	}
 	
 	public static interface WeaponsetCallback extends Callback {
-		void callback(Pointer context, JnaFrontlib.WeaponsetPtr arg1);
+		void callback(Pointer context, WeaponsetPtr arg1);
 	}
 	
 	public static interface MapimageCallback extends Callback {
 		void callback(Pointer context, Pointer buffer, int hedgehogCount);
 	}
 	
+	public static interface LogCallback extends Callback {
+		void callback(int level, String logMessage);
+	}
+	
     int flib_init();
     void flib_quit();
 	
-	JnaFrontlib.NetconnPtr flib_netconn_create(String playerName, JnaFrontlib.MetaschemePtr meta, String dataDirPath, String host, int port);
-	void flib_netconn_destroy(JnaFrontlib.NetconnPtr conn);
+	NetconnPtr flib_netconn_create(String playerName, MetaschemePtr meta, String dataDirPath, String host, int port);
+	void flib_netconn_destroy(NetconnPtr conn);
 
-	void flib_netconn_tick(JnaFrontlib.NetconnPtr conn);
-	JnaFrontlib.RoomlistPtr flib_netconn_get_roomlist(JnaFrontlib.NetconnPtr conn);
-	boolean flib_netconn_is_chief(JnaFrontlib.NetconnPtr conn);
-	boolean flib_netconn_is_in_room_context(JnaFrontlib.NetconnPtr conn);
-	JnaFrontlib.GameSetupPtr flib_netconn_create_gamesetup(JnaFrontlib.NetconnPtr conn);
-	int flib_netconn_send_quit(JnaFrontlib.NetconnPtr conn, String quitmsg);
-	int flib_netconn_send_chat(JnaFrontlib.NetconnPtr conn, String chat);
-	int flib_netconn_send_teamchat(JnaFrontlib.NetconnPtr conn, String msg);
-	int flib_netconn_send_password(JnaFrontlib.NetconnPtr conn, String passwd);
-	int flib_netconn_send_nick(JnaFrontlib.NetconnPtr conn, String nick);
-	int flib_netconn_send_joinRoom(JnaFrontlib.NetconnPtr conn, String room);
-	int flib_netconn_send_createRoom(JnaFrontlib.NetconnPtr conn, String room);
-	int flib_netconn_send_renameRoom(JnaFrontlib.NetconnPtr conn, String roomName);
-	int flib_netconn_send_leaveRoom(JnaFrontlib.NetconnPtr conn, String msg);
-	int flib_netconn_send_toggleReady(JnaFrontlib.NetconnPtr conn);
-	int flib_netconn_send_addTeam(JnaFrontlib.NetconnPtr conn, JnaFrontlib.TeamPtr team);
-	int flib_netconn_send_removeTeam(JnaFrontlib.NetconnPtr conn, String teamname);
-	int flib_netconn_send_engineMessage(JnaFrontlib.NetconnPtr conn, Buffer message, NativeLong size); // TODO check if NativeLong==size_t
-	int flib_netconn_send_teamHogCount(JnaFrontlib.NetconnPtr conn, String teamname, int hogcount);
-	int flib_netconn_send_teamColor(JnaFrontlib.NetconnPtr conn, String teamname, int colorIndex);
-	int flib_netconn_send_weaponset(JnaFrontlib.NetconnPtr conn, JnaFrontlib.WeaponsetPtr weaponset);
-	int flib_netconn_send_map(JnaFrontlib.NetconnPtr conn, JnaFrontlib.MapRecipePtr map);
-	int flib_netconn_send_mapName(JnaFrontlib.NetconnPtr conn, String mapName);
-	int flib_netconn_send_mapGen(JnaFrontlib.NetconnPtr conn, int mapGen);
-	int flib_netconn_send_mapTemplate(JnaFrontlib.NetconnPtr conn, int templateFilter);
-	int flib_netconn_send_mapMazeSize(JnaFrontlib.NetconnPtr conn, int mazeSize);
-	int flib_netconn_send_mapSeed(JnaFrontlib.NetconnPtr conn, String seed);
-	int flib_netconn_send_mapTheme(JnaFrontlib.NetconnPtr conn, String theme);
-	int flib_netconn_send_mapDrawdata(JnaFrontlib.NetconnPtr conn, Buffer drawData, NativeLong size);
-	int flib_netconn_send_script(JnaFrontlib.NetconnPtr conn, String scriptName);
-	int flib_netconn_send_scheme(JnaFrontlib.NetconnPtr conn, JnaFrontlib.SchemePtr scheme);
-	int flib_netconn_send_roundfinished(JnaFrontlib.NetconnPtr conn, boolean withoutError);
-	int flib_netconn_send_ban(JnaFrontlib.NetconnPtr conn, String playerName);
-	int flib_netconn_send_kick(JnaFrontlib.NetconnPtr conn, String playerName);
-	int flib_netconn_send_playerInfo(JnaFrontlib.NetconnPtr conn, String playerName);
-	int flib_netconn_send_playerFollow(JnaFrontlib.NetconnPtr conn, String playerName);
-	int flib_netconn_send_startGame(JnaFrontlib.NetconnPtr conn);
-	int flib_netconn_send_toggleRestrictJoins(JnaFrontlib.NetconnPtr conn);
-	int flib_netconn_send_toggleRestrictTeams(JnaFrontlib.NetconnPtr conn);
-	int flib_netconn_send_clearAccountsCache(JnaFrontlib.NetconnPtr conn);
-	int flib_netconn_send_setServerVar(JnaFrontlib.NetconnPtr conn, String name, String value);
-	int flib_netconn_send_getServerVars(JnaFrontlib.NetconnPtr conn);
+	void flib_netconn_tick(NetconnPtr conn);
+	boolean flib_netconn_is_chief(NetconnPtr conn);
+	boolean flib_netconn_is_in_room_context(NetconnPtr conn);
+	String flib_netconn_get_playername(NetconnPtr conn);
+	GameSetupPtr flib_netconn_create_gamesetup(NetconnPtr conn);
+	int flib_netconn_send_quit(NetconnPtr conn, String quitmsg);
+	int flib_netconn_send_chat(NetconnPtr conn, String chat);
+	int flib_netconn_send_teamchat(NetconnPtr conn, String msg);
+	int flib_netconn_send_password(NetconnPtr conn, String passwd);
+	int flib_netconn_send_nick(NetconnPtr conn, String nick);
+	int flib_netconn_send_request_roomlist(NetconnPtr conn);
+	int flib_netconn_send_joinRoom(NetconnPtr conn, String room);
+	int flib_netconn_send_createRoom(NetconnPtr conn, String room);
+	int flib_netconn_send_renameRoom(NetconnPtr conn, String roomName);
+	int flib_netconn_send_leaveRoom(NetconnPtr conn, String msg);
+	int flib_netconn_send_toggleReady(NetconnPtr conn);
+	int flib_netconn_send_addTeam(NetconnPtr conn, TeamPtr team);
+	int flib_netconn_send_removeTeam(NetconnPtr conn, String teamname);
+	int flib_netconn_send_engineMessage(NetconnPtr conn, Buffer message, NativeLong size); // TODO check if NativeLong==size_t
+	int flib_netconn_send_teamHogCount(NetconnPtr conn, String teamname, int hogcount);
+	int flib_netconn_send_teamColor(NetconnPtr conn, String teamname, int colorIndex);
+	int flib_netconn_send_weaponset(NetconnPtr conn, WeaponsetPtr weaponset);
+	int flib_netconn_send_map(NetconnPtr conn, MapRecipePtr map);
+	int flib_netconn_send_mapName(NetconnPtr conn, String mapName);
+	int flib_netconn_send_mapGen(NetconnPtr conn, int mapGen);
+	int flib_netconn_send_mapTemplate(NetconnPtr conn, int templateFilter);
+	int flib_netconn_send_mapMazeSize(NetconnPtr conn, int mazeSize);
+	int flib_netconn_send_mapSeed(NetconnPtr conn, String seed);
+	int flib_netconn_send_mapTheme(NetconnPtr conn, String theme);
+	int flib_netconn_send_mapDrawdata(NetconnPtr conn, Buffer drawData, NativeLong size);
+	int flib_netconn_send_script(NetconnPtr conn, String scriptName);
+	int flib_netconn_send_scheme(NetconnPtr conn, SchemePtr scheme);
+	int flib_netconn_send_roundfinished(NetconnPtr conn, boolean withoutError);
+	int flib_netconn_send_ban(NetconnPtr conn, String playerName);
+	int flib_netconn_send_kick(NetconnPtr conn, String playerName);
+	int flib_netconn_send_playerInfo(NetconnPtr conn, String playerName);
+	int flib_netconn_send_playerFollow(NetconnPtr conn, String playerName);
+	int flib_netconn_send_startGame(NetconnPtr conn);
+	int flib_netconn_send_toggleRestrictJoins(NetconnPtr conn);
+	int flib_netconn_send_toggleRestrictTeams(NetconnPtr conn);
+	int flib_netconn_send_clearAccountsCache(NetconnPtr conn);
+	int flib_netconn_send_setServerVar(NetconnPtr conn, String name, String value);
+	int flib_netconn_send_getServerVars(NetconnPtr conn);
 	
-	void flib_netconn_onMessage(JnaFrontlib.NetconnPtr conn, JnaFrontlib.IntStrCallback callback, Pointer context);
-	void flib_netconn_onChat(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrStrCallback callback, Pointer context);
-	void flib_netconn_onConnected(JnaFrontlib.NetconnPtr conn, JnaFrontlib.VoidCallback callback, Pointer context);
-	void flib_netconn_onDisconnected(JnaFrontlib.NetconnPtr conn, JnaFrontlib.IntStrCallback callback, Pointer context);
-	void flib_netconn_onRoomAdd(JnaFrontlib.NetconnPtr conn, JnaFrontlib.RoomCallback callback, Pointer context);
-	void flib_netconn_onRoomDelete(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
-	void flib_netconn_onRoomUpdate(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrRoomCallback callback, Pointer context);
-	void flib_netconn_onLobbyJoin(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
-	void flib_netconn_onLobbyLeave(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrStrCallback callback, Pointer context);
-	void flib_netconn_onNickTaken(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
-	void flib_netconn_onPasswordRequest(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
-	void flib_netconn_onEnterRoom(JnaFrontlib.NetconnPtr conn, JnaFrontlib.BoolCallback callback, Pointer context);
-	void flib_netconn_onRoomChiefStatus(JnaFrontlib.NetconnPtr conn, JnaFrontlib.BoolCallback callback, Pointer context);
-	void flib_netconn_onReadyState(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrBoolCallback callback, Pointer context);
-	void flib_netconn_onLeaveRoom(JnaFrontlib.NetconnPtr conn, JnaFrontlib.IntStrCallback callback, Pointer context);
-	void flib_netconn_onTeamAdd(JnaFrontlib.NetconnPtr conn, JnaFrontlib.TeamCallback callback, Pointer context);
-	void flib_netconn_onTeamDelete(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
-	void flib_netconn_onRoomJoin(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
-	void flib_netconn_onRoomLeave(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrStrCallback callback, Pointer context);
-	void flib_netconn_onRunGame(JnaFrontlib.NetconnPtr conn, JnaFrontlib.VoidCallback callback, Pointer context);
-	void flib_netconn_onTeamAccepted(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
-	void flib_netconn_onHogCountChanged(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrIntCallback callback, Pointer context);
-	void flib_netconn_onTeamColorChanged(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrIntCallback callback, Pointer context);
-	void flib_netconn_onEngineMessage(JnaFrontlib.NetconnPtr conn, JnaFrontlib.BytesCallback callback, Pointer context);
-	void flib_netconn_onCfgScheme(JnaFrontlib.NetconnPtr conn, JnaFrontlib.SchemeCallback callback, Pointer context);
-	void flib_netconn_onMapChanged(JnaFrontlib.NetconnPtr conn, JnaFrontlib.MapIntCallback callback, Pointer context);
-	void flib_netconn_onScriptChanged(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
-	void flib_netconn_onWeaponsetChanged(JnaFrontlib.NetconnPtr conn, JnaFrontlib.WeaponsetCallback callback, Pointer context);
-	void flib_netconn_onAdminAccess(JnaFrontlib.NetconnPtr conn, JnaFrontlib.VoidCallback callback, Pointer context);
-	void flib_netconn_onServerVar(JnaFrontlib.NetconnPtr conn, JnaFrontlib.StrStrCallback callback, Pointer context);
+	void flib_netconn_onMessage(NetconnPtr conn, IntStrCallback callback, Pointer context);
+	void flib_netconn_onChat(NetconnPtr conn, StrStrCallback callback, Pointer context);
+	void flib_netconn_onConnected(NetconnPtr conn, VoidCallback callback, Pointer context);
+	void flib_netconn_onDisconnected(NetconnPtr conn, IntStrCallback callback, Pointer context);
+	void flib_netconn_onRoomlist(NetconnPtr conn, RoomListCallback callback, Pointer context);
+	void flib_netconn_onRoomAdd(NetconnPtr conn, RoomCallback callback, Pointer context);
+	void flib_netconn_onRoomDelete(NetconnPtr conn, StrCallback callback, Pointer context);
+	void flib_netconn_onRoomUpdate(NetconnPtr conn, StrRoomCallback callback, Pointer context);
+	void flib_netconn_onLobbyJoin(NetconnPtr conn, StrCallback callback, Pointer context);
+	void flib_netconn_onLobbyLeave(NetconnPtr conn, StrStrCallback callback, Pointer context);
+	void flib_netconn_onNickTaken(NetconnPtr conn, StrCallback callback, Pointer context);
+	void flib_netconn_onPasswordRequest(NetconnPtr conn, StrCallback callback, Pointer context);
+	void flib_netconn_onEnterRoom(NetconnPtr conn, BoolCallback callback, Pointer context);
+	void flib_netconn_onRoomChiefStatus(NetconnPtr conn, BoolCallback callback, Pointer context);
+	void flib_netconn_onReadyState(NetconnPtr conn, StrBoolCallback callback, Pointer context);
+	void flib_netconn_onLeaveRoom(NetconnPtr conn, IntStrCallback callback, Pointer context);
+	void flib_netconn_onTeamAdd(NetconnPtr conn, TeamCallback callback, Pointer context);
+	void flib_netconn_onTeamDelete(NetconnPtr conn, StrCallback callback, Pointer context);
+	void flib_netconn_onRoomJoin(NetconnPtr conn, StrCallback callback, Pointer context);
+	void flib_netconn_onRoomLeave(NetconnPtr conn, StrStrCallback callback, Pointer context);
+	void flib_netconn_onRunGame(NetconnPtr conn, VoidCallback callback, Pointer context);
+	void flib_netconn_onTeamAccepted(NetconnPtr conn, StrCallback callback, Pointer context);
+	void flib_netconn_onHogCountChanged(NetconnPtr conn, StrIntCallback callback, Pointer context);
+	void flib_netconn_onTeamColorChanged(NetconnPtr conn, StrIntCallback callback, Pointer context);
+	void flib_netconn_onEngineMessage(NetconnPtr conn, BytesCallback callback, Pointer context);
+	void flib_netconn_onCfgScheme(NetconnPtr conn, SchemeCallback callback, Pointer context);
+	void flib_netconn_onMapChanged(NetconnPtr conn, MapIntCallback callback, Pointer context);
+	void flib_netconn_onScriptChanged(NetconnPtr conn, StrCallback callback, Pointer context);
+	void flib_netconn_onWeaponsetChanged(NetconnPtr conn, WeaponsetCallback callback, Pointer context);
+	void flib_netconn_onAdminAccess(NetconnPtr conn, VoidCallback callback, Pointer context);
+	void flib_netconn_onServerVar(NetconnPtr conn, StrStrCallback callback, Pointer context);
 
 	// Gameconn
-	JnaFrontlib.GameconnPtr flib_gameconn_create(String playerName, JnaFrontlib.GameSetupPtr setup, boolean netgame);
-	JnaFrontlib.GameconnPtr flib_gameconn_create_playdemo(Buffer demo, NativeLong size);
-	JnaFrontlib.GameconnPtr flib_gameconn_create_loadgame(String playerName, Buffer save, NativeLong size);
-	JnaFrontlib.GameconnPtr flib_gameconn_create_campaign(String playerName, String seed, String script);
+	GameconnPtr flib_gameconn_create(String playerName, GameSetupPtr setup, boolean netgame);
+	GameconnPtr flib_gameconn_create_playdemo(Buffer demo, NativeLong size);
+	GameconnPtr flib_gameconn_create_loadgame(String playerName, Buffer save, NativeLong size);
+	GameconnPtr flib_gameconn_create_campaign(String playerName, String seed, String script);
 
-	void flib_gameconn_destroy(JnaFrontlib.GameconnPtr conn);
-	int flib_gameconn_getport(JnaFrontlib.GameconnPtr conn);
-	void flib_gameconn_tick(JnaFrontlib.GameconnPtr conn);
+	void flib_gameconn_destroy(GameconnPtr conn);
+	int flib_gameconn_getport(GameconnPtr conn);
+	void flib_gameconn_tick(GameconnPtr conn);
 
-	int flib_gameconn_send_enginemsg(JnaFrontlib.GameconnPtr conn, Buffer data, NativeLong len);
-	int flib_gameconn_send_textmsg(JnaFrontlib.GameconnPtr conn, int msgtype, String msg);
-	int flib_gameconn_send_chatmsg(JnaFrontlib.GameconnPtr conn, String playername, String msg);
+	int flib_gameconn_send_enginemsg(GameconnPtr conn, Buffer data, NativeLong len);
+	int flib_gameconn_send_textmsg(GameconnPtr conn, int msgtype, String msg);
+	int flib_gameconn_send_chatmsg(GameconnPtr conn, String playername, String msg);
 	
-	void flib_gameconn_onConnect(JnaFrontlib.GameconnPtr conn, JnaFrontlib.VoidCallback callback, Pointer context);
-	void flib_gameconn_onDisconnect(JnaFrontlib.GameconnPtr conn, JnaFrontlib.IntCallback callback, Pointer context);
-	void flib_gameconn_onErrorMessage(JnaFrontlib.GameconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
-	void flib_gameconn_onChat(JnaFrontlib.GameconnPtr conn, JnaFrontlib.StrBoolCallback callback, Pointer context);
-	void flib_gameconn_onGameRecorded(JnaFrontlib.GameconnPtr conn, JnaFrontlib.BytesBoolCallback callback, Pointer context);
-	void flib_gameconn_onEngineMessage(JnaFrontlib.GameconnPtr conn, JnaFrontlib.BytesCallback callback, Pointer context);
+	void flib_gameconn_onConnect(GameconnPtr conn, VoidCallback callback, Pointer context);
+	void flib_gameconn_onDisconnect(GameconnPtr conn, IntCallback callback, Pointer context);
+	void flib_gameconn_onErrorMessage(GameconnPtr conn, StrCallback callback, Pointer context);
+	void flib_gameconn_onChat(GameconnPtr conn, StrBoolCallback callback, Pointer context);
+	void flib_gameconn_onGameRecorded(GameconnPtr conn, BytesBoolCallback callback, Pointer context);
+	void flib_gameconn_onEngineMessage(GameconnPtr conn, BytesCallback callback, Pointer context);
 	
 	// MapConn
-	JnaFrontlib.MapconnPtr flib_mapconn_create(JnaFrontlib.MapRecipePtr mapdesc);
-	void flib_mapconn_destroy(JnaFrontlib.MapconnPtr conn);
-	int flib_mapconn_getport(JnaFrontlib.MapconnPtr conn);
-	void flib_mapconn_onSuccess(JnaFrontlib.MapconnPtr conn, JnaFrontlib.MapimageCallback callback, Pointer context);
-	void flib_mapconn_onFailure(JnaFrontlib.MapconnPtr conn, JnaFrontlib.StrCallback callback, Pointer context);
-	void flib_mapconn_tick(JnaFrontlib.MapconnPtr conn);
+	MapconnPtr flib_mapconn_create(MapRecipePtr mapdesc);
+	void flib_mapconn_destroy(MapconnPtr conn);
+	int flib_mapconn_getport(MapconnPtr conn);
+	void flib_mapconn_onSuccess(MapconnPtr conn, MapimageCallback callback, Pointer context);
+	void flib_mapconn_onFailure(MapconnPtr conn, StrCallback callback, Pointer context);
+	void flib_mapconn_tick(MapconnPtr conn);
 	
 	// GameSetup
-	void flib_gamesetup_destroy(JnaFrontlib.GameSetupPtr gamesetup);
-	JnaFrontlib.GameSetupPtr flib_gamesetup_copy(JnaFrontlib.GameSetupPtr gamesetup);
+	void flib_gamesetup_destroy(GameSetupPtr gamesetup);
+	GameSetupPtr flib_gamesetup_copy(GameSetupPtr gamesetup);
 	
 	// MapRecipe
 	public static final int MAPGEN_REGULAR = 0;
@@ -265,18 +342,26 @@
 	public static final int MAZE_SIZE_MEDIUM_ISLANDS = 4;
 	public static final int MAZE_SIZE_LARGE_ISLANDS = 5;
 	
-	JnaFrontlib.MapRecipePtr flib_map_create_regular(String seed, String theme, int templateFilter);
-	JnaFrontlib.MapRecipePtr flib_map_create_maze(String seed, String theme, int mazeSize);
-	JnaFrontlib.MapRecipePtr flib_map_create_named(String seed, String name);
-	JnaFrontlib.MapRecipePtr flib_map_create_drawn(String seed, String theme, Buffer drawData, NativeLong drawDataSize);
-	JnaFrontlib.MapRecipePtr flib_map_copy(JnaFrontlib.MapRecipePtr map);
-	JnaFrontlib.MapRecipePtr flib_map_retain(JnaFrontlib.MapRecipePtr map);
-	void flib_map_release(JnaFrontlib.MapRecipePtr map);
+	MapRecipePtr flib_map_create_regular(String seed, String theme, int templateFilter);
+	MapRecipePtr flib_map_create_maze(String seed, String theme, int mazeSize);
+	MapRecipePtr flib_map_create_named(String seed, String name);
+	MapRecipePtr flib_map_create_drawn(String seed, String theme, Buffer drawData, NativeLong drawDataSize);
+	MapRecipePtr flib_map_copy(MapRecipePtr map);
+	MapRecipePtr flib_map_retain(MapRecipePtr map);
+	void flib_map_release(MapRecipePtr map);
 	
 	// Metascheme
-	JnaFrontlib.MetaschemePtr flib_metascheme_from_ini(String filename);
-	JnaFrontlib.MetaschemePtr flib_metascheme_retain(JnaFrontlib.MetaschemePtr metainfo);
-	void flib_metascheme_release(JnaFrontlib.MetaschemePtr metainfo);
+	MetaschemePtr flib_metascheme_from_ini(String filename);
+	MetaschemePtr flib_metascheme_retain(MetaschemePtr metainfo);
+	void flib_metascheme_release(MetaschemePtr metainfo);
+	
+	public static final int FLIB_LOGLEVEL_ALL = -100;
+	public static final int FLIB_LOGLEVEL_DEBUG = -1;
+	public static final int FLIB_LOGLEVEL_INFO = 0;
+	public static final int FLIB_LOGLEVEL_WARNING = 1;
+	public static final int FLIB_LOGLEVEL_ERROR = 2;
+	public static final int FLIB_LOGLEVEL_NONE = 100;
 	
     void flib_log_setLevel(int level);
+    void flib_log_setCallback(LogCallback callback);
 }
\ No newline at end of file