1 2 /* File: variable.c */ 3 4 /* Purpose: Angband variables */ 5 6 /* 7 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke 8 * 9 * This software may be copied and distributed for educational, research, and 10 * not for profit purposes provided that this copyright and statement are 11 * included in all such copies. 12 */ 13 14 #include "mangband.h" 15 16 17 /* 18 * Hack -- Link a copyright message into the executable 19 */ 20 cptr copyright[6] = 21 { 22 "Copyright (c) 1989 James E. Wilson, Robert A. Keoneke", 23 "also Copyright (c) 1997 Keldon L. Jones", 24 "", 25 "This software may be copied and distributed for educational, research,", 26 "and not for profit purposes provided that this copyright and statement", 27 "are included in all such copies." 28 }; 29 30 31 /* 32 * Hack -- Link the "version" into the executable 33 */ 34 byte version_major = SERVER_VERSION_MAJOR; 35 byte version_minor = SERVER_VERSION_MINOR; 36 byte version_patch = SERVER_VERSION_PATCH; 37 byte version_extra = SERVER_VERSION_EXTRA; 38 39 40 u16b shutdown_timer; /* Shutdown server in (seconds) */ 41 42 /* 43 * Hack -- Savefile information 44 */ 45 u32b sf_xtra; /* Operating system info */ 46 u32b sf_when; /* Time when savefile created */ 47 u16b sf_lives; /* Number of past "lives" with this file */ 48 u16b sf_saves; /* Number of "saves" during this life */ 49 50 /* 51 * Hack -- Run-time arguments 52 */ 53 cptr arg_config_file = NULL; /* Command arg -- Desired config file */ 54 bool arg_wizard; /* Command arg -- Enter wizard mode */ 55 bool arg_fiddle; /* Command arg -- Enter fiddle mode */ 56 bool arg_force_original; /* Command arg -- Force original keyset */ 57 bool arg_force_roguelike; /* Command arg -- Force roguelike keyset */ 58 59 bool server_generated; /* The character exists */ 60 bool server_dungeon; /* The character has a dungeon */ 61 bool server_state_loaded; /* The server state was loaded from a savefile */ 62 bool server_saved; /* The character was just saved to a savefile */ 63 64 bool character_loaded; /* The character was loaded from a savefile */ 65 bool character_died; /* The character in the savefile was dead */ 66 bool character_xtra; /* The game is in an icky startup mode */ 67 68 u32b seed_flavor; /* Hack -- consistent object colors */ 69 u32b seed_town; /* Hack -- consistent town layout */ 70 71 /*s16b command_cmd;*/ /* Current "Angband Command" */ 72 73 /*s16b command_arg;*/ /* Gives argument of current command */ 74 /*s16b command_rep;*/ /* Gives repetition of current command */ 75 /*s16b command_dir;*/ /* Gives direction of current command */ 76 77 /*s16b command_see;*/ /* See "cmd1.c" */ 78 /*s16b command_wrk;*/ /* See "cmd1.c" */ 79 /*s16b command_gap = 50;*/ /* See "cmd1.c" */ 80 81 /*s16b command_new;*/ /* Command chaining from inven/equip view */ 82 83 bool create_up_stair; /* Auto-create "up stairs" */ 84 bool create_down_stair; /* Auto-create "down stairs" */ 85 86 bool msg_flag; /* Used in msg_print() for "buffering" */ 87 88 /*bool alive;*/ /* True if game is running */ 89 /*bool death;*/ /* True if player has died */ 90 91 /*s16b running;*/ /* Current counter for running, if any */ 92 /*s16b resting;*/ /* Current counter for resting, if any */ 93 94 /*s16b cur_hgt; */ /* Current dungeon height */ 95 /*s16b cur_wid; */ /* Current dungeon width */ 96 /*s16b dun_level; */ /* Current dungeon level */ 97 s16b num_repro; /* Current reproducer count */ 98 s16b object_level; /* Current object creation level */ 99 s16b monster_level; /* Current monster creation level */ 100 101 byte trees_in_town; 102 103 byte level_up_y[MAX_DEPTH]; /* Where do players start if coming up? */ 104 byte level_up_x[MAX_DEPTH]; 105 byte level_down_y[MAX_DEPTH]; /* Where do players start if going down? */ 106 byte level_down_x[MAX_DEPTH]; 107 byte level_rand_y[MAX_DEPTH]; /* Where do players start if they tele level? */ 108 byte level_rand_x[MAX_DEPTH]; 109 110 s16b players_on_world[MAX_DEPTH + MAX_WILD]; 111 s16b *players_on_depth=&(players_on_world[MAX_WILD]); /* How many players are at each depth */ 112 113 s16b special_levels[MAX_SPECIAL_LEVELS]; /* List of depths which are special static levels */ 114 115 char summon_kin_type; /* Hack -- See summon_specific() */ 116 117 hturn turn; /* Current game turn */ 118 hturn turn_compact; /* Last time m_list and o_list were compacted */ 119 /*hturn old_turn;*/ /* Turn when level began (feelings) */ 120 121 s32b player_id; /* Current player ID */ 122 123 /*bool wizard;*/ /* Is the player currently in Wizard mode? */ 124 /*bool can_be_wizard;*/ /* Does the player have wizard permissions? */ 125 126 /*u16b total_winner;*/ /* Semi-Hack -- Game has been won */ 127 128 u16b panic_save; /* Track some special "conditions" */ 129 u16b noscore; /* Track various "cheating" conditions */ 130 131 s16b signal_count = 0; /* Hack -- Count interupts */ 132 133 #if 0 /* moved to client */ 134 bool inkey_base; /* See the "inkey()" function */ 135 bool inkey_xtra; /* See the "inkey()" function */ 136 bool inkey_scan; /* See the "inkey()" function */ 137 bool inkey_flag; /* See the "inkey()" function */ 138 #endif 139 140 s16b coin_type; /* Hack -- force coin type */ 141 142 bool opening_chest; /* Hack -- prevent chest generation */ 143 144 int use_graphics; /* Hack -- Assume no graphics mapping */ 145 146 bool use_sound; /* Hack -- Assume no special sounds */ 147 148 bool scan_monsters; /* Hack -- optimize multi-hued code, etc */ 149 bool scan_objects; /* Hack -- optimize multi-hued code, etc */ 150 151 /*s16b total_weight;*/ /* Total weight being carried */ 152 153 /*s16b inven_nxt;*/ /* Hack -- unused */ 154 155 /*s16b inven_cnt;*/ /* Number of items in inventory */ 156 /*s16b equip_cnt;*/ /* Number of items in equipment */ 157 158 s32b o_nxt = 1; /* Object free scanner */ 159 s32b m_nxt = 1; /* Monster free scanner */ 160 161 s32b o_max = 1; /* Object heap size */ 162 s32b m_max = 1; /* Monster heap size */ 163 164 s32b o_top = 0; /* Object top size */ 165 s32b m_top = 0; /* Monster top size */ 166 167 s32b p_max = 0; /* Player heap size */ 168 169 /* 170 * Server options, set in mangband.cfg 171 */ 172 173 bool cfg_report_to_meta = 0; 174 char * cfg_meta_address = NULL; 175 char * cfg_report_address = NULL; 176 char * cfg_bind_name = NULL; 177 char * cfg_console_password = NULL; 178 bool cfg_console_local_only = FALSE; 179 char * cfg_dungeon_master = NULL; 180 char * cfg_load_pref_file = NULL; 181 bool cfg_secret_dungeon_master = 0; 182 s16b cfg_fps = 12; 183 s32b cfg_tcp_port = 18346; 184 bool cfg_safe_recharge = FALSE; 185 bool cfg_no_steal = 0; 186 bool cfg_newbies_cannot_drop = 0; 187 bool cfg_ghost_diving = 0; 188 s32b cfg_level_unstatic_chance = 60; 189 bool cfg_random_artifacts = 0; /* No randarts by default */ 190 s16b cfg_preserve_artifacts = 3; 191 s32b cfg_retire_timer = -1; 192 bool cfg_ironman = 0; 193 bool cfg_more_towns = 0; 194 bool cfg_town_wall = 0; 195 s32b cfg_unique_respawn_time = 300; 196 s32b cfg_unique_max_respawn_time = 50000; 197 s16b cfg_max_townies = 100; 198 s16b cfg_max_trees = 100; 199 s16b cfg_max_houses = 0; 200 bool cfg_chardump_color = FALSE; 201 s16b cfg_pvp_hostility = 2; 202 bool cfg_pvp_notify = FALSE; 203 s16b cfg_pvp_safehostility = 3; 204 s16b cfg_pvp_safedepth = -1; 205 s16b cfg_pvp_saferadius = -1; 206 s16b cfg_pvp_safelevel = -1; 207 bool cfg_party_share_exp = TRUE; 208 bool cfg_party_share_quest = FALSE; 209 bool cfg_party_share_kill = FALSE; 210 bool cfg_party_share_win = TRUE; 211 s16b cfg_party_sharelevel = -1; 212 bool cfg_instance_closed = FALSE; 213 214 215 216 217 bool dungeon_align; /* Most recent align request */ 218 s16b feeling; /* Most recent feeling */ 219 s16b rating; /* Level's current rating */ 220 221 bool good_item_flag; /* True if "Artifact" on this level */ 222 223 /*bool new_level_flag;*/ /* Start a new level */ 224 225 /*bool closing_flag;*/ /* Dungeon is closing */ 226 227 228 /* Dungeon size info */ 229 /*s16b max_panel_rows, max_panel_cols; 230 s16b panel_row, panel_col; 231 s16b panel_row_min, panel_row_max; 232 s16b panel_col_min, panel_col_max;*/ 233 /*s16b panel_col_prt, panel_row_prt;*/ 234 235 /* Player location in dungeon */ 236 /* This is now put in the player info --KLJ-- */ 237 /*s16b py; 238 s16b px;*/ 239 240 /* Targetting variables */ 241 /* ... in player info */ 242 /*s32b target_who; 243 s16b target_col; 244 s16b target_row;*/ 245 246 /* Health bar variable -DRS- */ 247 /*s16b health_who;*/ 248 249 /* Monster recall race */ 250 /*s16b recent_idx;*/ 251 252 253 254 /* Collection of connections/players */ 255 element_group* players = NULL; 256 257 /* User info in z-file.c 258 int player_uid = 0; 259 int player_euid = 0; 260 int player_egid = 0; 261 */ 262 263 /* The array of players */ 264 player_type **Players; 265 266 /* The party information */ 267 party_type parties[MAX_PARTIES]; 268 269 /* Chat channels */ 270 channel_type channels[MAX_CHANNELS]; 271 int chan_audit, chan_debug, chan_cheat; 272 273 /* Arenas information */ 274 arena_type arenas[MAX_ARENAS]; 275 int num_arenas; 276 277 /* The information about houses */ 278 house_type houses[MAX_HOUSES]; 279 int num_houses; 280 281 /* This information will help client */ 282 byte spell_flags[MAX_SPELL_REALMS][PY_MAX_SPELLS]; 283 byte spell_tests[MAX_SPELL_REALMS][PY_MAX_SPELLS]; 284 285 /* Player for doing text_out */ 286 player_type* player_textout = NULL; 287 288 /* Current player's character name */ 289 /* In the player info --KLJ-- */ 290 /*char player_name[32];*/ 291 292 /* Stripped version of "player_name" */ 293 /* In the player info --KLJ-- */ 294 /*char player_base[32];*/ 295 296 /* What killed the player */ 297 /* In the player info --KLJ-- */ 298 /*char died_from[80];*/ 299 300 /* Hack -- Textual "history" for the Player */ 301 /* In the player info --KLJ-- */ 302 /*char history[4][60];*/ 303 304 /* Buffer to hold the current savefile name */ 305 /*char savefile[1024];*/ 306 307 308 /* 309 * Array of grids lit by player lite (see "cave.c") 310 */ 311 /*s16b lite_n; 312 byte lite_y[LITE_MAX]; 313 byte lite_x[LITE_MAX];*/ 314 315 /* 316 * Array of grids viewable to the player (see "cave.c") 317 * 318 * This is now in the player info, so that every player sees the cave 319 * differently --KLJ-- 320 */ 321 /*s16b view_n; 322 byte view_y[VIEW_MAX]; 323 byte view_x[VIEW_MAX];*/ 324 325 /* 326 * Array of grids for use by various functions (see "cave.c") 327 */ /* In player info */ 328 /*s16b temp_n; 329 byte temp_y[TEMP_MAX]; 330 byte temp_x[TEMP_MAX];*/ 331 332 333 /* 334 * Number of active macros. 335 */ 336 s16b macro__num; 337 338 /* 339 * Array of macro patterns [MACRO_MAX] 340 */ 341 cptr *macro__pat; 342 343 /* 344 * Array of macro actions [MACRO_MAX] 345 */ 346 cptr *macro__act; 347 348 /* 349 * Array of macro types [MACRO_MAX] 350 */ 351 bool *macro__cmd; 352 353 /* 354 * Current macro action [1024] 355 */ 356 char *macro__buf; 357 358 359 /* 360 * The number of quarks 361 */ 362 s16b quark__num; 363 364 /* 365 * The pointers to the quarks [QUARK_MAX] 366 */ 367 cptr *quark__str; 368 369 370 /* 371 * The next "free" index to use 372 */ 373 u16b message__next; 374 375 /* 376 * The index of the oldest message (none yet) 377 */ 378 u16b message__last; 379 380 /* 381 * The next "free" offset 382 */ 383 u16b message__head; 384 385 /* 386 * The offset to the oldest used char (none yet) 387 */ 388 u16b message__tail; 389 390 /* 391 * The array of offsets, by index [MESSAGE_MAX] 392 */ 393 u16b *message__ptr; 394 395 /* 396 * The array of chars, by offset [MESSAGE_BUF] 397 */ 398 char *message__buf; 399 400 401 /* 402 * The array of normal options 403 */ /* on client / player info */ 404 /*u32b option_flag[8]; 405 u32b option_mask[8];*/ 406 407 408 /* 409 * The array of window options 410 */ /* on client */ 411 /*u32b window_flag[8]; 412 u32b window_mask[8];*/ 413 414 415 /* 416 * The array of window pointers 417 */ 418 /*term *ang_term[8];*/ 419 420 421 /* 422 * The array of indexes of "live" objects 423 */ 424 s16b o_fast[MAX_O_IDX]; 425 426 /* 427 * The array of indexes of "live" monsters 428 */ 429 s16b m_fast[MAX_M_IDX]; 430 431 432 /* 433 * The array of "cave grids" [MAX_WID][MAX_HGT]. 434 * Not completely allocated, that would be inefficient 435 * Not completely hardcoded, that would overflow memory 436 */ 437 /* For wilderness, I am hacking this to extend in the negative direction. 438 I currently have a huge number (4096?) of wilderness levels allocated. 439 -APD- 440 */ 441 cave_type **world[MAX_DEPTH+MAX_WILD]; 442 cave_type ***cave = &world[MAX_WILD]; 443 wilderness_type world_info[MAX_WILD+1]; 444 wilderness_type *wild_info=&(world_info[MAX_WILD]); 445 446 /* 447 * Track turns which were used for dungeon generation 448 */ 449 hturn turn_worldgen[MAX_DEPTH+MAX_WILD]; 450 hturn *turn_cavegen = &turn_worldgen[MAX_WILD]; 451 452 /* 453 * The array of dungeon items [MAX_O_IDX] 454 */ 455 object_type *o_list; 456 457 /* 458 * The array of dungeon monsters [MAX_M_IDX] 459 */ 460 monster_type *m_list; 461 462 /* 463 * The array of dungeon players [MAX_PLAYERS] 464 */ 465 player_type **p_list; 466 467 /* 468 * Hack -- Quest array 469 * 470 * Also moved to player info 471 */ 472 /* quest q_list[MAX_Q_IDX]; */ 473 474 475 /* 476 * The stores [MAX_STORES] 477 */ 478 store_type *store; 479 480 /* 481 * The player's inventory [INVEN_TOTAL] 482 * 483 * This is now in the player info --KLJ-- 484 */ 485 /* object_type *inventory; */ 486 487 488 /* 489 * The size of "alloc_kind_table" (at most MAX_K_IDX * 4) 490 */ 491 s16b alloc_kind_size; 492 493 /* 494 * The entries in the "kind allocator table" 495 */ 496 alloc_entry *alloc_kind_table; 497 498 499 /* 500 * The size of "alloc_race_table" (at most MAX_R_IDX) 501 */ 502 s16b alloc_race_size; 503 504 /* 505 * The entries in the "race allocator table" 506 */ 507 alloc_entry *alloc_race_table; 508 509 510 511 /* 512 * Specify attr/char pairs for visual special effects 513 * Be sure to use "index & 0x400" to avoid illegal access 514 */ 515 byte misc_to_attr[1024]; 516 char misc_to_char[1024]; 517 /* 518 * Specify attr/char pairs for inventory items (by tval) 519 * Be sure to use "index & 0x7F" to avoid illegal access 520 */ 521 byte tval_to_attr[128]; 522 char tval_to_char[128]; 523 524 /* 525 * Simple keymap method, see "init.c" and "cmd6.c". 526 * Be sure to use "index & 0x7F" to avoid illegal access 527 */ 528 byte keymap_cmds[128]; 529 byte keymap_dirs[128]; 530 531 532 /* 533 * Global table of color definitions 534 * Be sure to use "index & 0xFF" to avoid illegal access 535 */ 536 byte color_table[256][4]; 537 538 /* 539 * Static arrays to hold text screen loaded from TEXTFILEs. 540 */ 541 char text_screen[MAX_TEXTFILES][TEXTFILE__WID * TEXTFILE__HGT]; 542 543 /*** Player information ***/ 544 545 /* 546 * Static player info record 547 * 548 * Don't need this anymore --KLJ-- 549 */ 550 /*static player_type p_body;*/ 551 552 /* 553 * Pointer to the player info 554 * 555 * Or this --KLJ-- 556 */ 557 /*player_type *p_ptr = &p_body;*/ 558 559 /* 560 * Pointer to the player tables (race, class, magic) 561 * 562 * This is in the player info now --KLJ-- 563 */ 564 /*player_race *rp_ptr; 565 player_class *cp_ptr; 566 player_magic *mp_ptr;*/ 567 568 569 570 /* 571 * Calculated base hp values for player at each level, 572 * store them so that drain life + restore life does not 573 * affect hit points. Also prevents shameless use of backup 574 * savefiles for hitpoint acquirement. 575 * 576 * This is in the player info now --KLJ-- 577 */ 578 /*s16b player_hp[PY_MAX_LEVEL];*/ 579 580 581 /* Length of equipment slot names combined */ 582 u32b eq_name_size; 583 584 /* 585 * Structure (not array) of size limits 586 */ 587 maxima *z_info; 588 589 /* 590 * The vault generation arrays 591 */ 592 vault_type *v_info; 593 char *v_name; 594 char *v_text; 595 596 /* 597 * The terrain feature arrays 598 */ 599 feature_type *f_info; 600 char *f_name; 601 char *f_text; 602 char *f_char_s; /* copy of f_info characters */ 603 byte *f_attr_s; /* copy of f_info attributes */ 604 605 /* 606 * The object kind arrays 607 */ 608 object_kind *k_info; 609 char *k_name; 610 char *k_text; 611 char *k_char_s; /* copy of k_info characters */ 612 byte *k_attr_s; /* copy of k_info attributes */ 613 614 /* 615 * The artifact arrays 616 */ 617 artifact_type *a_info; 618 char *a_name; 619 char *a_text; 620 621 /* 622 * The ego-item arrays 623 */ 624 ego_item_type *e_info; 625 char *e_name; 626 char *e_text; 627 628 629 /* 630 * The monster race arrays 631 */ 632 monster_race *r_info; 633 char *r_name; 634 char *r_text; 635 char *r_char_s; /* copy of r_info characters */ 636 byte *r_attr_s; /* copy of r_info attributes */ 637 638 639 /* 640 * The player race arrays 641 */ 642 player_race *p_info; 643 char *p_name; 644 char *p_text; 645 646 /* 647 * The player class arrays 648 */ 649 player_class *c_info; 650 char *c_name; 651 char *c_text; 652 653 /* 654 * The shop owner arrays 655 */ 656 owner_type *b_info; 657 char *b_name; 658 char *b_text; 659 660 /* 661 * The racial price adjustment arrays 662 */ 663 byte *g_info; 664 char *g_name; 665 char *g_text; 666 667 /* 668 * The player history arrays 669 */ 670 hist_type *h_info; 671 char *h_text; 672 673 /* 674 * The object flavor arrays 675 */ 676 flavor_type *flavor_info; 677 char *flavor_name; 678 char *flavor_text; 679 char *flavor_char_s; /* copy of flavor_info characters */ 680 byte *flavor_attr_s; /* copy of flavor_info attributes */ 681 682 /* 683 * Hack -- The special Angband "System Suffix" 684 * This variable is used to choose an appropriate "pref-xxx" file 685 */ 686 cptr ANGBAND_SYS = "xxx"; 687 688 /* 689 * Path name: The main "lib" directory 690 * This variable is not actually used anywhere in the code 691 */ 692 cptr ANGBAND_DIR; 693 694 695 /* 696 * Various data files for the game, such as the high score and 697 * the mangband logs. 698 */ 699 cptr ANGBAND_DIR_DATA; 700 701 /* 702 * Textual template files for the "*_info" arrays (ascii) 703 * These files are portable between platforms 704 */ 705 cptr ANGBAND_DIR_EDIT; 706 707 /* 708 * Various user editable text files (ascii), such as the help and greeting 709 * screen. These files may be portable between platforms 710 */ 711 cptr ANGBAND_DIR_HELP; 712 713 /* 714 * Savefiles for current characters (binary) 715 * These files are portable between platforms 716 */ 717 cptr ANGBAND_DIR_SAVE; 718 719 /* 720 * Bone files for player ghosts (ascii) 721 * These files are portable between platforms 722 * (Used for death dumps in MAngband) 723 */ 724 cptr ANGBAND_DIR_BONE; 725 726 /* 727 * User "preference" files (ascii) 728 * These files are rarely portable between platforms 729 */ 730 cptr ANGBAND_DIR_PREF; 731 732 733 /* 734 * Total Hack -- allow all items to be listed (even empty ones) 735 * This is only used by "do_cmd_inven_e()" and is cleared there. 736 */ 737 bool item_tester_full; 738 739 740 /* 741 * Here is a "pseudo-hook" used during calls to "get_item()" and 742 * "show_inven()" and "show_equip()", and the choice window routines. 743 */ 744 byte item_tester_tval; 745 746 747 /* 748 * Here is a "hook" used during calls to "get_item()" and 749 * "show_inven()" and "show_equip()", and the choice window routines. 750 */ 751 bool (*item_tester_hook)(object_type*); 752 753 754 755 756 757 /* 758 * Hack -- function hook to restrict "get_mon_num_prep()" function 759 */ 760 bool (*get_mon_num_hook)(int r_idx); 761 762 763 764 /* 765 * Hack -- function hook to restrict "get_obj_num_prep()" function 766 */ 767 bool (*get_obj_num_hook)(int k_idx); 768