Window, Chest, Furnace and Pawn are not using cPackets at all
git-svn-id: http://mc-server.googlecode.com/svn/trunk@762 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
427e582d5f
commit
674fe1e955
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "cBlockEntity.h"
|
#include "cBlockEntity.h"
|
||||||
#include "cWindowOwner.h"
|
#include "cWindowOwner.h"
|
||||||
#include "packets/cPacket_BlockAction.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1883,6 +1883,38 @@ void cChunk::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandl
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cChunk::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude)
|
||||||
|
{
|
||||||
|
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
|
||||||
|
{
|
||||||
|
if (*itr == a_Exclude)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
(*itr)->SendEntityStatus(a_Entity, a_Status);
|
||||||
|
} // for itr - LoadedByClient[]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cChunk::BroadcastMetadata(const cPawn & a_Pawn, const cClientHandle * a_Exclude)
|
||||||
|
{
|
||||||
|
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
|
||||||
|
{
|
||||||
|
if (*itr == a_Exclude)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
(*itr)->SendMetadata(a_Pawn);
|
||||||
|
} // for itr - LoadedByClient[]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::PositionToWorldPosition(int a_ChunkX, int a_ChunkY, int a_ChunkZ, int & a_X, int & a_Y, int & a_Z)
|
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;
|
a_Y = a_ChunkY;
|
||||||
|
@ -41,6 +41,7 @@ class cChunkMap;
|
|||||||
class cChestEntity;
|
class cChestEntity;
|
||||||
class cFurnaceEntity;
|
class cFurnaceEntity;
|
||||||
class cBlockArea;
|
class cBlockArea;
|
||||||
|
class cPawn;
|
||||||
|
|
||||||
typedef std::list<cClientHandle *> cClientHandleList;
|
typedef std::list<cClientHandle *> cClientHandleList;
|
||||||
typedef cItemCallback<cEntity> cEntityCallback;
|
typedef cItemCallback<cEntity> cEntityCallback;
|
||||||
@ -182,7 +183,9 @@ public:
|
|||||||
void BroadcastEntLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
void BroadcastEntLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
||||||
void BroadcastEntHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
void BroadcastEntHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
||||||
void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, const cClientHandle * a_Exclude = NULL);
|
void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, const cClientHandle * a_Exclude = NULL);
|
||||||
void BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
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 PositionToWorldPosition(int a_ChunkX, int a_ChunkY, int a_ChunkZ, int & a_X, int & a_Y, int & a_Z);
|
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 ); }
|
Vector3i PositionToWorldPosition( const Vector3i & a_InChunkPos ) { return PositionToWorldPosition( a_InChunkPos.x, a_InChunkPos.y, a_InChunkPos.z ); }
|
||||||
|
@ -402,6 +402,39 @@ void cChunkMap::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHa
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cChunkMap::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, 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->BroadcastEntityStatus(a_Entity, a_Status, a_Exclude);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cChunkMap::BroadcastMetadata(const cPawn & a_Pawn, const cClientHandle * a_Exclude)
|
||||||
|
{
|
||||||
|
cCSLock Lock(m_CSLayers);
|
||||||
|
cChunkPtr Chunk = GetChunkNoGen(a_Pawn.GetChunkX(), a_Pawn.GetChunkY(), a_Pawn.GetChunkZ());
|
||||||
|
if (Chunk == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// It's perfectly legal to broadcast packets even to invalid chunks!
|
||||||
|
Chunk->BroadcastMetadata(a_Pawn, a_Exclude);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunkMap::UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
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
|
// a_Player rclked block entity at the coords specified, handle it
|
||||||
|
@ -20,6 +20,7 @@ class cPacket;
|
|||||||
class cPlayer;
|
class cPlayer;
|
||||||
class cChestEntity;
|
class cChestEntity;
|
||||||
class cFurnaceEntity;
|
class cFurnaceEntity;
|
||||||
|
class cPawn;
|
||||||
|
|
||||||
typedef std::list<cClientHandle *> cClientHandleList;
|
typedef std::list<cClientHandle *> cClientHandleList;
|
||||||
typedef cChunk * cChunkPtr;
|
typedef cChunk * cChunkPtr;
|
||||||
@ -70,6 +71,10 @@ public:
|
|||||||
|
|
||||||
void BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
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);
|
||||||
|
|
||||||
/// a_Player rclked block entity at the coords specified, handle it
|
/// 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);
|
void UseBlockEntity(cPlayer * a_Player, int a_X, int a_Y, int a_Z);
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include "packets/cPacket_13.h"
|
#include "packets/cPacket_13.h"
|
||||||
#include "packets/cPacket_ArmAnim.h"
|
#include "packets/cPacket_ArmAnim.h"
|
||||||
|
#include "packets/cPacket_BlockAction.h"
|
||||||
#include "packets/cPacket_BlockChange.h"
|
#include "packets/cPacket_BlockChange.h"
|
||||||
#include "packets/cPacket_BlockDig.h"
|
#include "packets/cPacket_BlockDig.h"
|
||||||
#include "packets/cPacket_BlockPlace.h"
|
#include "packets/cPacket_BlockPlace.h"
|
||||||
@ -50,8 +51,10 @@
|
|||||||
#include "packets/cPacket_Disconnect.h"
|
#include "packets/cPacket_Disconnect.h"
|
||||||
#include "packets/cPacket_EntityEquipment.h"
|
#include "packets/cPacket_EntityEquipment.h"
|
||||||
#include "packets/cPacket_EntityLook.h"
|
#include "packets/cPacket_EntityLook.h"
|
||||||
|
#include "packets/cPacket_EntityStatus.h"
|
||||||
#include "packets/cPacket_Flying.h"
|
#include "packets/cPacket_Flying.h"
|
||||||
#include "packets/cPacket_Handshake.h"
|
#include "packets/cPacket_Handshake.h"
|
||||||
|
#include "packets/cPacket_InventoryProgressBar.h"
|
||||||
#include "packets/cPacket_InventorySlot.h"
|
#include "packets/cPacket_InventorySlot.h"
|
||||||
#include "packets/cPacket_ItemSwitch.h"
|
#include "packets/cPacket_ItemSwitch.h"
|
||||||
#include "packets/cPacket_KeepAlive.h"
|
#include "packets/cPacket_KeepAlive.h"
|
||||||
@ -1779,6 +1782,42 @@ void cClientHandle::SendPlayerMoveLook(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cClientHandle::SendEntityStatus(const cEntity & a_Entity, char a_Status)
|
||||||
|
{
|
||||||
|
cPacket_EntityStatus es;
|
||||||
|
es.m_Status = a_Status;
|
||||||
|
es.m_UniqueID = a_Entity.GetUniqueID();
|
||||||
|
Send(es);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cClientHandle::SendMetadata(const cPawn & a_Pawn)
|
||||||
|
{
|
||||||
|
cPacket_Metadata md(a_Pawn.GetMetaData(), a_Pawn.GetUniqueID());
|
||||||
|
Send(md);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cClientHandle::SendInventoryProgress(char a_WindowID, short a_ProgressBar, short a_Value)
|
||||||
|
{
|
||||||
|
cPacket_InventoryProgressBar Progress;
|
||||||
|
Progress.m_WindowID = a_WindowID;
|
||||||
|
Progress.m_ProgressBar = a_ProgressBar;
|
||||||
|
Progress.m_Value = a_Value;
|
||||||
|
Progress.m_WindowID = a_WindowID;
|
||||||
|
Send(Progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cClientHandle::CheckIfWorldDownloaded(void)
|
void cClientHandle::CheckIfWorldDownloaded(void)
|
||||||
{
|
{
|
||||||
if (m_State != csDownloadingWorld)
|
if (m_State != csDownloadingWorld)
|
||||||
|
@ -32,6 +32,7 @@ class cPlayer;
|
|||||||
class cRedstone;
|
class cRedstone;
|
||||||
class cInventory;
|
class cInventory;
|
||||||
class cWindow;
|
class cWindow;
|
||||||
|
class cPawn;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -103,6 +104,9 @@ public:
|
|||||||
void SendGameMode(char a_GameMode);
|
void SendGameMode(char a_GameMode);
|
||||||
void SendDestroyEntity(const cEntity & a_Entity);
|
void SendDestroyEntity(const cEntity & a_Entity);
|
||||||
void SendPlayerMoveLook(void);
|
void SendPlayerMoveLook(void);
|
||||||
|
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);
|
||||||
|
|
||||||
const AString & GetUsername(void) const; //tolua_export
|
const AString & GetUsername(void) const; //tolua_export
|
||||||
|
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
#include "cReferenceManager.h"
|
#include "cReferenceManager.h"
|
||||||
#include "cClientHandle.h"
|
#include "cClientHandle.h"
|
||||||
|
|
||||||
#include "packets/cPacket_DestroyEntity.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -115,11 +113,7 @@ void cEntity::MoveToCorrectChunk(bool a_bIgnoreOldChunk)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_Destroy == NULL)
|
a_Client->SendDestroyEntity(*m_Entity);
|
||||||
{
|
|
||||||
m_Destroy = new cPacket_DestroyEntity(m_Entity);
|
|
||||||
}
|
|
||||||
a_Client->Send(*m_Destroy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Added(cClientHandle * a_Client) override
|
virtual void Added(cClientHandle * a_Client) override
|
||||||
@ -134,14 +128,12 @@ void cEntity::MoveToCorrectChunk(bool a_bIgnoreOldChunk)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cPacket * m_Destroy;
|
|
||||||
cPacket * m_Spawn;
|
cPacket * m_Spawn;
|
||||||
bool m_IgnoreOldChunk;
|
bool m_IgnoreOldChunk;
|
||||||
cEntity * m_Entity;
|
cEntity * m_Entity;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cMover(cEntity * a_Entity, bool a_IgnoreOldChunk) :
|
cMover(cEntity * a_Entity, bool a_IgnoreOldChunk) :
|
||||||
m_Destroy(NULL),
|
|
||||||
m_Spawn(NULL),
|
m_Spawn(NULL),
|
||||||
m_IgnoreOldChunk(a_IgnoreOldChunk),
|
m_IgnoreOldChunk(a_IgnoreOldChunk),
|
||||||
m_Entity(a_Entity)
|
m_Entity(a_Entity)
|
||||||
@ -150,7 +142,6 @@ void cEntity::MoveToCorrectChunk(bool a_bIgnoreOldChunk)
|
|||||||
~cMover()
|
~cMover()
|
||||||
{
|
{
|
||||||
delete m_Spawn;
|
delete m_Spawn;
|
||||||
delete m_Destroy;
|
|
||||||
}
|
}
|
||||||
} Mover(this, a_bIgnoreOldChunk);
|
} Mover(this, a_bIgnoreOldChunk);
|
||||||
|
|
||||||
@ -177,7 +168,7 @@ void cEntity::Destroy()
|
|||||||
RemoveFromChunk();
|
RemoveFromChunk();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_World->BroadcastToChunk(m_ChunkX, m_ChunkY, m_ChunkZ, cPacket_DestroyEntity(this));
|
m_World->BroadcastDestroyEntity(*this);
|
||||||
|
|
||||||
m_bDestroyed = true;
|
m_bDestroyed = true;
|
||||||
|
|
||||||
|
@ -48,25 +48,37 @@ class cPacket;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// tolua_begin
|
||||||
|
class cEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ENTITY_STATUS_HURT = 2,
|
||||||
|
ENTITY_STATUS_DEAD = 3,
|
||||||
|
ENTITY_STATUS_WOLF_TAMING = 6,
|
||||||
|
ENTITY_STATUS_WOLF_TAMED = 7,
|
||||||
|
ENTITY_STATUS_WOLF_SHAKING = 8,
|
||||||
|
ENTITY_STATUS_EATING_ACCEPTED = 9,
|
||||||
|
ENTITY_STATUS_SHEEP_EATING = 10,
|
||||||
|
} ;
|
||||||
|
|
||||||
class cEntity //tolua_export
|
cEntity(const double & a_X, const double & a_Y, const double & a_Z);
|
||||||
{ //tolua_export
|
virtual ~cEntity();
|
||||||
public: //tolua_export
|
|
||||||
cEntity(const double & a_X, const double & a_Y, const double & a_Z); //tolua_export
|
|
||||||
virtual ~cEntity(); //tolua_export
|
|
||||||
|
|
||||||
virtual void Initialize( cWorld* a_World ); //tolua_export
|
virtual void Initialize( cWorld* a_World );
|
||||||
|
|
||||||
enum eEntityType //tolua_export
|
enum eEntityType
|
||||||
{ //tolua_export
|
{
|
||||||
eEntityType_Entity, //tolua_export
|
eEntityType_Entity,
|
||||||
eEntityType_Player, //tolua_export
|
eEntityType_Player,
|
||||||
eEntityType_Pickup //tolua_export
|
eEntityType_Pickup
|
||||||
}; //tolua_export
|
};
|
||||||
|
|
||||||
virtual unsigned int GetEntityType() { return m_EntityType; } //tolua_export
|
virtual unsigned int GetEntityType() { return m_EntityType; }
|
||||||
virtual bool IsA( const char* a_EntityType ); //tolua_export
|
virtual bool IsA( const char* a_EntityType );
|
||||||
virtual const char* GetClass(); //tolua_export
|
virtual const char* GetClass();
|
||||||
|
// tolua_end
|
||||||
|
|
||||||
cWorld * GetWorld(void) const { return m_World; } //tolua_export
|
cWorld * GetWorld(void) const { return m_World; } //tolua_export
|
||||||
|
|
||||||
|
@ -12,9 +12,6 @@
|
|||||||
#include "cServer.h"
|
#include "cServer.h"
|
||||||
#include "cPickup.h"
|
#include "cPickup.h"
|
||||||
#include "cRoot.h"
|
#include "cRoot.h"
|
||||||
|
|
||||||
#include "packets/cPacket_InventoryProgressBar.h"
|
|
||||||
|
|
||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
|
|
||||||
|
|
||||||
@ -146,13 +143,10 @@ bool cFurnaceEntity::Tick( float a_Dt )
|
|||||||
cWindow * Window = GetWindow();
|
cWindow * Window = GetWindow();
|
||||||
if (Window != NULL)
|
if (Window != NULL)
|
||||||
{
|
{
|
||||||
cPacket_InventoryProgressBar Progress;
|
short Value = (short)( m_TimeCooked * (180.f / m_CookTime));
|
||||||
Progress.m_ProgressBar = 0;
|
if (Value > 180) Value = 180;
|
||||||
Progress.m_WindowID = (char)Window->GetWindowID();
|
if (Value < 0) Value = 0;
|
||||||
Progress.m_Value = (short)( m_TimeCooked * (180.f / m_CookTime) );
|
Window->BroadcastInventoryProgress(0, Value);
|
||||||
if (Progress.m_Value > 180) Progress.m_Value = 180;
|
|
||||||
if (Progress.m_Value < 0) Progress.m_Value = 0;
|
|
||||||
Window->Broadcast(Progress);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,21 +165,14 @@ bool cFurnaceEntity::Tick( float a_Dt )
|
|||||||
}
|
}
|
||||||
if (Window != NULL)
|
if (Window != NULL)
|
||||||
{
|
{
|
||||||
cPacket_InventoryProgressBar Progress;
|
short Value = 0;
|
||||||
Progress.m_WindowID = (char)Window->GetWindowID();
|
|
||||||
Progress.m_ProgressBar = 1;
|
|
||||||
|
|
||||||
if (m_BurnTime > 0.f)
|
if (m_BurnTime > 0.f)
|
||||||
{
|
{
|
||||||
Progress.m_Value = 250 - (short)( m_TimeBurned * (250.f / m_BurnTime) );
|
Value = 250 - (short)( m_TimeBurned * (250.f / m_BurnTime));
|
||||||
if (Progress.m_Value > 250) Progress.m_Value = 250;
|
if (Value > 250) Value = 250;
|
||||||
if (Progress.m_Value < 0) Progress.m_Value = 0;
|
if (Value < 0) Value = 0;
|
||||||
}
|
}
|
||||||
else
|
Window->BroadcastInventoryProgress(1, Value);
|
||||||
{
|
|
||||||
Progress.m_Value = 0;
|
|
||||||
}
|
|
||||||
Window->Broadcast(Progress);
|
|
||||||
}
|
}
|
||||||
return ((m_CookingItem != NULL) || (m_TimeBurned < m_BurnTime)) && (m_BurnTime > 0.0); // Keep on ticking, if there's more to cook, or if it's cooking
|
return ((m_CookingItem != NULL) || (m_TimeBurned < m_BurnTime)) && (m_BurnTime > 0.0); // Keep on ticking, if there's more to cook, or if it's cooking
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,8 @@
|
|||||||
#include "cPluginManager.h"
|
#include "cPluginManager.h"
|
||||||
#include "Vector3d.h"
|
#include "Vector3d.h"
|
||||||
#include "BlockID.h"
|
#include "BlockID.h"
|
||||||
|
|
||||||
#include "Defines.h"
|
#include "Defines.h"
|
||||||
|
|
||||||
#include "packets/cPacket_TeleportEntity.h"
|
|
||||||
#include "packets/cPacket_EntityStatus.h"
|
|
||||||
#include "packets/cPacket_Metadata.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -62,27 +57,34 @@ void cPawn::Heal( int a_Health )
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cPawn::TakeDamage( int a_Damage, cEntity* a_Instigator )
|
void cPawn::TakeDamage(int a_Damage, cEntity * a_Instigator)
|
||||||
{
|
{
|
||||||
TakeDamageInfo TDI;
|
TakeDamageInfo TDI;
|
||||||
TDI.Damage = a_Damage;
|
TDI.Damage = a_Damage;
|
||||||
TDI.Instigator = a_Instigator;
|
TDI.Instigator = a_Instigator;
|
||||||
cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_TAKE_DAMAGE, 2, this, &TDI );
|
cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_TAKE_DAMAGE, 2, this, &TDI);
|
||||||
|
|
||||||
if( TDI.Damage == 0 ) return;
|
if (TDI.Damage == 0)
|
||||||
if( m_Health <= 0 ) return; // Can't take damage if already dead
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_Health <= 0)
|
||||||
|
{
|
||||||
|
// Can't take damage if already dead
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_Health -= (short)TDI.Damage;
|
m_Health -= (short)TDI.Damage;
|
||||||
if( m_Health < 0 ) m_Health = 0;
|
if (m_Health < 0)
|
||||||
|
{
|
||||||
|
m_Health = 0;
|
||||||
|
}
|
||||||
|
|
||||||
cPacket_EntityStatus Status;
|
m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_HURT);
|
||||||
Status.m_UniqueID = GetUniqueID();
|
|
||||||
Status.m_Status = cPacket_EntityStatus::STATUS_TAKEDAMAGE;
|
|
||||||
m_World->BroadcastToChunk(m_ChunkX, m_ChunkY, m_ChunkZ, Status);
|
|
||||||
|
|
||||||
if (m_Health <= 0)
|
if (m_Health <= 0)
|
||||||
{
|
{
|
||||||
KilledBy( TDI.Instigator );
|
KilledBy(TDI.Instigator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +92,7 @@ void cPawn::TakeDamage( int a_Damage, cEntity* a_Instigator )
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cPawn::KilledBy( cEntity* a_Killer )
|
void cPawn::KilledBy(cEntity * a_Killer)
|
||||||
{
|
{
|
||||||
m_Health = 0;
|
m_Health = 0;
|
||||||
|
|
||||||
@ -99,19 +101,16 @@ void cPawn::KilledBy( cEntity* a_Killer )
|
|||||||
return; // Give plugins a chance to 'unkill' the pawn.
|
return; // Give plugins a chance to 'unkill' the pawn.
|
||||||
}
|
}
|
||||||
|
|
||||||
cPacket_EntityStatus Status;
|
m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_DEAD);
|
||||||
Status.m_UniqueID = GetUniqueID();
|
|
||||||
Status.m_Status = cPacket_EntityStatus::STATUS_DIE;
|
|
||||||
m_World->BroadcastToChunk(m_ChunkX, m_ChunkY, m_ChunkZ, Status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cPawn::TeleportToEntity( cEntity* a_Entity )
|
void cPawn::TeleportToEntity(cEntity * a_Entity)
|
||||||
{
|
{
|
||||||
TeleportTo( a_Entity->GetPosX(), a_Entity->GetPosY(), a_Entity->GetPosZ() );
|
TeleportTo(a_Entity->GetPosX(), a_Entity->GetPosY(), a_Entity->GetPosZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -148,8 +147,7 @@ void cPawn::SetMetaData(MetaData a_MetaData)
|
|||||||
{
|
{
|
||||||
//Broadcast new status to clients in the chunk
|
//Broadcast new status to clients in the chunk
|
||||||
m_MetaData = a_MetaData;
|
m_MetaData = a_MetaData;
|
||||||
cPacket_Metadata md(a_MetaData, GetUniqueID());
|
m_World->BroadcastMetadata(*this);
|
||||||
m_World->BroadcastToChunk(m_ChunkX, m_ChunkY, m_ChunkZ, md);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
enum MetaData {NORMAL, BURNING, CROUCHED, RIDING, SPRINTING, EATING, BLOCKING};
|
enum MetaData {NORMAL, BURNING, CROUCHED, RIDING, SPRINTING, EATING, BLOCKING};
|
||||||
|
|
||||||
virtual void SetMetaData(MetaData a_MetaData);
|
virtual void SetMetaData(MetaData a_MetaData);
|
||||||
virtual MetaData GetMetaData() { return m_MetaData; }
|
virtual MetaData GetMetaData(void) const { return m_MetaData; }
|
||||||
|
|
||||||
virtual void InStateBurning(float a_Dt);
|
virtual void InStateBurning(float a_Dt);
|
||||||
|
|
||||||
|
@ -360,12 +360,12 @@ void cWindow::BroadcastWholeWindow(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cWindow::Broadcast(const cPacket & a_Packet)
|
void cWindow::BroadcastInventoryProgress(short a_Progressbar, short a_Value)
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CS);
|
cCSLock Lock(m_CS);
|
||||||
for (cPlayerList::iterator itr = m_OpenedBy.begin(); itr != m_OpenedBy.end(); ++itr)
|
for (cPlayerList::iterator itr = m_OpenedBy.begin(); itr != m_OpenedBy.end(); ++itr)
|
||||||
{
|
{
|
||||||
(*itr)->GetClientHandle()->Send(a_Packet);
|
(*itr)->GetClientHandle()->SendInventoryProgress(m_WindowID, a_Progressbar, a_Value);
|
||||||
} // for itr - m_OpenedBy[]
|
} // for itr - m_OpenedBy[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ class cPlayer;
|
|||||||
class cItem;
|
class cItem;
|
||||||
class cWindowOwner;
|
class cWindowOwner;
|
||||||
class cClientHandle;
|
class cClientHandle;
|
||||||
class cPacket; // TODO: remove this
|
|
||||||
|
|
||||||
typedef std::list<cPlayer *> cPlayerList;
|
typedef std::list<cPlayer *> cPlayerList;
|
||||||
|
|
||||||
@ -76,7 +75,7 @@ public:
|
|||||||
|
|
||||||
void SendWholeWindow(cClientHandle * a_Client);
|
void SendWholeWindow(cClientHandle * a_Client);
|
||||||
void BroadcastWholeWindow(void);
|
void BroadcastWholeWindow(void);
|
||||||
void Broadcast(const cPacket & a_Packet);
|
void BroadcastInventoryProgress(short a_Progressbar, short a_Value);
|
||||||
|
|
||||||
const AString & GetWindowTitle() const { return m_WindowTitle; }
|
const AString & GetWindowTitle() const { return m_WindowTitle; }
|
||||||
void SetWindowTitle( const std::string & a_WindowTitle ) { m_WindowTitle = a_WindowTitle; }
|
void SetWindowTitle( const std::string & a_WindowTitle ) { m_WindowTitle = a_WindowTitle; }
|
||||||
|
@ -1372,6 +1372,24 @@ void cWorld::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandl
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cWorld::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude)
|
||||||
|
{
|
||||||
|
m_ChunkMap->BroadcastEntityStatus(a_Entity, a_Status, a_Exclude);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cWorld::BroadcastMetadata(const cPawn & a_Pawn, const cClientHandle * a_Exclude)
|
||||||
|
{
|
||||||
|
m_ChunkMap->BroadcastMetadata(a_Pawn, a_Exclude);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cWorld::MarkChunkDirty (int a_ChunkX, int a_ChunkY, int a_ChunkZ)
|
void cWorld::MarkChunkDirty (int a_ChunkX, int a_ChunkY, int a_ChunkZ)
|
||||||
{
|
{
|
||||||
m_ChunkMap->MarkChunkDirty (a_ChunkX, a_ChunkY, a_ChunkZ);
|
m_ChunkMap->MarkChunkDirty (a_ChunkX, a_ChunkY, a_ChunkZ);
|
||||||
|
@ -88,6 +88,8 @@ public:
|
|||||||
void BroadcastEntHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
void BroadcastEntHeadLook (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
||||||
void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, const cClientHandle * a_Exclude = NULL);
|
void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, const cClientHandle * a_Exclude = NULL);
|
||||||
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
|
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 MarkChunkDirty (int a_ChunkX, int a_ChunkY, int a_ChunkZ);
|
void MarkChunkDirty (int a_ChunkX, int a_ChunkY, int a_ChunkZ);
|
||||||
void MarkChunkSaving(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
|
void MarkChunkSaving(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
|
||||||
|
@ -14,16 +14,17 @@ public:
|
|||||||
: m_WindowID( 0 )
|
: m_WindowID( 0 )
|
||||||
, m_ProgressBar( 0 )
|
, m_ProgressBar( 0 )
|
||||||
, m_Value( 0 )
|
, m_Value( 0 )
|
||||||
{ m_PacketID = E_INVENTORY_PROGRESS; }
|
{
|
||||||
virtual cPacket* Clone() const { return new cPacket_InventoryProgressBar(*this); }
|
m_PacketID = E_INVENTORY_PROGRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual cPacket * Clone() const { return new cPacket_InventoryProgressBar(*this); }
|
||||||
|
|
||||||
virtual void Serialize(AString & a_Data) const override;
|
virtual void Serialize(AString & a_Data) const override;
|
||||||
|
|
||||||
char m_WindowID;
|
char m_WindowID;
|
||||||
short m_ProgressBar;
|
short m_ProgressBar;
|
||||||
short m_Value;
|
short m_Value;
|
||||||
|
|
||||||
static const unsigned int c_Size = 1 + 1 + 2 + 2;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user