Disable CSM at compile-time (#78)

This commit is contained in:
sfan5 2017-07-09 22:37:40 +02:00 committed by Maksim Gamarnik
parent 97a8512c76
commit 1698a96d2a
5 changed files with 60 additions and 2 deletions

View File

@ -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

View File

@ -127,9 +127,11 @@ bool Camera::successfullyCreated(std::string &error_message)
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();
}

View File

@ -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);

View File

@ -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(&current_formspec, client, device, &input->joystick, fs_src, txt_dst);
}
#endif
/****************************************************************************/
/****************************************************************************
extern function for launching the game

View File

@ -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