Pickup: Fixed a possible crash when a pickup went up above the world.
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1428 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
9e38229b0d
commit
912f93a544
@ -68,25 +68,29 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
|
|
||||||
if (!m_bCollected)
|
if (!m_bCollected)
|
||||||
{
|
{
|
||||||
int BlockX = (int) floor(GetPosX());
|
|
||||||
int BlockY = (int) floor(GetPosY());
|
int BlockY = (int) floor(GetPosY());
|
||||||
|
if (BlockY < cChunkDef::Height) // Don't do anything except for falling when above the world
|
||||||
|
{
|
||||||
|
int BlockX = (int) floor(GetPosX());
|
||||||
int BlockZ = (int) floor(GetPosZ());
|
int BlockZ = (int) floor(GetPosZ());
|
||||||
//Position might have changed due to physics. So we have to make sure we have the correct chunk.
|
//Position might have changed due to physics. So we have to make sure we have the correct chunk.
|
||||||
cChunk * CurrentChunk = a_Chunk.GetNeighborChunk(BlockX,BlockZ);
|
cChunk * CurrentChunk = a_Chunk.GetNeighborChunk(BlockX, BlockZ);
|
||||||
if (CurrentChunk != NULL) //Making sure the chunk is loaded
|
if (CurrentChunk != NULL) // Make sure the chunk is loaded
|
||||||
{
|
{
|
||||||
int RelBlockX = BlockX - (CurrentChunk->GetPosX() * cChunkDef::Width);
|
int RelBlockX = BlockX - (CurrentChunk->GetPosX() * cChunkDef::Width);
|
||||||
int RelBlockZ = BlockZ - (CurrentChunk->GetPosZ() * cChunkDef::Width);
|
int RelBlockZ = BlockZ - (CurrentChunk->GetPosZ() * cChunkDef::Width);
|
||||||
|
|
||||||
BLOCKTYPE BlockBelow = CurrentChunk->GetBlock( RelBlockX, BlockY - 1, RelBlockZ );
|
BLOCKTYPE BlockBelow = CurrentChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ);
|
||||||
BLOCKTYPE BlockIn = CurrentChunk->GetBlock( RelBlockX, BlockY, RelBlockZ );
|
BLOCKTYPE BlockIn = CurrentChunk->GetBlock(RelBlockX, BlockY, RelBlockZ);
|
||||||
|
|
||||||
if( IsBlockLava(BlockBelow) || BlockBelow == E_BLOCK_FIRE
|
if (
|
||||||
|| IsBlockLava(BlockIn) || BlockIn == E_BLOCK_FIRE )
|
IsBlockLava(BlockBelow) || (BlockBelow == E_BLOCK_FIRE) ||
|
||||||
|
IsBlockLava(BlockIn) || (BlockIn == E_BLOCK_FIRE)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
m_bCollected = true;
|
m_bCollected = true;
|
||||||
m_Timer = 0; //We have to reset the timer.
|
m_Timer = 0; // We have to reset the timer.
|
||||||
m_Timer += a_Dt; //In case we have to destroy the pickup in the same tick.
|
m_Timer += a_Dt; // In case we have to destroy the pickup in the same tick.
|
||||||
if (m_Timer > 500.f)
|
if (m_Timer > 500.f)
|
||||||
{
|
{
|
||||||
Destroy();
|
Destroy();
|
||||||
@ -95,6 +99,7 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_Timer > 500.f) // 0.5 second
|
if (m_Timer > 500.f) // 0.5 second
|
||||||
|
Loading…
Reference in New Issue
Block a user