Debian Codegraph @

terps/agility/exec.h

raw symbols SCIP
1 /* exec.h-- Header file for verb execution routines */
2 /* Copyright (C) 1996-1999,2001 Robert Masenten */
3 /* This program may be redistributed under the terms of the
4 GNU General Public License, version 2; see agility.h for details. */
5 /* */
6 /* This is part of the source for AGiliTy: the (Mostly) Universal */
7 /* AGT Interpreter */
8
9
10 #ifndef global /* Don't touch this */
11 #define global extern
12 #define global_defined_exec
13 #endif
14
15
16
17 /* This contains the decoding of the current instruction */
18 typedef struct {
19 integer op;
20 int arg1;
21 int arg2;
22 int optype;
23 int argcnt; /* Actual number of argument words present */
24 const opdef *opdata;
25 const char *errmsg;
26 rbool disambig; /* Trigger disambiguation? */
27 rbool negate; /* NOT? (cond token only) */
28 rbool failmsg; /* Run only on failure? */
29 rbool endor; /* End any OR blocks? (action tokens, mainly) */
30 } op_rec;
31
32
33
34 /* The following determines if we are doing disambiguation
35 or actually executing a verb */
36 global uchar do_disambig; /* 0= execution
37 1= disambiguating noun
38 2= disambiguating object */
39
40
41 /* Flags used during turn execution */
42 global rbool beforecmd; /* Only used by 1.8x games */
43 global rbool supress_debug; /* Causes debugging info to _not_ be printed
44 even if debugging is on; used by disambiguator
45 and to supress ANY commands */
46 global rbool was_metaverb; /* Was the verb that just executed a metaverb? */
47 /* Metaverbs are commands that should not take game time
48 to execute: SAVE, RESTORE, RESTART, QUIT, SCRIPT, UNSCRIPT,
49 NOTIFY, SCORE, etc. */
50 global integer oldloc; /* Save old location for NO_BLOCK_HOSTILE purposes */
51
52 /* This is a hack to pass the subroutine number from exec_token
53 back to scan_metacommand when a DoSubroutine is done */
54 global integer subcall_arg;
55
56 /* This fixes a bug in the original AGT spec, causing "actor, verb ..."
57 commands to misfire if there is more than one creature of the same
58 name. */
59 global integer *creat_fix;
60
61
62 /* -------------------------------------------------------------------- */
63 /* Defined in EXEC.C */
64 /* -------------------------------------------------------------------- */
65 void raw_lineout(const char *s, rbool do_repl,
66 int context, const char *pword);
67 void msgout(int msgnum,rbool add_nl);
68 void sysmsg(int msgid,char *s);
69 void alt_sysmsg(int msgid,char *s,
70 parse_rec *new_dobjrec,parse_rec *new_iobjrec);
71 void sysmsgd(int msgid,char *s,parse_rec *new_dobj_rec);
72
73 rbool ask_question(int qnum);
74 void increment_turn(void);
75
76 /* Warning: the following function rfrees <ans> */
77 rbool match_answer(char *ans, int anum);
78
79 void look_room(void);
80 void runptr(int i, descr_ptr dp[], char *msg, int msgid,
81 parse_rec *nounrec,parse_rec *objrec);
82
83 int normalize_time(int tnum); /* Convert hhmm so mm<60 */
84 void add_time(int dt);
85
86
87 /* -------------------------------------------------------------------- */
88 /* Defined in OBJECT.C */
89 /* -------------------------------------------------------------------- */
90 parse_rec *make_parserec(int obj,parse_rec *rec);
91 parse_rec *copy_parserec(parse_rec *rec);
92 void free_all_parserec(void); /* Freeds doj_rec, iobj_rec, and actor_rec */
93
94 rbool in_scope(int item);
95 rbool islit(void);
96 rbool it_possess(int item);
97 rbool it_proper(int item);
98 rbool it_isweapon(int item);
99 rbool it_door(int obj,word noun); /* Is obj a door? */
100 rbool is_within(integer obj1, integer obj2, rbool stop_if_closed);
101
102 integer it_room(int item); /* Returns the room that the item is in */
103
104 int lightcheck(int parent,int roomlight,rbool active);
105 /* If active is false, we don't care if the light is actually working. */
106
107 #define it_move(a,b) it_reposition(a,b,0)
108 #define it_destroy(item) it_move(item,0)
109 #define get_obj(dobj) it_move(dobj,1)
110 #define drop_obj(dobj) it_move(dobj,loc+first_room)
111
112 void it_reposition(int item,int newloc,rbool save_pos);
113 void goto_room(int newroom);
114
115 void it_describe(int dobj);
116 int print_contents(int obj,int ind_lev);
117
118 void recompute_score(void);
119
120 int check_fit(int obj1, int obj2);
121
122 /* And its possible return values: */
123
124 #define FIT_OK 0 /* Fits */
125 #define FIT_WEIGHT 1 /* Too heavy [*] */
126 #define FIT_NETWEIGHT 2 /* With other stuff is too heavy [*] */
127 #define FIT_SIZE 3 /* Too big */
128 #define FIT_NETSIZE 4 /* With other stuff is too big */
129 /* [*]-- These can only occur if obj2==1 or for ME/1.5-1.7 */
130
131
132 long getprop(int obj, int prop);
133 void setprop(int obj, int prop, long val);
134 rbool getattr(int obj, int prop);
135 void setattr(int obj, int prop, rbool val);
136
137 rbool matchclass(int obj, int oclass);
138
139 /* ---------------------------------------------------------------------- */
140 /* Define in RUNVERB.C */
141 /* ---------------------------------------------------------------------- */
142
143 /* Verbs actually used elsewhere in th interpreter */
144 void v_inventory(void);
145 void v_look(void);
146 void v_listexit(void);
147
148 /* The routine that actually runs the current player command */
149 void exec_verb(void);
150
151
152 /* ---------------------------------------------------------------------- */
153 /* In METACOMMAND.C */
154 /* ---------------------------------------------------------------------- */
155 /* The main routine to search the metacommand list and run the appropriate
156 meta-commands */
157 int scan_metacommand(integer m_actor,int vcode,
158 integer m_dobj, word m_prep, integer m_iobj,
159 int *redir_flag);
160
161 /* The type checking routine */
162 rbool argvalid(int argtype,int arg);
163
164 /* ---------------------------------------------------------------------- */
165 /* In TOKEN.C */
166 /* ---------------------------------------------------------------------- */
167 int exec_instr(op_rec *oprec); /* Execute instruction */
168 long pop_expr_stack(void); /* Wrapper around routine to access TOS */
169
170 /* ---------------------------------------------------------------------- */
171 /* Defined in DEBUGCMD.C */
172 /* ---------------------------------------------------------------------- */
173 void get_debugcmd(void); /* Get and execute debugging commands */
174
175
176 /* ------------------------------------------------------------------- */
177 /* Macros for getting information about items */
178 /* (mainly used to blackbox the difference between nouns and creatures) */
179 /* -------------------------------------------------------------------- */
180
181 /* A note on object codes:
182 <0 obj is a 'virtual' object, existing only as the word
183 dict[-obj], e.g. DOOR, flag nouns, global nouns
184 0 No object (or any object)
185 1 Self(i.e. the player)
186 first_room..last_room Rooms
187 first_noun..last_noun Nouns
188 first_creat..last_creat Creatures
189 1000 Being worn by the player */
190
191
192 /* The following macro loops over the contents of an object */
193 #define contloop(i,obj) for(i=it_contents(obj);i!=0;i=it_next(i))
194 #define safecontloop(i,j,obj) for(i=it_contents(obj),j=it_next(i); \
195 i!=0;i=j,j=it_next(i))
196
197 #define cnt_val(c) ((c)==-1 ? 0 : (c))
198
199
200 /* -------------------------------------------------------------------- */
201 /* These are the macros that should usually be used to determine */
202 /* information about the objects in the game, unless the object type */
203 /* is definitely known */
204 /* ------------------------------------------------------------------- */
205
206 #define it_on(item) nounattr(item,on)
207 #define it_group(item) creatattr(item,groupmemb)
208 #define it_adj(item) objattr(item,adj)
209 #define it_pushable(item) nounattr(item,pushable)
210 #define it_pullable(item) nounattr(item,pullable)
211 #define it_turnable(item) nounattr(item,turnable)
212 #define it_playable(item) nounattr(item,playable)
213 #define it_plur(item) nounattr(item,plural)
214 #define it_gender(item) creatattr(item,gender)
215
216 #define it_pict(item) objattr(item,pict)
217 #define it_class(item) anyattr(item,oclass)
218 #define it_next(item) objattr(item,next)
219 #define it_isglobal(item) objattr(item,isglobal)
220 #define it_flagnum(item) objattr(item,flagnum)
221 #define it_seen(item) anyattr(item,seen)
222
223
224 #define it_name(item) objattr2(item,name,(item<0) ? -item : 0)
225 #define it_open(item) nounattr2(item,open, tcreat(item) || \
226 (tdoor(item) && !room[loc].locked_door))
227
228 /* This checks to make sure the object isn't unmovable. */
229 /* (As such, all non-nouns automatically pass) */
230 #define it_canmove(item) (!tnoun(item) || noun[(item)-first_noun].movable)
231
232
233 #ifdef IT_MACRO
234 #define it_contents(item) objattr2(item,contents,\
235 roomattr2(item,contents,\
236 (item==1) ? player_contents : \
237 (item==1000) ? player_worn : 0))
238 #define it_lockable(item) nounattr2(item,lockable, (tdoor(item) ? 1 : 0) )
239 #define it_locked(item,name) nounattr2(item,locked,\
240 (tdoor(item) && room[loc].locked_door ? \
241 1 : 0))
242 #else
243 int it_contents(integer obj);
244 rbool it_lockable(integer obj,word noun);
245 rbool it_locked(integer obj, word noun);
246 #endif
247
248
249 #ifdef global_defined_exec
250 #undef global
251 #undef global_defined_exec
252 #endif
253
254