Hedgeroid: Added experimental lobby chat
authorMedo <smaxein@googlemail.com>
Wed, 11 Jul 2012 01:52:01 +0200 (2012-07-10)
changeset 7328 cd919a2ead4e
parent 7326 1fae07363938
child 7330 867e4fda496e
Hedgeroid: Added experimental lobby chat
project_files/Android-build/SDL-android-project/AndroidManifest.xml
project_files/Android-build/SDL-android-project/assets/Data/metasettings.ini
project_files/Android-build/SDL-android-project/res/layout/activity_lobby.xml
project_files/Android-build/SDL-android-project/res/layout/main.xml
project_files/Android-build/SDL-android-project/res/values/strings.xml
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/MainActivity.java
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/FrontlibTypeMapper.java
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/JnaFrontlib.java
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/LobbyActivity.java
--- a/project_files/Android-build/SDL-android-project/AndroidManifest.xml	Wed Jul 11 01:51:28 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/AndroidManifest.xml	Wed Jul 11 01:52:01 2012 +0200
@@ -1,54 +1,75 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-      package="org.hedgewars.hedgeroid"
-      android:versionCode="8"
-      android:installLocation="preferExternal" android:versionName="0.2">
-    <uses-sdk android:targetSdkVersion="14" android:minSdkVersion="7"></uses-sdk>
-    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
-    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
-    <application android:label="@string/app_name" android:icon="@drawable/icon">
-        <activity android:name=".MainActivity"
-                  android:label="@string/app_name"
- 		  		  android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
+    package="org.hedgewars.hedgeroid"
+    android:installLocation="preferExternal"
+    android:versionCode="8"
+    android:versionName="0.2" >
+
+    <uses-sdk
+        android:minSdkVersion="7"
+        android:targetSdkVersion="14" >
+    </uses-sdk>
+
+    <uses-permission android:name="android.permission.INTERNET" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
+    </uses-permission>
+
+    <application
+        android:icon="@drawable/icon"
+        android:label="@string/app_name" >
+        <activity
+            android:name=".MainActivity"
+            android:label="@string/app_name"
+            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
+
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
-        <activity android:name=".SDLActivity"
-                  android:label="@string/app_name"
- 		  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
-		  android:screenOrientation='landscape'>
+        <activity
+            android:name=".SDLActivity"
+            android:label="@string/app_name"
+            android:screenOrientation="landscape"
+            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
         </activity>
-        
-        <activity android:name=".Downloader.DownloadFragment"
-                  android:label="@string/app_name"
-				  android:theme="@android:style/Theme.Dialog">
+        <activity
+            android:name=".Downloader.DownloadFragment"
+            android:label="@string/app_name"
+            android:theme="@android:style/Theme.Dialog" >
         </activity>
-        
-        <activity android:name=".Downloader.DownloadListActivity"
-                  android:label="@string/app_name"
-				  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
-				  android:screenOrientation='landscape'
-				  android:launchMode="singleTop"/>
-        
-        <service android:name=".Downloader.DownloadService"/>
-        
-        <activity android:name="StartGameActivity"
-                  android:label="@string/app_name"
-				  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
-				  android:screenOrientation='landscape'>
+        <activity
+            android:name=".Downloader.DownloadListActivity"
+            android:label="@string/app_name"
+            android:launchMode="singleTop"
+            android:screenOrientation="landscape"
+            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
+
+        <service android:name=".Downloader.DownloadService" />
+
+        <activity
+            android:name="StartGameActivity"
+            android:label="@string/app_name"
+            android:screenOrientation="landscape"
+            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
         </activity>
-        <activity android:name="TeamSelectionActivity"
-                  android:label="@string/app_name"
-				  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
-				  android:screenOrientation='landscape'>
+        <activity
+            android:name="TeamSelectionActivity"
+            android:label="@string/app_name"
+            android:screenOrientation="landscape"
+            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
         </activity>
