From e2a557f46cb564caadd750114dd4a0e8225b9b4e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 6 Dec 2013 20:39:42 +0000 Subject: Added pickup invalid item check They aren't spawned at all if their itemtype isn't valid; possibly fixes the client crashing with bad pickups. --- src/World.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 7982924ae..04eab1851 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -1585,6 +1585,12 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double 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) { + if (!IsValidItem(itr->m_ItemType)) + { + // Don't spawn pickup if item isn't even valid; should prevent client crashing too + continue; + } + float SpeedX = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500)); float SpeedY = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500)); float SpeedZ = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500)); @@ -1605,6 +1611,11 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double { for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr) { + if (!IsValidItem(itr->m_ItemType)) + { + continue; + } + cPickup * Pickup = new cPickup( a_BlockX, a_BlockY, a_BlockZ, *itr, IsPlayerCreated, (float)a_SpeedX, (float)a_SpeedY, (float)a_SpeedZ -- cgit v1.2.3 From b02873172639db2ac7a494389899c2175e0ddd8f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 6 Dec 2013 22:29:15 +0000 Subject: Fixed duplication glitch with QueueSetBlock If a coordinate was queued, and then the block there was broken, it would reappear: double items! Also now just sets meta if previous and current blocktypes matched. --- src/World.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 04eab1851..0cf34b861 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -1470,9 +1470,9 @@ void cWorld::FastSetBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBB -void cWorld::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_TickDelay) +void cWorld::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_TickDelay, BLOCKTYPE a_PreviousBlockType) { - m_ChunkMap->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, GetWorldAge() + a_TickDelay); + m_ChunkMap->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, GetWorldAge() + a_TickDelay, a_PreviousBlockType); } -- cgit v1.2.3 From 30ead790490f04248b861db79fddde9148b552f4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 6 Dec 2013 23:47:07 +0000 Subject: Renamed animation function Renamed BroadcastPlayerAnimation to BroadcastEntityAnimation. Not just players can have animations, you know. --- src/World.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 0cf34b861..2da4a89be 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -1858,9 +1858,9 @@ void cWorld::BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHand -void cWorld::BroadcastPlayerAnimation(const cPlayer & a_Player, char a_Animation, const cClientHandle * a_Exclude) +void cWorld::BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude) { - m_ChunkMap->BroadcastPlayerAnimation(a_Player, a_Animation, a_Exclude); + m_ChunkMap->BroadcastEntityAnimation(a_Entity, a_Animation, a_Exclude); } -- cgit v1.2.3 From 838d4d5d1d9be001357d6795a343244a43652e2f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 7 Dec 2013 23:45:33 +0000 Subject: Bonemeal has particles, fixes #393 --- src/World.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 2da4a89be..41f08d97f 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -1259,6 +1259,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy if (BlockMeta < 7) { FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, 7); + BroadcastSoundParticleEffect(2005, a_BlockX, a_BlockY, a_BlockZ, 0); } return true; } @@ -1272,6 +1273,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy if (BlockMeta < 7) { FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, 7); + BroadcastSoundParticleEffect(2005, a_BlockX, a_BlockY, a_BlockZ, 0); } return true; } @@ -1285,6 +1287,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy return false; } FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, 7); + BroadcastSoundParticleEffect(2005, a_BlockX, a_BlockY, a_BlockZ, 0); } else { @@ -1306,6 +1309,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy if (BlockMeta < 7) { FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, 7); + BroadcastSoundParticleEffect(2005, a_BlockX, a_BlockY, a_BlockZ, 0); } return true; } @@ -1319,6 +1323,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy return false; } FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, 7); + BroadcastSoundParticleEffect(2005, a_BlockX, a_BlockY, a_BlockZ, 0); } else { @@ -1377,6 +1382,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy } } // switch (random spawn block type) FastSetBlock(a_BlockX + OfsX, a_BlockY + OfsY + 1, a_BlockZ + OfsZ, SpawnType, SpawnMeta); + BroadcastSoundParticleEffect(2005, a_BlockX + OfsX, a_BlockY + OfsY, a_BlockZ + OfsZ, 0); } // for i - 50 times return true; } -- cgit v1.2.3