1 /* NetHack 3.7 decl.h $NHDT-Date: 1607641577 2020/12/10 23:06:17 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.248 $ */ 2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3 /*-Copyright (c) Michael Allison, 2007. */ 4 /* NetHack may be freely redistributed. See license for details. */ 5 6 #ifndef DECL_H 7 #define DECL_H 8 9 #define E extern 10 11 /* max size of a windowtype option */ 12 #define WINTYPELEN 16 13 14 struct dgn_topology { /* special dungeon levels for speed */ 15 d_level d_oracle_level; 16 d_level d_bigroom_level; /* unused */ 17 d_level d_medusa_level; 18 d_level d_stronghold_level; 19 d_level d_valley_level; 20 d_level d_wiz1_level; 21 d_level d_wiz2_level; 22 d_level d_wiz3_level; 23 d_level d_juiblex_level; 24 d_level d_orcus_level; 25 d_level d_baalzebub_level; /* unused */ 26 d_level d_asmodeus_level; /* unused */ 27 d_level d_portal_level; /* only in goto_level() [do.c] */ 28 d_level d_sanctum_level; 29 d_level d_earth_level; 30 d_level d_water_level; 31 d_level d_fire_level; 32 d_level d_air_level; 33 d_level d_astral_level; 34 xchar d_tower_dnum; 35 xchar d_sokoban_dnum; 36 xchar d_mines_dnum, d_quest_dnum; 37 d_level d_qstart_level, d_qlocate_level, d_nemesis_level; 38 d_level d_knox_level; 39 d_level d_mineend_level; 40 d_level d_sokoend_level; 41 }; 42 43 /* macros for accessing the dungeon levels by their old names */ 44 /* clang-format off */ 45 #define oracle_level (g.dungeon_topology.d_oracle_level) 46 #define bigroom_level (g.dungeon_topology.d_bigroom_level) 47 #define medusa_level (g.dungeon_topology.d_medusa_level) 48 #define stronghold_level (g.dungeon_topology.d_stronghold_level) 49 #define valley_level (g.dungeon_topology.d_valley_level) 50 #define wiz1_level (g.dungeon_topology.d_wiz1_level) 51 #define wiz2_level (g.dungeon_topology.d_wiz2_level) 52 #define wiz3_level (g.dungeon_topology.d_wiz3_level) 53 #define juiblex_level (g.dungeon_topology.d_juiblex_level) 54 #define orcus_level (g.dungeon_topology.d_orcus_level) 55 #define baalzebub_level (g.dungeon_topology.d_baalzebub_level) 56 #define asmodeus_level (g.dungeon_topology.d_asmodeus_level) 57 #define portal_level (g.dungeon_topology.d_portal_level) 58 #define sanctum_level (g.dungeon_topology.d_sanctum_level) 59 #define earth_level (g.dungeon_topology.d_earth_level) 60 #define water_level (g.dungeon_topology.d_water_level) 61 #define fire_level (g.dungeon_topology.d_fire_level) 62 #define air_level (g.dungeon_topology.d_air_level) 63 #define astral_level (g.dungeon_topology.d_astral_level) 64 #define tower_dnum (g.dungeon_topology.d_tower_dnum) 65 #define sokoban_dnum (g.dungeon_topology.d_sokoban_dnum) 66 #define mines_dnum (g.dungeon_topology.d_mines_dnum) 67 #define quest_dnum (g.dungeon_topology.d_quest_dnum) 68 #define qstart_level (g.dungeon_topology.d_qstart_level) 69 #define qlocate_level (g.dungeon_topology.d_qlocate_level) 70 #define nemesis_level (g.dungeon_topology.d_nemesis_level) 71 #define knox_level (g.dungeon_topology.d_knox_level) 72 #define mineend_level (g.dungeon_topology.d_mineend_level) 73 #define sokoend_level (g.dungeon_topology.d_sokoend_level) 74 /* clang-format on */ 75 76 #define dunlev_reached(x) (g.dungeons[(x)->dnum].dunlev_ureached) 77 78 #include "quest.h" 79 80 E NEARDATA char tune[6]; 81 82 #define MAXLINFO (MAXDUNGEON * MAXLEVEL) 83 84 struct sinfo { 85 int gameover; /* self explanatory? */ 86 int stopprint; /* inhibit further end of game disclosure */ 87 #ifdef HANGUPHANDLING 88 volatile int done_hup; /* SIGHUP or moral equivalent received 89 * -- no more screen output */ 90 int preserve_locks; /* don't remove level files prior to exit */ 91 #endif 92 int something_worth_saving; /* in case of panic */ 93 int panicking; /* `panic' is in progress */ 94 int exiting; /* an exit handler is executing */ 95 int saving; 96 int restoring; 97 int in_moveloop; 98 int in_impossible; 99 int in_self_recover; 100 int in_parseoptions; /* in parseoptions */ 101 int config_error_ready; /* config_error_add is ready, available */ 102 #ifdef PANICLOG 103 int in_paniclog; 104 #endif 105 int wizkit_wishing; 106 }; 107 108 /* Flags for controlling uptodate */ 109 #define UTD_CHECKSIZES 0x01 110 #define UTD_CHECKFIELDCOUNTS 0x02 111 #define UTD_SKIP_SANITY1 0x04 112 #define UTD_SKIP_SAVEFILEINFO 0x08 113 114 /* NetHack ftypes */ 115 #define NHF_LEVELFILE 1 116 #define NHF_SAVEFILE 2 117 #define NHF_BONESFILE 3 118 /* modes */ 119 #define READING 0x0 120 #define COUNTING 0x1 121 #define WRITING 0x2 122 #define FREEING 0x4 123 #define MAX_BMASK 4 124 /* operations of the various saveXXXchn & co. routines */ 125 #define perform_bwrite(nhfp) ((nhfp)->mode & (COUNTING | WRITING)) 126 #define release_data(nhfp) ((nhfp)->mode & FREEING) 127 128 /* Content types for fieldlevel files */ 129 struct fieldlevel_content { 130 boolean deflt; /* individual fields */ 131 boolean binary; /* binary rather than text */ 132 boolean json; /* JSON */ 133 }; 134 135 typedef struct { 136 int fd; /* for traditional structlevel binary writes */ 137 int mode; /* holds READING, WRITING, or FREEING modes */ 138 int ftype; /* NHF_LEVELFILE, NHF_SAVEFILE, or NHF_BONESFILE */ 139 int fnidx; /* index of procs for fieldlevel saves */ 140 long count; /* holds current line count for default style file, 141 field count for binary style */ 142 boolean structlevel; /* traditional structure binary saves */ 143 boolean fieldlevel; /* fieldlevel saves saves each field individually */ 144 boolean addinfo; /* if set, some additional context info from core */ 145 boolean eof; /* place to mark eof reached */ 146 boolean bendian; /* set to true if executing on big-endian machine */ 147 FILE *fpdef; /* file pointer for fieldlevel default style */ 148 FILE *fpdefmap; /* file pointer mapfile for def format */ 149 FILE *fplog; /* file pointer logfile */ 150 FILE *fpdebug; /* file pointer debug info */ 151 struct fieldlevel_content style; 152 } NHFILE; 153 154 E const char quitchars[]; 155 E const char vowels[]; 156 E const char ynchars[]; 157 E const char ynqchars[]; 158 E const char ynaqchars[]; 159 E const char ynNaqchars[]; 160 E NEARDATA long yn_number; 161 162 E const char disclosure_options[]; 163 164 struct kinfo { 165 struct kinfo *next; /* chain of delayed killers */ 166 int id; /* uprop keys to ID a delayed killer */ 167 int format; /* one of the killer formats */ 168 #define KILLED_BY_AN 0 169 #define KILLED_BY 1 170 #define NO_KILLER_PREFIX 2 171 char name[BUFSZ]; /* actual killer name */ 172 }; 173 174 #ifdef WHEREIS_FILE 175 E char whereis_real_path[255]; 176 #endif 177 178 E const schar xdir[], ydir[], zdir[]; 179 180 struct multishot { 181 int n, i; 182 short o; 183 boolean s; 184 }; 185 186 E NEARDATA boolean has_strong_rngseed; 187 E const int shield_static[]; 188 189 #include "spell.h" 190 191 #include "color.h" 192 #ifdef TEXTCOLOR 193 E const int zapcolors[]; 194 #endif 195 196 E const struct class_sym def_oc_syms[MAXOCLASSES]; /* default class symbols */ 197 E uchar oc_syms[MAXOCLASSES]; /* current class symbols */ 198 E const struct class_sym def_monsyms[MAXMCLASSES]; /* default class symbols */ 199 E uchar monsyms[MAXMCLASSES]; /* current class symbols */ 200 201 #include "obj.h" 202 E NEARDATA struct obj *uarm, *uarmc, *uarmh, *uarms, *uarmg, *uarmf, 203 *uarmu, /* under-wear, so to speak */ 204 *uskin, *uamul, *uleft, *uright, *ublindf, *uwep, *uswapwep, *uquiver; 205 206 E NEARDATA struct obj *uchain; /* defined only when punished */ 207 E NEARDATA struct obj *uball; 208 209 #include "engrave.h" 210 E struct engr *head_engr; 211 212 #include "you.h" 213 E NEARDATA struct you u; 214 E NEARDATA time_t ubirthday; 215 E NEARDATA struct u_realtime urealtime; 216 217 #include "onames.h" 218 #ifndef PM_H /* (pm.h has already been included via youprop.h) */ 219 #include "pm.h" 220 #endif 221 222 struct mvitals { 223 uchar born; 224 uchar died; 225 uchar mvflags; 226 }; 227 228 struct c_color_names { 229 const char *const c_black, *const c_amber, *const c_golden, 230 *const c_light_blue, *const c_red, *const c_green, *const c_silver, 231 *const c_blue, *const c_purple, *const c_white, *const c_orange; 232 }; 233 234 E NEARDATA const struct c_color_names c_color_names; 235 236 #define NH_BLACK c_color_names.c_black 237 #define NH_AMBER c_color_names.c_amber 238 #define NH_GOLDEN c_color_names.c_golden 239 #define NH_LIGHT_BLUE c_color_names.c_light_blue 240 #define NH_RED c_color_names.c_red 241 #define NH_GREEN c_color_names.c_green 242 #define NH_SILVER c_color_names.c_silver 243 #define NH_BLUE c_color_names.c_blue 244 #define NH_PURPLE c_color_names.c_purple 245 #define NH_WHITE c_color_names.c_white 246 #define NH_ORANGE c_color_names.c_orange 247 248 /* The names of the colors used for gems, etc. */ 249 E const char *c_obj_colors[]; 250 251 struct c_common_strings { 252 const char *const c_nothing_happens, *const c_thats_enough_tries, 253 *const c_silly_thing_to, *const c_shudder_for_moment, 254 *const c_something, *const c_Something, *const c_You_can_move_again, 255 *const c_Never_mind, *c_vision_clears, *const c_the_your[2], 256 *const c_fakename[2]; 257 }; 258 259 E const struct c_common_strings c_common_strings; 260 261 #define nothing_happens c_common_strings.c_nothing_happens 262 #define thats_enough_tries c_common_strings.c_thats_enough_tries 263 #define silly_thing_to c_common_strings.c_silly_thing_to 264 #define shudder_for_moment c_common_strings.c_shudder_for_moment 265 #define something c_common_strings.c_something 266 #define Something c_common_strings.c_Something 267 #define You_can_move_again c_common_strings.c_You_can_move_again 268 #define Never_mind c_common_strings.c_Never_mind 269 #define vision_clears c_common_strings.c_vision_clears 270 #define the_your c_common_strings.c_the_your 271 /* fakename[] used occasionally so vtense() won't be fooled by an assigned 272 name ending in 's' */ 273 #define fakename c_common_strings.c_fakename 274 275 /* material strings */ 276 E const char *materialnm[]; 277 278 /* empty string that is non-const for parameter use */ 279 E char emptystr[]; 280 281 /* Monster name articles */ 282 #define ARTICLE_NONE 0 283 #define ARTICLE_THE 1 284 #define ARTICLE_A 2 285 #define ARTICLE_YOUR 3 286 287 /* Monster name suppress masks */ 288 #define SUPPRESS_IT 0x01 289 #define SUPPRESS_INVISIBLE 0x02 290 #define SUPPRESS_HALLUCINATION 0x04 291 #define SUPPRESS_SADDLE 0x08 292 #define EXACT_NAME 0x0F 293 #define SUPPRESS_NAME 0x10 294 295 /* Window system stuff */ 296 E NEARDATA winid WIN_MESSAGE; 297 E NEARDATA winid WIN_STATUS; 298 E NEARDATA winid WIN_MAP, WIN_INVEN; 299 300 /* pline (et al) for a single string argument (suppress compiler warning) */ 301 #define pline1(cstr) pline("%s", cstr) 302 #define Your1(cstr) Your("%s", cstr) 303 #define You1(cstr) You("%s", cstr) 304 #define verbalize1(cstr) verbalize("%s", cstr) 305 #define You_hear1(cstr) You_hear("%s", cstr) 306 #define Sprintf1(buf, cstr) Sprintf(buf, "%s", cstr) 307 #define panic1(cstr) panic("%s", cstr) 308 309 #ifndef TCAP_H 310 E struct tc_gbl_data { /* also declared in tcap.h */ 311 char *tc_AS, *tc_AE; /* graphics start and end (tty font swapping) */ 312 int tc_LI, tc_CO; /* lines and columns */ 313 } tc_gbl_data; 314 #define AS g.tc_gbl_data.tc_AS 315 #define AE g.tc_gbl_data.tc_AE 316 #define LI g.tc_gbl_data.tc_LI 317 #define CO g.tc_gbl_data.tc_CO 318 #endif 319 320 /* Some systems want to use full pathnames for some subsets of file names, 321 * rather than assuming that they're all in the current directory. This 322 * provides all the subclasses that seem reasonable, and sets up for all 323 * prefixes being null. Port code can set those that it wants. 324 */ 325 #define HACKPREFIX 0 /* shared, RO */ 326 #define LEVELPREFIX 1 /* per-user, RW */ 327 #define SAVEPREFIX 2 /* per-user, RW */ 328 #define BONESPREFIX 3 /* shared, RW */ 329 #define DATAPREFIX 4 /* dungeon/dlb; must match value in dlb.c */ 330 #define SCOREPREFIX 5 /* shared, RW */ 331 #define LOCKPREFIX 6 /* shared, RW */ 332 #define SYSCONFPREFIX 7 /* shared, RO */ 333 #define CONFIGPREFIX 8 334 #define TROUBLEPREFIX 9 /* shared or per-user, RW (append-only) */ 335 #define PREFIX_COUNT 10 336 /* used in files.c; xxconf.h can override if needed */ 337 #ifndef FQN_MAX_FILENAME 338 #define FQN_MAX_FILENAME 512 339 #endif 340 341 #if defined(NOCWD_ASSUMPTIONS) || defined(VAR_PLAYGROUND) 342 /* the bare-bones stuff is unconditional above to simplify coding; for 343 * ports that actually use prefixes, add some more localized things 344 */ 345 #define PREFIXES_IN_USE 346 #endif 347 348 #ifdef WIN32 349 E boolean fqn_prefix_locked[PREFIX_COUNT]; 350 #endif 351 #ifdef PREFIXES_IN_USE 352 E const char *fqn_prefix_names[PREFIX_COUNT]; 353 #endif 354 355 struct restore_info { 356 const char *name; 357 int mread_flags; 358 }; 359 E struct restore_info restoreinfo; 360 361 E NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo; 362 363 struct selectionvar { 364 int wid, hei; 365 char *map; 366 }; 367 368 struct autopickup_exception { 369 struct nhregex *regex; 370 char *pattern; 371 boolean grab; 372 struct autopickup_exception *next; 373 }; 374 375 struct plinemsg_type { 376 xchar msgtype; /* one of MSGTYP_foo */ 377 struct nhregex *regex; 378 char *pattern; 379 struct plinemsg_type *next; 380 }; 381 382 #define MSGTYP_NORMAL 0 383 #define MSGTYP_NOREP 1 384 #define MSGTYP_NOSHOW 2 385 #define MSGTYP_STOP 3 386 #define MSGTYP_ALERT 4 387 /* bitmask for callers of hide_unhide_msgtypes() */ 388 #define MSGTYP_MASK_REP_SHOW ((1 << MSGTYP_NOREP) | (1 << MSGTYP_NOSHOW)) 389 390 391 enum bcargs {override_restriction = -1}; 392 struct breadcrumbs { 393 const char *funcnm; 394 int linenum; 395 boolean in_effect; 396 }; 397 #ifdef PANICTRACE 398 E const char *ARGV0; 399 #endif 400 401 enum earlyarg {ARG_DEBUG, ARG_VERSION, ARG_SHOWPATHS 402 #ifdef WIN32 403 ,ARG_WINDOWS 404 #endif 405 }; 406 407 struct early_opt { 408 enum earlyarg e; 409 const char *name; 410 int minlength; 411 boolean valallowed; 412 }; 413 414 #define FUZZER_LOG_SIZE 20000 415 E char *fuzzer_log[FUZZER_LOG_SIZE]; 416 E long fuzzer_log_idx; 417 #define FUZLOG(s) fuz_log(s) 418 419 /* special key functions */ 420 enum nh_keyfunc { 421 NHKF_ESC = 0, 422 NHKF_DOAGAIN, 423 424 NHKF_REQMENU, 425 426 /* run ... clicklook need to be in a continuous block */ 427 NHKF_RUN, /* 'G' */ 428 NHKF_RUN2, /* '5' or M-5 */ 429 NHKF_RUSH, /* 'g' */ 430 NHKF_RUSH2, /* M-5 or '5' */ 431 NHKF_FIGHT, /* 'F' */ 432 NHKF_FIGHT2, /* '-' */ 433 NHKF_NOPICKUP, /* 'm' */ 434 NHKF_RUN_NOPICKUP, /* 'M' */ 435 NHKF_DOINV, /* '0' */ 436 NHKF_TRAVEL, /* via mouse */ 437 NHKF_CLICKLOOK, 438 439 NHKF_REDRAW, 440 NHKF_REDRAW2, 441 NHKF_GETDIR_SELF, 442 NHKF_GETDIR_SELF2, 443 NHKF_GETDIR_HELP, 444 NHKF_COUNT, 445 NHKF_GETPOS_SELF, 446 NHKF_GETPOS_PICK, 447 NHKF_GETPOS_PICK_Q, /* quick */ 448 NHKF_GETPOS_PICK_O, /* once */ 449 NHKF_GETPOS_PICK_V, /* verbose */ 450 NHKF_GETPOS_SHOWVALID, 451 NHKF_GETPOS_AUTODESC, 452 NHKF_GETPOS_MON_NEXT, 453 NHKF_GETPOS_MON_PREV, 454 NHKF_GETPOS_OBJ_NEXT, 455 NHKF_GETPOS_OBJ_PREV, 456 NHKF_GETPOS_DOOR_NEXT, 457 NHKF_GETPOS_DOOR_PREV, 458 NHKF_GETPOS_UNEX_NEXT, 459 NHKF_GETPOS_UNEX_PREV, 460 NHKF_GETPOS_INTERESTING_NEXT, 461 NHKF_GETPOS_INTERESTING_PREV, 462 NHKF_GETPOS_VALID_NEXT, 463 NHKF_GETPOS_VALID_PREV, 464 NHKF_GETPOS_HELP, 465 NHKF_GETPOS_MENU, 466 NHKF_GETPOS_LIMITVIEW, 467 NHKF_GETPOS_MOVESKIP, 468 469 NUM_NHKF 470 }; 471 472 /* commands[] is used to directly access cmdlist[] instead of looping 473 through it to find the entry for a given input character; 474 move_X is the character used for moving one step in direction X; 475 alphadirchars corresponds to old sdir, 476 dirchars corresponds to ``iflags.num_pad ? ndir : sdir''; 477 pcHack_compat and phone_layout only matter when num_pad is on, 478 swap_yz only matters when it's off */ 479 struct cmd { 480 unsigned serialno; /* incremented after each update */ 481 boolean num_pad; /* same as iflags.num_pad except during updates */ 482 boolean pcHack_compat; /* for numpad: affects 5, M-5, and M-0 */ 483 boolean phone_layout; /* inverted keypad: 1,2,3 above, 7,8,9 below */ 484 boolean swap_yz; /* QWERTZ keyboards; use z to move NW, y to zap */ 485 char move_W, move_NW, move_N, move_NE, move_E, move_SE, move_S, move_SW; 486 const char *dirchars; /* current movement/direction characters */ 487 const char *alphadirchars; /* same as dirchars if !numpad */ 488 const struct ext_func_tab *commands[256]; /* indexed by input character */ 489 char spkeys[NUM_NHKF]; 490 }; 491 492 493 #define ENTITIES 2 494 495 struct entity { 496 struct monst *emon; /* youmonst for the player */ 497 struct permonst *edata; /* must be non-zero for record to be valid */ 498 int ex, ey; 499 }; 500 501 /* these probably ought to be generated by makedefs, like LAST_GEM */ 502 #define FIRST_GEM DILITHIUM_CRYSTAL 503 #define FIRST_AMULET AMULET_OF_ESP 504 #define LAST_AMULET AMULET_OF_YENDOR 505 506 struct valuable_data { 507 long count; 508 int typ; 509 }; 510 511 struct val_list { 512 struct valuable_data *list; 513 int size; 514 }; 515 516 /* at most one of `door' and `box' should be non-null at any given time */ 517 struct xlock_s { 518 struct rm *door; 519 struct obj *box; 520 int picktyp, /* key|pick|card for unlock, sharp vs blunt for #force */ 521 chance, usedtime; 522 boolean magic_key; 523 }; 524 525 struct trapinfo { 526 struct obj *tobj; 527 xchar tx, ty; 528 int time_needed; 529 boolean force_bungle; 530 }; 531 532 typedef struct { 533 xchar gnew; /* perhaps move this bit into the rm structure. */ 534 int glyph; 535 #ifndef UNBUFFERED_GLYPHINFO 536 glyph_info glyphinfo; 537 #endif 538 } gbuf_entry; 539 540 enum vanq_order_modes { 541 VANQ_MLVL_MNDX = 0, 542 VANQ_MSTR_MNDX, 543 VANQ_ALPHA_SEP, 544 VANQ_ALPHA_MIX, 545 VANQ_MCLS_HTOL, 546 VANQ_MCLS_LTOH, 547 VANQ_COUNT_H_L, 548 VANQ_COUNT_L_H, 549 550 NUM_VANQ_ORDER_MODES 551 }; 552 553 struct rogueroom { 554 xchar rlx, rly; 555 xchar dx, dy; 556 boolean real; 557 uchar doortable; 558 int nroom; /* Only meaningful for "real" rooms */ 559 }; 560 561 typedef struct ls_t { 562 struct ls_t *next; 563 xchar x, y; /* source's position */ 564 short range; /* source's current range */ 565 short flags; 566 short type; /* type of light source */ 567 anything id; /* source's identifier */ 568 } light_source; 569 570 struct container { 571 struct container *next; 572 xchar x, y; 573 short what; 574 genericptr_t list; 575 }; 576 577 enum bubble_contains_types { 578 CONS_OBJ = 0, 579 CONS_MON, 580 CONS_HERO, 581 CONS_TRAP 582 }; 583 584 #define MAX_BMASK 4 585 586 struct bubble { 587 xchar x, y; /* coordinates of the upper left corner */ 588 schar dx, dy; /* the general direction of the bubble's movement */ 589 uchar bm[MAX_BMASK + 2]; /* bubble bit mask */ 590 struct bubble *prev, *next; /* need to traverse the list up and down */ 591 struct container *cons; 592 }; 593 594 struct musable { 595 struct obj *offensive; 596 struct obj *defensive; 597 struct obj *misc; 598 int has_offense, has_defense, has_misc; 599 /* =0, no capability; otherwise, different numbers. 600 * If it's an object, the object is also set (it's 0 otherwise). 601 */ 602 }; 603 604 struct h2o_ctx { 605 int dkn_boom, unk_boom; /* track dknown, !dknown separately */ 606 boolean ctx_valid; 607 }; 608 609 struct launchplace { 610 struct obj *obj; 611 xchar x, y; 612 }; 613 614 struct repo { /* repossession context */ 615 struct monst *shopkeeper; 616 coord location; 617 }; 618 619 /* from options.c */ 620 #define MAX_MENU_MAPPED_CMDS 32 /* some number */ 621 622 /* player selection constants */ 623 #define BP_ALIGN 0 624 #define BP_GEND 1 625 #define BP_RACE 2 626 #define BP_ROLE 3 627 #define NUM_BP 4 628 629 #define NUM_ROLES (13) 630 #define NUM_RACES (5) 631 struct role_filter { 632 boolean roles[NUM_ROLES+1]; 633 short mask; 634 }; 635 636 /* read.c, create_particular() & create_particular_parse() */ 637 struct _create_particular_data { 638 int quan; 639 int which; 640 int fem; /* -1, MALE, FEMALE, NEUTRAL */ 641 int genderconf; /* conflicting gender */ 642 char monclass; 643 boolean randmonst; 644 boolean maketame, makepeaceful, makehostile; 645 boolean sleeping, saddled, invisible, hidden; 646 }; 647 648 /* some array sizes for 'g' */ 649 #define BSIZE 20 650 #define WIZKIT_MAX 128 651 #define CVT_BUF_SIZE 64 652 653 #define LUA_VER_BUFSIZ 20 654 #define LUA_COPYRIGHT_BUFSIZ 120 655 656 /* 657 * 'g' -- instance_globals holds engine state that does not need to be 658 * persisted upon game exit. The initialization state is well defined 659 * and set in decl.c during early early engine initialization. 660 * 661 * Unlike instance_flags, values in the structure can be of any type. 662 * 663 * Pulled from other files to be grouped in one place. Some comments 664 * which came with them don't make much sense out of their original context. 665 */ 666 struct instance_globals { 667 668 /* apply.c */ 669 int jumping_is_magic; /* current jump result of magic */ 670 int polearm_range_min; 671 int polearm_range_max; 672 struct trapinfo trapinfo; 673 674 /* artifcat.c */ 675 int spec_dbon_applies; /* coordinate effects from spec_dbon() with 676 messages in artifact_hit() */ 677 /* flags including which artifacts have already been created */ 678 boolean artiexist[1 + NROFARTIFACTS + 1]; 679 /* and a discovery list for them (no dummy first entry here) */ 680 xchar artidisco[NROFARTIFACTS]; 681 int mkot_trap_warn_count; 682 683 /* botl.c */ 684 int mrank_sz; /* loaded by max_rank_sz */ 685 struct istat_s blstats[2][MAXBLSTATS]; 686 boolean blinit; 687 boolean update_all; 688 boolean valset[MAXBLSTATS]; 689 #ifdef STATUS_HILITES 690 long bl_hilite_moves; 691 #endif 692 unsigned long cond_hilites[BL_ATTCLR_MAX]; 693 int now_or_before_idx; /* 0..1 for array[2][] first index */ 694 int condmenu_sortorder; 695 696 /* cmd.c */ 697 struct cmd Cmd; /* flag.h */ 698 /* Provide a means to redo the last command. The flag `in_doagain' 699 (decl.c below) is set to true while redoing the command. This flag 700 is tested in commands that require additional input (like `throw' 701 which requires a thing and a direction), and the input prompt is 702 not shown. Also, while in_doagain is TRUE, no keystrokes can be 703 saved into the saveq. */ 704 char pushq[BSIZE]; 705 char saveq[BSIZE]; 706 int phead; 707 int ptail; 708 int shead; 709 int stail; 710 coord clicklook_cc; 711 winid en_win; 712 boolean en_via_menu; 713 long last_command_count; 714 715 /* dbridge.c */ 716 struct entity occupants[ENTITIES]; 717 718 /* decl.c */ 719 int (*occupation)(void); 720 int (*afternmv)(void); 721 const char *hname; /* name of the game (argv[0] of main) */ 722 int hackpid; /* current process id */ 723 char chosen_windowtype[WINTYPELEN]; 724 int bases[MAXOCLASSES + 1]; 725 int multi; 726 char command_line[COLNO]; 727 long command_count; 728 const char *multi_reason; 729 char multireasonbuf[QBUFSZ]; /* note: smaller than usual [BUFSZ] */ 730 int nroom; 731 int nsubroom; 732 int occtime; 733 int warn_obj_cnt; /* count of monsters meeting criteria */ 734 int x_maze_max; 735 int y_maze_max; 736 int otg_temp; /* used by object_to_glyph() [otg] */ 737 int in_doagain; 738 stairway *stairs; 739 /* smeq - stores room numbers for the purposes of determining which rooms have 740 * been connected yet, and which haven't. 741 * Not sure why this isn't just stored in struct mkroom directly. */ 742 int smeq[MAXNROFROOMS + 1]; 743 int doorindex; 744 char *save_cm; 745 long done_money; 746 long domove_attempting; 747 long domove_succeeded; 748 #define DOMOVE_WALK 0x00000001 749 #define DOMOVE_RUSH 0x00000002 750 const char *nomovemsg; 751 char plname[PL_NSIZ]; /* player name */ 752 int plnamelen; /* length of plname[] if that came from getlogin() */ 753 char pl_character[PL_CSIZ]; 754 char pl_race; /* character's race */ 755 char pl_fruit[PL_FSIZ]; 756 struct fruit *ffruit; 757 char tune[6]; 758 const char *occtxt; /* defined when occupation != NULL */ 759 schar tbx; /* mthrowu: target x */ 760 schar tby; /* mthrowu: target y */ 761 s_level * sp_levchn; 762 /* for xname handling of multiple shot missile volleys: 763 number of shots, index of current one, validity check, shoot vs throw */ 764 struct multishot m_shot; 765 dungeon dungeons[MAXDUNGEON]; /* ini'ed by init_dungeon() */ 766 dest_area updest; 767 dest_area dndest; 768 coord inv_pos; 769 boolean defer_see_monsters; 770 boolean in_mklev; 771 boolean stoned; /* done to monsters hit by 'c' */ 772 boolean unweapon; 773 boolean mrg_to_wielded; /* weapon picked is merged with wielded one */ 774 struct plinemsg_type *plinemsg_types; 775 char toplines[TBUFSZ]; 776 coord bhitpos; /* place where throw or zap hits or stops */ 777 boolean in_steed_dismounting; 778 /* Holds the coordinates of all doors on the level. 779 * mkroom structs each have a fdoor which is their first door in this array. 780 */ 781 coord doors[DOORMAX]; 782 struct menucoloring *menu_colorings; 783 schar lastseentyp[COLNO][ROWNO]; /* last seen/touched dungeon typ */ 784 struct spell spl_book[MAXSPELL + 1]; 785 struct linfo level_info[MAXLINFO]; 786 struct trap *ftrap; 787 /* some objects need special handling during destruction or placement */ 788 struct obj *current_wand; /* wand currently zapped/applied */ 789 struct obj *thrownobj; /* object in flight due to throwing */ 790 struct obj *kickedobj; /* object in flight due to kicking */ 791 struct dgn_topology dungeon_topology; 792 struct kinfo killer; 793 struct mkroom rooms[(MAXNROFROOMS + 1) * 2]; 794 struct mkroom *subrooms; 795 dlevel_t level; /* level map */ 796 long moves; 797 long monstermoves; /* moves and monstermoves diverge when player is Fast */ 798 long wailmsg; 799 struct obj *migrating_objs; /* objects moving to another dungeon level */ 800 struct obj *billobjs; /* objects not yet paid for */ 801 #if defined(MICRO) || defined(WIN32) 802 char hackdir[PATHLEN]; /* where rumors, help, record are */ 803 #endif /* MICRO || WIN32 */ 804 struct monst youmonst; 805 struct obj *invent; 806 struct context_info context; 807 char *fqn_prefix[PREFIX_COUNT]; 808 /* Windowing stuff that's really tty oriented, but present for all ports */ 809 struct tc_gbl_data tc_gbl_data; /* AS,AE, LI,CO */ 810 #if defined(UNIX) || defined(VMS) 811 int locknum; /* max num of simultaneous users */ 812 #endif 813 #ifdef DEF_PAGER 814 char *catmore; /* default pager */ 815 #endif 816 #ifdef MICRO 817 char levels[PATHLEN]; /* where levels are */ 818 #endif /* MICRO */ 819 struct sinfo program_state; 820 821 /* detect.c */ 822 823 int already_found_flag; /* used to augment first "already found a monster" 824 * message if 'cmdassist' is Off */ 825 /* dig.c */ 826 827 boolean did_dig_msg; 828 829 /* display.c */ 830 gbuf_entry gbuf[ROWNO][COLNO]; 831 xchar gbuf_start[ROWNO]; 832 xchar gbuf_stop[ROWNO]; 833 uchar monstercolors[NUMMONS]; 834 835 /* do.c */ 836 boolean at_ladder; 837 char *dfr_pre_msg; /* pline() before level change */ 838 char *dfr_post_msg; /* pline() after level change */ 839 int did_nothing_flag; /* to augment the no-rest-next-to-monster message */ 840 d_level save_dlevel; /* ? [even back in 3.4.3, only used in bones.c] */ 841 842 /* do_name.c */ 843 struct selectionvar *gloc_filter_map; 844 int gloc_filter_floodfill_match_glyph; 845 int via_naming; 846 847 /* do_wear.c */ 848 /* starting equipment gets auto-worn at beginning of new game, 849 and we don't want stealth or displacement feedback then */ 850 boolean initial_don; /* manipulated in set_wear() */ 851 852 /* dog.c */ 853 int petname_used; /* user preferred pet name has been used */ 854 xchar gtyp; /* type of dog's current goal */ 855 xchar gx; /* x position of dog's current goal */ 856 xchar gy; /* y position of dog's current goal */ 857 char dogname[PL_PSIZ]; 858 char catname[PL_PSIZ]; 859 char horsename[PL_PSIZ]; 860 char preferred_pet; /* '\0', 'c', 'd', 'n' (none) */ 861 struct monst *mydogs; /* monsters that went down/up together with @ */ 862 struct monst *migrating_mons; /* monsters moving to another level */ 863 struct autopickup_exception *apelist; 864 struct mvitals mvitals[NUMMONS]; 865 866 /* dokick.c */ 867 struct rm *maploc; 868 struct rm nowhere; 869 const char *gate_str; 870 871 /* drawing */ 872 struct symsetentry symset[NUM_GRAPHICS]; 873 int currentgraphics; 874 nhsym showsyms[SYM_MAX]; /* symbols to be displayed */ 875 nhsym primary_syms[SYM_MAX]; /* loaded primary symbols */ 876 nhsym ov_primary_syms[SYM_MAX]; /* loaded primary symbols */ 877 nhsym warnsyms[WARNCOUNT]; /* the current warning display symbols */ 878 879 /* dungeon.c */ 880 int n_dgns; /* number of dungeons (also used in mklev.c and do.c) */ 881 branch *branches; /* dungeon branch list */ 882 mapseen *mapseenchn; /*DUNGEON_OVERVIEW*/ 883 884 /* eat.c */ 885 boolean force_save_hs; 886 char *eatmbuf; /* set by cpostfx() */ 887 888 889 /* end.c */ 890 struct valuable_data gems[LAST_GEM + 1 - FIRST_GEM + 1]; /* +1 for glass */ 891 struct valuable_data amulets[LAST_AMULET + 1 - FIRST_AMULET]; 892 struct val_list valuables[3]; 893 int vanq_sortmode; 894 895 /* files.c */ 896 char wizkit[WIZKIT_MAX]; 897 int lockptr; 898 char *config_section_chosen; 899 char *config_section_current; 900 int nesting; 901 int symset_count; /* for pick-list building only */ 902 boolean chosen_symset_start; 903 boolean chosen_symset_end; 904 int symset_which_set; 905 /* SAVESIZE, BONESSIZE, LOCKNAMESIZE are defined in "fnamesiz.h" */ 906 char SAVEF[SAVESIZE]; /* relative path of save file from playground */ 907 #ifdef MICRO 908 char SAVEP[SAVESIZE]; /* holds path of directory for save file */ 909 #endif 910 char bones[BONESSIZE]; 911 char lock[LOCKNAMESIZE]; 912 913 /* hack.c */ 914 anything tmp_anything; 915 int wc; /* current weight_cap(); valid after call to inv_weight() */ 916 917 /* insight.c */ 918 919 /* invent.c */ 920 int lastinvnr; /* 0 ... 51 (never saved&restored) */ 921 unsigned sortlootmode; /* set by sortloot() for use by sortloot_cmp(); 922 * reset by sortloot when done */ 923 char *invbuf; 924 unsigned invbufsiz; 925 /* for perm_invent when operating on a partial inventory display, so that 926 persistent one doesn't get shrunk during filtering for item selection 927 then regrown to full inventory, possibly being resized in the process */ 928 winid cached_pickinv_win; 929 /* query objlist callback: return TRUE if obj type matches "this_type" */ 930 int this_type; 931 /* query objlist callback: return TRUE if obj is at given location */ 932 coord only; 933 934 /* light.c */ 935 light_source *light_base; 936 937 /* lock.c */ 938 struct xlock_s xlock; 939 940 /* makemon.c */ 941 942 /* mhitm.c */ 943 long noisetime; 944 boolean far_noise; 945 boolean vis; 946 boolean skipdrin; /* mind flayer against headless target */ 947 948 /* mhitu.c */ 949 int mhitu_dieroll; 950 951 /* mklev.c */ 952 genericptr_t luathemes[MAXDUNGEON]; 953 xchar vault_x; 954 xchar vault_y; 955 boolean made_branch; /* used only during level creation */ 956 957 /* mkmap.c */ 958 char *new_locations; 959 int min_rx; /* rectangle bounds for regions */ 960 int max_rx; 961 int min_ry; 962 int max_ry; 963 int n_loc_filled; 964 965 /* mkmaze.c */ 966 lev_region bughack; /* for preserving the insect legs when wallifying 967 * baalz level */ 968 boolean was_waterlevel; /* ugh... this shouldn't be needed */ 969 struct bubble *bbubbles; 970 struct bubble *ebubbles; 971 struct trap *wportal; 972 int xmin, ymin, xmax, ymax; /* level boundaries */ 973 boolean ransacked; 974 975 /* mkobj.c */ 976 boolean mkcorpstat_norevive; /* for trolls */ 977 978 /* mon.c */ 979 boolean vamp_rise_msg; 980 boolean disintegested; 981 xchar zombify; 982 short *animal_list; /* list of PM values for animal monsters */ 983 int animal_list_count; 984 985 /* mthrowu.c */ 986 int mesg_given; /* for m_throw()/thitu() 'miss' message */ 987 struct monst *mtarget; /* monster being shot by another monster */ 988 struct monst *marcher; /* monster that is shooting */ 989 990 /* muse.c */ 991 boolean m_using; /* kludge to use mondided instead of killed */ 992 int trapx; 993 int trapy; 994 boolean zap_oseen; /* for wands which use mbhitm and are zapped at 995 * players. We usually want an oseen local to 996 * the function, but this is impossible since the 997 * function mbhitm has to be compatible with the 998 * normal zap routines, and those routines don't 999 * remember who zapped the wand. */ 1000 struct musable m; 1001 1002 /* nhlan.c */ 1003 #ifdef MAX_LAN_USERNAME 1004 char lusername[MAX_LAN_USERNAME]; 1005 int lusername_size; 1006 #endif 1007 1008 /* o_init.c */ 1009 short disco[NUM_OBJECTS]; 1010 1011 /* objname.c */ 1012 /* distantname used by distant_name() to pass extra information to 1013 xname_flags(); it would be much cleaner if this were a parameter, 1014 but that would require all xname() and doname() calls to be modified */ 1015 int distantname; 1016 1017 /* options.c */ 1018 struct symsetentry *symset_list; /* files.c will populate this with 1019 * list of available sets */ 1020 /* Allow the user to map incoming characters to various menu commands. */ 1021 char mapped_menu_cmds[MAX_MENU_MAPPED_CMDS + 1]; /* exported */ 1022 char mapped_menu_op[MAX_MENU_MAPPED_CMDS + 1]; 1023 short n_menu_mapped; 1024 /* options processing */ 1025 boolean opt_initial; 1026 boolean opt_from_file; 1027 boolean opt_need_redraw; /* for doset() */ 1028 /* use menucolors to show colors in the pick-a-color menu */ 1029 boolean save_menucolors; /* copy of iflags.use_menu_colors */ 1030 struct menucoloring *save_colorings; /* copy of g.menu_colorings */ 1031 struct menucoloring *color_colorings; /* alternate set of menu colors */ 1032 1033 /* pickup.c */ 1034 int oldcap; /* last encumberance */ 1035 /* current_container is set in use_container(), to be used by the 1036 callback routines in_container() and out_container() from askchain() 1037 and use_container(). Also used by menu_loot() and container_gone(). */ 1038 struct obj *current_container; 1039 boolean abort_looting; 1040 /* Value set by query_objlist() for n_or_more(). */ 1041 long val_for_n_or_more; 1042 /* list of menu classes for query_objlist() and allow_category callback 1043 (with room for all object classes, 'u'npaid, BUCX, and terminator) */ 1044 char valid_menu_classes[MAXOCLASSES + 1 + 4 + 1]; 1045 boolean class_filter; 1046 boolean bucx_filter; 1047 boolean shop_filter; 1048 1049 /* pline.c */ 1050 unsigned pline_flags; 1051 char prevmsg[BUFSZ]; 1052 #ifdef DUMPLOG 1053 unsigned saved_pline_index; /* slot in saved_plines[] to use next */ 1054 char *saved_plines[DUMPLOG_MSG_COUNT]; 1055 #endif 1056 /* work buffer for You(), &c and verbalize() */ 1057 char *you_buf; 1058 int you_buf_siz; 1059 1060 /* polyself.c */ 1061 int sex_change_ok; /* controls whether taking on new form or becoming new 1062 man can also change sex (ought to be an arg to 1063 polymon() and newman() instead) */ 1064 1065 /* potion.c */ 1066 boolean notonhead; /* for long worms */ 1067 int potion_nothing; 1068 int potion_unkn; 1069 1070 /* pray.c */ 1071 /* values calculated when prayer starts, and used when completed */ 1072 aligntyp p_aligntyp; 1073 int p_trouble; 1074 int p_type; /* (-1)-3: (-1)=really naughty, 3=really good */ 1075 1076 /* quest.c */ 1077 struct q_score quest_status; 1078 1079 /* questpgr.c */ 1080 char cvt_buf[CVT_BUF_SIZE]; 1081 /* used by ldrname() and neminame(), then copied into cvt_buf */ 1082 char nambuf[CVT_BUF_SIZE]; 1083 1084 /* read.c */ 1085 boolean known; 1086 1087 /* region.c */ 1088 NhRegion **regions; 1089 int n_regions; 1090 int max_regions; 1091 1092 /* restore.c */ 1093 int n_ids_mapped; 1094 struct bucket *id_map; 1095 boolean restoring; 1096 struct fruit *oldfruit; 1097 long omoves; 1098 1099 /* rip.c */ 1100 char **rip; 1101 1102 /* role.c */ 1103 struct Role urole; /* player's role. May be munged in role_init() */ 1104 struct Race urace; /* player's race. May be munged in role_init() */ 1105 char role_pa[NUM_BP]; 1106 char role_post_attribs; 1107 struct role_filter rfilter; 1108 1109 /* rumors.c */ 1110 long true_rumor_size; /* rumor size variables are signed so that value -1 1111 can be used as a flag */ 1112 long false_rumor_size; 1113 unsigned long true_rumor_start; /* rumor start offsets are unsigned because 1114 they're handled via %lx format */ 1115 unsigned long false_rumor_start; 1116 long true_rumor_end; /* rumor end offsets are signed because they're 1117 compared with [dlb_]ftell() */ 1118 long false_rumor_end; 1119 int oracle_flg; /* -1=>don't use, 0=>need init, 1=>init done */ 1120 unsigned oracle_cnt; /* oracles are handled differently from rumors... */ 1121 unsigned long *oracle_loc; 1122 1123 /* save.c */ 1124 boolean havestate; 1125 unsigned ustuck_id; /* need to preserve during save */ 1126 unsigned usteed_id; /* need to preserve during save */ 1127 struct obj *looseball; /* track uball during save and... */ 1128 struct obj *loosechain; /* track uchain since saving might free it */ 1129 1130 /* shk.c */ 1131 /* auto-response flag for/from "sell foo?" 'a' => 'y', 'q' => 'n' */ 1132 char sell_response; 1133 int sell_how; 1134 /* can't just use sell_response='y' for auto_credit because 'a' response 1135 shouldn't carry over from ordinary selling to credit selling */ 1136 boolean auto_credit; 1137 struct repo repo; 1138 long int followmsg; /* last time of follow message */ 1139 1140 /* sp_lev.c */ 1141 char *lev_message; 1142 lev_region *lregions; 1143 int num_lregions; 1144 struct sp_coder *coder; 1145 xchar xstart, ystart; 1146 xchar xsize, ysize; 1147 boolean in_mk_themerooms; 1148 boolean themeroom_failed; 1149 1150 /* spells.c */ 1151 int spl_sortmode; /* index into spl_sortchoices[] */ 1152 int *spl_orderindx; /* array of g.spl_book[] indices */ 1153 1154 /* steal.c */ 1155 unsigned int stealoid; /* object to be stolen */ 1156 unsigned int stealmid; /* monster doing the stealing */ 1157 1158 /* teleport.c */ 1159 1160 /* timeout.c */ 1161 /* ordered timer list */ 1162 struct fe *timer_base; /* "active" */ 1163 unsigned long timer_id; 1164 1165 /* topten.c */ 1166 winid toptenwin; 1167 1168 /* trap.c */ 1169 int force_mintrap; /* mintrap() should take a flags argument, but for time 1170 being we use this */ 1171 /* context for water_damage(), managed by water_damage_chain(); 1172 when more than one stack of potions of acid explode while processing 1173 a chain of objects, use alternate phrasing after the first message */ 1174 struct h2o_ctx acid_ctx; 1175 /* 1176 * The following are used to track launched objects to 1177 * prevent them from vanishing if you are killed. They 1178 * will reappear at the launchplace in bones files. 1179 */ 1180 struct launchplace launchplace; 1181 1182 1183 /* u_init.c */ 1184 short nocreate; 1185 short nocreate2; 1186 short nocreate3; 1187 short nocreate4; 1188 /* uhitm.c */ 1189 boolean override_confirmation; /* Used to flag attacks caused by 1190 Stormbringer's maliciousness. */ 1191 1192 /* vision.c */ 1193 xchar **viz_array; /* used in cansee() and couldsee() macros */ 1194 xchar *viz_rmin; /* min could see indices */ 1195 xchar *viz_rmax; /* max could see indices */ 1196 boolean vision_full_recalc; 1197 1198 /* weapon.c */ 1199 struct obj *propellor; 1200 1201 /* windows.c */ 1202 struct win_choices *last_winchoice; 1203 1204 /* zap.c */ 1205 int poly_zapped; 1206 boolean obj_zapped; 1207 1208 /* new stuff */ 1209 char lua_ver[LUA_VER_BUFSIZ]; 1210 char lua_copyright[LUA_COPYRIGHT_BUFSIZ]; 1211 1212 /* per-level glyph mapping flags */ 1213 long glyphmap_perlevel_flags; 1214 1215 unsigned long magic; /* validate that structure layout is preserved */ 1216 }; 1217 1218 E struct instance_globals g; 1219 1220 struct const_globals { 1221 const struct obj zeroobj; /* used to zero out a struct obj */ 1222 const struct monst zeromonst; /* used to zero out a struct monst */ 1223 const anything zeroany; /* used to zero out union any */ 1224 }; 1225 1226 E const struct const_globals cg; 1227 1228 E const glyph_info nul_glyphinfo; 1229 1230 #undef E 1231 1232 #endif /* DECL_H */ 1233 1234 1235