| 17 |
|
#include "boost/date_time/gregorian/gregorian.hpp" |
| 18 |
|
#include "boost/date_time/date_parsing.hpp" |
| 19 |
|
#include "boost/date_time/posix_time/posix_time.hpp" |
| 20 |
+ |
#include <boost/algorithm/string.hpp> |
| 21 |
|
#include "installer.h" |
| 22 |
|
#include "aeinstallerapp.h" |
| 23 |
|
|
| 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 |
|
{ |
| 232 |
|
|
| 233 |
|
|
| 234 |
|
if ( strcmp(levels[i].c_str(), "0") ){ |
| 235 |
< |
system((strOniSplit + " -move:overwrite ../GameDataFolder/level" + levels[i] + "_Final ../GameDataFolder/level" + levels[i] + "_Final/AKEV/AKEV*.oni").c_str()); |
| 235 |
> |
system((strOniSplit + " -move:overwrite ../GameDataFolder/level" + levels[i] + "_Final ../GameDataFolder/level" + levels[i] + |
| 236 |
> |
"_Final/AKEV/AKEV*.oni").c_str()); |
| 237 |
|
remove( "../GameDataFolder/level" + levels[i] + "_Final/AKEV" ); |
| 238 |
|
} |
| 239 |
|
|
| 247 |
|
for (int i = 0; i < 15; i++) |
| 248 |
|
{ |
| 249 |
|
logfile << "\tReimporting level" << levels[i] << "_Final.oni\n"; |
| 250 |
< |
setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " reimporting level" + levels[i]+"_Final.oni"); |
| 250 |
> |
setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " reimporting level" + |
| 251 |
> |
levels[i] + "_Final.oni"); |
| 252 |
|
logfile << (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level" |
| 253 |
|
+ levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize.log").c_str() << '\n'; |
| 254 |
|
string sys_str = (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level" |
| 273 |
|
setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + ": moving level0_Characters" ); |
| 274 |
|
copy((path)"../GameDataFolder/level0_Characters", (path)("VanillaDats/level0_Final")); |
| 275 |
|
GDFPaths.push_back( Characters ); |
| 276 |
+ |
//concactates level0.... |
| 277 |
|
for(int i = 0; i < GDFPaths.size(); i++) |
| 278 |
|
{ |
| 279 |
|
directory_iterator end_iter; |
| 288 |
|
} |
| 289 |
|
} |
| 290 |
|
} |
| 291 |
+ |
//?: syntax is fun. |
| 292 |
+ |
//condition ? value_if_true : value_if_false |
| 293 |
+ |
(is_empty(Characters) ? remove( Characters ) : 1); |
| 294 |
+ |
(is_empty(Particles) ? remove( Particles ) : 1); |
| 295 |
+ |
(is_empty(Textures) ? remove( Textures ) : 1); |
| 296 |
+ |
(is_empty(Sounds) ? remove( Sounds ) : 1); |
| 297 |
+ |
(is_empty(TRAC) ? remove( TRAC ) : 1); |
| 298 |
+ |
(is_empty(TRAM) ? remove( TRAM ) : 1); |
| 299 |
+ |
(is_empty(Animations) ? remove( Animations ) : 1); |
| 300 |
|
|
| 301 |
|
create_directory((path)"../GameDataFolder/IGMD"); |
| 302 |
|
copy((path)"packages/VanillaBSL/IGMD", (path)"../GameDataFolder"); |
| 303 |
|
setProgressBar( 1000 ); |
| 304 |
< |
|
| 305 |
< |
if(exists("../../persist.dat")) |
| 306 |
< |
if(!exists("../persist.dat")) |
| 307 |
< |
|
| 294 |
< |
//TODO: Concatenate level0 Dirs. |
| 295 |
< |
|
| 296 |
< |
copy("../../persist.dat",".."); |
| 297 |
< |
if(exists("../../key_config.txt")) |
| 298 |
< |
if(!exists("../key_config.txt")) |
| 299 |
< |
copy("../../key_config.txt",".."); |
| 300 |
< |
|
| 304 |
> |
|
| 305 |
> |
if(exists("../../persist.dat") && !exists("../persist.dat")) copy("../../persist.dat",".."); |
| 306 |
> |
if(exists("../../key_config.txt")&& !exists("../key_config.txt")) copy("../../key_config.txt",".."); |
| 307 |
> |
|
| 308 |
|
#ifndef WIN32 |
| 309 |
|
/* On Mac only, set the current GDF to the AE GDF by writing to Oni's global preferences file (thankfully a standard OS X ".plist" XML file). |
| 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 the folder that *contains* the GDF) |
| 313 |
< |
char prefsCommand[300] = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '"; |
| 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 |
< |
system(prefsCommand); |
| 317 |
> |
*/ |
| 318 |
> |
string prefsCommand = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '" |
| 319 |
> |
+ fullAEpath + "'"; |
| 320 |
> |
system(prefsCommand.c_str()); |
| 321 |
> |
|
| 322 |
|
#endif |
| 323 |
|
|
| 324 |
|
setStatusArea((string)"Done! Now select your mod packages and click install."); |
| 352 |
|
|
| 353 |
|
if (!file.fail()) |
| 354 |
|
{ |
| 355 |
< |
package = fileToModPackage(file); |
| 355 |
> |
package = fileToModPackage(file, dir_itr->path().filename()); |
| 356 |
|
if (package.installerVersion.compare(INSTALLER_VERSION) < 1) // if mod requires newer version of the Installer, we won't add it to the list |
| 357 |
|
{ |
| 358 |
|
#ifdef WIN32 |
| 376 |
|
return packages; |
| 377 |
|
} |
| 378 |
|
|
| 379 |
< |
ModPackage fileToModPackage(fstream &file) |
| 380 |
< |
{ |
| 369 |
< |
/* |
| 370 |
< |
This converts a file to a ModPackage struct. |
| 371 |
< |
|
| 372 |
< |
A few notes... |
| 373 |
< |
"iter" is the current word we are on. I should have named it "token" or something, but I don't have multiple iterators, so its ok. |
| 374 |
< |
I refer to (*iter) at the beginning of each if statement block. I could probably store it as a variable, but I'm pretty sure that dereferencing a pointer\iterator isn't much |
| 375 |
< |
slower than reading a variable. |
| 376 |
< |
*/ |
| 379 |
> |
ModPackage fileToModPackage(fstream &file, string modName) |
| 380 |
> |
{ |
| 381 |
|
ModPackage package; |
| 382 |
|
string line; |
| 383 |
< |
static string AEInstallVersion = "AEInstallVersion"; // used for comparing to the current token... |
| 384 |
< |
static string NameOfMod = "NameOfMod"; |
| 385 |
< |
static string ARROW = "->"; |
| 386 |
< |
static string ModString = "ModString"; |
| 387 |
< |
static string Platform = "Platform"; |
| 388 |
< |
static string HasOnis = "HasOnis"; |
| 389 |
< |
static string HasDeltas = "HasDeltas"; |
| 390 |
< |
static string HasBSL = "HasBSL"; |
| 391 |
< |
static string HasDats = "HasDats"; |
| 392 |
< |
static string IsEngine = "IsEngine"; |
| 393 |
< |
static string Readme = "Readme"; |
| 394 |
< |
static string GlobalNeeded = "GlobalNeeded"; |
| 395 |
< |
static string Category = "Category"; |
| 396 |
< |
static string Creator = "Creator"; |
| 383 |
> |
const string AEInstallVersion = "AEInstallVersion"; // used for comparing to the current token... |
| 384 |
> |
const string NameOfMod = "NameOfMod"; |
| 385 |
> |
const string ARROW = "->"; |
| 386 |
> |
const string ModString = "ModString"; |
| 387 |
> |
const string ModVersion = "ModVersion"; |
| 388 |
> |
const string Platform = "Platform"; |
| 389 |
> |
const string HasOnis = "HasOnis"; |
| 390 |
> |
const string HasDeltas = "HasDeltas"; |
| 391 |
> |
const string HasBSL = "HasBSL"; |
| 392 |
> |
const string HasDats = "HasDats"; |
| 393 |
> |
const string IsEngine = "IsEngine"; |
| 394 |
> |
const string Readme = "Readme"; |
| 395 |
> |
const string GlobalNeeded = "GlobalNeeded"; |
| 396 |
> |
const string Category = "Category"; |
| 397 |
> |
const string Creator = "Creator"; |
| 398 |
> |
package.modStringName = modName; |
| 399 |
|
while (!file.eof()) |
| 400 |
|
{ |
| 401 |
|
getline(file,line); |
| 422 |
|
else if (!ModString.compare(*iter)) |
| 423 |
|
{ |
| 424 |
|
iter++; iter++; |
| 425 |
< |
package.modStringName = *iter; |
| 425 |
> |
//package.modStringName = *iter; |
| 426 |
|
iter++; |
| 427 |
< |
package.modStringVersion = atoi((*iter).c_str()); |
| 427 |
> |
package.modStringVersion = atof((*iter).c_str()); |
| 428 |
> |
} |
| 429 |
> |
else if (!ModString.compare(*iter)) |
| 430 |
> |
{ |
| 431 |
> |
iter++; iter++; |
| 432 |
> |
package.modStringVersion = atof((*iter).c_str()); |
| 433 |
|
} |
| 434 |
|
else if (!Platform.compare(*iter)) |
| 435 |
|
{ |
| 444 |
|
else if (!HasBSL.compare(*iter)) |
| 445 |
|
{ |
| 446 |
|
iter++; iter++; |
| 447 |
< |
if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasBSL = true; |
| 447 |
> |
if (boost::iequals(*iter, "Yes")) package.hasBSL = true; |
| 448 |
|
else if (boost::iequals(*iter, "Addon")) package.hasAddon = true; |
| 449 |
|
} |
| 450 |
|
else if (!HasDeltas.compare(*iter)) |
| 569 |
|
|
| 570 |
|
|
| 571 |
|
setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats |
| 572 |
< |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); |
| 572 |
> |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + |
| 573 |
> |
dir_itr->path().filename() + " "); |
| 574 |
|
|
| 575 |
|
system(importCommand.c_str()); |
| 576 |
|
j++; |
| 626 |
|
importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log"; |
| 627 |
|
|
| 628 |
|
setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats |
| 629 |
< |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); |
| 629 |
> |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + |
| 630 |
> |
dir_itr->path().filename() + " "); |
| 631 |
|
system(importCommand.c_str()); |
| 632 |
|
j++; |
| 633 |
|
} |
| 704 |
|
|
| 705 |
|
void copyBSL(string copypath, vector<string>& BSLfolders, ModPackage pkg) |
| 706 |
|
{ |
| 707 |
< |
ofstream BSLlog("BSL2.log", ios::app ); |
| 707 |
> |
ofstream BSLlog("BSL.log", ios::app ); |
| 708 |
|
|
| 709 |
|
try { |
| 710 |
|
for ( directory_iterator dir_itr( copypath ), end_itr; |
| 735 |
|
copy_file(bsl_itr->path(), "../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); |
| 736 |
|
} |
| 737 |
|
} |
| 738 |
< |
BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon |
| 739 |
< |
BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ; |
| 738 |
> |
if( !pkg.hasAddon ) { |
| 739 |
> |
BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon |
| 740 |
> |
BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ; |
| 741 |
> |
} |
| 742 |
|
} |
| 743 |
|
} |
| 744 |
|
} |
| 814 |
|
| Installer to be replaced (when the new Installer | |
| 815 |
|
| launches, this function will be called again but will | |
| 816 |
|
| return UPDATE_SIMP_AVAIL or UPDATE_GLOB_AVAIL) | |
| 817 |
+ |
| UPDATE_PKG_AVAIL -- A newer version of individual package(s) is available | |
| 818 |
|
\* UPDATE_CONT_UPD -- Currently unused */ |
| 819 |
|
int GetUpdateStatus(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) |
| 820 |
|
{ |
| 843 |
|
else |
| 844 |
|
return UPDATE_LOG_READ_ERR; |
| 845 |
|
} |
| 846 |
< |
|
| 847 |
< |
// Is there an update folder, and is it a monthly release or a patch? |
| 848 |
< |
if (!exists("../updates/Edition")) |
| 846 |
> |
|
| 847 |
> |
// Is there an update in the updates/ folder, and is it a monthly release or a patch? |
| 848 |
> |
bool firstParty = 0; |
| 849 |
> |
// First create the folder if it's missing, so users are never left wondering where updates are supposed to be put |
| 850 |
> |
if (!exists("../updates")) |
| 851 |
> |
create_directory("../updates"); |
| 852 |
> |
if (exists("../updates/Edition")) |
| 853 |
|
{ |
| 854 |
+ |
firstParty = 1; |
| 855 |
+ |
} |
| 856 |
+ |
else { |
| 857 |
|
strEUFN = "Edition-patch"; |
| 858 |
< |
if (!exists("../updates/Edition-patch")) |
| 859 |
< |
return UPDATE_NO_UPD_AVAIL; |
| 858 |
> |
if (exists("../updates/Edition-patch")) { |
| 859 |
> |
firstParty = 1; |
| 860 |
> |
} |
| 861 |
> |
|
| 862 |
|
} |
| 863 |
< |
|
| 864 |
< |
// Unlike the current AE's version info, we *need* to find the update's version info or we won't continue |
| 865 |
< |
string updateCfgPath = ("../updates/" + strEUFN + "/install/packages/Globalize/Install_Info.cfg"); |
| 866 |
< |
updateAECfg.open(updateCfgPath.c_str()); |
| 867 |
< |
if (!updateAECfg.fail()) |
| 868 |
< |
{ |
| 869 |
< |
if (!ReadInstallInfoCfg(&updateAECfg, updateAE)) |
| 863 |
> |
|
| 864 |
> |
if(firstParty) { |
| 865 |
> |
// Unlike the current AE's version info, we *need* to find the update's version info or we won't continue |
| 866 |
> |
string updateCfgPath = ("../updates/" + strEUFN + "/install/packages/Globalize/Install_Info.cfg"); |
| 867 |
> |
updateAECfg.open(updateCfgPath.c_str()); |
| 868 |
> |
if (!updateAECfg.fail()) |
| 869 |
> |
{ |
| 870 |
> |
if (!ReadInstallInfoCfg(&updateAECfg, updateAE)) |
| 871 |
> |
return UPDATE_LOG_READ_ERR; |
| 872 |
> |
|
| 873 |
> |
updateAECfg.close(); |
| 874 |
> |
updateAECfg.clear(); |
| 875 |
> |
} |
| 876 |
> |
else |
| 877 |
|
return UPDATE_LOG_READ_ERR; |
| 846 |
– |
|
| 847 |
– |
updateAECfg.close(); |
| 848 |
– |
updateAECfg.clear(); |
| 849 |
– |
} |
| 850 |
– |
else |
| 851 |
– |
return UPDATE_LOG_READ_ERR; |
| 878 |
|
|
| 879 |
< |
// Now we check for an Installer update in progress |
| 880 |
< |
if (exists("Update.log")) |
| 881 |
< |
{ |
| 882 |
< |
updateLog.open("Update.log"); |
| 883 |
< |
if (!updateLog.fail()) |
| 858 |
< |
{ |
| 859 |
< |
vector<string> lines; |
| 860 |
< |
string line; |
| 861 |
< |
int num_lines = 0; |
| 862 |
< |
bool readingInstallerVersion = false, doneReadingFile = false; |
| 863 |
< |
|
| 864 |
< |
while (!updateLog.eof() && !doneReadingFile) |
| 879 |
> |
// Now we check for an Installer update in progress |
| 880 |
> |
if (exists("Update.log")) |
| 881 |
> |
{ |
| 882 |
> |
updateLog.open("Update.log"); |
| 883 |
> |
if (!updateLog.fail()) |
| 884 |
|
{ |
| 885 |
< |
getline(updateLog, line); |
| 886 |
< |
lines.push_back(line); |
| 887 |
< |
num_lines++; |
| 888 |
< |
vector<string> tokens; |
| 889 |
< |
vector<string>::iterator iter; |
| 890 |
< |
tokenize(line, tokens); |
| 872 |
< |
iter = tokens.begin(); |
| 873 |
< |
if (!readingInstallerVersion && tokens.capacity() >= 4) |
| 885 |
> |
vector<string> lines; |
| 886 |
> |
string line; |
| 887 |
> |
int num_lines = 0; |
| 888 |
> |
bool readingInstallerVersion = false, doneReadingFile = false; |
| 889 |
> |
|
| 890 |
> |
while (!updateLog.eof() && !doneReadingFile) |
| 891 |
|
{ |
| 892 |
< |
if (!strInstaller.compare(*iter)) |
| 892 |
> |
getline(updateLog, line); |
| 893 |
> |
lines.push_back(line); |
| 894 |
> |
num_lines++; |
| 895 |
> |
vector<string> tokens; |
| 896 |
> |
vector<string>::iterator iter; |
| 897 |
> |
tokenize(line, tokens); |
| 898 |
> |
iter = tokens.begin(); |
| 899 |
> |
if (!readingInstallerVersion && tokens.capacity() >= 4) |
| 900 |
|
{ |
| 901 |
< |
if (!strBeing.compare(*++iter)) |
| 902 |
< |
readingInstallerVersion = true; |
| 903 |
< |
else if (!strWas.compare(*iter)) |
| 904 |
< |
*installerJustUpdated = true; // our third indirect return value after currentAE and updateAE |
| 901 |
> |
if (!strInstaller.compare(*iter)) |
| 902 |
> |
{ |
| 903 |
> |
if (!strBeing.compare(*++iter)) |
| 904 |
> |
readingInstallerVersion = true; |
| 905 |
> |
else if (!strWas.compare(*iter)) |
| 906 |
> |
*installerJustUpdated = true; // our third indirect return value after currentAE and updateAE |
| 907 |
> |
} |
| 908 |
|
} |
| 909 |
< |
} |
| 883 |
< |
else if (readingInstallerVersion && tokens.capacity() >= 3) |
| 884 |
< |
{ |
| 885 |
< |
readingInstallerVersion = false; |
| 886 |
< |
string installerVersion = INSTALLER_VERSION; |
| 887 |
< |
if (installerVersion.compare(*iter)) // then the shell script-powered replacement failed |
| 888 |
< |
return UPDATE_INST_REPL_ERR; |
| 889 |
< |
else |
| 909 |
> |
else if (readingInstallerVersion && tokens.capacity() >= 3) |
| 910 |
|
{ |
| 911 |
< |
updateLog.close(); |
| 912 |
< |
updateLog.clear(); |
| 913 |
< |
Sleep(1000); |
| 914 |
< |
remove("Update.log"); |
| 915 |
< |
ofstream newUpdateLog("Update.log"); |
| 896 |
< |
if (!newUpdateLog.fail()) |
| 911 |
> |
readingInstallerVersion = false; |
| 912 |
> |
string installerVersion = INSTALLER_VERSION; |
| 913 |
> |
if (installerVersion.compare(*iter)) // then the shell script-powered replacement failed |
| 914 |
> |
return UPDATE_INST_REPL_ERR; |
| 915 |
> |
else |
| 916 |
|
{ |
| 917 |
< |
// Write over old log with updated information |
| 918 |
< |
ptime startTime(second_clock::local_time()); |
| 919 |
< |
string strStartTime = to_simple_string(startTime); |
| 920 |
< |
string newUpdateLine = installerVersion + " on " + strStartTime; |
| 921 |
< |
for (int a = 0; a < lines.capacity() - 2; a++) // if there were even lines in the log before this at all |
| 917 |
> |
updateLog.close(); |
| 918 |
> |
updateLog.clear(); |
| 919 |
> |
Sleep(1000); |
| 920 |
> |
remove("Update.log"); |
| 921 |
> |
ofstream newUpdateLog("Update.log"); |
| 922 |
> |
if (!newUpdateLog.fail()) |
| 923 |
|
{ |
| 924 |
< |
newUpdateLog << lines[a].c_str(); |
| 925 |
< |
newUpdateLog << "\n"; |
| 924 |
> |
// Write over old log with updated information |
| 925 |
> |
ptime startTime(second_clock::local_time()); |
| 926 |
> |
string strStartTime = to_simple_string(startTime); |
| 927 |
> |
string newUpdateLine = installerVersion + " on " + strStartTime; |
| 928 |
> |
for (int a = 0; a < lines.capacity() - 2; a++) // if there were even lines in the log before this at all |
| 929 |
> |
{ |
| 930 |
> |
newUpdateLog << lines[a].c_str(); |
| 931 |
> |
newUpdateLog << "\n"; |
| 932 |
> |
} |
| 933 |
> |
newUpdateLog << "Installer was updated to:\n"; |
| 934 |
> |
newUpdateLog << newUpdateLine.c_str(); |
| 935 |
> |
*installerJustUpdated = true; // this value is indirectly returned to AEInstallerApp::OnInit() |
| 936 |
> |
doneReadingFile = true; |
| 937 |
> |
newUpdateLog.close(); |
| 938 |
> |
newUpdateLog.clear(); |
| 939 |
> |
//return UPDATE_CONT_UPD; // as noted above, we are not using this return value; in fact, we want... |
| 940 |
> |
// ...the code to continue running down through the Edition version check |
| 941 |
|
} |
| 942 |
< |
newUpdateLog << "Installer was updated to:\n"; |
| 943 |
< |
newUpdateLog << newUpdateLine.c_str(); |
| 909 |
< |
*installerJustUpdated = true; // this value is indirectly returned to AEInstallerAp::OnInit() |
| 910 |
< |
doneReadingFile = true; |
| 911 |
< |
newUpdateLog.close(); |
| 912 |
< |
newUpdateLog.clear(); |
| 913 |
< |
//return UPDATE_CONT_UPD; // as noted above, we are not using this return value; in fact, we want... |
| 914 |
< |
// ...the code to continue running down through the Edition version check |
| 942 |
> |
else |
| 943 |
> |
return UPDATE_LOG_READ_ERR; |
| 944 |
|
} |
| 916 |
– |
else |
| 917 |
– |
return UPDATE_LOG_READ_ERR; |
| 945 |
|
} |
| 946 |
|
} |
| 947 |
+ |
updateLog.close(); |
| 948 |
+ |
updateLog.clear(); |
| 949 |
|
} |
| 950 |
< |
updateLog.close(); |
| 951 |
< |
updateLog.clear(); |
| 950 |
> |
else |
| 951 |
> |
return UPDATE_LOG_READ_ERR; |
| 952 |
|
} |
| 953 |
< |
else |
| 954 |
< |
return UPDATE_LOG_READ_ERR; |
| 926 |
< |
} |
| 927 |
< |
|
| 928 |
< |
if (updateAE->AEVersion.compare(currentAE->AEVersion) >= 1) // is the release update newer than what's installed? |
| 929 |
< |
{ |
| 930 |
< |
if (!strEUFN.compare("Edition-patch")) // if update is a patch... |
| 953 |
> |
|
| 954 |
> |
if (updateAE->AEVersion.compare(currentAE->AEVersion) >= 1) // is the release update newer than what's installed? |
| 955 |
|
{ |
| 956 |
< |
if (currentAE->AEVersion.compare(updateAE->AEVersion.substr(0, updateAE->AEVersion.length() - 1))) // ...is it for a different month? |
| 957 |
< |
return UPDATE_MNTH_REQD_ERR; |
| 956 |
> |
if (!strEUFN.compare("Edition-patch")) // if update is a patch... |
| 957 |
> |
{ |
| 958 |
> |
if (currentAE->AEVersion.compare(updateAE->AEVersion.substr(0, updateAE->AEVersion.length() - 1))) // ...is it for a different month? |
| 959 |
> |
return UPDATE_MNTH_REQD_ERR; |
| 960 |
> |
} |
| 961 |
> |
string strNewInstallerPath = "../updates/" + strEUFN + "/install/" + strInstallerName; |
| 962 |
> |
string installerVersion = INSTALLER_VERSION; |
| 963 |
> |
if (updateAE->InstallerVersion.compare(installerVersion) >= 1) |
| 964 |
> |
{ |
| 965 |
> |
if (exists(strNewInstallerPath)) |
| 966 |
> |
return UPDATE_INST_AVAIL; |
| 967 |
> |
} |
| 968 |
> |
else if (updateAE->globalizationRequired) |
| 969 |
> |
return UPDATE_GLOB_AVAIL; |
| 970 |
> |
else |
| 971 |
> |
return UPDATE_SIMP_AVAIL; |
| 972 |
|
} |
| 973 |
< |
string strNewInstallerPath = "../updates/" + strEUFN + "/install/" + strInstallerName; |
| 974 |
< |
string installerVersion = INSTALLER_VERSION; |
| 975 |
< |
if (updateAE->InstallerVersion.compare(installerVersion) >= 1) |
| 973 |
> |
} |
| 974 |
> |
try |
| 975 |
> |
{ |
| 976 |
> |
directory_iterator end; |
| 977 |
> |
if (exists("../updates")) |
| 978 |
|
{ |
| 979 |
< |
if (exists(strNewInstallerPath)) |
| 980 |
< |
return UPDATE_INST_AVAIL; |
| 979 |
> |
for (directory_iterator install_iter("../updates"); install_iter != end; ++install_iter) |
| 980 |
> |
{ |
| 981 |
> |
ModPackage installedPackage, updatePackage; |
| 982 |
> |
if (is_directory(install_iter->path()) && exists(install_iter->path().string() + "/Mod_Info.cfg")) |
| 983 |
> |
{ |
| 984 |
> |
fstream file; |
| 985 |
> |
file.open((install_iter->path().string() + "/Mod_Info.cfg").c_str()); |
| 986 |
> |
if (!file.fail()) |
| 987 |
> |
updatePackage = fileToModPackage(file, install_iter->path().filename()); |
| 988 |
> |
else |
| 989 |
> |
{ |
| 990 |
> |
file.close(); |
| 991 |
> |
continue; |
| 992 |
> |
} |
| 993 |
> |
if (exists("packages/" + install_iter->path().filename() + "/Mod_Info.cfg")) |
| 994 |
> |
{ |
| 995 |
> |
file.close(); |
| 996 |
> |
file.clear(); |
| 997 |
> |
file.open(("packages/" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); |
| 998 |
> |
if (!file.fail()) |
| 999 |
> |
installedPackage = fileToModPackage(file, install_iter->path().filename()); |
| 1000 |
> |
file.close(); |
| 1001 |
> |
if (updatePackage.modStringVersion > installedPackage.modStringVersion) |
| 1002 |
> |
{ |
| 1003 |
> |
if (updatePackage.installerVersion <= INSTALLER_VERSION) |
| 1004 |
> |
return UPDATE_PKG_AVAIL; |
| 1005 |
> |
} |
| 1006 |
> |
} |
| 1007 |
> |
else |
| 1008 |
> |
{ |
| 1009 |
> |
file.close(); |
| 1010 |
> |
return UPDATE_PKG_AVAIL; |
| 1011 |
> |
} |
| 1012 |
> |
} |
| 1013 |
> |
} |
| 1014 |
|
} |
| 942 |
– |
else if (updateAE->globalizationRequired) |
| 943 |
– |
return UPDATE_GLOB_AVAIL; |
| 944 |
– |
else |
| 945 |
– |
return UPDATE_SIMP_AVAIL; |
| 1015 |
|
} |
| 1016 |
< |
else |
| 1017 |
< |
return UPDATE_NO_UPD_AVAIL; |
| 1018 |
< |
|
| 1016 |
> |
catch (exception & ex) { |
| 1017 |
> |
// setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 1018 |
> |
} |
| 1019 |
> |
|
| 1020 |
|
return UPDATE_NO_UPD_AVAIL; |
| 1021 |
|
} |
| 1022 |
|
|
| 1030 |
|
string strDaodanVersion = "Daodan_Version"; |
| 1031 |
|
string strOniSplitVersion = "OniSplit_Version"; |
| 1032 |
|
string strGUIWinVersion = "GUI_Win_Version"; |
| 1033 |
< |
string strGUIMacVersion = "GUI_Mac_Version"; |
| 1033 |
> |
string strGUIMacVersion = "GUI_Mac_Version"; |
| 1034 |
|
string strReglobalize = "Reglobalize"; |
| 1035 |
|
string strDeleteList = "Delete_List"; |
| 1036 |
|
string strArrow = "->"; |
| 1242 |
|
|
| 1243 |
|
string popenCommand = "../updates/" + strEUFN + "/install/"; |
| 1244 |
|
#ifdef WIN32 |
| 1175 |
– |
// TODO: Fill in Windows equivalent of code below :-3 |
| 1245 |
|
popenCommand = "replace_installer.bat"; |
| 1246 |
|
#else |
| 1247 |
|
// We can't just use '~' to mean "the home directory" because we need to check the path in C... |
| 1274 |
|
|
| 1275 |
|
bool ProcessAEUpdate(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) |
| 1276 |
|
{ |
| 1277 |
+ |
try { |
| 1278 |
|
fstream file; |
| 1279 |
|
string line; |
| 1280 |
|
vector<string> tokens, updateStarted; |
| 1294 |
|
string strOniApp = "Oni.exe"; |
| 1295 |
|
#else |
| 1296 |
|
string strOniApp = "Oni.app"; |
| 1227 |
– |
#endif |
| 1297 |
|
bool needNewTrashDir = false; |
| 1298 |
+ |
#endif |
| 1299 |
+ |
|
| 1300 |
|
bool readingVerAndDate = false; |
| 1301 |
|
|
| 1231 |
– |
// TODO: Fill in Windows equivalent of code below |
| 1302 |
|
#ifdef WIN32 |
| 1303 |
< |
string strTrashDir = "Trash\\"; |
| 1303 |
> |
//string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted |
| 1304 |
|
#else |
| 1305 |
|
FILE *fUserName = NULL; |
| 1306 |
|
char chrUserName[32]; |
| 1335 |
|
if (readingVerAndDate && tokens.capacity() >= 3) |
| 1336 |
|
tokenize(tokens[2], updateStarted, "-"); |
| 1337 |
|
} |
| 1338 |
+ |
#ifndef WIN32 |
| 1339 |
|
if (updateStarted.capacity() < 3) |
| 1340 |
|
needNewTrashDir = true; |
| 1341 |
|
else |
| 1345 |
|
if (!exists(strTrashDir)) |
| 1346 |
|
needNewTrashDir = true; |
| 1347 |
|
} |
| 1348 |
+ |
#endif |
| 1349 |
|
} |
| 1350 |
|
#ifndef WIN32 |
| 1351 |
|
if (!*installerJustUpdated || needNewTrashDir) // prepare a new directory for deleted files to go to |
| 1363 |
|
if (exists(strPathToEUFN + strOniApp)) |
| 1364 |
|
{ |
| 1365 |
|
if (exists(strOniApp)) |
| 1366 |
+ |
#ifdef WIN32 |
| 1367 |
+ |
remove((path)strOniApp); |
| 1368 |
+ |
#else |
| 1369 |
|
rename((path)strOniApp, (path)(strTrashDir + strOniApp)); |
| 1370 |
+ |
#endif |
| 1371 |
|
rename((path)(strPathToEUFN + strOniApp), (path)strOniApp); |
| 1372 |
|
} |
| 1373 |
|
if (updateAE->OniSplitVersion.compare(currentAE->OniSplitVersion) >= 1) |
| 1375 |
|
if (exists(strPathToEUFNInstall + strOniSplit)) |
| 1376 |
|
{ |
| 1377 |
|
if (exists(strOniSplit)) |
| 1378 |
+ |
#ifdef WIN32 |
| 1379 |
+ |
remove((path)strOniSplit); |
| 1380 |
+ |
#else |
| 1381 |
|
rename((path)strOniSplit, (path)(strTrashDir + strOniSplit)); |
| 1382 |
+ |
#endif |
| 1383 |
|
rename((path)(strPathToEUFNInstall + strOniSplit), (path)strOniSplit); |
| 1384 |
|
} |
| 1385 |
|
} |
| 1389 |
|
if (exists(strPathToEUFN + strDaodan)) |
| 1390 |
|
{ |
| 1391 |
|
if (exists(("../" + strDaodan))) |
| 1392 |
< |
rename((path)("../" + strDaodan), (path)(strTrashDir + strDaodan)); |
| 1392 |
> |
remove((path)("../" + strDaodan)); |
| 1393 |
|
rename((path)(strPathToEUFN + strDaodan), (path)("../" + strDaodan)); |
| 1394 |
|
} |
| 1395 |
|
} |
| 1398 |
|
if (exists(strPathToEUFNInstall + strWinGUI)) |
| 1399 |
|
{ |
| 1400 |
|
if (exists((path)strWinGUI)) |
| 1401 |
< |
rename((path)strWinGUI, (path)(strTrashDir + strWinGUI)); |
| 1401 |
> |
remove((path)strWinGUI); |
| 1402 |
|
if (exists(strWinGUILang)) |
| 1403 |
< |
rename((path)strWinGUILang, (path)(strTrashDir + strWinGUILang)); |
| 1403 |
> |
remove((path)strWinGUILang); |
| 1404 |
|
rename((path)(strPathToEUFNInstall + strWinGUI), (path)strWinGUI); |
| 1405 |
|
rename((path)(strPathToEUFNInstall + strWinGUILang), (path)strWinGUILang); |
| 1406 |
|
} |
| 1433 |
|
while (curPos != string::npos && curPos < thePath.size()) |
| 1434 |
|
{ |
| 1435 |
|
aParentPath = aParentPath + thePath.substr(lastPos, curPos - lastPos); |
| 1436 |
+ |
#ifndef WIN32 |
| 1437 |
|
if (!exists(strTrashDir + aParentPath)) |
| 1438 |
|
create_directory(strTrashDir + aParentPath); |
| 1439 |
+ |
#endif |
| 1440 |
|
lastPos = curPos + 1; |
| 1441 |
|
curPos = thePath.find("/", lastPos); |
| 1442 |
|
aParentPath = aParentPath + "/"; |
| 1449 |
|
} |
| 1450 |
|
} |
| 1451 |
|
|
| 1452 |
< |
// Now we crawl the update's package folders for newer versions and move them over, trashing ones that are already present |
| 1371 |
< |
vector<ModPackage> updatePackages, currentPackages; |
| 1372 |
< |
bool matchFound; |
| 1373 |
< |
updatePackages.reserve(256); |
| 1374 |
< |
currentPackages.reserve(256); |
| 1375 |
< |
|
| 1376 |
< |
currentPackages = getPackages(); |
| 1377 |
< |
updatePackages = getPackages(strPathToEUFNPackages); |
| 1378 |
< |
|
| 1379 |
< |
for (vector<ModPackage>::iterator iter1 = updatePackages.begin(); iter1 != updatePackages.end(); iter1++) |
| 1380 |
< |
{ |
| 1381 |
< |
matchFound = false; |
| 1382 |
< |
for (vector<ModPackage>::iterator iter2 = currentPackages.begin(); iter2 != currentPackages.end(); iter2++) |
| 1383 |
< |
{ |
| 1384 |
< |
if (!iter1->modStringName.compare(iter2->modStringName)) |
| 1385 |
< |
{ |
| 1386 |
< |
matchFound = true; |
| 1387 |
< |
if (iter1->modStringVersion > iter2->modStringVersion) |
| 1388 |
< |
{ |
| 1389 |
< |
#ifndef WIN32 |
| 1390 |
< |
rename((path)(strPathToPackages + iter2->modStringName), (path)(strTrashDir + iter2->modStringName)); |
| 1391 |
< |
#else |
| 1392 |
< |
remove((path)(strPathToPackages + iter2->modStringName)); |
| 1393 |
< |
#endif |
| 1394 |
< |
rename((path)(strPathToEUFNPackages + iter1->modStringName), (path)(strPathToPackages + iter1->modStringName)); |
| 1395 |
< |
} |
| 1396 |
< |
} |
| 1397 |
< |
} |
| 1398 |
< |
if (!matchFound) // then there's no old package in the way, so just move in the one from the update |
| 1399 |
< |
rename((path)(strPathToEUFNPackages + iter1->modStringName), (path)(strPathToPackages + iter1->modStringName)); |
| 1400 |
< |
} |
| 1452 |
> |
ProcessPackageUpdates(strPathToEUFNPackages, strPathToPackages); |
| 1453 |
|
|
| 1454 |
|
// 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... |
| 1455 |
|
// ...and folders which do not exist in the current AE will be created there |
| 1481 |
|
for (vector<string>::iterator iter = filesToMove.begin(); iter != filesToMove.end(); iter++) |
| 1482 |
|
{ |
| 1483 |
|
if (exists(strPathToPackages + strGlobalize + *iter)) |
| 1484 |
+ |
#ifdef WIN32 |
| 1485 |
+ |
remove((path)(strPathToPackages + strGlobalize + *iter)); |
| 1486 |
+ |
#else |
| 1487 |
|
rename((path)(strPathToPackages + strGlobalize + *iter), (path)(strTrashDir + *iter)); |
| 1488 |
+ |
#endif |
| 1489 |
|
rename((path)(strPathToEUFNPackages + strGlobalize + *iter), (path)(strPathToPackages + strGlobalize + *iter)); |
| 1490 |
|
} |
| 1491 |
|
|
| 1492 |
|
// Clean up after ourselves, trashing any packages or programs in the update package that are not newer than the current AE |
| 1493 |
+ |
#ifdef WIN32 |
| 1494 |
+ |
remove((path)strPathToEUFN); |
| 1495 |
+ |
#else |
| 1496 |
|
create_directory(strTrashDir + "Unneeded update files"); |
| 1497 |
|
rename((path)strPathToEUFN, (path)(strTrashDir + "Unneeded update files/" + strEUFN)); |
| 1498 |
< |
|
| 1498 |
> |
#endif |
| 1499 |
|
// Write to log that we are finished with update |
| 1500 |
|
ptime end_time(second_clock::local_time()); |
| 1501 |
|
string progressMsg2 = "Edition was updated to:\n" + |
| 1513 |
|
CheckForGlobalization(true); // the 'true' value forces re-globalization |
| 1514 |
|
|
| 1515 |
|
globalPackages = getPackages(); // refresh the list in memory |
| 1516 |
+ |
wxCommandEvent e; |
| 1517 |
+ |
TheWindow->OnRefreshButtonClick( e ); |
| 1518 |
+ |
return true; |
| 1519 |
+ |
} |
| 1520 |
+ |
catch (exception & ex) |
| 1521 |
+ |
{ |
| 1522 |
+ |
setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 1523 |
+ |
return false; |
| 1524 |
+ |
} |
| 1525 |
|
|
| 1526 |
< |
// TODO: Refresh the packages list in the window |
| 1526 |
> |
} |
| 1527 |
|
|
| 1528 |
< |
return true; |
| 1528 |
> |
void ProcessPackageUpdates(string pathToUpdate, string strPathToPackages) |
| 1529 |
> |
{ |
| 1530 |
> |
ptime startTime(second_clock::local_time()); |
| 1531 |
> |
#ifdef WIN32 |
| 1532 |
> |
string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted |
| 1533 |
> |
#else |
| 1534 |
> |
FILE *fUserName = NULL; |
| 1535 |
> |
char chrUserName[32]; |
| 1536 |
> |
fUserName = popen("whoami", "r"); |
| 1537 |
> |
fgets(chrUserName, sizeof(chrUserName), fUserName); |
| 1538 |
> |
pclose(fUserName); |
| 1539 |
> |
string strUserName = (string)chrUserName; // stringsblaaarrrgggghhhh |
| 1540 |
> |
int endOfName = strUserName.find("\n", 0); |
| 1541 |
> |
string strTrashDir = "/Users/" + strUserName.substr(0, endOfName) + "/.Trash/"; |
| 1542 |
> |
bool needNewTrashDir = true; |
| 1543 |
> |
tm tmStartTime = to_tm(startTime); |
| 1544 |
> |
#endif |
| 1545 |
> |
|
| 1546 |
> |
try |
| 1547 |
> |
{ |
| 1548 |
> |
directory_iterator end; |
| 1549 |
> |
for (directory_iterator update_iter(pathToUpdate); update_iter != end; ++update_iter) |
| 1550 |
> |
{ |
| 1551 |
> |
ModPackage installedPackage, updatePackage; |
| 1552 |
> |
string updtPath = update_iter->path().string(); |
| 1553 |
> |
string updtFolder = update_iter->path().filename(); |
| 1554 |
> |
string updtModInfo = updtPath + "/Mod_Info.cfg"; |
| 1555 |
> |
string instModInfo = strPathToPackages + "/" + updtFolder + "/Mod_Info.cfg"; |
| 1556 |
> |
if (!boost::iequals(updtFolder, "Edition") |
| 1557 |
> |
&& !boost::iequals(updtFolder, "Edition-patch") |
| 1558 |
> |
&& is_directory(update_iter->path()) |
| 1559 |
> |
&& exists(updtModInfo)) |
| 1560 |
> |
{ |
| 1561 |
> |
fstream file; |
| 1562 |
> |
file.open((updtModInfo).c_str()); |
| 1563 |
> |
if (!file.fail()) |
| 1564 |
> |
updatePackage = fileToModPackage(file, updtFolder); |
| 1565 |
> |
else |
| 1566 |
> |
{ |
| 1567 |
> |
file.close(); |
| 1568 |
> |
continue; |
| 1569 |
> |
} |
| 1570 |
> |
if (exists(instModInfo)) |
| 1571 |
> |
{ |
| 1572 |
> |
file.close(); |
| 1573 |
> |
file.clear(); |
| 1574 |
> |
file.open(instModInfo.c_str()); |
| 1575 |
> |
if (!file.fail()) |
| 1576 |
> |
{ |
| 1577 |
> |
installedPackage = fileToModPackage(file, updtFolder); |
| 1578 |
> |
} |
| 1579 |
> |
file.close(); |
| 1580 |
> |
} |
| 1581 |
> |
file.close(); |
| 1582 |
> |
if (updatePackage.modStringVersion > installedPackage.modStringVersion) |
| 1583 |
> |
{ |
| 1584 |
> |
if (updatePackage.installerVersion <= INSTALLER_VERSION) |
| 1585 |
> |
{ |
| 1586 |
> |
if(exists(strPathToPackages + "/" + updatePackage.modStringName)) { |
| 1587 |
> |
#ifdef WIN32 |
| 1588 |
> |
remove_all((path)(strPathToPackages + "/" + updatePackage.modStringName)); |
| 1589 |
> |
#else |
| 1590 |
> |
if (needNewTrashDir) |
| 1591 |
> |
{ |
| 1592 |
> |
strTrashDir = strTrashDir + "Old_packages_" + boost::lexical_cast<string>(tmStartTime.tm_hour) + "-" + |
| 1593 |
> |
boost::lexical_cast<string>(tmStartTime.tm_min) + "-" + boost::lexical_cast<string>(tmStartTime.tm_sec) + "/"; |
| 1594 |
> |
create_directory(strTrashDir); |
| 1595 |
> |
needNewTrashDir = false; |
| 1596 |
> |
} |
| 1597 |
> |
rename((path)(strPathToPackages + "/" + updatePackage.modStringName), (path)(strTrashDir + updatePackage.modStringName)); |
| 1598 |
> |
#endif |
| 1599 |
> |
} |
| 1600 |
> |
rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName)); |
| 1601 |
> |
} |
| 1602 |
> |
} |
| 1603 |
> |
} |
| 1604 |
> |
} |
| 1605 |
> |
} |
| 1606 |
> |
catch (exception & ex) |
| 1607 |
> |
{ |
| 1608 |
> |
setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 1609 |
> |
} |
| 1610 |
> |
wxCommandEvent e; |
| 1611 |
> |
TheWindow->OnRefreshButtonClick( e ); |
| 1612 |
|
} |
| 1613 |
|
|
| 1614 |
|
/* MakePathLocalToGlobalize is a function used once by ProcessAEUpdate() that takes a file in an \ |