components/prboom/d_main.c
//
// IdentifyVersion
//
// Set the location of the defaults file and the savegame root
// Locate and validate an IWAD file
// Determine gamemode from the IWAD
//
// supports IWADs with custom names. Also allows the -iwad parameter to
// specify which iwad is being searched for if several exist in one dir.
// The -iwad parm may specify:
//
// 1) a specific pathname, which must exist (.wad optional)
// 2) or a directory, which must contain a standard IWAD,
// 3) or a filename, which must be found in one of the standard places:
//   a) current dir,
//   b) exe dir
//   c) $DOOMWADDIR
//   d) or $HOME
//
// jff 4/19/98 rewritten to use a more advanced search algorithm
IdentifyVersion
Set the location of the defaults file and the savegame root
Locate and validate an IWAD file
Determine gamemode from the IWAD

supports IWADs with custom names. Also allows the -iwad parameter to
specify which iwad is being searched for if several exist in one dir.
The -iwad parm may specify.

1) a specific pathname, which must exist (.wad optional)
2) or a directory, which must contain a standard IWAD,
3) or a filename, which must be found in one of the standard places:
a) current dir,
b) exe dir
c) $DOOMWADDIR
d) or $HOME

jff 4/19/98 rewritten to use a more advanced search algorithm
IdentifyVersion Set the location of the defaults file and the savegame root Locate and validate an IWAD file Determine gamemode from the IWAD supports IWADs with custom names . Also allows the - iwad parameter to specify which iwad is being searched for if several exist in one dir . The - iwad parm may specify . 1 ) a specific pathname which must exist ( . wad optional ) 2 ) or a directory which must contain a standard IWAD 3 ) or a filename which must be found in one of the standard places : a ) current dir b ) exe dir c ) $DOOMWADDIR d ) or $HOME jff 4 / 19 / 98 rewritten to use a more advanced search algorithm
static void IdentifyVersion (void)
{
  int         i;    
  struct stat sbuf; 
  char *iwad;
  {
    char* p = getenv("DOOMSAVEDIR");
    if (p != NULL)
      if (strlen(p) > PATH_MAX-12) p = NULL;
    strcpy(basesavegame,(p == NULL) ? I_DoomExeDir() : p);
  }
  if ((i=M_CheckParm("-save")) && i<myargc-1) 
  {
    if (!stat(myargv[i+1],&sbuf) && S_ISDIR(sbuf.st_mode)) 
    {
      strcpy(basesavegame,myargv[i+1]);  
      NormalizeSlashes(basesavegame);    
    }
    else lprintf(LO_ERROR,"Error: -save path does not exist, using %s\n", basesavegame);
  }
  iwad = FindIWADFile();
#if (0)
  {
    FILE *f;
    f=fopen("levelinfo.txt","w");
    if (f)
    {
      fprintf(f,"%s\n",iwad);
      fclose(f);
    }
  }
#endif
  if (iwad && *iwad)
  {
    lprintf(LO_CONFIRM,"IWAD found: %s\n",iwad); 
    CheckIWAD(iwad,&gamemode,&haswolflevels);
    switch(gamemode)
    {
      case retail:
      case registered:
      case shareware:
        gamemission = doom;
        break;
      case commercial:
        i = strlen(iwad);
        gamemission = doom2;
        if (i>=10 && !strnicmp(iwad+i-10,"doom2f.wad",10))
          language=french;
        else if (i>=7 && !strnicmp(iwad+i-7,"tnt.wad",7))
          gamemission = pack_tnt;
        else if (i>=12 && !strnicmp(iwad+i-12,"plutonia.wad",12))
          gamemission = pack_plut;
        break;
      default:
        gamemission = none;
        break;
    }
    if (gamemode == indetermined)
      lprintf(LO_WARN,"Unknown Game Version, may not work\n");
    D_AddFile(iwad,source_iwad);
    free(iwad);
  }
  else
    I_Error("IdentifyVersion: IWAD not found\n");
}
static void IdentifyVersion ( void ) { int i ; struct stat sbuf ; char * iwad ; { char * p = getenv ( " " ) ; if ( p != NULL ) if ( strlen ( p ) > PATH_MAX - 12 ) p = NULL ; strcpy ( basesavegame , ( p == NULL ) ? I_DoomExeDir ( ) : p ) ; } if ( ( i = M_CheckParm ( " " ) ) && i < myargc - 1 ) { if ( ! stat ( myargv [ i + 1 ] , & sbuf ) && S_ISDIR ( sbuf . st_mode ) ) { strcpy ( basesavegame , myargv [ i + 1 ] ) ; NormalizeSlashes ( basesavegame ) ; } else lprintf ( LO_ERROR , " \n " , basesavegame ) ; } iwad = FindIWADFile ( ) ; #if ( 0 ) { FILE * f ; f = fopen ( " " , " " ) ; if ( f ) { fprintf ( f , " \n " , iwad ) ; fclose ( f ) ; } } #endif if ( iwad && * iwad ) { lprintf ( LO_CONFIRM , " \n " , iwad ) ; CheckIWAD ( iwad , & gamemode , & haswolflevels ) ; switch ( gamemode ) { case retail : case registered : case shareware : gamemission = doom ; break ; case commercial : i = strlen ( iwad ) ; gamemission = doom2 ; if ( i >= 10 && ! strnicmp ( iwad + i - 10 , " " , 10 ) ) language = french ; else if ( i >= 7 && ! strnicmp ( iwad + i - 7 , " " , 7 ) ) gamemission = pack_tnt ; else if ( i >= 12 && ! strnicmp ( iwad + i - 12 , " " , 12 ) ) gamemission = pack_plut ; break ; default : gamemission = none ; break ; } if ( gamemode == indetermined ) lprintf ( LO_WARN , " \n " ) ; D_AddFile ( iwad , source_iwad ) ; free ( iwad ) ; } else I_Error ( " \n " ) ; }
IdentifyVersion
Set the location of the defaults file and the savegame root
Locate and validate an IWAD file
Determine gamemode from the IWAD
IdentifyVersion Set the location of the defaults file and the savegame root Locate and validate an IWAD file Determine gamemode from the IWAD
//jff 3/24/98 index of args on commandline //jff 3/24/98 used to test save path for existence // set save path to -save parm or current dir //jff 3/27/98 default to current dir //V.Aguilar (5/30/99): In LiNUX, default to $HOME/.lxdoom // CPhipps - use DOOMSAVEDIR if defined //jff 3/24/98 if -save present // and is a dir //jff 3/24/98 use that for savegame //jff 9/22/98 fix c:\ not working //jff 9/3/98 use logical output routine // locate the IWAD and determine game mode from it // proff 11/99: used for debugging //jff 9/3/98 use logical output routine //jff 4/20/98 print only if found /* jff 8/23/98 set gamemission global appropriately in all cases
     * cphipps 12/1999 - no version output here, leave that to the caller
     */ //jff 9/3/98 use logical output routine