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

📄 g_game.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 5 页
字号:
// Emacs style mode select   -*- C++ -*- //-----------------------------------------------------------------------------//// $Id: g_game.c,v 1.35 2001/05/03 21:22:25 hurdler Exp $//// Copyright (C) 1993-1996 by id Software, Inc.// Portions Copyright (C) 1998-2000 by DooM Legacy Team.//// This program is free software; you can redistribute it and/or// modify it under the terms of the GNU General Public License// as published by the Free Software Foundation; either version 2// of the License, or (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.////// $Log: g_game.c,v $// Revision 1.35  2001/05/03 21:22:25  hurdler// remove some warnings//// Revision 1.34  2001/04/17 22:26:07  calumr// Initial Mac add//// Revision 1.33  2001/04/01 17:35:06  bpereira// no message//// Revision 1.32  2001/03/03 06:17:33  bpereira// no message//// Revision 1.31  2001/02/24 13:35:19  bpereira// no message//// Revision 1.30  2001/02/10 12:27:13  bpereira// no message//// Revision 1.29  2001/01/25 22:15:41  bpereira// added heretic support//// Revision 1.28  2000/11/26 20:36:14  hurdler// Adding autorun2//// Revision 1.27  2000/11/11 13:59:45  bpereira// no message//// Revision 1.26  2000/11/06 20:52:15  bpereira// no message//// Revision 1.25  2000/11/04 16:23:42  bpereira// no message//// Revision 1.24  2000/11/02 19:49:35  bpereira// no message//// Revision 1.23  2000/11/02 17:50:06  stroggonmeth// Big 3Dfloors & FraggleScript commit!!//// Revision 1.22  2000/10/21 08:43:28  bpereira// no message//// Revision 1.21  2000/10/09 14:03:31  crashrl// *** empty log message ***//// Revision 1.20  2000/10/08 13:30:00  bpereira// no message//// Revision 1.19  2000/10/07 20:36:13  crashrl// Added deathmatch team-start-sectors via sector/line-tag and linedef-type 1000-1031//// Revision 1.18  2000/10/01 10:18:17  bpereira// no message//// Revision 1.17  2000/09/28 20:57:14  bpereira// no message//// Revision 1.16  2000/08/31 14:30:55  bpereira// no message//// Revision 1.15  2000/08/10 14:08:48  hurdler// no message//// Revision 1.14  2000/04/30 10:30:10  bpereira// no message//// Revision 1.13  2000/04/23 16:19:52  bpereira// no message//// Revision 1.12  2000/04/19 10:56:51  hurdler// commited for exe release and tag only//// Revision 1.11  2000/04/16 18:38:07  bpereira// no message//// Revision 1.10  2000/04/11 19:07:23  stroggonmeth// Finished my logs, fixed a crashing bug.//// Revision 1.9  2000/04/07 23:11:17  metzgermeister// added mouse move//// Revision 1.8  2000/04/06 20:40:22  hurdler// Mostly remove warnings under windows//// Revision 1.7  2000/04/04 00:32:45  stroggonmeth// Initial Boom compatability plus few misc changes all around.//// Revision 1.6  2000/03/29 19:39:48  bpereira// no message//// Revision 1.5  2000/03/23 22:54:00  metzgermeister// added support for HOME/.legacy under Linux//// Revision 1.4  2000/02/27 16:30:28  hurdler// dead player bug fix + add allowmlook <yes|no>//// Revision 1.3  2000/02/27 00:42:10  hurdler// fix CR+LF problem//// Revision 1.2  2000/02/26 00:28:42  hurdler// Mostly bug fix (see borislog.txt 23-2-2000, 24-2-2000)////// DESCRIPTION://      game loop functions, events handling////-----------------------------------------------------------------------------#include "doomdef.h"#include "command.h"#include "console.h"#include "dstrings.h"#include "d_main.h"#include "d_net.h"#include "d_netcmd.h"#include "f_finale.h"#include "p_setup.h"#include "p_saveg.h"#include "i_system.h"#include "wi_stuff.h"#include "am_map.h"#include "m_random.h"#include "p_local.h"#include "p_tick.h"// SKY handling - still the wrong place.#include "r_data.h"#include "r_draw.h"#include "r_main.h"#include "r_sky.h"#include "s_sound.h"#include "g_game.h"#include "g_state.h"#include "g_input.h"//added:16-01-98:quick hack test of rocket trails#include "p_fab.h"#include "m_cheat.h"#include "m_misc.h"#include "m_menu.h"#include "m_argv.h"#include "hu_stuff.h"#include "st_stuff.h"#include "keys.h"#include "w_wad.h"#include "z_zone.h"#include "i_video.h"#include "p_inter.h"#include "p_info.h"#include "byteptr.h"#include "i_joy.h"// added 8-3-98 increse savegame size from 0x2c000 (180kb) to 512*1024#define SAVEGAMESIZE    (512*1024)#define SAVESTRINGSIZE  24boolean G_CheckDemoStatus (void);void    G_ReadDemoTiccmd (ticcmd_t* cmd,int playernum);void    G_WriteDemoTiccmd (ticcmd_t* cmd,int playernum);void    G_InitNew (skill_t skill, char* mapname, boolean resetplayer);void    G_DoCompleted (void);void    G_DoVictory (void);void    G_DoWorldDone (void);// demoversion the 'dynamic' version number, this should be == game VERSION// when playing back demos, 'demoversion' receives the version number of the// demo. At each change to the game play, demoversion is compared to// the game version, if it's older, the changes are not done, and the older// code is used for compatibility.//byte            demoversion=VERSION;byte            gameepisode;byte            gamemap;char            gamemapname[MAX_WADPATH];      // an external wad filenamegamemode_t      gamemode = indetermined;       // Game Mode - identify IWAD as shareware, retail etc.gamemission_t   gamemission = doom;boolean         raven = false;language_t      language = english;            // Language.boolean         modifiedgame;                  // Set if homebrew PWAD stuff has been added.boolean         paused;boolean         timingdemo;             // if true, exit with report on completionboolean         nodrawers;              // for comparative timing purposesboolean         noblit;                 // for comparative timing purposestic_t           demostarttime;              // for comparative timing purposesboolean         viewactive;boolean         netgame;                // only true if packets are broadcastboolean         multiplayer;boolean         playeringame[MAXPLAYERS];player_t        players[MAXPLAYERS];int             consoleplayer;          // player taking events and displayingint             displayplayer;          // view being displayedint             secondarydisplayplayer; // for splitscreenint             statusbarplayer;        // player who's statusbar is displayed                                        // (for spying with F12)tic_t           gametic;tic_t           levelstarttic;          // gametic at level startint             totalkills, totalitems, totalsecret;    // for intermissionchar            demoname[32];boolean         demorecording;boolean         demoplayback;byte*           demobuffer;byte*           demo_p;byte*           demoend;boolean         singledemo;             // quit after playing a demo from cmdlineboolean         precache = true;        // if true, load all graphics at startwbstartstruct_t wminfo;                 // parms for world map / intermissionbyte*           savebuffer;void ShowMessage_OnChange(void);void AllowTurbo_OnChange(void);CV_PossibleValue_t showmessages_cons_t[]={{0,"Off"},{1,"On"},{2,"Not All"},{0,NULL}};CV_PossibleValue_t crosshair_cons_t[]   ={{0,"Off"},{1,"Cross"},{2,"Angle"},{3,"Point"},{0,NULL}};consvar_t cv_crosshair        = {"crosshair"   ,"0",CV_SAVE,crosshair_cons_t};consvar_t cv_autorun          = {"autorun"     ,"0",CV_SAVE,CV_OnOff};consvar_t cv_autorun2         = {"autorun2"    ,"0",CV_SAVE,CV_OnOff};consvar_t cv_invertmouse      = {"invertmouse" ,"0",CV_SAVE,CV_OnOff};consvar_t cv_alwaysfreelook   = {"alwaysmlook" ,"0",CV_SAVE,CV_OnOff};consvar_t cv_invertmouse2     = {"invertmouse2","0",CV_SAVE,CV_OnOff};consvar_t cv_alwaysfreelook2  = {"alwaysmlook2","0",CV_SAVE,CV_OnOff};consvar_t cv_showmessages     = {"showmessages","1",CV_SAVE | CV_CALL | CV_NOINIT,showmessages_cons_t,ShowMessage_OnChange};consvar_t cv_allowturbo       = {"allowturbo"  ,"0",CV_NETVAR | CV_CALL, CV_YesNo, AllowTurbo_OnChange};consvar_t cv_mousemove        = {"mousemove"   ,"1",CV_SAVE,CV_OnOff};consvar_t cv_mousemove2       = {"mousemove2"  ,"1",CV_SAVE,CV_OnOff};consvar_t cv_joystickfreelook = {"joystickfreelook" ,"0",CV_SAVE,CV_OnOff};#if MAXPLAYERS>32#error please update "player_name" table using the new value for MAXPLAYERS#endif#if MAXPLAYERNAME!=21#error please update "player_name" table using the new value for MAXPLAYERNAME#endif// changed to 2d array 19990220 by Kinchar    player_names[MAXPLAYERS][MAXPLAYERNAME] ={    // THESE SHOULD BE AT LEAST MAXPLAYERNAME CHARS    "Player 1\0a123456789a\0",    "Player 2\0a123456789a\0",    "Player 3\0a123456789a\0",    "Player 4\0a123456789a\0",    "Player 5\0a123456789a\0",        // added 14-1-98 for support 8 players    "Player 6\0a123456789a\0",        // added 14-1-98 for support 8 players    "Player 7\0a123456789a\0",        // added 14-1-98 for support 8 players    "Player 8\0a123456789a\0",        // added 14-1-98 for support 8 players    "Player 9\0a123456789a\0",    "Player 10\0a123456789\0",    "Player 11\0a123456789\0",    "Player 12\0a123456789\0",    "Player 13\0a123456789\0",    "Player 14\0a123456789\0",    "Player 15\0a123456789\0",    "Player 16\0a123456789\0",    "Player 17\0a123456789\0",    "Player 18\0a123456789\0",    "Player 19\0a123456789\0",    "Player 20\0a123456789\0",    "Player 21\0a123456789\0",    "Player 22\0a123456789\0",    "Player 23\0a123456789\0",    "Player 24\0a123456789\0",    "Player 25\0a123456789\0",    "Player 26\0a123456789\0",    "Player 27\0a123456789\0",    "Player 28\0a123456789\0",    "Player 29\0a123456789\0",    "Player 30\0a123456789\0",    "Player 31\0a123456789\0",    "Player 32\0a123456789\0"};char *team_names[MAXPLAYERS] ={    "Team 1\0a890123456789b\0",    "Team 2\0a890123456789b\0",    "Team 3\0a890123456789b\0",    "Team 4\0a890123456789b\0",    "Team 5\0a890123456789b\0",    "Team 6\0a890123456789b\0",    "Team 7\0a890123456789b\0",    "Team 8\0a890123456789b\0",    "Team 9\0a890123456789b\0",    "Team 10\0a90123456789b\0",    "Team 11\0a90123456789b\0",    "Team 12\0a90123456789b\0",      // the other name hare not used because no colors    "Team 13\0a90123456789b\0",      // but who know ?    "Team 14\0a90123456789b\0",    "Team 15\0a90123456789b\0",    "Team 16\0a90123456789b\0",    "Team 17\0a90123456789b\0",    "Team 18\0a90123456789b\0",    "Team 19\0a90123456789b\0",    "Team 20\0a90123456789b\0",    "Team 21\0a90123456789b\0",    "Team 22\0a90123456789b\0",    "Team 23\0a90123456789b\0",    "Team 24\0a90123456789b\0",    "Team 25\0a90123456789b\0",    "Team 26\0a90123456789b\0",    "Team 27\0a90123456789b\0",    "Team 28\0a90123456789b\0",    "Team 29\0a90123456789b\0",    "Team 30\0a90123456789b\0",    "Team 31\0a90123456789b\0",    "Team 32\0a90123456789b\0"};mobj_t*   bodyque[BODYQUESIZE];int       bodyqueslot;void*     statcopy;                      // for statistics drivervoid ShowMessage_OnChange(void){    if (!cv_showmessages.value)        CONS_Printf("%s\n",MSGOFF);    else        CONS_Printf("%s\n",MSGON);}//  Build an original game map name from episode and map number,//  based on the game mode (doom1, doom2...)//char* G_BuildMapName (int episode, int map){    static char  mapname[9];    // internal map name (wad resource name)    if (gamemode==commercial)        strcpy (mapname, va("MAP%#02d",map));    else    {        mapname[0] = 'E';        mapname[1] = '0' + episode;        mapname[2] = 'M';        mapname[3] = '0' + map;        mapname[4] = 0;    }    return mapname;}////  Clip the console player mouse aiming to the current view,//  also returns a signed char for the player ticcmd if needed.//  Used whenever the player view pitch is changed manually////added:22-02-98://changed:3-3-98: do a angle limitation nowshort G_ClipAimingPitch (int* aiming){    int limitangle;    //note: the current software mode implementation doesn't have true perspective    if ( rendermode == render_soft )        limitangle = 732<<ANGLETOFINESHIFT;    else        limitangle = ANG90 - 1;    if (*aiming > limitangle )        *aiming = limitangle;    else    if (*aiming < -limitangle)        *aiming = -limitangle;    return (*aiming)>>16;}//// G_BuildTiccmd// Builds a ticcmd from all of the available inputs// or reads it from the demo buffer.// If recording a demo, write it out//// set secondaryplayer true to build player 2's ticcmd in splitscreen mode//int     localaiming,localaiming2;angle_t localangle,localangle2;//added:06-02-98: mouseaiming (looking up/down with the mouse or keyboard)#define KB_LOOKSPEED    (1<<25)#define MAXPLMOVE       (forwardmove[1])#define TURBOTHRESHOLD  0x32#define SLOWTURNTICS    (6*NEWTICRATERATIO)static fixed_t forwardmove[2] = {25/NEWTICRATERATIO, 50/NEWTICRATERATIO};static fixed_t sidemove[2]    = {24/NEWTICRATERATIO, 40/NEWTICRATERATIO};static fixed_t angleturn[3]   = {640, 1280, 320};        // + slow turn// for change this table change also nextweapon func in g_game and P_PlayerThinkchar extraweapons[8]={wp_chainsaw,-1,wp_supershotgun,-1,-1,-1,-1,-1};byte nextweaponorder[NUMWEAPONS]={wp_fist,wp_chainsaw,wp_pistol,     wp_shotgun,wp_supershotgun,wp_chaingun,wp_missile,wp_plasma,wp_bfg};byte NextWeapon(player_t *player,int step){    byte   w;    int    i;    for (i=0;i<NUMWEAPONS;i++)        if( player->readyweapon == nextweaponorder[i] )        {            i = (i+NUMWEAPONS+step)%NUMWEAPONS;            break;        }    for (;nextweaponorder[i]!=player->readyweapon; i=(i+NUMWEAPONS+step)%NUMWEAPONS)    {        w = nextweaponorder[i];                // skip super shotgun for non-Doom2        if (gamemode!=commercial && w==wp_supershotgun)

⌨️ 快捷键说明

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