mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-02-07 13:27:13 +01:00
Attempt to fix (or make it easy to be fixed) the spectating crash.
This commit is contained in:
parent
14d7b8c225
commit
7a469d870d
@ -1346,21 +1346,39 @@ LightObj & CPlayer::GetSpectator() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void CPlayer::SetSpectator(CPlayer * target) const
|
void CPlayer::SetSpectator(CPlayer & target) const
|
||||||
{
|
{
|
||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
Validate();
|
||||||
// See if the given target is null
|
|
||||||
if (target == nullptr)
|
|
||||||
{
|
|
||||||
// Spectate an invalid player
|
|
||||||
_Func->SetPlayerSpectateTarget(m_ID, -1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Spectate the given target
|
// Spectate the given target
|
||||||
_Func->SetPlayerSpectateTarget(m_ID, target->GetID());
|
_Func->SetPlayerSpectateTarget(m_ID, target.GetID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQInteger CPlayer::GetSpectatorID() const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Retrieve the identifier of the player
|
||||||
|
return _Func->GetPlayerSpectateTarget(m_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void CPlayer::SetSpectatorID(SQInteger id) const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Spectate the given target
|
||||||
|
_Func->SetPlayerSpectateTarget(m_ID, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void CPlayer::SpectateNone() const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Spectate the given target
|
||||||
|
_Func->SetPlayerSpectateTarget(m_ID, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -2501,6 +2519,7 @@ void Register_CPlayer(HSQUIRRELVM vm)
|
|||||||
.Prop(_SC("TouchedObject"), &CPlayer::StandingOnObject)
|
.Prop(_SC("TouchedObject"), &CPlayer::StandingOnObject)
|
||||||
.Prop(_SC("Away"), &CPlayer::IsAway)
|
.Prop(_SC("Away"), &CPlayer::IsAway)
|
||||||
.Prop(_SC("Spec"), &CPlayer::GetSpectator, &CPlayer::SetSpectator)
|
.Prop(_SC("Spec"), &CPlayer::GetSpectator, &CPlayer::SetSpectator)
|
||||||
|
.Prop(_SC("SpecID"), &CPlayer::GetSpectatorID, &CPlayer::SetSpectatorID)
|
||||||
.Prop(_SC("CollideAreas"), &CPlayer::GetCollideAreas, &CPlayer::SetCollideAreas)
|
.Prop(_SC("CollideAreas"), &CPlayer::GetCollideAreas, &CPlayer::SetCollideAreas)
|
||||||
.Prop(_SC("Authority"), &CPlayer::GetAuthority, &CPlayer::SetAuthority)
|
.Prop(_SC("Authority"), &CPlayer::GetAuthority, &CPlayer::SetAuthority)
|
||||||
.Prop(_SC("TrackPosition"), &CPlayer::GetTrackPosition, &CPlayer::SetTrackPosition)
|
.Prop(_SC("TrackPosition"), &CPlayer::GetTrackPosition, &CPlayer::SetTrackPosition)
|
||||||
@ -2548,6 +2567,7 @@ void Register_CPlayer(HSQUIRRELVM vm)
|
|||||||
.Func(_SC("StripWeapons"), &CPlayer::StripWeapons)
|
.Func(_SC("StripWeapons"), &CPlayer::StripWeapons)
|
||||||
.Func(_SC("RestoreCamera"), &CPlayer::RestoreCamera)
|
.Func(_SC("RestoreCamera"), &CPlayer::RestoreCamera)
|
||||||
.Func(_SC("Spectating"), &CPlayer::GetSpectator)
|
.Func(_SC("Spectating"), &CPlayer::GetSpectator)
|
||||||
|
.Func(_SC("SpectateNone"), &CPlayer::SpectateNone)
|
||||||
.Func(_SC("Spectate"), &CPlayer::SetSpectator)
|
.Func(_SC("Spectate"), &CPlayer::SetSpectator)
|
||||||
.Func(_SC("Redirect"), &CPlayer::Redirect)
|
.Func(_SC("Redirect"), &CPlayer::Redirect)
|
||||||
.Func(_SC("PlaySound"), &CPlayer::PlaySound)
|
.Func(_SC("PlaySound"), &CPlayer::PlaySound)
|
||||||
|
@ -727,7 +727,22 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Set the managed player entity to spectate the specified player entity.
|
* Set the managed player entity to spectate the specified player entity.
|
||||||
*/
|
*/
|
||||||
void SetSpectator(CPlayer * target) const;
|
void SetSpectator(CPlayer & target) const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the identifier of the player that the managed player entity is spectating.
|
||||||
|
*/
|
||||||
|
SQInteger GetSpectatorID() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Set the managed player entity to spectate the specified player entity.
|
||||||
|
*/
|
||||||
|
void SetSpectatorID(SQInteger id) const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Set the managed player entity to spectate no one.
|
||||||
|
*/
|
||||||
|
void SpectateNone() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Redirect the managed player entity to the specified server.
|
* Redirect the managed player entity to the specified server.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user