1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Somehow it works but JNI signatures were incorrect

This commit is contained in:
Andrii Danylchenko 2023-01-25 08:59:59 +02:00
parent 1b3c07eda4
commit 4cfc93d2da
3 changed files with 16 additions and 5 deletions

View File

@ -771,14 +771,14 @@ void CClient::reinitScripting()
} }
#ifdef VCMI_ANDROID #ifdef VCMI_ANDROID
extern "C" JNIEXPORT void JNICALL Java_eu_vcmi_vcmi_NativeMethods_clientSetupJNI(JNIEnv * env, jobject cls) extern "C" JNIEXPORT void JNICALL Java_eu_vcmi_vcmi_NativeMethods_clientSetupJNI(JNIEnv * env, jclass cls)
{ {
logNetwork->info("Received clientSetupJNI"); logNetwork->info("Received clientSetupJNI");
CAndroidVMHelper::cacheVM(env); CAndroidVMHelper::cacheVM(env);
} }
extern "C" JNIEXPORT void JNICALL Java_eu_vcmi_vcmi_NativeMethods_notifyServerClosed(JNIEnv * env, jobject cls) extern "C" JNIEXPORT void JNICALL Java_eu_vcmi_vcmi_NativeMethods_notifyServerClosed(JNIEnv * env, jclass cls)
{ {
logNetwork->info("Received server closed signal"); logNetwork->info("Received server closed signal");
if (CSH) { if (CSH) {
@ -786,13 +786,13 @@ extern "C" JNIEXPORT void JNICALL Java_eu_vcmi_vcmi_NativeMethods_notifyServerCl
} }
} }
extern "C" JNIEXPORT void JNICALL Java_eu_vcmi_vcmi_NativeMethods_notifyServerReady(JNIEnv * env, jobject cls) extern "C" JNIEXPORT void JNICALL Java_eu_vcmi_vcmi_NativeMethods_notifyServerReady(JNIEnv * env, jclass cls)
{ {
logNetwork->info("Received server ready signal"); logNetwork->info("Received server ready signal");
androidTestServerReadyFlag.store(true); androidTestServerReadyFlag.store(true);
} }
extern "C" JNIEXPORT bool JNICALL Java_eu_vcmi_vcmi_NativeMethods_tryToSaveTheGame(JNIEnv * env, jobject cls) extern "C" JNIEXPORT jboolean JNICALL Java_eu_vcmi_vcmi_NativeMethods_tryToSaveTheGame(JNIEnv * env, jclass cls)
{ {
logGlobal->info("Received emergency save game request"); logGlobal->info("Received emergency save game request");
if(!LOCPLINT || !LOCPLINT->cb) if(!LOCPLINT || !LOCPLINT->cb)

View File

@ -96,7 +96,7 @@ jclass CAndroidVMHelper::findClass(const std::string & name, bool classloaded)
return get()->FindClass(name.c_str()); return get()->FindClass(name.c_str());
} }
extern "C" JNIEXPORT void JNICALL Java_eu_vcmi_vcmi_NativeMethods_initClassloader(JNIEnv * baseEnv, jobject * cls) extern "C" JNIEXPORT void JNICALL Java_eu_vcmi_vcmi_NativeMethods_initClassloader(JNIEnv * baseEnv, jclass cls)
{ {
CAndroidVMHelper::cacheVM(baseEnv); CAndroidVMHelper::cacheVM(baseEnv);
CAndroidVMHelper envHelper; CAndroidVMHelper envHelper;

View File

@ -28,6 +28,8 @@
#include "../lib/mapping/CMap.h" #include "../lib/mapping/CMap.h"
#include "../lib/rmg/CMapGenOptions.h" #include "../lib/rmg/CMapGenOptions.h"
#ifdef VCMI_ANDROID #ifdef VCMI_ANDROID
#include <jni.h>
#include <android/log.h>
#include "lib/CAndroidVMHelper.h" #include "lib/CAndroidVMHelper.h"
#elif !defined(VCMI_IOS) #elif !defined(VCMI_IOS)
#include "../lib/Interprocess.h" #include "../lib/Interprocess.h"
@ -1118,12 +1120,21 @@ int main(int argc, char * argv[])
} }
#ifdef VCMI_ANDROID #ifdef VCMI_ANDROID
extern "C" JNIEXPORT void JNICALL Java_eu_vcmi_vcmi_NativeMethods_createServer(JNIEnv * env, jclass cls)
{
__android_log_write(ANDROID_LOG_INFO, "VCMI", "Got jni call to init server");
CAndroidVMHelper::cacheVM(env);
CVCMIServer::create();
}
void CVCMIServer::create() void CVCMIServer::create()
{ {
const char * foo = "android-server"; const char * foo = "android-server";
std::vector<const void *> argv = {foo}; std::vector<const void *> argv = {foo};
main(argv.size(), reinterpret_cast<char **>(const_cast<void **>(&*argv.begin()))); main(argv.size(), reinterpret_cast<char **>(const_cast<void **>(&*argv.begin())));
} }
#elif defined(SINGLE_PROCESS_APP) #elif defined(SINGLE_PROCESS_APP)
void CVCMIServer::create(boost::condition_variable * cond, const std::vector<std::string> & args) void CVCMIServer::create(boost::condition_variable * cond, const std::vector<std::string> & args)
{ {