From 6522889492eb1037938b779d91de318621dd386f Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Wed, 16 Nov 2016 16:19:29 +0200 Subject: [PATCH] Adjust the GetColor function to use the new method of receiving formatted strings. --- source/Base/Shared.cpp | 14 ++++++++++---- source/Base/Shared.hpp | 7 ++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/source/Base/Shared.cpp b/source/Base/Shared.cpp index cfa752cc..f59689ef 100644 --- a/source/Base/Shared.cpp +++ b/source/Base/Shared.cpp @@ -324,12 +324,18 @@ const Color3 & GetRandomColor() } // ------------------------------------------------------------------------------------------------ -Color3 GetColor(CSStr name) +Color3 GetColor(const StackStrF & name) +{ + return name.mLen <= 0 ? Color3() : GetColorStr(name.mPtr); +} + +// ------------------------------------------------------------------------------------------------ +Color3 GetColorStr(CSStr name) { // See if we actually have something to search for - if(!name || *name == 0) + if(!name || *name == '\0') { - STHROWF("Cannot extract values from an empty string"); + return Color3::NIL; // Use default color } // Clone the string into an editable version CSStr str = StrJustAlphaNum(name); @@ -337,7 +343,7 @@ Color3 GetColor(CSStr name) // See if we still have a valid name after the cleanup if(!str || *str == '\0') { - STHROWF("Cannot extract values from an invalid string: %s", name); + return Color3::NIL; // Use default color } // Calculate the name length const Uint32 len = std::strlen(str); diff --git a/source/Base/Shared.hpp b/source/Base/Shared.hpp index 603c6b6b..4888407c 100644 --- a/source/Base/Shared.hpp +++ b/source/Base/Shared.hpp @@ -211,7 +211,12 @@ const Color3 & GetRandomColor(); /* ------------------------------------------------------------------------------------------------ * Attempt to identify the color in the specified name and return it. */ -Color3 GetColor(CSStr name); +Color3 GetColorStr(CSStr name); + +/* ------------------------------------------------------------------------------------------------ + * Attempt to identify the color in the specified name and return it. +*/ +Color3 GetColor(const StackStrF & name); /* ------------------------------------------------------------------------------------------------ * Throw the last system error as an exception.