From 6d85435f60e4fa94b1956ceb44c7dddd92c4b39b Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 20 Oct 2020 12:28:45 +0100 Subject: [PATCH] Remove BLOCKENTITY_PROTODEF --- src/BlockEntities/BeaconEntity.h | 10 ++---- src/BlockEntities/BedEntity.h | 5 ++- src/BlockEntities/BlockEntity.h | 40 +---------------------- src/BlockEntities/BlockEntityWithItems.h | 8 +---- src/BlockEntities/BrewingstandEntity.h | 8 ----- src/BlockEntities/ChestEntity.h | 8 ----- src/BlockEntities/CommandBlockEntity.h | 6 ---- src/BlockEntities/DispenserEntity.h | 6 +--- src/BlockEntities/DropSpenserEntity.h | 7 +--- src/BlockEntities/DropperEntity.h | 7 ---- src/BlockEntities/EnchantingTableEntity.h | 2 -- src/BlockEntities/EndPortalEntity.h | 2 -- src/BlockEntities/EnderChestEntity.h | 6 ---- src/BlockEntities/FlowerPotEntity.h | 7 ---- src/BlockEntities/FurnaceEntity.h | 6 ---- src/BlockEntities/HopperEntity.h | 9 +---- src/BlockEntities/JukeboxEntity.h | 6 ---- src/BlockEntities/MobHeadEntity.h | 6 ---- src/BlockEntities/MobSpawnerEntity.h | 6 +--- src/BlockEntities/NoteEntity.h | 2 -- src/BlockEntities/SignEntity.h | 6 ---- 21 files changed, 10 insertions(+), 153 deletions(-) diff --git a/src/BlockEntities/BeaconEntity.h b/src/BlockEntities/BeaconEntity.h index 8403dfa01..21c35610d 100644 --- a/src/BlockEntities/BeaconEntity.h +++ b/src/BlockEntities/BeaconEntity.h @@ -16,18 +16,15 @@ // tolua_begin -class cBeaconEntity: +class cBeaconEntity : public cBlockEntityWithItems { // tolua_end using Super = cBlockEntityWithItems; - public: // tolua_export - BLOCKENTITY_PROTODEF(cBeaconEntity) - cBeaconEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); // cBlockEntity overrides: @@ -77,12 +74,9 @@ public: // tolua_export // tolua_end protected: + bool m_IsActive; char m_BeaconLevel; cEntityEffect::eType m_PrimaryEffect, m_SecondaryEffect; } ; // tolua_export - - - - diff --git a/src/BlockEntities/BedEntity.h b/src/BlockEntities/BedEntity.h index fe5970681..9f75b7946 100644 --- a/src/BlockEntities/BedEntity.h +++ b/src/BlockEntities/BedEntity.h @@ -12,7 +12,7 @@ // tolua_begin -class cBedEntity: +class cBedEntity : public cBlockEntity { // tolua_end @@ -20,8 +20,6 @@ class cBedEntity: public: // tolua_export - BLOCKENTITY_PROTODEF(cBedEntity) - cBedEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World, short a_Color = E_META_WOOL_RED); // tolua_begin @@ -44,5 +42,6 @@ public: // tolua_export virtual void SendTo(cClientHandle & a_Client) override; private: + short m_Color; }; // tolua_export diff --git a/src/BlockEntities/BlockEntity.h b/src/BlockEntities/BlockEntity.h index c133c186c..3355cdf44 100644 --- a/src/BlockEntities/BlockEntity.h +++ b/src/BlockEntities/BlockEntity.h @@ -5,27 +5,6 @@ -/** Place this macro in the declaration of each cBlockEntity descendant. */ -#define BLOCKENTITY_PROTODEF(classname) \ - virtual bool IsA(const char * a_ClassName) const override \ - { \ - return ((a_ClassName != nullptr) && ((strcmp(a_ClassName, #classname) == 0) || Super::IsA(a_ClassName))); \ - } \ - virtual const char * GetClass() const override \ - { \ - return #classname; \ - } \ - static const char * GetClassStatic() \ - { \ - return #classname; \ - } \ - virtual const char * GetParentClass() const override \ - { \ - return Super::GetClass(); \ - } - - - class cChunk; @@ -56,6 +35,7 @@ protected: } public: + // tolua_end virtual ~cBlockEntity() {} // force a virtual destructor in all descendants @@ -93,20 +73,6 @@ public: Super::CopyFrom(a_Src) to copy the common ones. */ virtual void CopyFrom(const cBlockEntity & a_Src); - static const char * GetClassStatic() // Needed for ManualBindings's ForEach templates - { - return "cBlockEntity"; - } - - /** Returns true if the object is the specified class, or its descendant. */ - virtual bool IsA(const char * a_ClassName) const { return (strcmp(a_ClassName, "cBlockEntity") == 0); } - - /** Returns the name of the topmost class (the most descendant). Used for Lua bindings to push the correct object type. */ - virtual const char * GetClass() const { return GetClassStatic(); } - - /** Returns the name of the parent class, or empty string if no parent class. */ - virtual const char * GetParentClass() const { return ""; } - // tolua_begin // Position, in absolute block coordinates: @@ -163,7 +129,3 @@ protected: cWorld * m_World; } ; // tolua_export - - - - diff --git a/src/BlockEntities/BlockEntityWithItems.h b/src/BlockEntities/BlockEntityWithItems.h index 74e02693d..f191c8f43 100644 --- a/src/BlockEntities/BlockEntityWithItems.h +++ b/src/BlockEntities/BlockEntityWithItems.h @@ -32,9 +32,6 @@ class cBlockEntityWithItems : public: // tolua_export - BLOCKENTITY_PROTODEF(cBlockEntityWithItems) - - cBlockEntityWithItems( BLOCKTYPE a_BlockType, // Type of the block that the entity represents NIBBLETYPE a_BlockMeta, // Meta of the block that the entity represents @@ -64,12 +61,9 @@ public: // tolua_export const cItemGrid & GetContents(void) const { return m_Contents; } protected: + cItemGrid m_Contents; // cItemGrid::cListener overrides: virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) override; } ; // tolua_export - - - - diff --git a/src/BlockEntities/BrewingstandEntity.h b/src/BlockEntities/BrewingstandEntity.h index 90c6003df..5f6822ff7 100644 --- a/src/BlockEntities/BrewingstandEntity.h +++ b/src/BlockEntities/BrewingstandEntity.h @@ -40,8 +40,6 @@ public: // tolua_end - BLOCKENTITY_PROTODEF(cBrewingstandEntity) - /** Constructor used for normal operation */ cBrewingstandEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); @@ -144,10 +142,4 @@ protected: // cItemGrid::cListener overrides: virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override; - } ; // tolua_export - - - - - diff --git a/src/BlockEntities/ChestEntity.h b/src/BlockEntities/ChestEntity.h index 84b6eef0c..7c28214eb 100644 --- a/src/BlockEntities/ChestEntity.h +++ b/src/BlockEntities/ChestEntity.h @@ -34,8 +34,6 @@ public: // tolua_end - BLOCKENTITY_PROTODEF(cChestEntity) - /** Constructor used for normal operation */ cChestEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); @@ -64,7 +62,6 @@ public: /** Sets the number of players who currently have this chest open */ void SetNumberOfPlayers(int a_NumActivePlayers) { m_NumActivePlayers = a_NumActivePlayers; } - private: /** Number of players who currently have this chest open */ @@ -75,9 +72,4 @@ private: /** cItemGrid::cListener overrides: */ virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) override; - } ; // tolua_export - - - - diff --git a/src/BlockEntities/CommandBlockEntity.h b/src/BlockEntities/CommandBlockEntity.h index 715fe445c..a24a34287 100644 --- a/src/BlockEntities/CommandBlockEntity.h +++ b/src/BlockEntities/CommandBlockEntity.h @@ -26,8 +26,6 @@ class cCommandBlockEntity : public: // tolua_export - BLOCKENTITY_PROTODEF(cCommandBlockEntity) - /** Creates a new empty command block entity */ cCommandBlockEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); @@ -73,7 +71,3 @@ private: NIBBLETYPE m_Result; } ; // tolua_export - - - - diff --git a/src/BlockEntities/DispenserEntity.h b/src/BlockEntities/DispenserEntity.h index c123f76cb..47c0996f4 100644 --- a/src/BlockEntities/DispenserEntity.h +++ b/src/BlockEntities/DispenserEntity.h @@ -17,8 +17,6 @@ class cDispenserEntity : public: // tolua_export - BLOCKENTITY_PROTODEF(cDispenserEntity) - /** Constructor used for normal operation */ cDispenserEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); @@ -54,6 +52,7 @@ public: // tolua_export // tolua_end private: + // cDropSpenser overrides: virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) override; @@ -64,6 +63,3 @@ private: does the m_Contents processing and returns true. Returns false otherwise. */ bool EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum); } ; // tolua_export - - - diff --git a/src/BlockEntities/DropSpenserEntity.h b/src/BlockEntities/DropSpenserEntity.h index 475937afe..e16149797 100644 --- a/src/BlockEntities/DropSpenserEntity.h +++ b/src/BlockEntities/DropSpenserEntity.h @@ -42,8 +42,6 @@ public: // tolua_end - BLOCKENTITY_PROTODEF(cDropSpenserEntity) - cDropSpenserEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); virtual ~cDropSpenserEntity() override; @@ -64,6 +62,7 @@ public: // tolua_end protected: + bool m_ShouldDropSpense; ///< If true, the dropspenser will dropspense an item in the next tick /** Does the actual work on dropspensing an item. Chooses the slot, calls DropSpenseFromSlot() and handles smoke / sound effects */ @@ -75,7 +74,3 @@ protected: /** Helper function, drops one item from the specified slot (like a dropper) */ void DropFromSlot(cChunk & a_Chunk, int a_SlotNum); } ; // tolua_export - - - - diff --git a/src/BlockEntities/DropperEntity.h b/src/BlockEntities/DropperEntity.h index 3ba2cbbe5..ea12a89b9 100644 --- a/src/BlockEntities/DropperEntity.h +++ b/src/BlockEntities/DropperEntity.h @@ -25,18 +25,11 @@ class cDropperEntity : public: // tolua_export - BLOCKENTITY_PROTODEF(cDropperEntity) - /** Constructor used for normal operation */ cDropperEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); - protected: // cDropSpenserEntity overrides: virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) override; } ; // tolua_export - - - - diff --git a/src/BlockEntities/EnchantingTableEntity.h b/src/BlockEntities/EnchantingTableEntity.h index d5e947838..1f0aafdf3 100644 --- a/src/BlockEntities/EnchantingTableEntity.h +++ b/src/BlockEntities/EnchantingTableEntity.h @@ -14,8 +14,6 @@ class cEnchantingTableEntity : public: - BLOCKENTITY_PROTODEF(cEnchantingTableEntity) - cEnchantingTableEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World, AString a_CustomName = ""); const AString & GetCustomName() const { return m_CustomName; } diff --git a/src/BlockEntities/EndPortalEntity.h b/src/BlockEntities/EndPortalEntity.h index fe5ed4322..3480ad49c 100644 --- a/src/BlockEntities/EndPortalEntity.h +++ b/src/BlockEntities/EndPortalEntity.h @@ -14,8 +14,6 @@ class cEndPortalEntity : public: - BLOCKENTITY_PROTODEF(cEndPortalEntity) - cEndPortalEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); private: diff --git a/src/BlockEntities/EnderChestEntity.h b/src/BlockEntities/EnderChestEntity.h index e380d1e3e..bb5974b15 100644 --- a/src/BlockEntities/EnderChestEntity.h +++ b/src/BlockEntities/EnderChestEntity.h @@ -19,8 +19,6 @@ class cEnderChestEntity : public: // tolua_export - BLOCKENTITY_PROTODEF(cEnderChestEntity) - cEnderChestEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); virtual ~cEnderChestEntity() override; @@ -34,7 +32,3 @@ public: // tolua_export /** Opens a new enderchest window for this enderchest */ void OpenNewWindow(void); } ; // tolua_export - - - - diff --git a/src/BlockEntities/FlowerPotEntity.h b/src/BlockEntities/FlowerPotEntity.h index 5ba4e4ab2..c93e2f4d9 100644 --- a/src/BlockEntities/FlowerPotEntity.h +++ b/src/BlockEntities/FlowerPotEntity.h @@ -16,7 +16,6 @@ // tolua_begin - class cFlowerPotEntity : public cBlockEntity { @@ -26,8 +25,6 @@ class cFlowerPotEntity : public: // tolua_export - BLOCKENTITY_PROTODEF(cFlowerPotEntity) - /** Creates a new flowerpot entity at the specified block coords. a_World may be nullptr */ cFlowerPotEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); @@ -57,7 +54,3 @@ private: cItem m_Item; } ; // tolua_export - - - - diff --git a/src/BlockEntities/FurnaceEntity.h b/src/BlockEntities/FurnaceEntity.h index 454c23785..079b45fef 100644 --- a/src/BlockEntities/FurnaceEntity.h +++ b/src/BlockEntities/FurnaceEntity.h @@ -38,8 +38,6 @@ public: // tolua_end - BLOCKENTITY_PROTODEF(cFurnaceEntity) - /** Constructor used for normal operation */ cFurnaceEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); @@ -175,7 +173,3 @@ protected: virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override; } ; // tolua_export - - - - diff --git a/src/BlockEntities/HopperEntity.h b/src/BlockEntities/HopperEntity.h index ff21471b6..366eb8e9e 100644 --- a/src/BlockEntities/HopperEntity.h +++ b/src/BlockEntities/HopperEntity.h @@ -26,6 +26,7 @@ class cHopperEntity : // tolua_begin public: + enum { ContentsHeight = 1, @@ -33,12 +34,8 @@ public: TICKS_PER_TRANSFER = 8, ///< How many ticks at minimum between two item transfers to or from the hopper } ; - - // tolua_end - BLOCKENTITY_PROTODEF(cHopperEntity) - /** Constructor used for normal operation */ cHopperEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); @@ -100,7 +97,3 @@ private: bool m_Locked; } ; // tolua_export - - - - diff --git a/src/BlockEntities/JukeboxEntity.h b/src/BlockEntities/JukeboxEntity.h index 6e8443a7e..744012fe6 100644 --- a/src/BlockEntities/JukeboxEntity.h +++ b/src/BlockEntities/JukeboxEntity.h @@ -19,8 +19,6 @@ class cJukeboxEntity : public: // tolua_export - BLOCKENTITY_PROTODEF(cJukeboxEntity) - cJukeboxEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); // tolua_begin @@ -55,7 +53,3 @@ public: // tolua_export private: int m_Record; } ; // tolua_end - - - - diff --git a/src/BlockEntities/MobHeadEntity.h b/src/BlockEntities/MobHeadEntity.h index fe82a1027..5ed2d8d01 100644 --- a/src/BlockEntities/MobHeadEntity.h +++ b/src/BlockEntities/MobHeadEntity.h @@ -27,8 +27,6 @@ class cMobHeadEntity : public: // tolua_export - BLOCKENTITY_PROTODEF(cMobHeadEntity) - /** Creates a new mob head entity at the specified block coords. a_World may be nullptr */ cMobHeadEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); @@ -85,7 +83,3 @@ private: AString m_OwnerTexture; AString m_OwnerTextureSignature; } ; // tolua_export - - - - diff --git a/src/BlockEntities/MobSpawnerEntity.h b/src/BlockEntities/MobSpawnerEntity.h index a037343f4..3cd178d81 100644 --- a/src/BlockEntities/MobSpawnerEntity.h +++ b/src/BlockEntities/MobSpawnerEntity.h @@ -33,7 +33,6 @@ public: // tolua_export virtual bool UsedBy(cPlayer * a_Player) override; virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; - static const char * GetClassStatic(void) { return "cMobSpawnerEntity"; } // tolua_begin /** Update the active flag from the mob spawner. This function will called every 5 seconds from the Tick() function. */ @@ -71,6 +70,7 @@ public: // tolua_export // tolua_end private: + /** The entity to spawn. */ eMonsterType m_Entity; @@ -96,7 +96,3 @@ private: short m_RequiredPlayerRange = 16; } ; // tolua_end - - - - diff --git a/src/BlockEntities/NoteEntity.h b/src/BlockEntities/NoteEntity.h index c5da3b44e..8579ba930 100644 --- a/src/BlockEntities/NoteEntity.h +++ b/src/BlockEntities/NoteEntity.h @@ -36,8 +36,6 @@ class cNoteEntity : public: // tolua_export - BLOCKENTITY_PROTODEF(cNoteEntity) - /** Creates a new note entity. a_World may be nullptr */ cNoteEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); diff --git a/src/BlockEntities/SignEntity.h b/src/BlockEntities/SignEntity.h index 83eb0352d..b5abd9f51 100644 --- a/src/BlockEntities/SignEntity.h +++ b/src/BlockEntities/SignEntity.h @@ -25,8 +25,6 @@ class cSignEntity : public: // tolua_export - BLOCKENTITY_PROTODEF(cSignEntity) - /** Creates a new empty sign entity at the specified block coords and block type (wall or standing). a_World may be nullptr */ cSignEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); @@ -52,7 +50,3 @@ private: AString m_Line[4]; } ; // tolua_export - - - -