From 36f7084e3fb4193676b14f302d0f961f2102e4ba Mon Sep 17 00:00:00 2001 From: "admin@omencraft.com" Date: Sun, 6 Nov 2011 09:23:20 +0000 Subject: Patch with diff file created by Sebi (implemented some stuff like lava physics, drops are deleted when in lava, water is now slower, lava gives actual damage etc.). Pistons now work mostly as they should. They do not yet show the motion animation and do not emit sound. They do extend, push, and retract as they should though. Right now the only way to activate a piston is to light redstone wire adjacent to it with a redstone torch. git-svn-id: http://mc-server.googlecode.com/svn/trunk@67 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cWorld.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'source/cWorld.cpp') diff --git a/source/cWorld.cpp b/source/cWorld.cpp index c67998064..0601746e8 100644 --- a/source/cWorld.cpp +++ b/source/cWorld.cpp @@ -13,6 +13,7 @@ #include "../iniFile/iniFile.h" #include "cChunkMap.h" #include "cWaterSimulator.h" +#include "cLavaSimulator.h" #include "cChicken.h" #include "cSpider.h" #include "cCow.h" //cow @@ -47,6 +48,8 @@ #include #endif + + float cWorld::m_Time = 0.f; char g_BlockLightValue[128]; @@ -94,6 +97,7 @@ cWorld::~cWorld() UnlockEntities(); delete m_WaterSimulator; + delete m_LavaSimulator; UnloadUnusedChunks(); delete m_ChunkMap; @@ -114,9 +118,9 @@ cWorld::cWorld( const char* a_WorldName ) cMakeDir::MakeDir(m_pState->WorldName.c_str()); srand( (unsigned int) time(0) ); - m_SpawnX = (double)((rand()%10000)-5000); + m_SpawnX = (double)((rand()%1000)-500); m_SpawnY = 128; - m_SpawnZ = (double)((rand()%10000)-5000); + m_SpawnZ = (double)((rand()%1000)-500); m_WorldSeed = rand(); m_GameMode = 0; @@ -187,6 +191,7 @@ cWorld::cWorld( const char* a_WorldName ) m_ChunksCriticalSection = new cCriticalSection(); m_WaterSimulator = new cWaterSimulator( this ); + m_LavaSimulator = new cLavaSimulator( this ); memset( g_BlockLightValue, 0x0, 128 ); memset( g_BlockSpreadLightFalloff, 0xf, 128 ); // 0xf means total falloff @@ -263,6 +268,8 @@ void cWorld::Tick(float a_Dt) { m_Time+=a_Dt/1000.f; + CurrentTick++; + bool bSendTime = false; m_WorldTimeFraction+=a_Dt/1000.f; while( m_WorldTimeFraction > 1.f ) @@ -302,7 +309,10 @@ void cWorld::Tick(float a_Dt) } m_ChunkMap->Tick(a_Dt); - m_WaterSimulator->Simulate(a_Dt); + if( CurrentTick % 6 == 0 ) + m_WaterSimulator->Simulate(a_Dt); + if( CurrentTick % 12 == 0 ) + m_LavaSimulator->Simulate(a_Dt); UnlockChunks(); if( m_Time - m_LastSave > 60*5 ) // Save each 5 minutes @@ -499,6 +509,7 @@ cChunk* cWorld::GetChunkOfBlock( int a_X, int a_Y, int a_Z ) void cWorld::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta ) { m_WaterSimulator->WakeUp( a_X, a_Y, a_Z ); + m_LavaSimulator->WakeUp( a_X, a_Y, a_Z ); int ChunkX, ChunkY, ChunkZ; AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkY, ChunkZ ); @@ -556,6 +567,7 @@ bool cWorld::DigBlock( int a_X, int a_Y, int a_Z, cItem & a_PickupItem ) { DestChunk->SetBlock(PosX, PosY, PosZ, 0, 0 ); m_WaterSimulator->WakeUp( a_X, a_Y, a_Z ); + m_LavaSimulator->WakeUp( a_X, a_Y, a_Z ); if( !a_PickupItem.IsEmpty() ) { -- cgit v1.2.3