From 8e0a9edb3e8655dcf5c3d64c794cc6597ddb8489 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Fri, 24 Jun 2016 23:37:58 +0300 Subject: [PATCH] Update the checkpoint creation process to allow creating checkpoints for all players as well as dedicated to a certain player. Should close #10 --- source/Entity/Checkpoint.cpp | 26 +++++++++++----------- source/Entity/Player.cpp | 42 ++++++++++++++++++++++++++++++++++++ source/Entity/Player.hpp | 25 +++++++++++++++++++++ 3 files changed, 79 insertions(+), 14 deletions(-) diff --git a/source/Entity/Checkpoint.cpp b/source/Entity/Checkpoint.cpp index 0ac7273e..d917e550 100644 --- a/source/Entity/Checkpoint.cpp +++ b/source/Entity/Checkpoint.cpp @@ -448,36 +448,34 @@ void CCheckpoint::SetColorA(Int32 a) const } // ------------------------------------------------------------------------------------------------ -static Object & Checkpoint_CreateEx(CPlayer & player, Int32 world, bool sphere, - Float32 x, Float32 y, Float32 z, +static Object & Checkpoint_CreateEx(Int32 world, bool sphere, Float32 x, Float32 y, Float32 z, Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius) { - return Core::Get().NewCheckpoint(player.GetID(), world, sphere, x, y, z, r, g, b, a, radius, + return Core::Get().NewCheckpoint(-1, world, sphere, x, y, z, r, g, b, a, radius, SQMOD_CREATE_DEFAULT, NullObject()); } -static Object & Checkpoint_CreateEx(CPlayer & player, Int32 world, bool sphere, - Float32 x, Float32 y, Float32 z, +static Object & Checkpoint_CreateEx(Int32 world, bool sphere, Float32 x, Float32 y, Float32 z, Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius, Int32 header, Object & payload) { - return Core::Get().NewCheckpoint(player.GetID(), world, sphere, x, y, z, r, g, b, a, + return Core::Get().NewCheckpoint(-1, world, sphere, x, y, z, r, g, b, a, radius, header, payload); } // ------------------------------------------------------------------------------------------------ -static Object & Checkpoint_Create(CPlayer & player, Int32 world, bool sphere, const Vector3 & pos, +static Object & Checkpoint_Create(Int32 world, bool sphere, const Vector3 & pos, const Color4 & color, Float32 radius) { - return Core::Get().NewCheckpoint(player.GetID(), world, sphere, pos.x, pos.y, pos.z, + return Core::Get().NewCheckpoint(-1, world, sphere, pos.x, pos.y, pos.z, color.r, color.g, color.b, color.a, radius, SQMOD_CREATE_DEFAULT, NullObject()); } -static Object & Checkpoint_Create(CPlayer & player, Int32 world, bool sphere, const Vector3 & pos, +static Object & Checkpoint_Create(Int32 world, bool sphere, const Vector3 & pos, const Color4 & color, Float32 radius, Int32 header, Object & payload) { - return Core::Get().NewCheckpoint(player.GetID(), world, sphere, pos.x, pos.y, pos.z, + return Core::Get().NewCheckpoint(-1, world, sphere, pos.x, pos.y, pos.z, color.r, color.g, color.b, color.a, radius, header, payload); } @@ -530,13 +528,13 @@ void Register_CCheckpoint(HSQUIRRELVM vm) .Overload< void (CCheckpoint::*)(Uint8, Uint8, Uint8, Uint8) const > (_SC("SetColor"), &CCheckpoint::SetColorEx) // Static Overloads - .StaticOverload< Object & (*)(CPlayer &, Int32, bool, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32) > + .StaticOverload< Object & (*)(Int32, bool, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32) > (_SC("CreateEx"), &Checkpoint_CreateEx) - .StaticOverload< Object & (*)(CPlayer &, Int32, bool, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32, Int32, Object &) > + .StaticOverload< Object & (*)(Int32, bool, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32, Int32, Object &) > (_SC("CreateEx"), &Checkpoint_CreateEx) - .StaticOverload< Object & (*)(CPlayer &, Int32, bool, const Vector3 &, const Color4 &, Float32) > + .StaticOverload< Object & (*)(Int32, bool, const Vector3 &, const Color4 &, Float32) > (_SC("Create"), &Checkpoint_Create) - .StaticOverload< Object & (*)(CPlayer &, Int32, bool, const Vector3 &, const Color4 &, Float32, Int32, Object &) > + .StaticOverload< Object & (*)(Int32, bool, const Vector3 &, const Color4 &, Float32, Int32, Object &) > (_SC("Create"), &Checkpoint_Create) ); } diff --git a/source/Entity/Player.cpp b/source/Entity/Player.cpp index 4e886ca8..fdb6773b 100644 --- a/source/Entity/Player.cpp +++ b/source/Entity/Player.cpp @@ -1201,6 +1201,40 @@ void CPlayer::PlaySound(Int32 sound_id) const _Func->PlaySound(_Func->GetPlayerUniqueWorld(m_ID), sound_id, NAN, NAN, NAN); } +// ------------------------------------------------------------------------------------------------ +Object & CPlayer::CreateCheckpointEx(Int32 world, bool sphere, Float32 x, Float32 y, Float32 z, + Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius) const +{ + return Core::Get().NewCheckpoint(m_ID, world, sphere, x, y, z, r, g, b, a, radius, + SQMOD_CREATE_DEFAULT, NullObject()); +} + +// ------------------------------------------------------------------------------------------------ +Object & CPlayer::CreateCheckpointEx(Int32 world, bool sphere, Float32 x, Float32 y, Float32 z, + Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius, + Int32 header, Object & payload) const +{ + return Core::Get().NewCheckpoint(m_ID, world, sphere, x, y, z, r, g, b, a, + radius, header, payload); +} + +// ------------------------------------------------------------------------------------------------ +Object & CPlayer::CreateCheckpoint(Int32 world, bool sphere, const Vector3 & pos, + const Color4 & color, Float32 radius) const +{ + return Core::Get().NewCheckpoint(m_ID, world, sphere, pos.x, pos.y, pos.z, + color.r, color.g, color.b, color.a, radius, + SQMOD_CREATE_DEFAULT, NullObject()); +} + +// ------------------------------------------------------------------------------------------------ +Object & CPlayer::CreateCheckpoint(Int32 world, bool sphere, const Vector3 & pos, const Color4 & color, + Float32 radius, Int32 header, Object & payload) const +{ + return Core::Get().NewCheckpoint(m_ID, world, sphere, pos.x, pos.y, pos.z, + color.r, color.g, color.b, color.a, radius, header, payload); +} + // ------------------------------------------------------------------------------------------------ Int32 CPlayer::GetAuthority() const { @@ -2251,6 +2285,14 @@ void Register_CPlayer(HSQUIRRELVM vm) (_SC("SetAnimation"), &CPlayer::SetAnimation) .Overload< void (CPlayer::*)(Int32, Int32) const > (_SC("SetAnimation"), &CPlayer::SetAnimation) + .Overload< Object & (CPlayer::*)(Int32, bool, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32) const > + (_SC("CreateCheckpointEx"), &CPlayer::CreateCheckpointEx) + .Overload< Object & (CPlayer::*)(Int32, bool, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32, Int32, Object &) const > + (_SC("CreateCheckpointEx"), &CPlayer::CreateCheckpointEx) + .Overload< Object & (CPlayer::*)(Int32, bool, const Vector3 &, const Color4 &, Float32) const > + (_SC("CreateCheckpoint"), &CPlayer::CreateCheckpoint) + .Overload< Object & (CPlayer::*)(Int32, bool, const Vector3 &, const Color4 &, Float32, Int32, Object &) const > + (_SC("CreateCheckpoint"), &CPlayer::CreateCheckpoint) // Static Functions .StaticFunc(_SC("Find"), &Player_FindAuto) // Raw Squirrel Methods diff --git a/source/Entity/Player.hpp b/source/Entity/Player.hpp index 66ed4e73..2c04b8bb 100644 --- a/source/Entity/Player.hpp +++ b/source/Entity/Player.hpp @@ -710,6 +710,31 @@ public: */ void PlaySound(Int32 sound_id) const; + /* -------------------------------------------------------------------------------------------- + * Create a checkpoint or sphere for this player. + */ + Object & CreateCheckpointEx(Int32 world, bool sphere, Float32 x, Float32 y, Float32 z, + Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius) const; + + /* -------------------------------------------------------------------------------------------- + * Create a checkpoint or sphere for this player. + */ + Object & CreateCheckpointEx(Int32 world, bool sphere, Float32 x, Float32 y, Float32 z, + Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius, + Int32 header, Object & payload) const; + + /* -------------------------------------------------------------------------------------------- + * Create a checkpoint or sphere for this player. + */ + Object & CreateCheckpoint(Int32 world, bool sphere, const Vector3 & pos, + const Color4 & color, Float32 radius) const; + + /* -------------------------------------------------------------------------------------------- + * Create a checkpoint or sphere for this player. + */ + Object & CreateCheckpoint(Int32 world, bool sphere, const Vector3 & pos, const Color4 & color, + Float32 radius, Int32 header, Object & payload) const; + /* -------------------------------------------------------------------------------------------- * Retrieve the authority level of the managed player entity. */