-        <activity android:name="TeamCreatorActivity"
-                  android:label="@string/app_name"
-				  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
-				  android:screenOrientation='landscape'
-				  android:windowSoftInputMode="stateUnchanged">
+        <activity
+            android:name="TeamCreatorActivity"
+            android:label="@string/app_name"
+            android:screenOrientation="landscape"
+            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
+            android:windowSoftInputMode="stateUnchanged" >
+        </activity>
+        <activity
+            android:name=".netplay.LobbyActivity"
+            android:label="@string/title_activity_lobby" >
         </activity>
     </application>
-</manifest> 
+</manifest>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/assets/Data/metasettings.ini	Wed Jul 11 01:52:01 2012 +0200
@@ -0,0 +1,234 @@
+[mod0]
+name=fortsmode
+bitmaskindex=12
+
+[mod1]
+name=divteams
+bitmaskindex=4
+
+[mod2]
+name=solidland
+bitmaskindex=2
+
+[mod3]
+name=border
+bitmaskindex=3
+
+[mod4]
+name=lowgrav
+bitmaskindex=5
+
+[mod5]
+name=laser
+bitmaskindex=6
+
+[mod6]
+name=invulnerability
+bitmaskindex=7
+
+[mod7]
+name=resethealth
+bitmaskindex=8
+
+[mod8]
+name=vampiric
+bitmaskindex=9
+
+[mod9]
+name=karma
+bitmaskindex=10
+
+[mod10]
+name=artillery
+bitmaskindex=11
+
+[mod11]
+name=randomorder
+bitmaskindex=13
+
+[mod12]
+name=king
+bitmaskindex=14
+
+[mod13]
+name=placehog
+bitmaskindex=15
+
+[mod14]
+name=sharedammo
+bitmaskindex=16
+
+[mod15]
+name=disablegirders
+bitmaskindex=17
+
+[mod16]
+name=disablelandobjects
+bitmaskindex=18
+
+[mod17]
+name=aisurvival
+bitmaskindex=19
+
+[mod18]
+name=infattack
+bitmaskindex=20
+
+[mod19]
+name=resetweps
+bitmaskindex=21
+
+[mod20]
+name=perhogammo
+bitmaskindex=22
+
+[mod21]
+name=disablewind
+bitmaskindex=23
+
+[mod22]
+name=morewind
+bitmaskindex=24
+
+[mod23]
+name=tagteam
+bitmaskindex=25
+
+[mod24]
+name=bottomborder
+bitmaskindex=26
+
+
+[setting0]
+name=damagefactor
+times1000=false
+command=e$damagepct
+maxmeansinfinity=false
+min=10
+max=300
+default=100
+
+[setting1]
+name=turntime
+times1000=true
+command=e$turntime
+maxmeansinfinity=true
+min=1
+max=9999
+default=45
+
+[setting2]
+name=health
+times1000=false
+maxmeansinfinity=false
+min=50
+max=200
+default=100
+
+[setting3]
+name=suddendeath
+times1000=false
+command=e$sd_turns
+maxmeansinfinity=true
+min=0
+max=50
+default=15
+
+[setting4]
+name=caseprobability
+times1000=false
+command=e$casefreq
+maxmeansinfinity=false
+min=0
+max=9
+default=5
+
+[setting5]
+name=minestime
+times1000=true
+command=e$minestime
+maxmeansinfinity=false
+min=-1
+max=5
+default=3
+
+[setting6]
+name=minesnum
+times1000=false
+command=e$minesnum
+maxmeansinfinity=false
+min=0
+max=80
+default=4
+
+[setting7]
+name=minedudpct
+times1000=false
+command=e$minedudpct
+maxmeansinfinity=false
+min=0
+max=100
+default=0
+
+[setting8]
+name=explosives
+times1000=false
+command=e$explosives
+maxmeansinfinity=false
+min=0
+max=40
+default=2
+
+[setting9]
+name=healthprobability
+times1000=false
+command=e$healthprob
+maxmeansinfinity=false
+min=0
+max=100
+default=35
+
+[setting10]
+name=healthcaseamount
+times1000=false
+command=e$hcaseamount
+maxmeansinfinity=false
+min=0
+max=200
+default=25
+
+[setting11]
+name=waterrise
+times1000=false
+command=e$waterrise
+maxmeansinfinity=false
+min=0
+max=100
+default=47
+
+[setting12]
+name=healthdecrease
+times1000=false
+command=e$healthdec
+maxmeansinfinity=false
+min=0
+max=100
+default=5
+
+[setting13]
+name=ropepct
+times1000=false
+command=e$ropepct
+maxmeansinfinity=false
+min=25
+max=999
+default=100
+
+[setting14]
+name=getawaytime
+times1000=false
+command=e$getawaytime
+maxmeansinfinity=false
+min=0
+max=999
+default=100
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/res/layout/activity_lobby.xml	Wed Jul 11 01:52:01 2012 +0200
@@ -0,0 +1,35 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent" >
+
+    <TextView
+        android:id="@+id/textbox"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_alignParentRight="true"
+        android:layout_alignParentBottom="true"
+        android:layout_below="@+id/editText"
+        android:text=""
+        tools:context=".LobbyActivity" />
+
+    <EditText
+        android:id="@+id/editText"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_alignParentTop="true"
+        android:layout_toLeftOf="@+id/lobbySendButton"
+        android:ems="10"
+        android:inputType="text" />
+
+    <Button
+        android:id="@+id/lobbySendButton"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentRight="true"
+        android:layout_alignParentTop="true"
+        android:text="Send" />
+
+</RelativeLayout>
--- a/project_files/Android-build/SDL-android-project/res/layout/main.xml	Wed Jul 11 01:51:28 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/res/layout/main.xml	Wed Jul 11 01:52:01 2012 +0200
@@ -21,5 +21,11 @@
     	android:layout_height="wrap_content"
     	android:text="startgame"/>
     	
