From fdcad8a72d6f66d62dcd5893f9ba7bf421043a61 Mon Sep 17 00:00:00 2001 From: faketruth Date: Sat, 2 Feb 2013 23:55:29 +0000 Subject: Added a GetClassStatic function to all entities, as well as cFurnaceEntity, cChestEntity and cWorld Using templates to generate ForEach* functions instead of MACROS Better error reporting in ForEach* functions git-svn-id: http://mc-server.googlecode.com/svn/trunk@1191 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Entity.h | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) (limited to 'source/Entity.h') diff --git a/source/Entity.h b/source/Entity.h index 94f565385..8d8d2690b 100644 --- a/source/Entity.h +++ b/source/Entity.h @@ -11,31 +11,6 @@ -#define CLASS_PROT_ISA() virtual bool IsA(const char * a_EntityType) const override; -#define CLASS_PROT_GETCLASS() virtual const char * GetClass (void) const override; -#define CLASS_PROT_GETPARENT() virtual const char * GetParentClass(void) const override; - -#define CLASS_PROTOTYPE() \ - CLASS_PROT_ISA(); \ - CLASS_PROT_GETCLASS(); \ - CLASS_PROT_GETPARENT(); - -#define CLASS_DEF_ISA(classname) \ - bool classname::IsA(const char * a_ClassName) const \ - { \ - return ((strcmp(a_ClassName, #classname) == 0) || super::IsA(a_ClassName)); \ - } - -#define CLASS_DEF_GETCLASS(classname) \ - const char * classname::GetClass(void) const \ - { \ - return #classname; \ - } - -#define CLASS_DEFINITION(classname) \ - CLASS_DEF_ISA(classname) \ - CLASS_DEF_GETCLASS(classname) - // Place this macro in the header of each cEntity descendant class and you're done :) #define CLASS_PROTODEF(classname) \ virtual bool IsA(const char * a_ClassName) const override\ @@ -46,6 +21,10 @@ { \ return #classname; \ } \ + static const char * GetClassStatic(void) \ + { \ + return #classname; \ + } \ virtual const char * GetParentClass(void) const override \ { \ return super::GetClass(); \ @@ -109,6 +88,9 @@ public: /// Returns the topmost class name for the object virtual const char * GetClass(void) const; + + // Returns the class name of this class + static const char * GetClassStatic(void); /// Returns the topmost class's parent class name for the object. cEntity returns an empty string (no parent). virtual const char * GetParentClass(void) const; -- cgit v1.2.3