void TextureDescriptor::ConvertToCurrentVersion(int8 version, int32 signature, DAVA::File *file) { // Logger::Info("[TextureDescriptor::ConvertToCurrentVersion] (%s) from version %d", pathname.c_str(), version); if(version == 2) { LoadVersion2(signature, file); } else if(version == 3) { LoadVersion3(signature, file); } else if(version == 4) { LoadVersion4(signature, file); } else if(version == 5) { LoadVersion5(signature, file); } else if(version == 6) { LoadVersion6(signature, file); } }
bool CLevel::LoadFromFile() { bool ErrorOccurred = false; // Open the existing level file for reading ifstream in; in.open( m_Filename_full.c_str(), ios_base::in ); // If it failed if (!in.is_open()) { theLog.WriteLine ("Options => Loading level file %s failed.", m_Filename_full.c_str() ); // Stop loading levels return false; } // This is the first line for the level files beginning with version 2 (therefore "V2plus") string headerV2plus( "; Bombermaaan level file version=" ); string s; getline( in, s ); int LevelVersion; // When header string is found at the beginning of the string, find() returns 0 (offset 0) if ( s.find( headerV2plus ) == 0 ) { // We can look for the level version now LevelVersion = atoi( s.substr( headerV2plus.length() ).c_str() ); } else { LevelVersion = 1; } switch ( LevelVersion ) { case 1: if (!LoadVersion1( in ) ) { ErrorOccurred = true; } break; case 2: if (!LoadVersion2( m_Filename_full ) ) { ErrorOccurred = true; } break; default: theLog.WriteLine ("Options => !!! Unsupported version of level file %s.", m_Filename_short.c_str()); ErrorOccurred = true; break; } // Close the level file in.close(); // Validate this level if no error occurred so far if (!ErrorOccurred) { ErrorOccurred = !Validate(); } // If there wasn't any problem if (!ErrorOccurred) { theLog.WriteLine ("Options => Level file %s was successfully loaded (version %d).", m_Filename_short.c_str(), LevelVersion); } // If there was a problem else { theLog.WriteLine ("Options => !!! Could not load level file %s (version %d).", m_Filename_short.c_str(), LevelVersion); } // If we had to stop then there is a problem. if (ErrorOccurred) return false; // Everything went right return true; }