From d1759bb123473c4a92dbb35ab1d7c22c7f187c26 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 22 Nov 2006 01:51:31 +0000 Subject: [PATCH] Resolve directory names to embedded default.xml/default.lua files at the pathname resolution stage (THEME:GetPath, ResolvePath), not at loading. This means that pathnames to Lua files are actually paths to Lua files, without any extra processing, and we always load actual files (except for BGAnimation compatibility), not directories. (fixes Lua LoadActor() on a directory loading as a BGA and not as Lua) --- stepmania/src/ActorUtil.cpp | 37 ++++++++++++++++------------------ stepmania/src/ThemeManager.cpp | 14 +++++++++++++ 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/stepmania/src/ActorUtil.cpp b/stepmania/src/ActorUtil.cpp index 968fd5e5f8..9c81968541 100644 --- a/stepmania/src/ActorUtil.cpp +++ b/stepmania/src/ActorUtil.cpp @@ -103,6 +103,23 @@ retry: sPath = asPaths[0]; } + if( ft == RageFileManager::TYPE_DIR ) + { + RString sXMLPath = sPath + "/default.xml"; + if( DoesFileExist(sXMLPath) ) + { + sPath = sXMLPath; + return true; + } + + RString sLuaPath = sPath + "/default.lua"; + if( DoesFileExist(sLuaPath) ) + { + sPath = sLuaPath; + return true; + } + } + sPath = DerefRedir( sPath ); return true; } @@ -356,26 +373,6 @@ Actor* ActorUtil::MakeActor( const RString &sPath_, Actor *pParentActor, const X if( ft == FT_Directory && sPath.Right(1) != "/" ) sPath += '/'; - if( ft == FT_Directory ) - { - RString sXMLPath = sPath + "default.xml"; - if( DoesFileExist(sXMLPath) ) - { - sPath = sXMLPath; - ft = FT_Xml; - } - } - - if( ft == FT_Directory ) - { - RString sLuaPath = sPath + "default.lua"; - if( DoesFileExist(sLuaPath) ) - { - sPath = sLuaPath; - ft = FT_Lua; - } - } - switch( ft ) { case FT_Xml: diff --git a/stepmania/src/ThemeManager.cpp b/stepmania/src/ThemeManager.cpp index 08148ae700..528eae496c 100644 --- a/stepmania/src/ThemeManager.cpp +++ b/stepmania/src/ThemeManager.cpp @@ -593,6 +593,20 @@ try_element_again: if( bDirIsEmpty ) continue; #endif + + RString sXMLPath = asPaths[p] + "/default.xml"; + if( DoesFileExist(sXMLPath) ) + { + asElementPaths.push_back( sXMLPath ); + break; + } + + RString sLuaPath = asPaths[p] + "/default.lua"; + if( DoesFileExist(sLuaPath) ) + { + asElementPaths.push_back( sLuaPath ); + break; + } } if( ext == asset_masks[i] || !strcmp(asset_masks[i], "*") )