mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-10-15 07:27:19 +02:00
Implement a new event to receive notifications when a player world has changed.
This commit is contained in:
@@ -417,12 +417,27 @@ Int32 CPlayer::GetWorld() const
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CPlayer::SetWorld(Int32 world) const
|
||||
void CPlayer::SetWorld(Int32 world)
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Perform the requested operation
|
||||
// Grab the current value for this property
|
||||
const Int32 current = _Func->GetPlayerWorld(m_ID);
|
||||
// Don't even bother if it's the same value
|
||||
if (current == world)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Avoid property unwind from a recursive call
|
||||
_Func->SetPlayerWorld(m_ID, world);
|
||||
// Avoid infinite recursive event loops
|
||||
if (!(m_CircularLocks & PCL_EMIT_PLAYER_WORLD))
|
||||
{
|
||||
// Prevent this event from triggering while executed
|
||||
BitGuardU32 bg(m_CircularLocks, PCL_EMIT_PLAYER_WORLD);
|
||||
// Now forward the event call
|
||||
Core::Get().EmitPlayerWorld(m_ID, current, world, false);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -435,12 +450,27 @@ Int32 CPlayer::GetSecondaryWorld() const
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CPlayer::SetSecondaryWorld(Int32 world) const
|
||||
void CPlayer::SetSecondaryWorld(Int32 world)
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Perform the requested operation
|
||||
// Grab the current value for this property
|
||||
const Int32 current = _Func->GetPlayerSecondaryWorld(m_ID);
|
||||
// Don't even bother if it's the same value
|
||||
if (current == world)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Avoid property unwind from a recursive call
|
||||
_Func->SetPlayerSecondaryWorld(m_ID, world);
|
||||
// Avoid infinite recursive event loops
|
||||
if (!(m_CircularLocks & PCL_EMIT_PLAYER_WORLD))
|
||||
{
|
||||
// Prevent this event from triggering while executed
|
||||
BitGuardU32 bg(m_CircularLocks, PCL_EMIT_PLAYER_WORLD);
|
||||
// Now forward the event call
|
||||
Core::Get().EmitPlayerWorld(m_ID, current, world, true);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@@ -15,6 +15,7 @@ enum PlayerCircularLocks
|
||||
{
|
||||
PCL_EMIT_PLAYER_OPTION = (1 << 0)
|
||||
PCL_EMIT_PLAYER_ADMIN = (2 << 0),
|
||||
PCL_EMIT_PLAYER_WORLD = (3 << 0),
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
@@ -329,7 +330,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the world in which the managed player entity exists.
|
||||
*/
|
||||
void SetWorld(Int32 world) const;
|
||||
void SetWorld(Int32 world);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the secondary world of the managed player entity.
|
||||
|
Reference in New Issue
Block a user