From 1cca9b13b3d320ff767cfc552413265b2ef6e0d6 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Wed, 6 Jun 2012 20:18:50 +0000 Subject: Item-dropping code rewritten and centralized - now there's only one place to modify if we want to split or merge same-item drops: cWorld:SpawnItemPickups(). Also, mined blocks can now drop more items, and they recognize if they're being mined by the correct tool. git-svn-id: http://mc-server.googlecode.com/svn/trunk@561 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cFluidSimulator.cpp | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'source/cFluidSimulator.cpp') diff --git a/source/cFluidSimulator.cpp b/source/cFluidSimulator.cpp index c2df9b1f2..38bf55d77 100644 --- a/source/cFluidSimulator.cpp +++ b/source/cFluidSimulator.cpp @@ -1,13 +1,19 @@ #include "Globals.h" + +#include +#include + #include "cFluidSimulator.h" #include "cWorld.h" #include "Vector3i.h" #include "BlockID.h" #include "Defines.h" -#include -#include "cPickup.h" #include "cItem.h" -#include +#include "cBlockToPickup.h" + + + + //#define DEBUG_FLUID #ifdef DEBUG_FLUID @@ -17,6 +23,9 @@ #endif + + + class cFluidSimulator::FluidData { public: @@ -343,14 +352,15 @@ void cFluidSimulator::Simulate( float a_Dt ) { char DownID = m_World->GetBlock( pos.x, pos.y-1, pos.z ); bool bWashedAwayItem = CanWashAway( DownID ); - if( (IsPassableForFluid(DownID) || bWashedAwayItem)&&!IsStationaryBlock(DownID) ) // free for fluid + if( (IsPassableForFluid(DownID) || bWashedAwayItem) && !IsStationaryBlock(DownID) ) // free for fluid { if( bWashedAwayItem ) { - cPickup* Pickup = new cPickup( pos.x * 32 + 16, (pos.y-1) * 32 + 16, pos.z * 32 + 16, cItem( (ENUM_ITEM_ID)DownID, 1, m_World->GetBlockMeta( pos.x, pos.y-1, pos.z ) ) ); - Pickup->Initialize( m_World ); + cItems Drops; + cBlockToPickup::ToPickup(DownID, m_World->GetBlockMeta(pos.x, pos.y - 1, pos.z), E_ITEM_EMPTY, Drops); + m_World->SpawnItemPickups(Drops, pos.x, pos.y - 1, pos.z); } - if( pos.y > 0 ) + if (pos.y > 0) { m_World->FastSetBlock( pos.x, pos.y-1, pos.z, m_FluidBlock, 8 ); // falling AddBlock( pos.x, pos.y-1, pos.z ); @@ -374,14 +384,15 @@ void cFluidSimulator::Simulate( float a_Dt ) char BlockID = m_World->GetBlock( p.x, p.y, p.z ); bool bWashedAwayItem = CanWashAway( BlockID ); - if(!IsPassableForFluid(BlockID)) continue; + if (!IsPassableForFluid(BlockID)) continue; - if( !IsAllowedBlock( BlockID ) ) + if (!IsAllowedBlock(BlockID)) { - if( bWashedAwayItem ) + if (bWashedAwayItem) { - cPickup* Pickup = new cPickup( p.x * 32 + 16, p.y * 32 + 16, p.z * 32 + 16, cItem( (ENUM_ITEM_ID)BlockID, 1, m_World->GetBlockMeta( p.x, p.y, p.z ) ) ); - Pickup->Initialize( m_World ); + cItems Drops; + cBlockToPickup::ToPickup(DownID, m_World->GetBlockMeta(p.x, p.y, p.z), E_ITEM_EMPTY, Drops); + m_World->SpawnItemPickups(Drops, p.x, p.y, p.z); } if( p.y == pos.y ) -- cgit v1.2.3