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 | { |
… | |
… | |
226 | } chars_names; |
163 | } chars_names; |
227 | |
164 | |
228 | int |
165 | int |
229 | command_afk (object *op, char *params) |
166 | command_afk (object *op, char *params) |
230 | { |
167 | { |
231 | if QUERY_FLAG |
168 | if ((op->contr->ns->afk = !op->contr->ns->afk)) |
232 | (op, FLAG_AFK) |
|
|
233 | { |
|
|
234 | CLEAR_FLAG (op, FLAG_AFK); |
|
|
235 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer AFK"); |
169 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer AFK"); |
236 | } |
|
|
237 | else |
170 | else |
238 | { |
|
|
239 | SET_FLAG (op, FLAG_AFK); |
|
|
240 | new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK"); |
171 | new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK"); |
241 | } |
172 | |
242 | return 1; |
173 | return 1; |
243 | } |
174 | } |
244 | |
175 | |
245 | int |
176 | int |
246 | command_mapinfo (object *op, char *params) |
177 | command_mapinfo (object *op, char *params) |
… | |
… | |
255 | current_region_info (op); |
186 | current_region_info (op); |
256 | return 1; |
187 | return 1; |
257 | } |
188 | } |
258 | |
189 | |
259 | int |
190 | int |
260 | command_maps (object *op, char *params) |
|
|
261 | { |
|
|
262 | map_info (op, params); |
|
|
263 | return 1; |
|
|
264 | } |
|
|
265 | |
|
|
266 | int |
|
|
267 | command_time (object *op, char *params) |
191 | command_time (object *op, char *params) |
268 | { |
192 | { |
269 | print_tod (op); |
193 | print_tod (op); |
270 | return 1; |
194 | return 1; |
271 | } |
195 | } |
272 | |
196 | |
273 | int |
197 | int |
274 | command_weather (object *op, char *params) |
198 | command_weather (object *op, char *params) |
275 | { |
199 | { |
|
|
200 | #if 0 |
276 | int wx, wy, temp, sky; |
201 | int wx, wy, temp, sky; |
277 | char buf[MAX_BUF]; |
202 | char buf[MAX_BUF]; |
278 | |
203 | |
279 | if (settings.dynamiclevel < 1) |
204 | if (settings.dynamiclevel < 1) |
280 | return 1; |
205 | return 1; |
… | |
… | |
396 | break; |
321 | break; |
397 | case SKY_BLIZZARD: |
322 | case SKY_BLIZZARD: |
398 | new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); |
323 | new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); |
399 | break; |
324 | break; |
400 | } |
325 | } |
401 | return 1; |
326 | #endif |
402 | } |
|
|
403 | |
|
|
404 | int |
|
|
405 | command_archs (object *op, char *params) |
|
|
406 | { |
|
|
407 | arch_info (op); |
|
|
408 | return 1; |
327 | return 1; |
409 | } |
328 | } |
410 | |
329 | |
411 | int |
330 | int |
412 | command_hiscore (object *op, char *params) |
331 | command_hiscore (object *op, char *params) |
… | |
… | |
463 | dump_friendly_objects (); |
382 | dump_friendly_objects (); |
464 | return 0; |
383 | return 0; |
465 | } |
384 | } |
466 | |
385 | |
467 | int |
386 | int |
468 | command_dumpmap (object *op, char *params) |
|
|
469 | { |
|
|
470 | if (op) |
|
|
471 | dump_map (op->map); |
|
|
472 | return 0; |
|
|
473 | } |
|
|
474 | |
|
|
475 | int |
|
|
476 | command_dumpallmaps (object *op, char *params) |
|
|
477 | { |
|
|
478 | dump_all_maps (); |
|
|
479 | return 0; |
|
|
480 | } |
|
|
481 | |
|
|
482 | int |
|
|
483 | command_printlos (object *op, char *params) |
387 | command_printlos (object *op, char *params) |
484 | { |
388 | { |
485 | if (op) |
389 | if (op) |
486 | print_los (op); |
390 | print_los (op); |
487 | return 0; |
391 | return 0; |
… | |
… | |
492 | command_version (object *op, char *params) |
396 | command_version (object *op, char *params) |
493 | { |
397 | { |
494 | version (op); |
398 | version (op); |
495 | return 0; |
399 | return 0; |
496 | } |
400 | } |
497 | |
|
|
498 | |
401 | |
499 | #ifndef BUG_LOG |
402 | #ifndef BUG_LOG |
500 | # define BUG_LOG "bug_log" |
403 | # define BUG_LOG "bug_log" |
501 | #endif |
404 | #endif |
502 | void |
405 | void |
… | |
… | |
582 | int |
485 | int |
583 | command_statistics (object *pl, char *params) |
486 | command_statistics (object *pl, char *params) |
584 | { |
487 | { |
585 | if (!pl->contr) |
488 | if (!pl->contr) |
586 | return 1; |
489 | return 1; |
587 | #ifndef WIN32 |
|
|
588 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %lld", pl->stats.exp); |
|
|
589 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %lld", level_exp (pl->level + 1, pl->expmul)); |
|
|
590 | #else |
|
|
591 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %I64d", pl->stats.exp); |
490 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %" PRId64, pl->stats.exp); |
592 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %I64d", level_exp (pl->level + 1, pl->expmul)); |
491 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %" PRId64, level_exp (pl->level + 1, pl->expmul)); |
593 | #endif |
|
|
594 | new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max"); |
492 | new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max"); |
595 | |
493 | |
596 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Str %2d/ %3d/%3d", |
494 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Str %2d/ %3d/%3d", |
597 | pl->contr->orig_stats.Str, pl->stats.Str, 20 + pl->arch->clone.stats.Str); |
495 | pl->contr->orig_stats.Str, pl->stats.Str, 20 + pl->arch->clone.stats.Str); |
598 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Dex %2d/ %3d/%3d", |
496 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Dex %2d/ %3d/%3d", |
… | |
… | |
615 | |
513 | |
616 | int |
514 | int |
617 | command_fix_me (object *op, char *params) |
515 | command_fix_me (object *op, char *params) |
618 | { |
516 | { |
619 | sum_weight (op); |
517 | sum_weight (op); |
620 | fix_player (op); |
518 | op->update_stats (); |
621 | return 1; |
|
|
622 | } |
|
|
623 | |
|
|
624 | int |
|
|
625 | command_players (object *op, char *paramss) |
|
|
626 | { |
|
|
627 | char buf[MAX_BUF]; |
|
|
628 | char *t; |
|
|
629 | DIR *Dir; |
|
|
630 | |
|
|
631 | sprintf (buf, "%s/%s/", settings.localdir, settings.playerdir); |
|
|
632 | t = buf + strlen (buf); |
|
|
633 | if ((Dir = opendir (buf)) != NULL) |
|
|
634 | { |
|
|
635 | const struct dirent *Entry; |
|
|
636 | |
|
|
637 | while ((Entry = readdir (Dir)) != NULL) |
|
|
638 | { |
|
|
639 | /* skip '.' , '..' */ |
|
|
640 | if (!((Entry->d_name[0] == '.' && Entry->d_name[1] == '\0') || |
|
|
641 | (Entry->d_name[0] == '.' && Entry->d_name[1] == '.' && Entry->d_name[2] == '\0'))) |
|
|
642 | { |
|
|
643 | struct stat Stat; |
|
|
644 | |
|
|
645 | strcpy (t, Entry->d_name); |
|
|
646 | if (stat (buf, &Stat) == 0) |
|
|
647 | { |
|
|
648 | /* This was not posix compatible |
|
|
649 | * if ((Stat.st_mode & S_IFMT)==S_IFDIR) { |
|
|
650 | */ |
|
|
651 | if (S_ISDIR (Stat.st_mode)) |
|
|
652 | { |
|
|
653 | char buf2[MAX_BUF]; |
|
|
654 | struct tm *tm = localtime (&Stat.st_mtime); |
|
|
655 | |
|
|
656 | sprintf (buf2, "%s\t%04d %02d %02d %02d %02d %02d", |
|
|
657 | Entry->d_name, 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); |
|
|
658 | new_draw_info (NDI_UNIQUE, 0, op, buf2); |
|
|
659 | } |
|
|
660 | } |
|
|
661 | } |
|
|
662 | } |
|
|
663 | } |
|
|
664 | closedir (Dir); |
|
|
665 | return 0; |
519 | return 1; |
666 | } |
520 | } |
667 | |
|
|
668 | |
|
|
669 | |
521 | |
670 | int |
522 | int |
671 | command_logs (object *op, char *params) |
523 | command_logs (object *op, char *params) |
672 | { |
524 | { |
673 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
525 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
… | |
… | |
696 | else |
548 | else |
697 | { |
549 | { |
698 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params); |
550 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params); |
699 | return 0; |
551 | return 0; |
700 | } |
552 | } |
|
|
553 | |
701 | new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s", |
554 | new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s", |
702 | (unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]); |
555 | (unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]); |
703 | return 1; |
556 | return 1; |
704 | } |
557 | } |
705 | |
558 | |
… | |
… | |
727 | found++; |
580 | found++; |
728 | op->contr->bowtype = (bowtype_t) i; |
581 | op->contr->bowtype = (bowtype_t) i; |
729 | break; |
582 | break; |
730 | } |
583 | } |
731 | } |
584 | } |
|
|
585 | |
732 | if (!found) |
586 | if (!found) |
733 | { |
587 | { |
734 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
588 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
735 | for (i = 0; i <= bow_bestarrow; i++) |
589 | for (i = 0; i <= bow_bestarrow; i++) |
736 | { |
590 | { |
… | |
… | |
742 | strcat (buf, "."); |
596 | strcat (buf, "."); |
743 | } |
597 | } |
744 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
598 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
745 | return 0; |
599 | return 0; |
746 | } |
600 | } |
|
|
601 | |
747 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
602 | 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; |
603 | return 1; |
749 | } |
604 | } |
750 | |
605 | |
751 | int |
606 | int |
… | |
… | |
790 | for (obl = first_friendly_object; obl != NULL; obl = next) |
645 | for (obl = first_friendly_object; obl != NULL; obl = next) |
791 | { |
646 | { |
792 | object *ob = obl->ob; |
647 | object *ob = obl->ob; |
793 | |
648 | |
794 | next = obl->next; |
649 | next = obl->next; |
795 | if (get_owner (ob) == op) |
650 | if (ob->owner == op) |
796 | { |
651 | { |
797 | if (target == 0) |
652 | if (target == 0) |
798 | { |
653 | { |
799 | if (counter == 0) |
654 | if (counter == 0) |
800 | new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
655 | new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
… | |
… | |
907 | char filename[MAX_BUF], line[80]; |
762 | char filename[MAX_BUF], line[80]; |
908 | int namelen, linelen = 0; |
763 | int namelen, linelen = 0; |
909 | |
764 | |
910 | switch (what) |
765 | switch (what) |
911 | { |
766 | { |
912 | case 1: |
767 | case 1: |
913 | sprintf (filename, "%s/wizhelp", settings.datadir); |
768 | sprintf (filename, "%s/wizhelp", settings.datadir); |
914 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
769 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
915 | break; |
770 | break; |
916 | case 3: |
771 | case 3: |
917 | sprintf (filename, "%s/mischelp", settings.datadir); |
772 | sprintf (filename, "%s/mischelp", settings.datadir); |
918 | new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
773 | new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
919 | break; |
774 | break; |
920 | default: |
775 | default: |
921 | sprintf (filename, "%s/help", settings.datadir); |
776 | sprintf (filename, "%s/help", settings.datadir); |
922 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
777 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
923 | break; |
778 | break; |
924 | } |
779 | } |
|
|
780 | |
925 | if (!(dirp = opendir (filename))) |
781 | if (!(dirp = opendir (filename))) |
926 | return; |
782 | return; |
927 | |
783 | |
928 | line[0] = '\0'; |
784 | line[0] = '\0'; |
929 | for (de = readdir (dirp); de; de = readdir (dirp)) |
785 | while ((de = readdir (dirp))) |
930 | { |
786 | { |
931 | namelen = NAMLEN (de); |
787 | namelen = strlen (de->d_name); |
932 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
788 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
933 | continue; |
789 | continue; |
934 | linelen += namelen + 1; |
790 | linelen += namelen + 1; |
935 | if (linelen > 42) |
791 | if (linelen > 42) |
936 | { |
792 | { |
… | |
… | |
1141 | return 0; |
997 | return 0; |
1142 | } |
998 | } |
1143 | } |
999 | } |
1144 | |
1000 | |
1145 | int |
1001 | int |
1146 | command_quit (object *op, char *params) |
|
|
1147 | { |
|
|
1148 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1149 | "Quitting will delete your character PERMANENTLY. If you are sure you want to do this, then use the quit_character command instead of quit."); |
|
|
1150 | return 1; |
|
|
1151 | } |
|
|
1152 | |
|
|
1153 | int |
|
|
1154 | command_real_quit (object *op, char *params) |
|
|
1155 | { |
|
|
1156 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Quitting will delete your character.\nAre you sure you want to quit (y/n):"); |
|
|
1157 | |
|
|
1158 | op->contr->state = ST_CONFIRM_QUIT; |
|
|
1159 | return 1; |
|
|
1160 | } |
|
|
1161 | |
|
|
1162 | /* |
|
|
1163 | * don't allow people to exit explore mode. It otherwise becomes |
|
|
1164 | * really easy to abuse this. |
|
|
1165 | */ |
|
|
1166 | int |
|
|
1167 | command_explore (object *op, char *params) |
|
|
1168 | { |
|
|
1169 | if (settings.explore_mode == FALSE) |
|
|
1170 | return 1; |
|
|
1171 | /* |
|
|
1172 | * I guess this is the best way to see if we are solo or not. Actually, |
|
|
1173 | * are there any cases when first_player->next==NULL and we are not solo? |
|
|
1174 | */ |
|
|
1175 | if ((first_player != op->contr) || (first_player->next != NULL)) |
|
|
1176 | { |
|
|
1177 | new_draw_info (NDI_UNIQUE, 0, op, "You can not enter explore mode if you are in a party"); |
|
|
1178 | } |
|
|
1179 | else if (op->contr->explore) |
|
|
1180 | new_draw_info (NDI_UNIQUE, 0, op, "There is no return from explore mode"); |
|
|
1181 | else |
|
|
1182 | { |
|
|
1183 | op->contr->explore = 1; |
|
|
1184 | new_draw_info (NDI_UNIQUE, 0, op, "You are now in explore mode"); |
|
|
1185 | } |
|
|
1186 | return 1; |
|
|
1187 | } |
|
|
1188 | |
|
|
1189 | int |
|
|
1190 | command_sound (object *op, char *params) |
1002 | command_sound (object *op, char *params) |
1191 | { |
1003 | { |
1192 | if (op->contr->socket.sound) |
1004 | if (op->contr->ns->sound) |
1193 | { |
1005 | { |
1194 | op->contr->socket.sound = 0; |
1006 | op->contr->ns->sound = 0; |
1195 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
1007 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
1196 | } |
1008 | } |
1197 | else |
1009 | else |
1198 | { |
1010 | { |
1199 | op->contr->socket.sound = 1; |
1011 | op->contr->ns->sound = 1; |
1200 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
1012 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
1201 | } |
1013 | } |
1202 | return 1; |
|
|
1203 | } |
|
|
1204 | |
1014 | |
1205 | /* Perhaps these should be in player.c, but that file is |
|
|
1206 | * already a bit big. |
|
|
1207 | */ |
|
|
1208 | |
|
|
1209 | void |
|
|
1210 | receive_player_name (object *op, char k) |
|
|
1211 | { |
|
|
1212 | |
|
|
1213 | if (!check_name (op->contr, op->contr->write_buf + 1)) |
|
|
1214 | { |
|
|
1215 | get_name (op); |
|
|
1216 | return; |
|
|
1217 | } |
|
|
1218 | op->name = op->contr->write_buf + 1; |
|
|
1219 | op->name_pl = op->contr->write_buf + 1; |
|
|
1220 | new_draw_info (NDI_UNIQUE, 0, op, op->contr->write_buf); |
|
|
1221 | op->contr->name_changed = 1; |
|
|
1222 | get_password (op); |
|
|
1223 | } |
|
|
1224 | |
|
|
1225 | void |
|
|
1226 | receive_player_password (object *op, char k) |
|
|
1227 | { |
|
|
1228 | |
|
|
1229 | unsigned int pwd_len = strlen (op->contr->write_buf); |
|
|
1230 | |
|
|
1231 | if (pwd_len <= 1 || pwd_len > 17) |
|
|
1232 | { |
|
|
1233 | get_name (op); |
|
|
1234 | return; |
|
|
1235 | } |
|
|
1236 | new_draw_info (NDI_UNIQUE, 0, op, " "); /* To hide the password better */ |
|
|
1237 | |
|
|
1238 | if (checkbanned (op->name, op->contr->socket.host)) |
|
|
1239 | { |
|
|
1240 | LOG (llevInfo, "Banned player tried to add: [%s@%s]\n", &op->name, op->contr->socket.host); |
|
|
1241 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, op, "You are not allowed to play."); |
|
|
1242 | get_name (op); |
|
|
1243 | return; |
|
|
1244 | } |
|
|
1245 | |
|
|
1246 | if (op->contr->state == ST_CONFIRM_PASSWORD) |
|
|
1247 | { |
|
|
1248 | if (!check_password (op->contr->write_buf + 1, op->contr->password)) |
|
|
1249 | { |
|
|
1250 | new_draw_info (NDI_UNIQUE, 0, op, "The passwords did not match."); |
|
|
1251 | get_name (op); |
|
|
1252 | return; |
|
|
1253 | } |
|
|
1254 | clear_win_info (op); |
|
|
1255 | display_motd (op); |
|
|
1256 | new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
1257 | new_draw_info (NDI_UNIQUE, 0, op, "Welcome, Brave New Warrior!"); |
|
|
1258 | new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
1259 | Roll_Again (op); |
|
|
1260 | op->contr->state = ST_ROLL_STAT; |
|
|
1261 | return; |
|
|
1262 | } |
|
|
1263 | strcpy (op->contr->password, crypt_string (op->contr->write_buf + 1, NULL)); |
|
|
1264 | op->contr->state = ST_ROLL_STAT; |
|
|
1265 | check_login (op); |
|
|
1266 | return; |
|
|
1267 | } |
|
|
1268 | |
|
|
1269 | |
|
|
1270 | int |
|
|
1271 | explore_mode (void) |
|
|
1272 | { |
|
|
1273 | player *pl; |
|
|
1274 | |
|
|
1275 | if (settings.explore_mode == TRUE) |
|
|
1276 | { |
|
|
1277 | for (pl = first_player; pl != (player *) NULL; pl = pl->next) |
|
|
1278 | if (pl->explore) |
|
|
1279 | return 1; |
|
|
1280 | } |
|
|
1281 | return 0; |
1015 | return 1; |
1282 | } |
1016 | } |
1283 | |
|
|
1284 | |
1017 | |
1285 | int |
1018 | int |
1286 | command_title (object *op, char *params) |
1019 | command_title (object *op, char *params) |
1287 | { |
1020 | { |
1288 | char buf[MAX_BUF]; |
1021 | char buf[MAX_BUF]; |
… | |
… | |
1327 | strcpy (op->contr->own_title, params); |
1060 | strcpy (op->contr->own_title, params); |
1328 | return 1; |
1061 | return 1; |
1329 | } |
1062 | } |
1330 | |
1063 | |
1331 | int |
1064 | int |
1332 | command_save (object *op, char *params) |
|
|
1333 | { |
|
|
1334 | // if (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) { |
|
|
1335 | // new_draw_info(NDI_UNIQUE, 0, op, "You can not save on unholy ground"); |
|
|
1336 | // } else |
|
|
1337 | if (!op->stats.exp) |
|
|
1338 | { |
|
|
1339 | new_draw_info (NDI_UNIQUE, 0, op, "You don't deserve to save yet."); |
|
|
1340 | } |
|
|
1341 | else |
|
|
1342 | { |
|
|
1343 | if (save_player (op, 1)) |
|
|
1344 | new_draw_info (NDI_UNIQUE, 0, op, "You have been saved."); |
|
|
1345 | else |
|
|
1346 | new_draw_info (NDI_UNIQUE, 0, op, "SAVE FAILED!"); |
|
|
1347 | } |
|
|
1348 | return 1; |
|
|
1349 | } |
|
|
1350 | |
|
|
1351 | |
|
|
1352 | int |
|
|
1353 | command_peaceful (object *op, char *params) |
1065 | command_peaceful (object *op, char *params) |
1354 | { |
1066 | { |
1355 | new_draw_info (NDI_UNIQUE, 0, op, |
1067 | new_draw_info (NDI_UNIQUE, 0, op, |
1356 | "You cannot change your peaceful setting with this command." |
1068 | "You cannot change your peaceful setting with this command." |
1357 | " Please speak to the priest in the temple of Gorokh" |
1069 | " Please speak to the priest in the temple of Gorokh" |
… | |
… | |
1364 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
1076 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
1365 | */ |
1077 | */ |
1366 | return 1; |
1078 | return 1; |
1367 | } |
1079 | } |
1368 | |
1080 | |
1369 | |
|
|
1370 | |
|
|
1371 | int |
1081 | int |
1372 | command_wimpy (object *op, char *params) |
1082 | command_wimpy (object *op, char *params) |
1373 | { |
1083 | { |
1374 | int i; |
1084 | int i; |
1375 | char buf[MAX_BUF]; |
1085 | char buf[MAX_BUF]; |
… | |
… | |
1384 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1094 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1385 | op->run_away = i; |
1095 | op->run_away = i; |
1386 | return 1; |
1096 | return 1; |
1387 | } |
1097 | } |
1388 | |
1098 | |
1389 | |
|
|
1390 | int |
1099 | int |
1391 | command_brace (object *op, char *params) |
1100 | command_brace (object *op, char *params) |
1392 | { |
1101 | { |
1393 | if (!params) |
1102 | if (!params) |
1394 | op->contr->braced = !op->contr->braced; |
1103 | op->contr->braced = !op->contr->braced; |
… | |
… | |
1398 | if (op->contr->braced) |
1107 | if (op->contr->braced) |
1399 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
1108 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
1400 | else |
1109 | else |
1401 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
1110 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
1402 | |
1111 | |
1403 | fix_player (op); |
1112 | op->update_stats (); |
1404 | return 0; |
|
|
1405 | } |
|
|
1406 | |
|
|
1407 | int |
|
|
1408 | command_style_map_info (object *op, char *params) |
|
|
1409 | { |
|
|
1410 | extern maptile *styles; |
|
|
1411 | maptile *mp; |
|
|
1412 | int maps_used = 0, mapmem = 0, objects_used = 0, x, y; |
|
|
1413 | object *tmp; |
|
|
1414 | |
|
|
1415 | for (mp = styles; mp != NULL; mp = mp->next) |
|
|
1416 | { |
|
|
1417 | maps_used++; |
|
|
1418 | mapmem += MAP_WIDTH (mp) * MAP_HEIGHT (mp) * (sizeof (object *) + sizeof (MapSpace)) + sizeof (maptile); |
|
|
1419 | for (x = 0; x < MAP_WIDTH (mp); x++) |
|
|
1420 | { |
|
|
1421 | for (y = 0; y < MAP_HEIGHT (mp); y++) |
|
|
1422 | { |
|
|
1423 | for (tmp = get_map_ob (mp, x, y); tmp != NULL; tmp = tmp->above) |
|
|
1424 | objects_used++; |
|
|
1425 | } |
|
|
1426 | } |
|
|
1427 | } |
|
|
1428 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style maps loaded: %d", maps_used); |
|
|
1429 | new_draw_info (NDI_UNIQUE, 0, op, "Memory used, not"); |
|
|
1430 | new_draw_info_format (NDI_UNIQUE, 0, op, "including objects: %d", mapmem); |
|
|
1431 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style objects: %d", objects_used); |
|
|
1432 | new_draw_info_format (NDI_UNIQUE, 0, op, "Mem for objects: %d", objects_used * sizeof (object)); |
|
|
1433 | return 0; |
1113 | return 0; |
1434 | } |
1114 | } |
1435 | |
1115 | |
1436 | int |
1116 | int |
1437 | command_kill_pets (object *op, char *params) |
1117 | command_kill_pets (object *op, char *params) |
… | |
… | |
1451 | for (obl = first_friendly_object; obl != NULL; obl = next) |
1131 | for (obl = first_friendly_object; obl != NULL; obl = next) |
1452 | { |
1132 | { |
1453 | object *ob = obl->ob; |
1133 | object *ob = obl->ob; |
1454 | |
1134 | |
1455 | next = obl->next; |
1135 | next = obl->next; |
1456 | if (get_owner (ob) == op) |
1136 | if (ob->owner == op) |
1457 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
1137 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
1458 | { |
1138 | { |
1459 | if (!QUERY_FLAG (ob, FLAG_REMOVED)) |
|
|
1460 | remove_ob (ob); |
|
|
1461 | remove_friendly_object (ob); |
|
|
1462 | free_object (ob); |
1139 | ob->destroy (); |
1463 | removecount++; |
1140 | removecount++; |
1464 | } |
1141 | } |
1465 | } |
1142 | } |
1466 | if (removecount != 0) |
1143 | if (removecount != 0) |
1467 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
1144 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |