- typedef std::map<CopiedString, Doom3ModelSkin> SkinMap;
- SkinMap m_skins;
- Doom3ModelSkin g_nullSkin;
-
- Doom3ModelSkin& getSkin(const char* name)
- {
- SkinMap::iterator i = m_skins.find(name);
- if(i != m_skins.end())
- {
- return (*i).second;
- }
-
- return g_nullSkin;
- }
-
- bool parseTokens(Tokeniser& tokeniser)
- {
- tokeniser.nextLine();
- for(;;)
- {
- const char* token = tokeniser.getToken();
- if(token == 0)
- {
- // end of token stream
- return true;
- }
- if(!string_equal(token, "skin"))
- {
- Tokeniser_unexpectedError(tokeniser, token, "skin");
- return false;
- }
- const char* other = tokeniser.getToken();
- if(other == 0)
- {
- Tokeniser_unexpectedError(tokeniser, token, "#string");
- return false;
- }
- CopiedString name;
- parseShaderName(name, other);
- Doom3ModelSkin& skin = m_skins[name];
- RETURN_FALSE_IF_FAIL(skin.parseTokens(tokeniser));
- }
- }
-
- void parseFile(const char* name)
- {
- StringOutputStream relativeName(64);
- relativeName << "skins/" << name;
- ArchiveTextFile* file = GlobalFileSystem().openTextFile(relativeName.c_str());
- if(file != 0)
- {
- globalOutputStream() << "parsing skins from " << makeQuoted(name) << "\n";
- {
- Tokeniser& tokeniser = GlobalScriptLibrary().m_pfnNewSimpleTokeniser(file->getInputStream());
- parseTokens(tokeniser);
- tokeniser.release();
- }
- file->release();
- }
- else
- {
- globalErrorStream() << "failed to open " << makeQuoted(name) << "\n";
- }
- }
-
- typedef MemberCaller1<GlobalSkins, const char*, &GlobalSkins::parseFile> ParseFileCaller;
-
- void construct()
- {
- GlobalFileSystem().forEachFile("skins/", "skin", ParseFileCaller(*this));
- }
-
- void destroy()
- {
- m_skins.clear();
- }
-
- void realise()
- {
- construct();
- }
- void unrealise()
- {
- destroy();
- }
+typedef std::map<CopiedString, Doom3ModelSkin> SkinMap;
+SkinMap m_skins;
+Doom3ModelSkin g_nullSkin;
+
+Doom3ModelSkin& getSkin( const char* name ){
+ SkinMap::iterator i = m_skins.find( name );
+ if ( i != m_skins.end() ) {
+ return ( *i ).second;
+ }
+
+ return g_nullSkin;
+}
+
+bool parseTokens( Tokeniser& tokeniser ){
+ tokeniser.nextLine();
+ for (;; )
+ {
+ const char* token = tokeniser.getToken();
+ if ( token == 0 ) {
+ // end of token stream
+ return true;
+ }
+ if ( !string_equal( token, "skin" ) ) {
+ Tokeniser_unexpectedError( tokeniser, token, "skin" );
+ return false;
+ }
+ const char* other = tokeniser.getToken();
+ if ( other == 0 ) {
+ Tokeniser_unexpectedError( tokeniser, token, "#string" );
+ return false;
+ }
+ CopiedString name;
+ parseShaderName( name, other );
+ Doom3ModelSkin& skin = m_skins[name];
+ RETURN_FALSE_IF_FAIL( skin.parseTokens( tokeniser ) );
+ }
+}
+
+void parseFile( const char* name ){
+ StringOutputStream relativeName( 64 );
+ relativeName << "skins/" << name;
+ ArchiveTextFile* file = GlobalFileSystem().openTextFile( relativeName.c_str() );
+ if ( file != 0 ) {
+ globalOutputStream() << "parsing skins from " << makeQuoted( name ) << "\n";
+ {
+ Tokeniser& tokeniser = GlobalScriptLibrary().m_pfnNewSimpleTokeniser( file->getInputStream() );
+ parseTokens( tokeniser );
+ tokeniser.release();
+ }
+ file->release();
+ }
+ else
+ {
+ globalErrorStream() << "failed to open " << makeQuoted( name ) << "\n";
+ }
+}
+
+typedef MemberCaller1<GlobalSkins, const char*, &GlobalSkins::parseFile> ParseFileCaller;
+
+void construct(){
+ GlobalFileSystem().forEachFile( "skins/", "skin", ParseFileCaller( *this ) );
+}
+
+void destroy(){
+ m_skins.clear();
+}
+
+void realise(){
+ construct();
+}
+void unrealise(){
+ destroy();
+}