| 24 |
|
using namespace boost::gregorian; |
| 25 |
|
using namespace boost::posix_time; |
| 26 |
|
|
| 27 |
– |
// externs declared in installer.h |
| 27 |
|
string strInstallCfg = "../GameDataFolder/Add.cfg"; |
| 28 |
|
string strEUFN = "Edition"; // GetUpdateStatus() may set this to "Edition-patch" later, but this is the assumed name of the new Edition folder in Updates/ |
| 29 |
|
extern MainWindow* TheWindow; |
| 347 |
|
if (!file.fail()) |
| 348 |
|
{ |
| 349 |
|
package = fileToModPackage(file, dir_itr->path().filename()); |
| 350 |
< |
if (package.installerVersion.compare(INSTALLER_VERSION) < 1) // if mod requires newer version of the Installer, we won't add it to the list |
| 350 |
> |
|
| 351 |
> |
if (package.installerVersion.compare(gInstallerVersion) < 1) // if mod requires newer version of the Installer, we won't add it to the list |
| 352 |
|
{ |
| 353 |
|
#ifdef WIN32 |
| 354 |
|
if (!package.platform.compare("Windows") || !package.platform.compare("Both")) // don't show package if it's not for the right OS |
| 374 |
|
ModPackage fileToModPackage(fstream &file, string modName) |
| 375 |
|
{ |
| 376 |
|
ModPackage package; |
| 377 |
– |
string line; |
| 377 |
|
const string AEInstallVersion = "AEInstallVersion"; // used for comparing to the current token... |
| 378 |
|
const string NameOfMod = "NameOfMod"; |
| 379 |
|
const string ARROW = "->"; |
| 389 |
|
const string GlobalNeeded = "GlobalNeeded"; |
| 390 |
|
const string Category = "Category"; |
| 391 |
|
const string Creator = "Creator"; |
| 393 |
– |
package.modStringName = modName; |
| 392 |
|
while (!file.eof()) |
| 393 |
|
{ |
| 394 |
< |
getline(file,line); |
| 395 |
< |
vector<string> tokens; |
| 394 |
> |
string line; |
| 395 |
> |
getline(file, line); |
| 396 |
> |
vector<string> tokens; |
| 397 |
|
vector<string>::iterator iter; |
| 398 |
|
tokenize(line, tokens); |
| 399 |
|
if (tokens.capacity() >= 3) |
| 400 |
|
{ |
| 401 |
+ |
for (int a = 0; a < tokens.size(); a++) |
| 402 |
+ |
StripNewlines(&tokens.at(a)); |
| 403 |
|
iter = tokens.begin(); |
| 404 |
< |
|
| 404 |
> |
|
| 405 |
|
if (!AEInstallVersion.compare(*iter)) |
| 406 |
|
{ |
| 407 |
|
iter++; iter++; |
| 422 |
|
iter++; |
| 423 |
|
package.modStringVersion = atof((*iter).c_str()); |
| 424 |
|
} |
| 425 |
< |
else if (!ModString.compare(*iter)) |
| 425 |
> |
else if (!ModVersion.compare(*iter)) |
| 426 |
|
{ |
| 427 |
|
iter++; iter++; |
| 428 |
|
package.modStringVersion = atof((*iter).c_str()); |
| 493 |
|
} |
| 494 |
|
} |
| 495 |
|
} |
| 496 |
< |
|
| 496 |
> |
package.modStringName = modName; |
| 497 |
|
return package; |
| 498 |
|
} |
| 499 |
|
|
| 659 |
|
vector<string> skippedfolders; |
| 660 |
|
|
| 661 |
|
ofstream BSLlog("BSL.log"); |
| 662 |
< |
if(exists("../GameDataFolder/BSLBackup/")) { |
| 662 |
< |
remove_all("../GameDataFolder/BSLBackup/"); |
| 663 |
< |
} |
| 664 |
< |
else { |
| 662 |
> |
if(!exists("../GameDataFolder/BSLBackup/")) { |
| 663 |
|
create_directory("../GameDataFolder/BSLBackup/"); |
| 664 |
+ |
copy("../GameDataFolder/IGMD/", "../GameDataFolder/BSLBackup/"); |
| 665 |
|
} |
| 666 |
< |
copy("../GameDataFolder/IGMD/", "../GameDataFolder/BSLBackup/"); |
| 666 |
> |
|
| 667 |
|
for ( directory_iterator dir_itr( "../GameDataFolder/IGMD/" ), end_itr; |
| 668 |
|
dir_itr != end_itr; |
| 669 |
|
++dir_itr ) { |
| 676 |
|
for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) |
| 677 |
|
for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages |
| 678 |
|
if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it |
| 679 |
< |
if(globalPackages[j].hasBSL) break; //skip non-BSL |
| 679 |
> |
if(!globalPackages[j].hasBSL) break; //skip non-BSL |
| 680 |
|
if( exists( "packages/" + globalPackages[j].modStringName + "/BSL/" ) ) { |
| 681 |
|
copyBSL("packages/" + globalPackages[j].modStringName + "/BSL", BSLfolders, globalPackages[j] ); |
| 682 |
|
BSLlog << "Copied " << globalPackages[j].modStringName << "!\n"; |
| 756 |
|
} |
| 757 |
|
} |
| 758 |
|
if (!skip_folder && !exists("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/ignore.txt")) { |
| 759 |
< |
remove_all( "../GameDataFolder/IGMD/" + dir_itr->path().filename() ); |
| 759 |
> |
if(!pkg.hasAddon) remove_all( "../GameDataFolder/IGMD/" + dir_itr->path().filename() ); |
| 760 |
|
Sleep(100); |
| 761 |
|
create_directory( "../GameDataFolder/IGMD/" + dir_itr->path().filename()); |
| 762 |
|
BSLlog << "Copied " << dir_itr->path().string() << " in " << pkg.modStringName << "!\n"; |
| 764 |
|
bsl_itr != end_itr; |
| 765 |
|
bsl_itr++ ) { |
| 766 |
|
if ( bsl_itr->path().extension() == ".bsl" ) { |
| 767 |
+ |
if(exists("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename())) |
| 768 |
+ |
remove("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); |
| 769 |
|
copy_file(bsl_itr->path(), "../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); |
| 770 |
|
} |
| 771 |
|
} |
| 943 |
|
else if (readingInstallerVersion && tokens.capacity() >= 3) |
| 944 |
|
{ |
| 945 |
|
readingInstallerVersion = false; |
| 946 |
< |
string installerVersion = INSTALLER_VERSION; |
| 946 |
< |
if (installerVersion.compare(*iter)) // then the shell script-powered replacement failed |
| 946 |
> |
if (gInstallerVersion.compare(*iter)) // then the shell script-powered replacement failed |
| 947 |
|
return UPDATE_INST_REPL_ERR; |
| 948 |
|
else |
| 949 |
|
{ |
| 957 |
|
// Write over old log with updated information |
| 958 |
|
ptime startTime(second_clock::local_time()); |
| 959 |
|
string strStartTime = to_simple_string(startTime); |
| 960 |
< |
string newUpdateLine = installerVersion + " on " + strStartTime; |
| 960 |
> |
string newUpdateLine = gInstallerVersion + " on " + strStartTime; |
| 961 |
|
for (int a = 0; a < lines.capacity() - 2; a++) // if there were even lines in the log before this at all |
| 962 |
|
{ |
| 963 |
|
newUpdateLog << lines[a].c_str(); |
| 987 |
|
if (updateAE->AEVersion.compare(currentAE->AEVersion) > 0) // is the release update newer than what's installed? |
| 988 |
|
{ |
| 989 |
|
string strNewInstallerPath = "../updates/" + strEUFN + "/install/" + strInstallerName; |
| 990 |
< |
string installerVersion = INSTALLER_VERSION; |
| 991 |
< |
if (updateAE->InstallerVersion.compare(installerVersion) >= 1) |
| 990 |
> |
if (updateAE->InstallerVersion.compare(gInstallerVersion) >= 1) |
| 991 |
|
{ |
| 992 |
|
if (exists(strNewInstallerPath)) |
| 993 |
|
return UPDATE_INST_AVAIL; |
| 1029 |
|
file.close(); |
| 1030 |
|
if (updatePackage.modStringVersion > installedPackage.modStringVersion) |
| 1031 |
|
{ |
| 1032 |
< |
if (updatePackage.installerVersion <= INSTALLER_VERSION) |
| 1032 |
> |
if (updatePackage.installerVersion.compare(gInstallerVersion) < 1) |
| 1033 |
|
return UPDATE_PKG_AVAIL; |
| 1034 |
|
} |
| 1035 |
|
} |
| 1478 |
|
#ifndef WIN32 |
| 1479 |
|
rename((path)("../" + thePath), (path)(strTrashDir + thePath)); |
| 1480 |
|
#else |
| 1481 |
< |
remove((path)("../" + thePath)); |
| 1481 |
> |
remove_all((path)("../" + thePath)); |
| 1482 |
|
#endif |
| 1483 |
|
} |
| 1484 |
|
} |
| 1550 |
|
} |
| 1551 |
|
catch (exception & ex) |
| 1552 |
|
{ |
| 1553 |
+ |
wxMessageDialog* DotNetDialogOfDeath = |
| 1554 |
+ |
new wxMessageDialog(TheWindow, ex.what(), "AE Installer Alert", |
| 1555 |
+ |
wxICON_EXCLAMATION , wxDefaultPosition); |
| 1556 |
+ |
|
| 1557 |
+ |
DotNetDialogOfDeath->ShowModal(); |
| 1558 |
|
setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 1559 |
|
return false; |
| 1560 |
|
} |
| 1616 |
|
file.close(); |
| 1617 |
|
if (updatePackage.modStringVersion > installedPackage.modStringVersion) |
| 1618 |
|
{ |
| 1619 |
< |
if (updatePackage.installerVersion <= INSTALLER_VERSION) |
| 1619 |
> |
if (updatePackage.installerVersion.compare(gInstallerVersion) < 1) |
| 1620 |
|
{ |
| 1621 |
|
if(exists(strPathToPackages + "/" + updatePackage.modStringName)) { |
| 1622 |
|
#ifdef WIN32 |
| 1689 |
|
|
| 1690 |
|
/* StripNewlines() gets rids of any linebreaks that come from text returned by getline(); \ |
| 1691 |
|
| getline() should be stripping those out, but Windows CR/LF files seem to be sneaking | |
| 1692 |
< |
\ some extra return characters into strings in the ReadInstallInfoCfg() function. */ |
| 1692 |
> |
\ some extra return characters into strings. */ |
| 1693 |
|
void StripNewlines(string *theLine) |
| 1694 |
|
{ |
| 1695 |
|
int deleteFromHere = 0; |