+    <Button
+    	android:id="@+id/joinLobby"
+    	android:layout_width="wrap_content"
+    	android:layout_height="wrap_content"
+    	android:text="join lobby"/>
+    
 </LinearLayout>
 </FrameLayout>
\ No newline at end of file
--- a/project_files/Android-build/SDL-android-project/res/values/strings.xml	Wed Jul 11 01:51:28 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/res/values/strings.xml	Wed Jul 11 01:52:01 2012 +0200
@@ -1,20 +1,20 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
+
     <string name="app_name">Hedgewars</string>
-    
     <string name="select">Select</string>
     <string name="edit">Edit</string>
     <string name="delete">Delete</string>
     <string name="saved">Saved succesfully</string>
-    
+
     <!-- SDCARD -->
     <string name="sdcard_not_mounted_title">Sorry! Could not find the SDCard</string>
     <string name="sdcard_not_mounted">There\'s been an error when accessing the SDcard. Please check if there is an SDcard present in the device (internal or external) and if the SDcard is not mounted (via usb to your computer for example). Hedgewars for Android will now quit</string>
-        
+
     <!-- Notification -->
     <string name="notification_title">Downloading hedgewars files...</string>
     <string name="notification_done">Successfully downloaded: </string>
-    
+
     <!-- Download Activity -->
     <string name="download_background">Continue in background</string>
     <string name="download_cancel">Cancel</string>
@@ -23,24 +23,20 @@
     <string name="download_tryagain">Try again</string>
     <string name="download_failed">The download has failed because of: </string>
     <string name="download_userexplain">Before starting the game we must download some extra files...</string>
-    
     <string name="download_areyousure">Are you sure you want to download this package?</string>
     <string name="download_alreadydownloaded">You\'ve already downloaded this package, are you sure you want to download it again?</string>
     <string name="download_downloadnow">Download now!</string>
-    
     <string name="download_queued">This download has been queued</string>
-    
+
     <!-- start game -->
-    
+
     <string name="start_gameplay">Style</string>
     <string name="start_gamescheme">Game scheme</string>
     <string name="start_weapons">Weapons</string>
     <string name="start_map">Map</string>
     <string name="start_filter">Filter</string>
     <string name="start_themes">Themes</string>
-    
-    
-    
+
     <!-- Teams -->
     <string name="not_enough_teams">Not enough teams</string>
     <string name="teams_info_template">Selected teams = %d</string>
