--- AE/Installer/trunk/source/installer.cpp 2010/05/22 22:07:58 526 +++ AE/Installer/trunk/source/installer.cpp 2010/05/29 00:13:35 552 @@ -597,37 +597,53 @@ void recompileAll(vector install else if(splitInstances == false){ directory_iterator end_iter; - for ( directory_iterator dir_itr( vanilla_dir ); - dir_itr != end_iter; - ++dir_itr ) - { - if ( is_directory( dir_itr->status() ) ) - { - numberOfDats++; + + char levelnums[256] = {0}; + + + + for(int k = 0; k < 256; k++) { + if( exists( (path)("./VanillaDats/level" + lexical_cast(k) + "_final/") ) ) { + levelnums[k] = 1; + } } - + + 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 + for(int k = 0; k < 256; k++) { + if( globalPackages[j].hasOnis && + exists( (path)("packages/" + globalPackages[j].modStringName + "/oni/level" + lexical_cast(k) + "_final/") ) ) { + levelnums[k] = 1; + + } + } + } + } + } + for (int levelnum = 0; levelnum < 256; levelnum++) + if (levelnums[levelnum]) + numberOfDats++; + out << numberOfDats; datString = out.str(); - - for ( directory_iterator dir_itr( vanilla_dir ); - dir_itr != end_iter; - ++dir_itr ) - { + + for(int levelnum = 0; levelnum < 256; levelnum++) { try { - if ( is_directory( dir_itr->status() ) ) + if ( levelnums[levelnum] ) { - importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " "; + importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + "level" + lexical_cast(levelnum) + "_Final "; for (unsigned int i = 0; i < installedMods.size(); ++i) { - if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename() )) - importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename(); + if (exists((path)("packages/" + installedMods[i] + "/oni/level" + lexical_cast(levelnum) + "_final") )) + importCommand += " packages/" + installedMods[i] + "/oni/level" + lexical_cast(levelnum) + "_Final"; } - importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log"; + importCommand += " ../GameDataFolder/level" + lexical_cast(levelnum) + "_Final.dat >> Install.log"; setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats setStatusArea("Step " + lexical_cast(j) + '/' + lexical_cast(numberOfDats)+ ": Importing " + - dir_itr->path().filename() + " "); + "level" + lexical_cast(levelnum) + "_Final"+ " "); system(importCommand.c_str()); j++; } @@ -647,6 +663,13 @@ void recompileAll(vector install vector skippedfolders; ofstream BSLlog("BSL.log"); + if(exists("../GameDataFolder/BSLBackup/")) { + remove_all("../GameDataFolder/BSLBackup/"); + } + else { + create_directory("../GameDataFolder/BSLBackup/"); + } + copy("../GameDataFolder/IGMD/", "../GameDataFolder/BSLBackup/"); for ( directory_iterator dir_itr( "../GameDataFolder/IGMD/" ), end_itr; dir_itr != end_itr; ++dir_itr ) { @@ -659,7 +682,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].hasAddon || 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"; @@ -668,12 +691,26 @@ void recompileAll(vector install } } + + ModPackage emptyPackage; emptyPackage.modStringName = "VanillaBSL"; emptyPackage.hasBSL = 1; copyBSL("packages/VanillaBSL/IGMD", BSLfolders, emptyPackage); BSLlog.close(); - + + 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].hasAddon) 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"; + } + } + } + } + logfile << "Writing config file"; writeInstalledMods(installedMods); setProgressBar(1000); @@ -714,13 +751,14 @@ void copyBSL(string copypath, vectorpath() ) && dir_itr->path().string() != ".svn" ) { BSLlog << "Testing " << dir_itr->path().string() << " HasBSL: " << pkg.hasBSL << " HasAddon: " << pkg.hasAddon << "\n"; int skip_folder = 0; - - for(unsigned int k = 0; k < BSLfolders.size(); k++) {//iterate through already found BSL folders - BSLlog << "testing " << dir_itr->path().filename() << " vs " << BSLfolders[k] << "\n"; - if(dir_itr->path().filename() == BSLfolders[k]) { - skip_folder = 1; - BSLlog << "skipping " << BSLfolders[k] << " in " << pkg.modStringName << "\n"; - break; + if(!pkg.hasAddon) { + for(unsigned int k = 0; k < BSLfolders.size(); k++) {//iterate through already found BSL folders + BSLlog << "testing " << dir_itr->path().filename() << " vs " << BSLfolders[k] << "\n"; + if(dir_itr->path().filename() == BSLfolders[k]) { + skip_folder = 1; + BSLlog << "skipping " << BSLfolders[k] << " in " << pkg.modStringName << "\n"; + break; + } } } if (!skip_folder && !exists("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/ignore.txt")) { @@ -844,8 +882,11 @@ int GetUpdateStatus(Install_info_cfg *cu return UPDATE_LOG_READ_ERR; } - // Is there an update folder, and is it a monthly release or a patch? + // Is there an update in the updates/ folder, and is it a monthly release or a patch? bool firstParty = 0; + // First create the folder if it's missing, so users are never left wondering where updates are supposed to be put + if (!exists("../updates")) + create_directory("../updates"); if (exists("../updates/Edition")) { firstParty = 1; @@ -1271,6 +1312,7 @@ bool ProcessInstallerUpdate(Install_info bool ProcessAEUpdate(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) { + try { fstream file; string line; vector tokens, updateStarted; @@ -1290,12 +1332,18 @@ bool ProcessAEUpdate(Install_info_cfg *c string strOniApp = "Oni.exe"; #else string strOniApp = "Oni.app"; -#endif bool needNewTrashDir = false; +#endif + bool readingVerAndDate = false; #ifdef WIN32 - string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted + //remove readonly attrib from files. + setStatusArea("Removing readonly attribute..."); + system("attrib -r ./* /s"); + system("attrib -r ../Oni.exe /s"); + system("attrib -r ../binkw32.dll /s"); + #else FILE *fUserName = NULL; char chrUserName[32]; @@ -1330,6 +1378,7 @@ bool ProcessAEUpdate(Install_info_cfg *c if (readingVerAndDate && tokens.capacity() >= 3) tokenize(tokens[2], updateStarted, "-"); } +#ifndef WIN32 if (updateStarted.capacity() < 3) needNewTrashDir = true; else @@ -1339,6 +1388,7 @@ bool ProcessAEUpdate(Install_info_cfg *c if (!exists(strTrashDir)) needNewTrashDir = true; } +#endif } #ifndef WIN32 if (!*installerJustUpdated || needNewTrashDir) // prepare a new directory for deleted files to go to @@ -1355,16 +1405,24 @@ bool ProcessAEUpdate(Install_info_cfg *c // Special code to replace our special files -- the Oni app, OniSplit, the Daodan DLL, and the GUI for OniSplit if (exists(strPathToEUFN + strOniApp)) { - if (exists(strOniApp)) - rename((path)strOniApp, (path)(strTrashDir + strOniApp)); - rename((path)(strPathToEUFN + strOniApp), (path)strOniApp); + if (exists("../" + strOniApp)) +#ifdef WIN32 + remove((path)("../" + strOniApp)); +#else + rename((path)("../" + strOniApp), (path)(strTrashDir + strOniApp)); +#endif + rename((path)(strPathToEUFN + strOniApp), (path)("../" + strOniApp)); } if (updateAE->OniSplitVersion.compare(currentAE->OniSplitVersion) >= 1) { if (exists(strPathToEUFNInstall + strOniSplit)) { if (exists(strOniSplit)) +#ifdef WIN32 + remove((path)strOniSplit); +#else rename((path)strOniSplit, (path)(strTrashDir + strOniSplit)); +#endif rename((path)(strPathToEUFNInstall + strOniSplit), (path)strOniSplit); } } @@ -1374,7 +1432,7 @@ bool ProcessAEUpdate(Install_info_cfg *c if (exists(strPathToEUFN + strDaodan)) { if (exists(("../" + strDaodan))) - rename((path)("../" + strDaodan), (path)(strTrashDir + strDaodan)); + remove((path)("../" + strDaodan)); rename((path)(strPathToEUFN + strDaodan), (path)("../" + strDaodan)); } } @@ -1383,9 +1441,9 @@ bool ProcessAEUpdate(Install_info_cfg *c if (exists(strPathToEUFNInstall + strWinGUI)) { if (exists((path)strWinGUI)) - rename((path)strWinGUI, (path)(strTrashDir + strWinGUI)); + remove((path)strWinGUI); if (exists(strWinGUILang)) - rename((path)strWinGUILang, (path)(strTrashDir + strWinGUILang)); + remove((path)strWinGUILang); rename((path)(strPathToEUFNInstall + strWinGUI), (path)strWinGUI); rename((path)(strPathToEUFNInstall + strWinGUILang), (path)strWinGUILang); } @@ -1418,8 +1476,10 @@ bool ProcessAEUpdate(Install_info_cfg *c while (curPos != string::npos && curPos < thePath.size()) { aParentPath = aParentPath + thePath.substr(lastPos, curPos - lastPos); +#ifndef WIN32 if (!exists(strTrashDir + aParentPath)) create_directory(strTrashDir + aParentPath); +#endif lastPos = curPos + 1; curPos = thePath.find("/", lastPos); aParentPath = aParentPath + "/"; @@ -1464,14 +1524,21 @@ bool ProcessAEUpdate(Install_info_cfg *c for (vector::iterator iter = filesToMove.begin(); iter != filesToMove.end(); iter++) { if (exists(strPathToPackages + strGlobalize + *iter)) +#ifdef WIN32 + remove((path)(strPathToPackages + strGlobalize + *iter)); +#else rename((path)(strPathToPackages + strGlobalize + *iter), (path)(strTrashDir + *iter)); +#endif rename((path)(strPathToEUFNPackages + strGlobalize + *iter), (path)(strPathToPackages + strGlobalize + *iter)); } // Clean up after ourselves, trashing any packages or programs in the update package that are not newer than the current AE +#ifdef WIN32 + remove_all((path)strPathToEUFN); +#else create_directory(strTrashDir + "Unneeded update files"); rename((path)strPathToEUFN, (path)(strTrashDir + "Unneeded update files/" + strEUFN)); - +#endif // Write to log that we are finished with update ptime end_time(second_clock::local_time()); string progressMsg2 = "Edition was updated to:\n" + @@ -1492,6 +1559,13 @@ bool ProcessAEUpdate(Install_info_cfg *c wxCommandEvent e; TheWindow->OnRefreshButtonClick( e ); return true; + } + catch (exception & ex) + { + setStatusArea("Warning, handled exception: " + (string)ex.what()); + return false; + } + } void ProcessPackageUpdates(string pathToUpdate, string strPathToPackages)