1 /* 2 * File: externs.h 3 * Summary: Fixed size 2D vector class that asserts if you do something bad. 4 * Written by: Linley Henzell 5 * 6 * Change History (most recent first): 7 * 8 * <3> 7/29/00 JDJ Renamed sh_x, sh_y, sh_greed, sh_type, sh_level so 9 * they start with shop. 10 * <2> 7/29/00 JDJ Switched to using bounds checked array classes. 11 * Made a few char arrays unsigned char arrays. 12 */ 13 14 #ifndef EXTERNS_H 15 #define EXTERNS_H 16 17 #include <queue> 18 19 #include <time.h> 20 21 #include "defines.h" 22 #include "enum.h" 23 #include "FixAry.h" 24 #include "message.h" 25 26 #define INFO_SIZE 200 // size of message buffers 27 #define ITEMNAME_SIZE 200 // size of item names/shop names/etc 28 #define HIGHSCORE_SIZE 800 // <= 10 Lines for long format scores 29 30 #define MAX_NUM_GODS 21 31 32 extern char info[INFO_SIZE]; // defined in acr.cc {dlb} 33 34 extern unsigned char show_green; // defined in view.cc {dlb} 35 36 // defined in mon-util.cc -- w/o this screen redraws *really* slow {dlb} 37 extern FixedVector<unsigned short, 1000> mcolour; 38 39 #ifdef SHORT_FILE_NAMES 40 const int kNameLen = 30; 41 const int kFileNameLen = 6; 42 const int kFileNameSize = 5 + kFileNameLen; 43 44 #else 45 #ifdef SAVE_DIR_PATH 46 // file name length has to be able to cover full paths -- bwross 47 const int kNameLen = 30; 48 const int kFileNameLen = 250; 49 const int kFileNameSize = 5 + kFileNameLen; 50 #else 51 const int kNameLen = 30; 52 const int kFileNameLen = 28; 53 const int kFileNameSize = 5 + kFileNameLen; 54 #endif 55 #endif 56 57 58 // Length of Path + File Name 59 const int kPathLen = 256; 60 61 // This value is used to mark that the current berserk is free from 62 // penalty (Xom's granted or from a deck of cards). 63 #define NO_BERSERK_PENALTY -1 64 65 struct coord_def 66 { 67 int x; 68 int y; 69 70 // coord_def( int x_in = 0, int y_in = 0 ) : x(x_in), y(y_in) {}; 71 }; 72 73 struct dice_def 74 { 75 int num; 76 int size; 77 numdice_def78 dice_def( int n = 0, int s = 0 ) : num(n), size(s) {} 79 }; 80 81 // output from direction() function: 82 struct dist 83 { 84 bool isValid; // valid target chosen? 85 bool isTarget; // target (true), or direction (false)? 86 bool isMe; // selected self (convenience: tx == you.x_pos, 87 // ty == you.y_pos) 88 bool isCancel; // user cancelled (usually <ESC> key) 89 int tx,ty; // target x,y or logical extension of beam to map edge 90 int dx,dy; // delta x and y if direction - always -1,0,1 91 92 // internal use - ignore 93 int prev_target; // previous target 94 }; 95 96 97 struct bolt 98 { 99 // INPUT parameters set by caller 100 int range; // minimum range 101 int rangeMax; // maximum range 102 int type; // missile gfx 103 int colour; 104 int flavour; 105 int source_x, source_y; // beam origin 106 dice_def damage; 107 int ench_power, hit; 108 int target_x, target_y; // intended target 109 char thrower; // what kind of thing threw this? 110 char ex_size; // explosion radius (0==none) 111 int beam_source; // NON_MONSTER or monster index # 112 char beam_name[40]; 113 bool isBeam; // beams? (can hits multiple targets?) 114 const char *aux_source; // source of KILL_MISC beams 115 116 // OUTPUT parameters (tracing, ID) 117 bool obviousEffect; // did an 'obvious' effect happen? 118 int fr_count, foe_count; // # of times a friend/foe is "hit" 119 int fr_power, foe_power; // total levels/hit dice affected 120 121 // INTERNAL use - should not usually be set outside of beam.cc 122 bool isTracer; // is this a tracer? 123 bool aimedAtFeet; // this was aimed at self! 124 bool msgGenerated; // an appropriate msg was already mpr'd 125 bool isExplosion; // explosion phase (as opposed to beam phase) 126 bool smartMonster; // tracer firer can guess at other mons. resists? 127 bool canSeeInvis; // tracer firer can see invisible? 128 bool isFriendly; // tracer firer is enslaved or pet 129 int foeRatio; // 100* foe ratio (see mons_should_fire()) 130 }; 131 132 133 struct run_check_dir 134 { 135 unsigned char grid; 136 char dx; 137 char dy; 138 }; 139 140 141 struct delay_queue_item 142 { 143 int type; 144 int duration; 145 int parm1; 146 int parm2; 147 }; 148 149 150 struct item_def 151 { 152 unsigned char base_type; // basic class (ie OBJ_WEAPON) 153 unsigned char sub_type; // type within that class (ie WPN_DAGGER) 154 short plus; // +to hit, charges, corpse mon id 155 short plus2; // +to dam, sub-sub type for boots and helms 156 long special; // special stuff 157 unsigned char colour; // item colour 158 unsigned long flags; // item statuc flags 159 short quantity; // number of items 160 161 short x; // x-location; for inventory items = -1 162 short y; // y-location; for inventory items = -1 163 short link; // link to next item; for inventory items = slot 164 }; 165 166 167 struct player 168 { 169 char turn_is_over; // flag signaling that player has performed a timed action 170 171 unsigned char prev_targ; 172 char your_name[kNameLen]; 173 174 unsigned char species; 175 176 char run_x; 177 char run_y; 178 FixedVector< run_check_dir, 3 > run_check; // array of grids to check 179 char running; 180 181 char special_wield; 182 char deaths_door; 183 char fire_shield; 184 185 double elapsed_time; // total amount of elapsed time in the game 186 187 unsigned char synch_time; // amount to wait before calling handle_time 188 189 unsigned char disease; 190 191 char max_level; 192 193 int x_pos; 194 int y_pos; 195 196 int hunger; 197 FixedVector<char, NUM_EQUIP> equip; 198 199 int hp; 200 int hp_max; 201 int base_hp; // temporary max HP loss (rotting) 202 int base_hp2; // base HPs from levels (and permanent loss) 203 204 int magic_points; 205 int max_magic_points; 206 int base_magic_points; // temporary max MP loss? (currently unused) 207 int base_magic_points2; // base MPs from levels and potions of magic 208 209 char strength; 210 char intel; 211 char dex; 212 char max_strength; 213 char max_intel; 214 char max_dex; 215 216 char hunger_state; 217 218 bool wield_change; // redraw weapon 219 220 unsigned long redraw_status_flags; 221 char redraw_hit_points; 222 char redraw_magic_points; 223 char redraw_strength; 224 char redraw_intelligence; 225 char redraw_dexterity; 226 char redraw_experience; 227 char redraw_armour_class; 228 229 char redraw_gold; 230 char redraw_evasion; 231 232 unsigned char hit_points_regeneration; 233 unsigned char magic_points_regeneration; 234 235 unsigned long experience; 236 int experience_level; 237 unsigned int gold; 238 int char_class; 239 char class_name[30]; 240 // char speed; // now unused 241 int time_taken; 242 243 char shield_blocks; // number of shield blocks since last action 244 245 FixedVector< item_def, ENDOFPACK > inv; 246 247 int burden; 248 char burden_state; 249 FixedVector<unsigned char, 25> spells; 250 char spell_no; 251 unsigned char char_direction; // 252 253 unsigned char pet_target; 254 255 int your_level; // offset by one (-1 == 0, 0 == 1, etc.) for display 256 257 // durational things. Why didn't I do this for haste etc 258 // right from the start? Oh well. 259 FixedVector<int, NUM_DURATIONS> duration; 260 261 int invis; 262 int conf; 263 int paralysis; 264 int slow; 265 int haste; 266 int might; 267 int levitation; 268 269 int poison; 270 int rotting; 271 int berserker; 272 273 int exhausted; // fatigue counter for berserk 274 275 int berserk_penalty; // pelnalty for moving while berserk 276 277 FixedVector<unsigned char, 30> attribute; // see ATTRIBUTES in enum.h 278 279 char is_undead; // see UNDEAD_STATES in enum.h 280 281 std::queue< delay_queue_item > delay_queue; // pending actions 282 283 FixedVector<unsigned char, 50> skills; 284 FixedVector<unsigned char, 50> practise_skill; 285 FixedVector<unsigned int, 50> skill_points; 286 FixedVector<unsigned char, 50> skill_order; 287 int skill_cost_level; 288 int total_skill_points; 289 int exp_available; 290 291 FixedArray<unsigned char, 5, 50> item_description; 292 FixedVector<unsigned char, 50> unique_items; 293 FixedVector<unsigned char, 50> unique_creatures; 294 char level_type; 295 296 char where_are_you; 297 298 FixedVector<unsigned char, 30> branch_stairs; 299 300 char religion; 301 unsigned char piety; 302 unsigned char gift_timeout; 303 FixedVector<unsigned char, MAX_NUM_GODS> penance; 304 FixedVector<unsigned char, MAX_NUM_GODS> worshipped; 305 306 307 FixedVector<unsigned char, 100> mutation; 308 FixedVector<unsigned char, 100> demon_pow; 309 unsigned char magic_contamination; 310 311 char confusing_touch; 312 char sure_blade; 313 314 FixedVector<unsigned char, 50> had_book; 315 316 unsigned char betrayal; 317 unsigned char normal_vision; // how far the species gets to see 318 unsigned char current_vision; // current sight radius (cells) 319 320 unsigned char hell_exit; // which level plyr goes to on hell exit. 321 322 // This field is here even in non-WIZARD compiles, since the 323 // player might have been playing previously under wiz mode. 324 bool wizard; // true if player has entered wiz mode. 325 time_t birth_time; // start time of game 326 327 time_t start_time; // start time of session 328 long real_time; // real time played (in seconds) 329 long num_turns; // number of turns taken 330 331 int old_hunger; // used for hunger delta-meter (see output.cc) 332 333 // Warning: these two are quite different. 334 // 335 // The spell table is an index to a specific spell slot (you.spells). 336 // The ability table lists the ability (ABIL_*) which prefers that letter. 337 // 338 // In other words, the spell table contains hard links and the ability 339 // table contains soft links. 340 FixedVector<int, 52> spell_letter_table; // ref to spell by slot 341 FixedVector<int, 52> ability_letter_table; // ref to ability by enum 342 }; 343 344 extern struct player you; 345 346 struct monsters 347 { 348 int type; 349 int hit_points; 350 int max_hit_points; 351 int hit_dice; 352 int armour_class; // great -- more mixed american/proper spelling 353 int evasion; 354 unsigned int speed; 355 unsigned int speed_increment; 356 unsigned char x; 357 unsigned char y; 358 unsigned char target_x; 359 unsigned char target_y; 360 FixedVector<int, 8> inv; 361 unsigned char attitude; // from MONS_ATTITUDE 362 unsigned int behaviour; 363 unsigned int foe; 364 FixedVector<unsigned int, NUM_MON_ENCHANTS> enchantment; 365 unsigned char flags; // bitfield of boolean flags 366 unsigned int number; // #heads (hydra), etc. 367 int foe_memory; // how long to 'remember' foe x,y 368 // once they go out of sight 369 }; 370 371 struct cloud_struct 372 { 373 unsigned char x; 374 unsigned char y; 375 unsigned char type; 376 int decay; 377 }; 378 379 struct shop_struct 380 { 381 unsigned char x; 382 unsigned char y; 383 unsigned char greed; 384 unsigned char type; 385 unsigned char level; 386 387 FixedVector<unsigned char, 3> keeper_name; 388 }; 389 390 struct trap_struct 391 { 392 unsigned char x; 393 unsigned char y; 394 unsigned char type; 395 }; 396 397 struct crawl_environment 398 { 399 unsigned char rock_colour; 400 unsigned char floor_colour; 401 402 FixedVector< item_def, MAX_ITEMS > item; // item list 403 FixedVector< monsters, MAX_MONSTERS > mons; // monster list 404 405 FixedArray< unsigned char, GXM, GYM > grid; // terrain grid 406 FixedArray< unsigned char, GXM, GYM > mgrid; // monster grid 407 FixedArray< int, GXM, GYM > igrid; // item grid 408 FixedArray< unsigned char, GXM, GYM > cgrid; // cloud grid 409 410 FixedArray< unsigned char, GXM, GYM > map; // discovered terrain 411 412 FixedArray< unsigned int, 19, 19> show; // view window char 413 FixedArray< unsigned short, 19, 19> show_col; // view window colour 414 415 FixedVector< cloud_struct, MAX_CLOUDS > cloud; // cloud list 416 unsigned char cloud_no; 417 418 FixedVector< shop_struct, MAX_SHOPS > shop; // shop list 419 FixedVector< trap_struct, MAX_TRAPS > trap; // trap list 420 421 FixedVector< int, 20 > mons_alloc; 422 int trap_known; 423 double elapsed_time; // used during level load 424 }; 425 426 extern struct crawl_environment env; 427 428 429 struct ghost_struct 430 { 431 char name[20]; 432 FixedVector< short, NUM_GHOST_VALUES > values; 433 }; 434 435 436 extern struct ghost_struct ghost; 437 438 439 extern void (*viewwindow) (char, bool); 440 441 442 struct system_environment 443 { 444 char *crawl_name; 445 char *crawl_pizza; 446 char *crawl_rc; 447 char *crawl_dir; 448 char *home; // only used by MULTIUSER systems 449 bool board_with_nail; // Easter Egg silliness 450 }; 451 452 extern system_environment SysEnv; 453 454 struct game_options 455 { 456 long autopickups; // items to autopickup 457 bool verbose_dump; // make character dumps contain more detail 458 bool colour_map; // add colour to the map 459 bool clean_map; // remove unseen clouds/monsters 460 bool show_uncursed; // label known uncursed items as "uncursed" 461 bool always_greet; // display greeting message when reloading 462 bool easy_open; // open doors with movement 463 bool easy_armour; // allow auto-removing of armour 464 bool easy_butcher; // open doors with movement 465 int easy_confirm; // make yesno() confirming easier 466 int easy_quit_item_prompts; // make item prompts quitable on space 467 int colour[16]; // macro fg colours to other colours 468 int background; // select default background colour 469 int channels[NUM_MESSAGE_CHANNELS]; // msg channel colouring 470 int weapon; // auto-choose weapon for character 471 int chaos_knight; // choice of god for Chaos Knights (Xom/Makleb) 472 int death_knight; // choice of god/necromancy for Death Knights 473 int priest; // choice of god for priests (Zin/Yred) 474 bool random_pick; // randomly generate character 475 int hp_warning; // percentage hp for danger warning 476 int hp_attention; // percentage hp for danger attention 477 char race; // preselected race 478 char cls; // preselected class 479 bool terse_hand; // use terse description for wielded item 480 bool delay_message_clear; // avoid clearing messages each turn 481 unsigned int friend_brand; // Attribute for branding friendly monsters 482 bool no_dark_brand; // Attribute for branding friendly monsters 483 484 int fire_items_start; // index of first item for fire command 485 FixedVector<int, NUM_FIRE_TYPES> fire_order; // order for 'f' command 486 487 bool auto_list; // automatically jump to appropriate item lists 488 489 bool flush_input[NUM_FLUSH_REASONS]; // when to flush input buff 490 bool lowercase_invocations; // prefer lowercase invocations 491 492 #ifdef CURSES 493 int num_colours; // used for setting up colour table (8 or 16) 494 #endif 495 496 #ifdef WIZARD 497 int wiz_mode; // yes, no, never in wiz mode to start 498 #endif 499 500 // internal use only: 501 int sc_entries; // # of score entries 502 int sc_format; // Format for score entries 503 }; 504 505 extern game_options Options; 506 507 struct tagHeader 508 { 509 short tagID; 510 long offset; 511 }; 512 513 struct scorefile_entry 514 { 515 char version; 516 char release; 517 long points; 518 char name[kNameLen]; 519 long uid; // for multiuser systems 520 char race; 521 char cls; 522 char race_class_name[5]; // overrides race & cls if non-null 523 char lvl; // player level. 524 char best_skill; // best skill # 525 char best_skill_lvl; // best skill level 526 int death_type; 527 int death_source; // 0 or monster TYPE 528 int mon_num; // sigh... 529 char death_source_name[40]; // overrides death_source 530 char auxkilldata[ITEMNAME_SIZE]; // weapon wielded, spell cast, etc 531 char dlvl; // dungeon level (relative) 532 char level_type; // what kind of level died on.. 533 char branch; // dungeon branch 534 int final_hp; // actual current HPs (probably <= 0) 535 int final_max_hp; // net HPs after rot 536 int final_max_max_hp; // gross HPs before rot 537 int damage; // damage of final attack 538 int str; // final str (useful for nickname) 539 int intel; // final int 540 int dex; // final dex (useful for nickname) 541 int god; // god 542 int piety; // piety 543 int penance; // penance 544 char wiz_mode; // character used wiz mode 545 time_t birth_time; // start time of character 546 time_t death_time; // end time of character 547 long real_time; // real playing time in seconds 548 long num_turns; // number of turns taken 549 int num_diff_runes; // number of rune types in inventory 550 int num_runes; // total number of runes in inventory 551 }; 552 553 #endif // EXTERNS_H 554