Make itemdef.h safe to include anywhere

This commit is contained in:
sfan5 2024-09-09 20:39:35 +02:00
parent dd83ec1f08
commit 16fef8f479
12 changed files with 35 additions and 17 deletions

View File

@ -395,12 +395,14 @@ set(independent_SRCS
face_position_cache.cpp
httpfetch.cpp
hud.cpp
inventory.cpp
itemstackmetadata.cpp
lighting.cpp
log.cpp
metadata.cpp
modchannels.cpp
nameidmapping.cpp
nodemetadata.cpp
nodetimer.cpp
noise.cpp
objdef.cpp
@ -428,7 +430,6 @@ set(common_SRCS
environment.cpp
filesys.cpp
gettext.cpp
inventory.cpp
inventorymanager.cpp
itemdef.cpp
light.cpp
@ -439,7 +440,6 @@ set(common_SRCS
mapnode.cpp
mapsector.cpp
nodedef.cpp
nodemetadata.cpp
pathfinder.cpp
player.cpp
porting.cpp

View File

@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/renderingengine.h"
#include "client/sound.h"
#include "client/texturepaths.h"
#include "client/texturesource.h"
#include "client/mesh_generator_thread.h"
#include "client/particles.h"
#include "client/localplayer.h"

View File

@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "shader.h"
#include "mapblock.h"
#include "client/renderingengine.h"
#include "client/texturesource.h"
#include "gettext.h"
////

View File

@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/content_cao.h"
#include "client/clientevent.h"
#include "client/renderingengine.h"
#include "client/texturesource.h"
#include "util/numeric.h"
#include "light.h"
#include "localplayer.h"

View File

@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "guiscalingfilter.h"
#include "localplayer.h"
#include "client/hud.h"
#include "client/texturesource.h"
#include "camera.h"
#include "minimap.h"
#include "clientmap.h"

View File

@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "profiler.h"
#include "util/numeric.h"
#include "client/renderingengine.h"
#include "client/texturesource.h"
#include "settings.h"
#include "camera.h" // CameraModes

View File

@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapblock_mesh.h"
#include "client/meshgen/collector.h"
#include "client/tile.h"
#include "client/texturesource.h"
#include "log.h"
#include "util/numeric.h"
#include <map>

View File

@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "IVideoDriver.h"
#include "client/client.h"
#include "client/renderingengine.h"
#include "client/texturesource.h"
#include "hud.h"
#include "inventory.h"
#include "util/string.h"

View File

@ -33,13 +33,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "itemdef.h"
#include "client/game.h"
#include "client/texturesource.h"
namespace irr
{
class IrrlichtDevice;
}
using namespace irr;
using namespace irr::core;
using namespace irr::gui;

View File

@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/mesh.h"
#include "client/wieldmesh.h"
#include "client/client.h"
#include "client/texturesource.h"
#endif
#include "log.h"
#include "settings.h"
@ -448,8 +449,9 @@ public:
// Get the definition
return m_item_definitions.find(name) != m_item_definitions.cend();
}
#if CHECK_CLIENT_BUILD()
public:
protected:
ClientCached* createClientCachedDirect(const ItemStack &item, Client *client) const
{
// This is not thread-safe
@ -490,6 +492,7 @@ public:
return ptr;
}
public:
// Get item inventory texture
virtual video::ITexture* getInventoryTexture(const ItemStack &item,
Client *client) const

View File

@ -35,11 +35,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class IGameDef;
class Client;
struct ToolCapabilities;
#if CHECK_CLIENT_BUILD()
#include "client/texturesource.h"
struct ItemMesh;
struct ItemStack;
#endif
typedef std::vector<video::SColor> Palette; // copied from src/client/texturesource.h
namespace irr::video { class ITexture; }
using namespace irr;
/*
Base item definition
@ -155,25 +155,32 @@ 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;
#if CHECK_CLIENT_BUILD()
virtual void serialize(std::ostream &os, u16 protocol_version)=0;
/* Client-specific methods */
// TODO: should be moved elsewhere in the future
// 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
{ return nullptr; }
/**
* Get wield mesh
*
* Returns nullptr if there is an inventory image
* @returns nullptr if there is an inventory image
*/
virtual ItemMesh* getWieldMesh(const ItemStack &item, Client *client) const = 0;
virtual ItemMesh* getWieldMesh(const ItemStack &item, Client *client) const
{ return nullptr; }
// Get item palette
virtual Palette* getPalette(const ItemStack &item, Client *client) const = 0;
virtual Palette* getPalette(const ItemStack &item, Client *client) const
{ return nullptr; }
// Returns the base color of an item stack: the color of all
// tiles that do not define their own color.
virtual video::SColor getItemstackColor(const ItemStack &stack,
Client *client) const = 0;
#endif
virtual void serialize(std::ostream &os, u16 protocol_version)=0;
Client *client) const
{ return video::SColor(0); }
};
class IWritableItemDefManager : public IItemDefManager

View File

@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/shader.h"
#include "client/client.h"
#include "client/renderingengine.h"
#include "client/texturesource.h"
#include "client/tile.h"
#include <IMeshManipulator.h>
#endif