| 27 |
|
// externs declared in installer.h |
| 28 |
|
string strInstallCfg = "../GameDataFolder/Add.cfg"; |
| 29 |
|
string strEUFN = "Edition"; // GetUpdateStatus() may set this to "Edition-patch" later, but this is the assumed name of the new Edition folder in Updates/ |
| 30 |
+ |
extern MainWindow* TheWindow; |
| 31 |
|
|
| 32 |
|
int globalizeData(void) |
| 33 |
|
{ |
| 647 |
|
vector<string> skippedfolders; |
| 648 |
|
|
| 649 |
|
ofstream BSLlog("BSL.log"); |
| 650 |
+ |
if(exists("../GameDataFolder/BSLBackup/")) { |
| 651 |
+ |
remove_all("../GameDataFolder/BSLBackup/"); |
| 652 |
+ |
} |
| 653 |
+ |
else { |
| 654 |
+ |
create_directory("../GameDataFolder/BSLBackup/"); |
| 655 |
+ |
} |
| 656 |
+ |
copy("../GameDataFolder/IGMD/", "../GameDataFolder/BSLBackup/"); |
| 657 |
|
for ( directory_iterator dir_itr( "../GameDataFolder/IGMD/" ), end_itr; |
| 658 |
|
dir_itr != end_itr; |
| 659 |
|
++dir_itr ) { |
| 666 |
|
for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) |
| 667 |
|
for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages |
| 668 |
|
if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it |
| 669 |
< |
if(!(globalPackages[j].hasAddon || globalPackages[j].hasBSL)) break; //skip non-BSL |
| 669 |
> |
if(globalPackages[j].hasBSL) break; //skip non-BSL |
| 670 |
|
if( exists( "packages/" + globalPackages[j].modStringName + "/BSL/" ) ) { |
| 671 |
|
copyBSL("packages/" + globalPackages[j].modStringName + "/BSL", BSLfolders, globalPackages[j] ); |
| 672 |
|
BSLlog << "Copied " << globalPackages[j].modStringName << "!\n"; |
| 675 |
|
} |
| 676 |
|
} |
| 677 |
|
|
| 678 |
+ |
|
| 679 |
+ |
|
| 680 |
|
ModPackage emptyPackage; |
| 681 |
|
emptyPackage.modStringName = "VanillaBSL"; |
| 682 |
|
emptyPackage.hasBSL = 1; |
| 683 |
|
copyBSL("packages/VanillaBSL/IGMD", BSLfolders, emptyPackage); |
| 684 |
|
BSLlog.close(); |
| 685 |
< |
|
| 685 |
> |
|
| 686 |
> |
for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) |
| 687 |
> |
for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages |
| 688 |
> |
if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it |
| 689 |
> |
if(!globalPackages[j].hasAddon) break; //skip non-BSL |
| 690 |
> |
if( exists( "packages/" + globalPackages[j].modStringName + "/BSL/" ) ) { |
| 691 |
> |
copyBSL("packages/" + globalPackages[j].modStringName + "/BSL", BSLfolders, globalPackages[j] ); |
| 692 |
> |
BSLlog << "Copied " << globalPackages[j].modStringName << "!\n"; |
| 693 |
> |
} |
| 694 |
> |
} |
| 695 |
> |
} |
| 696 |
> |
} |
| 697 |
> |
|
| 698 |
|
logfile << "Writing config file"; |
| 699 |
|
writeInstalledMods(installedMods); |
| 700 |
|
setProgressBar(1000); |
| 735 |
|
if ( is_directory( dir_itr->path() ) && dir_itr->path().string() != ".svn" ) { |
| 736 |
|
BSLlog << "Testing " << dir_itr->path().string() << " HasBSL: " << pkg.hasBSL << " HasAddon: " << pkg.hasAddon << "\n"; |
| 737 |
|
int skip_folder = 0; |
| 738 |
< |
|
| 739 |
< |
for(unsigned int k = 0; k < BSLfolders.size(); k++) {//iterate through already found BSL folders |
| 740 |
< |
BSLlog << "testing " << dir_itr->path().filename() << " vs " << BSLfolders[k] << "\n"; |
| 741 |
< |
if(dir_itr->path().filename() == BSLfolders[k]) { |
| 742 |
< |
skip_folder = 1; |
| 743 |
< |
BSLlog << "skipping " << BSLfolders[k] << " in " << pkg.modStringName << "\n"; |
| 744 |
< |
break; |
| 738 |
> |
if(!pkg.hasAddon) { |
| 739 |
> |
for(unsigned int k = 0; k < BSLfolders.size(); k++) {//iterate through already found BSL folders |
| 740 |
> |
BSLlog << "testing " << dir_itr->path().filename() << " vs " << BSLfolders[k] << "\n"; |
| 741 |
> |
if(dir_itr->path().filename() == BSLfolders[k]) { |
| 742 |
> |
skip_folder = 1; |
| 743 |
> |
BSLlog << "skipping " << BSLfolders[k] << " in " << pkg.modStringName << "\n"; |
| 744 |
> |
break; |
| 745 |
> |
} |
| 746 |
|
} |
| 747 |
|
} |
| 748 |
|
if (!skip_folder && !exists("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/ignore.txt")) { |
| 757 |
|
copy_file(bsl_itr->path(), "../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); |
| 758 |
|
} |
| 759 |
|
} |
| 760 |
< |
BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon |
| 761 |
< |
BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ; |
| 760 |
> |
if( !pkg.hasAddon ) { |
| 761 |
> |
BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon |
| 762 |
> |
BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ; |
| 763 |
> |
} |
| 764 |
|
} |
| 765 |
|
} |
| 766 |
|
} |
| 866 |
|
return UPDATE_LOG_READ_ERR; |
| 867 |
|
} |
| 868 |
|
|
| 869 |
< |
// Is there an update folder, and is it a monthly release or a patch? |
| 869 |
> |
// Is there an update in the updates/ folder, and is it a monthly release or a patch? |
| 870 |
|
bool firstParty = 0; |
| 871 |
+ |
// First create the folder if it's missing, so users are never left wondering where updates are supposed to be put |
| 872 |
+ |
if (!exists("../updates")) |
| 873 |
+ |
create_directory("../updates"); |
| 874 |
|
if (exists("../updates/Edition")) |
| 875 |
|
{ |
| 876 |
|
firstParty = 1; |
| 1003 |
|
ModPackage installedPackage, updatePackage; |
| 1004 |
|
if (is_directory(install_iter->path()) && exists(install_iter->path().string() + "/Mod_Info.cfg")) |
| 1005 |
|
{ |
| 978 |
– |
string blah =install_iter->path().string() + "/Mod_Info.cfg"; |
| 979 |
– |
string blah2 = "packages/" + install_iter->path().filename() + "/Mod_Info.cfg"; |
| 1006 |
|
fstream file; |
| 1007 |
|
file.open((install_iter->path().string() + "/Mod_Info.cfg").c_str()); |
| 1008 |
|
if (!file.fail()) |
| 1296 |
|
|
| 1297 |
|
bool ProcessAEUpdate(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) |
| 1298 |
|
{ |
| 1299 |
+ |
try { |
| 1300 |
|
fstream file; |
| 1301 |
|
string line; |
| 1302 |
|
vector<string> tokens, updateStarted; |
| 1316 |
|
string strOniApp = "Oni.exe"; |
| 1317 |
|
#else |
| 1318 |
|
string strOniApp = "Oni.app"; |
| 1292 |
– |
#endif |
| 1319 |
|
bool needNewTrashDir = false; |
| 1320 |
+ |
#endif |
| 1321 |
+ |
|
| 1322 |
|
bool readingVerAndDate = false; |
| 1323 |
|
|
| 1324 |
|
#ifdef WIN32 |
| 1325 |
< |
string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted |
| 1325 |
> |
//string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted |
| 1326 |
|
#else |
| 1327 |
|
FILE *fUserName = NULL; |
| 1328 |
|
char chrUserName[32]; |
| 1357 |
|
if (readingVerAndDate && tokens.capacity() >= 3) |
| 1358 |
|
tokenize(tokens[2], updateStarted, "-"); |
| 1359 |
|
} |
| 1360 |
+ |
#ifndef WIN32 |
| 1361 |
|
if (updateStarted.capacity() < 3) |
| 1362 |
|
needNewTrashDir = true; |
| 1363 |
|
else |
| 1367 |
|
if (!exists(strTrashDir)) |
| 1368 |
|
needNewTrashDir = true; |
| 1369 |
|
} |
| 1370 |
+ |
#endif |
| 1371 |
|
} |
| 1372 |
|
#ifndef WIN32 |
| 1373 |
|
if (!*installerJustUpdated || needNewTrashDir) // prepare a new directory for deleted files to go to |
| 1384 |
|
// Special code to replace our special files -- the Oni app, OniSplit, the Daodan DLL, and the GUI for OniSplit |
| 1385 |
|
if (exists(strPathToEUFN + strOniApp)) |
| 1386 |
|
{ |
| 1387 |
< |
if (exists(strOniApp)) |
| 1388 |
< |
rename((path)strOniApp, (path)(strTrashDir + strOniApp)); |
| 1389 |
< |
rename((path)(strPathToEUFN + strOniApp), (path)strOniApp); |
| 1387 |
> |
if (exists("../" + strOniApp)) |
| 1388 |
> |
#ifdef WIN32 |
| 1389 |
> |
remove((path)("../" + strOniApp)); |
| 1390 |
> |
#else |
| 1391 |
> |
rename((path)("../" + strOniApp), (path)(strTrashDir + strOniApp)); |
| 1392 |
> |
#endif |
| 1393 |
> |
rename((path)(strPathToEUFN + strOniApp), (path)("../" + strOniApp)); |
| 1394 |
|
} |
| 1395 |
|
if (updateAE->OniSplitVersion.compare(currentAE->OniSplitVersion) >= 1) |
| 1396 |
|
{ |
| 1397 |
|
if (exists(strPathToEUFNInstall + strOniSplit)) |
| 1398 |
|
{ |
| 1399 |
|
if (exists(strOniSplit)) |
| 1400 |
+ |
#ifdef WIN32 |
| 1401 |
+ |
remove((path)strOniSplit); |
| 1402 |
+ |
#else |
| 1403 |
|
rename((path)strOniSplit, (path)(strTrashDir + strOniSplit)); |
| 1404 |
+ |
#endif |
| 1405 |
|
rename((path)(strPathToEUFNInstall + strOniSplit), (path)strOniSplit); |
| 1406 |
|
} |
| 1407 |
|
} |
| 1411 |
|
if (exists(strPathToEUFN + strDaodan)) |
| 1412 |
|
{ |
| 1413 |
|
if (exists(("../" + strDaodan))) |
| 1414 |
< |
rename((path)("../" + strDaodan), (path)(strTrashDir + strDaodan)); |
| 1414 |
> |
remove((path)("../" + strDaodan)); |
| 1415 |
|
rename((path)(strPathToEUFN + strDaodan), (path)("../" + strDaodan)); |
| 1416 |
|
} |
| 1417 |
|
} |
| 1420 |
|
if (exists(strPathToEUFNInstall + strWinGUI)) |
| 1421 |
|
{ |
| 1422 |
|
if (exists((path)strWinGUI)) |
| 1423 |
< |
rename((path)strWinGUI, (path)(strTrashDir + strWinGUI)); |
| 1423 |
> |
remove((path)strWinGUI); |
| 1424 |
|
if (exists(strWinGUILang)) |
| 1425 |
< |
rename((path)strWinGUILang, (path)(strTrashDir + strWinGUILang)); |
| 1425 |
> |
remove((path)strWinGUILang); |
| 1426 |
|
rename((path)(strPathToEUFNInstall + strWinGUI), (path)strWinGUI); |
| 1427 |
|
rename((path)(strPathToEUFNInstall + strWinGUILang), (path)strWinGUILang); |
| 1428 |
|
} |
| 1455 |
|
while (curPos != string::npos && curPos < thePath.size()) |
| 1456 |
|
{ |
| 1457 |
|
aParentPath = aParentPath + thePath.substr(lastPos, curPos - lastPos); |
| 1458 |
+ |
#ifndef WIN32 |
| 1459 |
|
if (!exists(strTrashDir + aParentPath)) |
| 1460 |
|
create_directory(strTrashDir + aParentPath); |
| 1461 |
+ |
#endif |
| 1462 |
|
lastPos = curPos + 1; |
| 1463 |
|
curPos = thePath.find("/", lastPos); |
| 1464 |
|
aParentPath = aParentPath + "/"; |
| 1503 |
|
for (vector<string>::iterator iter = filesToMove.begin(); iter != filesToMove.end(); iter++) |
| 1504 |
|
{ |
| 1505 |
|
if (exists(strPathToPackages + strGlobalize + *iter)) |
| 1506 |
+ |
#ifdef WIN32 |
| 1507 |
+ |
remove((path)(strPathToPackages + strGlobalize + *iter)); |
| 1508 |
+ |
#else |
| 1509 |
|
rename((path)(strPathToPackages + strGlobalize + *iter), (path)(strTrashDir + *iter)); |
| 1510 |
+ |
#endif |
| 1511 |
|
rename((path)(strPathToEUFNPackages + strGlobalize + *iter), (path)(strPathToPackages + strGlobalize + *iter)); |
| 1512 |
|
} |
| 1513 |
|
|
| 1514 |
|
// Clean up after ourselves, trashing any packages or programs in the update package that are not newer than the current AE |
| 1515 |
+ |
#ifdef WIN32 |
| 1516 |
+ |
remove_all((path)strPathToEUFN); |
| 1517 |
+ |
#else |
| 1518 |
|
create_directory(strTrashDir + "Unneeded update files"); |
| 1519 |
|
rename((path)strPathToEUFN, (path)(strTrashDir + "Unneeded update files/" + strEUFN)); |
| 1520 |
< |
|
| 1520 |
> |
#endif |
| 1521 |
|
// Write to log that we are finished with update |
| 1522 |
|
ptime end_time(second_clock::local_time()); |
| 1523 |
|
string progressMsg2 = "Edition was updated to:\n" + |
| 1535 |
|
CheckForGlobalization(true); // the 'true' value forces re-globalization |
| 1536 |
|
|
| 1537 |
|
globalPackages = getPackages(); // refresh the list in memory |
| 1491 |
– |
// TODO: Refresh the packages list in the window |
| 1538 |
|
wxCommandEvent e; |
| 1539 |
|
TheWindow->OnRefreshButtonClick( e ); |
| 1540 |
|
return true; |
| 1541 |
+ |
} |
| 1542 |
+ |
catch (exception & ex) |
| 1543 |
+ |
{ |
| 1544 |
+ |
setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 1545 |
+ |
return false; |
| 1546 |
+ |
} |
| 1547 |
+ |
|
| 1548 |
|
} |
| 1549 |
< |
extern MainWindow* TheWindow; |
| 1549 |
> |
|
| 1550 |
|
void ProcessPackageUpdates(string pathToUpdate, string strPathToPackages) |
| 1551 |
|
{ |
| 1552 |
|
ptime startTime(second_clock::local_time()); |