summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MCServer/Plugins/Core/main.lua2
-rw-r--r--MCServer/Plugins/Core/onkilling.lua (renamed from MCServer/Plugins/Core/onkilled.lua)10
-rw-r--r--MCServer/Plugins/HookNotify/HookNotify.lua6
-rw-r--r--source/Bindings.cpp4
-rw-r--r--source/Bindings.h2
-rw-r--r--source/Pawn.cpp8
-rw-r--r--source/Plugin.cpp4
-rw-r--r--source/Plugin.h2
-rw-r--r--source/PluginManager.cpp6
-rw-r--r--source/PluginManager.h4
-rw-r--r--source/Plugin_NewLua.cpp21
-rw-r--r--source/Plugin_NewLua.h2
12 files changed, 34 insertions, 37 deletions
diff --git a/MCServer/Plugins/Core/main.lua b/MCServer/Plugins/Core/main.lua
index 97263f1d6..2dfbfb407 100644
--- a/MCServer/Plugins/Core/main.lua
+++ b/MCServer/Plugins/Core/main.lua
@@ -19,7 +19,7 @@ function Initialize( Plugin )
PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_BREAKING_BLOCK)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_PLACING_BLOCK)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_LOGIN)
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_KILLED)
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_KILLING)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_CRAFTING_NO_RECIPE)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT) -- used in web_chat.lua
diff --git a/MCServer/Plugins/Core/onkilled.lua b/MCServer/Plugins/Core/onkilling.lua
index a8a92f667..19bf0ea9d 100644
--- a/MCServer/Plugins/Core/onkilled.lua
+++ b/MCServer/Plugins/Core/onkilling.lua
@@ -1,6 +1,6 @@
-function OnKilled( Killed, Killer )
- if( Killer == nil ) then
- local KilledPlayer = tolua.cast( Killed, "cPlayer")
+function OnKilling(Victim, Killer)
+ if (Killer == nil) then
+ local KilledPlayer = tolua.cast(Victim, "cPlayer")
if( not KilledPlayer:IsA("cPlayer") or KilledPlayer == nil ) then
return false
end
@@ -8,11 +8,11 @@ function OnKilled( Killed, Killer )
local Server = cRoot:Get():GetServer()
Server:SendMessage( cChatColor.Red .. KilledPlayer:GetName() .. " died" )
else
- local KilledPlayer = tolua.cast( Killed, "cPlayer")
+ local KilledPlayer = tolua.cast(Victim, "cPlayer")
if( not KilledPlayer:IsA("cPlayer") or KilledPlayer == nil ) then
return false
end
- local KillerPlayer = tolua.cast( Killer, "cPlayer")
+ local KillerPlayer = tolua.cast(Killer, "cPlayer")
if( not KillerPlayer:IsA("cPlayer") or KillerPlayer == nil ) then
return false
end
diff --git a/MCServer/Plugins/HookNotify/HookNotify.lua b/MCServer/Plugins/HookNotify/HookNotify.lua
index 2d74a38d8..f04dc023c 100644
--- a/MCServer/Plugins/HookNotify/HookNotify.lua
+++ b/MCServer/Plugins/HookNotify/HookNotify.lua
@@ -21,7 +21,7 @@ function Initialize(Plugin)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_CRAFTING_NO_RECIPE);
PluginManager:AddHook(Plugin, cPluginManager.HOOK_DISCONNECT);
PluginManager:AddHook(Plugin, cPluginManager.HOOK_HANDSHAKE);
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_KILLED);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_KILLING);
PluginManager:AddHook(Plugin, cPluginManager.HOOK_LOGIN);
PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_BREAKING_BLOCK);
PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_BROKEN_BLOCK);
@@ -154,8 +154,8 @@ end
-function OnKilled(...)
- LogHook("OnKilled", unpack(arg));
+function OnKilling(...)
+ LogHook("OnKilling", unpack(arg));
end
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;