--- AE/Installer/trunk/source/installer.cpp 2010/05/29 02:09:04 553 +++ AE/Installer/trunk/source/installer.cpp 2010/07/21 22:44:28 570 @@ -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++; @@ -421,7 +422,7 @@ ModPackage fileToModPackage(fstream &fil iter++; package.modStringVersion = atof((*iter).c_str()); } - else if (!ModString.compare(*iter)) + else if (!ModVersion.compare(*iter)) { iter++; iter++; package.modStringVersion = atof((*iter).c_str()); @@ -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 ) { @@ -677,7 +676,7 @@ void recompileAll(vector install for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it - if(globalPackages[j].hasBSL) break; //skip non-BSL + if(!globalPackages[j].hasBSL) break; //skip non-BSL if( exists( "packages/" + globalPackages[j].modStringName + "/BSL/" ) ) { copyBSL("packages/" + globalPackages[j].modStringName + "/BSL", BSLfolders, globalPackages[j] ); BSLlog << "Copied " << globalPackages[j].modStringName << "!\n"; @@ -757,7 +756,7 @@ void copyBSL(string copypath, vectorpath().filename() + "/ignore.txt")) { - remove_all( "../GameDataFolder/IGMD/" + dir_itr->path().filename() ); + if(!pkg.hasAddon) remove_all( "../GameDataFolder/IGMD/" + dir_itr->path().filename() ); Sleep(100); create_directory( "../GameDataFolder/IGMD/" + dir_itr->path().filename()); BSLlog << "Copied " << dir_itr->path().string() << " in " << pkg.modStringName << "!\n"; @@ -765,6 +764,8 @@ void copyBSL(string copypath, vectorpath().extension() == ".bsl" ) { + if(exists("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename())) + remove("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); copy_file(bsl_itr->path(), "../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); } } @@ -942,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 { @@ -957,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(); @@ -987,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; @@ -1030,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; } } @@ -1479,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 } } @@ -1551,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; } @@ -1612,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 @@ -1685,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;