--- AE/Installer/trunk/source/installer.cpp 2010/03/03 02:09:02 499 +++ AE/Installer/trunk/source/installer.cpp 2010/03/14 23:31:14 500 @@ -302,9 +302,9 @@ int globalizeData(void) /* 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). 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 run Oni before :-p */ - string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for edition/ + string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for Edition/ (Oni wants the folder that *contains* the GDF) char prefsCommand[300] = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '"; - strcat(prefsCommand, fullAEpath.c_str()); // get path of Edition/ folder (Oni wants the folder that *contains* the GDF) + strcat(prefsCommand, fullAEpath.c_str()); strcat(prefsCommand, "'"); // path string is enclosed in single quotes to avoid the need to escape UNIX-unfriendly characters system(prefsCommand); #endif @@ -326,6 +326,7 @@ int globalizeData(void) vector getPackages(string packageDir) { vector packages; + ModPackage package; packages.reserve(256); fstream file; string filename = "\0"; @@ -337,10 +338,11 @@ vector getPackages(string pa { file.open((dir_itr->path().string() + "/" + MODINFO_CFG).c_str()); - if(!file.fail()) + if (!file.fail()) { - //would prefer to push a pointer to a package, but this will do for now - packages.push_back(fileToModPackage(file)); + package = fileToModPackage(file); + if (package.installerVersion.compare(INSTALLER_VERSION) < 1) // if mod requires newer version of the Installer, we won't add it to the list + packages.push_back(package); } file.close(); file.clear(); @@ -367,10 +369,10 @@ ModPackage fileToModPackage(fstream &fil */ ModPackage package; string line; - static string NameOfMod = "NameOfMod"; //used for comparing to the current token... - //I could have done it in reverse (*iter).compare("ModString") or - static string ARROW = "->"; //did something like "ModString".compare(*iter), and it would have been - static string ModString = "ModString"; //functionably the same. + static string AEInstallVersion = "AEInstallVersion"; // used for comparing to the current token... + static string NameOfMod = "NameOfMod"; + static string ARROW = "->"; + static string ModString = "ModString"; static string HasOnis = "HasOnis"; static string HasDeltas = "HasDeltas"; static string HasBSL = "HasBSL"; @@ -380,81 +382,96 @@ ModPackage fileToModPackage(fstream &fil static string GlobalNeeded = "GlobalNeeded"; static string Category = "Category"; static string Creator = "Creator"; - while (! file.eof() ) + while (!file.eof()) { - getline (file,line); + getline(file,line); vector tokens; vector::iterator iter; - tokenize(line, tokens); //string to vector of "words" - if (tokens.capacity() >= 3) { //make sure they are using enough stuff - iter = tokens.begin(); //what word we are on, starts at first word - /* TODO: Get this "required Installer version" code working - if (!AEInstallVersion.compare(*iter)) - If mod is too old, skip this mod. - */ - /*else*/if (!NameOfMod.compare(*iter)) { //if it contains the name - for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { // iterates through the words, ends if it reaches the end of the line or a "//" comment - if (ARROW.compare(*iter) && NameOfMod.compare(*iter)) { // ignores "->" and "NameOfMod" + tokenize(line, tokens); + if (tokens.capacity() >= 3) + { + iter = tokens.begin(); + + if (!AEInstallVersion.compare(*iter)) + { + iter++; iter++; + package.installerVersion = *iter; + } + else if (!NameOfMod.compare(*iter)) + { + for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) // iterates through the words, ends if it reaches the end of the line or a "//" comment + { + if (ARROW.compare(*iter) && NameOfMod.compare(*iter)) // ignores "->" and "NameOfMod" package.name += *iter + " "; - } } - } - else if (!ModString.compare(*iter)) { + else if (!ModString.compare(*iter)) + { iter++; iter++; package.modStringName = *iter; iter++; package.modStringVersion = atoi((*iter).c_str()); } - else if (!HasOnis.compare(*iter)) { + else if (!HasOnis.compare(*iter)) + { iter++; iter++; - if ( boost::iequals(*iter, "Yes")) package.hasOnis = 1; + if (boost::iequals(*iter, "Yes")) package.hasOnis = 1; } - else if (!HasBSL.compare(*iter)) { - if(toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasBSL = true; - else if ( boost::iequals(*iter, "Addon")) package.hasAddon = true; + else if (!HasBSL.compare(*iter)) + { + iter++; iter++; + if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasBSL = true; + else if (boost::iequals(*iter, "Addon")) package.hasAddon = true; } - else if (!HasDeltas.compare(*iter)) { + else if (!HasDeltas.compare(*iter)) + { iter++; iter++; - if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDeltas = 1; + if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasDeltas = 1; } - else if (!HasDats.compare(*iter)) { + else if (!HasDats.compare(*iter)) + { iter++; iter++; - if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDats = 1; + if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasDats = 1; } - else if (!IsEngine.compare(*iter)) { + else if (!IsEngine.compare(*iter)) + { iter++; iter++; - if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.isEngine = 1; + if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.isEngine = 1; } - else if (!GlobalNeeded.compare(*iter)) { + else if (!GlobalNeeded.compare(*iter)) + { iter++; iter++; - if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.globalNeeded = 1; - else if (toupper((*iter)[0]) + toupper((*iter)[1]) == 'N' + 'O') package.globalNeeded = 1; // only place where checking for "No" is important atm. + if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.globalNeeded = 1; + else if (toupper((*iter)[0]) == 'N' && toupper((*iter)[1]) == 'O') package.globalNeeded = 1; // only place where checking for "No" is important atm } - else if (!Category.compare(*iter)) { - for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { // iterates through the words, ends if it reaches end of line or a "//" comment - if (ARROW.compare(*iter) && Category.compare(*iter)) { // ignores "->" and "Category" + else if (!Category.compare(*iter)) + { + for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) + { + if (ARROW.compare(*iter) && Category.compare(*iter)) // ignores "->" and "Category" package.category += *iter + " "; - } } } - else if (!Creator.compare(*iter)) { //if it contains the name - for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { // iterates through the words, ends if it reaches end of line or a "//" comment - if (ARROW.compare(*iter) && Creator.compare(*iter)) { // ignores "->" and "Creator" + else if (!Creator.compare(*iter)) + { + for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) + { + if (ARROW.compare(*iter) && Creator.compare(*iter)) // ignores "->" and "Creator" package.creator += *iter + " "; - } } } - else if (!Readme.compare(*iter)) { //if it contains the name - for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { // iterates through the words, ends if it reaches end of line or a "//" comment - if (ARROW.compare(*iter) && Readme.compare(*iter)) { // ignores "->" and "Readme" - if(!(*iter).compare("\\n")) package.readme += '\n'; + else if (!Readme.compare(*iter)) + { + for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) + { + if (ARROW.compare(*iter) && Readme.compare(*iter)) // ignores "->" and "Readme" + { + if (!(*iter).compare("\\n")) package.readme += '\n'; else package.readme += *iter + " "; } } } } - } return package;