| 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/ |
| 313 |
< |
char prefsCommand[300] = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '"; |
| 314 |
< |
strcat(prefsCommand, fullAEpath.c_str()); // get path of Edition/ folder (Oni wants the folder that *contains* the GDF) |
| 315 |
< |
strcat(prefsCommand, "'"); // path string is enclosed in single quotes to avoid the need to escape UNIX-unfriendly characters |
| 316 |
< |
system(prefsCommand); |
| 312 |
> |
string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for Edition/ (Oni wants folder that *contains* the GDF) |
| 313 |
> |
string prefsCommand = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '" |
| 314 |
> |
+ fullAEpath + "'"; |
| 315 |
> |
system(prefsCommand.c_str()); |
| 316 |
> |
|
| 317 |
|
#endif |
| 318 |
|
|
| 319 |
|
setStatusArea((string)"Done! Now select your mod packages and click install."); |
| 333 |
|
vector<ModPackage> getPackages(string packageDir) |
| 334 |
|
{ |
| 335 |
|
vector<ModPackage> packages; |
| 336 |
+ |
ModPackage package; |
| 337 |
|
packages.reserve(256); |
| 338 |
|
fstream file; |
| 339 |
|
string filename = "\0"; |
| 345 |
|
{ |
| 346 |
|
file.open((dir_itr->path().string() + "/" + MODINFO_CFG).c_str()); |
| 347 |
|
|
| 348 |
< |
if(!file.fail()) |
| 348 |
> |
if (!file.fail()) |
| 349 |
|
{ |
| 350 |
< |
//would prefer to push a pointer to a package, but this will do for now |
| 351 |
< |
packages.push_back(fileToModPackage(file)); |
| 350 |
> |
package = fileToModPackage(file, dir_itr->path().filename()); |
| 351 |
> |
if (package.installerVersion.compare(INSTALLER_VERSION) < 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 |
| 355 |
> |
#else |
| 356 |
> |
if (!package.platform.compare("Macintosh") || !package.platform.compare("Both")) |
| 357 |
> |
#endif |
| 358 |
> |
packages.push_back(package); |
| 359 |
> |
} |
| 360 |
|
} |
| 361 |
|
file.close(); |
| 362 |
|
file.clear(); |
| 371 |
|
return packages; |
| 372 |
|
} |
| 373 |
|
|
| 374 |
< |
ModPackage fileToModPackage(fstream &file) |
| 375 |
< |
{ |
| 360 |
< |
/* |
| 361 |
< |
This converts a file to a ModPackage struct. |
| 362 |
< |
|
| 363 |
< |
A few notes... |
| 364 |
< |
"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. |
| 365 |
< |
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 |
| 366 |
< |
slower than reading a variable. |
| 367 |
< |
*/ |
| 374 |
> |
ModPackage fileToModPackage(fstream &file, string modName) |
| 375 |
> |
{ |
| 376 |
|
ModPackage package; |
| 377 |
|
string line; |
| 378 |
< |
static string NameOfMod = "NameOfMod"; //used for comparing to the current token... |
| 379 |
< |
//I could have done it in reverse (*iter).compare("ModString") or |
| 380 |
< |
static string ARROW = "->"; //did something like "ModString".compare(*iter), and it would have been |
| 381 |
< |
static string ModString = "ModString"; //functionably the same. |
| 382 |
< |
static string HasOnis = "HasOnis"; |
| 383 |
< |
static string HasDeltas = "HasDeltas"; |
| 384 |
< |
static string HasBSL = "HasBSL"; |
| 385 |
< |
static string HasDats = "HasDats"; |
| 386 |
< |
static string IsEngine = "IsEngine"; |
| 387 |
< |
static string Readme = "Readme"; |
| 388 |
< |
static string GlobalNeeded = "GlobalNeeded"; |
| 389 |
< |
static string Category = "Category"; |
| 390 |
< |
static string Creator = "Creator"; |
| 391 |
< |
while (! file.eof() ) |
| 378 |
> |
const string AEInstallVersion = "AEInstallVersion"; // used for comparing to the current token... |
| 379 |
> |
const string NameOfMod = "NameOfMod"; |
| 380 |
> |
const string ARROW = "->"; |
| 381 |
> |
const string ModString = "ModString"; |
| 382 |
> |
const string ModVersion = "ModVersion"; |
| 383 |
> |
const string Platform = "Platform"; |
| 384 |
> |
const string HasOnis = "HasOnis"; |
| 385 |
> |
const string HasDeltas = "HasDeltas"; |
| 386 |
> |
const string HasBSL = "HasBSL"; |
| 387 |
> |
const string HasDats = "HasDats"; |
| 388 |
> |
const string IsEngine = "IsEngine"; |
| 389 |
> |
const string Readme = "Readme"; |
| 390 |
> |
const string GlobalNeeded = "GlobalNeeded"; |
| 391 |
> |
const string Category = "Category"; |
| 392 |
> |
const string Creator = "Creator"; |
| 393 |
> |
package.modStringName = modName; |
| 394 |
> |
while (!file.eof()) |
| 395 |
|
{ |
| 396 |
< |
getline (file,line); |
| 396 |
> |
getline(file,line); |
| 397 |
|
vector<string> tokens; |
| 398 |
|
vector<string>::iterator iter; |
| 399 |
< |
tokenize(line, tokens); //string to vector of "words" |
| 400 |
< |
if (tokens.capacity() >= 3) { //make sure they are using enough stuff |
| 401 |
< |
iter = tokens.begin(); //what word we are on, starts at first word |
| 402 |
< |
/* TODO: Get this "required Installer version" code working |
| 403 |
< |
if (!AEInstallVersion.compare(*iter)) |
| 404 |
< |
If mod is too old, skip this mod. |
| 405 |
< |
*/ |
| 406 |
< |
/*else*/if (!NameOfMod.compare(*iter)) { //if it contains the name |
| 407 |
< |
for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { // iterates through the words, ends if it reaches the end of the line or a "//" comment |
| 408 |
< |
if (ARROW.compare(*iter) && NameOfMod.compare(*iter)) { // ignores "->" and "NameOfMod" |
| 399 |
> |
tokenize(line, tokens); |
| 400 |
> |
if (tokens.capacity() >= 3) |
| 401 |
> |
{ |
| 402 |
> |
iter = tokens.begin(); |
| 403 |
> |
|
| 404 |
> |
if (!AEInstallVersion.compare(*iter)) |
| 405 |
> |
{ |
| 406 |
> |
iter++; iter++; |
| 407 |
> |
package.installerVersion = *iter; |
| 408 |
> |
} |
| 409 |
> |
else if (!NameOfMod.compare(*iter)) |
| 410 |
> |
{ |
| 411 |
> |
for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) // iterates through the words, ends if it reaches the end of the line or a "//" comment |
| 412 |
> |
{ |
| 413 |
> |
if (ARROW.compare(*iter) && NameOfMod.compare(*iter)) // ignores "->" and "NameOfMod" |
| 414 |
|
package.name += *iter + " "; |
| 399 |
– |
} |
| 415 |
|
} |
| 401 |
– |
|
| 416 |
|
} |
| 417 |
< |
else if (!ModString.compare(*iter)) { |
| 417 |
> |
else if (!ModString.compare(*iter)) |
| 418 |
> |
{ |
| 419 |
|
iter++; iter++; |
| 420 |
< |
package.modStringName = *iter; |
| 420 |
> |
//package.modStringName = *iter; |
| 421 |
|
iter++; |
| 422 |
< |
package.modStringVersion = atoi((*iter).c_str()); |
| 422 |
> |
package.modStringVersion = atof((*iter).c_str()); |
| 423 |
> |
} |
| 424 |
> |
else if (!ModVersion.compare(*iter)) |
| 425 |
> |
{ |
| 426 |
> |
iter++; iter++; |
| 427 |
> |
package.modStringVersion = atof((*iter).c_str()); |
| 428 |
> |
} |
| 429 |
> |
else if (!Platform.compare(*iter)) |
| 430 |
> |
{ |
| 431 |
> |
iter++; iter++; |
| 432 |
> |
package.platform = *iter; |
| 433 |
|
} |
| 434 |
< |
else if (!HasOnis.compare(*iter)) { |
| 434 |
> |
else if (!HasOnis.compare(*iter)) |
| 435 |
> |
{ |
| 436 |
|
iter++; iter++; |
| 437 |
< |
if ( boost::iequals(*iter, "Yes")) package.hasOnis = 1; |
| 437 |
> |
if (boost::iequals(*iter, "Yes")) package.hasOnis = 1; |
| 438 |
|
} |
| 439 |
< |
else if (!HasBSL.compare(*iter)) { |
| 440 |
< |
if(toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasBSL = true; |
| 441 |
< |
else if ( boost::iequals(*iter, "Addon")) package.hasAddon = true; |
| 439 |
> |
else if (!HasBSL.compare(*iter)) |
| 440 |
> |
{ |
| 441 |
> |
iter++; iter++; |
| 442 |
> |
if (boost::iequals(*iter, "Yes")) package.hasBSL = true; |
| 443 |
> |
else if (boost::iequals(*iter, "Addon")) package.hasAddon = true; |
| 444 |
|
} |
| 445 |
< |
else if (!HasDeltas.compare(*iter)) { |
| 445 |
> |
else if (!HasDeltas.compare(*iter)) |
| 446 |
> |
{ |
| 447 |
|
iter++; iter++; |
| 448 |
< |
if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDeltas = 1; |
| 448 |
> |
if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasDeltas = 1; |
| 449 |
|
} |
| 450 |
< |
else if (!HasDats.compare(*iter)) { |
| 450 |
> |
else if (!HasDats.compare(*iter)) |
| 451 |
> |
{ |
| 452 |
|
iter++; iter++; |
| 453 |
< |
if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDats = 1; |
| 453 |
> |
if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasDats = 1; |
| 454 |
|
} |
| 455 |
< |
else if (!IsEngine.compare(*iter)) { |
| 455 |
> |
else if (!IsEngine.compare(*iter)) |
| 456 |
> |
{ |
| 457 |
|
iter++; iter++; |
| 458 |
< |
if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.isEngine = 1; |
| 458 |
> |
if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.isEngine = 1; |
| 459 |
|
} |
| 460 |
< |
else if (!GlobalNeeded.compare(*iter)) { |
| 460 |
> |
else if (!GlobalNeeded.compare(*iter)) |
| 461 |
> |
{ |
| 462 |
|
iter++; iter++; |
| 463 |
< |
if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.globalNeeded = 1; |
| 464 |
< |
else if (toupper((*iter)[0]) + toupper((*iter)[1]) == 'N' + 'O') package.globalNeeded = 1; // only place where checking for "No" is important atm. |
| 463 |
> |
if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.globalNeeded = 1; |
| 464 |
> |
else if (toupper((*iter)[0]) == 'N' && toupper((*iter)[1]) == 'O') package.globalNeeded = 1; // only place where checking for "No" is important atm |
| 465 |
|
} |
| 466 |
< |
else if (!Category.compare(*iter)) { |
| 467 |
< |
for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { // iterates through the words, ends if it reaches end of line or a "//" comment |
| 468 |
< |
if (ARROW.compare(*iter) && Category.compare(*iter)) { // ignores "->" and "Category" |
| 466 |
> |
else if (!Category.compare(*iter)) |
| 467 |
> |
{ |
| 468 |
> |
for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) |
| 469 |
> |
{ |
| 470 |
> |
if (ARROW.compare(*iter) && Category.compare(*iter)) // ignores "->" and "Category" |
| 471 |
|
package.category += *iter + " "; |
| 438 |
– |
} |
| 472 |
|
} |
| 473 |
|
} |
| 474 |
< |
else if (!Creator.compare(*iter)) { //if it contains the name |
| 475 |
< |
for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { // iterates through the words, ends if it reaches end of line or a "//" comment |
| 476 |
< |
if (ARROW.compare(*iter) && Creator.compare(*iter)) { // ignores "->" and "Creator" |
| 474 |
> |
else if (!Creator.compare(*iter)) |
| 475 |
> |
{ |
| 476 |
> |
for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) |
| 477 |
> |
{ |
| 478 |
> |
if (ARROW.compare(*iter) && Creator.compare(*iter)) // ignores "->" and "Creator" |
| 479 |
|
package.creator += *iter + " "; |
| 445 |
– |
} |
| 480 |
|
} |
| 481 |
|
} |
| 482 |
< |
else if (!Readme.compare(*iter)) { //if it contains the name |
| 483 |
< |
for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { // iterates through the words, ends if it reaches end of line or a "//" comment |
| 484 |
< |
if (ARROW.compare(*iter) && Readme.compare(*iter)) { // ignores "->" and "Readme" |
| 485 |
< |
if(!(*iter).compare("\\n")) package.readme += '\n'; |
| 482 |
> |
else if (!Readme.compare(*iter)) |
| 483 |
> |
{ |
| 484 |
> |
for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) |
| 485 |
> |
{ |
| 486 |
> |
if (ARROW.compare(*iter) && Readme.compare(*iter)) // ignores "->" and "Readme" |
| 487 |
> |
{ |
| 488 |
> |
if (!(*iter).compare("\\n")) package.readme += '\n'; |
| 489 |
|
else package.readme += *iter + " "; |
| 490 |
|
} |
| 491 |
|
} |
| 492 |
|
} |
| 493 |
|
} |
| 457 |
– |
|
| 494 |
|
} |
| 495 |
|
|
| 496 |
|
return package; |
| 564 |
|
|
| 565 |
|
|
| 566 |
|
setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats |
| 567 |
< |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); |
| 567 |
> |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + |
| 568 |
> |
dir_itr->path().filename() + " "); |
| 569 |
|
|
| 570 |
|
system(importCommand.c_str()); |
| 571 |
|
j++; |
| 592 |
|
else if(splitInstances == false){ |
| 593 |
|
directory_iterator end_iter; |
| 594 |
|
|
| 595 |
< |
for ( directory_iterator dir_itr( vanilla_dir ); |
| 596 |
< |
dir_itr != end_iter; |
| 597 |
< |
++dir_itr ) |
| 598 |
< |
{ |
| 599 |
< |
if ( is_directory( dir_itr->status() ) ) |
| 600 |
< |
{ |
| 601 |
< |
numberOfDats++; |
| 595 |
> |
|
| 596 |
> |
char levelnums[256] = {0}; |
| 597 |
> |
|
| 598 |
> |
|
| 599 |
> |
|
| 600 |
> |
for(int k = 0; k < 256; k++) { |
| 601 |
> |
if( exists( (path)("./VanillaDats/level" + lexical_cast<std::string>(k) + "_final/") ) ) { |
| 602 |
> |
levelnums[k] = 1; |
| 603 |
> |
|
| 604 |
|
} |
| 605 |
|
} |
| 606 |
< |
|
| 606 |
> |
|
| 607 |
> |
for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) |
| 608 |
> |
for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages |
| 609 |
> |
if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it |
| 610 |
> |
for(int k = 0; k < 256; k++) { |
| 611 |
> |
if( globalPackages[j].hasOnis && |
| 612 |
> |
exists( (path)("packages/" + globalPackages[j].modStringName + "/oni/level" + lexical_cast<std::string>(k) + "_final/") ) ) { |
| 613 |
> |
levelnums[k] = 1; |
| 614 |
> |
|
| 615 |
> |
} |
| 616 |
> |
} |
| 617 |
> |
} |
| 618 |
> |
} |
| 619 |
> |
} |
| 620 |
> |
for (int levelnum = 0; levelnum < 256; levelnum++) |
| 621 |
> |
if (levelnums[levelnum]) |
| 622 |
> |
numberOfDats++; |
| 623 |
> |
|
| 624 |
|
out << numberOfDats; |
| 625 |
|
datString = out.str(); |
| 626 |
< |
|
| 627 |
< |
for ( directory_iterator dir_itr( vanilla_dir ); |
| 572 |
< |
dir_itr != end_iter; |
| 573 |
< |
++dir_itr ) |
| 574 |
< |
{ |
| 626 |
> |
|
| 627 |
> |
for(int levelnum = 0; levelnum < 256; levelnum++) { |
| 628 |
|
try |
| 629 |
|
{ |
| 630 |
< |
if ( is_directory( dir_itr->status() ) ) |
| 630 |
> |
if ( levelnums[levelnum] ) |
| 631 |
|
{ |
| 632 |
< |
importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " "; |
| 632 |
> |
importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + "level" + lexical_cast<std::string>(levelnum) + "_Final "; |
| 633 |
|
for (unsigned int i = 0; i < installedMods.size(); ++i) { |
| 634 |
< |
if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename() )) |
| 635 |
< |
importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename(); |
| 634 |
> |
if (exists((path)("packages/" + installedMods[i] + "/oni/level" + lexical_cast<std::string>(levelnum) + "_final") )) |
| 635 |
> |
importCommand += " packages/" + installedMods[i] + "/oni/level" + lexical_cast<std::string>(levelnum) + "_Final"; |
| 636 |
|
} |
| 637 |
< |
importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log"; |
| 637 |
> |
importCommand += " ../GameDataFolder/level" + lexical_cast<std::string>(levelnum) + "_Final.dat >> Install.log"; |
| 638 |
|
|
| 639 |
|
setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats |
| 640 |
< |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); |
| 640 |
> |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + |
| 641 |
> |
"level" + lexical_cast<std::string>(levelnum) + "_Final"+ " "); |
| 642 |
|
system(importCommand.c_str()); |
| 643 |
|
j++; |
| 644 |
|
} |
| 658 |
|
vector<string> skippedfolders; |
| 659 |
|
|
| 660 |
|
ofstream BSLlog("BSL.log"); |
| 661 |
+ |
if(!exists("../GameDataFolder/BSLBackup/")) { |
| 662 |
+ |
create_directory("../GameDataFolder/BSLBackup/"); |
| 663 |
+ |
copy("../GameDataFolder/IGMD/", "../GameDataFolder/BSLBackup/"); |
| 664 |
+ |
} |
| 665 |
+ |
|
| 666 |
|
for ( directory_iterator dir_itr( "../GameDataFolder/IGMD/" ), end_itr; |
| 667 |
|
dir_itr != end_itr; |
| 668 |
|
++dir_itr ) { |
| 675 |
|
for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) |
| 676 |
|
for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages |
| 677 |
|
if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it |
| 678 |
< |
if(!(globalPackages[j].hasAddon || globalPackages[j].hasBSL)) break; //skip non-BSL |
| 678 |
> |
if(globalPackages[j].hasBSL) break; //skip non-BSL |
| 679 |
|
if( exists( "packages/" + globalPackages[j].modStringName + "/BSL/" ) ) { |
| 680 |
|
copyBSL("packages/" + globalPackages[j].modStringName + "/BSL", BSLfolders, globalPackages[j] ); |
| 681 |
|
BSLlog << "Copied " << globalPackages[j].modStringName << "!\n"; |
| 684 |
|
} |
| 685 |
|
} |
| 686 |
|
|
| 687 |
+ |
|
| 688 |
+ |
|
| 689 |
|
ModPackage emptyPackage; |
| 690 |
|
emptyPackage.modStringName = "VanillaBSL"; |
| 691 |
|
emptyPackage.hasBSL = 1; |
| 692 |
|
copyBSL("packages/VanillaBSL/IGMD", BSLfolders, emptyPackage); |
| 693 |
|
BSLlog.close(); |
| 694 |
< |
|
| 694 |
> |
|
| 695 |
> |
for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) |
| 696 |
> |
for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages |
| 697 |
> |
if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it |
| 698 |
> |
if(!globalPackages[j].hasAddon) break; //skip non-BSL |
| 699 |
> |
if( exists( "packages/" + globalPackages[j].modStringName + "/BSL/" ) ) { |
| 700 |
> |
copyBSL("packages/" + globalPackages[j].modStringName + "/BSL", BSLfolders, globalPackages[j] ); |
| 701 |
> |
BSLlog << "Copied " << globalPackages[j].modStringName << "!\n"; |
| 702 |
> |
} |
| 703 |
> |
} |
| 704 |
> |
} |
| 705 |
> |
} |
| 706 |
> |
|
| 707 |
|
logfile << "Writing config file"; |
| 708 |
|
writeInstalledMods(installedMods); |
| 709 |
|
setProgressBar(1000); |
| 734 |
|
|
| 735 |
|
void copyBSL(string copypath, vector<string>& BSLfolders, ModPackage pkg) |
| 736 |
|
{ |
| 737 |
< |
ofstream BSLlog("BSL2.log", ios::app ); |
| 737 |
> |
ofstream BSLlog("BSL.log", ios::app ); |
| 738 |
|
|
| 739 |
|
try { |
| 740 |
|
for ( directory_iterator dir_itr( copypath ), end_itr; |
| 744 |
|
if ( is_directory( dir_itr->path() ) && dir_itr->path().string() != ".svn" ) { |
| 745 |
|
BSLlog << "Testing " << dir_itr->path().string() << " HasBSL: " << pkg.hasBSL << " HasAddon: " << pkg.hasAddon << "\n"; |
| 746 |
|
int skip_folder = 0; |
| 747 |
< |
|
| 748 |
< |
for(unsigned int k = 0; k < BSLfolders.size(); k++) {//iterate through already found BSL folders |
| 749 |
< |
BSLlog << "testing " << dir_itr->path().filename() << " vs " << BSLfolders[k] << "\n"; |
| 750 |
< |
if(dir_itr->path().filename() == BSLfolders[k]) { |
| 751 |
< |
skip_folder = 1; |
| 752 |
< |
BSLlog << "skipping " << BSLfolders[k] << " in " << pkg.modStringName << "\n"; |
| 753 |
< |
break; |
| 747 |
> |
if(!pkg.hasAddon) { |
| 748 |
> |
for(unsigned int k = 0; k < BSLfolders.size(); k++) {//iterate through already found BSL folders |
| 749 |
> |
BSLlog << "testing " << dir_itr->path().filename() << " vs " << BSLfolders[k] << "\n"; |
| 750 |
> |
if(dir_itr->path().filename() == BSLfolders[k]) { |
| 751 |
> |
skip_folder = 1; |
| 752 |
> |
BSLlog << "skipping " << BSLfolders[k] << " in " << pkg.modStringName << "\n"; |
| 753 |
> |
break; |
| 754 |
> |
} |
| 755 |
|
} |
| 756 |
|
} |
| 757 |
|
if (!skip_folder && !exists("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/ignore.txt")) { |
| 758 |
< |
remove_all( "../GameDataFolder/IGMD/" + dir_itr->path().filename() ); |
| 758 |
> |
if(!pkg.hasAddon) remove_all( "../GameDataFolder/IGMD/" + dir_itr->path().filename() ); |
| 759 |
|
Sleep(100); |
| 760 |
|
create_directory( "../GameDataFolder/IGMD/" + dir_itr->path().filename()); |
| 761 |
|
BSLlog << "Copied " << dir_itr->path().string() << " in " << pkg.modStringName << "!\n"; |
| 763 |
|
bsl_itr != end_itr; |
| 764 |
|
bsl_itr++ ) { |
| 765 |
|
if ( bsl_itr->path().extension() == ".bsl" ) { |
| 766 |
+ |
if(exists("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename())) |
| 767 |
+ |
remove("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); |
| 768 |
|
copy_file(bsl_itr->path(), "../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); |
| 769 |
|
} |
| 770 |
|
} |
| 771 |
< |
BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon |
| 772 |
< |
BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ; |
| 771 |
> |
if( !pkg.hasAddon ) { |
| 772 |
> |
BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon |
| 773 |
> |
BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ; |
| 774 |
> |
} |
| 775 |
|
} |
| 776 |
|
} |
| 777 |
|
} |
| 847 |
|
| Installer to be replaced (when the new Installer | |
| 848 |
|
| launches, this function will be called again but will | |
| 849 |
|
| return UPDATE_SIMP_AVAIL or UPDATE_GLOB_AVAIL) | |
| 850 |
+ |
| UPDATE_PKG_AVAIL -- A newer version of individual package(s) is available | |
| 851 |
|
\* UPDATE_CONT_UPD -- Currently unused */ |
| 852 |
|
int GetUpdateStatus(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) |
| 853 |
|
{ |
| 876 |
|
else |
| 877 |
|
return UPDATE_LOG_READ_ERR; |
| 878 |
|
} |
| 879 |
< |
|
| 880 |
< |
// Is there an update folder, and is it a monthly release or a patch? |
| 881 |
< |
if (!exists("../updates/Edition")) |
| 879 |
> |
|
| 880 |
> |
// Is there an update in the updates/ folder, and is it a monthly release or a patch? |
| 881 |
> |
bool firstParty = 0; |
| 882 |
> |
// First create the folder if it's missing, so users are never left wondering where updates are supposed to be put |
| 883 |
> |
if (!exists("../updates")) |
| 884 |
> |
create_directory("../updates"); |
| 885 |
> |
if (exists("../updates/Edition")) |
| 886 |
|
{ |
| 887 |
+ |
firstParty = 1; |
| 888 |
+ |
} |
| 889 |
+ |
else { |
| 890 |
|
strEUFN = "Edition-patch"; |
| 891 |
< |
if (!exists("../updates/Edition-patch")) |
| 892 |
< |
return UPDATE_NO_UPD_AVAIL; |
| 891 |
> |
if (exists("../updates/Edition-patch")) { |
| 892 |
> |
firstParty = 1; |
| 893 |
> |
} |
| 894 |
> |
|
| 895 |
|
} |
| 896 |
< |
|
| 897 |
< |
// Unlike the current AE's version info, we *need* to find the update's version info or we won't continue |
| 898 |
< |
string updateCfgPath = ("../updates/" + strEUFN + "/install/packages/Globalize/Install_Info.cfg"); |
| 899 |
< |
updateAECfg.open(updateCfgPath.c_str()); |
| 900 |
< |
if (!updateAECfg.fail()) |
| 901 |
< |
{ |
| 902 |
< |
if (!ReadInstallInfoCfg(&updateAECfg, updateAE)) |
| 896 |
> |
|
| 897 |
> |
if(firstParty) { |
| 898 |
> |
// Unlike the current AE's version info, we *need* to find the update's version info or we won't continue |
| 899 |
> |
string updateCfgPath = ("../updates/" + strEUFN + "/install/packages/Globalize/Install_Info.cfg"); |
| 900 |
> |
updateAECfg.open(updateCfgPath.c_str()); |
| 901 |
> |
if (!updateAECfg.fail()) |
| 902 |
> |
{ |
| 903 |
> |
if (!ReadInstallInfoCfg(&updateAECfg, updateAE)) |
| 904 |
> |
return UPDATE_LOG_READ_ERR; |
| 905 |
> |
|
| 906 |
> |
updateAECfg.close(); |
| 907 |
> |
updateAECfg.clear(); |
| 908 |
> |
} |
| 909 |
> |
else |
| 910 |
|
return UPDATE_LOG_READ_ERR; |
| 816 |
– |
|
| 817 |
– |
updateAECfg.close(); |
| 818 |
– |
updateAECfg.clear(); |
| 819 |
– |
} |
| 820 |
– |
else |
| 821 |
– |
return UPDATE_LOG_READ_ERR; |
| 911 |
|
|
| 912 |
< |
// Now we check for an Installer update in progress |
| 913 |
< |
if (exists("Update.log")) |
| 914 |
< |
{ |
| 915 |
< |
updateLog.open("Update.log"); |
| 916 |
< |
if (!updateLog.fail()) |
| 828 |
< |
{ |
| 829 |
< |
vector<string> lines; |
| 830 |
< |
string line; |
| 831 |
< |
int num_lines = 0; |
| 832 |
< |
bool readingInstallerVersion = false, doneReadingFile = false; |
| 833 |
< |
|
| 834 |
< |
while (!updateLog.eof() && !doneReadingFile) |
| 912 |
> |
// Now we check for an Installer update in progress |
| 913 |
> |
if (exists("Update.log")) |
| 914 |
> |
{ |
| 915 |
> |
updateLog.open("Update.log"); |
| 916 |
> |
if (!updateLog.fail()) |
| 917 |
|
{ |
| 918 |
< |
getline(updateLog, line); |
| 919 |
< |
lines.push_back(line); |
| 920 |
< |
num_lines++; |
| 921 |
< |
vector<string> tokens; |
| 922 |
< |
vector<string>::iterator iter; |
| 923 |
< |
tokenize(line, tokens); |
| 842 |
< |
iter = tokens.begin(); |
| 843 |
< |
if (!readingInstallerVersion && tokens.capacity() >= 4) |
| 918 |
> |
vector<string> lines; |
| 919 |
> |
string line; |
| 920 |
> |
int num_lines = 0; |
| 921 |
> |
bool readingInstallerVersion = false, doneReadingFile = false; |
| 922 |
> |
|
| 923 |
> |
while (!updateLog.eof() && !doneReadingFile) |
| 924 |
|
{ |
| 925 |
< |
if (!strInstaller.compare(*iter)) |
| 925 |
> |
getline(updateLog, line); |
| 926 |
> |
lines.push_back(line); |
| 927 |
> |
num_lines++; |
| 928 |
> |
vector<string> tokens; |
| 929 |
> |
vector<string>::iterator iter; |
| 930 |
> |
tokenize(line, tokens); |
| 931 |
> |
iter = tokens.begin(); |
| 932 |
> |
if (!readingInstallerVersion && tokens.capacity() >= 4) |
| 933 |
|
{ |
| 934 |
< |
if (!strBeing.compare(*++iter)) |
| 935 |
< |
readingInstallerVersion = true; |
| 936 |
< |
else if (!strWas.compare(*iter)) |
| 937 |
< |
*installerJustUpdated = true; // our third indirect return value after currentAE and updateAE |
| 934 |
> |
if (!strInstaller.compare(*iter)) |
| 935 |
> |
{ |
| 936 |
> |
if (!strBeing.compare(*++iter)) |
| 937 |
> |
readingInstallerVersion = true; |
| 938 |
> |
else if (!strWas.compare(*iter)) |
| 939 |
> |
*installerJustUpdated = true; // our third indirect return value after currentAE and updateAE |
| 940 |
> |
} |
| 941 |
|
} |
| 942 |
< |
} |
| 853 |
< |
else if (readingInstallerVersion && tokens.capacity() >= 3) |
| 854 |
< |
{ |
| 855 |
< |
readingInstallerVersion = false; |
| 856 |
< |
string installerVersion = INSTALLER_VERSION; |
| 857 |
< |
if (installerVersion.compare(*iter)) // then the shell script-powered replacement failed |
| 858 |
< |
return UPDATE_INST_REPL_ERR; |
| 859 |
< |
else |
| 942 |
> |
else if (readingInstallerVersion && tokens.capacity() >= 3) |
| 943 |
|
{ |
| 944 |
< |
updateLog.close(); |
| 945 |
< |
updateLog.clear(); |
| 946 |
< |
Sleep(1000); |
| 947 |
< |
remove("Update.log"); |
| 948 |
< |
ofstream newUpdateLog("Update.log"); |
| 866 |
< |
if (!newUpdateLog.fail()) |
| 944 |
> |
readingInstallerVersion = false; |
| 945 |
> |
string installerVersion = INSTALLER_VERSION; |
| 946 |
> |
if (installerVersion.compare(*iter)) // then the shell script-powered replacement failed |
| 947 |
> |
return UPDATE_INST_REPL_ERR; |
| 948 |
> |
else |
| 949 |
|
{ |
| 950 |
< |
// Write over old log with updated information |
| 951 |
< |
ptime startTime(second_clock::local_time()); |
| 952 |
< |
string strStartTime = to_simple_string(startTime); |
| 953 |
< |
string newUpdateLine = installerVersion + " on " + strStartTime; |
| 954 |
< |
for (int a = 0; a < lines.capacity() - 2; a++) // if there were even lines in the log before this at all |
| 950 |
> |
updateLog.close(); |
| 951 |
> |
updateLog.clear(); |
| 952 |
> |
Sleep(1000); |
| 953 |
> |
remove("Update.log"); |
| 954 |
> |
ofstream newUpdateLog("Update.log"); |
| 955 |
> |
if (!newUpdateLog.fail()) |
| 956 |
|
{ |
| 957 |
< |
newUpdateLog << lines[a].c_str(); |
| 958 |
< |
newUpdateLog << "\n"; |
| 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; |
| 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(); |
| 964 |
> |
newUpdateLog << "\n"; |
| 965 |
> |
} |
| 966 |
> |
newUpdateLog << "Installer was updated to:\n"; |
| 967 |
> |
newUpdateLog << newUpdateLine.c_str(); |
| 968 |
> |
*installerJustUpdated = true; // this value is indirectly returned to AEInstallerApp::OnInit() |
| 969 |
> |
doneReadingFile = true; |
| 970 |
> |
newUpdateLog.close(); |
| 971 |
> |
newUpdateLog.clear(); |
| 972 |
> |
//return UPDATE_CONT_UPD; // as noted above, we are not using this return value; in fact, we want... |
| 973 |
> |
// ...the code to continue running down through the Edition version check |
| 974 |
|
} |
| 975 |
< |
newUpdateLog << "Installer was updated to:\n"; |
| 976 |
< |
newUpdateLog << newUpdateLine.c_str(); |
| 879 |
< |
*installerJustUpdated = true; // this value is indirectly returned to AEInstallerAp::OnInit() |
| 880 |
< |
doneReadingFile = true; |
| 881 |
< |
newUpdateLog.close(); |
| 882 |
< |
newUpdateLog.clear(); |
| 883 |
< |
//return UPDATE_CONT_UPD; // as noted above, we are not using this return value; in fact, we want... |
| 884 |
< |
// ...the code to continue running down through the Edition version check |
| 975 |
> |
else |
| 976 |
> |
return UPDATE_LOG_READ_ERR; |
| 977 |
|
} |
| 886 |
– |
else |
| 887 |
– |
return UPDATE_LOG_READ_ERR; |
| 978 |
|
} |
| 979 |
|
} |
| 980 |
+ |
updateLog.close(); |
| 981 |
+ |
updateLog.clear(); |
| 982 |
|
} |
| 983 |
< |
updateLog.close(); |
| 984 |
< |
updateLog.clear(); |
| 983 |
> |
else |
| 984 |
> |
return UPDATE_LOG_READ_ERR; |
| 985 |
> |
} |
| 986 |
> |
|
| 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) |
| 992 |
> |
{ |
| 993 |
> |
if (exists(strNewInstallerPath)) |
| 994 |
> |
return UPDATE_INST_AVAIL; |
| 995 |
> |
} |
| 996 |
> |
else if (updateAE->globalizationRequired) |
| 997 |
> |
return UPDATE_GLOB_AVAIL; |
| 998 |
> |
else |
| 999 |
> |
return UPDATE_SIMP_AVAIL; |
| 1000 |
|
} |
| 1001 |
|
else |
| 1002 |
< |
return UPDATE_LOG_READ_ERR; |
| 1002 |
> |
return UPDATE_MNTH_REQD_ERR; |
| 1003 |
|
} |
| 1004 |
< |
|
| 898 |
< |
if (updateAE->AEVersion.compare(currentAE->AEVersion) >= 1) // is the release update newer than what's installed? |
| 1004 |
> |
try |
| 1005 |
|
{ |
| 1006 |
< |
if (!strEUFN.compare("Edition-patch")) // if update is a patch... |
| 1007 |
< |
{ |
| 902 |
< |
if (currentAE->AEVersion.compare(updateAE->AEVersion.substr(0, updateAE->AEVersion.length() - 1))) // ...is it for a different month? |
| 903 |
< |
return UPDATE_MNTH_REQD_ERR; |
| 904 |
< |
} |
| 905 |
< |
string strNewInstallerPath = "../updates/" + strEUFN + "/install/" + strInstallerName; |
| 906 |
< |
string installerVersion = INSTALLER_VERSION; |
| 907 |
< |
if (updateAE->InstallerVersion.compare(installerVersion) >= 1) |
| 1006 |
> |
directory_iterator end; |
| 1007 |
> |
if (exists("../updates")) |
| 1008 |
|
{ |
| 1009 |
< |
if (exists(strNewInstallerPath)) |
| 1010 |
< |
return UPDATE_INST_AVAIL; |
| 1009 |
> |
for (directory_iterator install_iter("../updates"); install_iter != end; ++install_iter) |
| 1010 |
> |
{ |
| 1011 |
> |
ModPackage installedPackage, updatePackage; |
| 1012 |
> |
if (is_directory(install_iter->path()) && exists(install_iter->path().string() + "/Mod_Info.cfg")) |
| 1013 |
> |
{ |
| 1014 |
> |
fstream file; |
| 1015 |
> |
file.open((install_iter->path().string() + "/Mod_Info.cfg").c_str()); |
| 1016 |
> |
if (!file.fail()) |
| 1017 |
> |
updatePackage = fileToModPackage(file, install_iter->path().filename()); |
| 1018 |
> |
else |
| 1019 |
> |
{ |
| 1020 |
> |
file.close(); |
| 1021 |
> |
continue; |
| 1022 |
> |
} |
| 1023 |
> |
if (exists("packages/" + install_iter->path().filename() + "/Mod_Info.cfg")) |
| 1024 |
> |
{ |
| 1025 |
> |
file.close(); |
| 1026 |
> |
file.clear(); |
| 1027 |
> |
file.open(("packages/" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); |
| 1028 |
> |
if (!file.fail()) |
| 1029 |
> |
installedPackage = fileToModPackage(file, install_iter->path().filename()); |
| 1030 |
> |
file.close(); |
| 1031 |
> |
if (updatePackage.modStringVersion > installedPackage.modStringVersion) |
| 1032 |
> |
{ |
| 1033 |
> |
if (updatePackage.installerVersion <= INSTALLER_VERSION) |
| 1034 |
> |
return UPDATE_PKG_AVAIL; |
| 1035 |
> |
} |
| 1036 |
> |
} |
| 1037 |
> |
else |
| 1038 |
> |
{ |
| 1039 |
> |
file.close(); |
| 1040 |
> |
return UPDATE_PKG_AVAIL; |
| 1041 |
> |
} |
| 1042 |
> |
} |
| 1043 |
> |
} |
| 1044 |
|
} |
| 912 |
– |
else if (updateAE->globalizationRequired) |
| 913 |
– |
return UPDATE_GLOB_AVAIL; |
| 914 |
– |
else |
| 915 |
– |
return UPDATE_SIMP_AVAIL; |
| 1045 |
|
} |
| 1046 |
< |
else |
| 1047 |
< |
return UPDATE_NO_UPD_AVAIL; |
| 1048 |
< |
|
| 1046 |
> |
catch (exception & ex) { |
| 1047 |
> |
// setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 1048 |
> |
} |
| 1049 |
> |
|
| 1050 |
|
return UPDATE_NO_UPD_AVAIL; |
| 1051 |
|
} |
| 1052 |
|
|
| 1060 |
|
string strDaodanVersion = "Daodan_Version"; |
| 1061 |
|
string strOniSplitVersion = "OniSplit_Version"; |
| 1062 |
|
string strGUIWinVersion = "GUI_Win_Version"; |
| 1063 |
< |
string strGUIMacVersion = "GUI_Mac_Version"; |
| 1063 |
> |
string strGUIMacVersion = "GUI_Mac_Version"; |
| 1064 |
|
string strReglobalize = "Reglobalize"; |
| 1065 |
|
string strDeleteList = "Delete_List"; |
| 1066 |
|
string strArrow = "->"; |
| 1272 |
|
|
| 1273 |
|
string popenCommand = "../updates/" + strEUFN + "/install/"; |
| 1274 |
|
#ifdef WIN32 |
| 1145 |
– |
// TODO: Fill in Windows equivalent of code below :-3 |
| 1275 |
|
popenCommand = "replace_installer.bat"; |
| 1276 |
|
#else |
| 1277 |
|
// We can't just use '~' to mean "the home directory" because we need to check the path in C... |
| 1304 |
|
|
| 1305 |
|
bool ProcessAEUpdate(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) |
| 1306 |
|
{ |
| 1307 |
+ |
try { |
| 1308 |
|
fstream file; |
| 1309 |
|
string line; |
| 1310 |
|
vector<string> tokens, updateStarted; |
| 1324 |
|
string strOniApp = "Oni.exe"; |
| 1325 |
|
#else |
| 1326 |
|
string strOniApp = "Oni.app"; |
| 1197 |
– |
#endif |
| 1327 |
|
bool needNewTrashDir = false; |
| 1328 |
+ |
#endif |
| 1329 |
+ |
|
| 1330 |
|
bool readingVerAndDate = false; |
| 1331 |
|
|
| 1201 |
– |
// TODO: Fill in Windows equivalent of code below |
| 1332 |
|
#ifdef WIN32 |
| 1333 |
< |
string strTrashDir = "Trash\\"; |
| 1333 |
> |
//remove readonly attrib from files. |
| 1334 |
> |
setStatusArea("Removing readonly attribute..."); |
| 1335 |
> |
system("attrib -r ./* /s"); |
| 1336 |
> |
system("attrib -r ../Oni.exe /s"); |
| 1337 |
> |
system("attrib -r ../binkw32.dll /s"); |
| 1338 |
> |
|
| 1339 |
|
#else |
| 1340 |
|
FILE *fUserName = NULL; |
| 1341 |
|
char chrUserName[32]; |
| 1370 |
|
if (readingVerAndDate && tokens.capacity() >= 3) |
| 1371 |
|
tokenize(tokens[2], updateStarted, "-"); |
| 1372 |
|
} |
| 1373 |
+ |
#ifndef WIN32 |
| 1374 |
|
if (updateStarted.capacity() < 3) |
| 1375 |
|
needNewTrashDir = true; |
| 1376 |
|
else |
| 1380 |
|
if (!exists(strTrashDir)) |
| 1381 |
|
needNewTrashDir = true; |
| 1382 |
|
} |
| 1383 |
+ |
#endif |
| 1384 |
|
} |
| 1385 |
|
#ifndef WIN32 |
| 1386 |
|
if (!*installerJustUpdated || needNewTrashDir) // prepare a new directory for deleted files to go to |
| 1397 |
|
// Special code to replace our special files -- the Oni app, OniSplit, the Daodan DLL, and the GUI for OniSplit |
| 1398 |
|
if (exists(strPathToEUFN + strOniApp)) |
| 1399 |
|
{ |
| 1400 |
< |
if (exists(strOniApp)) |
| 1401 |
< |
rename((path)strOniApp, (path)(strTrashDir + strOniApp)); |
| 1402 |
< |
rename((path)(strPathToEUFN + strOniApp), (path)strOniApp); |
| 1400 |
> |
if (exists("../" + strOniApp)) |
| 1401 |
> |
#ifdef WIN32 |
| 1402 |
> |
remove((path)("../" + strOniApp)); |
| 1403 |
> |
#else |
| 1404 |
> |
rename((path)("../" + strOniApp), (path)(strTrashDir + strOniApp)); |
| 1405 |
> |
#endif |
| 1406 |
> |
rename((path)(strPathToEUFN + strOniApp), (path)("../" + strOniApp)); |
| 1407 |
|
} |
| 1408 |
|
if (updateAE->OniSplitVersion.compare(currentAE->OniSplitVersion) >= 1) |
| 1409 |
|
{ |
| 1410 |
|
if (exists(strPathToEUFNInstall + strOniSplit)) |
| 1411 |
|
{ |
| 1412 |
|
if (exists(strOniSplit)) |
| 1413 |
+ |
#ifdef WIN32 |
| 1414 |
+ |
remove((path)strOniSplit); |
| 1415 |
+ |
#else |
| 1416 |
|
rename((path)strOniSplit, (path)(strTrashDir + strOniSplit)); |
| 1417 |
+ |
#endif |
| 1418 |
|
rename((path)(strPathToEUFNInstall + strOniSplit), (path)strOniSplit); |
| 1419 |
|
} |
| 1420 |
|
} |
| 1424 |
|
if (exists(strPathToEUFN + strDaodan)) |
| 1425 |
|
{ |
| 1426 |
|
if (exists(("../" + strDaodan))) |
| 1427 |
< |
rename((path)("../" + strDaodan), (path)(strTrashDir + strDaodan)); |
| 1427 |
> |
remove((path)("../" + strDaodan)); |
| 1428 |
|
rename((path)(strPathToEUFN + strDaodan), (path)("../" + strDaodan)); |
| 1429 |
|
} |
| 1430 |
|
} |
| 1433 |
|
if (exists(strPathToEUFNInstall + strWinGUI)) |
| 1434 |
|
{ |
| 1435 |
|
if (exists((path)strWinGUI)) |
| 1436 |
< |
rename((path)strWinGUI, (path)(strTrashDir + strWinGUI)); |
| 1436 |
> |
remove((path)strWinGUI); |
| 1437 |
|
if (exists(strWinGUILang)) |
| 1438 |
< |
rename((path)strWinGUILang, (path)(strTrashDir + strWinGUILang)); |
| 1438 |
> |
remove((path)strWinGUILang); |
| 1439 |
|
rename((path)(strPathToEUFNInstall + strWinGUI), (path)strWinGUI); |
| 1440 |
|
rename((path)(strPathToEUFNInstall + strWinGUILang), (path)strWinGUILang); |
| 1441 |
|
} |
| 1468 |
|
while (curPos != string::npos && curPos < thePath.size()) |
| 1469 |
|
{ |
| 1470 |
|
aParentPath = aParentPath + thePath.substr(lastPos, curPos - lastPos); |
| 1471 |
+ |
#ifndef WIN32 |
| 1472 |
|
if (!exists(strTrashDir + aParentPath)) |
| 1473 |
|
create_directory(strTrashDir + aParentPath); |
| 1474 |
+ |
#endif |
| 1475 |
|
lastPos = curPos + 1; |
| 1476 |
|
curPos = thePath.find("/", lastPos); |
| 1477 |
|
aParentPath = aParentPath + "/"; |
| 1484 |
|
} |
| 1485 |
|
} |
| 1486 |
|
|
| 1487 |
< |
// Now we crawl the update's package folders for newer versions and move them over, trashing ones that are already present |
| 1341 |
< |
vector<ModPackage> updatePackages, currentPackages; |
| 1342 |
< |
bool matchFound; |
| 1343 |
< |
updatePackages.reserve(256); |
| 1344 |
< |
currentPackages.reserve(256); |
| 1487 |
> |
ProcessPackageUpdates(strPathToEUFNPackages, strPathToPackages); |
| 1488 |
|
|
| 1489 |
< |
currentPackages = getPackages(); |
| 1490 |
< |
updatePackages = getPackages(strPathToEUFNPackages); |
| 1491 |
< |
|
| 1492 |
< |
for (vector<ModPackage>::iterator iter1 = updatePackages.begin(); iter1 != updatePackages.end(); iter1++) |
| 1489 |
> |
// 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... |
| 1490 |
> |
// ...create_directories() function |
| 1491 |
> |
string strPath; |
| 1492 |
> |
path thePath; |
| 1493 |
> |
for (recursive_directory_iterator dir_itr(strPathToEUFNPackages + strGlobalize), end_itr; dir_itr != end_itr; ++dir_itr) |
| 1494 |
|
{ |
| 1495 |
< |
matchFound = false; |
| 1496 |
< |
for (vector<ModPackage>::iterator iter2 = currentPackages.begin(); iter2 != currentPackages.end(); iter2++) |
| 1495 |
> |
strPath = dir_itr->path().string(); |
| 1496 |
> |
MakePathLocalToGlobalize(&strPath); |
| 1497 |
> |
thePath = (path)strPath; |
| 1498 |
> |
if (is_regular_file(dir_itr->status())) |
| 1499 |
|
{ |
| 1500 |
< |
if (!iter1->modStringName.compare(iter2->modStringName)) |
| 1500 |
> |
if (thePath.filename().at(0) != '.') // skip over dot-files, which are invisible in Unix |
| 1501 |
|
{ |
| 1502 |
< |
matchFound = true; |
| 1357 |
< |
if (iter1->modStringVersion > iter2->modStringVersion) |
| 1502 |
> |
if (exists(strPathToPackages + strGlobalize + strPath)) |
| 1503 |
|
{ |
| 1504 |
< |
#ifndef WIN32 |
| 1505 |
< |
rename((path)(strPathToPackages + iter2->modStringName), (path)(strTrashDir + iter2->modStringName)); |
| 1504 |
> |
#ifdef WIN32 |
| 1505 |
> |
remove((path)(strPathToPackages + strGlobalize + strPath)); |
| 1506 |
|
#else |
| 1507 |
< |
remove((path)(strPathToPackages + iter2->modStringName)); |
| 1507 |
> |
create_directories((path)(strTrashDir + thePath.parent_path().string())); |
| 1508 |
> |
rename((path)(strPathToPackages + strGlobalize + strPath), (path)(strTrashDir + strPath)); |
| 1509 |
|
#endif |
| 1510 |
< |
rename((path)(strPathToEUFNPackages + iter1->modStringName), (path)(strPathToPackages + iter1->modStringName)); |
| 1510 |
> |
rename((path)(strPathToEUFNPackages + strGlobalize + strPath), (path)(strPathToPackages + strGlobalize + strPath)); |
| 1511 |
> |
} |
| 1512 |
> |
else |
| 1513 |
> |
{ |
| 1514 |
> |
int slashLoc = 0; |
| 1515 |
> |
slashLoc = strPath.find("/", 0); |
| 1516 |
> |
if (slashLoc != string::npos) // then path contains slashes, so we need to make sure its parents' paths exist before moving it |
| 1517 |
> |
create_directories((path)(strPathToPackages + strGlobalize + thePath.parent_path().string())); |
| 1518 |
> |
rename((path)(strPathToEUFNPackages + strGlobalize + strPath), (path)(strPathToPackages + strGlobalize + strPath)); |
| 1519 |
|
} |
| 1520 |
|
} |
| 1521 |
|
} |
| 1368 |
– |
if (!matchFound) // then there's no old package in the way, so just move in the one from the update |
| 1369 |
– |
rename((path)(strPathToEUFNPackages + iter1->modStringName), (path)(strPathToPackages + iter1->modStringName)); |
| 1370 |
– |
} |
| 1371 |
– |
|
| 1372 |
– |
// 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... |
| 1373 |
– |
// ...and folders which do not exist in the current AE will be created there |
| 1374 |
– |
vector<string> foldersToMake, filesToMove; |
| 1375 |
– |
string thePath; |
| 1376 |
– |
for (recursive_directory_iterator dir_itr(strPathToEUFNPackages + strGlobalize), end_itr; dir_itr != end_itr; ++dir_itr) |
| 1377 |
– |
{ |
| 1378 |
– |
thePath = dir_itr->path().string(); |
| 1379 |
– |
MakePathLocalToGlobalize(&thePath); |
| 1380 |
– |
if (is_regular_file(dir_itr->status())) |
| 1381 |
– |
{ |
| 1382 |
– |
if (dir_itr->filename().at(0) != '.') // skip over dot-files, which are invisible in Unix |
| 1383 |
– |
filesToMove.push_back(thePath); |
| 1384 |
– |
} |
| 1385 |
– |
else if (is_directory(dir_itr->status())) |
| 1386 |
– |
{ |
| 1387 |
– |
if (!exists(strPathToPackages + strGlobalize + thePath)) |
| 1388 |
– |
foldersToMake.push_back(thePath); |
| 1389 |
– |
} |
| 1390 |
– |
} |
| 1391 |
– |
// Sort the foldersToMake strings by length, which is a fast solution to the problem of "How do we make sure we create folder 'parent/'... |
| 1392 |
– |
// ...before folder 'parent/child/'"? |
| 1393 |
– |
sort(foldersToMake.begin(), foldersToMake.end(), SortBySize); // SortBySize is a custom comparison function found later in this source file |
| 1394 |
– |
// First make the folders that don't exist in the current AE, so all the files have a place to go |
| 1395 |
– |
for (vector<string>::iterator iter = foldersToMake.begin(); iter != foldersToMake.end(); iter++) |
| 1396 |
– |
{ |
| 1397 |
– |
create_directory(strPathToPackages + strGlobalize + *iter); |
| 1398 |
– |
} |
| 1399 |
– |
for (vector<string>::iterator iter = filesToMove.begin(); iter != filesToMove.end(); iter++) |
| 1400 |
– |
{ |
| 1401 |
– |
if (exists(strPathToPackages + strGlobalize + *iter)) |
| 1402 |
– |
rename((path)(strPathToPackages + strGlobalize + *iter), (path)(strTrashDir + *iter)); |
| 1403 |
– |
rename((path)(strPathToEUFNPackages + strGlobalize + *iter), (path)(strPathToPackages + strGlobalize + *iter)); |
| 1522 |
|
} |
| 1523 |
|
|
| 1524 |
|
// Clean up after ourselves, trashing any packages or programs in the update package that are not newer than the current AE |
| 1525 |
+ |
#ifdef WIN32 |
| 1526 |
+ |
remove_all((path)strPathToEUFN); |
| 1527 |
+ |
#else |
| 1528 |
|
create_directory(strTrashDir + "Unneeded update files"); |
| 1529 |
|
rename((path)strPathToEUFN, (path)(strTrashDir + "Unneeded update files/" + strEUFN)); |
| 1530 |
< |
|
| 1530 |
> |
#endif |
| 1531 |
|
// Write to log that we are finished with update |
| 1532 |
|
ptime end_time(second_clock::local_time()); |
| 1533 |
|
string progressMsg2 = "Edition was updated to:\n" + |
| 1545 |
|
CheckForGlobalization(true); // the 'true' value forces re-globalization |
| 1546 |
|
|
| 1547 |
|
globalPackages = getPackages(); // refresh the list in memory |
| 1548 |
< |
|
| 1549 |
< |
// TODO: Refresh the packages list in the window |
| 1429 |
< |
|
| 1548 |
> |
wxCommandEvent e; |
| 1549 |
> |
TheWindow->OnRefreshButtonClick( e ); |
| 1550 |
|
return true; |
| 1551 |
+ |
} |
| 1552 |
+ |
catch (exception & ex) |
| 1553 |
+ |
{ |
| 1554 |
+ |
setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 1555 |
+ |
return false; |
| 1556 |
+ |
} |
| 1557 |
+ |
} |
| 1558 |
+ |
|
| 1559 |
+ |
void ProcessPackageUpdates(string pathToUpdate, string strPathToPackages) |
| 1560 |
+ |
{ |
| 1561 |
+ |
ptime startTime(second_clock::local_time()); |
| 1562 |
+ |
#ifdef WIN32 |
| 1563 |
+ |
string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted |
| 1564 |
+ |
#else |
| 1565 |
+ |
FILE *fUserName = NULL; |
| 1566 |
+ |
char chrUserName[32]; |
| 1567 |
+ |
fUserName = popen("whoami", "r"); |
| 1568 |
+ |
fgets(chrUserName, sizeof(chrUserName), fUserName); |
| 1569 |
+ |
pclose(fUserName); |
| 1570 |
+ |
string strUserName = (string)chrUserName; // stringsblaaarrrgggghhhh |
| 1571 |
+ |
int endOfName = strUserName.find("\n", 0); |
| 1572 |
+ |
string strTrashDir = "/Users/" + strUserName.substr(0, endOfName) + "/.Trash/"; |
| 1573 |
+ |
bool needNewTrashDir = true; |
| 1574 |
+ |
tm tmStartTime = to_tm(startTime); |
| 1575 |
+ |
#endif |
| 1576 |
+ |
|
| 1577 |
+ |
try |
| 1578 |
+ |
{ |
| 1579 |
+ |
directory_iterator end; |
| 1580 |
+ |
for (directory_iterator update_iter(pathToUpdate); update_iter != end; ++update_iter) |
| 1581 |
+ |
{ |
| 1582 |
+ |
ModPackage installedPackage, updatePackage; |
| 1583 |
+ |
string updtPath = update_iter->path().string(); |
| 1584 |
+ |
string updtFolder = update_iter->path().filename(); |
| 1585 |
+ |
string updtModInfo = updtPath + "/Mod_Info.cfg"; |
| 1586 |
+ |
string instModInfo = strPathToPackages + "/" + updtFolder + "/Mod_Info.cfg"; |
| 1587 |
+ |
if (!boost::iequals(updtFolder, "Edition") |
| 1588 |
+ |
&& !boost::iequals(updtFolder, "Edition-patch") |
| 1589 |
+ |
&& is_directory(update_iter->path()) |
| 1590 |
+ |
&& exists(updtModInfo)) |
| 1591 |
+ |
{ |
| 1592 |
+ |
fstream file; |
| 1593 |
+ |
file.open((updtModInfo).c_str()); |
| 1594 |
+ |
if (!file.fail()) |
| 1595 |
+ |
updatePackage = fileToModPackage(file, updtFolder); |
| 1596 |
+ |
else |
| 1597 |
+ |
{ |
| 1598 |
+ |
file.close(); |
| 1599 |
+ |
continue; |
| 1600 |
+ |
} |
| 1601 |
+ |
if (exists(instModInfo)) |
| 1602 |
+ |
{ |
| 1603 |
+ |
file.close(); |
| 1604 |
+ |
file.clear(); |
| 1605 |
+ |
file.open(instModInfo.c_str()); |
| 1606 |
+ |
if (!file.fail()) |
| 1607 |
+ |
{ |
| 1608 |
+ |
installedPackage = fileToModPackage(file, updtFolder); |
| 1609 |
+ |
} |
| 1610 |
+ |
file.close(); |
| 1611 |
+ |
} |
| 1612 |
+ |
file.close(); |
| 1613 |
+ |
if (updatePackage.modStringVersion > installedPackage.modStringVersion) |
| 1614 |
+ |
{ |
| 1615 |
+ |
if (updatePackage.installerVersion <= INSTALLER_VERSION) |
| 1616 |
+ |
{ |
| 1617 |
+ |
if(exists(strPathToPackages + "/" + updatePackage.modStringName)) { |
| 1618 |
+ |
#ifdef WIN32 |
| 1619 |
+ |
remove_all((path)(strPathToPackages + "/" + updatePackage.modStringName)); |
| 1620 |
+ |
#else |
| 1621 |
+ |
if (needNewTrashDir) |
| 1622 |
+ |
{ |
| 1623 |
+ |
strTrashDir = strTrashDir + "Old_packages_" + boost::lexical_cast<string>(tmStartTime.tm_hour) + "-" + |
| 1624 |
+ |
boost::lexical_cast<string>(tmStartTime.tm_min) + "-" + boost::lexical_cast<string>(tmStartTime.tm_sec) + "/"; |
| 1625 |
+ |
create_directory(strTrashDir); |
| 1626 |
+ |
needNewTrashDir = false; |
| 1627 |
+ |
} |
| 1628 |
+ |
rename((path)(strPathToPackages + "/" + updatePackage.modStringName), (path)(strTrashDir + updatePackage.modStringName)); |
| 1629 |
+ |
#endif |
| 1630 |
+ |
} |
| 1631 |
+ |
rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName)); |
| 1632 |
+ |
} |
| 1633 |
+ |
} |
| 1634 |
+ |
} |
| 1635 |
+ |
} |
| 1636 |
+ |
} |
| 1637 |
+ |
catch (exception & ex) |
| 1638 |
+ |
{ |
| 1639 |
+ |
setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 1640 |
+ |
} |
| 1641 |
+ |
wxCommandEvent e; |
| 1642 |
+ |
TheWindow->OnRefreshButtonClick( e ); |
| 1643 |
|
} |
| 1644 |
|
|
| 1645 |
|
/* MakePathLocalToGlobalize is a function used once by ProcessAEUpdate() that takes a file in an \ |
| 1738 |
|
|
| 1739 |
|
} |
| 1740 |
|
else if(from_ph.filename() != ".svn") |
| 1741 |
< |
{ |
| 1742 |
< |
path destination; |
| 1743 |
< |
if(!exists(to_ph)) |
| 1744 |
< |
{ |
| 1745 |
< |
destination=to_ph; |
| 1746 |
< |
} |
| 1747 |
< |
else |
| 1748 |
< |
{ |
| 1749 |
< |
destination=to_ph/from_ph.filename(); |
| 1750 |
< |
} |
| 1741 |
> |
{ |
| 1742 |
> |
path destination; |
| 1743 |
> |
if(!exists(to_ph)) |
| 1744 |
> |
{ |
| 1745 |
> |
destination=to_ph; |
| 1746 |
> |
} |
| 1747 |
> |
else |
| 1748 |
> |
{ |
| 1749 |
> |
destination=to_ph/from_ph.filename(); |
| 1750 |
> |
} |
| 1751 |
|
|
| 1752 |
< |
for(directory_iterator i(from_ph); i!=directory_iterator(); ++i) |
| 1752 |
> |
for(directory_iterator i(from_ph); i!=directory_iterator(); ++i) |
| 1753 |
|
{ |
| 1754 |
|
//the idiot who coded this in the first place (not me) |
| 1755 |
|
//forgot to make a new directory. Exception city. x_x |
| 1756 |
< |
create_directory(destination); |
| 1757 |
< |
copy(*i,destination/i->filename()); |
| 1756 |
> |
create_directory(destination); |
| 1757 |
> |
copy(*i, destination/i->filename()); |
| 1758 |
|
} |
| 1759 |
|
} |
| 1760 |
|
} |
| 1808 |
|
name = ""; |
| 1809 |
|
modStringName = ""; |
| 1810 |
|
modStringVersion = 0; |
| 1811 |
+ |
platform = "Both"; |
| 1812 |
|
hasOnis = false; |
| 1813 |
|
hasDeltas = false; |
| 1814 |
|
hasBSL = false; |