summaryrefslogtreecommitdiffstats
path: root/source/World.cpp
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 /source/World.cpp
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
Diffstat (limited to 'source/World.cpp')
-rw-r--r--source/World.cpp50
1 files changed, 25 insertions, 25 deletions
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);
}
}
}