1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-05 18:41:05 +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

@ -51,7 +51,7 @@ ServerInventoryManager *ModApiBase::getServerInventoryMgr(lua_State *L)
return getScriptApiBase(L)->getServer()->getInventoryMgr();
}
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
Client *ModApiBase::getClient(lua_State *L)
{
return getScriptApiBase(L)->getClient();
@ -68,7 +68,7 @@ Environment *ModApiBase::getEnv(lua_State *L)
return getScriptApiBase(L)->getEnv();
}
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
GUIEngine *ModApiBase::getGuiEngine(lua_State *L)
{
return getScriptApiBase(L)->getGuiEngine();

View file

@ -30,7 +30,7 @@ extern "C" {
#include <lauxlib.h>
}
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
class Client;
class GUIEngine;
#endif
@ -45,7 +45,7 @@ public:
static ScriptApiBase* getScriptApiBase(lua_State *L);
static Server* getServer(lua_State *L);
static ServerInventoryManager *getServerInventoryMgr(lua_State *L);
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
static Client* getClient(lua_State *L);
static GUIEngine* getGuiEngine(lua_State *L);
#endif // !SERVER

View file

@ -43,7 +43,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "server/player_sao.h"
#include "util/string.h"
#include "translation.h"
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
#include "client/client.h"
#endif
@ -71,7 +71,7 @@ int LuaRaycast::l_next(lua_State *L)
ServerEnvironment *senv = dynamic_cast<ServerEnvironment*>(env);
bool csm = false;
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
csm = getClient(L) != nullptr;
#endif
@ -847,7 +847,7 @@ int ModApiEnv::l_find_node_near(lua_State *L)
int start_radius = (lua_isboolean(L, 4) && readParam<bool>(L, 4)) ? 0 : 1;
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
// Client API limitations
if (Client *client = getClient(L))
radius = client->CSMClampRadius(pos, radius);
@ -959,7 +959,7 @@ int ModApiEnv::l_find_nodes_in_area(lua_State *L)
const NodeDefManager *ndef = env->getGameDef()->ndef();
Map &map = env->getMap();
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
if (Client *client = getClient(L)) {
minp = client->CSMClampPos(minp);
maxp = client->CSMClampPos(maxp);
@ -1021,7 +1021,7 @@ int ModApiEnv::l_find_nodes_in_area_under_air(lua_State *L)
const NodeDefManager *ndef = env->getGameDef()->ndef();
Map &map = env->getMap();
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
if (Client *client = getClient(L)) {
minp = client->CSMClampPos(minp);
maxp = client->CSMClampPos(maxp);

View file

@ -222,7 +222,7 @@ void ModApiHttp::Initialize(lua_State *L, int top)
#if USE_CURL
bool isMainmenu = false;
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
isMainmenu = ModApiBase::getGuiEngine(L) != nullptr;
#endif

View file

@ -47,7 +47,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
/* In debug mode ensure no code tries to retrieve the server env when it isn't
* actually available (in CSM) */
#if !defined(SERVER) && !defined(NDEBUG)
#if CHECK_CLIENT_BUILD() && !defined(NDEBUG)
#define DEBUG_ASSERT_NO_CLIENTAPI \
FATAL_ERROR_IF(getClient(L) != nullptr, "Tried " \
"to retrieve ServerEnvironment on client")

View file

@ -46,7 +46,7 @@ static inline int checkSettingSecurity(lua_State* L, const std::string &name)
throw LuaError("Attempted to set secure setting.");
bool is_mainmenu = false;
#ifndef SERVER
#if CHECK_CLIENT_BUILD()
is_mainmenu = ModApiBase::getGuiEngine(L) != nullptr;
#endif
if (!is_mainmenu && (name == "mg_name" || name == "mg_flags")) {