--- AE/Installer/trunk/source/installer.cpp 2010/05/29 19:21:27 558 +++ AE/Installer/trunk/source/installer.cpp 2010/06/01 13:13:59 565 @@ -24,7 +24,6 @@ using namespace boost::gregorian; using namespace boost::posix_time; -// externs declared in installer.h string strInstallCfg = "../GameDataFolder/Add.cfg"; string strEUFN = "Edition"; // GetUpdateStatus() may set this to "Edition-patch" later, but this is the assumed name of the new Edition folder in Updates/ extern MainWindow* TheWindow; @@ -348,7 +347,8 @@ vector getPackages(string pa if (!file.fail()) { 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 + + if (package.installerVersion.compare(gInstallerVersion) < 1) // if mod requires newer version of the Installer, we won't add it to the list { #ifdef WIN32 if (!package.platform.compare("Windows") || !package.platform.compare("Both")) // don't show package if it's not for the right OS @@ -374,7 +374,6 @@ vector getPackages(string pa ModPackage fileToModPackage(fstream &file, string modName) { ModPackage package; - string line; const string AEInstallVersion = "AEInstallVersion"; // used for comparing to the current token... const string NameOfMod = "NameOfMod"; const string ARROW = "->"; @@ -390,17 +389,19 @@ ModPackage fileToModPackage(fstream &fil const string GlobalNeeded = "GlobalNeeded"; const string Category = "Category"; const string Creator = "Creator"; - package.modStringName = modName; while (!file.eof()) { - getline(file,line); - vector tokens; + string line; + getline(file, line); + vector tokens; vector::iterator iter; tokenize(line, tokens); if (tokens.capacity() >= 3) { + for (int a = 0; a < tokens.size(); a++) + StripNewlines(&tokens.at(a)); iter = tokens.begin(); - + if (!AEInstallVersion.compare(*iter)) { iter++; iter++; @@ -492,7 +493,7 @@ ModPackage fileToModPackage(fstream &fil } } } - + package.modStringName = modName; return package; } @@ -658,13 +659,11 @@ void recompileAll(vector install vector skippedfolders; ofstream BSLlog("BSL.log"); - if(exists("../GameDataFolder/BSLBackup/")) { - remove_all("../GameDataFolder/BSLBackup/"); - } - else { + if(!exists("../GameDataFolder/BSLBackup/")) { create_directory("../GameDataFolder/BSLBackup/"); + copy("../GameDataFolder/IGMD/", "../GameDataFolder/BSLBackup/"); } - copy("../GameDataFolder/IGMD/", "../GameDataFolder/BSLBackup/"); + for ( directory_iterator dir_itr( "../GameDataFolder/IGMD/" ), end_itr; dir_itr != end_itr; ++dir_itr ) { @@ -944,8 +943,7 @@ int GetUpdateStatus(Install_info_cfg *cu else if (readingInstallerVersion && tokens.capacity() >= 3) { readingInstallerVersion = false; - string installerVersion = INSTALLER_VERSION; - if (installerVersion.compare(*iter)) // then the shell script-powered replacement failed + if (gInstallerVersion.compare(*iter)) // then the shell script-powered replacement failed return UPDATE_INST_REPL_ERR; else { @@ -959,7 +957,7 @@ int GetUpdateStatus(Install_info_cfg *cu // Write over old log with updated information ptime startTime(second_clock::local_time()); string strStartTime = to_simple_string(startTime); - string newUpdateLine = installerVersion + " on " + strStartTime; + string newUpdateLine = gInstallerVersion + " on " + strStartTime; for (int a = 0; a < lines.capacity() - 2; a++) // if there were even lines in the log before this at all { newUpdateLog << lines[a].c_str(); @@ -989,8 +987,7 @@ int GetUpdateStatus(Install_info_cfg *cu if (updateAE->AEVersion.compare(currentAE->AEVersion) > 0) // is the release update newer than what's installed? { string strNewInstallerPath = "../updates/" + strEUFN + "/install/" + strInstallerName; - string installerVersion = INSTALLER_VERSION; - if (updateAE->InstallerVersion.compare(installerVersion) >= 1) + if (updateAE->InstallerVersion.compare(gInstallerVersion) >= 1) { if (exists(strNewInstallerPath)) return UPDATE_INST_AVAIL; @@ -1032,7 +1029,7 @@ int GetUpdateStatus(Install_info_cfg *cu file.close(); if (updatePackage.modStringVersion > installedPackage.modStringVersion) { - if (updatePackage.installerVersion <= INSTALLER_VERSION) + if (updatePackage.installerVersion.compare(gInstallerVersion) < 1) return UPDATE_PKG_AVAIL; } } @@ -1481,7 +1478,7 @@ bool ProcessAEUpdate(Install_info_cfg *c #ifndef WIN32 rename((path)("../" + thePath), (path)(strTrashDir + thePath)); #else - remove((path)("../" + thePath)); + remove_all((path)("../" + thePath)); #endif } } @@ -1553,6 +1550,11 @@ bool ProcessAEUpdate(Install_info_cfg *c } catch (exception & ex) { + wxMessageDialog* DotNetDialogOfDeath = + new wxMessageDialog(TheWindow, ex.what(), "AE Installer Alert", + wxICON_EXCLAMATION , wxDefaultPosition); + + DotNetDialogOfDeath->ShowModal(); setStatusArea("Warning, handled exception: " + (string)ex.what()); return false; } @@ -1614,7 +1616,7 @@ void ProcessPackageUpdates(string pathTo file.close(); if (updatePackage.modStringVersion > installedPackage.modStringVersion) { - if (updatePackage.installerVersion <= INSTALLER_VERSION) + if (updatePackage.installerVersion.compare(gInstallerVersion) < 1) { if(exists(strPathToPackages + "/" + updatePackage.modStringName)) { #ifdef WIN32 @@ -1687,7 +1689,7 @@ void tokenize(const string& str, vector< /* StripNewlines() gets rids of any linebreaks that come from text returned by getline(); \ | getline() should be stripping those out, but Windows CR/LF files seem to be sneaking | -\ some extra return characters into strings in the ReadInstallInfoCfg() function. */ +\ some extra return characters into strings. */ void StripNewlines(string *theLine) { int deleteFromHere = 0;