diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-01-28 17:54:11 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-01-28 17:54:11 +0100 |
commit | 71bbf2d44ba5fc00fcb15ed96aff083342309498 (patch) | |
tree | 94657c14eddc2f81fe55d8c6a15e22165f6d7897 /source | |
parent | Updated HookNotify with the hook renaming. (diff) | |
download | cuberite-71bbf2d44ba5fc00fcb15ed96aff083342309498.tar cuberite-71bbf2d44ba5fc00fcb15ed96aff083342309498.tar.gz cuberite-71bbf2d44ba5fc00fcb15ed96aff083342309498.tar.bz2 cuberite-71bbf2d44ba5fc00fcb15ed96aff083342309498.tar.lz cuberite-71bbf2d44ba5fc00fcb15ed96aff083342309498.tar.xz cuberite-71bbf2d44ba5fc00fcb15ed96aff083342309498.tar.zst cuberite-71bbf2d44ba5fc00fcb15ed96aff083342309498.zip |
Diffstat (limited to 'source')
-rw-r--r-- | source/Bindings.cpp | 4 | ||||
-rw-r--r-- | source/Bindings.h | 2 | ||||
-rw-r--r-- | source/Pawn.cpp | 8 | ||||
-rw-r--r-- | source/Plugin.cpp | 4 | ||||
-rw-r--r-- | source/Plugin.h | 2 | ||||
-rw-r--r-- | source/PluginManager.cpp | 6 | ||||
-rw-r--r-- | source/PluginManager.h | 4 | ||||
-rw-r--r-- | source/Plugin_NewLua.cpp | 21 | ||||
-rw-r--r-- | source/Plugin_NewLua.h | 2 |
9 files changed, 25 insertions, 28 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp index fcdf7ac78..c1cba495c 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 01/28/13 17:07:07. +** Generated automatically by tolua++-1.0.92 on 01/28/13 17:46:12. */ #ifndef __cplusplus @@ -21260,7 +21260,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_DISCONNECT",cPluginManager::HOOK_DISCONNECT); tolua_constant(tolua_S,"HOOK_HANDSHAKE",cPluginManager::HOOK_HANDSHAKE); - tolua_constant(tolua_S,"HOOK_KILLED",cPluginManager::HOOK_KILLED); + tolua_constant(tolua_S,"HOOK_KILLING",cPluginManager::HOOK_KILLING); tolua_constant(tolua_S,"HOOK_LOGIN",cPluginManager::HOOK_LOGIN); tolua_constant(tolua_S,"HOOK_PLAYER_BREAKING_BLOCK",cPluginManager::HOOK_PLAYER_BREAKING_BLOCK); tolua_constant(tolua_S,"HOOK_PLAYER_BROKEN_BLOCK",cPluginManager::HOOK_PLAYER_BROKEN_BLOCK); diff --git a/source/Bindings.h b/source/Bindings.h index e551744f8..3d4cb5c5a 100644 --- a/source/Bindings.h +++ b/source/Bindings.h @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 01/28/13 17:07:08. +** Generated automatically by tolua++-1.0.92 on 01/28/13 17:46:13. */ /* Exported function */ diff --git a/source/Pawn.cpp b/source/Pawn.cpp index 451dd3af9..d0546eccc 100644 --- a/source/Pawn.cpp +++ b/source/Pawn.cpp @@ -121,13 +121,13 @@ void cPawn::DoTakeDamage(TakeDamageInfo & a_TDI) void cPawn::KilledBy(cPawn * a_Killer) { - short OldHealth = m_Health; m_Health = 0; - if (cRoot::Get()->GetPluginManager()->CallHookKilled(*this, a_Killer)) + cRoot::Get()->GetPluginManager()->CallHookKilling(*this, a_Killer); + + if (m_Health > 0) { - // Plugin wants to 'unkill' the pawn. Set health back and abort - m_Health = OldHealth; + // Plugin wants to 'unkill' the pawn. Abort return; } diff --git a/source/Plugin.cpp b/source/Plugin.cpp index 8339d1c7a..2b26ae2cb 100644 --- a/source/Plugin.cpp +++ b/source/Plugin.cpp @@ -126,9 +126,9 @@ bool cPlugin::OnDisconnect(cPlayer * a_Player, const AString & a_Reason) -bool cPlugin::OnKilled(cPawn & a_Killed, cEntity * a_Killer) +bool cPlugin::OnKilling(cPawn & a_Victim, cEntity * a_Killer) { - UNUSED(a_Killed); + UNUSED(a_Victim); UNUSED(a_Killer); return false; } diff --git a/source/Plugin.h b/source/Plugin.h index 653667171..44d8d29a5 100644 --- a/source/Plugin.h +++ b/source/Plugin.h @@ -56,7 +56,7 @@ public: virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); virtual bool OnDisconnect (cPlayer * a_Player, const AString & a_Reason); virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username); - virtual bool OnKilled (cPawn & a_Killed, cEntity * a_Killer); + virtual bool OnKilling (cPawn & a_Victim, cEntity * a_Killer); virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username); virtual bool OnPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp index e7a4329ca..921955ba4 100644 --- a/source/PluginManager.cpp +++ b/source/PluginManager.cpp @@ -407,16 +407,16 @@ bool cPluginManager::CallHookHandshake(cClientHandle * a_ClientHandle, const ASt -bool cPluginManager::CallHookKilled(cPawn & a_Victim, cEntity * a_Killer) +bool cPluginManager::CallHookKilling(cPawn & a_Victim, cEntity * a_Killer) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_KILLED); + HookMap::iterator Plugins = m_Hooks.find(HOOK_KILLING); if (Plugins == m_Hooks.end()) { return false; } for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnKilled(a_Victim, a_Killer)) + if ((*itr)->OnKilling(a_Victim, a_Killer)) { return true; } diff --git a/source/PluginManager.h b/source/PluginManager.h index 3a7914b56..9a7d36f91 100644 --- a/source/PluginManager.h +++ b/source/PluginManager.h @@ -54,7 +54,7 @@ public: // tolua_export HOOK_CRAFTING_NO_RECIPE, HOOK_DISCONNECT, HOOK_HANDSHAKE, - HOOK_KILLED, + HOOK_KILLING, HOOK_LOGIN, HOOK_PLAYER_BREAKING_BLOCK, HOOK_PLAYER_BROKEN_BLOCK, @@ -106,7 +106,7 @@ public: // tolua_export bool CallHookCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); bool CallHookDisconnect (cPlayer * a_Player, const AString & a_Reason); bool CallHookHandshake (cClientHandle * a_ClientHandle, const AString & a_Username); - bool CallHookKilled (cPawn & a_Victim, cEntity * a_Killer); + bool CallHookKilling (cPawn & a_Victim, cEntity * a_Killer); bool CallHookLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username); bool CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); bool CallHookPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); diff --git a/source/Plugin_NewLua.cpp b/source/Plugin_NewLua.cpp index 418c484ad..ed497e1a9 100644 --- a/source/Plugin_NewLua.cpp +++ b/source/Plugin_NewLua.cpp @@ -14,26 +14,23 @@ extern "C" #include "Bindings.h" #include "ManualBindings.h" -#ifdef _WIN32 -// #include "wdirent.h" -#else -#include <dirent.h> -#endif +extern bool report_errors(lua_State * lua, int status); -extern bool report_errors(lua_State* lua, int status); +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cPlugin_NewLua: -cPlugin_NewLua::cPlugin_NewLua( const AString & a_PluginDirectory ) +cPlugin_NewLua::cPlugin_NewLua(const AString & a_PluginDirectory) : m_LuaState( 0 ) , cWebPlugin() - , cPlugin( a_PluginDirectory ) + , cPlugin(a_PluginDirectory) { } @@ -389,17 +386,17 @@ bool cPlugin_NewLua::OnHandshake(cClientHandle * a_Client, const AString & a_Use -bool cPlugin_NewLua::OnKilled(cPawn & a_Killed, cEntity * a_Killer) +bool cPlugin_NewLua::OnKilling(cPawn & a_Victim, cEntity * a_Killer) { cCSLock Lock(m_CriticalSection); - const char * FnName = GetHookFnName(cPluginManager::HOOK_KILLED); + const char * FnName = GetHookFnName(cPluginManager::HOOK_KILLING); ASSERT(FnName != NULL); if (!PushFunction(FnName)) { return false; } - tolua_pushusertype(m_LuaState, &a_Killed, "cPawn"); + tolua_pushusertype(m_LuaState, &a_Victim, "cPawn"); tolua_pushusertype(m_LuaState, a_Killer, "cEntity"); if (!CallFunction(2, 1, FnName)) @@ -1194,7 +1191,7 @@ const char * cPlugin_NewLua::GetHookFnName(cPluginManager::PluginHook a_Hook) case cPluginManager::HOOK_CRAFTING_NO_RECIPE: return "OnCraftingNoRecipe"; case cPluginManager::HOOK_DISCONNECT: return "OnDisconnect"; case cPluginManager::HOOK_HANDSHAKE: return "OnHandshake"; - case cPluginManager::HOOK_KILLED: return "OnKilled"; + case cPluginManager::HOOK_KILLING: return "OnKilling"; case cPluginManager::HOOK_LOGIN: return "OnLogin"; case cPluginManager::HOOK_PLAYER_BREAKING_BLOCK: return "OnPlayerBreakingBlock"; case cPluginManager::HOOK_PLAYER_BROKEN_BLOCK: return "OnPlayerBrokenBlock"; diff --git a/source/Plugin_NewLua.h b/source/Plugin_NewLua.h index 3e0b33838..87b30b26d 100644 --- a/source/Plugin_NewLua.h +++ b/source/Plugin_NewLua.h @@ -38,7 +38,7 @@ public: virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; virtual bool OnDisconnect (cPlayer * a_Player, const AString & a_Reason) override; virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) override; - virtual bool OnKilled (cPawn & a_Killed, cEntity * a_Killer) override; + virtual bool OnKilling (cPawn & a_Victim, cEntity * a_Killer) override; virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) override; virtual bool OnPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; |