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 // quakedef.h -- primary header for client 21 22 //#define GLTEST // experimental stuff 23 24 #define QUAKE_GAME // as opposed to utilities 25 26 #define VERSION 1.09 27 #define GLQUAKE_VERSION 1.00 28 #define D3DQUAKE_VERSION 0.01 29 #define WINQUAKE_VERSION 0.996 30 #define LINUX_VERSION 1.30 31 #define X11_VERSION 1.10 32 33 //define PARANOID // speed sapping error checking 34 35 #define GLQUAKE 36 #define USE_OPENGLES 37 #define id386 0 38 39 #ifdef QUAKE2 40 #define GAMENAME "id1" // directory to look in by default 41 #else 42 #define GAMENAME "id1" 43 #endif 44 45 #include <math.h> 46 #include <string.h> 47 #include <stdarg.h> 48 #include <stdio.h> 49 #include <stdlib.h> 50 #include <setjmp.h> 51 52 #if defined(_WIN32) && !defined(WINDED) 53 54 #if defined(_M_IX86) 55 #define __i386__ 1 56 #endif 57 58 void VID_LockBuffer (void); 59 void VID_UnlockBuffer (void); 60 61 #else 62 63 #define VID_LockBuffer() 64 #define VID_UnlockBuffer() 65 66 #endif 67 68 #if !defined id386 69 #if defined __i386__ // && !defined __sun__ 70 #define id386 1 71 #else 72 #define id386 0 73 #endif 74 #endif 75 76 #if id386 77 #define UNALIGNED_OK 1 // set to 0 if unaligned accesses are not supported 78 #else 79 #define UNALIGNED_OK 0 80 #endif 81 82 // !!! if this is changed, it must be changed in d_ifacea.h too !!! 83 #define CACHE_SIZE 32 // used to align key data structures 84 85 #define UNUSED(x) (x = x) // for pesky compiler / lint warnings 86 87 #define MINIMUM_MEMORY 0x550000 88 #define MINIMUM_MEMORY_LEVELPAK (MINIMUM_MEMORY + 0x100000) 89 90 #define MAX_NUM_ARGVS 50 91 92 // up / down 93 #define PITCH 0 94 95 // left / right 96 #define YAW 1 97 98 // fall over 99 #define ROLL 2 100 101 102 #define MAX_QPATH 64 // max length of a quake game pathname 103 #define MAX_OSPATH 128 // max length of a filesystem pathname 104 105 #define ON_EPSILON 0.1 // point on plane side epsilon 106 107 #define MAX_MSGLEN 8000 // max length of a reliable message 108 #define MAX_DATAGRAM 1024 // max length of unreliable message 109 110 // 111 // per-level limits 112 // 113 #define MAX_EDICTS 600 // FIXME: ouch! ouch! ouch! 114 #define MAX_LIGHTSTYLES 64 115 #define MAX_MODELS 256 // these are sent over the net as bytes 116 #define MAX_SOUNDS 256 // so they cannot be blindly increased 117 118 #define SAVEGAME_COMMENT_LENGTH 39 119 120 #define MAX_STYLESTRING 64 121 122 // 123 // stats are integers communicated to the client by the server 124 // 125 #define MAX_CL_STATS 32 126 #define STAT_HEALTH 0 127 #define STAT_FRAGS 1 128 #define STAT_WEAPON 2 129 #define STAT_AMMO 3 130 #define STAT_ARMOR 4 131 #define STAT_WEAPONFRAME 5 132 #define STAT_SHELLS 6 133 #define STAT_NAILS 7 134 #define STAT_ROCKETS 8 135 #define STAT_CELLS 9 136 #define STAT_ACTIVEWEAPON 10 137 #define STAT_TOTALSECRETS 11 138 #define STAT_TOTALMONSTERS 12 139 #define STAT_SECRETS 13 // bumped on client side by svc_foundsecret 140 #define STAT_MONSTERS 14 // bumped by svc_killedmonster 141 142 // stock defines 143 144 #define IT_SHOTGUN 1 145 #define IT_SUPER_SHOTGUN 2 146 #define IT_NAILGUN 4 147 #define IT_SUPER_NAILGUN 8 148 #define IT_GRENADE_LAUNCHER 16 149 #define IT_ROCKET_LAUNCHER 32 150 #define IT_LIGHTNING 64 151 #define IT_SUPER_LIGHTNING 128 152 #define IT_SHELLS 256 153 #define IT_NAILS 512 154 #define IT_ROCKETS 1024 155 #define IT_CELLS 2048 156 #define IT_AXE 4096 157 #define IT_ARMOR1 8192 158 #define IT_ARMOR2 16384 159 #define IT_ARMOR3 32768 160 #define IT_SUPERHEALTH 65536 161 #define IT_KEY1 131072 162 #define IT_KEY2 262144 163 #define IT_INVISIBILITY 524288 164 #define IT_INVULNERABILITY 1048576 165 #define IT_SUIT 2097152 166 #define IT_QUAD 4194304 167 #define IT_SIGIL1 (1<<28) 168 #define IT_SIGIL2 (1<<29) 169 #define IT_SIGIL3 (1<<30) 170 #define IT_SIGIL4 (1<<31) 171 172 //=========================================== 173 //rogue changed and added defines 174 175 #define RIT_SHELLS 128 176 #define RIT_NAILS 256 177 #define RIT_ROCKETS 512 178 #define RIT_CELLS 1024 179 #define RIT_AXE 2048 180 #define RIT_LAVA_NAILGUN 4096 181 #define RIT_LAVA_SUPER_NAILGUN 8192 182 #define RIT_MULTI_GRENADE 16384 183 #define RIT_MULTI_ROCKET 32768 184 #define RIT_PLASMA_GUN 65536 185 #define RIT_ARMOR1 8388608 186 #define RIT_ARMOR2 16777216 187 #define RIT_ARMOR3 33554432 188 #define RIT_LAVA_NAILS 67108864 189 #define RIT_PLASMA_AMMO 134217728 190 #define RIT_MULTI_ROCKETS 268435456 191 #define RIT_SHIELD 536870912 192 #define RIT_ANTIGRAV 1073741824 193 #define RIT_SUPERHEALTH 2147483648 194 195 //MED 01/04/97 added hipnotic defines 196 //=========================================== 197 //hipnotic added defines 198 #define HIT_PROXIMITY_GUN_BIT 16 199 #define HIT_MJOLNIR_BIT 7 200 #define HIT_LASER_CANNON_BIT 23 201 #define HIT_PROXIMITY_GUN (1<<HIT_PROXIMITY_GUN_BIT) 202 #define HIT_MJOLNIR (1<<HIT_MJOLNIR_BIT) 203 #define HIT_LASER_CANNON (1<<HIT_LASER_CANNON_BIT) 204 #define HIT_WETSUIT (1<<(23+2)) 205 #define HIT_EMPATHY_SHIELDS (1<<(23+3)) 206 207 //=========================================== 208 209 #define MAX_SCOREBOARD 16 210 #define MAX_SCOREBOARDNAME 32 211 212 #define SOUND_CHANNELS 8 213 214 // This makes anyone on id's net privileged 215 // Use for multiplayer testing only - VERY dangerous!!! 216 // #define IDGODS 217 218 #include "common.h" 219 #include "bspfile.h" 220 #include "vid.h" 221 #include "sys.h" 222 #include "zone.h" 223 #include "mathlib.h" 224 225 typedef struct 226 { 227 vec3_t origin; 228 vec3_t angles; 229 int modelindex; 230 int frame; 231 int colormap; 232 int skin; 233 int effects; 234 } entity_state_t; 235 236 237 #include "wad.h" 238 #include "draw.h" 239 #include "cvar.h" 240 #include "screen.h" 241 #include "net.h" 242 #include "protocol.h" 243 #include "cmd.h" 244 #include "sbar.h" 245 #include "sound.h" 246 #include "render.h" 247 #include "client.h" 248 #include "progs.h" 249 #include "server.h" 250 251 #ifdef GLQUAKE 252 #include "gl_model.h" 253 #else 254 #include "model.h" 255 #include "d_iface.h" 256 #endif 257 258 #include "input.h" 259 #include "world.h" 260 #include "keys.h" 261 #include "console.h" 262 #include "view.h" 263 #include "menu.h" 264 #include "crc.h" 265 #include "cdaudio.h" 266 267 #ifdef GLQUAKE 268 #include "glquake.h" 269 #else 270 #define GLCHECK(PROMPT) do {} while(0) 271 #endif 272 273 //============================================================================= 274 275 // the host system specifies the base of the directory tree, the 276 // command line parms passed to the program, and the amount of memory 277 // available for the program to use 278 279 typedef struct 280 { 281 const char *basedir; 282 const char *cachedir; // for development over ISDN lines 283 int argc; 284 const char **argv; 285 void *membase; 286 int memsize; 287 } quakeparms_t; 288 289 290 //============================================================================= 291 292 293 294 extern qboolean noclip_anglehack; 295 296 297 // 298 // host 299 // 300 extern quakeparms_t host_parms; 301 302 extern cvar_t sys_ticrate; 303 extern cvar_t sys_nostdout; 304 extern cvar_t developer; 305 306 extern qboolean host_initialized; // true if into command execution 307 extern double host_frametime; 308 extern byte *host_basepal; 309 extern byte *host_colormap; 310 extern int host_framecount; // incremented every frame, never reset 311 extern qboolean host_framethrottled; // Running too fast 312 extern double realtime; // not bounded in any way, changed at 313 // start of every frame, never reset 314 315 void Host_ClearMemory (void); 316 void Host_ServerFrame (void); 317 void Host_InitCommands (void); 318 void Host_Init (quakeparms_t *parms); 319 void Host_Shutdown(void); 320 void Host_Error (const char *error, ...); 321 void Host_EndGame (const char *message, ...); 322 void Host_Frame (float time); 323 void Host_Quit_f (void); 324 void Host_ClientCommands (const char *fmt, ...); 325 void Host_ShutdownServer (qboolean crash); 326 327 extern qboolean msg_suppress_1; // suppresses resolution and cache size console output 328 // an fullscreen DIB focus gain/loss 329 extern int current_skill; // skill level for currently loaded level (in case 330 // the user changes the cvar while the level is 331 // running, this reflects the level actually in use) 332 333 extern qboolean isDedicated; 334 335 extern int minimum_memory; 336 337 // 338 // chase 339 // 340 extern cvar_t chase_active; 341 342 void Chase_Init (void); 343 void Chase_Reset (void); 344 void Chase_Update (void); 345 346 qboolean SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, trace_t *trace); 347 348 // Linux versions of msdos CRT functions 349 #define stricmp strcasecmp 350 351 // Helper functions for OpenGL ES 352 void DrawQuad_NoTex(GLfloat x, GLfloat y, GLfloat w, GLfloat h); 353 void DrawQuad(GLfloat x, GLfloat y, GLfloat w, GLfloat h, GLfloat u, GLfloat v, GLfloat uw, GLfloat vh); 354 355 void shadowLoadIdentity( GLfloat* m); 356 void shadowRotatef( GLfloat* m, GLfloat a, GLfloat x, GLfloat y, GLfloat z); 357 void shadowTranslatef( GLfloat* m, GLfloat x, GLfloat y, GLfloat z); 358 359 #ifdef USE_OPENGLES 360 // Reimplementation of OpenGL functions that are missing in OpenGL ES 361 362 #define GL_INTENSITY 0x8049 363 364 void glColor3f(GLfloat r, GLfloat g, GLfloat b); 365 void glColor4fv(GLfloat* pColor); 366 367 #define VERTEXARRAYSIZE 2048 368 369 extern float gVertexBuffer[VERTEXARRAYSIZE]; 370 extern float gColorBuffer[VERTEXARRAYSIZE]; 371 extern float gTexCoordBuffer[VERTEXARRAYSIZE]; 372 373 #endif // USE_OPENGLES 374 375 void glTexImage2DHelper( GLenum target, 376 GLint level, 377 GLint internalformat, 378 GLsizei width, 379 GLsizei height, 380 GLint border, 381 GLenum format, 382 GLenum type, 383 const GLvoid *pixels ); 384 385 // Forward declarations: 386 387 qboolean VID_Is8bit(void); 388 void GL_SubdivideSurface (msurface_t *fa); 389 void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr); 390 int R_LightPoint (vec3_t p); 391 void R_DrawBrushModel (entity_t *e); 392 void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees ); 393 void R_AnimateLight (void); 394 void V_CalcBlend (void); 395 void R_DrawWorld (void); 396 void R_RenderDlights(void); 397 void R_DrawParticles (void); 398 void R_DrawWaterSurfaces (void); 399 void R_RenderBrushPoly (msurface_t *fa); 400 void R_InitParticles (void); 401 void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboolean alpha); 402 void R_ClearParticles (void); 403 void GL_BuildLightmaps (void); 404 void EmitWaterPolys (msurface_t *fa); 405 void EmitSkyPolys (msurface_t *fa); 406 void EmitBothSkyLayers (msurface_t *fa); 407 void R_DrawSkyChain (msurface_t *s); 408 qboolean R_CullBox (vec3_t mins, vec3_t maxs); 409 void R_MarkLights (dlight_t *light, int bit, mnode_t *node); 410 void R_RotateForEntity (entity_t *e); 411 void R_StoreEfrags (efrag_t **ppefrag); 412 void GL_Set2D (void); 413 414 // Poor Man's Profiler 415 // (And general loging.) 416 417 void PMP_Begin(const char* fmt,...); 418 void PMP_Event(const char* fmt,...); 419 void PMP_End(const char* fmt,...); 420 421 #define PMPLOG(ARGS) PMP_Event ARGS 422 #define PMPWARNING(ARGS) PMP_Event ARGS 423 #define PMPERROR(ARGS) PMP_Event ARGS 424 425 // #define ENABLE_PMP 426 427 #ifdef ENABLE_PMP 428 429 #define PMPBEGIN(ARGS) PMP_Begin ARGS 430 #define PMPEVENT(ARGS) PMP_Event ARGS 431 #define PMPEND(ARGS) PMP_End ARGS 432 433 #else 434 435 #define PMPBEGIN(ARGS) ((void) 0) 436 #define PMPEVENT(ARGS) ((void) 0) 437 #define PMPEND(ARGS) ((void) 0) 438 439 #endif 440 441 // Measure fastest / slowest frames 442 typedef struct frameTime_ { 443 int frame; 444 float time; 445 } frameTime; 446 447 extern frameTime fastestFrame; 448 extern frameTime slowestFrame; 449 450 void InitFrameTimes(); 451 452 // Feature configuration 453 454 #define SUPPORT_8BIT_MIPMAPGENERATION 455 456 #ifdef SUPPORT_8BIT_MIPMAPGENERATION 457 extern unsigned char d_15to8table[65536]; 458 #endif // SUPPORT_8BIT_MIPMAPGENERATION 459 460