summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/Bindings.cpp224
-rw-r--r--source/Bindings.h2
-rw-r--r--source/Chunk.cpp12
-rw-r--r--source/Entity.cpp6
-rw-r--r--source/Entity.h30
-rw-r--r--source/FallingBlock.cpp2
-rw-r--r--source/Mobs/AggressiveMonster.cpp62
-rw-r--r--source/Mobs/AggressiveMonster.h26
-rw-r--r--source/Mobs/Monster.cpp3
-rw-r--r--source/Mobs/PassiveAggressiveMonster.cpp4
-rw-r--r--source/Mobs/Zombiepigman.cpp2
-rw-r--r--source/Pawn.cpp4
-rw-r--r--source/Pawn.h2
-rw-r--r--source/Pickup.cpp5
-rw-r--r--source/Player.cpp4
15 files changed, 228 insertions, 160 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 2b4282123..d21173aed 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 21:19:57.
+** Generated automatically by tolua++-1.0.92 on 12/21/12 21:44:41.
*/
#ifndef __cplusplus
@@ -4020,7 +4020,7 @@ static int tolua_AllToLua_cEntity_GetEntityType00(lua_State* tolua_S)
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEntityType'", NULL);
#endif
{
- unsigned int tolua_ret = (unsigned int) self->GetEntityType();
+ cEntity::eEntityType tolua_ret = (cEntity::eEntityType) self->GetEntityType();
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
@@ -4033,6 +4033,102 @@ static int tolua_AllToLua_cEntity_GetEntityType00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: IsPlayer of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_IsPlayer00
+static int tolua_AllToLua_cEntity_IsPlayer00(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 'IsPlayer'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsPlayer();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsPlayer'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: IsPickup of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_IsPickup00
+static int tolua_AllToLua_cEntity_IsPickup00(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 'IsPickup'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsPickup();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsPickup'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: IsMob of class cEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_IsMob00
+static int tolua_AllToLua_cEntity_IsMob00(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 'IsMob'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsMob();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsMob'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: IsA of class cEntity */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_IsA00
static int tolua_AllToLua_cEntity_IsA00(lua_State* tolua_S)
@@ -5024,16 +5120,6 @@ public:
return ( void ) cEntity:: Initialize(a_World);
};
};
- 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);
- lua_pop(lua_state, 1);
- return tolua_ret;
- } else {
- return (unsigned int ) cEntity:: GetEntityType();
- };
- };
bool IsA( const char* a_ClassName)const {
if (push_method("IsA", tolua_AllToLua_cEntity_IsA00)) {
tolua_pushstring(lua_state, (const char*)a_ClassName);
@@ -5091,9 +5177,6 @@ public:
void cEntity__Initialize( cWorld* a_World) {
return ( void )cEntity::Initialize(a_World);
};
- unsigned int cEntity__GetEntityType( void ) {
- return (unsigned int )cEntity::GetEntityType();
- };
bool cEntity__IsA( const char* a_ClassName) {
return ( bool )cEntity::IsA(a_ClassName);
};
@@ -5106,7 +5189,7 @@ public:
void cEntity__SpawnOn( cClientHandle& a_Client) {
return ( void )cEntity::SpawnOn(a_Client);
};
- Lua__cEntity( double a_X, double a_Y, double a_Z): cEntity(a_X,a_Y,a_Z){};
+ Lua__cEntity( cEntity::eEntityType a_EntityType, double a_X, double a_Y, double a_Z): cEntity(a_EntityType,a_X,a_Y,a_Z){};
};
/* method: tolua__set_instance of class Lua__cEntity */
@@ -5175,38 +5258,6 @@ static int tolua_AllToLua_Lua__cEntity_cEntity__Initialize00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
-/* method: cEntity__GetEntityType of class Lua__cEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cEntity_cEntity__GetEntityType00
-static int tolua_AllToLua_Lua__cEntity_cEntity__GetEntityType00(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__GetEntityType'", NULL);
-#endif
- {
- unsigned int tolua_ret = (unsigned int) self->cEntity__GetEntityType();
- tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
- }
- }
- return 1;
-#ifndef TOLUA_RELEASE
- tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'cEntity__GetEntityType'.",&tolua_err);
- return 0;
-#endif
-}
-#endif //#ifndef TOLUA_DISABLE
-
/* method: cEntity__IsA of class Lua__cEntity */
#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cEntity_cEntity__IsA00
static int tolua_AllToLua_Lua__cEntity_cEntity__IsA00(lua_State* tolua_S)
@@ -5349,17 +5400,19 @@ static int tolua_AllToLua_Lua__cEntity_new00(lua_State* tolua_S)
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isnumber(tolua_S,4,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,5,&tolua_err)
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- double a_X = ((double) tolua_tonumber(tolua_S,2,0));
- double a_Y = ((double) tolua_tonumber(tolua_S,3,0));
- double a_Z = ((double) tolua_tonumber(tolua_S,4,0));
+ cEntity::eEntityType a_EntityType = ((cEntity::eEntityType) (int) tolua_tonumber(tolua_S,2,0));
+ double a_X = ((double) tolua_tonumber(tolua_S,3,0));
+ double a_Y = ((double) tolua_tonumber(tolua_S,4,0));
+ double a_Z = ((double) tolua_tonumber(tolua_S,5,0));
{
- Lua__cEntity* tolua_ret = (Lua__cEntity*) Mtolua_new((Lua__cEntity)(a_X,a_Y,a_Z));
+ Lua__cEntity* tolua_ret = (Lua__cEntity*) Mtolua_new((Lua__cEntity)(a_EntityType,a_X,a_Y,a_Z));
tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cEntity");
}
}
@@ -5383,17 +5436,19 @@ static int tolua_AllToLua_Lua__cEntity_new00_local(lua_State* tolua_S)
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isnumber(tolua_S,4,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,5,&tolua_err)
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- double a_X = ((double) tolua_tonumber(tolua_S,2,0));
- double a_Y = ((double) tolua_tonumber(tolua_S,3,0));
- double a_Z = ((double) tolua_tonumber(tolua_S,4,0));
+ cEntity::eEntityType a_EntityType = ((cEntity::eEntityType) (int) tolua_tonumber(tolua_S,2,0));
+ double a_X = ((double) tolua_tonumber(tolua_S,3,0));
+ double a_Y = ((double) tolua_tonumber(tolua_S,4,0));
+ double a_Z = ((double) tolua_tonumber(tolua_S,5,0));
{
- Lua__cEntity* tolua_ret = (Lua__cEntity*) Mtolua_new((Lua__cEntity)(a_X,a_Y,a_Z));
+ Lua__cEntity* tolua_ret = (Lua__cEntity*) Mtolua_new((Lua__cEntity)(a_EntityType,a_X,a_Y,a_Z));
tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cEntity");
tolua_register_gc(tolua_S,lua_gettop(tolua_S));
}
@@ -6347,16 +6402,6 @@ public:
return ( void ) cPawn:: Initialize(a_World);
};
};
- 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);
- lua_pop(lua_state, 1);
- return tolua_ret;
- } else {
- return (unsigned int ) cPawn:: GetEntityType();
- };
- };
bool IsA( const char* a_ClassName)const {
if (push_method("IsA", tolua_AllToLua_cEntity_IsA00)) {
tolua_pushstring(lua_state, (const char*)a_ClassName);
@@ -6450,9 +6495,6 @@ public:
void cPawn__Initialize( cWorld* a_World) {
return ( void )cPawn::Initialize(a_World);
};
- unsigned int cPawn__GetEntityType( void ) {
- return (unsigned int )cPawn::GetEntityType();
- };
bool cPawn__IsA( const char* a_ClassName) {
return ( bool )cPawn::IsA(a_ClassName);
};
@@ -8349,16 +8391,6 @@ public:
return ( cItem ) cPlayer:: GetEquippedBoots();
};
};
- 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);
- lua_pop(lua_state, 1);
- return tolua_ret;
- } else {
- return (unsigned int ) cPlayer:: GetEntityType();
- };
- };
bool IsA( const char* a_ClassName)const {
if (push_method("IsA", tolua_AllToLua_cEntity_IsA00)) {
tolua_pushstring(lua_state, (const char*)a_ClassName);
@@ -8455,9 +8487,6 @@ public:
cItem cPlayer__GetEquippedBoots( void ) {
return ( cItem )cPlayer::GetEquippedBoots();
};
- unsigned int cPlayer__GetEntityType( void ) {
- return (unsigned int )cPlayer::GetEntityType();
- };
bool cPlayer__IsA( const char* a_ClassName) {
return ( bool )cPlayer::IsA(a_ClassName);
};
@@ -16115,16 +16144,6 @@ public:
return ( void ) cPickup:: Initialize(a_World);
};
};
- 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);
- lua_pop(lua_state, 1);
- return tolua_ret;
- } else {
- return (unsigned int ) cPickup:: GetEntityType();
- };
- };
bool IsA( const char* a_ClassName)const {
if (push_method("IsA", tolua_AllToLua_cEntity_IsA00)) {
tolua_pushstring(lua_state, (const char*)a_ClassName);
@@ -16185,9 +16204,6 @@ public:
void cPickup__Initialize( cWorld* a_World) {
return ( void )cPickup::Initialize(a_World);
};
- unsigned int cPickup__GetEntityType( void ) {
- return (unsigned int )cPickup::GetEntityType();
- };
bool cPickup__IsA( const char* a_ClassName) {
return ( bool )cPickup::IsA(a_ClassName);
};
@@ -24000,12 +24016,21 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"ENTITY_STATUS_WOLF_SHAKING",cEntity::ENTITY_STATUS_WOLF_SHAKING);
tolua_constant(tolua_S,"ENTITY_STATUS_EATING_ACCEPTED",cEntity::ENTITY_STATUS_EATING_ACCEPTED);
tolua_constant(tolua_S,"ENTITY_STATUS_SHEEP_EATING",cEntity::ENTITY_STATUS_SHEEP_EATING);
- tolua_function(tolua_S,"delete",tolua_AllToLua_cEntity_delete00);
- tolua_function(tolua_S,"Initialize",tolua_AllToLua_cEntity_Initialize00);
+ tolua_constant(tolua_S,"etEntity",cEntity::etEntity);
+ tolua_constant(tolua_S,"etPlayer",cEntity::etPlayer);
+ tolua_constant(tolua_S,"etPickup",cEntity::etPickup);
+ tolua_constant(tolua_S,"etMob",cEntity::etMob);
+ tolua_constant(tolua_S,"etFallingBlock",cEntity::etFallingBlock);
tolua_constant(tolua_S,"eEntityType_Entity",cEntity::eEntityType_Entity);
tolua_constant(tolua_S,"eEntityType_Player",cEntity::eEntityType_Player);
tolua_constant(tolua_S,"eEntityType_Pickup",cEntity::eEntityType_Pickup);
+ tolua_constant(tolua_S,"eEntityType_Mob",cEntity::eEntityType_Mob);
+ tolua_function(tolua_S,"delete",tolua_AllToLua_cEntity_delete00);
+ tolua_function(tolua_S,"Initialize",tolua_AllToLua_cEntity_Initialize00);
tolua_function(tolua_S,"GetEntityType",tolua_AllToLua_cEntity_GetEntityType00);
+ tolua_function(tolua_S,"IsPlayer",tolua_AllToLua_cEntity_IsPlayer00);
+ tolua_function(tolua_S,"IsPickup",tolua_AllToLua_cEntity_IsPickup00);
+ tolua_function(tolua_S,"IsMob",tolua_AllToLua_cEntity_IsMob00);
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);
@@ -24045,7 +24070,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_beginmodule(tolua_S,"Lua__cEntity");
tolua_function(tolua_S,"tolua__set_instance",tolua_AllToLua_Lua__cEntity_tolua__set_instance00);
tolua_function(tolua_S,"cEntity__Initialize",tolua_AllToLua_Lua__cEntity_cEntity__Initialize00);
- 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);
diff --git a/source/Bindings.h b/source/Bindings.h
index f6ae8790c..04e5cd8ec 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 21:19:58.
+** Generated automatically by tolua++-1.0.92 on 12/21/12 21:44:41.
*/
/* Exported function */
diff --git a/source/Chunk.cpp b/source/Chunk.cpp
index 5dc19915a..165eda831 100644
--- a/source/Chunk.cpp
+++ b/source/Chunk.cpp
@@ -115,7 +115,7 @@ cChunk::~cChunk()
cEntityList Entities;
for (cEntityList::const_iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
{
- if ((*itr)->GetEntityType() != cEntity::eEntityType_Player)
+ if (!(*itr)->IsPlayer())
{
Entities.push_back(*itr);
}
@@ -1382,7 +1382,7 @@ void cChunk::CollectPickupsByPlayer(cPlayer * a_Player)
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
{
- if ( (*itr)->GetEntityType() != cEntity::eEntityType_Pickup )
+ if (!(*itr)->IsPickup())
{
continue; // Only pickups
}
@@ -1515,13 +1515,13 @@ bool cChunk::HasAnyClients(void)
-void cChunk::AddEntity( cEntity * a_Entity)
+void cChunk::AddEntity(cEntity * a_Entity)
{
- if (a_Entity->GetEntityType() != cEntity::eEntityType_Player)
+ if (!a_Entity->IsPlayer())
{
MarkDirty();
}
- m_Entities.push_back( a_Entity );
+ m_Entities.push_back(a_Entity);
}
@@ -1537,7 +1537,7 @@ void cChunk::RemoveEntity(cEntity * a_Entity)
if (SizeBefore != SizeAfter)
{
// Mark as dirty if it was a server-generated entity:
- if (a_Entity->GetEntityType() != cEntity::eEntityType_Player)
+ if (!a_Entity->IsPlayer())
{
MarkDirty();
}
diff --git a/source/Entity.cpp b/source/Entity.cpp
index a2e0c4a27..381a62e42 100644
--- a/source/Entity.cpp
+++ b/source/Entity.cpp
@@ -22,7 +22,7 @@ cCriticalSection cEntity::m_CSCount;
-cEntity::cEntity(double a_X, double a_Y, double a_Z)
+cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z)
: m_UniqueID( 0 )
, m_Referencers( new cReferenceManager( cReferenceManager::RFMNGR_REFERENCERS ) )
, m_References( new cReferenceManager( cReferenceManager::RFMNGR_REFERENCES ) )
@@ -33,8 +33,8 @@ cEntity::cEntity(double a_X, double a_Y, double a_Z)
, m_bDirtyPosition( true )
, m_bDirtyOrientation( true )
, m_bDestroyed( false )
- , m_EntityType( eEntityType_Entity )
- , m_World( 0 )
+ , m_EntityType(a_EntityType)
+ , m_World(NULL)
, m_bRemovedFromChunk( false )
, m_FireDamageInterval(0.f)
, m_BurnPeriod(0.f)
diff --git a/source/Entity.h b/source/Entity.h
index 7cb168581..132679db2 100644
--- a/source/Entity.h
+++ b/source/Entity.h
@@ -77,19 +77,31 @@ public:
ENTITY_STATUS_SHEEP_EATING = 10,
} ;
- cEntity(double a_X, double a_Y, double a_Z);
+ enum eEntityType
+ {
+ etEntity, // For all other types
+ etPlayer,
+ etPickup,
+ etMob,
+ etFallingBlock,
+
+ // Older constants, left over for compatibility reasons (plugins)
+ eEntityType_Entity = etEntity,
+ eEntityType_Player = etPlayer,
+ eEntityType_Pickup = etPickup,
+ eEntityType_Mob = etMob,
+ } ;
+
+ cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z);
virtual ~cEntity();
virtual void Initialize(cWorld * a_World);
- enum eEntityType
- {
- eEntityType_Entity,
- eEntityType_Player,
- eEntityType_Pickup
- };
-
- virtual unsigned int GetEntityType(void) const { return m_EntityType; }
+ eEntityType GetEntityType(void) const { return m_EntityType; }
+
+ bool IsPlayer(void) const { return (m_EntityType == etPlayer); }
+ bool IsPickup(void) const { return (m_EntityType == etPickup); }
+ bool IsMob (void) const { return (m_EntityType == etMob); }
/// 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;
diff --git a/source/FallingBlock.cpp b/source/FallingBlock.cpp
index 93eac0815..006acd6e2 100644
--- a/source/FallingBlock.cpp
+++ b/source/FallingBlock.cpp
@@ -9,7 +9,7 @@
cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType)
- : super( a_BlockPosition.x + 0.5f, a_BlockPosition.y + 0.5f, a_BlockPosition.z + 0.5f )
+ : super(etFallingBlock, a_BlockPosition.x + 0.5f, a_BlockPosition.y + 0.5f, a_BlockPosition.z + 0.5f )
, m_BlockType( a_BlockType )
, m_OriginalPosition( a_BlockPosition )
, m_SpeedY( 0 )
diff --git a/source/Mobs/AggressiveMonster.cpp b/source/Mobs/AggressiveMonster.cpp
index d178ce8f8..eabfb6669 100644
--- a/source/Mobs/AggressiveMonster.cpp
+++ b/source/Mobs/AggressiveMonster.cpp
@@ -8,26 +8,30 @@
#include "../MersenneTwister.h"
+
+
+
cAggressiveMonster::cAggressiveMonster()
: m_ChaseTime(999999)
{
m_EMPersonality = AGGRESSIVE;
}
-cAggressiveMonster::~cAggressiveMonster()
-{
-}
-//What to do if in Chasing State
-void cAggressiveMonster::InStateChasing(float a_Dt) {
- cMonster::InStateChasing(a_Dt);
+
+
+
+// What to do if in Chasing State
+void cAggressiveMonster::InStateChasing(float a_Dt)
+{
+ super::InStateChasing(a_Dt);
m_ChaseTime += a_Dt;
- if( m_Target )
+ if (m_Target != NULL)
{
- if(m_Target->GetEntityType() == cEntity::eEntityType_Player)
+ if (m_Target->IsPlayer())
{
cPlayer * Player = (cPlayer *) m_Target;
- if(Player->GetGameMode() == 1)
+ if (Player->GetGameMode() == 1)
{
m_EMState = IDLE;
return;
@@ -36,11 +40,14 @@ void cAggressiveMonster::InStateChasing(float a_Dt) {
Vector3f Pos = Vector3f( m_Pos );
Vector3f Their = Vector3f( m_Target->GetPosition() );
- if( (Their - Pos).Length() <= m_AttackRange) {
+ if ((Their - Pos).Length() <= m_AttackRange)
+ {
cMonster::Attack(a_Dt);
}
- MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
- } else if( m_ChaseTime > 5.f ) {
+ MoveToPosition(Their + Vector3f(0, 0.65f, 0));
+ }
+ else if (m_ChaseTime > 5.f)
+ {
m_ChaseTime = 0;
m_EMState = IDLE;
}
@@ -48,31 +55,44 @@ void cAggressiveMonster::InStateChasing(float a_Dt) {
-void cAggressiveMonster::EventSeePlayer(cEntity *a_Entity)
+
+
+void cAggressiveMonster::EventSeePlayer(cEntity * a_Entity)
{
- cMonster::EventSeePlayer(a_Entity);
+ super::EventSeePlayer(a_Entity);
m_EMState = CHASING;
}
+
+
+
+
void cAggressiveMonster::Tick(float a_Dt)
{
- cMonster::Tick(a_Dt);
+ super::Tick(a_Dt);
m_SeePlayerInterval += a_Dt;
- if(m_SeePlayerInterval > 1)
+ if (m_SeePlayerInterval > 1)
{
MTRand r1;
- int rem = r1.randInt() % 3 + 1; //check most of the time but miss occasionally
+ int rem = r1.randInt() % 3 + 1; // Check most of the time but miss occasionally
m_SeePlayerInterval = 0.0;
- if(rem >= 2)
+ if (rem >= 2)
{
- if(m_EMState == CHASING){
+ if (m_EMState == CHASING)
+ {
CheckEventLostPlayer();
- } else {
+ }
+ else
+ {
CheckEventSeePlayer();
}
}
}
-} \ No newline at end of file
+}
+
+
+
+
diff --git a/source/Mobs/AggressiveMonster.h b/source/Mobs/AggressiveMonster.h
index 7d741dc9a..f71da7b3c 100644
--- a/source/Mobs/AggressiveMonster.h
+++ b/source/Mobs/AggressiveMonster.h
@@ -1,17 +1,29 @@
+
#pragma once
#include "Monster.h"
-class cAggressiveMonster : public cMonster
+
+
+
+
+class cAggressiveMonster :
+ public cMonster
{
+ typedef cMonster super;
+
public:
- cAggressiveMonster();
- ~cAggressiveMonster();
+ cAggressiveMonster(void);
- virtual void Tick(float a_Dt);
- virtual void InStateChasing(float a_Dt);
+ virtual void Tick(float a_Dt) override;
+ virtual void InStateChasing(float a_Dt) override;
+
+ virtual void EventSeePlayer(cEntity *) override;
- virtual void EventSeePlayer(cEntity *);
protected:
float m_ChaseTime;
-};
+} ;
+
+
+
+
diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp
index e79e6c00f..6c9b870e1 100644
--- a/source/Mobs/Monster.cpp
+++ b/source/Mobs/Monster.cpp
@@ -29,7 +29,8 @@
cMonster::cMonster(void)
- : m_Target(NULL)
+ : super(etMob)
+ , m_Target(NULL)
, m_bMovingToDestination(false)
, m_DestinationTime( 0 )
, m_Gravity( -9.81f)
diff --git a/source/Mobs/PassiveAggressiveMonster.cpp b/source/Mobs/PassiveAggressiveMonster.cpp
index 465c302a1..b5ef7aa97 100644
--- a/source/Mobs/PassiveAggressiveMonster.cpp
+++ b/source/Mobs/PassiveAggressiveMonster.cpp
@@ -20,7 +20,9 @@ cPassiveAggressiveMonster::cPassiveAggressiveMonster(void)
void cPassiveAggressiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
{
- if ((m_Target != NULL) && (m_Target->GetEntityType() == cEntity::eEntityType_Player))
+ super::DoTakeDamage(a_TDI);
+
+ if ((m_Target != NULL) && (m_Target->IsPlayer()))
{
cPlayer * Player = (cPlayer *) m_Target;
if (Player->GetGameMode() != 1)
diff --git a/source/Mobs/Zombiepigman.cpp b/source/Mobs/Zombiepigman.cpp
index e917da979..37cf02925 100644
--- a/source/Mobs/Zombiepigman.cpp
+++ b/source/Mobs/Zombiepigman.cpp
@@ -48,7 +48,7 @@ void cZombiepigman::KilledBy(cPawn * a_Killer)
{
super::KilledBy(a_Killer);
- if ((a_Killer != NULL) && (a_Killer->GetEntityType() == eEntityType_Player))
+ if ((a_Killer != NULL) && (a_Killer->IsPlayer()))
{
// TODO: Anger all nearby zombie pigmen
// TODO: In vanilla, if one player angers ZPs, do they attack any nearby player, or only that one attacker?
diff --git a/source/Pawn.cpp b/source/Pawn.cpp
index 7f6bc2660..a26d80699 100644
--- a/source/Pawn.cpp
+++ b/source/Pawn.cpp
@@ -15,8 +15,8 @@
-cPawn::cPawn(void)
- : cEntity( 0, 0, 0 )
+cPawn::cPawn(eEntityType a_EntityType)
+ : cEntity(a_EntityType, 0, 0, 0)
, m_Health(1)
, m_MaxHealth(1)
, m_LastPosX( 0.0 )
diff --git a/source/Pawn.h b/source/Pawn.h
index 5a7ace636..a8a25c04f 100644
--- a/source/Pawn.h
+++ b/source/Pawn.h
@@ -81,7 +81,7 @@ class cPawn :
public:
CLASS_PROTODEF(cPawn);
- cPawn(void);
+ cPawn(eEntityType a_EntityType);
virtual void Tick(float a_Dt) override;
diff --git a/source/Pickup.cpp b/source/Pickup.cpp
index 9dd54c648..3034e73de 100644
--- a/source/Pickup.cpp
+++ b/source/Pickup.cpp
@@ -25,7 +25,7 @@
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 )
+ : cEntity(etPickup, ((double)(a_X))/32, ((double)(a_Y))/32, ((double)(a_Z))/32 )
, m_Speed( a_SpeedX, a_SpeedY, a_SpeedZ )
, m_bOnGround( false )
, m_bReplicated( false )
@@ -33,9 +33,6 @@ cPickup::cPickup(int a_X, int a_Y, int a_Z, const cItem & a_Item, float a_SpeedX
, m_Item( new cItem( a_Item ) )
, m_bCollected( false )
{
- // LOGD("New pickup: ID(%i) Amount(%i) Health(%i)", m_Item.m_ItemID, m_Item.m_ItemCount, m_Item.m_ItemHealth );
-
- m_EntityType = eEntityType_Pickup;
}
diff --git a/source/Player.cpp b/source/Player.cpp
index c5779ef5a..a5d915572 100644
--- a/source/Player.cpp
+++ b/source/Player.cpp
@@ -33,7 +33,8 @@
cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
- : m_GameMode(eGameMode_NotSet)
+ : super(etPlayer)
+ , m_GameMode(eGameMode_NotSet)
, m_IP("")
, m_LastBlockActionTime( 0 )
, m_LastBlockActionCnt( 0 )
@@ -54,7 +55,6 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
a_PlayerName.c_str(), a_Client->GetIPString().c_str(),
this, GetUniqueID()
);
- m_EntityType = eEntityType_Player;
m_InventoryWindow = new cInventoryWindow(*this);
m_CurrentWindow = m_InventoryWindow;