1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | |
3 | * |
|
|
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | (at your option) any later version. |
11 | * option) any later version. |
11 | |
12 | * |
12 | This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
16 | |
17 | * |
17 | You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | along with this program; if not, write to the Free Software |
19 | * and the GNU General Public License along with this program. If not, see |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * <http://www.gnu.org/licenses/>. |
20 | |
21 | * |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include <global.h> |
25 | #include <global.h> |
25 | #include <loader.h> |
|
|
26 | #include <sproto.h> |
26 | #include <sproto.h> |
27 | |
27 | |
28 | #include <dirent.h> |
|
|
29 | |
|
|
30 | extern weathermap_t **weathermap; |
|
|
31 | |
|
|
32 | /* Handles misc. input request - things like hash table, malloc, maps, |
28 | /* Handles misc. input request - things like hash table, malloc, maps, etc */ |
33 | * who, etc. |
|
|
34 | */ |
|
|
35 | |
|
|
36 | void |
|
|
37 | map_info (object *op, char *search) |
|
|
38 | { |
|
|
39 | maptile *m; |
|
|
40 | char buf[MAX_BUF], map_path[MAX_BUF]; |
|
|
41 | long sec = time (0); |
|
|
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 | } |
|
|
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 | int |
|
|
68 | command_body (object *op, char *params) |
|
|
69 | { |
|
|
70 | int i; |
|
|
71 | |
|
|
72 | /* 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 | } |
|
|
87 | } |
|
|
88 | 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 | |
|
|
93 | return 1; |
|
|
94 | } |
|
|
95 | |
|
|
96 | |
|
|
97 | int |
|
|
98 | command_motd (object *op, char *params) |
|
|
99 | { |
|
|
100 | display_motd (op); |
|
|
101 | return 1; |
|
|
102 | } |
|
|
103 | |
|
|
104 | int |
|
|
105 | command_bug (object *op, char *params) |
|
|
106 | { |
|
|
107 | char buf[MAX_BUF]; |
|
|
108 | |
|
|
109 | if (params == NULL) |
|
|
110 | { |
|
|
111 | new_draw_info (NDI_UNIQUE, 0, op, "what bugs?"); |
|
|
112 | return 1; |
|
|
113 | } |
|
|
114 | 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 | } |
|
|
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 | 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 | |
|
|
139 | if (!r) |
|
|
140 | return; |
|
|
141 | /* This should only be possible if regions are not operating on this server. */ |
|
|
142 | |
|
|
143 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are in %s. \n %s", get_region_longname (r), get_region_msg (r)); |
|
|
144 | } |
|
|
145 | |
|
|
146 | void |
|
|
147 | current_map_info (object *op) |
|
|
148 | { |
|
|
149 | maptile *m = op->map; |
|
|
150 | |
|
|
151 | if (!m) |
|
|
152 | return; |
|
|
153 | |
|
|
154 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) in %s", m->name, m->path, get_name_of_region_for_map (m)); |
|
|
155 | |
|
|
156 | 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 | |
|
|
162 | } |
|
|
163 | if (m->msg) |
|
|
164 | new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
|
|
165 | } |
|
|
166 | |
|
|
167 | #ifdef DEBUG_MALLOC_LEVEL |
|
|
168 | int |
|
|
169 | command_malloc_verify (object *op, char *parms) |
|
|
170 | { |
|
|
171 | extern int malloc_verify (void); |
|
|
172 | |
|
|
173 | 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 | #endif |
|
|
180 | |
|
|
181 | int |
|
|
182 | command_whereabouts (object *op, char *params) |
|
|
183 | { |
|
|
184 | |
|
|
185 | region *reg; |
|
|
186 | player *pl; |
|
|
187 | |
|
|
188 | /* |
|
|
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 | } |
|
|
211 | else /*uh oh, we shouldn't be here. */ |
|
|
212 | LOG (llevError, "command_whereabouts() Region %s with no longname has no parent", reg->name); |
|
|
213 | } |
|
|
214 | } |
|
|
215 | 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 | } |
|
|
221 | |
|
|
222 | typedef struct |
|
|
223 | { |
|
|
224 | char namebuf[MAX_BUF]; |
|
|
225 | int login_order; |
|
|
226 | } chars_names; |
|
|
227 | |
|
|
228 | 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 | { |
|
|
239 | SET_FLAG (op, FLAG_AFK); |
|
|
240 | new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK"); |
|
|
241 | } |
|
|
242 | return 1; |
|
|
243 | } |
|
|
244 | |
|
|
245 | int |
|
|
246 | command_mapinfo (object *op, char *params) |
|
|
247 | { |
|
|
248 | current_map_info (op); |
|
|
249 | return 1; |
|
|
250 | } |
|
|
251 | |
|
|
252 | int |
|
|
253 | command_whereami (object *op, char *params) |
|
|
254 | { |
|
|
255 | current_region_info (op); |
|
|
256 | return 1; |
|
|
257 | } |
|
|
258 | |
|
|
259 | int |
|
|
260 | command_maps (object *op, char *params) |
|
|
261 | { |
|
|
262 | map_info (op, params); |
|
|
263 | return 1; |
|
|
264 | } |
|
|
265 | |
29 | |
266 | int |
30 | int |
267 | command_time (object *op, char *params) |
31 | command_time (object *op, char *params) |
268 | { |
32 | { |
269 | print_tod (op); |
33 | print_tod (op); |
270 | return 1; |
|
|
271 | } |
|
|
272 | |
|
|
273 | int |
|
|
274 | command_weather (object *op, char *params) |
|
|
275 | { |
|
|
276 | 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 | |
|
|
315 | /* 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 | |
|
|
356 | 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 | } |
|
|
401 | return 1; |
|
|
402 | } |
|
|
403 | |
|
|
404 | int |
|
|
405 | command_archs (object *op, char *params) |
|
|
406 | { |
|
|
407 | arch_info (op); |
|
|
408 | return 1; |
|
|
409 | } |
|
|
410 | |
|
|
411 | int |
|
|
412 | command_hiscore (object *op, char *params) |
|
|
413 | { |
|
|
414 | display_high_score (op, op == NULL ? 9999 : 50, params); |
|
|
415 | return 1; |
34 | return 1; |
416 | } |
35 | } |
417 | |
36 | |
418 | int |
37 | int |
419 | command_debug (object *op, char *params) |
38 | command_debug (object *op, char *params) |
… | |
… | |
425 | { |
44 | { |
426 | sprintf (buf, "Global debug level is %d.", settings.debug); |
45 | sprintf (buf, "Global debug level is %d.", settings.debug); |
427 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
46 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
428 | return 1; |
47 | return 1; |
429 | } |
48 | } |
430 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
49 | |
431 | { |
50 | settings.debug = i; |
432 | new_draw_info (NDI_UNIQUE, 0, op, "Privileged command."); |
51 | |
433 | return 1; |
|
|
434 | } |
|
|
435 | settings.debug = (enum LogLevel) FABS (i); |
|
|
436 | sprintf (buf, "Set debug level to %d.", i); |
52 | sprintf (buf, "Set debug level to %d.", i); |
437 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
53 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
438 | return 1; |
54 | return 1; |
439 | } |
55 | } |
440 | |
|
|
441 | |
56 | |
442 | /* |
57 | /* |
443 | * Those dumps should be just one dump with good parser |
58 | * Those dumps should be just one dump with good parser |
444 | */ |
59 | */ |
445 | |
60 | |
… | |
… | |
456 | } |
71 | } |
457 | return 0; |
72 | return 0; |
458 | } |
73 | } |
459 | |
74 | |
460 | int |
75 | int |
461 | command_dumpfriendlyobjects (object *op, char *params) |
|
|
462 | { |
|
|
463 | dump_friendly_objects (); |
|
|
464 | return 0; |
|
|
465 | } |
|
|
466 | |
|
|
467 | int |
|
|
468 | command_dumpmap (object *op, char *params) |
|
|
469 | { |
|
|
470 | if (op) |
|
|
471 | dump_map (op->map); |
|
|
472 | return 0; |
|
|
473 | } |
|
|
474 | |
|
|
475 | int |
|
|
476 | command_dumpallmaps (object *op, char *params) |
|
|
477 | { |
|
|
478 | dump_all_maps (); |
|
|
479 | return 0; |
|
|
480 | } |
|
|
481 | |
|
|
482 | int |
|
|
483 | command_printlos (object *op, char *params) |
|
|
484 | { |
|
|
485 | if (op) |
|
|
486 | print_los (op); |
|
|
487 | return 0; |
|
|
488 | } |
|
|
489 | |
|
|
490 | |
|
|
491 | int |
|
|
492 | command_version (object *op, char *params) |
76 | command_version (object *op, char *params) |
493 | { |
77 | { |
494 | version (op); |
78 | version (op); |
495 | return 0; |
79 | return 0; |
496 | } |
|
|
497 | |
|
|
498 | |
|
|
499 | #ifndef BUG_LOG |
|
|
500 | # define BUG_LOG "bug_log" |
|
|
501 | #endif |
|
|
502 | 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 | } |
|
|
516 | } |
|
|
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 | |
|
|
537 | return 1; |
|
|
538 | } |
|
|
539 | |
|
|
540 | int |
|
|
541 | command_output_count (object *op, char *params) |
|
|
542 | { |
|
|
543 | int val; |
|
|
544 | |
|
|
545 | 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 | } |
|
|
550 | 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 | |
|
|
559 | return 1; |
|
|
560 | } |
|
|
561 | |
|
|
562 | int |
|
|
563 | command_listen (object *op, char *params) |
|
|
564 | { |
|
|
565 | int i; |
|
|
566 | |
|
|
567 | 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 | return 1; |
|
|
571 | } |
|
|
572 | 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 | } |
80 | } |
576 | |
81 | |
577 | /* Prints out some useful information for the character. Everything we print |
82 | /* 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 - |
83 | * 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 |
84 | * rather, we are making it convenient to find the values. params have |
… | |
… | |
582 | int |
87 | int |
583 | command_statistics (object *pl, char *params) |
88 | command_statistics (object *pl, char *params) |
584 | { |
89 | { |
585 | if (!pl->contr) |
90 | if (!pl->contr) |
586 | return 1; |
91 | return 1; |
587 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %" PRId64, pl->stats.exp); |
|
|
588 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %" PRId64, level_exp (pl->level + 1, pl->expmul)); |
|
|
589 | new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max"); |
|
|
590 | |
92 | |
591 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Str %2d/ %3d/%3d", |
93 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
592 | pl->contr->orig_stats.Str, pl->stats.Str, 20 + pl->arch->clone.stats.Str); |
94 | |
593 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Dex %2d/ %3d/%3d", |
95 | msg << " Experience: " << pl->stats.exp << '\n' |
594 | pl->contr->orig_stats.Dex, pl->stats.Dex, 20 + pl->arch->clone.stats.Dex); |
96 | << " Next Level: " << level_exp (pl->level + 1, pl->expmul) << '\n' |
595 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Con %2d/ %3d/%3d", |
97 | << "\n Stat Nat/Real/Max\n"; |
596 | pl->contr->orig_stats.Con, pl->stats.Con, 20 + pl->arch->clone.stats.Con); |
98 | |
597 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Int %2d/ %3d/%3d", |
99 | for (int i = 0; i < NUM_STATS; ++i) |
598 | pl->contr->orig_stats.Int, pl->stats.Int, 20 + pl->arch->clone.stats.Int); |
100 | msg.printf (" %s %2d/ %3d/%3d\n", short_stat_name [i], pl->contr->orig_stats.stat (i), pl->stats.stat (i), 20 + pl->arch->stats.stat (i)); |
599 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Wis %2d/ %3d/%3d", |
101 | |
600 | pl->contr->orig_stats.Wis, pl->stats.Wis, 20 + pl->arch->clone.stats.Wis); |
102 | msg << "\nYou are " << (pl->contr->peaceful ? "peaceful" : "hostile") << '.'; |
601 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Pow %2d/ %3d/%3d", |
103 | |
602 | pl->contr->orig_stats.Pow, pl->stats.Pow, 20 + pl->arch->clone.stats.Pow); |
104 | pl->contr->infobox (MSG_CHANNEL ("statistics"), msg); |
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 | |
105 | |
607 | /* Can't think of anything else to print right now */ |
106 | /* Can't think of anything else to print right now */ |
608 | return 0; |
107 | return 0; |
609 | } |
108 | } |
610 | |
109 | |
611 | int |
110 | int |
612 | command_fix_me (object *op, char *params) |
111 | command_fix_me (object *op, char *params) |
613 | { |
112 | { |
614 | sum_weight (op); |
113 | op->update_weight (); |
615 | fix_player (op); |
114 | op->update_stats (); |
616 | return 1; |
115 | new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed."); |
617 | } |
|
|
618 | |
116 | |
619 | int |
|
|
620 | command_players (object *op, char *paramss) |
|
|
621 | { |
|
|
622 | 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))) |
|
|
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 | { |
|
|
638 | struct stat Stat; |
|
|
639 | |
|
|
640 | 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 | } |
|
|
655 | } |
|
|
656 | } |
|
|
657 | } |
|
|
658 | } |
|
|
659 | closedir (Dir); |
|
|
660 | return 0; |
|
|
661 | } |
|
|
662 | |
|
|
663 | |
|
|
664 | |
|
|
665 | int |
|
|
666 | command_logs (object *op, char *params) |
|
|
667 | { |
|
|
668 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
|
|
669 | |
|
|
670 | return 1; |
|
|
671 | } |
|
|
672 | |
|
|
673 | int |
|
|
674 | command_applymode (object *op, char *params) |
|
|
675 | { |
|
|
676 | unapplymode unapply = op->contr->unapply; |
|
|
677 | static const char *const types[] = { "nochoice", "never", "always" }; |
|
|
678 | |
|
|
679 | 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; |
117 | return 1; |
699 | } |
118 | } |
700 | |
119 | |
701 | int |
120 | int |
702 | command_bowmode (object *op, char *params) |
121 | command_bowmode (object *op, char *params) |
703 | { |
122 | { |
704 | bowtype_t oldtype = op->contr->bowtype; |
123 | bowtype_t oldtype = op->contr->bowtype; |
705 | static const char *const types[] = { "normal", "threewide", "spreadshot", "firenorth", |
124 | static const char *const types[] = { |
|
|
125 | "normal", "threewide", "spreadshot", "firenorth", |
706 | "firene", "fireeast", "firese", "firesouth", |
126 | "firene", "fireeast", "firese", "firesouth", |
707 | "firesw", "firewest", "firenw", "bestarrow" |
127 | "firesw", "firewest", "firenw", "bestarrow" |
708 | }; |
128 | }; |
709 | char buf[MAX_BUF]; |
129 | char buf[MAX_BUF]; |
710 | int i, found; |
130 | int i, found; |
… | |
… | |
722 | found++; |
142 | found++; |
723 | op->contr->bowtype = (bowtype_t) i; |
143 | op->contr->bowtype = (bowtype_t) i; |
724 | break; |
144 | break; |
725 | } |
145 | } |
726 | } |
146 | } |
|
|
147 | |
727 | if (!found) |
148 | if (!found) |
728 | { |
149 | { |
729 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
150 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
|
|
151 | |
730 | for (i = 0; i <= bow_bestarrow; i++) |
152 | for (i = 0; i <= bow_bestarrow; i++) |
731 | { |
153 | { |
732 | strcat (buf, " "); |
154 | strcat (buf, " "); |
733 | strcat (buf, types[i]); |
155 | strcat (buf, types[i]); |
734 | if (i < bow_nw) |
156 | if (i < bow_nw) |
… | |
… | |
737 | strcat (buf, "."); |
159 | strcat (buf, "."); |
738 | } |
160 | } |
739 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
161 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
740 | return 0; |
162 | return 0; |
741 | } |
163 | } |
|
|
164 | |
742 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
165 | 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; |
166 | return 1; |
744 | } |
167 | } |
745 | |
168 | |
746 | int |
169 | int |
747 | command_petmode (object *op, char *params) |
|
|
748 | { |
|
|
749 | petmode_t oldtype = op->contr->petmode; |
|
|
750 | static const char *const types[] = { "normal", "sad", "defend", "arena" }; |
|
|
751 | |
|
|
752 | 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 | } |
|
|
775 | |
|
|
776 | int |
|
|
777 | command_showpets (object *op, char *params) |
170 | command_showpets (object *op, char *params) |
778 | { |
171 | { |
779 | objectlink *obl, *next; |
|
|
780 | int counter = 0, target = 0; |
172 | int counter = 0, target = 0; |
781 | int have_shown_pet = 0; |
173 | int have_shown_pet = 0; |
782 | |
174 | |
|
|
175 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
|
|
176 | |
783 | if (params != NULL) |
177 | if (params) |
784 | target = atoi (params); |
178 | target = atoi (params); |
|
|
179 | |
785 | for (obl = first_friendly_object; obl != NULL; obl = next) |
180 | for (objectlink *obl = first_friendly_object; obl; obl = obl->next) |
786 | { |
181 | { |
787 | object *ob = obl->ob; |
182 | object *ob = obl->ob; |
788 | |
183 | |
789 | next = obl->next; |
|
|
790 | if (get_owner (ob) == op) |
184 | if (ob->owner == op) |
791 | { |
185 | { |
792 | if (target == 0) |
186 | if (target == 0) |
793 | { |
187 | { |
794 | if (counter == 0) |
188 | if (counter == 0) |
795 | new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
189 | msg << "T<Pets>\n\n"; |
|
|
190 | |
796 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d %s - level %d", ++counter, &ob->name, ob->level); |
191 | msg.printf (" %3d %s, level %d\n", ++counter, &ob->name, ob->level); |
797 | } |
192 | } |
798 | else if (!have_shown_pet && ++counter == target) |
193 | else if (!have_shown_pet && ++counter == target) |
799 | { |
194 | { |
800 | new_draw_info_format (NDI_UNIQUE, 0, op, "level %d %s", ob->level, &ob->name); |
195 | msg.printf ("T<%s>\n\n" |
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); |
196 | " level %d\n" |
802 | /* this is not a nice way to do this, it should be made to be more like the statistics command */ |
197 | " %d/%d HP, %d/%d SP\n" |
803 | new_draw_info_format (NDI_UNIQUE, 0, op, "Str %d", ob->stats.Str); |
198 | " Str %2d\n" |
804 | new_draw_info_format (NDI_UNIQUE, 0, op, "Dex %d", ob->stats.Dex); |
199 | " Dex %2d\n" |
805 | new_draw_info_format (NDI_UNIQUE, 0, op, "Con %d", ob->stats.Con); |
200 | " Con %2d\n" |
806 | new_draw_info_format (NDI_UNIQUE, 0, op, "Int %d", ob->stats.Int); |
201 | " Int %2d\n" |
807 | new_draw_info_format (NDI_UNIQUE, 0, op, "Wis %d", ob->stats.Wis); |
202 | " Wis %2d\n" |
808 | new_draw_info_format (NDI_UNIQUE, 0, op, "Cha %d", ob->stats.Cha); |
203 | " Cha %2d\n" |
809 | new_draw_info_format (NDI_UNIQUE, 0, op, "Pow %d", ob->stats.Pow); |
204 | " Pow %2d\n" |
810 | new_draw_info_format (NDI_UNIQUE, 0, op, "wc %d damage %d ac %d ", ob->stats.wc, ob->stats.dam, ob->stats.ac); |
205 | " wc %d damage %d ac %d\n", |
|
|
206 | &ob->name, |
|
|
207 | ob->level, |
|
|
208 | ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp, |
|
|
209 | ob->stats.Str, |
|
|
210 | ob->stats.Dex, |
|
|
211 | ob->stats.Con, |
|
|
212 | ob->stats.Int, |
|
|
213 | ob->stats.Wis, |
|
|
214 | ob->stats.Cha, |
|
|
215 | ob->stats.Pow, |
|
|
216 | ob->stats.wc, ob->stats.dam, ob->stats.ac); |
|
|
217 | |
811 | have_shown_pet = 1; |
218 | have_shown_pet = 1; |
812 | } |
219 | } |
813 | } |
220 | } |
814 | } |
221 | } |
|
|
222 | |
815 | if (counter == 0) |
223 | if (counter == 0) |
816 | new_draw_info (NDI_UNIQUE, 0, op, "you have no pets."); |
224 | msg << "you have no pets."; |
817 | else if (target != 0 && have_shown_pet == 0) |
225 | else if (target != 0 && have_shown_pet == 0) |
818 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
226 | msg << "no such pet."; |
819 | return 0; |
|
|
820 | } |
|
|
821 | |
227 | |
822 | int |
228 | op->contr->infobox (MSG_CHANNEL ("pets"), msg); |
823 | command_usekeys (object *op, char *params) |
|
|
824 | { |
|
|
825 | usekeytype oldtype = op->contr->usekeys; |
|
|
826 | static const char *const types[] = { "inventory", "keyrings", "containers" }; |
|
|
827 | |
229 | |
828 | 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; |
230 | return 0; |
847 | } |
231 | } |
848 | |
232 | |
849 | int |
233 | int |
850 | command_resistances (object *op, char *params) |
234 | command_resistances (object *op, char *params) |
851 | { |
235 | { |
852 | int i; |
236 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
853 | |
237 | |
854 | if (!op) |
238 | msg << "Resistances:\n\n"; |
855 | return 0; |
|
|
856 | |
239 | |
857 | for (i = 0; i < NROFATTACKS; i++) |
240 | for (int i = 0; i < NROFATTACKS; i++) |
858 | { |
|
|
859 | if (i == ATNR_INTERNAL) |
241 | if (i != ATNR_INTERNAL) |
860 | continue; |
242 | msg.printf (" %-20s %+4d\n", attacktype_desc [i], op->resist [i]); |
861 | |
|
|
862 | new_draw_info_format (NDI_UNIQUE, 0, op, "%-20s %+5d", attacktype_desc[i], op->resist[i]); |
|
|
863 | } |
|
|
864 | |
243 | |
865 | /* If dragon player, let's display natural resistances */ |
244 | /* If dragon player, let's display natural resistances */ |
866 | if (is_dragon_pl (op)) |
245 | if (op->is_dragon ()) |
867 | { |
|
|
868 | int attack; |
|
|
869 | object *tmp; |
|
|
870 | |
|
|
871 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
246 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
872 | { |
|
|
873 | if ((tmp->type == FORCE) && (strcmp (tmp->arch->name, "dragon_skin_force") == 0)) |
247 | if ((tmp->type == FORCE) && tmp->arch->archname == shstr_dragon_skin_force) |
874 | { |
248 | { |
875 | new_draw_info (NDI_UNIQUE, 0, op, "\nNatural skin resistances:"); |
249 | msg << "\nOf those, these are natural skin resistances:\n\n"; |
|
|
250 | |
876 | for (attack = 0; attack < NROFATTACKS; attack++) |
251 | for (int attack = 0; attack < NROFATTACKS; attack++) |
877 | { |
|
|
878 | if (atnr_is_dragon_enabled (attack)) |
252 | if (atnr_is_dragon_enabled (attack)) |
879 | { |
253 | msg.printf (" %-20s %+4d\n", change_resist_msg [attack], tmp->resist [attack]); |
880 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s: %d", change_resist_msg[attack], tmp->resist[attack]); |
|
|
881 | } |
|
|
882 | } |
|
|
883 | break; |
|
|
884 | } |
|
|
885 | } |
|
|
886 | } |
|
|
887 | |
254 | |
888 | return 0; |
|
|
889 | } |
|
|
890 | |
|
|
891 | /* |
|
|
892 | * Actual commands. |
|
|
893 | * Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
|
|
894 | */ |
|
|
895 | |
|
|
896 | |
|
|
897 | static void |
|
|
898 | help_topics (object *op, int what) |
|
|
899 | { |
|
|
900 | DIR *dirp; |
|
|
901 | struct dirent *de; |
|
|
902 | char filename[MAX_BUF], line[80]; |
|
|
903 | int namelen, linelen = 0; |
|
|
904 | |
|
|
905 | switch (what) |
|
|
906 | { |
|
|
907 | case 1: |
|
|
908 | sprintf (filename, "%s/wizhelp", settings.datadir); |
|
|
909 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
|
|
910 | break; |
|
|
911 | case 3: |
|
|
912 | sprintf (filename, "%s/mischelp", settings.datadir); |
|
|
913 | new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
|
|
914 | break; |
|
|
915 | default: |
|
|
916 | sprintf (filename, "%s/help", settings.datadir); |
|
|
917 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
|
|
918 | break; |
|
|
919 | } |
|
|
920 | |
|
|
921 | if (!(dirp = opendir (filename))) |
|
|
922 | return; |
|
|
923 | |
|
|
924 | line[0] = '\0'; |
|
|
925 | while (de = readdir (dirp)) |
|
|
926 | { |
|
|
927 | namelen = strlen (de->d_name); |
|
|
928 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
|
|
929 | continue; |
|
|
930 | linelen += namelen + 1; |
|
|
931 | if (linelen > 42) |
|
|
932 | { |
|
|
933 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
934 | sprintf (line, " %s", de->d_name); |
|
|
935 | linelen = namelen + 1; |
|
|
936 | continue; |
|
|
937 | } |
|
|
938 | strcat (line, " "); |
|
|
939 | strcat (line, de->d_name); |
|
|
940 | } |
|
|
941 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
942 | closedir (dirp); |
|
|
943 | } |
|
|
944 | |
|
|
945 | static void |
|
|
946 | show_commands (object *op, int what) |
|
|
947 | { |
|
|
948 | char line[80]; |
|
|
949 | int i, size, namelen, linelen = 0; |
|
|
950 | CommArray_s *ap; |
|
|
951 | extern CommArray_s Commands[], WizCommands[]; |
|
|
952 | extern const int CommandsSize, WizCommandsSize; |
|
|
953 | |
|
|
954 | switch (what) |
|
|
955 | { |
|
|
956 | case 1: |
|
|
957 | ap = WizCommands; |
|
|
958 | size = WizCommandsSize; |
|
|
959 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
|
|
960 | break; |
255 | break; |
961 | case 2: |
|
|
962 | ap = CommunicationCommands; |
|
|
963 | size = CommunicationCommandSize; |
|
|
964 | new_draw_info (NDI_UNIQUE, 0, op, " Communication commands:"); |
|
|
965 | break; |
|
|
966 | default: |
|
|
967 | ap = Commands; |
|
|
968 | size = CommandsSize; |
|
|
969 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
|
|
970 | break; |
|
|
971 | } |
|
|
972 | |
|
|
973 | line[0] = '\0'; |
|
|
974 | for (i = 0; i < size; i++) |
|
|
975 | { |
|
|
976 | namelen = strlen (ap[i].name); |
|
|
977 | linelen += namelen + 1; |
|
|
978 | if (linelen > 42) |
|
|
979 | { |
256 | } |
980 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
981 | sprintf (line, " %s", ap[i].name); |
|
|
982 | linelen = namelen + 1; |
|
|
983 | continue; |
|
|
984 | } |
|
|
985 | strcat (line, " "); |
|
|
986 | strcat (line, ap[i].name); |
|
|
987 | } |
|
|
988 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
989 | } |
|
|
990 | |
257 | |
|
|
258 | op->contr->infobox (MSG_CHANNEL ("resistances"), msg); |
991 | |
259 | |
992 | int |
|
|
993 | command_help (object *op, char *params) |
|
|
994 | { |
|
|
995 | struct stat st; |
|
|
996 | FILE *fp; |
|
|
997 | char filename[MAX_BUF], line[MAX_BUF]; |
|
|
998 | int len; |
|
|
999 | |
|
|
1000 | if (op != NULL) |
|
|
1001 | clear_win_info (op); |
|
|
1002 | |
|
|
1003 | /* |
|
|
1004 | * Main help page? |
|
|
1005 | */ |
|
|
1006 | if (!params) |
|
|
1007 | { |
|
|
1008 | sprintf (filename, "%s/def_help", settings.datadir); |
|
|
1009 | if ((fp = fopen (filename, "r")) == NULL) |
|
|
1010 | { |
|
|
1011 | LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
|
|
1012 | return 0; |
|
|
1013 | } |
|
|
1014 | while (fgets (line, MAX_BUF, fp)) |
|
|
1015 | { |
|
|
1016 | line[MAX_BUF - 1] = '\0'; |
|
|
1017 | len = strlen (line) - 1; |
|
|
1018 | if (line[len] == '\n') |
|
|
1019 | line[len] = '\0'; |
|
|
1020 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
1021 | } |
|
|
1022 | fclose (fp); |
|
|
1023 | return 0; |
|
|
1024 | } |
|
|
1025 | |
|
|
1026 | /* |
|
|
1027 | * Topics list |
|
|
1028 | */ |
|
|
1029 | if (!strcmp (params, "topics")) |
|
|
1030 | { |
|
|
1031 | help_topics (op, 3); |
|
|
1032 | help_topics (op, 0); |
|
|
1033 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
1034 | help_topics (op, 1); |
|
|
1035 | return 0; |
|
|
1036 | } |
|
|
1037 | |
|
|
1038 | /* |
|
|
1039 | * Commands list |
|
|
1040 | */ |
|
|
1041 | if (!strcmp (params, "commands")) |
|
|
1042 | { |
|
|
1043 | show_commands (op, 0); |
|
|
1044 | show_commands (op, 2); /* show comm commands */ |
|
|
1045 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
1046 | show_commands (op, 1); |
|
|
1047 | return 0; |
|
|
1048 | } |
|
|
1049 | |
|
|
1050 | /* |
|
|
1051 | * User wants info about command |
|
|
1052 | */ |
|
|
1053 | if (strchr (params, '.') || strchr (params, ' ') || strchr (params, '/')) |
|
|
1054 | { |
|
|
1055 | sprintf (line, "Illegal characters in '%s'", params); |
|
|
1056 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
1057 | return 0; |
|
|
1058 | } |
|
|
1059 | |
|
|
1060 | sprintf (filename, "%s/mischelp/%s", settings.datadir, params); |
|
|
1061 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
1062 | { |
|
|
1063 | if (op) |
|
|
1064 | { |
|
|
1065 | sprintf (filename, "%s/help/%s", settings.datadir, params); |
|
|
1066 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
1067 | { |
|
|
1068 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
1069 | { |
|
|
1070 | sprintf (filename, "%s/wizhelp/%s", settings.datadir, params); |
|
|
1071 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
1072 | goto nohelp; |
|
|
1073 | } |
|
|
1074 | else |
|
|
1075 | goto nohelp; |
|
|
1076 | } |
|
|
1077 | } |
|
|
1078 | } |
|
|
1079 | |
|
|
1080 | /* |
|
|
1081 | * Found that. Just cat it to screen. |
|
|
1082 | */ |
|
|
1083 | if ((fp = fopen (filename, "r")) == NULL) |
|
|
1084 | { |
|
|
1085 | LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
|
|
1086 | return 0; |
|
|
1087 | } |
|
|
1088 | sprintf (line, "Help about '%s'", params); |
|
|
1089 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
1090 | while (fgets (line, MAX_BUF, fp)) |
|
|
1091 | { |
|
|
1092 | line[MAX_BUF - 1] = '\0'; |
|
|
1093 | len = strlen (line) - 1; |
|
|
1094 | if (line[len] == '\n') |
|
|
1095 | line[len] = '\0'; |
|
|
1096 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
1097 | } |
|
|
1098 | fclose (fp); |
|
|
1099 | return 0; |
|
|
1100 | |
|
|
1101 | /* |
|
|
1102 | * No_help -escape |
|
|
1103 | */ |
|
|
1104 | nohelp: |
|
|
1105 | sprintf (line, "No help available on '%s'", params); |
|
|
1106 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
1107 | return 0; |
|
|
1108 | } |
|
|
1109 | |
|
|
1110 | |
|
|
1111 | int |
|
|
1112 | onoff_value (const char *line) |
|
|
1113 | { |
|
|
1114 | int i; |
|
|
1115 | |
|
|
1116 | if (sscanf (line, "%d", &i)) |
|
|
1117 | return (i != 0); |
|
|
1118 | switch (line[0]) |
|
|
1119 | { |
|
|
1120 | case 'o': |
|
|
1121 | switch (line[1]) |
|
|
1122 | { |
|
|
1123 | case 'n': |
|
|
1124 | return 1; /* on */ |
|
|
1125 | default: |
|
|
1126 | return 0; /* o[ff] */ |
|
|
1127 | } |
|
|
1128 | case 'y': /* y[es] */ |
|
|
1129 | case 'k': /* k[ylla] */ |
|
|
1130 | case 's': |
|
|
1131 | case 'd': |
|
|
1132 | return 1; |
|
|
1133 | case 'n': /* n[o] */ |
|
|
1134 | case 'e': /* e[i] */ |
|
|
1135 | case 'u': |
|
|
1136 | default: |
|
|
1137 | return 0; |
|
|
1138 | } |
|
|
1139 | } |
|
|
1140 | |
|
|
1141 | int |
|
|
1142 | command_quit (object *op, char *params) |
|
|
1143 | { |
|
|
1144 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1145 | "Quitting will delete your character PERMANENTLY. If you are sure you want to do this, then use the quit_character command instead of quit."); |
|
|
1146 | return 1; |
260 | return 0; |
1147 | } |
261 | } |
1148 | |
|
|
1149 | int |
|
|
1150 | command_real_quit (object *op, char *params) |
|
|
1151 | { |
|
|
1152 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Quitting will delete your character.\nAre you sure you want to quit (y/n):"); |
|
|
1153 | |
|
|
1154 | op->contr->state = ST_CONFIRM_QUIT; |
|
|
1155 | return 1; |
|
|
1156 | } |
|
|
1157 | |
|
|
1158 | /* |
|
|
1159 | * don't allow people to exit explore mode. It otherwise becomes |
|
|
1160 | * really easy to abuse this. |
|
|
1161 | */ |
|
|
1162 | int |
|
|
1163 | command_explore (object *op, char *params) |
|
|
1164 | { |
|
|
1165 | if (settings.explore_mode == FALSE) |
|
|
1166 | return 1; |
|
|
1167 | /* |
|
|
1168 | * I guess this is the best way to see if we are solo or not. Actually, |
|
|
1169 | * are there any cases when first_player->next==NULL and we are not solo? |
|
|
1170 | */ |
|
|
1171 | if ((first_player != op->contr) || (first_player->next != NULL)) |
|
|
1172 | { |
|
|
1173 | new_draw_info (NDI_UNIQUE, 0, op, "You can not enter explore mode if you are in a party"); |
|
|
1174 | } |
|
|
1175 | else if (op->contr->explore) |
|
|
1176 | new_draw_info (NDI_UNIQUE, 0, op, "There is no return from explore mode"); |
|
|
1177 | else |
|
|
1178 | { |
|
|
1179 | op->contr->explore = 1; |
|
|
1180 | new_draw_info (NDI_UNIQUE, 0, op, "You are now in explore mode"); |
|
|
1181 | } |
|
|
1182 | return 1; |
|
|
1183 | } |
|
|
1184 | |
|
|
1185 | int |
|
|
1186 | command_sound (object *op, char *params) |
|
|
1187 | { |
|
|
1188 | if (op->contr->socket.sound) |
|
|
1189 | { |
|
|
1190 | op->contr->socket.sound = 0; |
|
|
1191 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
|
|
1192 | } |
|
|
1193 | else |
|
|
1194 | { |
|
|
1195 | op->contr->socket.sound = 1; |
|
|
1196 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
|
|
1197 | } |
|
|
1198 | return 1; |
|
|
1199 | } |
|
|
1200 | |
|
|
1201 | /* Perhaps these should be in player.c, but that file is |
|
|
1202 | * already a bit big. |
|
|
1203 | */ |
|
|
1204 | |
|
|
1205 | void |
|
|
1206 | receive_player_name (object *op, char k) |
|
|
1207 | { |
|
|
1208 | |
|
|
1209 | if (!check_name (op->contr, op->contr->write_buf + 1)) |
|
|
1210 | { |
|
|
1211 | get_name (op); |
|
|
1212 | return; |
|
|
1213 | } |
|
|
1214 | op->name = op->contr->write_buf + 1; |
|
|
1215 | op->name_pl = op->contr->write_buf + 1; |
|
|
1216 | new_draw_info (NDI_UNIQUE, 0, op, op->contr->write_buf); |
|
|
1217 | op->contr->name_changed = 1; |
|
|
1218 | get_password (op); |
|
|
1219 | } |
|
|
1220 | |
|
|
1221 | void |
|
|
1222 | receive_player_password (object *op, char k) |
|
|
1223 | { |
|
|
1224 | |
|
|
1225 | unsigned int pwd_len = strlen (op->contr->write_buf); |
|
|
1226 | |
|
|
1227 | if (pwd_len <= 1 || pwd_len > 17) |
|
|
1228 | { |
|
|
1229 | get_name (op); |
|
|
1230 | return; |
|
|
1231 | } |
|
|
1232 | new_draw_info (NDI_UNIQUE, 0, op, " "); /* To hide the password better */ |
|
|
1233 | |
|
|
1234 | if (checkbanned (op->name, op->contr->socket.host)) |
|
|
1235 | { |
|
|
1236 | LOG (llevInfo, "Banned player tried to add: [%s@%s]\n", &op->name, op->contr->socket.host); |
|
|
1237 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, op, "You are not allowed to play."); |
|
|
1238 | get_name (op); |
|
|
1239 | return; |
|
|
1240 | } |
|
|
1241 | |
|
|
1242 | if (op->contr->state == ST_CONFIRM_PASSWORD) |
|
|
1243 | { |
|
|
1244 | if (!check_password (op->contr->write_buf + 1, op->contr->password)) |
|
|
1245 | { |
|
|
1246 | new_draw_info (NDI_UNIQUE, 0, op, "The passwords did not match."); |
|
|
1247 | get_name (op); |
|
|
1248 | return; |
|
|
1249 | } |
|
|
1250 | clear_win_info (op); |
|
|
1251 | display_motd (op); |
|
|
1252 | new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
1253 | new_draw_info (NDI_UNIQUE, 0, op, "Welcome, Brave New Warrior!"); |
|
|
1254 | new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
1255 | Roll_Again (op); |
|
|
1256 | op->contr->state = ST_ROLL_STAT; |
|
|
1257 | return; |
|
|
1258 | } |
|
|
1259 | strcpy (op->contr->password, crypt_string (op->contr->write_buf + 1, NULL)); |
|
|
1260 | op->contr->state = ST_ROLL_STAT; |
|
|
1261 | check_login (op); |
|
|
1262 | return; |
|
|
1263 | } |
|
|
1264 | |
|
|
1265 | |
|
|
1266 | int |
|
|
1267 | explore_mode (void) |
|
|
1268 | { |
|
|
1269 | player *pl; |
|
|
1270 | |
|
|
1271 | if (settings.explore_mode == TRUE) |
|
|
1272 | { |
|
|
1273 | for (pl = first_player; pl != (player *) NULL; pl = pl->next) |
|
|
1274 | if (pl->explore) |
|
|
1275 | return 1; |
|
|
1276 | } |
|
|
1277 | return 0; |
|
|
1278 | } |
|
|
1279 | |
|
|
1280 | |
262 | |
1281 | int |
263 | int |
1282 | command_title (object *op, char *params) |
264 | command_title (object *op, char *params) |
1283 | { |
265 | { |
1284 | char buf[MAX_BUF]; |
266 | char buf[MAX_BUF]; |
… | |
… | |
1288 | new_draw_info (NDI_UNIQUE, 0, op, "You cannot change your title."); |
270 | new_draw_info (NDI_UNIQUE, 0, op, "You cannot change your title."); |
1289 | return 1; |
271 | return 1; |
1290 | } |
272 | } |
1291 | |
273 | |
1292 | /* dragon players cannot change titles */ |
274 | /* dragon players cannot change titles */ |
1293 | if (is_dragon_pl (op)) |
275 | if (op->is_dragon ()) |
1294 | { |
276 | { |
1295 | new_draw_info (NDI_UNIQUE, 0, op, "Dragons cannot change titles."); |
277 | new_draw_info (NDI_UNIQUE, 0, op, "Dragons cannot change titles."); |
1296 | return 1; |
278 | return 1; |
1297 | } |
279 | } |
1298 | |
280 | |
… | |
… | |
1323 | strcpy (op->contr->own_title, params); |
305 | strcpy (op->contr->own_title, params); |
1324 | return 1; |
306 | return 1; |
1325 | } |
307 | } |
1326 | |
308 | |
1327 | int |
309 | int |
1328 | command_save (object *op, char *params) |
|
|
1329 | { |
|
|
1330 | // if (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) { |
|
|
1331 | // new_draw_info(NDI_UNIQUE, 0, op, "You can not save on unholy ground"); |
|
|
1332 | // } else |
|
|
1333 | if (!op->stats.exp) |
|
|
1334 | { |
|
|
1335 | new_draw_info (NDI_UNIQUE, 0, op, "You don't deserve to save yet."); |
|
|
1336 | } |
|
|
1337 | else |
|
|
1338 | { |
|
|
1339 | if (save_player (op, 1)) |
|
|
1340 | new_draw_info (NDI_UNIQUE, 0, op, "You have been saved."); |
|
|
1341 | else |
|
|
1342 | new_draw_info (NDI_UNIQUE, 0, op, "SAVE FAILED!"); |
|
|
1343 | } |
|
|
1344 | return 1; |
|
|
1345 | } |
|
|
1346 | |
|
|
1347 | |
|
|
1348 | int |
|
|
1349 | command_peaceful (object *op, char *params) |
|
|
1350 | { |
|
|
1351 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1352 | "You cannot change your peaceful setting with this command." |
|
|
1353 | " Please speak to the priest in the temple of Gorokh" |
|
|
1354 | " if you want to become hostile or in temple of Valriel" " if you want to become peaceful again."); |
|
|
1355 | |
|
|
1356 | /* |
|
|
1357 | if((op->contr->peaceful=!op->contr->peaceful)) |
|
|
1358 | new_draw_info(NDI_UNIQUE, 0,op,"You will not attack other players."); |
|
|
1359 | else |
|
|
1360 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
|
|
1361 | */ |
|
|
1362 | return 1; |
|
|
1363 | } |
|
|
1364 | |
|
|
1365 | |
|
|
1366 | |
|
|
1367 | int |
|
|
1368 | command_wimpy (object *op, char *params) |
|
|
1369 | { |
|
|
1370 | int i; |
|
|
1371 | char buf[MAX_BUF]; |
|
|
1372 | |
|
|
1373 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
1374 | { |
|
|
1375 | sprintf (buf, "Your current wimpy level is %d.", op->run_away); |
|
|
1376 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1377 | return 1; |
|
|
1378 | } |
|
|
1379 | sprintf (buf, "Your new wimpy level is %d.", i); |
|
|
1380 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1381 | op->run_away = i; |
|
|
1382 | return 1; |
|
|
1383 | } |
|
|
1384 | |
|
|
1385 | |
|
|
1386 | int |
|
|
1387 | command_brace (object *op, char *params) |
|
|
1388 | { |
|
|
1389 | if (!params) |
|
|
1390 | op->contr->braced = !op->contr->braced; |
|
|
1391 | else |
|
|
1392 | op->contr->braced = onoff_value (params); |
|
|
1393 | |
|
|
1394 | if (op->contr->braced) |
|
|
1395 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
|
|
1396 | else |
|
|
1397 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
|
|
1398 | |
|
|
1399 | fix_player (op); |
|
|
1400 | return 0; |
|
|
1401 | } |
|
|
1402 | |
|
|
1403 | int |
|
|
1404 | command_style_map_info (object *op, char *params) |
|
|
1405 | { |
|
|
1406 | extern maptile *styles; |
|
|
1407 | maptile *mp; |
|
|
1408 | int maps_used = 0, mapmem = 0, objects_used = 0, x, y; |
|
|
1409 | object *tmp; |
|
|
1410 | |
|
|
1411 | for (mp = styles; mp != NULL; mp = mp->next) |
|
|
1412 | { |
|
|
1413 | maps_used++; |
|
|
1414 | mapmem += MAP_WIDTH (mp) * MAP_HEIGHT (mp) * (sizeof (object *) + sizeof (MapSpace)) + sizeof (maptile); |
|
|
1415 | for (x = 0; x < MAP_WIDTH (mp); x++) |
|
|
1416 | { |
|
|
1417 | for (y = 0; y < MAP_HEIGHT (mp); y++) |
|
|
1418 | { |
|
|
1419 | for (tmp = get_map_ob (mp, x, y); tmp != NULL; tmp = tmp->above) |
|
|
1420 | objects_used++; |
|
|
1421 | } |
|
|
1422 | } |
|
|
1423 | } |
|
|
1424 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style maps loaded: %d", maps_used); |
|
|
1425 | new_draw_info (NDI_UNIQUE, 0, op, "Memory used, not"); |
|
|
1426 | new_draw_info_format (NDI_UNIQUE, 0, op, "including objects: %d", mapmem); |
|
|
1427 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style objects: %d", objects_used); |
|
|
1428 | new_draw_info_format (NDI_UNIQUE, 0, op, "Mem for objects: %d", objects_used * sizeof (object)); |
|
|
1429 | return 0; |
|
|
1430 | } |
|
|
1431 | |
|
|
1432 | int |
|
|
1433 | command_kill_pets (object *op, char *params) |
310 | command_kill_pets (object *op, char *params) |
1434 | { |
311 | { |
1435 | objectlink *obl, *next; |
312 | objectlink *obl, *next; |
1436 | int counter = 0, removecount = 0; |
313 | int counter = 0, removecount = 0; |
1437 | |
314 | |
1438 | if (params == NULL) |
315 | if (!params) |
1439 | { |
316 | { |
1440 | terminate_all_pets (op); |
317 | terminate_all_pets (op); |
1441 | new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); |
318 | new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); |
1442 | } |
319 | } |
1443 | else |
320 | else |
1444 | { |
321 | { |
1445 | int target = atoi (params); |
322 | int target = atoi (params); |
1446 | |
323 | |
1447 | for (obl = first_friendly_object; obl != NULL; obl = next) |
324 | for (obl = first_friendly_object; obl; obl = next) |
1448 | { |
325 | { |
1449 | object *ob = obl->ob; |
326 | object *ob = obl->ob; |
1450 | |
327 | |
1451 | next = obl->next; |
328 | next = obl->next; |
|
|
329 | |
1452 | if (get_owner (ob) == op) |
330 | if (ob->owner == op) |
1453 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
331 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
1454 | { |
332 | { |
1455 | ob->destroy (); |
333 | ob->destroy (); |
1456 | removecount++; |
334 | removecount++; |
1457 | } |
335 | } |
1458 | } |
336 | } |
|
|
337 | |
1459 | if (removecount != 0) |
338 | if (removecount != 0) |
1460 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
339 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
1461 | else |
340 | else |
1462 | new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
341 | new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
1463 | } |
342 | } |
|
|
343 | |
1464 | return 0; |
344 | return 0; |
1465 | } |
345 | } |