summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-18 00:20:35 +0200
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-18 00:20:35 +0200
commitc40af4c4ab0541638a6079a97c601a774ed65d02 (patch)
tree425de85573c9ca79f0216224fa3bbe69d5ea0930
parentFixed an assert in bucket placement (diff)
downloadcuberite-c40af4c4ab0541638a6079a97c601a774ed65d02.tar
cuberite-c40af4c4ab0541638a6079a97c601a774ed65d02.tar.gz
cuberite-c40af4c4ab0541638a6079a97c601a774ed65d02.tar.bz2
cuberite-c40af4c4ab0541638a6079a97c601a774ed65d02.tar.lz
cuberite-c40af4c4ab0541638a6079a97c601a774ed65d02.tar.xz
cuberite-c40af4c4ab0541638a6079a97c601a774ed65d02.tar.zst
cuberite-c40af4c4ab0541638a6079a97c601a774ed65d02.zip
Diffstat (limited to '')
-rw-r--r--VC2008/MCServer.vcproj64
-rw-r--r--jni/Android.mk2
-rw-r--r--jni/ToJava.cpp3
-rw-r--r--jni/ToJava.h47
-rw-r--r--jni/app-android.cpp57
-rw-r--r--source/cLog.cpp2
-rw-r--r--source/cPlugin_NewLua.cpp2
-rw-r--r--src/com/mcserver/MCServerActivity.java39
8 files changed, 163 insertions, 53 deletions
diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj
index fec83695d..90ceaca56 100644
--- a/VC2008/MCServer.vcproj
+++ b/VC2008/MCServer.vcproj
@@ -1620,6 +1620,70 @@
RelativePath="..\source\cTimer.h"
>
</File>
+ <Filter
+ Name="Android Specific"
+ >
+ <File
+ RelativePath="..\jni\Android.mk"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\jni\app-android.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\jni\Application.mk"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\jni\ToJava.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\jni\ToJava.h"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
</Filter>
<Filter
Name="Bindings"
diff --git a/jni/Android.mk b/jni/Android.mk
index b55990005..68c807c6e 100644
--- a/jni/Android.mk
+++ b/jni/Android.mk
@@ -9,7 +9,7 @@ LOCAL_SRC_FILES := $(shell find lua-5.1.4 jsoncpp-src-0.5.0 zlib-1.2.7 source sq
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_SRC_FILES += app-android.cpp ToJava.cpp
LOCAL_CFLAGS := -DANDROID_NDK \
-ffast-math \
diff --git a/jni/ToJava.cpp b/jni/ToJava.cpp
new file mode 100644
index 000000000..10d4e84a0
--- /dev/null
+++ b/jni/ToJava.cpp
@@ -0,0 +1,3 @@
+#include "Globals.h"
+
+#include "ToJava.h" \ No newline at end of file
diff --git a/jni/ToJava.h b/jni/ToJava.h
new file mode 100644
index 000000000..59dc4c366
--- /dev/null
+++ b/jni/ToJava.h
@@ -0,0 +1,47 @@
+#pragma once
+
+#include <jni.h>
+#include <android/log.h>
+extern JNIEnv* g_CurrentJNIEnv;
+
+extern jobject g_JavaThread;
+//extern jobject g_JavaActivity;
+
+//__android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList);
+
+static void CallJavaFunction_Void_String( jobject a_Object, const std::string & a_FunctionName, const std::string & a_StringParam )
+{
+ //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "JNIEnv: %i Object: %i", g_CurrentJNIEnv, a_Object );
+ jclass cls = g_CurrentJNIEnv->GetObjectClass( a_Object );
+ //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "jclass: %i", cls );
+ jmethodID mid = g_CurrentJNIEnv->GetMethodID( cls, a_FunctionName.c_str(), "(Ljava/lang/String;)V"); // void a_FunctionName( String )
+ //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "jmethodID: %i", mid );
+ if (mid != 0)
+ {
+ //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "Going to call right NOW! %s", a_FunctionName.c_str() );
+ g_CurrentJNIEnv->CallVoidMethod( a_Object, mid, g_CurrentJNIEnv->NewStringUTF( a_StringParam.c_str() ) );
+ }
+ else
+ {
+ __android_log_print(ANDROID_LOG_ERROR,"MCServer", "It was 0, derp" );
+ }
+}
+
+
+static void CallJavaFunction_Void_Void( jobject a_Object, const std::string & a_FunctionName )
+{
+ __android_log_print(ANDROID_LOG_ERROR,"MCServer", "JNIEnv: %i Object: %i", g_CurrentJNIEnv, a_Object );
+ jclass cls = g_CurrentJNIEnv->GetObjectClass( a_Object );
+ __android_log_print(ANDROID_LOG_ERROR,"MCServer", "jclass: %i", cls );
+ jmethodID mid = g_CurrentJNIEnv->GetMethodID( cls, a_FunctionName.c_str(), "()V"); // void a_FunctionName( String )
+ __android_log_print(ANDROID_LOG_ERROR,"MCServer", "jmethodID: %i", mid );
+ if (mid != 0)
+ {
+ __android_log_print(ANDROID_LOG_ERROR,"MCServer", "Going to call right NOW! %s", a_FunctionName.c_str() );
+ g_CurrentJNIEnv->CallVoidMethod( a_Object, mid );
+ }
+ else
+ {
+ __android_log_print(ANDROID_LOG_ERROR,"MCServer", "It was 0, derp" );
+ }
+} \ No newline at end of file
diff --git a/jni/app-android.cpp b/jni/app-android.cpp
index d02947440..461f433bf 100644
--- a/jni/app-android.cpp
+++ b/jni/app-android.cpp
@@ -13,24 +13,34 @@
#include "cCriticalSection.h"
#include "cRoot.h"
#include "cMakeDir.h"
+#include "ToJava.h"
#include <android/log.h>
cCriticalSection g_CriticalSection;
JNIEnv* g_CurrentJNIEnv = 0;
-jobject g_JavaRenderer = 0;
+jobject g_JavaThread = 0;
+//jobject g_JavaActivity = 0;
cRoot * pRoot = NULL;
+
+
+
+
/* Called when program/activity is created */
-extern "C" void Java_com_mcserver_MainThread_NativeOnCreate( JNIEnv* env )
+extern "C" void Java_com_mcserver_MainThread_NativeOnCreate( JNIEnv* env, jobject thiz )
{
g_CriticalSection.Lock();
g_CurrentJNIEnv = env;
+ g_JavaThread = thiz;
//if( !cLogger::GetSingletonPtr() ) new cLogger();
__android_log_print(ANDROID_LOG_ERROR,"MCServer", "%s", "Logging from C++!");
g_CriticalSection.Unlock();
+
+ //CallJavaFunction_Void_Void(g_JavaActivity, "TestTest" );
+ //CallJavaFunction_Void_String(g_JavaThread, "AddToLog", "herpderpderp!!" );
mkdir("/sdcard/mcserver", S_IRWXU | S_IRWXG | S_IRWXO);
@@ -39,57 +49,20 @@ extern "C" void Java_com_mcserver_MainThread_NativeOnCreate( JNIEnv* env )
delete pRoot;
}
-extern "C" void Java_com_mcserver_MCServerActivity_NativeCleanUp( JNIEnv* env )
-{
- g_CriticalSection.Lock();
- g_CurrentJNIEnv = env;
-
- g_CriticalSection.Unlock();
- pRoot->ServerCommand("stop");
-}
-/* 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 )
+extern "C" void Java_com_mcserver_MainThread_NativeCleanUp( JNIEnv* env, jobject thiz )
{
g_CriticalSection.Lock();
g_CurrentJNIEnv = env;
- g_JavaRenderer = thiz;
-
+ g_JavaThread = 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();
+ pRoot->ServerCommand("stop");
}
-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();
-} \ No newline at end of file
diff --git a/source/cLog.cpp b/source/cLog.cpp
index d1874f7e2..57ad9b418 100644
--- a/source/cLog.cpp
+++ b/source/cLog.cpp
@@ -11,6 +11,7 @@
#if defined(ANDROID_NDK)
#include <android/log.h>
+#include "ToJava.h"
#endif
@@ -130,6 +131,7 @@ void cLog::Log(const char * a_Format, va_list argList)
// Print to console:
#if defined(ANDROID_NDK)
__android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList);
+ //CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line );
#else
printf("%s", Line.c_str());
#endif
diff --git a/source/cPlugin_NewLua.cpp b/source/cPlugin_NewLua.cpp
index feba602ba..7f7f0c20c 100644
--- a/source/cPlugin_NewLua.cpp
+++ b/source/cPlugin_NewLua.cpp
@@ -73,7 +73,7 @@ bool cPlugin_NewLua::Initialize()
ManualBindings::Bind( m_LuaState );
}
- std::string PluginPath = std::string("Plugins/") + m_Directory + "/";
+ std::string PluginPath = FILE_IO_PREFIX + std::string("Plugins/") + m_Directory + "/";
// Load all files for this plugin, and execute them
AStringList Files = GetDirectoryContents(PluginPath.c_str());
diff --git a/src/com/mcserver/MCServerActivity.java b/src/com/mcserver/MCServerActivity.java
index f7bfc76e3..ff1a4fae2 100644
--- a/src/com/mcserver/MCServerActivity.java
+++ b/src/com/mcserver/MCServerActivity.java
@@ -2,35 +2,42 @@ package com.mcserver;
import android.app.Activity;
import android.os.Bundle;
+import android.util.Log;
import android.view.KeyEvent;
public class MCServerActivity extends Activity {
+ MainThread mThread = null;
+
/** 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();
+ mThread = new MainThread();
+ mThread.start();
}
- public boolean onKeyDown(int keyCode, KeyEvent event)
- {
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode==KeyEvent.KEYCODE_BACK)
{
//android.os.Process.killProcess(android.os.Process.myPid());
- NativeCleanUp();
+ mThread.NativeCleanUp();
return super.onKeyDown(keyCode, event);
}
return false;
}
+ public void AddToLog( String logMessage ) {
+
+ }
+
static {
System.loadLibrary("mcserver");
}
- private static native void NativeCleanUp();
+
+
}
@@ -39,9 +46,23 @@ class MainThread extends Thread {
MainThread() {
}
+ public void AddToLog( String logMessage ) {
+ //Log.d("MCServer", "Add to log: " + logMessage);
+ }
+
+ public void TestTest(){
+ Log.d("MCServer", "in testtest");
+ }
+
public void run() {
NativeOnCreate();
}
-
- private static native void NativeOnCreate();
-} \ No newline at end of file
+ public native void NativeOnCreate();
+ public native void NativeCleanUp();
+}
+
+
+
+
+
+