Ignore:
Timestamp:
Mar 15, 2010, 12:31:14 AM (15 years ago)
Author:
iritscen
Message:

Changed 'Installer replacement failed' message so user can choose not to quit.
Fixed BSL mod package-detecting bug and other dubious flag-detecting code.
Added check for required Installer version when scanning package info files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • AE/Installer/trunk/source/installer.cpp

    r499 r500  
    303303                 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
    304304                 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)
    306306                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());
    308308                strcat(prefsCommand, "'"); // path string is enclosed in single quotes to avoid the need to escape UNIX-unfriendly characters
    309309                system(prefsCommand);
     
    327327{
    328328        vector<ModPackage> packages;
     329        ModPackage package;
    329330        packages.reserve(256);
    330331        fstream file;
     
    338339                        file.open((dir_itr->path().string() + "/" + MODINFO_CFG).c_str());
    339340                       
    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);
    344346                        }       
    345347                        file.close();
     
    368370        ModPackage package;
    369371        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") or 
    372         static string ARROW = "->";                             //did something like "ModString".compare(*iter), and it would have been
    373         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";
    374376        static string HasOnis = "HasOnis";
    375377        static string HasDeltas = "HasDeltas";
     
    381383        static string Category = "Category";
    382384        static string Creator = "Creator";
    383         while (! file.eof() )
    384         {
    385                 getline (file,line);
     385        while (!file.eof())
     386        {
     387                getline(file,line);
    386388                vector<string> tokens;
    387389                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"
    398405                                                package.name += *iter + " ";
    399                                         }
    400                                 }
    401                                
    402                         }
    403                         else if (!ModString.compare(*iter)) {
     406                                }
     407                        }
     408                        else if (!ModString.compare(*iter))
     409                        {
    404410                                iter++; iter++;
    405411                                package.modStringName = *iter;
     
    407413                                package.modStringVersion = atoi((*iter).c_str());
    408414                        }
    409                         else if (!HasOnis.compare(*iter)) {
     415                        else if (!HasOnis.compare(*iter))
     416                        {
    410417                                iter++; iter++; 
    411                                 if ( boost::iequals(*iter, "Yes")) package.hasOnis = 1;
     418                                if (boost::iequals(*iter, "Yes")) package.hasOnis = 1;
    412419                        }       
    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                        {
    418428                                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                        {
    422433                                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                        {
    426438                                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                        {
    430443                                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"
    437452                                                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"
    444460                                                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';
    452470                                                else package.readme += *iter + " ";
    453471                                        }
     
    455473                        }
    456474                }
    457                
    458475        }
    459476
Note: See TracChangeset for help on using the changeset viewer.