1 /* 2 * Copyright 2000 David Chess; Copyright 2005 Sam Trenholme 3 * 4 * Slump is free software; you can redistribute it and/or modify it under 5 * the terms of the GNU General Public License as published by the Free 6 * Software Foundation; either version 2, or (at your option) any later 7 * version. 8 * 9 * Slump is distributed in the hope that it will be useful, but WITHOUT ANY 10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with Slump; see the file GPL. If not, write to the Free 16 * Software Foundation, 59 Temple Place - Suite 330, Boston, MA 17 * 02111-1307, USA. 18 * 19 * Additionally, while not required for redistribution of this program, 20 * the following requests are made when making a derived version of 21 * this program: 22 * 23 * - Slump's code is partly derived from the Doom map generator 24 * called SLIGE, by David Chess. Please inform David Chess of 25 * any derived version that you make. His email address is at 26 * the domain "theogeny.com" with the name "chess" placed before 27 * the at symbol. 28 * 29 * - Please do not call any derivative of this program SLIGE. 30 */ 31 32 /* Slump 0.003.02 */ 33 #define SOURCE_VERSION (0) 34 #define SOURCE_SERIAL (003) 35 #define SOURCE_PATCHLEVEL (02) 36 37 /* Header file for things all slump files use */ 38 39 /* Some Microsoft-specific defines which we will probably get rid of in 40 * a later release */ 41 #ifdef _MSC_VER 42 #define RAND_SUCKS 43 #define USE_STRICMP 44 #endif 45 46 typedef unsigned char boolean; 47 #define TRUE (1==1) 48 #define FALSE (!TRUE) 49 #define HUGE_NUMBER (1000000) 50 51 #define LEVEL_MAX_BARS (30) 52 #define LEVEL_MAX_CRUSHERS (2) 53 54 #define TLMPSIZE(rows,columns) ((rows+9)*columns + 8) 55 56 typedef unsigned char byte; 57 58 #ifndef USE_STRICMP 59 #define stricmp(x,y) strcasecmp(x,y) 60 #define strnicmp(x,y,n) strncasecmp(x,y,n) 61 #endif 62 63 #ifdef OK_TO_USE_REAL_MONSTER_WIDTH 64 #define MONSTER_WIDTH(m) (m->width) 65 #else 66 #define MONSTER_WIDTH(m) (64) 67 #endif 68 69 /* Minimum room size on a level with teleports */ 70 #define TELEPORT_MINROOMSIZE 256 71 /* Percentage change that a given level will have teleports */ 72 #define TELEPORTS_PERCENT 30 73 /* The absolute minimum allowed light in a room */ 74 #define ABSOLUTE_MINLIGHT 126 75 76 typedef unsigned long themebits; /* Bitarray, really */ 77 /* So at most 32 themes in a config file */ 78 79 typedef unsigned char gamebits; /* Also bitarray */ 80 #define DOOM0_BIT (0x01) 81 #define DOOM1_BIT (0x02) 82 #define DOOM2_BIT (0x04) 83 /* This is "clean" doom, with no "GROSS" items */ 84 #define DOOMC_BIT (0x08) 85 /* "Intrinsic"; i.e. no SLUMP-special textures */ 86 #define DOOMI_BIT (0x10) 87 /* and that's all */ 88 89 typedef unsigned long propertybits; /* Another bitarray */ 90 #define FLOOR (0x01) 91 #define CEILING (0x02) 92 #define DOOR (0x04) 93 #define ERROR_TEXTURE (0x08) 94 #define WALL (0x10) 95 #define SUPPORT (0x20) 96 #define NUKAGE (0x40) 97 #define JAMB (0x80) 98 #define RED (0x100) 99 #define BLUE (0x200) 100 #define YELLOW (0x400) 101 #define GRATING (0x800) 102 #define PLAQUE (0x1000) 103 #define HALF_PLAQUE (0x2000) 104 #define LIGHT (0x4000) 105 #define BIG (0x8000) 106 #define SWITCH (0x10000) 107 #define OUTDOOR (0x20000) 108 #define GATE (0x40000) 109 #define EXITSWITCH (0x80000) 110 #define STEP (0x100000) 111 #define LIFT_TEXTURE (0x200000) 112 #define VTILES (0x400000) 113 /* and so on and so on; 32 may well not be enough! */ 114 115 /* Some thing-only bits; corresponding bits above are texture/flat-only */ 116 #define MONSTER (0x01) 117 #define AMMO (0x02) 118 #define HEALTH (0x04) 119 #define WEAPON (0x08) 120 #define PICKABLE (0x10) 121 #define SHOOTS (0x20) 122 #define EXPLODES (0x40) 123 #define FLIES (0x80) 124 #define BOSS (0x100) 125 #define SPECIAL (0x800) 126 127 typedef struct s_theme { 128 char *name; 129 boolean secret; 130 struct s_theme *next; 131 } theme, *ptheme; 132 133 typedef struct s_texture { 134 char name[9]; /* Room for the eos */ 135 char *realname; /* the DOOM name, in case the name name is an alias */ 136 gamebits gamemask; 137 themebits compatible; 138 themebits core; 139 propertybits props; 140 short width; 141 short height; 142 short y_hint; 143 short y_bias; /* Y offset that a switch needs */ 144 struct s_texture *subtle; 145 struct s_texture *switch_texture; 146 boolean used; 147 struct s_texture *next; 148 } texture, *ptexture; 149 150 typedef struct s_flat { 151 char name[9]; /* Room for the eos */ 152 gamebits gamemask; 153 themebits compatible; 154 propertybits props; 155 boolean used; 156 struct s_flat *next; 157 } flat, *pflat; 158 159 typedef struct s_linedef linedef, *plinedef; 160 typedef struct s_gate gate, *pgate; 161 162 typedef struct s_link { 163 int type; 164 propertybits bits; 165 int height1; /* Basic height, or zero for "floor-to-ceiling" */ 166 int width1; /* Basic width, or zero for "wall-to-wall" */ 167 int width2; /* Width of the interalcove-passage, if any */ 168 int depth1; /* Depth of doors / arches (overall depth for OPEN) */ 169 int depth2; /* Depth of recess sectors */ 170 int depth3; /* Length (depth) of the core (if any) */ 171 int floordelta; /* Far sector floorheight - near sector floorheight */ 172 int stepcount; /* Number of steps to slice depth3 into (minus one) */ 173 linedef *cld; /* The inner side of a twinned core, sometimes */ 174 struct s_link *next; 175 } link, *plink; 176 177 /* Values for link.type */ 178 #define BASIC_LINK 1001 179 #define OPEN_LINK 1002 180 #define GATE_LINK 1003 181 182 /* Bits for link.bits */ 183 #define LINK_NEAR_DOOR (0x01) 184 #define LINK_RECESS (0x02) 185 #define LINK_ALCOVE (0x04) 186 #define LINK_TWIN (0x08) 187 #define LINK_CORE (0x10) 188 #define LINK_LIFT (0x20) 189 #define LINK_STEPS (0x40) 190 /* LINK_WINDOW is used only if LINK_TWIN */ 191 #define LINK_WINDOW (0x80) 192 #define LINK_MAX_CEILING (0x100) 193 #define LINK_TRIGGERED (0x200) 194 #define LINK_LAMPS (0x400) 195 #define LINK_BARS (0x800) 196 #define LINK_LEFT (0x1000) 197 #define LINK_LOCK_CORE (0x2000) 198 #define LINK_FAR_TWINS (0x4000) 199 #define LINK_DECROOM (0x8000) 200 #define LINK_FAR_DOOR (0x10000) 201 202 #define LINK_ANY_DOOR (LINK_NEAR_DOOR | LINK_FAR_DOOR) 203 204 /* The kinds of things that there are */ 205 206 typedef struct s_genus { 207 gamebits gamemask; 208 themebits compatible; 209 propertybits bits; 210 short thingid; 211 #define ID_PLAYER1 (0x0001) 212 #define ID_PLAYER2 (0x0002) 213 #define ID_PLAYER3 (0x0003) 214 #define ID_PLAYER4 (0x0004) 215 #define ID_DM (0x000b) 216 #define ID_GATEOUT (0x000e) 217 /* The monsters */ 218 #define ID_TROOPER (0x0bbc) 219 #define ID_SERGEANT (0x0009) 220 #define ID_IMP (0x0bb9) 221 #define ID_PINK (0x0bba) 222 #define ID_SPECTRE (0x003a) 223 #define ID_COMMANDO (0x041) 224 #define ID_NAZI (0x054) 225 #define ID_SKULL (0xbbe) 226 #define ID_HEAD (0xbbd) 227 #define ID_SKEL (0x042) 228 #define ID_ARACH (0x044) 229 #define ID_MANCUB (0x0043) 230 /* The following monsers are not in FreeDoom 0.3 */ 231 #define ID_HELL (0x045) 232 #define ID_BARON (0x0bbb) 233 #define ID_PAIN (0x047) 234 #define ID_ARCHIE (0x0040) 235 #define ID_CYBER (0x10) 236 #define ID_SPIDERBOSS (0x07) 237 #define ID_BRAIN (0x58) 238 short width; 239 short height; 240 int min_level; /* Minimum level to put monster in */ 241 boolean in_freedoom; /* Whether the monster is in FreeDoom 0.3 */ 242 float ammo_to_kill[3]; 243 float ammo_provides; /* For monsters / ammo / weapons */ 244 float damage[3]; /* damage[0] will be health provided by HEALTHs */ 245 float altdamage[3]; 246 boolean marked; 247 struct s_genus *next; 248 } genus, *pgenus; 249 250 #define ID_SHOTGUN (0x7d1) 251 #define ID_SSGUN (0x052) 252 #define ID_CHAINGUN (0x7d2) 253 #define ID_CHAINSAW (0x7d5) 254 #define ID_PLASMA (0x7d4) 255 #define ID_BFG (0x7d6) 256 #define ID_CLIP (0x7d7) 257 #define ID_SHELLS (0x7d8) 258 #define ID_BULBOX (0x800) 259 #define ID_SHELLBOX (0x801) 260 #define ID_CELL (0x7ff) 261 #define ID_CELLPACK (0x11) 262 #define ID_BACKPACK (0x08) 263 #define ID_LAUNCHER (0x7d3) 264 #define ID_ROCKET (0x7da) 265 #define ID_ROCKBOX (0x7fe) 266 267 #define ID_STIMPACK (0x7DB) 268 #define ID_MEDIKIT (0x7dc) 269 #define ID_POTION (0x7de) 270 #define ID_SOUL (0x7dd) 271 #define ID_BERSERK (0x7e7) 272 #define ID_INVIS (0x7e8) 273 #define ID_SUIT (0x7e9) 274 #define ID_MAP (0x7ea) 275 276 #define ID_HELMET (0x7df) 277 #define ID_BLUESUIT (0x7e3) 278 #define ID_GREENSUIT (0x7e2) 279 280 #define ID_BLUEKEY (0x028) 281 #define ID_REDKEY (0x026) 282 #define ID_YELLOWKEY (0x027) 283 #define ID_BLUECARD (0x0005) 284 #define ID_REDCARD (0x00d) 285 #define ID_YELLOWCARD (0x006) 286 287 #define ID_LAMP (0x07ec) 288 #define ID_ELEC (0x030) 289 #define ID_TLAMP2 (0x055) 290 #define ID_LAMP2 (0x056) 291 #define ID_TALLBLUE (0x002c) 292 #define ID_SHORTBLUE (0x037) 293 #define ID_TALLGREEN (0x02d) 294 #define ID_SHORTGREEN (0x038) 295 #define ID_TALLRED (0x02e) 296 #define ID_SHORTRED (0x039) 297 #define ID_CANDLE (0x022) 298 #define ID_CBRA (0x023) 299 #define ID_BARREL (0x07f3) 300 #define ID_FBARREL (0x0046) 301 #define ID_SMIT (0x002f) 302 #define ID_TREE1 (0x002b) 303 #define ID_TREE2 (0x0036) 304 305 /* The style is the dynamic architectural knowledge and stuff. */ 306 /* It changes throughout the run. */ 307 typedef struct s_style { 308 int theme_number; 309 flat *floor0; 310 flat *ceiling0; 311 flat *ceilinglight; 312 flat *doorfloor; 313 flat *doorceiling; 314 flat *stepfloor; 315 flat *nukage1; 316 texture *wall0; 317 texture *switch0; 318 texture *support0; 319 texture *doorjamb; 320 texture *widedoorface; 321 texture *narrowdoorface; 322 texture *twdoorface; /* tall-wide */ 323 texture *tndoorface; /* tall-narrow */ 324 texture *lockdoorface; /* can be NULL */ 325 texture *walllight; /* Can be NULL */ 326 texture *liftface; /* can be NULL */ 327 texture *kickplate; /* At least 64 tall */ 328 texture *stepfront; /* May be quite short */ 329 texture *grating; 330 texture *plaque; 331 texture *redface; 332 texture *blueface; 333 texture *yellowface; 334 genus *lamp0; 335 genus *shortlamp0; 336 short doorlight0; 337 short roomlight0; 338 short wallheight0; 339 short linkheight0; 340 short closet_width; 341 short closet_depth; 342 short closet_light_delta; 343 /* Shouldn't all these booleans just be in a properties bitarray? */ 344 boolean moving_jambs; 345 boolean secret_doors; /* a silly thing */ 346 boolean soundproof_doors; 347 boolean center_pillars; 348 boolean paint_recesses; /* Put keycolors on recesses, not doors? */ 349 boolean lightboxes; /* Ephemeral */ 350 boolean gaudy_locks; 351 int auxheight; /* Height off the ground of lightboxes (etc) */ 352 short auxspecial; /* Special light thing for lightboxes (etc) */ 353 short doortype; /* Should be part of link? */ 354 short slifttype; /* part of link? */ 355 int sillheight; /* should be part of link? */ 356 int windowheight; /* part of link? */ 357 int windowborder; /* part of link? */ 358 boolean slitwindows; /* part of link? */ 359 boolean window_grate; /* part of link? */ 360 int window_decor; /* part of link? */ 361 #define WINDOW_NORMAL (5001) 362 #define WINDOW_JAMBS (5002) 363 #define WINDOW_SUPPORT (5003) 364 #define WINDOW_LIGHT (5004) 365 int lightbox_lighting; 366 #define LIGHTBOX_NORMAL (6001) 367 #define LIGHTBOX_LIGHTED (6002) 368 #define LIGHTBOX_DARK (6003) 369 boolean light_recesses; 370 boolean light_steps; 371 boolean light_edges; 372 boolean peg_lightstrips; 373 int construct_family; 374 boolean do_constructs; 375 link *link0; 376 struct s_style *next; 377 } style, *pstyle; 378 379 /* General linked list of textures, for constructs */ 380 typedef struct s_texture_cell { 381 texture *texture; 382 boolean marked; 383 boolean primary; 384 short y_offset1; 385 short y_offset2; 386 short width; 387 struct s_texture_cell *next; 388 } texture_cell, *ptexture_cell; 389 390 /* General linked list of flats */ 391 typedef struct s_flat_cell { 392 flat *flat; 393 struct s_flat_cell *next; 394 } flat_cell, *pflat_cell; 395 396 /* Things that are basically boxes with sides */ 397 typedef struct s_construct { 398 gamebits gamemask; 399 themebits compatible; 400 int family; /* What general kind of thing is it? */ 401 short height; 402 texture_cell *texture_cell_anchor; 403 flat_cell *flat_cell_anchor; 404 boolean marked; 405 struct s_construct *next; 406 } construct, *pconstruct; 407 408 typedef struct s_thing { 409 short x; 410 short y; 411 short angle; 412 genus *genus; 413 short options; 414 short number; 415 struct s_thing *next; 416 } thing, *pthing; 417 418 /* These are sort of two-natured; they represent both sectors in the */ 419 /* DooM-engine sense, and rooms. Split the meanings someday. */ 420 typedef struct s_sector { 421 short floor_height; 422 short ceiling_height; 423 flat *floor_flat; 424 flat *ceiling_flat; 425 short light_level; 426 short special; 427 short tag; 428 short number; /* Used only during dumping */ 429 style *style; /* Style used to create it */ 430 boolean marked; 431 boolean has_key; /* Has a key been placed in here? */ 432 boolean has_dm; /* A DM start in here? */ 433 boolean has_dm_weapon; /* Any weapons in here yet in DM? */ 434 boolean middle_enhanced; /* Already specially enhanced */ 435 gate *gate; 436 short entry_x, entry_y; 437 boolean findrec_data_valid; 438 short minx, miny, maxx, maxy; 439 struct s_sector *next; 440 } sector, *psector; 441 442 typedef struct s_vertex { 443 short x; 444 short y; 445 short number; 446 boolean marked; 447 struct s_vertex *next; 448 } vertex, *pvertex; 449 450 typedef struct s_sidedef { 451 short x_offset; 452 short x_misalign; 453 short y_offset; 454 short y_misalign; 455 texture *upper_texture; 456 texture *lower_texture; 457 texture *middle_texture; 458 sector *sector; 459 short number; 460 boolean isBoundary; 461 struct s_sidedef *next; 462 } sidedef, *psidedef; 463 464 struct s_linedef { 465 vertex *from; 466 vertex *to; 467 short flags; 468 short type; /* Ooh, could even have linedef-type-kind records! */ 469 short tag; 470 sidedef *right; 471 sidedef *left; 472 short number; 473 boolean marked; 474 boolean f_misaligned; 475 boolean b_misaligned; 476 struct s_linedef *group_next; /* Used during texture-alignment */ 477 struct s_linedef *group_previous; /* A group gets aligned together */ 478 struct s_linedef *next; 479 }; /* linedef and plinedef defined above; gcc chokes if we do it again! */ 480 481 /* Linedef flags */ 482 #define IMPASSIBLE (0x01) 483 #define BLOCK_MONSTERS (0x02) 484 #define TWO_SIDED (0x04) 485 #define UPPER_UNPEGGED (0x08) 486 #define LOWER_UNPEGGED (0x10) 487 #define SECRET_LINEDEF (0x20) 488 #define BLOCK_SOUND (0x40) 489 #define NOT_ON_MAP (0x80) 490 #define ALREADY_ON_MAP (0x100) 491 492 /* Linedef types */ 493 #define LINEDEF_NORMAL (0) 494 #define LINEDEF_NORMAL_DOOR (1) 495 #define LINEDEF_NORMAL_S1_DOOR (31) 496 #define LINEDEF_BLUE_S1_DOOR (32) 497 #define LINEDEF_RED_S1_DOOR (33) 498 #define LINEDEF_YELLOW_S1_DOOR (34) 499 #define LINEDEF_S1_OPEN_DOOR (103) 500 #define LINEDEF_S1_OPEN_DOOR_BLUE (133) 501 #define LINEDEF_S1_OPEN_DOOR_RED (135) 502 #define LINEDEF_S1_OPEN_DOOR_YELLOW (137) 503 #define LINEDEF_WR_OPEN_DOOR (86) 504 #define LINEDEF_W1_OPEN_DOOR (2) 505 #define LINEDEF_GR_OPEN_DOOR (46) 506 #define LINEDEF_SR_OC_DOOR (63) 507 #define LINEDEF_WR_OC_DOOR (90) 508 #define LINEDEF_BLAZE_DOOR (117) 509 #define LINEDEF_BLAZE_S1_DOOR (118) 510 #define LINEDEF_S1_BLAZE_O_DOOR (112) 511 #define LINEDEF_SR_BLAZE_OC_DOOR (114) 512 #define LINEDEF_S1_END_LEVEL (11) 513 #define LINEDEF_W1_END_LEVEL (52) 514 #define LINEDEF_S1_SEC_LEVEL (51) 515 #define LINEDEF_W1_SEC_LEVEL (124) 516 #define LINEDEF_WR_FAST_CRUSH (77) 517 #define LINEDEF_WR_LOWER_LIFT (88) 518 #define LINEDEF_SR_LOWER_LIFT (62) 519 #define LINEDEF_WR_TURBO_LIFT (120) 520 #define LINEDEF_SR_TURBO_LIFT (123) 521 #define LINEDEF_S1_RAISE_AND_CLEAN_FLOOR (20) 522 #define LINEDEF_S1_RAISE_FLOOR (18) 523 #define LINEDEF_W1_RAISE_FLOOR (119) 524 #define LINEDEF_S1_RAISE_STAIRS (7) 525 #define LINEDEF_S1_LOWER_FLOOR (23) 526 #define LINEDEF_SCROLL (48) 527 #define LINEDEF_TELEPORT (97) 528 /* and so on and so on */ 529 530 /* Sector specials */ 531 #define RANDOM_BLINK (1) 532 #define SYNC_FAST_BLINK (0x0c) 533 #define SYNC_SLOW_BLINK (0x0d) 534 #define GLOW_BLINK (0x08) 535 #define SECRET_SECTOR (0x09) 536 #define NUKAGE1_SPECIAL (5) 537 #define DEATH_SECTOR (0x0b) 538 539 /* Stuff related to an open PWAD we're generating */ 540 541 typedef struct s_index_entry { 542 char name[9]; 543 unsigned int offset; 544 unsigned int length; 545 struct s_index_entry *next; 546 } index_entry, *pindex_entry; 547 548 typedef struct s_dump_record { 549 FILE *f; 550 unsigned int offset_to_index; 551 unsigned int lmpcount; 552 index_entry *index_entry_anchor; 553 } dump_record, *pdump_record, *dumphandle; 554 555 typedef struct s_musheader { 556 char tag[4]; /* MUS[0x1a] */ 557 short muslength; 558 short headerlength; 559 short primchannels; 560 short secchannels; 561 short patches; 562 short dummy; 563 } musheader, *pmusheader; 564 565 typedef struct s_patch { 566 short number; 567 short x; 568 short y; 569 struct s_patch *next; 570 } patch, *ppatch; 571 572 typedef struct s_custom_texture { 573 char *name; 574 short xsize; 575 short ysize; 576 patch *patch_anchor; 577 struct s_custom_texture *next; 578 } custom_texture, *pcustom_texture; 579 580 typedef struct s_texture_lmp { 581 char *name; 582 custom_texture *custom_texture_anchor; 583 } texture_lmp, *ptexture_lmp; 584 585 /* Health, Armor, and Ammo estimates */ 586 587 typedef struct s_one_haa { 588 float health; 589 float armor; 590 float ammo; 591 boolean can_use_shells; 592 boolean can_use_rockets; 593 boolean can_use_cells; 594 boolean has_chaingun; 595 boolean has_chainsaw; 596 boolean has_backpack; 597 boolean has_berserk; 598 boolean has_ssgun; 599 boolean shells_pending; 600 boolean chaingun_pending; 601 } one_haa, *pone_haa; 602 603 typedef struct s_haa { 604 one_haa haas[3]; 605 #define ITYTD (0) 606 #define HMP (1) 607 #define UV (2) 608 } haa, *phaa; 609 610 typedef struct s_quest { 611 short goal; /* What kind of quest? */ 612 short tag; /* If a linedef/switch, what's the tag? */ 613 short tag2; /* Another tag, if needed for GATEs etc. */ 614 short type; /* What should we do to the tag? */ 615 /* Or what's the ID of the key */ 616 sector *room; /* What room will the quest let us into? */ 617 short count; /* How many rooms in the quest so far? */ 618 short minrooms; /* How many rooms at least should it have? */ 619 short auxtag; /* Tag of door to open when taking goal */ 620 linedef *surprise; /* Linedef to populate after goal room */ 621 thing *thing; /* Thing that closed a closed thing-quest */ 622 struct s_quest *next; /* For the quest stack */ 623 } quest, *pquest; 624 625 /* Values for quest.goal */ 626 #define LEVEL_END_GOAL 101 627 #define KEY_GOAL 102 628 #define SWITCH_GOAL 103 629 #define NULL_GOAL 104 630 #define ARENA_GOAL 105 631 #define GATE_GOAL 106 632 633 /* Teleport gates */ 634 struct s_gate { 635 short in_tag; 636 short out_tag; 637 short gate_lock; /* The linedef-type, if any, to open the gate */ 638 boolean is_entry; /* Does one enter the room by it the first time? */ 639 gate *next; 640 }; 641 642 /* The Arena */ 643 644 typedef struct s_arena { 645 propertybits props; 646 #define ARENA_ROOF (0x01) 647 #define ARENA_PORCH (0x02) 648 #define ARENA_LAMPS (0x04) 649 #define ARENA_ARRIVAL_HOLE (0x08) 650 #define ARENA_NUKAGE (0x10) 651 genus *boss; 652 int boss_count; 653 genus *weapon; 654 genus *ammo; 655 flat *floor; 656 texture *walls; 657 boolean placed_health; 658 boolean placed_armor; 659 boolean placed_ammo; 660 boolean placed_weapon; 661 short minx, miny, maxx, maxy; 662 sector *innersec; 663 sector *outersec; 664 short fromtag; 665 struct s_arena *next; 666 } arena, *parena; 667 668 typedef struct s_level { 669 thing *thing_anchor; 670 sector *sector_anchor; 671 vertex *vertex_anchor; 672 sidedef *sidedef_anchor; 673 linedef *linedef_anchor; 674 boolean used_red; 675 boolean used_blue; 676 boolean used_yellow; 677 int last_tag_used; 678 short sl_tag; /* Tag for thing to activate to open secret level exit */ 679 short sl_type; /* Type for ... */ 680 sector *sl_open_start; /* The first room the opener can go in */ 681 boolean sl_open_ok; /* Is it time to do the opener yet? */ 682 sector *sl_exit_sector; /* The room the exit switch is in */ 683 boolean sl_done; /* Did we done it yet? */ 684 sector *first_room; 685 sector *goal_room; 686 int secret_count; 687 int dm_count; 688 int dm_rho; 689 boolean support_misaligns; 690 boolean seen_suit; 691 boolean seen_map; 692 boolean scrolling_keylights; 693 int skyclosets; /* Percent chance of closets being open to the sky */ 694 int p_new_pillars; 695 int p_stair_lamps; 696 int p_force_nukage; 697 int p_force_sky; 698 int p_deep_baths; 699 int p_falling_core; 700 int p_barrels; 701 int p_extwindow; 702 int p_extroom; 703 int p_rising_room; 704 int p_surprise; 705 int p_swcloset; 706 int p_rational_facing; 707 int p_biggest_monsters; 708 int p_open_link; 709 int p_s1_door; 710 int p_special_room; /* Should be in Style, maybe? */ 711 int lift_rho; /* How common are lifts? */ 712 int amcl_rho; /* How common are ambush-closets? */ 713 int maxkeys; /* How many key or switch quests, at most, to use */ 714 int barcount; /* How many door-bars so far? */ 715 int crushercount; /* How many left-on crushers so far? */ 716 int hugeness; /* A one or a two or whatever */ 717 boolean skullkeys; /* Use skull (not card) keys? */ 718 boolean use_gates; /* Allowed to use non-exit teleporters? */ 719 boolean raise_gates; /* Teleport flats raised a bit? */ 720 boolean all_wide_links; 721 boolean no_doors; 722 short outside_light_level; /* I don't know if it's cloudy or bright */ 723 short bright_light_level; /* How bright a bright room is */ 724 short lit_light_level; /* How bright a working lamp/light is */ 725 /* These lists are just for memory-freeing purposes */ 726 style *style_anchor; 727 link *link_anchor; 728 gate *gate_anchor; 729 arena *arena_anchor; 730 } level, *plevel; 731 732 /* The config is the static architectural knowledge and stuff. */ 733 /* It's read from a config file (parts of it, anyway!). */ 734 typedef struct s_config { 735 char *configfile; /* Name of the configuration file */ 736 char *configdata; /* Contents of the configuration file */ 737 char *outfile; /* Name of the output file */ 738 boolean cwadonly; /* Do we want just the customization lumps? */ 739 unsigned int ranseed; 740 unsigned char themecount; /* How many (non-secret) themes there are */ 741 unsigned char sthemecount; /* How many secret themes there are */ 742 boolean secret_themes; 743 boolean lock_themes; 744 boolean major_nukage; 745 propertybits required_monster_bits; 746 propertybits forbidden_monster_bits; 747 short minrooms; 748 theme *theme_anchor; 749 genus *genus_anchor; 750 flat *flat_anchor; 751 texture *texture_anchor; 752 construct *construct_anchor; 753 flat *sky_flat; 754 flat *water_flat; 755 texture *null_texture; 756 texture *error_texture; 757 texture *gate_exitsign_texture; 758 gamebits gamemask; /* Which games must we be compatible with? */ 759 int levelcount; /* How many levels to produce */ 760 boolean produce_null_lmps; 761 boolean do_music; 762 boolean do_slinfo; 763 boolean do_seclevels; 764 boolean do_dm; 765 boolean secret_monsters; 766 boolean force_secret; 767 boolean force_arena; 768 boolean force_biggest; 769 boolean weapons_are_special; /* Can weapons (not) be given out as ammo? */ 770 boolean recess_switches; 771 boolean big_weapons; 772 boolean big_monsters; 773 boolean gunk_channels; 774 boolean clights; 775 boolean allow_boring_rooms; 776 boolean both_doors; 777 boolean doorless_jambs; 778 float machoh; /* Macho-factor for Hurt Me Plenty */ 779 float machou; /* Macho-factor for Ultraviolins */ 780 int p_bigify; /* Percent chance of maybe expanding rooms */ 781 int usualammo[3]; /* Usual ammo/armor/health for the three hardnesses */ 782 int usualarmor[3]; 783 int usualhealth[3]; 784 int minhealth[3]; /* Minimal OK healths for the three hardnesses */ 785 boolean immediate_monsters; /* OK to have monsters in first room? */ 786 int p_hole_ends_level; 787 int p_gate_ends_level; 788 int p_use_steps; 789 int p_sync_doors; 790 int p_grid_gaps; 791 int p_pushquest; 792 int rad_newtheme; /* How likely to use a random theme beyond a lock */ 793 int norm_newtheme; /* How likely beyond a non-lock link */ 794 int rad_vary; /* How much to vary the style beyond a lock */ 795 int norm_vary; /* How much beyon a non-lock link */ 796 boolean monsters_can_teleport; 797 boolean window_airshafts; 798 int homogenize_monsters; /* How likely to have all room monsters == */ 799 int minlight; /* How dark is dark? */ 800 /* These are *not* actually static */ 801 int episode, mission, map; /* What map/mission we're on now. */ 802 boolean last_mission; /* This the last one we're doing? */ 803 } config, *pconfig; 804 805 /* Lots and lots and lots of functions */ 806 /* And this isn't even all of 'em! */ 807 808 config *get_config(int argc, char *arg[]); 809 void NewLevel(level *l, haa *init_haa, config *c); 810 void DumpLevel(dumphandle dh,config *c,level *l,int episode,int mission,int map); 811 void FreeLevel(level *l); 812 dumphandle OpenDump(config *c); 813 void CloseDump(dumphandle dh); 814 quest *starting_quest(level *l,config *c); 815 haa *starting_haa(void); 816 style *random_style(level *l,config *c); 817 boolean enough_quest(level *l,sector *s,quest *ThisQuest,config *c); 818 boolean rollpercent(int linenum,int percent); 819 int roll(int linenum,int zero_to_this_minus_one); 820 linedef *starting_linedef(level *l,style *ThisStyle,config *c); 821 int mark_adequate_linedefs(level *l,sector *s,style *ThisStyle,config *c); 822 int mark_decent_boundary_linedefs(level *l,sector *s,int minlen); 823 boolean isAdequate(level *l,linedef *ld,style *ThisStyle,config *c); 824 linedef *random_marked_linedef(level *l,int i); 825 void unmark_linedefs(level *l); 826 void embellish_room(level *l,sector *oldsector, haa *haa, 827 style *ThisStyle,quest *ThisQuest,boolean should_watermark, 828 boolean edges_only, config *c); 829 boolean grid_room(level *l,sector *oldsector, haa *haa, 830 style *ThisStyle,quest *ThisQuest,boolean first_room,config *c); 831 void enhance_room(level *l,sector *oldsector, haa *haa, 832 style *ThisStyle,quest *ThisQuest,boolean first_room,config *c); 833 void align_textures(level *l,sector *oldsector,config *c); 834 void gloabl_align_textures(level *l,config *c); 835 void populate(level *l,sector *oldsector,config *c,haa *ThisHaa,boolean first); 836 void gate_populate(level *l,sector *s,haa *haa, boolean first, config *c); 837 link *random_link(level *l,linedef *ld,style *ThisStyle,quest *ThisQuest, 838 config *c); 839 link *random_open_link(level *l,linedef *ld,style *ThisStyle,quest *ThisQuest, 840 config *c); 841 link *random_basic_link(level *l,linedef *ld,style *ThisStyle,quest *ThisQuest, 842 config *c); 843 link *gate_link(level *l,config *c); 844 sector *generate_room_outline(level *l,linedef *ld,style *ThisStyle, 845 boolean try_reduction,config *c); 846 int lengthsquared(linedef *ld); 847 int distancesquared(int x1, int y1, int x2, int y2); 848 int infinity_norm(int x1, int y1, int x2, int y2); 849 boolean empty_rectangle(level *l,int x1, int y1, int x2, int y2, 850 int x3, int y3, int x4, int y4); 851 boolean empty_left_side(level *l, linedef *ld, int sdepth); 852 void close_quest(level *l,sector *s,quest *ThisQuest,haa *haa,config *c); 853 void maybe_push_quest(level *l,sector *s,quest *ThisQuest,config *c); 854 linedef *make_parallel(level *l,linedef *ld,int depth,linedef *old); 855 linedef *lefthand_box_ext(level *l,linedef *ldf1,int depth, 856 style *ThisStyle,config *c, 857 linedef **nld1, linedef **nld2); 858 #define lefthand_box(l,ldf1,depth,ThisStyle,c) (lefthand_box_ext(l,ldf1,depth,ThisStyle,c,NULL,NULL)) 859 int facing_along(int x1, int y1, int x2, int y2); 860 int facing_right_from(int x1, int y1, int x2, int y2); 861 int facing_right_from_ld(linedef *ld); 862 linedef *make_linkto(level *l,linedef *ldf,link *ThisLink, 863 style *ThisStyle,config *c, linedef *old); 864 void e_bl_inner(level *l,linedef *ldf1,linedef *ldf2,link *ThisLink, 865 quest *ThisQuest,style *ThisStyle,style *NewStyle, 866 short flipstate, haa *haa,config *c); 867 void e_ol_inner(level *l,linedef *ldf1,linedef *ldf2,link *ThisLink, 868 quest *ThisQuest,style *ThisStyle,style *NewStyle, 869 haa *haa,config *c); 870 void establish_basic_link(level *l,linedef *ldf1,linedef *ldf2,link *ThisLink, 871 quest *ThisQuest,style *ThisStyle,style *NewStyle, 872 haa *haa,config *c); 873 void establish_open_link(level *l,linedef *ldf1,linedef *ldf2,link *ThisLink, 874 quest *ThisQuest,style *ThisStyle,style *NewStyle, 875 haa *haa,config *c); 876 void establish_link(level *l,linedef *ldf1,linedef *ldf2,link *ThisLink, 877 quest *ThisQuest,style *ThisStyle,style *NewStyle, 878 haa *haa,config *c); 879 void stairify(level *l,linedef *ldf1,linedef *ldf2,linedef *lde1, 880 linedef *lde2,short nearheight,short farheight, 881 quest *ThisQuest, style *ThisStyle, config *c); 882 void paint_room(level *l,sector *s,style *ThisStyle,config *c); 883 linedef *split_linedef(level *l, linedef *ld, int len, config *c); 884 boolean link_fitsq(link *ThisLink,quest *ThisQuest); 885 boolean link_fitsh(linedef *ldf,link *ThisLink,config *c); 886 boolean link_fitsv(level *l,linedef *ldf1,linedef *ldf2,link *ThisLink); 887 void Usage0(void); 888 void Usage(void); 889 void Usage2(void); 890 boolean do_switches(int argc,char *argv[],config *c,char *s,int conly); 891 boolean read_switches(config *c); 892 boolean nonswitch_config(config *c); 893 void load_config(config *c); 894 void unload_config(config *c); 895 texture *new_texture(config *c, char *name); 896 texture *find_texture(config *c, char *name); 897 genus *find_genus(config *c, int thingid); 898 genus *new_genus(config *c,int thingid); 899 flat *new_flat(config *c, char *name); 900 flat *find_flat(config *c, char *name); 901 theme *new_theme(config *c, char *name, boolean secret); 902 gate *new_gate(level *l,short in,short out,short lock,boolean entry,config *c); 903 void patch_upper(linedef *ld,texture *t,config *c); 904 void patch_lower(linedef *ld,texture *t,config *c); 905 linedef *flip_linedef(linedef *ld); 906 sector *make_box_ext(level *l,linedef *ldf1, linedef *ldf2, 907 style *ThisStyle, config *c, 908 linedef **nld1, linedef **nld2); 909 #define make_box(l,ld1,ld2,st,c) (make_box_ext(l,ld1,ld2,st,c,NULL,NULL)) 910 thing *place_object(level *l,sector *s,config *c,short thingid,int width, 911 int angle,int ax,int ay,int bits); 912 thing *place_object_in_region(level *l,int minx, int miny, int maxx, int maxy, 913 config *c,short thingid,int width, 914 int angle,int ax,int ay,int bits); 915 thing *place_required_pickable(level *l,sector *s,config *c,short id); 916 genus *timely_monster(haa *haa,config *c,int *levels,boolean biggest,int mno); 917 genus *timely_monster_ex(haa *haa,config *c,int *levels,boolean biggest, 918 int mno,propertybits req); 919 void update_haa_for_monster(haa *haa,genus *m,int levels,int mno,config *c); 920 void ammo_value(short ammotype, haa *haa, int *a0, int *a1, int *a2); 921 void haa_unpend(haa *haa); 922 void trigger_box(level *l,thing *t,sector *s,short tag,short type,config *c); 923 void populate_linedef(level *l,linedef *ldnew2,haa *haa,config *c,boolean s); 924 void find_rec(level *l, sector *s, int *minx, int *miny, int *maxx, int *maxy); 925 void mid_tile(level *l, sector *s, short *tlx, short *tly, short *thx, short *thy); 926 linedef *centerpart(level *l,linedef *ld,linedef **ld2,int width, 927 style *ThisStyle,config *c); 928 texture *texture_for_key(short key, style *s, config *c); 929 texture *texture_for_bits(propertybits pb, style *s, config *c); 930 short type_for_key(short key); 931 void make_lighted(level *l, sector *s, config *c); 932 short locked_linedef_for(short type,short key,config *c); 933 void install_gate(level *l,sector *s,style *ThisStyle,haa *ThisHaa, 934 boolean force_exit_style,config *c); 935 void frame_innersec_ex(level *l,sector *oldsector,sector *innersec, 936 texture *tm, texture *tu, texture *tl, 937 int x1,int y1,int x2,int y2, 938 int x3,int y3,int x4,int y4, 939 config *c, 940 linedef **l1, linedef **l2, linedef **l3, linedef **l4); 941 #define frame_innersec(l,s,i,tm,tu,tl,x1,y1,x2,y2,x3,y3,x4,y4,c) frame_innersec_ex(l,s,i,tm,tu,tl,x1,y1,x2,y2,x3,y3,x4,y4,c,NULL,NULL,NULL,NULL) 942 void parallel_innersec_ex(level *l,sector *oldsector,sector *innersec, 943 texture *tm, texture *tu, texture *tl, 944 int minx,int miny,int maxx,int maxy,config *c, 945 linedef **l1, linedef **l2, linedef **l3, linedef **l4); 946 #define parallel_innersec(l,o,i,tm,tu,tl,ix,iy,ax,ay,c) parallel_innersec_ex(l,o,i,tm,tu,tl,ix,iy,ax,ay,c,NULL,NULL,NULL,NULL) 947 boolean install_construct(level *l,sector *oldsector, 948 int minx,int miny,int maxx,int maxy, 949 style *ThisStyle,config *c); 950 951 void make_music(dumphandle dh,config *c); 952 void make_slinfo(dumphandle dh,config *c); 953 void record_custom_textures(dumphandle dh,config *c); 954 void record_custom_flats(dumphandle dh,config *c,boolean even_unused); 955 void record_custom_patches(dumphandle dh,config *c,boolean even_unused); 956 957 boolean need_secret_level(config *c); 958 void make_secret_level(dumphandle dh, haa *haa, config *c); 959 void secretize_config(config *c); 960 boolean install_sl_exit(level *l,sector *oldsector,haa *ThisHaa, 961 style *ThisStyle, quest *ThisQuest, 962 boolean opens, config *c); 963 964 #define NONE -1 965 #define VERBOSE 0 966 #define LOG 1 967 #define NOTE 2 968 #define WARNING 3 969 #define ERROR 4 970 void announce(int announcetype, char *s); 971 972 #define RIGHT_TURN (90) 973 #define LEFT_TURN (270) 974 void point_from(int x1, int y1, int x2, int y2, int angle, int len, 975 int *x3, int *y3); 976 unsigned short psi_sqrt(int v); 977 #define linelen(x) (unsigned short)(psi_sqrt(lengthsquared(x))) 978 boolean no_monsters_stuck_on(level *l,linedef *ld1); 979 980 flat *random_ceiling0(config *c, style *s); 981 flat *random_ceilinglight(config *c, style *s); 982 flat *random_floor0(config *c, style *s); 983 flat *random_gate(config *c, style *s); 984 flat *random_doorceiling(config *c,style *s); 985 flat *random_doorfloor(config *c,style *s); 986 flat *random_stepfloor(config *c,style *s); 987 flat *random_nukage1(config *c,style *s); 988 flat *random_flat0(propertybits pmask, config *c, style *s); 989 genus *random_thing0(propertybits pmask,config *c,style *s,int minh,int maxh); 990 texture *random_texture0(propertybits pmask, config *c, style *s); 991 texture *random_wall0(config *c,style *s); 992 texture *random_kickplate(config *c,style *s); 993 texture *random_stepfront(config *c,style *s); 994 texture *switch0_for(config *c, style *s); 995 texture *random_support0(config *c, style *s); 996 texture *random_doorjamb(config *c, style *s); 997 texture *random_widedoorface(config *c, style *s); 998 texture *random_widedoorface_ex(config *c, style *s,boolean hi); 999 texture *random_narrowdoorface(config *c, style *s); 1000 texture *random_narrowdoorface_ex(config *c, style *s,boolean hi); 1001 texture *random_twdoorface(config *c, style *s); 1002 texture *random_tndoorface(config *c, style *s); 1003 texture *random_lockdoorface(config *c, style *s); 1004 texture *random_grating(config *c, style *s); 1005 texture *random_walllight(config *c, style *s); 1006 texture *random_liftface(config *c, style *s); 1007 texture *random_plaque(config *c, style *s); 1008 genus *random_lamp0(config *c, style *s); 1009 genus *random_shortlamp0(config *c, style *s); 1010 genus *random_barrel(config *c, style *s); 1011 genus *random_plant(config *c, style *s); 1012 texture *random_redface(config*c, style *s); 1013 texture *random_blueface(config*c, style *s); 1014 texture *random_yellowface(config*c, style *s); 1015 1016 void place_monsters(level *l,sector *s,config *c,haa *haa); 1017 void place_timely_something(level *l,haa *haa, config *c,int x, int y); 1018 void place_armor(level *l,sector *s,config *c,haa *haa); 1019 void place_ammo(level *l,sector *s,config *c,haa *haa); 1020 void place_health(level *l,sector *s,config *c,haa *haa); 1021 void place_barrels(level *l,sector *s,config *c,haa *haa); 1022 void place_plants(level *l,int allow,sector *s,config *c); 1023 1024 boolean common_texture(sidedef *sd1, sidedef *sd2); 1025 boolean coalignable(texture *t1, texture *t2); 1026 1027 void global_align_textures(level *l,config *c); 1028 void global_align_linedef(level *l, linedef *ld); 1029 void global_align_forward(level *l, linedef *ld); 1030 void global_align_backward(level *l, linedef *ld); 1031 void global_align_group_backbone_forward(level *l,linedef *ld); 1032 void global_align_group_backbone_backward(level *l,linedef *ld); 1033 void global_align_group_etc_forward(level *l,linedef *ld); 1034 void global_align_group_etc_backward(level *l,linedef *ld); 1035 1036 /* End of slump.h */ 1037 1038