summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-19 10:21:39 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-19 10:21:39 +0200
commit9b9a37e5070a4553b0945ea4b770cf75c375bec5 (patch)
treef869a7f1d8273efd29503a98ad2e74900ec253f8
parentcPlayer now uses BroadcastMovementUpdate during its Tick function (diff)
downloadcuberite-9b9a37e5070a4553b0945ea4b770cf75c375bec5.tar
cuberite-9b9a37e5070a4553b0945ea4b770cf75c375bec5.tar.gz
cuberite-9b9a37e5070a4553b0945ea4b770cf75c375bec5.tar.bz2
cuberite-9b9a37e5070a4553b0945ea4b770cf75c375bec5.tar.lz
cuberite-9b9a37e5070a4553b0945ea4b770cf75c375bec5.tar.xz
cuberite-9b9a37e5070a4553b0945ea4b770cf75c375bec5.tar.zst
cuberite-9b9a37e5070a4553b0945ea4b770cf75c375bec5.zip
-rw-r--r--source/ClientHandle.cpp4
-rw-r--r--source/ClientHandle.h2
-rw-r--r--source/Protocol/Protocol.h2
-rw-r--r--source/Protocol/Protocol125.cpp21
-rw-r--r--source/Protocol/Protocol125.h2
-rw-r--r--source/Protocol/ProtocolRecognizer.cpp4
-rw-r--r--source/Protocol/ProtocolRecognizer.h2
-rw-r--r--source/Vector3i.h6
-rw-r--r--source/World.cpp50
9 files changed, 47 insertions, 46 deletions
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index 2a8ceabc7..ab7e3e2d9 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -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);
}
diff --git a/source/ClientHandle.h b/source/ClientHandle.h
index 0a228af3d..269022b55 100644
--- a/source/ClientHandle.h
+++ b/source/ClientHandle.h
@@ -98,7 +98,7 @@ public:
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 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 SendHealth (void);
void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value);
diff --git a/source/Protocol/Protocol.h b/source/Protocol/Protocol.h
index 48d32384c..91017dbaf 100644
--- a/source/Protocol/Protocol.h
+++ b/source/Protocol/Protocol.h
@@ -67,7 +67,7 @@ public:
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 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 SendHealth (void) = 0;
virtual void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value) = 0;
diff --git a/source/Protocol/Protocol125.cpp b/source/Protocol/Protocol125.cpp
index e588bc595..184bd1d30 100644
--- a/source/Protocol/Protocol125.cpp
+++ b/source/Protocol/Protocol125.cpp
@@ -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);
WriteByte(PACKET_EXPLOSION);
@@ -360,19 +360,16 @@ void cProtocol125::SendExplosion(double a_BlockX, double a_BlockY, double a_Bloc
WriteDouble (a_BlockY);
WriteDouble (a_BlockZ);
WriteFloat (a_Radius);
- WriteInt (a_BlocksAffected.size());//it should be a_RecordCount
- /*WriteByte (0); //It should be the record
- WriteByte (0);
- WriteByte (0);*/
- for (cVector3iList::iterator itr = a_BlocksAffected.begin(); itr != a_BlocksAffected.end(); ++itr)
+ WriteInt (a_BlocksAffected.size());
+ for (cVector3iArray::const_iterator itr = a_BlocksAffected.begin(); itr != a_BlocksAffected.end(); ++itr)
{
- WriteByte ((Byte)((*itr)->x - a_BlockX));
- WriteByte ((Byte)((*itr)->y - a_BlockY));
- WriteByte ((Byte)((*itr)->z - a_BlockZ));
+ WriteByte ((Byte)(itr->x - a_BlockX));
+ WriteByte ((Byte)(itr->y - a_BlockY));
+ WriteByte ((Byte)(itr->z - a_BlockZ));
}
- WriteFloat (a_PlayerMotionX);
- WriteFloat (a_PlayerMotionY);
- WriteFloat (a_PlayerMotionZ);
+ WriteFloat ((float)a_PlayerMotion.x);
+ WriteFloat ((float)a_PlayerMotion.y);
+ WriteFloat ((float)a_PlayerMotion.z);
Flush();
}
diff --git a/source/Protocol/Protocol125.h b/source/Protocol/Protocol125.h
index 1cf03357d..b7c5ff424 100644
--- a/source/Protocol/Protocol125.h
+++ b/source/Protocol/Protocol125.h
@@ -44,7 +44,7 @@ public:
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 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 SendHealth (void) override;
virtual void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value) override;
diff --git a/source/Protocol/ProtocolRecognizer.cpp b/source/Protocol/ProtocolRecognizer.cpp
index ea60dafae..cae267524 100644
--- a/source/Protocol/ProtocolRecognizer.cpp
+++ b/source/Protocol/ProtocolRecognizer.cpp
@@ -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);
- 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);
}
diff --git a/source/Protocol/ProtocolRecognizer.h b/source/Protocol/ProtocolRecognizer.h
index f897f1804..1d301394c 100644
--- a/source/Protocol/ProtocolRecognizer.h
+++ b/source/Protocol/ProtocolRecognizer.h
@@ -71,7 +71,7 @@ public:
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 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 SendHealth (void) override;
virtual void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value) override;
diff --git a/source/Vector3i.h b/source/Vector3i.h
index 820368c28..7d726a7b3 100644
--- a/source/Vector3i.h
+++ b/source/Vector3i.h
@@ -37,5 +37,9 @@ public: // tolua_export
int x, y, z; // tolua_export
}; // tolua_export
+typedef std::list<Vector3i> cVector3iList;
+typedef std::vector<Vector3i> cVector3iArray;
+
+
+
-typedef std::list< Vector3i * > cVector3iList; \ No newline at end of file
diff --git a/source/World.cpp b/source/World.cpp
index 6b1e5f8c8..312249709 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -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)
{
- //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);
- cVector3iList BlocksAffected;
- for (int i=0;i<a_ExplosionSize;i++)
+ cVector3iArray BlocksAffected;
+ 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+i,a_BlockY-j,a_BlockZ+k);
- DigBlock(a_BlockX-i,a_BlockY-j,a_BlockZ-k);
- DigBlock(a_BlockX-i,a_BlockY+j,a_BlockZ-k);
- DigBlock(a_BlockX+i,a_BlockY+j,a_BlockZ-k);
- DigBlock(a_BlockX+i,a_BlockY-j,a_BlockZ-k);
- DigBlock(a_BlockX-i,a_BlockY+j,a_BlockZ+k);
- DigBlock(a_BlockX-i,a_BlockY-j,a_BlockZ+k);
- BlocksAffected.push_back(&Vector3i(a_BlockX+i,a_BlockY+j,a_BlockZ+k));
- BlocksAffected.push_back(&Vector3i(a_BlockX+i,a_BlockY-j,a_BlockZ+k));
- BlocksAffected.push_back(&Vector3i(a_BlockX-i,a_BlockY-j,a_BlockZ-k));
- BlocksAffected.push_back(&Vector3i(a_BlockX-i,a_BlockY+j,a_BlockZ-k));
- BlocksAffected.push_back(&Vector3i(a_BlockX+i,a_BlockY+j,a_BlockZ-k));
- BlocksAffected.push_back(&Vector3i(a_BlockX+i,a_BlockY-j,a_BlockZ-k));
- BlocksAffected.push_back(&Vector3i(a_BlockX-i,a_BlockY+j,a_BlockZ+k));
- BlocksAffected.push_back(&Vector3i(a_BlockX-i,a_BlockY-j,a_BlockZ+k));
+ DigBlock(a_BlockX + x, a_BlockY + y, a_BlockZ + z);
+ DigBlock(a_BlockX + x, a_BlockY - y, a_BlockZ + z);
+ DigBlock(a_BlockX - x, a_BlockY - y, a_BlockZ - z);
+ DigBlock(a_BlockX - x, a_BlockY + y, a_BlockZ - z);
+ DigBlock(a_BlockX + x, a_BlockY + y, a_BlockZ - z);
+ DigBlock(a_BlockX + x, a_BlockY - y, a_BlockZ - z);
+ DigBlock(a_BlockX - x, a_BlockY + y, a_BlockZ + z);
+ DigBlock(a_BlockX - x, a_BlockY - y, a_BlockZ + z);
+ BlocksAffected.push_back(Vector3i(a_BlockX + x, a_BlockY + y, a_BlockZ + z));
+ BlocksAffected.push_back(Vector3i(a_BlockX + x, a_BlockY - y, a_BlockZ + z));
+ BlocksAffected.push_back(Vector3i(a_BlockX - x, a_BlockY - y, a_BlockZ - z));
+ BlocksAffected.push_back(Vector3i(a_BlockX - x, a_BlockY + y, a_BlockZ - z));
+ BlocksAffected.push_back(Vector3i(a_BlockX + x, a_BlockY + y, a_BlockZ - z));
+ BlocksAffected.push_back(Vector3i(a_BlockX + x, a_BlockY - y, a_BlockZ - z));
+ BlocksAffected.push_back(Vector3i(a_BlockX - x, a_BlockY + y, a_BlockZ + z));
+ 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;
if (distance_explosion.SqrLength() < 4096.0)
{
- double real_distance = sqrt( distance_explosion.SqrLength());
- if (real_distance <= 0.0004)
- real_distance = 0.0004;
+ double real_distance = std::max(0.004, sqrt(distance_explosion.SqrLength()));
double power = a_ExplosionSize / real_distance;
if (power <= 1)
+ {
power = 0;
+ }
distance_explosion.Normalize();
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);
}
}
}