1
0

Added cWorld::SetSignLines(), re-exported to Lua manually to avoid ghost return values

FS #364

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1582 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2013-06-12 07:14:06 +00:00
parent bb3e53df08
commit fe3712284e
9 changed files with 92 additions and 68 deletions

View File

@ -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);

View File

@ -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 */

View File

@ -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;
}

View File

@ -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 );

View File

@ -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);
}

View File

@ -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);

View File

@ -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");

View File

@ -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;
}
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);
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;
}
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);
}

View File

@ -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);