1
0

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
This commit is contained in:
madmaxoft@gmail.com 2012-12-21 12:21:20 +00:00
parent 999014170d
commit 033af999ba
60 changed files with 312 additions and 385 deletions

View File

@ -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);

View File

@ -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 */

View File

@ -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);
}

View File

@ -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; }

View File

@ -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 );
}
}
}

View File

@ -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));
}
};
} ;

View File

@ -16,13 +16,3 @@ cBat::cBat(void)
bool cBat::IsA(const char * a_EntityType)
{
return ((strcmp(a_EntityType, "cBat") == 0) || super::IsA(a_EntityType));
}

View File

@ -15,7 +15,7 @@ class cBat :
public:
cBat(void);
virtual bool IsA(const char * a_EntityType) override;
CLASS_PROTODEF(cBat);
} ;

View File

@ -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);

View File

@ -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;
} ;

View File

@ -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;
}

View File

@ -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;

View File

@ -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);

View File

@ -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;
} ;

View File

@ -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);

View File

@ -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;
} ;

View File

@ -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);

View File

@ -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;
} ;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;
} ;

View File

@ -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);

View File

@ -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;
} ;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;
} ;

View File

@ -16,13 +16,3 @@ cOcelot::cOcelot()
bool cOcelot::IsA(const char * a_EntityType)
{
return ((strcmp(a_EntityType, "cOcelot") == 0) || super::IsA(a_EntityType));
}

View File

@ -15,7 +15,7 @@ class cOcelot :
public:
cOcelot();
virtual bool IsA(const char * a_EntityType) override;
CLASS_PROTODEF(cOcelot);
} ;

View File

@ -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);

View File

@ -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;
} ;

View File

@ -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)

View File

@ -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;
} ;

View File

@ -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 );
}

View File

@ -1,12 +1,23 @@
#pragma once
#include "AggressiveMonster.h"
class cSilverfish : public cAggressiveMonster
{
public:
cSilverfish();
~cSilverfish();
virtual bool IsA(const char * a_EntityType);
};
class cSilverfish :
public cAggressiveMonster
{
typedef cAggressiveMonster super;
public:
cSilverfish(void);
CLASS_PROTODEF(cSilverfish);
} ;

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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;
} ;

View File

@ -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);

View File

@ -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;
} ;

View File

@ -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

View File

@ -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;
} ;

View File

@ -16,12 +16,3 @@ cVillager::cVillager()
bool cVillager::IsA(const char * a_EntityType)
{
return ((strcmp(a_EntityType, "cVillager") == 0) || super::IsA(a_EntityType));
}

View File

@ -15,7 +15,7 @@ class cVillager :
public:
cVillager();
virtual bool IsA(const char * a_EntityType) override;
CLASS_PROTODEF(cVillager);
} ;

View File

@ -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);

View File

@ -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;
} ;

View File

@ -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 );
}

View File

@ -1,12 +1,23 @@
#pragma once
#include "PassiveAggressiveMonster.h"
class cWolf : public cPassiveAggressiveMonster
{
public:
cWolf();
~cWolf();
virtual bool IsA( const char* a_EntityType );
};
class cWolf :
public cPassiveAggressiveMonster
{
typedef cPassiveAggressiveMonster super;
public:
cWolf(void);
CLASS_PROTODEF(cWolf);
} ;

View File

@ -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);

View File

@ -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;
} ;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 )

View File

@ -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

View File

@ -32,12 +32,6 @@
CLASS_DEFINITION( cPlayer, cPawn );
cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
: m_GameMode(eGameMode_NotSet)
, m_IP("")

View File

@ -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();