| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
#include "globaldefs.h" |
| 36 |
#if GDEF_COMPILER_MSVC |
| 37 |
#ifdef NDEBUG |
| 38 |
#pragma warning(disable : 4305) // truncate from double to float |
| 39 |
#pragma warning(disable : 4244) // conversion from double to float |
| 40 |
#pragma warning(disable : 4018) // signed/unsigned mismatch |
| 41 |
#endif |
| 42 |
#endif |
| 43 |
|
| 44 |
#define IDPAKHEADER ( ( 'K' << 24 ) + ( 'C' << 16 ) + ( 'A' << 8 ) + 'P' ) |
| 45 |
|
| 46 |
typedef struct |
| 47 |
{ |
| 48 |
char name[56]; |
| 49 |
int filepos, filelen; |
| 50 |
} dpackfile_t; |
| 51 |
|
| 52 |
typedef struct |
| 53 |
{ |
| 54 |
int ident; |
| 55 |
int dirofs; |
| 56 |
int dirlen; |
| 57 |
} dpackheader_t; |
| 58 |
|
| 59 |
#define MAX_FILES_IN_PACK 4096 |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
typedef struct |
| 71 |
{ |
| 72 |
char manufacturer; |
| 73 |
char version; |
| 74 |
char encoding; |
| 75 |
char bits_per_pixel; |
| 76 |
unsigned short xmin,ymin,xmax,ymax; |
| 77 |
unsigned short hres,vres; |
| 78 |
unsigned char palette[48]; |
| 79 |
char reserved; |
| 80 |
char color_planes; |
| 81 |
unsigned short bytes_per_line; |
| 82 |
unsigned short palette_type; |
| 83 |
char filler[58]; |
| 84 |
unsigned char data; |
| 85 |
} pcx_t; |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
#define IDALIASHEADER ( ( '2' << 24 ) + ( 'P' << 16 ) + ( 'D' << 8 ) + 'I' ) |
| 97 |
#define ALIAS_VERSION 8 |
| 98 |
|
| 99 |
#define MAX_TRIANGLES 4096 |
| 100 |
#define MAX_VERTS 2048 |
| 101 |
#define MAX_FRAMES 512 |
| 102 |
#define MAX_MD2SKINS 32 |
| 103 |
#define MAX_SKINNAME 64 |
| 104 |
|
| 105 |
typedef struct |
| 106 |
{ |
| 107 |
short s; |
| 108 |
short t; |
| 109 |
} dstvert_t; |
| 110 |
|
| 111 |
typedef struct |
| 112 |
{ |
| 113 |
short index_xyz[3]; |
| 114 |
short index_st[3]; |
| 115 |
} dtriangle_t; |
| 116 |
|
| 117 |
typedef struct |
| 118 |
{ |
| 119 |
byte v[3]; |
| 120 |
byte lightnormalindex; |
| 121 |
} dtrivertx_t; |
| 122 |
|
| 123 |
#define DTRIVERTX_V0 0 |
| 124 |
#define DTRIVERTX_V1 1 |
| 125 |
#define DTRIVERTX_V2 2 |
| 126 |
#define DTRIVERTX_LNI 3 |
| 127 |
#define DTRIVERTX_SIZE 4 |
| 128 |
|
| 129 |
typedef struct |
| 130 |
{ |
| 131 |
float scale[3]; |
| 132 |
float translate[3]; |
| 133 |
char name[16]; |
| 134 |
dtrivertx_t verts[1]; |
| 135 |
} daliasframe_t; |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
typedef struct |
| 148 |
{ |
| 149 |
int ident; |
| 150 |
int version; |
| 151 |
|
| 152 |
int skinwidth; |
| 153 |
int skinheight; |
| 154 |
int framesize; |
| 155 |
|
| 156 |
int num_skins; |
| 157 |
int num_xyz; |
| 158 |
int num_st; |
| 159 |
int num_tris; |
| 160 |
int num_glcmds; |
| 161 |
int num_frames; |
| 162 |
|
| 163 |
int ofs_skins; |
| 164 |
int ofs_st; |
| 165 |
int ofs_tris; |
| 166 |
int ofs_frames; |
| 167 |
int ofs_glcmds; |
| 168 |
int ofs_end; |
| 169 |
|
| 170 |
} dmdl_t; |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
#define IDSPRITEHEADER ( ( '2' << 24 ) + ( 'S' << 16 ) + ( 'D' << 8 ) + 'I' ) |
| 181 |
|
| 182 |
#define SPRITE_VERSION 2 |
| 183 |
|
| 184 |
typedef struct |
| 185 |
{ |
| 186 |
int width, height; |
| 187 |
int origin_x, origin_y; |
| 188 |
char name[MAX_SKINNAME]; |
| 189 |
} dsprframe_t; |
| 190 |
|
| 191 |
typedef struct { |
| 192 |
int ident; |
| 193 |
int version; |
| 194 |
int numframes; |
| 195 |
dsprframe_t frames[1]; |
| 196 |
} dsprite_t; |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
#define MIPLEVELS 4 |
| 208 |
typedef struct miptex_s |
| 209 |
{ |
| 210 |
char name[32]; |
| 211 |
unsigned width, height; |
| 212 |
unsigned offsets[MIPLEVELS]; |
| 213 |
char animname[32]; |
| 214 |
int flags; |
| 215 |
int contents; |
| 216 |
int value; |
| 217 |
} miptex_t; |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
typedef struct palette_s |
| 229 |
{ |
| 230 |
union |
| 231 |
{ |
| 232 |
struct |
| 233 |
{ |
| 234 |
byte r,g,b; |
| 235 |
}; |
| 236 |
}; |
| 237 |
} palette_t; |
| 238 |
|
| 239 |
#define MIP_VERSION 2 |
| 240 |
#define PAL_SIZE 256 |
| 241 |
#define H2_MIPLEVELS 16 |
| 242 |
|
| 243 |
typedef struct miptex_m8_s |
| 244 |
{ |
| 245 |
int version; |
| 246 |
char name[32]; |
| 247 |
unsigned width[H2_MIPLEVELS], height[H2_MIPLEVELS]; |
| 248 |
unsigned offsets[H2_MIPLEVELS]; |
| 249 |
char animname[32]; |
| 250 |
palette_t palette[PAL_SIZE]; |
| 251 |
int flags; |
| 252 |
int contents; |
| 253 |
int value; |
| 254 |
} miptex_m8_t; |
| 255 |
|
| 256 |
|
| 257 |
#define MIP32_VERSION 4 |
| 258 |
|
| 259 |
#define MIP32_NOMIP_FLAG2 0x00000001 |
| 260 |
#define MIP32_DETAILER_FLAG2 0x00000002 |
| 261 |
|
| 262 |
typedef struct miptex_m32_s |
| 263 |
{ |
| 264 |
int version; |
| 265 |
char name[128]; |
| 266 |
char altname[128]; |
| 267 |
char animname[128]; |
| 268 |
char damagename[128]; |
| 269 |
unsigned width[H2_MIPLEVELS], height[H2_MIPLEVELS]; |
| 270 |
unsigned offsets[H2_MIPLEVELS]; |
| 271 |
int flags; |
| 272 |
int contents; |
| 273 |
int value; |
| 274 |
float scale_x, scale_y; |
| 275 |
int mip_scale; |
| 276 |
|
| 277 |
|
| 278 |
char dt_name[128]; |
| 279 |
float dt_scale_x, dt_scale_y; |
| 280 |
float dt_u, dt_v; |
| 281 |
float dt_alpha; |
| 282 |
int dt_src_blend_mode, dt_dst_blend_mode; |
| 283 |
|
| 284 |
int flags2; |
| 285 |
int unused[19]; |
| 286 |
} miptex_m32_t; |
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
#define IDBSPHEADER ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'B' << 8 ) + 'I' ) |
| 300 |
|
| 301 |
|
| 302 |
#define BSPVERSION 38 |
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
#define MAX_MAP_MODELS 1024 |
| 309 |
#define MAX_MAP_BRUSHES 8192 |
| 310 |
#define MAX_MAP_ENTITIES 2048 |
| 311 |
#define MAX_MAP_ENTSTRING 0x40000 |
| 312 |
#define MAX_MAP_TEXINFO 8192 |
| 313 |
|
| 314 |
#define MAX_MAP_AREAS 256 |
| 315 |
#define MAX_MAP_AREAPORTALS 1024 |
| 316 |
#define MAX_MAP_PLANES 65536 |
| 317 |
#define MAX_MAP_NODES 65536 |
| 318 |
#define MAX_MAP_BRUSHSIDES 65536 |
| 319 |
#define MAX_MAP_LEAFS 65536 |
| 320 |
#define MAX_MAP_VERTS 65536 |
| 321 |
#define MAX_MAP_FACES 65536 |
| 322 |
#define MAX_MAP_LEAFFACES 65536 |
| 323 |
#define MAX_MAP_LEAFBRUSHES 65536 |
| 324 |
#define MAX_MAP_PORTALS 65536 |
| 325 |
#define MAX_MAP_EDGES 128000 |
| 326 |
#define MAX_MAP_SURFEDGES 256000 |
| 327 |
#define MAX_MAP_LIGHTING 0x200000 |
| 328 |
#define MAX_MAP_VISIBILITY 0x100000 |
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
#define MAX_KEY 32 |
| 333 |
#define MAX_VALUE 1024 |
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
typedef struct |
| 338 |
{ |
| 339 |
int fileofs, filelen; |
| 340 |
} lump_t; |
| 341 |
|
| 342 |
#define LUMP_ENTITIES 0 |
| 343 |
#define LUMP_PLANES 1 |
| 344 |
#define LUMP_VERTEXES 2 |
| 345 |
#define LUMP_VISIBILITY 3 |
| 346 |
#define LUMP_NODES 4 |
| 347 |
#define LUMP_TEXINFO 5 |
| 348 |
#define LUMP_FACES 6 |
| 349 |
#define LUMP_LIGHTING 7 |
| 350 |
#define LUMP_LEAFS 8 |
| 351 |
#define LUMP_LEAFFACES 9 |
| 352 |
#define LUMP_LEAFBRUSHES 10 |
| 353 |
#define LUMP_EDGES 11 |
| 354 |
#define LUMP_SURFEDGES 12 |
| 355 |
#define LUMP_MODELS 13 |
| 356 |
#define LUMP_BRUSHES 14 |
| 357 |
#define LUMP_BRUSHSIDES 15 |
| 358 |
#define LUMP_POP 16 |
| 359 |
#define LUMP_AREAS 17 |
| 360 |
#define LUMP_AREAPORTALS 18 |
| 361 |
#define HEADER_LUMPS 19 |
| 362 |
|
| 363 |
typedef struct |
| 364 |
{ |
| 365 |
int ident; |
| 366 |
int version; |
| 367 |
lump_t lumps[HEADER_LUMPS]; |
| 368 |
} dheader_t; |
| 369 |
|
| 370 |
typedef struct |
| 371 |
{ |
| 372 |
float mins[3], maxs[3]; |
| 373 |
float origin[3]; |
| 374 |
int headnode; |
| 375 |
int firstface, numfaces; |
| 376 |
|
| 377 |
} dmodel_t; |
| 378 |
|
| 379 |
|
| 380 |
typedef struct |
| 381 |
{ |
| 382 |
float point[3]; |
| 383 |
} dvertex_t; |
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
#define PLANE_X 0 |
| 388 |
#define PLANE_Y 1 |
| 389 |
#define PLANE_Z 2 |
| 390 |
|
| 391 |
|
| 392 |
#define PLANE_ANYX 3 |
| 393 |
#define PLANE_ANYY 4 |
| 394 |
#define PLANE_ANYZ 5 |
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
typedef struct |
| 399 |
{ |
| 400 |
float normal[3]; |
| 401 |
float dist; |
| 402 |
int type; |
| 403 |
} dplane_t; |
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
#define CONTENTS_SOLID 1 // an eye is never valid in a solid |
| 414 |
#define CONTENTS_WINDOW 2 // translucent, but not watery |
| 415 |
#define CONTENTS_AUX 4 |
| 416 |
#define CONTENTS_LAVA 8 |
| 417 |
#define CONTENTS_SLIME 16 |
| 418 |
#define CONTENTS_WATER 32 |
| 419 |
#define CONTENTS_MIST 64 |
| 420 |
#define LAST_VISIBLE_CONTENTS 64 |
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
#define CONTENTS_AREAPORTAL 0x8000 |
| 425 |
|
| 426 |
#define CONTENTS_PLAYERCLIP 0x10000 |
| 427 |
#define CONTENTS_MONSTERCLIP 0x20000 |
| 428 |
|
| 429 |
|
| 430 |
#define CONTENTS_CURRENT_0 0x40000 |
| 431 |
#define CONTENTS_CURRENT_90 0x80000 |
| 432 |
#define CONTENTS_CURRENT_180 0x100000 |
| 433 |
#define CONTENTS_CURRENT_270 0x200000 |
| 434 |
#define CONTENTS_CURRENT_UP 0x400000 |
| 435 |
#define CONTENTS_CURRENT_DOWN 0x800000 |
| 436 |
|
| 437 |
#define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity |
| 438 |
|
| 439 |
#define CONTENTS_MONSTER 0x2000000 // should never be on a brush, only in game |
| 440 |
#define CONTENTS_DEADMONSTER 0x4000000 |
| 441 |
#define CONTENTS_DETAIL 0x8000000 // brushes to be added after vis leafs |
| 442 |
#define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans |
| 443 |
#define CONTENTS_LADDER 0x20000000 |
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
#define SURF_LIGHT 0x1 // value will hold the light strength |
| 448 |
|
| 449 |
#define SURF_SLICK 0x2 // effects game physics |
| 450 |
|
| 451 |
#define SURF_SKY 0x4 // don't draw, but add to skybox |
| 452 |
#define SURF_WARP 0x8 // turbulent water warp |
| 453 |
#define SURF_TRANS33 0x10 |
| 454 |
#define SURF_TRANS66 0x20 |
| 455 |
#define SURF_FLOWING 0x40 // scroll towards angle |
| 456 |
#define SURF_NODRAW 0x80 // don't bother referencing the texture |
| 457 |
|
| 458 |
#define SURF_HINT 0x100 // make a primary bsp splitter |
| 459 |
#define SURF_SKIP 0x200 // completely ignore, allowing non-closed brushes |
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
typedef struct |
| 464 |
{ |
| 465 |
int planenum; |
| 466 |
int children[2]; |
| 467 |
short mins[3]; |
| 468 |
short maxs[3]; |
| 469 |
unsigned short firstface; |
| 470 |
unsigned short numfaces; |
| 471 |
} dnode_t; |
| 472 |
|
| 473 |
|
| 474 |
typedef struct texinfo_s |
| 475 |
{ |
| 476 |
float vecs[2][4]; |
| 477 |
int flags; |
| 478 |
int value; |
| 479 |
char texture[32]; |
| 480 |
int nexttexinfo; |
| 481 |
} texinfo_t; |
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
typedef struct |
| 487 |
{ |
| 488 |
unsigned short v[2]; |
| 489 |
} dedge_t; |
| 490 |
|
| 491 |
#define MAXLIGHTMAPS 4 |
| 492 |
typedef struct |
| 493 |
{ |
| 494 |
unsigned short planenum; |
| 495 |
short side; |
| 496 |
|
| 497 |
int firstedge; |
| 498 |
short numedges; |
| 499 |
short texinfo; |
| 500 |
|
| 501 |
|
| 502 |
byte styles[MAXLIGHTMAPS]; |
| 503 |
int lightofs; |
| 504 |
} dface_t; |
| 505 |
|
| 506 |
typedef struct |
| 507 |
{ |
| 508 |
int contents; |
| 509 |
|
| 510 |
short cluster; |
| 511 |
short area; |
| 512 |
|
| 513 |
short mins[3]; |
| 514 |
short maxs[3]; |
| 515 |
|
| 516 |
unsigned short firstleafface; |
| 517 |
unsigned short numleaffaces; |
| 518 |
|
| 519 |
unsigned short firstleafbrush; |
| 520 |
unsigned short numleafbrushes; |
| 521 |
} dleaf_t; |
| 522 |
|
| 523 |
typedef struct |
| 524 |
{ |
| 525 |
unsigned short planenum; |
| 526 |
short texinfo; |
| 527 |
} dbrushside_t; |
| 528 |
|
| 529 |
typedef struct |
| 530 |
{ |
| 531 |
int firstside; |
| 532 |
int numsides; |
| 533 |
int contents; |
| 534 |
} dbrush_t; |
| 535 |
|
| 536 |
#define ANGLE_UP -1 |
| 537 |
#define ANGLE_DOWN -2 |
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
#define DVIS_PVS 0 |
| 544 |
#define DVIS_PHS 1 |
| 545 |
typedef struct |
| 546 |
{ |
| 547 |
int numclusters; |
| 548 |
int bitofs[8][2]; |
| 549 |
} dvis_t; |
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
typedef struct |
| 555 |
{ |
| 556 |
int portalnum; |
| 557 |
int otherarea; |
| 558 |
} dareaportal_t; |
| 559 |
|
| 560 |
typedef struct |
| 561 |
{ |
| 562 |
int numareaportals; |
| 563 |
int firstareaportal; |
| 564 |
} darea_t; |