Annotation of early-roguelike/rogue4/rogue.h, Revision 1.1
1.1 ! rubenllo 1: /*
! 2: * Rogue definitions and variable declarations
! 3: *
! 4: * @(#)rogue.h 5.2 (Berkeley) 5/10/82
! 5: *
! 6: * Rogue: Exploring the Dungeons of Doom
! 7: * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman
! 8: * All rights reserved.
! 9: *
! 10: * See the file LICENSE.TXT for full copyright and licensing information.
! 11: */
! 12:
! 13: typedef struct {
! 14: const char *st_name;
! 15: const int st_value;
! 16: } STONE;
! 17:
! 18: extern const char *rainbow[];
! 19: extern const STONE stones[];
! 20: extern const char *sylls[];
! 21: extern const char *wood[];
! 22: extern const char *metal[];
! 23:
! 24: #define NCOLORS 27
! 25: #define NSYLLS 159
! 26: #define NSTONES 26
! 27: #define NWOOD 33
! 28: #define NMETAL 22
! 29:
! 30: /*
! 31: * Maximum number of different things
! 32: */
! 33: #define MAXDAEMONS 20
! 34: #define MAXROOMS 9
! 35: #define MAXTHINGS 9
! 36: #define MAXOBJ 9
! 37: #define MAXPACK 23
! 38: #define MAXTRAPS 10
! 39: #define AMULETLEVEL 26
! 40: #define NUMTHINGS 7 /* number of types of things */
! 41: #define MAXPASS 13 /* upper limit on number of passages */
! 42:
! 43: /*
! 44: * return values for get functions
! 45: */
! 46: #define NORM 0 /* normal exit */
! 47: #define QUIT 1 /* quit option setting */
! 48: #define MINUS 2 /* back up one option */
! 49:
! 50: /*
! 51: * All the fun defines
! 52: */
! 53: #define shint char /* short integer (for very small #s) */
! 54: #define when break;case
! 55: #define otherwise break;default
! 56: #define until(expr) while(!(expr))
! 57: #define next(ptr) (*ptr).l_next
! 58: #define prev(ptr) (*ptr).l_prev
! 59: #define winat(y,x) (moat(y,x) != NULL ? moat(y,x)->t_disguise : chat(y,x))
! 60: #define DISTANCE(y1, x1, y2, x2) ((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))
! 61: #define ce(a,b) ((a).x == (b).x && (a).y == (b).y)
! 62: #define hero player.t_pos
! 63: #define pstats player.t_stats
! 64: #define pack player.t_pack
! 65: #define proom player.t_room
! 66: #define max_hp player.t_stats.s_maxhp
! 67: #define attach(a,b) _attach(&a,b)
! 68: #define detach(a,b) _detach(&a,b)
! 69: #define free_list(a) _free_list(&a)
! 70: #ifndef max
! 71: #define max(a,b) ((a) > (b) ? (a) : (b))
! 72: #endif
! 73: #define on(thing,flag) (((thing).t_flags & (flag)) != 0)
! 74: #undef CTRL
! 75: #define CTRL(ch) (ch & 037)
! 76: #define GOLDCALC (rnd(50 + 10 * level) + 2)
! 77: #define ISRING(h,r) (cur_ring[h] != NULL && cur_ring[h]->o_which == r)
! 78: #define ISWEARING(r) (ISRING(LEFT, r) || ISRING(RIGHT, r))
! 79: #define ISMULT(type) (type==POTION || type==SCROLL || type==FOOD || type==GOLD)
! 80: #define INDEX(y,x) (((x) << 5) + (y))
! 81: #define chat(y,x) (_level[((x) << 5) + (y)])
! 82: #define flat(y,x) (_flags[((x) << 5) + (y)])
! 83: #define moat(y,x) (_monst[((x) << 5) + (y)])
! 84: #define unc(cp) (cp).y, (cp).x
! 85: #ifdef WIZARD
! 86: #define debug if (wizard) msg
! 87: #endif
! 88:
! 89: /*
! 90: * Things that appear on the screens
! 91: */
! 92: #define PASSAGE '#'
! 93: #define DOOR '+'
! 94: #define FLOOR '.'
! 95: #define PLAYER '@'
! 96: #define TRAP '^'
! 97: #define STAIRS '%'
! 98: #define GOLD '*'
! 99: #define POTION '!'
! 100: #define SCROLL '?'
! 101: #define MAGIC '$'
! 102: #define FOOD ':'
! 103: #define WEAPON ')'
! 104: #define ARMOR ']'
! 105: #define AMULET ','
! 106: #define RING '='
! 107: #define STICK '/'
! 108: #define CALLABLE -1
! 109:
! 110: int spread(int nm);
! 111: /*
! 112: * Various constants
! 113: */
! 114: #define PASSWD "mTuZ7WUV9RWkQ"
! 115: #define BEARTIME spread(3)
! 116: #define SLEEPTIME spread(5)
! 117: #define HEALTIME spread(30)
! 118: #define HOLDTIME spread(2)
! 119: #define WANDERTIME spread(70)
! 120: #define BEFORE spread(1)
! 121: #define AFTER spread(2)
! 122: #define HUHDURATION spread(20)
! 123: #define SEEDURATION spread(850)
! 124: #define HUNGERTIME spread(1300)
! 125: #define MORETIME 150
! 126: #define STOMACHSIZE 2000
! 127: #define STARVETIME 850
! 128: #define ESCAPE 27
! 129: #define LEFT 0
! 130: #define RIGHT 1
! 131: #define BOLT_LENGTH 6
! 132: #define LAMPDIST 3
! 133:
! 134: /*
! 135: * Save against things
! 136: */
! 137: #define VS_POISON 00
! 138: #define VS_PARALYZATION 00
! 139: #define VS_DEATH 00
! 140: #define VS_BREATH 02
! 141: #define VS_MAGIC 03
! 142:
! 143: /*
! 144: * Various flag bits
! 145: */
! 146: /* flags for rooms */
! 147: #define ISDARK 0000001 /* room is dark */
! 148: #define ISGONE 0000002 /* room is gone (a corridor) */
! 149:
! 150: /* flags for objects */
! 151: #define ISCURSED 000001 /* object is cursed */
! 152: #define ISKNOW 0000002 /* player knows details about the object */
! 153: #define ISMISL 0000004 /* object is a missile type */
! 154: #define ISMANY 0000010 /* object comes in groups */
! 155:
! 156: /* flags for creatures */
! 157: #define CANHUH 0000001 /* creature can confuse */
! 158: #define CANSEE 0000002 /* creature can see invisible creatures */
! 159: #define ISBLIND 0000004 /* creature is blind */
! 160: #define ISCANC 0000010 /* creature has special qualities cancelled */
! 161: #define ISFOUND 0000020 /* creature has been seen (used for objects) */
! 162: #define ISGREED 0000040 /* creature runs to protect gold */
! 163: #define ISHASTE 0000100 /* creature has been hastened */
! 164: #define ISHELD 0000400 /* creature has been held */
! 165: #define ISHUH 0001000 /* creature is confused */
! 166: #define ISINVIS 0002000 /* creature is invisible */
! 167: #define ISMEAN 0004000 /* creature can wake when player enters room */
! 168: #define ISREGEN 0010000 /* creature can regenerate */
! 169: #define ISRUN 0020000 /* creature is running at the player */
! 170: #define SEEMONST 040000 /* hero can detect unseen monsters */
! 171: #define ISSLOW 0100000 /* creature has been slowed */
! 172:
! 173: /*
! 174: * Flags for level map
! 175: */
! 176: #define F_PASS 0x80 /* is a passageway */
! 177: #define F_SEEN 0x40 /* have seen this corridor before */
! 178: #define F_DROPPED 0x20 /* object was dropped here */
! 179: #define F_LOCKED 0x20 /* door is locked */
! 180: #define F_REAL 0x10 /* what you see is what you get */
! 181: #define F_PNUM 0x0f /* passage number mask */
! 182: #define F_TMASK 0x07 /* trap number mask */
! 183:
! 184: /*
! 185: * Trap types
! 186: */
! 187: #define T_DOOR 00
! 188: #define T_ARROW 01
! 189: #define T_SLEEP 02
! 190: #define T_BEAR 03
! 191: #define T_TELEP 04
! 192: #define T_DART 05
! 193: #define NTRAPS 6
! 194:
! 195: /*
! 196: * Potion types
! 197: */
! 198: #define P_CONFUSE 0
! 199: #define P_PARALYZE 1
! 200: #define P_POISON 2
! 201: #define P_STRENGTH 3
! 202: #define P_SEEINVIS 4
! 203: #define P_HEALING 5
! 204: #define P_MFIND 6
! 205: #define P_TFIND 7
! 206: #define P_RAISE 8
! 207: #define P_XHEAL 9
! 208: #define P_HASTE 10
! 209: #define P_RESTORE 11
! 210: #define P_BLIND 12
! 211: #define P_NOP 13
! 212: #define MAXPOTIONS 14
! 213:
! 214: /*
! 215: * Scroll types
! 216: */
! 217: #define S_CONFUSE 0
! 218: #define S_MAP 1
! 219: #define S_HOLD 2
! 220: #define S_SLEEP 3
! 221: #define S_ARMOR 4
! 222: #define S_IDENT 5
! 223: #define S_SCARE 6
! 224: #define S_GFIND 7
! 225: #define S_TELEP 8
! 226: #define S_ENCH 9
! 227: #define S_CREATE 10
! 228: #define S_REMOVE 11
! 229: #define S_AGGR 12
! 230: #define S_NOP 13
! 231: #define S_GENOCIDE 14
! 232: #define MAXSCROLLS 15
! 233:
! 234: /*
! 235: * Weapon types
! 236: */
! 237: #define MACE 0
! 238: #define SWORD 1
! 239: #define BOW 2
! 240: #define ARROW 3
! 241: #define DAGGER 4
! 242: #define TWOSWORD 5
! 243: #define DART 6
! 244: #define CROSSBOW 7
! 245: #define BOLT 8
! 246: #define SPEAR 9
! 247: #define FLAME 10 /* fake entry for dragon breath (ick) */
! 248: #define MAXWEAPONS 10 /* this should equal FLAME */
! 249:
! 250: /*
! 251: * Armor types
! 252: */
! 253: #define LEATHER 0
! 254: #define RING_MAIL 1
! 255: #define STUDDED_LEATHER 2
! 256: #define SCALE_MAIL 3
! 257: #define CHAIN_MAIL 4
! 258: #define SPLINT_MAIL 5
! 259: #define BANDED_MAIL 6
! 260: #define PLATE_MAIL 7
! 261: #define MAXARMORS 8
! 262:
! 263: /*
! 264: * Ring types
! 265: */
! 266: #define R_PROTECT 0
! 267: #define R_ADDSTR 1
! 268: #define R_SUSTSTR 2
! 269: #define R_SEARCH 3
! 270: #define R_SEEINVIS 4
! 271: #define R_NOP 5
! 272: #define R_AGGR 6
! 273: #define R_ADDHIT 7
! 274: #define R_ADDDAM 8
! 275: #define R_REGEN 9
! 276: #define R_DIGEST 10
! 277: #define R_TELEPORT 11
! 278: #define R_STEALTH 12
! 279: #define R_SUSTARM 13
! 280: #define MAXRINGS 14
! 281:
! 282: /*
! 283: * Rod/Wand/Staff types
! 284: */
! 285:
! 286: #define WS_LIGHT 0
! 287: #define WS_HIT 1
! 288: #define WS_ELECT 2
! 289: #define WS_FIRE 3
! 290: #define WS_COLD 4
! 291: #define WS_POLYMORPH 5
! 292: #define WS_MISSILE 6
! 293: #define WS_HASTE_M 7
! 294: #define WS_SLOW_M 8
! 295: #define WS_DRAIN 9
! 296: #define WS_NOP 10
! 297: #define WS_TELAWAY 11
! 298: #define WS_TELTO 12
! 299: #define WS_CANCEL 13
! 300: #define MAXSTICKS 14
! 301:
! 302: /*
! 303: * Now we define the structures and types
! 304: */
! 305:
! 306: /*
! 307: * Help list
! 308: */
! 309:
! 310: struct h_list {
! 311: char h_ch;
! 312: char *h_desc;
! 313: };
! 314:
! 315: /*
! 316: * Coordinate data type
! 317: */
! 318: typedef struct {
! 319: shint x;
! 320: shint y;
! 321: } coord;
! 322:
! 323: /* daemon/fuse data type */
! 324:
! 325: struct delayed_action {
! 326: int d_type;
! 327: void (*d_func)();
! 328: int d_arg;
! 329: int d_time;
! 330: };
! 331:
! 332: /**/
! 333:
! 334: typedef unsigned int str_t;
! 335:
! 336: /*
! 337: * Stuff about magic items
! 338: */
! 339:
! 340: struct magic_item {
! 341: const char *mi_name;
! 342: shint mi_prob;
! 343: short mi_worth;
! 344: };
! 345:
! 346: /*
! 347: * Room structure
! 348: */
! 349: struct room {
! 350: coord r_pos; /* Upper left corner */
! 351: coord r_max; /* Size of room */
! 352: coord r_gold; /* Where the gold is */
! 353: int r_goldval; /* How much the gold is worth */
! 354: short r_flags; /* Info about the room */
! 355: shint r_nexits; /* Number of exits */
! 356: coord r_exit[12]; /* Where the exits are */
! 357: };
! 358:
! 359: /*
! 360: * Structure describing a fighting being
! 361: */
! 362: struct stats {
! 363: str_t s_str; /* Strength */
! 364: long s_exp; /* Experience */
! 365: shint s_lvl; /* Level of mastery */
! 366: shint s_arm; /* Armor class */
! 367: short s_hpt; /* Hit points */
! 368: char s_dmg[16]; /* String describing damage done */
! 369: shint s_maxhp; /* Max hit points */
! 370: };
! 371:
! 372: /*
! 373: * Structure for monsters and player
! 374: */
! 375: union thing {
! 376: struct {
! 377: union thing *_l_next, *_l_prev; /* Next pointer in link */
! 378: coord _t_pos; /* Position */
! 379: bool _t_turn; /* If slowed, is it a turn to move */
! 380: unsigned char _t_type; /* What it is */
! 381: char _t_disguise; /* What mimic looks like */
! 382: char _t_oldch; /* Character that was where it was */
! 383: coord *_t_dest; /* Where it is running to */
! 384: short _t_flags; /* State word */
! 385: struct stats _t_stats; /* Physical description */
! 386: struct room *_t_room; /* Current room for thing */
! 387: union thing *_t_pack; /* What the thing is carrying */
! 388: int _t_reserved;
! 389: } _t;
! 390: struct {
! 391: union thing *_l_next, *_l_prev; /* Next pointer in link */
! 392: shint _o_type; /* What kind of object it is */
! 393: coord _o_pos; /* Where it lives on the screen */
! 394: char *_o_text; /* What it says if you read it */
! 395: char _o_launch; /* What you need to launch it */
! 396: char _o_damage[8]; /* Damage if used like sword */
! 397: char _o_hurldmg[8]; /* Damage if thrown */
! 398: shint _o_count; /* Count for plural objects */
! 399: shint _o_which; /* Which object of a type it is */
! 400: shint _o_hplus; /* Plusses to hit */
! 401: shint _o_dplus; /* Plusses to damage */
! 402: short _o_ac; /* Armor class */
! 403: short _o_flags; /* Information about objects */
! 404: shint _o_group; /* Group number for this object */
! 405: } _o;
! 406: };
! 407:
! 408: typedef union thing THING;
! 409:
! 410: #define l_next _t._l_next
! 411: #define l_prev _t._l_prev
! 412: #define t_pos _t._t_pos
! 413: #define t_turn _t._t_turn
! 414: #define t_type _t._t_type
! 415: #define t_disguise _t._t_disguise
! 416: #define t_oldch _t._t_oldch
! 417: #define t_dest _t._t_dest
! 418: #define t_flags _t._t_flags
! 419: #define t_stats _t._t_stats
! 420: #define t_pack _t._t_pack
! 421: #define t_room _t._t_room
! 422: #define t_reserved _t._t_reserved
! 423: #define o_type _o._o_type
! 424: #define o_pos _o._o_pos
! 425: #define o_text _o._o_text
! 426: #define o_launch _o._o_launch
! 427: #define o_damage _o._o_damage
! 428: #define o_hurldmg _o._o_hurldmg
! 429: #define o_count _o._o_count
! 430: #define o_which _o._o_which
! 431: #define o_hplus _o._o_hplus
! 432: #define o_dplus _o._o_dplus
! 433: #define o_ac _o._o_ac
! 434: #define o_charges o_ac
! 435: #define o_goldval o_ac
! 436: #define o_flags _o._o_flags
! 437: #define o_group _o._o_group
! 438: #define o_reserved _o._o_reserved
! 439:
! 440: /*
! 441: * Array containing information on all the various types of mosnters
! 442: */
! 443: struct monster {
! 444: const char *m_name; /* What to call the monster */
! 445: const shint m_carry; /* Probability of carrying something */
! 446: const short m_flags; /* Things about the monster */
! 447: struct stats m_stats; /* Initial stats */
! 448: };
! 449:
! 450: /*
! 451: * External variables
! 452: */
! 453:
! 454: extern struct delayed_action d_list[20];
! 455:
! 456: extern THING *_monst[], *cur_armor, *cur_ring[], *cur_weapon,
! 457: *lvl_obj, *mlist, player;
! 458:
! 459: extern coord delta, oldpos;
! 460:
! 461: extern struct h_list helpstr[];
! 462:
! 463: extern struct room *oldrp, passages[], rooms[];
! 464:
! 465: extern struct stats max_stats;
! 466:
! 467: extern struct monster monsters[];
! 468:
! 469: extern struct magic_item p_magic[], r_magic[], s_magic[],
! 470: things[], ws_magic[];
! 471:
! 472: /*
! 473: * Function types
! 474: */
! 475:
! 476: coord *find_dest(), *rndmove();
! 477:
! 478: THING *find_mons(), *find_obj(), *get_item(), *new_item(),
! 479: *new_thing(), *wake_monster();
! 480:
! 481: struct room *roomin(coord *cp);
! 482:
! 483: void _attach(THING **list, THING *item);
! 484: void _detach(THING **list, THING *item);
! 485: void _free_list(THING **ptr);
! 486: bool add_haste(bool potion);
! 487: void add_line(char *fmt, char *arg);
! 488: void add_pack(THING *obj, bool silent);
! 489: void add_str(str_t *sp, int amt);
! 490: void addmsg(char *fmt, ...);
! 491: void aggravate(void);
! 492: int attack(THING *mp);
! 493: void auto_save(int sig);
! 494: void call_it(bool know, char **guess);
! 495: bool cansee(int y, int x);
! 496: char *charge_str(THING *obj);
! 497: void check_level(void);
! 498: void chg_str(int amt);
! 499: void command(void);
! 500: void death(char monst);
! 501: bool diag_ok(coord *sp, coord *ep);
! 502: void discard(THING *item);
! 503: void discovered(void);
! 504: void do_daemons(int flag);
! 505: void do_fuses(int flag);
! 506: void do_motion(THING *obj, int ydelta, int xdelta);
! 507: void do_move(int dy, int dx);
! 508: void do_passages(void);
! 509: void do_rooms(void);
! 510: void do_run(char ch);
! 511: void do_zap(void);
! 512: void doctor(void);
! 513: void door_open(struct room *rp);
! 514: void drop(void);
! 515: bool dropcheck(THING *op);
! 516: void eat(void);
! 517: int encread(void *starta, int size, FILE *inf);
! 518: void encwrite(void *starta, int size, FILE *outf);
! 519: void end_line(void);
! 520: void endmsg(void);
! 521: void enter_room(coord *cp);
! 522: void extinguish(void (*func)());
! 523: void fall(THING *obj, bool pr);
! 524: bool fallpos(coord *pos, coord *newpos, bool pass);
! 525: void fatal(char *s);
! 526: bool fight(coord *mp, char mn, THING *weap, bool thrown);
! 527: THING *find_obj(int y, int x);
! 528: void fire_bolt(coord *start, coord *dir, char *name);
! 529: void fix_stick(THING *cur);
! 530: void flush_type(void);
! 531: void fuse(void (*func)(), int arg, int time, int type);
! 532: void genocide(void);
! 533: bool get_dir(void);
! 534: THING *get_item(char *purpose, int type);
! 535: int get_str(char *opt, WINDOW *win);
! 536: void give_pack(THING *tp);
! 537: bool hit_monster(int y, int x, THING *obj);
! 538: void init_check(void);
! 539: void init_colors(void);
! 540: void init_materials(void);
! 541: void init_names(void);
! 542: void init_player(void);
! 543: void init_stones(void);
! 544: void init_things(void);
! 545: void init_weapon(THING *weap, char type);
! 546: char *inv_name(THING *obj, bool drop);
! 547: bool inventory(THING *list, int type);
! 548: void invis_on(void);
! 549: bool is_current(THING *obj);
! 550: bool is_magic(THING *obj);
! 551: bool issymlink(char *sp);
! 552: void kill_daemon(void (*func)());
! 553: void killed(THING *tp, bool pr);
! 554: void leave(int sig);
! 555: void leave_room(coord *cp);
! 556: void lengthen(void (*func)(), int xtime);
! 557: bool lock_sc(void);
! 558: void look(bool wakeup);
! 559: void missile(int ydelta, int xdelta);
! 560: void msg(char *fmt, ...);
! 561: THING *new_item(void);
! 562: void new_level(void);
! 563: void new_monster(THING *tp, char type, coord *cp);
! 564: THING *new_thing(void);
! 565: void nohaste(void);
! 566: char *num(int n1, int n2, char type);
! 567: void open_log(void);
! 568: void open_score(void);
! 569: void option(void);
! 570: char pack_char(THING *obj);
! 571: void parse_opts(char *str);
! 572: void pick_up(char ch);
! 573: void picky_inven(void);
! 574: void playit(void);
! 575: void quaff(void);
! 576: void quit(int a);
! 577: void raise_level(void);
! 578: char randmonster(bool wander);
! 579: void read_scroll(void);
! 580: int readchar(void);
! 581: int readcharw(WINDOW *win);
! 582: void remove_monster(coord *mp, THING *tp, bool waskill);
! 583: bool restore(char *file, char **envp);
! 584: int ring_eat(int hand);
! 585: char *ring_num(THING *obj);
! 586: void ring_off(void);
! 587: void ring_on(void);
! 588: int rnd(int range);
! 589: void rnd_pos(struct room *rp, coord *cp);
! 590: int rnd_room(void);
! 591: coord *rndmove(THING *who);
! 592: int roll(int number, int sides);
! 593: void rollwand(void);
! 594: void runners(void);
! 595: void runto(coord *runner, coord *spot);
! 596: bool save(int which);
! 597: bool save_game(void);
! 598: bool save_throw(int which, THING *tp);
! 599: void score(int amount, int flags, char monst);
! 600: bool see_monst(THING *mp);
! 601: void setup(void);
! 602: void shell(void);
! 603: void show_win(WINDOW *scr, char *message);
! 604: void sight(void);
! 605: int sign(int nm);
! 606: void start_daemon(void (*func)(), int arg, int type);
! 607: void start_score(void);
! 608: void status(void);
! 609: bool step_ok(char ch);
! 610: void stomach(void);
! 611: void strucpy(char *s1, char *s2, int len);
! 612: void swander(void);
! 613: bool swing(int at_lvl, int op_arm, int wplus);
! 614: void take_off(void);
! 615: int teleport(void);
! 616: void total_winner(void);
! 617: char *tr_name(char type);
! 618: bool turn_see(bool turn_off);
! 619: void turn_see_off(void);
! 620: void unconfuse(void);
! 621: char *unctrol(char ch);
! 622: void unlock_sc(void);
! 623: void unsee(void);
! 624: char *vowelstr(const char *str);
! 625: char *xcrypt(const char *key, const char *setting);
! 626: void w_wait_for(WINDOW *win, char ch);
! 627: void wait_for(char ch);
! 628: THING *wake_monster(int y, int x);
! 629: void wanderer(void);
! 630: void waste_time(void);
! 631: void wear(void);
! 632: void whatis(bool insist);
! 633: void wield(void);
! 634: void writelog(int amount, int flags, char monst);
! 635:
! 636: #ifdef HAVE_CONFIG_H
! 637: #include "config.h"
! 638: #endif
! 639: #include "extern.h"
! 640:
! 641: #ifndef PATH_MAX
! 642: #define PATH_MAX _MAX_PATH
! 643: #endif
CVSweb