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

📄 g_game.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 5 页
字号:
//// G_NextLevel (WorldDone)//// init next level or go to the final scene// called by end of intermision screen (wi_stuff)void G_NextLevel (void){    gameaction = ga_worlddone;    if (secretexit)        players[consoleplayer].didsecret = true;    if ( gamemode == commercial)    {        if(cv_deathmatch.value==0)        {            switch (gamemap)            {            case 15:            case 31:                if (!secretexit)                    break;            case 6:            case 11:            case 20:            case 30:                gameaction = ga_nothing;                CL_Reset();                F_StartFinale ();                break;            }        }        else            if(gamemap==30)                wminfo.next = 0; // wrape around in deathmatch    }}void G_DoWorldDone (void){    if( demoversion<129 )    {        gamemap = wminfo.next+1;        G_DoLoadLevel (true);    }    else        // not in demo because demo have the mapcommand on it        if(server && !demoplayback)         {            if( cv_deathmatch.value==0 )                // don't reset player between maps                COM_BufAddText (va("map \"%s\" -noresetplayers\n",G_BuildMapName(gameepisode,wminfo.next+1)));            else                // resetplayer in deathmatch for more equality                COM_BufAddText (va("map \"%s\"\n",G_BuildMapName(gameepisode,wminfo.next+1)));        }        gameaction = ga_nothing;    viewactive = true;}//// G_InitFromSavegame// Can be called by the startup code or the menu task.//void G_LoadGame (int slot){    COM_BufAddText(va("load %d\n",slot));}#define VERSIONSIZE             16void G_DoLoadGame (int slot){    int         length;    char        vcheck[VERSIONSIZE];    char        savename[255];    sprintf(savename, savegamename, slot);    length = FIL_ReadFile (savename, &savebuffer);    if (!length)    {        CONS_Printf ("Couldn't read file %s", savename);        return;    }    // skip the description field    save_p = savebuffer + SAVESTRINGSIZE;        memset (vcheck,0,sizeof(vcheck));    sprintf (vcheck,"version %i",VERSION);    if (strcmp (save_p, vcheck))    {        M_StartMessage ("Save game from different version\n\nPress ESC\n",NULL,MM_NOTHING);        return;                         // bad version    }    save_p += VERSIONSIZE;    if(demoplayback)  // reset game engine        G_StopDemo();    //added:27-02-98: reset the game version    G_Downgrade(VERSION);    paused        = false;    automapactive = false;    viewactive    = true;    // dearchive all the modifications    if( !P_LoadGame() )    {        M_StartMessage ("savegame file corrupted\n\nPress ESC\n", NULL, MM_NOTHING);        Command_ExitGame_f();        Z_Free (savebuffer);        return;    }    gameaction = ga_nothing;    gamestate = GS_LEVEL;    displayplayer = consoleplayer;    // done    Z_Free (savebuffer);    multiplayer = playeringame[1];    if(playeringame[1] && !netgame)        CV_SetValue(&cv_splitscreen,1);    if (setsizeneeded)        R_ExecuteSetViewSize ();    // draw the pattern into the back screen    R_FillBackScreen ();    CON_ToggleOff ();}//// G_SaveGame// Called by the menu task.// Description is a 24 byte text string//void G_SaveGame ( int   slot, char* description ){    if (server)        COM_BufAddText(va("save %d \"%s\"\n",slot,description));}void G_DoSaveGame (int   savegameslot, char* savedescription){    char        name2[VERSIONSIZE];    char        description[SAVESTRINGSIZE];    int         length;    char        name[256];    gameaction = ga_nothing;    sprintf(name, savegamename, savegameslot);    gameaction = ga_nothing;    save_p = savebuffer = (byte *)malloc(SAVEGAMESIZE);    if(!save_p)    {        CONS_Printf ("No More free memory for savegame\n");        return;    }    strcpy(description,savedescription);    description[SAVESTRINGSIZE]=0;    WRITEMEM(save_p, description, SAVESTRINGSIZE);    memset (name2,0,sizeof(name2));    sprintf (name2,"version %i",VERSION);    WRITEMEM(save_p, name2, VERSIONSIZE);    P_SaveGame();    length = save_p - savebuffer;    if (length > SAVEGAMESIZE)        I_Error ("Savegame buffer overrun");    FIL_WriteFile (name, savebuffer, length);    free(savebuffer);    gameaction = ga_nothing;    players[consoleplayer].message = GGSAVED;    // draw the pattern into the back screen    R_FillBackScreen ();}//// G_InitNew//  Can be called by the startup code or the menu task,//  consoleplayer, displayplayer, playeringame[] should be set.//// Boris comment : single player start gamevoid G_DeferedInitNew (skill_t skill, char* mapname, boolean StartSplitScreenGame){    G_Downgrade(VERSION);    paused        = false;        if( demoplayback )        COM_BufAddText ("stopdemo\n");    // this leave the actual game if needed    SV_StartSinglePlayerServer();        COM_BufAddText (va("splitscreen %d;deathmatch 0;fastmonsters 0;"                       "respawnmonsters 0;timelimit 0;fraglimit 0\n",                       StartSplitScreenGame));    COM_BufAddText (va("map \"%s\" -skill %d -monsters 1\n",mapname,skill+1));}//// This is the map command interpretation something like Command_Map_f//// called at : map cmd execution, doloadgame, doplaydemovoid G_InitNew (skill_t skill, char* mapname, boolean resetplayer){    //added:27-02-98: disable selected features for compatibility with    //                older demos, plus reset new features as default    if(!G_Downgrade (demoversion))    {        CONS_Printf("Cannot Downgrade engine\n");        CL_Reset();        D_StartTitle();        return;    }    if (paused)    {        paused = false;        S_ResumeSound ();    }    if (skill > sk_nightmare)        skill = sk_nightmare;    M_ClearRandom ();    if( server && skill == sk_nightmare )    {        CV_SetValue(&cv_respawnmonsters,1);        CV_SetValue(&cv_fastmonsters,1);    }    // for internal maps only    if (FIL_CheckExtension(mapname))    {        // external map file        strncpy (gamemapname, mapname, MAX_WADPATH);        gameepisode = 1;        gamemap = 1;    }    else    {        // internal game map        // well this  check is useless because it is done before (d_netcmd.c::command_map_f)        // but in case of for demos....        if (W_CheckNumForName(mapname)==-1)        {            CONS_Printf("\2Internal game map '%s' not found\n"                        "(use .wad extension for external maps)\n",mapname);            Command_ExitGame_f();            return;        }        gamemapname[0] = 0;             // means not an external wad file        if (gamemode==commercial)       //doom2        {            gamemap = atoi(mapname+3);  // get xx out of MAPxx            gameepisode = 1;        }        else        {            gamemap = mapname[3]-'0';           // ExMy            gameepisode = mapname[1]-'0';        }    }    gameskill      = skill;    playerdeadview = false;    viewactive     = true;    automapactive  = false;    G_DoLoadLevel (resetplayer);}//added:03-02-98:////  'Downgrade' the game engine so that it is compatible with older demo//   versions. This will probably get harder and harder with each new//   'feature' that we add to the game. This will stay until it cannot//   be done a 'clean' way, then we'll have to forget about old demos..//boolean G_Downgrade(int version){    int i;    if (version<109)        return false;    if( version<130 )    {        mobjinfo[MT_BLOOD].radius = 20*FRACUNIT;        mobjinfo[MT_BLOOD].height = 16*FRACUNIT;        mobjinfo[MT_BLOOD].flags  = MF_NOBLOCKMAP;    }    else    {        mobjinfo[MT_BLOOD].radius = 3*FRACUNIT;        mobjinfo[MT_BLOOD].height = 0*FRACUNIT;        mobjinfo[MT_BLOOD].flags  = 0;    }    // smoke trails for skull head attack since v1.25    if (version<125)    {        states[S_ROCKET].action.acv = NULL;        states[S_SKULL_ATK3].action.acv = NULL;        states[S_SKULL_ATK4].action.acv = NULL;    }    else    {        //activate rocket trails by default        states[S_ROCKET].action.acv     = A_SmokeTrailer;        // smoke trails behind the skull heads        states[S_SKULL_ATK3].action.acv = A_SmokeTrailer;        states[S_SKULL_ATK4].action.acv = A_SmokeTrailer;    }    //hmmm.. first time I see an use to the switch without break...    switch (version)    {      case 109:        // disable rocket trails        states[S_ROCKET].action.acv = NULL; //NULL like in Doom2 v1.9        // Boris : for older demos, initalise the new skincolor value        //         also disable the new preferred weapons order.        for(i=0;i<4;i++)        {            players[i].skincolor = i % MAXSKINCOLORS;            players[i].originalweaponswitch=true;        }//eof Boris      case 110:      case 111:        //added:16-02-98: make sure autoaim is used for older        //                demos not using mouse aiming        for(i=0;i<MAXPLAYERS;i++)            players[i].autoaim_toggle = true;      default:        break;    }    //SoM: 3/17/2000: Demo compatability    if(version < 129)     {        boomsupport = 0;        allow_pushers = 0;        variable_friction = 0;    }    else     {        boomsupport = 1;        allow_pushers = 1;        variable_friction = 1;    }    // always true now, might be false in the future, if couldn't    // go backward and disable all the features...    demoversion = version;    return true;}//// DEMO RECORDING//#define ZT_FWD          0x01#define ZT_SIDE         0x02#define ZT_ANGLE        0x04#define ZT_BUTTONS      0x08#define ZT_AIMING       0x10#define ZT_CHAT         0x20    // no more used#define ZT_EXTRADATA    0x40#define DEMOMARKER      0x80    // demoendticcmd_t oldcmd[MAXPLAYERS];void G_ReadDemoTiccmd (ticcmd_t* cmd,int playernum){    if (*demo_p == DEMOMARKER)    {        // end of demo data stream        G_CheckDemoStatus ();        return;    }    if(demoversion<112)    {        cmd->forwardmove = READCHAR(demo_p);        cmd->sidemove = READCHAR(demo_p);        cmd->angleturn = READBYTE(demo_p)<<8;        cmd->buttons = READBYTE(demo_p);        cmd->aiming = 0;    }    else    {        char ziptic=*demo_p++;        if(ziptic & ZT_FWD)            oldcmd[playernum].forwardmove = READCHAR(demo_p);        if(ziptic & ZT_SIDE)            oldcmd[playernum].sidemove = READCHAR(demo_p);        if(ziptic & ZT_ANGLE)        {            if(demoversion<125)                oldcmd[playernum].angleturn = READBYTE(demo_p)<<8;            else                oldcmd[playernum].angleturn = READSHORT(demo_p);        }        if(ziptic & ZT_BUTTONS)            oldcmd[playernum].buttons = READBYTE(demo_p);        if(ziptic & ZT_AIMING)        {            if(demoversion<128)                oldcmd[playernum].aiming = READCHAR(demo_p);            else                oldcmd[playernum].aiming = READSHORT(demo_p);        }        if(ziptic & ZT_CHAT)            demo_p++;        if(ziptic & ZT_EXTRADATA)            ReadLmpExtraData(&demo_p,playernum);        else            ReadLmpExtraData(0,playernum);        memcpy(cmd,&(oldcmd[playernum]),sizeof(ticcmd_t));    }}void G_WriteDemoTiccmd (ticcmd_t* cmd,int playernum){    char ziptic=0;    byte *ziptic_p;    ziptic_p=demo_p++;  // the ziptic     

⌨️ 快捷键说明

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