X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;ds=sidebyside;f=src%2Fitemdef.h;h=dcb98e8a945d01c49e2e3bb1010d6493516765ab;hb=45a9145a4bd44a677c77687880d0b0acb7e6b421;hp=74c6d0b3e2f3c5548006991cf6aba26aee18266a;hpb=91bafceee6606fab79db1bde4cba01b84fed65c7;p=minetest.git diff --git a/src/itemdef.h b/src/itemdef.h index 74c6d0b3e..dcb98e8a9 100644 --- a/src/itemdef.h +++ b/src/itemdef.h @@ -25,18 +25,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include -#include #include "itemgroup.h" #include "sound.h" -#include "util/container.h" -#include "util/thread.h" - -#ifndef SERVER -#include "client/tile.h" -#endif - class IGameDef; -class INodeDefManager; struct ToolCapabilities; /* @@ -48,7 +39,7 @@ enum ItemType ITEM_NONE, ITEM_NODE, ITEM_CRAFT, - ITEM_TOOL + ITEM_TOOL, }; struct ItemDefinition @@ -66,13 +57,11 @@ struct ItemDefinition std::string inventory_image; // Optional for nodes, mandatory for tools/craftitems std::string wield_image; // If empty, inventory_image or mesh (only nodes) is used v3f wield_scale; - std::string meshname; // name of internal mesh (or meshfile to use TBD) - std::string meshtexture; // meshtexture /* Item stack and interaction properties */ - s16 stack_max; + u16 stack_max; bool usable; bool liquids_pointable; // May be NULL. If non-NULL, deleted by destructor @@ -155,6 +144,7 @@ class IWritableItemDefManager : public IItemDefManager virtual void clear()=0; // Register item definition virtual void registerItem(const ItemDefinition &def)=0; + virtual void unregisterItem(const std::string &name)=0; // Set an alias so that items named will load as . // Alias is not set if has already been defined. // Alias will be removed if is defined at a later point of time. @@ -168,84 +158,6 @@ class IWritableItemDefManager : public IItemDefManager virtual void processQueue(IGameDef *gamedef)=0; }; - -class CItemDefManager: public IWritableItemDefManager -{ -public: - CItemDefManager(); - virtual ~CItemDefManager(); - virtual const ItemDefinition& get(const std::string &name_) const; - virtual std::string getAlias(const std::string &name) const; - virtual std::set getAll() const; - virtual bool isKnown(const std::string &name_) const; - -#ifndef SERVER - // Get item inventory texture - virtual video::ITexture* getInventoryTexture(const std::string &name, - IGameDef *gamedef) const; - - // Get item wield mesh - virtual scene::IMesh* getWieldMesh(const std::string &name, - IGameDef *gamedef) const; -#endif - void clear(); - - virtual void registerItem(const ItemDefinition &def); - virtual void registerAlias(const std::string &name, - const std::string &convert_to); - void serialize(std::ostream &os, u16 protocol_version); - void deSerialize(std::istream &is); - - void processQueue(IGameDef *gamedef); - -private: - -#ifndef SERVER - struct ClientCached - { - video::ITexture *inventory_texture; - scene::IMesh *wield_mesh; - - ClientCached(); - }; - - void createNodeItemTexture(const std::string& name, - const ItemDefinition& def, INodeDefManager* nodedef, - ClientCached* cc, IGameDef* gamedef, ITextureSource* tsrc) const; - - void createMeshItemTexture(const std::string& name, - const ItemDefinition& def, INodeDefManager* nodedef, - ClientCached* cc, IGameDef* gamedef, ITextureSource* tsrc) const; - - void renderMeshToTexture(const ItemDefinition& def, scene::IMesh* mesh, - ClientCached* cc, ITextureSource* tsrc) const; - - ClientCached* createClientCachedDirect(const std::string &name, - IGameDef *gamedef) const; - - ClientCached* getClientCached(const std::string &name, - IGameDef *gamedef) const; - - // The id of the thread that is allowed to use irrlicht directly - threadid_t m_main_thread; - - // A reference to this can be returned when nothing is found, to avoid NULLs - mutable ClientCached m_dummy_clientcached; - - // Cached textures and meshes - mutable MutexedMap m_clientcached; - - // Queued clientcached fetches (to be processed by the main thread) - mutable RequestQueue m_get_clientcached_queue; -#endif - - // Key is name - std::map m_item_definitions; - - // Aliases - std::map m_aliases; -}; - IWritableItemDefManager* createItemDefManager(); #endif