Merge remote-tracking branch 'sandstranger/fix-bad-code-in-command-line'

celladd
Marc Zinnschlag 10 years ago
commit 545ca9c9b4

@ -1,18 +1,20 @@
#include "android_commandLine.h" #include "android_commandLine.h"
#include "string.h" #include "string.h"
const char *argvData[15];
int argcData;
const char **argvData;
int argcData;
JNIEXPORT void JNICALL Java_ui_activity_GameActivity_commandLine(JNIEnv *env, JNIEXPORT void JNICALL Java_ui_activity_GameActivity_commandLine(JNIEnv *env,
jobject obj, jint argc, jobjectArray stringArray) { jobject obj, jint argc, jobjectArray stringArray) {
jboolean iscopy; jboolean iscopy;
argcData = (int) argc; argcData = (int) argc;
argvData[0]="openmw"; argvData= new const char * [argcData+1];
for (int i = 0; i < argcData; i++) { argvData[0] = "openmw";
jstring string = (jstring) (*env).GetObjectArrayElement(stringArray, i); for (int i = 1; i < argcData+1; i++) {
argvData[i+1] = (env)->GetStringUTFChars(string, &iscopy); jstring string = (jstring) (*env).GetObjectArrayElement(stringArray, i-1);
argvData[i] = (env)->GetStringUTFChars(string, &iscopy);
} }
} }

@ -12,7 +12,7 @@
extern void SDL_Android_Init(JNIEnv* env, jclass cls); extern void SDL_Android_Init(JNIEnv* env, jclass cls);
extern int argcData; extern int argcData;
extern const char *argvData[15]; extern const char **argvData;
int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls,
jobject obj) { jobject obj) {
@ -26,6 +26,7 @@ int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls,
int status; int status;
status = main(argcData+1, argvData); status = main(argcData+1, argvData);
free (argvData);
/* Do not issue an exit or the whole application will terminate instead of just the SDL thread */ /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
/* exit(status); */ /* exit(status); */

Loading…
Cancel
Save