1
0

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.
This commit is contained in:
Tiger Wang 2013-12-06 20:39:42 +00:00
parent 126577214a
commit e2a557f46c

View File

@ -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 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) 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 SpeedX = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500));
float SpeedY = (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)); 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) for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr)
{ {
if (!IsValidItem(itr->m_ItemType))
{
continue;
}
cPickup * Pickup = new cPickup( cPickup * Pickup = new cPickup(
a_BlockX, a_BlockY, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ,
*itr, IsPlayerCreated, (float)a_SpeedX, (float)a_SpeedY, (float)a_SpeedZ *itr, IsPlayerCreated, (float)a_SpeedX, (float)a_SpeedY, (float)a_SpeedZ