diff options
author | Paramat <paramat@users.noreply.github.com> | 2018-11-24 10:41:11 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-24 10:41:11 +0000 |
commit | 2e37ee956530b7cd310e0d6cfb8ce3cd8f6973e6 (patch) | |
tree | 4f607e1f226fa169c2bd98de531b62cba4de3260 /src/client.cpp | |
parent | a969635322576218312be3e32e5b4fcb0359ac05 (diff) | |
download | minetest-2e37ee956530b7cd310e0d6cfb8ce3cd8f6973e6.tar.gz minetest-2e37ee956530b7cd310e0d6cfb8ce3cd8f6973e6.tar.bz2 minetest-2e37ee956530b7cd310e0d6cfb8ce3cd8f6973e6.zip |
CSM: Don't create the client script environment if CSM is disabled (#7874)
Use the CSM death formspec when CSM is enabled and use the engine death formspec when CSM is disabled.
Move the CSM death formspec code to a dedicated file.
Diffstat (limited to 'src/client.cpp')
-rw-r--r-- | src/client.cpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/client.cpp b/src/client.cpp index 378efd5fe..17ee3a10a 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -110,36 +110,37 @@ Client::Client( m_cache_save_interval = g_settings->getU16("server_map_save_interval"); m_modding_enabled = g_settings->getBool("enable_client_modding"); - m_script = new ClientScripting(this); - m_env.setScript(m_script); - m_script->setEnv(&m_env); -} - -void Client::loadBuiltin() -{ - // Load builtin - scanModIntoMemory(BUILTIN_MOD_NAME, getBuiltinLuaPath()); - - m_script->loadModFromMemory(BUILTIN_MOD_NAME); + // Only create the client script environment if client modding is enabled + if (m_modding_enabled) { + m_script = new ClientScripting(this); + m_env.setScript(m_script); + m_script->setEnv(&m_env); + } } void Client::loadMods() { - // Don't permit to load mods twice + // Don't load mods twice if (m_mods_loaded) { return; } - // If modding is not enabled or CSM restrictions disable it - // don't load CSM mods, only builtin + // If client modding is not enabled, don't load client-provided CSM mods or + // builtin. if (!m_modding_enabled) { warningstream << "Client side mods are disabled by configuration." << std::endl; return; } + // Load builtin + scanModIntoMemory(BUILTIN_MOD_NAME, getBuiltinLuaPath()); + m_script->loadModFromMemory(BUILTIN_MOD_NAME); + + // If the server has disabled client-provided CSM mod loading, don't load + // client-provided CSM mods. Builtin is loaded so needs verfying. if (checkCSMRestrictionFlag(CSMRestrictionFlags::CSM_RF_LOAD_CLIENT_MODS)) { warningstream << "Client side mods are disabled by server." << std::endl; - // If mods loading is disabled and builtin integrity is wrong, disconnect user. + // If builtin integrity is wrong, disconnect user if (!checkBuiltinIntegrity()) { // @TODO disconnect user } @@ -227,8 +228,8 @@ const ModSpec* Client::getModSpec(const std::string &modname) const void Client::Stop() { m_shutdown = true; - // Don't disable this part when modding is disabled, it's used in builtin - m_script->on_shutdown(); + if (m_modding_enabled) + m_script->on_shutdown(); //request all client managed threads to stop m_mesh_update_thread.stop(); // Save local server map @@ -237,7 +238,8 @@ void Client::Stop() m_localdb->endSave(); } - delete m_script; + if (m_modding_enabled) + delete m_script; } bool Client::isShutdown() @@ -1491,10 +1493,9 @@ void Client::typeChatMessage(const std::wstring &message) if (message.empty()) return; - // If message was ate by script API, don't send it to server - if (m_script->on_sending_message(wide_to_utf8(message))) { + // If message was consumed by script API, don't send it to server + if (m_modding_enabled && m_script->on_sending_message(wide_to_utf8(message))) return; - } // Send to others sendChatMessage(message); |