Monster classes don't use cPackets. Chat messages are sent / broadcast without cPackets. BlockEntities don't use cPackets.
git-svn-id: http://mc-server.googlecode.com/svn/trunk@783 0a769ca7-a7f5-676a-18bf-c427514a06d6master
parent
263ce31bd6
commit
e92b9e7ecb
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
** Lua binding: AllToLua
|
||||
** Generated automatically by tolua++-1.0.92 on 08/23/12 22:41:28.
|
||||
** Generated automatically by tolua++-1.0.92 on 08/24/12 09:56:22.
|
||||
*/
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
@ -171,18 +171,17 @@ static void tolua_reg_types (lua_State* tolua_S)
|
|||
tolua_usertype(tolua_S,"cServer");
|
||||
tolua_usertype(tolua_S,"cRoot");
|
||||
tolua_usertype(tolua_S,"cLuaItems");
|
||||
tolua_usertype(tolua_S,"cCraftingGrid");
|
||||
tolua_usertype(tolua_S,"cPlugin::CommandStruct");
|
||||
tolua_usertype(tolua_S,"cPickup");
|
||||
tolua_usertype(tolua_S,"cItems");
|
||||
tolua_usertype(tolua_S,"cLuaChunk");
|
||||
tolua_usertype(tolua_S,"cCraftingGrid");
|
||||
tolua_usertype(tolua_S,"cClientHandle");
|
||||
tolua_usertype(tolua_S,"cGroup");
|
||||
tolua_usertype(tolua_S,"cFurnaceRecipe");
|
||||
tolua_usertype(tolua_S,"cTracer");
|
||||
tolua_usertype(tolua_S,"cChatColor");
|
||||
tolua_usertype(tolua_S,"cMCLogger");
|
||||
tolua_usertype(tolua_S,"cPacket_PickupSpawn");
|
||||
tolua_usertype(tolua_S,"cFurnaceRecipe");
|
||||
tolua_usertype(tolua_S,"cGroup");
|
||||
tolua_usertype(tolua_S,"cChatColor");
|
||||
tolua_usertype(tolua_S,"cTracer");
|
||||
tolua_usertype(tolua_S,"cLuaChunk");
|
||||
tolua_usertype(tolua_S,"Lua__cWebPlugin");
|
||||
tolua_usertype(tolua_S,"Lua__cPawn");
|
||||
tolua_usertype(tolua_S,"cCuboid");
|
||||
|
@ -4811,7 +4810,7 @@ static int tolua_AllToLua_cEntity_SpawnOn00(lua_State* tolua_S)
|
|||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"cEntity",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,2,"cClientHandle",0,&tolua_err) ||
|
||||
(tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"cClientHandle",0,&tolua_err)) ||
|
||||
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
|
@ -4824,7 +4823,7 @@ static int tolua_AllToLua_cEntity_SpawnOn00(lua_State* tolua_S)
|
|||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SpawnOn'", NULL);
|
||||
#endif
|
||||
{
|
||||
self->SpawnOn(a_Client);
|
||||
self->SpawnOn(*a_Client);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -4891,6 +4890,14 @@ public:
|
|||
return ( void )0;
|
||||
};
|
||||
};
|
||||
void SpawnOn( cClientHandle& a_Client) {
|
||||
if (push_method("SpawnOn", tolua_AllToLua_cEntity_SpawnOn00)) {
|
||||
tolua_pushusertype(lua_state, (void*)&a_Client, "cClientHandle");
|
||||
ToluaBase::dbcall(lua_state, 2, 0);
|
||||
} else {
|
||||
return ( void ) cEntity:: SpawnOn(a_Client);
|
||||
};
|
||||
};
|
||||
|
||||
void cEntity__Initialize( cWorld* a_World) {
|
||||
return ( void )cEntity::Initialize(a_World);
|
||||
|
@ -4903,6 +4910,9 @@ public:
|
|||
};
|
||||
const char* cEntity__GetClass( void ) {
|
||||
return ( const char* )cEntity::GetClass();
|
||||
};
|
||||
void cEntity__SpawnOn( cClientHandle& a_Client) {
|
||||
return ( void )cEntity::SpawnOn(a_Client);
|
||||
};
|
||||
Lua__cEntity( const double& a_X, const double& a_Y, const double& a_Z): cEntity(a_X,a_Y,a_Z){};
|
||||
};
|
||||
|
@ -5071,6 +5081,39 @@ static int tolua_AllToLua_Lua__cEntity_cEntity__GetClass00(lua_State* tolua_S)
|
|||
}
|
||||
#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)
|
||||
{
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"Lua__cEntity",0,&tolua_err) ||
|
||||
(tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"cClientHandle",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);
|
||||
cClientHandle* a_Client = ((cClientHandle*) tolua_tousertype(tolua_S,2,0));
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cEntity__SpawnOn'", NULL);
|
||||
#endif
|
||||
{
|
||||
self->cEntity__SpawnOn(*a_Client);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'cEntity__SpawnOn'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#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)
|
||||
|
@ -5543,6 +5586,14 @@ public:
|
|||
return ( void )0;
|
||||
};
|
||||
};
|
||||
void SpawnOn( cClientHandle& a_Client) {
|
||||
if (push_method("SpawnOn", tolua_AllToLua_cEntity_SpawnOn00)) {
|
||||
tolua_pushusertype(lua_state, (void*)&a_Client, "cClientHandle");
|
||||
ToluaBase::dbcall(lua_state, 2, 0);
|
||||
} else {
|
||||
return ( void ) cPawn:: SpawnOn(a_Client);
|
||||
};
|
||||
};
|
||||
|
||||
void cPawn__TeleportToEntity( cEntity* a_Entity) {
|
||||
return ( void )cPawn::TeleportToEntity(a_Entity);
|
||||
|
@ -5568,6 +5619,9 @@ public:
|
|||
const char* cPawn__GetClass( void ) {
|
||||
return ( const char* )cPawn::GetClass();
|
||||
};
|
||||
void cPawn__SpawnOn( cClientHandle& a_Client) {
|
||||
return ( void )cPawn::SpawnOn(a_Client);
|
||||
};
|
||||
};
|
||||
|
||||
/* method: tolua__set_instance of class Lua__cPawn */
|
||||
|
@ -6026,14 +6080,14 @@ static int tolua_AllToLua_cPlayer_GetGameMode00(lua_State* tolua_S)
|
|||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,2,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
|
||||
const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetGameMode'", NULL);
|
||||
#endif
|
||||
|
@ -6975,6 +7029,14 @@ public:
|
|||
return ( void )0;
|
||||
};
|
||||
};
|
||||
void SpawnOn( cClientHandle& a_Client) {
|
||||
if (push_method("SpawnOn", tolua_AllToLua_cEntity_SpawnOn00)) {
|
||||
tolua_pushusertype(lua_state, (void*)&a_Client, "cClientHandle");
|
||||
ToluaBase::dbcall(lua_state, 2, 0);
|
||||
} else {
|
||||
return ( void ) cPlayer:: SpawnOn(a_Client);
|
||||
};
|
||||
};
|
||||
|
||||
void cPlayer__Initialize( cWorld* a_World) {
|
||||
return ( void )cPlayer::Initialize(a_World);
|
||||
|
@ -7003,6 +7065,9 @@ public:
|
|||
const char* cPlayer__GetClass( void ) {
|
||||
return ( const char* )cPlayer::GetClass();
|
||||
};
|
||||
void cPlayer__SpawnOn( cClientHandle& a_Client) {
|
||||
return ( void )cPlayer::SpawnOn(a_Client);
|
||||
};
|
||||
};
|
||||
|
||||
/* method: tolua__set_instance of class Lua__cPlayer */
|
||||
|
@ -10735,7 +10800,7 @@ static int tolua_AllToLua_cServer_SendMessage00(lua_State* tolua_S)
|
|||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"cServer",0,&tolua_err) ||
|
||||
!tolua_isstring(tolua_S,2,0,&tolua_err) ||
|
||||
!tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,3,"cPlayer",1,&tolua_err) ||
|
||||
!tolua_isboolean(tolua_S,4,1,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,5,&tolua_err)
|
||||
|
@ -10745,17 +10810,18 @@ static int tolua_AllToLua_cServer_SendMessage00(lua_State* tolua_S)
|
|||
#endif
|
||||
{
|
||||
cServer* self = (cServer*) tolua_tousertype(tolua_S,1,0);
|
||||
const char* a_Message = ((const char*) tolua_tostring(tolua_S,2,0));
|
||||
cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0));
|
||||
const AString a_Message = ((const AString) tolua_tocppstring(tolua_S,2,0));
|
||||
cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,NULL));
|
||||
bool a_bExclude = ((bool) tolua_toboolean(tolua_S,4,false));
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SendMessage'", NULL);
|
||||
#endif
|
||||
{
|
||||
self->SendMessage(a_Message,a_Player,a_bExclude);
|
||||
tolua_pushcppstring(tolua_S,(const char*)a_Message);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'SendMessage'.",&tolua_err);
|
||||
|
@ -13637,57 +13703,6 @@ static int tolua_AllToLua_cPickup_new00_local(lua_State* tolua_S)
|
|||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: new of class cPickup */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPickup_new01
|
||||
static int tolua_AllToLua_cPickup_new01(lua_State* tolua_S)
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertable(tolua_S,1,"cPickup",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,2,"cPacket_PickupSpawn",0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
else
|
||||
{
|
||||
cPacket_PickupSpawn* a_PickupSpawnPacket = ((cPacket_PickupSpawn*) tolua_tousertype(tolua_S,2,0));
|
||||
{
|
||||
cPickup* tolua_ret = (cPickup*) Mtolua_new((cPickup)(a_PickupSpawnPacket));
|
||||
tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPickup");
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
tolua_lerror:
|
||||
return tolua_AllToLua_cPickup_new00(tolua_S);
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: new_local of class cPickup */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPickup_new01_local
|
||||
static int tolua_AllToLua_cPickup_new01_local(lua_State* tolua_S)
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertable(tolua_S,1,"cPickup",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,2,"cPacket_PickupSpawn",0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
else
|
||||
{
|
||||
cPacket_PickupSpawn* a_PickupSpawnPacket = ((cPacket_PickupSpawn*) tolua_tousertype(tolua_S,2,0));
|
||||
{
|
||||
cPickup* tolua_ret = (cPickup*) Mtolua_new((cPickup)(a_PickupSpawnPacket));
|
||||
tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPickup");
|
||||
tolua_register_gc(tolua_S,lua_gettop(tolua_S));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
tolua_lerror:
|
||||
return tolua_AllToLua_cPickup_new00_local(tolua_S);
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: delete of class cPickup */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPickup_delete00
|
||||
static int tolua_AllToLua_cPickup_delete00(lua_State* tolua_S)
|
||||
|
@ -13849,6 +13864,14 @@ public:
|
|||
return ( void )0;
|
||||
};
|
||||
};
|
||||
void SpawnOn( cClientHandle& a_Client) {
|
||||
if (push_method("SpawnOn", tolua_AllToLua_cEntity_SpawnOn00)) {
|
||||
tolua_pushusertype(lua_state, (void*)&a_Client, "cClientHandle");
|
||||
ToluaBase::dbcall(lua_state, 2, 0);
|
||||
} else {
|
||||
return ( void ) cPickup:: SpawnOn(a_Client);
|
||||
};
|
||||
};
|
||||
|
||||
bool cPickup__CollectedBy( cPlayer* a_Dest) {
|
||||
return ( bool )cPickup::CollectedBy(a_Dest);
|
||||
|
@ -13864,9 +13887,11 @@ public:
|
|||
};
|
||||
const char* cPickup__GetClass( void ) {
|
||||
return ( const char* )cPickup::GetClass();
|
||||
};
|
||||
void cPickup__SpawnOn( cClientHandle& a_Client) {
|
||||
return ( void )cPickup::SpawnOn(a_Client);
|
||||
};
|
||||
Lua__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): cPickup(a_X,a_Y,a_Z,a_Item,a_SpeedX,a_SpeedY,a_SpeedZ){};
|
||||
Lua__cPickup( cPacket_PickupSpawn* a_PickupSpawnPacket): cPickup(a_PickupSpawnPacket){};
|
||||
};
|
||||
|
||||
/* method: tolua__set_instance of class Lua__cPickup */
|
||||
|
@ -14021,57 +14046,6 @@ static int tolua_AllToLua_Lua__cPickup_new00_local(lua_State* tolua_S)
|
|||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: new of class Lua__cPickup */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPickup_new01
|
||||
static int tolua_AllToLua_Lua__cPickup_new01(lua_State* tolua_S)
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertable(tolua_S,1,"Lua__cPickup",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,2,"cPacket_PickupSpawn",0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
else
|
||||
{
|
||||
cPacket_PickupSpawn* a_PickupSpawnPacket = ((cPacket_PickupSpawn*) tolua_tousertype(tolua_S,2,0));
|
||||
{
|
||||
Lua__cPickup* tolua_ret = (Lua__cPickup*) Mtolua_new((Lua__cPickup)(a_PickupSpawnPacket));
|
||||
tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cPickup");
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
tolua_lerror:
|
||||
return tolua_AllToLua_Lua__cPickup_new00(tolua_S);
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: new_local of class Lua__cPickup */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPickup_new01_local
|
||||
static int tolua_AllToLua_Lua__cPickup_new01_local(lua_State* tolua_S)
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertable(tolua_S,1,"Lua__cPickup",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,2,"cPacket_PickupSpawn",0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
else
|
||||
{
|
||||
cPacket_PickupSpawn* a_PickupSpawnPacket = ((cPacket_PickupSpawn*) tolua_tousertype(tolua_S,2,0));
|
||||
{
|
||||
Lua__cPickup* tolua_ret = (Lua__cPickup*) Mtolua_new((Lua__cPickup)(a_PickupSpawnPacket));
|
||||
tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cPickup");
|
||||
tolua_register_gc(tolua_S,lua_gettop(tolua_S));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
tolua_lerror:
|
||||
return tolua_AllToLua_Lua__cPickup_new00_local(tolua_S);
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: delete of class Lua__cPickup */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPickup_delete00
|
||||
static int tolua_AllToLua_Lua__cPickup_delete00(lua_State* tolua_S)
|
||||
|
@ -21323,6 +21297,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__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);
|
||||
|
@ -21664,9 +21639,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
|
|||
tolua_function(tolua_S,"new",tolua_AllToLua_cPickup_new00);
|
||||
tolua_function(tolua_S,"new_local",tolua_AllToLua_cPickup_new00_local);
|
||||
tolua_function(tolua_S,".call",tolua_AllToLua_cPickup_new00_local);
|
||||
tolua_function(tolua_S,"new",tolua_AllToLua_cPickup_new01);
|
||||
tolua_function(tolua_S,"new_local",tolua_AllToLua_cPickup_new01_local);
|
||||
tolua_function(tolua_S,".call",tolua_AllToLua_cPickup_new01_local);
|
||||
tolua_function(tolua_S,"delete",tolua_AllToLua_cPickup_delete00);
|
||||
tolua_function(tolua_S,"GetItem",tolua_AllToLua_cPickup_GetItem00);
|
||||
tolua_function(tolua_S,"CollectedBy",tolua_AllToLua_cPickup_CollectedBy00);
|
||||
|
@ -21682,9 +21654,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
|
|||
tolua_function(tolua_S,"new",tolua_AllToLua_Lua__cPickup_new00);
|
||||
tolua_function(tolua_S,"new_local",tolua_AllToLua_Lua__cPickup_new00_local);
|
||||
tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cPickup_new00_local);
|
||||
tolua_function(tolua_S,"new",tolua_AllToLua_Lua__cPickup_new01);
|
||||
tolua_function(tolua_S,"new_local",tolua_AllToLua_Lua__cPickup_new01_local);
|
||||
tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cPickup_new01_local);
|
||||
tolua_function(tolua_S,"delete",tolua_AllToLua_Lua__cPickup_delete00);
|
||||
tolua_endmodule(tolua_S);
|
||||
tolua_cclass(tolua_S,"cRoot","cRoot","",NULL);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
** Lua binding: AllToLua
|
||||
** Generated automatically by tolua++-1.0.92 on 08/23/12 22:41:28.
|
||||
** Generated automatically by tolua++-1.0.92 on 08/24/12 09:56:22.
|
||||
*/
|
||||
|
||||
/* Exported function */
|
||||
|
|
|
@ -237,20 +237,21 @@ void cChunkSender::SendChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cClientHa
|
|||
a_Client->Send(MapChunk);
|
||||
}
|
||||
|
||||
// Send entity creation packets:
|
||||
for (PacketList::iterator itr = m_Packets.begin(); itr != m_Packets.end(); ++itr)
|
||||
// Send block-entity packets:
|
||||
for (sBlockCoords::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
|
||||
{
|
||||
if (a_Client == NULL)
|
||||
{
|
||||
m_World->BroadcastToChunk(a_ChunkX, a_ChunkY, a_ChunkZ, **itr);
|
||||
m_World->BroadcastBlockEntity(itr->m_BlockX, itr->m_BlockY, itr->m_BlockZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
a_Client->Send(**itr);
|
||||
m_World->SendBlockEntity(itr->m_BlockX, itr->m_BlockY, itr->m_BlockZ, *a_Client);
|
||||
}
|
||||
delete *itr;
|
||||
} // for itr - m_Packets[]
|
||||
m_Packets.clear();
|
||||
m_BlockEntities.clear();
|
||||
|
||||
// TODO: Send entity spawn packets
|
||||
}
|
||||
|
||||
|
||||
|
@ -259,11 +260,7 @@ void cChunkSender::SendChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cClientHa
|
|||
|
||||
void cChunkSender::BlockEntity(cBlockEntity * a_Entity)
|
||||
{
|
||||
cPacket * Packet = a_Entity->GetPacket();
|
||||
if (Packet != NULL)
|
||||
{
|
||||
m_Packets.push_back(Packet);
|
||||
}
|
||||
m_BlockEntities.push_back(sBlockCoord(a_Entity->GetPosX(), a_Entity->GetPosY(), a_Entity->GetPosZ()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ Note that it may be called by world's BroadcastToChunk() if the client is still
|
|||
|
||||
#include "cIsThread.h"
|
||||
#include "ChunkDef.h"
|
||||
#include "packets/cPacket.h"
|
||||
|
||||
|
||||
|
||||
|
@ -116,9 +115,25 @@ protected:
|
|||
(a_Other.m_Client == m_Client)
|
||||
);
|
||||
}
|
||||
};
|
||||
} ;
|
||||
typedef std::list<sSendChunk> sSendChunkList;
|
||||
|
||||
struct sBlockCoord
|
||||
{
|
||||
int m_BlockX;
|
||||
int m_BlockY;
|
||||
int m_BlockZ;
|
||||
|
||||
sBlockCoord(int a_BlockX, int a_BlockY, int a_BlockZ) :
|
||||
m_BlockX(a_BlockX),
|
||||
m_BlockY(a_BlockY),
|
||||
m_BlockZ(a_BlockZ)
|
||||
{
|
||||
}
|
||||
} ;
|
||||
|
||||
typedef std::vector<sBlockCoord> sBlockCoords;
|
||||
|
||||
cWorld * m_World;
|
||||
|
||||
cCriticalSection m_CS;
|
||||
|
@ -133,7 +148,8 @@ protected:
|
|||
// Data about the chunk that is being sent:
|
||||
// NOTE that m_BlockData[] is inherited from the cChunkDataCollector
|
||||
unsigned char m_BiomeMap[cChunkDef::Width * cChunkDef::Width];
|
||||
PacketList m_Packets; // Accumulator for the entity-packets to send
|
||||
sBlockCoords m_BlockEntities; // Coords of the block entities to send
|
||||
// TODO: sEntityIDs m_Entities; // Entity-IDs of the entities to send
|
||||
|
||||
// cIsThread override:
|
||||
virtual void Execute(void) override;
|
||||
|
|
|
@ -58,25 +58,10 @@ public:
|
|||
|
||||
virtual void UsedBy( cPlayer * a_Player ) = 0;
|
||||
|
||||
void SendTo( cClientHandle* a_Client )
|
||||
{
|
||||
std::auto_ptr<cPacket> Packet(GetPacket());
|
||||
if (Packet.get() == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ( a_Client != NULL )
|
||||
{
|
||||
a_Client->Send(*(Packet.get()));
|
||||
}
|
||||
else // broadcast to all chunk clients
|
||||
{
|
||||
m_World->BroadcastToChunkOfBlock(m_PosX, m_PosY, m_PosZ, Packet.get());
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the packet to send to clients to represent this entity; NULL if no packet needed; caller is supposed to delete the packet
|
||||
virtual cPacket * GetPacket(void) {return NULL; }
|
||||
/** Sends the packet defining the block entity to the client specified.
|
||||
To send to all eligible clients, use cWorld::BroadcastBlockEntity()
|
||||
*/
|
||||
virtual void SendTo(cClientHandle & a_Client) = 0;
|
||||
|
||||
protected:
|
||||
int m_PosX; // Position in absolute block coordinates
|
||||
|
|
|
@ -156,11 +156,12 @@ void cChestEntity::SaveToJson( Json::Value& a_Value )
|
|||
|
||||
|
||||
|
||||
void cChestEntity::SendTo( cClientHandle* a_Client, cServer* a_Server )
|
||||
void cChestEntity::SendTo(cClientHandle & a_Client)
|
||||
{
|
||||
// The chest entity doesn't need anything sent to the client when it's created / gets in the viewdistance
|
||||
// All the actual handling is in the cWindow UI code that gets called when the chest is rclked
|
||||
|
||||
UNUSED(a_Client);
|
||||
UNUSED(a_Server);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
bool LoadFromJson( const Json::Value& a_Value );
|
||||
virtual void SaveToJson(Json::Value& a_Value ) override;
|
||||
|
||||
void SendTo( cClientHandle* a_Client, cServer* a_Server );
|
||||
virtual void SendTo(cClientHandle & a_Client) override;
|
||||
|
||||
virtual void UsedBy( cPlayer * a_Player ) override;
|
||||
|
||||
|
|
|
@ -1230,7 +1230,6 @@ void cChunk::AddBlockEntity( cBlockEntity* a_BlockEntity )
|
|||
|
||||
cBlockEntity * cChunk::GetBlockEntity(int a_X, int a_Y, int a_Z)
|
||||
{
|
||||
// Assumes that the m_CSBlockList is already locked, we're being called from SetBlock()
|
||||
for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
|
||||
{
|
||||
if (
|
||||
|
@ -1308,7 +1307,7 @@ void cChunk::UpdateSign(int a_PosX, int a_PosY, int a_PosZ, const AString & a_Li
|
|||
{
|
||||
MarkDirty();
|
||||
(reinterpret_cast<cSignEntity *>(*itr))->SetLines(a_Line1, a_Line2, a_Line3, a_Line4);
|
||||
(*itr)->SendTo(NULL);
|
||||
m_World->BroadcastBlockEntity(a_PosX, a_PosY, a_PosZ);
|
||||
}
|
||||
} // for itr - m_BlockEntities[]
|
||||
}
|
||||
|
@ -1342,8 +1341,8 @@ bool cChunk::AddClient(cClientHandle* a_Client)
|
|||
|
||||
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr )
|
||||
{
|
||||
LOGD("cChunk: Entity #%d (%s) at [%i, %i, %i] spawning for player \"%s\"", (*itr)->GetUniqueID(), (*itr)->GetClass(), m_PosX, m_PosY, m_PosZ, a_Client->GetUsername().c_str() );
|
||||
(*itr)->SpawnOn( a_Client );
|
||||
LOGD("cChunk: Entity #%d (%s) at [%i, %i, %i] spawning for player \"%s\"", (*itr)->GetUniqueID(), (*itr)->GetClass(), m_PosX, m_PosY, m_PosZ, a_Client->GetUsername().c_str());
|
||||
(*itr)->SpawnOn(*a_Client);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1915,6 +1914,58 @@ void cChunk::BroadcastMetadata(const cPawn & a_Pawn, const cClientHandle * a_Exc
|
|||
|
||||
|
||||
|
||||
void cChunk::BroadcastSpawn(cEntity & a_Entity, const cClientHandle * a_Exclude)
|
||||
{
|
||||
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
|
||||
{
|
||||
if (*itr == a_Exclude)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
a_Entity.SpawnOn(*(*itr));
|
||||
} // for itr - LoadedByClient[]
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cChunk::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
|
||||
{
|
||||
// We can operate on entity pointers, we're inside the ChunkMap's CS lock which guards the list
|
||||
cBlockEntity * Entity = GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ);
|
||||
if (Entity == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
|
||||
{
|
||||
if (*itr == a_Exclude)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Entity->SendTo(*(*itr));
|
||||
} // for itr - LoadedByClient[]
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cChunk::SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client)
|
||||
{
|
||||
cBlockEntity * Entity = GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ);
|
||||
if (Entity == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Entity->SendTo(a_Client);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cChunk::PositionToWorldPosition(int a_ChunkX, int a_ChunkY, int a_ChunkZ, int & a_X, int & a_Y, int & a_Z)
|
||||
{
|
||||
a_Y = a_ChunkY;
|
||||
|
|
|
@ -186,6 +186,10 @@ public:
|
|||
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastMetadata (const cPawn & a_Pawn, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastSpawn (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
|
||||
|
||||
void SendBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
|
||||
|
||||
void PositionToWorldPosition(int a_ChunkX, int a_ChunkY, int a_ChunkZ, int & a_X, int & a_Y, int & a_Z);
|
||||
Vector3i PositionToWorldPosition( const Vector3i & a_InChunkPos ) { return PositionToWorldPosition( a_InChunkPos.x, a_InChunkPos.y, a_InChunkPos.z ); }
|
||||
|
|
|
@ -435,6 +435,56 @@ void cChunkMap::BroadcastMetadata(const cPawn & a_Pawn, const cClientHandle * a_
|
|||
|
||||
|
||||
|
||||
void cChunkMap::BroadcastSpawn(cEntity & a_Entity, const cClientHandle * a_Exclude)
|
||||
{
|
||||
cCSLock Lock(m_CSLayers);
|
||||
cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), a_Entity.GetChunkY(), a_Entity.GetChunkZ());
|
||||
if (Chunk == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// It's perfectly legal to broadcast packets even to invalid chunks!
|
||||
Chunk->BroadcastSpawn(a_Entity, a_Exclude);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cChunkMap::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
|
||||
{
|
||||
cCSLock Lock(m_CSLayers);
|
||||
int ChunkX, ChunkZ;
|
||||
cChunkDef::BlockToChunk(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
|
||||
cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ);
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Chunk->BroadcastBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_Exclude);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cChunkMap::SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client)
|
||||
{
|
||||
cCSLock Lock(m_CSLayers);
|
||||
int ChunkX, ChunkZ;
|
||||
cChunkDef::BlockToChunk(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
|
||||
cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ);
|
||||
if ((Chunk == NULL) || !Chunk->IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Chunk->SendBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_Client);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cChunkMap::UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
// a_Player rclked block entity at the coords specified, handle it
|
||||
|
|
|
@ -75,6 +75,14 @@ public:
|
|||
|
||||
void BroadcastMetadata(const cPawn & a_Pawn, const cClientHandle * a_Exclude = NULL);
|
||||
|
||||
void BroadcastSpawn(cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
||||
|
||||
/// Broadcasts the block entity, if it is at the coords specified, to all clients except a_Exclude
|
||||
void BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude);
|
||||
|
||||
/// Sends the block entity, if it is at the coords specified, to a_Client
|
||||
void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
|
||||
|
||||
/// a_Player rclked block entity at the coords specified, handle it
|
||||
void UseBlockEntity(cPlayer * a_Player, int a_X, int a_Y, int a_Z);
|
||||
|
||||
|
|
|
@ -1818,6 +1818,83 @@ void cClientHandle::SendInventoryProgress(char a_WindowID, short a_ProgressBar,
|
|||
|
||||
|
||||
|
||||
void cClientHandle::SendPlayerSpawn(const cPlayer & a_Player)
|
||||
{
|
||||
cPacket_NamedEntitySpawn SpawnPacket;
|
||||
SpawnPacket.m_UniqueID = a_Player.GetUniqueID();
|
||||
SpawnPacket.m_PlayerName = a_Player.GetName();
|
||||
SpawnPacket.m_PosX = (int)(a_Player.GetPosX() * 32);
|
||||
SpawnPacket.m_PosY = (int)(a_Player.GetPosY() * 32);
|
||||
SpawnPacket.m_PosZ = (int)(a_Player.GetPosZ() * 32);
|
||||
SpawnPacket.m_Rotation = (char)((a_Player.GetRot().x / 360.f) * 256);
|
||||
SpawnPacket.m_Pitch = (char)((a_Player.GetRot().y / 360.f) * 256);
|
||||
const cItem & HeldItem = a_Player.GetEquippedItem();
|
||||
SpawnPacket.m_CurrentItem = HeldItem.IsEmpty() ? 0 : HeldItem.m_ItemType; // Unlike -1 in inventory, the named entity packet uses 0 for "empty"
|
||||
Send(SpawnPacket);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cClientHandle::SendPickupSpawn(const cPickup & a_Pickup)
|
||||
{
|
||||
cPacket_PickupSpawn PickupSpawn;
|
||||
PickupSpawn.m_UniqueID = a_Pickup.GetUniqueID();
|
||||
PickupSpawn.m_ItemType = a_Pickup.GetItem()->m_ItemType;
|
||||
PickupSpawn.m_ItemCount = a_Pickup.GetItem()->m_ItemCount;
|
||||
PickupSpawn.m_ItemDamage = a_Pickup.GetItem()->m_ItemHealth;
|
||||
PickupSpawn.m_PosX = (int) (a_Pickup.GetPosX() * 32);
|
||||
PickupSpawn.m_PosY = (int) (a_Pickup.GetPosY() * 32);
|
||||
PickupSpawn.m_PosZ = (int) (a_Pickup.GetPosZ() * 32);
|
||||
PickupSpawn.m_Rotation = (char)(a_Pickup.GetSpeed().x * 8);
|
||||
PickupSpawn.m_Pitch = (char)(a_Pickup.GetSpeed().y * 8);
|
||||
PickupSpawn.m_Roll = (char)(a_Pickup.GetSpeed().z * 8);
|
||||
Send(PickupSpawn);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cClientHandle::SendSpawnMob(const cMonster & a_Mob)
|
||||
{
|
||||
cPacket_SpawnMob Spawn;
|
||||
Spawn.m_UniqueID = a_Mob.GetUniqueID();
|
||||
Spawn.m_Type = a_Mob.GetMobType();
|
||||
Spawn.m_Pos = ((Vector3i)(a_Mob.GetPosition())) * 32;
|
||||
Spawn.m_Yaw = 0;
|
||||
Spawn.m_Pitch = 0;
|
||||
Spawn.m_MetaDataSize = 1;
|
||||
Spawn.m_MetaData = new char[Spawn.m_MetaDataSize];
|
||||
Spawn.m_MetaData[0] = 0x7f; // not on fire/crouching/riding
|
||||
Send(Spawn);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cClientHandle::SendUpdateSign(
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ,
|
||||
const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4
|
||||
)
|
||||
{
|
||||
cPacket_UpdateSign us;
|
||||
us.m_BlockX = a_BlockX;
|
||||
us.m_BlockY = a_BlockY;
|
||||
us.m_BlockZ = a_BlockZ;
|
||||
us.m_Line1 = a_Line1;
|
||||
us.m_Line2 = a_Line2;
|
||||
us.m_Line3 = a_Line3;
|
||||
us.m_Line4 = a_Line4;
|
||||
Send(us);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cClientHandle::CheckIfWorldDownloaded(void)
|
||||
{
|
||||
if (m_State != csDownloadingWorld)
|
||||
|
|
|
@ -33,6 +33,8 @@ class cRedstone;
|
|||
class cInventory;
|
||||
class cWindow;
|
||||
class cPawn;
|
||||
class cPickup;
|
||||
class cMonster;
|
||||
|
||||
|
||||
|
||||
|
@ -107,6 +109,10 @@ public:
|
|||
void SendEntityStatus(const cEntity & a_Entity, char a_Status);
|
||||
void SendMetadata(const cPawn & a_Entity);
|
||||
void SendInventoryProgress(char a_WindowID, short a_Progressbar, short a_Value);
|
||||
void SendPlayerSpawn(const cPlayer & a_Player);
|
||||
void SendPickupSpawn(const cPickup & a_Pickup);
|
||||
void SendSpawnMob (const cMonster & a_Mob);
|
||||
void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
|
||||
|
||||
const AString & GetUsername(void) const; //tolua_export
|
||||
|
||||
|
|
|
@ -68,7 +68,13 @@ cEntity::~cEntity()
|
|||
|
||||
|
||||
|
||||
void cEntity::Initialize( cWorld* a_World )
|
||||
CLASS_DEF_GETCLASS(cEntity);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cEntity::Initialize(cWorld * a_World)
|
||||
{
|
||||
m_World = a_World;
|
||||
m_World->AddEntity( this );
|
||||
|
@ -118,31 +124,17 @@ void cEntity::MoveToCorrectChunk(bool a_bIgnoreOldChunk)
|
|||
|
||||
virtual void Added(cClientHandle * a_Client) override
|
||||
{
|
||||
if (m_Spawn == NULL)
|
||||
{
|
||||
m_Spawn = m_Entity->GetSpawnPacket(); // Only create the packet when needed
|
||||
}
|
||||
if (m_Spawn != NULL)
|
||||
{
|
||||
a_Client->Send(*m_Spawn);
|
||||
}
|
||||
m_Entity->SpawnOn(*a_Client);
|
||||
}
|
||||
|
||||
cPacket * m_Spawn;
|
||||
bool m_IgnoreOldChunk;
|
||||
cEntity * m_Entity;
|
||||
|
||||
public:
|
||||
cMover(cEntity * a_Entity, bool a_IgnoreOldChunk) :
|
||||
m_Spawn(NULL),
|
||||
m_IgnoreOldChunk(a_IgnoreOldChunk),
|
||||
m_Entity(a_Entity)
|
||||
{}
|
||||
|
||||
~cMover()
|
||||
{
|
||||
delete m_Spawn;
|
||||
}
|
||||
} Mover(this, a_bIgnoreOldChunk);
|
||||
|
||||
m_World->CompareChunkClients(m_ChunkX, m_ChunkY, m_ChunkZ, ChunkX, ChunkY, ChunkZ, Mover);
|
||||
|
@ -194,29 +186,6 @@ void cEntity::RemoveFromChunk(void)
|
|||
|
||||
|
||||
|
||||
void cEntity::SpawnOn(cClientHandle * a_Client)
|
||||
{
|
||||
std::auto_ptr<cPacket> SpawnPacket(GetSpawnPacket());
|
||||
if (SpawnPacket.get() == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (a_Client == NULL)
|
||||
{
|
||||
m_World->BroadcastToChunk(m_ChunkX, m_ChunkY, m_ChunkZ, *SpawnPacket.get(), NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
a_Client->Send(*(SpawnPacket.get()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CLASS_DEF_GETCLASS( cEntity );
|
||||
bool cEntity::IsA( const char* a_EntityType )
|
||||
{
|
||||
//LOG("IsA( cEntity ) : %s", a_EntityType);
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
cEntity(const double & a_X, const double & a_Y, const double & a_Z);
|
||||
virtual ~cEntity();
|
||||
|
||||
virtual void Initialize( cWorld* a_World );
|
||||
virtual void Initialize(cWorld * a_World);
|
||||
|
||||
enum eEntityType
|
||||
{
|
||||
|
@ -114,8 +114,11 @@ public:
|
|||
|
||||
virtual void Tick(float a_Dt) = 0; //tolua_export
|
||||
|
||||
virtual cPacket * GetSpawnPacket(void) const {ASSERT(!"GetSpawnedPacket unimplemented!"); return NULL; }; // _X: Needs to be implemented due to Lua bindings
|
||||
void SpawnOn (cClientHandle * a_Client); // tolua_export
|
||||
/** Descendants override this function to send a command to the specified client to spawn the entity on the client.
|
||||
To spawn on all eligible clients, use cChunkMap::BroadcastSpawnEntity()
|
||||
Needs to have a default implementation due to Lua bindings.
|
||||
*/
|
||||
virtual void SpawnOn(cClientHandle & a_Client) {ASSERT(!"SpawnOn() unimplemented!"); } // tolua_export
|
||||
|
||||
void WrapRotation();
|
||||
|
||||
|
|
|
@ -386,3 +386,13 @@ void cFurnaceEntity::SaveToJson( Json::Value& a_Value )
|
|||
|
||||
|
||||
|
||||
|
||||
void cFurnaceEntity::SendTo(cClientHandle & a_Client)
|
||||
{
|
||||
// Nothing needs to be sent
|
||||
UNUSED(a_Client);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@ public:
|
|||
bool LoadFromJson(const Json::Value& a_Value );
|
||||
virtual void SaveToJson(Json::Value& a_Value ) override;
|
||||
|
||||
virtual void SendTo(cClientHandle & a_Client) override;
|
||||
|
||||
// Returns true if there's any change, forcing the chunk to go dirty.
|
||||
bool Tick( float a_Dt );
|
||||
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
#include "cFurnaceEntity.h"
|
||||
#include "cPlayer.h"
|
||||
|
||||
#include "packets/cPacket_WindowClick.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -235,7 +235,7 @@ void cInventory::SetEquippedSlot( int a_SlotNum )
|
|||
|
||||
|
||||
|
||||
cItem & cInventory::GetEquippedItem()
|
||||
cItem & cInventory::GetEquippedItem(void)
|
||||
{
|
||||
cItem* Item = GetFromHotBar( m_EquippedSlot );
|
||||
if( Item )
|
||||
|
@ -254,6 +254,15 @@ cItem & cInventory::GetEquippedItem()
|
|||
|
||||
|
||||
|
||||
const cItem & cInventory::GetEquippedItem(void) const
|
||||
{
|
||||
return *m_EquippedItem;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cInventory::SendWholeInventory(cClientHandle * a_Client)
|
||||
{
|
||||
a_Client->SendWholeInventory(*this);
|
||||
|
|
|
@ -47,7 +47,8 @@ public:
|
|||
cItem* GetSlots() const { return m_Slots; }
|
||||
cItem* GetFromHotBar( int a_SlotNum ); //tolua_export
|
||||
|
||||
cItem & GetEquippedItem(); //tolua_export
|
||||
cItem & GetEquippedItem(void); //tolua_export
|
||||
const cItem & GetEquippedItem(void) const;
|
||||
void SetEquippedSlot( int a_SlotNum ); //tolua_export
|
||||
short GetEquippedSlot() { return m_EquippedSlot; } //tolua_export
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include "cMonsterConfig.h"
|
||||
#include "MersenneTwister.h"
|
||||
|
||||
#include "packets/cPacket_SpawnMob.h"
|
||||
|
||||
#include "Vector3f.h"
|
||||
#include "Vector3i.h"
|
||||
#include "Vector3d.h"
|
||||
|
@ -78,18 +76,9 @@ bool cMonster::IsA( const char* a_EntityType )
|
|||
|
||||
|
||||
|
||||
cPacket * cMonster::GetSpawnPacket(void) const
|
||||
void cMonster::SpawnOn(cClientHandle & a_Client)
|
||||
{
|
||||
cPacket_SpawnMob * Spawn = new cPacket_SpawnMob;
|
||||
Spawn->m_UniqueID = GetUniqueID();
|
||||
Spawn->m_Type = m_MobType;
|
||||
*Spawn->m_Pos = ((Vector3i)(m_Pos)) * 32;
|
||||
Spawn->m_Yaw = 0;
|
||||
Spawn->m_Pitch = 0;
|
||||
Spawn->m_MetaDataSize = 1;
|
||||
Spawn->m_MetaData = new char[Spawn->m_MetaDataSize];
|
||||
Spawn->m_MetaData[0] = 0x7f; // not on fire/crouching/riding
|
||||
return Spawn;
|
||||
a_Client.SendSpawnMob(*this);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,22 +27,23 @@ public:
|
|||
|
||||
virtual bool IsA( const char* a_EntityType );
|
||||
|
||||
virtual cPacket * GetSpawnPacket(void) const override;
|
||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||
|
||||
virtual void Tick(float a_Dt) override;
|
||||
|
||||
virtual void HandlePhysics(float a_Dt);
|
||||
virtual void ReplicateMovement();
|
||||
virtual void ReplicateMovement(void);
|
||||
|
||||
virtual void TakeDamage( int a_Damage, cEntity* a_Instigator );
|
||||
virtual void KilledBy( cEntity* a_Killer );
|
||||
virtual void TakeDamage(int a_Damage, cEntity * a_Instigator) override;
|
||||
virtual void KilledBy(cEntity * a_Killer) override;
|
||||
|
||||
virtual void MoveToPosition( const Vector3f & a_Position );
|
||||
virtual bool ReachedDestination();
|
||||
virtual void MoveToPosition(const Vector3f & a_Position);
|
||||
virtual bool ReachedDestination(void);
|
||||
|
||||
char GetMobType(void) const {return m_MobType; }
|
||||
|
||||
const char *GetState();
|
||||
const char * GetState();
|
||||
void SetState(const AString & str);
|
||||
static void ListMonsters();
|
||||
|
||||
virtual void CheckEventSeePlayer();
|
||||
virtual void EventSeePlayer(cEntity *);
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
#include "cRoot.h"
|
||||
#include "cTracer.h"
|
||||
|
||||
#include "packets/cPacket_TeleportEntity.h"
|
||||
#include "packets/cPacket_PickupSpawn.h"
|
||||
#include "packets/cPacket_CollectItem.h"
|
||||
|
||||
#include "Vector3d.h"
|
||||
|
@ -30,10 +28,9 @@
|
|||
|
||||
CLASS_DEFINITION( cPickup, cEntity )
|
||||
|
||||
cPickup::~cPickup()
|
||||
{
|
||||
delete m_Item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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 )
|
||||
|
@ -44,18 +41,7 @@ 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 )
|
||||
{
|
||||
|
||||
//LOG("New pickup: ID(%i) Amount(%i) Health(%i)", m_Item.m_ItemID, m_Item.m_ItemCount, m_Item.m_ItemHealth );
|
||||
|
||||
// Spawn it on clients
|
||||
if (!a_Item.IsEmpty())
|
||||
{
|
||||
std::auto_ptr<cPacket> PickupSpawn(GetSpawnPacket());
|
||||
if (PickupSpawn.get() != NULL)
|
||||
{
|
||||
cRoot::Get()->GetServer()->Broadcast(*(PickupSpawn.get()));
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
@ -64,59 +50,28 @@ cPickup::cPickup(int a_X, int a_Y, int a_Z, const cItem & a_Item, float a_SpeedX
|
|||
|
||||
|
||||
|
||||
cPickup::cPickup(cPacket_PickupSpawn* a_PickupSpawnPacket)
|
||||
: cEntity( ((double)a_PickupSpawnPacket->m_PosX)/32, ((double)a_PickupSpawnPacket->m_PosY)/32, ((double)a_PickupSpawnPacket->m_PosZ)/32 )
|
||||
, m_Speed( new Vector3f() )
|
||||
, m_ResultingSpeed(new Vector3f())
|
||||
, m_WaterSpeed(new Vector3f())
|
||||
, m_bOnGround( false )
|
||||
, m_bReplicated( false )
|
||||
, m_Timer( 0.f )
|
||||
, m_bCollected( false )
|
||||
cPickup::~cPickup()
|
||||
{
|
||||
a_PickupSpawnPacket->m_UniqueID = m_UniqueID;
|
||||
|
||||
m_Item = new cItem();
|
||||
m_Item->m_ItemID = (ENUM_ITEM_ID)a_PickupSpawnPacket->m_Item;
|
||||
m_Item->m_ItemCount = a_PickupSpawnPacket->m_Count;
|
||||
m_Item->m_ItemHealth = 0x0;
|
||||
|
||||
m_Speed.x = (float)(a_PickupSpawnPacket->m_Rotation) / 8;
|
||||
m_Speed.y = (float)(a_PickupSpawnPacket->m_Pitch) / 8;
|
||||
m_Speed.z = (float)(a_PickupSpawnPacket->m_Roll) / 8;
|
||||
|
||||
// Spawn it on clients
|
||||
if (a_PickupSpawnPacket->m_Item != E_ITEM_EMPTY)
|
||||
{
|
||||
cRoot::Get()->GetServer()->Broadcast( *a_PickupSpawnPacket );
|
||||
}
|
||||
|
||||
m_EntityType = eEntityType_Pickup;
|
||||
delete m_Item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cPacket * cPickup::GetSpawnPacket(void) const
|
||||
void cPickup::Initialize(cWorld * a_World)
|
||||
{
|
||||
if (m_Item->IsEmpty())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cPacket_PickupSpawn * PickupSpawn = new cPacket_PickupSpawn;
|
||||
PickupSpawn->m_UniqueID = m_UniqueID;
|
||||
PickupSpawn->m_Item = (short)m_Item->m_ItemID;
|
||||
PickupSpawn->m_Count = m_Item->m_ItemCount;
|
||||
PickupSpawn->m_Health = m_Item->m_ItemHealth;
|
||||
PickupSpawn->m_PosX = (int) (m_Pos.x * 32);
|
||||
PickupSpawn->m_PosY = (int) (m_Pos.y * 32);
|
||||
PickupSpawn->m_PosZ = (int) (m_Pos.z * 32);
|
||||
PickupSpawn->m_Rotation = (char)(m_Speed.x * 8);
|
||||
PickupSpawn->m_Pitch = (char)(m_Speed.y * 8);
|
||||
PickupSpawn->m_Roll = (char)(m_Speed.z * 8);
|
||||
return PickupSpawn;
|
||||
super::Initialize(a_World);
|
||||
a_World->BroadcastSpawn(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cPickup::SpawnOn(cClientHandle & a_Client)
|
||||
{
|
||||
a_Client.SendPickupSpawn(*this);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,24 +14,35 @@ class cItem;
|
|||
|
||||
|
||||
|
||||
class cPickup : public cEntity //tolua_export
|
||||
{ //tolua_export
|
||||
// tolua_begin
|
||||
class cPickup :
|
||||
public cEntity
|
||||
{
|
||||
// tolua_end
|
||||
typedef cEntity super;
|
||||
// tolua_begin
|
||||
|
||||
public:
|
||||
// tolua_end
|
||||
CLASS_PROTOTYPE();
|
||||
|
||||
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(cPacket_PickupSpawn * a_PickupSpawnPacket); //tolua_export
|
||||
~cPickup(); //tolua_export
|
||||
|
||||
virtual void Initialize(cWorld * a_World) override;
|
||||
|
||||
cItem * GetItem() { return m_Item; } //tolua_export
|
||||
cItem * GetItem(void) {return m_Item; } //tolua_export
|
||||
const cItem * GetItem(void) const {return m_Item; }
|
||||
|
||||
virtual cPacket * GetSpawnPacket(void) const override;
|
||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||
|
||||
virtual bool CollectedBy( cPlayer* a_Dest ); //tolua_export
|
||||
|
||||
void Tick(float a_Dt);
|
||||
void HandlePhysics(float a_Dt);
|
||||
|
||||
const Vector3f & GetSpeed(void) const {return m_Speed; }
|
||||
|
||||
private:
|
||||
|
||||
Vector3f m_Speed;
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "cClientHandle.h"
|
||||
#include "cWorld.h"
|
||||
#include "BlockID.h"
|
||||
#include "packets/cPacket_BlockAction.h"
|
||||
#include "cServer.h"
|
||||
#include "blocks/Block.h"
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
#include "cTimer.h"
|
||||
#include "MersenneTwister.h"
|
||||
|
||||
#include "packets/cPacket_NamedEntitySpawn.h"
|
||||
|
||||
#include "Vector3d.h"
|
||||
#include "Vector3f.h"
|
||||
|
||||
|
@ -102,16 +100,6 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
|
|||
|
||||
|
||||
|
||||
void cPlayer::Initialize( cWorld* a_World )
|
||||
{
|
||||
cPawn::Initialize( a_World );
|
||||
GetWorld()->AddPlayer( this );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cPlayer::~cPlayer(void)
|
||||
{
|
||||
LOG("Deleting cPlayer \"%s\" at %p, ID %d", m_PlayerName.c_str(), this, GetUniqueID());
|
||||
|
@ -134,6 +122,16 @@ cPlayer::~cPlayer(void)
|
|||
|
||||
|
||||
|
||||
void cPlayer::Initialize( cWorld* a_World )
|
||||
{
|
||||
cPawn::Initialize( a_World );
|
||||
GetWorld()->AddPlayer( this );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cPlayer::Destroyed()
|
||||
{
|
||||
CloseWindow(-1);
|
||||
|
@ -144,28 +142,18 @@ void cPlayer::Destroyed()
|
|||
|
||||
|
||||
|
||||
cPacket * cPlayer::GetSpawnPacket(void) const
|
||||
void cPlayer::SpawnOn(cClientHandle & a_Client)
|
||||
{
|
||||
LOGD("cPlayer::GetSpawnPacket for \"%s\" at pos {%.2f, %.2f, %.2f}",
|
||||
m_PlayerName.c_str(), m_Pos.x, m_Pos.y, m_Pos.z
|
||||
/*
|
||||
LOGD("cPlayer::SpawnOn(%s) for \"%s\" at pos {%.2f, %.2f, %.2f}",
|
||||
a_Client.GetUsername().c_str(), m_PlayerName.c_str(), m_Pos.x, m_Pos.y, m_Pos.z
|
||||
);
|
||||
|
||||
if (!m_bVisible )
|
||||
*/
|
||||
|
||||
if (m_bVisible)
|
||||
{
|
||||
return NULL;
|
||||
a_Client.SendPlayerSpawn(*this);
|
||||
}
|
||||
|
||||
cPacket_NamedEntitySpawn * SpawnPacket = new cPacket_NamedEntitySpawn;
|
||||
SpawnPacket->m_UniqueID = m_UniqueID;
|
||||
SpawnPacket->m_PlayerName = m_PlayerName;
|
||||
SpawnPacket->m_PosX = (int)(m_Pos.x * 32);
|
||||
SpawnPacket->m_PosY = (int)(m_Pos.y * 32);
|
||||
SpawnPacket->m_PosZ = (int)(m_Pos.z * 32);
|
||||
SpawnPacket->m_Rotation = (char)((m_Rot.x / 360.f) * 256);
|
||||
SpawnPacket->m_Pitch = (char)((m_Rot.y / 360.f) * 256);
|
||||
short ItemID = (short)m_Inventory->GetEquippedItem().m_ItemID;
|
||||
SpawnPacket->m_CurrentItem = (ItemID > 0) ? ItemID : 0; // Unlike -1 in inventory, the named entity packet uses 0 for "none"
|
||||
return SpawnPacket;
|
||||
}
|
||||
|
||||
|
||||
|
@ -603,7 +591,7 @@ void cPlayer::SetVisible(bool a_bVisible)
|
|||
if (a_bVisible && !m_bVisible) // Make visible
|
||||
{
|
||||
m_bVisible = true;
|
||||
SpawnOn(NULL); // Spawn on all clients
|
||||
m_World->BroadcastSpawn(*this);
|
||||
}
|
||||
if (!a_bVisible && m_bVisible)
|
||||
{
|
||||
|
@ -620,7 +608,7 @@ void cPlayer::AddToGroup( const char* a_GroupName )
|
|||
{
|
||||
cGroup* Group = cRoot::Get()->GetGroupManager()->GetGroup( a_GroupName );
|
||||
m_Groups.push_back( Group );
|
||||
LOG("Added %s to group %s", m_PlayerName.c_str(), a_GroupName );
|
||||
LOGD("Added %s to group %s", m_PlayerName.c_str(), a_GroupName );
|
||||
ResolveGroups();
|
||||
ResolvePermissions();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,8 @@ public:
|
|||
|
||||
virtual void Initialize( cWorld* a_World ); //tolua_export
|
||||
|
||||
virtual cPacket * GetSpawnPacket(void) const override;
|
||||
virtual void SpawnOn(cClientHandle & a_Client) override;
|
||||
|
||||
virtual void Tick(float a_Dt) override;
|
||||
|
||||
void SetTouchGround( bool a_bTouchGround );
|
||||
|
@ -42,11 +43,14 @@ public:
|
|||
inline bool GetFlying() { return m_bTouchGround; } //tolua_export
|
||||
inline bool IsOnGround(void) const {return m_bTouchGround; } // tolua_export
|
||||
inline const double GetStance(void) const { return m_Pos.y + 1.62; } //tolua_export // TODO: Proper stance when crouching etc.
|
||||
inline cInventory & GetInventory() { if(GetGameMode() == eGameMode_Survival) return *m_Inventory; else return *m_CreativeInventory; } //tolua_export
|
||||
inline cInventory & GetInventory(void) { if (GetGameMode() == eGameMode_Survival) return *m_Inventory; else return *m_CreativeInventory; } //tolua_export
|
||||
inline const cInventory & GetInventory(void) const { if (GetGameMode() == eGameMode_Survival) return *m_Inventory; else return *m_CreativeInventory; }
|
||||
|
||||
inline const cItem & GetEquippedItem(void) const {return GetInventory().GetEquippedItem(); }
|
||||
|
||||
virtual void TeleportTo( const double & a_PosX, const double & a_PosY, const double & a_PosZ ); //tolua_export
|
||||
|
||||
eGameMode GetGameMode() { return m_GameMode; } //tolua_export
|
||||
eGameMode GetGameMode(void) const { return m_GameMode; } //tolua_export
|
||||
std::string GetIP() { return m_IP; } //tolua_export
|
||||
float GetLastBlockActionTime() { return m_LastBlockActionTime; } //tolua_export
|
||||
int GetLastBlockActionCnt() { return m_LastBlockActionCnt; } //tolua_export
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include "../iniFile/iniFile.h"
|
||||
#include "Vector3f.h"
|
||||
|
||||
#include "packets/cPacket_Chat.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
@ -286,16 +284,33 @@ cServer::~cServer()
|
|||
|
||||
|
||||
// TODO - Need to modify this or something, so it broadcasts to all worlds? And move this to cWorld?
|
||||
void cServer::Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude /* = 0 */ )
|
||||
void cServer::Broadcast(const cPacket & a_Packet, cClientHandle * a_Exclude)
|
||||
{
|
||||
cCSLock Lock(m_CSClients);
|
||||
for( ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr)
|
||||
for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr)
|
||||
{
|
||||
if ((*itr == a_Exclude) || !(*itr)->IsLoggedIn())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
(*itr)->Send( a_Packet );
|
||||
(*itr)->Send(a_Packet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cServer::BroadcastChat(const AString & a_Message, const cClientHandle * a_Exclude)
|
||||
{
|
||||
cCSLock Lock(m_CSClients);
|
||||
for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr)
|
||||
{
|
||||
if ((*itr == a_Exclude) || !(*itr)->IsLoggedIn())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
(*itr)->SendChat(a_Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -520,9 +535,10 @@ void cServer::ServerCommand(const AString & a_Cmd)
|
|||
{
|
||||
if (split[0].compare("say") == 0)
|
||||
{
|
||||
AString Message = cChatColor::Purple + "[SERVER] " + a_Cmd.substr(a_Cmd.find_first_of("say") + 4);
|
||||
LOG("%s", Message.c_str() );
|
||||
Broadcast(cPacket_Chat(Message));
|
||||
AString ToSay = a_Cmd.substr(a_Cmd.find_first_of("say") + 4);
|
||||
AString Message = cChatColor::Purple + "[SERVER] " + ToSay;
|
||||
LOG("[SERVER]: %s", ToSay.c_str());
|
||||
BroadcastChat(Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -534,17 +550,19 @@ void cServer::ServerCommand(const AString & a_Cmd)
|
|||
|
||||
|
||||
|
||||
void cServer::SendMessage( const char* a_Message, cPlayer* a_Player /* = 0 */, bool a_bExclude /* = false */ )
|
||||
void cServer::SendMessage(const AString & a_Message, cPlayer * a_Player /* = NULL */, bool a_bExclude /* = false */ )
|
||||
{
|
||||
cPacket_Chat Chat( a_Message );
|
||||
if( a_Player && !a_bExclude )
|
||||
if ((a_Player != NULL) && !a_bExclude)
|
||||
{
|
||||
cClientHandle* Client = a_Player->GetClientHandle();
|
||||
if( Client ) Client->Send( Chat );
|
||||
cClientHandle * Client = a_Player->GetClientHandle();
|
||||
if (Client != NULL)
|
||||
{
|
||||
Client->SendChat(a_Message);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Broadcast( Chat, (a_Player)?a_Player->GetClientHandle():0 );
|
||||
BroadcastChat(a_Message, (a_Player != NULL) ? a_Player->GetClientHandle() : NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ public: //tolua_export
|
|||
void StartListenClient(); // Listen to client
|
||||
|
||||
void Broadcast(const cPacket & a_Packet, cClientHandle* a_Exclude = NULL);
|
||||
void BroadcastChat(const AString & a_Message, const cClientHandle * a_Exclude = NULL);
|
||||
|
||||
bool Tick(float a_Dt);
|
||||
|
||||
|
@ -48,7 +49,7 @@ public: //tolua_export
|
|||
void ServerCommand(const AString & a_Cmd); //tolua_export
|
||||
void Shutdown();
|
||||
|
||||
void SendMessage( const char* a_Message, cPlayer* a_Player = 0, bool a_bExclude = false ); //tolua_export
|
||||
void SendMessage(const AString & a_Message, cPlayer * a_Player = NULL, bool a_bExclude = false ); // tolua_export
|
||||
|
||||
void KickUser(int a_ClientID, const AString & a_Reason);
|
||||
void AuthenticateUser(int a_ClientID); // Called by cAuthenticator to auth the specified user
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
#include "cWorld.h"
|
||||
#include "cRoot.h"
|
||||
|
||||
#include "packets/cPacket_UpdateSign.h"
|
||||
|
||||
#include <json/json.h>
|
||||
|
||||
|
||||
|
@ -80,17 +78,9 @@ AString cSignEntity::GetLine( int a_Index ) const
|
|||
|
||||
|
||||
|
||||
cPacket * cSignEntity::GetPacket(void)
|
||||
void cSignEntity::SendTo(cClientHandle & a_Client)
|
||||
{
|
||||
cPacket_UpdateSign * Sign = new cPacket_UpdateSign;
|
||||
Sign->m_BlockX = m_PosX;
|
||||
Sign->m_BlockY = (short)m_PosY;
|
||||
Sign->m_BlockZ = m_PosZ;
|
||||
Sign->m_Line1 = m_Line[0];
|
||||
Sign->m_Line2 = m_Line[1];
|
||||
Sign->m_Line3 = m_Line[2];
|
||||
Sign->m_Line4 = m_Line[3];
|
||||
return Sign;
|
||||
a_Client.SendUpdateSign(m_PosX, m_PosY, m_PosZ, m_Line[0], m_Line[1], m_Line[2], m_Line[3]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,8 +32,7 @@ public:
|
|||
AString GetLine( int a_Index ) const;
|
||||
|
||||
virtual void UsedBy( cPlayer * a_Player ) override;
|
||||
|
||||
virtual cPacket * GetPacket(void) override;
|
||||
virtual void SendTo(cClientHandle & a_Client) override;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -723,9 +723,9 @@ void cWorld::TickSpawnMobs(float a_Dt)
|
|||
|
||||
if( Monster )
|
||||
{
|
||||
Monster->Initialize( this );
|
||||
Monster->TeleportTo( SpawnPos.x, (double)(Height) + 2, SpawnPos.z );
|
||||
Monster->SpawnOn(0);
|
||||
Monster->Initialize(this);
|
||||
Monster->TeleportTo(SpawnPos.x, (double)(Height) + 2, SpawnPos.z);
|
||||
BroadcastSpawn(*Monster);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1134,7 +1134,7 @@ void cWorld::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYP
|
|||
void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed)
|
||||
{
|
||||
MTRand r1;
|
||||
a_FlyAwaySpeed /= 1000; // Pre-divide, so that we can don't have to divide each time inside the loop
|
||||
a_FlyAwaySpeed /= 1000; // Pre-divide, so that we don't have to divide each time inside the loop
|
||||
for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr)
|
||||
{
|
||||
float SpeedX = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500));
|
||||
|
@ -1390,6 +1390,33 @@ void cWorld::BroadcastMetadata(const cPawn & a_Pawn, const cClientHandle * a_Exc
|
|||
|
||||
|
||||
|
||||
void cWorld::BroadcastSpawn(cEntity & a_Entity, const cClientHandle * a_Exclude)
|
||||
{
|
||||
m_ChunkMap->BroadcastSpawn(a_Entity, a_Exclude);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cWorld::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude)
|
||||
{
|
||||
m_ChunkMap->BroadcastBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_Exclude);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cWorld::SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client)
|
||||
{
|
||||
m_ChunkMap->SendBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_Client);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cWorld::MarkChunkDirty (int a_ChunkX, int a_ChunkY, int a_ChunkZ)
|
||||
{
|
||||
m_ChunkMap->MarkChunkDirty (a_ChunkX, a_ChunkY, a_ChunkZ);
|
||||
|
|
|
@ -90,6 +90,13 @@ public:
|
|||
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastMetadata (const cPawn & a_Pawn, const cClientHandle * a_Exclude = NULL);
|
||||
void BroadcastSpawn (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
||||
|
||||
/// If there is a block entity at the specified coods, sends it to all clients except a_Exclude
|
||||
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
|
||||
|
||||
/// If there is a block entity at the specified coords, sends it to the client specified
|
||||
void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
|
||||
|
||||
void MarkChunkDirty (int a_ChunkX, int a_ChunkY, int a_ChunkZ);
|
||||
void MarkChunkSaving(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
|
||||
|
|
|
@ -10,16 +10,16 @@
|
|||
int cPacket_PickupSpawn::Parse(cByteBuffer & a_Buffer)
|
||||
{
|
||||
int TotalBytes = 0;
|
||||
HANDLE_PACKET_READ(ReadBEInt, m_UniqueID, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadBEShort, m_Item, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadChar, m_Count, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadBEShort, m_Health, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadBEInt, m_PosX, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadBEInt, m_PosY, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadBEInt, m_PosZ, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadChar, m_Rotation, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadChar, m_Pitch, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadChar, m_Roll, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadBEInt, m_UniqueID, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadBEShort, m_ItemType, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadChar, m_ItemCount, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadBEShort, m_ItemDamage, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadBEInt, m_PosX, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadBEInt, m_PosY, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadBEInt, m_PosZ, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadChar, m_Rotation, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadChar, m_Pitch, TotalBytes);
|
||||
HANDLE_PACKET_READ(ReadChar, m_Roll, TotalBytes);
|
||||
return TotalBytes;
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,9 @@ void cPacket_PickupSpawn::Serialize(AString & a_Data) const
|
|||
{
|
||||
AppendByte (a_Data, m_PacketID);
|
||||
AppendInteger(a_Data, m_UniqueID);
|
||||
AppendShort (a_Data, m_Item);
|
||||
AppendByte (a_Data, m_Count);
|
||||
AppendShort (a_Data, m_Health);
|
||||
AppendShort (a_Data, m_ItemType);
|
||||
AppendByte (a_Data, m_ItemCount);
|
||||
AppendShort (a_Data, m_ItemDamage);
|
||||
AppendInteger(a_Data, m_PosX);
|
||||
AppendInteger(a_Data, m_PosY);
|
||||
AppendInteger(a_Data, m_PosZ);
|
||||
|
|
|
@ -12,33 +12,34 @@ class cPacket_PickupSpawn : public cPacket
|
|||
public:
|
||||
cPacket_PickupSpawn()
|
||||
: m_UniqueID( 0 )
|
||||
, m_Item( 0 )
|
||||
, m_Count( 0 )
|
||||
, m_Health( 0 )
|
||||
, m_ItemType( 0 )
|
||||
, m_ItemCount( 0 )
|
||||
, m_ItemDamage( 0 )
|
||||
, m_PosX( 0 )
|
||||
, m_PosY( 0 )
|
||||
, m_PosZ( 0 )
|
||||
, m_Rotation( 0 )
|
||||
, m_Pitch( 0 )
|
||||
, m_Roll( 0 )
|
||||
{ m_PacketID = E_PICKUP_SPAWN; }
|
||||
{
|
||||
m_PacketID = E_PICKUP_SPAWN;
|
||||
}
|
||||
|
||||
virtual cPacket* Clone() const { return new cPacket_PickupSpawn(*this); }
|
||||
|
||||
virtual int Parse(cByteBuffer & a_Buffer) override;
|
||||
virtual int Parse(cByteBuffer & a_Buffer) override;
|
||||
virtual void Serialize(AString & a_Data) const override;
|
||||
|
||||
int m_UniqueID;
|
||||
short m_Item;
|
||||
char m_Count;
|
||||
short m_Health;
|
||||
int m_PosX;
|
||||
int m_PosY;
|
||||
int m_PosZ;
|
||||
char m_Rotation;
|
||||
char m_Pitch;
|
||||
char m_Roll;
|
||||
|
||||
static const unsigned int c_Size = 1 + 4 + 2 + 1 + 2 + 4 + 4 + 4 + 1 + 1 + 1;
|
||||
int m_UniqueID;
|
||||
short m_ItemType;
|
||||
char m_ItemCount;
|
||||
short m_ItemDamage;
|
||||
int m_PosX;
|
||||
int m_PosY;
|
||||
int m_PosZ;
|
||||
char m_Rotation;
|
||||
char m_Pitch;
|
||||
char m_Roll;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
cPacket_SpawnMob::~cPacket_SpawnMob()
|
||||
{
|
||||
if( m_MetaData ) delete [] m_MetaData;
|
||||
delete m_Pos;
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,7 +20,6 @@ cPacket_SpawnMob::~cPacket_SpawnMob()
|
|||
cPacket_SpawnMob::cPacket_SpawnMob()
|
||||
: m_UniqueID( 0 )
|
||||
, m_Type( 0 )
|
||||
, m_Pos( new Vector3i() )
|
||||
, m_Yaw( 0 )
|
||||
, m_Pitch( 0 )
|
||||
, m_MetaDataSize( 0 )
|
||||
|
@ -37,12 +35,10 @@ cPacket_SpawnMob::cPacket_SpawnMob()
|
|||
|
||||
cPacket_SpawnMob::cPacket_SpawnMob( const cPacket_SpawnMob & a_Clone )
|
||||
{
|
||||
m_Pos = new Vector3i();
|
||||
|
||||
m_PacketID = E_SPAWN_MOB;
|
||||
m_UniqueID = a_Clone.m_UniqueID;
|
||||
m_Type = a_Clone.m_Type;
|
||||
*m_Pos = *a_Clone.m_Pos;
|
||||
m_Pos = a_Clone.m_Pos;
|
||||
m_Yaw = a_Clone.m_Yaw;
|
||||
m_Pitch = a_Clone.m_Pitch;
|
||||
m_HeadYaw = a_Clone.m_HeadYaw;
|
||||
|
@ -61,9 +57,9 @@ void cPacket_SpawnMob::Serialize(AString & a_Data) const
|
|||
AppendByte (a_Data, m_PacketID);
|
||||
AppendInteger (a_Data, m_UniqueID);
|
||||
AppendByte (a_Data, m_Type);
|
||||
AppendInteger (a_Data, m_Pos->x);
|
||||
AppendInteger (a_Data, m_Pos->y);
|
||||
AppendInteger (a_Data, m_Pos->z);
|
||||
AppendInteger (a_Data, m_Pos.x);
|
||||
AppendInteger (a_Data, m_Pos.y);
|
||||
AppendInteger (a_Data, m_Pos.z);
|
||||
AppendByte (a_Data, m_Yaw);
|
||||
AppendByte (a_Data, m_Pitch);
|
||||
AppendByte (a_Data, m_HeadYaw);
|
||||
|
|
|
@ -2,18 +2,14 @@
|
|||
#pragma once
|
||||
|
||||
#include "cPacket.h"
|
||||
#include "../Vector3i.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Vector3i;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class cPacket_SpawnMob : public cPacket
|
||||
class cPacket_SpawnMob :
|
||||
public cPacket
|
||||
{
|
||||
public:
|
||||
cPacket_SpawnMob();
|
||||
|
@ -23,15 +19,15 @@ public:
|
|||
|
||||
virtual void Serialize(AString & a_Data) const override;
|
||||
|
||||
int m_UniqueID;
|
||||
char m_Type;
|
||||
Vector3i* m_Pos;
|
||||
char m_Yaw;
|
||||
char m_Pitch;
|
||||
char m_HeadYaw;
|
||||
int m_UniqueID;
|
||||
char m_Type;
|
||||
Vector3i m_Pos;
|
||||
char m_Yaw;
|
||||
char m_Pitch;
|
||||
char m_HeadYaw;
|
||||
|
||||
unsigned int m_MetaDataSize;
|
||||
char * m_MetaData;
|
||||
char * m_MetaData;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ public:
|
|||
m_PacketID = E_UPDATE_SIGN;
|
||||
}
|
||||
|
||||
virtual cPacket * Clone() const { return new cPacket_UpdateSign( *this ); }
|
||||
virtual cPacket * Clone() const { return new cPacket_UpdateSign( *this); }
|
||||
|
||||
virtual int Parse(cByteBuffer & a_Buffer) override;
|
||||
virtual void Serialize(AString & a_Data) const override;
|
||||
|
|
|
@ -65,8 +65,6 @@ void BindSquirrel(HSQUIRRELVM vm)
|
|||
.Func("GetUniqueID", &cEntity::GetUniqueID)
|
||||
.Func("IsDestroyed", &cEntity::IsDestroyed)
|
||||
.Func("Destroy", &cEntity::Destroy)
|
||||
.Func("SpawnOn", &cEntity::SpawnOn)
|
||||
|
||||
);
|
||||
|
||||
ConstTable().Enum("MetaData", Enumeration()
|
||||
|
|
Loading…
Reference in New Issue