1
0

- Pickups should now burn in fire

- The player no longer gets an empty bucket when in creative mode
- improved the simulators again (moved to std::list because this should be faster with so many objects) (But the water simulation still is very slow)

git-svn-id: http://mc-server.googlecode.com/svn/trunk@153 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
lapayo94@gmail.com 2011-12-29 02:44:21 +00:00
parent f5466a4cb3
commit 2ca40c819e
5 changed files with 33 additions and 20 deletions

View File

@ -872,21 +872,28 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
case E_ITEM_LAVA_BUCKET:
if((m_Player->GetGameMode() == 1) || (m_Player->GetInventory().RemoveItem( Item )))
{
PacketData->m_ItemType = E_BLOCK_LAVA;
if(m_Player->GetGameMode() == 1)
break; //No new Bucket for creative players
cItem NewItem;
NewItem.m_ItemID = E_ITEM_BUCKET;
NewItem.m_ItemCount = 1;
m_Player->GetInventory().AddItem( NewItem );
PacketData->m_ItemType = E_BLOCK_LAVA;
}
break;
case E_ITEM_WATER_BUCKET:
if((m_Player->GetGameMode() == 1) || (m_Player->GetInventory().RemoveItem( Item )))
{
PacketData->m_ItemType = E_BLOCK_WATER;
if(m_Player->GetGameMode() == 1)
break; //No new Bucket for creative players
cItem NewItem;
NewItem.m_ItemID = E_ITEM_BUCKET;
NewItem.m_ItemCount = 1;
m_Player->GetInventory().AddItem( NewItem );
PacketData->m_ItemType = E_BLOCK_WATER;
}
break;
case E_BLOCK_WHITE_CLOTH:

View File

@ -9,9 +9,9 @@ class cFluidSimulator::FluidData
{
public:
FluidData( cWorld* a_World, cFluidSimulator *a_Simulator )
: m_ActiveFluid( new std::vector< Vector3i >() )
: m_ActiveFluid( new std::list < Vector3i >() )
, m_Simulator (a_Simulator)
, m_Buffer( new std::vector< Vector3i >() )
, m_Buffer( new std::list< Vector3i >() )
, m_World( a_World )
{}
@ -71,8 +71,8 @@ public:
return Points;
}
std::vector< Vector3i >* m_ActiveFluid;
std::vector< Vector3i >* m_Buffer;
std::list< Vector3i >* m_ActiveFluid;
std::list< Vector3i >* m_Buffer;
cWorld* m_World;
cFluidSimulator *m_Simulator;
};
@ -95,8 +95,8 @@ void cFluidSimulator::AddBlock( int a_X, int a_Y, int a_Z )
return;
// Check for duplicates
std::vector< Vector3i > & ActiveFluid = *m_Data->m_ActiveFluid;
for( std::vector< Vector3i >::iterator itr = ActiveFluid.begin(); itr != ActiveFluid.end(); ++itr )
std::list< Vector3i > & ActiveFluid = *m_Data->m_ActiveFluid;
for( std::list< Vector3i >::iterator itr = ActiveFluid.begin(); itr != ActiveFluid.end(); ++itr )
{
Vector3i & Pos = *itr;
if( Pos.x == a_X && Pos.y == a_Y && Pos.z == a_Z )
@ -137,8 +137,8 @@ void cFluidSimulator::Simulate( float a_Dt )
std::swap( m_Data->m_ActiveFluid, m_Data->m_Buffer ); // Swap so blocks can be added to empty ActiveFluid array
m_Data->m_ActiveFluid->clear();
std::vector< Vector3i > & FluidBlocks = *m_Data->m_Buffer;
for( std::vector< Vector3i >::iterator itr = FluidBlocks.begin(); itr != FluidBlocks.end(); ++itr )
std::list< Vector3i > & FluidBlocks = *m_Data->m_Buffer;
for( std::list< Vector3i >::iterator itr = FluidBlocks.begin(); itr != FluidBlocks.end(); ++itr )
{
Vector3i & pos = *itr;
@ -251,6 +251,8 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
std::vector< Vector3i * > Points;
Points.reserve(4); //Already allocate 4 places :D
//add blocks around the checking pos
Points.push_back(new Vector3i(a_X - 1, a_Y, a_Z));
Points.push_back(new Vector3i(a_X + 1, a_Y, a_Z));

View File

@ -169,13 +169,17 @@ void cPickup::HandlePhysics(float a_Dt)
{
m_bOnGround = false;
}
char block = World->GetBlock( BlockX, (int)m_Pos->y - (int)m_bOnGround, BlockZ );
if( block == E_BLOCK_STATIONARY_LAVA || block == E_BLOCK_LAVA ) {
char Block = World->GetBlock( BlockX, (int)m_Pos->y - (int)m_bOnGround, BlockZ );
char BlockIn = World->GetBlock( BlockX, (int)m_Pos->y, BlockZ );
if( IsBlockLava(Block) || Block == E_BLOCK_FIRE
|| IsBlockLava(BlockIn) || BlockIn == E_BLOCK_FIRE)
{
m_bCollected = true;
m_Timer = 0;
return;
}
char BlockIn = World->GetBlock( BlockX, (int)m_Pos->y, BlockZ );
if( BlockIn != E_BLOCK_AIR && !IsBlockWater(BlockIn) ) // If in ground itself, push it out
{
m_bOnGround = true;

View File

@ -7,8 +7,8 @@
cSandSimulator::cSandSimulator( cWorld* a_World )
: cSimulator(a_World)
, m_Blocks(new std::vector <Vector3i *>)
, m_Buffer(new std::vector <Vector3i *>)
, m_Blocks(new std::list <Vector3i *>)
, m_Buffer(new std::list <Vector3i *>)
{
}
@ -24,7 +24,7 @@ void cSandSimulator::Simulate( float a_Dt )
m_Buffer->clear();
std::swap( m_Blocks, m_Buffer );
for( std::vector<Vector3i *>::iterator itr = m_Buffer->begin(); itr != m_Buffer->end(); ++itr )
for( std::list<Vector3i *>::iterator itr = m_Buffer->begin(); itr != m_Buffer->end(); ++itr )
{
Vector3i *Pos = *itr;
char BlockID = m_World->GetBlock(Pos->x, Pos->y, Pos->z);
@ -57,7 +57,7 @@ void cSandSimulator::AddBlock(int a_X, int a_Y, int a_Z)
Vector3i *Block = new Vector3i(a_X, a_Y, a_Z);
//check for duplicates
for( std::vector<Vector3i *>::iterator itr = m_Blocks->begin(); itr != m_Blocks->end(); ++itr )
for( std::list<Vector3i *>::iterator itr = m_Blocks->begin(); itr != m_Blocks->end(); ++itr )
{
Vector3i *Pos = *itr;
if( Pos->x == a_X && Pos->y == a_Y && Pos->z == a_Z )

View File

@ -1,7 +1,7 @@
#pragma once
#include "cSimulator.h"
#include "cBlockEntity.h"
#include "vector"
#include <list>
class Vector3i;
class cWorld;
@ -20,6 +20,6 @@ public:
protected:
virtual void AddBlock(int a_X, int a_Y, int a_Z);
std::vector <Vector3i *> *m_Blocks;
std::vector <Vector3i *> *m_Buffer;
std::list <Vector3i *> *m_Blocks;
std::list <Vector3i *> *m_Buffer;
};