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
|
||||
"$<$<PLATFORM_ID:Android>:${SDL2_LIBRARIES}>"
|
||||
)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE "MT_BUILDTARGET=1")
|
||||
if(NOT USE_LUAJIT)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
# This is necessary for dynamic Lua modules
|
||||
@ -679,8 +680,7 @@ if(BUILD_SERVER)
|
||||
${GMP_LIBRARY}
|
||||
${PLATFORM_LIBS}
|
||||
)
|
||||
set_target_properties(${PROJECT_NAME}server PROPERTIES
|
||||
COMPILE_DEFINITIONS "SERVER")
|
||||
target_compile_definitions(${PROJECT_NAME}server PRIVATE "MT_BUILDTARGET=2")
|
||||
if(NOT USE_LUAJIT)
|
||||
set_target_properties(${PROJECT_NAME}server PROPERTIES
|
||||
# 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)
|
||||
{
|
||||
for (MapBlock *block : vec) {
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
bool foo = !!block->mesh;
|
||||
#else
|
||||
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 "util/numeric.h"
|
||||
#include "util/string.h" // StringMap
|
||||
#include "config.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#if !IS_CLIENT_BUILD
|
||||
#error Do not include in server builds
|
||||
#endif
|
||||
|
||||
|
@ -23,9 +23,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "util/numeric.h" // IntervalLimiter
|
||||
#include "activeobjectmgr.h" // client::ActiveObjectMgr
|
||||
#include "irr_ptr.h"
|
||||
#include "config.h"
|
||||
#include <set>
|
||||
|
||||
#ifdef SERVER
|
||||
#if !IS_CLIENT_BUILD
|
||||
#error Do not include in server builds
|
||||
#endif
|
||||
|
||||
|
@ -20,9 +20,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#pragma once
|
||||
|
||||
#include "irrlichttypes.h"
|
||||
#include "config.h"
|
||||
#include <string>
|
||||
|
||||
#ifdef SERVER
|
||||
#if !IS_CLIENT_BUILD
|
||||
#error Do not include in server builds
|
||||
#endif
|
||||
|
||||
|
@ -26,13 +26,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "client/inputhandler.h"
|
||||
#include "irrlichttypes_extrabloated.h"
|
||||
#include "debug.h"
|
||||
#include "config.h"
|
||||
#include "client/shader.h"
|
||||
#include "client/render/core.h"
|
||||
// include the shadow mapper classes too
|
||||
#include "client/shadows/dynamicshadowsrender.h"
|
||||
#include <IVideoDriver.h>
|
||||
|
||||
#ifdef SERVER
|
||||
#if !IS_CLIENT_BUILD
|
||||
#error Do not include in server builds
|
||||
#endif
|
||||
|
||||
|
@ -20,13 +20,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#pragma once
|
||||
|
||||
#include "irr_v3d.h"
|
||||
#include "config.h"
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#ifdef SERVER
|
||||
#if !IS_CLIENT_BUILD
|
||||
#error Do not include in server builds
|
||||
#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.
|
||||
*/
|
||||
|
||||
#ifndef SERVER
|
||||
|
||||
#include "clientdynamicinfo.h"
|
||||
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
|
||||
#include "settings.h"
|
||||
#include "client/renderingengine.h"
|
||||
#include "gui/guiFormSpecMenu.h"
|
||||
|
@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#pragma once
|
||||
|
||||
#include "irrlichttypes_bloated.h"
|
||||
#include "config.h"
|
||||
|
||||
|
||||
struct ClientDynamicInfo
|
||||
@ -38,7 +39,7 @@ public:
|
||||
touch_controls == other.touch_controls;
|
||||
}
|
||||
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
static ClientDynamicInfo getCurrent();
|
||||
|
||||
private:
|
||||
|
@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "map.h"
|
||||
#include "nodedef.h"
|
||||
#include "gamedef.h"
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
#include "client/clientenvironment.h"
|
||||
#include "client/localplayer.h"
|
||||
#endif
|
||||
@ -285,7 +285,7 @@ static void add_object_boxes(Environment *env,
|
||||
const f32 distance = speed_f.getLength() * dtime +
|
||||
box_0.getExtent().getLength() + 1.5f * BS;
|
||||
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
ClientEnvironment *c_env = dynamic_cast<ClientEnvironment*>(env);
|
||||
if (c_env) {
|
||||
std::vector<DistanceSortedActiveObject> clientobjects;
|
||||
|
42
src/config.h
42
src/config.h
@ -5,3 +5,45 @@
|
||||
#else
|
||||
#warning Missing configuration
|
||||
#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 "util/string.h"
|
||||
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
#include "client/texturepaths.h"
|
||||
#endif
|
||||
|
||||
@ -192,7 +192,7 @@ SubgameSpec findSubgame(const std::string &id)
|
||||
}
|
||||
|
||||
std::string menuicon_path;
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
menuicon_path = getImagePath(
|
||||
game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png");
|
||||
#endif
|
||||
|
@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "log.h"
|
||||
#include "config.h"
|
||||
#include "porting.h"
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
#include "irr_ptr.h"
|
||||
#include <IFileArchive.h>
|
||||
#include <IFileSystem.h>
|
||||
@ -945,7 +945,7 @@ bool safeWriteToFile(const std::string &path, std::string_view content)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
bool extractZipFile(io::IFileSystem *fs, const char *filename, const std::string &destination)
|
||||
{
|
||||
// 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
|
||||
|
||||
#include "config.h"
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@ -154,7 +155,7 @@ const char *GetFilenameFromPath(const char *path);
|
||||
// logs and returns false on error
|
||||
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);
|
||||
#endif
|
||||
|
||||
|
@ -184,7 +184,7 @@ void init_gettext(const char *path, const std::string &configured_language,
|
||||
setenv("LANGUAGE", configured_language.c_str(), 1);
|
||||
SetEnvironmentVariableA("LANGUAGE", configured_language.c_str());
|
||||
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
// Hack to force gettext to see the right environment
|
||||
if (current_language != configured_language)
|
||||
MSVC_LocaleWorkaround(argc, argv);
|
||||
|
@ -20,8 +20,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#pragma once
|
||||
|
||||
#include "irrlichttypes_bloated.h"
|
||||
#include "config.h" // IS_CLIENT_BUILD
|
||||
|
||||
#ifndef SERVER
|
||||
#if IS_CLIENT_BUILD
|
||||
#include <IMesh.h>
|
||||
#include <IImage.h>
|
||||
#include <IMeshSceneNode.h>
|
||||
|
@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "nodedef.h"
|
||||
#include "tool.h"
|
||||
#include "inventory.h"
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
#include "client/mapblock_mesh.h"
|
||||
#include "client/mesh.h"
|
||||
#include "client/wieldmesh.h"
|
||||
@ -374,7 +374,7 @@ void ItemDefinition::deSerialize(std::istream &is, u16 protocol_version)
|
||||
|
||||
class CItemDefManager: public IWritableItemDefManager
|
||||
{
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
struct ClientCached
|
||||
{
|
||||
video::ITexture *inventory_texture;
|
||||
@ -399,7 +399,7 @@ public:
|
||||
CItemDefManager()
|
||||
{
|
||||
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
m_main_thread = std::this_thread::get_id();
|
||||
#endif
|
||||
clear();
|
||||
@ -448,7 +448,7 @@ public:
|
||||
// Get the definition
|
||||
return m_item_definitions.find(name) != m_item_definitions.cend();
|
||||
}
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
public:
|
||||
ClientCached* createClientCachedDirect(const ItemStack &item, Client *client) const
|
||||
{
|
||||
@ -678,7 +678,7 @@ private:
|
||||
std::map<std::string, ItemDefinition*> m_item_definitions;
|
||||
// Aliases
|
||||
StringMap m_aliases;
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
// The id of the thread that is allowed to use irrlicht directly
|
||||
std::thread::id m_main_thread;
|
||||
// Cached textures and meshes
|
||||
|
@ -35,7 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
class IGameDef;
|
||||
class Client;
|
||||
struct ToolCapabilities;
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
#include "client/texturesource.h"
|
||||
struct ItemMesh;
|
||||
struct ItemStack;
|
||||
@ -155,7 +155,7 @@ public:
|
||||
virtual void getAll(std::set<std::string> &result) const=0;
|
||||
// Check if item is known
|
||||
virtual bool isKnown(const std::string &name) const=0;
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
// Get item inventory texture
|
||||
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 "settings.h"
|
||||
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
|
||||
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
|
||||
#include <cassert>
|
||||
#include "config.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
|
||||
#define LIGHT_SUN 15
|
||||
|
||||
#ifndef SERVER
|
||||
#if IS_CLIENT_BUILD
|
||||
|
||||
/**
|
||||
* \internal
|
||||
@ -67,7 +68,7 @@ float decode_light_f(float light_f);
|
||||
|
||||
void set_light_table(float gamma);
|
||||
|
||||
#endif // ifndef SERVER
|
||||
#endif
|
||||
|
||||
// 0 <= daylight_factor <= 1000
|
||||
// 0 <= lightday, lightnight <= LIGHT_SUN
|
||||
|
@ -44,7 +44,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#if USE_CURSES
|
||||
#include "terminal_chat_console.h"
|
||||
#endif
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
#include "gui/guiMainMenu.h"
|
||||
#include "client/clientlauncher.h"
|
||||
#include "gui/guiEngine.h"
|
||||
@ -243,7 +243,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
GameStartData game_params;
|
||||
#ifdef SERVER
|
||||
#if !CHECK_CLIENT_BUILD()
|
||||
porting::attachOrCreateConsole();
|
||||
game_params.is_dedicated_server = true;
|
||||
#else
|
||||
@ -261,7 +261,7 @@ int main(int argc, char *argv[])
|
||||
if (game_params.is_dedicated_server)
|
||||
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;
|
||||
#else
|
||||
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)"))));
|
||||
allowed_options->insert(std::make_pair("recompress", ValueSpec(VALUETYPE_FLAG,
|
||||
_("Recompress the blocks of the given map database."))));
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
allowed_options->insert(std::make_pair("address", ValueSpec(VALUETYPE_STRING,
|
||||
_("Address to connect to. ('' = local game)"))));
|
||||
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_nodemeta.h" // For legacy deserialization
|
||||
#include "serialization.h"
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
#include "client/mapblock_mesh.h"
|
||||
#endif
|
||||
#include "porting.h"
|
||||
@ -77,7 +77,7 @@ MapBlock::MapBlock(v3s16 pos, IGameDef *gamedef):
|
||||
|
||||
MapBlock::~MapBlock()
|
||||
{
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
{
|
||||
delete mesh;
|
||||
mesh = nullptr;
|
||||
|
@ -460,7 +460,7 @@ private:
|
||||
*/
|
||||
|
||||
public:
|
||||
#ifndef SERVER // Only on client
|
||||
#if CHECK_CLIENT_BUILD() // Only on client
|
||||
MapBlockMesh *mesh = nullptr;
|
||||
|
||||
// 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 "itemdef.h"
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
#include "client/mesh.h"
|
||||
#include "client/shader.h"
|
||||
#include "client/client.h"
|
||||
@ -332,7 +332,7 @@ ContentFeatures::ContentFeatures()
|
||||
|
||||
ContentFeatures::~ContentFeatures()
|
||||
{
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
for (u16 j = 0; j < 6; j++) {
|
||||
delete tiles[j].layers[0].frames;
|
||||
delete tiles[j].layers[1].frames;
|
||||
@ -347,7 +347,7 @@ void ContentFeatures::reset()
|
||||
/*
|
||||
Cached stuff
|
||||
*/
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
solidness = 2;
|
||||
visual_solidness = 0;
|
||||
backface_culling = true;
|
||||
@ -370,7 +370,7 @@ void ContentFeatures::reset()
|
||||
groups["dig_immediate"] = 2;
|
||||
drawtype = NDT_NORMAL;
|
||||
mesh.clear();
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
for (auto &i : mesh_ptr)
|
||||
i = NULL;
|
||||
minimap_color = video::SColor(0, 0, 0, 0);
|
||||
@ -686,7 +686,7 @@ void ContentFeatures::deSerialize(std::istream &is, u16 protocol_version)
|
||||
} catch (SerializationError &e) {};
|
||||
}
|
||||
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
static void fillTileAttribs(ITextureSource *tsrc, TileLayer *layer,
|
||||
const TileSpec &tile, const TileDef &tiledef, video::SColor color,
|
||||
u8 material_type, u32 shader_id, bool backface_culling,
|
||||
@ -1026,7 +1026,7 @@ NodeDefManager::NodeDefManager()
|
||||
|
||||
NodeDefManager::~NodeDefManager()
|
||||
{
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
for (ContentFeatures &f : m_content_features) {
|
||||
for (auto &j : f.mesh_ptr) {
|
||||
if (j)
|
||||
@ -1479,7 +1479,7 @@ void NodeDefManager::applyTextureOverrides(const std::vector<TextureOverride> &o
|
||||
|
||||
void NodeDefManager::updateTextures(IGameDef *gamedef, void *progress_callback_args)
|
||||
{
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
infostream << "NodeDefManager::updateTextures(): Updating "
|
||||
"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 "mapnode.h"
|
||||
#include "nameidmapping.h"
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
#include "client/tile.h"
|
||||
#include <IMeshManipulator.h>
|
||||
class Client;
|
||||
@ -315,7 +315,7 @@ struct ContentFeatures
|
||||
/*
|
||||
Cached stuff
|
||||
*/
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
// 0 1 2 3 4 5
|
||||
// up down right left back front
|
||||
TileSpec tiles[6];
|
||||
@ -351,7 +351,7 @@ struct ContentFeatures
|
||||
|
||||
enum NodeDrawType drawtype;
|
||||
std::string mesh;
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
scene::IMesh *mesh_ptr[24];
|
||||
video::SColor minimap_color;
|
||||
#endif
|
||||
@ -530,7 +530,7 @@ struct ContentFeatures
|
||||
return itemgroup_get(groups, group);
|
||||
}
|
||||
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
void updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc,
|
||||
scene::IMeshManipulator *meshmanip, Client *client, const TextureSettings &tsettings);
|
||||
#endif
|
||||
|
@ -209,7 +209,7 @@ void PlayerControl::setMovementFromKeys()
|
||||
movement_direction = std::atan2(x, y);
|
||||
}
|
||||
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
|
||||
u32 PlayerControl::getKeysPressed() const
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ struct PlayerControl
|
||||
// joystick input.
|
||||
void setMovementFromKeys();
|
||||
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
// For client use
|
||||
u32 getKeysPressed() const;
|
||||
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 <atomic>
|
||||
|
||||
#if !defined(SERVER) && defined(_WIN32)
|
||||
#if CHECK_CLIENT_BUILD() && defined(_WIN32)
|
||||
// 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.
|
||||
extern "C" {
|
||||
|
@ -249,7 +249,6 @@ int getInputDialogSelection()
|
||||
return jnienv->CallIntMethod(activity, dialogvalue);
|
||||
}
|
||||
|
||||
#ifndef SERVER
|
||||
float getDisplayDensity()
|
||||
{
|
||||
static bool firstrun = true;
|
||||
@ -325,5 +324,4 @@ bool hasPhysicalKeyboardAndroid()
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // ndef SERVER
|
||||
}
|
||||
|
@ -97,9 +97,7 @@ int getInputDialogSelection();
|
||||
|
||||
bool hasPhysicalKeyboardAndroid();
|
||||
|
||||
#ifndef SERVER
|
||||
float getDisplayDensity();
|
||||
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_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,
|
||||
lua_setfield(L, -2, "minimap_color"); // but the people need to know!
|
||||
#endif
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
||||
|
@ -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")
|
||||
|
@ -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")) {
|
||||
|
@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include <unordered_map>
|
||||
|
||||
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
// Client translations
|
||||
static 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 <string>
|
||||
#include <vector>
|
||||
#include "config.h"
|
||||
|
||||
class Translations;
|
||||
#ifndef SERVER
|
||||
#if IS_CLIENT_BUILD
|
||||
extern Translations *g_client_translations;
|
||||
#endif
|
||||
|
||||
|
@ -935,7 +935,7 @@ std::wstring translate_string(std::wstring_view s, Translations *translations)
|
||||
// Translate string client side
|
||||
std::wstring translate_string(std::wstring_view s)
|
||||
{
|
||||
#ifdef SERVER
|
||||
#if !CHECK_CLIENT_BUILD()
|
||||
return translate_string(s, nullptr);
|
||||
#else
|
||||
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
|
||||
|
||||
#include "irrlichttypes_bloated.h"
|
||||
#ifndef SERVER
|
||||
#include "config.h" // IS_CLIENT_BUILD
|
||||
#if IS_CLIENT_BUILD
|
||||
#include "irrString.h"
|
||||
#endif
|
||||
#include <cstdlib>
|
||||
@ -755,7 +756,7 @@ inline std::string str_join(const std::vector<std::string> &list,
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
#ifndef SERVER
|
||||
#if IS_CLIENT_BUILD
|
||||
/**
|
||||
* Create a UTF8 std::string from an irr::core::stringw.
|
||||
*/
|
||||
|
@ -37,7 +37,7 @@ const char *g_build_info =
|
||||
"BUILD_TYPE=" BUILD_TYPE "\n"
|
||||
"RUN_IN_PLACE=" STR(RUN_IN_PLACE) "\n"
|
||||
"USE_CURL=" STR(USE_CURL) "\n"
|
||||
#ifndef SERVER
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
"USE_GETTEXT=" STR(USE_GETTEXT) "\n"
|
||||
"USE_SOUND=" STR(USE_SOUND) "\n"
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user