1 |
elmex |
1.1 |
/* |
2 |
|
|
CrossFire, A Multiplayer game for X-windows |
3 |
|
|
|
4 |
|
|
Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 |
|
|
Copyright (C) 1992 Frank Tore Johansen |
6 |
|
|
|
7 |
|
|
This program is free software; you can redistribute it and/or modify |
8 |
|
|
it under the terms of the GNU General Public License as published by |
9 |
|
|
the Free Software Foundation; either version 2 of the License, or |
10 |
|
|
(at your option) any later version. |
11 |
|
|
|
12 |
|
|
This program is distributed in the hope that it will be useful, |
13 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
GNU General Public License for more details. |
16 |
|
|
|
17 |
|
|
You should have received a copy of the GNU General Public License |
18 |
|
|
along with this program; if not, write to the Free Software |
19 |
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 |
|
|
|
21 |
root |
1.8 |
The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 |
elmex |
1.1 |
*/ |
23 |
|
|
|
24 |
|
|
#include <global.h> |
25 |
|
|
#include <loader.h> |
26 |
|
|
#ifndef __CEXTRACT__ |
27 |
root |
1.7 |
# include <sproto.h> |
28 |
elmex |
1.1 |
#endif |
29 |
|
|
|
30 |
|
|
extern weathermap_t **weathermap; |
31 |
|
|
|
32 |
|
|
/* Handles misc. input request - things like hash table, malloc, maps, |
33 |
|
|
* who, etc. |
34 |
|
|
*/ |
35 |
|
|
|
36 |
root |
1.7 |
void |
37 |
|
|
map_info (object *op, char *search) |
38 |
|
|
{ |
39 |
root |
1.9 |
maptile *m; |
40 |
elmex |
1.1 |
char buf[MAX_BUF], map_path[MAX_BUF]; |
41 |
root |
1.7 |
long sec = seconds (); |
42 |
|
|
|
43 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Current time is: %02ld:%02ld:%02ld.", (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60); |
44 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Path Pl PlM IM TO Dif Reset"); |
45 |
|
|
for (m = first_map; m != NULL; m = m->next) |
46 |
|
|
{ |
47 |
|
|
|
48 |
|
|
if (search && strstr (m->path, search) == NULL) |
49 |
|
|
continue; /* Skip unwanted maps */ |
50 |
|
|
/* Print out the last 18 characters of the map name... */ |
51 |
|
|
if (strlen (m->path) <= 18) |
52 |
|
|
strcpy (map_path, m->path); |
53 |
|
|
else |
54 |
|
|
strcpy (map_path, m->path + strlen (m->path) - 18); |
55 |
|
|
sprintf (buf, "%-18.18s %2d %2d %1d %4d %2d %02d:%02d:%02d", |
56 |
|
|
map_path, m->players, players_on_map (m, FALSE), |
57 |
|
|
m->in_memory, m->timeout, m->difficulty, |
58 |
|
|
(MAP_WHEN_RESET (m) % 86400) / 3600, (MAP_WHEN_RESET (m) % 3600) / 60, MAP_WHEN_RESET (m) % 60); |
59 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, buf); |
60 |
|
|
} |
61 |
elmex |
1.1 |
} |
62 |
|
|
|
63 |
|
|
/* This command dumps the body information for object *op. |
64 |
|
|
* it doesn't care what the params are. |
65 |
|
|
* This is mostly meant as a debug command. |
66 |
|
|
*/ |
67 |
root |
1.7 |
int |
68 |
|
|
command_body (object *op, char *params) |
69 |
elmex |
1.1 |
{ |
70 |
root |
1.7 |
int i; |
71 |
elmex |
1.1 |
|
72 |
root |
1.7 |
/* Too hard to try and make a header that lines everything up, so just |
73 |
|
|
* give a description. |
74 |
|
|
*/ |
75 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "The first column is the name of the body location."); |
76 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "The second column is how many of those locations your body has."); |
77 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "The third column is how many slots in that location are available."); |
78 |
|
|
for (i = 0; i < NUM_BODY_LOCATIONS; i++) |
79 |
|
|
{ |
80 |
|
|
/* really debugging - normally body_used should not be set to anything |
81 |
|
|
* if body_info isn't also set. |
82 |
|
|
*/ |
83 |
|
|
if (op->body_info[i] || op->body_used[i]) |
84 |
|
|
{ |
85 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "%-30s %5d %5d", body_locations[i].use_name, op->body_info[i], op->body_used[i]); |
86 |
root |
1.3 |
} |
87 |
elmex |
1.1 |
} |
88 |
root |
1.7 |
if (!QUERY_FLAG (op, FLAG_USE_ARMOUR)) |
89 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You are not allowed to wear armor"); |
90 |
|
|
if (!QUERY_FLAG (op, FLAG_USE_WEAPON)) |
91 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You are not allowed to use weapons"); |
92 |
elmex |
1.1 |
|
93 |
root |
1.7 |
return 1; |
94 |
elmex |
1.1 |
} |
95 |
|
|
|
96 |
|
|
|
97 |
root |
1.7 |
int |
98 |
|
|
command_motd (object *op, char *params) |
99 |
elmex |
1.1 |
{ |
100 |
root |
1.7 |
display_motd (op); |
101 |
|
|
return 1; |
102 |
elmex |
1.1 |
} |
103 |
|
|
|
104 |
root |
1.7 |
int |
105 |
|
|
command_bug (object *op, char *params) |
106 |
elmex |
1.1 |
{ |
107 |
root |
1.7 |
char buf[MAX_BUF]; |
108 |
elmex |
1.1 |
|
109 |
root |
1.7 |
if (params == NULL) |
110 |
|
|
{ |
111 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "what bugs?"); |
112 |
elmex |
1.1 |
return 1; |
113 |
|
|
} |
114 |
root |
1.7 |
strcpy (buf, op->name); |
115 |
|
|
strcat (buf, " bug-reports: "); |
116 |
|
|
strncat (buf, ++params, MAX_BUF - strlen (buf)); |
117 |
|
|
buf[MAX_BUF - 1] = '\0'; |
118 |
|
|
bug_report (buf); |
119 |
|
|
LOG (llevError, "%s\n", buf); |
120 |
|
|
new_draw_info (NDI_ALL | NDI_UNIQUE, 1, NULL, buf); |
121 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "OK, thanks!"); |
122 |
|
|
return 1; |
123 |
elmex |
1.1 |
} |
124 |
|
|
|
125 |
|
|
/* |
126 |
|
|
* Pretty much identical to current map_info, but on a bigger scale |
127 |
|
|
* This function returns the name of the players current region, and |
128 |
|
|
* a description of it. It is there merely for flavour text. |
129 |
|
|
*/ |
130 |
root |
1.7 |
void |
131 |
|
|
current_region_info (object *op) |
132 |
|
|
{ |
133 |
|
|
/* |
134 |
|
|
* Ok I /suppose/ I should write a seperate function for this, but it isn't |
135 |
|
|
* going to be /that/ slow, and won't get called much |
136 |
|
|
*/ |
137 |
|
|
region *r = get_region_by_name (get_name_of_region_for_map (op->map)); |
138 |
elmex |
1.1 |
|
139 |
root |
1.7 |
if (!r) |
140 |
|
|
return; |
141 |
|
|
/* This should only be possible if regions are not operating on this server. */ |
142 |
elmex |
1.1 |
|
143 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, "You are in %s. \n %s", get_region_longname (r), get_region_msg (r)); |
144 |
elmex |
1.1 |
} |
145 |
|
|
|
146 |
root |
1.7 |
void |
147 |
|
|
current_map_info (object *op) |
148 |
|
|
{ |
149 |
root |
1.9 |
maptile *m = op->map; |
150 |
elmex |
1.1 |
|
151 |
root |
1.7 |
if (!m) |
152 |
|
|
return; |
153 |
elmex |
1.1 |
|
154 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) in %s", m->name, m->path, get_name_of_region_for_map (m)); |
155 |
elmex |
1.1 |
|
156 |
root |
1.7 |
if (QUERY_FLAG (op, FLAG_WIZ)) |
157 |
|
|
{ |
158 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, |
159 |
|
|
"players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld", |
160 |
|
|
m->players, m->difficulty, MAP_WIDTH (m), MAP_HEIGHT (m), MAP_ENTER_X (m), MAP_ENTER_Y (m), MAP_TIMEOUT (m)); |
161 |
elmex |
1.1 |
|
162 |
|
|
} |
163 |
root |
1.7 |
if (m->msg) |
164 |
|
|
new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
165 |
elmex |
1.1 |
} |
166 |
|
|
|
167 |
|
|
#ifdef DEBUG_MALLOC_LEVEL |
168 |
root |
1.7 |
int |
169 |
|
|
command_malloc_verify (object *op, char *parms) |
170 |
elmex |
1.1 |
{ |
171 |
root |
1.7 |
extern int malloc_verify (void); |
172 |
elmex |
1.1 |
|
173 |
root |
1.7 |
if (!malloc_verify ()) |
174 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Heap is corrupted."); |
175 |
|
|
else |
176 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Heap checks out OK."); |
177 |
|
|
return 1; |
178 |
|
|
} |
179 |
elmex |
1.1 |
#endif |
180 |
|
|
|
181 |
root |
1.7 |
int |
182 |
|
|
command_whereabouts (object *op, char *params) |
183 |
|
|
{ |
184 |
|
|
|
185 |
|
|
region *reg; |
186 |
|
|
player *pl; |
187 |
elmex |
1.1 |
|
188 |
root |
1.7 |
/* |
189 |
|
|
* reset the counter on the region, then use it to store the number of |
190 |
|
|
* players there. |
191 |
|
|
* I don't know how thread-safe this would be, I suspect not very.... |
192 |
|
|
*/ |
193 |
|
|
for (reg = first_region; reg != NULL; reg = reg->next) |
194 |
|
|
{ |
195 |
|
|
reg->counter = 0; |
196 |
|
|
} |
197 |
|
|
for (pl = first_player; pl != NULL; pl = pl->next) |
198 |
|
|
if (pl->ob->map != NULL) |
199 |
|
|
get_region_by_map (pl->ob->map)->counter++; |
200 |
|
|
|
201 |
|
|
/* we only want to print out by places with a 'longname' field... */ |
202 |
|
|
for (reg = first_region; reg != NULL; reg = reg->next) |
203 |
|
|
{ |
204 |
|
|
if (reg->longname == NULL && reg->counter > 0) |
205 |
|
|
{ |
206 |
|
|
if (reg->parent != NULL) |
207 |
|
|
{ |
208 |
|
|
reg->parent->counter += reg->counter; |
209 |
|
|
reg->counter = 0; |
210 |
root |
1.3 |
} |
211 |
root |
1.7 |
else /*uh oh, we shouldn't be here. */ |
212 |
|
|
LOG (llevError, "command_whereabouts() Region %s with no longname has no parent", reg->name); |
213 |
root |
1.3 |
} |
214 |
|
|
} |
215 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, "In the world currently there are:"); |
216 |
|
|
for (reg = first_region; reg != NULL; reg = reg->next) |
217 |
|
|
if (reg->counter > 0) |
218 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "%u players in %s", reg->counter, get_region_longname (reg)); |
219 |
|
|
return 1; |
220 |
elmex |
1.1 |
} |
221 |
|
|
|
222 |
|
|
typedef struct |
223 |
root |
1.7 |
{ |
224 |
|
|
char namebuf[MAX_BUF]; |
225 |
|
|
int login_order; |
226 |
|
|
} chars_names; |
227 |
elmex |
1.1 |
|
228 |
root |
1.7 |
int |
229 |
|
|
command_afk (object *op, char *params) |
230 |
|
|
{ |
231 |
|
|
if QUERY_FLAG |
232 |
|
|
(op, FLAG_AFK) |
233 |
|
|
{ |
234 |
|
|
CLEAR_FLAG (op, FLAG_AFK); |
235 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You are no longer AFK"); |
236 |
|
|
} |
237 |
|
|
else |
238 |
elmex |
1.1 |
{ |
239 |
root |
1.7 |
SET_FLAG (op, FLAG_AFK); |
240 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK"); |
241 |
elmex |
1.1 |
} |
242 |
root |
1.7 |
return 1; |
243 |
elmex |
1.1 |
} |
244 |
|
|
|
245 |
root |
1.7 |
int |
246 |
|
|
command_mapinfo (object *op, char *params) |
247 |
elmex |
1.1 |
{ |
248 |
root |
1.7 |
current_map_info (op); |
249 |
|
|
return 1; |
250 |
|
|
} |
251 |
elmex |
1.1 |
|
252 |
root |
1.7 |
int |
253 |
|
|
command_whereami (object *op, char *params) |
254 |
elmex |
1.1 |
{ |
255 |
root |
1.7 |
current_region_info (op); |
256 |
|
|
return 1; |
257 |
elmex |
1.1 |
} |
258 |
|
|
|
259 |
root |
1.7 |
int |
260 |
|
|
command_maps (object *op, char *params) |
261 |
elmex |
1.1 |
{ |
262 |
root |
1.7 |
map_info (op, params); |
263 |
|
|
return 1; |
264 |
|
|
} |
265 |
elmex |
1.1 |
|
266 |
root |
1.7 |
int |
267 |
|
|
command_time (object *op, char *params) |
268 |
elmex |
1.1 |
{ |
269 |
root |
1.2 |
print_tod (op); |
270 |
|
|
return 1; |
271 |
|
|
} |
272 |
elmex |
1.1 |
|
273 |
root |
1.7 |
int |
274 |
|
|
command_weather (object *op, char *params) |
275 |
elmex |
1.1 |
{ |
276 |
root |
1.7 |
int wx, wy, temp, sky; |
277 |
|
|
char buf[MAX_BUF]; |
278 |
|
|
|
279 |
|
|
if (settings.dynamiclevel < 1) |
280 |
|
|
return 1; |
281 |
|
|
|
282 |
|
|
if (op->map == NULL) |
283 |
|
|
return 1; |
284 |
|
|
|
285 |
|
|
if (worldmap_to_weathermap (op->x, op->y, &wx, &wy, op->map) != 0) |
286 |
|
|
return 1; |
287 |
|
|
|
288 |
|
|
if (QUERY_FLAG (op, FLAG_WIZ)) |
289 |
|
|
{ |
290 |
|
|
/* dump the weather, Dm style! Yo! */ |
291 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Real temp: %d", real_world_temperature (op->x, op->y, op->map)); |
292 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Base temp: %d", weathermap[wx][wy].temp); |
293 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Humid: %d", weathermap[wx][wy].humid); |
294 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Wind: dir=%d speed=%d", weathermap[wx][wy].winddir, weathermap[wx][wy].windspeed); |
295 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Pressure: %d", weathermap[wx][wy].pressure); |
296 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Avg Elevation: %d", weathermap[wx][wy].avgelev); |
297 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Rainfall: %d Water: %d", weathermap[wx][wy].rainfall, weathermap[wx][wy].water); |
298 |
|
|
} |
299 |
|
|
|
300 |
|
|
temp = real_world_temperature (op->x, op->y, op->map); |
301 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "It's currently %d degrees " "Centigrade out.", temp); |
302 |
|
|
|
303 |
|
|
/* humid */ |
304 |
|
|
if (weathermap[wx][wy].humid < 20) |
305 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is very dry."); |
306 |
|
|
else if (weathermap[wx][wy].humid < 40) |
307 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is very comfortable today."); |
308 |
|
|
else if (weathermap[wx][wy].humid < 60) |
309 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is a bit muggy."); |
310 |
|
|
else if (weathermap[wx][wy].humid < 80) |
311 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is muggy."); |
312 |
|
|
else |
313 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is uncomfortably muggy."); |
314 |
elmex |
1.1 |
|
315 |
root |
1.7 |
/* wind */ |
316 |
|
|
switch (weathermap[wx][wy].winddir) |
317 |
|
|
{ |
318 |
|
|
case 1: |
319 |
|
|
sprintf (buf, "north"); |
320 |
|
|
break; |
321 |
|
|
case 2: |
322 |
|
|
sprintf (buf, "northeast"); |
323 |
|
|
break; |
324 |
|
|
case 3: |
325 |
|
|
sprintf (buf, "east"); |
326 |
|
|
break; |
327 |
|
|
case 4: |
328 |
|
|
sprintf (buf, "southeast"); |
329 |
|
|
break; |
330 |
|
|
case 5: |
331 |
|
|
sprintf (buf, "south"); |
332 |
|
|
break; |
333 |
|
|
case 6: |
334 |
|
|
sprintf (buf, "southwest"); |
335 |
|
|
break; |
336 |
|
|
case 7: |
337 |
|
|
sprintf (buf, "west"); |
338 |
|
|
break; |
339 |
|
|
case 8: |
340 |
|
|
sprintf (buf, "northwest"); |
341 |
|
|
break; |
342 |
|
|
} |
343 |
|
|
if (weathermap[wx][wy].windspeed < 5) |
344 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "There is a mild breeze " "coming from the %s.", buf); |
345 |
|
|
else if (weathermap[wx][wy].windspeed < 10) |
346 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "There is a strong breeze " "coming from the %s.", buf); |
347 |
|
|
else if (weathermap[wx][wy].windspeed < 15) |
348 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "There is a light wind " "coming from the %s.", buf); |
349 |
|
|
else if (weathermap[wx][wy].windspeed < 25) |
350 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "There is a strong wind " "coming from the %s.", buf); |
351 |
|
|
else if (weathermap[wx][wy].windspeed < 35) |
352 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "There is a heavy wind " "coming from the %s.", buf); |
353 |
|
|
else |
354 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "The wind from the %s is " "incredibly strong!", buf); |
355 |
elmex |
1.1 |
|
356 |
root |
1.7 |
sky = weathermap[wx][wy].sky; |
357 |
|
|
if (temp <= 0 && sky > SKY_OVERCAST && sky < SKY_FOG) |
358 |
|
|
sky += 10; /*let it snow */ |
359 |
|
|
switch (sky) |
360 |
|
|
{ |
361 |
|
|
case SKY_CLEAR: |
362 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "There isn''t a cloud in the sky."); |
363 |
|
|
break; |
364 |
|
|
case SKY_LIGHTCLOUD: |
365 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "There are a few light clouds in the sky."); |
366 |
|
|
break; |
367 |
|
|
case SKY_OVERCAST: |
368 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "The sky is cloudy and dreary."); |
369 |
|
|
break; |
370 |
|
|
case SKY_LIGHT_RAIN: |
371 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is raining softly."); |
372 |
|
|
break; |
373 |
|
|
case SKY_RAIN: |
374 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is raining."); |
375 |
|
|
break; |
376 |
|
|
case SKY_HEAVY_RAIN: |
377 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It is raining heavily."); |
378 |
|
|
break; |
379 |
|
|
case SKY_HURRICANE: |
380 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "There is a heavy storm! You should go inside!"); |
381 |
|
|
break; |
382 |
|
|
case SKY_FOG: |
383 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It''s foggy and miserable."); |
384 |
|
|
break; |
385 |
|
|
case SKY_HAIL: |
386 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It''s hailing out! Take cover!"); |
387 |
|
|
break; |
388 |
|
|
case SKY_LIGHT_SNOW: |
389 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Snow is gently falling from the sky."); |
390 |
|
|
break; |
391 |
|
|
case SKY_SNOW: |
392 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "It''s snowing out."); |
393 |
|
|
break; |
394 |
|
|
case SKY_HEAVY_SNOW: |
395 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "The snow is falling very heavily now."); |
396 |
|
|
break; |
397 |
|
|
case SKY_BLIZZARD: |
398 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); |
399 |
|
|
break; |
400 |
elmex |
1.1 |
} |
401 |
root |
1.7 |
return 1; |
402 |
elmex |
1.1 |
} |
403 |
|
|
|
404 |
root |
1.7 |
int |
405 |
|
|
command_archs (object *op, char *params) |
406 |
elmex |
1.1 |
{ |
407 |
root |
1.7 |
arch_info (op); |
408 |
|
|
return 1; |
409 |
|
|
} |
410 |
elmex |
1.1 |
|
411 |
root |
1.7 |
int |
412 |
|
|
command_hiscore (object *op, char *params) |
413 |
elmex |
1.1 |
{ |
414 |
root |
1.7 |
display_high_score (op, op == NULL ? 9999 : 50, params); |
415 |
|
|
return 1; |
416 |
|
|
} |
417 |
elmex |
1.1 |
|
418 |
root |
1.7 |
int |
419 |
|
|
command_debug (object *op, char *params) |
420 |
elmex |
1.1 |
{ |
421 |
root |
1.7 |
int i; |
422 |
|
|
char buf[MAX_BUF]; |
423 |
|
|
|
424 |
|
|
if (params == NULL || !sscanf (params, "%d", &i)) |
425 |
|
|
{ |
426 |
|
|
sprintf (buf, "Global debug level is %d.", settings.debug); |
427 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, buf); |
428 |
elmex |
1.1 |
return 1; |
429 |
|
|
} |
430 |
root |
1.7 |
if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
431 |
|
|
{ |
432 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Privileged command."); |
433 |
elmex |
1.1 |
return 1; |
434 |
|
|
} |
435 |
root |
1.7 |
settings.debug = (enum LogLevel) FABS (i); |
436 |
|
|
sprintf (buf, "Set debug level to %d.", i); |
437 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, buf); |
438 |
|
|
return 1; |
439 |
|
|
} |
440 |
elmex |
1.1 |
|
441 |
|
|
|
442 |
|
|
/* |
443 |
|
|
* Those dumps should be just one dump with good parser |
444 |
|
|
*/ |
445 |
|
|
|
446 |
root |
1.7 |
int |
447 |
|
|
command_dumpbelow (object *op, char *params) |
448 |
elmex |
1.1 |
{ |
449 |
root |
1.7 |
if (op && op->below) |
450 |
|
|
{ |
451 |
root |
1.14 |
char *dump = dump_object (op->below); |
452 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, dump); |
453 |
|
|
free (dump); |
454 |
elmex |
1.1 |
/* Let's push that item on the dm's stack */ |
455 |
root |
1.7 |
dm_stack_push (op->contr, op->below->count); |
456 |
|
|
} |
457 |
elmex |
1.1 |
return 0; |
458 |
|
|
} |
459 |
|
|
|
460 |
root |
1.7 |
int |
461 |
|
|
command_dumpfriendlyobjects (object *op, char *params) |
462 |
elmex |
1.1 |
{ |
463 |
root |
1.7 |
dump_friendly_objects (); |
464 |
elmex |
1.1 |
return 0; |
465 |
|
|
} |
466 |
|
|
|
467 |
root |
1.7 |
int |
468 |
|
|
command_dumpmap (object *op, char *params) |
469 |
elmex |
1.1 |
{ |
470 |
root |
1.7 |
if (op) |
471 |
|
|
dump_map (op->map); |
472 |
elmex |
1.1 |
return 0; |
473 |
|
|
} |
474 |
|
|
|
475 |
root |
1.7 |
int |
476 |
|
|
command_dumpallmaps (object *op, char *params) |
477 |
elmex |
1.1 |
{ |
478 |
root |
1.7 |
dump_all_maps (); |
479 |
elmex |
1.1 |
return 0; |
480 |
|
|
} |
481 |
|
|
|
482 |
root |
1.7 |
int |
483 |
|
|
command_printlos (object *op, char *params) |
484 |
elmex |
1.1 |
{ |
485 |
|
|
if (op) |
486 |
root |
1.7 |
print_los (op); |
487 |
elmex |
1.1 |
return 0; |
488 |
|
|
} |
489 |
|
|
|
490 |
|
|
|
491 |
root |
1.7 |
int |
492 |
|
|
command_version (object *op, char *params) |
493 |
elmex |
1.1 |
{ |
494 |
root |
1.7 |
version (op); |
495 |
|
|
return 0; |
496 |
elmex |
1.1 |
} |
497 |
|
|
|
498 |
|
|
|
499 |
|
|
#ifndef BUG_LOG |
500 |
root |
1.7 |
# define BUG_LOG "bug_log" |
501 |
elmex |
1.1 |
#endif |
502 |
root |
1.7 |
void |
503 |
|
|
bug_report (const char *reportstring) |
504 |
|
|
{ |
505 |
|
|
FILE *fp; |
506 |
|
|
|
507 |
|
|
if ((fp = fopen (BUG_LOG, "a")) != NULL) |
508 |
|
|
{ |
509 |
|
|
fprintf (fp, "%s\n", reportstring); |
510 |
|
|
fclose (fp); |
511 |
|
|
} |
512 |
|
|
else |
513 |
|
|
{ |
514 |
|
|
LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno)); |
515 |
elmex |
1.1 |
} |
516 |
root |
1.7 |
} |
517 |
|
|
|
518 |
|
|
int |
519 |
|
|
command_output_sync (object *op, char *params) |
520 |
|
|
{ |
521 |
|
|
int val; |
522 |
|
|
|
523 |
|
|
if (!params) |
524 |
|
|
{ |
525 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time is presently %d", op->contr->outputs_sync); |
526 |
|
|
return 1; |
527 |
|
|
} |
528 |
|
|
val = atoi (params); |
529 |
|
|
if (val > 0) |
530 |
|
|
{ |
531 |
|
|
op->contr->outputs_sync = val; |
532 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time now set to %d", op->contr->outputs_sync); |
533 |
|
|
} |
534 |
|
|
else |
535 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_sync."); |
536 |
elmex |
1.1 |
|
537 |
root |
1.7 |
return 1; |
538 |
elmex |
1.1 |
} |
539 |
|
|
|
540 |
root |
1.7 |
int |
541 |
|
|
command_output_count (object *op, char *params) |
542 |
elmex |
1.1 |
{ |
543 |
root |
1.7 |
int val; |
544 |
elmex |
1.1 |
|
545 |
root |
1.7 |
if (!params) |
546 |
|
|
{ |
547 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Output count is presently %d", op->contr->outputs_count); |
548 |
|
|
return 1; |
549 |
elmex |
1.1 |
} |
550 |
root |
1.7 |
val = atoi (params); |
551 |
|
|
if (val > 0) |
552 |
|
|
{ |
553 |
|
|
op->contr->outputs_count = val; |
554 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Output count now set to %d", op->contr->outputs_count); |
555 |
|
|
} |
556 |
|
|
else |
557 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_count."); |
558 |
elmex |
1.1 |
|
559 |
root |
1.7 |
return 1; |
560 |
elmex |
1.1 |
} |
561 |
|
|
|
562 |
root |
1.7 |
int |
563 |
|
|
command_listen (object *op, char *params) |
564 |
elmex |
1.1 |
{ |
565 |
|
|
int i; |
566 |
|
|
|
567 |
root |
1.7 |
if (params == NULL || !sscanf (params, "%d", &i)) |
568 |
|
|
{ |
569 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Set listen to what (presently %d)?", op->contr->listening); |
570 |
elmex |
1.1 |
return 1; |
571 |
|
|
} |
572 |
root |
1.7 |
op->contr->listening = (char) i; |
573 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Your verbose level is now %d.", i); |
574 |
|
|
return 1; |
575 |
elmex |
1.1 |
} |
576 |
|
|
|
577 |
|
|
/* Prints out some useful information for the character. Everything we print |
578 |
|
|
* out can be determined by the docs, so we aren't revealing anything extra - |
579 |
|
|
* rather, we are making it convenient to find the values. params have |
580 |
|
|
* no meaning here. |
581 |
|
|
*/ |
582 |
root |
1.7 |
int |
583 |
|
|
command_statistics (object *pl, char *params) |
584 |
elmex |
1.1 |
{ |
585 |
root |
1.7 |
if (!pl->contr) |
586 |
|
|
return 1; |
587 |
pippijn |
1.17 |
new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %" I64_PFd, pl->stats.exp); |
588 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %" I64_PFd, level_exp (pl->level + 1, pl->expmul)); |
589 |
root |
1.7 |
new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max"); |
590 |
elmex |
1.1 |
|
591 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, pl, "Str %2d/ %3d/%3d", |
592 |
|
|
pl->contr->orig_stats.Str, pl->stats.Str, 20 + pl->arch->clone.stats.Str); |
593 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, "Dex %2d/ %3d/%3d", |
594 |
|
|
pl->contr->orig_stats.Dex, pl->stats.Dex, 20 + pl->arch->clone.stats.Dex); |
595 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, "Con %2d/ %3d/%3d", |
596 |
|
|
pl->contr->orig_stats.Con, pl->stats.Con, 20 + pl->arch->clone.stats.Con); |
597 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, "Int %2d/ %3d/%3d", |
598 |
|
|
pl->contr->orig_stats.Int, pl->stats.Int, 20 + pl->arch->clone.stats.Int); |
599 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, "Wis %2d/ %3d/%3d", |
600 |
|
|
pl->contr->orig_stats.Wis, pl->stats.Wis, 20 + pl->arch->clone.stats.Wis); |
601 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, "Pow %2d/ %3d/%3d", |
602 |
|
|
pl->contr->orig_stats.Pow, pl->stats.Pow, 20 + pl->arch->clone.stats.Pow); |
603 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, "Cha %2d/ %3d/%3d", |
604 |
|
|
pl->contr->orig_stats.Cha, pl->stats.Cha, 20 + pl->arch->clone.stats.Cha); |
605 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, pl, "\nAttack Mode: %s", pl->contr->peaceful ? "Peaceful" : "Hostile"); |
606 |
elmex |
1.1 |
|
607 |
root |
1.7 |
/* Can't think of anything else to print right now */ |
608 |
|
|
return 0; |
609 |
elmex |
1.1 |
} |
610 |
|
|
|
611 |
root |
1.7 |
int |
612 |
|
|
command_fix_me (object *op, char *params) |
613 |
elmex |
1.1 |
{ |
614 |
root |
1.7 |
sum_weight (op); |
615 |
|
|
fix_player (op); |
616 |
|
|
return 1; |
617 |
elmex |
1.1 |
} |
618 |
|
|
|
619 |
root |
1.7 |
int |
620 |
|
|
command_players (object *op, char *paramss) |
621 |
elmex |
1.1 |
{ |
622 |
root |
1.7 |
char buf[MAX_BUF]; |
623 |
|
|
char *t; |
624 |
|
|
DIR *Dir; |
625 |
|
|
|
626 |
|
|
sprintf (buf, "%s/%s/", settings.localdir, settings.playerdir); |
627 |
|
|
t = buf + strlen (buf); |
628 |
|
|
if ((Dir = opendir (buf)) != NULL) |
629 |
|
|
{ |
630 |
|
|
const struct dirent *Entry; |
631 |
|
|
|
632 |
|
|
while ((Entry = readdir (Dir)) != NULL) |
633 |
|
|
{ |
634 |
|
|
/* skip '.' , '..' */ |
635 |
|
|
if (!((Entry->d_name[0] == '.' && Entry->d_name[1] == '\0') || |
636 |
|
|
(Entry->d_name[0] == '.' && Entry->d_name[1] == '.' && Entry->d_name[2] == '\0'))) |
637 |
root |
1.3 |
{ |
638 |
root |
1.7 |
struct stat Stat; |
639 |
elmex |
1.1 |
|
640 |
root |
1.7 |
strcpy (t, Entry->d_name); |
641 |
|
|
if (stat (buf, &Stat) == 0) |
642 |
|
|
{ |
643 |
|
|
/* This was not posix compatible |
644 |
|
|
* if ((Stat.st_mode & S_IFMT)==S_IFDIR) { |
645 |
|
|
*/ |
646 |
|
|
if (S_ISDIR (Stat.st_mode)) |
647 |
|
|
{ |
648 |
|
|
char buf2[MAX_BUF]; |
649 |
|
|
struct tm *tm = localtime (&Stat.st_mtime); |
650 |
|
|
|
651 |
|
|
sprintf (buf2, "%s\t%04d %02d %02d %02d %02d %02d", |
652 |
|
|
Entry->d_name, 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); |
653 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, buf2); |
654 |
root |
1.3 |
} |
655 |
|
|
} |
656 |
|
|
} |
657 |
|
|
} |
658 |
elmex |
1.1 |
} |
659 |
root |
1.7 |
closedir (Dir); |
660 |
|
|
return 0; |
661 |
elmex |
1.1 |
} |
662 |
|
|
|
663 |
|
|
|
664 |
|
|
|
665 |
root |
1.7 |
int |
666 |
|
|
command_logs (object *op, char *params) |
667 |
elmex |
1.1 |
{ |
668 |
root |
1.10 |
new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
669 |
elmex |
1.1 |
|
670 |
root |
1.7 |
return 1; |
671 |
elmex |
1.1 |
} |
672 |
|
|
|
673 |
root |
1.7 |
int |
674 |
|
|
command_applymode (object *op, char *params) |
675 |
elmex |
1.1 |
{ |
676 |
root |
1.7 |
unapplymode unapply = op->contr->unapply; |
677 |
|
|
static const char *const types[] = { "nochoice", "never", "always" }; |
678 |
elmex |
1.1 |
|
679 |
root |
1.7 |
if (!params) |
680 |
|
|
{ |
681 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "applymode is set to %s", types[op->contr->unapply]); |
682 |
|
|
return 1; |
683 |
|
|
} |
684 |
|
|
|
685 |
|
|
if (!strcmp (params, "nochoice")) |
686 |
|
|
op->contr->unapply = unapply_nochoice; |
687 |
|
|
else if (!strcmp (params, "never")) |
688 |
|
|
op->contr->unapply = unapply_never; |
689 |
|
|
else if (!strcmp (params, "always")) |
690 |
|
|
op->contr->unapply = unapply_always; |
691 |
|
|
else |
692 |
|
|
{ |
693 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params); |
694 |
|
|
return 0; |
695 |
|
|
} |
696 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s", |
697 |
|
|
(unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]); |
698 |
|
|
return 1; |
699 |
elmex |
1.1 |
} |
700 |
|
|
|
701 |
root |
1.7 |
int |
702 |
|
|
command_bowmode (object *op, char *params) |
703 |
elmex |
1.1 |
{ |
704 |
root |
1.7 |
bowtype_t oldtype = op->contr->bowtype; |
705 |
|
|
static const char *const types[] = { "normal", "threewide", "spreadshot", "firenorth", |
706 |
|
|
"firene", "fireeast", "firese", "firesouth", |
707 |
|
|
"firesw", "firewest", "firenw", "bestarrow" |
708 |
|
|
}; |
709 |
|
|
char buf[MAX_BUF]; |
710 |
|
|
int i, found; |
711 |
|
|
|
712 |
|
|
if (!params) |
713 |
|
|
{ |
714 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode is set to %s", types[op->contr->bowtype]); |
715 |
|
|
return 1; |
716 |
|
|
} |
717 |
|
|
|
718 |
|
|
for (i = 0, found = 0; i <= bow_bestarrow; i++) |
719 |
|
|
{ |
720 |
|
|
if (!strcmp (params, types[i])) |
721 |
|
|
{ |
722 |
|
|
found++; |
723 |
|
|
op->contr->bowtype = (bowtype_t) i; |
724 |
|
|
break; |
725 |
root |
1.3 |
} |
726 |
elmex |
1.1 |
} |
727 |
root |
1.7 |
if (!found) |
728 |
|
|
{ |
729 |
|
|
sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
730 |
|
|
for (i = 0; i <= bow_bestarrow; i++) |
731 |
|
|
{ |
732 |
|
|
strcat (buf, " "); |
733 |
|
|
strcat (buf, types[i]); |
734 |
|
|
if (i < bow_nw) |
735 |
|
|
strcat (buf, ","); |
736 |
|
|
else |
737 |
|
|
strcat (buf, "."); |
738 |
root |
1.3 |
} |
739 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
740 |
|
|
return 0; |
741 |
elmex |
1.1 |
} |
742 |
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]); |
743 |
|
|
return 1; |
744 |
elmex |
1.1 |
} |
745 |
|
|
|
746 |
root |
1.7 |
int |
747 |
|
|
command_petmode (object *op, char *params) |
748 |
elmex |
1.1 |
{ |
749 |
root |
1.7 |
petmode_t oldtype = op->contr->petmode; |
750 |
|
|
static const char *const types[] = { "normal", "sad", "defend", "arena" }; |
751 |
elmex |
1.1 |
|
752 |
root |
1.7 |
if (!params) |
753 |
|
|
{ |
754 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "petmode is set to %s", types[op->contr->petmode]); |
755 |
|
|
return 1; |
756 |
|
|
} |
757 |
|
|
|
758 |
|
|
if (!strcmp (params, "normal")) |
759 |
|
|
op->contr->petmode = pet_normal; |
760 |
|
|
else if (!strcmp (params, "sad")) |
761 |
|
|
op->contr->petmode = pet_sad; |
762 |
|
|
else if (!strcmp (params, "defend")) |
763 |
|
|
op->contr->petmode = pet_defend; |
764 |
|
|
else if (!strcmp (params, "arena")) |
765 |
|
|
op->contr->petmode = pet_arena; |
766 |
|
|
else |
767 |
|
|
{ |
768 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, |
769 |
|
|
"petmode: Unknown options %s, valid options are normal," "sad (seek and destroy), defend, arena", params); |
770 |
|
|
return 0; |
771 |
|
|
} |
772 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "petmode %s set to %s", (oldtype == op->contr->petmode ? "" : "now"), types[op->contr->petmode]); |
773 |
|
|
return 1; |
774 |
elmex |
1.1 |
} |
775 |
|
|
|
776 |
root |
1.7 |
int |
777 |
|
|
command_showpets (object *op, char *params) |
778 |
elmex |
1.1 |
{ |
779 |
root |
1.7 |
objectlink *obl, *next; |
780 |
|
|
int counter = 0, target = 0; |
781 |
|
|
int have_shown_pet = 0; |
782 |
|
|
|
783 |
|
|
if (params != NULL) |
784 |
|
|
target = atoi (params); |
785 |
|
|
for (obl = first_friendly_object; obl != NULL; obl = next) |
786 |
|
|
{ |
787 |
|
|
object *ob = obl->ob; |
788 |
|
|
|
789 |
|
|
next = obl->next; |
790 |
|
|
if (get_owner (ob) == op) |
791 |
|
|
{ |
792 |
|
|
if (target == 0) |
793 |
|
|
{ |
794 |
|
|
if (counter == 0) |
795 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
796 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "%d %s - level %d", ++counter, &ob->name, ob->level); |
797 |
|
|
} |
798 |
|
|
else if (!have_shown_pet && ++counter == target) |
799 |
|
|
{ |
800 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "level %d %s", ob->level, &ob->name); |
801 |
|
|
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); |
802 |
|
|
/* this is not a nice way to do this, it should be made to be more like the statistics command */ |
803 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Str %d", ob->stats.Str); |
804 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Dex %d", ob->stats.Dex); |
805 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Con %d", ob->stats.Con); |
806 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Int %d", ob->stats.Int); |
807 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Wis %d", ob->stats.Wis); |
808 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Cha %d", ob->stats.Cha); |
809 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Pow %d", ob->stats.Pow); |
810 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "wc %d damage %d ac %d ", ob->stats.wc, ob->stats.dam, ob->stats.ac); |
811 |
|
|
have_shown_pet = 1; |
812 |
root |
1.3 |
} |
813 |
|
|
} |
814 |
elmex |
1.1 |
} |
815 |
root |
1.7 |
if (counter == 0) |
816 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "you have no pets."); |
817 |
|
|
else if (target != 0 && have_shown_pet == 0) |
818 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
819 |
|
|
return 0; |
820 |
elmex |
1.1 |
} |
821 |
|
|
|
822 |
root |
1.7 |
int |
823 |
|
|
command_usekeys (object *op, char *params) |
824 |
elmex |
1.1 |
{ |
825 |
root |
1.7 |
usekeytype oldtype = op->contr->usekeys; |
826 |
|
|
static const char *const types[] = { "inventory", "keyrings", "containers" }; |
827 |
elmex |
1.1 |
|
828 |
root |
1.7 |
if (!params) |
829 |
|
|
{ |
830 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys is set to %s", types[op->contr->usekeys]); |
831 |
|
|
return 1; |
832 |
|
|
} |
833 |
|
|
|
834 |
|
|
if (!strcmp (params, "inventory")) |
835 |
|
|
op->contr->usekeys = key_inventory; |
836 |
|
|
else if (!strcmp (params, "keyrings")) |
837 |
|
|
op->contr->usekeys = keyrings; |
838 |
|
|
else if (!strcmp (params, "containers")) |
839 |
|
|
op->contr->usekeys = containers; |
840 |
|
|
else |
841 |
|
|
{ |
842 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys: Unknown options %s, valid options are inventory, keyrings, containers", params); |
843 |
|
|
return 0; |
844 |
|
|
} |
845 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys %s set to %s", (oldtype == op->contr->usekeys ? "" : "now"), types[op->contr->usekeys]); |
846 |
|
|
return 1; |
847 |
elmex |
1.1 |
} |
848 |
|
|
|
849 |
root |
1.7 |
int |
850 |
|
|
command_resistances (object *op, char *params) |
851 |
elmex |
1.1 |
{ |
852 |
root |
1.7 |
int i; |
853 |
elmex |
1.1 |
|
854 |
root |
1.7 |
if (!op) |
855 |
|
|
return 0; |
856 |
|
|
|
857 |
|
|
for (i = 0; i < NROFATTACKS; i++) |
858 |
|
|
{ |
859 |
|
|
if (i == ATNR_INTERNAL) |
860 |
|
|
continue; |
861 |
elmex |
1.1 |
|
862 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, "%-20s %+5d", attacktype_desc[i], op->resist[i]); |
863 |
elmex |
1.1 |
} |
864 |
|
|
|
865 |
root |
1.7 |
/* If dragon player, let's display natural resistances */ |
866 |
|
|
if (is_dragon_pl (op)) |
867 |
|
|
{ |
868 |
|
|
int attack; |
869 |
|
|
object *tmp; |
870 |
|
|
|
871 |
|
|
for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
872 |
elmex |
1.1 |
{ |
873 |
root |
1.7 |
if ((tmp->type == FORCE) && (strcmp (tmp->arch->name, "dragon_skin_force") == 0)) |
874 |
elmex |
1.1 |
{ |
875 |
root |
1.7 |
new_draw_info (NDI_UNIQUE, 0, op, "\nNatural skin resistances:"); |
876 |
|
|
for (attack = 0; attack < NROFATTACKS; attack++) |
877 |
elmex |
1.1 |
{ |
878 |
root |
1.7 |
if (atnr_is_dragon_enabled (attack)) |
879 |
elmex |
1.1 |
{ |
880 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, "%s: %d", change_resist_msg[attack], tmp->resist[attack]); |
881 |
elmex |
1.1 |
} |
882 |
|
|
} |
883 |
root |
1.7 |
break; |
884 |
elmex |
1.1 |
} |
885 |
|
|
} |
886 |
root |
1.7 |
} |
887 |
elmex |
1.1 |
|
888 |
root |
1.7 |
return 0; |
889 |
elmex |
1.1 |
} |
890 |
root |
1.7 |
|
891 |
elmex |
1.1 |
/* |
892 |
|
|
* Actual commands. |
893 |
|
|
* Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
894 |
|
|
*/ |
895 |
|
|
|
896 |
|
|
|
897 |
root |
1.7 |
static void |
898 |
|
|
help_topics (object *op, int what) |
899 |
elmex |
1.1 |
{ |
900 |
root |
1.7 |
DIR *dirp; |
901 |
|
|
struct dirent *de; |
902 |
|
|
char filename[MAX_BUF], line[80]; |
903 |
|
|
int namelen, linelen = 0; |
904 |
|
|
|
905 |
|
|
switch (what) |
906 |
|
|
{ |
907 |
root |
1.3 |
case 1: |
908 |
root |
1.7 |
sprintf (filename, "%s/wizhelp", settings.datadir); |
909 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
910 |
|
|
break; |
911 |
root |
1.3 |
case 3: |
912 |
root |
1.7 |
sprintf (filename, "%s/mischelp", settings.datadir); |
913 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
914 |
|
|
break; |
915 |
root |
1.3 |
default: |
916 |
root |
1.7 |
sprintf (filename, "%s/help", settings.datadir); |
917 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
918 |
|
|
break; |
919 |
|
|
} |
920 |
|
|
if (!(dirp = opendir (filename))) |
921 |
|
|
return; |
922 |
|
|
|
923 |
|
|
line[0] = '\0'; |
924 |
|
|
for (de = readdir (dirp); de; de = readdir (dirp)) |
925 |
|
|
{ |
926 |
|
|
namelen = NAMLEN (de); |
927 |
|
|
if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
928 |
|
|
continue; |
929 |
|
|
linelen += namelen + 1; |
930 |
|
|
if (linelen > 42) |
931 |
|
|
{ |
932 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, line); |
933 |
|
|
sprintf (line, " %s", de->d_name); |
934 |
|
|
linelen = namelen + 1; |
935 |
|
|
continue; |
936 |
root |
1.3 |
} |
937 |
root |
1.7 |
strcat (line, " "); |
938 |
|
|
strcat (line, de->d_name); |
939 |
elmex |
1.1 |
} |
940 |
root |
1.7 |
new_draw_info (NDI_UNIQUE, 0, op, line); |
941 |
|
|
closedir (dirp); |
942 |
elmex |
1.1 |
} |
943 |
|
|
|
944 |
root |
1.7 |
static void |
945 |
|
|
show_commands (object *op, int what) |
946 |
elmex |
1.1 |
{ |
947 |
|
|
char line[80]; |
948 |
root |
1.7 |
int i, size, namelen, linelen = 0; |
949 |
elmex |
1.1 |
CommArray_s *ap; |
950 |
|
|
extern CommArray_s Commands[], WizCommands[]; |
951 |
|
|
extern const int CommandsSize, WizCommandsSize; |
952 |
root |
1.7 |
|
953 |
|
|
switch (what) |
954 |
|
|
{ |
955 |
|
|
case 1: |
956 |
|
|
ap = WizCommands; |
957 |
|
|
size = WizCommandsSize; |
958 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
959 |
|
|
break; |
960 |
|
|
case 2: |
961 |
|
|
ap = CommunicationCommands; |
962 |
|
|
size = CommunicationCommandSize; |
963 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, " Communication commands:"); |
964 |
|
|
break; |
965 |
|
|
default: |
966 |
|
|
ap = Commands; |
967 |
|
|
size = CommandsSize; |
968 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
969 |
|
|
break; |
970 |
|
|
} |
971 |
|
|
|
972 |
|
|
line[0] = '\0'; |
973 |
|
|
for (i = 0; i < size; i++) |
974 |
|
|
{ |
975 |
|
|
namelen = strlen (ap[i].name); |
976 |
|
|
linelen += namelen + 1; |
977 |
|
|
if (linelen > 42) |
978 |
|
|
{ |
979 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, line); |
980 |
|
|
sprintf (line, " %s", ap[i].name); |
981 |
|
|
linelen = namelen + 1; |
982 |
|
|
continue; |
983 |
|
|
} |
984 |
|
|
strcat (line, " "); |
985 |
|
|
strcat (line, ap[i].name); |
986 |
|
|
} |
987 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, line); |
988 |
elmex |
1.1 |
} |
989 |
|
|
|
990 |
|
|
|
991 |
root |
1.7 |
int |
992 |
|
|
command_help (object *op, char *params) |
993 |
elmex |
1.1 |
{ |
994 |
|
|
struct stat st; |
995 |
|
|
FILE *fp; |
996 |
|
|
char filename[MAX_BUF], line[MAX_BUF]; |
997 |
|
|
int len; |
998 |
|
|
|
999 |
root |
1.7 |
if (op != NULL) |
1000 |
|
|
clear_win_info (op); |
1001 |
elmex |
1.1 |
|
1002 |
|
|
/* |
1003 |
|
|
* Main help page? |
1004 |
|
|
*/ |
1005 |
root |
1.7 |
if (!params) |
1006 |
|
|
{ |
1007 |
|
|
sprintf (filename, "%s/def_help", settings.datadir); |
1008 |
|
|
if ((fp = fopen (filename, "r")) == NULL) |
1009 |
|
|
{ |
1010 |
|
|
LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
1011 |
|
|
return 0; |
1012 |
|
|
} |
1013 |
|
|
while (fgets (line, MAX_BUF, fp)) |
1014 |
|
|
{ |
1015 |
|
|
line[MAX_BUF - 1] = '\0'; |
1016 |
|
|
len = strlen (line) - 1; |
1017 |
|
|
if (line[len] == '\n') |
1018 |
|
|
line[len] = '\0'; |
1019 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, line); |
1020 |
|
|
} |
1021 |
|
|
fclose (fp); |
1022 |
elmex |
1.1 |
return 0; |
1023 |
|
|
} |
1024 |
|
|
|
1025 |
|
|
/* |
1026 |
|
|
* Topics list |
1027 |
|
|
*/ |
1028 |
root |
1.7 |
if (!strcmp (params, "topics")) |
1029 |
|
|
{ |
1030 |
|
|
help_topics (op, 3); |
1031 |
|
|
help_topics (op, 0); |
1032 |
|
|
if (QUERY_FLAG (op, FLAG_WIZ)) |
1033 |
|
|
help_topics (op, 1); |
1034 |
|
|
return 0; |
1035 |
elmex |
1.1 |
} |
1036 |
root |
1.7 |
|
1037 |
elmex |
1.1 |
/* |
1038 |
|
|
* Commands list |
1039 |
|
|
*/ |
1040 |
root |
1.7 |
if (!strcmp (params, "commands")) |
1041 |
|
|
{ |
1042 |
|
|
show_commands (op, 0); |
1043 |
|
|
show_commands (op, 2); /* show comm commands */ |
1044 |
|
|
if (QUERY_FLAG (op, FLAG_WIZ)) |
1045 |
|
|
show_commands (op, 1); |
1046 |
|
|
return 0; |
1047 |
|
|
} |
1048 |
elmex |
1.1 |
|
1049 |
|
|
/* |
1050 |
|
|
* User wants info about command |
1051 |
|
|
*/ |
1052 |
root |
1.7 |
if (strchr (params, '.') || strchr (params, ' ') || strchr (params, '/')) |
1053 |
|
|
{ |
1054 |
|
|
sprintf (line, "Illegal characters in '%s'", params); |
1055 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, line); |
1056 |
|
|
return 0; |
1057 |
|
|
} |
1058 |
elmex |
1.1 |
|
1059 |
root |
1.7 |
sprintf (filename, "%s/mischelp/%s", settings.datadir, params); |
1060 |
|
|
if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
1061 |
|
|
{ |
1062 |
|
|
if (op) |
1063 |
|
|
{ |
1064 |
|
|
sprintf (filename, "%s/help/%s", settings.datadir, params); |
1065 |
|
|
if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
1066 |
|
|
{ |
1067 |
|
|
if (QUERY_FLAG (op, FLAG_WIZ)) |
1068 |
|
|
{ |
1069 |
|
|
sprintf (filename, "%s/wizhelp/%s", settings.datadir, params); |
1070 |
|
|
if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
1071 |
|
|
goto nohelp; |
1072 |
|
|
} |
1073 |
|
|
else |
1074 |
|
|
goto nohelp; |
1075 |
|
|
} |
1076 |
|
|
} |
1077 |
|
|
} |
1078 |
elmex |
1.1 |
|
1079 |
|
|
/* |
1080 |
|
|
* Found that. Just cat it to screen. |
1081 |
|
|
*/ |
1082 |
root |
1.7 |
if ((fp = fopen (filename, "r")) == NULL) |
1083 |
|
|
{ |
1084 |
|
|
LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
1085 |
|
|
return 0; |
1086 |
|
|
} |
1087 |
|
|
sprintf (line, "Help about '%s'", params); |
1088 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, line); |
1089 |
|
|
while (fgets (line, MAX_BUF, fp)) |
1090 |
|
|
{ |
1091 |
|
|
line[MAX_BUF - 1] = '\0'; |
1092 |
|
|
len = strlen (line) - 1; |
1093 |
|
|
if (line[len] == '\n') |
1094 |
|
|
line[len] = '\0'; |
1095 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, line); |
1096 |
elmex |
1.1 |
} |
1097 |
root |
1.7 |
fclose (fp); |
1098 |
elmex |
1.1 |
return 0; |
1099 |
|
|
|
1100 |
|
|
/* |
1101 |
|
|
* No_help -escape |
1102 |
|
|
*/ |
1103 |
root |
1.7 |
nohelp: |
1104 |
|
|
sprintf (line, "No help available on '%s'", params); |
1105 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, line); |
1106 |
elmex |
1.1 |
return 0; |
1107 |
|
|
} |
1108 |
|
|
|
1109 |
|
|
|
1110 |
root |
1.7 |
int |
1111 |
|
|
onoff_value (const char *line) |
1112 |
elmex |
1.1 |
{ |
1113 |
|
|
int i; |
1114 |
|
|
|
1115 |
root |
1.7 |
if (sscanf (line, "%d", &i)) |
1116 |
elmex |
1.1 |
return (i != 0); |
1117 |
root |
1.7 |
switch (line[0]) |
1118 |
|
|
{ |
1119 |
|
|
case 'o': |
1120 |
|
|
switch (line[1]) |
1121 |
|
|
{ |
1122 |
|
|
case 'n': |
1123 |
|
|
return 1; /* on */ |
1124 |
|
|
default: |
1125 |
|
|
return 0; /* o[ff] */ |
1126 |
|
|
} |
1127 |
|
|
case 'y': /* y[es] */ |
1128 |
|
|
case 'k': /* k[ylla] */ |
1129 |
|
|
case 's': |
1130 |
|
|
case 'd': |
1131 |
|
|
return 1; |
1132 |
|
|
case 'n': /* n[o] */ |
1133 |
|
|
case 'e': /* e[i] */ |
1134 |
|
|
case 'u': |
1135 |
|
|
default: |
1136 |
|
|
return 0; |
1137 |
|
|
} |
1138 |
elmex |
1.1 |
} |
1139 |
|
|
|
1140 |
root |
1.7 |
int |
1141 |
|
|
command_quit (object *op, char *params) |
1142 |
elmex |
1.1 |
{ |
1143 |
root |
1.7 |
new_draw_info (NDI_UNIQUE, 0, op, |
1144 |
|
|
"Quitting will delete your character PERMANENTLY. If you are sure you want to do this, then use the quit_character command instead of quit."); |
1145 |
|
|
return 1; |
1146 |
elmex |
1.1 |
} |
1147 |
|
|
|
1148 |
root |
1.7 |
int |
1149 |
|
|
command_real_quit (object *op, char *params) |
1150 |
elmex |
1.1 |
{ |
1151 |
root |
1.7 |
send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Quitting will delete your character.\nAre you sure you want to quit (y/n):"); |
1152 |
elmex |
1.1 |
|
1153 |
root |
1.7 |
op->contr->state = ST_CONFIRM_QUIT; |
1154 |
|
|
return 1; |
1155 |
|
|
} |
1156 |
elmex |
1.1 |
|
1157 |
|
|
/* |
1158 |
|
|
* don't allow people to exit explore mode. It otherwise becomes |
1159 |
|
|
* really easy to abuse this. |
1160 |
|
|
*/ |
1161 |
root |
1.7 |
int |
1162 |
|
|
command_explore (object *op, char *params) |
1163 |
elmex |
1.1 |
{ |
1164 |
root |
1.7 |
if (settings.explore_mode == FALSE) |
1165 |
|
|
return 1; |
1166 |
elmex |
1.1 |
/* |
1167 |
|
|
* I guess this is the best way to see if we are solo or not. Actually, |
1168 |
|
|
* are there any cases when first_player->next==NULL and we are not solo? |
1169 |
|
|
*/ |
1170 |
root |
1.7 |
if ((first_player != op->contr) || (first_player->next != NULL)) |
1171 |
|
|
{ |
1172 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You can not enter explore mode if you are in a party"); |
1173 |
|
|
} |
1174 |
|
|
else if (op->contr->explore) |
1175 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "There is no return from explore mode"); |
1176 |
|
|
else |
1177 |
|
|
{ |
1178 |
|
|
op->contr->explore = 1; |
1179 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You are now in explore mode"); |
1180 |
elmex |
1.1 |
} |
1181 |
root |
1.7 |
return 1; |
1182 |
elmex |
1.1 |
} |
1183 |
|
|
|
1184 |
root |
1.7 |
int |
1185 |
|
|
command_sound (object *op, char *params) |
1186 |
elmex |
1.1 |
{ |
1187 |
root |
1.7 |
if (op->contr->socket.sound) |
1188 |
|
|
{ |
1189 |
|
|
op->contr->socket.sound = 0; |
1190 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
1191 |
|
|
} |
1192 |
|
|
else |
1193 |
|
|
{ |
1194 |
|
|
op->contr->socket.sound = 1; |
1195 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
1196 |
elmex |
1.1 |
} |
1197 |
root |
1.7 |
return 1; |
1198 |
elmex |
1.1 |
} |
1199 |
|
|
|
1200 |
|
|
/* Perhaps these should be in player.c, but that file is |
1201 |
|
|
* already a bit big. |
1202 |
|
|
*/ |
1203 |
|
|
|
1204 |
root |
1.7 |
void |
1205 |
|
|
receive_player_name (object *op, char k) |
1206 |
|
|
{ |
1207 |
elmex |
1.1 |
|
1208 |
root |
1.7 |
if (!check_name (op->contr, op->contr->write_buf + 1)) |
1209 |
|
|
{ |
1210 |
|
|
get_name (op); |
1211 |
|
|
return; |
1212 |
elmex |
1.1 |
} |
1213 |
root |
1.7 |
op->name = op->contr->write_buf + 1; |
1214 |
|
|
op->name_pl = op->contr->write_buf + 1; |
1215 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, op->contr->write_buf); |
1216 |
|
|
op->contr->name_changed = 1; |
1217 |
|
|
get_password (op); |
1218 |
elmex |
1.1 |
} |
1219 |
|
|
|
1220 |
root |
1.7 |
void |
1221 |
|
|
receive_player_password (object *op, char k) |
1222 |
|
|
{ |
1223 |
|
|
|
1224 |
|
|
unsigned int pwd_len = strlen (op->contr->write_buf); |
1225 |
elmex |
1.1 |
|
1226 |
root |
1.7 |
if (pwd_len <= 1 || pwd_len > 17) |
1227 |
|
|
{ |
1228 |
|
|
get_name (op); |
1229 |
|
|
return; |
1230 |
|
|
} |
1231 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, " "); /* To hide the password better */ |
1232 |
elmex |
1.1 |
|
1233 |
root |
1.7 |
if (checkbanned (op->name, op->contr->socket.host)) |
1234 |
|
|
{ |
1235 |
|
|
LOG (llevInfo, "Banned player tried to add: [%s@%s]\n", &op->name, op->contr->socket.host); |
1236 |
|
|
new_draw_info (NDI_UNIQUE | NDI_RED, 0, op, "You are not allowed to play."); |
1237 |
|
|
get_name (op); |
1238 |
|
|
return; |
1239 |
|
|
} |
1240 |
elmex |
1.1 |
|
1241 |
root |
1.7 |
if (op->contr->state == ST_CONFIRM_PASSWORD) |
1242 |
|
|
{ |
1243 |
|
|
if (!check_password (op->contr->write_buf + 1, op->contr->password)) |
1244 |
|
|
{ |
1245 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "The passwords did not match."); |
1246 |
|
|
get_name (op); |
1247 |
|
|
return; |
1248 |
|
|
} |
1249 |
|
|
clear_win_info (op); |
1250 |
|
|
display_motd (op); |
1251 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, " "); |
1252 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Welcome, Brave New Warrior!"); |
1253 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, " "); |
1254 |
|
|
Roll_Again (op); |
1255 |
|
|
op->contr->state = ST_ROLL_STAT; |
1256 |
elmex |
1.1 |
return; |
1257 |
|
|
} |
1258 |
root |
1.7 |
strcpy (op->contr->password, crypt_string (op->contr->write_buf + 1, NULL)); |
1259 |
|
|
op->contr->state = ST_ROLL_STAT; |
1260 |
|
|
check_login (op); |
1261 |
elmex |
1.1 |
return; |
1262 |
|
|
} |
1263 |
|
|
|
1264 |
|
|
|
1265 |
root |
1.7 |
int |
1266 |
|
|
explore_mode (void) |
1267 |
|
|
{ |
1268 |
|
|
player *pl; |
1269 |
elmex |
1.1 |
|
1270 |
root |
1.7 |
if (settings.explore_mode == TRUE) |
1271 |
|
|
{ |
1272 |
|
|
for (pl = first_player; pl != (player *) NULL; pl = pl->next) |
1273 |
|
|
if (pl->explore) |
1274 |
|
|
return 1; |
1275 |
elmex |
1.1 |
} |
1276 |
root |
1.7 |
return 0; |
1277 |
elmex |
1.1 |
} |
1278 |
|
|
|
1279 |
|
|
|
1280 |
root |
1.7 |
int |
1281 |
|
|
command_title (object *op, char *params) |
1282 |
elmex |
1.1 |
{ |
1283 |
root |
1.7 |
char buf[MAX_BUF]; |
1284 |
|
|
|
1285 |
|
|
if (settings.set_title == FALSE) |
1286 |
|
|
{ |
1287 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You cannot change your title."); |
1288 |
|
|
return 1; |
1289 |
elmex |
1.1 |
} |
1290 |
root |
1.7 |
|
1291 |
|
|
/* dragon players cannot change titles */ |
1292 |
|
|
if (is_dragon_pl (op)) |
1293 |
|
|
{ |
1294 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Dragons cannot change titles."); |
1295 |
|
|
return 1; |
1296 |
|
|
} |
1297 |
|
|
|
1298 |
|
|
if (params == NULL) |
1299 |
|
|
{ |
1300 |
|
|
if (op->contr->own_title[0] == '\0') |
1301 |
|
|
sprintf (buf, "Your title is '%s'.", op->contr->title); |
1302 |
|
|
else |
1303 |
|
|
sprintf (buf, "Your title is '%s'.", op->contr->own_title); |
1304 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, buf); |
1305 |
|
|
return 1; |
1306 |
|
|
} |
1307 |
|
|
if (strcmp (params, "clear") == 0 || strcmp (params, "default") == 0) |
1308 |
|
|
{ |
1309 |
|
|
if (op->contr->own_title[0] == '\0') |
1310 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Your title is the default title."); |
1311 |
|
|
else |
1312 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Title set to default."); |
1313 |
|
|
op->contr->own_title[0] = '\0'; |
1314 |
|
|
return 1; |
1315 |
|
|
} |
1316 |
|
|
|
1317 |
|
|
if ((int) strlen (params) >= MAX_NAME) |
1318 |
|
|
{ |
1319 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Title too long."); |
1320 |
|
|
return 1; |
1321 |
|
|
} |
1322 |
|
|
strcpy (op->contr->own_title, params); |
1323 |
|
|
return 1; |
1324 |
elmex |
1.1 |
} |
1325 |
|
|
|
1326 |
root |
1.7 |
int |
1327 |
|
|
command_save (object *op, char *params) |
1328 |
elmex |
1.1 |
{ |
1329 |
|
|
// if (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) { |
1330 |
root |
1.7 |
// new_draw_info(NDI_UNIQUE, 0, op, "You can not save on unholy ground"); |
1331 |
elmex |
1.1 |
// } else |
1332 |
root |
1.7 |
if (!op->stats.exp) |
1333 |
|
|
{ |
1334 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You don't deserve to save yet."); |
1335 |
|
|
} |
1336 |
|
|
else |
1337 |
|
|
{ |
1338 |
|
|
if (save_player (op, 1)) |
1339 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You have been saved."); |
1340 |
|
|
else |
1341 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "SAVE FAILED!"); |
1342 |
elmex |
1.1 |
} |
1343 |
root |
1.7 |
return 1; |
1344 |
elmex |
1.1 |
} |
1345 |
|
|
|
1346 |
|
|
|
1347 |
root |
1.7 |
int |
1348 |
|
|
command_peaceful (object *op, char *params) |
1349 |
elmex |
1.1 |
{ |
1350 |
root |
1.7 |
new_draw_info (NDI_UNIQUE, 0, op, |
1351 |
|
|
"You cannot change your peaceful setting with this command." |
1352 |
|
|
" Please speak to the priest in the temple of Gorokh" |
1353 |
|
|
" if you want to become hostile or in temple of Valriel" " if you want to become peaceful again."); |
1354 |
elmex |
1.1 |
|
1355 |
|
|
/* |
1356 |
|
|
if((op->contr->peaceful=!op->contr->peaceful)) |
1357 |
|
|
new_draw_info(NDI_UNIQUE, 0,op,"You will not attack other players."); |
1358 |
|
|
else |
1359 |
|
|
new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
1360 |
|
|
*/ |
1361 |
root |
1.7 |
return 1; |
1362 |
elmex |
1.1 |
} |
1363 |
|
|
|
1364 |
|
|
|
1365 |
|
|
|
1366 |
root |
1.7 |
int |
1367 |
|
|
command_wimpy (object *op, char *params) |
1368 |
elmex |
1.1 |
{ |
1369 |
root |
1.7 |
int i; |
1370 |
|
|
char buf[MAX_BUF]; |
1371 |
elmex |
1.1 |
|
1372 |
root |
1.7 |
if (params == NULL || !sscanf (params, "%d", &i)) |
1373 |
|
|
{ |
1374 |
|
|
sprintf (buf, "Your current wimpy level is %d.", op->run_away); |
1375 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, buf); |
1376 |
|
|
return 1; |
1377 |
|
|
} |
1378 |
|
|
sprintf (buf, "Your new wimpy level is %d.", i); |
1379 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, buf); |
1380 |
|
|
op->run_away = i; |
1381 |
|
|
return 1; |
1382 |
elmex |
1.1 |
} |
1383 |
|
|
|
1384 |
|
|
|
1385 |
root |
1.7 |
int |
1386 |
|
|
command_brace (object *op, char *params) |
1387 |
elmex |
1.1 |
{ |
1388 |
|
|
if (!params) |
1389 |
root |
1.7 |
op->contr->braced = !op->contr->braced; |
1390 |
elmex |
1.1 |
else |
1391 |
root |
1.7 |
op->contr->braced = onoff_value (params); |
1392 |
elmex |
1.1 |
|
1393 |
root |
1.7 |
if (op->contr->braced) |
1394 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
1395 |
elmex |
1.1 |
else |
1396 |
root |
1.7 |
new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
1397 |
elmex |
1.1 |
|
1398 |
root |
1.7 |
fix_player (op); |
1399 |
elmex |
1.1 |
return 0; |
1400 |
|
|
} |
1401 |
|
|
|
1402 |
root |
1.7 |
int |
1403 |
|
|
command_style_map_info (object *op, char *params) |
1404 |
elmex |
1.1 |
{ |
1405 |
root |
1.9 |
extern maptile *styles; |
1406 |
|
|
maptile *mp; |
1407 |
root |
1.7 |
int maps_used = 0, mapmem = 0, objects_used = 0, x, y; |
1408 |
|
|
object *tmp; |
1409 |
|
|
|
1410 |
|
|
for (mp = styles; mp != NULL; mp = mp->next) |
1411 |
|
|
{ |
1412 |
|
|
maps_used++; |
1413 |
root |
1.9 |
mapmem += MAP_WIDTH (mp) * MAP_HEIGHT (mp) * (sizeof (object *) + sizeof (MapSpace)) + sizeof (maptile); |
1414 |
root |
1.7 |
for (x = 0; x < MAP_WIDTH (mp); x++) |
1415 |
|
|
{ |
1416 |
|
|
for (y = 0; y < MAP_HEIGHT (mp); y++) |
1417 |
|
|
{ |
1418 |
|
|
for (tmp = get_map_ob (mp, x, y); tmp != NULL; tmp = tmp->above) |
1419 |
|
|
objects_used++; |
1420 |
root |
1.3 |
} |
1421 |
|
|
} |
1422 |
elmex |
1.1 |
} |
1423 |
root |
1.7 |
new_draw_info_format (NDI_UNIQUE, 0, op, "Style maps loaded: %d", maps_used); |
1424 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Memory used, not"); |
1425 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "including objects: %d", mapmem); |
1426 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Style objects: %d", objects_used); |
1427 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "Mem for objects: %d", objects_used * sizeof (object)); |
1428 |
|
|
return 0; |
1429 |
elmex |
1.1 |
} |
1430 |
|
|
|
1431 |
root |
1.7 |
int |
1432 |
|
|
command_kill_pets (object *op, char *params) |
1433 |
elmex |
1.1 |
{ |
1434 |
root |
1.7 |
objectlink *obl, *next; |
1435 |
|
|
int counter = 0, removecount = 0; |
1436 |
|
|
|
1437 |
|
|
if (params == NULL) |
1438 |
|
|
{ |
1439 |
|
|
terminate_all_pets (op); |
1440 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); |
1441 |
|
|
} |
1442 |
|
|
else |
1443 |
|
|
{ |
1444 |
|
|
int target = atoi (params); |
1445 |
|
|
|
1446 |
|
|
for (obl = first_friendly_object; obl != NULL; obl = next) |
1447 |
|
|
{ |
1448 |
|
|
object *ob = obl->ob; |
1449 |
|
|
|
1450 |
|
|
next = obl->next; |
1451 |
|
|
if (get_owner (ob) == op) |
1452 |
|
|
if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
1453 |
|
|
{ |
1454 |
|
|
if (!QUERY_FLAG (ob, FLAG_REMOVED)) |
1455 |
|
|
remove_ob (ob); |
1456 |
|
|
remove_friendly_object (ob); |
1457 |
|
|
free_object (ob); |
1458 |
root |
1.3 |
removecount++; |
1459 |
root |
1.7 |
} |
1460 |
root |
1.3 |
} |
1461 |
root |
1.7 |
if (removecount != 0) |
1462 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
1463 |
|
|
else |
1464 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
1465 |
elmex |
1.1 |
} |
1466 |
root |
1.7 |
return 0; |
1467 |
elmex |
1.1 |
} |