| 310 |
|
Tests for presence of prefs with [ -f ] before doing anything so it doesn't create a partial prefs file -- just in case user has never |
| 311 |
|
run Oni before :-p */ |
| 312 |
|
string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for Edition/ (Oni wants folder that *contains* the GDF) |
| 313 |
– |
//bad Iritscen, bad! fixed buffers can cause crashes. |
| 314 |
– |
/*char prefsCommand[300] = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '"; |
| 315 |
– |
strcat(prefsCommand, fullAEpath.c_str()); |
| 316 |
– |
strcat(prefsCommand, "'"); // path string is enclosed in single quotes to avoid the need to escape UNIX-unfriendly characters |
| 317 |
– |
*/ |
| 313 |
|
string prefsCommand = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '" |
| 314 |
|
+ fullAEpath + "'"; |
| 315 |
|
system(prefsCommand.c_str()); |
| 390 |
|
const string GlobalNeeded = "GlobalNeeded"; |
| 391 |
|
const string Category = "Category"; |
| 392 |
|
const string Creator = "Creator"; |
| 398 |
– |
package.modStringName = modName; |
| 393 |
|
while (!file.eof()) |
| 394 |
|
{ |
| 395 |
|
getline(file,line); |
| 420 |
|
iter++; |
| 421 |
|
package.modStringVersion = atof((*iter).c_str()); |
| 422 |
|
} |
| 423 |
< |
else if (!ModString.compare(*iter)) |
| 423 |
> |
else if (!ModVersion.compare(*iter)) |
| 424 |
|
{ |
| 425 |
|
iter++; iter++; |
| 426 |
|
package.modStringVersion = atof((*iter).c_str()); |
| 491 |
|
} |
| 492 |
|
} |
| 493 |
|
} |
| 494 |
< |
|
| 494 |
> |
package.modStringName = modName; |
| 495 |
|
return package; |
| 496 |
|
} |
| 497 |
|
|
| 591 |
|
else if(splitInstances == false){ |
| 592 |
|
directory_iterator end_iter; |
| 593 |
|
|
| 594 |
< |
for ( directory_iterator dir_itr( vanilla_dir ); |
| 595 |
< |
dir_itr != end_iter; |
| 596 |
< |
++dir_itr ) |
| 597 |
< |
{ |
| 598 |
< |
if ( is_directory( dir_itr->status() ) ) |
| 599 |
< |
{ |
| 600 |
< |
numberOfDats++; |
| 594 |
> |
|
| 595 |
> |
char levelnums[256] = {0}; |
| 596 |
> |
|
| 597 |
> |
|
| 598 |
> |
|
| 599 |
> |
for(int k = 0; k < 256; k++) { |
| 600 |
> |
if( exists( (path)("./VanillaDats/level" + lexical_cast<std::string>(k) + "_final/") ) ) { |
| 601 |
> |
levelnums[k] = 1; |
| 602 |
> |
|
| 603 |
|
} |
| 604 |
|
} |
| 605 |
< |
|
| 605 |
> |
|
| 606 |
> |
for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) |
| 607 |
> |
for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages |
| 608 |
> |
if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it |
| 609 |
> |
for(int k = 0; k < 256; k++) { |
| 610 |
> |
if( globalPackages[j].hasOnis && |
| 611 |
> |
exists( (path)("packages/" + globalPackages[j].modStringName + "/oni/level" + lexical_cast<std::string>(k) + "_final/") ) ) { |
| 612 |
> |
levelnums[k] = 1; |
| 613 |
> |
|
| 614 |
> |
} |
| 615 |
> |
} |
| 616 |
> |
} |
| 617 |
> |
} |
| 618 |
> |
} |
| 619 |
> |
for (int levelnum = 0; levelnum < 256; levelnum++) |
| 620 |
> |
if (levelnums[levelnum]) |
| 621 |
> |
numberOfDats++; |
| 622 |
> |
|
| 623 |
|
out << numberOfDats; |
| 624 |
|
datString = out.str(); |
| 625 |
< |
|
| 626 |
< |
for ( directory_iterator dir_itr( vanilla_dir ); |
| 614 |
< |
dir_itr != end_iter; |
| 615 |
< |
++dir_itr ) |
| 616 |
< |
{ |
| 625 |
> |
|
| 626 |
> |
for(int levelnum = 0; levelnum < 256; levelnum++) { |
| 627 |
|
try |
| 628 |
|
{ |
| 629 |
< |
if ( is_directory( dir_itr->status() ) ) |
| 629 |
> |
if ( levelnums[levelnum] ) |
| 630 |
|
{ |
| 631 |
< |
importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " "; |
| 631 |
> |
importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + "level" + lexical_cast<std::string>(levelnum) + "_Final "; |
| 632 |
|
for (unsigned int i = 0; i < installedMods.size(); ++i) { |
| 633 |
< |
if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename() )) |
| 634 |
< |
importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename(); |
| 633 |
> |
if (exists((path)("packages/" + installedMods[i] + "/oni/level" + lexical_cast<std::string>(levelnum) + "_final") )) |
| 634 |
> |
importCommand += " packages/" + installedMods[i] + "/oni/level" + lexical_cast<std::string>(levelnum) + "_Final"; |
| 635 |
|
} |
| 636 |
< |
importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log"; |
| 636 |
> |
importCommand += " ../GameDataFolder/level" + lexical_cast<std::string>(levelnum) + "_Final.dat >> Install.log"; |
| 637 |
|
|
| 638 |
|
setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats |
| 639 |
|
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + |
| 640 |
< |
dir_itr->path().filename() + " "); |
| 640 |
> |
"level" + lexical_cast<std::string>(levelnum) + "_Final"+ " "); |
| 641 |
|
system(importCommand.c_str()); |
| 642 |
|
j++; |
| 643 |
|
} |
| 657 |
|
vector<string> skippedfolders; |
| 658 |
|
|
| 659 |
|
ofstream BSLlog("BSL.log"); |
| 660 |
< |
if(exists("../GameDataFolder/BSLBackup/")) { |
| 651 |
< |
remove_all("../GameDataFolder/BSLBackup/"); |
| 652 |
< |
} |
| 653 |
< |
else { |
| 660 |
> |
if(!exists("../GameDataFolder/BSLBackup/")) { |
| 661 |
|
create_directory("../GameDataFolder/BSLBackup/"); |
| 662 |
+ |
copy("../GameDataFolder/IGMD/", "../GameDataFolder/BSLBackup/"); |
| 663 |
|
} |
| 664 |
< |
copy("../GameDataFolder/IGMD/", "../GameDataFolder/BSLBackup/"); |
| 664 |
> |
|
| 665 |
|
for ( directory_iterator dir_itr( "../GameDataFolder/IGMD/" ), end_itr; |
| 666 |
|
dir_itr != end_itr; |
| 667 |
|
++dir_itr ) { |
| 754 |
|
} |
| 755 |
|
} |
| 756 |
|
if (!skip_folder && !exists("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/ignore.txt")) { |
| 757 |
< |
remove_all( "../GameDataFolder/IGMD/" + dir_itr->path().filename() ); |
| 757 |
> |
if(!pkg.hasAddon) remove_all( "../GameDataFolder/IGMD/" + dir_itr->path().filename() ); |
| 758 |
|
Sleep(100); |
| 759 |
|
create_directory( "../GameDataFolder/IGMD/" + dir_itr->path().filename()); |
| 760 |
|
BSLlog << "Copied " << dir_itr->path().string() << " in " << pkg.modStringName << "!\n"; |
| 762 |
|
bsl_itr != end_itr; |
| 763 |
|
bsl_itr++ ) { |
| 764 |
|
if ( bsl_itr->path().extension() == ".bsl" ) { |
| 765 |
+ |
if(exists("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename())) |
| 766 |
+ |
remove("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); |
| 767 |
|
copy_file(bsl_itr->path(), "../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); |
| 768 |
|
} |
| 769 |
|
} |
| 983 |
|
return UPDATE_LOG_READ_ERR; |
| 984 |
|
} |
| 985 |
|
|
| 986 |
< |
if (updateAE->AEVersion.compare(currentAE->AEVersion) >= 1) // is the release update newer than what's installed? |
| 986 |
> |
if (updateAE->AEVersion.compare(currentAE->AEVersion) > 0) // is the release update newer than what's installed? |
| 987 |
|
{ |
| 978 |
– |
if (!strEUFN.compare("Edition-patch")) // if update is a patch... |
| 979 |
– |
{ |
| 980 |
– |
if (currentAE->AEVersion.compare(updateAE->AEVersion.substr(0, updateAE->AEVersion.length() - 1))) // ...is it for a different month? |
| 981 |
– |
return UPDATE_MNTH_REQD_ERR; |
| 982 |
– |
} |
| 988 |
|
string strNewInstallerPath = "../updates/" + strEUFN + "/install/" + strInstallerName; |
| 989 |
|
string installerVersion = INSTALLER_VERSION; |
| 990 |
|
if (updateAE->InstallerVersion.compare(installerVersion) >= 1) |
| 997 |
|
else |
| 998 |
|
return UPDATE_SIMP_AVAIL; |
| 999 |
|
} |
| 1000 |
+ |
else |
| 1001 |
+ |
return UPDATE_MNTH_REQD_ERR; |
| 1002 |
|
} |
| 1003 |
|
try |
| 1004 |
|
{ |
| 1329 |
|
bool readingVerAndDate = false; |
| 1330 |
|
|
| 1331 |
|
#ifdef WIN32 |
| 1332 |
< |
//string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted |
| 1332 |
> |
//remove readonly attrib from files. |
| 1333 |
> |
setStatusArea("Removing readonly attribute..."); |
| 1334 |
> |
system("attrib -r ./* /s"); |
| 1335 |
> |
system("attrib -r ../Oni.exe /s"); |
| 1336 |
> |
system("attrib -r ../binkw32.dll /s"); |
| 1337 |
> |
|
| 1338 |
|
#else |
| 1339 |
|
FILE *fUserName = NULL; |
| 1340 |
|
char chrUserName[32]; |
| 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 |
|
} |
| 1485 |
|
|
| 1486 |
|
ProcessPackageUpdates(strPathToEUFNPackages, strPathToPackages); |
| 1487 |
|
|
| 1488 |
< |
// Next, we get a list of which files and folders in the update's Globalize folder to move over; all files not starting with '.' will be moved... |
| 1489 |
< |
// ...and folders which do not exist in the current AE will be created there |
| 1490 |
< |
vector<string> foldersToMake, filesToMove; |
| 1491 |
< |
string thePath; |
| 1488 |
> |
// Next, move over files in the update's Globalize folder; subfolders which do not exist in the current AE will be created by Boost's... |
| 1489 |
> |
// ...create_directories() function |
| 1490 |
> |
string strPath; |
| 1491 |
> |
path thePath; |
| 1492 |
|
for (recursive_directory_iterator dir_itr(strPathToEUFNPackages + strGlobalize), end_itr; dir_itr != end_itr; ++dir_itr) |
| 1493 |
|
{ |
| 1494 |
< |
thePath = dir_itr->path().string(); |
| 1495 |
< |
MakePathLocalToGlobalize(&thePath); |
| 1494 |
> |
strPath = dir_itr->path().string(); |
| 1495 |
> |
MakePathLocalToGlobalize(&strPath); |
| 1496 |
> |
thePath = (path)strPath; |
| 1497 |
|
if (is_regular_file(dir_itr->status())) |
| 1498 |
|
{ |
| 1499 |
< |
if (dir_itr->filename().at(0) != '.') // skip over dot-files, which are invisible in Unix |
| 1500 |
< |
filesToMove.push_back(thePath); |
| 1501 |
< |
} |
| 1502 |
< |
else if (is_directory(dir_itr->status())) |
| 1490 |
< |
{ |
| 1491 |
< |
if (!exists(strPathToPackages + strGlobalize + thePath)) |
| 1492 |
< |
foldersToMake.push_back(thePath); |
| 1493 |
< |
} |
| 1494 |
< |
} |
| 1495 |
< |
// Sort the foldersToMake strings by length, which is a fast solution to the problem of "How do we make sure we create folder 'parent/'... |
| 1496 |
< |
// ...before folder 'parent/child/'"? |
| 1497 |
< |
sort(foldersToMake.begin(), foldersToMake.end(), SortBySize); // SortBySize is a custom comparison function found later in this source file |
| 1498 |
< |
// First make the folders that don't exist in the current AE, so all the files have a place to go |
| 1499 |
< |
for (vector<string>::iterator iter = foldersToMake.begin(); iter != foldersToMake.end(); iter++) |
| 1500 |
< |
{ |
| 1501 |
< |
create_directory(strPathToPackages + strGlobalize + *iter); |
| 1502 |
< |
} |
| 1503 |
< |
for (vector<string>::iterator iter = filesToMove.begin(); iter != filesToMove.end(); iter++) |
| 1504 |
< |
{ |
| 1505 |
< |
if (exists(strPathToPackages + strGlobalize + *iter)) |
| 1499 |
> |
if (thePath.filename().at(0) != '.') // skip over dot-files, which are invisible in Unix |
| 1500 |
> |
{ |
| 1501 |
> |
if (exists(strPathToPackages + strGlobalize + strPath)) |
| 1502 |
> |
{ |
| 1503 |
|
#ifdef WIN32 |
| 1504 |
< |
remove((path)(strPathToPackages + strGlobalize + *iter)); |
| 1504 |
> |
remove((path)(strPathToPackages + strGlobalize + strPath)); |
| 1505 |
|
#else |
| 1506 |
< |
rename((path)(strPathToPackages + strGlobalize + *iter), (path)(strTrashDir + *iter)); |
| 1506 |
> |
create_directories((path)(strTrashDir + thePath.parent_path().string())); |
| 1507 |
> |
rename((path)(strPathToPackages + strGlobalize + strPath), (path)(strTrashDir + strPath)); |
| 1508 |
|
#endif |
| 1509 |
< |
rename((path)(strPathToEUFNPackages + strGlobalize + *iter), (path)(strPathToPackages + strGlobalize + *iter)); |
| 1509 |
> |
rename((path)(strPathToEUFNPackages + strGlobalize + strPath), (path)(strPathToPackages + strGlobalize + strPath)); |
| 1510 |
> |
} |
| 1511 |
> |
else |
| 1512 |
> |
{ |
| 1513 |
> |
int slashLoc = 0; |
| 1514 |
> |
slashLoc = strPath.find("/", 0); |
| 1515 |
> |
if (slashLoc != string::npos) // then path contains slashes, so we need to make sure its parents' paths exist before moving it |
| 1516 |
> |
create_directories((path)(strPathToPackages + strGlobalize + thePath.parent_path().string())); |
| 1517 |
> |
rename((path)(strPathToEUFNPackages + strGlobalize + strPath), (path)(strPathToPackages + strGlobalize + strPath)); |
| 1518 |
> |
} |
| 1519 |
> |
} |
| 1520 |
> |
} |
| 1521 |
|
} |
| 1522 |
|
|
| 1523 |
|
// Clean up after ourselves, trashing any packages or programs in the update package that are not newer than the current AE |
| 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 |
|
} |
| 1547 |
– |
|
| 1561 |
|
} |
| 1562 |
|
|
| 1563 |
|
void ProcessPackageUpdates(string pathToUpdate, string strPathToPackages) |
| 1742 |
|
|
| 1743 |
|
} |
| 1744 |
|
else if(from_ph.filename() != ".svn") |
| 1745 |
< |
{ |
| 1746 |
< |
path destination; |
| 1747 |
< |
if(!exists(to_ph)) |
| 1748 |
< |
{ |
| 1749 |
< |
destination=to_ph; |
| 1750 |
< |
} |
| 1751 |
< |
else |
| 1752 |
< |
{ |
| 1753 |
< |
destination=to_ph/from_ph.filename(); |
| 1754 |
< |
} |
| 1745 |
> |
{ |
| 1746 |
> |
path destination; |
| 1747 |
> |
if(!exists(to_ph)) |
| 1748 |
> |
{ |
| 1749 |
> |
destination=to_ph; |
| 1750 |
> |
} |
| 1751 |
> |
else |
| 1752 |
> |
{ |
| 1753 |
> |
destination=to_ph/from_ph.filename(); |
| 1754 |
> |
} |
| 1755 |
|
|
| 1756 |
< |
for(directory_iterator i(from_ph); i!=directory_iterator(); ++i) |
| 1756 |
> |
for(directory_iterator i(from_ph); i!=directory_iterator(); ++i) |
| 1757 |
|
{ |
| 1758 |
|
//the idiot who coded this in the first place (not me) |
| 1759 |
|
//forgot to make a new directory. Exception city. x_x |
| 1760 |
< |
create_directory(destination); |
| 1761 |
< |
copy(*i,destination/i->filename()); |
| 1760 |
> |
create_directory(destination); |
| 1761 |
> |
copy(*i, destination/i->filename()); |
| 1762 |
|
} |
| 1763 |
|
} |
| 1764 |
|
} |