Fixed Linux compilation, slight code cleanup
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1396 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
0ceadbe7e0
commit
9b9a37e507
@ -1552,9 +1552,9 @@ void cClientHandle::SendEntityStatus(const cEntity & a_Entity, char a_Status)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cClientHandle::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, cVector3iList a_BlocksAffected, float a_PlayerMotionX, float a_PlayerMotionY, float a_PlayerMotionZ)
|
void cClientHandle::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, cVector3iArray a_BlocksAffected, const Vector3d & a_PlayerMotion)
|
||||||
{
|
{
|
||||||
m_Protocol->SendExplosion(a_BlockX,a_BlockY,a_BlockZ,a_Radius, a_BlocksAffected, a_PlayerMotionX, a_PlayerMotionY,a_PlayerMotionZ);
|
m_Protocol->SendExplosion(a_BlockX,a_BlockY,a_BlockZ,a_Radius, a_BlocksAffected, a_PlayerMotion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ public:
|
|||||||
void SendEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ);
|
void SendEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ);
|
||||||
void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item);
|
void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item);
|
||||||
void SendEntityStatus (const cEntity & a_Entity, char a_Status);
|
void SendEntityStatus (const cEntity & a_Entity, char a_Status);
|
||||||
void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, cVector3iList a_BlocksAffected, float a_PlayerMotionX, float a_PlayerMotionY, float a_PlayerMotionZ);
|
void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, cVector3iArray a_BlocksAffected, const Vector3d & a_PlayerMotion);
|
||||||
void SendGameMode (eGameMode a_GameMode);
|
void SendGameMode (eGameMode a_GameMode);
|
||||||
void SendHealth (void);
|
void SendHealth (void);
|
||||||
void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value);
|
void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value);
|
||||||
|
@ -67,7 +67,7 @@ public:
|
|||||||
virtual void SendEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) = 0;
|
virtual void SendEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) = 0;
|
||||||
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) = 0;
|
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) = 0;
|
||||||
virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) = 0;
|
virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) = 0;
|
||||||
virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, cVector3iList a_BlocksAffected, float a_PlayerMotionX, float a_PlayerMotionY, float a_PlayerMotionZ) = 0;
|
virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, cVector3iArray a_BlocksAffected, const Vector3d & a_PlayerMotion) = 0;
|
||||||
virtual void SendGameMode (eGameMode a_GameMode) = 0;
|
virtual void SendGameMode (eGameMode a_GameMode) = 0;
|
||||||
virtual void SendHealth (void) = 0;
|
virtual void SendHealth (void) = 0;
|
||||||
virtual void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value) = 0;
|
virtual void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value) = 0;
|
||||||
|
@ -352,7 +352,7 @@ void cProtocol125::SendEntityStatus(const cEntity & a_Entity, char a_Status)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol125::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, cVector3iList a_BlocksAffected, float a_PlayerMotionX, float a_PlayerMotionY, float a_PlayerMotionZ)
|
void cProtocol125::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, cVector3iArray a_BlocksAffected, const Vector3d & a_PlayerMotion)
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CSPacket);
|
cCSLock Lock(m_CSPacket);
|
||||||
WriteByte(PACKET_EXPLOSION);
|
WriteByte(PACKET_EXPLOSION);
|
||||||
@ -360,19 +360,16 @@ void cProtocol125::SendExplosion(double a_BlockX, double a_BlockY, double a_Bloc
|
|||||||
WriteDouble (a_BlockY);
|
WriteDouble (a_BlockY);
|
||||||
WriteDouble (a_BlockZ);
|
WriteDouble (a_BlockZ);
|
||||||
WriteFloat (a_Radius);
|
WriteFloat (a_Radius);
|
||||||
WriteInt (a_BlocksAffected.size());//it should be a_RecordCount
|
WriteInt (a_BlocksAffected.size());
|
||||||
/*WriteByte (0); //It should be the record
|
for (cVector3iArray::const_iterator itr = a_BlocksAffected.begin(); itr != a_BlocksAffected.end(); ++itr)
|
||||||
WriteByte (0);
|
|
||||||
WriteByte (0);*/
|
|
||||||
for (cVector3iList::iterator itr = a_BlocksAffected.begin(); itr != a_BlocksAffected.end(); ++itr)
|
|
||||||
{
|
{
|
||||||
WriteByte ((Byte)((*itr)->x - a_BlockX));
|
WriteByte ((Byte)(itr->x - a_BlockX));
|
||||||
WriteByte ((Byte)((*itr)->y - a_BlockY));
|
WriteByte ((Byte)(itr->y - a_BlockY));
|
||||||
WriteByte ((Byte)((*itr)->z - a_BlockZ));
|
WriteByte ((Byte)(itr->z - a_BlockZ));
|
||||||
}
|
}
|
||||||
WriteFloat (a_PlayerMotionX);
|
WriteFloat ((float)a_PlayerMotion.x);
|
||||||
WriteFloat (a_PlayerMotionY);
|
WriteFloat ((float)a_PlayerMotion.y);
|
||||||
WriteFloat (a_PlayerMotionZ);
|
WriteFloat ((float)a_PlayerMotion.z);
|
||||||
Flush();
|
Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
virtual void SendEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
|
virtual void SendEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
|
||||||
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
|
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
|
||||||
virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) override;
|
virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) override;
|
||||||
virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, cVector3iList a_BlocksAffected, float a_PlayerMotionX, float a_PlayerMotionY, float a_PlayerMotionZ) override;
|
virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, cVector3iArray a_BlocksAffected, const Vector3d & a_PlayerMotion) override;
|
||||||
virtual void SendGameMode (eGameMode a_GameMode) override;
|
virtual void SendGameMode (eGameMode a_GameMode) override;
|
||||||
virtual void SendHealth (void) override;
|
virtual void SendHealth (void) override;
|
||||||
virtual void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value) override;
|
virtual void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value) override;
|
||||||
|
@ -266,10 +266,10 @@ void cProtocolRecognizer::SendEntityStatus(const cEntity & a_Entity, char a_Stat
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocolRecognizer::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, cVector3iList a_BlocksAffected, float a_PlayerMotionX, float a_PlayerMotionY, float a_PlayerMotionZ)
|
void cProtocolRecognizer::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, cVector3iArray a_BlocksAffected, const Vector3d & a_PlayerMotion)
|
||||||
{
|
{
|
||||||
ASSERT(m_Protocol != NULL);
|
ASSERT(m_Protocol != NULL);
|
||||||
m_Protocol->SendExplosion(a_BlockX,a_BlockY,a_BlockZ,a_Radius, a_BlocksAffected, a_PlayerMotionX, a_PlayerMotionY,a_PlayerMotionZ);
|
m_Protocol->SendExplosion(a_BlockX,a_BlockY,a_BlockZ,a_Radius, a_BlocksAffected, a_PlayerMotion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public:
|
|||||||
virtual void SendEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
|
virtual void SendEntRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) override;
|
||||||
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
|
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
|
||||||
virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) override;
|
virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) override;
|
||||||
virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, cVector3iList a_BlocksAffected, float a_PlayerMotionX, float a_PlayerMotionY, float a_PlayerMotionZ) override;
|
virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, cVector3iArray a_BlocksAffected, const Vector3d & a_PlayerMotion) override;
|
||||||
virtual void SendGameMode (eGameMode a_GameMode) override;
|
virtual void SendGameMode (eGameMode a_GameMode) override;
|
||||||
virtual void SendHealth (void) override;
|
virtual void SendHealth (void) override;
|
||||||
virtual void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value) override;
|
virtual void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value) override;
|
||||||
|
@ -37,5 +37,9 @@ public: // tolua_export
|
|||||||
int x, y, z; // tolua_export
|
int x, y, z; // tolua_export
|
||||||
}; // tolua_export
|
}; // tolua_export
|
||||||
|
|
||||||
|
typedef std::list<Vector3i> cVector3iList;
|
||||||
|
typedef std::vector<Vector3i> cVector3iArray;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef std::list< Vector3i * > cVector3iList;
|
|
@ -705,31 +705,31 @@ bool cWorld::ForEachFurnaceInChunk(int a_ChunkX, int a_ChunkZ, cFurnaceCallback
|
|||||||
|
|
||||||
void cWorld::DoExplosiontAt(float a_ExplosionSize, int a_BlockX, int a_BlockY, int a_BlockZ)
|
void cWorld::DoExplosiontAt(float a_ExplosionSize, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||||
{
|
{
|
||||||
//TODO implement explosion using cBlockArea, add damage to pawns, add support for pickups, and implement block hardiness
|
// TODO: implement explosion using cBlockArea / in cChunkMap, add damage to entities, add support for pickups, and implement block hardiness
|
||||||
Vector3d explosion_pos = Vector3d(a_BlockX,a_BlockY,a_BlockZ);
|
Vector3d explosion_pos = Vector3d(a_BlockX,a_BlockY,a_BlockZ);
|
||||||
cVector3iList BlocksAffected;
|
cVector3iArray BlocksAffected;
|
||||||
for (int i=0;i<a_ExplosionSize;i++)
|
for (int x = 0; x < a_ExplosionSize; x++)
|
||||||
{
|
{
|
||||||
for (int j=0;j<a_ExplosionSize;j++)
|
for (int y = 0; y < a_ExplosionSize; y++)
|
||||||
{
|
{
|
||||||
for (int k=0;k<a_ExplosionSize;k++)
|
for (int z = 0; z < a_ExplosionSize; z++)
|
||||||
{
|
{
|
||||||
DigBlock(a_BlockX+i,a_BlockY+j,a_BlockZ+k);
|
DigBlock(a_BlockX + x, a_BlockY + y, a_BlockZ + z);
|
||||||
DigBlock(a_BlockX+i,a_BlockY-j,a_BlockZ+k);
|
DigBlock(a_BlockX + x, a_BlockY - y, a_BlockZ + z);
|
||||||
DigBlock(a_BlockX-i,a_BlockY-j,a_BlockZ-k);
|
DigBlock(a_BlockX - x, a_BlockY - y, a_BlockZ - z);
|
||||||
DigBlock(a_BlockX-i,a_BlockY+j,a_BlockZ-k);
|
DigBlock(a_BlockX - x, a_BlockY + y, a_BlockZ - z);
|
||||||
DigBlock(a_BlockX+i,a_BlockY+j,a_BlockZ-k);
|
DigBlock(a_BlockX + x, a_BlockY + y, a_BlockZ - z);
|
||||||
DigBlock(a_BlockX+i,a_BlockY-j,a_BlockZ-k);
|
DigBlock(a_BlockX + x, a_BlockY - y, a_BlockZ - z);
|
||||||
DigBlock(a_BlockX-i,a_BlockY+j,a_BlockZ+k);
|
DigBlock(a_BlockX - x, a_BlockY + y, a_BlockZ + z);
|
||||||
DigBlock(a_BlockX-i,a_BlockY-j,a_BlockZ+k);
|
DigBlock(a_BlockX - x, a_BlockY - y, a_BlockZ + z);
|
||||||
BlocksAffected.push_back(&Vector3i(a_BlockX+i,a_BlockY+j,a_BlockZ+k));
|
BlocksAffected.push_back(Vector3i(a_BlockX + x, a_BlockY + y, a_BlockZ + z));
|
||||||
BlocksAffected.push_back(&Vector3i(a_BlockX+i,a_BlockY-j,a_BlockZ+k));
|
BlocksAffected.push_back(Vector3i(a_BlockX + x, a_BlockY - y, a_BlockZ + z));
|
||||||
BlocksAffected.push_back(&Vector3i(a_BlockX-i,a_BlockY-j,a_BlockZ-k));
|
BlocksAffected.push_back(Vector3i(a_BlockX - x, a_BlockY - y, a_BlockZ - z));
|
||||||
BlocksAffected.push_back(&Vector3i(a_BlockX-i,a_BlockY+j,a_BlockZ-k));
|
BlocksAffected.push_back(Vector3i(a_BlockX - x, a_BlockY + y, a_BlockZ - z));
|
||||||
BlocksAffected.push_back(&Vector3i(a_BlockX+i,a_BlockY+j,a_BlockZ-k));
|
BlocksAffected.push_back(Vector3i(a_BlockX + x, a_BlockY + y, a_BlockZ - z));
|
||||||
BlocksAffected.push_back(&Vector3i(a_BlockX+i,a_BlockY-j,a_BlockZ-k));
|
BlocksAffected.push_back(Vector3i(a_BlockX + x, a_BlockY - y, a_BlockZ - z));
|
||||||
BlocksAffected.push_back(&Vector3i(a_BlockX-i,a_BlockY+j,a_BlockZ+k));
|
BlocksAffected.push_back(Vector3i(a_BlockX - x, a_BlockY + y, a_BlockZ + z));
|
||||||
BlocksAffected.push_back(&Vector3i(a_BlockX-i,a_BlockY-j,a_BlockZ+k));
|
BlocksAffected.push_back(Vector3i(a_BlockX - x, a_BlockY - y, a_BlockZ + z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -747,15 +747,15 @@ void cWorld::DoExplosiontAt(float a_ExplosionSize, int a_BlockX, int a_BlockY, i
|
|||||||
Vector3d distance_explosion = (*itr)->GetPosition() - explosion_pos;
|
Vector3d distance_explosion = (*itr)->GetPosition() - explosion_pos;
|
||||||
if (distance_explosion.SqrLength() < 4096.0)
|
if (distance_explosion.SqrLength() < 4096.0)
|
||||||
{
|
{
|
||||||
double real_distance = sqrt( distance_explosion.SqrLength());
|
double real_distance = std::max(0.004, sqrt(distance_explosion.SqrLength()));
|
||||||
if (real_distance <= 0.0004)
|
|
||||||
real_distance = 0.0004;
|
|
||||||
double power = a_ExplosionSize / real_distance;
|
double power = a_ExplosionSize / real_distance;
|
||||||
if (power <= 1)
|
if (power <= 1)
|
||||||
|
{
|
||||||
power = 0;
|
power = 0;
|
||||||
|
}
|
||||||
distance_explosion.Normalize();
|
distance_explosion.Normalize();
|
||||||
distance_explosion *= power;
|
distance_explosion *= power;
|
||||||
ch->SendExplosion(a_BlockX,a_BlockY,a_BlockZ,a_ExplosionSize,BlocksAffected,(float)distance_explosion.x,(float)distance_explosion.y,(float)distance_explosion.z);
|
ch->SendExplosion(a_BlockX, a_BlockY, a_BlockZ, a_ExplosionSize, BlocksAffected, distance_explosion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user