|
Odamex
Setting the Standard in Multiplayer Doom
|
00001 // Emacs style mode select -*- C++ -*- 00002 //----------------------------------------------------------------------------- 00003 // 00004 // $Id: r_defs.h 1892 2010-09-11 01:25:43Z mike $ 00005 // 00006 // Copyright (C) 1993-1996 by id Software, Inc. 00007 // Copyright (C) 2006-2010 by The Odamex Team. 00008 // 00009 // This program is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU General Public License 00011 // as published by the Free Software Foundation; either version 2 00012 // of the License, or (at your option) any later version. 00013 // 00014 // This program is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // DESCRIPTION: 00020 // Refresh/rendering module, shared data struct definitions. 00021 // 00022 //----------------------------------------------------------------------------- 00023 00024 00025 #ifndef __R_DEFS_H__ 00026 #define __R_DEFS_H__ 00027 00028 // Screenwidth. 00029 #include "doomdef.h" 00030 00031 // Some more or less basic data types 00032 // we depend on. 00033 #include "m_fixed.h" 00034 #include "m_swap.h" 00035 00036 // We rely on the thinker data struct 00037 // to handle sound origins in sectors. 00038 // SECTORS do store MObjs anyway. 00039 #include "actor.h" 00040 00041 #include "dthinker.h" 00042 00043 00044 00045 00046 00047 // Silhouette, needed for clipping Segs (mainly) 00048 // and sprites representing things. 00049 #define SIL_NONE 0 00050 #define SIL_BOTTOM 1 00051 #define SIL_TOP 2 00052 #define SIL_BOTH 3 00053 00054 extern int MaxDrawSegs; 00055 00056 00057 00058 00059 00060 // 00061 // INTERNAL MAP TYPES 00062 // used by play and refresh 00063 // 00064 00065 // 00066 // Your plain vanilla vertex. 00067 // Note: transformed values not buffered locally, 00068 // like some DOOM-alikes ("wt", "WebView") did. 00069 // 00070 struct vertex_s 00071 { 00072 fixed_t x, y; 00073 }; 00074 typedef struct vertex_s vertex_t; 00075 00076 // Forward of LineDefs, for Sectors. 00077 struct line_s; 00078 00079 class player_s; 00080 00081 // 00082 // The SECTORS record, at runtime. 00083 // Stores things/mobjs. 00084 // 00085 struct dyncolormap_s; 00086 00087 class DSectorEffect; 00088 00089 struct sector_s 00090 { 00091 fixed_t floorheight; 00092 fixed_t ceilingheight; 00093 short floorpic; 00094 short ceilingpic; 00095 short lightlevel; 00096 short special; 00097 short tag; 00098 int nexttag,firsttag; // killough 1/30/98: improves searches for tags. 00099 00100 // 0 = untraversed, 1,2 = sndlines -1 00101 int soundtraversed; 00102 00103 // thing that made a sound (or null) 00104 AActor::AActorPtr soundtarget; 00105 00106 // mapblock bounding box for height changes 00107 int blockbox[4]; 00108 00109 // origin for any sounds played by the sector 00110 fixed_t soundorg[3]; 00111 00112 // if == validcount, already checked 00113 int validcount; 00114 00115 // list of mobjs in sector 00116 AActor* thinglist; 00117 00118 int sky; 00119 00120 // killough 8/28/98: friction is a sector property, not an mobj property. 00121 // these fields used to be in AActor, but presented performance problems 00122 // when processed as mobj properties. Fix is to make them sector properties. 00123 int friction, movefactor; 00124 00125 // thinker_t for reversable actions 00126 DSectorEffect *floordata; // jff 2/22/98 make thinkers on 00127 DSectorEffect *ceilingdata; // floors, ceilings, lighting, 00128 DSectorEffect *lightingdata; // independent of one another 00129 00130 bool moveable; // [csDoom] mark a sector as moveable if it is moving. 00131 // If (sector->moveable) the server sends information 00132 // about this sector when a client connects. 00133 00134 // jff 2/26/98 lockout machinery for stairbuilding 00135 int stairlock; // -2 on first locked -1 after thinker done 0 normally 00136 int prevsec; // -1 or number of sector for previous step 00137 int nextsec; // -1 or number of next step sector 00138 00139 // killough 3/7/98: floor and ceiling texture offsets 00140 fixed_t floor_xoffs, floor_yoffs; 00141 fixed_t ceiling_xoffs, ceiling_yoffs; 00142 00143 // [RH] floor and ceiling texture scales 00144 fixed_t floor_xscale, floor_yscale; 00145 fixed_t ceiling_xscale, ceiling_yscale; 00146 00147 // [RH] floor and ceiling texture rotation 00148 angle_t floor_angle, ceiling_angle; 00149 00150 fixed_t base_ceiling_angle, base_ceiling_yoffs; 00151 fixed_t base_floor_angle, base_floor_yoffs; 00152 00153 // killough 3/7/98: support flat heights drawn at another sector's heights 00154 struct sector_s *heightsec; // other sector, or NULL if no other sector 00155 00156 // killough 4/11/98: support for lightlevels coming from another sector 00157 struct sector_s *floorlightsec, *ceilinglightsec; 00158 00159 unsigned int bottommap, midmap, topmap; // killough 4/4/98: dynamic colormaps 00160 // [RH] these can also be blend values if 00161 // the alpha mask is non-zero 00162 00163 // list of mobjs that are at least partially in the sector 00164 // thinglist is a subset of touching_thinglist 00165 struct msecnode_s *touching_thinglist; // phares 3/14/98 00166 00167 int linecount; 00168 struct line_s **lines; // [linecount] size 00169 00170 float gravity; // [RH] Sector gravity (1.0 is normal) 00171 short damage; // [RH] Damage to do while standing on floor 00172 short mod; // [RH] Means-of-death for applied damage 00173 struct dyncolormap_s *floorcolormap; // [RH] Per-sector colormap 00174 struct dyncolormap_s *ceilingcolormap; 00175 00176 bool alwaysfake; // [RH] Always apply heightsec modifications? 00177 byte waterzone; // [RH] Sector is underwater? 00178 }; 00179 typedef struct sector_s sector_t; 00180 00181 00182 00183 // 00184 // The SideDef. 00185 // 00186 struct side_s 00187 { 00188 // add this to the calculated texture column 00189 fixed_t textureoffset; 00190 00191 // add this to the calculated texture top 00192 fixed_t rowoffset; 00193 00194 // Texture indices. 00195 // We do not maintain names here. 00196 short toptexture; 00197 short bottomtexture; 00198 short midtexture; 00199 00200 // Sector the SideDef is facing. 00201 sector_t* sector; 00202 00203 // [RH] Bah. Had to add these for BOOM stuff 00204 short linenum; 00205 short special; 00206 short tag; 00207 }; 00208 typedef struct side_s side_t; 00209 00210 00211 // 00212 // Move clipping aid for LineDefs. 00213 // 00214 typedef enum 00215 { 00216 ST_HORIZONTAL, 00217 ST_VERTICAL, 00218 ST_POSITIVE, 00219 ST_NEGATIVE 00220 } slopetype_t; 00221 00222 struct line_s 00223 { 00224 // Vertices, from v1 to v2. 00225 vertex_t* v1; 00226 vertex_t* v2; 00227 00228 // Precalculated v2 - v1 for side checking. 00229 fixed_t dx; 00230 fixed_t dy; 00231 00232 // Animation related. 00233 short flags; 00234 byte special; // [RH] specials are only one byte (like Hexen) 00235 byte lucency; // <--- translucency (0-255/255=opaque) 00236 00237 // Visual appearance: SideDefs. 00238 // sidenum[1] will be -1 if one sided 00239 short sidenum[2]; 00240 00241 // Neat. Another bounding box, for the extent 00242 // of the LineDef. 00243 fixed_t bbox[4]; 00244 00245 // To aid move clipping. 00246 slopetype_t slopetype; 00247 00248 // Front and back sector. 00249 // Note: redundant? Can be retrieved from SideDefs. 00250 sector_t* frontsector; 00251 sector_t* backsector; 00252 00253 // if == validcount, already checked 00254 int validcount; 00255 00256 short id; // <--- same as tag or set with Line_SetIdentification 00257 short args[5]; // <--- hexen-style arguments 00258 // note that these are shorts in order to support 00259 // the tag parameter from DOOM. 00260 int firstid, nextid; 00261 00262 // denis - has this switch ever been pressed? 00263 bool wastoggled; 00264 }; 00265 typedef struct line_s line_t; 00266 00267 // phares 3/14/98 00268 // 00269 // Sector list node showing all sectors an object appears in. 00270 // 00271 // There are two threads that flow through these nodes. The first thread 00272 // starts at touching_thinglist in a sector_t and flows through the m_snext 00273 // links to find all mobjs that are entirely or partially in the sector. 00274 // The second thread starts at touching_sectorlist in a AActor and flows 00275 // through the m_tnext links to find all sectors a thing touches. This is 00276 // useful when applying friction or push effects to sectors. These effects 00277 // can be done as thinkers that act upon all objects touching their sectors. 00278 // As an mobj moves through the world, these nodes are created and 00279 // destroyed, with the links changed appropriately. 00280 // 00281 // For the links, NULL means top or end of list. 00282 00283 typedef struct msecnode_s 00284 { 00285 sector_t *m_sector; // a sector containing this object 00286 AActor *m_thing; // this object 00287 struct msecnode_s *m_tprev; // prev msecnode_t for this thing 00288 struct msecnode_s *m_tnext; // next msecnode_t for this thing 00289 struct msecnode_s *m_sprev; // prev msecnode_t for this sector 00290 struct msecnode_s *m_snext; // next msecnode_t for this sector 00291 BOOL visited; // killough 4/4/98, 4/7/98: used in search algorithms 00292 } msecnode_t; 00293 00294 // 00295 // The LineSeg. 00296 // 00297 struct seg_s 00298 { 00299 vertex_t* v1; 00300 vertex_t* v2; 00301 00302 fixed_t offset; 00303 00304 angle_t angle; 00305 00306 side_t* sidedef; 00307 line_t* linedef; 00308 00309 // Sector references. 00310 // Could be retrieved from linedef, too. 00311 sector_t* frontsector; 00312 sector_t* backsector; // NULL for one-sided lines 00313 00314 }; 00315 typedef struct seg_s seg_t; 00316 00317 // ===== Polyobj data ===== 00318 typedef struct FPolyObj 00319 { 00320 int numsegs; 00321 seg_t **segs; 00322 fixed_t startSpot[3]; 00323 vertex_t *originalPts; // used as the base for the rotations 00324 vertex_t *prevPts; // use to restore the old point values 00325 angle_t angle; 00326 int tag; // reference tag assigned in HereticEd 00327 int bbox[4]; 00328 int validcount; 00329 BOOL crush; // should the polyobj attempt to crush mobjs? 00330 int seqType; 00331 fixed_t size; // polyobj size (area of POLY_AREAUNIT == size of FRACUNIT) 00332 DThinker *specialdata; // pointer to a thinker, if the poly is moving 00333 } polyobj_t; 00334 00335 typedef struct polyblock_s 00336 { 00337 polyobj_t *polyobj; 00338 struct polyblock_s *prev; 00339 struct polyblock_s *next; 00340 } polyblock_t; 00341 00342 // 00343 // A SubSector. 00344 // References a Sector. 00345 // Basically, this is a list of LineSegs, 00346 // indicating the visible walls that define 00347 // (all or some) sides of a convex BSP leaf. 00348 // 00349 typedef struct subsector_s 00350 { 00351 sector_t *sector; 00352 unsigned short numlines; 00353 unsigned short firstline; 00354 polyobj_t *poly; 00355 } subsector_t; 00356 00357 // 00358 // BSP node. 00359 // 00360 struct node_s 00361 { 00362 // Partition line. 00363 fixed_t x; 00364 fixed_t y; 00365 fixed_t dx; 00366 fixed_t dy; 00367 fixed_t bbox[2][4]; // Bounding box for each child. 00368 unsigned short children[2]; // If NF_SUBSECTOR its a subsector. 00369 }; 00370 typedef struct node_s node_t; 00371 00372 00373 00374 // posts are runs of non masked source pixels 00375 struct post_s 00376 { 00377 byte topdelta; // -1 is the last post in a column 00378 byte length; // length data bytes follows 00379 }; 00380 typedef struct post_s post_t; 00381 00382 // column_t is a list of 0 or more post_t, (byte)-1 terminated 00383 typedef post_t column_t; 00384 00385 00386 // 00387 // OTHER TYPES 00388 // 00389 00390 typedef byte lighttable_t; // This could be wider for >8 bit display. 00391 00392 struct drawseg_s 00393 { 00394 seg_t* curline; 00395 00396 int x1; 00397 int x2; 00398 00399 fixed_t scale1; 00400 fixed_t scale2; 00401 fixed_t scalestep; 00402 00403 fixed_t light, lightstep; 00404 00405 // 0=none, 1=bottom, 2=top, 3=both 00406 int silhouette; 00407 00408 // do not clip sprites above this 00409 fixed_t bsilheight; 00410 00411 // do not clip sprites below this 00412 fixed_t tsilheight; 00413 00414 // Pointers to lists for sprite clipping, 00415 // all three adjusted so [x1] is first value. 00416 int* sprtopclip; 00417 int* sprbottomclip; 00418 int* maskedtexturecol; 00419 }; 00420 typedef struct drawseg_s drawseg_t; 00421 00422 00423 // Patches. 00424 // A patch holds one or more columns. 00425 // Patches are used for sprites and all masked pictures, and we compose 00426 // textures from the TEXTURE1/2 lists of patches. 00427 struct patch_s 00428 { 00429 private: 00430 short _width; // bounding box size 00431 short _height; 00432 short _leftoffset; // pixels to the left of origin 00433 short _topoffset; // pixels below the origin 00434 00435 public: 00436 00437 short width() const { return SHORT(_width); } 00438 short height() const { return SHORT(_height); } 00439 short leftoffset() const { return SHORT(_leftoffset); } 00440 short topoffset() const { return SHORT(_topoffset); } 00441 00442 int columnofs[8]; // only [width] used 00443 // the [0] is &columnofs[width] 00444 }; 00445 typedef struct patch_s patch_t; 00446 00447 00448 // A vissprite_t is a thing 00449 // that will be drawn during a refresh. 00450 // I.e. a sprite object that is partly visible. 00451 struct vissprite_s 00452 { 00453 int x1; 00454 int x2; 00455 00456 // for line side calculation 00457 fixed_t gx; 00458 fixed_t gy; 00459 00460 // global bottom / top for silhouette clipping 00461 fixed_t gz; 00462 fixed_t gzt; 00463 00464 // horizontal position of x1 00465 fixed_t startfrac; 00466 00467 fixed_t xscale, yscale; 00468 00469 // negative if flipped 00470 fixed_t xiscale; 00471 00472 fixed_t depth; 00473 fixed_t texturemid; 00474 int patch; 00475 00476 // for color translation and shadow draw, 00477 // maxbright frames as well 00478 lighttable_t* colormap; 00479 00480 int mobjflags; 00481 00482 byte *translation; // [RH] for translation; 00483 sector_t *heightsec; // killough 3/27/98: height sector for underwater/fake ceiling 00484 fixed_t translucency; 00485 }; 00486 typedef struct vissprite_s vissprite_t; 00487 00488 // 00489 // Sprites are patches with a special naming convention 00490 // so they can be recognized by R_InitSprites. 00491 // The base name is NNNNFx or NNNNFxFx, with 00492 // x indicating the rotation, x = 0, 1-7. 00493 // The sprite and frame specified by a thing_t 00494 // is range checked at run time. 00495 // A sprite is a patch_t that is assumed to represent 00496 // a three dimensional object and may have multiple 00497 // rotations pre drawn. 00498 // Horizontal flipping is used to save space, 00499 // thus NNNNF2F5 defines a mirrored patch. 00500 // Some sprites will only have one picture used 00501 // for all views: NNNNF0 00502 // 00503 struct spriteframe_s 00504 { 00505 // If false use 0 for any position. 00506 // Note: as eight entries are available, 00507 // we might as well insert the same name eight times. 00508 bool rotate; 00509 00510 // Lump to use for view angles 0-7. 00511 short lump[8]; 00512 00513 // Flip bit (1 = flip) to use for view angles 0-7. 00514 byte flip[8]; 00515 00516 // [RH] Move some data out of spritewidth, spriteoffset, 00517 // and spritetopoffset arrays. 00518 fixed_t width[8]; 00519 fixed_t topoffset[8]; 00520 fixed_t offset[8]; 00521 }; 00522 typedef struct spriteframe_s spriteframe_t; 00523 00524 // 00525 // A sprite definition: 00526 // a number of animation frames. 00527 // 00528 struct spritedef_s 00529 { 00530 int numframes; 00531 spriteframe_t *spriteframes; 00532 }; 00533 typedef struct spritedef_s spritedef_t; 00534 00535 // 00536 // [RH] Internal "skin" definition. 00537 // 00538 struct playerskin_s 00539 { 00540 char name[17]; // 16 chars + NULL 00541 char face[3]; 00542 spritenum_t sprite; 00543 int namespc; // namespace for this skin 00544 int gender; // This skin's gender (not used) 00545 }; 00546 typedef struct playerskin_s playerskin_t; 00547 00548 // 00549 // The infamous visplane 00550 // 00551 struct visplane_s 00552 { 00553 struct visplane_s *next; // Next visplane in hash chain -- killough 00554 00555 fixed_t height; 00556 int picnum; 00557 int lightlevel; 00558 fixed_t xoffs, yoffs; // killough 2/28/98: Support scrolling flats 00559 int minx; 00560 int maxx; 00561 00562 byte *colormap; // [RH] Support multiple colormaps 00563 fixed_t xscale, yscale; // [RH] Support flat scaling 00564 angle_t angle; // [RH] Support flat rotation 00565 00566 unsigned int *bottom; // [RH] bottom and top arrays are dynamically 00567 unsigned int pad; // allocated immediately after the 00568 unsigned int top[3]; // visplane. 00569 }; 00570 typedef struct visplane_s visplane_t; 00571 00572 #endif 00573 00574