summaryrefslogtreecommitdiffstats
path: root/source/World.cpp
diff options
context:
space:
mode:
authorAlexander Harkness <bearbin@gmail.com>2013-08-07 19:37:03 +0200
committerAlexander Harkness <bearbin@gmail.com>2013-08-07 19:37:03 +0200
commitbe7a6d7a6679fd17e88e9f5131036d69978e4151 (patch)
tree8e1b46a9b8ac8d3d47a65f903a63e063e5550e94 /source/World.cpp
parentDrag in the latest core changes. (diff)
parentMerge pull request #48 from mc-server/BlockTracing (diff)
downloadcuberite-be7a6d7a6679fd17e88e9f5131036d69978e4151.tar
cuberite-be7a6d7a6679fd17e88e9f5131036d69978e4151.tar.gz
cuberite-be7a6d7a6679fd17e88e9f5131036d69978e4151.tar.bz2
cuberite-be7a6d7a6679fd17e88e9f5131036d69978e4151.tar.lz
cuberite-be7a6d7a6679fd17e88e9f5131036d69978e4151.tar.xz
cuberite-be7a6d7a6679fd17e88e9f5131036d69978e4151.tar.zst
cuberite-be7a6d7a6679fd17e88e9f5131036d69978e4151.zip
Diffstat (limited to '')
-rw-r--r--source/World.cpp73
1 files changed, 69 insertions, 4 deletions
diff --git a/source/World.cpp b/source/World.cpp
index 880f6e5b2..699767d5e 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -1,4 +1,3 @@
-
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "BlockID.h"
@@ -59,6 +58,9 @@
#include "tolua++.h"
+// DEBUG: Test out the cLineBlockTracer class by tracing a few lines:
+#include "LineBlockTracer.h"
+
#ifndef _WIN32
#include <stdlib.h>
#endif
@@ -278,7 +280,7 @@ cWorld::cWorld(const AString & a_WorldName) :
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);
@@ -442,6 +444,60 @@ void cWorld::InitializeSpawn(void)
// TODO: Better spawn detection - move spawn out of the water if it isn't set in the INI already
m_SpawnY = (double)GetHeight((int)m_SpawnX, (int)m_SpawnZ) + 1.6f; // +1.6f eye height
+
+
+ #ifdef TEST_LINEBLOCKTRACER
+ // DEBUG: Test out the cLineBlockTracer class by tracing a few lines:
+ class cTracerCallbacks :
+ public cBlockTracer::cCallbacks
+ {
+ virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
+ {
+ LOGD("Block {%d, %d, %d}: %d:%d (%s)",
+ a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta,
+ ItemToString(cItem(a_BlockType, 1, a_BlockMeta)).c_str()
+ );
+ return false;
+ }
+
+ virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ LOGD("Block {%d, %d, %d}: no data available",
+ a_BlockX, a_BlockY, a_BlockZ
+ );
+ return false;
+ }
+
+ virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ) override
+ {
+ LOGD("Out of world at {%f, %f, %f}", a_BlockX, a_BlockY, a_BlockZ);
+ return false;
+ }
+
+ virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ) override
+ {
+ LOGD("Into world at {%f, %f, %f}", a_BlockX, a_BlockY, a_BlockZ);
+ return false;
+ }
+
+ virtual void OnNoMoreHits(void) override
+ {
+ LOGD("No more hits");
+ }
+ } Callbacks;
+ LOGD("Spawn is at {%f, %f, %f}", m_SpawnX, m_SpawnY, m_SpawnZ);
+ LOGD("Tracing a line along +X:");
+ cLineBlockTracer::Trace(*this, Callbacks, m_SpawnX - 10, m_SpawnY, m_SpawnZ, m_SpawnX + 10, m_SpawnY, m_SpawnZ);
+ LOGD("Tracing a line along -Z:");
+ cLineBlockTracer::Trace(*this, Callbacks, m_SpawnX, m_SpawnY, m_SpawnZ + 10, m_SpawnX, m_SpawnY, m_SpawnZ - 10);
+ LOGD("Tracing a line along -Y, out of world:");
+ cLineBlockTracer::Trace(*this, Callbacks, m_SpawnX, 260, m_SpawnZ, m_SpawnX, -5, m_SpawnZ);
+ LOGD("Tracing a line along XY:");
+ cLineBlockTracer::Trace(*this, Callbacks, m_SpawnX - 10, m_SpawnY - 10, m_SpawnZ, m_SpawnX + 10, m_SpawnY + 10, m_SpawnZ);
+ LOGD("Tracing a line in generic direction:");
+ cLineBlockTracer::Trace(*this, Callbacks, m_SpawnX - 15, m_SpawnY - 5, m_SpawnZ + 7.5, m_SpawnX + 13, m_SpawnY - 10, m_SpawnZ + 8.5);
+ LOGD("Tracing tests done");
+ #endif // TEST_LINEBLOCKTRACER
}
@@ -634,7 +690,6 @@ void cWorld::TickSpawnMobs(float a_Dt)
{
switch (nightRand)
{
- case 1: MobType = E_ENTITY_TYPE_ZOMBIE; break; // _X 2013_06_25: Really? Zombies in the Nether?
case 5: MobType = E_ENTITY_TYPE_GHAST; break;
case 6: MobType = E_ENTITY_TYPE_ZOMBIE_PIGMAN; break;
}
@@ -642,8 +697,9 @@ void cWorld::TickSpawnMobs(float a_Dt)
else
{
switch (nightRand)
- {
+ {
case 0: MobType = E_ENTITY_TYPE_SPIDER; break;
+ case 1: MobType = E_ENTITY_TYPE_ZOMBIE; break;
case 2: MobType = E_ENTITY_TYPE_ENDERMAN; break;
case 3: MobType = E_ENTITY_TYPE_CREEPER; break;
case 4: MobType = E_ENTITY_TYPE_CAVE_SPIDER; break;
@@ -832,6 +888,15 @@ bool cWorld::GetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_
+bool cWorld::DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback & a_Callback)
+{
+ return m_ChunkMap->DoWithChunk(a_ChunkX, a_ChunkZ, a_Callback);
+}
+
+
+
+
+
void cWorld::GrowTree(int a_X, int a_Y, int a_Z)
{
if (GetBlock(a_X, a_Y, a_Z) == E_BLOCK_SAPLING)