1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

Change the preprocessor macro that differs server/client builds

This commit is contained in:
sfan5 2024-10-15 15:47:23 +02:00
parent e2ea359925
commit 37095f3e49
45 changed files with 137 additions and 88 deletions

View file

@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "porting.h"
#include "util/string.h"
#include "server.h"
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
#include "client/client.h"
#endif
@ -185,7 +185,7 @@ int ScriptApiBase::luaPanic(lua_State *L)
return 0;
}
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
void ScriptApiBase::clientOpenLibs(lua_State *L)
{
static const std::vector<std::pair<std::string, lua_CFunction>> m_libs = {
@ -305,7 +305,7 @@ void ScriptApiBase::loadScript(const std::string &script_path)
lua_pop(L, 1); // Pop error handler
}
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
void ScriptApiBase::loadModFromMemory(const std::string &mod_name)
{
ModNameStorer mod_name_storer(getStack(), mod_name);
@ -351,7 +351,7 @@ void ScriptApiBase::loadModFromMemory(const std::string &mod_name)
void ScriptApiBase::runCallbacksRaw(int nargs,
RunCallbacksMode mode, const char *fxn)
{
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
// Hard fail for bad guarded callbacks
// Only run callbacks when the scripting enviroment is loaded
FATAL_ERROR_IF(m_type == ScriptingType::Client &&
@ -565,7 +565,7 @@ Server* ScriptApiBase::getServer()
return dynamic_cast<Server *>(m_gamedef);
}
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
Client* ScriptApiBase::getClient()
{
return dynamic_cast<Client *>(m_gamedef);

View file

@ -66,7 +66,7 @@ enum class ScriptingType: u8 {
};
class Server;
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
class Client;
#endif
class EmergeThread;
@ -91,7 +91,7 @@ public:
void loadMod(const std::string &script_path, const std::string &mod_name);
void loadScript(const std::string &script_path);
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
void loadModFromMemory(const std::string &mod_name);
#endif
@ -106,7 +106,7 @@ public:
IGameDef *getGameDef() { return m_gamedef; }
Server* getServer();
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
Client* getClient();
#endif
@ -128,7 +128,7 @@ public:
// returns "" on error
static std::string getCurrentModName(lua_State *L);
#ifdef SERVER
#if !CHECK_CLIENT_BUILD()
inline void clientOpenLibs(lua_State *L) { assert(false); }
#else
void clientOpenLibs(lua_State *L);
@ -172,7 +172,7 @@ protected:
Environment* getEnv() { return m_environment; }
void setEnv(Environment* env) { m_environment = env; }
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
GUIEngine* getGuiEngine() { return m_guiengine; }
void setGuiEngine(GUIEngine* guiengine) { m_guiengine = guiengine; }
#endif
@ -199,7 +199,7 @@ private:
IGameDef *m_gamedef = nullptr;
Environment *m_environment = nullptr;
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
GUIEngine *m_guiengine = nullptr;
#endif
EmergeThread *m_emerge = nullptr;

View file

@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "filesys.h"
#include "porting.h"
#include "server.h"
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
#include "client/client.h"
#endif
#include "settings.h"
@ -423,7 +423,7 @@ void ScriptApiSecurity::setLuaEnv(lua_State *L, int thread)
bool ScriptApiSecurity::isSecure(lua_State *L)
{
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
auto script = ModApiBase::getScriptApiBase(L);
// CSM keeps no globals backup but is always secure
if (script->getType() == ScriptingType::Client)
@ -743,7 +743,7 @@ int ScriptApiSecurity::sl_g_load(lua_State *L)
int ScriptApiSecurity::sl_g_loadfile(lua_State *L)
{
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
ScriptApiBase *script = ModApiBase::getScriptApiBase(L);
// Client implementation