diff options
Diffstat (limited to '')
-rw-r--r-- | source/World.cpp | 68 |
1 files changed, 21 insertions, 47 deletions
diff --git a/source/World.cpp b/source/World.cpp index e5011e65d..7a9bf46af 100644 --- a/source/World.cpp +++ b/source/World.cpp @@ -33,8 +33,6 @@ #include "MobSpawner.h" #include "MobTypesManager.h" - -#include "OSSupport/MakeDir.h" #include "MersenneTwister.h" #include "Generating/Trees.h" #include "PluginManager.h" @@ -236,7 +234,7 @@ cWorld::cWorld(const AString & a_WorldName) : { LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str()); - cMakeDir::MakeDir(m_WorldName.c_str()); + cFile::CreateFolder(FILE_IO_PREFIX + m_WorldName); } @@ -510,7 +508,7 @@ void cWorld::Start(void) m_LastSave = 0; m_LastUnload = 0; - // preallocate some memory for ticking blocks so we don�t need to allocate that often + // preallocate some memory for ticking blocks so we don't need to allocate that often m_BlockTickQueue.reserve(1000); m_BlockTickQueueCopy.reserve(1000); @@ -604,7 +602,7 @@ void cWorld::Tick(float a_Dt) m_ChunkMap->Tick(a_Dt); TickClients(a_Dt); - TickQueuedBlocks(a_Dt); + TickQueuedBlocks(); TickQueuedTasks(); GetSimulatorManager()->Simulate(a_Dt); @@ -788,7 +786,7 @@ void cWorld::TickQueuedTasks(void) } // Execute and delete each task: - for (cTasks::iterator itr = m_Tasks.begin(), end = m_Tasks.end(); itr != end; ++itr) + for (cTasks::iterator itr = Tasks.begin(), end = Tasks.end(); itr != end; ++itr) { (*itr)->Run(*this); delete *itr; @@ -1038,7 +1036,7 @@ void cWorld::GrowTree(int a_X, int a_Y, int a_Z) -void cWorld::GrowTreeFromSapling(int a_X, int a_Y, int a_Z, char a_SaplingMeta) +void cWorld::GrowTreeFromSapling(int a_X, int a_Y, int a_Z, NIBBLETYPE a_SaplingMeta) { cNoise Noise(m_Generator.GetSeed()); sSetBlockVector Logs, Other; @@ -1290,7 +1288,7 @@ void cWorld::GrowCactus(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlock -void cWorld::GrowMelonPumpkin(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockType) +void cWorld::GrowMelonPumpkin(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType) { MTRand Rand; m_ChunkMap->GrowMelonPumpkin(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, Rand); @@ -1459,25 +1457,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) { float SpeedX = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500)); - float SpeedY = (float)(a_FlyAwaySpeed * r1.randInt(1000)); + float SpeedY = 1; float SpeedZ = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500)); - // Add random offset to the spawn position: - int MicroX = (int)(a_BlockX * 32) + (r1.randInt(16) + r1.randInt(16) - 16); - int MicroY = (int)(a_BlockY * 32) + (r1.randInt(16) + r1.randInt(16) - 16); - int MicroZ = (int)(a_BlockZ * 32) + (r1.randInt(16) + r1.randInt(16) - 16); - - // TODO 2013_05_12 _X: Because spawning pickups with nonzero speed causes them to bug (FS #338), - // I decided to temporarily reset the speed to zero to fix it, until we have proper pickup physics - SpeedX = SpeedY = SpeedZ = 0; - - // TODO 2013_05_12 _X: It seems that pickups bug out even with zero speed, trying mid-block position: - MicroX = (int)(floor(a_BlockX) * 32) + 16; - MicroY = (int)(floor(a_BlockY) * 32) + 16; - MicroZ = (int)(floor(a_BlockZ) * 32) + 16; - cPickup * Pickup = new cPickup( - MicroX, MicroY, MicroZ, + a_BlockX, a_BlockY, a_BlockZ, *itr, SpeedX, SpeedY, SpeedZ ); Pickup->Initialize(this); @@ -1490,25 +1474,10 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ) { - // TODO 2013_05_12 _X: Because spawning pickups with nonzero speed causes them to bug (FS #338), - // I decided to temporarily reset the speed to zero to fix it, until we have proper pickup physics - a_SpeedX = a_SpeedY = a_SpeedZ = 0; - - MTRand r1; for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr) { - // Add random offset to the spawn position: - int MicroX = (int)(a_BlockX * 32) + (r1.randInt(16) + r1.randInt(16) - 16); - int MicroY = (int)(a_BlockY * 32) + (r1.randInt(16) + r1.randInt(16) - 16); - int MicroZ = (int)(a_BlockZ * 32) + (r1.randInt(16) + r1.randInt(16) - 16); - - // TODO 2013_05_12 _X: It seems that pickups bug out even with zero speed, trying mid-block position: - MicroX = (int)(floor(a_BlockX) * 32) + 16; - MicroY = (int)(floor(a_BlockY) * 32) + 16; - MicroZ = (int)(floor(a_BlockZ) * 32) + 16; - cPickup * Pickup = new cPickup( - MicroX, MicroY, MicroZ, + a_BlockX, a_BlockY, a_BlockZ, *itr, (float)a_SpeedX, (float)a_SpeedY, (float)a_SpeedZ ); Pickup->Initialize(this); @@ -2477,7 +2446,7 @@ void cWorld::GetChunkStats(int & a_NumValid, int & a_NumDirty, int & a_NumInLigh -void cWorld::TickQueuedBlocks(float a_Dt) +void cWorld::TickQueuedBlocks(void) { if (m_BlockTickQueue.empty()) { @@ -2489,15 +2458,16 @@ void cWorld::TickQueuedBlocks(float a_Dt) for (std::vector<BlockTickQueueItem *>::iterator itr = m_BlockTickQueueCopy.begin(); itr != m_BlockTickQueueCopy.end(); itr++) { BlockTickQueueItem *Block = (*itr); - Block->ToWait -= a_Dt; - if (Block->ToWait <= 0) + Block->TicksToWait -= 1; + if (Block->TicksToWait <= 0) { + // TODO: Handle the case when the chunk is already unloaded BlockHandler(GetBlock(Block->X, Block->Y, Block->Z))->OnUpdate(this, Block->X, Block->Y, Block->Z); - delete Block; //We don't have to remove it from the vector, this will happen automatically on the next tick + delete Block; // We don't have to remove it from the vector, this will happen automatically on the next tick } else { - m_BlockTickQueue.push_back(Block); //Keep the block in the queue + m_BlockTickQueue.push_back(Block); // Keep the block in the queue } } // for itr - m_BlockTickQueueCopy[] } @@ -2506,13 +2476,13 @@ void cWorld::TickQueuedBlocks(float a_Dt) -void cWorld::QueueBlockForTick(int a_BlockX, int a_BlockY, int a_BlockZ, float a_TimeToWait) +void cWorld::QueueBlockForTick(int a_BlockX, int a_BlockY, int a_BlockZ, int a_TicksToWait) { BlockTickQueueItem * Block = new BlockTickQueueItem; Block->X = a_BlockX; Block->Y = a_BlockY; Block->Z = a_BlockZ; - Block->ToWait = a_TimeToWait; + Block->TicksToWait = a_TicksToWait; m_BlockTickQueue.push_back(Block); } @@ -2538,6 +2508,10 @@ bool cWorld::IsBlockDirectlyWatered(int a_BlockX, int a_BlockY, int a_BlockZ) int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eType a_MonsterType) { cMonster * Monster = NULL; + + int SlSize = GetTickRandomNumber(2) + 1; // 1 .. 3 - Slime + int ShColor = GetTickRandomNumber(15); // 0 .. 15 - Sheep + bool SkType = GetDimension() == biNether; // Skeleton cMobTypesManager::NewMonsterFromType(a_MonsterType); Monster->SetPosition(a_PosX, a_PosY, a_PosZ); |