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) |
… | |
… | |
430 | |
331 | |
431 | if (params == NULL || !sscanf (params, "%d", &i)) |
332 | if (params == NULL || !sscanf (params, "%d", &i)) |
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; |
|
|
436 | } |
|
|
437 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
|
|
438 | { |
|
|
439 | new_draw_info (NDI_UNIQUE, 0, op, "Privileged command."); |
|
|
440 | return 1; |
336 | return 1; |
441 | } |
337 | } |
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); |
… | |
… | |
470 | dump_friendly_objects (); |
366 | dump_friendly_objects (); |
471 | return 0; |
367 | return 0; |
472 | } |
368 | } |
473 | |
369 | |
474 | int |
370 | int |
475 | command_dumpmap (object *op, char *params) |
|
|
476 | { |
|
|
477 | if (op) |
|
|
478 | dump_map (op->map); |
|
|
479 | return 0; |
|
|
480 | } |
|
|
481 | |
|
|
482 | int |
|
|
483 | command_dumpallmaps (object *op, char *params) |
|
|
484 | { |
|
|
485 | dump_all_maps (); |
|
|
486 | return 0; |
|
|
487 | } |
|
|
488 | |
|
|
489 | int |
|
|
490 | command_printlos (object *op, char *params) |
371 | command_printlos (object *op, char *params) |
491 | { |
372 | { |
492 | if (op) |
373 | if (op) |
493 | print_los (op); |
374 | print_los (op); |
494 | return 0; |
375 | return 0; |
… | |
… | |
499 | command_version (object *op, char *params) |
380 | command_version (object *op, char *params) |
500 | { |
381 | { |
501 | version (op); |
382 | version (op); |
502 | return 0; |
383 | return 0; |
503 | } |
384 | } |
504 | |
|
|
505 | |
385 | |
506 | #ifndef BUG_LOG |
386 | #ifndef BUG_LOG |
507 | # define BUG_LOG "bug_log" |
387 | # define BUG_LOG "bug_log" |
508 | #endif |
388 | #endif |
509 | void |
389 | void |
… | |
… | |
564 | 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."); |
565 | |
445 | |
566 | return 1; |
446 | return 1; |
567 | } |
447 | } |
568 | |
448 | |
569 | int |
|
|
570 | command_listen (object *op, char *params) |
|
|
571 | { |
|
|
572 | int i; |
|
|
573 | |
|
|
574 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
575 | { |
|
|
576 | new_draw_info_format (NDI_UNIQUE, 0, op, "Set listen to what (presently %d)?", op->contr->listening); |
|
|
577 | return 1; |
|
|
578 | } |
|
|
579 | op->contr->listening = (char) i; |
|
|
580 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your verbose level is now %d.", i); |
|
|
581 | return 1; |
|
|
582 | } |
|
|
583 | |
|
|
584 | /* Prints out some useful information for the character. Everything we print |
449 | /* Prints out some useful information for the character. Everything we print |
585 | * 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 - |
586 | * 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 |
587 | * no meaning here. |
452 | * no meaning here. |
588 | */ |
453 | */ |
589 | int |
454 | int |
590 | command_statistics (object *pl, char *params) |
455 | command_statistics (object *pl, char *params) |
591 | { |
456 | { |
592 | if (!pl->contr) |
457 | if (!pl->contr) |
593 | return 1; |
458 | return 1; |
594 | #ifndef WIN32 |
|
|
595 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %lld", pl->stats.exp); |
|
|
596 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %lld", level_exp (pl->level + 1, pl->expmul)); |
|
|
597 | #else |
|
|
598 | 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); |
599 | 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)); |
600 | #endif |
|
|
601 | new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max"); |
461 | new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max"); |
602 | |
462 | |
603 | 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", |
604 | 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); |
605 | 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", |
… | |
… | |
622 | |
482 | |
623 | int |
483 | int |
624 | command_fix_me (object *op, char *params) |
484 | command_fix_me (object *op, char *params) |
625 | { |
485 | { |
626 | sum_weight (op); |
486 | sum_weight (op); |
627 | fix_player (op); |
487 | op->update_stats (); |
628 | return 1; |
488 | new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed."); |
629 | } |
|
|
630 | |
489 | |
631 | int |
|
|
632 | command_players (object *op, char *paramss) |
|
|
633 | { |
|
|
634 | char buf[MAX_BUF]; |
|
|
635 | char *t; |
|
|
636 | DIR *Dir; |
|
|
637 | |
|
|
638 | sprintf (buf, "%s/%s/", settings.localdir, settings.playerdir); |
|
|
639 | t = buf + strlen (buf); |
|
|
640 | if ((Dir = opendir (buf)) != NULL) |
|
|
641 | { |
|
|
642 | const struct dirent *Entry; |
|
|
643 | |
|
|
644 | while ((Entry = readdir (Dir)) != NULL) |
|
|
645 | { |
|
|
646 | /* skip '.' , '..' */ |
|
|
647 | if (!((Entry->d_name[0] == '.' && Entry->d_name[1] == '\0') || |
|
|
648 | (Entry->d_name[0] == '.' && Entry->d_name[1] == '.' && Entry->d_name[2] == '\0'))) |
|
|
649 | { |
|
|
650 | struct stat Stat; |
|
|
651 | |
|
|
652 | strcpy (t, Entry->d_name); |
|
|
653 | if (stat (buf, &Stat) == 0) |
|
|
654 | { |
|
|
655 | /* This was not posix compatible |
|
|
656 | * if ((Stat.st_mode & S_IFMT)==S_IFDIR) { |
|
|
657 | */ |
|
|
658 | if (S_ISDIR (Stat.st_mode)) |
|
|
659 | { |
|
|
660 | char buf2[MAX_BUF]; |
|
|
661 | struct tm *tm = localtime (&Stat.st_mtime); |
|
|
662 | |
|
|
663 | sprintf (buf2, "%s\t%04d %02d %02d %02d %02d %02d", |
|
|
664 | Entry->d_name, 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); |
|
|
665 | new_draw_info (NDI_UNIQUE, 0, op, buf2); |
|
|
666 | } |
|
|
667 | } |
|
|
668 | } |
|
|
669 | } |
|
|
670 | } |
|
|
671 | closedir (Dir); |
|
|
672 | return 0; |
490 | return 1; |
673 | } |
491 | } |
674 | |
|
|
675 | |
|
|
676 | |
492 | |
677 | int |
493 | int |
678 | command_logs (object *op, char *params) |
494 | command_logs (object *op, char *params) |
679 | { |
495 | { |
680 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
496 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
681 | |
497 | |
682 | return 1; |
|
|
683 | } |
|
|
684 | |
|
|
685 | int |
|
|
686 | command_applymode (object *op, char *params) |
|
|
687 | { |
|
|
688 | unapplymode unapply = op->contr->unapply; |
|
|
689 | static const char *const types[] = { "nochoice", "never", "always" }; |
|
|
690 | |
|
|
691 | if (!params) |
|
|
692 | { |
|
|
693 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode is set to %s", types[op->contr->unapply]); |
|
|
694 | return 1; |
|
|
695 | } |
|
|
696 | |
|
|
697 | if (!strcmp (params, "nochoice")) |
|
|
698 | op->contr->unapply = unapply_nochoice; |
|
|
699 | else if (!strcmp (params, "never")) |
|
|
700 | op->contr->unapply = unapply_never; |
|
|
701 | else if (!strcmp (params, "always")) |
|
|
702 | op->contr->unapply = unapply_always; |
|
|
703 | else |
|
|
704 | { |
|
|
705 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params); |
|
|
706 | return 0; |
|
|
707 | } |
|
|
708 | new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s", |
|
|
709 | (unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]); |
|
|
710 | return 1; |
498 | return 1; |
711 | } |
499 | } |
712 | |
500 | |
713 | int |
501 | int |
714 | command_bowmode (object *op, char *params) |
502 | command_bowmode (object *op, char *params) |
… | |
… | |
734 | found++; |
522 | found++; |
735 | op->contr->bowtype = (bowtype_t) i; |
523 | op->contr->bowtype = (bowtype_t) i; |
736 | break; |
524 | break; |
737 | } |
525 | } |
738 | } |
526 | } |
|
|
527 | |
739 | if (!found) |
528 | if (!found) |
740 | { |
529 | { |
741 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
530 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
742 | for (i = 0; i <= bow_bestarrow; i++) |
531 | for (i = 0; i <= bow_bestarrow; i++) |
743 | { |
532 | { |
… | |
… | |
749 | strcat (buf, "."); |
538 | strcat (buf, "."); |
750 | } |
539 | } |
751 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
540 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
752 | return 0; |
541 | return 0; |
753 | } |
542 | } |
|
|
543 | |
754 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
544 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
755 | return 1; |
|
|
756 | } |
|
|
757 | |
|
|
758 | int |
|
|
759 | command_petmode (object *op, char *params) |
|
|
760 | { |
|
|
761 | petmode_t oldtype = op->contr->petmode; |
|
|
762 | static const char *const types[] = { "normal", "sad", "defend", "arena" }; |
|
|
763 | |
|
|
764 | if (!params) |
|
|
765 | { |
|
|
766 | new_draw_info_format (NDI_UNIQUE, 0, op, "petmode is set to %s", types[op->contr->petmode]); |
|
|
767 | return 1; |
|
|
768 | } |
|
|
769 | |
|
|
770 | if (!strcmp (params, "normal")) |
|
|
771 | op->contr->petmode = pet_normal; |
|
|
772 | else if (!strcmp (params, "sad")) |
|
|
773 | op->contr->petmode = pet_sad; |
|
|
774 | else if (!strcmp (params, "defend")) |
|
|
775 | op->contr->petmode = pet_defend; |
|
|
776 | else if (!strcmp (params, "arena")) |
|
|
777 | op->contr->petmode = pet_arena; |
|
|
778 | else |
|
|
779 | { |
|
|
780 | new_draw_info_format (NDI_UNIQUE, 0, op, |
|
|
781 | "petmode: Unknown options %s, valid options are normal," "sad (seek and destroy), defend, arena", params); |
|
|
782 | return 0; |
|
|
783 | } |
|
|
784 | new_draw_info_format (NDI_UNIQUE, 0, op, "petmode %s set to %s", (oldtype == op->contr->petmode ? "" : "now"), types[op->contr->petmode]); |
|
|
785 | return 1; |
545 | return 1; |
786 | } |
546 | } |
787 | |
547 | |
788 | int |
548 | int |
789 | command_showpets (object *op, char *params) |
549 | command_showpets (object *op, char *params) |
… | |
… | |
797 | for (obl = first_friendly_object; obl != NULL; obl = next) |
557 | for (obl = first_friendly_object; obl != NULL; obl = next) |
798 | { |
558 | { |
799 | object *ob = obl->ob; |
559 | object *ob = obl->ob; |
800 | |
560 | |
801 | next = obl->next; |
561 | next = obl->next; |
802 | if (get_owner (ob) == op) |
562 | if (ob->owner == op) |
803 | { |
563 | { |
804 | if (target == 0) |
564 | if (target == 0) |
805 | { |
565 | { |
806 | if (counter == 0) |
566 | if (counter == 0) |
807 | new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
567 | new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
… | |
… | |
830 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
590 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
831 | return 0; |
591 | return 0; |
832 | } |
592 | } |
833 | |
593 | |
834 | int |
594 | int |
835 | command_usekeys (object *op, char *params) |
|
|
836 | { |
|
|
837 | usekeytype oldtype = op->contr->usekeys; |
|
|
838 | static const char *const types[] = { "inventory", "keyrings", "containers" }; |
|
|
839 | |
|
|
840 | if (!params) |
|
|
841 | { |
|
|
842 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys is set to %s", types[op->contr->usekeys]); |
|
|
843 | return 1; |
|
|
844 | } |
|
|
845 | |
|
|
846 | if (!strcmp (params, "inventory")) |
|
|
847 | op->contr->usekeys = key_inventory; |
|
|
848 | else if (!strcmp (params, "keyrings")) |
|
|
849 | op->contr->usekeys = keyrings; |
|
|
850 | else if (!strcmp (params, "containers")) |
|
|
851 | op->contr->usekeys = containers; |
|
|
852 | else |
|
|
853 | { |
|
|
854 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys: Unknown options %s, valid options are inventory, keyrings, containers", params); |
|
|
855 | return 0; |
|
|
856 | } |
|
|
857 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys %s set to %s", (oldtype == op->contr->usekeys ? "" : "now"), types[op->contr->usekeys]); |
|
|
858 | return 1; |
|
|
859 | } |
|
|
860 | |
|
|
861 | int |
|
|
862 | command_resistances (object *op, char *params) |
595 | command_resistances (object *op, char *params) |
863 | { |
596 | { |
864 | int i; |
597 | int i; |
865 | |
598 | |
866 | if (!op) |
599 | if (!op) |
… | |
… | |
914 | char filename[MAX_BUF], line[80]; |
647 | char filename[MAX_BUF], line[80]; |
915 | int namelen, linelen = 0; |
648 | int namelen, linelen = 0; |
916 | |
649 | |
917 | switch (what) |
650 | switch (what) |
918 | { |
651 | { |
919 | case 1: |
652 | case 1: |
920 | sprintf (filename, "%s/wizhelp", settings.datadir); |
653 | sprintf (filename, "%s/wizhelp", settings.datadir); |
921 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
654 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
922 | break; |
655 | break; |
923 | case 3: |
656 | case 3: |
924 | sprintf (filename, "%s/mischelp", settings.datadir); |
657 | sprintf (filename, "%s/mischelp", settings.datadir); |
925 | new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
658 | new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
926 | break; |
659 | break; |
927 | default: |
660 | default: |
928 | sprintf (filename, "%s/help", settings.datadir); |
661 | sprintf (filename, "%s/help", settings.datadir); |
929 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
662 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
930 | break; |
663 | break; |
931 | } |
664 | } |
|
|
665 | |
932 | if (!(dirp = opendir (filename))) |
666 | if (!(dirp = opendir (filename))) |
933 | return; |
667 | return; |
934 | |
668 | |
935 | line[0] = '\0'; |
669 | line[0] = '\0'; |
936 | for (de = readdir (dirp); de; de = readdir (dirp)) |
670 | while ((de = readdir (dirp))) |
937 | { |
671 | { |
938 | namelen = NAMLEN (de); |
672 | namelen = strlen (de->d_name); |
939 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
673 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
940 | continue; |
674 | continue; |
941 | linelen += namelen + 1; |
675 | linelen += namelen + 1; |
942 | if (linelen > 42) |
676 | if (linelen > 42) |
943 | { |
677 | { |
… | |
… | |
1148 | return 0; |
882 | return 0; |
1149 | } |
883 | } |
1150 | } |
884 | } |
1151 | |
885 | |
1152 | int |
886 | int |
1153 | command_quit (object *op, char *params) |
|
|
1154 | { |
|
|
1155 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1156 | "Quitting will delete your character PERMANENTLY. If you are sure you want to do this, then use the quit_character command instead of quit."); |
|
|
1157 | return 1; |
|
|
1158 | } |
|
|
1159 | |
|
|
1160 | int |
|
|
1161 | command_real_quit (object *op, char *params) |
|
|
1162 | { |
|
|
1163 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Quitting will delete your character.\nAre you sure you want to quit (y/n):"); |
|
|
1164 | |
|
|
1165 | op->contr->state = ST_CONFIRM_QUIT; |
|
|
1166 | return 1; |
|
|
1167 | } |
|
|
1168 | |
|
|
1169 | /* |
|
|
1170 | * don't allow people to exit explore mode. It otherwise becomes |
|
|
1171 | * really easy to abuse this. |
|
|
1172 | */ |
|
|
1173 | int |
|
|
1174 | command_explore (object *op, char *params) |
|
|
1175 | { |
|
|
1176 | if (settings.explore_mode == FALSE) |
|
|
1177 | return 1; |
|
|
1178 | /* |
|
|
1179 | * I guess this is the best way to see if we are solo or not. Actually, |
|
|
1180 | * are there any cases when first_player->next==NULL and we are not solo? |
|
|
1181 | */ |
|
|
1182 | if ((first_player != op->contr) || (first_player->next != NULL)) |
|
|
1183 | { |
|
|
1184 | new_draw_info (NDI_UNIQUE, 0, op, "You can not enter explore mode if you are in a party"); |
|
|
1185 | } |
|
|
1186 | else if (op->contr->explore) |
|
|
1187 | new_draw_info (NDI_UNIQUE, 0, op, "There is no return from explore mode"); |
|
|
1188 | else |
|
|
1189 | { |
|
|
1190 | op->contr->explore = 1; |
|
|
1191 | new_draw_info (NDI_UNIQUE, 0, op, "You are now in explore mode"); |
|
|
1192 | } |
|
|
1193 | return 1; |
|
|
1194 | } |
|
|
1195 | |
|
|
1196 | int |
|
|
1197 | command_sound (object *op, char *params) |
|
|
1198 | { |
|
|
1199 | if (op->contr->socket.sound) |
|
|
1200 | { |
|
|
1201 | op->contr->socket.sound = 0; |
|
|
1202 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
|
|
1203 | } |
|
|
1204 | else |
|
|
1205 | { |
|
|
1206 | op->contr->socket.sound = 1; |
|
|
1207 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
|
|
1208 | } |
|
|
1209 | return 1; |
|
|
1210 | } |
|
|
1211 | |
|
|
1212 | /* Perhaps these should be in player.c, but that file is |
|
|
1213 | * already a bit big. |
|
|
1214 | */ |
|
|
1215 | |
|
|
1216 | void |
|
|
1217 | receive_player_name (object *op, char k) |
|
|
1218 | { |
|
|
1219 | |
|
|
1220 | if (!check_name (op->contr, op->contr->write_buf + 1)) |
|
|
1221 | { |
|
|
1222 | get_name (op); |
|
|
1223 | return; |
|
|
1224 | } |
|
|
1225 | op->name = op->contr->write_buf + 1; |
|
|
1226 | op->name_pl = op->contr->write_buf + 1; |
|
|
1227 | new_draw_info (NDI_UNIQUE, 0, op, op->contr->write_buf); |
|
|
1228 | op->contr->name_changed = 1; |
|
|
1229 | get_password (op); |
|
|
1230 | } |
|
|
1231 | |
|
|
1232 | void |
|
|
1233 | receive_player_password (object *op, char k) |
|
|
1234 | { |
|
|
1235 | |
|
|
1236 | unsigned int pwd_len = strlen (op->contr->write_buf); |
|
|
1237 | |
|
|
1238 | if (pwd_len <= 1 || pwd_len > 17) |
|
|
1239 | { |
|
|
1240 | get_name (op); |
|
|
1241 | return; |
|
|
1242 | } |
|
|
1243 | new_draw_info (NDI_UNIQUE, 0, op, " "); /* To hide the password better */ |
|
|
1244 | |
|
|
1245 | if (checkbanned (op->name, op->contr->socket.host)) |
|
|
1246 | { |
|
|
1247 | LOG (llevInfo, "Banned player tried to add: [%s@%s]\n", &op->name, op->contr->socket.host); |
|
|
1248 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, op, "You are not allowed to play."); |
|
|
1249 | get_name (op); |
|
|
1250 | return; |
|
|
1251 | } |
|
|
1252 | |
|
|
1253 | if (op->contr->state == ST_CONFIRM_PASSWORD) |
|
|
1254 | { |
|
|
1255 | if (!check_password (op->contr->write_buf + 1, op->contr->password)) |
|
|
1256 | { |
|
|
1257 | new_draw_info (NDI_UNIQUE, 0, op, "The passwords did not match."); |
|
|
1258 | get_name (op); |
|
|
1259 | return; |
|
|
1260 | } |
|
|
1261 | clear_win_info (op); |
|
|
1262 | display_motd (op); |
|
|
1263 | new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
1264 | new_draw_info (NDI_UNIQUE, 0, op, "Welcome, Brave New Warrior!"); |
|
|
1265 | new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
1266 | Roll_Again (op); |
|
|
1267 | op->contr->state = ST_ROLL_STAT; |
|
|
1268 | return; |
|
|
1269 | } |
|
|
1270 | strcpy (op->contr->password, crypt_string (op->contr->write_buf + 1, NULL)); |
|
|
1271 | op->contr->state = ST_ROLL_STAT; |
|
|
1272 | check_login (op); |
|
|
1273 | return; |
|
|
1274 | } |
|
|
1275 | |
|
|
1276 | |
|
|
1277 | int |
|
|
1278 | explore_mode (void) |
|
|
1279 | { |
|
|
1280 | player *pl; |
|
|
1281 | |
|
|
1282 | if (settings.explore_mode == TRUE) |
|
|
1283 | { |
|
|
1284 | for (pl = first_player; pl != (player *) NULL; pl = pl->next) |
|
|
1285 | if (pl->explore) |
|
|
1286 | return 1; |
|
|
1287 | } |
|
|
1288 | return 0; |
|
|
1289 | } |
|
|
1290 | |
|
|
1291 | |
|
|
1292 | int |
|
|
1293 | command_title (object *op, char *params) |
887 | command_title (object *op, char *params) |
1294 | { |
888 | { |
1295 | char buf[MAX_BUF]; |
889 | char buf[MAX_BUF]; |
1296 | |
890 | |
1297 | if (settings.set_title == FALSE) |
891 | if (settings.set_title == FALSE) |
… | |
… | |
1334 | strcpy (op->contr->own_title, params); |
928 | strcpy (op->contr->own_title, params); |
1335 | return 1; |
929 | return 1; |
1336 | } |
930 | } |
1337 | |
931 | |
1338 | int |
932 | int |
1339 | command_save (object *op, char *params) |
|
|
1340 | { |
|
|
1341 | // if (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) { |
|
|
1342 | // new_draw_info(NDI_UNIQUE, 0, op, "You can not save on unholy ground"); |
|
|
1343 | // } else |
|
|
1344 | if (!op->stats.exp) |
|
|
1345 | { |
|
|
1346 | new_draw_info (NDI_UNIQUE, 0, op, "You don't deserve to save yet."); |
|
|
1347 | } |
|
|
1348 | else |
|
|
1349 | { |
|
|
1350 | if (save_player (op, 1)) |
|
|
1351 | new_draw_info (NDI_UNIQUE, 0, op, "You have been saved."); |
|
|
1352 | else |
|
|
1353 | new_draw_info (NDI_UNIQUE, 0, op, "SAVE FAILED!"); |
|
|
1354 | } |
|
|
1355 | return 1; |
|
|
1356 | } |
|
|
1357 | |
|
|
1358 | |
|
|
1359 | int |
|
|
1360 | command_peaceful (object *op, char *params) |
|
|
1361 | { |
|
|
1362 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1363 | "You cannot change your peaceful setting with this command." |
|
|
1364 | " Please speak to the priest in the temple of Gorokh" |
|
|
1365 | " if you want to become hostile or in temple of Valriel" " if you want to become peaceful again."); |
|
|
1366 | |
|
|
1367 | /* |
|
|
1368 | if((op->contr->peaceful=!op->contr->peaceful)) |
|
|
1369 | new_draw_info(NDI_UNIQUE, 0,op,"You will not attack other players."); |
|
|
1370 | else |
|
|
1371 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
|
|
1372 | */ |
|
|
1373 | return 1; |
|
|
1374 | } |
|
|
1375 | |
|
|
1376 | |
|
|
1377 | |
|
|
1378 | int |
|
|
1379 | command_wimpy (object *op, char *params) |
|
|
1380 | { |
|
|
1381 | int i; |
|
|
1382 | char buf[MAX_BUF]; |
|
|
1383 | |
|
|
1384 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
1385 | { |
|
|
1386 | sprintf (buf, "Your current wimpy level is %d.", op->run_away); |
|
|
1387 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1388 | return 1; |
|
|
1389 | } |
|
|
1390 | sprintf (buf, "Your new wimpy level is %d.", i); |
|
|
1391 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1392 | op->run_away = i; |
|
|
1393 | return 1; |
|
|
1394 | } |
|
|
1395 | |
|
|
1396 | |
|
|
1397 | int |
|
|
1398 | command_brace (object *op, char *params) |
|
|
1399 | { |
|
|
1400 | if (!params) |
|
|
1401 | op->contr->braced = !op->contr->braced; |
|
|
1402 | else |
|
|
1403 | op->contr->braced = onoff_value (params); |
|
|
1404 | |
|
|
1405 | if (op->contr->braced) |
|
|
1406 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
|
|
1407 | else |
|
|
1408 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
|
|
1409 | |
|
|
1410 | fix_player (op); |
|
|
1411 | return 0; |
|
|
1412 | } |
|
|
1413 | |
|
|
1414 | int |
|
|
1415 | command_style_map_info (object *op, char *params) |
|
|
1416 | { |
|
|
1417 | extern maptile *styles; |
|
|
1418 | maptile *mp; |
|
|
1419 | int maps_used = 0, mapmem = 0, objects_used = 0, x, y; |
|
|
1420 | object *tmp; |
|
|
1421 | |
|
|
1422 | for (mp = styles; mp != NULL; mp = mp->next) |
|
|
1423 | { |
|
|
1424 | maps_used++; |
|
|
1425 | mapmem += MAP_WIDTH (mp) * MAP_HEIGHT (mp) * (sizeof (object *) + sizeof (MapSpace)) + sizeof (maptile); |
|
|
1426 | for (x = 0; x < MAP_WIDTH (mp); x++) |
|
|
1427 | { |
|
|
1428 | for (y = 0; y < MAP_HEIGHT (mp); y++) |
|
|
1429 | { |
|
|
1430 | for (tmp = get_map_ob (mp, x, y); tmp != NULL; tmp = tmp->above) |
|
|
1431 | objects_used++; |
|
|
1432 | } |
|
|
1433 | } |
|
|
1434 | } |
|
|
1435 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style maps loaded: %d", maps_used); |
|
|
1436 | new_draw_info (NDI_UNIQUE, 0, op, "Memory used, not"); |
|
|
1437 | new_draw_info_format (NDI_UNIQUE, 0, op, "including objects: %d", mapmem); |
|
|
1438 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style objects: %d", objects_used); |
|
|
1439 | new_draw_info_format (NDI_UNIQUE, 0, op, "Mem for objects: %d", objects_used * sizeof (object)); |
|
|
1440 | return 0; |
|
|
1441 | } |
|
|
1442 | |
|
|
1443 | int |
|
|
1444 | command_kill_pets (object *op, char *params) |
933 | command_kill_pets (object *op, char *params) |
1445 | { |
934 | { |
1446 | objectlink *obl, *next; |
935 | objectlink *obl, *next; |
1447 | int counter = 0, removecount = 0; |
936 | int counter = 0, removecount = 0; |
1448 | |
937 | |
… | |
… | |
1458 | for (obl = first_friendly_object; obl != NULL; obl = next) |
947 | for (obl = first_friendly_object; obl != NULL; obl = next) |
1459 | { |
948 | { |
1460 | object *ob = obl->ob; |
949 | object *ob = obl->ob; |
1461 | |
950 | |
1462 | next = obl->next; |
951 | next = obl->next; |
1463 | if (get_owner (ob) == op) |
952 | if (ob->owner == op) |
1464 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
953 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
1465 | { |
954 | { |
1466 | if (!QUERY_FLAG (ob, FLAG_REMOVED)) |
|
|
1467 | remove_ob (ob); |
|
|
1468 | remove_friendly_object (ob); |
|
|
1469 | free_object (ob); |
955 | ob->destroy (); |
1470 | removecount++; |
956 | removecount++; |
1471 | } |
957 | } |
1472 | } |
958 | } |
1473 | if (removecount != 0) |
959 | if (removecount != 0) |
1474 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
960 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |