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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 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 <loader.h> |
26 | #ifndef __CEXTRACT__ |
|
|
27 | # include <sproto.h> |
27 | #include <sproto.h> |
28 | #endif |
|
|
29 | |
28 | |
30 | extern weathermap_t **weathermap; |
|
|
31 | |
|
|
32 | /* Handles misc. input request - things like hash table, malloc, maps, |
29 | /* 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 = 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 | } |
|
|
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 | |
30 | |
222 | typedef struct |
31 | typedef struct |
223 | { |
32 | { |
224 | char namebuf[MAX_BUF]; |
33 | char namebuf[MAX_BUF]; |
225 | int login_order; |
34 | int login_order; |
226 | } chars_names; |
35 | } chars_names; |
227 | |
36 | |
228 | int |
37 | 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 | |
|
|
266 | int |
|
|
267 | command_time (object *op, char *params) |
38 | command_time (object *op, char *params) |
268 | { |
39 | { |
269 | print_tod (op); |
40 | 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; |
41 | return 1; |
416 | } |
42 | } |
417 | |
43 | |
418 | int |
44 | int |
419 | command_debug (object *op, char *params) |
45 | command_debug (object *op, char *params) |
… | |
… | |
425 | { |
51 | { |
426 | sprintf (buf, "Global debug level is %d.", settings.debug); |
52 | sprintf (buf, "Global debug level is %d.", settings.debug); |
427 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
53 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
428 | return 1; |
54 | return 1; |
429 | } |
55 | } |
430 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
56 | |
431 | { |
57 | settings.debug = i; |
432 | new_draw_info (NDI_UNIQUE, 0, op, "Privileged command."); |
58 | |
433 | return 1; |
|
|
434 | } |
|
|
435 | settings.debug = (enum LogLevel) FABS (i); |
|
|
436 | sprintf (buf, "Set debug level to %d.", i); |
59 | sprintf (buf, "Set debug level to %d.", i); |
437 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
60 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
438 | return 1; |
61 | return 1; |
439 | } |
62 | } |
440 | |
|
|
441 | |
63 | |
442 | /* |
64 | /* |
443 | * Those dumps should be just one dump with good parser |
65 | * Those dumps should be just one dump with good parser |
444 | */ |
66 | */ |
445 | |
67 | |
… | |
… | |
456 | } |
78 | } |
457 | return 0; |
79 | return 0; |
458 | } |
80 | } |
459 | |
81 | |
460 | int |
82 | 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) |
83 | command_version (object *op, char *params) |
493 | { |
84 | { |
494 | version (op); |
85 | version (op); |
495 | return 0; |
86 | 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 | } |
87 | } |
576 | |
88 | |
577 | /* Prints out some useful information for the character. Everything we print |
89 | /* 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 - |
90 | * 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 |
91 | * rather, we are making it convenient to find the values. params have |
… | |
… | |
582 | int |
94 | int |
583 | command_statistics (object *pl, char *params) |
95 | command_statistics (object *pl, char *params) |
584 | { |
96 | { |
585 | if (!pl->contr) |
97 | if (!pl->contr) |
586 | return 1; |
98 | return 1; |
587 | #ifndef WIN32 |
|
|
588 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %lld", pl->stats.exp); |
|
|
589 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %lld", level_exp (pl->level + 1, pl->expmul)); |
|
|
590 | #else |
|
|
591 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %I64d", pl->stats.exp); |
|
|
592 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %I64d", level_exp (pl->level + 1, pl->expmul)); |
|
|
593 | #endif |
|
|
594 | new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max"); |
|
|
595 | |
99 | |
596 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Str %2d/ %3d/%3d", |
100 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
597 | pl->contr->orig_stats.Str, pl->stats.Str, 20 + pl->arch->clone.stats.Str); |
101 | |
598 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Dex %2d/ %3d/%3d", |
102 | msg << " Experience: " << pl->stats.exp << '\n' |
599 | pl->contr->orig_stats.Dex, pl->stats.Dex, 20 + pl->arch->clone.stats.Dex); |
103 | << " Next Level: " << level_exp (pl->level + 1, pl->expmul) << '\n' |
600 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Con %2d/ %3d/%3d", |
104 | << "\n Stat Nat/Real/Max\n"; |
601 | pl->contr->orig_stats.Con, pl->stats.Con, 20 + pl->arch->clone.stats.Con); |
105 | |
602 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Int %2d/ %3d/%3d", |
106 | for (int i = 0; i < NUM_STATS; ++i) |
603 | pl->contr->orig_stats.Int, pl->stats.Int, 20 + pl->arch->clone.stats.Int); |
107 | 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)); |
604 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Wis %2d/ %3d/%3d", |
108 | |
605 | pl->contr->orig_stats.Wis, pl->stats.Wis, 20 + pl->arch->clone.stats.Wis); |
109 | msg << "\nYou are " << (pl->contr->peaceful ? "peaceful" : "hostile") << '.'; |
606 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Pow %2d/ %3d/%3d", |
110 | |
607 | pl->contr->orig_stats.Pow, pl->stats.Pow, 20 + pl->arch->clone.stats.Pow); |
111 | pl->contr->infobox (MSG_CHANNEL ("statistics"), msg); |
608 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Cha %2d/ %3d/%3d", |
|
|
609 | pl->contr->orig_stats.Cha, pl->stats.Cha, 20 + pl->arch->clone.stats.Cha); |
|
|
610 | new_draw_info_format (NDI_UNIQUE, 0, pl, "\nAttack Mode: %s", pl->contr->peaceful ? "Peaceful" : "Hostile"); |
|
|
611 | |
112 | |
612 | /* Can't think of anything else to print right now */ |
113 | /* Can't think of anything else to print right now */ |
613 | return 0; |
114 | return 0; |
614 | } |
115 | } |
615 | |
116 | |
616 | int |
117 | int |
617 | command_fix_me (object *op, char *params) |
118 | command_fix_me (object *op, char *params) |
618 | { |
119 | { |
619 | sum_weight (op); |
120 | op->update_weight (); |
620 | fix_player (op); |
121 | op->update_stats (); |
621 | return 1; |
122 | new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed."); |
622 | } |
|
|
623 | |
123 | |
624 | int |
|
|
625 | command_players (object *op, char *paramss) |
|
|
626 | { |
|
|
627 | char buf[MAX_BUF]; |
|
|
628 | char *t; |
|
|
629 | DIR *Dir; |
|
|
630 | |
|
|
631 | sprintf (buf, "%s/%s/", settings.localdir, settings.playerdir); |
|
|
632 | t = buf + strlen (buf); |
|
|
633 | if ((Dir = opendir (buf)) != NULL) |
|
|
634 | { |
|
|
635 | const struct dirent *Entry; |
|
|
636 | |
|
|
637 | while ((Entry = readdir (Dir)) != NULL) |
|
|
638 | { |
|
|
639 | /* skip '.' , '..' */ |
|
|
640 | if (!((Entry->d_name[0] == '.' && Entry->d_name[1] == '\0') || |
|
|
641 | (Entry->d_name[0] == '.' && Entry->d_name[1] == '.' && Entry->d_name[2] == '\0'))) |
|
|
642 | { |
|
|
643 | struct stat Stat; |
|
|
644 | |
|
|
645 | strcpy (t, Entry->d_name); |
|
|
646 | if (stat (buf, &Stat) == 0) |
|
|
647 | { |
|
|
648 | /* This was not posix compatible |
|
|
649 | * if ((Stat.st_mode & S_IFMT)==S_IFDIR) { |
|
|
650 | */ |
|
|
651 | if (S_ISDIR (Stat.st_mode)) |
|
|
652 | { |
|
|
653 | char buf2[MAX_BUF]; |
|
|
654 | struct tm *tm = localtime (&Stat.st_mtime); |
|
|
655 | |
|
|
656 | sprintf (buf2, "%s\t%04d %02d %02d %02d %02d %02d", |
|
|
657 | Entry->d_name, 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); |
|
|
658 | new_draw_info (NDI_UNIQUE, 0, op, buf2); |
|
|
659 | } |
|
|
660 | } |
|
|
661 | } |
|
|
662 | } |
|
|
663 | } |
|
|
664 | closedir (Dir); |
|
|
665 | return 0; |
|
|
666 | } |
|
|
667 | |
|
|
668 | |
|
|
669 | |
|
|
670 | int |
|
|
671 | command_logs (object *op, char *params) |
|
|
672 | { |
|
|
673 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
|
|
674 | |
|
|
675 | return 1; |
|
|
676 | } |
|
|
677 | |
|
|
678 | int |
|
|
679 | command_applymode (object *op, char *params) |
|
|
680 | { |
|
|
681 | unapplymode unapply = op->contr->unapply; |
|
|
682 | static const char *const types[] = { "nochoice", "never", "always" }; |
|
|
683 | |
|
|
684 | if (!params) |
|
|
685 | { |
|
|
686 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode is set to %s", types[op->contr->unapply]); |
|
|
687 | return 1; |
|
|
688 | } |
|
|
689 | |
|
|
690 | if (!strcmp (params, "nochoice")) |
|
|
691 | op->contr->unapply = unapply_nochoice; |
|
|
692 | else if (!strcmp (params, "never")) |
|
|
693 | op->contr->unapply = unapply_never; |
|
|
694 | else if (!strcmp (params, "always")) |
|
|
695 | op->contr->unapply = unapply_always; |
|
|
696 | else |
|
|
697 | { |
|
|
698 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params); |
|
|
699 | return 0; |
|
|
700 | } |
|
|
701 | new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s", |
|
|
702 | (unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]); |
|
|
703 | return 1; |
124 | return 1; |
704 | } |
125 | } |
705 | |
126 | |
706 | int |
127 | int |
707 | command_bowmode (object *op, char *params) |
128 | command_bowmode (object *op, char *params) |
708 | { |
129 | { |
709 | bowtype_t oldtype = op->contr->bowtype; |
130 | bowtype_t oldtype = op->contr->bowtype; |
710 | static const char *const types[] = { "normal", "threewide", "spreadshot", "firenorth", |
131 | static const char *const types[] = { |
|
|
132 | "normal", "threewide", "spreadshot", "firenorth", |
711 | "firene", "fireeast", "firese", "firesouth", |
133 | "firene", "fireeast", "firese", "firesouth", |
712 | "firesw", "firewest", "firenw", "bestarrow" |
134 | "firesw", "firewest", "firenw", "bestarrow" |
713 | }; |
135 | }; |
714 | char buf[MAX_BUF]; |
136 | char buf[MAX_BUF]; |
715 | int i, found; |
137 | int i, found; |
… | |
… | |
727 | found++; |
149 | found++; |
728 | op->contr->bowtype = (bowtype_t) i; |
150 | op->contr->bowtype = (bowtype_t) i; |
729 | break; |
151 | break; |
730 | } |
152 | } |
731 | } |
153 | } |
|
|
154 | |
732 | if (!found) |
155 | if (!found) |
733 | { |
156 | { |
734 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
157 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
|
|
158 | |
735 | for (i = 0; i <= bow_bestarrow; i++) |
159 | for (i = 0; i <= bow_bestarrow; i++) |
736 | { |
160 | { |
737 | strcat (buf, " "); |
161 | strcat (buf, " "); |
738 | strcat (buf, types[i]); |
162 | strcat (buf, types[i]); |
739 | if (i < bow_nw) |
163 | if (i < bow_nw) |
… | |
… | |
742 | strcat (buf, "."); |
166 | strcat (buf, "."); |
743 | } |
167 | } |
744 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
168 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
745 | return 0; |
169 | return 0; |
746 | } |
170 | } |
|
|
171 | |
747 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
172 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
748 | return 1; |
173 | return 1; |
749 | } |
174 | } |
750 | |
175 | |
751 | int |
176 | int |
752 | command_petmode (object *op, char *params) |
|
|
753 | { |
|
|
754 | petmode_t oldtype = op->contr->petmode; |
|
|
755 | static const char *const types[] = { "normal", "sad", "defend", "arena" }; |
|
|
756 | |
|
|
757 | if (!params) |
|
|
758 | { |
|
|
759 | new_draw_info_format (NDI_UNIQUE, 0, op, "petmode is set to %s", types[op->contr->petmode]); |
|
|
760 | return 1; |
|
|
761 | } |
|
|
762 | |
|
|
763 | if (!strcmp (params, "normal")) |
|
|
764 | op->contr->petmode = pet_normal; |
|
|
765 | else if (!strcmp (params, "sad")) |
|
|
766 | op->contr->petmode = pet_sad; |
|
|
767 | else if (!strcmp (params, "defend")) |
|
|
768 | op->contr->petmode = pet_defend; |
|
|
769 | else if (!strcmp (params, "arena")) |
|
|
770 | op->contr->petmode = pet_arena; |
|
|
771 | else |
|
|
772 | { |
|
|
773 | new_draw_info_format (NDI_UNIQUE, 0, op, |
|
|
774 | "petmode: Unknown options %s, valid options are normal," "sad (seek and destroy), defend, arena", params); |
|
|
775 | return 0; |
|
|
776 | } |
|
|
777 | new_draw_info_format (NDI_UNIQUE, 0, op, "petmode %s set to %s", (oldtype == op->contr->petmode ? "" : "now"), types[op->contr->petmode]); |
|
|
778 | return 1; |
|
|
779 | } |
|
|
780 | |
|
|
781 | int |
|
|
782 | command_showpets (object *op, char *params) |
177 | command_showpets (object *op, char *params) |
783 | { |
178 | { |
784 | objectlink *obl, *next; |
|
|
785 | int counter = 0, target = 0; |
179 | int counter = 0, target = 0; |
786 | int have_shown_pet = 0; |
180 | int have_shown_pet = 0; |
787 | |
181 | |
|
|
182 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
|
|
183 | |
788 | if (params != NULL) |
184 | if (params) |
789 | target = atoi (params); |
185 | target = atoi (params); |
|
|
186 | |
790 | for (obl = first_friendly_object; obl != NULL; obl = next) |
187 | for (objectlink *obl = first_friendly_object; obl; obl = obl->next) |
791 | { |
188 | { |
792 | object *ob = obl->ob; |
189 | object *ob = obl->ob; |
793 | |
190 | |
794 | next = obl->next; |
|
|
795 | if (get_owner (ob) == op) |
191 | if (ob->owner == op) |
796 | { |
192 | { |
797 | if (target == 0) |
193 | if (target == 0) |
798 | { |
194 | { |
799 | if (counter == 0) |
195 | if (counter == 0) |
800 | new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
196 | msg << "T<Pets>\n\n"; |
|
|
197 | |
801 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d %s - level %d", ++counter, &ob->name, ob->level); |
198 | msg.printf (" %3d %s, level %d\n", ++counter, &ob->name, ob->level); |
802 | } |
199 | } |
803 | else if (!have_shown_pet && ++counter == target) |
200 | else if (!have_shown_pet && ++counter == target) |
804 | { |
201 | { |
805 | new_draw_info_format (NDI_UNIQUE, 0, op, "level %d %s", ob->level, &ob->name); |
202 | msg.printf ("T<%s>\n\n" |
806 | 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); |
203 | " level %d\n" |
807 | /* this is not a nice way to do this, it should be made to be more like the statistics command */ |
204 | " %d/%d HP, %d/%d SP\n" |
808 | new_draw_info_format (NDI_UNIQUE, 0, op, "Str %d", ob->stats.Str); |
205 | " Str %2d\n" |
809 | new_draw_info_format (NDI_UNIQUE, 0, op, "Dex %d", ob->stats.Dex); |
206 | " Dex %2d\n" |
810 | new_draw_info_format (NDI_UNIQUE, 0, op, "Con %d", ob->stats.Con); |
207 | " Con %2d\n" |
811 | new_draw_info_format (NDI_UNIQUE, 0, op, "Int %d", ob->stats.Int); |
208 | " Int %2d\n" |
812 | new_draw_info_format (NDI_UNIQUE, 0, op, "Wis %d", ob->stats.Wis); |
209 | " Wis %2d\n" |
813 | new_draw_info_format (NDI_UNIQUE, 0, op, "Cha %d", ob->stats.Cha); |
210 | " Cha %2d\n" |
814 | new_draw_info_format (NDI_UNIQUE, 0, op, "Pow %d", ob->stats.Pow); |
211 | " Pow %2d\n" |
815 | new_draw_info_format (NDI_UNIQUE, 0, op, "wc %d damage %d ac %d ", ob->stats.wc, ob->stats.dam, ob->stats.ac); |
212 | " wc %d damage %d ac %d\n", |
|
|
213 | &ob->name, |
|
|
214 | &ob->name, |
|
|
215 | ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp, |
|
|
216 | ob->stats.Str, |
|
|
217 | ob->stats.Dex, |
|
|
218 | ob->stats.Con, |
|
|
219 | ob->stats.Int, |
|
|
220 | ob->stats.Wis, |
|
|
221 | ob->stats.Cha, |
|
|
222 | ob->stats.Pow, |
|
|
223 | ob->stats.wc, ob->stats.dam, ob->stats.ac); |
|
|
224 | |
816 | have_shown_pet = 1; |
225 | have_shown_pet = 1; |
817 | } |
226 | } |
818 | } |
227 | } |
819 | } |
228 | } |
|
|
229 | |
820 | if (counter == 0) |
230 | if (counter == 0) |
821 | new_draw_info (NDI_UNIQUE, 0, op, "you have no pets."); |
231 | msg << "you have no pets."; |
822 | else if (target != 0 && have_shown_pet == 0) |
232 | else if (target != 0 && have_shown_pet == 0) |
823 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
233 | msg << "no such pet."; |
824 | return 0; |
|
|
825 | } |
|
|
826 | |
234 | |
827 | int |
235 | op->contr->infobox (MSG_CHANNEL ("pets"), msg); |
828 | command_usekeys (object *op, char *params) |
|
|
829 | { |
|
|
830 | usekeytype oldtype = op->contr->usekeys; |
|
|
831 | static const char *const types[] = { "inventory", "keyrings", "containers" }; |
|
|
832 | |
236 | |
833 | if (!params) |
|
|
834 | { |
|
|
835 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys is set to %s", types[op->contr->usekeys]); |
|
|
836 | return 1; |
|
|
837 | } |
|
|
838 | |
|
|
839 | if (!strcmp (params, "inventory")) |
|
|
840 | op->contr->usekeys = key_inventory; |
|
|
841 | else if (!strcmp (params, "keyrings")) |
|
|
842 | op->contr->usekeys = keyrings; |
|
|
843 | else if (!strcmp (params, "containers")) |
|
|
844 | op->contr->usekeys = containers; |
|
|
845 | else |
|
|
846 | { |
|
|
847 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys: Unknown options %s, valid options are inventory, keyrings, containers", params); |
|
|
848 | return 0; |
|
|
849 | } |
|
|
850 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys %s set to %s", (oldtype == op->contr->usekeys ? "" : "now"), types[op->contr->usekeys]); |
|
|
851 | return 1; |
237 | return 0; |
852 | } |
238 | } |
853 | |
239 | |
854 | int |
240 | int |
855 | command_resistances (object *op, char *params) |
241 | command_resistances (object *op, char *params) |
856 | { |
242 | { |
857 | int i; |
243 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
858 | |
244 | |
859 | if (!op) |
245 | msg << "Resistances:\n\n"; |
860 | return 0; |
|
|
861 | |
246 | |
862 | for (i = 0; i < NROFATTACKS; i++) |
247 | for (int i = 0; i < NROFATTACKS; i++) |
863 | { |
|
|
864 | if (i == ATNR_INTERNAL) |
248 | if (i != ATNR_INTERNAL) |
865 | continue; |
249 | msg.printf (" %-20s %+4d\n", attacktype_desc [i], op->resist [i]); |
866 | |
|
|
867 | new_draw_info_format (NDI_UNIQUE, 0, op, "%-20s %+5d", attacktype_desc[i], op->resist[i]); |
|
|
868 | } |
|
|
869 | |
250 | |
870 | /* If dragon player, let's display natural resistances */ |
251 | /* If dragon player, let's display natural resistances */ |
871 | if (is_dragon_pl (op)) |
252 | if (is_dragon_pl (op)) |
872 | { |
|
|
873 | int attack; |
|
|
874 | object *tmp; |
|
|
875 | |
|
|
876 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
253 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
877 | { |
|
|
878 | if ((tmp->type == FORCE) && (strcmp (tmp->arch->name, "dragon_skin_force") == 0)) |
254 | if ((tmp->type == FORCE) && tmp->arch->archname == shstr_dragon_skin_force) |
879 | { |
255 | { |
880 | new_draw_info (NDI_UNIQUE, 0, op, "\nNatural skin resistances:"); |
256 | msg << "\nOf those, these are natural skin resistances:\n\n"; |
|
|
257 | |
881 | for (attack = 0; attack < NROFATTACKS; attack++) |
258 | for (int attack = 0; attack < NROFATTACKS; attack++) |
882 | { |
|
|
883 | if (atnr_is_dragon_enabled (attack)) |
259 | if (atnr_is_dragon_enabled (attack)) |
884 | { |
260 | msg.printf (" %-20s %+4d\n", change_resist_msg [attack], tmp->resist [attack]); |
885 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s: %d", change_resist_msg[attack], tmp->resist[attack]); |
261 | |
886 | } |
|
|
887 | } |
|
|
888 | break; |
262 | break; |
889 | } |
263 | } |
890 | } |
264 | |
891 | } |
265 | op->contr->infobox (MSG_CHANNEL ("resistances"), msg); |
892 | |
266 | |
893 | return 0; |
267 | return 0; |
894 | } |
268 | } |
895 | |
269 | |
896 | /* |
270 | /* |
897 | * Actual commands. |
271 | * Actual commands. |
898 | * Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
272 | * Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
899 | */ |
273 | */ |
900 | |
|
|
901 | |
|
|
902 | static void |
274 | static int |
903 | help_topics (object *op, int what) |
|
|
904 | { |
|
|
905 | DIR *dirp; |
|
|
906 | struct dirent *de; |
|
|
907 | char filename[MAX_BUF], line[80]; |
|
|
908 | int namelen, linelen = 0; |
|
|
909 | |
|
|
910 | switch (what) |
|
|
911 | { |
|
|
912 | case 1: |
|
|
913 | sprintf (filename, "%s/wizhelp", settings.datadir); |
|
|
914 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
|
|
915 | break; |
|
|
916 | case 3: |
|
|
917 | sprintf (filename, "%s/mischelp", settings.datadir); |
|
|
918 | new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
|
|
919 | break; |
|
|
920 | default: |
|
|
921 | sprintf (filename, "%s/help", settings.datadir); |
|
|
922 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
|
|
923 | break; |
|
|
924 | } |
|
|
925 | if (!(dirp = opendir (filename))) |
|
|
926 | return; |
|
|
927 | |
|
|
928 | line[0] = '\0'; |
|
|
929 | for (de = readdir (dirp); de; de = readdir (dirp)) |
|
|
930 | { |
|
|
931 | namelen = NAMLEN (de); |
|
|
932 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
|
|
933 | continue; |
|
|
934 | linelen += namelen + 1; |
|
|
935 | if (linelen > 42) |
|
|
936 | { |
|
|
937 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
938 | sprintf (line, " %s", de->d_name); |
|
|
939 | linelen = namelen + 1; |
|
|
940 | continue; |
|
|
941 | } |
|
|
942 | strcat (line, " "); |
|
|
943 | strcat (line, de->d_name); |
|
|
944 | } |
|
|
945 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
946 | closedir (dirp); |
|
|
947 | } |
|
|
948 | |
|
|
949 | static void |
|
|
950 | show_commands (object *op, int what) |
|
|
951 | { |
|
|
952 | char line[80]; |
|
|
953 | int i, size, namelen, linelen = 0; |
|
|
954 | CommArray_s *ap; |
|
|
955 | extern CommArray_s Commands[], WizCommands[]; |
|
|
956 | extern const int CommandsSize, WizCommandsSize; |
|
|
957 | |
|
|
958 | switch (what) |
|
|
959 | { |
|
|
960 | case 1: |
|
|
961 | ap = WizCommands; |
|
|
962 | size = WizCommandsSize; |
|
|
963 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
|
|
964 | break; |
|
|
965 | case 2: |
|
|
966 | ap = CommunicationCommands; |
|
|
967 | size = CommunicationCommandSize; |
|
|
968 | new_draw_info (NDI_UNIQUE, 0, op, " Communication commands:"); |
|
|
969 | break; |
|
|
970 | default: |
|
|
971 | ap = Commands; |
|
|
972 | size = CommandsSize; |
|
|
973 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
|
|
974 | break; |
|
|
975 | } |
|
|
976 | |
|
|
977 | line[0] = '\0'; |
|
|
978 | for (i = 0; i < size; i++) |
|
|
979 | { |
|
|
980 | namelen = strlen (ap[i].name); |
|
|
981 | linelen += namelen + 1; |
|
|
982 | if (linelen > 42) |
|
|
983 | { |
|
|
984 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
985 | sprintf (line, " %s", ap[i].name); |
|
|
986 | linelen = namelen + 1; |
|
|
987 | continue; |
|
|
988 | } |
|
|
989 | strcat (line, " "); |
|
|
990 | strcat (line, ap[i].name); |
|
|
991 | } |
|
|
992 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
993 | } |
|
|
994 | |
|
|
995 | |
|
|
996 | int |
|
|
997 | command_help (object *op, char *params) |
|
|
998 | { |
|
|
999 | struct stat st; |
|
|
1000 | FILE *fp; |
|
|
1001 | char filename[MAX_BUF], line[MAX_BUF]; |
|
|
1002 | int len; |
|
|
1003 | |
|
|
1004 | if (op != NULL) |
|
|
1005 | clear_win_info (op); |
|
|
1006 | |
|
|
1007 | /* |
|
|
1008 | * Main help page? |
|
|
1009 | */ |
|
|
1010 | if (!params) |
|
|
1011 | { |
|
|
1012 | sprintf (filename, "%s/def_help", settings.datadir); |
|
|
1013 | if ((fp = fopen (filename, "r")) == NULL) |
|
|
1014 | { |
|
|
1015 | LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
|
|
1016 | return 0; |
|
|
1017 | } |
|
|
1018 | while (fgets (line, MAX_BUF, fp)) |
|
|
1019 | { |
|
|
1020 | line[MAX_BUF - 1] = '\0'; |
|
|
1021 | len = strlen (line) - 1; |
|
|
1022 | if (line[len] == '\n') |
|
|
1023 | line[len] = '\0'; |
|
|
1024 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
1025 | } |
|
|
1026 | fclose (fp); |
|
|
1027 | return 0; |
|
|
1028 | } |
|
|
1029 | |
|
|
1030 | /* |
|
|
1031 | * Topics list |
|
|
1032 | */ |
|
|
1033 | if (!strcmp (params, "topics")) |
|
|
1034 | { |
|
|
1035 | help_topics (op, 3); |
|
|
1036 | help_topics (op, 0); |
|
|
1037 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
1038 | help_topics (op, 1); |
|
|
1039 | return 0; |
|
|
1040 | } |
|
|
1041 | |
|
|
1042 | /* |
|
|
1043 | * Commands list |
|
|
1044 | */ |
|
|
1045 | if (!strcmp (params, "commands")) |
|
|
1046 | { |
|
|
1047 | show_commands (op, 0); |
|
|
1048 | show_commands (op, 2); /* show comm commands */ |
|
|
1049 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
1050 | show_commands (op, 1); |
|
|
1051 | return 0; |
|
|
1052 | } |
|
|
1053 | |
|
|
1054 | /* |
|
|
1055 | * User wants info about command |
|
|
1056 | */ |
|
|
1057 | if (strchr (params, '.') || strchr (params, ' ') || strchr (params, '/')) |
|
|
1058 | { |
|
|
1059 | sprintf (line, "Illegal characters in '%s'", params); |
|
|
1060 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
1061 | return 0; |
|
|
1062 | } |
|
|
1063 | |
|
|
1064 | sprintf (filename, "%s/mischelp/%s", settings.datadir, params); |
|
|
1065 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
1066 | { |
|
|
1067 | if (op) |
|
|
1068 | { |
|
|
1069 | sprintf (filename, "%s/help/%s", settings.datadir, params); |
|
|
1070 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
1071 | { |
|
|
1072 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
1073 | { |
|
|
1074 | sprintf (filename, "%s/wizhelp/%s", settings.datadir, params); |
|
|
1075 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
1076 | goto nohelp; |
|
|
1077 | } |
|
|
1078 | else |
|
|
1079 | goto nohelp; |
|
|
1080 | } |
|
|
1081 | } |
|
|
1082 | } |
|
|
1083 | |
|
|
1084 | /* |
|
|
1085 | * Found that. Just cat it to screen. |
|
|
1086 | */ |
|
|
1087 | if ((fp = fopen (filename, "r")) == NULL) |
|
|
1088 | { |
|
|
1089 | LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
|
|
1090 | return 0; |
|
|
1091 | } |
|
|
1092 | sprintf (line, "Help about '%s'", params); |
|
|
1093 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
1094 | while (fgets (line, MAX_BUF, fp)) |
|
|
1095 | { |
|
|
1096 | line[MAX_BUF - 1] = '\0'; |
|
|
1097 | len = strlen (line) - 1; |
|
|
1098 | if (line[len] == '\n') |
|
|
1099 | line[len] = '\0'; |
|
|
1100 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
1101 | } |
|
|
1102 | fclose (fp); |
|
|
1103 | return 0; |
|
|
1104 | |
|
|
1105 | /* |
|
|
1106 | * No_help -escape |
|
|
1107 | */ |
|
|
1108 | nohelp: |
|
|
1109 | sprintf (line, "No help available on '%s'", params); |
|
|
1110 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
1111 | return 0; |
|
|
1112 | } |
|
|
1113 | |
|
|
1114 | |
|
|
1115 | int |
|
|
1116 | onoff_value (const char *line) |
275 | onoff_value (const char *line) |
1117 | { |
276 | { |
1118 | int i; |
277 | int i; |
1119 | |
278 | |
1120 | if (sscanf (line, "%d", &i)) |
279 | if (sscanf (line, "%d", &i)) |
… | |
… | |
1141 | return 0; |
300 | return 0; |
1142 | } |
301 | } |
1143 | } |
302 | } |
1144 | |
303 | |
1145 | int |
304 | int |
1146 | command_quit (object *op, char *params) |
|
|
1147 | { |
|
|
1148 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1149 | "Quitting will delete your character PERMANENTLY. If you are sure you want to do this, then use the quit_character command instead of quit."); |
|
|
1150 | return 1; |
|
|
1151 | } |
|
|
1152 | |
|
|
1153 | int |
|
|
1154 | command_real_quit (object *op, char *params) |
|
|
1155 | { |
|
|
1156 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Quitting will delete your character.\nAre you sure you want to quit (y/n):"); |
|
|
1157 | |
|
|
1158 | op->contr->state = ST_CONFIRM_QUIT; |
|
|
1159 | return 1; |
|
|
1160 | } |
|
|
1161 | |
|
|
1162 | /* |
|
|
1163 | * don't allow people to exit explore mode. It otherwise becomes |
|
|
1164 | * really easy to abuse this. |
|
|
1165 | */ |
|
|
1166 | int |
|
|
1167 | command_explore (object *op, char *params) |
|
|
1168 | { |
|
|
1169 | if (settings.explore_mode == FALSE) |
|
|
1170 | return 1; |
|
|
1171 | /* |
|
|
1172 | * I guess this is the best way to see if we are solo or not. Actually, |
|
|
1173 | * are there any cases when first_player->next==NULL and we are not solo? |
|
|
1174 | */ |
|
|
1175 | if ((first_player != op->contr) || (first_player->next != NULL)) |
|
|
1176 | { |
|
|
1177 | new_draw_info (NDI_UNIQUE, 0, op, "You can not enter explore mode if you are in a party"); |
|
|
1178 | } |
|
|
1179 | else if (op->contr->explore) |
|
|
1180 | new_draw_info (NDI_UNIQUE, 0, op, "There is no return from explore mode"); |
|
|
1181 | else |
|
|
1182 | { |
|
|
1183 | op->contr->explore = 1; |
|
|
1184 | new_draw_info (NDI_UNIQUE, 0, op, "You are now in explore mode"); |
|
|
1185 | } |
|
|
1186 | return 1; |
|
|
1187 | } |
|
|
1188 | |
|
|
1189 | int |
|
|
1190 | command_sound (object *op, char *params) |
|
|
1191 | { |
|
|
1192 | if (op->contr->socket.sound) |
|
|
1193 | { |
|
|
1194 | op->contr->socket.sound = 0; |
|
|
1195 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
|
|
1196 | } |
|
|
1197 | else |
|
|
1198 | { |
|
|
1199 | op->contr->socket.sound = 1; |
|
|
1200 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
|
|
1201 | } |
|
|
1202 | return 1; |
|
|
1203 | } |
|
|
1204 | |
|
|
1205 | /* Perhaps these should be in player.c, but that file is |
|
|
1206 | * already a bit big. |
|
|
1207 | */ |
|
|
1208 | |
|
|
1209 | void |
|
|
1210 | receive_player_name (object *op, char k) |
|
|
1211 | { |
|
|
1212 | |
|
|
1213 | if (!check_name (op->contr, op->contr->write_buf + 1)) |
|
|
1214 | { |
|
|
1215 | get_name (op); |
|
|
1216 | return; |
|
|
1217 | } |
|
|
1218 | op->name = op->contr->write_buf + 1; |
|
|
1219 | op->name_pl = op->contr->write_buf + 1; |
|
|
1220 | new_draw_info (NDI_UNIQUE, 0, op, op->contr->write_buf); |
|
|
1221 | op->contr->name_changed = 1; |
|
|
1222 | get_password (op); |
|
|
1223 | } |
|
|
1224 | |
|
|
1225 | void |
|
|
1226 | receive_player_password (object *op, char k) |
|
|
1227 | { |
|
|
1228 | |
|
|
1229 | unsigned int pwd_len = strlen (op->contr->write_buf); |
|
|
1230 | |
|
|
1231 | if (pwd_len <= 1 || pwd_len > 17) |
|
|
1232 | { |
|
|
1233 | get_name (op); |
|
|
1234 | return; |
|
|
1235 | } |
|
|
1236 | new_draw_info (NDI_UNIQUE, 0, op, " "); /* To hide the password better */ |
|
|
1237 | |
|
|
1238 | if (checkbanned (op->name, op->contr->socket.host)) |
|
|
1239 | { |
|
|
1240 | LOG (llevInfo, "Banned player tried to add: [%s@%s]\n", &op->name, op->contr->socket.host); |
|
|
1241 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, op, "You are not allowed to play."); |
|
|
1242 | get_name (op); |
|
|
1243 | return; |
|
|
1244 | } |
|
|
1245 | |
|
|
1246 | if (op->contr->state == ST_CONFIRM_PASSWORD) |
|
|
1247 | { |
|
|
1248 | if (!check_password (op->contr->write_buf + 1, op->contr->password)) |
|
|
1249 | { |
|
|
1250 | new_draw_info (NDI_UNIQUE, 0, op, "The passwords did not match."); |
|
|
1251 | get_name (op); |
|
|
1252 | return; |
|
|
1253 | } |
|
|
1254 | clear_win_info (op); |
|
|
1255 | display_motd (op); |
|
|
1256 | new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
1257 | new_draw_info (NDI_UNIQUE, 0, op, "Welcome, Brave New Warrior!"); |
|
|
1258 | new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
1259 | Roll_Again (op); |
|
|
1260 | op->contr->state = ST_ROLL_STAT; |
|
|
1261 | return; |
|
|
1262 | } |
|
|
1263 | strcpy (op->contr->password, crypt_string (op->contr->write_buf + 1, NULL)); |
|
|
1264 | op->contr->state = ST_ROLL_STAT; |
|
|
1265 | check_login (op); |
|
|
1266 | return; |
|
|
1267 | } |
|
|
1268 | |
|
|
1269 | |
|
|
1270 | int |
|
|
1271 | explore_mode (void) |
|
|
1272 | { |
|
|
1273 | player *pl; |
|
|
1274 | |
|
|
1275 | if (settings.explore_mode == TRUE) |
|
|
1276 | { |
|
|
1277 | for (pl = first_player; pl != (player *) NULL; pl = pl->next) |
|
|
1278 | if (pl->explore) |
|
|
1279 | return 1; |
|
|
1280 | } |
|
|
1281 | return 0; |
|
|
1282 | } |
|
|
1283 | |
|
|
1284 | |
|
|
1285 | int |
|
|
1286 | command_title (object *op, char *params) |
305 | command_title (object *op, char *params) |
1287 | { |
306 | { |
1288 | char buf[MAX_BUF]; |
307 | char buf[MAX_BUF]; |
1289 | |
308 | |
1290 | if (settings.set_title == FALSE) |
309 | if (settings.set_title == FALSE) |
… | |
… | |
1327 | strcpy (op->contr->own_title, params); |
346 | strcpy (op->contr->own_title, params); |
1328 | return 1; |
347 | return 1; |
1329 | } |
348 | } |
1330 | |
349 | |
1331 | int |
350 | int |
1332 | command_save (object *op, char *params) |
|
|
1333 | { |
|
|
1334 | // if (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) { |
|
|
1335 | // new_draw_info(NDI_UNIQUE, 0, op, "You can not save on unholy ground"); |
|
|
1336 | // } else |
|
|
1337 | if (!op->stats.exp) |
|
|
1338 | { |
|
|
1339 | new_draw_info (NDI_UNIQUE, 0, op, "You don't deserve to save yet."); |
|
|
1340 | } |
|
|
1341 | else |
|
|
1342 | { |
|
|
1343 | if (save_player (op, 1)) |
|
|
1344 | new_draw_info (NDI_UNIQUE, 0, op, "You have been saved."); |
|
|
1345 | else |
|
|
1346 | new_draw_info (NDI_UNIQUE, 0, op, "SAVE FAILED!"); |
|
|
1347 | } |
|
|
1348 | return 1; |
|
|
1349 | } |
|
|
1350 | |
|
|
1351 | |
|
|
1352 | int |
|
|
1353 | command_peaceful (object *op, char *params) |
|
|
1354 | { |
|
|
1355 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1356 | "You cannot change your peaceful setting with this command." |
|
|
1357 | " Please speak to the priest in the temple of Gorokh" |
|
|
1358 | " if you want to become hostile or in temple of Valriel" " if you want to become peaceful again."); |
|
|
1359 | |
|
|
1360 | /* |
|
|
1361 | if((op->contr->peaceful=!op->contr->peaceful)) |
|
|
1362 | new_draw_info(NDI_UNIQUE, 0,op,"You will not attack other players."); |
|
|
1363 | else |
|
|
1364 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
|
|
1365 | */ |
|
|
1366 | return 1; |
|
|
1367 | } |
|
|
1368 | |
|
|
1369 | |
|
|
1370 | |
|
|
1371 | int |
|
|
1372 | command_wimpy (object *op, char *params) |
|
|
1373 | { |
|
|
1374 | int i; |
|
|
1375 | char buf[MAX_BUF]; |
|
|
1376 | |
|
|
1377 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
1378 | { |
|
|
1379 | sprintf (buf, "Your current wimpy level is %d.", op->run_away); |
|
|
1380 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1381 | return 1; |
|
|
1382 | } |
|
|
1383 | sprintf (buf, "Your new wimpy level is %d.", i); |
|
|
1384 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1385 | op->run_away = i; |
|
|
1386 | return 1; |
|
|
1387 | } |
|
|
1388 | |
|
|
1389 | |
|
|
1390 | int |
|
|
1391 | command_brace (object *op, char *params) |
|
|
1392 | { |
|
|
1393 | if (!params) |
|
|
1394 | op->contr->braced = !op->contr->braced; |
|
|
1395 | else |
|
|
1396 | op->contr->braced = onoff_value (params); |
|
|
1397 | |
|
|
1398 | if (op->contr->braced) |
|
|
1399 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
|
|
1400 | else |
|
|
1401 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
|
|
1402 | |
|
|
1403 | fix_player (op); |
|
|
1404 | return 0; |
|
|
1405 | } |
|
|
1406 | |
|
|
1407 | int |
|
|
1408 | command_style_map_info (object *op, char *params) |
|
|
1409 | { |
|
|
1410 | extern maptile *styles; |
|
|
1411 | maptile *mp; |
|
|
1412 | int maps_used = 0, mapmem = 0, objects_used = 0, x, y; |
|
|
1413 | object *tmp; |
|
|
1414 | |
|
|
1415 | for (mp = styles; mp != NULL; mp = mp->next) |
|
|
1416 | { |
|
|
1417 | maps_used++; |
|
|
1418 | mapmem += MAP_WIDTH (mp) * MAP_HEIGHT (mp) * (sizeof (object *) + sizeof (MapSpace)) + sizeof (maptile); |
|
|
1419 | for (x = 0; x < MAP_WIDTH (mp); x++) |
|
|
1420 | { |
|
|
1421 | for (y = 0; y < MAP_HEIGHT (mp); y++) |
|
|
1422 | { |
|
|
1423 | for (tmp = get_map_ob (mp, x, y); tmp != NULL; tmp = tmp->above) |
|
|
1424 | objects_used++; |
|
|
1425 | } |
|
|
1426 | } |
|
|
1427 | } |
|
|
1428 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style maps loaded: %d", maps_used); |
|
|
1429 | new_draw_info (NDI_UNIQUE, 0, op, "Memory used, not"); |
|
|
1430 | new_draw_info_format (NDI_UNIQUE, 0, op, "including objects: %d", mapmem); |
|
|
1431 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style objects: %d", objects_used); |
|
|
1432 | new_draw_info_format (NDI_UNIQUE, 0, op, "Mem for objects: %d", objects_used * sizeof (object)); |
|
|
1433 | return 0; |
|
|
1434 | } |
|
|
1435 | |
|
|
1436 | int |
|
|
1437 | command_kill_pets (object *op, char *params) |
351 | command_kill_pets (object *op, char *params) |
1438 | { |
352 | { |
1439 | objectlink *obl, *next; |
353 | objectlink *obl, *next; |
1440 | int counter = 0, removecount = 0; |
354 | int counter = 0, removecount = 0; |
1441 | |
355 | |
1442 | if (params == NULL) |
356 | if (!params) |
1443 | { |
357 | { |
1444 | terminate_all_pets (op); |
358 | terminate_all_pets (op); |
1445 | new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); |
359 | new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); |
1446 | } |
360 | } |
1447 | else |
361 | else |
1448 | { |
362 | { |
1449 | int target = atoi (params); |
363 | int target = atoi (params); |
1450 | |
364 | |
1451 | for (obl = first_friendly_object; obl != NULL; obl = next) |
365 | for (obl = first_friendly_object; obl; obl = next) |
1452 | { |
366 | { |
1453 | object *ob = obl->ob; |
367 | object *ob = obl->ob; |
1454 | |
368 | |
1455 | next = obl->next; |
369 | next = obl->next; |
|
|
370 | |
1456 | if (get_owner (ob) == op) |
371 | if (ob->owner == op) |
1457 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
372 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
1458 | { |
373 | { |
1459 | if (!QUERY_FLAG (ob, FLAG_REMOVED)) |
|
|
1460 | remove_ob (ob); |
|
|
1461 | remove_friendly_object (ob); |
|
|
1462 | free_object (ob); |
374 | ob->destroy (); |
1463 | removecount++; |
375 | removecount++; |
1464 | } |
376 | } |
1465 | } |
377 | } |
|
|
378 | |
1466 | if (removecount != 0) |
379 | if (removecount != 0) |
1467 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
380 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
1468 | else |
381 | else |
1469 | new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
382 | new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
1470 | } |
383 | } |
|
|
384 | |
1471 | return 0; |
385 | return 0; |
1472 | } |
386 | } |