1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game for X-windows |
3 | |
3 | * |
|
|
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. |
11 | * (at your 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 GNU General Public License |
18 | along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | |
21 | * |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
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 | |
|
|
30 | extern weathermap_t **weathermap; |
|
|
31 | |
28 | |
32 | /* Handles misc. input request - things like hash table, malloc, maps, |
29 | /* Handles misc. input request - things like hash table, malloc, maps, |
33 | * who, etc. |
30 | * who, etc. |
34 | */ |
31 | */ |
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 | |
32 | |
63 | /* This command dumps the body information for object *op. |
33 | /* This command dumps the body information for object *op. |
64 | * it doesn't care what the params are. |
34 | * it doesn't care what the params are. |
65 | * This is mostly meant as a debug command. |
35 | * This is mostly meant as a debug command. |
66 | */ |
36 | */ |
… | |
… | |
99 | { |
69 | { |
100 | display_motd (op); |
70 | display_motd (op); |
101 | return 1; |
71 | return 1; |
102 | } |
72 | } |
103 | |
73 | |
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 | /* |
74 | /* |
126 | * Pretty much identical to current map_info, but on a bigger scale |
75 | * Pretty much identical to current map_info, but on a bigger scale |
127 | * This function returns the name of the players current region, and |
76 | * This function returns the name of the players current region, and |
128 | * a description of it. It is there merely for flavour text. |
77 | * a description of it. It is there merely for flavour text. |
129 | */ |
78 | */ |
130 | void |
79 | void |
131 | current_region_info (object *op) |
80 | current_region_info (object *op) |
132 | { |
81 | { |
133 | /* |
82 | if (region *reg = op->region ()) |
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)); |
83 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are %s.\n%s", ®->longname, ®->msg); |
144 | } |
84 | } |
145 | |
85 | |
146 | void |
86 | void |
147 | current_map_info (object *op) |
87 | current_map_info (object *op) |
148 | { |
88 | { |
149 | maptile *m = op->map; |
89 | maptile *m = op->map; |
150 | |
90 | |
151 | if (!m) |
91 | if (!m) |
152 | return; |
92 | return; |
153 | |
93 | |
154 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) in %s", m->name, m->path, get_name_of_region_for_map (m)); |
94 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) %s", &m->name, &m->path, &op->region ()->longname); |
155 | |
95 | |
156 | if (QUERY_FLAG (op, FLAG_WIZ)) |
96 | if (QUERY_FLAG (op, FLAG_WIZ)) |
157 | { |
|
|
158 | new_draw_info_format (NDI_UNIQUE, 0, op, |
97 | new_draw_info_format (NDI_UNIQUE, 0, op, |
159 | "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld", |
98 | "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)); |
99 | m->players, m->difficulty, m->width, m->height, m->enter_x, m->enter_y, m->timeout); |
161 | |
100 | |
162 | } |
|
|
163 | if (m->msg) |
101 | if (m->msg) |
164 | new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
102 | new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
165 | } |
103 | } |
166 | |
104 | |
167 | #ifdef DEBUG_MALLOC_LEVEL |
105 | #ifdef DEBUG_MALLOC_LEVEL |
… | |
… | |
179 | #endif |
117 | #endif |
180 | |
118 | |
181 | int |
119 | int |
182 | command_whereabouts (object *op, char *params) |
120 | command_whereabouts (object *op, char *params) |
183 | { |
121 | { |
184 | |
122 | //TODO: should obviously not waste space in struct region for this. |
185 | region *reg; |
|
|
186 | player *pl; |
|
|
187 | |
|
|
188 | /* |
123 | /* |
189 | * reset the counter on the region, then use it to store the number of |
124 | * reset the counter on the region, then use it to store the number of |
190 | * players there. |
125 | * players there. |
191 | * I don't know how thread-safe this would be, I suspect not very.... |
126 | * I don't know how thread-safe this would be, I suspect not very.... |
192 | */ |
127 | */ |
193 | for (reg = first_region; reg != NULL; reg = reg->next) |
128 | for_all_regions (rgn) |
194 | { |
|
|
195 | reg->counter = 0; |
129 | rgn->counter = 0; |
196 | } |
130 | |
197 | for (pl = first_player; pl != NULL; pl = pl->next) |
131 | for_all_players (pl) |
198 | if (pl->ob->map != NULL) |
132 | if (pl->ob->map) |
199 | get_region_by_map (pl->ob->map)->counter++; |
133 | ++pl->ob->region ()->counter; |
200 | |
134 | |
201 | /* we only want to print out by places with a 'longname' field... */ |
135 | /* we only want to print out by places with a 'longname' field... */ |
202 | for (reg = first_region; reg != NULL; reg = reg->next) |
136 | for_all_regions (rgn) |
203 | { |
137 | { |
204 | if (reg->longname == NULL && reg->counter > 0) |
138 | if (!rgn->longname && rgn->counter > 0) |
205 | { |
139 | { |
206 | if (reg->parent != NULL) |
140 | if (rgn->parent) |
207 | { |
141 | { |
208 | reg->parent->counter += reg->counter; |
142 | rgn->parent->counter += rgn->counter; |
209 | reg->counter = 0; |
143 | rgn->counter = 0; |
210 | } |
144 | } |
211 | else /*uh oh, we shouldn't be here. */ |
145 | else /*uh oh, we shouldn't be here. */ |
212 | LOG (llevError, "command_whereabouts() Region %s with no longname has no parent", reg->name); |
146 | LOG (llevError, "command_whereabouts() Region %s with no longname has no parent", &rgn->name); |
213 | } |
147 | } |
214 | } |
148 | } |
|
|
149 | |
215 | new_draw_info_format (NDI_UNIQUE, 0, op, "In the world currently there are:"); |
150 | new_draw_info_format (NDI_UNIQUE, 0, op, "In the world currently there are:"); |
216 | for (reg = first_region; reg != NULL; reg = reg->next) |
151 | |
|
|
152 | for_all_regions (rgn) |
217 | if (reg->counter > 0) |
153 | if (rgn->counter) |
218 | new_draw_info_format (NDI_UNIQUE, 0, op, "%u players in %s", reg->counter, get_region_longname (reg)); |
154 | new_draw_info_format (NDI_UNIQUE, 0, op, "%u players %s", rgn->counter, &rgn->longname); |
|
|
155 | |
219 | return 1; |
156 | return 1; |
220 | } |
157 | } |
221 | |
158 | |
222 | typedef struct |
159 | typedef struct |
223 | { |
160 | { |
224 | char namebuf[MAX_BUF]; |
161 | char namebuf[MAX_BUF]; |
225 | int login_order; |
162 | int login_order; |
226 | } chars_names; |
163 | } chars_names; |
227 | |
164 | |
228 | /*local functon for qsort comparison*/ |
|
|
229 | static int |
|
|
230 | name_cmp (const chars_names * c1, const chars_names * c2) |
|
|
231 | { |
|
|
232 | return strcasecmp (c1->namebuf, c2->namebuf); |
|
|
233 | } |
|
|
234 | |
|
|
235 | int |
|
|
236 | command_afk (object *op, char *params) |
|
|
237 | { |
|
|
238 | if QUERY_FLAG |
|
|
239 | (op, FLAG_AFK) |
|
|
240 | { |
|
|
241 | CLEAR_FLAG (op, FLAG_AFK); |
|
|
242 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer AFK"); |
|
|
243 | } |
|
|
244 | else |
|
|
245 | { |
|
|
246 | SET_FLAG (op, FLAG_AFK); |
|
|
247 | new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK"); |
|
|
248 | } |
|
|
249 | return 1; |
|
|
250 | } |
|
|
251 | |
|
|
252 | int |
165 | int |
253 | command_mapinfo (object *op, char *params) |
166 | command_mapinfo (object *op, char *params) |
254 | { |
167 | { |
255 | current_map_info (op); |
168 | current_map_info (op); |
256 | return 1; |
169 | return 1; |
… | |
… | |
262 | current_region_info (op); |
175 | current_region_info (op); |
263 | return 1; |
176 | return 1; |
264 | } |
177 | } |
265 | |
178 | |
266 | int |
179 | int |
267 | command_maps (object *op, char *params) |
|
|
268 | { |
|
|
269 | map_info (op, params); |
|
|
270 | return 1; |
|
|
271 | } |
|
|
272 | |
|
|
273 | int |
|
|
274 | command_time (object *op, char *params) |
180 | command_time (object *op, char *params) |
275 | { |
181 | { |
276 | print_tod (op); |
182 | print_tod (op); |
277 | return 1; |
183 | return 1; |
278 | } |
184 | } |
279 | |
185 | |
280 | int |
186 | int |
281 | command_weather (object *op, char *params) |
187 | command_weather (object *op, char *params) |
282 | { |
188 | { |
|
|
189 | #if 0 |
283 | int wx, wy, temp, sky; |
190 | int wx, wy, temp, sky; |
284 | char buf[MAX_BUF]; |
191 | char buf[MAX_BUF]; |
285 | |
192 | |
286 | if (settings.dynamiclevel < 1) |
193 | if (settings.dynamiclevel < 1) |
287 | return 1; |
194 | return 1; |
… | |
… | |
403 | break; |
310 | break; |
404 | case SKY_BLIZZARD: |
311 | case SKY_BLIZZARD: |
405 | new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); |
312 | new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); |
406 | break; |
313 | break; |
407 | } |
314 | } |
408 | return 1; |
315 | #endif |
409 | } |
|
|
410 | |
|
|
411 | int |
|
|
412 | command_archs (object *op, char *params) |
|
|
413 | { |
|
|
414 | arch_info (op); |
|
|
415 | return 1; |
316 | return 1; |
416 | } |
317 | } |
417 | |
318 | |
418 | int |
319 | int |
419 | command_hiscore (object *op, char *params) |
320 | command_hiscore (object *op, char *params) |
… | |
… | |
432 | { |
333 | { |
433 | sprintf (buf, "Global debug level is %d.", settings.debug); |
334 | sprintf (buf, "Global debug level is %d.", settings.debug); |
434 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
335 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
435 | return 1; |
336 | return 1; |
436 | } |
337 | } |
437 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
|
|
438 | { |
|
|
439 | new_draw_info (NDI_UNIQUE, 0, op, "Privileged command."); |
|
|
440 | return 1; |
|
|
441 | } |
|
|
442 | settings.debug = (enum LogLevel) FABS (i); |
338 | settings.debug = (enum LogLevel) FABS (i); |
443 | sprintf (buf, "Set debug level to %d.", i); |
339 | sprintf (buf, "Set debug level to %d.", i); |
444 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
340 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
445 | return 1; |
341 | return 1; |
446 | } |
342 | } |
… | |
… | |
453 | int |
349 | int |
454 | command_dumpbelow (object *op, char *params) |
350 | command_dumpbelow (object *op, char *params) |
455 | { |
351 | { |
456 | if (op && op->below) |
352 | if (op && op->below) |
457 | { |
353 | { |
458 | dump_object (op->below); |
354 | char *dump = dump_object (op->below); |
459 | new_draw_info (NDI_UNIQUE, 0, op, errmsg); |
355 | new_draw_info (NDI_UNIQUE, 0, op, dump); |
|
|
356 | free (dump); |
460 | /* Let's push that item on the dm's stack */ |
357 | /* Let's push that item on the dm's stack */ |
461 | dm_stack_push (op->contr, op->below->count); |
358 | dm_stack_push (op->contr, op->below->count); |
462 | } |
359 | } |
463 | return 0; |
360 | return 0; |
464 | } |
361 | } |
465 | |
362 | |
466 | int |
363 | int |
467 | command_wizpass (object *op, char *params) |
|
|
468 | { |
|
|
469 | int i; |
|
|
470 | |
|
|
471 | if (!op) |
|
|
472 | return 0; |
|
|
473 | |
|
|
474 | if (!params) |
|
|
475 | i = (QUERY_FLAG (op, FLAG_WIZPASS)) ? 0 : 1; |
|
|
476 | else |
|
|
477 | i = onoff_value (params); |
|
|
478 | |
|
|
479 | if (i) |
|
|
480 | { |
|
|
481 | new_draw_info (NDI_UNIQUE, 0, op, "You will now walk through walls.\n"); |
|
|
482 | SET_FLAG (op, FLAG_WIZPASS); |
|
|
483 | } |
|
|
484 | else |
|
|
485 | { |
|
|
486 | new_draw_info (NDI_UNIQUE, 0, op, "You will now be stopped by walls.\n"); |
|
|
487 | CLEAR_FLAG (op, FLAG_WIZPASS); |
|
|
488 | } |
|
|
489 | return 0; |
|
|
490 | } |
|
|
491 | |
|
|
492 | int |
|
|
493 | command_wizcast (object *op, char *params) |
|
|
494 | { |
|
|
495 | int i; |
|
|
496 | |
|
|
497 | if (!op) |
|
|
498 | return 0; |
|
|
499 | |
|
|
500 | if (!params) |
|
|
501 | i = (QUERY_FLAG (op, FLAG_WIZCAST)) ? 0 : 1; |
|
|
502 | else |
|
|
503 | i = onoff_value (params); |
|
|
504 | |
|
|
505 | if (i) |
|
|
506 | { |
|
|
507 | new_draw_info (NDI_UNIQUE, 0, op, "You can now cast spells anywhere."); |
|
|
508 | SET_FLAG (op, FLAG_WIZCAST); |
|
|
509 | } |
|
|
510 | else |
|
|
511 | { |
|
|
512 | new_draw_info (NDI_UNIQUE, 0, op, "You now cannot cast spells in no-magic areas."); |
|
|
513 | CLEAR_FLAG (op, FLAG_WIZCAST); |
|
|
514 | } |
|
|
515 | return 0; |
|
|
516 | } |
|
|
517 | |
|
|
518 | int |
|
|
519 | command_dumpallobjects (object *op, char *params) |
|
|
520 | { |
|
|
521 | dump_all_objects (); |
|
|
522 | return 0; |
|
|
523 | } |
|
|
524 | |
|
|
525 | int |
|
|
526 | command_dumpfriendlyobjects (object *op, char *params) |
364 | command_dumpfriendlyobjects (object *op, char *params) |
527 | { |
365 | { |
528 | dump_friendly_objects (); |
366 | dump_friendly_objects (); |
529 | return 0; |
|
|
530 | } |
|
|
531 | |
|
|
532 | int |
|
|
533 | command_dumpallarchetypes (object *op, char *params) |
|
|
534 | { |
|
|
535 | dump_all_archetypes (); |
|
|
536 | return 0; |
|
|
537 | } |
|
|
538 | |
|
|
539 | int |
|
|
540 | command_dumpmap (object *op, char *params) |
|
|
541 | { |
|
|
542 | if (op) |
|
|
543 | dump_map (op->map); |
|
|
544 | return 0; |
|
|
545 | } |
|
|
546 | |
|
|
547 | int |
|
|
548 | command_dumpallmaps (object *op, char *params) |
|
|
549 | { |
|
|
550 | dump_all_maps (); |
|
|
551 | return 0; |
367 | return 0; |
552 | } |
368 | } |
553 | |
369 | |
554 | int |
370 | int |
555 | command_printlos (object *op, char *params) |
371 | command_printlos (object *op, char *params) |
… | |
… | |
564 | command_version (object *op, char *params) |
380 | command_version (object *op, char *params) |
565 | { |
381 | { |
566 | version (op); |
382 | version (op); |
567 | return 0; |
383 | return 0; |
568 | } |
384 | } |
569 | |
|
|
570 | |
385 | |
571 | #ifndef BUG_LOG |
386 | #ifndef BUG_LOG |
572 | # define BUG_LOG "bug_log" |
387 | # define BUG_LOG "bug_log" |
573 | #endif |
388 | #endif |
574 | void |
389 | void |
… | |
… | |
629 | new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_count."); |
444 | new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_count."); |
630 | |
445 | |
631 | return 1; |
446 | return 1; |
632 | } |
447 | } |
633 | |
448 | |
634 | int |
|
|
635 | command_listen (object *op, char *params) |
|
|
636 | { |
|
|
637 | int i; |
|
|
638 | |
|
|
639 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
640 | { |
|
|
641 | new_draw_info_format (NDI_UNIQUE, 0, op, "Set listen to what (presently %d)?", op->contr->listening); |
|
|
642 | return 1; |
|
|
643 | } |
|
|
644 | op->contr->listening = (char) i; |
|
|
645 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your verbose level is now %d.", i); |
|
|
646 | return 1; |
|
|
647 | } |
|
|
648 | |
|
|
649 | /* Prints out some useful information for the character. Everything we print |
449 | /* Prints out some useful information for the character. Everything we print |
650 | * out can be determined by the docs, so we aren't revealing anything extra - |
450 | * out can be determined by the docs, so we aren't revealing anything extra - |
651 | * rather, we are making it convenient to find the values. params have |
451 | * rather, we are making it convenient to find the values. params have |
652 | * no meaning here. |
452 | * no meaning here. |
653 | */ |
453 | */ |
654 | int |
454 | int |
655 | command_statistics (object *pl, char *params) |
455 | command_statistics (object *pl, char *params) |
656 | { |
456 | { |
657 | if (!pl->contr) |
457 | if (!pl->contr) |
658 | return 1; |
458 | return 1; |
659 | #ifndef WIN32 |
|
|
660 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %lld", pl->stats.exp); |
|
|
661 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %lld", level_exp (pl->level + 1, pl->expmul)); |
|
|
662 | #else |
|
|
663 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %I64d", pl->stats.exp); |
459 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %" PRId64, pl->stats.exp); |
664 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %I64d", level_exp (pl->level + 1, pl->expmul)); |
460 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %" PRId64, level_exp (pl->level + 1, pl->expmul)); |
665 | #endif |
|
|
666 | new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max"); |
461 | new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max"); |
667 | |
462 | |
668 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Str %2d/ %3d/%3d", |
463 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Str %2d/ %3d/%3d", |
669 | pl->contr->orig_stats.Str, pl->stats.Str, 20 + pl->arch->clone.stats.Str); |
464 | pl->contr->orig_stats.Str, pl->stats.Str, 20 + pl->arch->clone.stats.Str); |
670 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Dex %2d/ %3d/%3d", |
465 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Dex %2d/ %3d/%3d", |
… | |
… | |
687 | |
482 | |
688 | int |
483 | int |
689 | command_fix_me (object *op, char *params) |
484 | command_fix_me (object *op, char *params) |
690 | { |
485 | { |
691 | sum_weight (op); |
486 | sum_weight (op); |
692 | fix_player (op); |
487 | op->update_stats (); |
693 | return 1; |
|
|
694 | } |
|
|
695 | |
|
|
696 | int |
|
|
697 | command_players (object *op, char *paramss) |
|
|
698 | { |
|
|
699 | char buf[MAX_BUF]; |
|
|
700 | char *t; |
|
|
701 | DIR *Dir; |
|
|
702 | |
|
|
703 | sprintf (buf, "%s/%s/", settings.localdir, settings.playerdir); |
|
|
704 | t = buf + strlen (buf); |
|
|
705 | if ((Dir = opendir (buf)) != NULL) |
|
|
706 | { |
|
|
707 | const struct dirent *Entry; |
|
|
708 | |
|
|
709 | while ((Entry = readdir (Dir)) != NULL) |
|
|
710 | { |
|
|
711 | /* skip '.' , '..' */ |
|
|
712 | if (!((Entry->d_name[0] == '.' && Entry->d_name[1] == '\0') || |
|
|
713 | (Entry->d_name[0] == '.' && Entry->d_name[1] == '.' && Entry->d_name[2] == '\0'))) |
|
|
714 | { |
|
|
715 | struct stat Stat; |
|
|
716 | |
|
|
717 | strcpy (t, Entry->d_name); |
|
|
718 | if (stat (buf, &Stat) == 0) |
|
|
719 | { |
|
|
720 | /* This was not posix compatible |
|
|
721 | * if ((Stat.st_mode & S_IFMT)==S_IFDIR) { |
|
|
722 | */ |
|
|
723 | if (S_ISDIR (Stat.st_mode)) |
|
|
724 | { |
|
|
725 | char buf2[MAX_BUF]; |
|
|
726 | struct tm *tm = localtime (&Stat.st_mtime); |
|
|
727 | |
|
|
728 | sprintf (buf2, "%s\t%04d %02d %02d %02d %02d %02d", |
|
|
729 | Entry->d_name, 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); |
|
|
730 | new_draw_info (NDI_UNIQUE, 0, op, buf2); |
|
|
731 | } |
|
|
732 | } |
|
|
733 | } |
|
|
734 | } |
|
|
735 | } |
|
|
736 | closedir (Dir); |
|
|
737 | return 0; |
488 | return 1; |
738 | } |
489 | } |
739 | |
|
|
740 | |
|
|
741 | |
490 | |
742 | int |
491 | int |
743 | command_logs (object *op, char *params) |
492 | command_logs (object *op, char *params) |
744 | { |
493 | { |
745 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
494 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
… | |
… | |
768 | else |
517 | else |
769 | { |
518 | { |
770 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params); |
519 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params); |
771 | return 0; |
520 | return 0; |
772 | } |
521 | } |
|
|
522 | |
773 | new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s", |
523 | new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s", |
774 | (unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]); |
524 | (unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]); |
775 | return 1; |
525 | return 1; |
776 | } |
526 | } |
777 | |
527 | |
… | |
… | |
799 | found++; |
549 | found++; |
800 | op->contr->bowtype = (bowtype_t) i; |
550 | op->contr->bowtype = (bowtype_t) i; |
801 | break; |
551 | break; |
802 | } |
552 | } |
803 | } |
553 | } |
|
|
554 | |
804 | if (!found) |
555 | if (!found) |
805 | { |
556 | { |
806 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
557 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
807 | for (i = 0; i <= bow_bestarrow; i++) |
558 | for (i = 0; i <= bow_bestarrow; i++) |
808 | { |
559 | { |
… | |
… | |
814 | strcat (buf, "."); |
565 | strcat (buf, "."); |
815 | } |
566 | } |
816 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
567 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
817 | return 0; |
568 | return 0; |
818 | } |
569 | } |
|
|
570 | |
819 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
571 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
820 | return 1; |
572 | return 1; |
821 | } |
573 | } |
822 | |
574 | |
823 | int |
575 | int |
… | |
… | |
862 | for (obl = first_friendly_object; obl != NULL; obl = next) |
614 | for (obl = first_friendly_object; obl != NULL; obl = next) |
863 | { |
615 | { |
864 | object *ob = obl->ob; |
616 | object *ob = obl->ob; |
865 | |
617 | |
866 | next = obl->next; |
618 | next = obl->next; |
867 | if (get_owner (ob) == op) |
619 | if (ob->owner == op) |
868 | { |
620 | { |
869 | if (target == 0) |
621 | if (target == 0) |
870 | { |
622 | { |
871 | if (counter == 0) |
623 | if (counter == 0) |
872 | new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
624 | new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
… | |
… | |
895 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
647 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
896 | return 0; |
648 | return 0; |
897 | } |
649 | } |
898 | |
650 | |
899 | int |
651 | int |
900 | command_usekeys (object *op, char *params) |
|
|
901 | { |
|
|
902 | usekeytype oldtype = op->contr->usekeys; |
|
|
903 | static const char *const types[] = { "inventory", "keyrings", "containers" }; |
|
|
904 | |
|
|
905 | if (!params) |
|
|
906 | { |
|
|
907 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys is set to %s", types[op->contr->usekeys]); |
|
|
908 | return 1; |
|
|
909 | } |
|
|
910 | |
|
|
911 | if (!strcmp (params, "inventory")) |
|
|
912 | op->contr->usekeys = key_inventory; |
|
|
913 | else if (!strcmp (params, "keyrings")) |
|
|
914 | op->contr->usekeys = keyrings; |
|
|
915 | else if (!strcmp (params, "containers")) |
|
|
916 | op->contr->usekeys = containers; |
|
|
917 | else |
|
|
918 | { |
|
|
919 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys: Unknown options %s, valid options are inventory, keyrings, containers", params); |
|
|
920 | return 0; |
|
|
921 | } |
|
|
922 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys %s set to %s", (oldtype == op->contr->usekeys ? "" : "now"), types[op->contr->usekeys]); |
|
|
923 | return 1; |
|
|
924 | } |
|
|
925 | |
|
|
926 | int |
|
|
927 | command_resistances (object *op, char *params) |
652 | command_resistances (object *op, char *params) |
928 | { |
653 | { |
929 | int i; |
654 | int i; |
930 | |
655 | |
931 | if (!op) |
656 | if (!op) |
… | |
… | |
979 | char filename[MAX_BUF], line[80]; |
704 | char filename[MAX_BUF], line[80]; |
980 | int namelen, linelen = 0; |
705 | int namelen, linelen = 0; |
981 | |
706 | |
982 | switch (what) |
707 | switch (what) |
983 | { |
708 | { |
984 | case 1: |
709 | case 1: |
985 | sprintf (filename, "%s/wizhelp", settings.datadir); |
710 | sprintf (filename, "%s/wizhelp", settings.datadir); |
986 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
711 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
987 | break; |
712 | break; |
988 | case 3: |
713 | case 3: |
989 | sprintf (filename, "%s/mischelp", settings.datadir); |
714 | sprintf (filename, "%s/mischelp", settings.datadir); |
990 | new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
715 | new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
991 | break; |
716 | break; |
992 | default: |
717 | default: |
993 | sprintf (filename, "%s/help", settings.datadir); |
718 | sprintf (filename, "%s/help", settings.datadir); |
994 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
719 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
995 | break; |
720 | break; |
996 | } |
721 | } |
|
|
722 | |
997 | if (!(dirp = opendir (filename))) |
723 | if (!(dirp = opendir (filename))) |
998 | return; |
724 | return; |
999 | |
725 | |
1000 | line[0] = '\0'; |
726 | line[0] = '\0'; |
1001 | for (de = readdir (dirp); de; de = readdir (dirp)) |
727 | while ((de = readdir (dirp))) |
1002 | { |
728 | { |
1003 | namelen = NAMLEN (de); |
729 | namelen = strlen (de->d_name); |
1004 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
730 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
1005 | continue; |
731 | continue; |
1006 | linelen += namelen + 1; |
732 | linelen += namelen + 1; |
1007 | if (linelen > 42) |
733 | if (linelen > 42) |
1008 | { |
734 | { |
… | |
… | |
1213 | return 0; |
939 | return 0; |
1214 | } |
940 | } |
1215 | } |
941 | } |
1216 | |
942 | |
1217 | int |
943 | int |
1218 | command_quit (object *op, char *params) |
|
|
1219 | { |
|
|
1220 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1221 | "Quitting will delete your character PERMANENTLY. If you are sure you want to do this, then use the quit_character command instead of quit."); |
|
|
1222 | return 1; |
|
|
1223 | } |
|
|
1224 | |
|
|
1225 | int |
|
|
1226 | command_real_quit (object *op, char *params) |
|
|
1227 | { |
|
|
1228 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Quitting will delete your character.\nAre you sure you want to quit (y/n):"); |
|
|
1229 | |
|
|
1230 | op->contr->state = ST_CONFIRM_QUIT; |
|
|
1231 | return 1; |
|
|
1232 | } |
|
|
1233 | |
|
|
1234 | /* |
|
|
1235 | * don't allow people to exit explore mode. It otherwise becomes |
|
|
1236 | * really easy to abuse this. |
|
|
1237 | */ |
|
|
1238 | int |
|
|
1239 | command_explore (object *op, char *params) |
|
|
1240 | { |
|
|
1241 | if (settings.explore_mode == FALSE) |
|
|
1242 | return 1; |
|
|
1243 | /* |
|
|
1244 | * I guess this is the best way to see if we are solo or not. Actually, |
|
|
1245 | * are there any cases when first_player->next==NULL and we are not solo? |
|
|
1246 | */ |
|
|
1247 | if ((first_player != op->contr) || (first_player->next != NULL)) |
|
|
1248 | { |
|
|
1249 | new_draw_info (NDI_UNIQUE, 0, op, "You can not enter explore mode if you are in a party"); |
|
|
1250 | } |
|
|
1251 | else if (op->contr->explore) |
|
|
1252 | new_draw_info (NDI_UNIQUE, 0, op, "There is no return from explore mode"); |
|
|
1253 | else |
|
|
1254 | { |
|
|
1255 | op->contr->explore = 1; |
|
|
1256 | new_draw_info (NDI_UNIQUE, 0, op, "You are now in explore mode"); |
|
|
1257 | } |
|
|
1258 | return 1; |
|
|
1259 | } |
|
|
1260 | |
|
|
1261 | int |
|
|
1262 | command_sound (object *op, char *params) |
|
|
1263 | { |
|
|
1264 | if (op->contr->socket.sound) |
|
|
1265 | { |
|
|
1266 | op->contr->socket.sound = 0; |
|
|
1267 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
|
|
1268 | } |
|
|
1269 | else |
|
|
1270 | { |
|
|
1271 | op->contr->socket.sound = 1; |
|
|
1272 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
|
|
1273 | } |
|
|
1274 | return 1; |
|
|
1275 | } |
|
|
1276 | |
|
|
1277 | /* Perhaps these should be in player.c, but that file is |
|
|
1278 | * already a bit big. |
|
|
1279 | */ |
|
|
1280 | |
|
|
1281 | void |
|
|
1282 | receive_player_name (object *op, char k) |
|
|
1283 | { |
|
|
1284 | |
|
|
1285 | if (!check_name (op->contr, op->contr->write_buf + 1)) |
|
|
1286 | { |
|
|
1287 | get_name (op); |
|
|
1288 | return; |
|
|
1289 | } |
|
|
1290 | op->name = op->contr->write_buf + 1; |
|
|
1291 | op->name_pl = op->contr->write_buf + 1; |
|
|
1292 | new_draw_info (NDI_UNIQUE, 0, op, op->contr->write_buf); |
|
|
1293 | op->contr->name_changed = 1; |
|
|
1294 | get_password (op); |
|
|
1295 | } |
|
|
1296 | |
|
|
1297 | void |
|
|
1298 | receive_player_password (object *op, char k) |
|
|
1299 | { |
|
|
1300 | |
|
|
1301 | unsigned int pwd_len = strlen (op->contr->write_buf); |
|
|
1302 | |
|
|
1303 | if (pwd_len <= 1 || pwd_len > 17) |
|
|
1304 | { |
|
|
1305 | get_name (op); |
|
|
1306 | return; |
|
|
1307 | } |
|
|
1308 | new_draw_info (NDI_UNIQUE, 0, op, " "); /* To hide the password better */ |
|
|
1309 | |
|
|
1310 | if (checkbanned (op->name, op->contr->socket.host)) |
|
|
1311 | { |
|
|
1312 | LOG (llevInfo, "Banned player tried to add: [%s@%s]\n", &op->name, op->contr->socket.host); |
|
|
1313 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, op, "You are not allowed to play."); |
|
|
1314 | get_name (op); |
|
|
1315 | return; |
|
|
1316 | } |
|
|
1317 | |
|
|
1318 | if (op->contr->state == ST_CONFIRM_PASSWORD) |
|
|
1319 | { |
|
|
1320 | if (!check_password (op->contr->write_buf + 1, op->contr->password)) |
|
|
1321 | { |
|
|
1322 | new_draw_info (NDI_UNIQUE, 0, op, "The passwords did not match."); |
|
|
1323 | get_name (op); |
|
|
1324 | return; |
|
|
1325 | } |
|
|
1326 | clear_win_info (op); |
|
|
1327 | display_motd (op); |
|
|
1328 | new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
1329 | new_draw_info (NDI_UNIQUE, 0, op, "Welcome, Brave New Warrior!"); |
|
|
1330 | new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
1331 | Roll_Again (op); |
|
|
1332 | op->contr->state = ST_ROLL_STAT; |
|
|
1333 | return; |
|
|
1334 | } |
|
|
1335 | strcpy (op->contr->password, crypt_string (op->contr->write_buf + 1, NULL)); |
|
|
1336 | op->contr->state = ST_ROLL_STAT; |
|
|
1337 | check_login (op); |
|
|
1338 | return; |
|
|
1339 | } |
|
|
1340 | |
|
|
1341 | |
|
|
1342 | int |
|
|
1343 | explore_mode (void) |
|
|
1344 | { |
|
|
1345 | player *pl; |
|
|
1346 | |
|
|
1347 | if (settings.explore_mode == TRUE) |
|
|
1348 | { |
|
|
1349 | for (pl = first_player; pl != (player *) NULL; pl = pl->next) |
|
|
1350 | if (pl->explore) |
|
|
1351 | return 1; |
|
|
1352 | } |
|
|
1353 | return 0; |
|
|
1354 | } |
|
|
1355 | |
|
|
1356 | |
|
|
1357 | int |
|
|
1358 | command_title (object *op, char *params) |
944 | command_title (object *op, char *params) |
1359 | { |
945 | { |
1360 | char buf[MAX_BUF]; |
946 | char buf[MAX_BUF]; |
1361 | |
947 | |
1362 | if (settings.set_title == FALSE) |
948 | if (settings.set_title == FALSE) |
… | |
… | |
1399 | strcpy (op->contr->own_title, params); |
985 | strcpy (op->contr->own_title, params); |
1400 | return 1; |
986 | return 1; |
1401 | } |
987 | } |
1402 | |
988 | |
1403 | int |
989 | int |
1404 | command_save (object *op, char *params) |
|
|
1405 | { |
|
|
1406 | // if (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) { |
|
|
1407 | // new_draw_info(NDI_UNIQUE, 0, op, "You can not save on unholy ground"); |
|
|
1408 | // } else |
|
|
1409 | if (!op->stats.exp) |
|
|
1410 | { |
|
|
1411 | new_draw_info (NDI_UNIQUE, 0, op, "You don't deserve to save yet."); |
|
|
1412 | } |
|
|
1413 | else |
|
|
1414 | { |
|
|
1415 | if (save_player (op, 1)) |
|
|
1416 | new_draw_info (NDI_UNIQUE, 0, op, "You have been saved."); |
|
|
1417 | else |
|
|
1418 | new_draw_info (NDI_UNIQUE, 0, op, "SAVE FAILED!"); |
|
|
1419 | } |
|
|
1420 | return 1; |
|
|
1421 | } |
|
|
1422 | |
|
|
1423 | |
|
|
1424 | int |
|
|
1425 | command_peaceful (object *op, char *params) |
|
|
1426 | { |
|
|
1427 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1428 | "You cannot change your peaceful setting with this command." |
|
|
1429 | " Please speak to the priest in the temple of Gorokh" |
|
|
1430 | " if you want to become hostile or in temple of Valriel" " if you want to become peaceful again."); |
|
|
1431 | |
|
|
1432 | /* |
|
|
1433 | if((op->contr->peaceful=!op->contr->peaceful)) |
|
|
1434 | new_draw_info(NDI_UNIQUE, 0,op,"You will not attack other players."); |
|
|
1435 | else |
|
|
1436 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
|
|
1437 | */ |
|
|
1438 | return 1; |
|
|
1439 | } |
|
|
1440 | |
|
|
1441 | |
|
|
1442 | |
|
|
1443 | int |
|
|
1444 | command_wimpy (object *op, char *params) |
|
|
1445 | { |
|
|
1446 | int i; |
|
|
1447 | char buf[MAX_BUF]; |
|
|
1448 | |
|
|
1449 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
1450 | { |
|
|
1451 | sprintf (buf, "Your current wimpy level is %d.", op->run_away); |
|
|
1452 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1453 | return 1; |
|
|
1454 | } |
|
|
1455 | sprintf (buf, "Your new wimpy level is %d.", i); |
|
|
1456 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1457 | op->run_away = i; |
|
|
1458 | return 1; |
|
|
1459 | } |
|
|
1460 | |
|
|
1461 | |
|
|
1462 | int |
|
|
1463 | command_brace (object *op, char *params) |
|
|
1464 | { |
|
|
1465 | if (!params) |
|
|
1466 | op->contr->braced = !op->contr->braced; |
|
|
1467 | else |
|
|
1468 | op->contr->braced = onoff_value (params); |
|
|
1469 | |
|
|
1470 | if (op->contr->braced) |
|
|
1471 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
|
|
1472 | else |
|
|
1473 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
|
|
1474 | |
|
|
1475 | fix_player (op); |
|
|
1476 | return 0; |
|
|
1477 | } |
|
|
1478 | |
|
|
1479 | int |
|
|
1480 | command_style_map_info (object *op, char *params) |
|
|
1481 | { |
|
|
1482 | extern maptile *styles; |
|
|
1483 | maptile *mp; |
|
|
1484 | int maps_used = 0, mapmem = 0, objects_used = 0, x, y; |
|
|
1485 | object *tmp; |
|
|
1486 | |
|
|
1487 | for (mp = styles; mp != NULL; mp = mp->next) |
|
|
1488 | { |
|
|
1489 | maps_used++; |
|
|
1490 | mapmem += MAP_WIDTH (mp) * MAP_HEIGHT (mp) * (sizeof (object *) + sizeof (MapSpace)) + sizeof (maptile); |
|
|
1491 | for (x = 0; x < MAP_WIDTH (mp); x++) |
|
|
1492 | { |
|
|
1493 | for (y = 0; y < MAP_HEIGHT (mp); y++) |
|
|
1494 | { |
|
|
1495 | for (tmp = get_map_ob (mp, x, y); tmp != NULL; tmp = tmp->above) |
|
|
1496 | objects_used++; |
|
|
1497 | } |
|
|
1498 | } |
|
|
1499 | } |
|
|
1500 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style maps loaded: %d", maps_used); |
|
|
1501 | new_draw_info (NDI_UNIQUE, 0, op, "Memory used, not"); |
|
|
1502 | new_draw_info_format (NDI_UNIQUE, 0, op, "including objects: %d", mapmem); |
|
|
1503 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style objects: %d", objects_used); |
|
|
1504 | new_draw_info_format (NDI_UNIQUE, 0, op, "Mem for objects: %d", objects_used * sizeof (object)); |
|
|
1505 | return 0; |
|
|
1506 | } |
|
|
1507 | |
|
|
1508 | int |
|
|
1509 | command_kill_pets (object *op, char *params) |
990 | command_kill_pets (object *op, char *params) |
1510 | { |
991 | { |
1511 | objectlink *obl, *next; |
992 | objectlink *obl, *next; |
1512 | int counter = 0, removecount = 0; |
993 | int counter = 0, removecount = 0; |
1513 | |
994 | |
… | |
… | |
1523 | for (obl = first_friendly_object; obl != NULL; obl = next) |
1004 | for (obl = first_friendly_object; obl != NULL; obl = next) |
1524 | { |
1005 | { |
1525 | object *ob = obl->ob; |
1006 | object *ob = obl->ob; |
1526 | |
1007 | |
1527 | next = obl->next; |
1008 | next = obl->next; |
1528 | if (get_owner (ob) == op) |
1009 | if (ob->owner == op) |
1529 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
1010 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
1530 | { |
1011 | { |
1531 | if (!QUERY_FLAG (ob, FLAG_REMOVED)) |
|
|
1532 | remove_ob (ob); |
|
|
1533 | remove_friendly_object (ob); |
|
|
1534 | free_object (ob); |
1012 | ob->destroy (); |
1535 | removecount++; |
1013 | removecount++; |
1536 | } |
1014 | } |
1537 | } |
1015 | } |
1538 | if (removecount != 0) |
1016 | if (removecount != 0) |
1539 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
1017 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |