From 18a99085f468dfcb4ec2d9f93361b23874364d82 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 16 Jun 2012 15:06:14 +0000 Subject: Added new hooks: UPDATING_SIGN and UPDATED_SIGN. The first one is capable of changing the sign text by returning the new four lines along with the bool value git-svn-id: http://mc-server.googlecode.com/svn/trunk@622 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Bindings.cpp | 300 +++++++++++++++++++++++++++++++++++++++++++++- source/Bindings.h | 2 +- source/cPlugin.h | 2 + source/cPluginManager.cpp | 45 ++++++- source/cPluginManager.h | 7 +- source/cPlugin_NewLua.cpp | 84 +++++++++++++ source/cPlugin_NewLua.h | 2 + source/cWorld.cpp | 17 ++- 8 files changed, 451 insertions(+), 8 deletions(-) diff --git a/source/Bindings.cpp b/source/Bindings.cpp index 17d65bfcb..d91d8b101 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on Sat Jun 16 00:40:32 2012. +** Generated automatically by tolua++-1.0.92 on 06/16/12 17:04:45. */ #ifndef __cplusplus @@ -8117,6 +8117,110 @@ static int tolua_AllToLua_cPlugin_OnWeatherChanged00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* method: OnUpdatingSign of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnUpdatingSign00 +static int tolua_AllToLua_cPlugin_OnUpdatingSign00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(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_iscppstring(tolua_S,9,0,&tolua_err) || + !tolua_isnoobj(tolua_S,10,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); + cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); + int a_BlockX = ((int) tolua_tonumber(tolua_S,3,0)); + int a_BlockY = ((int) tolua_tonumber(tolua_S,4,0)); + int a_BlockZ = ((int) tolua_tonumber(tolua_S,5,0)); + AString a_Line1 = ((AString) tolua_tocppstring(tolua_S,6,0)); + AString a_Line2 = ((AString) tolua_tocppstring(tolua_S,7,0)); + AString a_Line3 = ((AString) tolua_tocppstring(tolua_S,8,0)); + AString a_Line4 = ((AString) tolua_tocppstring(tolua_S,9,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnUpdatingSign'", NULL); +#endif + { + bool tolua_ret = (bool) self->OnUpdatingSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + 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 5; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'OnUpdatingSign'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: OnUpdatedSign of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnUpdatedSign00 +static int tolua_AllToLua_cPlugin_OnUpdatedSign00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(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_iscppstring(tolua_S,9,0,&tolua_err) || + !tolua_isnoobj(tolua_S,10,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); + cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); + int a_BlockX = ((int) tolua_tonumber(tolua_S,3,0)); + int a_BlockY = ((int) tolua_tonumber(tolua_S,4,0)); + int a_BlockZ = ((int) tolua_tonumber(tolua_S,5,0)); + const AString a_Line1 = ((const AString) tolua_tocppstring(tolua_S,6,0)); + const AString a_Line2 = ((const AString) tolua_tocppstring(tolua_S,7,0)); + const AString a_Line3 = ((const AString) tolua_tocppstring(tolua_S,8,0)); + const AString a_Line4 = ((const AString) tolua_tocppstring(tolua_S,9,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnUpdatedSign'", NULL); +#endif + { + bool tolua_ret = (bool) self->OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + 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 5; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'OnUpdatedSign'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* method: GetName of class cPlugin */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_GetName00 static int tolua_AllToLua_cPlugin_GetName00(lua_State* tolua_S) @@ -8621,6 +8725,42 @@ public: return ( bool ) cPlugin:: OnWeatherChanged(a_World); }; }; + bool OnUpdatingSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString& a_Line1, AString& a_Line2, AString& a_Line3, AString& a_Line4) { + if (push_method("OnUpdatingSign", tolua_AllToLua_cPlugin_OnUpdatingSign00)) { + tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); + tolua_pushnumber(lua_state, (lua_Number)a_BlockX); + tolua_pushnumber(lua_state, (lua_Number)a_BlockY); + tolua_pushnumber(lua_state, (lua_Number)a_BlockZ); + tolua_pushcppstring(lua_state, (const char*)a_Line1); + tolua_pushcppstring(lua_state, (const char*)a_Line2); + tolua_pushcppstring(lua_state, (const char*)a_Line3); + tolua_pushcppstring(lua_state, (const char*)a_Line4); + ToluaBase::dbcall(lua_state, 9, 1); + bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( bool ) cPlugin:: OnUpdatingSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + }; + }; + bool OnUpdatedSign( cWorld* a_World, 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) { + if (push_method("OnUpdatedSign", tolua_AllToLua_cPlugin_OnUpdatedSign00)) { + tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); + tolua_pushnumber(lua_state, (lua_Number)a_BlockX); + tolua_pushnumber(lua_state, (lua_Number)a_BlockY); + tolua_pushnumber(lua_state, (lua_Number)a_BlockZ); + tolua_pushcppstring(lua_state, (const char*)a_Line1); + tolua_pushcppstring(lua_state, (const char*)a_Line2); + tolua_pushcppstring(lua_state, (const char*)a_Line3); + tolua_pushcppstring(lua_state, (const char*)a_Line4); + ToluaBase::dbcall(lua_state, 9, 1); + bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( bool ) cPlugin:: OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + }; + }; void cPlugin__OnDisable( void ) { return ( void )cPlugin::OnDisable(); @@ -8681,6 +8821,12 @@ public: }; bool cPlugin__OnWeatherChanged( cWorld* a_World) { return ( bool )cPlugin::OnWeatherChanged(a_World); + }; + bool cPlugin__OnUpdatingSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString& a_Line1, AString& a_Line2, AString& a_Line3, AString& a_Line4) { + return ( bool )cPlugin::OnUpdatingSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + }; + bool cPlugin__OnUpdatedSign( cWorld* a_World, 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) { + return ( bool )cPlugin::OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); }; Lua__cPlugin( void ): cPlugin(){}; }; @@ -9437,6 +9583,110 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnWeatherChanged00(lua_State* to } #endif //#ifndef TOLUA_DISABLE +/* method: cPlugin__OnUpdatingSign of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatingSign00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatingSign00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(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_iscppstring(tolua_S,9,0,&tolua_err) || + !tolua_isnoobj(tolua_S,10,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); + cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); + int a_BlockX = ((int) tolua_tonumber(tolua_S,3,0)); + int a_BlockY = ((int) tolua_tonumber(tolua_S,4,0)); + int a_BlockZ = ((int) tolua_tonumber(tolua_S,5,0)); + AString a_Line1 = ((AString) tolua_tocppstring(tolua_S,6,0)); + AString a_Line2 = ((AString) tolua_tocppstring(tolua_S,7,0)); + AString a_Line3 = ((AString) tolua_tocppstring(tolua_S,8,0)); + AString a_Line4 = ((AString) tolua_tocppstring(tolua_S,9,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnUpdatingSign'", NULL); +#endif + { + bool tolua_ret = (bool) self->cPlugin__OnUpdatingSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + 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 5; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnUpdatingSign'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: cPlugin__OnUpdatedSign of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatedSign00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatedSign00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(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_iscppstring(tolua_S,9,0,&tolua_err) || + !tolua_isnoobj(tolua_S,10,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); + cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); + int a_BlockX = ((int) tolua_tonumber(tolua_S,3,0)); + int a_BlockY = ((int) tolua_tonumber(tolua_S,4,0)); + int a_BlockZ = ((int) tolua_tonumber(tolua_S,5,0)); + const AString a_Line1 = ((const AString) tolua_tocppstring(tolua_S,6,0)); + const AString a_Line2 = ((const AString) tolua_tocppstring(tolua_S,7,0)); + const AString a_Line3 = ((const AString) tolua_tocppstring(tolua_S,8,0)); + const AString a_Line4 = ((const AString) tolua_tocppstring(tolua_S,9,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnUpdatedSign'", NULL); +#endif + { + bool tolua_ret = (bool) self->cPlugin__OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + 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 5; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnUpdatedSign'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* method: new of class Lua__cPlugin */ #ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_new00 static int tolua_AllToLua_Lua__cPlugin_new00(lua_State* tolua_S) @@ -9902,6 +10152,42 @@ public: return ( bool ) cPlugin_NewLua:: OnWeatherChanged(a_World); }; }; + bool OnUpdatingSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString& a_Line1, AString& a_Line2, AString& a_Line3, AString& a_Line4) { + if (push_method("OnUpdatingSign", tolua_AllToLua_cPlugin_OnUpdatingSign00)) { + tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); + tolua_pushnumber(lua_state, (lua_Number)a_BlockX); + tolua_pushnumber(lua_state, (lua_Number)a_BlockY); + tolua_pushnumber(lua_state, (lua_Number)a_BlockZ); + tolua_pushcppstring(lua_state, (const char*)a_Line1); + tolua_pushcppstring(lua_state, (const char*)a_Line2); + tolua_pushcppstring(lua_state, (const char*)a_Line3); + tolua_pushcppstring(lua_state, (const char*)a_Line4); + ToluaBase::dbcall(lua_state, 9, 1); + bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( bool ) cPlugin_NewLua:: OnUpdatingSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + }; + }; + bool OnUpdatedSign( cWorld* a_World, 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) { + if (push_method("OnUpdatedSign", tolua_AllToLua_cPlugin_OnUpdatedSign00)) { + tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); + tolua_pushnumber(lua_state, (lua_Number)a_BlockX); + tolua_pushnumber(lua_state, (lua_Number)a_BlockY); + tolua_pushnumber(lua_state, (lua_Number)a_BlockZ); + tolua_pushcppstring(lua_state, (const char*)a_Line1); + tolua_pushcppstring(lua_state, (const char*)a_Line2); + tolua_pushcppstring(lua_state, (const char*)a_Line3); + tolua_pushcppstring(lua_state, (const char*)a_Line4); + ToluaBase::dbcall(lua_state, 9, 1); + bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( bool ) cPlugin_NewLua:: OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + }; + }; void cPlugin_NewLua__OnDisable( void ) { return ( void )cPlugin_NewLua::OnDisable(); @@ -9966,6 +10252,12 @@ public: bool cPlugin_NewLua__OnWeatherChanged( cWorld* a_World) { return ( bool )cPlugin_NewLua::OnWeatherChanged(a_World); }; + bool cPlugin_NewLua__OnUpdatingSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString& a_Line1, AString& a_Line2, AString& a_Line3, AString& a_Line4) { + return ( bool )cPlugin_NewLua::OnUpdatingSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + }; + bool cPlugin_NewLua__OnUpdatedSign( cWorld* a_World, 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) { + return ( bool )cPlugin_NewLua::OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + }; }; /* method: tolua__set_instance of class Lua__cPlugin_NewLua */ @@ -20873,6 +21165,8 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_constant(tolua_S,"HOOK_POST_CRAFTING",cPluginManager::HOOK_POST_CRAFTING); tolua_constant(tolua_S,"HOOK_BLOCK_TO_PICKUP",cPluginManager::HOOK_BLOCK_TO_PICKUP); tolua_constant(tolua_S,"HOOK_WEATHER_CHANGED",cPluginManager::HOOK_WEATHER_CHANGED); + tolua_constant(tolua_S,"HOOK_UPDATING_SIGN",cPluginManager::HOOK_UPDATING_SIGN); + tolua_constant(tolua_S,"HOOK_UPDATED_SIGN",cPluginManager::HOOK_UPDATED_SIGN); tolua_constant(tolua_S,"E_PLUGIN_TICK",cPluginManager::E_PLUGIN_TICK); tolua_constant(tolua_S,"E_PLUGIN_CHAT",cPluginManager::E_PLUGIN_CHAT); tolua_constant(tolua_S,"E_PLUGIN_COLLECT_ITEM",cPluginManager::E_PLUGIN_COLLECT_ITEM); @@ -20927,6 +21221,8 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"OnPostCrafting",tolua_AllToLua_cPlugin_OnPostCrafting00); tolua_function(tolua_S,"OnBlockToPickup",tolua_AllToLua_cPlugin_OnBlockToPickup00); tolua_function(tolua_S,"OnWeatherChanged",tolua_AllToLua_cPlugin_OnWeatherChanged00); + tolua_function(tolua_S,"OnUpdatingSign",tolua_AllToLua_cPlugin_OnUpdatingSign00); + tolua_function(tolua_S,"OnUpdatedSign",tolua_AllToLua_cPlugin_OnUpdatedSign00); tolua_function(tolua_S,"GetName",tolua_AllToLua_cPlugin_GetName00); tolua_function(tolua_S,"SetName",tolua_AllToLua_cPlugin_SetName00); tolua_function(tolua_S,"GetVersion",tolua_AllToLua_cPlugin_GetVersion00); @@ -20966,6 +21262,8 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"cPlugin__OnPostCrafting",tolua_AllToLua_Lua__cPlugin_cPlugin__OnPostCrafting00); tolua_function(tolua_S,"cPlugin__OnBlockToPickup",tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockToPickup00); tolua_function(tolua_S,"cPlugin__OnWeatherChanged",tolua_AllToLua_Lua__cPlugin_cPlugin__OnWeatherChanged00); + tolua_function(tolua_S,"cPlugin__OnUpdatingSign",tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatingSign00); + tolua_function(tolua_S,"cPlugin__OnUpdatedSign",tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatedSign00); tolua_function(tolua_S,"new",tolua_AllToLua_Lua__cPlugin_new00); tolua_function(tolua_S,"new_local",tolua_AllToLua_Lua__cPlugin_new00_local); tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cPlugin_new00_local); diff --git a/source/Bindings.h b/source/Bindings.h index cd95c2699..be611c9d5 100644 --- a/source/Bindings.h +++ b/source/Bindings.h @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on Sat Jun 16 00:40:32 2012. +** Generated automatically by tolua++-1.0.92 on 06/16/12 17:04:45. */ /* Exported function */ diff --git a/source/cPlugin.h b/source/cPlugin.h index 41618e47e..e42e970c2 100644 --- a/source/cPlugin.h +++ b/source/cPlugin.h @@ -66,6 +66,8 @@ public: virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) {return false; } virtual bool OnBlockToPickup (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups) {return false; } virtual bool OnWeatherChanged (cWorld * a_World) {return false; } + virtual bool OnUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4) {return false; } + virtual bool OnUpdatedSign (cWorld * a_World, 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) {return false; } // Accessors const char* GetName() const { return m_Name.c_str(); } diff --git a/source/cPluginManager.cpp b/source/cPluginManager.cpp index 7c0d49ed5..f152911e8 100644 --- a/source/cPluginManager.cpp +++ b/source/cPluginManager.cpp @@ -514,7 +514,7 @@ bool cPluginManager::CallHookBlockToPickup( bool cPluginManager::CallHookWeatherChanged(cWorld * a_World) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_POST_CRAFTING); + HookMap::iterator Plugins = m_Hooks.find(HOOK_WEATHER_CHANGED); if (Plugins == m_Hooks.end()) { return false; @@ -533,6 +533,49 @@ bool cPluginManager::CallHookWeatherChanged(cWorld * a_World) +bool cPluginManager::CallHookUpdatingSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4) +{ + HookMap::iterator Plugins = m_Hooks.find(HOOK_UPDATING_SIGN); + if (Plugins == m_Hooks.end()) + { + return false; + } + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + if ((*itr)->OnUpdatingSign(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4)) + { + return true; + } + } + return false; +} + + + + + +bool cPluginManager::CallHookUpdatedSign(cWorld * a_World, 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) +{ + HookMap::iterator Plugins = m_Hooks.find(HOOK_UPDATED_SIGN); + if (Plugins == m_Hooks.end()) + { + return false; + } + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + if ((*itr)->OnUpdatedSign(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4)) + { + return true; + } + } + return false; +} + + + + + + cPlugin* cPluginManager::GetPlugin( const char* a_Plugin ) const { for( PluginList::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr ) diff --git a/source/cPluginManager.h b/source/cPluginManager.h index 9ae0d6175..e40b00dcf 100644 --- a/source/cPluginManager.h +++ b/source/cPluginManager.h @@ -55,7 +55,9 @@ public: //tolua_export HOOK_CRAFTING_NO_RECIPE, /// cPlayer, cCraftingGrid, cCraftingRecipe HOOK_POST_CRAFTING, /// cPlayer, cCraftingGrid, cCraftingRecipe HOOK_BLOCK_TO_PICKUP, /// BlockType, BlockMeta, cPlayer, cItem, cItems - HOOK_WEATHER_CHANGED, + HOOK_WEATHER_CHANGED, /// cWorld + HOOK_UPDATING_SIGN, /// cWorld, int, int, int, string, string, string, string + HOOK_UPDATED_SIGN, /// cWorld, int, int, int, string, string, string, string // E_PLUGIN_ names are obsolete, but are kept for compatibility reasons E_PLUGIN_TICK = HOOK_TICK, @@ -91,6 +93,7 @@ public: //tolua_export unsigned int GetNumPlugins() const; //tolua_export + // If the hook returns true, no further hook is called and the functions return false bool CallHook( PluginHook a_Hook, unsigned int a_NumArgs, ... ); bool CallHookChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_Chunk); @@ -99,6 +102,8 @@ public: //tolua_export bool CallHookPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); bool CallHookBlockToPickup (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups); bool CallHookWeatherChanged (cWorld * a_World); + bool CallHookUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4); + bool CallHookUpdatedSign (cWorld * a_World, 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); void RemoveHooks( cPlugin* a_Plugin ); void RemovePlugin( cPlugin* a_Plugin, bool a_bDelete = false ); //tolua_export diff --git a/source/cPlugin_NewLua.cpp b/source/cPlugin_NewLua.cpp index 7254bef01..feba602ba 100644 --- a/source/cPlugin_NewLua.cpp +++ b/source/cPlugin_NewLua.cpp @@ -531,6 +531,90 @@ bool cPlugin_NewLua::OnWeatherChanged(cWorld * a_World) +bool cPlugin_NewLua::OnUpdatingSign( + cWorld * a_World, + int a_BlockX, int a_BlockY, int a_BlockZ, + AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4 +) +{ + cCSLock Lock(m_CriticalSection); + if (!PushFunction("OnUpdatingSign")) + { + return false; + } + + tolua_pushusertype(m_LuaState, (void *)a_World, "cWorld"); + tolua_pushnumber (m_LuaState, a_BlockX); + tolua_pushnumber (m_LuaState, a_BlockY); + tolua_pushnumber (m_LuaState, a_BlockZ); + tolua_pushstring (m_LuaState, a_Line1.c_str()); + tolua_pushstring (m_LuaState, a_Line2.c_str()); + tolua_pushstring (m_LuaState, a_Line3.c_str()); + tolua_pushstring (m_LuaState, a_Line4.c_str()); + + if (!CallFunction(8, 5, "OnUpdatingSign")) + { + return false; + } + + bool bRetVal = (tolua_toboolean( m_LuaState, -5, 0) > 0); + if (lua_isstring(m_LuaState, -4)) + { + a_Line1 = tolua_tostring(m_LuaState, -4, ""); + } + if (lua_isstring(m_LuaState, -3)) + { + a_Line2 = tolua_tostring(m_LuaState, -3, ""); + } + if (lua_isstring(m_LuaState, -2)) + { + a_Line3 = tolua_tostring(m_LuaState, -2, ""); + } + if (lua_isstring(m_LuaState, -1)) + { + a_Line4 = tolua_tostring(m_LuaState, -1, ""); + } + return bRetVal; +} + + + + + +bool cPlugin_NewLua::OnUpdatedSign( + cWorld * a_World, + 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_CriticalSection); + if (!PushFunction("OnUpdatedSign")) + { + return false; + } + + tolua_pushusertype(m_LuaState, (void *)a_World, "cWorld"); + tolua_pushnumber (m_LuaState, a_BlockX); + tolua_pushnumber (m_LuaState, a_BlockY); + tolua_pushnumber (m_LuaState, a_BlockZ); + tolua_pushstring (m_LuaState, a_Line1.c_str()); + tolua_pushstring (m_LuaState, a_Line2.c_str()); + tolua_pushstring (m_LuaState, a_Line3.c_str()); + tolua_pushstring (m_LuaState, a_Line4.c_str()); + + if (!CallFunction(8, 1, "OnUpdatedSign")) + { + return false; + } + + bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0); + return bRetVal; +} + + + + + cWebPlugin_Lua* cPlugin_NewLua::CreateWebPlugin(lua_State* a_LuaState) { cCSLock Lock( m_CriticalSection ); diff --git a/source/cPlugin_NewLua.h b/source/cPlugin_NewLua.h index fb1ff5bbe..5756e526c 100644 --- a/source/cPlugin_NewLua.h +++ b/source/cPlugin_NewLua.h @@ -43,6 +43,8 @@ public: //tolua_export virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; virtual bool OnBlockToPickup (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups); virtual bool OnWeatherChanged (cWorld * a_World) override; + virtual bool OnUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4) override; + virtual bool OnUpdatedSign (cWorld * a_World, 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) override; lua_State* GetLuaState() { return m_LuaState; } diff --git a/source/cWorld.cpp b/source/cWorld.cpp index 0616fcf44..e5bff4c11 100644 --- a/source/cWorld.cpp +++ b/source/cWorld.cpp @@ -747,9 +747,9 @@ void cWorld::TickSpawnMobs(float a_Dt) if (m_WorldTime >= 12000 + 1000) { - if (GetBiomeAt(SpawnPos.x, SpawnPos.z) == biHell) // Spawn nether mobs + if (GetBiomeAt((int)SpawnPos.x, (int)SpawnPos.z) == biHell) // Spawn nether mobs { - if (nightRand == 1 && GetBiomeAt(SpawnPos.x, SpawnPos.z) == biHell) + if (nightRand == 1) Monster = new cZombie(); else if (nightRand == 5) Monster = new cGhast(); @@ -1753,9 +1753,18 @@ void cWorld::ChunkLoadFailed(int a_ChunkX, int a_ChunkY, int a_ChunkZ) -void cWorld::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) +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) { - m_ChunkMap->UpdateSign(a_X, a_Y, a_Z, a_Line1, a_Line2, a_Line3, a_Line4); + AString Line1(a_Line1); + AString Line2(a_Line2); + AString Line3(a_Line3); + AString Line4(a_Line4); + if (cRoot::Get()->GetPluginManager()->CallHookUpdatingSign(this, a_BlockX, a_BlockY, a_BlockZ, Line1, Line2, Line3, Line4)) + { + return; + } + 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); } -- cgit v1.2.3