1 /** 2 * @file dd_share.h 3 * Shared macros and constants. 4 * 5 * Various macros and constants used by the engine and games. 6 * 7 * @authors Copyright © 2003-2017 Jaakko Keränen <jaakko.keranen@iki.fi> 8 * @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net> 9 * 10 * @par License 11 * GPL: http://www.gnu.org/licenses/gpl.html 12 * 13 * <small>This program is free software; you can redistribute it and/or modify 14 * it under the terms of the GNU General Public License as published by the 15 * Free Software Foundation; either version 2 of the License, or (at your 16 * option) any later version. This program is distributed in the hope that it 17 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 18 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 19 * Public License for more details. You should have received a copy of the GNU 20 * General Public License along with this program; if not, write to the Free 21 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 22 * 02110-1301 USA</small> 23 */ 24 25 #ifndef LIBDENG_SHARED_H 26 #define LIBDENG_SHARED_H 27 28 #ifndef C_DECL 29 # if defined(WIN32) 30 /// Defines the calling convention for compare functions. Only used on Windows. 31 # define C_DECL __cdecl 32 # elif defined(UNIX) 33 # define C_DECL 34 # else 35 # define C_DECL 36 # endif 37 #endif 38 39 #include <stdlib.h> 40 #include <string.h> 41 #include <stdarg.h> 42 #include <de/aabox.h> 43 #include <doomsday/players.h> 44 #include <doomsday/player.h> 45 #include <doomsday/console/var.h> 46 #include <doomsday/console/cmd.h> 47 #include "dengproject.h" 48 #include "dd_version.h" 49 #include "dd_types.h" 50 #include "def_share.h" 51 #include "api_thinker.h" 52 #include "api_map.h" 53 #include "api_gl.h" 54 #include "api_busy.h" 55 #include "api_event.h" 56 #include "api_player.h" 57 #include "api_infine.h" 58 59 #ifdef __cplusplus 60 extern "C" { 61 #endif 62 63 //------------------------------------------------------------------------ 64 // 65 // General Definitions and Macros 66 // 67 //------------------------------------------------------------------------ 68 69 /// @defgroup apiFlags Flags 70 71 // The case-independent strcmps have different names. 72 #if WIN32 73 # define strcasecmp _stricmp 74 # define strncasecmp _strnicmp 75 # define strlwr _strlwr 76 #endif 77 78 #if UNIX 79 # define stricmp strcasecmp 80 # define strnicmp strncasecmp 81 #endif 82 83 // Format checking for printf-like functions in GCC2 84 #if defined(__GNUC__) && __GNUC__ >= 2 85 # define PRINTF_F(f,v) __attribute__ ((format (printf, f, v))) 86 #else 87 # define PRINTF_F(f,v) 88 #endif 89 90 int16_t ShortSwap(int16_t); 91 int32_t LongSwap(int32_t); 92 float FloatSwap(float); 93 94 #ifdef __BIG_ENDIAN__ 95 #define DD_SHORT(x) ShortSwap(x) 96 #define DD_LONG(x) LongSwap(x) 97 #define DD_FLOAT(x) FloatSwap(x) 98 99 #define BIGSHORT(x) (x) 100 #define BIGLONG(x) (x) 101 #define BIGFLOAT(x) (x) 102 103 // In these, x is evaluated multiple times, so increments and decrements 104 // cannot be used. 105 #define MACRO_SHORT(x) ((int16_t)(( ((int16_t)(x)) & 0xff ) << 8) | (( ((int16_t)(x)) & 0xff00) >> 8)) 106 #define MACRO_LONG(x) ((int32_t)((( ((int32_t)(x)) & 0xff) << 24) | (( ((int32_t)(x)) & 0xff00) << 8) | \ 107 (( ((int32_t)(x)) & 0xff0000) >> 8) | (( ((int32_t)(x)) & 0xff000000) >> 24) )) 108 #else 109 /// Byte order conversion from native to little-endian. @{ 110 #define DD_SHORT(x) (x) 111 #define DD_LONG(x) (x) 112 #define DD_FLOAT(x) (x) 113 ///@} 114 115 /// Byte order conversion from native to big-endian. @{ 116 #define BIGSHORT(x) ShortSwap(x) 117 #define BIGLONG(x) LongSwap(x) 118 #define BIGFLOAT(x) FloatSwap(x) 119 ///@} 120 121 #define MACRO_SHORT(x) (x) 122 #define MACRO_LONG(x) (x) 123 #endif 124 125 /// Byte order conversion from native to little-endian. @{ 126 #define DD_USHORT(x) ((uint16_t) DD_SHORT(x)) 127 #define DD_ULONG(x) ((uint32_t) DD_LONG(x)) 128 ///@} 129 130 enum { 131 DD_FIRST_VALUE = 0, 132 133 DD_NOVIDEO = DD_FIRST_VALUE, 134 DD_NETGAME, 135 DD_SERVER, ///< Running in server mode + listening. 136 DD_CLIENT, 137 DD_CONSOLEPLAYER, 138 DD_DISPLAYPLAYER, 139 DD_GOTFRAME, 140 DD_NUMSOUNDS, 141 142 // Server-only: 143 DD_SERVER_ALLOW_FRAMES, 144 145 // Client-only: 146 DD_RENDER_FULLBRIGHT, ///< Render everything fullbright? 147 DD_GAME_READY, 148 DD_PLAYBACK, 149 DD_CLIENT_PAUSED, 150 DD_WEAPON_OFFSET_SCALE_Y, ///< 1000x 151 DD_GAME_DRAW_HUD_HINT, ///< Doomsday advises not to draw the HUD. 152 DD_SYMBOLIC_ECHO, 153 DD_FIXEDCOLORMAP_ATTENUATE, 154 155 DD_LAST_VALUE, 156 157 // Other values: 158 DD_GAME_EXPORTS = 0x1000, 159 DD_SHIFT_DOWN, 160 161 DD_WINDOW_WIDTH = 0x1100, 162 DD_WINDOW_HEIGHT, 163 DD_WINDOW_HANDLE, 164 DD_USING_HEAD_TRACKING, 165 DD_DYNLIGHT_TEXTURE, 166 DD_PSPRITE_OFFSET_X, ///< 10x 167 DD_PSPRITE_OFFSET_Y, ///< 10x 168 DD_PSPRITE_LIGHTLEVEL_MULTIPLIER, 169 DD_TORCH_RED, 170 DD_TORCH_GREEN, 171 DD_TORCH_BLUE, 172 173 DD_DEFS = 0x1200, ///< engine definition database (DED) 174 DD_NUMMOBJTYPES, 175 176 DD_CURRENT_CLIENT_FINALE_ID = 0x1300, 177 178 DD_GAMETIC = 0x1400, 179 DD_MAP_BOUNDING_BOX, 180 DD_MAP_MUSIC, 181 DD_MAP_MIN_X, 182 DD_MAP_MIN_Y, 183 DD_MAP_MAX_X, 184 DD_MAP_MAX_Y, 185 DD_MAP_POLYOBJ_COUNT, 186 DD_MAP_GRAVITY, 187 }; 188 189 //------------------------------------------------------------------------ 190 // 191 // Games 192 // 193 //------------------------------------------------------------------------ 194 195 /** 196 * @defgroup game Game 197 */ 198 199 /** 200 * @defgroup fileFlags File Flags 201 * @ingroup apiFlags fs 202 */ 203 ///@{ 204 #define FF_STARTUP 0x1 ///< A required file needed for and loaded during game start up (can't be a virtual file). 205 #define FF_FOUND 0x2 ///< File has been located. 206 ///@} 207 208 /** 209 * @defgroup math Math Routines 210 * @ingroup base 211 */ 212 213 //------------------------------------------------------------------------ 214 // 215 // World Data 216 // 217 //------------------------------------------------------------------------ 218 219 /// @defgroup world World Data 220 221 /** 222 * @defgroup dmu Map Update (DMU) 223 * @ingroup world 224 */ 225 ///@{ 226 227 /// Map Update constants. @ingroup dmu 228 enum { 229 // Do not change the numerical values of the constants! 230 231 /// Flag. OR'ed with a DMU property constant. Note: these use only the most 232 /// significant byte. 233 /// @{ 234 DMU_FLAG_MASK = 0xff000000, 235 DMU_BACK_OF_LINE = 0x80000000, 236 DMU_FRONT_OF_LINE = 0x40000000, 237 DMU_TOP_OF_SIDE = 0x20000000, 238 DMU_MIDDLE_OF_SIDE = 0x10000000, 239 DMU_BOTTOM_OF_SIDE = 0x08000000, 240 DMU_FLOOR_OF_SECTOR = 0x04000000, 241 DMU_CEILING_OF_SECTOR = 0x02000000, 242 // (1 bits left) 243 ///@} 244 245 DMU_NONE = 0, 246 247 /* 248 * Element types: 249 */ 250 DMU_FIRST_ELEMENT_TYPE_ID = 1, 251 DMU_VERTEX = DMU_FIRST_ELEMENT_TYPE_ID, 252 DMU_SEGMENT, 253 DMU_LINE, 254 DMU_SIDE, 255 DMU_SECTOR, 256 DMU_PLANE, 257 DMU_SURFACE, 258 DMU_MATERIAL, 259 DMU_SUBSPACE, 260 DMU_SKY, 261 DMU_LAST_ELEMENT_TYPE_ID = DMU_SKY, 262 263 /* 264 * Selection methods: 265 */ 266 DMU_LINE_BY_TAG, 267 DMU_SECTOR_BY_TAG, 268 269 DMU_LINE_BY_ACT_TAG, 270 DMU_SECTOR_BY_ACT_TAG, 271 272 /* 273 * Element properties: 274 */ 275 DMU_ARCHIVE_INDEX, ///< Relevant data/definition position in the "archived" map. 276 277 DMU_X, 278 DMU_Y, 279 DMU_XY, 280 281 DMU_TANGENT_X, 282 DMU_TANGENT_Y, 283 DMU_TANGENT_Z, 284 DMU_TANGENT_XYZ, 285 286 DMU_BITANGENT_X, 287 DMU_BITANGENT_Y, 288 DMU_BITANGENT_Z, 289 DMU_BITANGENT_XYZ, 290 291 DMU_NORMAL_X, 292 DMU_NORMAL_Y, 293 DMU_NORMAL_Z, 294 DMU_NORMAL_XYZ, 295 296 DMU_VERTEX0, 297 DMU_VERTEX1, 298 299 DMU_FRONT, 300 DMU_BACK, 301 DMU_FLAGS, 302 DMU_DX, 303 DMU_DY, 304 DMU_DXY, 305 DMU_LENGTH, 306 DMU_SLOPETYPE, 307 DMU_ANGLE, 308 DMU_OFFSET, 309 310 DMU_OFFSET_X, 311 DMU_OFFSET_Y, 312 DMU_OFFSET_XY, 313 314 DMU_VALID_COUNT, 315 DMU_COLOR, ///< RGB 316 DMU_COLOR_RED, ///< red component 317 DMU_COLOR_GREEN, ///< green component 318 DMU_COLOR_BLUE, ///< blue component 319 DMU_ALPHA, 320 DMU_BLENDMODE, 321 DMU_LIGHT_LEVEL, 322 DMT_MOBJS, ///< pointer to start of sector mobjList 323 DMU_BOUNDING_BOX, ///< AABoxd 324 DMU_EMITTER, 325 DMU_WIDTH, 326 DMU_HEIGHT, 327 DMU_TARGET_HEIGHT, 328 DMU_SPEED, 329 DMU_FLOOR_PLANE, 330 DMU_CEILING_PLANE 331 }; 332 333 /// Determines whether @a val can be interpreted as a valid DMU element type id. 334 #define VALID_DMU_ELEMENT_TYPE_ID(val) ((int)(val) >= (int)DMU_FIRST_ELEMENT_TYPE_ID && (int)(val) <= (int)DMU_LAST_ELEMENT_TYPE_ID) 335 336 /** 337 * @defgroup ldefFlags Line Flags 338 * @ingroup dmu apiFlags 339 * For use with P_Set/Get(DMU_LINE, n, DMU_FLAGS). 340 */ 341 342 /// @addtogroup ldefFlags 343 ///@{ 344 #define DDLF_BLOCKING 0x0001 345 #define DDLF_DONTPEGTOP 0x0002 346 #define DDLF_DONTPEGBOTTOM 0x0004 347 ///@} 348 349 /** 350 * @defgroup sdefFlags Side Flags 351 * @ingroup dmu apiFlags 352 * For use with P_Set/Get(DMU_SIDE, n, DMU_FLAGS). 353 */ 354 355 /// @addtogroup sdefFlags 356 ///@{ 357 #define SDF_BLENDTOPTOMID 0x0001 358 #define SDF_BLENDMIDTOTOP 0x0002 359 #define SDF_BLENDMIDTOBOTTOM 0x0004 360 #define SDF_BLENDBOTTOMTOMID 0x0008 361 #define SDF_MIDDLE_STRETCH 0x0010 ///< Stretch the middle surface to reach from floor to ceiling. 362 363 /// Suppress the relative back sector and consider this as one-sided for the 364 /// purposes of rendering and line of sight tests. 365 #define SDF_SUPPRESS_BACK_SECTOR 0x0020 366 ///@} 367 368 /** 369 * @defgroup skyLayerFlags Sky Flags 370 * @ingroup dmu apiFlags 371 * For use with P_Set/Get(DMU_SKY, n, DMU_FLAGS). 372 */ 373 374 /// @addtogroup skyFlags 375 ///@{ 376 #define SKYF_LAYER0_ENABLED 0x00000100 ///< Layer 0 is enabled. 377 #define SKYF_LAYER1_ENABLED 0x00010000 ///< Layer 1 is enabled. 378 ///@} 379 380 /** 381 * @defgroup surfaceFlags Surface Flags 382 * @ingroup dmu apiFlags 383 * For use with P_Set/Get(DMU_SURFACE, n, DMU_FLAGS). 384 */ 385 386 /// @addtogroup surfaceFlags 387 ///@{ 388 #define DDSUF_MATERIAL_FLIPH 0x00000001 ///< Surface material is flipped horizontally. 389 #define DDSUF_MATERIAL_FLIPV 0x00000002 ///< Surface material is flipped vertically. 390 ///@} 391 392 /// Map Update status code constants. @ingroup dmu 393 /// Sent to the game when various map update events occur. 394 enum { /* Do NOT change the numerical values of the constants. */ 395 DMUSC_LINE_FIRSTRENDERED 396 }; 397 398 ///@} 399 400 /// @ingroup mobj 401 #define DD_BASE_DDMOBJ_ELEMENTS() \ 402 thinker_t thinker; /* thinker node */ \ 403 coord_t origin[3]; /* origin [x,y,z] */ \ 404 void *_bspLeaf; /* BSP leaf in which this resides (if known) */ 405 406 /** 407 * All map think-able objects must use this as a base. Also used for sound 408 * origin purposes for all of: mobj_t, Polyobj, Sector/Plane 409 * @ingroup mobj 410 */ 411 typedef struct ddmobj_base_s { 412 DD_BASE_DDMOBJ_ELEMENTS() 413 } ddmobj_base_t; 414 415 /// A base mobj instance is used as a "sound emitter". 416 typedef ddmobj_base_t SoundEmitter; 417 418 //------------------------------------------------------------------------ 419 // 420 // Mobjs 421 // 422 //------------------------------------------------------------------------ 423 424 /// @defgroup mobj Map Objects 425 /// @ingroup world 426 427 /** 428 * @defgroup stateFlags State Flags 429 * @ingroup mobj 430 */ 431 ///@{ 432 #define STF_FULLBRIGHT 0x00000001 433 #define STF_NOAUTOLIGHT 0x00000002 ///< Don't automatically add light if fullbright. 434 ///@} 435 436 /** 437 * @defgroup mobjFlags Mobj Flags 438 * @ingroup mobj 439 */ 440 ///@{ 441 #define DDMF_DONTDRAW 0x00000001 442 #define DDMF_SHADOW 0x00000002 443 #define DDMF_ALTSHADOW 0x00000004 444 #define DDMF_BRIGHTSHADOW 0x00000008 445 #define DDMF_VIEWALIGN 0x00000010 446 #define DDMF_FITTOP 0x00000020 ///< Don't let the sprite go into the ceiling. 447 #define DDMF_NOFITBOTTOM 0x00000040 448 #define DDMF_MOVEBLOCKEDX 0x00000080 ///< Indicates that mobj was unable to move last tick. 449 #define DDMF_MOVEBLOCKEDY 0x00000100 ///< Indicates that mobj was unable to move last tick. 450 #define DDMF_MOVEBLOCKEDZ 0x00000200 ///< Indicates that mobj was unable to move last tick. 451 #define DDMF_MOVEBLOCKED 0x00000380 ///< Combination of XYZ move blocked. 452 #define DDMF_BOB 0x00040000 ///< Bob the Z coord up and down. 453 #define DDMF_LOWGRAVITY 0x00080000 ///< 1/8th gravity (predict). 454 #define DDMF_MISSILE 0x00100000 ///< Client removes mobj upon impact. 455 #define DDMF_FLY 0x00200000 ///< Flying object (doesn't matter if airborne). 456 #define DDMF_NOGRAVITY 0x00400000 ///< Isn't affected by gravity (predict). 457 #define DDMF_ALWAYSLIT 0x00800000 ///< Always process DL even if hidden. 458 459 #define DDMF_SOLID 0x20000000 ///< Solid on client side. 460 #define DDMF_LOCAL 0x40000000 461 #define DDMF_REMOTE 0x80000000 ///< This mobj is really on the server. 462 463 /// Clear masks (flags the game plugin is not allowed to touch). 464 #define DDMF_CLEAR_MASK 0xc0000380 465 466 //#define DDMF_LIGHTSCALESHIFT 7 467 //#define DDMF_LIGHTOFFSETSHIFT 12 468 ///@} 469 470 #define DDMOBJ_RADIUS_MAX 32 471 472 /// The high byte of the selector is not used for modeldef selecting. 473 /// 1110 0000 = alpha level (0: opaque => 7: transparent 7/8) @ingroup mobj 474 #define DDMOBJ_SELECTOR_MASK 0x00ffffff 475 #define DDMOBJ_SELECTOR_SHIFT 24 476 477 #define VISIBLE 1 478 #define INVISIBLE -1 479 480 /// Momentum axis indices. @ingroup mobj 481 enum { MX, MY, MZ }; 482 483 /// Base mobj_t elements. Games MUST use this as the basis for mobj_t. @ingroup mobj 484 #define DD_BASE_MOBJ_ELEMENTS() \ 485 DD_BASE_DDMOBJ_ELEMENTS() \ 486 \ 487 nodeindex_t lineRoot; /* lines to which this is linked */ \ 488 struct mobj_s *sNext, **sPrev; /* links in sector (if needed) */ \ 489 \ 490 coord_t mom[3]; \ 491 angle_t angle; \ 492 spritenum_t sprite; /* used to find patch_t and flip value */ \ 493 int frame; \ 494 coord_t radius; \ 495 coord_t height; \ 496 int ddFlags; /* Doomsday mobj flags (DDMF_*) */ \ 497 coord_t floorClip; /* value to use for floor clipping */ \ 498 int valid; /* if == valid, already checked */ \ 499 int type; /* mobj type */ \ 500 struct state_s *state; \ 501 int tics; /* state tic counter */ \ 502 coord_t floorZ; /* highest contacted floor */ \ 503 coord_t ceilingZ; /* lowest contacted ceiling */ \ 504 struct mobj_s *onMobj; /* the mobj this one is on top of. */ \ 505 dd_bool wallHit; /* the mobj is hitting a wall. */ \ 506 struct ddplayer_s *dPlayer; /* NULL if not a player mobj. */ \ 507 coord_t srvo[3]; /* short-range visual offset (xyz) */ \ 508 short visAngle; /* visual angle ("angle-servo") */ \ 509 int selector; /* multipurpose info */ \ 510 int validCount; /* used in iterating */ \ 511 int addFrameCount; \ 512 int lumIdx; /* index of the lumobj or -1 */ \ 513 byte haloFactors[DDMAXPLAYERS]; /* strengths of halo */ \ 514 byte translucency; /* default = 0 = opaque */ \ 515 short visTarget; /* -1 = mobj is becoming less visible, */ \ 516 /* 0 = no change, 2= mobj is becoming more visible */ \ 517 int reactionTime; /* if not zero, freeze controls */ \ 518 int tmap, tclass; /* color translation (0, 0 == none) */ \ 519 int flags;\ 520 int flags2;\ 521 int flags3;\ 522 int health;\ 523 mobjinfo_t *info; /* &mobjinfo[mobj->type] */ 524 525 /// Base Polyobj elements. Games MUST use this as the basis for Polyobj. @ingroup world 526 #define DD_BASE_POLYOBJ_ELEMENTS() \ 527 DD_BASE_DDMOBJ_ELEMENTS() \ 528 \ 529 int tag; /* Reference tag. */ \ 530 int validCount; \ 531 AABoxd bounds; \ 532 coord_t dest[2]; /* Destination XY. */ \ 533 angle_t angle; \ 534 angle_t destAngle; /* Destination angle. */ \ 535 angle_t angleSpeed; /* Rotation speed. */ \ 536 double speed; /* Movement speed. */ \ 537 dd_bool crush; /* Should the polyobj attempt to crush mobjs? */ \ 538 int seqType; \ 539 540 //------------------------------------------------------------------------ 541 // 542 // Refresh 543 // 544 //------------------------------------------------------------------------ 545 546 #define SCREENWIDTH 320 547 #define SCREENHEIGHT 200 548 549 #define DD_SCREENSHOT_CHECK_EXISTS 0x1 550 551 /** 552 * @defgroup alignmentFlags Alignment Flags 553 * @ingroup apiFlags 554 */ 555 ///@{ 556 #define ALIGN_LEFT (0x1) 557 #define ALIGN_RIGHT (0x2) 558 #define ALIGN_TOP (0x4) 559 #define ALIGN_BOTTOM (0x8) 560 561 #define ALIGN_TOPLEFT (ALIGN_TOP|ALIGN_LEFT) 562 #define ALIGN_TOPRIGHT (ALIGN_TOP|ALIGN_RIGHT) 563 #define ALIGN_BOTTOMLEFT (ALIGN_BOTTOM|ALIGN_LEFT) 564 #define ALIGN_BOTTOMRIGHT (ALIGN_BOTTOM|ALIGN_RIGHT) 565 566 #define ALL_ALIGN_FLAGS (ALIGN_LEFT|ALIGN_RIGHT|ALIGN_TOP|ALIGN_BOTTOM) 567 ///@} 568 569 typedef enum { 570 ORDER_NONE = 0, 571 ORDER_LEFTTORIGHT, 572 ORDER_RIGHTTOLEFT 573 } order_t; 574 575 /// Can the value be interpreted as a valid scale mode identifier? 576 #define VALID_SCALEMODE(val) ((val) >= SCALEMODE_FIRST && (val) <= SCALEMODE_LAST) 577 578 #define DEFAULT_SCALEMODE_STRETCH_EPSILON (.1f) 579 580 //------------------------------------------------------------------------ 581 // 582 // Sound 583 // 584 //------------------------------------------------------------------------ 585 586 /** 587 * @defgroup soundFlags Sound Flags 588 * @ingroup apiFlags 589 * Flags specifying the logical behavior of a sound. 590 */ 591 ///@{ 592 #define DDSF_FLAG_MASK 0xff000000 593 #define DDSF_NO_ATTENUATION 0x80000000 594 #define DDSF_REPEAT 0x40000000 595 ///@} 596 597 /** 598 * @defgroup soundStopFlags Sound Stop Flags 599 * @ingroup apiFlags 600 * Flags for use with S_StopSound() 601 */ 602 ///@{ 603 #define SSF_SECTOR 0x1 ///< Stop sounds from the sector's emitter. 604 #define SSF_SECTOR_LINKED_SURFACES 0x2 ///< Stop sounds from surface emitters in the same sector. 605 #define SSF_ALL_SECTOR (SSF_SECTOR | SSF_SECTOR_LINKED_SURFACES) 606 ///@} 607 608 typedef struct { 609 float volume; // 0..1 610 float decay; // Decay factor: 0 (acoustically dead) ... 1 (live) 611 float damping; // High frequency damping factor: 0..1 612 float space; // 0 (small space) ... 1 (large space) 613 } reverb_t; 614 615 // Use with PlaySong(). 616 #define DDMUSICF_EXTERNAL 0x80000000 617 618 //------------------------------------------------------------------------ 619 // 620 // Graphics 621 // 622 //------------------------------------------------------------------------ 623 624 /// @defgroup resource Resources 625 ///@{ 626 627 /// Special value used to signify an invalid material id. 628 #define NOMATERIALID 0 629 630 ///@} 631 632 /// Unique identifier associated with each archived material. 633 /// @ingroup resource 634 typedef unsigned short materialarchive_serialid_t; 635 636 /** 637 * @defgroup materialFlags Material Flags 638 * @ingroup apiFlags resource 639 */ 640 641 /// @addtogroup materialFlags 642 ///@{ 643 //#define MATF_UNUSED1 0x1 644 #define MATF_NO_DRAW 0x2 ///< Material should never be drawn. 645 #define MATF_SKYMASK 0x4 ///< Sky-mask surfaces using this material. 646 ///@} 647 648 /** 649 * @defgroup animationGroupFlags (Material) Animation Group Flags 650 * @ingroup apiFlags resource 651 * @{ 652 */ 653 #define AGF_SMOOTH 0x1 654 #define AGF_FIRST_ONLY 0x2 655 #define AGF_PRECACHE 0x4000 ///< Group is just for precaching. 656 /**@}*/ 657 658 /* 659 * Font Schemes 660 */ 661 662 /// Font scheme identifier. @ingroup scheme 663 typedef enum fontschemeid_e { 664 FS_ANY = -1, 665 FONTSCHEME_FIRST = 3000, 666 FS_SYSTEM = FONTSCHEME_FIRST, 667 FS_GAME, 668 FONTSCHEME_LAST = FS_GAME, 669 FS_INVALID ///< Special value used to signify an invalid scheme identifier. 670 } fontschemeid_t; 671 672 #define FONTSCHEME_COUNT (FONTSCHEME_LAST - FONTSCHEME_FIRST + 1) 673 674 /** 675 * Determines whether @a val can be interpreted as a valid font scheme 676 * identifier. @ingroup scheme 677 * @param val Integer value. 678 * @return @c true or @c false. 679 */ 680 #define VALID_FONTSCHEMEID(val) ((val) >= FONTSCHEME_FIRST && (val) <= FONTSCHEME_LAST) 681 682 /// Patch Info 683 typedef struct { 684 patchid_t id; 685 struct patchinfo_flags_s { 686 uint isCustom:1; ///< Patch does not originate from the current game. 687 uint isEmpty:1; ///< Patch contains no color information. 688 } flags; 689 RectRaw geometry; 690 // Temporary until the big DGL drawing rewrite. 691 short extraOffset[2]; // Only used with upscaled and sharpened patches. 692 } patchinfo_t; 693 694 /// Sprite Info 695 typedef struct { 696 world_Material *material; 697 int flip; 698 RectRaw geometry; 699 float texCoord[2]; // Prepared texture coordinates. 700 } spriteinfo_t; 701 702 /** 703 * Processing modes for GL_LoadGraphics(). 704 */ 705 typedef enum gfxmode_e { 706 LGM_NORMAL = 0, 707 LGM_GRAYSCALE = 1, 708 LGM_GRAYSCALE_ALPHA = 2, 709 LGM_WHITE_ALPHA = 3 710 } gfxmode_t; 711 712 typedef uint colorpaletteid_t; 713 714 //------------------------------------------------------------------------ 715 // 716 // Console 717 // 718 //------------------------------------------------------------------------ 719 720 /// @defgroup console Console 721 722 /** 723 * @defgroup bindings Bindings 724 * @ingroup input 725 * Event and controller bindings. 726 * Input events and input controller state can be bound to console commands 727 * and player controls. 728 */ 729 730 /** 731 * @defgroup cvar Console Variables 732 * @ingroup console 733 */ 734 735 /** 736 * @defgroup ccmd Console Commands 737 * @ingroup console 738 */ 739 740 /** 741 * @defgroup busyModeFlags Busy Mode Flags 742 * @ingroup console apiFlags 743 */ 744 ///@{ 745 #define BUSYF_LAST_FRAME 0x1 746 #define BUSYF_CONSOLE_OUTPUT 0x2 747 #define BUSYF_PROGRESS_BAR 0x4 748 #define BUSYF_ACTIVITY 0x8 ///< Indicate activity. 749 #define BUSYF_NO_UPLOADS 0x10 ///< Deferred uploads not completed. 750 #define BUSYF_STARTUP 0x20 ///< Startup mode: normal fonts, texman not available. 751 #define BUSYF_TRANSITION 0x40 ///< Do a transition effect when busy mode ends. 752 ///@} 753 754 /** 755 * @defgroup consolePrintFlags Console Print Flags 756 * @ingroup console apiFlags 757 */ 758 ///@{ 759 #define CPF_BLACK 0x00000001 ///< These correspond to the good old text mode VGA colors. 760 #define CPF_BLUE 0x00000002 761 #define CPF_GREEN 0x00000004 762 #define CPF_CYAN 0x00000008 763 #define CPF_RED 0x00000010 764 #define CPF_MAGENTA 0x00000020 765 #define CPF_YELLOW 0x00000040 766 #define CPF_WHITE 0x00000080 767 #define CPF_LIGHT 0x00000100 768 #define CPF_UNUSED1 0x00000200 769 #define CPF_CENTER 0x00000400 770 #define CPF_TRANSMIT 0x80000000 ///< If server, sent to all clients. 771 ///@} 772 773 /// Argument type for B_BindingsForControl(). @ingroup bindings 774 typedef enum bfcinverse_e { 775 BFCI_BOTH, 776 BFCI_ONLY_NON_INVERSE, 777 BFCI_ONLY_INVERSE 778 } bfcinverse_t; 779 780 //------------------------------------------------------------------------ 781 // 782 // Networking 783 // 784 //------------------------------------------------------------------------ 785 786 /// @defgroup network Network 787 788 /** 789 * @defgroup netEvents Network Events 790 * @ingroup network 791 * @{ 792 */ 793 /// Network player event. 794 enum { 795 DDPE_ARRIVAL, ///< A player has arrived. 796 DDPE_EXIT, ///< A player has exited the game. 797 DDPE_CHAT_MESSAGE, ///< A player has sent a chat message. 798 DDPE_DATA_CHANGE ///< The data for this player has been changed. 799 }; 800 801 /// Network world events (handled by clients). 802 enum { 803 DDWE_HANDSHAKE, // Shake hands with a new player. 804 DDWE_DEMO_END // Demo playback ends. 805 }; 806 ///@} 807 808 /* 809 * Information about a multiplayer server. @ingroup network 810 * 811 * This structure is not sent over the network. The information is only sent either 812 * as plain text or as a serialized Record. 813 */ 814 /*typedef struct serverinfo_s { 815 int version; 816 char name[64]; 817 char description[80]; 818 int numPlayers, maxPlayers; 819 char canJoin; 820 char address[64]; 821 int port; 822 unsigned short ping; ///< Milliseconds. 823 char plugin[32]; ///< Game plugin and version. 824 char gameIdentityKey[17]; 825 char gameConfig[40]; 826 char map[20]; 827 char clientNames[128]; 828 unsigned int loadedFilesCRC; 829 char iwad[32]; ///< Obsolete. 830 char pwads[128]; 831 int data[3]; 832 } serverinfo_t;*/ 833 834 /** 835 * @defgroup netPackets Network Packets 836 * @ingroup network 837 * @{ 838 */ 839 #define DDPT_HELLO 0 840 #define DDPT_OK 1 841 #define DDPT_CANCEL 2 842 #define DDPT_FIRST_GAME_EVENT 64 ///< All packet types handled by the game should be >= 64. 843 #define DDPT_MESSAGE 67 844 ///@} 845 846 /** 847 * @defgroup netSendFlags Packet Send Flags 848 * @ingroup network apiFlags 849 * The flags are OR'd with @a to_player. 850 * @see Net_SendPacket() 851 * @{ 852 */ 853 #define DDSP_ALL_PLAYERS 0x80000000 ///< Broadcast (for server). 854 ///@} 855 856 #ifdef __cplusplus 857 } // extern "C" 858 #endif 859 860 #endif /* LIBDENG_SHARED_H */ 861