home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / quake_src / client.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-17  |  9.2 KB  |  376 lines

  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3.  
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  12.  
  13. See the GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. */
  20. // client.h
  21.  
  22. typedef struct
  23. {
  24.   vec3_t  viewangles;
  25.  
  26. // intended velocities
  27.   float forwardmove;
  28.   float sidemove;
  29.   float upmove;
  30. #ifdef QUAKE2
  31.   byte  lightlevel;
  32. #endif
  33. } usercmd_t;
  34.  
  35. typedef struct
  36. {
  37.   int   length;
  38.   char  map[MAX_STYLESTRING];
  39. } lightstyle_t;
  40.  
  41. typedef struct
  42. {
  43.   char  name[MAX_SCOREBOARDNAME];
  44.   float entertime;
  45.   int   frags;
  46.   int   colors;     // two 4 bit fields
  47.   byte  translations[VID_GRADES*256];
  48. } scoreboard_t;
  49.  
  50. typedef struct
  51. {
  52.   int   destcolor[3];
  53.   int   percent;    // 0-256
  54. } cshift_t;
  55.  
  56. #define CSHIFT_CONTENTS 0
  57. #define CSHIFT_DAMAGE 1
  58. #define CSHIFT_BONUS  2
  59. #define CSHIFT_POWERUP  3
  60. #define NUM_CSHIFTS   4
  61.  
  62. #define NAME_LENGTH 64
  63.  
  64.  
  65. //
  66. // client_state_t should hold all pieces of the client state
  67. //
  68.  
  69. #define SIGNONS   4     // signon messages to receive before connected
  70.  
  71. #define MAX_DLIGHTS   32
  72. typedef struct
  73. {
  74.   vec3_t  origin;
  75.   float radius;
  76.   float die;        // stop lighting after this time
  77.   float decay;        // drop this each second
  78.   float minlight;     // don't add when contributing less
  79.   int   key;
  80. #ifdef QUAKE2
  81.   qboolean  dark;     // subtracts light instead of adding
  82. #endif
  83. } dlight_t;
  84.  
  85.  
  86. #define MAX_BEAMS 24
  87. typedef struct
  88. {
  89.   int   entity;
  90.   struct model_s  *model;
  91.   float endtime;
  92.   vec3_t  start, end;
  93. } beam_t;
  94.  
  95. #define MAX_EFRAGS    640
  96.  
  97. #define MAX_MAPSTRING 2048
  98. #define MAX_DEMOS   8
  99. #define MAX_DEMONAME  16
  100.  
  101. typedef enum {
  102. ca_dedicated,     // a dedicated server with no ability to start a client
  103. ca_disconnected,  // full screen console with no connection
  104. ca_connected    // valid netcon, talking to a server
  105. } cactive_t;
  106.  
  107. //
  108. // the client_static_t structure is persistant through an arbitrary number
  109. // of server connections
  110. //
  111. typedef struct
  112. {
  113.   cactive_t state;
  114.  
  115. // personalization data sent to server  
  116.   char    mapstring[MAX_QPATH];
  117.   char    spawnparms[MAX_MAPSTRING];  // to restart a level
  118.  
  119. // demo loop control
  120.   int     demonum;    // -1 = don't play demos
  121.   char    demos[MAX_DEMOS][MAX_DEMONAME];   // when not playing
  122.  
  123. // demo recording info must be here, because record is started before
  124. // entering a map (and clearing client_state_t)
  125.   qboolean  demorecording;
  126.   qboolean  demoplayback;
  127.   qboolean  timedemo;
  128.   int     forcetrack;     // -1 = use normal cd track
  129.   FILE    *demofile;
  130.   int     td_lastframe;   // to meter out one message a frame
  131.   int     td_startframe;    // host_framecount at start
  132.   float   td_starttime;   // realtime at second frame of timedemo
  133.  
  134.  
  135. // connection information
  136.   int     signon;     // 0 to SIGNONS
  137.   struct qsocket_s  *netcon;
  138.   sizebuf_t message;    // writing buffer to send to server
  139.   
  140. } client_static_t;
  141.  
  142. extern client_static_t  cls;
  143.  
  144. //
  145. // the client_state_t structure is wiped completely at every
  146. // server signon
  147. //
  148. typedef struct
  149. {
  150.   int     movemessages; // since connecting to this server
  151.                 // throw out the first couple, so the player
  152.                 // doesn't accidentally do something the 
  153.                 // first frame
  154.   usercmd_t cmd;      // last command sent to the server
  155.  
  156. // information for local display
  157.   int     stats[MAX_CL_STATS];  // health, etc
  158.   int     items;      // inventory bit flags
  159.   float item_gettime[32]; // cl.time of aquiring item, for blinking
  160.   float   faceanimtime; // use anim frame if cl.time < this
  161.  
  162.   cshift_t  cshifts[NUM_CSHIFTS]; // color shifts for damage, powerups
  163.   cshift_t  prev_cshifts[NUM_CSHIFTS];  // and content types
  164.  
  165. // the client maintains its own idea of view angles, which are
  166. // sent to the server each frame.  The server sets punchangle when
  167. // the view is temporarliy offset, and an angle reset commands at the start
  168. // of each level and after teleporting.
  169.   vec3_t    mviewangles[2]; // during demo playback viewangles is lerped
  170.                 // between these
  171.   vec3_t    viewangles;
  172.   
  173.   vec3_t    mvelocity[2]; // update by server, used for lean+bob
  174.                 // (0 is newest)
  175.   vec3_t    velocity;   // lerped between mvelocity[0] and [1]
  176.  
  177.   vec3_t    punchangle;   // temporary offset
  178.   
  179. // pitch drifting vars
  180.   float   idealpitch;
  181.   float   pitchvel;
  182.   qboolean  nodrift;
  183.   float   driftmove;
  184.   double    laststop;
  185.  
  186.   float   viewheight;
  187.   float   crouch;     // local amount for smoothing stepups
  188.  
  189.   qboolean  paused;     // send over by server
  190.   qboolean  onground;
  191.   qboolean  inwater;
  192.   
  193.   int     intermission; // don't change view angle, full screen, etc
  194.   int     completed_time; // latched at intermission start
  195.   
  196.   double    mtime[2];   // the timestamp of last two messages 
  197.   double    time;     // clients view of time, should be between
  198.                 // servertime and oldservertime to generate
  199.                 // a lerp point for other data
  200.   double    oldtime;    // previous cl.time, time-oldtime is used
  201.                 // to decay light values and smooth step ups
  202.   
  203.  
  204.   float   last_received_message;  // (realtime) for net trouble icon
  205.  
  206. //
  207. // information that is static for the entire time connected to a server
  208. //
  209.   struct model_s    *model_precache[MAX_MODELS];
  210.   struct sfx_s    *sound_precache[MAX_SOUNDS];
  211.  
  212.   char    levelname[40];  // for display on solo scoreboard
  213.   int     viewentity;   // cl_entitites[cl.viewentity] = player
  214.   int     maxclients;
  215.   int     gametype;
  216.  
  217. // refresh related state
  218.   struct model_s  *worldmodel;  // cl_entitites[0].model
  219.   struct efrag_s  *free_efrags;
  220.   int     num_entities; // held in cl_entities array
  221.   int     num_statics;  // held in cl_staticentities array
  222.   entity_t  viewent;      // the gun model
  223.  
  224.   int     cdtrack, looptrack; // cd audio
  225.  
  226. // frag scoreboard
  227.   scoreboard_t  *scores;    // [cl.maxclients]
  228.  
  229. #ifdef QUAKE2
  230. // light level at player's position including dlights
  231. // this is sent back to the server each frame
  232. // architectually ugly but it works
  233.   int     light_level;
  234. #endif
  235. } client_state_t;
  236.  
  237.  
  238. //
  239. // cvars
  240. //
  241. extern  cvar_t  cl_name;
  242. extern  cvar_t  cl_color;
  243.  
  244. extern  cvar_t  cl_upspeed;
  245. extern  cvar_t  cl_forwardspeed;
  246. extern  cvar_t  cl_backspeed;
  247. extern  cvar_t  cl_sidespeed;
  248.  
  249. extern  cvar_t  cl_movespeedkey;
  250.  
  251. extern  cvar_t  cl_yawspeed;
  252. extern  cvar_t  cl_pitchspeed;
  253.  
  254. extern  cvar_t  cl_anglespeedkey;
  255.  
  256. extern  cvar_t  cl_autofire;
  257.  
  258. extern  cvar_t  cl_shownet;
  259. extern  cvar_t  cl_nolerp;
  260.  
  261. extern  cvar_t  cl_pitchdriftspeed;
  262. extern  cvar_t  lookspring;
  263. extern  cvar_t  lookstrafe;
  264. extern  cvar_t  sensitivity;
  265.  
  266. extern  cvar_t  m_pitch;
  267. extern  cvar_t  m_yaw;
  268. extern  cvar_t  m_forward;
  269. extern  cvar_t  m_side;
  270.  
  271.  
  272. #define MAX_TEMP_ENTITIES 64      // lightning bolts, etc
  273. #define MAX_STATIC_ENTITIES 128     // torches, etc
  274.  
  275. extern  client_state_t  cl;
  276.  
  277. // FIXME, allocate dynamically
  278. extern  efrag_t     cl_efrags[MAX_EFRAGS];
  279. extern  entity_t    cl_entities[MAX_EDICTS];
  280. extern  entity_t    cl_static_entities[MAX_STATIC_ENTITIES];
  281. extern  lightstyle_t  cl_lightstyle[MAX_LIGHTSTYLES];
  282. extern  dlight_t    cl_dlights[MAX_DLIGHTS];
  283. extern  entity_t    cl_temp_entities[MAX_TEMP_ENTITIES];
  284. extern  beam_t      cl_beams[MAX_BEAMS];
  285.  
  286. //=============================================================================
  287.  
  288. //
  289. // cl_main
  290. //
  291. dlight_t *CL_AllocDlight (int key);
  292. void  CL_DecayLights (void);
  293.  
  294. void CL_Init (void);
  295.  
  296. void CL_EstablishConnection (char *host);
  297. void CL_Signon1 (void);
  298. void CL_Signon2 (void);
  299. void CL_Signon3 (void);
  300. void CL_Signon4 (void);
  301.  
  302. void CL_Disconnect (void);
  303. void CL_Disconnect_f (void);
  304. void CL_NextDemo (void);
  305.  
  306. #define     MAX_VISEDICTS 256
  307. extern  int       cl_numvisedicts;
  308. extern  entity_t    *cl_visedicts[MAX_VISEDICTS];
  309.  
  310. //
  311. // cl_input
  312. //
  313. typedef struct
  314. {
  315.   int   down[2];    // key nums holding it down
  316.   int   state;      // low bit is down state
  317. } kbutton_t;
  318.  
  319. extern  kbutton_t in_mlook, in_klook;
  320. extern  kbutton_t   in_strafe;
  321. extern  kbutton_t   in_speed;
  322.  
  323. void CL_InitInput (void);
  324. void CL_SendCmd (void);
  325. void CL_SendMove (usercmd_t *cmd);
  326.  
  327. void CL_ParseTEnt (void);
  328. void CL_UpdateTEnts (void);
  329.  
  330. void CL_ClearState (void);
  331.  
  332.  
  333. int  CL_ReadFromServer (void);
  334. void CL_WriteToServer (usercmd_t *cmd);
  335. void CL_BaseMove (usercmd_t *cmd);
  336.  
  337.  
  338. float CL_KeyState (kbutton_t *key);
  339. char *Key_KeynumToString (int keynum);
  340.  
  341. //
  342. // cl_demo.c
  343. //
  344. void CL_StopPlayback (void);
  345. int CL_GetMessage (void);
  346.  
  347. void CL_Stop_f (void);
  348. void CL_Record_f (void);
  349. void CL_PlayDemo_f (void);
  350. void CL_TimeDemo_f (void);
  351.  
  352. //
  353. // cl_parse.c
  354. //
  355. void CL_ParseServerMessage (void);
  356. void CL_NewTranslation (int slot);
  357.  
  358. //
  359. // view
  360. //
  361. void V_StartPitchDrift (void);
  362. void V_StopPitchDrift (void);
  363.  
  364. void V_RenderView (void);
  365. void V_UpdatePalette (void);
  366. void V_Register (void);
  367. void V_ParseDamage (void);
  368. void V_SetContentsColor (int contents);
  369.  
  370.  
  371. //
  372. // cl_tent
  373. //
  374. void CL_InitTEnts (void);
  375. void CL_SignonReply (void);
  376.