@@ -21,13 +21,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
21
21
#error This file may only be compiled for android!
22
22
#endif
23
23
24
+ #include " util/numeric.h"
24
25
#include " porting.h"
25
26
#include " porting_android.h"
26
27
#include " threading/thread.h"
27
28
#include " config.h"
28
29
#include " filesys.h"
29
30
#include " log.h"
31
+
30
32
#include < sstream>
33
+ #include < exception>
34
+ #include < stdlib.h>
31
35
32
36
#ifdef GPROF
33
37
#include " prof.h"
@@ -40,28 +44,23 @@ void android_main(android_app *app)
40
44
int retval = 0 ;
41
45
porting::app_global = app;
42
46
43
- Thread::setName (" MainThread " );
47
+ Thread::setName (" Main " );
44
48
45
49
try {
46
50
app_dummy ();
47
- char *argv[] = {(char *) " minetest" };
48
- main (sizeof (argv) / sizeof (argv[0 ]), argv);
49
- } catch (BaseException &e) {
50
- std::stringstream msg;
51
- msg << " Exception handled by main: " << e.what ();
52
- const char *message = msg.str ().c_str ();
53
- __android_log_print (ANDROID_LOG_ERROR, PROJECT_NAME, " %s" , message);
54
- errorstream << msg << std::endl;
51
+ char *argv[] = {strdup (PROJECT_NAME), NULL };
52
+ main (ARRLEN (argv) - 1 , argv);
53
+ free (argv[0 ]);
54
+ } catch (std::exception &e) {
55
+ errorstream << " Uncaught exception in main thread: " << e.what () << std::endl;
55
56
retval = -1 ;
56
57
} catch (...) {
57
- __android_log_print (ANDROID_LOG_ERROR, PROJECT_NAME,
58
- " An unknown exception occured!" );
59
58
errorstream << " Uncaught exception in main thread!" << std::endl;
60
59
retval = -1 ;
61
60
}
62
61
63
62
porting::cleanupAndroid ();
64
- errorstream << " Shutting down." << std::endl;
63
+ infostream << " Shutting down." << std::endl;
65
64
exit (retval);
66
65
}
67
66
@@ -125,7 +124,7 @@ void initAndroid()
125
124
JavaVM *jvm = app_global->activity ->vm ;
126
125
JavaVMAttachArgs lJavaVMAttachArgs;
127
126
lJavaVMAttachArgs.version = JNI_VERSION_1_6;
128
- lJavaVMAttachArgs.name = " MinetestNativeThread " ;
127
+ lJavaVMAttachArgs.name = PROJECT_NAME_C " NativeThread " ;
129
128
lJavaVMAttachArgs.group = NULL ;
130
129
#ifdef NDEBUG
131
130
// This is a ugly hack as arm v7a non debuggable builds crash without this
@@ -146,7 +145,7 @@ void initAndroid()
146
145
147
146
#ifdef GPROF
148
147
/* in the start-up code */
149
- __android_log_print (ANDROID_LOG_ERROR, PROJECT_NAME ,
148
+ __android_log_print (ANDROID_LOG_ERROR, PROJECT_NAME_C ,
150
149
" Initializing GPROF profiler" );
151
150
monstartup (" libminetest.so" );
152
151
#endif
@@ -186,8 +185,8 @@ void setExternalStorageDir(JNIEnv* lJNIEnv)
186
185
lJNIEnv->ReleaseStringUTFChars (StringPath, externalPath);
187
186
188
187
path_storage = userPath;
189
- path_user = userPath + DIR_DELIM + PROJECT_NAME ;
190
- path_share = userPath + DIR_DELIM + PROJECT_NAME ;
188
+ path_user = userPath + DIR_DELIM + PROJECT_NAME_C ;
189
+ path_share = userPath + DIR_DELIM + PROJECT_NAME_C ;
191
190
}
192
191
193
192
void showInputDialog (const std::string& acceptButton, const std::string& hint,
@@ -240,7 +239,7 @@ std::string getInputDialogValue()
240
239
return text;
241
240
}
242
241
243
- #if not defined( SERVER)
242
+ #ifndef SERVER
244
243
float getDisplayDensity ()
245
244
{
246
245
static bool firstrun = true ;
@@ -290,5 +289,5 @@ v2u32 getDisplaySize()
290
289
}
291
290
return retval;
292
291
}
293
- #endif // SERVER
292
+ #endif // ndef SERVER
294
293
}
0 commit comments