1
0

Renamed hook HOOK_ENTITY_CHANGE_WORLD

This commit is contained in:
Lukas Pioch 2015-05-21 12:27:54 +02:00
parent eaedd5f19d
commit bc838e5bd2
9 changed files with 20 additions and 19 deletions

View File

@ -7,7 +7,7 @@ return
Desc = [[ Desc = [[
This hook is called after the server has moved the {{cEntity|entity}} to the given world. This is an information-only This hook is called after the server has moved the {{cEntity|entity}} to the given world. This is an information-only
callback, the entity is already in the new world.<p> callback, the entity is already in the new world.<p>
See also the {{OnEntityChangeWorld|HOOK_ENTITY_CHANGE_WORLD}} hook for a similar hook called before the See also the {{OnEntityChangingWorld|HOOK_ENTITY_CHANGING_WORLD}} hook for a similar hook called before the
entity is moved to the new world. entity is moved to the new world.
]], ]],
Params = Params =

View File

@ -1,9 +1,9 @@
return return
{ {
HOOK_ENTITY_CHANGE_WORLD = HOOK_ENTITY_CHANGING_WORLD =
{ {
CalledWhen = "Before a entity is changing the world.", CalledWhen = "Before a entity is changing the world.",
DefaultFnName = "OnEntityChangeWorld", -- also used as pagename DefaultFnName = "OnEntityChangingWorld", -- also used as pagename
Desc = [[ Desc = [[
This hook is called before the server moves the {{cEntity|entity}} to the given world. Plugins may This hook is called before the server moves the {{cEntity|entity}} to the given world. Plugins may
refuse the changing of the entity to the new world.<p> refuse the changing of the entity to the new world.<p>
@ -20,7 +20,7 @@ return
returns true, no other callback is called for this event and the change of the entity to the world is returns true, no other callback is called for this event and the change of the entity to the world is
cancelled. cancelled.
]], ]],
}, -- HOOK_ENTITY_CHANGE_WORLD }, -- HOOK_ENTITY_CHANGING_WORLD
} }

View File

@ -56,7 +56,7 @@ public:
virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) = 0; virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) = 0;
virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) = 0; virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) = 0;
virtual bool OnEntityTeleport (cEntity & a_Entity, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition) = 0; virtual bool OnEntityTeleport (cEntity & a_Entity, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition) = 0;
virtual bool OnEntityChangeWorld (cEntity & a_Entity, cWorld & a_World) = 0; virtual bool OnEntityChangingWorld (cEntity & a_Entity, cWorld & a_World) = 0;
virtual bool OnEntityChangedWorld (cEntity & a_Entity, cWorld & a_World) = 0; virtual bool OnEntityChangedWorld (cEntity & a_Entity, cWorld & a_World) = 0;
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split, const AString & a_EntireCommand, cPluginManager::CommandResult & a_Result) = 0; virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split, const AString & a_EntireCommand, cPluginManager::CommandResult & a_Result) = 0;
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0; virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;

View File

@ -534,7 +534,7 @@ bool cPluginLua::OnEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_E
bool cPluginLua::OnEntityChangeWorld(cEntity & a_Entity, cWorld & a_World) bool cPluginLua::OnEntityChangingWorld(cEntity & a_Entity, cWorld & a_World)
{ {
cCSLock Lock(m_CriticalSection); cCSLock Lock(m_CriticalSection);
if (!m_LuaState.IsValid()) if (!m_LuaState.IsValid())
@ -542,7 +542,7 @@ bool cPluginLua::OnEntityChangeWorld(cEntity & a_Entity, cWorld & a_World)
return false; return false;
} }
bool res = false; bool res = false;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_CHANGE_WORLD]; cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_CHANGING_WORLD];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{ {
m_LuaState.Call((int)(**itr), &a_Entity, &a_World, cLuaState::Return, res); m_LuaState.Call((int)(**itr), &a_Entity, &a_World, cLuaState::Return, res);
@ -1932,7 +1932,7 @@ const char * cPluginLua::GetHookFnName(int a_HookType)
case cPluginManager::HOOK_DISCONNECT: return "OnDisconnect"; case cPluginManager::HOOK_DISCONNECT: return "OnDisconnect";
case cPluginManager::HOOK_PLAYER_ANIMATION: return "OnPlayerAnimation"; case cPluginManager::HOOK_PLAYER_ANIMATION: return "OnPlayerAnimation";
case cPluginManager::HOOK_ENTITY_ADD_EFFECT: return "OnEntityAddEffect"; case cPluginManager::HOOK_ENTITY_ADD_EFFECT: return "OnEntityAddEffect";
case cPluginManager::HOOK_ENTITY_CHANGE_WORLD: return "OnEntityChangeWorld"; case cPluginManager::HOOK_ENTITY_CHANGING_WORLD: return "OnEntityChangingWorld";
case cPluginManager::HOOK_ENTITY_CHANGED_WORLD: return "OnEntityChangedWorld"; case cPluginManager::HOOK_ENTITY_CHANGED_WORLD: return "OnEntityChangedWorld";
case cPluginManager::HOOK_ENTITY_TELEPORT: return "OnEntityTeleport"; case cPluginManager::HOOK_ENTITY_TELEPORT: return "OnEntityTeleport";
case cPluginManager::HOOK_EXECUTE_COMMAND: return "OnExecuteCommand"; case cPluginManager::HOOK_EXECUTE_COMMAND: return "OnExecuteCommand";

View File

@ -115,7 +115,7 @@ public:
virtual bool OnCraftingNoRecipe (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe) override; virtual bool OnCraftingNoRecipe (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe) override;
virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) override; virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) override;
virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) override; virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) override;
virtual bool OnEntityChangeWorld (cEntity & a_Entity, cWorld & a_World) override; virtual bool OnEntityChangingWorld (cEntity & a_Entity, cWorld & a_World) override;
virtual bool OnEntityChangedWorld (cEntity & a_Entity, cWorld & a_World) override; virtual bool OnEntityChangedWorld (cEntity & a_Entity, cWorld & a_World) override;
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split, const AString & a_EntireCommand, cPluginManager::CommandResult & a_Result) override; virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split, const AString & a_EntireCommand, cPluginManager::CommandResult & a_Result) override;
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override; virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;

