1 |
elmex |
1.1 |
/* |
2 |
pippijn |
1.36 |
* CrossFire, A Multiplayer game for X-windows |
3 |
|
|
* |
4 |
|
|
* Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 |
|
|
* Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 |
|
|
* Copyright (C) 1992 Frank Tore Johansen |
7 |
|
|
* |
8 |
|
|
* This program is free software; you can redistribute it and/or modify |
9 |
|
|
* it under the terms of the GNU General Public License as published by |
10 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
11 |
|
|
* (at your option) any later version. |
12 |
|
|
* |
13 |
|
|
* This program is distributed in the hope that it will be useful, |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
|
|
* GNU General Public License for more details. |
17 |
|
|
* |
18 |
|
|
* You should have received a copy of the GNU General Public License |
19 |
|
|
* along with this program; if not, write to the Free Software |
20 |
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 |
|
|
* |
22 |
|
|
* The authors can be reached via e-mail at <crossfire@schmorp.de> |
23 |
|
|
*/ |
24 |
elmex |
1.1 |
|
25 |
|
|
#include <global.h> |
26 |
|
|
#include <loader.h> |
27 |
root |
1.21 |
#include <sproto.h> |
28 |
|
|
|
29 |
elmex |
1.1 |
/* Handles misc. input request - things like hash table, malloc, maps, |
30 |
|
|
* who, etc. |
31 |
|
|
*/ |
32 |
|
|
|
33 |
|
|
/* This command dumps the body information for object *op. |
34 |
|
|
* it doesn't care what the params are. |
35 |
|
|
* This is mostly meant as a debug command. |
36 |
|
|
*/ |
37 |
root |
1.7 |
int |
38 |
|
|
command_body (object *op, char *params) |
39 |
elmex |
1.1 |
{ |
40 |
root |
1.7 |
int i; |
41 |
elmex |
1.1 |
|
42 |
root |
1.7 |
/* Too hard to try and make a header that lines everything up, so just |
43 |
|
|
* give a description. |
44 |
|
|
*/ |
45 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "The first column is the name of the body location."); |
46 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "The second column is how many of those locations your body has."); |
47 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "The third column is how many slots in that location are available."); |
48 |
|
|
for (i = 0; i < NUM_BODY_LOCATIONS; i++) |
49 |
|
|
{ |
50 |
|
|
/* really debugging - normally body_used should not be set to anything |
51 |
|
|
* if body_info isn't also set. |
52 |
|
|
*/ |
53 |
|
|
if (op->body_info[i] || op->body_used[i]) |
54 |
|
|
{ |
55 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "%-30s %5d %5d", body_locations[i].use_name, op->body_info[i], op->body_used[i]); |
56 |
root |
1.3 |
} |
57 |
elmex |
1.1 |
} |
58 |
root |
1.7 |
if (!QUERY_FLAG (op, FLAG_USE_ARMOUR)) |
59 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You are not allowed to wear armor"); |
60 |
|
|
if (!QUERY_FLAG (op, FLAG_USE_WEAPON)) |
61 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You are not allowed to use weapons"); |
62 |
elmex |
1.1 |
|
63 |
root |
1.7 |
return 1; |
64 |
elmex |
1.1 |
} |
65 |
|
|
|
66 |
|
|
|
67 |
root |
1.7 |
int |
68 |
|
|
command_motd (object *op, char *params) |
69 |
elmex |
1.1 |
{ |
70 |
root |
1.7 |
display_motd (op); |
71 |
|
|
return 1; |
72 |
elmex |
1.1 |
} |
73 |
|
|
|
74 |
|
|
/* |
75 |
|
|
* Pretty much identical to current map_info, but on a bigger scale |
76 |
|
|
* This function returns the name of the players current region, and |
77 |
|
|
* a description of it. It is there merely for flavour text. |
78 |
|
|
*/ |
79 |
root |
1.7 |
void |
80 |
|
|
current_region_info (object *op) |
81 |
|
|
{ |
82 |
root |
1.38 |
if (region *reg = op->region ()) |
83 |
root |
1.44 |
new_draw_info_format (NDI_UNIQUE, 0, op, "You are %s.\n%s", ®->longname, ®->msg); |
84 |
elmex |
1.1 |
} |
85 |
|
|
|
86 |
root |
1.7 |
void |
87 |
|
|
current_map_info (object *op) |
88 |
|
|
{ |
89 |
root |
1.9 |
maptile *m = op->map; |
90 |
elmex |
1.1 |
|
91 |
root |
1.7 |
if (!m) |
92 |
|
|
return; |
93 |
elmex |
1.1 |
|
94 |
root |
1.44 |
new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) %s", &m->name, &m->path, &op->region ()->longname); |
95 |
elmex |
1.1 |
|
96 |
root |
1.7 |
if (QUERY_FLAG (op, FLAG_WIZ)) |
97 |
root |
1.38 |
new_draw_info_format (NDI_UNIQUE, 0, op, |
98 |
|
|
"players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld", |
99 |
|
|
m->players, m->difficulty, m->width, m->height, m->enter_x, m->enter_y, m->timeout); |
100 |
elmex |
1.1 |
|
101 |
root |
1.7 |
if (m->msg) |
102 |
|
|
new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
103 |
elmex |
1.1 |
} |
104 |
|
|
|
105 |
|
|
#ifdef DEBUG_MALLOC_LEVEL |
106 |
root |
1.7 |
int |
107 |
|
|
command_malloc_verify (object *op, char *parms) |
108 |
elmex |
1.1 |
{ |
109 |
root |
1.7 |
extern int malloc_verify (void); |
110 |
elmex |
1.1 |
|
111 |
root |
1.7 |
if (!malloc_verify ()) |
112 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Heap is corrupted."); |
113 |
|
|
else |
114 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Heap checks out OK."); |
115 |
|
|
return 1; |
116 |
|
|
} |
117 |
elmex |
1.1 |
#endif |
118 |
|
|
|
119 |
root |
1.7 |
int |
120 |
|
|
command_whereabouts (object *op, char *params) |
121 |
|
|
{ |
122 |
root |
1.38 |
//TODO: should obviously not waste space in struct region for this. |
123 |
root |
1.7 |
/* |
124 |
|
|
* reset the counter on the region, then use it to store the number of |
125 |
|
|
* players there. |
126 |
|
|
* I don't know how thread-safe this would be, I suspect not very.... |
127 |
|
|
*/ |
128 |
root |
1.41 |
for_all_regions (rgn) |
129 |
|
|
rgn->counter = 0; |
130 |
root |
1.38 |
|
131 |
root |
1.28 |
for_all_players (pl) |
132 |
root |
1.38 |
if (pl->ob->map) |
133 |
|
|
++pl->ob->region ()->counter; |
134 |
root |
1.7 |
|
135 |
|
|
/* we only want to print out by places with a 'longname' field... */ |
136 |
root |
1.41 |
for_all_regions (rgn) |
137 |
root |
1.7 |
{ |
138 |
root |
1.41 |
if (!rgn->longname && rgn->counter > 0) |
139 |
root |
1.7 |
{ |
140 |
root |
1.41 |
if (rgn->parent) |
141 |
root |
1.7 |
{ |
142 |
root |
1.41 |
rgn->parent->counter += rgn->counter; |
143 |
|
|
rgn->counter = 0; |
144 |
root |
1.3 |
} |
145 |
root |
1.7 |
else /*uh oh, we shouldn't be here. */ |
146 |
root |
1.41 |
LOG (llevError, "command_whereabouts() Region %s with no longname has no parent", &rgn->name); |
147 |
root |
1.3 |
} |
148 |
|
|
} |
149 |
root |
1.38 |
|
150 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, "In the world currently there are:"); |
151 |
root |
1.38 |
|
152 |
root |
1.41 |
for_all_regions (rgn) |
153 |
|
|
if (rgn->counter) |
154 |
root |
1.44 |
new_draw_info_format (NDI_UNIQUE, 0, op, "%u players %s", rgn->counter, &rgn->longname); |
155 |
root |
1.38 |
|
156 |
root |
1.7 |
return 1; |
157 |
elmex |
1.1 |
} |
158 |
|
|
|
159 |
|
|
typedef struct |
160 |
root |
1.7 |
{ |
161 |
|
|
char namebuf[MAX_BUF]; |
162 |
|
|
int login_order; |
163 |
|
|
} chars_names; |
164 |
elmex |
1.1 |
|
165 |
root |
1.7 |
int |
166 |
|
|
command_mapinfo (object *op, char *params) |
167 |
elmex |
1.1 |
{ |
168 |
root |
1.7 |
current_map_info (op); |
169 |
|
|
return 1; |
170 |
|
|
} |
171 |
elmex |
1.1 |
|
172 |
root |
1.7 |
int |
173 |
|
|
command_whereami (object *op, char *params) |
174 |
elmex |
1.1 |
{ |
175 |
root |
1.7 |
current_region_info (op); |
176 |
|
|
return 1; |
177 |
elmex |
1.1 |
} |
178 |
|
|
|
179 |
root |
1.7 |
int |
180 |
|
|
command_time (object *op, char *params) |
181 |
elmex |
1.1 |
{ |
182 |
root |
1.2 |
print_tod (op); |
183 |
|
|
return 1; |
184 |
|
|
} |
185 |
elmex |
1.1 |
|
186 |
root |
1.7 |
int |
187 |
|
|
command_weather (object *op, char *params) |
188 |
elmex |
1.1 |
{ |
189 |
root |
1.33 |
#if 0 |
190 |
root |
1.7 |
int wx, wy, temp, sky; |
191 |
|
|
char buf[MAX_BUF]; |
192 |
|
|
|
193 |
|
|
if (settings.dynamiclevel < 1) |
194 |
|
|
return 1; |
195 |
|
|
|
196 |
|
|
if (op->map == NULL) |
197 |
|
|
return 1; |
198 |
|
|
|
199 |
|
|
if (worldmap_to_weathermap (op->x, op->y, &wx, &wy, op->map) != 0) |
200 |
|
|
return 1; |
201 |
|
|
|
202 |
|
|
if (QUERY_FLAG (op, FLAG_WIZ)) |
203 |
|
|
{ |
204 |
|
|
/* dump the weather, Dm style! Yo! */ |
205 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Real temp: %d", real_world_temperature (op->x, op->y, op->map)); |
206 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Base temp: %d", weathermap[wx][wy].temp); |
207 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Humid: %d", weathermap[wx][wy].humid); |
208 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Wind: dir=%d speed=%d", weathermap[wx][wy].winddir, weathermap[wx][wy].windspeed); |
209 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Pressure: %d", weathermap[wx][wy].pressure); |
210 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Avg Elevation: %d", weathermap[wx][wy].avgelev); |
211 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Rainfall: %d Water: %d", weathermap[wx][wy].rainfall, weathermap[wx][wy].water); |
212 |
|
|
} |
213 |
|
|
|
214 |
|
|
temp = real_world_temperature (op->x, op->y, op->map); |
215 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "It's currently %d degrees " "Centigrade out.", temp); |
216 |
|
|
|
217 |
|
|
/* humid */ |
218 |
|
|
if (weathermap[wx][wy].humid < 20) |
219 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is very dry."); |
220 |
|
|
else if (weathermap[wx][wy].humid < 40) |
221 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is very comfortable today."); |
222 |
|
|
else if (weathermap[wx][wy].humid < 60) |
223 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is a bit muggy."); |
224 |
|
|
else if (weathermap[wx][wy].humid < 80) |
225 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is muggy."); |
226 |
|
|
else |
227 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is uncomfortably muggy."); |
228 |
elmex |
1.1 |
|
229 |
root |
1.7 |
/* wind */ |
230 |
|
|
switch (weathermap[wx][wy].winddir) |
231 |
|
|
{ |
232 |
|
|
case 1: |
233 |
|
|
sprintf (buf, "north"); |
234 |
|
|
break; |
235 |
|
|
case 2: |
236 |
|
|
sprintf (buf, "northeast"); |
237 |
|
|
break; |
238 |
|
|
case 3: |
239 |
|
|
sprintf (buf, "east"); |
240 |
|
|
break; |
241 |
|
|
case 4: |
242 |
|
|
sprintf (buf, "southeast"); |
243 |
|
|
break; |
244 |
|
|
case 5: |
245 |
|
|
sprintf (buf, "south"); |
246 |
|
|
break; |
247 |
|
|
case 6: |
248 |
|
|
sprintf (buf, "southwest"); |
249 |
|
|
break; |
250 |
|
|
case 7: |
251 |
|
|
sprintf (buf, "west"); |
252 |
|
|
break; |
253 |
|
|
case 8: |
254 |
|
|
sprintf (buf, "northwest"); |
255 |
|
|
break; |
256 |
|
|
} |
257 |
|
|
if (weathermap[wx][wy].windspeed < 5) |
258 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "There is a mild breeze " "coming from the %s.", buf); |
259 |
|
|
else if (weathermap[wx][wy].windspeed < 10) |
260 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "There is a strong breeze " "coming from the %s.", buf); |
261 |
|
|
else if (weathermap[wx][wy].windspeed < 15) |
262 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "There is a light wind " "coming from the %s.", buf); |
263 |
|
|
else if (weathermap[wx][wy].windspeed < 25) |
264 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "There is a strong wind " "coming from the %s.", buf); |
265 |
|
|
else if (weathermap[wx][wy].windspeed < 35) |
266 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "There is a heavy wind " "coming from the %s.", buf); |
267 |
|
|
else |
268 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "The wind from the %s is " "incredibly strong!", buf); |
269 |
elmex |
1.1 |
|
270 |
root |
1.7 |
sky = weathermap[wx][wy].sky; |
271 |
|
|
if (temp <= 0 && sky > SKY_OVERCAST && sky < SKY_FOG) |
272 |
|
|
sky += 10; /*let it snow */ |
273 |
|
|
switch (sky) |
274 |
|
|
{ |
275 |
|
|
case SKY_CLEAR: |
276 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "There isn''t a cloud in the sky."); |
277 |
|
|
break; |
278 |
|
|
case SKY_LIGHTCLOUD: |
279 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "There are a few light clouds in the sky."); |
280 |
|
|
break; |
281 |
|
|
case SKY_OVERCAST: |
282 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "The sky is cloudy and dreary."); |
283 |
|
|
break; |
284 |
|
|
case SKY_LIGHT_RAIN: |
285 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is raining softly."); |
286 |
|
|
break; |
287 |
|
|
case SKY_RAIN: |
288 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is raining."); |
289 |
|
|
break; |
290 |
|
|
case SKY_HEAVY_RAIN: |
291 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is raining heavily."); |
292 |
|
|
break; |
293 |
|
|
case SKY_HURRICANE: |
294 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "There is a heavy storm! You should go inside!"); |
295 |
|
|
break; |
296 |
|
|
case SKY_FOG: |
297 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It''s foggy and miserable."); |
298 |
|
|
break; |
299 |
|
|
case SKY_HAIL: |
300 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It''s hailing out! Take cover!"); |
301 |
|
|
break; |
302 |
|
|
case SKY_LIGHT_SNOW: |
303 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Snow is gently falling from the sky."); |
304 |
|
|
break; |
305 |
|
|
case SKY_SNOW: |
306 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It''s snowing out."); |
307 |
|
|
break; |
308 |
|
|
case SKY_HEAVY_SNOW: |
309 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "The snow is falling very heavily now."); |
310 |
|
|
break; |
311 |
|
|
case SKY_BLIZZARD: |
312 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); |
313 |
|
|
break; |
314 |
elmex |
1.1 |
} |
315 |
root |
1.33 |
#endif |
316 |
root |
1.7 |
return 1; |
317 |
elmex |
1.1 |
} |
318 |
|
|
|
319 |
root |
1.7 |
int |
320 |
|
|
command_hiscore (object *op, char *params) |
321 |
elmex |
1.1 |
{ |
322 |
root |
1.7 |
display_high_score (op, op == NULL ? 9999 : 50, params); |
323 |
|
|
return 1; |
324 |
|
|
} |
325 |
elmex |
1.1 |
|
326 |
root |
1.7 |
int |
327 |
|
|
command_debug (object *op, char *params) |
328 |
elmex |
1.1 |
{ |
329 |
root |
1.7 |
int i; |
330 |
|
|
char buf[MAX_BUF]; |
331 |
|
|
|
332 |
|
|
if (params == NULL || !sscanf (params, "%d", &i)) |
333 |
|
|
{ |
334 |
|
|
sprintf (buf, "Global debug level is %d.", settings.debug); |
335 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, buf); |
336 |
elmex |
1.1 |
return 1; |
337 |
|
|
} |
338 |
root |
1.7 |
settings.debug = (enum LogLevel) FABS (i); |
339 |
|
|
sprintf (buf, "Set debug level to %d.", i); |
340 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, buf); |
341 |
|
|
return 1; |
342 |
|
|
} |
343 |
elmex |
1.1 |
|
344 |
|
|
|
345 |
|
|
/* |
346 |
|
|
* Those dumps should be just one dump with good parser |
347 |
|
|
*/ |
348 |
|
|
|
349 |
root |
1.7 |
int |
350 |
|
|
command_dumpbelow (object *op, char *params) |
351 |
elmex |
1.1 |
{ |
352 |
root |
1.7 |
if (op && op->below) |
353 |
|
|
{ |
354 |
root |
1.14 |
char *dump = dump_object (op->below); |
355 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, dump); |
356 |
|
|
free (dump); |
357 |
elmex |
1.1 |
/* Let's push that item on the dm's stack */ |
358 |
root |
1.7 |
dm_stack_push (op->contr, op->below->count); |
359 |
|
|
} |
360 |
elmex |
1.1 |
return 0; |
361 |
|
|
} |
362 |
|
|
|
363 |
root |
1.7 |
int |
364 |
|
|
command_dumpfriendlyobjects (object *op, char *params) |
365 |
elmex |
1.1 |
{ |
366 |
root |
1.7 |
dump_friendly_objects (); |
367 |
elmex |
1.1 |
return 0; |
368 |
|
|
} |
369 |
|
|
|
370 |
root |
1.7 |
int |
371 |
|
|
command_printlos (object *op, char *params) |
372 |
elmex |
1.1 |
{ |
373 |
|
|
if (op) |
374 |
root |
1.7 |
print_los (op); |
375 |
elmex |
1.1 |
return 0; |
376 |
|
|
} |
377 |
|
|
|
378 |
|
|
|
379 |
root |
1.7 |
int |
380 |
|
|
command_version (object *op, char *params) |
381 |
elmex |
1.1 |
{ |
382 |
root |
1.7 |
version (op); |
383 |
|
|
return 0; |
384 |
elmex |
1.1 |
} |
385 |
|
|
|
386 |
|
|
#ifndef BUG_LOG |
387 |
root |
1.7 |
# define BUG_LOG "bug_log" |
388 |
elmex |
1.1 |
#endif |
389 |
root |
1.7 |
void |
390 |
|
|
bug_report (const char *reportstring) |
391 |
|
|
{ |
392 |
|
|
FILE *fp; |
393 |
|
|
|
394 |
|
|
if ((fp = fopen (BUG_LOG, "a")) != NULL) |
395 |
|
|
{ |
396 |
|
|
fprintf (fp, "%s\n", reportstring); |
397 |
|
|
fclose (fp); |
398 |
|
|
} |
399 |
|
|
else |
400 |
|
|
{ |
401 |
|
|
LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno)); |
402 |
elmex |
1.1 |
} |
403 |
root |
1.7 |
} |
404 |
|
|
|
405 |
|
|
int |
406 |
|
|
command_output_sync (object *op, char *params) |
407 |
|
|
{ |
408 |
|
|
int val; |
409 |
|
|
|
410 |
|
|
if (!params) |
411 |
|
|
{ |
412 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time is presently %d", op->contr->outputs_sync); |
413 |
|
|
return 1; |
414 |
|
|
} |
415 |
|
|
val = atoi (params); |
416 |
|
|
if (val > 0) |
417 |
|
|
{ |
418 |
|
|
op->contr->outputs_sync = val; |
419 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time now set to %d", op->contr->outputs_sync); |
420 |
|
|
} |
421 |
|
|
else |
422 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_sync."); |
423 |
elmex |
1.1 |
|
424 |
root |
1.7 |
return 1; |
425 |
elmex |
1.1 |
} |
426 |
|
|
|
427 |
root |
1.7 |
int |
428 |
|
|
command_output_count (object *op, char *params) |
429 |
elmex |
1.1 |
{ |
430 |
root |
1.7 |
int val; |
431 |
elmex |
1.1 |
|
432 |
root |
1.7 |
if (!params) |
433 |
|
|
{ |
434 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Output count is presently %d", op->contr->outputs_count); |
435 |
|
|
return 1; |
436 |
elmex |
1.1 |
} |
437 |
root |
1.7 |
val = atoi (params); |
438 |
|
|
if (val > 0) |
439 |
|
|
{ |
440 |
|
|
op->contr->outputs_count = val; |
441 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Output count now set to %d", op->contr->outputs_count); |
442 |
|
|
} |
443 |
|
|
else |
444 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_count."); |
445 |
elmex |
1.1 |
|
446 |
root |
1.7 |
return 1; |
447 |
elmex |
1.1 |
} |
448 |
|
|
|
449 |
|
|
/* Prints out some useful information for the character. Everything we print |
450 |
|
|
* out can be determined by the docs, so we aren't revealing anything extra - |
451 |
|
|
* rather, we are making it convenient to find the values. params have |
452 |
|
|
* no meaning here. |
453 |
|
|
*/ |
454 |
root |
1.7 |
int |
455 |
|
|
command_statistics (object *pl, char *params) |
456 |
elmex |
1.1 |
{ |
457 |
root |
1.7 |
if (!pl->contr) |
458 |
|
|
return 1; |
459 |
root |
1.18 |
new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %" PRId64, pl->stats.exp); |
460 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %" PRId64, level_exp (pl->level + 1, pl->expmul)); |
461 |
root |
1.7 |
new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max"); |
462 |
elmex |
1.1 |
|
463 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, pl, "Str %2d/ %3d/%3d", |
464 |
|
|
pl->contr->orig_stats.Str, pl->stats.Str, 20 + pl->arch->clone.stats.Str); |
465 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, "Dex %2d/ %3d/%3d", |
466 |
|
|
pl->contr->orig_stats.Dex, pl->stats.Dex, 20 + pl->arch->clone.stats.Dex); |
467 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, "Con %2d/ %3d/%3d", |
468 |
|
|
pl->contr->orig_stats.Con, pl->stats.Con, 20 + pl->arch->clone.stats.Con); |
469 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, "Int %2d/ %3d/%3d", |
470 |
|
|
pl->contr->orig_stats.Int, pl->stats.Int, 20 + pl->arch->clone.stats.Int); |
471 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, "Wis %2d/ %3d/%3d", |
472 |
|
|
pl->contr->orig_stats.Wis, pl->stats.Wis, 20 + pl->arch->clone.stats.Wis); |
473 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, "Pow %2d/ %3d/%3d", |
474 |
|
|
pl->contr->orig_stats.Pow, pl->stats.Pow, 20 + pl->arch->clone.stats.Pow); |
475 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, "Cha %2d/ %3d/%3d", |
476 |
|
|
pl->contr->orig_stats.Cha, pl->stats.Cha, 20 + pl->arch->clone.stats.Cha); |
477 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, "\nAttack Mode: %s", pl->contr->peaceful ? "Peaceful" : "Hostile"); |
478 |
elmex |
1.1 |
|
479 |
root |
1.7 |
/* Can't think of anything else to print right now */ |
480 |
|
|
return 0; |
481 |
elmex |
1.1 |
} |
482 |
|
|
|
483 |
root |
1.7 |
int |
484 |
|
|
command_fix_me (object *op, char *params) |
485 |
elmex |
1.1 |
{ |
486 |
root |
1.7 |
sum_weight (op); |
487 |
root |
1.27 |
op->update_stats (); |
488 |
root |
1.7 |
return 1; |
489 |
elmex |
1.1 |
} |
490 |
|
|
|
491 |
root |
1.7 |
int |
492 |
|
|
command_logs (object *op, char *params) |
493 |
elmex |
1.1 |
{ |
494 |
root |
1.10 |
new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
495 |
elmex |
1.1 |
|
496 |
root |
1.7 |
return 1; |
497 |
elmex |
1.1 |
} |
498 |
|
|
|
499 |
root |
1.7 |
int |
500 |
|
|
command_applymode (object *op, char *params) |
501 |
elmex |
1.1 |
{ |
502 |
root |
1.7 |
unapplymode unapply = op->contr->unapply; |
503 |
|
|
static const char *const types[] = { "nochoice", "never", "always" }; |
504 |
elmex |
1.1 |
|
505 |
root |
1.7 |
if (!params) |
506 |
|
|
{ |
507 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "applymode is set to %s", types[op->contr->unapply]); |
508 |
|
|
return 1; |
509 |
|
|
} |
510 |
|
|
|
511 |
|
|
if (!strcmp (params, "nochoice")) |
512 |
|
|
op->contr->unapply = unapply_nochoice; |
513 |
|
|
else if (!strcmp (params, "never")) |
514 |
|
|
op->contr->unapply = unapply_never; |
515 |
|
|
else if (!strcmp (params, "always")) |
516 |
|
|
op->contr->unapply = unapply_always; |
517 |
|
|
else |
518 |
|
|
{ |
519 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params); |
520 |
|
|
return 0; |
521 |
|
|
} |
522 |
root |
1.38 |
|
523 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s", |
524 |
|
|
(unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]); |
525 |
|
|
return 1; |
526 |
elmex |
1.1 |
} |
527 |
|
|
|
528 |
root |
1.7 |
int |
529 |
|
|
command_bowmode (object *op, char *params) |
530 |
elmex |
1.1 |
{ |
531 |
root |
1.7 |
bowtype_t oldtype = op->contr->bowtype; |
532 |
|
|
static const char *const types[] = { "normal", "threewide", "spreadshot", "firenorth", |
533 |
|
|
"firene", "fireeast", "firese", "firesouth", |
534 |
|
|
"firesw", "firewest", "firenw", "bestarrow" |
535 |
|
|
}; |
536 |
|
|
char buf[MAX_BUF]; |
537 |
|
|
int i, found; |
538 |
|
|
|
539 |
|
|
if (!params) |
540 |
|
|
{ |
541 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode is set to %s", types[op->contr->bowtype]); |
542 |
|
|
return 1; |
543 |
|
|
} |
544 |
|
|
|
545 |
|
|
for (i = 0, found = 0; i <= bow_bestarrow; i++) |
546 |
|
|
{ |
547 |
|
|
if (!strcmp (params, types[i])) |
548 |
|
|
{ |
549 |
|
|
found++; |
550 |
|
|
op->contr->bowtype = (bowtype_t) i; |
551 |
|
|
break; |
552 |
root |
1.3 |
} |
553 |
elmex |
1.1 |
} |
554 |
root |
1.38 |
|
555 |
root |
1.7 |
if (!found) |
556 |
|
|
{ |
557 |
|
|
sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
558 |
|
|
for (i = 0; i <= bow_bestarrow; i++) |
559 |
|
|
{ |
560 |
|
|
strcat (buf, " "); |
561 |
|
|
strcat (buf, types[i]); |
562 |
|
|
if (i < bow_nw) |
563 |
|
|
strcat (buf, ","); |
564 |
|
|
else |
565 |
|
|
strcat (buf, "."); |
566 |
root |
1.3 |
} |
567 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
568 |
|
|
return 0; |
569 |
elmex |
1.1 |
} |
570 |
root |
1.38 |
|
571 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
572 |
|
|
return 1; |
573 |
elmex |
1.1 |
} |
574 |
|
|
|
575 |
root |
1.7 |
int |
576 |
|
|
command_petmode (object *op, char *params) |
577 |
elmex |
1.1 |
{ |
578 |
root |
1.7 |
petmode_t oldtype = op->contr->petmode; |
579 |
|
|
static const char *const types[] = { "normal", "sad", "defend", "arena" }; |
580 |
elmex |
1.1 |
|
581 |
root |
1.7 |
if (!params) |
582 |
|
|
{ |
583 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "petmode is set to %s", types[op->contr->petmode]); |
584 |
|
|
return 1; |
585 |
|
|
} |
586 |
|
|
|
587 |
|
|
if (!strcmp (params, "normal")) |
588 |
|
|
op->contr->petmode = pet_normal; |
589 |
|
|
else if (!strcmp (params, "sad")) |
590 |
|
|
op->contr->petmode = pet_sad; |
591 |
|
|
else if (!strcmp (params, "defend")) |
592 |
|
|
op->contr->petmode = pet_defend; |
593 |
|
|
else if (!strcmp (params, "arena")) |
594 |
|
|
op->contr->petmode = pet_arena; |
595 |
|
|
else |
596 |
|
|
{ |
597 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, |
598 |
|
|
"petmode: Unknown options %s, valid options are normal," "sad (seek and destroy), defend, arena", params); |
599 |
|
|
return 0; |
600 |
|
|
} |
601 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "petmode %s set to %s", (oldtype == op->contr->petmode ? "" : "now"), types[op->contr->petmode]); |
602 |
|
|
return 1; |
603 |
elmex |
1.1 |
} |
604 |
|
|
|
605 |
root |
1.7 |
int |
606 |
|
|
command_showpets (object *op, char *params) |
607 |
elmex |
1.1 |
{ |
608 |
root |
1.7 |
objectlink *obl, *next; |
609 |
|
|
int counter = 0, target = 0; |
610 |
|
|
int have_shown_pet = 0; |
611 |
|
|
|
612 |
|
|
if (params != NULL) |
613 |
|
|
target = atoi (params); |
614 |
|
|
for (obl = first_friendly_object; obl != NULL; obl = next) |
615 |
|
|
{ |
616 |
|
|
object *ob = obl->ob; |
617 |
|
|
|
618 |
|
|
next = obl->next; |
619 |
root |
1.22 |
if (ob->owner == op) |
620 |
root |
1.7 |
{ |
621 |
|
|
if (target == 0) |
622 |
|
|
{ |
623 |
|
|
if (counter == 0) |
624 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
625 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "%d %s - level %d", ++counter, &ob->name, ob->level); |
626 |
|
|
} |
627 |
|
|
else if (!have_shown_pet && ++counter == target) |
628 |
|
|
{ |
629 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "level %d %s", ob->level, &ob->name); |
630 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "%d/%d HP, %d/%d SP", ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp); |
631 |
|
|
/* this is not a nice way to do this, it should be made to be more like the statistics command */ |
632 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Str %d", ob->stats.Str); |
633 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Dex %d", ob->stats.Dex); |
634 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Con %d", ob->stats.Con); |
635 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Int %d", ob->stats.Int); |
636 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Wis %d", ob->stats.Wis); |
637 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Cha %d", ob->stats.Cha); |
638 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Pow %d", ob->stats.Pow); |
639 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "wc %d damage %d ac %d ", ob->stats.wc, ob->stats.dam, ob->stats.ac); |
640 |
|
|
have_shown_pet = 1; |
641 |
root |
1.3 |
} |
642 |
|
|
} |
643 |
elmex |
1.1 |
} |
644 |
root |
1.7 |
if (counter == 0) |
645 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "you have no pets."); |
646 |
|
|
else if (target != 0 && have_shown_pet == 0) |
647 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
648 |
|
|
return 0; |
649 |
elmex |
1.1 |
} |
650 |
|
|
|
651 |
root |
1.7 |
int |
652 |
|
|
command_usekeys (object *op, char *params) |
653 |
elmex |
1.1 |
{ |
654 |
root |
1.7 |
usekeytype oldtype = op->contr->usekeys; |
655 |
|
|
static const char *const types[] = { "inventory", "keyrings", "containers" }; |
656 |
elmex |
1.1 |
|
657 |
root |
1.7 |
if (!params) |
658 |
|
|
{ |
659 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys is set to %s", types[op->contr->usekeys]); |
660 |
|
|
return 1; |
661 |
|
|
} |
662 |
|
|
|
663 |
|
|
if (!strcmp (params, "inventory")) |
664 |
|
|
op->contr->usekeys = key_inventory; |
665 |
|
|
else if (!strcmp (params, "keyrings")) |
666 |
|
|
op->contr->usekeys = keyrings; |
667 |
|
|
else if (!strcmp (params, "containers")) |
668 |
|
|
op->contr->usekeys = containers; |
669 |
|
|
else |
670 |
|
|
{ |
671 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys: Unknown options %s, valid options are inventory, keyrings, containers", params); |
672 |
|
|
return 0; |
673 |
|
|
} |
674 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys %s set to %s", (oldtype == op->contr->usekeys ? "" : "now"), types[op->contr->usekeys]); |
675 |
|
|
return 1; |
676 |
elmex |
1.1 |
} |
677 |
|
|
|
678 |
root |
1.7 |
int |
679 |
|
|
command_resistances (object *op, char *params) |
680 |
elmex |
1.1 |
{ |
681 |
root |
1.7 |
int i; |
682 |
elmex |
1.1 |
|
683 |
root |
1.7 |
if (!op) |
684 |
|
|
return 0; |
685 |
|
|
|
686 |
|
|
for (i = 0; i < NROFATTACKS; i++) |
687 |
|
|
{ |
688 |
|
|
if (i == ATNR_INTERNAL) |
689 |
|
|
continue; |
690 |
elmex |
1.1 |
|
691 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, "%-20s %+5d", attacktype_desc[i], op->resist[i]); |
692 |
elmex |
1.1 |
} |
693 |
|
|
|
694 |
root |
1.7 |
/* If dragon player, let's display natural resistances */ |
695 |
|
|
if (is_dragon_pl (op)) |
696 |
|
|
{ |
697 |
|
|
int attack; |
698 |
|
|
object *tmp; |
699 |
|
|
|
700 |
|
|
for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
701 |
elmex |
1.1 |
{ |
702 |
root |
1.7 |
if ((tmp->type == FORCE) && (strcmp (tmp->arch->name, "dragon_skin_force") == 0)) |
703 |
elmex |
1.1 |
{ |
704 |
root |
1.7 |
new_draw_info (NDI_UNIQUE, 0, op, "\nNatural skin resistances:"); |
705 |
|
|
for (attack = 0; attack < NROFATTACKS; attack++) |
706 |
elmex |
1.1 |
{ |
707 |
root |
1.7 |
if (atnr_is_dragon_enabled (attack)) |
708 |
elmex |
1.1 |
{ |
709 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, "%s: %d", change_resist_msg[attack], tmp->resist[attack]); |
710 |
elmex |
1.1 |
} |
711 |
|
|
} |
712 |
root |
1.7 |
break; |
713 |
elmex |
1.1 |
} |
714 |
|
|
} |
715 |
root |
1.7 |
} |
716 |
elmex |
1.1 |
|
717 |
root |
1.7 |
return 0; |
718 |
elmex |
1.1 |
} |
719 |
root |
1.7 |
|
720 |
elmex |
1.1 |
/* |
721 |
|
|
* Actual commands. |
722 |
|
|
* Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
723 |
|
|
*/ |
724 |
|
|
|
725 |
|
|
|
726 |
root |
1.7 |
static void |
727 |
|
|
help_topics (object *op, int what) |
728 |
elmex |
1.1 |
{ |
729 |
root |
1.7 |
DIR *dirp; |
730 |
|
|
struct dirent *de; |
731 |
|
|
char filename[MAX_BUF], line[80]; |
732 |
|
|
int namelen, linelen = 0; |
733 |
|
|
|
734 |
|
|
switch (what) |
735 |
|
|
{ |
736 |
root |
1.21 |
case 1: |
737 |
|
|
sprintf (filename, "%s/wizhelp", settings.datadir); |
738 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
739 |
|
|
break; |
740 |
|
|
case 3: |
741 |
|
|
sprintf (filename, "%s/mischelp", settings.datadir); |
742 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
743 |
|
|
break; |
744 |
|
|
default: |
745 |
|
|
sprintf (filename, "%s/help", settings.datadir); |
746 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
747 |
|
|
break; |
748 |
root |
1.7 |
} |
749 |
root |
1.21 |
|
750 |
root |
1.7 |
if (!(dirp = opendir (filename))) |
751 |
|
|
return; |
752 |
|
|
|
753 |
|
|
line[0] = '\0'; |
754 |
pippijn |
1.45 |
while ((de = readdir (dirp))) |
755 |
root |
1.7 |
{ |
756 |
root |
1.21 |
namelen = strlen (de->d_name); |
757 |
root |
1.7 |
if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
758 |
|
|
continue; |
759 |
|
|
linelen += namelen + 1; |
760 |
|
|
if (linelen > 42) |
761 |
|
|
{ |
762 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, line); |
763 |
|
|
sprintf (line, " %s", de->d_name); |
764 |
|
|
linelen = namelen + 1; |
765 |
|
|
continue; |
766 |
root |
1.3 |
} |
767 |
root |
1.7 |
strcat (line, " "); |
768 |
|
|
strcat (line, de->d_name); |
769 |
elmex |
1.1 |
} |
770 |
root |
1.7 |
new_draw_info (NDI_UNIQUE, 0, op, line); |
771 |
|
|
closedir (dirp); |
772 |
elmex |
1.1 |
} |
773 |
|
|
|
774 |
root |
1.7 |
static void |
775 |
|
|
show_commands (object *op, int what) |
776 |
elmex |
1.1 |
{ |
777 |
|
|
char line[80]; |
778 |
root |
1.7 |
int i, size, namelen, linelen = 0; |
779 |
elmex |
1.1 |
CommArray_s *ap; |
780 |
|
|
extern CommArray_s Commands[], WizCommands[]; |
781 |
|
|
extern const int CommandsSize, WizCommandsSize; |
782 |
root |
1.7 |
|
783 |
|
|
switch (what) |
784 |
|
|
{ |
785 |
|
|
case 1: |
786 |
|
|
ap = WizCommands; |
787 |
|
|
size = WizCommandsSize; |
788 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
789 |
|
|
break; |
790 |
|
|
case 2: |
791 |
|
|
ap = CommunicationCommands; |
792 |
|
|
size = CommunicationCommandSize; |
793 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, " Communication commands:"); |
794 |
|
|
break; |
795 |
|
|
default: |
796 |
|
|
ap = Commands; |
797 |
|
|
size = CommandsSize; |
798 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
799 |
|
|
break; |
800 |
|
|
} |
801 |
|
|
|
802 |
|
|
line[0] = '\0'; |
803 |
|
|
for (i = 0; i < size; i++) |
804 |
|
|
{ |
805 |
|
|
namelen = strlen (ap[i].name); |
806 |
|
|
linelen += namelen + 1; |
807 |
|
|
if (linelen > 42) |
808 |
|
|
{ |
809 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, line); |
810 |
|
|
sprintf (line, " %s", ap[i].name); |
811 |
|
|
linelen = namelen + 1; |
812 |
|
|
continue; |
813 |
|
|
} |
814 |
|
|
strcat (line, " "); |
815 |
|
|
strcat (line, ap[i].name); |
816 |
|
|
} |
817 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, line); |
818 |
elmex |
1.1 |
} |
819 |
|
|
|
820 |
|
|
|
821 |
root |
1.7 |
int |
822 |
|
|
command_help (object *op, char *params) |
823 |
elmex |
1.1 |
{ |
824 |
|
|
struct stat st; |
825 |
|
|
FILE *fp; |
826 |
|
|
char filename[MAX_BUF], line[MAX_BUF]; |
827 |
|
|
int len; |
828 |
|
|
|
829 |
root |
1.7 |
if (op != NULL) |
830 |
|
|
clear_win_info (op); |
831 |
elmex |
1.1 |
|
832 |
|
|
/* |
833 |
|
|
* Main help page? |
834 |
|
|
*/ |
835 |
root |
1.7 |
if (!params) |
836 |
|
|
{ |
837 |
|
|
sprintf (filename, "%s/def_help", settings.datadir); |
838 |
|
|
if ((fp = fopen (filename, "r")) == NULL) |
839 |
|
|
{ |
840 |
|
|
LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
841 |
|
|
return 0; |
842 |
|
|
} |
843 |
|
|
while (fgets (line, MAX_BUF, fp)) |
844 |
|
|
{ |
845 |
|
|
line[MAX_BUF - 1] = '\0'; |
846 |
|
|
len = strlen (line) - 1; |
847 |
|
|
if (line[len] == '\n') |
848 |
|
|
line[len] = '\0'; |
849 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, line); |
850 |
|
|
} |
851 |
|
|
fclose (fp); |
852 |
elmex |
1.1 |
return 0; |
853 |
|
|
} |
854 |
|
|
|
855 |
|
|
/* |
856 |
|
|
* Topics list |
857 |
|
|
*/ |
858 |
root |
1.7 |
if (!strcmp (params, "topics")) |
859 |
|
|
{ |
860 |
|
|
help_topics (op, 3); |
861 |
|
|
help_topics (op, 0); |
862 |
|
|
if (QUERY_FLAG (op, FLAG_WIZ)) |
863 |
|
|
help_topics (op, 1); |
864 |
|
|
return 0; |
865 |
elmex |
1.1 |
} |
866 |
root |
1.7 |
|
867 |
elmex |
1.1 |
/* |
868 |
|
|
* Commands list |
869 |
|
|
*/ |
870 |
root |
1.7 |
if (!strcmp (params, "commands")) |
871 |
|
|
{ |
872 |
|
|
show_commands (op, 0); |
873 |
|
|
show_commands (op, 2); /* show comm commands */ |
874 |
|
|
if (QUERY_FLAG (op, FLAG_WIZ)) |
875 |
|
|
show_commands (op, 1); |
876 |
|
|
return 0; |
877 |
|
|
} |
878 |
elmex |
1.1 |
|
879 |
|
|
/* |
880 |
|
|
* User wants info about command |
881 |
|
|
*/ |
882 |
root |
1.7 |
if (strchr (params, '.') || strchr (params, ' ') || strchr (params, '/')) |
883 |
|
|
{ |
884 |
|
|
sprintf (line, "Illegal characters in '%s'", params); |
885 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, line); |
886 |
|
|
return 0; |
887 |
|
|
} |
888 |
elmex |
1.1 |
|
889 |
root |
1.7 |
sprintf (filename, "%s/mischelp/%s", settings.datadir, params); |
890 |
|
|
if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
891 |
|
|
{ |
892 |
|
|
if (op) |
893 |
|
|
{ |
894 |
|
|
sprintf (filename, "%s/help/%s", settings.datadir, params); |
895 |
|
|
if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
896 |
|
|
{ |
897 |
|
|
if (QUERY_FLAG (op, FLAG_WIZ)) |
898 |
|
|
{ |
899 |
|
|
sprintf (filename, "%s/wizhelp/%s", settings.datadir, params); |
900 |
|
|
if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
901 |
|
|
goto nohelp; |
902 |
|
|
} |
903 |
|
|
else |
904 |
|
|
goto nohelp; |
905 |
|
|
} |
906 |
|
|
} |
907 |
|
|
} |
908 |
elmex |
1.1 |
|
909 |
|
|
/* |
910 |
|
|
* Found that. Just cat it to screen. |
911 |
|
|
*/ |
912 |
root |
1.7 |
if ((fp = fopen (filename, "r")) == NULL) |
913 |
|
|
{ |
914 |
|
|
LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
915 |
|
|
return 0; |
916 |
|
|
} |
917 |
|
|
sprintf (line, "Help about '%s'", params); |
918 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, line); |
919 |
|
|
while (fgets (line, MAX_BUF, fp)) |
920 |
|
|
{ |
921 |
|
|
line[MAX_BUF - 1] = '\0'; |
922 |
|
|
len = strlen (line) - 1; |
923 |
|
|
if (line[len] == '\n') |
924 |
|
|
line[len] = '\0'; |
925 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, line); |
926 |
elmex |
1.1 |
} |
927 |
root |
1.7 |
fclose (fp); |
928 |
elmex |
1.1 |
return 0; |
929 |
|
|
|
930 |
|
|
/* |
931 |
|
|
* No_help -escape |
932 |
|
|
*/ |
933 |
root |
1.7 |
nohelp: |
934 |
|
|
sprintf (line, "No help available on '%s'", params); |
935 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, line); |
936 |
elmex |
1.1 |
return 0; |
937 |
|
|
} |
938 |
|
|
|
939 |
|
|
|
940 |
root |
1.7 |
int |
941 |
|
|
onoff_value (const char *line) |
942 |
elmex |
1.1 |
{ |
943 |
|
|
int i; |
944 |
|
|
|
945 |
root |
1.7 |
if (sscanf (line, "%d", &i)) |
946 |
elmex |
1.1 |
return (i != 0); |
947 |
root |
1.7 |
switch (line[0]) |
948 |
|
|
{ |
949 |
|
|
case 'o': |
950 |
|
|
switch (line[1]) |
951 |
|
|
{ |
952 |
|
|
case 'n': |
953 |
|
|
return 1; /* on */ |
954 |
|
|
default: |
955 |
|
|
return 0; /* o[ff] */ |
956 |
|
|
} |
957 |
|
|
case 'y': /* y[es] */ |
958 |
|
|
case 'k': /* k[ylla] */ |
959 |
|
|
case 's': |
960 |
|
|
case 'd': |
961 |
|
|
return 1; |
962 |
|
|
case 'n': /* n[o] */ |
963 |
|
|
case 'e': /* e[i] */ |
964 |
|
|
case 'u': |
965 |
|
|
default: |
966 |
|
|
return 0; |
967 |
|
|
} |
968 |
elmex |
1.1 |
} |
969 |
|
|
|
970 |
root |
1.7 |
int |
971 |
|
|
command_sound (object *op, char *params) |
972 |
elmex |
1.1 |
{ |
973 |
root |
1.26 |
if (op->contr->ns->sound) |
974 |
root |
1.7 |
{ |
975 |
root |
1.26 |
op->contr->ns->sound = 0; |
976 |
root |
1.7 |
new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
977 |
|
|
} |
978 |
|
|
else |
979 |
|
|
{ |
980 |
root |
1.26 |
op->contr->ns->sound = 1; |
981 |
root |
1.7 |
new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
982 |
elmex |
1.1 |
} |
983 |
root |
1.23 |
|
984 |
root |
1.7 |
return 1; |
985 |
elmex |
1.1 |
} |
986 |
|
|
|
987 |
root |
1.7 |
int |
988 |
|
|
command_title (object *op, char *params) |
989 |
elmex |
1.1 |
{ |
990 |
root |
1.7 |
char buf[MAX_BUF]; |
991 |
|
|
|
992 |
|
|
if (settings.set_title == FALSE) |
993 |
|
|
{ |
994 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You cannot change your title."); |
995 |
|
|
return 1; |
996 |
elmex |
1.1 |
} |
997 |
root |
1.7 |
|
998 |
|
|
/* dragon players cannot change titles */ |
999 |
|
|
if (is_dragon_pl (op)) |
1000 |
|
|
{ |
1001 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Dragons cannot change titles."); |
1002 |
|
|
return 1; |
1003 |
|
|
} |
1004 |
|
|
|
1005 |
|
|
if (params == NULL) |
1006 |
|
|
{ |
1007 |
|
|
if (op->contr->own_title[0] == '\0') |
1008 |
|
|
sprintf (buf, "Your title is '%s'.", op->contr->title); |
1009 |
|
|
else |
1010 |
|
|
sprintf (buf, "Your title is '%s'.", op->contr->own_title); |
1011 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, buf); |
1012 |
|
|
return 1; |
1013 |
|
|
} |
1014 |
|
|
if (strcmp (params, "clear") == 0 || strcmp (params, "default") == 0) |
1015 |
|
|
{ |
1016 |
|
|
if (op->contr->own_title[0] == '\0') |
1017 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Your title is the default title."); |
1018 |
|
|
else |
1019 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Title set to default."); |
1020 |
|
|
op->contr->own_title[0] = '\0'; |
1021 |
|
|
return 1; |
1022 |
|
|
} |
1023 |
|
|
|
1024 |
|
|
if ((int) strlen (params) >= MAX_NAME) |
1025 |
|
|
{ |
1026 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Title too long."); |
1027 |
|
|
return 1; |
1028 |
|
|
} |
1029 |
|
|
strcpy (op->contr->own_title, params); |
1030 |
|
|
return 1; |
1031 |
elmex |
1.1 |
} |
1032 |
|
|
|
1033 |
root |
1.7 |
int |
1034 |
|
|
command_kill_pets (object *op, char *params) |
1035 |
elmex |
1.1 |
{ |
1036 |
root |
1.7 |
objectlink *obl, *next; |
1037 |
|
|
int counter = 0, removecount = 0; |
1038 |
|
|
|
1039 |
|
|
if (params == NULL) |
1040 |
|
|
{ |
1041 |
|
|
terminate_all_pets (op); |
1042 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); |
1043 |
|
|
} |
1044 |
|
|
else |
1045 |
|
|
{ |
1046 |
|
|
int target = atoi (params); |
1047 |
|
|
|
1048 |
|
|
for (obl = first_friendly_object; obl != NULL; obl = next) |
1049 |
|
|
{ |
1050 |
|
|
object *ob = obl->ob; |
1051 |
|
|
|
1052 |
|
|
next = obl->next; |
1053 |
root |
1.22 |
if (ob->owner == op) |
1054 |
root |
1.7 |
if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
1055 |
|
|
{ |
1056 |
root |
1.20 |
ob->destroy (); |
1057 |
root |
1.3 |
removecount++; |
1058 |
root |
1.7 |
} |
1059 |
root |
1.3 |
} |
1060 |
root |
1.7 |
if (removecount != 0) |
1061 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
1062 |
|
|
else |
1063 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
1064 |
elmex |
1.1 |
} |
1065 |
root |
1.7 |
return 0; |
1066 |
elmex |
1.1 |
} |