@@ -52,7 +48,7 @@
     <string name="flag">Flag</string>
     <string name="voice">Voice</string>
     <string name="fort">Fort</string>
-    
+
     <!-- Difficulty levels -->
     <string name="human">Human</string>
     <string name="bot5">Level 5</string>
@@ -60,5 +56,6 @@
     <string name="bot3">Level 3</string>
     <string name="bot2">Level 2</string>
     <string name="bot1">Level 1</string>
-    
+
+    <string name="title_activity_lobby">LobbyActivity</string>
 </resources>
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/MainActivity.java	Wed Jul 11 01:51:28 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/MainActivity.java	Wed Jul 11 01:52:01 2012 +0200
@@ -20,6 +20,7 @@
 
 import org.hedgewars.hedgeroid.Downloader.DownloadAssets;
 import org.hedgewars.hedgeroid.Downloader.DownloadListActivity;
+import org.hedgewars.hedgeroid.netplay.LobbyActivity;
 
 import android.app.AlertDialog;
 import android.app.Dialog;
@@ -36,7 +37,6 @@
 import android.widget.Toast;
 
 public class MainActivity extends FragmentActivity {
-
 	private Button downloader, startGame;
 	private ProgressDialog assetsDialog;
 
@@ -46,9 +46,15 @@
 
 		downloader = (Button)findViewById(R.id.downloader);
 		startGame = (Button)findViewById(R.id.startGame);
+		Button joinLobby = (Button)findViewById(R.id.joinLobby);
 
 		downloader.setOnClickListener(downloadClicker);
 		startGame.setOnClickListener(startGameClicker);
+		joinLobby.setOnClickListener(new OnClickListener() {
+			public void onClick(View v) {
+				startActivity(new Intent(getApplicationContext(), LobbyActivity.class));
+			}
+		});
 
 		if(!Utils.isDataPathAvailable()){
 			showDialog(0);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/FrontlibTypeMapper.java	Wed Jul 11 01:52:01 2012 +0200
@@ -0,0 +1,71 @@
+package org.hedgewars.hedgeroid.netplay;
+
+import java.io.UnsupportedEncodingException;
+
+import com.sun.jna.DefaultTypeMapper;
+import com.sun.jna.FromNativeContext;
+import com.sun.jna.FromNativeConverter;
+import com.sun.jna.Native;
+import com.sun.jna.Pointer;
+import com.sun.jna.ToNativeContext;
+import com.sun.jna.ToNativeConverter;
+import com.sun.jna.TypeConverter;
+import com.sun.jna.TypeMapper;
+
+public class FrontlibTypeMapper extends DefaultTypeMapper {
+    public static final TypeMapper INSTANCE = new FrontlibTypeMapper();
+    
+    protected FrontlibTypeMapper() {
+        addTypeConverter(Boolean.class, new BooleanConverter());
+		addToNativeConverter(String.class, new StringToNativeConverter());
+		addFromNativeConverter(String.class, new StringFromNativeConverter());
+    }
+}
+
+class BooleanConverter implements TypeConverter {
+    public Class<Byte> nativeType() {
+        return Byte.class;
+    }
+	public Object fromNative(Object value, FromNativeContext context) {
+		return ((Byte)value).intValue() != 0 ? Boolean.TRUE : Boolean.FALSE;
+	}
+	public Object toNative(Object value, ToNativeContext context) {
+		return Byte.valueOf((byte)(Boolean.TRUE.equals(value) ? 1 : 0));
+	}
+}
+
+class StringToNativeConverter implements ToNativeConverter {
+	public byte[] toNative(Object value, ToNativeContext context) {
+    	try {
+			return value==null ? null : Native.toByteArray((String)value, "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+			throw new AssertionError(e); // Never happens
+		}
+	}
+	
+	public Class<byte[]> nativeType() {
+		return byte[].class;
+	}
+}
+
+class StringFromNativeConverter implements FromNativeConverter {
+	public String fromNative(Object value, FromNativeContext context) {
+		Pointer p = (Pointer)value;
+		if(p==null) {
+			return null;
+		}
+		int i=0;
+		while(p.getByte(i) != 0) {
+			i++;
+		}
+    	try {
+			return new String(p.getByteArray(0, i), "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+			throw new AssertionError(e); // Never happens
+		}
+	}
+	
+	public Class<Pointer> nativeType() {
+		return Pointer.class;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/JnaFrontlib.java	Wed Jul 11 01:52:01 2012 +0200
@@ -0,0 +1,273 @@
+package org.hedgewars.hedgeroid.netplay;
+import java.nio.Buffer;
+
+import com.sun.jna.Callback;
+import com.sun.jna.Library;
+import com.sun.jna.NativeLong;
+import com.sun.jna.Pointer;
+import com.sun.jna.PointerType;
+
+
+public interface JnaFrontlib extends Library {
+	static final int NETCONN_STATE_CONNECTING = 0;
+	static final int NETCONN_STATE_LOBBY = 1;
+	static final int NETCONN_STATE_ROOM = 2;
+	static final int NETCONN_STATE_INGAME = 3;
+	static final int NETCONN_STATE_DISCONNECTED = 10;
+	
+	static final int NETCONN_DISCONNECT_NORMAL = 0;
+	static final int NETCONN_DISCONNECT_SERVER_TOO_OLD = 1;
+	static final int NETCONN_DISCONNECT_AUTH_FAILED = 2;
+	static final int NETCONN_DISCONNECT_CONNLOST = 3;
+	static final int NETCONN_DISCONNECT_INTERNAL_ERROR = 100;
+	
+	static final int NETCONN_ROOMLEAVE_ABANDONED = 0;
+	static final int NETCONN_ROOMLEAVE_KICKED = 1;
+	
+	static final int NETCONN_MSG_TYPE_PLAYERINFO = 0;
+	static final int NETCONN_MSG_TYPE_SERVERMESSAGE = 1;
+	static final int NETCONN_MSG_TYPE_WARNING = 2;
+	static final int NETCONN_MSG_TYPE_ERROR = 3;
+	
+	static final int NETCONN_MAPCHANGE_FULL = 0;
+	static final int NETCONN_MAPCHANGE_MAP = 1;
+	static final int NETCONN_MAPCHANGE_MAPGEN = 2;
+	static final int NETCONN_MAPCHANGE_DRAWNMAP = 3;
+	static final int NETCONN_MAPCHANGE_MAZE_SIZE = 4;
+	static final int NETCONN_MAPCHANGE_TEMPLATE = 5;
+	static final int NETCONN_MAPCHANGE_THEME = 6;
+	static final int NETCONN_MAPCHANGE_SEED = 7;
+	
+	static final int  GAME_END_FINISHED = 0;
+	static final int  GAME_END_INTERRUPTED = 1;
+	static final int  GAME_END_HALTED = 2;
+	static final int  GAME_END_ERROR = 3;
+	
+	static class NetconnPtr extends PointerType { }
+	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 TeamPtr extends PointerType { }
+	static class WeaponsetPtr extends PointerType { }
+	static class MapRecipePtr extends PointerType { }
+	static class SchemePtr extends PointerType { }
+	static class GameSetupPtr extends PointerType { }
+	
+	public static interface VoidCallback extends Callback {
+		void callback(Pointer context);
+	}
+	
+	public static interface StrCallback extends Callback {
+		void callback(Pointer context, String arg1);
+	}
+	
+	public static interface IntCallback extends Callback {
+		void callback(Pointer context, int arg1);
+	}
+	
+	public static interface IntStrCallback extends Callback {
+		void callback(Pointer context, int arg1, String arg2);
+	}
+	
+	public static interface StrIntCallback extends Callback {
+		void callback(Pointer context, String arg1, int arg2);
+	}
+	
+	public static interface StrStrCallback extends Callback {
+		void callback(Pointer context, String arg1, String arg2);
+	}
+	
+	public static interface RoomCallback extends Callback {
+		void callback(Pointer context, JnaFrontlib.RoomPtr arg1);
+	}
+	
+	public static interface StrRoomCallback extends Callback {
+		void callback(Pointer context, String arg1, JnaFrontlib.RoomPtr arg2);
+	}
+	
+	public static interface BoolCallback extends Callback {
+		void callback(Pointer context, boolean arg1);
+	}
+	
+	public static interface StrBoolCallback extends Callback {
+		void callback(Pointer context, String arg1, boolean arg2);
+	}
+	
+	public static interface TeamCallback extends Callback {
+		void callback(Pointer context, JnaFrontlib.TeamPtr arg1);
+	}
+	
+	public static interface BytesCallback extends Callback {
+		void callback(Pointer context, Pointer buffer, NativeLong size);
+	}
+	
+	public static interface BytesBoolCallback extends Callback {
+		void callback(Pointer context, Pointer buffer, NativeLong size, boolean arg3);
+	}
+	
+	public static interface SchemeCallback extends Callback {
+		void callback(Pointer context, JnaFrontlib.SchemePtr arg1);
+	}
+	
+	public static interface MapIntCallback extends Callback {
+		void callback(Pointer context, JnaFrontlib.MapRecipePtr arg1, int arg2);
+	}
+	
+	public static interface WeaponsetCallback extends Callback {
+		void callback(Pointer context, JnaFrontlib.WeaponsetPtr arg1);
+	}
+	
+	public static interface MapimageCallback extends Callback {
+		void callback(Pointer context, Pointer buffer, int hedgehogCount);
+	}
+	
+    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);
+
+	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_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);
+
+	// 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);
+
+	void flib_gameconn_destroy(JnaFrontlib.GameconnPtr conn);
+	int flib_gameconn_getport(JnaFrontlib.GameconnPtr conn);
+	void flib_gameconn_tick(JnaFrontlib.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);
+	
+	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);
+	
+	// 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);
+	
+	// GameSetup
+	void flib_gamesetup_destroy(JnaFrontlib.GameSetupPtr gamesetup);
+	JnaFrontlib.GameSetupPtr flib_gamesetup_copy(JnaFrontlib.GameSetupPtr gamesetup);
+	
+	// MapRecipe
+	public static final int MAPGEN_REGULAR = 0;
+	public static final int MAPGEN_MAZE = 1;
+	public static final int MAPGEN_DRAWN = 2;
+	public static final int MAPGEN_NAMED = 3;
+
+	public static final int TEMPLATEFILTER_ALL = 0;
+	public static final int TEMPLATEFILTER_SMALL = 1;
+	public static final int TEMPLATEFILTER_MEDIUM = 2;
+	public static final int TEMPLATEFILTER_LARGE = 3;
+	public static final int TEMPLATEFILTER_CAVERN = 4;
+	public static final int TEMPLATEFILTER_WACKY = 5;
+
+	public static final int MAZE_SIZE_SMALL_TUNNELS = 0;
+	public static final int MAZE_SIZE_MEDIUM_TUNNELS = 1;
+	public static final int MAZE_SIZE_LARGE_TUNNELS = 2;
+	public static final int MAZE_SIZE_SMALL_ISLANDS = 3;
+	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);
+	
+	// Metascheme
+	JnaFrontlib.MetaschemePtr flib_metascheme_from_ini(String filename);
+	JnaFrontlib.MetaschemePtr flib_metascheme_retain(JnaFrontlib.MetaschemePtr metainfo);
+	void flib_metascheme_release(JnaFrontlib.MetaschemePtr metainfo);
+	
+    void flib_log_setLevel(int level);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/LobbyActivity.java	Wed Jul 11 01:52:01 2012 +0200
@@ -0,0 +1,128 @@
+package org.hedgewars.hedgeroid.netplay;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.Collections;
+
+import org.hedgewars.hedgeroid.R;
+import org.hedgewars.hedgeroid.Utils;
+import org.hedgewars.hedgeroid.R.layout;
+
+import com.sun.jna.Library;
+import com.sun.jna.Native;
+import com.sun.jna.Pointer;
+
+import android.os.Bundle;
+import android.os.CountDownTimer;
+import android.app.Activity;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.inputmethod.EditorInfo;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.TextView.OnEditorActionListener;
+
+public class LobbyActivity extends Activity {
+	static {
+		System.loadLibrary("SDL_net");
+	}
+	static final JnaFrontlib FRONTLIB = (JnaFrontlib)Native.loadLibrary("frontlib", JnaFrontlib.class, Collections.singletonMap(Library.OPTION_TYPE_MAPPER, FrontlibTypeMapper.INSTANCE));
+	
+	TextView textView;
+	EditText editText;
+	Button button;
+	
+	boolean disconnected;
+	JnaFrontlib.NetconnPtr netconn;
+	CountDownTimer timer;
+	
+	private void commitText() {
+		if(!disconnected && netconn!=null) {
+			String text = editText.getText().toString();
+			editText.setText("");
+			textView.append("AndroidChatter: " + text + "\n");
+			FRONTLIB.flib_netconn_send_chat(netconn, text);
+		}
+	}
+	
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        disconnected = false;
+        setContentView(R.layout.activity_lobby);
+        textView = (TextView)findViewById(R.id.textbox);
+        editText = (EditText)findViewById(R.id.editText);
+        button = (Button)findViewById(R.id.lobbySendButton);
+        
+        button.setOnClickListener(new OnClickListener() {
+        	public void onClick(View v) {
+        		commitText();
+        	}
+        });
+        
+    	FRONTLIB.flib_init();
+    	try {
+    		JnaFrontlib.MetaschemePtr scheme = FRONTLIB.flib_metascheme_from_ini(new File(Utils.getDataPathFile(this), "metasettings.ini").getAbsolutePath());
+			netconn = FRONTLIB.flib_netconn_create("AndroidChatter", scheme, Utils.getDataPathFile(this).getAbsolutePath(), "140.247.62.101", 46631);
+			Log.d("Netconn", "netconn is "+netconn);
+			FRONTLIB.flib_metascheme_release(scheme);
+		} catch (FileNotFoundException e) {
+			throw new RuntimeException(e);
+		}
+        
+    	FRONTLIB.flib_netconn_onConnected(netconn, handleNetConnected, null);
+    	FRONTLIB.flib_netconn_onDisconnected(netconn, handleNetDisconnect, null);
+    	FRONTLIB.flib_netconn_onChat(netconn, handleChat, null);
+    	FRONTLIB.flib_netconn_onMessage(netconn, handleMessage, null);
+    	timer = new CountDownTimer(100000000, 100) {
+			@Override
+			public void onTick(long millisUntilFinished) {
+				if(!disconnected) {
+					FRONTLIB.flib_netconn_tick(netconn);
+				}
+			}
+			
+			@Override
+			public void onFinish() {
+			}
+		};
+		timer.start();
+    }
+
+    @Override
+    protected void onPause() {
+    	super.onPause();
+    	FRONTLIB.flib_netconn_send_quit(netconn, "Activity paused");
+    }
+    
+    private JnaFrontlib.VoidCallback handleNetConnected = new JnaFrontlib.VoidCallback() {
+		public void callback(Pointer context) {
+			textView.append("Connected. You can chat now.\n");
+		}
+	};
+	
+    private JnaFrontlib.IntStrCallback handleNetDisconnect = new JnaFrontlib.IntStrCallback() {
+		public void callback(Pointer context, int arg1, String arg2) {
+			disconnected = true;
+			timer.cancel();
+			FRONTLIB.flib_netconn_destroy(netconn);
+			netconn.setPointer(Pointer.NULL);
+			textView.append("You have been disconnected.");
+		}
+	};
+	
+    private JnaFrontlib.StrStrCallback handleChat = new JnaFrontlib.StrStrCallback() {
+		public void callback(Pointer context, String arg1, String arg2) {
+			textView.append(arg1+": "+arg2+"\n");
+		}
+	};
+	
+    private JnaFrontlib.IntStrCallback handleMessage = new JnaFrontlib.IntStrCallback() {
+		public void callback(Pointer context, int arg1, String arg2) {
+			textView.append(arg2+"\n");
+		}
+	};
+}