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