From e2a557f46cb564caadd750114dd4a0e8225b9b4e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 6 Dec 2013 20:39:42 +0000 Subject: [PATCH] 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(+) 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