Changeset 500 for AE/Installer/trunk/source/installer.cpp
- Timestamp:
- Mar 15, 2010, 12:31:14 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/Installer/trunk/source/installer.cpp
r499 r500 303 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 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 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 308 strcat(prefsCommand, "'"); // path string is enclosed in single quotes to avoid the need to escape UNIX-unfriendly characters 309 309 system(prefsCommand); … … 327 327 { 328 328 vector<ModPackage> packages; 329 ModPackage package; 329 330 packages.reserve(256); 330 331 fstream file; … … 338 339 file.open((dir_itr->path().string() + "/" + MODINFO_CFG).c_str()); 339 340 340 if(!file.fail()) 341 { 342 //would prefer to push a pointer to a package, but this will do for now 343 packages.push_back(fileToModPackage(file)); 341 if (!file.fail()) 342 { 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); 344 346 } 345 347 file.close(); … … 368 370 ModPackage package; 369 371 string line; 370 static string NameOfMod = "NameOfMod"; //used for comparing to the current token...371 //I could have done it in reverse (*iter).compare("ModString") or372 static string ARROW = "->"; //did something like "ModString".compare(*iter), and it would have been373 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"; 374 376 static string HasOnis = "HasOnis"; 375 377 static string HasDeltas = "HasDeltas"; … … 381 383 static string Category = "Category"; 382 384 static string Creator = "Creator"; 383 while (! file.eof())384 { 385 getline 385 while (!file.eof()) 386 { 387 getline(file,line); 386 388 vector<string> tokens; 387 389 vector<string>::iterator iter; 388 tokenize(line, tokens); //string to vector of "words" 389 if (tokens.capacity() >= 3) { //make sure they are using enough stuff 390 iter = tokens.begin(); //what word we are on, starts at first word 391 /* TODO: Get this "required Installer version" code working 392 if (!AEInstallVersion.compare(*iter)) 393 If mod is too old, skip this mod. 394 */ 395 /*else*/if (!NameOfMod.compare(*iter)) { //if it contains the name 396 for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { // iterates through the words, ends if it reaches the end of the line or a "//" comment 397 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" 398 405 package.name += *iter + " "; 399 } 400 } 401 402 } 403 else if (!ModString.compare(*iter)) { 406 } 407 } 408 else if (!ModString.compare(*iter)) 409 { 404 410 iter++; iter++; 405 411 package.modStringName = *iter; … … 407 413 package.modStringVersion = atoi((*iter).c_str()); 408 414 } 409 else if (!HasOnis.compare(*iter)) { 415 else if (!HasOnis.compare(*iter)) 416 { 410 417 iter++; iter++; 411 if ( 418 if (boost::iequals(*iter, "Yes")) package.hasOnis = 1; 412 419 } 413 else if (!HasBSL.compare(*iter)) { 414 if(toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasBSL = true; 415 else if ( boost::iequals(*iter, "Addon")) package.hasAddon = true; 416 } 417 else if (!HasDeltas.compare(*iter)) { 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)) 427 { 418 428 iter++; iter++; 419 if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDeltas = 1; 420 } 421 else if (!HasDats.compare(*iter)) { 429 if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasDeltas = 1; 430 } 431 else if (!HasDats.compare(*iter)) 432 { 422 433 iter++; iter++; 423 if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDats = 1; 424 } 425 else if (!IsEngine.compare(*iter)) { 434 if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasDats = 1; 435 } 436 else if (!IsEngine.compare(*iter)) 437 { 426 438 iter++; iter++; 427 if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.isEngine = 1; 428 } 429 else if (!GlobalNeeded.compare(*iter)) { 439 if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.isEngine = 1; 440 } 441 else if (!GlobalNeeded.compare(*iter)) 442 { 430 443 iter++; iter++; 431 if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.globalNeeded = 1; 432 else if (toupper((*iter)[0]) + toupper((*iter)[1]) == 'N' + 'O') package.globalNeeded = 1; // only place where checking for "No" is important atm. 433 } 434 else if (!Category.compare(*iter)) { 435 for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { // iterates through the words, ends if it reaches end of line or a "//" comment 436 if (ARROW.compare(*iter) && Category.compare(*iter)) { // ignores "->" and "Category" 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 { 449 for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) 450 { 451 if (ARROW.compare(*iter) && Category.compare(*iter)) // ignores "->" and "Category" 437 452 package.category += *iter + " "; 438 } 439 } 440 } 441 else if (!Creator.compare(*iter)) { //if it contains the name 442 for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { // iterates through the words, ends if it reaches end of line or a "//" comment 443 if (ARROW.compare(*iter) && Creator.compare(*iter)) { // ignores "->" and "Creator" 453 } 454 } 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" 444 460 package.creator += *iter + " "; 445 } 446 } 447 } 448 else if (!Readme.compare(*iter)) { //if it contains the name 449 for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { // iterates through the words, ends if it reaches end of line or a "//" comment 450 if (ARROW.compare(*iter) && Readme.compare(*iter)) { // ignores "->" and "Readme" 451 if(!(*iter).compare("\\n")) package.readme += '\n'; 461 } 462 } 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'; 452 470 else package.readme += *iter + " "; 453 471 } … … 455 473 } 456 474 } 457 458 475 } 459 476
Note:
See TracChangeset
for help on using the changeset viewer.