summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-14 21:20:31 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-14 21:20:31 +0200
commite1b5f0af046f2c4c05789adf33eef5404adba2c3 (patch)
tree6738e8d63067ef348113e0ae50433722ec952c38
parentAdded a world parameter to HOOK_CHUNK_GENERATING. (diff)
downloadcuberite-e1b5f0af046f2c4c05789adf33eef5404adba2c3.tar
cuberite-e1b5f0af046f2c4c05789adf33eef5404adba2c3.tar.gz
cuberite-e1b5f0af046f2c4c05789adf33eef5404adba2c3.tar.bz2
cuberite-e1b5f0af046f2c4c05789adf33eef5404adba2c3.tar.lz
cuberite-e1b5f0af046f2c4c05789adf33eef5404adba2c3.tar.xz
cuberite-e1b5f0af046f2c4c05789adf33eef5404adba2c3.tar.zst
cuberite-e1b5f0af046f2c4c05789adf33eef5404adba2c3.zip
-rw-r--r--source/Bindings.cpp102
-rw-r--r--source/Bindings.h2
-rw-r--r--source/cPlugin.h1
-rw-r--r--source/cPluginManager.cpp21
-rw-r--r--source/cPluginManager.h3
-rw-r--r--source/cPlugin_NewLua.cpp23
-rw-r--r--source/cPlugin_NewLua.h1
-rw-r--r--source/cWorld.cpp6
8 files changed, 152 insertions, 7 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 72fc08859..2edcd2c23 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/14/12 19:28:15.
+** Generated automatically by tolua++-1.0.92 on 06/14/12 21:17:55.
*/
#ifndef __cplusplus
@@ -8051,6 +8051,40 @@ static int tolua_AllToLua_cPlugin_OnBlockToPickup00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: OnWeatherChanged of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnWeatherChanged00
+static int tolua_AllToLua_cPlugin_OnWeatherChanged00(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_isnoobj(tolua_S,3,&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));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnWeatherChanged'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->OnWeatherChanged(a_World);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'OnWeatherChanged'.",&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)
@@ -8544,6 +8578,17 @@ public:
return ( bool ) cPlugin:: OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,a_EquippedItem,a_Pickups);
};
};
+ bool OnWeatherChanged( cWorld* a_World) {
+ if (push_method("OnWeatherChanged", tolua_AllToLua_cPlugin_OnWeatherChanged00)) {
+ tolua_pushusertype(lua_state, (void*)a_World, "cWorld");
+ ToluaBase::dbcall(lua_state, 2, 1);
+ bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( bool ) cPlugin:: OnWeatherChanged(a_World);
+ };
+ };
void cPlugin__OnDisable( void ) {
return ( void )cPlugin::OnDisable();
@@ -8602,6 +8647,9 @@ public:
bool cPlugin__OnBlockToPickup( BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) {
return ( bool )cPlugin::OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,a_EquippedItem,a_Pickups);
};
+ bool cPlugin__OnWeatherChanged( cWorld* a_World) {
+ return ( bool )cPlugin::OnWeatherChanged(a_World);
+ };
Lua__cPlugin( void ): cPlugin(){};
};
@@ -9323,6 +9371,40 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockToPickup00(lua_State* tol
}
#endif //#ifndef TOLUA_DISABLE
+/* method: cPlugin__OnWeatherChanged of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnWeatherChanged00
+static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnWeatherChanged00(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_isnoobj(tolua_S,3,&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));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnWeatherChanged'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->cPlugin__OnWeatherChanged(a_World);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlugin__OnWeatherChanged'.",&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)
@@ -9777,6 +9859,17 @@ public:
return ( bool ) cPlugin_NewLua:: OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,a_EquippedItem,a_Pickups);
};
};
+ bool OnWeatherChanged( cWorld* a_World) {
+ if (push_method("OnWeatherChanged", tolua_AllToLua_cPlugin_OnWeatherChanged00)) {
+ tolua_pushusertype(lua_state, (void*)a_World, "cWorld");
+ ToluaBase::dbcall(lua_state, 2, 1);
+ bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
+ lua_pop(lua_state, 1);
+ return tolua_ret;
+ } else {
+ return ( bool ) cPlugin_NewLua:: OnWeatherChanged(a_World);
+ };
+ };
void cPlugin_NewLua__OnDisable( void ) {
return ( void )cPlugin_NewLua::OnDisable();
@@ -9838,6 +9931,9 @@ public:
bool cPlugin_NewLua__OnBlockToPickup( BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) {
return ( bool )cPlugin_NewLua::OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,a_EquippedItem,a_Pickups);
};
+ bool cPlugin_NewLua__OnWeatherChanged( cWorld* a_World) {
+ return ( bool )cPlugin_NewLua::OnWeatherChanged(a_World);
+ };
};
/* method: tolua__set_instance of class Lua__cPlugin_NewLua */
@@ -20740,7 +20836,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"HOOK_CRAFTING_NO_RECIPE",cPluginManager::HOOK_CRAFTING_NO_RECIPE);
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_CHANGE",cPluginManager::HOOK_WEATHER_CHANGE);
+ tolua_constant(tolua_S,"HOOK_WEATHER_CHANGED",cPluginManager::HOOK_WEATHER_CHANGED);
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);
@@ -20794,6 +20890,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"OnCraftingNoRecipe",tolua_AllToLua_cPlugin_OnCraftingNoRecipe00);
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,"GetName",tolua_AllToLua_cPlugin_GetName00);
tolua_function(tolua_S,"SetName",tolua_AllToLua_cPlugin_SetName00);
tolua_function(tolua_S,"GetVersion",tolua_AllToLua_cPlugin_GetVersion00);
@@ -20832,6 +20929,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"cPlugin__OnCraftingNoRecipe",tolua_AllToLua_Lua__cPlugin_cPlugin__OnCraftingNoRecipe00);
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,"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 ed41f5dd4..b64b6f5c4 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/14/12 19:28:15.
+** Generated automatically by tolua++-1.0.92 on 06/14/12 21:17:55.
*/
/* Exported function */
diff --git a/source/cPlugin.h b/source/cPlugin.h
index 40f2b302e..41618e47e 100644
--- a/source/cPlugin.h
+++ b/source/cPlugin.h
@@ -65,6 +65,7 @@ public:
virtual bool OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) {return false; }
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; }
// Accessors
const char* GetName() const { return m_Name.c_str(); }
diff --git a/source/cPluginManager.cpp b/source/cPluginManager.cpp
index 77b8402c8..7c0d49ed5 100644
--- a/source/cPluginManager.cpp
+++ b/source/cPluginManager.cpp
@@ -512,6 +512,27 @@ bool cPluginManager::CallHookBlockToPickup(
+bool cPluginManager::CallHookWeatherChanged(cWorld * a_World)
+{
+ HookMap::iterator Plugins = m_Hooks.find(HOOK_POST_CRAFTING);
+ if (Plugins == m_Hooks.end())
+ {
+ return false;
+ }
+ for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
+ {
+ if ((*itr)->OnWeatherChanged(a_World))
+ {
+ 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 9f9e41e8b..9ae0d6175 100644
--- a/source/cPluginManager.h
+++ b/source/cPluginManager.h
@@ -55,7 +55,7 @@ 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_CHANGE,
+ HOOK_WEATHER_CHANGED,
// E_PLUGIN_ names are obsolete, but are kept for compatibility reasons
E_PLUGIN_TICK = HOOK_TICK,
@@ -98,6 +98,7 @@ public: //tolua_export
bool CallHookCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
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);
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 dd6b61b9b..7254bef01 100644
--- a/source/cPlugin_NewLua.cpp
+++ b/source/cPlugin_NewLua.cpp
@@ -508,6 +508,29 @@ bool cPlugin_NewLua::OnBlockToPickup(
+bool cPlugin_NewLua::OnWeatherChanged(cWorld * a_World)
+{
+ cCSLock Lock(m_CriticalSection);
+ if (!PushFunction("OnWeatherChanged"))
+ {
+ return false;
+ }
+
+ tolua_pushusertype(m_LuaState, (void *)a_World, "cWorld");
+
+ if (!CallFunction(1, 1, "OnWeatherChanged"))
+ {
+ 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 ffcd107d3..fb1ff5bbe 100644
--- a/source/cPlugin_NewLua.h
+++ b/source/cPlugin_NewLua.h
@@ -42,6 +42,7 @@ public: //tolua_export
virtual bool OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
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;
lua_State* GetLuaState() { return m_LuaState; }
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index b5ed59ccb..48fb3a3ad 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -673,13 +673,13 @@ void cWorld::ChangeWeather()
void cWorld::TickWeather(float a_Dt)
{
- if(m_WeatherInterval == 0)
+ if (m_WeatherInterval == 0)
{
ChangeWeather();
- cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::HOOK_WEATHER_CHANGE, 0 );
+ cRoot::Get()->GetPluginManager()->CallHookWeatherChanged(this);
- switch(GetWeather())
+ switch (GetWeather())
{
case eWeather_Sunny:
m_WeatherInterval = 14400 + (m_TickRand.randInt() % 4800); // 12 - 16 minutes