From b0c174e75e4e6b0be12785c04aabbbdb21b8c85d Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sun, 1 Nov 2015 01:32:41 +0200 Subject: [PATCH] Added constructor to create a player entity reference from a base reference. --- source/Entity/Player.cpp | 11 ++++++++++- source/Entity/Player.hpp | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/source/Entity/Player.cpp b/source/Entity/Player.cpp index c68f65c8..c758e9e0 100644 --- a/source/Entity/Player.cpp +++ b/source/Entity/Player.cpp @@ -18,6 +18,13 @@ Vector3 CPlayer::s_Vector3; // ------------------------------------------------------------------------------------------------ SQChar CPlayer::s_Buffer[128]; +// ------------------------------------------------------------------------------------------------ +CPlayer::CPlayer(const Reference< CPlayer > & o) noexcept + : Reference(o) +{ + /* ... */ +} + // ------------------------------------------------------------------------------------------------ bool CPlayer::IsStreamedFor(const Reference < CPlayer > & player) const noexcept { @@ -1700,10 +1707,12 @@ bool Register_CPlayer(HSQUIRRELVM vm) // Registration failed return false; } + // Typedef the base reference type for simplicity + typedef Reference< CPlayer > RefType; // Output debugging information LogDbg("Beginning registration of type"); // Attempt to register the actual reference that implements all of the entity functionality - Sqrat::RootTable(vm).Bind(_SC("CPlayer"), Sqrat::DerivedClass< CPlayer, Reference< CPlayer > >(vm, _SC("CPlayer")) + Sqrat::RootTable(vm).Bind(_SC("CPlayer"), Sqrat::DerivedClass< CPlayer, RefType >(vm, _SC("CPlayer")) /* Constructors */ .Ctor() .Ctor< SQInt32 >() diff --git a/source/Entity/Player.hpp b/source/Entity/Player.hpp index 8a017d80..e3c6b609 100644 --- a/source/Entity/Player.hpp +++ b/source/Entity/Player.hpp @@ -30,6 +30,11 @@ public: */ using RefType::Reference; + /* -------------------------------------------------------------------------------------------- + * Construct a reference from a base reference. + */ + CPlayer(const Reference< CPlayer > & o) noexcept; + /* -------------------------------------------------------------------------------------------- * See if the referenced player instance is streamed for the specified player. */