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 |
… | |
… | |
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 | |
28 | |
30 | extern weathermap_t **weathermap; |
29 | #include <dirent.h> |
31 | |
30 | |
32 | /* Handles misc. input request - things like hash table, malloc, maps, |
31 | /* Handles misc. input request - things like hash table, malloc, maps, |
33 | * who, etc. |
32 | * who, etc. |
34 | */ |
33 | */ |
35 | |
34 | |
|
|
35 | //TODO |
|
|
36 | #if 0 |
36 | void |
37 | void |
37 | map_info (object *op, char *search) |
38 | map_info (object *op, char *search) |
38 | { |
39 | { |
39 | maptile *m; |
40 | maptile *m; |
40 | char buf[MAX_BUF], map_path[MAX_BUF]; |
41 | char buf[MAX_BUF], map_path[31]; |
41 | long sec = seconds (); |
42 | long sec = time (0); |
42 | |
43 | |
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_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 | 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 | |
46 | |
|
|
47 | for (maps_container::iterator i = maps.begin (); i != maps.end (); ++i) |
|
|
48 | { |
|
|
49 | maptile *m = i->second; |
|
|
50 | |
48 | if (search && strstr (m->path, search) == NULL) |
51 | if (search && !strstr (m->path, search)) |
49 | continue; /* Skip unwanted maps */ |
52 | continue; /* Skip unwanted maps */ |
|
|
53 | |
50 | /* Print out the last 18 characters of the map name... */ |
54 | /* Print out the last 30 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 | strcpy (map_path, m->path + max (0, (int)strlen (m->path) - 30)); |
|
|
56 | |
55 | sprintf (buf, "%-18.18s %2d %2d %1d %4d %2d %02d:%02d:%02d", |
57 | sprintf (buf, "%-30.30s %2d %2d %1d %4d %2d %02d:%02d:%02d", |
56 | map_path, m->players, players_on_map (m, FALSE), |
58 | map_path, m->players, players_on_map (m, FALSE), |
57 | m->in_memory, m->timeout, m->difficulty, |
59 | 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); |
60 | (m->reset_time % 86400) / 3600, (m->reset_time % 3600) / 60, m->reset_time % 60); |
59 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
61 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
60 | } |
62 | } |
61 | } |
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 |
62 | |
94 | |
63 | /* This command dumps the body information for object *op. |
95 | /* This command dumps the body information for object *op. |
64 | * it doesn't care what the params are. |
96 | * it doesn't care what the params are. |
65 | * This is mostly meant as a debug command. |
97 | * This is mostly meant as a debug command. |
66 | */ |
98 | */ |
… | |
… | |
149 | maptile *m = op->map; |
181 | maptile *m = op->map; |
150 | |
182 | |
151 | if (!m) |
183 | if (!m) |
152 | return; |
184 | return; |
153 | |
185 | |
154 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) in %s", m->name, m->path, get_name_of_region_for_map (m)); |
186 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) in %s", &m->name, &m->path, get_name_of_region_for_map (m)); |
155 | |
187 | |
156 | if (QUERY_FLAG (op, FLAG_WIZ)) |
188 | if (QUERY_FLAG (op, FLAG_WIZ)) |
157 | { |
189 | { |
158 | new_draw_info_format (NDI_UNIQUE, 0, op, |
190 | new_draw_info_format (NDI_UNIQUE, 0, op, |
159 | "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld", |
191 | "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)); |
192 | m->players, m->difficulty, m->width, m->height, m->enter_x, m->enter_y, m->timeout); |
161 | |
193 | |
162 | } |
194 | } |
163 | if (m->msg) |
195 | if (m->msg) |
164 | new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
196 | new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
165 | } |
197 | } |
… | |
… | |
192 | */ |
224 | */ |
193 | for (reg = first_region; reg != NULL; reg = reg->next) |
225 | for (reg = first_region; reg != NULL; reg = reg->next) |
194 | { |
226 | { |
195 | reg->counter = 0; |
227 | reg->counter = 0; |
196 | } |
228 | } |
197 | for (pl = first_player; pl != NULL; pl = pl->next) |
229 | for_all_players (pl) |
198 | if (pl->ob->map != NULL) |
230 | if (pl->ob->map != NULL) |
199 | get_region_by_map (pl->ob->map)->counter++; |
231 | get_region_by_map (pl->ob->map)->counter++; |
200 | |
232 | |
201 | /* we only want to print out by places with a 'longname' field... */ |
233 | /* we only want to print out by places with a 'longname' field... */ |
202 | for (reg = first_region; reg != NULL; reg = reg->next) |
234 | for (reg = first_region; reg != NULL; reg = reg->next) |
… | |
… | |
226 | } chars_names; |
258 | } chars_names; |
227 | |
259 | |
228 | int |
260 | int |
229 | command_afk (object *op, char *params) |
261 | command_afk (object *op, char *params) |
230 | { |
262 | { |
231 | if QUERY_FLAG |
263 | 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"); |
264 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer AFK"); |
236 | } |
|
|
237 | else |
265 | else |
238 | { |
|
|
239 | SET_FLAG (op, FLAG_AFK); |
|
|
240 | new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK"); |
266 | new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK"); |
241 | } |
267 | |
242 | return 1; |
268 | return 1; |
243 | } |
269 | } |
244 | |
270 | |
245 | int |
271 | int |
246 | command_mapinfo (object *op, char *params) |
272 | command_mapinfo (object *op, char *params) |
… | |
… | |
255 | current_region_info (op); |
281 | current_region_info (op); |
256 | return 1; |
282 | return 1; |
257 | } |
283 | } |
258 | |
284 | |
259 | int |
285 | 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) |
286 | command_time (object *op, char *params) |
268 | { |
287 | { |
269 | print_tod (op); |
288 | print_tod (op); |
270 | return 1; |
289 | return 1; |
271 | } |
290 | } |
272 | |
291 | |
273 | int |
292 | int |
274 | command_weather (object *op, char *params) |
293 | command_weather (object *op, char *params) |
275 | { |
294 | { |
|
|
295 | #if 0 |
276 | int wx, wy, temp, sky; |
296 | int wx, wy, temp, sky; |
277 | char buf[MAX_BUF]; |
297 | char buf[MAX_BUF]; |
278 | |
298 | |
279 | if (settings.dynamiclevel < 1) |
299 | if (settings.dynamiclevel < 1) |
280 | return 1; |
300 | return 1; |
… | |
… | |
396 | break; |
416 | break; |
397 | case SKY_BLIZZARD: |
417 | case SKY_BLIZZARD: |
398 | new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); |
418 | new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); |
399 | break; |
419 | break; |
400 | } |
420 | } |
|
|
421 | #endif |
401 | return 1; |
422 | return 1; |
402 | } |
423 | } |
403 | |
424 | |
404 | int |
425 | int |
405 | command_archs (object *op, char *params) |
426 | command_archs (object *op, char *params) |
… | |
… | |
463 | dump_friendly_objects (); |
484 | dump_friendly_objects (); |
464 | return 0; |
485 | return 0; |
465 | } |
486 | } |
466 | |
487 | |
467 | int |
488 | 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) |
489 | command_printlos (object *op, char *params) |
484 | { |
490 | { |
485 | if (op) |
491 | if (op) |
486 | print_los (op); |
492 | print_los (op); |
487 | return 0; |
493 | return 0; |
… | |
… | |
492 | command_version (object *op, char *params) |
498 | command_version (object *op, char *params) |
493 | { |
499 | { |
494 | version (op); |
500 | version (op); |
495 | return 0; |
501 | return 0; |
496 | } |
502 | } |
497 | |
|
|
498 | |
503 | |
499 | #ifndef BUG_LOG |
504 | #ifndef BUG_LOG |
500 | # define BUG_LOG "bug_log" |
505 | # define BUG_LOG "bug_log" |
501 | #endif |
506 | #endif |
502 | void |
507 | void |
… | |
… | |
610 | |
615 | |
611 | int |
616 | int |
612 | command_fix_me (object *op, char *params) |
617 | command_fix_me (object *op, char *params) |
613 | { |
618 | { |
614 | sum_weight (op); |
619 | sum_weight (op); |
615 | fix_player (op); |
620 | op->update_stats (); |
616 | return 1; |
621 | return 1; |
617 | } |
622 | } |
618 | |
623 | |
619 | int |
624 | int |
620 | command_players (object *op, char *paramss) |
625 | command_players (object *op, char *paramss) |
… | |
… | |
627 | t = buf + strlen (buf); |
632 | t = buf + strlen (buf); |
628 | if ((Dir = opendir (buf)) != NULL) |
633 | if ((Dir = opendir (buf)) != NULL) |
629 | { |
634 | { |
630 | const struct dirent *Entry; |
635 | const struct dirent *Entry; |
631 | |
636 | |
632 | while ((Entry = readdir (Dir)) != NULL) |
637 | while ((Entry = readdir (Dir))) |
633 | { |
638 | { |
634 | /* skip '.' , '..' */ |
639 | /* skip '.' , '..' */ |
635 | if (!((Entry->d_name[0] == '.' && Entry->d_name[1] == '\0') || |
640 | if (!((Entry->d_name[0] == '.' && Entry->d_name[1] == '\0') || |
636 | (Entry->d_name[0] == '.' && Entry->d_name[1] == '.' && Entry->d_name[2] == '\0'))) |
641 | (Entry->d_name[0] == '.' && Entry->d_name[1] == '.' && Entry->d_name[2] == '\0'))) |
637 | { |
642 | { |
… | |
… | |
785 | for (obl = first_friendly_object; obl != NULL; obl = next) |
790 | for (obl = first_friendly_object; obl != NULL; obl = next) |
786 | { |
791 | { |
787 | object *ob = obl->ob; |
792 | object *ob = obl->ob; |
788 | |
793 | |
789 | next = obl->next; |
794 | next = obl->next; |
790 | if (get_owner (ob) == op) |
795 | if (ob->owner == op) |
791 | { |
796 | { |
792 | if (target == 0) |
797 | if (target == 0) |
793 | { |
798 | { |
794 | if (counter == 0) |
799 | if (counter == 0) |
795 | new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
800 | new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
… | |
… | |
902 | char filename[MAX_BUF], line[80]; |
907 | char filename[MAX_BUF], line[80]; |
903 | int namelen, linelen = 0; |
908 | int namelen, linelen = 0; |
904 | |
909 | |
905 | switch (what) |
910 | switch (what) |
906 | { |
911 | { |
907 | case 1: |
912 | case 1: |
908 | sprintf (filename, "%s/wizhelp", settings.datadir); |
913 | sprintf (filename, "%s/wizhelp", settings.datadir); |
909 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
914 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
910 | break; |
915 | break; |
911 | case 3: |
916 | case 3: |
912 | sprintf (filename, "%s/mischelp", settings.datadir); |
917 | sprintf (filename, "%s/mischelp", settings.datadir); |
913 | new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
918 | new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
914 | break; |
919 | break; |
915 | default: |
920 | default: |
916 | sprintf (filename, "%s/help", settings.datadir); |
921 | sprintf (filename, "%s/help", settings.datadir); |
917 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
922 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
918 | break; |
923 | break; |
919 | } |
924 | } |
|
|
925 | |
920 | if (!(dirp = opendir (filename))) |
926 | if (!(dirp = opendir (filename))) |
921 | return; |
927 | return; |
922 | |
928 | |
923 | line[0] = '\0'; |
929 | line[0] = '\0'; |
924 | for (de = readdir (dirp); de; de = readdir (dirp)) |
930 | while (de = readdir (dirp)) |
925 | { |
931 | { |
926 | namelen = NAMLEN (de); |
932 | namelen = strlen (de->d_name); |
927 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
933 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
928 | continue; |
934 | continue; |
929 | linelen += namelen + 1; |
935 | linelen += namelen + 1; |
930 | if (linelen > 42) |
936 | if (linelen > 42) |
931 | { |
937 | { |
… | |
… | |
1146 | } |
1152 | } |
1147 | |
1153 | |
1148 | int |
1154 | int |
1149 | command_real_quit (object *op, char *params) |
1155 | command_real_quit (object *op, char *params) |
1150 | { |
1156 | { |
1151 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Quitting will delete your character.\nAre you sure you want to quit (y/n):"); |
1157 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Quitting will delete your character.\nAre you sure you want to quit (y/n):"); |
1152 | |
1158 | |
1153 | op->contr->state = ST_CONFIRM_QUIT; |
1159 | op->contr->ns->state = ST_CONFIRM_QUIT; |
1154 | return 1; |
1160 | return 1; |
1155 | } |
1161 | } |
1156 | |
1162 | |
1157 | /* |
1163 | /* |
1158 | * don't allow people to exit explore mode. It otherwise becomes |
1164 | * don't allow people to exit explore mode. It otherwise becomes |
… | |
… | |
1182 | } |
1188 | } |
1183 | |
1189 | |
1184 | int |
1190 | int |
1185 | command_sound (object *op, char *params) |
1191 | command_sound (object *op, char *params) |
1186 | { |
1192 | { |
1187 | if (op->contr->socket.sound) |
1193 | if (op->contr->ns->sound) |
1188 | { |
1194 | { |
1189 | op->contr->socket.sound = 0; |
1195 | op->contr->ns->sound = 0; |
1190 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
1196 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
1191 | } |
1197 | } |
1192 | else |
1198 | else |
1193 | { |
1199 | { |
1194 | op->contr->socket.sound = 1; |
1200 | op->contr->ns->sound = 1; |
1195 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
1201 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
1196 | } |
1202 | } |
1197 | return 1; |
|
|
1198 | } |
|
|
1199 | |
1203 | |
1200 | /* Perhaps these should be in player.c, but that file is |
|
|
1201 | * already a bit big. |
|
|
1202 | */ |
|
|
1203 | |
|
|
1204 | void |
|
|
1205 | receive_player_name (object *op, char k) |
|
|
1206 | { |
|
|
1207 | |
|
|
1208 | if (!check_name (op->contr, op->contr->write_buf + 1)) |
|
|
1209 | { |
|
|
1210 | get_name (op); |
|
|
1211 | return; |
|
|
1212 | } |
|
|
1213 | op->name = op->contr->write_buf + 1; |
|
|
1214 | op->name_pl = op->contr->write_buf + 1; |
|
|
1215 | new_draw_info (NDI_UNIQUE, 0, op, op->contr->write_buf); |
|
|
1216 | op->contr->name_changed = 1; |
|
|
1217 | get_password (op); |
|
|
1218 | } |
|
|
1219 | |
|
|
1220 | void |
|
|
1221 | receive_player_password (object *op, char k) |
|
|
1222 | { |
|
|
1223 | |
|
|
1224 | unsigned int pwd_len = strlen (op->contr->write_buf); |
|
|
1225 | |
|
|
1226 | if (pwd_len <= 1 || pwd_len > 17) |
|
|
1227 | { |
|
|
1228 | get_name (op); |
|
|
1229 | return; |
|
|
1230 | } |
|
|
1231 | new_draw_info (NDI_UNIQUE, 0, op, " "); /* To hide the password better */ |
|
|
1232 | |
|
|
1233 | if (checkbanned (op->name, op->contr->socket.host)) |
|
|
1234 | { |
|
|
1235 | LOG (llevInfo, "Banned player tried to add: [%s@%s]\n", &op->name, op->contr->socket.host); |
|
|
1236 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, op, "You are not allowed to play."); |
|
|
1237 | get_name (op); |
|
|
1238 | return; |
|
|
1239 | } |
|
|
1240 | |
|
|
1241 | if (op->contr->state == ST_CONFIRM_PASSWORD) |
|
|
1242 | { |
|
|
1243 | if (!check_password (op->contr->write_buf + 1, op->contr->password)) |
|
|
1244 | { |
|
|
1245 | new_draw_info (NDI_UNIQUE, 0, op, "The passwords did not match."); |
|
|
1246 | get_name (op); |
|
|
1247 | return; |
|
|
1248 | } |
|
|
1249 | clear_win_info (op); |
|
|
1250 | display_motd (op); |
|
|
1251 | new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
1252 | new_draw_info (NDI_UNIQUE, 0, op, "Welcome, Brave New Warrior!"); |
|
|
1253 | new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
1254 | Roll_Again (op); |
|
|
1255 | op->contr->state = ST_ROLL_STAT; |
|
|
1256 | return; |
|
|
1257 | } |
|
|
1258 | strcpy (op->contr->password, crypt_string (op->contr->write_buf + 1, NULL)); |
|
|
1259 | op->contr->state = ST_ROLL_STAT; |
|
|
1260 | check_login (op); |
|
|
1261 | return; |
1204 | return 1; |
1262 | } |
1205 | } |
1263 | |
|
|
1264 | |
1206 | |
1265 | int |
1207 | int |
1266 | explore_mode (void) |
1208 | explore_mode (void) |
1267 | { |
1209 | { |
1268 | player *pl; |
1210 | player *pl; |
… | |
… | |
1273 | if (pl->explore) |
1215 | if (pl->explore) |
1274 | return 1; |
1216 | return 1; |
1275 | } |
1217 | } |
1276 | return 0; |
1218 | return 0; |
1277 | } |
1219 | } |
1278 | |
|
|
1279 | |
1220 | |
1280 | int |
1221 | int |
1281 | command_title (object *op, char *params) |
1222 | command_title (object *op, char *params) |
1282 | { |
1223 | { |
1283 | char buf[MAX_BUF]; |
1224 | char buf[MAX_BUF]; |
… | |
… | |
1324 | } |
1265 | } |
1325 | |
1266 | |
1326 | int |
1267 | int |
1327 | command_save (object *op, char *params) |
1268 | command_save (object *op, char *params) |
1328 | { |
1269 | { |
1329 | // if (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) { |
|
|
1330 | // new_draw_info(NDI_UNIQUE, 0, op, "You can not save on unholy ground"); |
|
|
1331 | // } else |
|
|
1332 | if (!op->stats.exp) |
1270 | if (!op->stats.exp) |
1333 | { |
|
|
1334 | new_draw_info (NDI_UNIQUE, 0, op, "You don't deserve to save yet."); |
1271 | new_draw_info (NDI_UNIQUE, 0, op, "You don't deserve to save yet."); |
|
|
1272 | else |
1335 | } |
1273 | { |
1336 | else |
1274 | op->contr->save (); |
1337 | { |
|
|
1338 | if (save_player (op, 1)) |
|
|
1339 | new_draw_info (NDI_UNIQUE, 0, op, "You have been saved."); |
1275 | new_draw_info (NDI_UNIQUE, 0, op, "You have been saved."); |
1340 | else |
|
|
1341 | new_draw_info (NDI_UNIQUE, 0, op, "SAVE FAILED!"); |
|
|
1342 | } |
1276 | } |
1343 | return 1; |
|
|
1344 | } |
|
|
1345 | |
1277 | |
|
|
1278 | return 1; |
|
|
1279 | } |
1346 | |
1280 | |
1347 | int |
1281 | int |
1348 | command_peaceful (object *op, char *params) |
1282 | command_peaceful (object *op, char *params) |
1349 | { |
1283 | { |
1350 | new_draw_info (NDI_UNIQUE, 0, op, |
1284 | new_draw_info (NDI_UNIQUE, 0, op, |
… | |
… | |
1359 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
1293 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
1360 | */ |
1294 | */ |
1361 | return 1; |
1295 | return 1; |
1362 | } |
1296 | } |
1363 | |
1297 | |
1364 | |
|
|
1365 | |
|
|
1366 | int |
1298 | int |
1367 | command_wimpy (object *op, char *params) |
1299 | command_wimpy (object *op, char *params) |
1368 | { |
1300 | { |
1369 | int i; |
1301 | int i; |
1370 | char buf[MAX_BUF]; |
1302 | char buf[MAX_BUF]; |
… | |
… | |
1379 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1311 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1380 | op->run_away = i; |
1312 | op->run_away = i; |
1381 | return 1; |
1313 | return 1; |
1382 | } |
1314 | } |
1383 | |
1315 | |
1384 | |
|
|
1385 | int |
1316 | int |
1386 | command_brace (object *op, char *params) |
1317 | command_brace (object *op, char *params) |
1387 | { |
1318 | { |
1388 | if (!params) |
1319 | if (!params) |
1389 | op->contr->braced = !op->contr->braced; |
1320 | op->contr->braced = !op->contr->braced; |
… | |
… | |
1393 | if (op->contr->braced) |
1324 | if (op->contr->braced) |
1394 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
1325 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
1395 | else |
1326 | else |
1396 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
1327 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
1397 | |
1328 | |
1398 | fix_player (op); |
1329 | op->update_stats (); |
1399 | return 0; |
|
|
1400 | } |
|
|
1401 | |
|
|
1402 | int |
|
|
1403 | command_style_map_info (object *op, char *params) |
|
|
1404 | { |
|
|
1405 | extern maptile *styles; |
|
|
1406 | maptile *mp; |
|
|
1407 | int maps_used = 0, mapmem = 0, objects_used = 0, x, y; |
|
|
1408 | object *tmp; |
|
|
1409 | |
|
|
1410 | for (mp = styles; mp != NULL; mp = mp->next) |
|
|
1411 | { |
|
|
1412 | maps_used++; |
|
|
1413 | mapmem += MAP_WIDTH (mp) * MAP_HEIGHT (mp) * (sizeof (object *) + sizeof (MapSpace)) + sizeof (maptile); |
|
|
1414 | for (x = 0; x < MAP_WIDTH (mp); x++) |
|
|
1415 | { |
|
|
1416 | for (y = 0; y < MAP_HEIGHT (mp); y++) |
|
|
1417 | { |
|
|
1418 | for (tmp = get_map_ob (mp, x, y); tmp != NULL; tmp = tmp->above) |
|
|
1419 | objects_used++; |
|
|
1420 | } |
|
|
1421 | } |
|
|
1422 | } |
|
|
1423 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style maps loaded: %d", maps_used); |
|
|
1424 | new_draw_info (NDI_UNIQUE, 0, op, "Memory used, not"); |
|
|
1425 | new_draw_info_format (NDI_UNIQUE, 0, op, "including objects: %d", mapmem); |
|
|
1426 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style objects: %d", objects_used); |
|
|
1427 | new_draw_info_format (NDI_UNIQUE, 0, op, "Mem for objects: %d", objects_used * sizeof (object)); |
|
|
1428 | return 0; |
1330 | return 0; |
1429 | } |
1331 | } |
1430 | |
1332 | |
1431 | int |
1333 | int |
1432 | command_kill_pets (object *op, char *params) |
1334 | command_kill_pets (object *op, char *params) |
… | |
… | |
1446 | for (obl = first_friendly_object; obl != NULL; obl = next) |
1348 | for (obl = first_friendly_object; obl != NULL; obl = next) |
1447 | { |
1349 | { |
1448 | object *ob = obl->ob; |
1350 | object *ob = obl->ob; |
1449 | |
1351 | |
1450 | next = obl->next; |
1352 | next = obl->next; |
1451 | if (get_owner (ob) == op) |
1353 | if (ob->owner == op) |
1452 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
1354 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
1453 | { |
1355 | { |
1454 | if (!QUERY_FLAG (ob, FLAG_REMOVED)) |
|
|
1455 | remove_ob (ob); |
|
|
1456 | remove_friendly_object (ob); |
|
|
1457 | free_object (ob); |
1356 | ob->destroy (); |
1458 | removecount++; |
1357 | removecount++; |
1459 | } |
1358 | } |
1460 | } |
1359 | } |
1461 | if (removecount != 0) |
1360 | if (removecount != 0) |
1462 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
1361 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |