-WARNS6 cleanups (3953 warnings)
[dragonfly.git] / games / rogue / rogue.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Timoth C. Stoehr.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)rogue.h 8.1 (Berkeley) 5/31/93
37 * $FreeBSD: src/games/rogue/rogue.h,v 1.3.2.1 2001/12/17 12:43:23 phantom Exp $
38 * $DragonFly: src/games/rogue/rogue.h,v 1.4 2006/09/02 19:31:07 pavalos Exp $
39 */
40
41#include <curses.h>
42#include <stdbool.h>
43#include <stdlib.h>
44#include <string.h>
45
46/*
47 * rogue.h
48 *
49 * This source herein may be modified and/or distributed by anybody who
50 * so desires, with the following restrictions:
51 * 1.) This notice shall not be removed.
52 * 2.) Credit shall not be taken for the creation of this source.
53 * 3.) This code is not to be traded, sold, or used for personal
54 * gain or profit.
55 */
56
57#define boolean bool
58
59#define NOTHING ((unsigned short) 0)
60#define OBJECT ((unsigned short) 01)
61#define MONSTER ((unsigned short) 02)
62#define STAIRS ((unsigned short) 04)
63#define HORWALL ((unsigned short) 010)
64#define VERTWALL ((unsigned short) 020)
65#define DOOR ((unsigned short) 040)
66#define FLOOR ((unsigned short) 0100)
67#define TUNNEL ((unsigned short) 0200)
68#define TRAP ((unsigned short) 0400)
69#define HIDDEN ((unsigned short) 01000)
70
71#define ARMOR ((unsigned short) 01)
72#define WEAPON ((unsigned short) 02)
73#define SCROL ((unsigned short) 04)
74#define POTION ((unsigned short) 010)
75#define GOLD ((unsigned short) 020)
76#define FOOD ((unsigned short) 040)
77#define WAND ((unsigned short) 0100)
78#define RING ((unsigned short) 0200)
79#define AMULET ((unsigned short) 0400)
80#define ALL_OBJECTS ((unsigned short) 0777)
81
82#define LEATHER 0
83#define RINGMAIL 1
84#define SCALE 2
85#define CHAIN 3
86#define BANDED 4
87#define SPLINT 5
88#define PLATE 6
89#define ARMORS 7
90
91#define BOW 0
92#define DART 1
93#define ARROW 2
94#define DAGGER 3
95#define SHURIKEN 4
96#define MACE 5
97#define LONG_SWORD 6
98#define TWO_HANDED_SWORD 7
99#define WEAPONS 8
100
101#define MAX_PACK_COUNT 24
102
103#define PROTECT_ARMOR 0
104#define HOLD_MONSTER 1
105#define ENCH_WEAPON 2
106#define ENCH_ARMOR 3
107#define IDENTIFY 4
108#define TELEPORT 5
109#define SLEEP 6
110#define SCARE_MONSTER 7
111#define REMOVE_CURSE 8
112#define CREATE_MONSTER 9
113#define AGGRAVATE_MONSTER 10
114#define MAGIC_MAPPING 11
115#define CON_MON 12
116#define SCROLS 13
117
118#define INCREASE_STRENGTH 0
119#define RESTORE_STRENGTH 1
120#define HEALING 2
121#define EXTRA_HEALING 3
122#define POISON 4
123#define RAISE_LEVEL 5
124#define BLINDNESS 6
125#define HALLUCINATION 7
126#define DETECT_MONSTER 8
127#define DETECT_OBJECTS 9
128#define CONFUSION 10
129#define LEVITATION 11
130#define HASTE_SELF 12
131#define SEE_INVISIBLE 13
132#define POTIONS 14
133
134#define TELE_AWAY 0
135#define SLOW_MONSTER 1
136#define INVISIBILITY 2
137#define POLYMORPH 3
138#define HASTE_MONSTER 4
139#define MAGIC_MISSILE 5
140#define CANCELLATION 6
141#define DO_NOTHING 7
142#define DRAIN_LIFE 8
143#define COLD 9
144#define FIRE 10
145#define WANDS 11
146
147#define STEALTH 0
148#define R_TELEPORT 1
149#define REGENERATION 2
150#define SLOW_DIGEST 3
151#define ADD_STRENGTH 4
152#define SUSTAIN_STRENGTH 5
153#define DEXTERITY 6
154#define ADORNMENT 7
155#define R_SEE_INVISIBLE 8
156#define MAINTAIN_ARMOR 9
157#define SEARCHING 10
158#define RINGS 11
159
160#define RATION 0
161#define FRUIT 1
162
163#define NOT_USED ((unsigned short) 0)
164#define BEING_WIELDED ((unsigned short) 01)
165#define BEING_WORN ((unsigned short) 02)
166#define ON_LEFT_HAND ((unsigned short) 04)
167#define ON_RIGHT_HAND ((unsigned short) 010)
168#define ON_EITHER_HAND ((unsigned short) 014)
169#define BEING_USED ((unsigned short) 017)
170
171#define NO_TRAP -1
172#define TRAP_DOOR 0
173#define BEAR_TRAP 1
174#define TELE_TRAP 2
175#define DART_TRAP 3
176#define SLEEPING_GAS_TRAP 4
177#define RUST_TRAP 5
178#define TRAPS 6
179
180#define STEALTH_FACTOR 3
181#define R_TELE_PERCENT 8
182
183#define UNIDENTIFIED ((unsigned short) 00) /* MUST BE ZERO! */
184#define IDENTIFIED ((unsigned short) 01)
185#define CALLED ((unsigned short) 02)
186
187#define DROWS 24
188#define DCOLS 80
189#define NMESSAGES 5
190#define MAX_TITLE_LENGTH 30
191#define MAXSYLLABLES 40
192#define MAX_METAL 14
193#define WAND_MATERIALS 30
194#define GEMS 14
195
196#define GOLD_PERCENT 46
197
198#define MAX_OPT_LEN 40
199
200#define HUNGER_STR_LEN 8
201
202#define MAX_ID_TITLE_LEN 64
203
204struct id {
205 short value;
206 char title[MAX_ID_TITLE_LEN];
207 const char *real;
208 unsigned short id_status;
209};
210
211/* The following #defines provide more meaningful names for some of the
212 * struct object fields that are used for monsters. This, since each monster
213 * and object (scrolls, potions, etc) are represented by a struct object.
214 * Ideally, this should be handled by some kind of union structure.
215 */
216
217#define m_damage damage
218#define hp_to_kill quantity
219#define m_char ichar
220#define first_level is_protected
221#define last_level is_cursed
222#define m_hit_chance class
223#define stationary_damage identified
224#define drop_percent which_kind
225#define trail_char d_enchant
226#define slowed_toggle quiver
227#define moves_confused hit_enchant
228#define nap_length picked_up
229#define disguise what_is
230#define next_monster next_object
231
232struct obj { /* comment is monster meaning */
233 unsigned long m_flags; /* monster flags */
234 const char *damage; /* damage it does */
235 short quantity; /* hit points to kill */
236 short ichar; /* 'A' is for aquatar */
237 short kill_exp; /* exp for killing it */
238 short is_protected; /* level starts */
239 short is_cursed; /* level ends */
240 short class; /* chance of hitting you */
241 short identified; /* 'F' damage, 1,2,3... */
242 unsigned short which_kind; /* item carry/drop % */
243 short o_row, o_col, o; /* o is how many times stuck at o_row, o_col */
244 short row, col; /* current row, col */
245 short d_enchant; /* room char when detect_monster */
246 short quiver; /* monster slowed toggle */
247 short trow, tcol; /* target row, col */
248 short hit_enchant; /* how many moves is confused */
249 unsigned short what_is; /* imitator's charactor (?!%: */
250 short picked_up; /* sleep from wand of sleep */
251 unsigned short in_use_flags;
252 struct obj *next_object; /* next monster */
253};
254
255typedef struct obj object;
256
257#define INIT_AW (object*)0,(object*)0
258#define INIT_RINGS (object*)0,(object*)0
259#define INIT_HP 12
260#define INIT_STR 16,16
261#define INIT_EXP 1,0
262#define INIT_PACK {0,"",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}
263#define INIT_GOLD 0
264#define INIT_CHAR '@'
265#define INIT_MOVES 1250
266
267struct fightr {
268 object *armor;
269 object *weapon;
270 object *left_ring, *right_ring;
271 short hp_current;
272 short hp_max;
273 short str_current;
274 short str_max;
275 object pack;
276 long gold;
277 short exp;
278 long exp_points;
279 short row, col;
280 short fchar;
281 short moves_left;
282};
283
284typedef struct fightr fighter;
285
286struct dr {
287 short oth_room;
288 short oth_row,
289 oth_col;
290 short door_row,
291 door_col;
292};
293
294typedef struct dr door;
295
296struct rm {
297 short bottom_row, right_col, left_col, top_row;
298 door doors[4];
299 unsigned short is_room;
300};
301
302typedef struct rm room;
303
304#define MAXROOMS 9
305#define BIG_ROOM 10
306
307#define NO_ROOM -1
308
309#define PASSAGE -3 /* cur_room value */
310
311#define AMULET_LEVEL 26
312
313#define R_NOTHING ((unsigned short) 01)
314#define R_ROOM ((unsigned short) 02)
315#define R_MAZE ((unsigned short) 04)
316#define R_DEADEND ((unsigned short) 010)
317#define R_CROSS ((unsigned short) 020)
318
319#define MAX_EXP_LEVEL 21
320#define MAX_EXP 10000001L
321#define MAX_GOLD 999999
322#define MAX_ARMOR 99
323#define MAX_HP 999
324#define MAX_STRENGTH 99
325#define LAST_DUNGEON 99
326
327#define STAT_LEVEL 01
328#define STAT_GOLD 02
329#define STAT_HP 04
330#define STAT_STRENGTH 010
331#define STAT_ARMOR 020
332#define STAT_EXP 040
333#define STAT_HUNGER 0100
334#define STAT_LABEL 0200
335#define STAT_ALL 0377
336
337#define PARTY_TIME 10 /* one party somewhere in each 10 level span */
338
339#define MAX_TRAPS 10 /* maximum traps per level */
340
341#define HIDE_PERCENT 12
342
343struct tr {
344 short trap_type;
345 short trap_row, trap_col;
346};
347
348typedef struct tr trap;
349
350extern fighter rogue;
351extern room rooms[];
352extern trap traps[];
353extern unsigned short dungeon[DROWS][DCOLS];
354extern object level_objects;
355
356extern struct id id_scrolls[];
357extern struct id id_potions[];
358extern struct id id_wands[];
359extern struct id id_rings[];
360extern struct id id_weapons[];
361extern struct id id_armors[];
362
363extern object mon_tab[];
364extern object level_monsters;
365
366#define MONSTERS 26
367
368#define HASTED 01L
369#define SLOWED 02L
370#define INVISIBLE 04L
371#define ASLEEP 010L
372#define WAKENS 020L
373#define WANDERS 040L
374#define FLIES 0100L
375#define FLITS 0200L
376#define CAN_FLIT 0400L /* can, but usually doesn't, flit */
377#define CONFUSED 01000L
378#define RUSTS 02000L
379#define HOLDS 04000L
380#define FREEZES 010000L
381#define STEALS_GOLD 020000L
382#define STEALS_ITEM 040000L
383#define STINGS 0100000L
384#define DRAINS_LIFE 0200000L
385#define DROPS_LEVEL 0400000L
386#define SEEKS_GOLD 01000000L
387#define FREEZING_ROGUE 02000000L
388#define RUST_VANISHED 04000000L
389#define CONFUSES 010000000L
390#define IMITATES 020000000L
391#define FLAMES 040000000L
392#define STATIONARY 0100000000L /* damage will be 1,2,3,... */
393#define NAPPING 0200000000L /* can't wake up for a while */
394#define ALREADY_MOVED 0400000000L
395
396#define SPECIAL_HIT (RUSTS|HOLDS|FREEZES|STEALS_GOLD|STEALS_ITEM|STINGS|DRAINS_LIFE|DROPS_LEVEL)
397
398#define WAKE_PERCENT 45
399#define FLIT_PERCENT 40
400#define PARTY_WAKE_PERCENT 75
401
402#define HYPOTHERMIA 1
403#define STARVATION 2
404#define POISON_DART 3
405#define QUIT 4
406#define WIN 5
407#define KFIRE 6
408
409#define UPWARD 0
410#define UPRIGHT 1
411#define RIGHT 2
412#define DOWNRIGHT 3
413#define DOWN 4
414#define DOWNLEFT 5
415#define LEFT 6
416#define UPLEFT 7
417#define DIRS 8
418
419#define ROW1 7
420#define ROW2 15
421
422#define COL1 26
423#define COL2 52
424
425#define MOVED 0
426#define MOVE_FAILED -1
427#define STOPPED_ON_SOMETHING -2
428#define CANCEL '\033'
429#define LIST '*'
430
431#define HUNGRY 300
432#define WEAK 150
433#define FAINT 20
434#define STARVE 0
435
436#define MIN_ROW 1
437
438struct rogue_time {
439 short year; /* >= 1987 */
440 short month; /* 1 - 12 */
441 short day; /* 1 - 31 */
442 short hour; /* 0 - 23 */
443 short minute; /* 0 - 59 */
444 short second; /* 0 - 59 */
445};
446
447/* external routine declarations.
448 */
449#define rrandom random
450#define srrandom(x) srandomdev()
451
452/* hit.c */
453void mon_hit(object *);
454void rogue_hit(object *, boolean);
455void rogue_damage(short, object *, short);
456int get_damage(const char *, boolean);
457int get_number(const char *);
458long lget_number(const char *);
459boolean mon_damage(object *, short);
460void fight(boolean);
461void get_dir_rc(short, short *, short *, short);
462short get_hit_chance(const object *);
463short get_weapon_damage(const object *);
464void s_con_mon(object *);
465
466/* init.c */
467boolean init(int, char**);
468void clean_up(const char *);
469void start_window(void);
470void stop_window(void);
471void byebye(void);
472void onintr(void);
473void error_save(void);
474
475/* inventory.c */
476void inventory(const object *, unsigned short);
477void id_com(void);
478void mix_colors(void);
479void make_scroll_titles(void);
480void get_desc(const object *, char *);
481void get_wand_and_ring_materials(void);
482void single_inv(short);
483struct id *get_id_table(const object *);
484void inv_armor_weapon(boolean);
485void id_type(void);
486
487/* level.c */
488void make_level(void);
489void clear_level(void);
490void put_player(short);
491boolean drop_check(void);
492boolean check_up(void);
493void add_exp(int, boolean);
494int hp_raise(void);
495void show_average_hp(void);
496
497/* machdep.c */
498#ifdef UNIX
499void md_slurp(void);
500void md_control_keybord(boolean);
501void md_heed_signals(void);
502void md_ignore_signals(void);
503int md_get_file_id(const char *);
504int md_link_count(const char *);
505void md_gct(struct rogue_time *);
506void md_gfmt(const char *, struct rogue_time *);
507boolean md_df(const char *);
508const char *md_gln(void);
509void md_sleep(int);
510char *md_getenv(const char *);
511char *md_malloc(int);
512int md_gseed(void);
513void md_exit(int);
514void md_lock(boolean);
515void md_shell(const char *);
516#endif
517
518/* message.c */
519void message(const char *, boolean);
520void remessage(short);
521void check_message(void);
522short get_input_line(const char *, const char *, char *,
523 const char *, boolean, boolean);
524int rgetchar(void);
525void print_stats(int);
526void sound_bell(void);
527boolean is_digit(short);
528int r_index(const char *, int, boolean);
529
530/* monster.c */
531void put_mons(void);
532object *gr_monster(object *, int);
533void mv_mons(void);
534void party_monsters(int, int);
535short gmc_row_col(int, int);
536short gmc(object *);
537void mv_1_monster(object *, short, short);
538void move_mon_to(object *, short, short);
539boolean mon_can_go(const object *, short, short);
540void wake_up(object *);
541void wake_room(short, boolean, short, short);
542const char *mon_name(const object *);
543void wanderer(void);
544void show_monsters(void);
545void create_monster(void);
546int rogue_can_see(int, int);
547char gr_obj_char(void);
548void aggravate(void);
549boolean mon_sees(const object *, int, int);
550void mv_aquatars(void);
551
552/* move.c */
553short one_move_rogue(short, short);
554void multiple_move_rogue(short);
555boolean is_passable(int, int);
556boolean can_move(short, short, short, short);
557void move_onto(void);
558boolean is_direction(short, short *);
559boolean reg_move(void);
560void rest(int);
561
562/* object.c */
563void put_objects(void);
564void place_at(object *, int, int);
565object *object_at(object *, short, short);
566object *get_letter_object(int);
567void free_stuff(object *);
568const char *name_of(const object *);
569object *gr_object(void);
570void get_food(object *, boolean);
571void put_stairs(void);
572short get_armor_class(const object *);
573object *alloc_object(void);
574void free_object(object *);
575void show_objects(void);
576void put_amulet(void);
577void c_object_for_wizard(void);
578
579/* pack.c */
580object *add_to_pack(object *, object *, int);
581void take_from_pack(object *, object *);
582object *pick_up(int, int, short *);
583void drop(void);
584void wait_for_ack(void);
585short pack_letter(const char *, unsigned short);
586void take_off(void);
587void wear(void);
588void unwear(object *);
589void do_wear(object *);
590void wield(void);
591void do_wield(object *);
592void unwield(object *);
593void call_it(void);
594short pack_count(const object *);
595boolean has_amulet(void);
596void kick_into_pack(void);
597
598/* play.c */
599void play_level(void);
600
601/* random.c */
602int get_rand(int, int);
603boolean rand_percent(int);
604boolean coin_toss(void);
605
606/* ring.c */
607void put_on_ring(void);
608void do_put_on(object *, boolean);
609void remove_ring(void);
610void un_put_on(object *);
611void gr_ring(object *, boolean);
612void inv_rings(void);
613void ring_stats(boolean);
614
615/* room.c */
616void light_up_room(int);
617void light_passage(int, int);
618void darken_room(short);
619char get_dungeon_char(int, int);
620char get_mask_char(unsigned short);
621void gr_row_col(short *, short *, unsigned short);
622short gr_room(void);
623short party_objects(short);
624short get_room_number(int, int);
625boolean is_all_connected(void);
626void draw_magic_map(void);
627void dr_course(object *, boolean, short, short);
628void edit_opts(void);
629void do_shell(void);
630
631/* save.c */
632void save_game(void);
633void save_into_file(const char *);
634void restore(const char *);
635
636/* score.c */
637void killed_by(const object *, short);
638void win(void);
639void quit(boolean);
640void put_scores(const object *, short);
641boolean is_vowel(short);
642void xxxx(char *, short);
643long xxx(boolean);
644
645/* spec_hit.c */
646void special_hit(object *);
647void rust(object *);
648void cough_up(object *);
649boolean seek_gold(object *);
650void check_gold_seeker(object *);
651boolean check_imitator(object *);
652boolean imitating(short, short);
653boolean m_confuse(object *);
654boolean flame_broil(object *);
655
656/* throw.c */
657void throw(void);
658void rand_around(short, short *, short *);
659
660/* trap.c */
661void trap_player(short, short);
662void add_traps(void);
663void id_trap(void);
664void show_traps(void);
665void search(short, boolean);
666
667/* use.c */
668void quaff(void);
669void read_scroll(void);
670void vanish(object *, short, object *);
671void eat(void);
672void tele(void);
673void hallucinate(void);
674void unhallucinate(void);
675void unblind(void);
676void relight(void);
677void take_a_nap(void);
678void cnfs(void);
679void unconfuse(void);
680
681/* zap.c */
682void zapp(void);
683void wizardize(void);
684void bounce(short, short, short, short, short);
685
686/*
687 * external variable declarations.
688 */
689extern char hunger_str[HUNGER_STR_LEN];
690extern char login_name[MAX_OPT_LEN];
691extern const char *error_file;