1
0

Added HOOK_WEATHER_CHANGING.

http://www.mc-server.org/support/index.php?do=details&task_id=299

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1210 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com
2013-02-13 19:22:08 +00:00
parent 22b71d0410
commit 8b1a8bee34
13 changed files with 251 additions and 120 deletions

View File

@@ -1210,7 +1210,7 @@ bool cPlugin_NewLua::OnUpdatingSign(
bool cPlugin_NewLua::OnWeatherChanged(cWorld * a_World)
bool cPlugin_NewLua::OnWeatherChanged(cWorld & a_World)
{
cCSLock Lock(m_CriticalSection);
const char * FnName = GetHookFnName(cPluginManager::HOOK_WEATHER_CHANGED);
@@ -1220,7 +1220,7 @@ bool cPlugin_NewLua::OnWeatherChanged(cWorld * a_World)
return false;
}
tolua_pushusertype(m_LuaState, (void *)a_World, "cWorld");
tolua_pushusertype(m_LuaState, &a_World, "cWorld");
if (!CallFunction(1, 1, FnName))
{
@@ -1236,6 +1236,37 @@ bool cPlugin_NewLua::OnWeatherChanged(cWorld * a_World)
bool cPlugin_NewLua::OnWeatherChanging(cWorld & a_World, eWeather & a_NewWeather)
{
cCSLock Lock(m_CriticalSection);
const char * FnName = GetHookFnName(cPluginManager::HOOK_WEATHER_CHANGED);
ASSERT(FnName != NULL);
if (!PushFunction(FnName))
{
return false;
}
tolua_pushusertype(m_LuaState, &a_World, "cWorld");
tolua_pushnumber (m_LuaState, a_NewWeather);
if (!CallFunction(2, 2, FnName))
{
return false;
}
bool bRetVal = (tolua_toboolean(m_LuaState, -1, 0) > 0);
if (lua_isnumber(m_LuaState, -2))
{
a_NewWeather = (eWeather)lua_tointeger(m_LuaState, -2);
}
lua_pop(m_LuaState, 1);
return bRetVal;
}
bool cPlugin_NewLua::HandleCommand(const AStringVector & a_Split, cPlayer * a_Player)
{
ASSERT(!a_Split.empty());
@@ -1395,6 +1426,7 @@ const char * cPlugin_NewLua::GetHookFnName(cPluginManager::PluginHook a_Hook)
case cPluginManager::HOOK_UPDATED_SIGN: return "OnUpdatedSign";
case cPluginManager::HOOK_UPDATING_SIGN: return "OnUpdatingSign";
case cPluginManager::HOOK_WEATHER_CHANGED: return "OnWeatherChanged";
case cPluginManager::HOOK_WEATHER_CHANGING: return "OnWeatherChanging";
default: return NULL;
} // switch (a_Hook)
}