From 9a52981f1913fdbec23a933c808e2d48bd55ab9a Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Wed, 16 Nov 2016 14:48:57 +0200 Subject: [PATCH] Adjust the Pickup entity methods to use the new method of receiving formatted strings. --- source/Entity/Pickup.cpp | 19 +++++++++++++++++-- source/Entity/Pickup.hpp | 7 ++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/source/Entity/Pickup.cpp b/source/Entity/Pickup.cpp index 088e9aac..5545cdee 100644 --- a/source/Entity/Pickup.cpp +++ b/source/Entity/Pickup.cpp @@ -56,9 +56,23 @@ const String & CPickup::GetTag() const } // ------------------------------------------------------------------------------------------------ -void CPickup::SetTag(CSStr tag) +void CPickup::SetTag(const StackStrF & tag) { - m_Tag.assign(tag); + if (tag.mLen > 0) + { + m_Tag.assign(tag.mPtr, tag.mLen); + } + else + { + m_Tag.clear(); + } +} + +// ------------------------------------------------------------------------------------------------ +CPickup & CPickup::ApplyTag(StackStrF & tag) +{ + SetTag(tag); + return *this; } // ------------------------------------------------------------------------------------------------ @@ -444,6 +458,7 @@ void Register_CPickup(HSQUIRRELVM vm) .Prop(_SC("Active"), &CPickup::IsActive) // Core Methods .Func(_SC("Bind"), &CPickup::BindEvent) + .FmtFunc(_SC("SetTag"), &CPickup::ApplyTag) .Func(_SC("CustomEvent"), &CPickup::CustomEvent) // Core Overloads .Overload< bool (CPickup::*)(void) >(_SC("Destroy"), &CPickup::Destroy) diff --git a/source/Entity/Pickup.hpp b/source/Entity/Pickup.hpp index 95b59f12..248a96b4 100644 --- a/source/Entity/Pickup.hpp +++ b/source/Entity/Pickup.hpp @@ -138,7 +138,12 @@ public: /* -------------------------------------------------------------------------------------------- * Modify the associated user tag. */ - void SetTag(CSStr tag); + void SetTag(const StackStrF & tag); + + /* -------------------------------------------------------------------------------------------- + * Modify the associated user tag. + */ + CPickup & ApplyTag(StackStrF & tag); /* -------------------------------------------------------------------------------------------- * Retrieve the associated user data.