--- AE/Installer/trunk/source/installer.cpp 2010/03/27 03:48:25 504 +++ AE/Installer/trunk/source/installer.cpp 2010/03/27 14:17:32 505 @@ -349,7 +349,7 @@ vector getPackages(string pa if (!file.fail()) { - package = fileToModPackage(file); + package = fileToModPackage(file, dir_itr->path().filename()); if (package.installerVersion.compare(INSTALLER_VERSION) < 1) // if mod requires newer version of the Installer, we won't add it to the list { #ifdef WIN32 @@ -373,7 +373,7 @@ vector getPackages(string pa return packages; } -ModPackage fileToModPackage(fstream &file) +ModPackage fileToModPackage(fstream &file, string modName) { /* This converts a file to a ModPackage struct. @@ -383,22 +383,25 @@ ModPackage fileToModPackage(fstream &fil I refer to (*iter) at the beginning of each if statement block. I could probably store it as a variable, but I'm pretty sure that dereferencing a pointer\iterator isn't much slower than reading a variable. */ + ModPackage package; string line; - static string AEInstallVersion = "AEInstallVersion"; // used for comparing to the current token... - static string NameOfMod = "NameOfMod"; - static string ARROW = "->"; - static string ModString = "ModString"; - static string Platform = "Platform"; - static string HasOnis = "HasOnis"; - static string HasDeltas = "HasDeltas"; - static string HasBSL = "HasBSL"; - static string HasDats = "HasDats"; - static string IsEngine = "IsEngine"; - static string Readme = "Readme"; - static string GlobalNeeded = "GlobalNeeded"; - static string Category = "Category"; - static string Creator = "Creator"; + const string AEInstallVersion = "AEInstallVersion"; // used for comparing to the current token... + const string NameOfMod = "NameOfMod"; + const string ARROW = "->"; + const string ModString = "ModString"; + const string ModVersion = "ModVersion"; + const string Platform = "Platform"; + const string HasOnis = "HasOnis"; + const string HasDeltas = "HasDeltas"; + const string HasBSL = "HasBSL"; + const string HasDats = "HasDats"; + const string IsEngine = "IsEngine"; + const string Readme = "Readme"; + const string GlobalNeeded = "GlobalNeeded"; + const string Category = "Category"; + const string Creator = "Creator"; + package.modStringName = modName; while (!file.eof()) { getline(file,line); @@ -425,10 +428,15 @@ ModPackage fileToModPackage(fstream &fil else if (!ModString.compare(*iter)) { iter++; iter++; - package.modStringName = *iter; + //package.modStringName = *iter; iter++; package.modStringVersion = atof((*iter).c_str()); } + else if (!ModString.compare(*iter)) + { + iter++; iter++; + package.modStringVersion = atof((*iter).c_str()); + } else if (!Platform.compare(*iter)) { iter++; iter++; @@ -442,7 +450,7 @@ ModPackage fileToModPackage(fstream &fil else if (!HasBSL.compare(*iter)) { iter++; iter++; - if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasBSL = true; + if (boost::iequals(*iter, "Yes")) package.hasBSL = true; else if (boost::iequals(*iter, "Addon")) package.hasAddon = true; } else if (!HasDeltas.compare(*iter)) @@ -975,7 +983,7 @@ int GetUpdateStatus(Install_info_cfg *cu file.open( (install_iter->path().string() + "/Mod_Info.cfg").c_str()); if (!file.fail()) { - ModPackage updatePackage = fileToModPackage(file); + ModPackage updatePackage = fileToModPackage(file, install_iter->path().filename()); } else { @@ -987,7 +995,7 @@ int GetUpdateStatus(Install_info_cfg *cu file.open( ("packages" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); if (!file.fail()) { - ModPackage installedPackage = fileToModPackage(file); + ModPackage installedPackage = fileToModPackage(file, install_iter->path().filename()); } else { @@ -1269,37 +1277,37 @@ bool ProcessInstallerUpdate(Install_info void CrawlPackages(string pathToUpdate, string strPathToPackages) { try{ directory_iterator end; - for ( directory_iterator install_iter( pathToUpdate ); - install_iter != end; - ++install_iter ) + for ( directory_iterator update_iter( pathToUpdate ); + update_iter != end; + ++update_iter ) { ModPackage installedPackage, updatePackage; - string updateStr = install_iter->path().string() + "/Mod_Info.cfg"; - if ( !boost::iequals(install_iter->path().filename(),"Edition") - && !boost::iequals(install_iter->path().filename(),"Edition-patch") - && is_directory( install_iter->path() ) - && exists( install_iter->path().string() + "/Mod_Info.cfg" ) ) + string updateStr = update_iter->path().string() + "/Mod_Info.cfg"; + if ( !boost::iequals(update_iter->path().filename(),"Edition") + && !boost::iequals(update_iter->path().filename(),"Edition-patch") + && is_directory( update_iter->path() ) + && exists( update_iter->path().string() + "/Mod_Info.cfg" ) ) { bool update = 0; fstream file; - file.open( (install_iter->path().string() + "/Mod_Info.cfg").c_str()); + file.open( (update_iter->path().string() + "/Mod_Info.cfg").c_str()); if (!file.fail()) { - updatePackage = fileToModPackage(file); + updatePackage = fileToModPackage(file, update_iter->path().filename()); } else { file.close(); continue; } - if(!exists(strPathToPackages + "/" + install_iter->path().filename() + "/Mod_Info.cfg")); + if(!exists(strPathToPackages + "/" + update_iter->path().filename() + "/Mod_Info.cfg")); file.close(); file.clear(); - file.open((strPathToPackages + "/" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); + file.open((strPathToPackages + "/" + update_iter->path().filename() + "/Mod_Info.cfg").c_str()); if (!file.fail()) { - installedPackage = fileToModPackage(file); + installedPackage = fileToModPackage(file, update_iter->path().filename()); file.close(); if(updatePackage.modStringVersion > installedPackage.modStringVersion) { remove_all((path)(strPathToPackages + "/" + installedPackage.modStringName));