mirror of
https://github.com/minetest/minetest.git
synced 2024-11-20 14:43:45 +01:00
Change the preprocessor macro that differs server/client builds
This commit is contained in:
parent
e2ea359925
commit
37095f3e49
@ -602,6 +602,7 @@ if(BUILD_CLIENT)
|
|||||||
# on other platforms, only IrrlichtMt depends on SDL2
|
# on other platforms, only IrrlichtMt depends on SDL2
|
||||||
"$<$<PLATFORM_ID:Android>:${SDL2_LIBRARIES}>"
|
"$<$<PLATFORM_ID:Android>:${SDL2_LIBRARIES}>"
|
||||||
)
|
)
|
||||||
|
target_compile_definitions(${PROJECT_NAME} PRIVATE "MT_BUILDTARGET=1")
|
||||||
if(NOT USE_LUAJIT)
|
if(NOT USE_LUAJIT)
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||||
# This is necessary for dynamic Lua modules
|
# This is necessary for dynamic Lua modules
|
||||||
@ -679,8 +680,7 @@ if(BUILD_SERVER)
|
|||||||
${GMP_LIBRARY}
|
${GMP_LIBRARY}
|
||||||
${PLATFORM_LIBS}
|
${PLATFORM_LIBS}
|
||||||
)
|
)
|
||||||
set_target_properties(${PROJECT_NAME}server PROPERTIES
|
target_compile_definitions(${PROJECT_NAME}server PRIVATE "MT_BUILDTARGET=2")
|
||||||
COMPILE_DEFINITIONS "SERVER")
|
|
||||||
if(NOT USE_LUAJIT)
|
if(NOT USE_LUAJIT)
|
||||||
set_target_properties(${PROJECT_NAME}server PROPERTIES
|
set_target_properties(${PROJECT_NAME}server PROPERTIES
|
||||||
# This is necessary for dynamic Lua modules
|
# This is necessary for dynamic Lua modules
|
||||||
|
@ -49,7 +49,7 @@ static inline void freeAll(MBContainer &vec) { freeSome(vec, vec.size()); }
|
|||||||
static void workOnMetadata(const MBContainer &vec)
|
static void workOnMetadata(const MBContainer &vec)
|
||||||
{
|
{
|
||||||
for (MapBlock *block : vec) {
|
for (MapBlock *block : vec) {
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
bool foo = !!block->mesh;
|
bool foo = !!block->mesh;
|
||||||
#else
|
#else
|
||||||
bool foo = true;
|
bool foo = true;
|
||||||
|
@ -36,8 +36,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "script/common/c_types.h" // LuaError
|
#include "script/common/c_types.h" // LuaError
|
||||||
#include "util/numeric.h"
|
#include "util/numeric.h"
|
||||||
#include "util/string.h" // StringMap
|
#include "util/string.h" // StringMap
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef SERVER
|
#if !IS_CLIENT_BUILD
|
||||||
#error Do not include in server builds
|
#error Do not include in server builds
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -23,9 +23,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "util/numeric.h" // IntervalLimiter
|
#include "util/numeric.h" // IntervalLimiter
|
||||||
#include "activeobjectmgr.h" // client::ActiveObjectMgr
|
#include "activeobjectmgr.h" // client::ActiveObjectMgr
|
||||||
#include "irr_ptr.h"
|
#include "irr_ptr.h"
|
||||||
|
#include "config.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#ifdef SERVER
|
#if !IS_CLIENT_BUILD
|
||||||
#error Do not include in server builds
|
#error Do not include in server builds
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -20,9 +20,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "irrlichttypes.h"
|
#include "irrlichttypes.h"
|
||||||
|
#include "config.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#ifdef SERVER
|
#if !IS_CLIENT_BUILD
|
||||||
#error Do not include in server builds
|
#error Do not include in server builds
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -26,13 +26,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "client/inputhandler.h"
|
#include "client/inputhandler.h"
|
||||||
#include "irrlichttypes_extrabloated.h"
|
#include "irrlichttypes_extrabloated.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
#include "config.h"
|
||||||
#include "client/shader.h"
|
#include "client/shader.h"
|
||||||
#include "client/render/core.h"
|
#include "client/render/core.h"
|
||||||
// include the shadow mapper classes too
|
// include the shadow mapper classes too
|
||||||
#include "client/shadows/dynamicshadowsrender.h"
|
#include "client/shadows/dynamicshadowsrender.h"
|
||||||
#include <IVideoDriver.h>
|
#include <IVideoDriver.h>
|
||||||
|
|
||||||
#ifdef SERVER
|
#if !IS_CLIENT_BUILD
|
||||||
#error Do not include in server builds
|
#error Do not include in server builds
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -20,13 +20,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "irr_v3d.h"
|
#include "irr_v3d.h"
|
||||||
|
#include "config.h"
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifdef SERVER
|
#if !IS_CLIENT_BUILD
|
||||||
#error Do not include in server builds
|
#error Do not include in server builds
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -17,10 +17,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SERVER
|
|
||||||
|
|
||||||
#include "clientdynamicinfo.h"
|
#include "clientdynamicinfo.h"
|
||||||
|
|
||||||
|
#if CHECK_CLIENT_BUILD()
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "client/renderingengine.h"
|
#include "client/renderingengine.h"
|
||||||
#include "gui/guiFormSpecMenu.h"
|
#include "gui/guiFormSpecMenu.h"
|
||||||
|
@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "irrlichttypes_bloated.h"
|
#include "irrlichttypes_bloated.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
struct ClientDynamicInfo
|
struct ClientDynamicInfo
|
||||||
@ -38,7 +39,7 @@ public:
|
|||||||
touch_controls == other.touch_controls;
|
touch_controls == other.touch_controls;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
static ClientDynamicInfo getCurrent();
|
static ClientDynamicInfo getCurrent();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "nodedef.h"
|
#include "nodedef.h"
|
||||||
#include "gamedef.h"
|
#include "gamedef.h"
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
#include "client/clientenvironment.h"
|
#include "client/clientenvironment.h"
|
||||||
#include "client/localplayer.h"
|
#include "client/localplayer.h"
|
||||||
#endif
|
#endif
|
||||||
@ -285,7 +285,7 @@ static void add_object_boxes(Environment *env,
|
|||||||
const f32 distance = speed_f.getLength() * dtime +
|
const f32 distance = speed_f.getLength() * dtime +
|
||||||
box_0.getExtent().getLength() + 1.5f * BS;
|
box_0.getExtent().getLength() + 1.5f * BS;
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
ClientEnvironment *c_env = dynamic_cast<ClientEnvironment*>(env);
|
ClientEnvironment *c_env = dynamic_cast<ClientEnvironment*>(env);
|
||||||
if (c_env) {
|
if (c_env) {
|
||||||
std::vector<DistanceSortedActiveObject> clientobjects;
|
std::vector<DistanceSortedActiveObject> clientobjects;
|
||||||
|
42
src/config.h
42
src/config.h
@ -5,3 +5,45 @@
|
|||||||
#else
|
#else
|
||||||
#warning Missing configuration
|
#warning Missing configuration
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* There are three ways a Minetest source file can be built:
|
||||||
|
* 1) we are currently building it for exclusively linking into the client
|
||||||
|
* 2) we are currently building it for exclusively linking into the server
|
||||||
|
* 3) we are building it only once for linking into both the client and server
|
||||||
|
* In case of 1 and 2 that means a single source file may be built twice if
|
||||||
|
* both a client and server build was requested.
|
||||||
|
*
|
||||||
|
* These options map to the following macros:
|
||||||
|
* 1) IS_CLIENT_BUILD = 1 and CHECK_CLIENT_BUILD() = 1
|
||||||
|
* 2) IS_CLIENT_BUILD = 0 and CHECK_CLIENT_BUILD() = 0
|
||||||
|
* 3) IS_CLIENT_BUILD = 0 and CHECK_CLIENT_BUILD() undefined
|
||||||
|
* As a function style macro CHECK_CLIENT_BUILD() has the special property that it
|
||||||
|
* cause a compile error if it used but not defined.
|
||||||
|
*
|
||||||
|
* v v v v v v v v v READ THIS PART v v v v v v v v v
|
||||||
|
* So that object files can be safely shared, these macros need to be used like so:
|
||||||
|
* - use IS_CLIENT_BUILD to exclude optional helpers in header files or similar
|
||||||
|
* - use CHECK_CLIENT_BUILD() in all source files, or in headers where it
|
||||||
|
* influences program behavior or e.g. class structure
|
||||||
|
* In practice this means any shared object files (case 3) cannot include any
|
||||||
|
* code that references CHECK_CLIENT_BUILD(), because a compiler error will occur.
|
||||||
|
* ^ ^ ^ ^ ^ ^ ^ ^ ^ READ THIS PART ^ ^ ^ ^ ^ ^ ^ ^ ^
|
||||||
|
*
|
||||||
|
* The background is that for any files built only once, we need to ensure that
|
||||||
|
* they are perfectly ABI-compatible between client/server or it will not work.
|
||||||
|
* This manifests either as a linker error (good case) or insidious memory corruption
|
||||||
|
* that causes obscure runtime behavior (bad case).
|
||||||
|
* Finally, note that the best option is to split code in such a way that usage
|
||||||
|
* of these macros is not necessary.
|
||||||
|
*/
|
||||||
|
#if MT_BUILDTARGET == 1
|
||||||
|
#define IS_CLIENT_BUILD 1
|
||||||
|
#define CHECK_CLIENT_BUILD() 1
|
||||||
|
#elif MT_BUILDTARGET == 2
|
||||||
|
#define IS_CLIENT_BUILD 0
|
||||||
|
#define CHECK_CLIENT_BUILD() 0
|
||||||
|
#else
|
||||||
|
#define IS_CLIENT_BUILD 0
|
||||||
|
#endif
|
||||||
|
#undef MT_BUILDTARGET
|
||||||
|
@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "map_settings_manager.h"
|
#include "map_settings_manager.h"
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
#include "client/texturepaths.h"
|
#include "client/texturepaths.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ SubgameSpec findSubgame(const std::string &id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string menuicon_path;
|
std::string menuicon_path;
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
menuicon_path = getImagePath(
|
menuicon_path = getImagePath(
|
||||||
game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png");
|
game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png");
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "porting.h"
|
#include "porting.h"
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
#include "irr_ptr.h"
|
#include "irr_ptr.h"
|
||||||
#include <IFileArchive.h>
|
#include <IFileArchive.h>
|
||||||
#include <IFileSystem.h>
|
#include <IFileSystem.h>
|
||||||
@ -945,7 +945,7 @@ bool safeWriteToFile(const std::string &path, std::string_view content)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
bool extractZipFile(io::IFileSystem *fs, const char *filename, const std::string &destination)
|
bool extractZipFile(io::IFileSystem *fs, const char *filename, const std::string &destination)
|
||||||
{
|
{
|
||||||
// Be careful here not to touch the global file hierarchy in Irrlicht
|
// Be careful here not to touch the global file hierarchy in Irrlicht
|
||||||
|
@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
@ -154,7 +155,7 @@ const char *GetFilenameFromPath(const char *path);
|
|||||||
// logs and returns false on error
|
// logs and returns false on error
|
||||||
bool safeWriteToFile(const std::string &path, std::string_view content);
|
bool safeWriteToFile(const std::string &path, std::string_view content);
|
||||||
|
|
||||||
#ifndef SERVER
|
#if IS_CLIENT_BUILD
|
||||||
bool extractZipFile(irr::io::IFileSystem *fs, const char *filename, const std::string &destination);
|
bool extractZipFile(irr::io::IFileSystem *fs, const char *filename, const std::string &destination);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ void init_gettext(const char *path, const std::string &configured_language,
|
|||||||
setenv("LANGUAGE", configured_language.c_str(), 1);
|
setenv("LANGUAGE", configured_language.c_str(), 1);
|
||||||
SetEnvironmentVariableA("LANGUAGE", configured_language.c_str());
|
SetEnvironmentVariableA("LANGUAGE", configured_language.c_str());
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
// Hack to force gettext to see the right environment
|
// Hack to force gettext to see the right environment
|
||||||
if (current_language != configured_language)
|
if (current_language != configured_language)
|
||||||
MSVC_LocaleWorkaround(argc, argv);
|
MSVC_LocaleWorkaround(argc, argv);
|
||||||
|
@ -20,8 +20,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "irrlichttypes_bloated.h"
|
#include "irrlichttypes_bloated.h"
|
||||||
|
#include "config.h" // IS_CLIENT_BUILD
|
||||||
|
|
||||||
#ifndef SERVER
|
#if IS_CLIENT_BUILD
|
||||||
#include <IMesh.h>
|
#include <IMesh.h>
|
||||||
#include <IImage.h>
|
#include <IImage.h>
|
||||||
#include <IMeshSceneNode.h>
|
#include <IMeshSceneNode.h>
|
||||||
|
@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "nodedef.h"
|
#include "nodedef.h"
|
||||||
#include "tool.h"
|
#include "tool.h"
|
||||||
#include "inventory.h"
|
#include "inventory.h"
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
#include "client/mapblock_mesh.h"
|
#include "client/mapblock_mesh.h"
|
||||||
#include "client/mesh.h"
|
#include "client/mesh.h"
|
||||||
#include "client/wieldmesh.h"
|
#include "client/wieldmesh.h"
|
||||||
@ -374,7 +374,7 @@ void ItemDefinition::deSerialize(std::istream &is, u16 protocol_version)
|
|||||||
|
|
||||||
class CItemDefManager: public IWritableItemDefManager
|
class CItemDefManager: public IWritableItemDefManager
|
||||||
{
|
{
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
struct ClientCached
|
struct ClientCached
|
||||||
{
|
{
|
||||||
video::ITexture *inventory_texture;
|
video::ITexture *inventory_texture;
|
||||||
@ -399,7 +399,7 @@ public:
|
|||||||
CItemDefManager()
|
CItemDefManager()
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
m_main_thread = std::this_thread::get_id();
|
m_main_thread = std::this_thread::get_id();
|
||||||
#endif
|
#endif
|
||||||
clear();
|
clear();
|
||||||
@ -448,7 +448,7 @@ public:
|
|||||||
// Get the definition
|
// Get the definition
|
||||||
return m_item_definitions.find(name) != m_item_definitions.cend();
|
return m_item_definitions.find(name) != m_item_definitions.cend();
|
||||||
}
|
}
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
public:
|
public:
|
||||||
ClientCached* createClientCachedDirect(const ItemStack &item, Client *client) const
|
ClientCached* createClientCachedDirect(const ItemStack &item, Client *client) const
|
||||||
{
|
{
|
||||||
@ -678,7 +678,7 @@ private:
|
|||||||
std::map<std::string, ItemDefinition*> m_item_definitions;
|
std::map<std::string, ItemDefinition*> m_item_definitions;
|
||||||
// Aliases
|
// Aliases
|
||||||
StringMap m_aliases;
|
StringMap m_aliases;
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
// The id of the thread that is allowed to use irrlicht directly
|
// The id of the thread that is allowed to use irrlicht directly
|
||||||
std::thread::id m_main_thread;
|
std::thread::id m_main_thread;
|
||||||
// Cached textures and meshes
|
// Cached textures and meshes
|
||||||
|
@ -35,7 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
class IGameDef;
|
class IGameDef;
|
||||||
class Client;
|
class Client;
|
||||||
struct ToolCapabilities;
|
struct ToolCapabilities;
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
#include "client/texturesource.h"
|
#include "client/texturesource.h"
|
||||||
struct ItemMesh;
|
struct ItemMesh;
|
||||||
struct ItemStack;
|
struct ItemStack;
|
||||||
@ -155,7 +155,7 @@ public:
|
|||||||
virtual void getAll(std::set<std::string> &result) const=0;
|
virtual void getAll(std::set<std::string> &result) const=0;
|
||||||
// Check if item is known
|
// Check if item is known
|
||||||
virtual bool isKnown(const std::string &name) const=0;
|
virtual bool isKnown(const std::string &name) const=0;
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
// Get item inventory texture
|
// Get item inventory texture
|
||||||
virtual video::ITexture* getInventoryTexture(const ItemStack &item, Client *client) const=0;
|
virtual video::ITexture* getInventoryTexture(const ItemStack &item, Client *client) const=0;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "util/numeric.h"
|
#include "util/numeric.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
|
|
||||||
static u8 light_LUT[LIGHT_SUN + 1];
|
static u8 light_LUT[LIGHT_SUN + 1];
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include "config.h"
|
||||||
#include "irrlichttypes.h"
|
#include "irrlichttypes.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -35,7 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
// This brightness is reserved for sunlight
|
// This brightness is reserved for sunlight
|
||||||
#define LIGHT_SUN 15
|
#define LIGHT_SUN 15
|
||||||
|
|
||||||
#ifndef SERVER
|
#if IS_CLIENT_BUILD
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \internal
|
* \internal
|
||||||
@ -67,7 +68,7 @@ float decode_light_f(float light_f);
|
|||||||
|
|
||||||
void set_light_table(float gamma);
|
void set_light_table(float gamma);
|
||||||
|
|
||||||
#endif // ifndef SERVER
|
#endif
|
||||||
|
|
||||||
// 0 <= daylight_factor <= 1000
|
// 0 <= daylight_factor <= 1000
|
||||||
// 0 <= lightday, lightnight <= LIGHT_SUN
|
// 0 <= lightday, lightnight <= LIGHT_SUN
|
||||||
|
@ -44,7 +44,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#if USE_CURSES
|
#if USE_CURSES
|
||||||
#include "terminal_chat_console.h"
|
#include "terminal_chat_console.h"
|
||||||
#endif
|
#endif
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
#include "gui/guiMainMenu.h"
|
#include "gui/guiMainMenu.h"
|
||||||
#include "client/clientlauncher.h"
|
#include "client/clientlauncher.h"
|
||||||
#include "gui/guiEngine.h"
|
#include "gui/guiEngine.h"
|
||||||
@ -243,7 +243,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
GameStartData game_params;
|
GameStartData game_params;
|
||||||
#ifdef SERVER
|
#if !CHECK_CLIENT_BUILD()
|
||||||
porting::attachOrCreateConsole();
|
porting::attachOrCreateConsole();
|
||||||
game_params.is_dedicated_server = true;
|
game_params.is_dedicated_server = true;
|
||||||
#else
|
#else
|
||||||
@ -261,7 +261,7 @@ int main(int argc, char *argv[])
|
|||||||
if (game_params.is_dedicated_server)
|
if (game_params.is_dedicated_server)
|
||||||
return run_dedicated_server(game_params, cmd_args) ? 0 : 1;
|
return run_dedicated_server(game_params, cmd_args) ? 0 : 1;
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
retval = ClientLauncher().run(game_params, cmd_args) ? 0 : 1;
|
retval = ClientLauncher().run(game_params, cmd_args) ? 0 : 1;
|
||||||
#else
|
#else
|
||||||
retval = 0;
|
retval = 0;
|
||||||
@ -377,7 +377,7 @@ static void set_allowed_options(OptionList *allowed_options)
|
|||||||
_("Feature an interactive terminal (Only works when using minetestserver or with --server)"))));
|
_("Feature an interactive terminal (Only works when using minetestserver or with --server)"))));
|
||||||
allowed_options->insert(std::make_pair("recompress", ValueSpec(VALUETYPE_FLAG,
|
allowed_options->insert(std::make_pair("recompress", ValueSpec(VALUETYPE_FLAG,
|
||||||
_("Recompress the blocks of the given map database."))));
|
_("Recompress the blocks of the given map database."))));
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
allowed_options->insert(std::make_pair("address", ValueSpec(VALUETYPE_STRING,
|
allowed_options->insert(std::make_pair("address", ValueSpec(VALUETYPE_STRING,
|
||||||
_("Address to connect to. ('' = local game)"))));
|
_("Address to connect to. ('' = local game)"))));
|
||||||
allowed_options->insert(std::make_pair("random-input", ValueSpec(VALUETYPE_FLAG,
|
allowed_options->insert(std::make_pair("random-input", ValueSpec(VALUETYPE_FLAG,
|
||||||
|
@ -31,7 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "content_mapnode.h" // For legacy name-id mapping
|
#include "content_mapnode.h" // For legacy name-id mapping
|
||||||
#include "content_nodemeta.h" // For legacy deserialization
|
#include "content_nodemeta.h" // For legacy deserialization
|
||||||
#include "serialization.h"
|
#include "serialization.h"
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
#include "client/mapblock_mesh.h"
|
#include "client/mapblock_mesh.h"
|
||||||
#endif
|
#endif
|
||||||
#include "porting.h"
|
#include "porting.h"
|
||||||
@ -77,7 +77,7 @@ MapBlock::MapBlock(v3s16 pos, IGameDef *gamedef):
|
|||||||
|
|
||||||
MapBlock::~MapBlock()
|
MapBlock::~MapBlock()
|
||||||
{
|
{
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
{
|
{
|
||||||
delete mesh;
|
delete mesh;
|
||||||
mesh = nullptr;
|
mesh = nullptr;
|
||||||
|
@ -460,7 +460,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#ifndef SERVER // Only on client
|
#if CHECK_CLIENT_BUILD() // Only on client
|
||||||
MapBlockMesh *mesh = nullptr;
|
MapBlockMesh *mesh = nullptr;
|
||||||
|
|
||||||
// marks the sides which are opaque: 00+Z-Z+Y-Y+X-X
|
// marks the sides which are opaque: 00+Z-Z+Y-Y+X-X
|
||||||
|
@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "nodedef.h"
|
#include "nodedef.h"
|
||||||
|
|
||||||
#include "itemdef.h"
|
#include "itemdef.h"
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
#include "client/mesh.h"
|
#include "client/mesh.h"
|
||||||
#include "client/shader.h"
|
#include "client/shader.h"
|
||||||
#include "client/client.h"
|
#include "client/client.h"
|
||||||
@ -332,7 +332,7 @@ ContentFeatures::ContentFeatures()
|
|||||||
|
|
||||||
ContentFeatures::~ContentFeatures()
|
ContentFeatures::~ContentFeatures()
|
||||||
{
|
{
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
for (u16 j = 0; j < 6; j++) {
|
for (u16 j = 0; j < 6; j++) {
|
||||||
delete tiles[j].layers[0].frames;
|
delete tiles[j].layers[0].frames;
|
||||||
delete tiles[j].layers[1].frames;
|
delete tiles[j].layers[1].frames;
|
||||||
@ -347,7 +347,7 @@ void ContentFeatures::reset()
|
|||||||
/*
|
/*
|
||||||
Cached stuff
|
Cached stuff
|
||||||
*/
|
*/
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
solidness = 2;
|
solidness = 2;
|
||||||
visual_solidness = 0;
|
visual_solidness = 0;
|
||||||
backface_culling = true;
|
backface_culling = true;
|
||||||
@ -370,7 +370,7 @@ void ContentFeatures::reset()
|
|||||||
groups["dig_immediate"] = 2;
|
groups["dig_immediate"] = 2;
|
||||||
drawtype = NDT_NORMAL;
|
drawtype = NDT_NORMAL;
|
||||||
mesh.clear();
|
mesh.clear();
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
for (auto &i : mesh_ptr)
|
for (auto &i : mesh_ptr)
|
||||||
i = NULL;
|
i = NULL;
|
||||||
minimap_color = video::SColor(0, 0, 0, 0);
|
minimap_color = video::SColor(0, 0, 0, 0);
|
||||||
@ -686,7 +686,7 @@ void ContentFeatures::deSerialize(std::istream &is, u16 protocol_version)
|
|||||||
} catch (SerializationError &e) {};
|
} catch (SerializationError &e) {};
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
static void fillTileAttribs(ITextureSource *tsrc, TileLayer *layer,
|
static void fillTileAttribs(ITextureSource *tsrc, TileLayer *layer,
|
||||||
const TileSpec &tile, const TileDef &tiledef, video::SColor color,
|
const TileSpec &tile, const TileDef &tiledef, video::SColor color,
|
||||||
u8 material_type, u32 shader_id, bool backface_culling,
|
u8 material_type, u32 shader_id, bool backface_culling,
|
||||||
@ -1026,7 +1026,7 @@ NodeDefManager::NodeDefManager()
|
|||||||
|
|
||||||
NodeDefManager::~NodeDefManager()
|
NodeDefManager::~NodeDefManager()
|
||||||
{
|
{
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
for (ContentFeatures &f : m_content_features) {
|
for (ContentFeatures &f : m_content_features) {
|
||||||
for (auto &j : f.mesh_ptr) {
|
for (auto &j : f.mesh_ptr) {
|
||||||
if (j)
|
if (j)
|
||||||
@ -1479,7 +1479,7 @@ void NodeDefManager::applyTextureOverrides(const std::vector<TextureOverride> &o
|
|||||||
|
|
||||||
void NodeDefManager::updateTextures(IGameDef *gamedef, void *progress_callback_args)
|
void NodeDefManager::updateTextures(IGameDef *gamedef, void *progress_callback_args)
|
||||||
{
|
{
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
infostream << "NodeDefManager::updateTextures(): Updating "
|
infostream << "NodeDefManager::updateTextures(): Updating "
|
||||||
"textures in node definitions" << std::endl;
|
"textures in node definitions" << std::endl;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include "mapnode.h"
|
#include "mapnode.h"
|
||||||
#include "nameidmapping.h"
|
#include "nameidmapping.h"
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
#include "client/tile.h"
|
#include "client/tile.h"
|
||||||
#include <IMeshManipulator.h>
|
#include <IMeshManipulator.h>
|
||||||
class Client;
|
class Client;
|
||||||
@ -315,7 +315,7 @@ struct ContentFeatures
|
|||||||
/*
|
/*
|
||||||
Cached stuff
|
Cached stuff
|
||||||
*/
|
*/
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
// 0 1 2 3 4 5
|
// 0 1 2 3 4 5
|
||||||
// up down right left back front
|
// up down right left back front
|
||||||
TileSpec tiles[6];
|
TileSpec tiles[6];
|
||||||
@ -351,7 +351,7 @@ struct ContentFeatures
|
|||||||
|
|
||||||
enum NodeDrawType drawtype;
|
enum NodeDrawType drawtype;
|
||||||
std::string mesh;
|
std::string mesh;
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
scene::IMesh *mesh_ptr[24];
|
scene::IMesh *mesh_ptr[24];
|
||||||
video::SColor minimap_color;
|
video::SColor minimap_color;
|
||||||
#endif
|
#endif
|
||||||
@ -530,7 +530,7 @@ struct ContentFeatures
|
|||||||
return itemgroup_get(groups, group);
|
return itemgroup_get(groups, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
void updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc,
|
void updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc,
|
||||||
scene::IMeshManipulator *meshmanip, Client *client, const TextureSettings &tsettings);
|
scene::IMeshManipulator *meshmanip, Client *client, const TextureSettings &tsettings);
|
||||||
#endif
|
#endif
|
||||||
|
@ -209,7 +209,7 @@ void PlayerControl::setMovementFromKeys()
|
|||||||
movement_direction = std::atan2(x, y);
|
movement_direction = std::atan2(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
|
|
||||||
u32 PlayerControl::getKeysPressed() const
|
u32 PlayerControl::getKeysPressed() const
|
||||||
{
|
{
|
||||||
|
@ -91,7 +91,7 @@ struct PlayerControl
|
|||||||
// joystick input.
|
// joystick input.
|
||||||
void setMovementFromKeys();
|
void setMovementFromKeys();
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
// For client use
|
// For client use
|
||||||
u32 getKeysPressed() const;
|
u32 getKeysPressed() const;
|
||||||
inline bool isMoving() const { return movement_speed > 0.001f; }
|
inline bool isMoving() const { return movement_speed > 0.001f; }
|
||||||
|
@ -80,7 +80,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
#if !defined(SERVER) && defined(_WIN32)
|
#if CHECK_CLIENT_BUILD() && defined(_WIN32)
|
||||||
// On Windows export some driver-specific variables to encourage Minetest to be
|
// On Windows export some driver-specific variables to encourage Minetest to be
|
||||||
// executed on the discrete GPU in case of systems with two. Portability is fun.
|
// executed on the discrete GPU in case of systems with two. Portability is fun.
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -249,7 +249,6 @@ int getInputDialogSelection()
|
|||||||
return jnienv->CallIntMethod(activity, dialogvalue);
|
return jnienv->CallIntMethod(activity, dialogvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SERVER
|
|
||||||
float getDisplayDensity()
|
float getDisplayDensity()
|
||||||
{
|
{
|
||||||
static bool firstrun = true;
|
static bool firstrun = true;
|
||||||
@ -325,5 +324,4 @@ bool hasPhysicalKeyboardAndroid()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ndef SERVER
|
|
||||||
}
|
}
|
||||||
|
@ -97,9 +97,7 @@ int getInputDialogSelection();
|
|||||||
|
|
||||||
bool hasPhysicalKeyboardAndroid();
|
bool hasPhysicalKeyboardAndroid();
|
||||||
|
|
||||||
#ifndef SERVER
|
|
||||||
float getDisplayDensity();
|
float getDisplayDensity();
|
||||||
v2u32 getDisplaySize();
|
v2u32 getDisplaySize();
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -998,7 +998,7 @@ void push_content_features(lua_State *L, const ContentFeatures &c)
|
|||||||
lua_pushstring(L, c.mesh.c_str());
|
lua_pushstring(L, c.mesh.c_str());
|
||||||
lua_setfield(L, -2, "mesh");
|
lua_setfield(L, -2, "mesh");
|
||||||
}
|
}
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
push_ARGB8(L, c.minimap_color); // I know this is not set-able w/ register_node,
|
push_ARGB8(L, c.minimap_color); // I know this is not set-able w/ register_node,
|
||||||
lua_setfield(L, -2, "minimap_color"); // but the people need to know!
|
lua_setfield(L, -2, "minimap_color"); // but the people need to know!
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "porting.h"
|
#include "porting.h"
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
#include "client/client.h"
|
#include "client/client.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ int ScriptApiBase::luaPanic(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
void ScriptApiBase::clientOpenLibs(lua_State *L)
|
void ScriptApiBase::clientOpenLibs(lua_State *L)
|
||||||
{
|
{
|
||||||
static const std::vector<std::pair<std::string, lua_CFunction>> m_libs = {
|
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
|
lua_pop(L, 1); // Pop error handler
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
void ScriptApiBase::loadModFromMemory(const std::string &mod_name)
|
void ScriptApiBase::loadModFromMemory(const std::string &mod_name)
|
||||||
{
|
{
|
||||||
ModNameStorer mod_name_storer(getStack(), 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,
|
void ScriptApiBase::runCallbacksRaw(int nargs,
|
||||||
RunCallbacksMode mode, const char *fxn)
|
RunCallbacksMode mode, const char *fxn)
|
||||||
{
|
{
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
// Hard fail for bad guarded callbacks
|
// Hard fail for bad guarded callbacks
|
||||||
// Only run callbacks when the scripting enviroment is loaded
|
// Only run callbacks when the scripting enviroment is loaded
|
||||||
FATAL_ERROR_IF(m_type == ScriptingType::Client &&
|
FATAL_ERROR_IF(m_type == ScriptingType::Client &&
|
||||||
@ -565,7 +565,7 @@ Server* ScriptApiBase::getServer()
|
|||||||
return dynamic_cast<Server *>(m_gamedef);
|
return dynamic_cast<Server *>(m_gamedef);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
Client* ScriptApiBase::getClient()
|
Client* ScriptApiBase::getClient()
|
||||||
{
|
{
|
||||||
return dynamic_cast<Client *>(m_gamedef);
|
return dynamic_cast<Client *>(m_gamedef);
|
||||||
|
@ -66,7 +66,7 @@ enum class ScriptingType: u8 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class Server;
|
class Server;
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
class Client;
|
class Client;
|
||||||
#endif
|
#endif
|
||||||
class EmergeThread;
|
class EmergeThread;
|
||||||
@ -91,7 +91,7 @@ public:
|
|||||||
void loadMod(const std::string &script_path, const std::string &mod_name);
|
void loadMod(const std::string &script_path, const std::string &mod_name);
|
||||||
void loadScript(const std::string &script_path);
|
void loadScript(const std::string &script_path);
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
void loadModFromMemory(const std::string &mod_name);
|
void loadModFromMemory(const std::string &mod_name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ public:
|
|||||||
|
|
||||||
IGameDef *getGameDef() { return m_gamedef; }
|
IGameDef *getGameDef() { return m_gamedef; }
|
||||||
Server* getServer();
|
Server* getServer();
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
Client* getClient();
|
Client* getClient();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ public:
|
|||||||
// returns "" on error
|
// returns "" on error
|
||||||
static std::string getCurrentModName(lua_State *L);
|
static std::string getCurrentModName(lua_State *L);
|
||||||
|
|
||||||
#ifdef SERVER
|
#if !CHECK_CLIENT_BUILD()
|
||||||
inline void clientOpenLibs(lua_State *L) { assert(false); }
|
inline void clientOpenLibs(lua_State *L) { assert(false); }
|
||||||
#else
|
#else
|
||||||
void clientOpenLibs(lua_State *L);
|
void clientOpenLibs(lua_State *L);
|
||||||
@ -172,7 +172,7 @@ protected:
|
|||||||
Environment* getEnv() { return m_environment; }
|
Environment* getEnv() { return m_environment; }
|
||||||
void setEnv(Environment* env) { m_environment = env; }
|
void setEnv(Environment* env) { m_environment = env; }
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
GUIEngine* getGuiEngine() { return m_guiengine; }
|
GUIEngine* getGuiEngine() { return m_guiengine; }
|
||||||
void setGuiEngine(GUIEngine* guiengine) { m_guiengine = guiengine; }
|
void setGuiEngine(GUIEngine* guiengine) { m_guiengine = guiengine; }
|
||||||
#endif
|
#endif
|
||||||
@ -199,7 +199,7 @@ private:
|
|||||||
|
|
||||||
IGameDef *m_gamedef = nullptr;
|
IGameDef *m_gamedef = nullptr;
|
||||||
Environment *m_environment = nullptr;
|
Environment *m_environment = nullptr;
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
GUIEngine *m_guiengine = nullptr;
|
GUIEngine *m_guiengine = nullptr;
|
||||||
#endif
|
#endif
|
||||||
EmergeThread *m_emerge = nullptr;
|
EmergeThread *m_emerge = nullptr;
|
||||||
|
@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "filesys.h"
|
#include "filesys.h"
|
||||||
#include "porting.h"
|
#include "porting.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
#include "client/client.h"
|
#include "client/client.h"
|
||||||
#endif
|
#endif
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
@ -423,7 +423,7 @@ void ScriptApiSecurity::setLuaEnv(lua_State *L, int thread)
|
|||||||
|
|
||||||
bool ScriptApiSecurity::isSecure(lua_State *L)
|
bool ScriptApiSecurity::isSecure(lua_State *L)
|
||||||
{
|
{
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
auto script = ModApiBase::getScriptApiBase(L);
|
auto script = ModApiBase::getScriptApiBase(L);
|
||||||
// CSM keeps no globals backup but is always secure
|
// CSM keeps no globals backup but is always secure
|
||||||
if (script->getType() == ScriptingType::Client)
|
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)
|
int ScriptApiSecurity::sl_g_loadfile(lua_State *L)
|
||||||
{
|
{
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
ScriptApiBase *script = ModApiBase::getScriptApiBase(L);
|
ScriptApiBase *script = ModApiBase::getScriptApiBase(L);
|
||||||
|
|
||||||
// Client implementation
|
// Client implementation
|
||||||
|
@ -51,7 +51,7 @@ ServerInventoryManager *ModApiBase::getServerInventoryMgr(lua_State *L)
|
|||||||
return getScriptApiBase(L)->getServer()->getInventoryMgr();
|
return getScriptApiBase(L)->getServer()->getInventoryMgr();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
Client *ModApiBase::getClient(lua_State *L)
|
Client *ModApiBase::getClient(lua_State *L)
|
||||||
{
|
{
|
||||||
return getScriptApiBase(L)->getClient();
|
return getScriptApiBase(L)->getClient();
|
||||||
@ -68,7 +68,7 @@ Environment *ModApiBase::getEnv(lua_State *L)
|
|||||||
return getScriptApiBase(L)->getEnv();
|
return getScriptApiBase(L)->getEnv();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
GUIEngine *ModApiBase::getGuiEngine(lua_State *L)
|
GUIEngine *ModApiBase::getGuiEngine(lua_State *L)
|
||||||
{
|
{
|
||||||
return getScriptApiBase(L)->getGuiEngine();
|
return getScriptApiBase(L)->getGuiEngine();
|
||||||
|
@ -30,7 +30,7 @@ extern "C" {
|
|||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
class Client;
|
class Client;
|
||||||
class GUIEngine;
|
class GUIEngine;
|
||||||
#endif
|
#endif
|
||||||
@ -45,7 +45,7 @@ public:
|
|||||||
static ScriptApiBase* getScriptApiBase(lua_State *L);
|
static ScriptApiBase* getScriptApiBase(lua_State *L);
|
||||||
static Server* getServer(lua_State *L);
|
static Server* getServer(lua_State *L);
|
||||||
static ServerInventoryManager *getServerInventoryMgr(lua_State *L);
|
static ServerInventoryManager *getServerInventoryMgr(lua_State *L);
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
static Client* getClient(lua_State *L);
|
static Client* getClient(lua_State *L);
|
||||||
static GUIEngine* getGuiEngine(lua_State *L);
|
static GUIEngine* getGuiEngine(lua_State *L);
|
||||||
#endif // !SERVER
|
#endif // !SERVER
|
||||||
|
@ -43,7 +43,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "server/player_sao.h"
|
#include "server/player_sao.h"
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
#include "translation.h"
|
#include "translation.h"
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
#include "client/client.h"
|
#include "client/client.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ int LuaRaycast::l_next(lua_State *L)
|
|||||||
ServerEnvironment *senv = dynamic_cast<ServerEnvironment*>(env);
|
ServerEnvironment *senv = dynamic_cast<ServerEnvironment*>(env);
|
||||||
|
|
||||||
bool csm = false;
|
bool csm = false;
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
csm = getClient(L) != nullptr;
|
csm = getClient(L) != nullptr;
|
||||||
#endif
|
#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;
|
int start_radius = (lua_isboolean(L, 4) && readParam<bool>(L, 4)) ? 0 : 1;
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
// Client API limitations
|
// Client API limitations
|
||||||
if (Client *client = getClient(L))
|
if (Client *client = getClient(L))
|
||||||
radius = client->CSMClampRadius(pos, radius);
|
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();
|
const NodeDefManager *ndef = env->getGameDef()->ndef();
|
||||||
Map &map = env->getMap();
|
Map &map = env->getMap();
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
if (Client *client = getClient(L)) {
|
if (Client *client = getClient(L)) {
|
||||||
minp = client->CSMClampPos(minp);
|
minp = client->CSMClampPos(minp);
|
||||||
maxp = client->CSMClampPos(maxp);
|
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();
|
const NodeDefManager *ndef = env->getGameDef()->ndef();
|
||||||
Map &map = env->getMap();
|
Map &map = env->getMap();
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
if (Client *client = getClient(L)) {
|
if (Client *client = getClient(L)) {
|
||||||
minp = client->CSMClampPos(minp);
|
minp = client->CSMClampPos(minp);
|
||||||
maxp = client->CSMClampPos(maxp);
|
maxp = client->CSMClampPos(maxp);
|
||||||
|
@ -222,7 +222,7 @@ void ModApiHttp::Initialize(lua_State *L, int top)
|
|||||||
#if USE_CURL
|
#if USE_CURL
|
||||||
|
|
||||||
bool isMainmenu = false;
|
bool isMainmenu = false;
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
isMainmenu = ModApiBase::getGuiEngine(L) != nullptr;
|
isMainmenu = ModApiBase::getGuiEngine(L) != nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -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
|
/* In debug mode ensure no code tries to retrieve the server env when it isn't
|
||||||
* actually available (in CSM) */
|
* actually available (in CSM) */
|
||||||
#if !defined(SERVER) && !defined(NDEBUG)
|
#if CHECK_CLIENT_BUILD() && !defined(NDEBUG)
|
||||||
#define DEBUG_ASSERT_NO_CLIENTAPI \
|
#define DEBUG_ASSERT_NO_CLIENTAPI \
|
||||||
FATAL_ERROR_IF(getClient(L) != nullptr, "Tried " \
|
FATAL_ERROR_IF(getClient(L) != nullptr, "Tried " \
|
||||||
"to retrieve ServerEnvironment on client")
|
"to retrieve ServerEnvironment on client")
|
||||||
|
@ -46,7 +46,7 @@ static inline int checkSettingSecurity(lua_State* L, const std::string &name)
|
|||||||
throw LuaError("Attempted to set secure setting.");
|
throw LuaError("Attempted to set secure setting.");
|
||||||
|
|
||||||
bool is_mainmenu = false;
|
bool is_mainmenu = false;
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
is_mainmenu = ModApiBase::getGuiEngine(L) != nullptr;
|
is_mainmenu = ModApiBase::getGuiEngine(L) != nullptr;
|
||||||
#endif
|
#endif
|
||||||
if (!is_mainmenu && (name == "mg_name" || name == "mg_flags")) {
|
if (!is_mainmenu && (name == "mg_name" || name == "mg_flags")) {
|
||||||
|
@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
// Client translations
|
// Client translations
|
||||||
static Translations client_translations;
|
static Translations client_translations;
|
||||||
Translations *g_client_translations = &client_translations;
|
Translations *g_client_translations = &client_translations;
|
||||||
|
@ -25,9 +25,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
class Translations;
|
class Translations;
|
||||||
#ifndef SERVER
|
#if IS_CLIENT_BUILD
|
||||||
extern Translations *g_client_translations;
|
extern Translations *g_client_translations;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -935,7 +935,7 @@ std::wstring translate_string(std::wstring_view s, Translations *translations)
|
|||||||
// Translate string client side
|
// Translate string client side
|
||||||
std::wstring translate_string(std::wstring_view s)
|
std::wstring translate_string(std::wstring_view s)
|
||||||
{
|
{
|
||||||
#ifdef SERVER
|
#if !CHECK_CLIENT_BUILD()
|
||||||
return translate_string(s, nullptr);
|
return translate_string(s, nullptr);
|
||||||
#else
|
#else
|
||||||
return translate_string(s, g_client_translations);
|
return translate_string(s, g_client_translations);
|
||||||
|
@ -20,7 +20,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "irrlichttypes_bloated.h"
|
#include "irrlichttypes_bloated.h"
|
||||||
#ifndef SERVER
|
#include "config.h" // IS_CLIENT_BUILD
|
||||||
|
#if IS_CLIENT_BUILD
|
||||||
#include "irrString.h"
|
#include "irrString.h"
|
||||||
#endif
|
#endif
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -755,7 +756,7 @@ inline std::string str_join(const std::vector<std::string> &list,
|
|||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SERVER
|
#if IS_CLIENT_BUILD
|
||||||
/**
|
/**
|
||||||
* Create a UTF8 std::string from an irr::core::stringw.
|
* Create a UTF8 std::string from an irr::core::stringw.
|
||||||
*/
|
*/
|
||||||
|
@ -37,7 +37,7 @@ const char *g_build_info =
|
|||||||
"BUILD_TYPE=" BUILD_TYPE "\n"
|
"BUILD_TYPE=" BUILD_TYPE "\n"
|
||||||
"RUN_IN_PLACE=" STR(RUN_IN_PLACE) "\n"
|
"RUN_IN_PLACE=" STR(RUN_IN_PLACE) "\n"
|
||||||
"USE_CURL=" STR(USE_CURL) "\n"
|
"USE_CURL=" STR(USE_CURL) "\n"
|
||||||
#ifndef SERVER
|
#if CHECK_CLIENT_BUILD()
|
||||||
"USE_GETTEXT=" STR(USE_GETTEXT) "\n"
|
"USE_GETTEXT=" STR(USE_GETTEXT) "\n"
|
||||||
"USE_SOUND=" STR(USE_SOUND) "\n"
|
"USE_SOUND=" STR(USE_SOUND) "\n"
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user