diff --git a/stepmania/src/LuaHelpers.cpp b/stepmania/src/LuaHelpers.cpp index 8a8584e4bc..35a8150be8 100644 --- a/stepmania/src/LuaHelpers.cpp +++ b/stepmania/src/LuaHelpers.cpp @@ -99,20 +99,15 @@ bool Lua::GetStack( lua_State *L, int pos, int &out ) void LoadFromString( lua_State *L, const CString &str ) { - // HACK: Many metrics have "//" comments that Lua fails to parse. - // Replace them with Lua-style comments. - CString str2 = str; - str2.Replace( "//", "--" ); - ChunkReaderData data; - data.buf = &str2; + data.buf = &str; int ret = lua_load( L, ChunkReaderString, &data, "in" ); if( ret ) { CString err; Lua::PopStack( L, err ); - RageException::Throw( "Error loading script \"%s\": %s", str2.c_str(), err.c_str() ); + RageException::Throw( "Error loading script \"%s\": %s", str.c_str(), err.c_str() ); } } diff --git a/stepmania/src/ThemeManager.cpp b/stepmania/src/ThemeManager.cpp index cd4ec45577..1fa85d2656 100644 --- a/stepmania/src/ThemeManager.cpp +++ b/stepmania/src/ThemeManager.cpp @@ -614,18 +614,24 @@ int ThemeManager::GetMetricI( CString sClassName, CString sValueName ) float ThemeManager::GetMetricF( CString sClassName, CString sValueName ) { - const CString str = GetMetricRaw( sClassName,sValueName ); + CString str = GetMetricRaw( sClassName,sValueName ); + // HACK: Many metrics have "//" comments that Lua fails to parse. + // Replace them with Lua-style comments. + str.Replace( "//", "--" ); return Lua::RunExpressionF( str ); } // #include "LuaHelpers.h" bool ThemeManager::GetMetricB( CString sClassName, CString sValueName ) { - const CString str = GetMetricRaw( sClassName,sValueName ); + CString str = GetMetricRaw( sClassName,sValueName ); if( str == "0" ) return false; /* optimization */ if( str == "1" ) return true; /* optimization */ + // HACK: Many metrics have "//" comments that Lua fails to parse. + // Replace them with Lua-style comments. + str.Replace( "//", "--" ); return Lua::RunExpressionB( str ); }