aboutsummaryrefslogtreecommitdiff
Commit message (Expand)AuthorAge
...
* Fix build error on Ubuntu 16.04sfan52020-06-10
* Fix broken coloring of wielditems (#9969)Danila Shutov2020-06-09
* Some vector functions useful for working with rotations (#9572)NetherEran2020-06-09
* LuaItemStack: Add __tostring metamethod (#8785)Paul Ouellette2020-06-09
* Fix player-to-object attachment teleport bug (#10008)hecktest2020-06-09
* TouchScreenGUI: fix some bugs, cleanupMoNTE482020-06-09
* TouchScreen Control: fix some bugs, cleanupMoNTE482020-06-09
* Fix real keyboard movements on touchscreen devicesMaksim2020-06-09
* Hide tooltip after ETIE_LEFT_UP (for touch control)MoNTE482020-06-09
* devtest: Improve tool and formspec usabilitysfan52020-06-08
* Reset touching_ground when in free_movesfan52020-06-07
* Fix Lua panic when error() message is not a stringPaul Ouellette2020-06-07
* Recalculate mesh normals for CAOs (#10000)Danila Shutov2020-06-07
* GenericCAO: Fix glow not working since a08d18aSmallJoker2020-06-07
* Restore visual_scale support for nodeboxes (and allfaces) (#9906)Vitaliy2020-06-06
* Fix incorrect extension used for ContentDB thumbnailsrubenwardy2020-06-06
* Add HTTP API to main menu (#9998)rubenwardy2020-06-06
* Fix HUD scaling (#9721)Maksim2020-06-05
* TestBan: Clean up properly after completing test (#9994)ANAND2020-06-05
* Show Toast in UI thread and fix unpacking on Android 10 (#9900)Bektur2020-06-05
* Add buttons to ContentDB in game bar and configure world (#9944)rubenwardy2020-06-04
* Move shared parameters sending to UnitSAO (#9968)SmallJoker2020-06-04
* Fix autoscale_mode segfault if tile doesn't have texturesfan52020-06-01
* Lua API: Log incorrect parameter types as error (#9954)SmallJoker2020-06-01
* ContentCAO: Update light of all attached entities (#9975)SmallJoker2020-06-01
* imageScaleNNAA: Fix image clipping on rect- instead of image dimensions (#9896)Hugues Ross2020-06-01
* Devtest: Fix missing/incorrect liquid properties (#9955)Wuzzy2020-05-30
* Clean up CAO nametag handling and remove deprecated AO_CMDsfan52020-05-29
* content_cao: Do not expire visuals when not necessarysfan52020-05-29
* Add disable_jump check for the player's feetMoNTE482020-05-29
* Add minetest.is_creative_enabledWuzzy2020-05-29
* Update ContentDB dialog (#9949)rubenwardy2020-05-29
* Value copy / allocation optimizations mostly in server, SAO and serialize codesfan52020-05-27
* Change item entity collisionbox so that they don't sink into the groundsfan52020-05-27
* Fix falling entity not falling through playerssfan52020-05-27
* Make ContentDB downloads not block the UI (#9948)rubenwardy2020-05-27
* Fix liquids refusing to flow in X+ or Z+ in some cases (#9874)sfan52020-05-26
* Devtest game: Update biome registrations (#9936)Paramat2020-05-26
* Fix devtest being ignored by .gitignorerubenwardy2020-05-26
* Devtest: Fix crash in player unittest (#9937)Wuzzy2020-05-26
* Rename “Minimal development test” to “Development Test” (#9928)Wuzzy2020-05-26
* L-System trees: Remove hardcoded use of 'mapgen_dirt' alias (#9931)Paramat2020-05-25
* Silence GCC warning in mapblock_meshSmallJoker2020-05-25
* Fix build on FreeBSD, broken since open_urlrubenwardy2020-05-24
* Add engine version string to ContentDB API request (#9890)rubenwardy2020-05-24
* Replacement for Minimal Development Test (PR) (#9450)Wuzzy2020-05-24
* Add chat_font_size setting (#9736)SmallJoker2020-05-24
* Fix two bugs in content_caosfan52020-05-24
* Fix constant re-queueing of emerges that will always be unsuccessfulsfan52020-05-24
* Fix documentation of emergequeue_limit settingssfan52020-05-24
an class="hl opt">[0]); } catch (std::exception &e) { errorstream << "Uncaught exception in main thread: " << e.what() << std::endl; retval = -1; } catch (...) { errorstream << "Uncaught exception in main thread!" << std::endl; retval = -1; } porting::cleanupAndroid(); infostream << "Shutting down." << std::endl; exit(retval); } /** * Handler for finished message box input * Intentionally NOT in namespace porting * ToDo: this doesn't work as expected, there's a workaround for it right now */ extern "C" { JNIEXPORT void JNICALL Java_net_minetest_minetest_GameActivity_putMessageBoxResult( JNIEnv *env, jclass thiz, jstring text) { errorstream << "Java_net_minetest_minetest_GameActivity_putMessageBoxResult got: " << std::string((const char*) env->GetStringChars(text, nullptr)) << std::endl; } } namespace porting { android_app *app_global; JNIEnv *jnienv; jclass nativeActivity; jclass findClass(const std::string &classname) { if (jnienv == nullptr) return nullptr; jclass nativeactivity = jnienv->FindClass("android/app/NativeActivity"); jmethodID getClassLoader = jnienv->GetMethodID( nativeactivity, "getClassLoader", "()Ljava/lang/ClassLoader;"); jobject cls = jnienv->CallObjectMethod( app_global->activity->clazz, getClassLoader); jclass classLoader = jnienv->FindClass("java/lang/ClassLoader"); jmethodID findClass = jnienv->GetMethodID(classLoader, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;"); jstring strClassName = jnienv->NewStringUTF(classname.c_str()); return (jclass) jnienv->CallObjectMethod(cls, findClass, strClassName); } void initAndroid() { porting::jnienv = nullptr; JavaVM *jvm = app_global->activity->vm; JavaVMAttachArgs lJavaVMAttachArgs; lJavaVMAttachArgs.version = JNI_VERSION_1_6; lJavaVMAttachArgs.name = PROJECT_NAME_C "NativeThread"; lJavaVMAttachArgs.group = nullptr; if (jvm->AttachCurrentThread(&porting::jnienv, &lJavaVMAttachArgs) == JNI_ERR) { errorstream << "Failed to attach native thread to jvm" << std::endl; exit(-1); } nativeActivity = findClass("net/minetest/minetest/GameActivity"); if (nativeActivity == nullptr) errorstream << "porting::initAndroid unable to find java native activity class" << std::endl; #ifdef GPROF // in the start-up code __android_log_print(ANDROID_LOG_ERROR, PROJECT_NAME_C, "Initializing GPROF profiler"); monstartup("libMinetest.so"); #endif } void cleanupAndroid() { #ifdef GPROF errorstream << "Shutting down GPROF profiler" << std::endl; setenv("CPUPROFILE", (path_user + DIR_DELIM + "gmon.out").c_str(), 1); moncleanup(); #endif JavaVM *jvm = app_global->activity->vm; jvm->DetachCurrentThread(); } static std::string javaStringToUTF8(jstring js) { std::string str; // Get string as a UTF-8 c-string const char *c_str = jnienv->GetStringUTFChars(js, nullptr); // Save it str = c_str; // And free the c-string jnienv->ReleaseStringUTFChars(js, c_str); return str; } // Calls static method if obj is NULL static std::string getAndroidPath( jclass cls, jobject obj, jmethodID mt_getAbsPath, const char *getter) { // Get getter method jmethodID mt_getter; if (obj) mt_getter = jnienv->GetMethodID(cls, getter, "()Ljava/io/File;"); else mt_getter = jnienv->GetStaticMethodID(cls, getter, "()Ljava/io/File;"); // Call getter jobject ob_file; if (obj) ob_file = jnienv->CallObjectMethod(obj, mt_getter); else ob_file = jnienv->CallStaticObjectMethod(cls, mt_getter); // Call getAbsolutePath auto js_path = (jstring) jnienv->CallObjectMethod(ob_file, mt_getAbsPath); return javaStringToUTF8(js_path); } void initializePathsAndroid() { // Get Environment class jclass cls_Env = jnienv->FindClass("android/os/Environment"); // Get File class jclass cls_File = jnienv->FindClass("java/io/File"); // Get getAbsolutePath method jmethodID mt_getAbsPath = jnienv->GetMethodID(cls_File, "getAbsolutePath", "()Ljava/lang/String;"); std::string path_storage = getAndroidPath(cls_Env, nullptr, mt_getAbsPath, "getExternalStorageDirectory"); path_user = path_storage + DIR_DELIM + PROJECT_NAME_C; path_share = path_storage + DIR_DELIM + PROJECT_NAME_C; path_cache = getAndroidPath(nativeActivity, app_global->activity->clazz, mt_getAbsPath, "getCacheDir"); migrateCachePath(); } void showInputDialog(const std::string &acceptButton, const std::string &hint, const std::string &current, int editType) { jmethodID showdialog = jnienv->GetMethodID(nativeActivity, "showDialog", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V"); FATAL_ERROR_IF(showdialog == nullptr, "porting::showInputDialog unable to find java show dialog method"); jstring jacceptButton = jnienv->NewStringUTF(acceptButton.c_str()); jstring jhint = jnienv->NewStringUTF(hint.c_str()); jstring jcurrent = jnienv->NewStringUTF(current.c_str()); jint jeditType = editType; jnienv->CallVoidMethod(app_global->activity->clazz, showdialog, jacceptButton, jhint, jcurrent, jeditType); } void openURIAndroid(const std::string &url) { jmethodID url_open = jnienv->GetMethodID(nativeActivity, "openURI", "(Ljava/lang/String;)V"); FATAL_ERROR_IF(url_open == nullptr, "porting::openURIAndroid unable to find java openURI method"); jstring jurl = jnienv->NewStringUTF(url.c_str()); jnienv->CallVoidMethod(app_global->activity->clazz, url_open, jurl); } int getInputDialogState() { jmethodID dialogstate = jnienv->GetMethodID(nativeActivity, "getDialogState", "()I"); FATAL_ERROR_IF(dialogstate == nullptr, "porting::getInputDialogState unable to find java dialog state method"); return jnienv->CallIntMethod(app_global->activity->clazz, dialogstate); } std::string getInputDialogValue() { jmethodID dialogvalue = jnienv->GetMethodID(nativeActivity, "getDialogValue", "()Ljava/lang/String;"); FATAL_ERROR_IF(dialogvalue == nullptr, "porting::getInputDialogValue unable to find java dialog value method"); jobject result = jnienv->CallObjectMethod(app_global->activity->clazz, dialogvalue); const char *javachars = jnienv->GetStringUTFChars((jstring) result, nullptr); std::string text(javachars); jnienv->ReleaseStringUTFChars((jstring) result, javachars); return text; } #ifndef SERVER float getDisplayDensity() { static bool firstrun = true; static float value = 0; if (firstrun) { jmethodID getDensity = jnienv->GetMethodID(nativeActivity, "getDensity", "()F"); FATAL_ERROR_IF(getDensity == nullptr, "porting::getDisplayDensity unable to find java getDensity method"); value = jnienv->CallFloatMethod(app_global->activity->clazz, getDensity); firstrun = false; } return value; } v2u32 getDisplaySize() { static bool firstrun = true; static v2u32 retval; if (firstrun) { jmethodID getDisplayWidth = jnienv->GetMethodID(nativeActivity, "getDisplayWidth", "()I"); FATAL_ERROR_IF(getDisplayWidth == nullptr, "porting::getDisplayWidth unable to find java getDisplayWidth method"); retval.X = jnienv->CallIntMethod(app_global->activity->clazz, getDisplayWidth); jmethodID getDisplayHeight = jnienv->GetMethodID(nativeActivity, "getDisplayHeight", "()I"); FATAL_ERROR_IF(getDisplayHeight == nullptr, "porting::getDisplayHeight unable to find java getDisplayHeight method"); retval.Y = jnienv->CallIntMethod(app_global->activity->clazz, getDisplayHeight); firstrun = false; } return retval; } #endif // ndef SERVER }