View File

@ -525,14 +525,14 @@ bool cPluginManager::CallHookEntityTeleport(cEntity & a_Entity, const Vector3d &
bool cPluginManager::CallHookEntityChangeWorld(cEntity & a_Entity, cWorld & a_World) bool cPluginManager::CallHookEntityChangingWorld(cEntity & a_Entity, cWorld & a_World)
{ {
FIND_HOOK(HOOK_ENTITY_CHANGE_WORLD); FIND_HOOK(HOOK_ENTITY_CHANGING_WORLD);
VERIFY_HOOK; VERIFY_HOOK;
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{ {
if ((*itr)->OnEntityChangeWorld(a_Entity, a_World)) if ((*itr)->OnEntityChangingWorld(a_Entity, a_World))
{ {
return true; return true;
} }

View File

@ -86,7 +86,7 @@ public:
HOOK_DISCONNECT, HOOK_DISCONNECT,
HOOK_PLAYER_ANIMATION, HOOK_PLAYER_ANIMATION,
HOOK_ENTITY_ADD_EFFECT, HOOK_ENTITY_ADD_EFFECT,
HOOK_ENTITY_CHANGE_WORLD, HOOK_ENTITY_CHANGING_WORLD,
HOOK_ENTITY_CHANGED_WORLD, HOOK_ENTITY_CHANGED_WORLD,
HOOK_EXECUTE_COMMAND, HOOK_EXECUTE_COMMAND,
HOOK_EXPLODED, HOOK_EXPLODED,
@ -203,7 +203,7 @@ public:
bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason); bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason);
bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier); bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier);
bool CallHookEntityTeleport (cEntity & a_Entity, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition); bool CallHookEntityTeleport (cEntity & a_Entity, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition);
bool CallHookEntityChangeWorld (cEntity & a_Entity, cWorld & a_World); bool CallHookEntityChangingWorld (cEntity & a_Entity, cWorld & a_World);
bool CallHookEntityChangedWorld (cEntity & a_Entity, cWorld & a_World); bool CallHookEntityChangedWorld (cEntity & a_Entity, cWorld & a_World);
bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split, const AString & a_EntireCommand, CommandResult & a_Result); // If a_Player == nullptr, it is a console cmd bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split, const AString & a_EntireCommand, CommandResult & a_Result); // If a_Player == nullptr, it is a console cmd
bool CallHookExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData); bool CallHookExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);

View File

@ -1403,10 +1403,10 @@ bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn)
return false; return false;
} }
// Ask the plugins if the entity is allowed to change the world // Ask the plugins if the entity is allowed to changing the world
if (cRoot::Get()->GetPluginManager()->CallHookEntityChangeWorld(*this, *a_World)) if (cRoot::Get()->GetPluginManager()->CallHookEntityChangingWorld(*this, *a_World))
{ {
// A Plugin doesn't allow the entity to change the world // A Plugin doesn't allow the entity to changing the world
return false; return false;
} }

View File

@ -1606,9 +1606,10 @@ bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn)
return false; return false;
} }
if (cRoot::Get()->GetPluginManager()->CallHookEntityChangeWorld(*this, *a_World)) // Ask the plugins if the player is allowed to changing the world
if (cRoot::Get()->GetPluginManager()->CallHookEntityChangingWorld(*this, *a_World))
{ {
// A Plugin doesn't allow the player to change the world // A Plugin doesn't allow the player to changing the world
return false; return false;
} }