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) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
7 | |
7 | * |
8 | 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 |
9 | 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 |
10 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. |
11 | * (at your option) any later version. |
12 | |
12 | * |
13 | 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, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | |
17 | * |
18 | 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 |
19 | along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | |
21 | * |
22 | 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> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <loader.h> |
26 | #include <loader.h> |
27 | #include <sproto.h> |
27 | #include <sproto.h> |
28 | |
28 | |
29 | #include <dirent.h> |
|
|
30 | |
|
|
31 | /* Handles misc. input request - things like hash table, malloc, maps, |
29 | /* Handles misc. input request - things like hash table, malloc, maps, |
32 | * who, etc. |
30 | * who, etc. |
33 | */ |
31 | */ |
34 | |
|
|
35 | //TODO |
|
|
36 | #if 0 |
|
|
37 | void |
|
|
38 | map_info (object *op, char *search) |
|
|
39 | { |
|
|
40 | maptile *m; |
|
|
41 | char buf[MAX_BUF], map_path[31]; |
|
|
42 | long sec = time (0); |
|
|
43 | |
|
|
44 | new_draw_info_format (NDI_UNIQUE, 0, op, "Current time is: %02ld:%02ld:%02ld.", (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60); |
|
|
45 | new_draw_info (NDI_UNIQUE, 0, op, "Path Pl PlM IM TO Dif Reset"); |
|
|
46 | |
|
|
47 | for (maps_container::iterator i = maps.begin (); i != maps.end (); ++i) |
|
|
48 | { |
|
|
49 | maptile *m = i->second; |
|
|
50 | |
|
|
51 | if (search && !strstr (m->path, search)) |
|
|
52 | continue; /* Skip unwanted maps */ |
|
|
53 | |
|
|
54 | /* Print out the last 30 characters of the map name... */ |
|
|
55 | strcpy (map_path, m->path + max (0, (int)strlen (m->path) - 30)); |
|
|
56 | |
|
|
57 | sprintf (buf, "%-30.30s %2d %2d %1d %4d %2d %02d:%02d:%02d", |
|
|
58 | map_path, m->players, players_on_map (m, FALSE), |
|
|
59 | m->in_memory, m->timeout, m->difficulty, |
|
|
60 | (m->reset_time % 86400) / 3600, (m->reset_time % 3600) / 60, m->reset_time % 60); |
|
|
61 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
62 | } |
|
|
63 | } |
|
|
64 | |
|
|
65 | int |
|
|
66 | command_style_map_info (object *op, char *params) |
|
|
67 | { |
|
|
68 | extern maptile *styles; |
|
|
69 | maptile *mp; |
|
|
70 | int maps_used = 0, mapmem = 0, objects_used = 0, x, y; |
|
|
71 | object *tmp; |
|
|
72 | |
|
|
73 | for (mp = styles; mp != NULL; mp = mp->next) |
|
|
74 | { |
|
|
75 | maps_used++; |
|
|
76 | mapmem += mp->width * mp->height * (sizeof (object *) + sizeof (mapspace)) + sizeof (maptile); |
|
|
77 | for (x = 0; x < mp->width; x++) |
|
|
78 | { |
|
|
79 | for (y = 0; y < mp->height; y++) |
|
|
80 | { |
|
|
81 | for (tmp = GET_MAP_OB (mp, x, y); tmp != NULL; tmp = tmp->above) |
|
|
82 | objects_used++; |
|
|
83 | } |
|
|
84 | } |
|
|
85 | } |
|
|
86 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style maps loaded: %d", maps_used); |
|
|
87 | new_draw_info (NDI_UNIQUE, 0, op, "Memory used, not"); |
|
|
88 | new_draw_info_format (NDI_UNIQUE, 0, op, "including objects: %d", mapmem); |
|
|
89 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style objects: %d", objects_used); |
|
|
90 | new_draw_info_format (NDI_UNIQUE, 0, op, "Mem for objects: %d", objects_used * sizeof (object)); |
|
|
91 | return 0; |
|
|
92 | } |
|
|
93 | #endif |
|
|
94 | |
32 | |
95 | /* This command dumps the body information for object *op. |
33 | /* This command dumps the body information for object *op. |
96 | * it doesn't care what the params are. |
34 | * it doesn't care what the params are. |
97 | * This is mostly meant as a debug command. |
35 | * This is mostly meant as a debug command. |
98 | */ |
36 | */ |
… | |
… | |
131 | { |
69 | { |
132 | display_motd (op); |
70 | display_motd (op); |
133 | return 1; |
71 | return 1; |
134 | } |
72 | } |
135 | |
73 | |
136 | int |
|
|
137 | command_bug (object *op, char *params) |
|
|
138 | { |
|
|
139 | char buf[MAX_BUF]; |
|
|
140 | |
|
|
141 | if (params == NULL) |
|
|
142 | { |
|
|
143 | new_draw_info (NDI_UNIQUE, 0, op, "what bugs?"); |
|
|
144 | return 1; |
|
|
145 | } |
|
|
146 | strcpy (buf, op->name); |
|
|
147 | strcat (buf, " bug-reports: "); |
|
|
148 | strncat (buf, ++params, MAX_BUF - strlen (buf)); |
|
|
149 | buf[MAX_BUF - 1] = '\0'; |
|
|
150 | bug_report (buf); |
|
|
151 | LOG (llevError, "%s\n", buf); |
|
|
152 | new_draw_info (NDI_ALL | NDI_UNIQUE, 1, NULL, buf); |
|
|
153 | new_draw_info (NDI_UNIQUE, 0, op, "OK, thanks!"); |
|
|
154 | return 1; |
|
|
155 | } |
|
|
156 | |
|
|
157 | /* |
74 | /* |
158 | * 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 |
159 | * This function returns the name of the players current region, and |
76 | * This function returns the name of the players current region, and |
160 | * a description of it. It is there merely for flavour text. |
77 | * a description of it. It is there merely for flavour text. |
161 | */ |
78 | */ |
162 | void |
79 | void |
163 | current_region_info (object *op) |
80 | current_region_info (object *op) |
164 | { |
81 | { |
165 | /* |
82 | if (region *reg = op->region ()) |
166 | * Ok I /suppose/ I should write a seperate function for this, but it isn't |
|
|
167 | * going to be /that/ slow, and won't get called much |
|
|
168 | */ |
|
|
169 | region *r = get_region_by_name (get_name_of_region_for_map (op->map)); |
|
|
170 | |
|
|
171 | if (!r) |
|
|
172 | return; |
|
|
173 | /* This should only be possible if regions are not operating on this server. */ |
|
|
174 | |
|
|
175 | 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); |
176 | } |
84 | } |
177 | |
85 | |
178 | void |
86 | void |
179 | current_map_info (object *op) |
87 | current_map_info (object *op) |
180 | { |
88 | { |
181 | maptile *m = op->map; |
89 | maptile *m = op->map; |
182 | |
90 | |
183 | if (!m) |
91 | if (!m) |
184 | return; |
92 | return; |
185 | |
93 | |
186 | 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); |
187 | |
95 | |
188 | if (QUERY_FLAG (op, FLAG_WIZ)) |
96 | if (QUERY_FLAG (op, FLAG_WIZ)) |
189 | { |
|
|
190 | new_draw_info_format (NDI_UNIQUE, 0, op, |
97 | new_draw_info_format (NDI_UNIQUE, 0, op, |
191 | "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", |
192 | m->players, m->difficulty, m->width, m->height, m->enter_x, m->enter_y, m->timeout); |
99 | m->players, m->difficulty, m->width, m->height, m->enter_x, m->enter_y, m->timeout); |
193 | |
100 | |
194 | } |
|
|
195 | if (m->msg) |
101 | if (m->msg) |
196 | new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
102 | new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
197 | } |
103 | } |
198 | |
104 | |
199 | #ifdef DEBUG_MALLOC_LEVEL |
105 | #ifdef DEBUG_MALLOC_LEVEL |
… | |
… | |
211 | #endif |
117 | #endif |
212 | |
118 | |
213 | int |
119 | int |
214 | command_whereabouts (object *op, char *params) |
120 | command_whereabouts (object *op, char *params) |
215 | { |
121 | { |
216 | |
122 | //TODO: should obviously not waste space in struct region for this. |
217 | region *reg; |
|
|
218 | player *pl; |
|
|
219 | |
|
|
220 | /* |
123 | /* |
221 | * 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 |
222 | * players there. |
125 | * players there. |
223 | * 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.... |
224 | */ |
127 | */ |
225 | for (reg = first_region; reg != NULL; reg = reg->next) |
128 | for_all_regions (rgn) |
226 | { |
|
|
227 | reg->counter = 0; |
129 | rgn->counter = 0; |
228 | } |
130 | |
229 | for_all_players (pl) |
131 | for_all_players (pl) |
230 | if (pl->ob->map != NULL) |
132 | if (pl->ob->map) |
231 | get_region_by_map (pl->ob->map)->counter++; |
133 | ++pl->ob->region ()->counter; |
232 | |
134 | |
233 | /* 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... */ |
234 | for (reg = first_region; reg != NULL; reg = reg->next) |
136 | for_all_regions (rgn) |
235 | { |
137 | { |
236 | if (reg->longname == NULL && reg->counter > 0) |
138 | if (!rgn->longname && rgn->counter > 0) |
237 | { |
139 | { |
238 | if (reg->parent != NULL) |
140 | if (rgn->parent) |
239 | { |
141 | { |
240 | reg->parent->counter += reg->counter; |
142 | rgn->parent->counter += rgn->counter; |
241 | reg->counter = 0; |
143 | rgn->counter = 0; |
242 | } |
144 | } |
243 | else /*uh oh, we shouldn't be here. */ |
145 | else /*uh oh, we shouldn't be here. */ |
244 | 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); |
245 | } |
147 | } |
246 | } |
148 | } |
|
|
149 | |
247 | 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:"); |
248 | for (reg = first_region; reg != NULL; reg = reg->next) |
151 | |
|
|
152 | for_all_regions (rgn) |
249 | if (reg->counter > 0) |
153 | if (rgn->counter) |
250 | 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 | |
251 | return 1; |
156 | return 1; |
252 | } |
157 | } |
253 | |
158 | |
254 | typedef struct |
159 | typedef struct |
255 | { |
160 | { |
256 | char namebuf[MAX_BUF]; |
161 | char namebuf[MAX_BUF]; |
257 | int login_order; |
162 | int login_order; |
258 | } chars_names; |
163 | } chars_names; |
259 | |
|
|
260 | int |
|
|
261 | command_afk (object *op, char *params) |
|
|
262 | { |
|
|
263 | if ((op->contr->ns->afk = !op->contr->ns->afk)) |
|
|
264 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer AFK"); |
|
|
265 | else |
|
|
266 | new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK"); |
|
|
267 | |
|
|
268 | return 1; |
|
|
269 | } |
|
|
270 | |
164 | |
271 | int |
165 | int |
272 | command_mapinfo (object *op, char *params) |
166 | command_mapinfo (object *op, char *params) |
273 | { |
167 | { |
274 | current_map_info (op); |
168 | current_map_info (op); |
… | |
… | |
421 | #endif |
315 | #endif |
422 | return 1; |
316 | return 1; |
423 | } |
317 | } |
424 | |
318 | |
425 | int |
319 | int |
426 | command_archs (object *op, char *params) |
|
|
427 | { |
|
|
428 | arch_info (op); |
|
|
429 | return 1; |
|
|
430 | } |
|
|
431 | |
|
|
432 | int |
|
|
433 | command_hiscore (object *op, char *params) |
320 | command_hiscore (object *op, char *params) |
434 | { |
321 | { |
435 | display_high_score (op, op == NULL ? 9999 : 50, params); |
322 | display_high_score (op, op == NULL ? 9999 : 50, params); |
436 | return 1; |
323 | return 1; |
437 | } |
324 | } |
… | |
… | |
444 | |
331 | |
445 | if (params == NULL || !sscanf (params, "%d", &i)) |
332 | if (params == NULL || !sscanf (params, "%d", &i)) |
446 | { |
333 | { |
447 | sprintf (buf, "Global debug level is %d.", settings.debug); |
334 | sprintf (buf, "Global debug level is %d.", settings.debug); |
448 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
335 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
449 | return 1; |
|
|
450 | } |
|
|
451 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
|
|
452 | { |
|
|
453 | new_draw_info (NDI_UNIQUE, 0, op, "Privileged command."); |
|
|
454 | return 1; |
336 | return 1; |
455 | } |
337 | } |
456 | settings.debug = (enum LogLevel) FABS (i); |
338 | settings.debug = (enum LogLevel) FABS (i); |
457 | sprintf (buf, "Set debug level to %d.", i); |
339 | sprintf (buf, "Set debug level to %d.", i); |
458 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
340 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
… | |
… | |
516 | } |
398 | } |
517 | else |
399 | else |
518 | { |
400 | { |
519 | LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno)); |
401 | LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno)); |
520 | } |
402 | } |
521 | } |
|
|
522 | |
|
|
523 | int |
|
|
524 | command_output_sync (object *op, char *params) |
|
|
525 | { |
|
|
526 | int val; |
|
|
527 | |
|
|
528 | if (!params) |
|
|
529 | { |
|
|
530 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time is presently %d", op->contr->outputs_sync); |
|
|
531 | return 1; |
|
|
532 | } |
|
|
533 | val = atoi (params); |
|
|
534 | if (val > 0) |
|
|
535 | { |
|
|
536 | op->contr->outputs_sync = val; |
|
|
537 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time now set to %d", op->contr->outputs_sync); |
|
|
538 | } |
|
|
539 | else |
|
|
540 | new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_sync."); |
|
|
541 | |
|
|
542 | return 1; |
|
|
543 | } |
|
|
544 | |
|
|
545 | int |
|
|
546 | command_output_count (object *op, char *params) |
|
|
547 | { |
|
|
548 | int val; |
|
|
549 | |
|
|
550 | if (!params) |
|
|
551 | { |
|
|
552 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output count is presently %d", op->contr->outputs_count); |
|
|
553 | return 1; |
|
|
554 | } |
|
|
555 | val = atoi (params); |
|
|
556 | if (val > 0) |
|
|
557 | { |
|
|
558 | op->contr->outputs_count = val; |
|
|
559 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output count now set to %d", op->contr->outputs_count); |
|
|
560 | } |
|
|
561 | else |
|
|
562 | new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_count."); |
|
|
563 | |
|
|
564 | return 1; |
|
|
565 | } |
|
|
566 | |
|
|
567 | int |
|
|
568 | command_listen (object *op, char *params) |
|
|
569 | { |
|
|
570 | int i; |
|
|
571 | |
|
|
572 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
573 | { |
|
|
574 | new_draw_info_format (NDI_UNIQUE, 0, op, "Set listen to what (presently %d)?", op->contr->listening); |
|
|
575 | return 1; |
|
|
576 | } |
|
|
577 | op->contr->listening = (char) i; |
|
|
578 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your verbose level is now %d.", i); |
|
|
579 | return 1; |
|
|
580 | } |
403 | } |
581 | |
404 | |
582 | /* Prints out some useful information for the character. Everything we print |
405 | /* Prints out some useful information for the character. Everything we print |
583 | * out can be determined by the docs, so we aren't revealing anything extra - |
406 | * out can be determined by the docs, so we aren't revealing anything extra - |
584 | * rather, we are making it convenient to find the values. params have |
407 | * rather, we are making it convenient to find the values. params have |
… | |
… | |
616 | int |
439 | int |
617 | command_fix_me (object *op, char *params) |
440 | command_fix_me (object *op, char *params) |
618 | { |
441 | { |
619 | sum_weight (op); |
442 | sum_weight (op); |
620 | op->update_stats (); |
443 | op->update_stats (); |
621 | return 1; |
444 | new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed."); |
622 | } |
|
|
623 | |
445 | |
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))) |
|
|
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; |
446 | return 1; |
666 | } |
447 | } |
667 | |
|
|
668 | |
|
|
669 | |
448 | |
670 | int |
449 | int |
671 | command_logs (object *op, char *params) |
450 | command_logs (object *op, char *params) |
672 | { |
451 | { |
673 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
452 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
674 | |
453 | |
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; |
454 | return 1; |
704 | } |
455 | } |
705 | |
456 | |
706 | int |
457 | int |
707 | command_bowmode (object *op, char *params) |
458 | command_bowmode (object *op, char *params) |
… | |
… | |
727 | found++; |
478 | found++; |
728 | op->contr->bowtype = (bowtype_t) i; |
479 | op->contr->bowtype = (bowtype_t) i; |
729 | break; |
480 | break; |
730 | } |
481 | } |
731 | } |
482 | } |
|
|
483 | |
732 | if (!found) |
484 | if (!found) |
733 | { |
485 | { |
734 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
486 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
735 | for (i = 0; i <= bow_bestarrow; i++) |
487 | for (i = 0; i <= bow_bestarrow; i++) |
736 | { |
488 | { |
… | |
… | |
742 | strcat (buf, "."); |
494 | strcat (buf, "."); |
743 | } |
495 | } |
744 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
496 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
745 | return 0; |
497 | return 0; |
746 | } |
498 | } |
|
|
499 | |
747 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
500 | 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; |
|
|
749 | } |
|
|
750 | |
|
|
751 | 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; |
501 | return 1; |
779 | } |
502 | } |
780 | |
503 | |
781 | int |
504 | int |
782 | command_showpets (object *op, char *params) |
505 | command_showpets (object *op, char *params) |
… | |
… | |
823 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
546 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
824 | return 0; |
547 | return 0; |
825 | } |
548 | } |
826 | |
549 | |
827 | int |
550 | int |
828 | command_usekeys (object *op, char *params) |
|
|
829 | { |
|
|
830 | usekeytype oldtype = op->contr->usekeys; |
|
|
831 | static const char *const types[] = { "inventory", "keyrings", "containers" }; |
|
|
832 | |
|
|
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; |
|
|
852 | } |
|
|
853 | |
|
|
854 | int |
|
|
855 | command_resistances (object *op, char *params) |
551 | command_resistances (object *op, char *params) |
856 | { |
552 | { |
857 | int i; |
553 | int i; |
858 | |
554 | |
859 | if (!op) |
555 | if (!op) |
… | |
… | |
925 | |
621 | |
926 | if (!(dirp = opendir (filename))) |
622 | if (!(dirp = opendir (filename))) |
927 | return; |
623 | return; |
928 | |
624 | |
929 | line[0] = '\0'; |
625 | line[0] = '\0'; |
930 | while (de = readdir (dirp)) |
626 | while ((de = readdir (dirp))) |
931 | { |
627 | { |
932 | namelen = strlen (de->d_name); |
628 | namelen = strlen (de->d_name); |
933 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
629 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
934 | continue; |
630 | continue; |
935 | linelen += namelen + 1; |
631 | linelen += namelen + 1; |
… | |
… | |
1142 | return 0; |
838 | return 0; |
1143 | } |
839 | } |
1144 | } |
840 | } |
1145 | |
841 | |
1146 | int |
842 | int |
1147 | command_sound (object *op, char *params) |
|
|
1148 | { |
|
|
1149 | if (op->contr->ns->sound) |
|
|
1150 | { |
|
|
1151 | op->contr->ns->sound = 0; |
|
|
1152 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
|
|
1153 | } |
|
|
1154 | else |
|
|
1155 | { |
|
|
1156 | op->contr->ns->sound = 1; |
|
|
1157 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
|
|
1158 | } |
|
|
1159 | |
|
|
1160 | return 1; |
|
|
1161 | } |
|
|
1162 | |
|
|
1163 | int |
|
|
1164 | command_title (object *op, char *params) |
843 | command_title (object *op, char *params) |
1165 | { |
844 | { |
1166 | char buf[MAX_BUF]; |
845 | char buf[MAX_BUF]; |
1167 | |
846 | |
1168 | if (settings.set_title == FALSE) |
847 | if (settings.set_title == FALSE) |
… | |
… | |
1202 | new_draw_info (NDI_UNIQUE, 0, op, "Title too long."); |
881 | new_draw_info (NDI_UNIQUE, 0, op, "Title too long."); |
1203 | return 1; |
882 | return 1; |
1204 | } |
883 | } |
1205 | strcpy (op->contr->own_title, params); |
884 | strcpy (op->contr->own_title, params); |
1206 | return 1; |
885 | return 1; |
1207 | } |
|
|
1208 | |
|
|
1209 | int |
|
|
1210 | command_peaceful (object *op, char *params) |
|
|
1211 | { |
|
|
1212 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1213 | "You cannot change your peaceful setting with this command." |
|
|
1214 | " Please speak to the priest in the temple of Gorokh" |
|
|
1215 | " if you want to become hostile or in temple of Valriel" " if you want to become peaceful again."); |
|
|
1216 | |
|
|
1217 | /* |
|
|
1218 | if((op->contr->peaceful=!op->contr->peaceful)) |
|
|
1219 | new_draw_info(NDI_UNIQUE, 0,op,"You will not attack other players."); |
|
|
1220 | else |
|
|
1221 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
|
|
1222 | */ |
|
|
1223 | return 1; |
|
|
1224 | } |
|
|
1225 | |
|
|
1226 | int |
|
|
1227 | command_wimpy (object *op, char *params) |
|
|
1228 | { |
|
|
1229 | int i; |
|
|
1230 | char buf[MAX_BUF]; |
|
|
1231 | |
|
|
1232 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
1233 | { |
|
|
1234 | sprintf (buf, "Your current wimpy level is %d.", op->run_away); |
|
|
1235 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1236 | return 1; |
|
|
1237 | } |
|
|
1238 | sprintf (buf, "Your new wimpy level is %d.", i); |
|
|
1239 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1240 | op->run_away = i; |
|
|
1241 | return 1; |
|
|
1242 | } |
|
|
1243 | |
|
|
1244 | int |
|
|
1245 | command_brace (object *op, char *params) |
|
|
1246 | { |
|
|
1247 | if (!params) |
|
|
1248 | op->contr->braced = !op->contr->braced; |
|
|
1249 | else |
|
|
1250 | op->contr->braced = onoff_value (params); |
|
|
1251 | |
|
|
1252 | if (op->contr->braced) |
|
|
1253 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
|
|
1254 | else |
|
|
1255 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
|
|
1256 | |
|
|
1257 | op->update_stats (); |
|
|
1258 | return 0; |
|
|
1259 | } |
886 | } |
1260 | |
887 | |
1261 | int |
888 | int |
1262 | command_kill_pets (object *op, char *params) |
889 | command_kill_pets (object *op, char *params) |
1263 | { |
890 | { |