Example #1
0
char *D_FindIWAD(int mask, GameMission_t *mission)
{
    char *result;
    char *iwadfile;
    int iwadparm;
    int i;

    // Check for the -iwad parameter

    //!
    // Specify an IWAD file to use.
    //
    // @arg <file>
    //

    iwadparm = M_CheckParmWithArgs("-iwad", 1);

    if (iwadparm)
    {
        // Search through IWAD dirs for an IWAD with the given name.

        iwadfile = myargv[iwadparm + 1];

        result = D_FindWADByName(iwadfile);

        if (result == NULL)
        {
            I_Error("IWAD file '%s' not found!", iwadfile);
        }
        
        *mission = IdentifyIWADByName(result, mask);
    }
    else
    {
        // Search through the list and look for an IWAD

        result = NULL;

        BuildIWADDirList();
    
        for (i=0; result == NULL && i<num_iwad_dirs; ++i)
        {
            result = SearchDirectoryForIWAD(iwad_dirs[i], mask, mission);
        }
    }

    return result;
}
Example #2
0
//
// FindIWAD
// Checks availability of IWAD files by name,
// to determine whether registered/commercial features
// should be executed (notably loading PWADs).
//
char *D_FindIWAD(void)
{
    char        *result = NULL;
    char        *iwadfile;
    int         iwadparm = M_CheckParmWithArgs("-iwad", 1);

    if (iwadparm)
    {
        // Search through IWAD dirs for an IWAD with the given name.
        iwadfile = myargv[iwadparm + 1];

        result = D_FindWADByName(iwadfile);

        if (result == NULL)
            I_Error("The IWAD file \"%s\" wasn't found!", iwadfile);

        IdentifyIWADByName(result);
    }

    return result;
}
Example #3
0
static int D_ChooseIWAD(void)
{
    OPENFILENAME        ofn;
    char                szFile[4096];
    int                 iwadfound = -1;
    boolean             sharewareiwad = false;

    ZeroMemory(&ofn, sizeof(ofn));
    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = NULL;
    ofn.lpstrFile = szFile;
    ofn.lpstrFile[0] = '\0';
    ofn.nMaxFile = sizeof(szFile);
    ofn.lpstrFilter = "IWAD/PWAD Files (*.wad)\0*.WAD\0";
    ofn.nFilterIndex = 1;
    ofn.lpstrFileTitle = NULL;
    ofn.nMaxFileTitle = 0;
    ofn.lpstrInitialDir = wadfolder;
    ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_ALLOWMULTISELECT
                | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_EXPLORER;
    ofn.lpstrTitle = "Where\u2019s All the Data?\0";

    if (GetOpenFileName(&ofn))
    {
        iwadfound = 0;

        // only one file was selected
        if (!ofn.lpstrFile[strlen(ofn.lpstrFile) + 1])
        {
            LPSTR       file = ofn.lpstrFile;

            wadfolder = strdup(M_ExtractFolder(file));

            // check if it's a valid and supported IWAD
            if (D_IsDOOMIWAD(file)
                || (W_WadType(file) == IWAD
                    && !D_IsUnsupportedIWAD(file)))
            {
                IdentifyIWADByContents(file, &gamemode, &gamemission);
                if (D_AddFile(file))
                    iwadfound = 1;
            }

            // if it's a PWAD, determine the IWAD required and try loading that as well
            else if (!D_CheckFilename(file, "DOOMRETRO.WAD")
                     && W_WadType(file) == PWAD
                     && !D_IsUnsupportedPWAD(file))
            {
                int             iwadrequired = IWADRequiredByPWAD(file);
                static char     fullpath[MAX_PATH];

                if (iwadrequired == indetermined)
                    return 0;

                sprintf(fullpath, "%s\\%s", wadfolder,
                        iwadrequired == doom ? "DOOM.WAD" : "DOOM2.WAD");
                IdentifyIWADByName(fullpath);
                if (D_AddFile(fullpath))
                {
                    iwadfound = 1;
                    if (W_MergeFile(file))
                    {
                        modifiedgame = true;
                        if (D_CheckFilename(file, "NERVE.WAD"))
                            nerve = true;
                    }
                }
            }
        }

        // more than one file was selected
        else
        {
            LPSTR       iwad = ofn.lpstrFile;
            LPSTR       pwad = ofn.lpstrFile;

            wadfolder = strdup(szFile);

            // find and add IWAD first
            while (iwad[0])
            {
                static char     fullpath[MAX_PATH];

                iwad += lstrlen(iwad) + 1;
                sprintf(fullpath, "%s\\%s", wadfolder, iwad);

                if (D_IsDOOMIWAD(fullpath)
                    || (W_WadType(fullpath) == IWAD
                        && !D_IsUnsupportedIWAD(fullpath)))
                {
                    if (!iwadfound)
                    {
                        IdentifyIWADByContents(fullpath, &gamemode, &gamemission);
                        if (D_AddFile(fullpath))
                        {
                            iwadfound = 1;
                            sharewareiwad = !strcasecmp(iwad, "DOOM1.WAD");
                            break;
                        }
                    }
                }

                // if it's NERVE.WAD, try to open DOOM2.WAD with it
                else if (!strcasecmp(iwad, "NERVE.WAD"))
                {
                    static char     fullpath2[MAX_PATH];

                    sprintf(fullpath2, "%s\\DOOM2.WAD", wadfolder);
                    IdentifyIWADByName(fullpath2);
                    if (D_AddFile(fullpath2))
                    {
                        iwadfound = 1;
                        if (W_MergeFile(fullpath))
                        {
                            modifiedgame = true;
                            nerve = true;
                        }
                        break;
                    }
                }
            }

            // merge any pwads
            if (iwadfound && !sharewareiwad)
                while (pwad[0])
                {
                    static char     fullpath[MAX_PATH];

                    pwad += lstrlen(pwad) + 1;
                    sprintf(fullpath, "%s\\%s", wadfolder, pwad);

                    if (!D_CheckFilename(pwad, "DOOMRETRO.WAD")
                        && W_WadType(fullpath) == PWAD
                        && !D_IsUnsupportedPWAD(fullpath))
                        if (W_MergeFile(fullpath))
                        {
                            modifiedgame = true;
                            if (!strcasecmp(pwad, "NERVE.WAD"))
                                nerve = true;
                        }
                }
        }
    }
    return iwadfound;
}