Compiles on Android! Added Eclipse project, import it into your workspace and it should be runnable on Android!
Disabled Squirrel for Android cLog now logs to Android LogCat as well Fixed Lua so it compiles on Android Removed/commented out exceptions in JsonCpp so it compiles on Android git-svn-id: http://mc-server.googlecode.com/svn/trunk@741 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
5bc07ba743
commit
d21e4dacf7
8
.classpath
Normal file
8
.classpath
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
33
.project
Normal file
33
.project
Normal file
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>MCServer</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
4
.settings/org.eclipse.jdt.core.prefs
Normal file
4
.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
25
AndroidManifest.xml
Normal file
25
AndroidManifest.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mcserver"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
|
||||
|
||||
<uses-sdk android:minSdkVersion="10" />
|
||||
|
||||
<application
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name" >
|
||||
<activity
|
||||
android:name=".MCServerActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -98,7 +98,9 @@ Socket::Socket() :
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
#if !defined(ANDROID_NDK)
|
||||
throw "INVALID_SOCKET";
|
||||
#endif
|
||||
}
|
||||
|
||||
refCounter_ = new int(1);
|
||||
@ -354,7 +356,9 @@ SocketSelect::SocketSelect(Socket const * const s1, Socket const * const s2, Typ
|
||||
}
|
||||
if (select(Highest + 1, &fds_, NULL, NULL, NULL) == SOCKET_ERROR)
|
||||
{
|
||||
#if !defined(ANDROID_NDK)
|
||||
throw "Error in select";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,9 @@
|
||||
|
||||
#include "base64.h"
|
||||
#include <iostream>
|
||||
#if defined(ANDROID_NDK)
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
static const std::string base64_chars =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
6
gen/com/mcserver/BuildConfig.java
Normal file
6
gen/com/mcserver/BuildConfig.java
Normal file
@ -0,0 +1,6 @@
|
||||
/** Automatically generated file. DO NOT MODIFY */
|
||||
package com.mcserver;
|
||||
|
||||
public final class BuildConfig {
|
||||
public final static boolean DEBUG = true;
|
||||
}
|
23
gen/com/mcserver/R.java
Normal file
23
gen/com/mcserver/R.java
Normal file
@ -0,0 +1,23 @@
|
||||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package com.mcserver;
|
||||
|
||||
public final class R {
|
||||
public static final class attr {
|
||||
}
|
||||
public static final class drawable {
|
||||
public static final int ic_launcher=0x7f020000;
|
||||
}
|
||||
public static final class layout {
|
||||
public static final int main=0x7f030000;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int app_name=0x7f040001;
|
||||
public static final int hello=0x7f040000;
|
||||
}
|
||||
}
|
44
jni/Android.mk
Normal file
44
jni/Android.mk
Normal file
@ -0,0 +1,44 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := mcserver
|
||||
|
||||
|
||||
|
||||
LOCAL_SRC_FILES := $(shell find lua-5.1.4 jsoncpp-src-0.5.0 zlib-1.2.7 source squirrel_3_0_1_stable tolua++-1.0.93 iniFile WebServer '(' -name '*.cpp' -o -name '*.c' ')')
|
||||
LOCAL_SRC_FILES := $(filter-out %SquirrelFunctions.cpp %SquirrelBindings.cpp %cPlugin_Squirrel.cpp %cSquirrelCommandBinder.cpp %minigzip.c %lua.c %tolua.c %toluabind.c %LeakFinder.cpp %StackWalker.cpp %example.c,$(LOCAL_SRC_FILES))
|
||||
LOCAL_SRC_FILES := $(patsubst %.cpp,../%.cpp,$(LOCAL_SRC_FILES))
|
||||
LOCAL_SRC_FILES := $(patsubst %.c,../%.c,$(LOCAL_SRC_FILES))
|
||||
LOCAL_SRC_FILES += app-android.cpp
|
||||
|
||||
LOCAL_CFLAGS := -DANDROID_NDK \
|
||||
-ffast-math \
|
||||
-O3 \
|
||||
-funroll-loops \
|
||||
-mfloat-abi=softfp -mfpu=neon \
|
||||
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := cpufeatures
|
||||
|
||||
LOCAL_C_INCLUDES := ./source \
|
||||
./source/md5 \
|
||||
./WebServer \
|
||||
./source/packets \
|
||||
./source/items \
|
||||
./source/blocks \
|
||||
./tolua++-1.0.93/src/lib \
|
||||
./lua-5.1.4/src \
|
||||
./zlib-1.2.7 \
|
||||
./iniFile \
|
||||
./tolua++-1.0.93/include \
|
||||
./jsoncpp-src-0.5.0/include \
|
||||
./jsoncpp-src-0.5.0/src/lib_json \
|
||||
./squirrel_3_0_1_stable/include \
|
||||
./squirrel_3_0_1_stable \
|
||||
./squirrel_3_0_1_stable/sqrat \
|
||||
|
||||
|
||||
LOCAL_LDLIBS := -ldl -llog
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
$(call import-module,cpufeatures)
|
4
jni/Application.mk
Normal file
4
jni/Application.mk
Normal file
@ -0,0 +1,4 @@
|
||||
# Build both ARMv5TE and ARMv7-A machine code.
|
||||
APP_MODULES := mcserver
|
||||
# APP_ABI := armeabi armeabi-v7a
|
||||
APP_STL := stlport_static
|
87
jni/app-android.cpp
Normal file
87
jni/app-android.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
#include "Globals.h"
|
||||
|
||||
#include <jni.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "cCriticalSection.h"
|
||||
#include "cRoot.h"
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
cCriticalSection g_CriticalSection;
|
||||
|
||||
JNIEnv* g_CurrentJNIEnv = 0;
|
||||
jobject g_JavaRenderer = 0;
|
||||
|
||||
/* Called when program/activity is created */
|
||||
extern "C" void Java_com_mcserver_MainThread_NativeOnCreate( JNIEnv* env )
|
||||
{
|
||||
g_CriticalSection.Lock();
|
||||
g_CurrentJNIEnv = env;
|
||||
//if( !cLogger::GetSingletonPtr() ) new cLogger();
|
||||
__android_log_print(ANDROID_LOG_ERROR,"Arashi", "%s", "Logging from C++!");
|
||||
g_CriticalSection.Unlock();
|
||||
|
||||
cRoot Root;
|
||||
Root.Start();
|
||||
}
|
||||
|
||||
extern "C" void Java_com_mcserver_MCServerActivity_NativeCleanUp( JNIEnv* env )
|
||||
{
|
||||
g_CriticalSection.Lock();
|
||||
g_CurrentJNIEnv = env;
|
||||
|
||||
g_CriticalSection.Unlock();
|
||||
}
|
||||
|
||||
/* Call to initialize the graphics state */
|
||||
extern "C" void Java_com_ballz_CppWrapperRenderer_NativeInitGL( JNIEnv* env, jobject thiz )
|
||||
{
|
||||
g_CriticalSection.Lock();
|
||||
g_CurrentJNIEnv = env;
|
||||
g_JavaRenderer = thiz;
|
||||
|
||||
g_CriticalSection.Unlock();
|
||||
}
|
||||
|
||||
extern "C" void Java_com_ballz_CppWrapperRenderer_NativeResize( JNIEnv* env, jobject thiz, jint w, jint h )
|
||||
{
|
||||
g_CriticalSection.Lock();
|
||||
g_CurrentJNIEnv = env;
|
||||
g_JavaRenderer = thiz;
|
||||
|
||||
g_CriticalSection.Unlock();
|
||||
}
|
||||
|
||||
extern "C" void Java_com_ballz_CppWrapperRenderer_NativeRender( JNIEnv* env, jobject thiz )
|
||||
{
|
||||
g_CriticalSection.Lock();
|
||||
g_CurrentJNIEnv = env;
|
||||
g_JavaRenderer = thiz;
|
||||
|
||||
|
||||
g_CriticalSection.Unlock();
|
||||
}
|
||||
|
||||
extern "C" void Java_com_ballz_CppWrapperGLSurfaceView_NativeTouchScreen( JNIEnv* env, jobject thiz, jint mouseid, jint touched )
|
||||
{
|
||||
g_CriticalSection.Lock();
|
||||
g_CurrentJNIEnv = env;
|
||||
|
||||
g_CriticalSection.Unlock();
|
||||
}
|
||||
|
||||
extern "C" void Java_com_ballz_CppWrapperGLSurfaceView_NativeTouchEvent( JNIEnv* env, jobject thiz, jint mouseid, jfloat x, jfloat y )
|
||||
{
|
||||
g_CriticalSection.Lock();
|
||||
g_CurrentJNIEnv = env;
|
||||
|
||||
g_CriticalSection.Unlock();
|
||||
}
|
@ -871,13 +871,13 @@ Reader::getFormatedErrorMessages() const
|
||||
return formattedMessage;
|
||||
}
|
||||
|
||||
|
||||
#define JSON_ASSERT( condition ) assert( condition );
|
||||
std::istream& operator>>( std::istream &sin, Value &root )
|
||||
{
|
||||
Json::Reader reader;
|
||||
bool ok = reader.parse(sin, root, true);
|
||||
//JSON_ASSERT( ok );
|
||||
if (!ok) throw std::runtime_error(reader.getFormatedErrorMessages());
|
||||
JSON_ASSERT( ok );
|
||||
//if (!ok) throw std::runtime_error(reader.getFormatedErrorMessages());
|
||||
return sin;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,8 @@ Value::CommentInfo::setComment( const char *text )
|
||||
if ( comment_ )
|
||||
valueAllocator()->releaseStringValue( comment_ );
|
||||
JSON_ASSERT( text );
|
||||
JSON_ASSERT_MESSAGE( text[0]=='\0' || text[0]=='/', "Comments must start with /");
|
||||
//JSON_ASSERT_MESSAGE( text[0]=='\0' || text[0]=='/', "Comments must start with /");
|
||||
JSON_ASSERT( text[0]=='\0' || text[0]=='/' );
|
||||
// It seems that /**/ style comments are acceptable as well.
|
||||
comment_ = valueAllocator()->duplicateStringValue( text );
|
||||
}
|
||||
@ -697,7 +698,8 @@ Value::asString() const
|
||||
case realValue:
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
JSON_ASSERT_MESSAGE( false, "Type is not convertible to string" );
|
||||
//JSON_ASSERT_MESSAGE( false, "Type is not convertible to string" );
|
||||
JSON_ASSERT( false );
|
||||
default:
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
@ -722,17 +724,20 @@ Value::asInt() const
|
||||
case intValue:
|
||||
return value_.int_;
|
||||
case uintValue:
|
||||
JSON_ASSERT_MESSAGE( value_.uint_ < (unsigned)maxInt, "integer out of signed integer range" );
|
||||
//JSON_ASSERT_MESSAGE( value_.uint_ < (unsigned)maxInt, "integer out of signed integer range" );
|
||||
JSON_ASSERT( value_.uint_ < (unsigned)maxInt );
|
||||
return value_.uint_;
|
||||
case realValue:
|
||||
JSON_ASSERT_MESSAGE( value_.real_ >= minInt && value_.real_ <= maxInt, "Real out of signed integer range" );
|
||||
//JSON_ASSERT_MESSAGE( value_.real_ >= minInt && value_.real_ <= maxInt, "Real out of signed integer range" );
|
||||
JSON_ASSERT( value_.real_ >= minInt && value_.real_ <= maxInt );
|
||||
return Int( value_.real_ );
|
||||
case booleanValue:
|
||||
return value_.bool_ ? 1 : 0;
|
||||
case stringValue:
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
JSON_ASSERT_MESSAGE( false, "Type is not convertible to int" );
|
||||
//JSON_ASSERT_MESSAGE( false, "Type is not convertible to int" );
|
||||
JSON_ASSERT( false );
|
||||
default:
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
@ -747,19 +752,22 @@ Value::asUInt() const
|
||||
case nullValue:
|
||||
return 0;
|
||||
case intValue:
|
||||
JSON_ASSERT_MESSAGE( value_.int_ >= 0, "Negative integer can not be converted to unsigned integer" );
|
||||
//JSON_ASSERT_MESSAGE( value_.int_ >= 0, "Negative integer can not be converted to unsigned integer" );
|
||||
JSON_ASSERT( value_.int_ >= 0 );
|
||||
return value_.int_;
|
||||
case uintValue:
|
||||
return value_.uint_;
|
||||
case realValue:
|
||||
JSON_ASSERT_MESSAGE( value_.real_ >= 0 && value_.real_ <= maxUInt, "Real out of unsigned integer range" );
|
||||
//JSON_ASSERT_MESSAGE( value_.real_ >= 0 && value_.real_ <= maxUInt, "Real out of unsigned integer range" );
|
||||
JSON_ASSERT( value_.real_ >= 0 && value_.real_ <= maxUInt );
|
||||
return UInt( value_.real_ );
|
||||
case booleanValue:
|
||||
return value_.bool_ ? 1 : 0;
|
||||
case stringValue:
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
JSON_ASSERT_MESSAGE( false, "Type is not convertible to uint" );
|
||||
//JSON_ASSERT_MESSAGE( false, "Type is not convertible to uint" );
|
||||
JSON_ASSERT( false );
|
||||
default:
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
@ -784,7 +792,8 @@ Value::asDouble() const
|
||||
case stringValue:
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
JSON_ASSERT_MESSAGE( false, "Type is not convertible to double" );
|
||||
//JSON_ASSERT_MESSAGE( false, "Type is not convertible to double" );
|
||||
JSON_ASSERT( false );
|
||||
default:
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
|
@ -176,9 +176,13 @@ static void buffreplace (LexState *ls, char from, char to) {
|
||||
|
||||
static void trydecpoint (LexState *ls, SemInfo *seminfo) {
|
||||
/* format error: try to update decimal point separator */
|
||||
struct lconv *cv = localeconv();
|
||||
char old = ls->decpoint;
|
||||
#if defined(ANDROID_NDK)
|
||||
ls->decpoint = '.';
|
||||
#else
|
||||
struct lconv *cv = localeconv();
|
||||
ls->decpoint = (cv ? cv->decimal_point[0] : '.');
|
||||
#endif
|
||||
buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */
|
||||
if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) {
|
||||
/* format error with correct decimal point: no more options */
|
||||
|
20
proguard-project.txt
Normal file
20
proguard-project.txt
Normal file
@ -0,0 +1,20 @@
|
||||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
14
project.properties
Normal file
14
project.properties
Normal file
@ -0,0 +1,14 @@
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-12
|
BIN
res/drawable-hdpi/ic_launcher.png
Normal file
BIN
res/drawable-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
BIN
res/drawable-ldpi/ic_launcher.png
Normal file
BIN
res/drawable-ldpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
BIN
res/drawable-mdpi/ic_launcher.png
Normal file
BIN
res/drawable-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
BIN
res/drawable-xhdpi/ic_launcher.png
Normal file
BIN
res/drawable-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
12
res/layout/main.xml
Normal file
12
res/layout/main.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/hello" />
|
||||
|
||||
</LinearLayout>
|
7
res/values/strings.xml
Normal file
7
res/values/strings.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="hello">Hello World, MCServerActivity!</string>
|
||||
<string name="app_name">MCServer</string>
|
||||
|
||||
</resources>
|
@ -114,8 +114,14 @@ typedef short Int16;
|
||||
#include <semaphore.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#if !defined(ANDROID_NDK)
|
||||
#include <tr1/memory>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(ANDROID_NDK)
|
||||
#define USE_SQUIRREL
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -5,6 +5,9 @@
|
||||
|
||||
#include "Globals.h"
|
||||
|
||||
#if defined(ANDROID_NDK)
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -9,6 +9,9 @@
|
||||
|
||||
#include "cIsThread.h"
|
||||
|
||||
#if defined(ANDROID_NDK)
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -97,6 +100,10 @@ void cLog::ClearLog()
|
||||
|
||||
void cLog::Log(const char * a_Format, va_list argList)
|
||||
{
|
||||
#if defined(ANDROID_NDK)
|
||||
__android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList);
|
||||
return; // This is as far as android goes
|
||||
#endif
|
||||
AString Message;
|
||||
AppendVPrintf(Message, a_Format, argList);
|
||||
|
||||
|
@ -4,20 +4,21 @@
|
||||
#include "cPlugin.h"
|
||||
#include "cPlugin_Lua.h"
|
||||
#include "cPlugin_NewLua.h"
|
||||
#include "cPlugin_Squirrel.h"
|
||||
#include "cWebAdmin.h"
|
||||
#include "cItem.h"
|
||||
#include "cRoot.h"
|
||||
#include "cLuaCommandBinder.h"
|
||||
#include "cSquirrelCommandBinder.h"
|
||||
#if USE_SQUIRREL
|
||||
# include "cPlugin_Squirrel.h"
|
||||
# include "cSquirrelCommandBinder.h"
|
||||
#endif
|
||||
#include "../iniFile/iniFile.h"
|
||||
#include "tolua++.h"
|
||||
#include "cPlayer.h"
|
||||
|
||||
#include "squirrelbindings/SquirrelBindings.h"
|
||||
#include "squirrelbindings/SquirrelFunctions.h"
|
||||
|
||||
#if USE_SQUIRREL
|
||||
#include "squirrelbindings/SquirrelBindings.h"
|
||||
#include "squirrelbindings/SquirrelFunctions.h"
|
||||
#pragma warning(disable:4100;disable:4127;disable:4510;disable:4610;disable:4244;disable:4512) // Getting A LOT of these warnings from SqPlus
|
||||
|
||||
#pragma warning(default:4100;default:4127;default:4510;default:4610;default:4244;default:4512)
|
||||
@ -39,7 +40,9 @@ cPluginManager* cPluginManager::GetPluginManager()
|
||||
|
||||
cPluginManager::cPluginManager()
|
||||
: m_LuaCommandBinder( new cLuaCommandBinder() )
|
||||
#if USE_SQUIRREL
|
||||
, m_SquirrelCommandBinder( new cSquirrelCommandBinder() )
|
||||
#endif
|
||||
, m_bReloadPlugins(false)
|
||||
{
|
||||
}
|
||||
@ -53,7 +56,9 @@ cPluginManager::~cPluginManager()
|
||||
UnloadPluginsNow();
|
||||
|
||||
delete m_LuaCommandBinder;
|
||||
#if USE_SQUIRREL
|
||||
delete m_SquirrelCommandBinder;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -197,10 +202,12 @@ bool cPluginManager::CallHook(PluginHook a_Hook, unsigned int a_NumArgs, ...)
|
||||
cPlayer * Player = va_arg(argptr, cPlayer * );
|
||||
va_end (argptr);
|
||||
|
||||
#if USE_SQUIRREL
|
||||
if (m_SquirrelCommandBinder->HandleCommand( std::string( Message ), Player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_LuaCommandBinder->HandleCommand( std::string( Message ), Player))
|
||||
{
|
||||
@ -682,7 +689,9 @@ void cPluginManager::RemovePlugin( cPlugin* a_Plugin, bool a_bDelete /* = false
|
||||
if( a_bDelete )
|
||||
{
|
||||
m_LuaCommandBinder->RemoveBindingsForPlugin( a_Plugin );
|
||||
#if USE_SQUIRREL
|
||||
m_SquirrelCommandBinder->RemoveBindingsForPlugin( a_Plugin );
|
||||
#endif
|
||||
m_Plugins.remove( a_Plugin );
|
||||
RemoveHooks( a_Plugin );
|
||||
a_Plugin->OnDisable();
|
||||
|
@ -16,8 +16,10 @@
|
||||
#include "cRedstone.h"
|
||||
#include "blocks/Block.h"
|
||||
#include "items/Item.h"
|
||||
#if USE_SQUIRREL
|
||||
#include "squirrelbindings/SquirrelFunctions.h"
|
||||
#include "squirrelbindings/SquirrelBindings.h"
|
||||
#endif
|
||||
#include "cChunk.h"
|
||||
|
||||
#include "../iniFile/iniFile.h"
|
||||
|
@ -111,7 +111,7 @@ AString cSocket::GetErrorString( int a_ErrNo )
|
||||
|
||||
// According to http://linux.die.net/man/3/strerror_r there are two versions of strerror_r():
|
||||
|
||||
#if ( _GNU_SOURCE ) // GNU version of strerror_r()
|
||||
#if ( _GNU_SOURCE ) && !defined(ANDROID_NDK) // GNU version of strerror_r()
|
||||
|
||||
char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer) );
|
||||
if( res != NULL )
|
||||
@ -158,7 +158,7 @@ int cSocket::GetLastError()
|
||||
|
||||
int cSocket::SetReuseAddress()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) || defined(ANDROID_NDK)
|
||||
char yes = 1;
|
||||
#else
|
||||
int yes = 1;
|
||||
|
@ -6,13 +6,16 @@
|
||||
#include <exception> //std::exception
|
||||
#include <csignal> //std::signal
|
||||
#include <stdlib.h> //exit()
|
||||
#ifdef USE_SQUIRREL
|
||||
#include "squirrelbindings/SquirrelFunctions.h"
|
||||
#include "squirrelbindings/SquirrelBindings.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <dbghelp.h>
|
||||
#endif // _WIN32
|
||||
|
||||
#include "squirrelbindings/SquirrelBindings.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@ -168,11 +171,14 @@ int main( int argc, char **argv )
|
||||
// DEBUG: test the dumpfile creation:
|
||||
// *((int *)0) = 0;
|
||||
|
||||
#if !defined(ANDROID_NDK)
|
||||
try
|
||||
#endif
|
||||
{
|
||||
cRoot Root;
|
||||
Root.Start();
|
||||
}
|
||||
#if !defined(ANDROID_NDK)
|
||||
catch( std::exception& e )
|
||||
{
|
||||
LOGERROR("Standard exception: %s", e.what() );
|
||||
@ -181,6 +187,7 @@ int main( int argc, char **argv )
|
||||
{
|
||||
LOGERROR("Unknown exception!");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER)
|
||||
|
37
src/com/mcserver/MCServerActivity.java
Normal file
37
src/com/mcserver/MCServerActivity.java
Normal file
@ -0,0 +1,37 @@
|
||||
package com.mcserver;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class MCServerActivity extends Activity {
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
MainThread p = new MainThread();
|
||||
p.start();
|
||||
|
||||
//NativeOnCreate();
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
System.loadLibrary("mcserver");
|
||||
}
|
||||
|
||||
private static native void NativeOnCreate();
|
||||
}
|
||||
|
||||
|
||||
class MainThread extends Thread {
|
||||
MainThread() {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
NativeOnCreate();
|
||||
}
|
||||
|
||||
private static native void NativeOnCreate();
|
||||
}
|
Loading…
Reference in New Issue
Block a user