From b50eb9399deb3cb6ed700cf985ca91a2875a4549 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 6 Nov 2004 06:46:43 +0000 Subject: [PATCH] add debug-only checks for absolute position metrics and command params --- stepmania/src/Actor.cpp | 10 ++++++++++ stepmania/src/ThemeManager.cpp | 26 ++++++++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index ba4c9b7311..b61f9aa5fc 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -631,6 +631,16 @@ void Actor::HandleCommand( const ParsedCommand &command ) const CString& sName = sParam(0); +#if defined(DEBUG) + if( sName == "x" || sName == "y" ) // an absolute X or Y position + { + if( sParam(1).Find('-') == -1 && sParam(1).Find('+') == -1 ) + { + LOG->Warn( "Command '%s' should contain a SCREEN_* constant", command.GetOriginalCommandString().c_str() ); + } + } +#endif + // Commands that go in the tweening queue: if ( sName=="sleep" ) Sleep( fParam(1) ); else if( sName=="linear" ) BeginTweening( fParam(1), TWEEN_LINEAR ); diff --git a/stepmania/src/ThemeManager.cpp b/stepmania/src/ThemeManager.cpp index 81a7308c64..343a550987 100644 --- a/stepmania/src/ThemeManager.cpp +++ b/stepmania/src/ThemeManager.cpp @@ -619,25 +619,35 @@ int ThemeManager::GetMetricI( const CString &sClassName, const CString &sValueNa float ThemeManager::GetMetricF( const CString &sClassName, const CString &sValueName ) { - CString str = GetMetricRaw( sClassName,sValueName ); + CString sValue = GetMetricRaw( sClassName, sValueName ); - Lua::PrepareExpression( str ); +#if defined(DEBUG) + if( sValueName.Right(1) == "X" || sValueName.Right(1) == "Y" ) // an absolute X or Y position + { + if( sValue.Find('-') == -1 && sValue.Find('+') == -1 ) + { + LOG->Warn( "Absolute position metric '%s'-'%s' should contain a SCREEN_* constant", sClassName.c_str(), sValueName.c_str() ); + } + } +#endif - return Lua::RunExpressionF( str ); + Lua::PrepareExpression( sValue ); + + return Lua::RunExpressionF( sValue ); } // #include "LuaHelpers.h" bool ThemeManager::GetMetricB( const CString &sClassName, const CString &sValueName ) { - CString str = GetMetricRaw( sClassName,sValueName ); - if( str == "0" ) + CString sValue = GetMetricRaw( sClassName,sValueName ); + if( sValue == "0" ) return false; /* optimization */ - if( str == "1" ) + if( sValue == "1" ) return true; /* optimization */ - Lua::PrepareExpression( str ); + Lua::PrepareExpression( sValue ); - return Lua::RunExpressionB( str ); + return Lua::RunExpressionB( sValue ); } RageColor ThemeManager::GetMetricC( const CString &sClassName, const CString &sValueName )