summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/Bindings.cpp40
-rw-r--r--source/Bindings.h2
-rw-r--r--source/cChunk.cpp30
-rw-r--r--source/cChunk.h8
-rw-r--r--source/cChunkMap.cpp17
-rw-r--r--source/cChunkMap.h3
-rw-r--r--source/cWorld.cpp9
-rw-r--r--source/cWorld.h3
8 files changed, 92 insertions, 20 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 28c407ea5..4e60d38db 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 05/30/12 20:19:21.
+** Generated automatically by tolua++-1.0.92 on 05/30/12 23:28:27.
*/
#ifndef __cplusplus
@@ -11072,6 +11072,43 @@ static int tolua_AllToLua_cWorld_GetWeather00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: SetNextBlockTick of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_SetNextBlockTick00
+static int tolua_AllToLua_cWorld_SetNextBlockTick00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetNextBlockTick'", NULL);
+#endif
+ {
+ self->SetNextBlockTick(a_BlockX,a_BlockY,a_BlockZ);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetNextBlockTick'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: Clear of class cInventory */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_Clear00
static int tolua_AllToLua_cInventory_Clear00(lua_State* tolua_S)
@@ -18387,6 +18424,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"CastThunderbolt",tolua_AllToLua_cWorld_CastThunderbolt00);
tolua_function(tolua_S,"SetWeather",tolua_AllToLua_cWorld_SetWeather00);
tolua_function(tolua_S,"GetWeather",tolua_AllToLua_cWorld_GetWeather00);
+ tolua_function(tolua_S,"SetNextBlockTick",tolua_AllToLua_cWorld_SetNextBlockTick00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cInventory","cInventory","",NULL);
tolua_beginmodule(tolua_S,"cInventory");
diff --git a/source/Bindings.h b/source/Bindings.h
index 836e61345..801e63566 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 05/30/12 20:19:22.
+** Generated automatically by tolua++-1.0.92 on 05/30/12 23:28:28.
*/
/* Exported function */
diff --git a/source/cChunk.cpp b/source/cChunk.cpp
index 67ae02ecf..024e50adc 100644
--- a/source/cChunk.cpp
+++ b/source/cChunk.cpp
@@ -519,16 +519,6 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom)
void cChunk::TickBlocks(MTRand & a_TickRandom)
{
// Tick dem blocks
- /*
- // DEBUG:
- int RandomX = 0;
- int RandomY = 1;
- int RandomZ = 0;
- m_BlockTickX = 0;
- m_BlockTickY = 40;
- m_BlockTickZ = 0;
- */
-
int RandomX = a_TickRandom.randInt();
int RandomY = a_TickRandom.randInt();
int RandomZ = a_TickRandom.randInt();
@@ -536,17 +526,21 @@ void cChunk::TickBlocks(MTRand & a_TickRandom)
int TickY = m_BlockTickY;
int TickZ = m_BlockTickZ;
- for (int i = 0; i < 50; i++)
- {
+ // This for loop looks disgusting, but it actually does a simple thing - first processes m_BlockTick, then adds random to it
+ // This is so that SetNextBlockTick() works
+ for (int i = 0; i < 50; i++,
+
// This weird construct (*2, then /2) is needed,
// otherwise the blocktick distribution is too biased towards even coords!
- TickX = (TickX + RandomX) % (Width * 2);
- TickY = (TickY + RandomY) % (Height * 2);
- TickZ = (TickZ + RandomZ) % (Width * 2);
- m_BlockTickX = TickX / 2;
- m_BlockTickY = TickY / 2;
- m_BlockTickZ = TickZ / 2;
+ TickX = (TickX + RandomX) % (Width * 2),
+ TickY = (TickY + RandomY) % (Height * 2),
+ TickZ = (TickZ + RandomZ) % (Width * 2),
+ m_BlockTickX = TickX / 2,
+ m_BlockTickY = TickY / 2,
+ m_BlockTickZ = TickZ / 2
+ )
+ {
if (m_BlockTickY > cChunkDef::GetHeight(m_HeightMap, m_BlockTickX, m_BlockTickZ))
{
diff --git a/source/cChunk.h b/source/cChunk.h
index f9456c40c..3ae29aaba 100644
--- a/source/cChunk.h
+++ b/source/cChunk.h
@@ -161,6 +161,14 @@ public:
m_IsSaving = false;
}
+ /// Sets the blockticking to start at the specified block. Only one blocktick may be set, second call overwrites the first call
+ inline void SetNextBlockTick(int a_RelX, int a_RelY, int a_RelZ)
+ {
+ m_BlockTickX = a_RelX;
+ m_BlockTickY = a_RelY;
+ m_BlockTickZ = a_RelZ;
+ }
+
inline NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) {return cChunkDef::GetNibble(m_BlockMeta, a_RelX, a_RelY, a_RelZ); }
inline NIBBLETYPE GetMeta(int a_BlockIdx) {return cChunkDef::GetNibble(m_BlockMeta, a_BlockIdx); }
inline void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta) { cChunkDef::SetNibble(m_BlockMeta, a_RelX, a_RelY, a_RelZ, a_Meta); }
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp
index 546e6f4c3..f28e2ecb0 100644
--- a/source/cChunkMap.cpp
+++ b/source/cChunkMap.cpp
@@ -1083,6 +1083,23 @@ void cChunkMap::GetChunkStats(int & a_NumChunksValid, int & a_NumChunksDirty)
+void cChunkMap::SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ int ChunkX, ChunkZ;
+ cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
+
+ cCSLock Lock(m_CSLayers);
+ cChunkPtr Chunk = GetChunkNoLoad(ChunkX, ZERO_CHUNK_Y, ChunkZ);
+ if (Chunk != NULL)
+ {
+ Chunk->SetNextBlockTick(a_BlockX, a_BlockY, a_BlockZ);
+ }
+}
+
+
+
+
+
void cChunkMap::Tick( float a_Dt, MTRand & a_TickRandom )
{
cCSLock Lock(m_CSLayers);
diff --git a/source/cChunkMap.h b/source/cChunkMap.h
index 4b381296d..1d2459d21 100644
--- a/source/cChunkMap.h
+++ b/source/cChunkMap.h
@@ -149,6 +149,9 @@ public:
/// Returns the number of valid chunks and the number of dirty chunks
void GetChunkStats(int & a_NumChunksValid, int & a_NumChunksDirty);
+
+ /// Sets the blockticking to start at the specified block. Only one blocktick per chunk may be set, second call overwrites the first call
+ void SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ);
void Tick( float a_Dt, MTRand & a_TickRand );
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index d04ac1af5..91b7b69bc 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -435,6 +435,15 @@ bool cWorld::IsPlacingItemLegal(Int16 a_ItemType, int a_BlockX, int a_BlockY, in
+void cWorld::SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ return m_ChunkMap->SetNextBlockTick(a_BlockX, a_BlockY, a_BlockZ);
+}
+
+
+
+
+
void cWorld::InitializeSpawn(void)
{
int ChunkX = 0, ChunkY = 0, ChunkZ = 0;
diff --git a/source/cWorld.h b/source/cWorld.h
index bd5e741cf..35ce2c406 100644
--- a/source/cWorld.h
+++ b/source/cWorld.h
@@ -295,6 +295,9 @@ public:
bool IsPlacingItemLegal(Int16 a_ItemType, int a_BlockX, int a_BlockY, int a_BlockZ);
+ /// Sets the blockticking to start at the specified block. Only one blocktick per chunk may be set, second call overwrites the first call
+ void SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
+
private:
friend class cRoot;