| 302 |  | /* 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). | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 303 |  | 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 | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 304 |  | run Oni before :-p */ | 
 
 
 
 
 
 
 
 
 
 
 | 305 | < | string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for edition/ | 
 
 
 
 
 
 
 
 
 | 305 | > | string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for Edition/ (Oni wants the folder that *contains* the GDF) | 
 
 
 
 
 
 
 
 
 
 
 | 306 |  | char prefsCommand[300] = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '"; | 
 
 
 
 
 
 
 
 
 
 
 | 307 | < | strcat(prefsCommand, fullAEpath.c_str()); // get path of Edition/ folder (Oni wants the folder that *contains* the GDF) | 
 
 
 
 
 
 
 
 
 | 307 | > | strcat(prefsCommand, fullAEpath.c_str()); | 
 
 
 
 
 
 
 
 
 
 
 | 308 |  | strcat(prefsCommand, "'"); // path string is enclosed in single quotes to avoid the need to escape UNIX-unfriendly characters | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 309 |  | system(prefsCommand); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 310 |  | #endif | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 326 |  | vector<ModPackage> getPackages(string packageDir) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 327 |  | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 328 |  | vector<ModPackage> packages; | 
 
 
 
 
 
 
 
 | 329 | + | ModPackage package; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 330 |  | packages.reserve(256); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 331 |  | fstream file; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 332 |  | string filename = "\0"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 338 |  | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 339 |  | file.open((dir_itr->path().string() + "/" + MODINFO_CFG).c_str()); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 340 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 341 | < | if(!file.fail()) | 
 
 
 
 
 
 
 
 
 | 341 | > | if (!file.fail()) | 
 
 
 
 
 
 
 
 
 
 
 | 342 |  | { | 
 
 
 
 
 
 
 
 
 
 
 | 343 | < | //would prefer to push a pointer to a package, but this will do for now | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 344 | < | packages.push_back(fileToModPackage(file)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 343 | > | package = fileToModPackage(file); | 
 
 
 
 
 | 344 | > | if (package.installerVersion.compare(INSTALLER_VERSION) < 1)  // if mod requires newer version of the Installer, we won't add it to the list | 
 
 
 
 
 | 345 | > | packages.push_back(package); | 
 
 
 
 
 
 
 
 
 
 
 | 346 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 347 |  | file.close(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 348 |  | file.clear(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 369 |  | */ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 370 |  | ModPackage package; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 371 |  | string line; | 
 
 
 
 
 
 
 
 
 
 
 | 372 | < | static string NameOfMod = "NameOfMod";  //used for comparing to the current token... | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 373 | < | //I could have done it in reverse (*iter).compare("ModString") or | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 374 | < | static string ARROW = "->";                             //did something like "ModString".compare(*iter), and it would have been | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 375 | < | static string ModString = "ModString";  //functionably the same. | 
 
 
 
 
 
 
 
 
 | 372 | > | static string AEInstallVersion = "AEInstallVersion"; // used for comparing to the current token... | 
 
 
 
 
 | 373 | > | static string NameOfMod = "NameOfMod"; | 
 
 
 
 
 | 374 | > | static string ARROW = "->"; | 
 
 
 
 
 | 375 | > | static string ModString = "ModString"; | 
 
 
 
 
 
 
 
 
 
 
 | 376 |  | static string HasOnis = "HasOnis"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 377 |  | static string HasDeltas = "HasDeltas"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 378 |  | static string HasBSL = "HasBSL"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 382 |  | static string GlobalNeeded = "GlobalNeeded"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 383 |  | static string Category = "Category"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 384 |  | static string Creator = "Creator"; | 
 
 
 
 
 
 
 
 
 
 
 | 385 | < | while (! file.eof() ) | 
 
 
 
 
 
 
 
 
 | 385 | > | while (!file.eof()) | 
 
 
 
 
 
 
 
 
 
 
 | 386 |  | { | 
 
 
 
 
 
 
 
 
 
 
 | 387 | < | getline (file,line); | 
 
 
 
 
 
 
 
 
 | 387 | > | getline(file,line); | 
 
 
 
 
 
 
 
 
 
 
 | 388 |  | vector<string> tokens; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 389 |  | vector<string>::iterator iter; | 
 
 
 
 
 
 
 
 
 
 
 | 390 | < | tokenize(line, tokens);                                 //string to vector of "words" | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 391 | < | if (tokens.capacity() >= 3) {                   //make sure they are using enough stuff | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 392 | < | iter = tokens.begin();                          //what word we are on, starts at first word | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 393 | < | /* TODO: Get this "required Installer version" code working | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 394 | < | if (!AEInstallVersion.compare(*iter)) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 395 | < | If mod is too old, skip this mod. | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 396 | < | */ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 397 | < | /*else*/if (!NameOfMod.compare(*iter))  {       //if it contains the name | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 398 | < | for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) {     // iterates through the words, ends if it reaches the end of the line or a "//" comment | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 399 | < | if (ARROW.compare(*iter) && NameOfMod.compare(*iter)) {                 // ignores "->" and "NameOfMod" | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 390 | > | tokenize(line, tokens); | 
 
 
 
 
 | 391 | > | if (tokens.capacity() >= 3) | 
 
 
 
 
 | 392 | > | { | 
 
 
 
 
 | 393 | > | iter = tokens.begin(); | 
 
 
 
 
 | 394 | > |  | 
 
 
 
 
 | 395 | > | if (!AEInstallVersion.compare(*iter)) | 
 
 
 
 
 | 396 | > | { | 
 
 
 
 
 | 397 | > | iter++; iter++; | 
 
 
 
 
 | 398 | > | package.installerVersion = *iter; | 
 
 
 
 
 | 399 | > | } | 
 
 
 
 
 | 400 | > | else if (!NameOfMod.compare(*iter)) | 
 
 
 
 
 | 401 | > | { | 
 
 
 
 
 | 402 | > | for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) // iterates through the words, ends if it reaches the end of the line or a "//" comment | 
 
 
 
 
 | 403 | > | { | 
 
 
 
 
 | 404 | > | if (ARROW.compare(*iter) && NameOfMod.compare(*iter)) // ignores "->" and "NameOfMod" | 
 
 
 
 
 
 
 
 
 
 
 | 405 |  | package.name += *iter + " "; | 
 
 
 
 
 
 
 
 
 | 399 | – | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 406 |  | } | 
 
 
 
 
 
 
 
 
 | 401 | – |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 407 |  | } | 
 
 
 
 
 
 
 
 
 
 
 | 408 | < | else if (!ModString.compare(*iter)) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 408 | > | else if (!ModString.compare(*iter)) | 
 
 
 
 
 | 409 | > | { | 
 
 
 
 
 
 
 
 
 
 
 | 410 |  | iter++; iter++; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 411 |  | package.modStringName = *iter; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 412 |  | iter++; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 413 |  | package.modStringVersion = atoi((*iter).c_str()); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 414 |  | } | 
 
 
 
 
 
 
 
 
 
 
 | 415 | < | else if (!HasOnis.compare(*iter)) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 415 | > | else if (!HasOnis.compare(*iter)) | 
 
 
 
 
 | 416 | > | { | 
 
 
 
 
 
 
 
 
 
 
 | 417 |  | iter++; iter++; | 
 
 
 
 
 
 
 
 
 
 
 | 418 | < | if ( boost::iequals(*iter, "Yes")) package.hasOnis = 1; | 
 
 
 
 
 
 
 
 
 | 418 | > | if (boost::iequals(*iter, "Yes")) package.hasOnis = 1; | 
 
 
 
 
 
 
 
 
 
 
 | 419 |  | } | 
 
 
 
 
 
 
 
 
 
 
 | 420 | < | else if (!HasBSL.compare(*iter)) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 421 | < | if(toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasBSL = true; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 422 | < | else if ( boost::iequals(*iter, "Addon")) package.hasAddon = true; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 420 | > | else if (!HasBSL.compare(*iter)) | 
 
 
 
 
 | 421 | > | { | 
 
 
 
 
 | 422 | > | iter++; iter++; | 
 
 
 
 
 | 423 | > | if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasBSL = true; | 
 
 
 
 
 | 424 | > | else if (boost::iequals(*iter, "Addon")) package.hasAddon = true; | 
 
 
 
 
 
 
 
 
 
 
 | 425 |  | } | 
 
 
 
 
 
 
 
 
 
 
 | 426 | < | else if (!HasDeltas.compare(*iter)) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 426 | > | else if (!HasDeltas.compare(*iter)) | 
 
 
 
 
 | 427 | > | { | 
 
 
 
 
 
 
 
 
 
 
 | 428 |  | iter++; iter++; | 
 
 
 
 
 
 
 
 
 
 
 | 429 | < | if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDeltas = 1; | 
 
 
 
 
 
 
 
 
 | 429 | > | if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasDeltas = 1; | 
 
 
 
 
 
 
 
 
 
 
 | 430 |  | } | 
 
 
 
 
 
 
 
 
 
 
 | 431 | < | else if (!HasDats.compare(*iter)) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 431 | > | else if (!HasDats.compare(*iter)) | 
 
 
 
 
 | 432 | > | { | 
 
 
 
 
 
 
 
 
 
 
 | 433 |  | iter++; iter++; | 
 
 
 
 
 
 
 
 
 
 
 | 434 | < | if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDats = 1; | 
 
 
 
 
 
 
 
 
 | 434 | > | if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasDats = 1; | 
 
 
 
 
 
 
 
 
 
 
 | 435 |  | } | 
 
 
 
 
 
 
 
 
 
 
 | 436 | < | else if (!IsEngine.compare(*iter)) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 436 | > | else if (!IsEngine.compare(*iter)) | 
 
 
 
 
 | 437 | > | { | 
 
 
 
 
 
 
 
 
 
 
 | 438 |  | iter++; iter++; | 
 
 
 
 
 
 
 
 
 
 
 | 439 | < | if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.isEngine = 1; | 
 
 
 
 
 
 
 
 
 | 439 | > | if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.isEngine = 1; | 
 
 
 
 
 
 
 
 
 
 
 | 440 |  | } | 
 
 
 
 
 
 
 
 
 
 
 | 441 | < | else if (!GlobalNeeded.compare(*iter)) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 441 | > | else if (!GlobalNeeded.compare(*iter)) | 
 
 
 
 
 | 442 | > | { | 
 
 
 
 
 
 
 
 
 
 
 | 443 |  | iter++; iter++; | 
 
 
 
 
 
 
 
 
 
 
 | 444 | < | if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.globalNeeded = 1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 445 | < | else if (toupper((*iter)[0]) + toupper((*iter)[1]) == 'N' + 'O') package.globalNeeded = 1; // only place where checking for "No" is important atm. | 
 
 
 
 
 
 
 
 
 | 444 | > | if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.globalNeeded = 1; | 
 
 
 
 
 | 445 | > | else if (toupper((*iter)[0]) == 'N' && toupper((*iter)[1]) == 'O') package.globalNeeded = 1; // only place where checking for "No" is important atm | 
 
 
 
 
 
 
 
 
 
 
 | 446 |  | } | 
 
 
 
 
 
 
 
 
 
 
 | 447 | < | else if (!Category.compare(*iter))  { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 448 | < | for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) {     // iterates through the words, ends if it reaches end of line or a "//" comment | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 449 | < | if (ARROW.compare(*iter) && Category.compare(*iter)) {                  // ignores "->" and "Category" | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 447 | > | else if (!Category.compare(*iter)) | 
 
 
 
 
 | 448 | > | { | 
 
 
 
 
 | 449 | > | for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) | 
 
 
 
 
 | 450 | > | { | 
 
 
 
 
 | 451 | > | if (ARROW.compare(*iter) && Category.compare(*iter)) // ignores "->" and "Category" | 
 
 
 
 
 
 
 
 
 
 
 | 452 |  | package.category += *iter + " "; | 
 
 
 
 
 
 
 
 
 | 438 | – | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 453 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 454 |  | } | 
 
 
 
 
 
 
 
 
 
 
 | 455 | < | else if (!Creator.compare(*iter))  {    //if it contains the name | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 456 | < | for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) {     // iterates through the words, ends if it reaches end of line or a "//" comment | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 457 | < | if (ARROW.compare(*iter) && Creator.compare(*iter)) {                   // ignores "->" and "Creator" | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 455 | > | else if (!Creator.compare(*iter)) | 
 
 
 
 
 | 456 | > | { | 
 
 
 
 
 | 457 | > | for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) | 
 
 
 
 
 | 458 | > | { | 
 
 
 
 
 | 459 | > | if (ARROW.compare(*iter) && Creator.compare(*iter)) // ignores "->" and "Creator" | 
 
 
 
 
 
 
 
 
 
 
 | 460 |  | package.creator += *iter + " "; | 
 
 
 
 
 
 
 
 
 | 445 | – | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 461 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 462 |  | } | 
 
 
 
 
 
 
 
 
 
 
 | 463 | < | else if (!Readme.compare(*iter))  {     //if it contains the name | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 464 | < | for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) {     // iterates through the words, ends if it reaches end of line or a "//" comment | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 465 | < | if (ARROW.compare(*iter) && Readme.compare(*iter)) {                    // ignores "->" and "Readme" | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 466 | < | if(!(*iter).compare("\\n")) package.readme += '\n'; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 463 | > | else if (!Readme.compare(*iter)) | 
 
 
 
 
 | 464 | > | { | 
 
 
 
 
 | 465 | > | for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) | 
 
 
 
 
 | 466 | > | { | 
 
 
 
 
 | 467 | > | if (ARROW.compare(*iter) && Readme.compare(*iter)) // ignores "->" and "Readme" | 
 
 
 
 
 | 468 | > | { | 
 
 
 
 
 | 469 | > | if (!(*iter).compare("\\n")) package.readme += '\n'; | 
 
 
 
 
 
 
 
 
 
 
 | 470 |  | else package.readme += *iter + " "; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 471 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 472 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 473 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 474 |  | } | 
 
 
 
 
 
 
 
 
 | 457 | – |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 475 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 476 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 477 |  | return package; |