diff --git a/build/android/jni/Android.mk b/build/android/jni/Android.mk index 97a08cf2e..67cef7d47 100644 --- a/build/android/jni/Android.mk +++ b/build/android/jni/Android.mk @@ -53,7 +53,8 @@ LOCAL_CFLAGS := -D_IRR_ANDROID_PLATFORM_ \ -DUSE_GETTEXT=1 \ -DUSE_LEVELDB=1 \ $(GPROF_DEF) \ - -pipe + -pipe \ + -DDISABLE_CSM ifndef NDEBUG LOCAL_CFLAGS += -g -D_DEBUG -O0 -fno-omit-frame-pointer diff --git a/src/camera.cpp b/src/camera.cpp index 9a1612e90..3d06453ae 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -126,10 +126,12 @@ bool Camera::successfullyCreated(std::string &error_message) } else { error_message.clear(); } - + +#ifndef DISABLE_CSM if (g_settings->getBool("enable_client_modding")) { m_client->getScript()->on_camera_ready(this); } +#endif return error_message.empty(); } diff --git a/src/client.cpp b/src/client.cpp index d8ae941f9..de0638025 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -135,14 +135,19 @@ Client::Client( } m_cache_save_interval = g_settings->getU16("server_map_save_interval"); +#ifdef DISABLE_CSM + m_modding_enabled = false; +#else m_modding_enabled = g_settings->getBool("enable_client_modding"); m_script = new ClientScripting(this); m_env.setScript(m_script); m_script->setEnv(&m_env); +#endif } void Client::initMods() { +#ifndef DISABLE_CSM m_script->loadMod(getBuiltinLuaPath() + DIR_DELIM "init.lua", BUILTIN_MOD_NAME); // If modding is not enabled, don't load mods, just builtin @@ -180,6 +185,7 @@ void Client::initMods() << script_path << "\"]" << std::endl; m_script->loadMod(script_path, mod.name); } +#endif } const std::string &Client::getBuiltinLuaPath() @@ -208,8 +214,10 @@ const ModSpec* Client::getModSpec(const std::string &modname) const void Client::Stop() { m_shutdown = true; +#ifndef DISABLE_CSM // Don't disable this part when modding is disabled, it's used in builtin m_script->on_shutdown(); +#endif //request all client managed threads to stop m_mesh_update_thread.stop(); // Save local server map @@ -1752,10 +1760,12 @@ void Client::afterContentReceived(IrrlichtDevice *device) m_state = LC_Ready; sendReady(); +#ifndef DISABLE_CSM if (g_settings->getBool("enable_client_modding")) { m_script->on_client_ready(m_env.getLocalPlayer()); m_script->on_connect(); } +#endif text = wgettext("Done!"); draw_load_screen(text, device, guienv, m_tsrc, 0, 100); diff --git a/src/game.cpp b/src/game.cpp index 8947acd6f..1b0e946e5 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -172,6 +172,18 @@ struct LocalFormspecHandler : public TextDest } } +#ifdef DISABLE_CSM + if (m_formname == "MT_DEATH_SCREEN") { + assert(m_client); + + if (fields.find("btn_respawn") != fields.end() || + fields.find("quit") != fields.end()) { + m_client->sendRespawn(); + return; + } + } +#endif + // Don't disable this part when modding is disabled, it's used in builtin m_client->getScript()->on_formspec_input(m_formname, fields); } @@ -1347,6 +1359,9 @@ protected: private: void showPauseMenu(); +#ifdef DISABLE_CSM + void showDeathScreen(); +#endif InputHandler *input; @@ -3216,8 +3231,13 @@ void Game::processClientEvents(CameraOrientation *cam) break; case CE_DEATHSCREEN: +#ifdef DISABLE_CSM + showDeathScreen(); + chat_backend->addMessage(L"", L"You died."); +#else // This should be enabled for death formspec in builtin client->getScript()->on_death(); +#endif /* Handle visualization */ runData.damage_flash = 0; @@ -4785,6 +4805,27 @@ void Game::showPauseMenu() current_formspec->doPause = true; } +#ifdef DISABLE_CSM +void Game::showDeathScreen() +{ + std::string formspec = + std::string(FORMSPEC_VERSION_STRING) + + SIZE_TAG + "bgcolor[#320000b4;true]" + "label[4.85,1.35;" + gettext("You died.") + "]" + "button_exit[4,3;3,0.5;btn_respawn;" + gettext("Respawn") + "]" + ; + + /* Create menu */ + /* Note: FormspecFormSource and LocalFormspecHandler + * are deleted by guiFormSpecMenu */ + FormspecFormSource *fs_src = new FormspecFormSource(formspec); + LocalFormspecHandler *txt_dst = new LocalFormspecHandler("MT_DEATH_SCREEN"); + + create_formspec_menu(¤t_formspec, client, device, &input->joystick, fs_src, txt_dst); +} +#endif + /****************************************************************************/ /**************************************************************************** extern function for launching the game diff --git a/src/script/scripting_client.cpp b/src/script/scripting_client.cpp index edfb12d5d..90d07b82b 100644 --- a/src/script/scripting_client.cpp +++ b/src/script/scripting_client.cpp @@ -32,6 +32,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "lua_api/l_localplayer.h" #include "lua_api/l_camera.h" +#ifndef DISABLE_CSM + ClientScripting::ClientScripting(Client *client): ScriptApiBase() { @@ -86,3 +88,5 @@ void ClientScripting::on_camera_ready(Camera *camera) { LuaCamera::create(getStack(), camera); } + +#endif