summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-12 09:14:06 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-12 09:14:06 +0200
commitfe3712284ebf1661a9c536dd51e32f757b66aba3 (patch)
tree90dec2ce1c58c781d3e06ad88f320d1d07e8d7cb /source
parentProtectionAreas: Added a license file. (diff)
downloadcuberite-fe3712284ebf1661a9c536dd51e32f757b66aba3.tar
cuberite-fe3712284ebf1661a9c536dd51e32f757b66aba3.tar.gz
cuberite-fe3712284ebf1661a9c536dd51e32f757b66aba3.tar.bz2
cuberite-fe3712284ebf1661a9c536dd51e32f757b66aba3.tar.lz
cuberite-fe3712284ebf1661a9c536dd51e32f757b66aba3.tar.xz
cuberite-fe3712284ebf1661a9c536dd51e32f757b66aba3.tar.zst
cuberite-fe3712284ebf1661a9c536dd51e32f757b66aba3.zip
Diffstat (limited to 'source')
-rw-r--r--source/Bindings.cpp54
-rw-r--r--source/Bindings.h2
-rw-r--r--source/Chunk.cpp4
-rw-r--r--source/Chunk.h4
-rw-r--r--source/ChunkMap.cpp8
-rw-r--r--source/ChunkMap.h5
-rw-r--r--source/ManualBindings.cpp55
-rw-r--r--source/World.cpp21
-rw-r--r--source/World.h7
9 files changed, 92 insertions, 68 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index bb0f44557..f8b645582 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 06/09/13 19:45:13.
+** Generated automatically by tolua++-1.0.92 on 06/12/13 09:09:44.
*/
#ifndef __cplusplus
@@ -10931,57 +10931,6 @@ static int tolua_AllToLua_cWorld_GetNumPlayers00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
-/* method: UpdateSign of class cWorld */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_UpdateSign00
-static int tolua_AllToLua_cWorld_UpdateSign00(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_iscppstring(tolua_S,5,0,&tolua_err) ||
- !tolua_iscppstring(tolua_S,6,0,&tolua_err) ||
- !tolua_iscppstring(tolua_S,7,0,&tolua_err) ||
- !tolua_iscppstring(tolua_S,8,0,&tolua_err) ||
- !tolua_isusertype(tolua_S,9,"cPlayer",1,&tolua_err) ||
- !tolua_isnoobj(tolua_S,10,&tolua_err)
- )
- goto tolua_lerror;
- else
-#endif
- {
- cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
- int a_X = ((int) tolua_tonumber(tolua_S,2,0));
- int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
- int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
- const AString a_Line1 = ((const AString) tolua_tocppstring(tolua_S,5,0));
- const AString a_Line2 = ((const AString) tolua_tocppstring(tolua_S,6,0));
- const AString a_Line3 = ((const AString) tolua_tocppstring(tolua_S,7,0));
- const AString a_Line4 = ((const AString) tolua_tocppstring(tolua_S,8,0));
- cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,9,NULL));
-#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'UpdateSign'", NULL);
-#endif
- {
- self->UpdateSign(a_X,a_Y,a_Z,a_Line1,a_Line2,a_Line3,a_Line4,a_Player);
- tolua_pushcppstring(tolua_S,(const char*)a_Line1);
- tolua_pushcppstring(tolua_S,(const char*)a_Line2);
- tolua_pushcppstring(tolua_S,(const char*)a_Line3);
- tolua_pushcppstring(tolua_S,(const char*)a_Line4);
- }
- }
- return 4;
-#ifndef TOLUA_RELEASE
- tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'UpdateSign'.",&tolua_err);
- return 0;
-#endif
-}
-#endif //#ifndef TOLUA_DISABLE
-
/* method: RegenerateChunk of class cWorld */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_RegenerateChunk00
static int tolua_AllToLua_cWorld_RegenerateChunk00(lua_State* tolua_S)
@@ -27563,7 +27512,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"GetMaxPlayers",tolua_AllToLua_cWorld_GetMaxPlayers00);
tolua_function(tolua_S,"SetMaxPlayers",tolua_AllToLua_cWorld_SetMaxPlayers00);
tolua_function(tolua_S,"GetNumPlayers",tolua_AllToLua_cWorld_GetNumPlayers00);
- tolua_function(tolua_S,"UpdateSign",tolua_AllToLua_cWorld_UpdateSign00);
tolua_function(tolua_S,"RegenerateChunk",tolua_AllToLua_cWorld_RegenerateChunk00);
tolua_function(tolua_S,"GenerateChunk",tolua_AllToLua_cWorld_GenerateChunk00);
tolua_function(tolua_S,"SetBlock",tolua_AllToLua_cWorld_SetBlock00);
diff --git a/source/Bindings.h b/source/Bindings.h
index a5f883281..fec4d4f09 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 06/09/13 19:45:14.
+** Generated automatically by tolua++-1.0.92 on 06/12/13 09:09:45.
*/
/* Exported function */
diff --git a/source/Chunk.cpp b/source/Chunk.cpp
index 3cebe7d5c..c2afb9d5c 100644
--- a/source/Chunk.cpp
+++ b/source/Chunk.cpp
@@ -1705,7 +1705,7 @@ void cChunk::CollectPickupsByPlayer(cPlayer * a_Player)
-void cChunk::UpdateSign(int a_PosX, int a_PosY, int a_PosZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
+bool cChunk::SetSignLines(int a_PosX, int a_PosY, int a_PosZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
{
// Also sends update packets to all clients in the chunk
for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
@@ -1723,8 +1723,10 @@ void cChunk::UpdateSign(int a_PosX, int a_PosY, int a_PosZ, const AString & a_Li
MarkDirty();
(reinterpret_cast<cSignEntity *>(*itr))->SetLines(a_Line1, a_Line2, a_Line3, a_Line4);
m_World->BroadcastBlockEntity(a_PosX, a_PosY, a_PosZ);
+ return true;
}
} // for itr - m_BlockEntities[]
+ return false;
}
diff --git a/source/Chunk.h b/source/Chunk.h
index a96d96ef3..748227b70 100644
--- a/source/Chunk.h
+++ b/source/Chunk.h
@@ -169,7 +169,9 @@ public:
EMCSBiome GetBiomeAt(int a_RelX, int a_RelZ) const {return cChunkDef::GetBiome(m_BiomeMap, a_RelX, a_RelZ); }
void CollectPickupsByPlayer(cPlayer * a_Player);
- void UpdateSign(int a_PosX, int a_PosY, int a_PosZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4); // Also sends update packets to all clients in the chunk
+
+ /// Sets the sign text. Returns true if successful. Also sends update packets to all clients in the chunk
+ bool SetSignLines(int a_RelX, int a_RelY, int a_RelZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
int GetHeight( int a_X, int a_Z );
diff --git a/source/ChunkMap.cpp b/source/ChunkMap.cpp
index 785238d1d..a4ca99c9f 100644
--- a/source/ChunkMap.cpp
+++ b/source/ChunkMap.cpp
@@ -1794,17 +1794,17 @@ void cChunkMap::ChunkLoadFailed(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
-void cChunkMap::UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
+bool cChunkMap::SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
{
cCSLock Lock(m_CSLayers);
int ChunkX, ChunkZ;
- cChunkDef::BlockToChunk(a_X, a_Y, a_Z, ChunkX, ChunkZ);
+ cChunkDef::BlockToChunk(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
if ((Chunk == NULL) || !Chunk->IsValid())
{
- return;
+ return false;
}
- Chunk->UpdateSign(a_X, a_Y, a_Z, a_Line1, a_Line2, a_Line3, a_Line4);
+ return Chunk->SetSignLines(a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4);
}
diff --git a/source/ChunkMap.h b/source/ChunkMap.h
index 4a25abd4b..1af26c39a 100644
--- a/source/ChunkMap.h
+++ b/source/ChunkMap.h
@@ -250,10 +250,11 @@ public:
/// Loads the chunks specified. Doesn't report failure, other than chunks being !IsValid()
void LoadChunks(const cChunkCoordsList & a_Chunks);
- /// Marks the chunk as failed-to-load:
+ /// Marks the chunk as failed-to-load
void ChunkLoadFailed(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
- void UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
+ /// Sets the sign text. Returns true if sign text changed.
+ bool SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
/// Marks (a_Stay == true) or unmarks (a_Stay == false) chunks as non-unloadable; to be used only by cChunkStay!
void ChunksStay(const cChunkCoordsList & a_Chunks, bool a_Stay = true);
diff --git a/source/ManualBindings.cpp b/source/ManualBindings.cpp
index fb0a471bf..30648a8b7 100644
--- a/source/ManualBindings.cpp
+++ b/source/ManualBindings.cpp
@@ -543,6 +543,59 @@ static int tolua_ForEach(lua_State * tolua_S)
+static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
+{
+ // Exported manually, because tolua would generate useless additional return values (a_Line1 .. a_Line4)
+ #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_iscppstring(tolua_S, 5, 0, &tolua_err) ||
+ !tolua_iscppstring(tolua_S, 6, 0, &tolua_err) ||
+ !tolua_iscppstring(tolua_S, 7, 0, &tolua_err) ||
+ !tolua_iscppstring(tolua_S, 8, 0, &tolua_err) ||
+ !tolua_isusertype (tolua_S, 9, "cPlayer", 1, &tolua_err) ||
+ !tolua_isnoobj (tolua_S, 10, &tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ #endif
+ {
+ cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, 0);
+ int BlockX = (int) tolua_tonumber (tolua_S, 2, 0);
+ int BlockY = (int) tolua_tonumber (tolua_S, 3, 0);
+ int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0);
+ const AString Line1 = tolua_tocppstring(tolua_S, 5, 0);
+ const AString Line2 = tolua_tocppstring(tolua_S, 6, 0);
+ const AString Line3 = tolua_tocppstring(tolua_S, 7, 0);
+ const AString Line4 = tolua_tocppstring(tolua_S, 8, 0);
+ cPlayer * Player = (cPlayer *)tolua_tousertype (tolua_S, 9, NULL);
+ #ifndef TOLUA_RELEASE
+ if (self == NULL)
+ {
+ tolua_error(tolua_S, "invalid 'self' in function 'SetSignLines' / 'UpdateSign'", NULL);
+ }
+ #endif
+ {
+ bool res = self->UpdateSign(BlockX, BlockY, BlockZ, Line1, Line2, Line3, Line4, Player);
+ tolua_pushboolean(tolua_S, res ? 1 : 0);
+ }
+ }
+ return 1;
+
+ #ifndef TOLUA_RELEASE
+tolua_lerror:
+ tolua_error(tolua_S, "#ferror in function 'SetSignLines' / 'UpdateSign'.", &tolua_err);
+ return 0;
+ #endif
+}
+
+
+
+
static int tolua_cPluginManager_GetAllPlugins(lua_State * tolua_S)
{
cPluginManager* self = (cPluginManager*) tolua_tousertype(tolua_S,1,0);
@@ -1284,6 +1337,8 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "DoWithDropperAt", tolua_DoWithXYZ<cWorld, cDropperEntity, &cWorld::DoWithDropperAt>);
tolua_function(tolua_S, "DoWithDropSpenserAt", tolua_DoWithXYZ<cWorld, cDropSpenserEntity, &cWorld::DoWithDropSpenserAt>);
tolua_function(tolua_S, "DoWithFurnaceAt", tolua_DoWithXYZ<cWorld, cFurnaceEntity, &cWorld::DoWithFurnaceAt>);
+ tolua_function(tolua_S, "SetSignLines", tolua_cWorld_SetSignLines);
+ tolua_function(tolua_S, "UpdateSign", tolua_cWorld_SetSignLines);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cPlugin");
diff --git a/source/World.cpp b/source/World.cpp
index 4b0e4e224..36fb08702 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -2068,7 +2068,7 @@ void cWorld::ChunkLoadFailed(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
-void cWorld::UpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player)
+bool cWorld::SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player)
{
AString Line1(a_Line1);
AString Line2(a_Line2);
@@ -2076,10 +2076,23 @@ void cWorld::UpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, const AString
AString Line4(a_Line4);
if (cRoot::Get()->GetPluginManager()->CallHookUpdatingSign(this, a_BlockX, a_BlockY, a_BlockZ, Line1, Line2, Line3, Line4, a_Player))
{
- return;
+ return false;
+ }
+ if (m_ChunkMap->SetSignLines(a_BlockX, a_BlockY, a_BlockZ, Line1, Line2, Line3, Line4))
+ {
+ cRoot::Get()->GetPluginManager()->CallHookUpdatedSign(this, a_BlockX, a_BlockY, a_BlockZ, Line1, Line2, Line3, Line4, a_Player);
+ return true;
}
- m_ChunkMap->UpdateSign(a_BlockX, a_BlockY, a_BlockZ, Line1, Line2, Line3, Line4);
- cRoot::Get()->GetPluginManager()->CallHookUpdatedSign(this, a_BlockX, a_BlockY, a_BlockZ, Line1, Line2, Line3, Line4, a_Player);
+ return false;
+}
+
+
+
+
+
+bool cWorld::UpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player)
+{
+ return SetSignLines(a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player);
}
diff --git a/source/World.h b/source/World.h
index b495750a9..21869bd41 100644
--- a/source/World.h
+++ b/source/World.h
@@ -260,8 +260,11 @@ public:
/// Marks the chunk as failed-to-load:
void ChunkLoadFailed(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
- /// Updates the sign, askin gplugins for permission forst. a_Player is the player who changed the sign, may be NULL
- void UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = NULL); // tolua_export
+ /// Sets the sign text, asking plugins for permission first. a_Player is the player who this change belongs to, may be NULL. Returns true if sign text changed. Same as UpdateSign()
+ bool SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = NULL); // Exported in ManualBindings.cpp
+
+ /// Sets the sign text, asking plugins for permission first. a_Player is the player who this change belongs to, may be NULL. Returns true if sign text changed. Same as SetSignLines()
+ bool UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = NULL); // Exported in ManualBindings.cpp
/// Marks (a_Stay == true) or unmarks (a_Stay == false) chunks as non-unloadable. To be used only by cChunkStay!
void ChunksStay(const cChunkCoordsList & a_Chunks, bool a_Stay = true);