⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d_main.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 4 页
字号:
        }        break;      case 5:        G_DeferedPlayDemo ("demo3");        pagetic = 9999999;        break;        // THE DEFINITIVE DOOM Special Edition demo      case 6:        G_DeferedPlayDemo ("demo4");        pagetic = 9999999;        break;    }}// =========================================================================//   D_DoomMain// =========================================================================//// D_StartTitle//void D_StartTitle (void){    gameaction = ga_nothing;    playerdeadview = false;    displayplayer = consoleplayer = statusbarplayer = 0;    demosequence = -1;    paused = false;    D_AdvanceDemo ();    CON_ToggleOff();}//// D_AddFile//void D_AddFile (char *file){    int     numwadfiles;    char    *newfile;    for (numwadfiles = 0 ; startupwadfiles[numwadfiles] ; numwadfiles++)        ;    newfile = malloc (strlen(file)+1);    strcpy (newfile, file);    startupwadfiles[numwadfiles] = newfile;}#ifdef __WIN32__#define R_OK    0                       //faB: win32 does not have R_OK in includes..#elif !defined( __OS2__)#define _MAX_PATH   MAX_WADPATH#endif// ==========================================================================// Identify the Doom version, and IWAD file to use.// Sets 'gamemode' to determine whether registered/commmercial features are// available (notable loading PWAD files).// ==========================================================================// return gamemode for Doom or Ultimate Doom, use size to detect which onegamemode_t GetDoomVersion (char* wadfile){    struct stat sbuf;    // Fab: and if I patch my main wad and the size gets    // bigger ? uh?    // BP: main wad MUST not be patched !    stat (wadfile, &sbuf);    if (sbuf.st_size<12408292)        return registered;    else        return retail;      // Ultimate}void IdentifyVersion (void){    char*       doom1wad;    char*       doomwad;    char*       doomuwad;    char*       doom2wad;    char*       plutoniawad;    char*       tntwad;    char*       hereticwad;    char*       hexenwad;    char*       legacywad;    char        pathtemp[_MAX_PATH];    char        pathiwad[_MAX_PATH+16];    int         p,i;//Fab:25-04-98:unused now//    char*       doom2fwad;    char *doomwaddir;#ifdef LINUX    // change to the directory where 'doom3.wad' is found   I_LocateWad();#endif    doomwaddir = getenv("DOOMWADDIR");    if (!doomwaddir)    {        // get the current directory (possible problem on NT with "." as current dir)        if ( getcwd(pathtemp, _MAX_PATH) != NULL )            doomwaddir = pathtemp;        else            doomwaddir = ".";    }        #ifdef __MACOS__        // cwd is always "/" when app is dbl-clicked        if (!stricmp(doomwaddir,"/"))                doomwaddir = I_GetWadDir();#endif    // Commercial.    doom2wad = malloc(strlen(doomwaddir)+1+9+1);    sprintf(doom2wad, "%s/%s", doomwaddir, text[DOOM2WAD_NUM]);    // Retail.    doomuwad = malloc(strlen(doomwaddir)+1+9+1);    sprintf(doomuwad, "%s/%s", doomwaddir, text[DOOMUWAD_NUM]);    // Registered.    doomwad = malloc(strlen(doomwaddir)+1+8+1);    sprintf(doomwad, "%s/%s", doomwaddir, text[DOOMWAD_NUM]);    // Shareware.    doom1wad = malloc(strlen(doomwaddir)+1+9+1);    sprintf(doom1wad, "%s/%s", doomwaddir, text[DOOM1WAD_NUM]);    // and... Doom LEGACY !!! :)    legacywad = malloc(strlen(doomwaddir)+1+9+1);    sprintf(legacywad, "%s/doom3.wad", doomwaddir);    // FinalDoom : Plutonia    plutoniawad = malloc(strlen(doomwaddir)+1+12+1);    sprintf(plutoniawad, "%s/plutonia.wad", doomwaddir);    // FinalDoom : Tnt Evilution    tntwad = malloc(strlen(doomwaddir)+1+7+1);    sprintf(tntwad, "%s/tnt.wad", doomwaddir);    hereticwad = malloc(strlen(doomwaddir)+1+12+1);    sprintf(hereticwad, "%s/heretic.wad", doomwaddir);    hexenwad = malloc(strlen(doomwaddir)+1+12+1);    sprintf(hexenwad, "%s/hexen.wad", doomwaddir);    /* French stuff.    doom2fwad = malloc(strlen(doomwaddir)+1+10+1);    sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir);*/    // will be overwrite in case of -cdrom or linux home    sprintf(configfile, "%s/"CONFIGFILENAME, doomwaddir);    if (M_CheckParm ("-shdev"))    {        gamemode = shareware;        devparm = true;        D_AddFile (DEVDATA"doom1.wad");        D_AddFile (DEVMAPS"data_se/texture1.lmp");        D_AddFile (DEVMAPS"data_se/pnames.lmp");        strcpy (configfile,DEVDATA CONFIGFILENAME);    }    else    if (M_CheckParm ("-regdev"))    {        gamemode = registered;        devparm = true;        D_AddFile (DEVDATA"doom.wad");        D_AddFile (DEVMAPS"data_se/texture1.lmp");        D_AddFile (DEVMAPS"data_se/texture2.lmp");        D_AddFile (DEVMAPS"data_se/pnames.lmp");        strcpy (configfile,DEVDATA CONFIGFILENAME);        return;    }    else    if (M_CheckParm ("-comdev"))    {        gamemode = commercial;        devparm = true;        /* I don't bother        if(plutonia)            D_AddFile (DEVDATA"plutonia.wad");        else if(tnt)            D_AddFile (DEVDATA"tnt.wad");        else*/            D_AddFile (DEVDATA"doom2.wad");        D_AddFile (DEVMAPS"cdata/texture1.lmp");        D_AddFile (DEVMAPS"cdata/pnames.lmp");        strcpy (configfile,DEVDATA CONFIGFILENAME);        return;    }    else    // specify the name of the IWAD file to use, so we can have several IWAD's    // in the same directory, and/or have legacy.exe only once in a different location    if ( (p = M_CheckParm ("-iwad")) && p < myargc-1 )    {        sprintf (pathiwad, "%s/%s", doomwaddir, myargv[p+1]);        if( access (pathiwad,R_OK) )             I_Error("%s not found\n",pathiwad);        D_AddFile (pathiwad);        // point to start of filename only        for (i=strlen(pathiwad)-1; i>=0; i--)            if (pathiwad[i]=='\\' || pathiwad[i]=='/' || pathiwad[i]==':')                break;        i++;        // find gamemode        if (!stricmp("plutonia.wad",pathiwad+i))            gamemode = commercial;        else if (!stricmp("tnt.wad",pathiwad+i))            gamemode = commercial;        else if (!stricmp("heretic.wad",pathiwad+i))            gamemode = heretic;        else if (!stricmp("hexen.wad",pathiwad+i))            gamemode = hexen;        else if (!stricmp(text[DOOM2WAD_NUM] ,pathiwad+i))            gamemode = commercial;        else if (!stricmp(text[DOOMUWAD_NUM] ,pathiwad+i))            gamemode = retail;        else if (!stricmp(text[DOOMWAD_NUM] ,pathiwad+i))            gamemode = GetDoomVersion (pathiwad);        else if (!stricmp(text[DOOM1WAD_NUM] ,pathiwad+i))            gamemode = shareware;        else {            gamemode = commercial;        }    }    else    /*    if ( !access (doom2fwad,R_OK) )    {        gamemode = commercial;        // C'est ridicule!        // Let's handle languages in config files, okay?        language = french;        CONS_Printf("French version\n");        D_AddFile (doom2fwad);    }    else*/    if ( !access (doom2wad,R_OK) )    {        gamemode = commercial;        D_AddFile (doom2wad);    }    else    if ( !access (doomuwad,R_OK) )    {        gamemode = retail;        D_AddFile (doomuwad);    }    else    if ( !access (doomwad,R_OK) )    {        gamemode = GetDoomVersion (doomwad);        D_AddFile (doomwad);    }    else    if ( !access (doom1wad,R_OK) )    {        gamemode = shareware;        D_AddFile (doom1wad);    }    else    if ( !access (plutoniawad, R_OK ) )    {      gamemode = commercial;      D_AddFile (plutoniawad);    }    else    if ( !access ( tntwad, R_OK ) )    {      gamemode = commercial;      D_AddFile (tntwad);    }    else    if ( !access ( hereticwad, R_OK ) )    {      gamemode = heretic;      D_AddFile (hereticwad);    }    else    if ( !access ( hexenwad, R_OK ) )    {      gamemode = hexen;      D_AddFile (hexenwad);    }    else    {        I_Error ("Main WAD file not found\nYou need either Doom.wad, Doom1.wad, Doom2.wad, Tnt.wad or Plutonia.wad\nfrom any sharware or commercial version of Doom !\n");        // unused code : I_ERROR never return        gamemode = indetermined;    }    raven = gamemode == heretic || gamemode == hexen;    D_AddFile(legacywad);}/* ======================================================================== */// Just print the nice red titlebar like the original DOOM2 for DOS./* ======================================================================== */#ifdef PC_DOSvoid D_Titlebar (char *title1, char *title2){    // DOOM LEGACY banner    clrscr();    textattr((BLUE<<4)+WHITE);    clreol();    cputs(title1);    // standard doom/doom2 banner    textattr((RED<<4)+WHITE);    clreol();    gotoxy((80-strlen(title2))/2,2);    cputs(title2);    normvideo();    gotoxy(1,3);}#endif//added:11-01-98:////  Center the title string, then add the date and time of compilation.//void D_MakeTitleString( char *s ){    char    temp[82];    char    *t;    char    *u;    int     i;    for(i=0,t=temp;i<82;i++) *t++=' ';    for(t=temp+(80-strlen(s))/2,u=s;*u!='\0';)        *t++ = *u++;    u=__DATE__;    for(t=temp+1,i=11;i--;)        *t++=*u++;    u=__TIME__;    for(t=temp+71,i=8;i--;)        *t++=*u++;    temp[80]='\0';    strcpy(s,temp);}void D_CheckWadVersion(){    int wadversion=0;    int lump;/* BP: disabled since this should work fine now...    // check main iwad using demo1 version     lump = W_CheckNumForNameFirst("demo1");    // well no demo1, this is not a main wad file    if(lump == -1)        I_Error("%s is not a Main wad file (IWAD)\n"                "try with Doom.wad or Doom2.wad\n"                "\n"                "Use -nocheckwadversion to remove this check,\n"                "but this can cause Legacy to hang\n",wadfiles[0]->filename);    W_ReadLumpHeader (lump,&wadversion,1);    if( wadversion<109 )        I_Error("Your %s file is version %d.%d\n"                "Doom Legacy need version 1.9\n"                "Upgrade your version to 1.9 using IdSofware patch\n"                "\n"                "Use -nocheckwadversion to remove this check,\n"                "but this can cause Legacy to hang\n",wadfiles[0]->filename,wadversion/100,wadversion%100);*/    // check version, of doom3.wad using version lump    lump=W_CheckNumForName("version");    if(lump==-1)        wadversion=0; // or less    else    {        char s[128];        int  l;        l=W_ReadLumpHeader (lump,&s,128);        wadversion=0;        if( l<128 )        {            s[l]='\0';            if( sscanf(s,"Doom Legacy WAD V%d.%d",&l,&wadversion)==2 )                wadversion+=l*100;        }    }    if(wadversion!=VERSION)        I_Error("Your Doom3.wad file is version %d.%d, you need version %d.%d\n"                "Use the Doom3.wad comming from the same zip file of this exe\n"                "\n"                "Use -nocheckwadversion to remove this check,\n"                "but this can cause Legacy to hang\n",                wadversion/100,wadversion%100,VERSION/100,VERSION%100);}//// D_DoomMain//void D_DoomMain (void){    int     p;    char    file[256];    char    legacy[82];    //added:18-02-98: legacy title banner    char    title[82];    //added:11-01-98:moved, doesn't need to be global    int     startepisode;    int     startmap;    boolean autostart;            // BP: set correct localtime so time compare work !    D_NetFileInit();    //added:18-02-98:keep error messages until the final flush(stderr)    if (setvbuf(stderr,NULL,_IOFBF,1000))        CONS_Printf("setvbuf didnt work\n");    // get parameters from a response file (eg: doom3 @parms.txt)    M_FindResponseFile ();            // identify the main IWAD file to use    IdentifyVersion ();    setbuf (stdout, NULL);      // non-buffered output    modifiedgame = false;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -