From 033af999ba419afadfa1830d288b021e7d9bc1f5 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Fri, 21 Dec 2012 12:21:20 +0000 Subject: Reworked the IsA() / GetClass() framework to actually be useful. Added GetParentClass(). git-svn-id: http://mc-server.googlecode.com/svn/trunk@1090 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Bindings.cpp | 196 ++++++++++++++++++++++++++++++++++--------- source/Bindings.h | 2 +- source/Entity.cpp | 15 +++- source/Entity.h | 56 +++++++++---- source/FallingBlock.cpp | 22 ++--- source/FallingBlock.h | 14 ++-- source/Mobs/Bat.cpp | 10 --- source/Mobs/Bat.h | 2 +- source/Mobs/Blaze.cpp | 9 -- source/Mobs/Blaze.h | 4 +- source/Mobs/Cavespider.cpp | 10 +-- source/Mobs/Cavespider.h | 2 +- source/Mobs/Chicken.cpp | 9 -- source/Mobs/Chicken.h | 2 +- source/Mobs/Cow.cpp | 9 -- source/Mobs/Cow.h | 2 +- source/Mobs/Creeper.cpp | 9 -- source/Mobs/Creeper.h | 2 +- source/Mobs/Enderman.cpp | 9 -- source/Mobs/Enderman.h | 2 +- source/Mobs/Ghast.cpp | 9 -- source/Mobs/Ghast.h | 2 +- source/Mobs/Magmacube.cpp | 9 -- source/Mobs/Magmacube.h | 2 +- source/Mobs/Monster.cpp | 19 ----- source/Mobs/Monster.h | 5 +- source/Mobs/Mooshroom.cpp | 9 -- source/Mobs/Mooshroom.h | 2 +- source/Mobs/Ocelot.cpp | 10 --- source/Mobs/Ocelot.h | 2 +- source/Mobs/Pig.cpp | 9 -- source/Mobs/Pig.h | 2 +- source/Mobs/Sheep.cpp | 9 -- source/Mobs/Sheep.h | 2 +- source/Mobs/Silverfish.cpp | 11 +-- source/Mobs/Silverfish.h | 21 +++-- source/Mobs/Skeleton.cpp | 9 -- source/Mobs/Skeleton.h | 2 +- source/Mobs/Slime.cpp | 9 -- source/Mobs/Slime.h | 8 +- source/Mobs/Spider.cpp | 9 -- source/Mobs/Spider.h | 4 +- source/Mobs/Squid.cpp | 9 -- source/Mobs/Squid.h | 3 +- source/Mobs/Villager.cpp | 9 -- source/Mobs/Villager.h | 2 +- source/Mobs/Witch.cpp | 9 -- source/Mobs/Witch.h | 2 +- source/Mobs/Wolf.cpp | 16 ++-- source/Mobs/Wolf.h | 21 +++-- source/Mobs/Zombie.cpp | 9 -- source/Mobs/Zombie.h | 4 +- source/Mobs/Zombiepigman.cpp | 9 -- source/Mobs/Zombiepigman.h | 4 +- source/Pawn.cpp | 15 ---- source/Pawn.h | 7 +- source/Pickup.cpp | 6 -- source/Pickup.h | 4 +- source/Player.cpp | 6 -- source/Player.h | 4 +- 60 files changed, 308 insertions(+), 381 deletions(-) diff --git a/source/Bindings.cpp b/source/Bindings.cpp index c6c5c65a4..2b4282123 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 12/21/12 19:26:06. +** Generated automatically by tolua++-1.0.92 on 12/21/12 21:19:57. */ #ifndef __cplusplus @@ -4008,14 +4008,14 @@ static int tolua_AllToLua_cEntity_GetEntityType00(lua_State* tolua_S) #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) || + !tolua_isusertype(tolua_S,1,"const cEntity",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { - cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0); + const cEntity* self = (const cEntity*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEntityType'", NULL); #endif @@ -4040,7 +4040,7 @@ static int tolua_AllToLua_cEntity_IsA00(lua_State* tolua_S) #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) || + !tolua_isusertype(tolua_S,1,"const cEntity",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) @@ -4048,13 +4048,13 @@ static int tolua_AllToLua_cEntity_IsA00(lua_State* tolua_S) else #endif { - cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0); - const char* a_EntityType = ((const char*) tolua_tostring(tolua_S,2,0)); + const cEntity* self = (const cEntity*) tolua_tousertype(tolua_S,1,0); + const char* a_ClassName = ((const char*) tolua_tostring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsA'", NULL); #endif { - bool tolua_ret = (bool) self->IsA(a_EntityType); + bool tolua_ret = (bool) self->IsA(a_ClassName); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } @@ -4074,14 +4074,14 @@ static int tolua_AllToLua_cEntity_GetClass00(lua_State* tolua_S) #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) || + !tolua_isusertype(tolua_S,1,"const cEntity",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { - cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0); + const cEntity* self = (const cEntity*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetClass'", NULL); #endif @@ -4099,6 +4099,38 @@ static int tolua_AllToLua_cEntity_GetClass00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* method: GetParentClass of class cEntity */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetParentClass00 +static int tolua_AllToLua_cEntity_GetParentClass00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cEntity",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cEntity* self = (const cEntity*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetParentClass'", NULL); +#endif + { + const char* tolua_ret = (const char*) self->GetParentClass(); + tolua_pushstring(tolua_S,(const char*)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetParentClass'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* method: GetWorld of class cEntity */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetWorld00 static int tolua_AllToLua_cEntity_GetWorld00(lua_State* tolua_S) @@ -4992,7 +5024,7 @@ public: return ( void ) cEntity:: Initialize(a_World); }; }; - unsigned int GetEntityType( void ) { + unsigned int GetEntityType( void )const { if (push_method("GetEntityType", tolua_AllToLua_cEntity_GetEntityType00)) { ToluaBase::dbcall(lua_state, 1, 1); unsigned int tolua_ret = (unsigned int )tolua_tonumber(lua_state, -1, 0); @@ -5002,18 +5034,18 @@ public: return (unsigned int ) cEntity:: GetEntityType(); }; }; - bool IsA( const char* a_EntityType) { + bool IsA( const char* a_ClassName)const { if (push_method("IsA", tolua_AllToLua_cEntity_IsA00)) { - tolua_pushstring(lua_state, (const char*)a_EntityType); + tolua_pushstring(lua_state, (const char*)a_ClassName); ToluaBase::dbcall(lua_state, 2, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cEntity:: IsA(a_EntityType); + return ( bool ) cEntity:: IsA(a_ClassName); }; }; - const char* GetClass( void ) { + const char* GetClass( void )const { if (push_method("GetClass", tolua_AllToLua_cEntity_GetClass00)) { ToluaBase::dbcall(lua_state, 1, 1); const char* tolua_ret = ( const char* )tolua_tostring(lua_state, -1, 0); @@ -5022,6 +5054,16 @@ public: } else { return ( const char* ) cEntity:: GetClass(); }; + }; + const char* GetParentClass( void )const { + if (push_method("GetParentClass", tolua_AllToLua_cEntity_GetParentClass00)) { + ToluaBase::dbcall(lua_state, 1, 1); + const char* tolua_ret = ( const char* )tolua_tostring(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( const char* ) cEntity:: GetParentClass(); + }; }; void Tick( float a_Dt) { if (push_method("Tick", tolua_AllToLua_cEntity_Tick00)) { @@ -5052,11 +5094,14 @@ public: unsigned int cEntity__GetEntityType( void ) { return (unsigned int )cEntity::GetEntityType(); }; - bool cEntity__IsA( const char* a_EntityType) { - return ( bool )cEntity::IsA(a_EntityType); + bool cEntity__IsA( const char* a_ClassName) { + return ( bool )cEntity::IsA(a_ClassName); }; const char* cEntity__GetClass( void ) { return ( const char* )cEntity::GetClass(); + }; + const char* cEntity__GetParentClass( void ) { + return ( const char* )cEntity::GetParentClass(); }; void cEntity__SpawnOn( cClientHandle& a_Client) { return ( void )cEntity::SpawnOn(a_Client); @@ -5178,12 +5223,12 @@ static int tolua_AllToLua_Lua__cEntity_cEntity__IsA00(lua_State* tolua_S) #endif { Lua__cEntity* self = (Lua__cEntity*) tolua_tousertype(tolua_S,1,0); - const char* a_EntityType = ((const char*) tolua_tostring(tolua_S,2,0)); + const char* a_ClassName = ((const char*) tolua_tostring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cEntity__IsA'", NULL); #endif { - bool tolua_ret = (bool) self->cEntity__IsA(a_EntityType); + bool tolua_ret = (bool) self->cEntity__IsA(a_ClassName); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } @@ -5228,6 +5273,38 @@ static int tolua_AllToLua_Lua__cEntity_cEntity__GetClass00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* method: cEntity__GetParentClass of class Lua__cEntity */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cEntity_cEntity__GetParentClass00 +static int tolua_AllToLua_Lua__cEntity_cEntity__GetParentClass00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Lua__cEntity",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Lua__cEntity* self = (Lua__cEntity*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cEntity__GetParentClass'", NULL); +#endif + { + const char* tolua_ret = (const char*) self->cEntity__GetParentClass(); + tolua_pushstring(tolua_S,(const char*)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'cEntity__GetParentClass'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* method: cEntity__SpawnOn of class Lua__cEntity */ #ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cEntity_cEntity__SpawnOn00 static int tolua_AllToLua_Lua__cEntity_cEntity__SpawnOn00(lua_State* tolua_S) @@ -6270,7 +6347,7 @@ public: return ( void ) cPawn:: Initialize(a_World); }; }; - unsigned int GetEntityType( void ) { + unsigned int GetEntityType( void )const { if (push_method("GetEntityType", tolua_AllToLua_cEntity_GetEntityType00)) { ToluaBase::dbcall(lua_state, 1, 1); unsigned int tolua_ret = (unsigned int )tolua_tonumber(lua_state, -1, 0); @@ -6280,18 +6357,18 @@ public: return (unsigned int ) cPawn:: GetEntityType(); }; }; - bool IsA( const char* a_EntityType) { + bool IsA( const char* a_ClassName)const { if (push_method("IsA", tolua_AllToLua_cEntity_IsA00)) { - tolua_pushstring(lua_state, (const char*)a_EntityType); + tolua_pushstring(lua_state, (const char*)a_ClassName); ToluaBase::dbcall(lua_state, 2, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPawn:: IsA(a_EntityType); + return ( bool ) cPawn:: IsA(a_ClassName); }; }; - const char* GetClass( void ) { + const char* GetClass( void )const { if (push_method("GetClass", tolua_AllToLua_cEntity_GetClass00)) { ToluaBase::dbcall(lua_state, 1, 1); const char* tolua_ret = ( const char* )tolua_tostring(lua_state, -1, 0); @@ -6300,6 +6377,16 @@ public: } else { return ( const char* ) cPawn:: GetClass(); }; + }; + const char* GetParentClass( void )const { + if (push_method("GetParentClass", tolua_AllToLua_cEntity_GetParentClass00)) { + ToluaBase::dbcall(lua_state, 1, 1); + const char* tolua_ret = ( const char* )tolua_tostring(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( const char* ) cPawn:: GetParentClass(); + }; }; void Tick( float a_Dt) { if (push_method("Tick", tolua_AllToLua_cEntity_Tick00)) { @@ -6366,11 +6453,14 @@ public: unsigned int cPawn__GetEntityType( void ) { return (unsigned int )cPawn::GetEntityType(); }; - bool cPawn__IsA( const char* a_EntityType) { - return ( bool )cPawn::IsA(a_EntityType); + bool cPawn__IsA( const char* a_ClassName) { + return ( bool )cPawn::IsA(a_ClassName); }; const char* cPawn__GetClass( void ) { return ( const char* )cPawn::GetClass(); + }; + const char* cPawn__GetParentClass( void ) { + return ( const char* )cPawn::GetParentClass(); }; void cPawn__SpawnOn( cClientHandle& a_Client) { return ( void )cPawn::SpawnOn(a_Client); @@ -8259,7 +8349,7 @@ public: return ( cItem ) cPlayer:: GetEquippedBoots(); }; }; - unsigned int GetEntityType( void ) { + unsigned int GetEntityType( void )const { if (push_method("GetEntityType", tolua_AllToLua_cEntity_GetEntityType00)) { ToluaBase::dbcall(lua_state, 1, 1); unsigned int tolua_ret = (unsigned int )tolua_tonumber(lua_state, -1, 0); @@ -8269,18 +8359,18 @@ public: return (unsigned int ) cPlayer:: GetEntityType(); }; }; - bool IsA( const char* a_EntityType) { + bool IsA( const char* a_ClassName)const { if (push_method("IsA", tolua_AllToLua_cEntity_IsA00)) { - tolua_pushstring(lua_state, (const char*)a_EntityType); + tolua_pushstring(lua_state, (const char*)a_ClassName); ToluaBase::dbcall(lua_state, 2, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlayer:: IsA(a_EntityType); + return ( bool ) cPlayer:: IsA(a_ClassName); }; }; - const char* GetClass( void ) { + const char* GetClass( void )const { if (push_method("GetClass", tolua_AllToLua_cEntity_GetClass00)) { ToluaBase::dbcall(lua_state, 1, 1); const char* tolua_ret = ( const char* )tolua_tostring(lua_state, -1, 0); @@ -8289,6 +8379,16 @@ public: } else { return ( const char* ) cPlayer:: GetClass(); }; + }; + const char* GetParentClass( void )const { + if (push_method("GetParentClass", tolua_AllToLua_cEntity_GetParentClass00)) { + ToluaBase::dbcall(lua_state, 1, 1); + const char* tolua_ret = ( const char* )tolua_tostring(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( const char* ) cPlayer:: GetParentClass(); + }; }; void Tick( float a_Dt) { if (push_method("Tick", tolua_AllToLua_cEntity_Tick00)) { @@ -8358,11 +8458,14 @@ public: unsigned int cPlayer__GetEntityType( void ) { return (unsigned int )cPlayer::GetEntityType(); }; - bool cPlayer__IsA( const char* a_EntityType) { - return ( bool )cPlayer::IsA(a_EntityType); + bool cPlayer__IsA( const char* a_ClassName) { + return ( bool )cPlayer::IsA(a_ClassName); }; const char* cPlayer__GetClass( void ) { return ( const char* )cPlayer::GetClass(); + }; + const char* cPlayer__GetParentClass( void ) { + return ( const char* )cPlayer::GetParentClass(); }; void cPlayer__SpawnOn( cClientHandle& a_Client) { return ( void )cPlayer::SpawnOn(a_Client); @@ -16012,7 +16115,7 @@ public: return ( void ) cPickup:: Initialize(a_World); }; }; - unsigned int GetEntityType( void ) { + unsigned int GetEntityType( void )const { if (push_method("GetEntityType", tolua_AllToLua_cEntity_GetEntityType00)) { ToluaBase::dbcall(lua_state, 1, 1); unsigned int tolua_ret = (unsigned int )tolua_tonumber(lua_state, -1, 0); @@ -16022,18 +16125,18 @@ public: return (unsigned int ) cPickup:: GetEntityType(); }; }; - bool IsA( const char* a_EntityType) { + bool IsA( const char* a_ClassName)const { if (push_method("IsA", tolua_AllToLua_cEntity_IsA00)) { - tolua_pushstring(lua_state, (const char*)a_EntityType); + tolua_pushstring(lua_state, (const char*)a_ClassName); ToluaBase::dbcall(lua_state, 2, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPickup:: IsA(a_EntityType); + return ( bool ) cPickup:: IsA(a_ClassName); }; }; - const char* GetClass( void ) { + const char* GetClass( void )const { if (push_method("GetClass", tolua_AllToLua_cEntity_GetClass00)) { ToluaBase::dbcall(lua_state, 1, 1); const char* tolua_ret = ( const char* )tolua_tostring(lua_state, -1, 0); @@ -16042,6 +16145,16 @@ public: } else { return ( const char* ) cPickup:: GetClass(); }; + }; + const char* GetParentClass( void )const { + if (push_method("GetParentClass", tolua_AllToLua_cEntity_GetParentClass00)) { + ToluaBase::dbcall(lua_state, 1, 1); + const char* tolua_ret = ( const char* )tolua_tostring(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( const char* ) cPickup:: GetParentClass(); + }; }; void Tick( float a_Dt) { if (push_method("Tick", tolua_AllToLua_cEntity_Tick00)) { @@ -16075,11 +16188,14 @@ public: unsigned int cPickup__GetEntityType( void ) { return (unsigned int )cPickup::GetEntityType(); }; - bool cPickup__IsA( const char* a_EntityType) { - return ( bool )cPickup::IsA(a_EntityType); + bool cPickup__IsA( const char* a_ClassName) { + return ( bool )cPickup::IsA(a_ClassName); }; const char* cPickup__GetClass( void ) { return ( const char* )cPickup::GetClass(); + }; + const char* cPickup__GetParentClass( void ) { + return ( const char* )cPickup::GetParentClass(); }; void cPickup__SpawnOn( cClientHandle& a_Client) { return ( void )cPickup::SpawnOn(a_Client); @@ -23892,6 +24008,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"GetEntityType",tolua_AllToLua_cEntity_GetEntityType00); tolua_function(tolua_S,"IsA",tolua_AllToLua_cEntity_IsA00); tolua_function(tolua_S,"GetClass",tolua_AllToLua_cEntity_GetClass00); + tolua_function(tolua_S,"GetParentClass",tolua_AllToLua_cEntity_GetParentClass00); tolua_function(tolua_S,"GetWorld",tolua_AllToLua_cEntity_GetWorld00); tolua_function(tolua_S,"GetPosition",tolua_AllToLua_cEntity_GetPosition00); tolua_function(tolua_S,"GetPosX",tolua_AllToLua_cEntity_GetPosX00); @@ -23931,6 +24048,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"cEntity__GetEntityType",tolua_AllToLua_Lua__cEntity_cEntity__GetEntityType00); tolua_function(tolua_S,"cEntity__IsA",tolua_AllToLua_Lua__cEntity_cEntity__IsA00); tolua_function(tolua_S,"cEntity__GetClass",tolua_AllToLua_Lua__cEntity_cEntity__GetClass00); + tolua_function(tolua_S,"cEntity__GetParentClass",tolua_AllToLua_Lua__cEntity_cEntity__GetParentClass00); tolua_function(tolua_S,"cEntity__SpawnOn",tolua_AllToLua_Lua__cEntity_cEntity__SpawnOn00); tolua_function(tolua_S,"new",tolua_AllToLua_Lua__cEntity_new00); tolua_function(tolua_S,"new_local",tolua_AllToLua_Lua__cEntity_new00_local); diff --git a/source/Bindings.h b/source/Bindings.h index ccf2051d8..f6ae8790c 100644 --- a/source/Bindings.h +++ b/source/Bindings.h @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 12/21/12 19:26:06. +** Generated automatically by tolua++-1.0.92 on 12/21/12 21:19:58. */ /* Exported function */ diff --git a/source/Entity.cpp b/source/Entity.cpp index e5e6061e5..a2e0c4a27 100644 --- a/source/Entity.cpp +++ b/source/Entity.cpp @@ -76,6 +76,15 @@ CLASS_DEF_GETCLASS(cEntity); +const char * cEntity::GetParentClass(void) const +{ + return ""; +} + + + + + void cEntity::Initialize(cWorld * a_World) { m_World = a_World; @@ -188,11 +197,9 @@ void cEntity::RemoveFromChunk(void) -bool cEntity::IsA( const char* a_EntityType ) +bool cEntity::IsA(const char * a_ClassName) const { - //LOG("IsA( cEntity ) : %s", a_EntityType); - if( strcmp( a_EntityType, "cEntity" ) == 0 ) return true; - return false; + return (strcmp(a_ClassName, "cEntity") == 0); } diff --git a/source/Entity.h b/source/Entity.h index 613032938..7cb168581 100644 --- a/source/Entity.h +++ b/source/Entity.h @@ -11,30 +11,45 @@ -#define CLASS_PROT_ISA() virtual bool IsA( const char* a_EntityType ); -#define CLASS_PROT_GETCLASS() virtual const char* GetClass(); +#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; -/* Can't use this (yet) because of tolua */ #define CLASS_PROTOTYPE() \ CLASS_PROT_ISA(); \ - CLASS_PROT_GETCLASS(); + CLASS_PROT_GETCLASS(); \ + CLASS_PROT_GETPARENT(); -#define CLASS_DEF_ISA( classname, superclass ) \ - bool classname::IsA( const char* a_EntityType ) \ +#define CLASS_DEF_ISA(classname) \ + bool classname::IsA(const char * a_ClassName) const \ { \ - if( strcmp( a_EntityType, #classname ) == 0 ) return true; \ - return superclass::IsA( a_EntityType ); \ + return ((strcmp(a_ClassName, #classname) == 0) || super::IsA(a_ClassName)); \ } -#define CLASS_DEF_GETCLASS( classname ) \ - const char* classname::GetClass() \ +#define CLASS_DEF_GETCLASS(classname) \ + const char * classname::GetClass(void) const \ { \ - return #classname; \ + return #classname; \ } -#define CLASS_DEFINITION( classname, superclass ) \ - CLASS_DEF_ISA( classname, superclass ) \ - CLASS_DEF_GETCLASS( 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\ + { \ + return ((strcmp(a_ClassName, #classname) == 0) || super::IsA(a_ClassName)); \ + } \ + virtual const char * GetClass(void) const override \ + { \ + return #classname; \ + } \ + virtual const char * GetParentClass(void) const override \ + { \ + return super::GetClass(); \ + } @@ -74,9 +89,16 @@ public: eEntityType_Pickup }; - virtual unsigned int GetEntityType() { return m_EntityType; } - virtual bool IsA( const char* a_EntityType ); - virtual const char* GetClass(); + virtual unsigned int GetEntityType(void) const { return m_EntityType; } + + /// Returns true if the entity is of the specified class or a subclass (cPawn's IsA("cEntity") returns true) + virtual bool IsA(const char * a_ClassName) const; + + /// Returns the topmost class name for the object + virtual const char * GetClass(void) const; + + /// Returns the topmost class's parent class name for the object. cEntity returns an empty string (no parent). + virtual const char * GetParentClass(void) const; cWorld * GetWorld(void) const { return m_World; } diff --git a/source/FallingBlock.cpp b/source/FallingBlock.cpp index 1ed9cd5ed..93eac0815 100644 --- a/source/FallingBlock.cpp +++ b/source/FallingBlock.cpp @@ -5,7 +5,7 @@ #include "ClientHandle.h" -CLASS_DEFINITION( cFallingBlock, cEntity ) + cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType) @@ -20,14 +20,6 @@ cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_Block -cFallingBlock::~cFallingBlock() -{ -} - - - - - void cFallingBlock::Initialize(cWorld * a_World) { super::Initialize( a_World ); @@ -55,10 +47,14 @@ void cFallingBlock::Tick(float a_Dt) //GetWorld()->BroadcastTeleportEntity(*this); // Testing position - Vector3i BlockPos( m_OriginalPosition.x, (int)(m_Pos.y-0.5), m_OriginalPosition.z ); - if( !IsPassable( GetWorld()->GetBlock( BlockPos ) ) ) + Vector3i BlockPos( m_OriginalPosition.x, (int)(m_Pos.y - 0.5), m_OriginalPosition.z ); + if (!IsPassable(GetWorld()->GetBlock(BlockPos))) { Destroy(); - GetWorld()->SetBlock( BlockPos.x, BlockPos.y+1, BlockPos.z, m_BlockType, 0 ); + GetWorld()->SetBlock( BlockPos.x, BlockPos.y + 1, BlockPos.z, m_BlockType, 0 ); } -} \ No newline at end of file +} + + + + diff --git a/source/FallingBlock.h b/source/FallingBlock.h index 08e3302e1..f62b40a92 100644 --- a/source/FallingBlock.h +++ b/source/FallingBlock.h @@ -15,29 +15,31 @@ class cItem; -class cFallingBlock : public cEntity +class cFallingBlock : + public cEntity { typedef cEntity super; + public: - CLASS_PROTOTYPE(); + CLASS_PROTODEF(cFallingBlock); cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType); - ~cFallingBlock(); virtual void Initialize(cWorld * a_World) override; virtual void SpawnOn(cClientHandle & a_ClientHandle) override; virtual void Tick(float a_Dt) override; + private: BLOCKTYPE m_BlockType; Vector3i m_OriginalPosition; float m_SpeedY; - static bool IsPassable( BLOCKTYPE a_BlockType ) + static bool IsPassable(BLOCKTYPE a_BlockType) { - return a_BlockType == E_BLOCK_AIR || IsBlockLiquid( a_BlockType ); + return ((a_BlockType == E_BLOCK_AIR) || IsBlockLiquid(a_BlockType)); } -}; +} ; diff --git a/source/Mobs/Bat.cpp b/source/Mobs/Bat.cpp index 24ce88184..e77cfd46d 100644 --- a/source/Mobs/Bat.cpp +++ b/source/Mobs/Bat.cpp @@ -16,13 +16,3 @@ cBat::cBat(void) - -bool cBat::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cBat") == 0) || super::IsA(a_EntityType)); -} - - - - - diff --git a/source/Mobs/Bat.h b/source/Mobs/Bat.h index 7965072fc..91279889f 100644 --- a/source/Mobs/Bat.h +++ b/source/Mobs/Bat.h @@ -15,7 +15,7 @@ class cBat : public: cBat(void); - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cBat); } ; diff --git a/source/Mobs/Blaze.cpp b/source/Mobs/Blaze.cpp index e53cbb44d..c3a1fbabf 100644 --- a/source/Mobs/Blaze.cpp +++ b/source/Mobs/Blaze.cpp @@ -17,15 +17,6 @@ cBlaze::cBlaze(void) -bool cBlaze::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cBlaze") == 0) || super::IsA(a_EntityType)); -} - - - - - void cBlaze::GetDrops(cItems & a_Drops, cPawn * a_Killer) { AddRandomDropItem(a_Drops, 0, 1, E_ITEM_BLAZE_ROD); diff --git a/source/Mobs/Blaze.h b/source/Mobs/Blaze.h index 6dca7fed0..a897d7e8a 100644 --- a/source/Mobs/Blaze.h +++ b/source/Mobs/Blaze.h @@ -15,8 +15,8 @@ class cBlaze : public: cBlaze(void); - virtual bool IsA(const char * a_EntityType) override; - + CLASS_PROTODEF(cBlaze); + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; } ; diff --git a/source/Mobs/Cavespider.cpp b/source/Mobs/Cavespider.cpp index 9336f8f5b..94eadf12d 100644 --- a/source/Mobs/Cavespider.cpp +++ b/source/Mobs/Cavespider.cpp @@ -17,18 +17,10 @@ cCavespider::cCavespider(void) -bool cCavespider::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cCaveSpider") == 0) || super::IsA(a_EntityType)); -} - - - - - void cCavespider::Tick(float a_Dt) { super::Tick(a_Dt); + // TODO: Check vanilla if cavespiders really get passive during the day m_EMPersonality = (GetWorld()->GetTimeOfDay() < (12000 + 1000)) ? PASSIVE : AGGRESSIVE; } diff --git a/source/Mobs/Cavespider.h b/source/Mobs/Cavespider.h index 10b462bea..33f67b6f5 100644 --- a/source/Mobs/Cavespider.h +++ b/source/Mobs/Cavespider.h @@ -15,7 +15,7 @@ class cCavespider : public: cCavespider(void); - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cCaveSpider); virtual void Tick(float a_Dt) override; virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; diff --git a/source/Mobs/Chicken.cpp b/source/Mobs/Chicken.cpp index cd282f5ed..fe6526d76 100644 --- a/source/Mobs/Chicken.cpp +++ b/source/Mobs/Chicken.cpp @@ -23,15 +23,6 @@ cChicken::cChicken(void) -bool cChicken::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cChicken") == 0) || super::IsA(a_EntityType)); -} - - - - - void cChicken::GetDrops(cItems & a_Drops, cPawn * a_Killer) { AddRandomDropItem(a_Drops, 0, 2, E_ITEM_FEATHER); diff --git a/source/Mobs/Chicken.h b/source/Mobs/Chicken.h index 49c88a059..ed36df4d5 100644 --- a/source/Mobs/Chicken.h +++ b/source/Mobs/Chicken.h @@ -15,7 +15,7 @@ class cChicken : public: cChicken(void); - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cChicken); virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; } ; diff --git a/source/Mobs/Cow.cpp b/source/Mobs/Cow.cpp index 8e1837434..f6ae5b7da 100644 --- a/source/Mobs/Cow.cpp +++ b/source/Mobs/Cow.cpp @@ -23,15 +23,6 @@ cCow::cCow(void) -bool cCow::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cCow") == 0) || super::IsA(a_EntityType)); -} - - - - - void cCow::GetDrops(cItems & a_Drops, cPawn * a_Killer) { AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER); diff --git a/source/Mobs/Cow.h b/source/Mobs/Cow.h index cc7db7af9..d50c8df08 100644 --- a/source/Mobs/Cow.h +++ b/source/Mobs/Cow.h @@ -15,7 +15,7 @@ class cCow : public: cCow(); - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cCow); virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; } ; diff --git a/source/Mobs/Creeper.cpp b/source/Mobs/Creeper.cpp index d247df96c..e3610198f 100644 --- a/source/Mobs/Creeper.cpp +++ b/source/Mobs/Creeper.cpp @@ -17,15 +17,6 @@ cCreeper::cCreeper(void) -bool cCreeper::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cCreeper") == 0) || super::IsA(a_EntityType)); -} - - - - - void cCreeper::GetDrops(cItems & a_Drops, cPawn * a_Killer) { AddRandomDropItem(a_Drops, 0, 2, E_ITEM_GUNPOWDER); diff --git a/source/Mobs/Creeper.h b/source/Mobs/Creeper.h index bd6b1e992..721847cb5 100644 --- a/source/Mobs/Creeper.h +++ b/source/Mobs/Creeper.h @@ -15,7 +15,7 @@ class cCreeper : public: cCreeper(void); - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cCreeper); virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; } ; diff --git a/source/Mobs/Enderman.cpp b/source/Mobs/Enderman.cpp index b41f8f405..2739265f1 100644 --- a/source/Mobs/Enderman.cpp +++ b/source/Mobs/Enderman.cpp @@ -17,15 +17,6 @@ cEnderman::cEnderman(void) -bool cEnderman::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cEnderman") == 0) || super::IsA(a_EntityType)); -} - - - - - void cEnderman::Tick(float a_Dt) { cMonster::Tick(a_Dt); diff --git a/source/Mobs/Enderman.h b/source/Mobs/Enderman.h index b175e8b1b..adcbe3b4b 100644 --- a/source/Mobs/Enderman.h +++ b/source/Mobs/Enderman.h @@ -15,7 +15,7 @@ class cEnderman : public: cEnderman(void); - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cEnderman); virtual void Tick(float a_Dt) override; virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; diff --git a/source/Mobs/Ghast.cpp b/source/Mobs/Ghast.cpp index 3bcb5e4ab..0e1656b95 100644 --- a/source/Mobs/Ghast.cpp +++ b/source/Mobs/Ghast.cpp @@ -17,15 +17,6 @@ cGhast::cGhast(void) -bool cGhast::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cGhast") == 0) || super::IsA(a_EntityType)); -} - - - - - void cGhast::GetDrops(cItems & a_Drops, cPawn * a_Killer) { AddRandomDropItem(a_Drops, 0, 2, E_ITEM_GUNPOWDER); diff --git a/source/Mobs/Ghast.h b/source/Mobs/Ghast.h index e6248b656..b560d6907 100644 --- a/source/Mobs/Ghast.h +++ b/source/Mobs/Ghast.h @@ -15,7 +15,7 @@ class cGhast : public: cGhast(void); - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cGhast); virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; } ; diff --git a/source/Mobs/Magmacube.cpp b/source/Mobs/Magmacube.cpp index 21c6f17b3..a71463928 100644 --- a/source/Mobs/Magmacube.cpp +++ b/source/Mobs/Magmacube.cpp @@ -17,15 +17,6 @@ cMagmacube::cMagmacube() -bool cMagmacube::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cMagmacube") == 0) || super::IsA(a_EntityType)); -} - - - - - void cMagmacube::GetDrops(cItems & a_Drops, cPawn * a_Killer) { AddRandomDropItem(a_Drops, 0, 1, E_ITEM_MAGMA_CREAM); diff --git a/source/Mobs/Magmacube.h b/source/Mobs/Magmacube.h index 8c61a7853..863ba7072 100644 --- a/source/Mobs/Magmacube.h +++ b/source/Mobs/Magmacube.h @@ -15,7 +15,7 @@ class cMagmacube : public: cMagmacube(); - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cMagmacube); virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; } ; diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 88cfcd992..e79e6c00f 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -58,25 +58,6 @@ cMonster::cMonster(void) -cMonster::~cMonster() -{ - LOGD("cMonster::~cMonster()"); -} - - - - - -bool cMonster::IsA( const char* a_EntityType ) -{ - if( strcmp( a_EntityType, "cMonster" ) == 0 ) return true; - return cPawn::IsA( a_EntityType ); -} - - - - - void cMonster::SpawnOn(cClientHandle & a_Client) { a_Client.SendSpawnMob(*this); diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 6d3d1d775..051477162 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -26,10 +26,9 @@ public: // tolua_end cMonster(void); - virtual ~cMonster(); - - virtual bool IsA(const char * a_EntityType); + CLASS_PROTODEF(cMonster); + virtual void SpawnOn(cClientHandle & a_ClientHandle) override; virtual void Tick(float a_Dt) override; diff --git a/source/Mobs/Mooshroom.cpp b/source/Mobs/Mooshroom.cpp index 0732b3fea..aca32873f 100644 --- a/source/Mobs/Mooshroom.cpp +++ b/source/Mobs/Mooshroom.cpp @@ -23,15 +23,6 @@ cMooshroom::cMooshroom(void) -bool cMooshroom::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cMooshroom") == 0) || super::IsA(a_EntityType)); -} - - - - - void cMooshroom::GetDrops(cItems & a_Drops, cPawn * a_Killer) { AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER); diff --git a/source/Mobs/Mooshroom.h b/source/Mobs/Mooshroom.h index b15bfc76f..c50c04ed8 100644 --- a/source/Mobs/Mooshroom.h +++ b/source/Mobs/Mooshroom.h @@ -15,7 +15,7 @@ class cMooshroom : public: cMooshroom(void); - virtual bool IsA(const char * a_EntityType); + CLASS_PROTODEF(cMooshroom); virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; } ; diff --git a/source/Mobs/Ocelot.cpp b/source/Mobs/Ocelot.cpp index 374161bde..02d5ccc37 100644 --- a/source/Mobs/Ocelot.cpp +++ b/source/Mobs/Ocelot.cpp @@ -16,13 +16,3 @@ cOcelot::cOcelot() - -bool cOcelot::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cOcelot") == 0) || super::IsA(a_EntityType)); -} - - - - - diff --git a/source/Mobs/Ocelot.h b/source/Mobs/Ocelot.h index 07095c660..acda6a1e6 100644 --- a/source/Mobs/Ocelot.h +++ b/source/Mobs/Ocelot.h @@ -15,7 +15,7 @@ class cOcelot : public: cOcelot(); - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cOcelot); } ; diff --git a/source/Mobs/Pig.cpp b/source/Mobs/Pig.cpp index 8abd0a10e..0e0d4e875 100644 --- a/source/Mobs/Pig.cpp +++ b/source/Mobs/Pig.cpp @@ -17,15 +17,6 @@ cPig::cPig(void) -bool cPig::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cPig") == 0) || super::IsA(a_EntityType)); -} - - - - - void cPig::GetDrops(cItems & a_Drops, cPawn * a_Killer) { AddRandomDropItem(a_Drops, 1, 3, (GetMetaData() == BURNING) ? E_ITEM_COOKED_PORKCHOP : E_ITEM_RAW_MEAT); diff --git a/source/Mobs/Pig.h b/source/Mobs/Pig.h index 018477778..995f2a593 100644 --- a/source/Mobs/Pig.h +++ b/source/Mobs/Pig.h @@ -15,7 +15,7 @@ class cPig : public: cPig(void); - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cPig); virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; } ; diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp index 9c67aba29..997184dcf 100644 --- a/source/Mobs/Sheep.cpp +++ b/source/Mobs/Sheep.cpp @@ -20,15 +20,6 @@ cSheep::cSheep(void) : -bool cSheep::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cSheep") == 0) || super::IsA(a_EntityType)); -} - - - - - void cSheep::GetDrops(cItems & a_Drops, cPawn * a_Killer) { if (!m_IsSheared) diff --git a/source/Mobs/Sheep.h b/source/Mobs/Sheep.h index ea43537cc..801cf97d7 100644 --- a/source/Mobs/Sheep.h +++ b/source/Mobs/Sheep.h @@ -18,7 +18,7 @@ public: bool m_IsSheared; NIBBLETYPE m_WoolColor; // Uses E_META_WOOL_ constants for colors - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cSheep); virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; } ; diff --git a/source/Mobs/Silverfish.cpp b/source/Mobs/Silverfish.cpp index 1525966c4..a8ced0b6b 100644 --- a/source/Mobs/Silverfish.cpp +++ b/source/Mobs/Silverfish.cpp @@ -7,19 +7,12 @@ -cSilverfish::cSilverfish() +cSilverfish::cSilverfish(void) { m_MobType = 60; GetMonsterConfig("Silverfish"); } -cSilverfish::~cSilverfish() -{ -} -bool cSilverfish::IsA( const char* a_EntityType ) -{ - if( strcmp( a_EntityType, "cSilverfish" ) == 0 ) return true; - return cMonster::IsA( a_EntityType ); -} + diff --git a/source/Mobs/Silverfish.h b/source/Mobs/Silverfish.h index 453995ec6..4e4fbd11c 100644 --- a/source/Mobs/Silverfish.h +++ b/source/Mobs/Silverfish.h @@ -1,12 +1,23 @@ + #pragma once #include "AggressiveMonster.h" -class cSilverfish : public cAggressiveMonster + + + + +class cSilverfish : + public cAggressiveMonster { + typedef cAggressiveMonster super; + public: - cSilverfish(); - ~cSilverfish(); + cSilverfish(void); + + CLASS_PROTODEF(cSilverfish); +} ; + + + - virtual bool IsA(const char * a_EntityType); -}; diff --git a/source/Mobs/Skeleton.cpp b/source/Mobs/Skeleton.cpp index f219713e0..684e1e13d 100644 --- a/source/Mobs/Skeleton.cpp +++ b/source/Mobs/Skeleton.cpp @@ -17,15 +17,6 @@ cSkeleton::cSkeleton(void) -bool cSkeleton::IsA( const char* a_EntityType ) -{ - return ((strcmp(a_EntityType, "cSkeleton") == 0) || super::IsA(a_EntityType)); -} - - - - - void cSkeleton::Tick(float a_Dt) { cMonster::Tick(a_Dt); diff --git a/source/Mobs/Skeleton.h b/source/Mobs/Skeleton.h index 101358f18..476b438e5 100644 --- a/source/Mobs/Skeleton.h +++ b/source/Mobs/Skeleton.h @@ -15,7 +15,7 @@ class cSkeleton : public: cSkeleton(); - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cSkeleton); virtual void Tick(float a_Dt) override; virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; diff --git a/source/Mobs/Slime.cpp b/source/Mobs/Slime.cpp index d85b97c97..5df887934 100644 --- a/source/Mobs/Slime.cpp +++ b/source/Mobs/Slime.cpp @@ -19,15 +19,6 @@ cSlime::cSlime(void) -bool cSlime::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cSlime") == 0) || super::IsA(a_EntityType)); -} - - - - - void cSlime::GetDrops(cItems & a_Drops, cPawn * a_Killer) { // TODO: only when tiny diff --git a/source/Mobs/Slime.h b/source/Mobs/Slime.h index 1f155e6f8..17bf0807a 100644 --- a/source/Mobs/Slime.h +++ b/source/Mobs/Slime.h @@ -3,15 +3,19 @@ #include "AggressiveMonster.h" + + + + class cSlime : public cAggressiveMonster { typedef cAggressiveMonster super; public: - cSlime(); + cSlime(void); - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cSlime); virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; } ; diff --git a/source/Mobs/Spider.cpp b/source/Mobs/Spider.cpp index 82a24f9b3..1e1338b58 100644 --- a/source/Mobs/Spider.cpp +++ b/source/Mobs/Spider.cpp @@ -17,15 +17,6 @@ cSpider::cSpider() -bool cSpider::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cSpider") == 0) || super::IsA(a_EntityType)); -} - - - - - void cSpider::GetDrops(cItems & a_Drops, cPawn * a_Killer) { AddRandomDropItem(a_Drops, 0, 2, E_ITEM_STRING); diff --git a/source/Mobs/Spider.h b/source/Mobs/Spider.h index c375df593..17a954a02 100644 --- a/source/Mobs/Spider.h +++ b/source/Mobs/Spider.h @@ -13,9 +13,9 @@ class cSpider : typedef cAggressiveMonster super; public: - cSpider(); + cSpider(void); - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cSpider); virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; } ; diff --git a/source/Mobs/Squid.cpp b/source/Mobs/Squid.cpp index 720eb05e5..b3df8711a 100644 --- a/source/Mobs/Squid.cpp +++ b/source/Mobs/Squid.cpp @@ -18,15 +18,6 @@ cSquid::cSquid() -bool cSquid::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cSquid") == 0) || super::IsA(a_EntityType)); -} - - - - - void cSquid::GetDrops(cItems & a_Drops, cPawn * a_Killer) { // Drops 0-3 Ink Sacs diff --git a/source/Mobs/Squid.h b/source/Mobs/Squid.h index 6500a3fea..4a8de4d28 100644 --- a/source/Mobs/Squid.h +++ b/source/Mobs/Squid.h @@ -17,7 +17,8 @@ public: virtual void Tick(float a_Dt) override; - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cSquid); + virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; } ; diff --git a/source/Mobs/Villager.cpp b/source/Mobs/Villager.cpp index 0e6d364d7..c97bb714f 100644 --- a/source/Mobs/Villager.cpp +++ b/source/Mobs/Villager.cpp @@ -16,12 +16,3 @@ cVillager::cVillager() - -bool cVillager::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cVillager") == 0) || super::IsA(a_EntityType)); -} - - - - diff --git a/source/Mobs/Villager.h b/source/Mobs/Villager.h index 74a6af868..4b50ed35e 100644 --- a/source/Mobs/Villager.h +++ b/source/Mobs/Villager.h @@ -15,7 +15,7 @@ class cVillager : public: cVillager(); - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cVillager); } ; diff --git a/source/Mobs/Witch.cpp b/source/Mobs/Witch.cpp index 5077f0cdd..2bbe5b94b 100644 --- a/source/Mobs/Witch.cpp +++ b/source/Mobs/Witch.cpp @@ -17,15 +17,6 @@ cWitch::cWitch() -bool cWitch::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cWitch") == 0) || super::IsA(a_EntityType)); -} - - - - - void cWitch::GetDrops(cItems & a_Drops, cPawn * a_Killer) { AddRandomDropItem(a_Drops, 0, 6, E_ITEM_GLASS_BOTTLE); diff --git a/source/Mobs/Witch.h b/source/Mobs/Witch.h index 2d21037bb..5b8c7ba4f 100644 --- a/source/Mobs/Witch.h +++ b/source/Mobs/Witch.h @@ -15,7 +15,7 @@ class cWitch : public: cWitch(); - virtual bool IsA(const char* a_EntityType) override; + CLASS_PROTODEF(cWitch); virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; } ; diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp index bd7fa213b..5a8ceabbc 100644 --- a/source/Mobs/Wolf.cpp +++ b/source/Mobs/Wolf.cpp @@ -3,18 +3,16 @@ #include "Wolf.h" -cWolf::cWolf() + + + + +cWolf::cWolf(void) { m_MobType = 95; GetMonsterConfig("Wolf"); } -cWolf::~cWolf() -{ -} -bool cWolf::IsA( const char* a_EntityType ) -{ - if( strcmp( a_EntityType, "cWolf" ) == 0 ) return true; - return cMonster::IsA( a_EntityType ); -} + + diff --git a/source/Mobs/Wolf.h b/source/Mobs/Wolf.h index bde5b9d32..5dd7065a7 100644 --- a/source/Mobs/Wolf.h +++ b/source/Mobs/Wolf.h @@ -1,12 +1,23 @@ + #pragma once #include "PassiveAggressiveMonster.h" -class cWolf : public cPassiveAggressiveMonster + + + + +class cWolf : + public cPassiveAggressiveMonster { + typedef cPassiveAggressiveMonster super; + public: - cWolf(); - ~cWolf(); + cWolf(void); + + CLASS_PROTODEF(cWolf); +} ; + + + - virtual bool IsA( const char* a_EntityType ); -}; diff --git a/source/Mobs/Zombie.cpp b/source/Mobs/Zombie.cpp index 5d753c4f8..15e99734b 100644 --- a/source/Mobs/Zombie.cpp +++ b/source/Mobs/Zombie.cpp @@ -17,15 +17,6 @@ cZombie::cZombie() -bool cZombie::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cZombie") == 0) || super::IsA(a_EntityType)); -} - - - - - void cZombie::Tick(float a_Dt) { super::Tick(a_Dt); diff --git a/source/Mobs/Zombie.h b/source/Mobs/Zombie.h index 8256c040a..06bd9244a 100644 --- a/source/Mobs/Zombie.h +++ b/source/Mobs/Zombie.h @@ -14,8 +14,8 @@ class cZombie : public: cZombie(); - virtual bool IsA(const char * a_EntityType) override; - + CLASS_PROTODEF(cZombie); + virtual void Tick(float a_Dt) override; virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; } ; diff --git a/source/Mobs/Zombiepigman.cpp b/source/Mobs/Zombiepigman.cpp index 9d3106829..e917da979 100644 --- a/source/Mobs/Zombiepigman.cpp +++ b/source/Mobs/Zombiepigman.cpp @@ -17,15 +17,6 @@ cZombiepigman::cZombiepigman() -bool cZombiepigman::IsA(const char * a_EntityType) -{ - return ((strcmp(a_EntityType, "cZombiepigman") == 0) || super::IsA(a_EntityType)); -} - - - - - void cZombiepigman::Tick(float a_Dt) { super::Tick(a_Dt); diff --git a/source/Mobs/Zombiepigman.h b/source/Mobs/Zombiepigman.h index 02ad21562..929d03241 100644 --- a/source/Mobs/Zombiepigman.h +++ b/source/Mobs/Zombiepigman.h @@ -13,9 +13,9 @@ class cZombiepigman : typedef cPassiveAggressiveMonster super; public: - cZombiepigman(); + cZombiepigman(void); - virtual bool IsA(const char * a_EntityType) override; + CLASS_PROTODEF(cZombiepigman); virtual void Tick(float a_Dt) override; virtual void GetDrops(cItems & a_Drops, cPawn * a_Killer = NULL) override; diff --git a/source/Pawn.cpp b/source/Pawn.cpp index 8d530abb4..7f6bc2660 100644 --- a/source/Pawn.cpp +++ b/source/Pawn.cpp @@ -15,12 +15,6 @@ -CLASS_DEFINITION( cPawn, cEntity ) - - - - - cPawn::cPawn(void) : cEntity( 0, 0, 0 ) , m_Health(1) @@ -38,15 +32,6 @@ cPawn::cPawn(void) -cPawn::~cPawn() -{ - // Nothing needed yet -} - - - - - void cPawn::Heal(int a_HitPoints) { m_Health += a_HitPoints; diff --git a/source/Pawn.h b/source/Pawn.h index 8c20ee1e6..5a7ace636 100644 --- a/source/Pawn.h +++ b/source/Pawn.h @@ -74,13 +74,14 @@ struct TakeDamageInfo // tolua_begin class cPawn : public cEntity -{ +{ // tolua_end + typedef cEntity super; + public: - CLASS_PROTOTYPE() + CLASS_PROTODEF(cPawn); cPawn(void); - virtual ~cPawn(); virtual void Tick(float a_Dt) override; diff --git a/source/Pickup.cpp b/source/Pickup.cpp index 7ea730708..9dd54c648 100644 --- a/source/Pickup.cpp +++ b/source/Pickup.cpp @@ -24,12 +24,6 @@ -CLASS_DEFINITION( cPickup, cEntity ) - - - - - cPickup::cPickup(int a_X, int a_Y, int a_Z, const cItem & a_Item, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */) : cEntity( ((double)(a_X))/32, ((double)(a_Y))/32, ((double)(a_Z))/32 ) , m_Speed( a_SpeedX, a_SpeedY, a_SpeedZ ) diff --git a/source/Pickup.h b/source/Pickup.h index 56a34c6a6..88b1fc167 100644 --- a/source/Pickup.h +++ b/source/Pickup.h @@ -19,11 +19,9 @@ class cPickup : { // tolua_end typedef cEntity super; - // tolua_begin public: - // tolua_end - CLASS_PROTOTYPE(); + CLASS_PROTODEF(cPickup); cPickup(int a_X, int a_Y, int a_Z, const cItem & a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); //tolua_export ~cPickup(); //tolua_export diff --git a/source/Player.cpp b/source/Player.cpp index 9460bfd97..c5779ef5a 100644 --- a/source/Player.cpp +++ b/source/Player.cpp @@ -32,12 +32,6 @@ -CLASS_DEFINITION( cPlayer, cPawn ); - - - - - cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) : m_GameMode(eGameMode_NotSet) , m_IP("") diff --git a/source/Player.h b/source/Player.h index a220e8fee..1bc166652 100644 --- a/source/Player.h +++ b/source/Player.h @@ -21,6 +21,8 @@ class cClientHandle; class cPlayer : public cPawn { + typedef cPawn super; + public: enum { @@ -30,7 +32,7 @@ public: typedef cPawn super; - CLASS_PROTOTYPE() + CLASS_PROTODEF(cPlayer) cPlayer(cClientHandle * a_Client, const AString & a_PlayerName); virtual ~cPlayer(); -- cgit v1.2.3