2012-08-15 17:24:11 -04:00
|
|
|
#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"
|
2012-08-16 16:28:14 -04:00
|
|
|
#include "cMakeDir.h"
|
2012-08-17 18:20:35 -04:00
|
|
|
#include "ToJava.h"
|
2012-08-15 17:24:11 -04:00
|
|
|
|
|
|
|
#include <android/log.h>
|
|
|
|
|
|
|
|
cCriticalSection g_CriticalSection;
|
|
|
|
|
|
|
|
JNIEnv* g_CurrentJNIEnv = 0;
|
2012-08-17 18:20:35 -04:00
|
|
|
jobject g_JavaThread = 0;
|
|
|
|
//jobject g_JavaActivity = 0;
|
2012-08-15 17:24:11 -04:00
|
|
|
|
2012-08-16 16:28:14 -04:00
|
|
|
cRoot * pRoot = NULL;
|
|
|
|
|
2012-08-17 18:20:35 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-15 17:24:11 -04:00
|
|
|
/* Called when program/activity is created */
|
2012-08-17 18:20:35 -04:00
|
|
|
extern "C" void Java_com_mcserver_MainThread_NativeOnCreate( JNIEnv* env, jobject thiz )
|
2012-08-15 17:24:11 -04:00
|
|
|
{
|
|
|
|
g_CriticalSection.Lock();
|
|
|
|
g_CurrentJNIEnv = env;
|
2012-08-17 18:20:35 -04:00
|
|
|
g_JavaThread = thiz;
|
2012-08-15 17:24:11 -04:00
|
|
|
//if( !cLogger::GetSingletonPtr() ) new cLogger();
|
2012-08-16 16:28:14 -04:00
|
|
|
__android_log_print(ANDROID_LOG_ERROR,"MCServer", "%s", "Logging from C++!");
|
2012-08-15 17:24:11 -04:00
|
|
|
g_CriticalSection.Unlock();
|
2012-08-17 18:20:35 -04:00
|
|
|
|
|
|
|
//CallJavaFunction_Void_Void(g_JavaActivity, "TestTest" );
|
|
|
|
//CallJavaFunction_Void_String(g_JavaThread, "AddToLog", "herpderpderp!!" );
|
2012-08-15 17:24:11 -04:00
|
|
|
|
2012-08-16 16:28:14 -04:00
|
|
|
mkdir("/sdcard/mcserver", S_IRWXU | S_IRWXG | S_IRWXO);
|
|
|
|
|
|
|
|
pRoot = new cRoot();
|
|
|
|
pRoot->Start();
|
|
|
|
delete pRoot;
|
2012-08-15 17:24:11 -04:00
|
|
|
}
|
|
|
|
|
2012-08-16 16:28:14 -04:00
|
|
|
|
2012-08-15 17:24:11 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-17 18:20:35 -04:00
|
|
|
extern "C" void Java_com_mcserver_MainThread_NativeCleanUp( JNIEnv* env, jobject thiz )
|
2012-08-15 17:24:11 -04:00
|
|
|
{
|
|
|
|
g_CriticalSection.Lock();
|
|
|
|
g_CurrentJNIEnv = env;
|
2012-08-17 18:20:35 -04:00
|
|
|
g_JavaThread = thiz;
|
2012-08-15 17:24:11 -04:00
|
|
|
g_CriticalSection.Unlock();
|
|
|
|
|
2012-08-17 18:20:35 -04:00
|
|
|
pRoot->ServerCommand("stop");
|
2012-08-15 17:24:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|