From 1bb569f8c4f1728b663552c143fbe8340eeb5c38 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 22 Sep 2006 07:50:05 +0000 Subject: [PATCH] LuaReference and apActorCommands are the same thing; apActorCommands just sticks the result in AutoPtrCopyOnWrite. apActorCommands might be eliminated; it's reference counting a garbage collected object. (It used to be more useful, when we stored actual command lists; now I'm not sure whether it is. Need to benchmark LuaRef copying to see.) So, we shouldn't be treating them differently, but we are: GetMetric(apActorCommands) parses actor commands, and GetMetric(LuaRef) does not. I don't like that distinction; actor commands can be passed around as a LuaReference, and other references can be put in apActorCommands. "Whether it's in a smart pointer" is a strange way to decide which overload to use. Also, we should have a consistent way to know whether a metric is to be parsed as a command or as a Lua expression, based on the data itself and not the code being used to read it. Let's use the name: all commands end with "Command". We already depend on this elsewhere, in ActorUtil::LoadAllCommandsFromName. Note that "actor commands" are not specific to the Actor system, other than a few compatibility hacks; they're just a shorthand for writing Lua functions. --- stepmania/src/ThemeManager.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/stepmania/src/ThemeManager.cpp b/stepmania/src/ThemeManager.cpp index bfabb0cb40..cd91ef852a 100644 --- a/stepmania/src/ThemeManager.cpp +++ b/stepmania/src/ThemeManager.cpp @@ -989,15 +989,23 @@ void ThemeManager::GetMetric( const RString &sClassName, const RString &sValueNa { RString sValue = GetMetricRaw( g_pLoadedThemeData->iniMetrics, sClassName, sValueName ); - LuaHelpers::PrepareExpression( sValue ); - valueOut.SetFromExpression( sValue ); + if( EndsWith(sValueName, "Command") ) + { + ActorUtil::ParseActorCommands( sValue, valueOut ); + } + else + { + LuaHelpers::PrepareExpression( sValue ); + valueOut.SetFromExpression( sValue ); + } } #if !defined(SMPACKAGE) apActorCommands ThemeManager::GetMetricA( const RString &sClassName, const RString &sValueName ) { - RString sValue = GetMetricRaw( g_pLoadedThemeData->iniMetrics, sClassName, sValueName ); - return ActorUtil::ParseActorCommands( sValue ); + LuaReference *pRef = new LuaReference; + GetMetric( sClassName, sValueName, *pRef ); + return apActorCommands( pRef ); } #endif