From 4ce0c5a983bbb82a0a8091ad735c6ec494c912e2 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Thu, 21 Feb 2013 21:55:36 +0000 Subject: Moved the Speed member into cEntity class instead of its descendants. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1222 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Bindings.cpp | 483 ++++++++++----------------------- source/Bindings.h | 2 +- source/ClientHandle.cpp | 4 +- source/ClientHandle.h | 2 +- source/Entity.h | 14 +- source/FallingBlock.cpp | 17 +- source/FallingBlock.h | 2 - source/Mobs/Monster.h | 1 - source/Pickup.cpp | 2 +- source/Pickup.h | 7 +- source/Protocol/Protocol.h | 2 +- source/Protocol/Protocol125.cpp | 10 +- source/Protocol/Protocol125.h | 2 +- source/Protocol/Protocol14x.cpp | 9 +- source/Protocol/Protocol14x.h | 2 +- source/Protocol/ProtocolRecognizer.cpp | 4 +- source/Protocol/ProtocolRecognizer.h | 2 +- 17 files changed, 180 insertions(+), 385 deletions(-) diff --git a/source/Bindings.cpp b/source/Bindings.cpp index e8a277fb0..e1cfed435 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 02/21/13 14:08:40. +** Generated automatically by tolua++-1.0.92 on 02/21/13 15:20:08. */ #ifndef __cplusplus @@ -85,9 +85,9 @@ static int tolua_collect_cPickup (lua_State* tolua_S) return 0; } -static int tolua_collect_cEntity (lua_State* tolua_S) +static int tolua_collect_cTracer (lua_State* tolua_S) { - cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0); + cTracer* self = (cTracer*) tolua_tousertype(tolua_S,1,0); Mtolua_delete(self); return 0; } @@ -106,13 +106,6 @@ static int tolua_collect_cCuboid (lua_State* tolua_S) return 0; } -static int tolua_collect_cBlockArea (lua_State* tolua_S) -{ - cBlockArea* self = (cBlockArea*) tolua_tousertype(tolua_S,1,0); - Mtolua_delete(self); - return 0; -} - static int tolua_collect_Vector3i (lua_State* tolua_S) { Vector3i* self = (Vector3i*) tolua_tousertype(tolua_S,1,0); @@ -120,9 +113,9 @@ static int tolua_collect_Vector3i (lua_State* tolua_S) return 0; } -static int tolua_collect_cTracer (lua_State* tolua_S) +static int tolua_collect_cBlockArea (lua_State* tolua_S) { - cTracer* self = (cTracer*) tolua_tousertype(tolua_S,1,0); + cBlockArea* self = (cBlockArea*) tolua_tousertype(tolua_S,1,0); Mtolua_delete(self); return 0; } @@ -3918,141 +3911,6 @@ static int tolua_AllToLua_cClientHandle_GetUniqueID00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* method: new of class cEntity */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_new00 -static int tolua_AllToLua_cEntity_new00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"cEntity",0,&tolua_err) || - !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_isnumber(tolua_S,5,0,&tolua_err) || - !tolua_isnoobj(tolua_S,6,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - 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)); - { - cEntity* tolua_ret = (cEntity*) Mtolua_new((cEntity)(a_EntityType,a_X,a_Y,a_Z)); - tolua_pushusertype(tolua_S,(void*)tolua_ret,"cEntity"); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: new_local of class cEntity */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_new00_local -static int tolua_AllToLua_cEntity_new00_local(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"cEntity",0,&tolua_err) || - !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_isnumber(tolua_S,5,0,&tolua_err) || - !tolua_isnoobj(tolua_S,6,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - 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)); - { - cEntity* tolua_ret = (cEntity*) Mtolua_new((cEntity)(a_EntityType,a_X,a_Y,a_Z)); - tolua_pushusertype(tolua_S,(void*)tolua_ret,"cEntity"); - tolua_register_gc(tolua_S,lua_gettop(tolua_S)); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: delete of class cEntity */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_delete00 -static int tolua_AllToLua_cEntity_delete00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"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); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL); -#endif - Mtolua_delete(self); - } - return 0; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: Initialize of class cEntity */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_Initialize00 -static int tolua_AllToLua_cEntity_Initialize00(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,2,"cWorld",0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - cEntity* self = (cEntity*) tolua_tousertype(tolua_S,1,0); - cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Initialize'", NULL); -#endif - { - self->Initialize(a_World); - } - } - return 0; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'Initialize'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - /* method: GetEntityType of class cEntity */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetEntityType00 static int tolua_AllToLua_cEntity_GetEntityType00(lua_State* tolua_S) @@ -4637,6 +4495,134 @@ static int tolua_AllToLua_cEntity_GetLookVector00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* method: GetSpeed of class cEntity */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetSpeed00 +static int tolua_AllToLua_cEntity_GetSpeed00(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 'GetSpeed'", NULL); +#endif + { + const Vector3d& tolua_ret = (const Vector3d&) self->GetSpeed(); + tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const Vector3d"); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetSpeed'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetSpeedX of class cEntity */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetSpeedX00 +static int tolua_AllToLua_cEntity_GetSpeedX00(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 'GetSpeedX'", NULL); +#endif + { + double tolua_ret = (double) self->GetSpeedX(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetSpeedX'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetSpeedY of class cEntity */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetSpeedY00 +static int tolua_AllToLua_cEntity_GetSpeedY00(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 'GetSpeedY'", NULL); +#endif + { + double tolua_ret = (double) self->GetSpeedY(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetSpeedY'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetSpeedZ of class cEntity */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetSpeedZ00 +static int tolua_AllToLua_cEntity_GetSpeedZ00(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 'GetSpeedZ'", NULL); +#endif + { + double tolua_ret = (double) self->GetSpeedZ(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetSpeedZ'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* method: GetChunkX of class cEntity */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_GetChunkX00 static int tolua_AllToLua_cEntity_GetChunkX00(lua_State* tolua_S) @@ -5227,14 +5213,6 @@ static int tolua_AllToLua_cEntity_SpawnOn00(lua_State* tolua_S) class Lua__cEntity : public cEntity, public ToluaBase { public: - void Initialize( cWorld* a_World) { - if (push_method("Initialize", tolua_AllToLua_cEntity_Initialize00)) { - tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); - ToluaBase::dbcall(lua_state, 2, 0); - } else { - return ( void ) cEntity:: Initialize(a_World); - }; - }; bool IsA( const char* a_ClassName)const { if (push_method("IsA", tolua_AllToLua_cEntity_IsA00)) { tolua_pushstring(lua_state, (const char*)a_ClassName); @@ -5292,9 +5270,6 @@ public: }; }; - void cEntity__Initialize( cWorld* a_World) { - return ( void )cEntity::Initialize(a_World); - }; bool cEntity__IsA( const char* a_ClassName) { return ( bool )cEntity::IsA(a_ClassName); }; @@ -5313,7 +5288,6 @@ public: void cEntity__SpawnOn( cClientHandle& a_Client) { return ( void )cEntity::SpawnOn(a_Client); }; - 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 */ @@ -5349,39 +5323,6 @@ static int tolua_AllToLua_Lua__cEntity_tolua__set_instance00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* method: cEntity__Initialize of class Lua__cEntity */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cEntity_cEntity__Initialize00 -static int tolua_AllToLua_Lua__cEntity_cEntity__Initialize00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"Lua__cEntity",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - Lua__cEntity* self = (Lua__cEntity*) tolua_tousertype(tolua_S,1,0); - cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cEntity__Initialize'", NULL); -#endif - { - self->cEntity__Initialize(a_World); - } - } - return 0; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cEntity__Initialize'.",&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) @@ -5581,120 +5522,6 @@ static int tolua_AllToLua_Lua__cEntity_cEntity__SpawnOn00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* method: new of class Lua__cEntity */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cEntity_new00 -static int tolua_AllToLua_Lua__cEntity_new00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"Lua__cEntity",0,&tolua_err) || - !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_isnumber(tolua_S,5,0,&tolua_err) || - !tolua_isnoobj(tolua_S,6,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - 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_EntityType,a_X,a_Y,a_Z)); - tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cEntity"); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: new_local of class Lua__cEntity */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cEntity_new00_local -static int tolua_AllToLua_Lua__cEntity_new00_local(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"Lua__cEntity",0,&tolua_err) || - !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_isnumber(tolua_S,5,0,&tolua_err) || - !tolua_isnoobj(tolua_S,6,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - 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_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)); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: delete of class Lua__cEntity */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cEntity_delete00 -static int tolua_AllToLua_Lua__cEntity_delete00(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 'delete'", NULL); -#endif - Mtolua_delete(self); - } - return 0; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - - -/* function to release collected object via destructor */ -#ifdef __cplusplus - -static int tolua_collect_Lua__cEntity (lua_State* tolua_S) -{ - Lua__cEntity* self = (Lua__cEntity*) tolua_tousertype(tolua_S,1,0); - delete self; - return 0; -} -#endif - /* get function: DamageType of class TakeDamageInfo */ #ifndef TOLUA_DISABLE_tolua_get_TakeDamageInfo_DamageType static int tolua_get_TakeDamageInfo_DamageType(lua_State* tolua_S) @@ -6585,14 +6412,6 @@ public: } else { return ( cItem ) cPawn:: GetEquippedBoots(); }; - }; - void Initialize( cWorld* a_World) { - if (push_method("Initialize", tolua_AllToLua_cEntity_Initialize00)) { - tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); - ToluaBase::dbcall(lua_state, 2, 0); - } else { - return ( void ) cPawn:: Initialize(a_World); - }; }; bool IsA( const char* a_ClassName)const { if (push_method("IsA", tolua_AllToLua_cEntity_IsA00)) { @@ -6686,9 +6505,6 @@ public: }; cItem cPawn__GetEquippedBoots( void ) { return ( cItem )cPawn::GetEquippedBoots(); - }; - void cPawn__Initialize( cWorld* a_World) { - return ( void )cPawn::Initialize(a_World); }; bool cPawn__IsA( const char* a_ClassName) { return ( bool )cPawn::IsA(a_ClassName); @@ -13562,14 +13378,6 @@ public: } else { return ( bool ) cPickup:: CollectedBy(a_Dest); }; - }; - void Initialize( cWorld* a_World) { - if (push_method("Initialize", tolua_AllToLua_cEntity_Initialize00)) { - tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); - ToluaBase::dbcall(lua_state, 2, 0); - } else { - return ( void ) cPickup:: Initialize(a_World); - }; }; bool IsA( const char* a_ClassName)const { if (push_method("IsA", tolua_AllToLua_cEntity_IsA00)) { @@ -13630,9 +13438,6 @@ public: bool cPickup__CollectedBy( cPlayer* a_Dest) { return ( bool )cPickup::CollectedBy(a_Dest); - }; - void cPickup__Initialize( cWorld* a_World) { - return ( void )cPickup::Initialize(a_World); }; bool cPickup__IsA( const char* a_ClassName) { return ( bool )cPickup::IsA(a_ClassName); @@ -21930,11 +21735,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"GetViewDistance",tolua_AllToLua_cClientHandle_GetViewDistance00); tolua_function(tolua_S,"GetUniqueID",tolua_AllToLua_cClientHandle_GetUniqueID00); tolua_endmodule(tolua_S); - #ifdef __cplusplus - tolua_cclass(tolua_S,"cEntity","cEntity","",tolua_collect_cEntity); - #else tolua_cclass(tolua_S,"cEntity","cEntity","",NULL); - #endif tolua_beginmodule(tolua_S,"cEntity"); tolua_constant(tolua_S,"ENTITY_STATUS_HURT",cEntity::ENTITY_STATUS_HURT); tolua_constant(tolua_S,"ENTITY_STATUS_DEAD",cEntity::ENTITY_STATUS_DEAD); @@ -21953,11 +21754,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) 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,"new",tolua_AllToLua_cEntity_new00); - tolua_function(tolua_S,"new_local",tolua_AllToLua_cEntity_new00_local); - tolua_function(tolua_S,".call",tolua_AllToLua_cEntity_new00_local); - 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); @@ -21976,6 +21772,10 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"GetPitch",tolua_AllToLua_cEntity_GetPitch00); tolua_function(tolua_S,"GetRoll",tolua_AllToLua_cEntity_GetRoll00); tolua_function(tolua_S,"GetLookVector",tolua_AllToLua_cEntity_GetLookVector00); + tolua_function(tolua_S,"GetSpeed",tolua_AllToLua_cEntity_GetSpeed00); + tolua_function(tolua_S,"GetSpeedX",tolua_AllToLua_cEntity_GetSpeedX00); + tolua_function(tolua_S,"GetSpeedY",tolua_AllToLua_cEntity_GetSpeedY00); + tolua_function(tolua_S,"GetSpeedZ",tolua_AllToLua_cEntity_GetSpeedZ00); tolua_function(tolua_S,"GetChunkX",tolua_AllToLua_cEntity_GetChunkX00); tolua_function(tolua_S,"GetChunkY",tolua_AllToLua_cEntity_GetChunkY00); tolua_function(tolua_S,"GetChunkZ",tolua_AllToLua_cEntity_GetChunkZ00); @@ -21995,24 +21795,15 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"HandlePhysics",tolua_AllToLua_cEntity_HandlePhysics00); tolua_function(tolua_S,"SpawnOn",tolua_AllToLua_cEntity_SpawnOn00); tolua_endmodule(tolua_S); - #ifdef __cplusplus - tolua_cclass(tolua_S,"Lua__cEntity","Lua__cEntity","cEntity",tolua_collect_Lua__cEntity); - #else tolua_cclass(tolua_S,"Lua__cEntity","Lua__cEntity","cEntity",NULL); - #endif 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__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__Tick",tolua_AllToLua_Lua__cEntity_cEntity__Tick00); tolua_function(tolua_S,"cEntity__HandlePhysics",tolua_AllToLua_Lua__cEntity_cEntity__HandlePhysics00); 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); - tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cEntity_new00_local); - tolua_function(tolua_S,"delete",tolua_AllToLua_Lua__cEntity_delete00); tolua_endmodule(tolua_S); tolua_constant(tolua_S,"dtAttack",dtAttack); tolua_constant(tolua_S,"dtLightning",dtLightning); diff --git a/source/Bindings.h b/source/Bindings.h index 9e0cdbb93..0aab00d79 100644 --- a/source/Bindings.h +++ b/source/Bindings.h @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 02/21/13 14:08:41. +** Generated automatically by tolua++-1.0.92 on 02/21/13 15:20:08. */ /* Exported function */ diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index e5c1f5786..3bf46420e 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -1694,9 +1694,9 @@ void cClientHandle::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_Blo -void cClientHandle::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) +void cClientHandle::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) { - m_Protocol->SendSpawnObject(a_Entity, a_ObjectType, a_ObjectData, a_SpeedX, a_SpeedY, a_SpeedZ, a_Yaw, a_Pitch); + m_Protocol->SendSpawnObject(a_Entity, a_ObjectType, a_ObjectData, a_Yaw, a_Pitch); } diff --git a/source/ClientHandle.h b/source/ClientHandle.h index 19466f145..b6bcb20a2 100644 --- a/source/ClientHandle.h +++ b/source/ClientHandle.h @@ -113,7 +113,7 @@ public: void SendBlockBreakAnim (int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage); void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock); void SendSpawnMob (const cMonster & a_Mob); - void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch); + void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch); void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType); void SendTeleportEntity (const cEntity & a_Entity); void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ); diff --git a/source/Entity.h b/source/Entity.h index 804e24490..f4f96df23 100644 --- a/source/Entity.h +++ b/source/Entity.h @@ -72,12 +72,16 @@ public: eEntityType_Pickup = etPickup, eEntityType_Mob = etMob, } ; + + // tolua_end cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z); virtual ~cEntity(); virtual void Initialize(cWorld * a_World); + // tolua_begin + eEntityType GetEntityType(void) const { return m_EntityType; } bool IsPlayer(void) const { return (m_EntityType == etPlayer); } @@ -107,6 +111,10 @@ public: float GetPitch (void) const {return m_Rot.y; } float GetRoll (void) const {return m_Rot.z; } Vector3f GetLookVector(void) const; + const Vector3d & GetSpeed (void) const { return m_Speed; } + double GetSpeedX (void) const { return m_Speed.x; } + double GetSpeedY (void) const { return m_Speed.y; } + double GetSpeedZ (void) const { return m_Speed.z; } int GetChunkX(void) const {return m_ChunkX; } int GetChunkY(void) const {return m_ChunkY; } @@ -168,10 +176,12 @@ protected: int m_ChunkX, m_ChunkY, m_ChunkZ; Vector3d m_Pos; - bool m_bDirtyPosition; + bool m_bDirtyPosition; Vector3f m_Rot; - bool m_bDirtyOrientation; + bool m_bDirtyOrientation; + + Vector3d m_Speed; bool m_bDestroyed; bool m_bRemovedFromChunk; diff --git a/source/FallingBlock.cpp b/source/FallingBlock.cpp index 7b0fa69fb..8f0320d9b 100644 --- a/source/FallingBlock.cpp +++ b/source/FallingBlock.cpp @@ -9,10 +9,9 @@ cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType) - : 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 ) + : 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) { } @@ -42,16 +41,16 @@ void cFallingBlock::SpawnOn(cClientHandle & a_ClientHandle) void cFallingBlock::Tick(float a_Dt, MTRand & a_TickRandom) { float MilliDt = a_Dt * 0.001f; - m_SpeedY -= MilliDt * 9.8f; - m_Pos.y += m_SpeedY * MilliDt; + m_Speed.y -= MilliDt * 9.8f; + m_Pos.y += m_Speed.y * MilliDt; - //GetWorld()->BroadcastTeleportEntity(*this); // Testing position + // GetWorld()->BroadcastTeleportEntity(*this); // Testing position - Vector3i BlockPos( m_OriginalPosition.x, (int)(m_Pos.y - 0.5), m_OriginalPosition.z ); + 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); } } diff --git a/source/FallingBlock.h b/source/FallingBlock.h index e40b342fe..abc3f8d9b 100644 --- a/source/FallingBlock.h +++ b/source/FallingBlock.h @@ -36,8 +36,6 @@ private: BLOCKTYPE m_BlockType; Vector3i m_OriginalPosition; - float m_SpeedY; - static bool IsPassable(BLOCKTYPE a_BlockType) { return ((a_BlockType == E_BLOCK_AIR) || IsBlockLiquid(a_BlockType)); diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 5f789fa47..5f30168f9 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -89,7 +89,6 @@ protected: bool m_bMovingToDestination; bool m_bPassiveAggressive; - Vector3f m_Speed; float m_DestinationTime; float m_Gravity; diff --git a/source/Pickup.cpp b/source/Pickup.cpp index ae4db86bb..19a825cc1 100644 --- a/source/Pickup.cpp +++ b/source/Pickup.cpp @@ -26,13 +26,13 @@ cPickup::cPickup(int a_MicroPosX, int a_MicroPosY, int a_MicroPosZ, const cItem & a_Item, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */) : cEntity(etPickup, ((double)(a_MicroPosX)) / 32, ((double)(a_MicroPosY)) / 32, ((double)(a_MicroPosZ)) / 32) - , m_Speed( a_SpeedX, a_SpeedY, a_SpeedZ ) , m_bOnGround( false ) , m_bReplicated( false ) , m_Timer( 0.f ) , m_Item(a_Item) , m_bCollected( false ) { + m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ); } diff --git a/source/Pickup.h b/source/Pickup.h index 838fb0270..d3be60794 100644 --- a/source/Pickup.h +++ b/source/Pickup.h @@ -38,14 +38,11 @@ public: virtual void Tick(float a_Dt, MTRand & a_TickRandom) override; virtual void HandlePhysics(float a_Dt) override; - const Vector3f & GetSpeed(void) const {return m_Speed; } - private: - Vector3f m_Speed; - Vector3f m_ResultingSpeed; //Can be used to modify the resulting speed for the current tick ;) + Vector3d m_ResultingSpeed; //Can be used to modify the resulting speed for the current tick ;) - Vector3f m_WaterSpeed; + Vector3d m_WaterSpeed; bool m_bOnGround; bool m_bReplicated; diff --git a/source/Protocol/Protocol.h b/source/Protocol/Protocol.h index ab35adbb5..876ab51f5 100644 --- a/source/Protocol/Protocol.h +++ b/source/Protocol/Protocol.h @@ -83,7 +83,7 @@ public: virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) = 0; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) = 0; virtual void SendSpawnMob (const cMonster & a_Mob) = 0; - virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) = 0; + virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) = 0; virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType) = 0; virtual void SendTeleportEntity (const cEntity & a_Entity) = 0; virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) = 0; diff --git a/source/Protocol/Protocol125.cpp b/source/Protocol/Protocol125.cpp index d45ea8837..4fef5623e 100644 --- a/source/Protocol/Protocol125.cpp +++ b/source/Protocol/Protocol125.cpp @@ -618,7 +618,7 @@ void cProtocol125::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_Src void cProtocol125::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock) { // This protocol version implements falling blocks using the spawn object / vehicle packet: - SendSpawnObject(a_FallingBlock, 70, a_FallingBlock.GetBlockType(), 0, 0, 0, 0, 0); + SendSpawnObject(a_FallingBlock, 70, a_FallingBlock.GetBlockType(), 0, 0); } @@ -644,7 +644,7 @@ void cProtocol125::SendSpawnMob(const cMonster & a_Mob) -void cProtocol125::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) +void cProtocol125::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) { UNUSED(a_Yaw); UNUSED(a_Pitch); @@ -659,9 +659,9 @@ void cProtocol125::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, WriteInt (a_ObjectData); if (a_ObjectData != 0) { - WriteShort(a_SpeedX); - WriteShort(a_SpeedY); - WriteShort(a_SpeedZ); + WriteShort((short)a_Entity.GetSpeedX()); + WriteShort((short)a_Entity.GetSpeedY()); + WriteShort((short)a_Entity.GetSpeedZ()); } Flush(); } diff --git a/source/Protocol/Protocol125.h b/source/Protocol/Protocol125.h index 47923235b..ad50c5796 100644 --- a/source/Protocol/Protocol125.h +++ b/source/Protocol/Protocol125.h @@ -60,7 +60,7 @@ public: virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override; virtual void SendSpawnMob (const cMonster & a_Mob) override; - virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) override; + virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override; virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType) override; virtual void SendTeleportEntity (const cEntity & a_Entity) override; virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override; diff --git a/source/Protocol/Protocol14x.cpp b/source/Protocol/Protocol14x.cpp index b70d6e0aa..d19768c5c 100644 --- a/source/Protocol/Protocol14x.cpp +++ b/source/Protocol/Protocol14x.cpp @@ -210,7 +210,7 @@ void cProtocol146::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock) -void cProtocol146::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) +void cProtocol146::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) { cCSLock Lock(m_CSPacket); WriteByte(PACKET_SPAWN_OBJECT); @@ -222,9 +222,10 @@ void cProtocol146::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, WriteInt (a_ObjectData); if (a_ObjectData != 0) { - WriteShort(a_SpeedX); - WriteShort(a_SpeedY); - WriteShort(a_SpeedZ); + // TODO: Proper speed units + WriteShort((short)a_Entity.GetSpeedX()); + WriteShort((short)a_Entity.GetSpeedY()); + WriteShort((short)a_Entity.GetSpeedZ()); WriteByte(a_Yaw); WriteByte(a_Pitch); } diff --git a/source/Protocol/Protocol14x.h b/source/Protocol/Protocol14x.h index 383544f8f..a9ff14d84 100644 --- a/source/Protocol/Protocol14x.h +++ b/source/Protocol/Protocol14x.h @@ -54,7 +54,7 @@ public: virtual void SendPickupSpawn (const cPickup & a_Pickup) override; virtual void SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock) override; - virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) override; + virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override; virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType) override; } ; diff --git a/source/Protocol/ProtocolRecognizer.cpp b/source/Protocol/ProtocolRecognizer.cpp index 0d26cdbd3..ccce8890d 100644 --- a/source/Protocol/ProtocolRecognizer.cpp +++ b/source/Protocol/ProtocolRecognizer.cpp @@ -426,10 +426,10 @@ void cProtocolRecognizer::SendSpawnMob(const cMonster & a_Mob) -void cProtocolRecognizer::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) +void cProtocolRecognizer::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) { ASSERT(m_Protocol != NULL); - m_Protocol->SendSpawnObject(a_Entity, a_ObjectType, a_ObjectData, a_SpeedX, a_SpeedY, a_SpeedZ, a_Yaw, a_Pitch); + m_Protocol->SendSpawnObject(a_Entity, a_ObjectType, a_ObjectData, a_Yaw, a_Pitch); } diff --git a/source/Protocol/ProtocolRecognizer.h b/source/Protocol/ProtocolRecognizer.h index f638b08d8..fdced8bbe 100644 --- a/source/Protocol/ProtocolRecognizer.h +++ b/source/Protocol/ProtocolRecognizer.h @@ -85,7 +85,7 @@ public: virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override; virtual void SendSpawnMob (const cMonster & a_Mob) override; - virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) override; + virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override; virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType) override; virtual void SendTeleportEntity (const cEntity & a_Entity) override; virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override; -- cgit v1.2.3