… | |
… | |
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 | /* Handles misc. input request - things like hash table, malloc, maps, |
29 | /* Handles misc. input request - things like hash table, malloc, maps, etc */ |
30 | * who, etc. |
|
|
31 | */ |
|
|
32 | |
|
|
33 | /* This command dumps the body information for object *op. |
|
|
34 | * it doesn't care what the params are. |
|
|
35 | * This is mostly meant as a debug command. |
|
|
36 | */ |
|
|
37 | int |
|
|
38 | command_body (object *op, char *params) |
|
|
39 | { |
|
|
40 | int i; |
|
|
41 | |
|
|
42 | /* Too hard to try and make a header that lines everything up, so just |
|
|
43 | * give a description. |
|
|
44 | */ |
|
|
45 | new_draw_info (NDI_UNIQUE, 0, op, "The first column is the name of the body location."); |
|
|
46 | new_draw_info (NDI_UNIQUE, 0, op, "The second column is how many of those locations your body has."); |
|
|
47 | new_draw_info (NDI_UNIQUE, 0, op, "The third column is how many slots in that location are available."); |
|
|
48 | for (i = 0; i < NUM_BODY_LOCATIONS; i++) |
|
|
49 | { |
|
|
50 | /* really debugging - normally body_used should not be set to anything |
|
|
51 | * if body_info isn't also set. |
|
|
52 | */ |
|
|
53 | if (op->body_info[i] || op->body_used[i]) |
|
|
54 | { |
|
|
55 | new_draw_info_format (NDI_UNIQUE, 0, op, "%-30s %5d %5d", body_locations[i].use_name, op->body_info[i], op->body_used[i]); |
|
|
56 | } |
|
|
57 | } |
|
|
58 | if (!QUERY_FLAG (op, FLAG_USE_ARMOUR)) |
|
|
59 | new_draw_info (NDI_UNIQUE, 0, op, "You are not allowed to wear armor"); |
|
|
60 | if (!QUERY_FLAG (op, FLAG_USE_WEAPON)) |
|
|
61 | new_draw_info (NDI_UNIQUE, 0, op, "You are not allowed to use weapons"); |
|
|
62 | |
|
|
63 | return 1; |
|
|
64 | } |
|
|
65 | |
|
|
66 | |
30 | |
67 | int |
31 | int |
68 | command_motd (object *op, char *params) |
32 | command_motd (object *op, char *params) |
69 | { |
33 | { |
70 | display_motd (op); |
34 | display_motd (op); |
71 | return 1; |
35 | return 1; |
72 | } |
36 | } |
73 | |
37 | |
74 | /* |
|
|
75 | * Pretty much identical to current map_info, but on a bigger scale |
|
|
76 | * This function returns the name of the players current region, and |
|
|
77 | * a description of it. It is there merely for flavour text. |
|
|
78 | */ |
|
|
79 | void |
|
|
80 | current_region_info (object *op) |
|
|
81 | { |
|
|
82 | if (region *reg = op->region ()) |
|
|
83 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are %s.\n%s", ®->longname, ®->msg); |
|
|
84 | } |
|
|
85 | |
|
|
86 | void |
|
|
87 | current_map_info (object *op) |
|
|
88 | { |
|
|
89 | maptile *m = op->map; |
|
|
90 | |
|
|
91 | if (!m) |
|
|
92 | return; |
|
|
93 | |
|
|
94 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) %s", &m->name, &m->path, &op->region ()->longname); |
|
|
95 | |
|
|
96 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
97 | new_draw_info_format (NDI_UNIQUE, 0, op, |
|
|
98 | "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld", |
|
|
99 | m->players, m->difficulty, m->width, m->height, m->enter_x, m->enter_y, m->timeout); |
|
|
100 | |
|
|
101 | if (m->msg) |
|
|
102 | new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
|
|
103 | } |
|
|
104 | |
|
|
105 | #ifdef DEBUG_MALLOC_LEVEL |
38 | #ifdef DEBUG_MALLOC_LEVEL |
106 | int |
39 | int |
107 | command_malloc_verify (object *op, char *parms) |
40 | command_malloc_verify (object *op, char *parms) |
108 | { |
41 | { |
109 | extern int malloc_verify (void); |
42 | extern int malloc_verify (void); |
110 | |
43 | |
111 | if (!malloc_verify ()) |
44 | if (!malloc_verify ()) |
112 | new_draw_info (NDI_UNIQUE, 0, op, "Heap is corrupted."); |
45 | new_draw_info (NDI_UNIQUE, 0, op, "Heap is corrupted."); |
113 | else |
46 | else |
114 | new_draw_info (NDI_UNIQUE, 0, op, "Heap checks out OK."); |
47 | new_draw_info (NDI_UNIQUE, 0, op, "Heap checks out OK."); |
115 | return 1; |
48 | return 1; |
… | |
… | |
159 | typedef struct |
92 | typedef struct |
160 | { |
93 | { |
161 | char namebuf[MAX_BUF]; |
94 | char namebuf[MAX_BUF]; |
162 | int login_order; |
95 | int login_order; |
163 | } chars_names; |
96 | } chars_names; |
164 | |
|
|
165 | int |
|
|
166 | command_afk (object *op, char *params) |
|
|
167 | { |
|
|
168 | if ((op->contr->ns->afk = !op->contr->ns->afk)) |
|
|
169 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer AFK"); |
|
|
170 | else |
|
|
171 | new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK"); |
|
|
172 | |
|
|
173 | return 1; |
|
|
174 | } |
|
|
175 | |
|
|
176 | int |
|
|
177 | command_mapinfo (object *op, char *params) |
|
|
178 | { |
|
|
179 | current_map_info (op); |
|
|
180 | return 1; |
|
|
181 | } |
|
|
182 | |
|
|
183 | int |
|
|
184 | command_whereami (object *op, char *params) |
|
|
185 | { |
|
|
186 | current_region_info (op); |
|
|
187 | return 1; |
|
|
188 | } |
|
|
189 | |
97 | |
190 | int |
98 | int |
191 | command_time (object *op, char *params) |
99 | command_time (object *op, char *params) |
192 | { |
100 | { |
193 | print_tod (op); |
101 | print_tod (op); |
… | |
… | |
344 | { |
252 | { |
345 | sprintf (buf, "Global debug level is %d.", settings.debug); |
253 | sprintf (buf, "Global debug level is %d.", settings.debug); |
346 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
254 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
347 | return 1; |
255 | return 1; |
348 | } |
256 | } |
349 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
|
|
350 | { |
|
|
351 | new_draw_info (NDI_UNIQUE, 0, op, "Privileged command."); |
|
|
352 | return 1; |
|
|
353 | } |
|
|
354 | settings.debug = (enum LogLevel) FABS (i); |
257 | settings.debug = (enum LogLevel) FABS (i); |
355 | sprintf (buf, "Set debug level to %d.", i); |
258 | sprintf (buf, "Set debug level to %d.", i); |
356 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
259 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
357 | return 1; |
260 | return 1; |
358 | } |
261 | } |
… | |
… | |
414 | } |
317 | } |
415 | else |
318 | else |
416 | { |
319 | { |
417 | LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno)); |
320 | LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno)); |
418 | } |
321 | } |
419 | } |
|
|
420 | |
|
|
421 | int |
|
|
422 | command_output_sync (object *op, char *params) |
|
|
423 | { |
|
|
424 | int val; |
|
|
425 | |
|
|
426 | if (!params) |
|
|
427 | { |
|
|
428 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time is presently %d", op->contr->outputs_sync); |
|
|
429 | return 1; |
|
|
430 | } |
|
|
431 | val = atoi (params); |
|
|
432 | if (val > 0) |
|
|
433 | { |
|
|
434 | op->contr->outputs_sync = val; |
|
|
435 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time now set to %d", op->contr->outputs_sync); |
|
|
436 | } |
|
|
437 | else |
|
|
438 | new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_sync."); |
|
|
439 | |
|
|
440 | return 1; |
|
|
441 | } |
|
|
442 | |
|
|
443 | int |
|
|
444 | command_output_count (object *op, char *params) |
|
|
445 | { |
|
|
446 | int val; |
|
|
447 | |
|
|
448 | if (!params) |
|
|
449 | { |
|
|
450 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output count is presently %d", op->contr->outputs_count); |
|
|
451 | return 1; |
|
|
452 | } |
|
|
453 | val = atoi (params); |
|
|
454 | if (val > 0) |
|
|
455 | { |
|
|
456 | op->contr->outputs_count = val; |
|
|
457 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output count now set to %d", op->contr->outputs_count); |
|
|
458 | } |
|
|
459 | else |
|
|
460 | new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_count."); |
|
|
461 | |
|
|
462 | return 1; |
|
|
463 | } |
|
|
464 | |
|
|
465 | int |
|
|
466 | command_listen (object *op, char *params) |
|
|
467 | { |
|
|
468 | int i; |
|
|
469 | |
|
|
470 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
471 | { |
|
|
472 | new_draw_info_format (NDI_UNIQUE, 0, op, "Set listen to what (presently %d)?", op->contr->listening); |
|
|
473 | return 1; |
|
|
474 | } |
|
|
475 | op->contr->listening = (char) i; |
|
|
476 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your verbose level is now %d.", i); |
|
|
477 | return 1; |
|
|
478 | } |
322 | } |
479 | |
323 | |
480 | /* Prints out some useful information for the character. Everything we print |
324 | /* Prints out some useful information for the character. Everything we print |
481 | * out can be determined by the docs, so we aren't revealing anything extra - |
325 | * out can be determined by the docs, so we aren't revealing anything extra - |
482 | * rather, we are making it convenient to find the values. params have |
326 | * rather, we are making it convenient to find the values. params have |
… | |
… | |
514 | int |
358 | int |
515 | command_fix_me (object *op, char *params) |
359 | command_fix_me (object *op, char *params) |
516 | { |
360 | { |
517 | sum_weight (op); |
361 | sum_weight (op); |
518 | op->update_stats (); |
362 | op->update_stats (); |
|
|
363 | new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed."); |
|
|
364 | |
519 | return 1; |
365 | return 1; |
520 | } |
366 | } |
521 | |
367 | |
522 | int |
368 | int |
523 | command_logs (object *op, char *params) |
369 | command_logs (object *op, char *params) |
524 | { |
370 | { |
525 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
371 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
526 | |
372 | |
527 | return 1; |
|
|
528 | } |
|
|
529 | |
|
|
530 | int |
|
|
531 | command_applymode (object *op, char *params) |
|
|
532 | { |
|
|
533 | unapplymode unapply = op->contr->unapply; |
|
|
534 | static const char *const types[] = { "nochoice", "never", "always" }; |
|
|
535 | |
|
|
536 | if (!params) |
|
|
537 | { |
|
|
538 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode is set to %s", types[op->contr->unapply]); |
|
|
539 | return 1; |
|
|
540 | } |
|
|
541 | |
|
|
542 | if (!strcmp (params, "nochoice")) |
|
|
543 | op->contr->unapply = unapply_nochoice; |
|
|
544 | else if (!strcmp (params, "never")) |
|
|
545 | op->contr->unapply = unapply_never; |
|
|
546 | else if (!strcmp (params, "always")) |
|
|
547 | op->contr->unapply = unapply_always; |
|
|
548 | else |
|
|
549 | { |
|
|
550 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params); |
|
|
551 | return 0; |
|
|
552 | } |
|
|
553 | |
|
|
554 | new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s", |
|
|
555 | (unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]); |
|
|
556 | return 1; |
373 | return 1; |
557 | } |
374 | } |
558 | |
375 | |
559 | int |
376 | int |
560 | command_bowmode (object *op, char *params) |
377 | command_bowmode (object *op, char *params) |
… | |
… | |
598 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
415 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
599 | return 0; |
416 | return 0; |
600 | } |
417 | } |
601 | |
418 | |
602 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
419 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
603 | return 1; |
|
|
604 | } |
|
|
605 | |
|
|
606 | int |
|
|
607 | command_petmode (object *op, char *params) |
|
|
608 | { |
|
|
609 | petmode_t oldtype = op->contr->petmode; |
|
|
610 | static const char *const types[] = { "normal", "sad", "defend", "arena" }; |
|
|
611 | |
|
|
612 | if (!params) |
|
|
613 | { |
|
|
614 | new_draw_info_format (NDI_UNIQUE, 0, op, "petmode is set to %s", types[op->contr->petmode]); |
|
|
615 | return 1; |
|
|
616 | } |
|
|
617 | |
|
|
618 | if (!strcmp (params, "normal")) |
|
|
619 | op->contr->petmode = pet_normal; |
|
|
620 | else if (!strcmp (params, "sad")) |
|
|
621 | op->contr->petmode = pet_sad; |
|
|
622 | else if (!strcmp (params, "defend")) |
|
|
623 | op->contr->petmode = pet_defend; |
|
|
624 | else if (!strcmp (params, "arena")) |
|
|
625 | op->contr->petmode = pet_arena; |
|
|
626 | else |
|
|
627 | { |
|
|
628 | new_draw_info_format (NDI_UNIQUE, 0, op, |
|
|
629 | "petmode: Unknown options %s, valid options are normal," "sad (seek and destroy), defend, arena", params); |
|
|
630 | return 0; |
|
|
631 | } |
|
|
632 | new_draw_info_format (NDI_UNIQUE, 0, op, "petmode %s set to %s", (oldtype == op->contr->petmode ? "" : "now"), types[op->contr->petmode]); |
|
|
633 | return 1; |
420 | return 1; |
634 | } |
421 | } |
635 | |
422 | |
636 | int |
423 | int |
637 | command_showpets (object *op, char *params) |
424 | command_showpets (object *op, char *params) |
… | |
… | |
678 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
465 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
679 | return 0; |
466 | return 0; |
680 | } |
467 | } |
681 | |
468 | |
682 | int |
469 | int |
683 | command_usekeys (object *op, char *params) |
|
|
684 | { |
|
|
685 | usekeytype oldtype = op->contr->usekeys; |
|
|
686 | static const char *const types[] = { "inventory", "keyrings", "containers" }; |
|
|
687 | |
|
|
688 | if (!params) |
|
|
689 | { |
|
|
690 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys is set to %s", types[op->contr->usekeys]); |
|
|
691 | return 1; |
|
|
692 | } |
|
|
693 | |
|
|
694 | if (!strcmp (params, "inventory")) |
|
|
695 | op->contr->usekeys = key_inventory; |
|
|
696 | else if (!strcmp (params, "keyrings")) |
|
|
697 | op->contr->usekeys = keyrings; |
|
|
698 | else if (!strcmp (params, "containers")) |
|
|
699 | op->contr->usekeys = containers; |
|
|
700 | else |
|
|
701 | { |
|
|
702 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys: Unknown options %s, valid options are inventory, keyrings, containers", params); |
|
|
703 | return 0; |
|
|
704 | } |
|
|
705 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys %s set to %s", (oldtype == op->contr->usekeys ? "" : "now"), types[op->contr->usekeys]); |
|
|
706 | return 1; |
|
|
707 | } |
|
|
708 | |
|
|
709 | int |
|
|
710 | command_resistances (object *op, char *params) |
470 | command_resistances (object *op, char *params) |
711 | { |
471 | { |
712 | int i; |
472 | int i; |
713 | |
473 | |
714 | if (!op) |
474 | if (!op) |
… | |
… | |
750 | |
510 | |
751 | /* |
511 | /* |
752 | * Actual commands. |
512 | * Actual commands. |
753 | * Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
513 | * Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
754 | */ |
514 | */ |
755 | |
|
|
756 | |
|
|
757 | static void |
|
|
758 | help_topics (object *op, int what) |
|
|
759 | { |
|
|
760 | DIR *dirp; |
|
|
761 | struct dirent *de; |
|
|
762 | char filename[MAX_BUF], line[80]; |
|
|
763 | int namelen, linelen = 0; |
|
|
764 | |
|
|
765 | switch (what) |
|
|
766 | { |
|
|
767 | case 1: |
|
|
768 | sprintf (filename, "%s/wizhelp", settings.datadir); |
|
|
769 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
|
|
770 | break; |
|
|
771 | case 3: |
|
|
772 | sprintf (filename, "%s/mischelp", settings.datadir); |
|
|
773 | new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
|
|
774 | break; |
|
|
775 | default: |
|
|
776 | sprintf (filename, "%s/help", settings.datadir); |
|
|
777 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
|
|
778 | break; |
|
|
779 | } |
|
|
780 | |
|
|
781 | if (!(dirp = opendir (filename))) |
|
|
782 | return; |
|
|
783 | |
|
|
784 | line[0] = '\0'; |
|
|
785 | while ((de = readdir (dirp))) |
|
|
786 | { |
|
|
787 | namelen = strlen (de->d_name); |
|
|
788 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
|
|
789 | continue; |
|
|
790 | linelen += namelen + 1; |
|
|
791 | if (linelen > 42) |
|
|
792 | { |
|
|
793 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
794 | sprintf (line, " %s", de->d_name); |
|
|
795 | linelen = namelen + 1; |
|
|
796 | continue; |
|
|
797 | } |
|
|
798 | strcat (line, " "); |
|
|
799 | strcat (line, de->d_name); |
|
|
800 | } |
|
|
801 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
802 | closedir (dirp); |
|
|
803 | } |
|
|
804 | |
|
|
805 | static void |
|
|
806 | show_commands (object *op, int what) |
|
|
807 | { |
|
|
808 | char line[80]; |
|
|
809 | int i, size, namelen, linelen = 0; |
|
|
810 | CommArray_s *ap; |
|
|
811 | extern CommArray_s Commands[], WizCommands[]; |
|
|
812 | extern const int CommandsSize, WizCommandsSize; |
|
|
813 | |
|
|
814 | switch (what) |
|
|
815 | { |
|
|
816 | case 1: |
|
|
817 | ap = WizCommands; |
|
|
818 | size = WizCommandsSize; |
|
|
819 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
|
|
820 | break; |
|
|
821 | case 2: |
|
|
822 | ap = CommunicationCommands; |
|
|
823 | size = CommunicationCommandSize; |
|
|
824 | new_draw_info (NDI_UNIQUE, 0, op, " Communication commands:"); |
|
|
825 | break; |
|
|
826 | default: |
|
|
827 | ap = Commands; |
|
|
828 | size = CommandsSize; |
|
|
829 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
|
|
830 | break; |
|
|
831 | } |
|
|
832 | |
|
|
833 | line[0] = '\0'; |
|
|
834 | for (i = 0; i < size; i++) |
|
|
835 | { |
|
|
836 | namelen = strlen (ap[i].name); |
|
|
837 | linelen += namelen + 1; |
|
|
838 | if (linelen > 42) |
|
|
839 | { |
|
|
840 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
841 | sprintf (line, " %s", ap[i].name); |
|
|
842 | linelen = namelen + 1; |
|
|
843 | continue; |
|
|
844 | } |
|
|
845 | strcat (line, " "); |
|
|
846 | strcat (line, ap[i].name); |
|
|
847 | } |
|
|
848 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
849 | } |
|
|
850 | |
|
|
851 | |
|
|
852 | int |
|
|
853 | command_help (object *op, char *params) |
|
|
854 | { |
|
|
855 | struct stat st; |
|
|
856 | FILE *fp; |
|
|
857 | char filename[MAX_BUF], line[MAX_BUF]; |
|
|
858 | int len; |
|
|
859 | |
|
|
860 | if (op != NULL) |
|
|
861 | clear_win_info (op); |
|
|
862 | |
|
|
863 | /* |
|
|
864 | * Main help page? |
|
|
865 | */ |
|
|
866 | if (!params) |
|
|
867 | { |
|
|
868 | sprintf (filename, "%s/def_help", settings.datadir); |
|
|
869 | if ((fp = fopen (filename, "r")) == NULL) |
|
|
870 | { |
|
|
871 | LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
|
|
872 | return 0; |
|
|
873 | } |
|
|
874 | while (fgets (line, MAX_BUF, fp)) |
|
|
875 | { |
|
|
876 | line[MAX_BUF - 1] = '\0'; |
|
|
877 | len = strlen (line) - 1; |
|
|
878 | if (line[len] == '\n') |
|
|
879 | line[len] = '\0'; |
|
|
880 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
881 | } |
|
|
882 | fclose (fp); |
|
|
883 | return 0; |
|
|
884 | } |
|
|
885 | |
|
|
886 | /* |
|
|
887 | * Topics list |
|
|
888 | */ |
|
|
889 | if (!strcmp (params, "topics")) |
|
|
890 | { |
|
|
891 | help_topics (op, 3); |
|
|
892 | help_topics (op, 0); |
|
|
893 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
894 | help_topics (op, 1); |
|
|
895 | return 0; |
|
|
896 | } |
|
|
897 | |
|
|
898 | /* |
|
|
899 | * Commands list |
|
|
900 | */ |
|
|
901 | if (!strcmp (params, "commands")) |
|
|
902 | { |
|
|
903 | show_commands (op, 0); |
|
|
904 | show_commands (op, 2); /* show comm commands */ |
|
|
905 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
906 | show_commands (op, 1); |
|
|
907 | return 0; |
|
|
908 | } |
|
|
909 | |
|
|
910 | /* |
|
|
911 | * User wants info about command |
|
|
912 | */ |
|
|
913 | if (strchr (params, '.') || strchr (params, ' ') || strchr (params, '/')) |
|
|
914 | { |
|
|
915 | sprintf (line, "Illegal characters in '%s'", params); |
|
|
916 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
917 | return 0; |
|
|
918 | } |
|
|
919 | |
|
|
920 | sprintf (filename, "%s/mischelp/%s", settings.datadir, params); |
|
|
921 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
922 | { |
|
|
923 | if (op) |
|
|
924 | { |
|
|
925 | sprintf (filename, "%s/help/%s", settings.datadir, params); |
|
|
926 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
927 | { |
|
|
928 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
929 | { |
|
|
930 | sprintf (filename, "%s/wizhelp/%s", settings.datadir, params); |
|
|
931 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
932 | goto nohelp; |
|
|
933 | } |
|
|
934 | else |
|
|
935 | goto nohelp; |
|
|
936 | } |
|
|
937 | } |
|
|
938 | } |
|
|
939 | |
|
|
940 | /* |
|
|
941 | * Found that. Just cat it to screen. |
|
|
942 | */ |
|
|
943 | if ((fp = fopen (filename, "r")) == NULL) |
|
|
944 | { |
|
|
945 | LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
|
|
946 | return 0; |
|
|
947 | } |
|
|
948 | sprintf (line, "Help about '%s'", params); |
|
|
949 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
950 | while (fgets (line, MAX_BUF, fp)) |
|
|
951 | { |
|
|
952 | line[MAX_BUF - 1] = '\0'; |
|
|
953 | len = strlen (line) - 1; |
|
|
954 | if (line[len] == '\n') |
|
|
955 | line[len] = '\0'; |
|
|
956 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
957 | } |
|
|
958 | fclose (fp); |
|
|
959 | return 0; |
|
|
960 | |
|
|
961 | /* |
|
|
962 | * No_help -escape |
|
|
963 | */ |
|
|
964 | nohelp: |
|
|
965 | sprintf (line, "No help available on '%s'", params); |
|
|
966 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
967 | return 0; |
|
|
968 | } |
|
|
969 | |
|
|
970 | |
515 | |
971 | int |
516 | int |
972 | onoff_value (const char *line) |
517 | onoff_value (const char *line) |
973 | { |
518 | { |
974 | int i; |
519 | int i; |
… | |
… | |
997 | return 0; |
542 | return 0; |
998 | } |
543 | } |
999 | } |
544 | } |
1000 | |
545 | |
1001 | int |
546 | int |
1002 | command_sound (object *op, char *params) |
|
|
1003 | { |
|
|
1004 | if (op->contr->ns->sound) |
|
|
1005 | { |
|
|
1006 | op->contr->ns->sound = 0; |
|
|
1007 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
|
|
1008 | } |
|
|
1009 | else |
|
|
1010 | { |
|
|
1011 | op->contr->ns->sound = 1; |
|
|
1012 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
|
|
1013 | } |
|
|
1014 | |
|
|
1015 | return 1; |
|
|
1016 | } |
|
|
1017 | |
|
|
1018 | int |
|
|
1019 | command_title (object *op, char *params) |
547 | command_title (object *op, char *params) |
1020 | { |
548 | { |
1021 | char buf[MAX_BUF]; |
549 | char buf[MAX_BUF]; |
1022 | |
550 | |
1023 | if (settings.set_title == FALSE) |
551 | if (settings.set_title == FALSE) |
… | |
… | |
1060 | strcpy (op->contr->own_title, params); |
588 | strcpy (op->contr->own_title, params); |
1061 | return 1; |
589 | return 1; |
1062 | } |
590 | } |
1063 | |
591 | |
1064 | int |
592 | int |
1065 | command_peaceful (object *op, char *params) |
|
|
1066 | { |
|
|
1067 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1068 | "You cannot change your peaceful setting with this command." |
|
|
1069 | " Please speak to the priest in the temple of Gorokh" |
|
|
1070 | " if you want to become hostile or in temple of Valriel" " if you want to become peaceful again."); |
|
|
1071 | |
|
|
1072 | /* |
|
|
1073 | if((op->contr->peaceful=!op->contr->peaceful)) |
|
|
1074 | new_draw_info(NDI_UNIQUE, 0,op,"You will not attack other players."); |
|
|
1075 | else |
|
|
1076 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
|
|
1077 | */ |
|
|
1078 | return 1; |
|
|
1079 | } |
|
|
1080 | |
|
|
1081 | int |
|
|
1082 | command_wimpy (object *op, char *params) |
|
|
1083 | { |
|
|
1084 | int i; |
|
|
1085 | char buf[MAX_BUF]; |
|
|
1086 | |
|
|
1087 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
1088 | { |
|
|
1089 | sprintf (buf, "Your current wimpy level is %d.", op->run_away); |
|
|
1090 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1091 | return 1; |
|
|
1092 | } |
|
|
1093 | sprintf (buf, "Your new wimpy level is %d.", i); |
|
|
1094 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1095 | op->run_away = i; |
|
|
1096 | return 1; |
|
|
1097 | } |
|
|
1098 | |
|
|
1099 | int |
|
|
1100 | command_brace (object *op, char *params) |
|
|
1101 | { |
|
|
1102 | if (!params) |
|
|
1103 | op->contr->braced = !op->contr->braced; |
|
|
1104 | else |
|
|
1105 | op->contr->braced = onoff_value (params); |
|
|
1106 | |
|
|
1107 | if (op->contr->braced) |
|
|
1108 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
|
|
1109 | else |
|
|
1110 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
|
|
1111 | |
|
|
1112 | op->update_stats (); |
|
|
1113 | return 0; |
|
|
1114 | } |
|
|
1115 | |
|
|
1116 | int |
|
|
1117 | command_kill_pets (object *op, char *params) |
593 | command_kill_pets (object *op, char *params) |
1118 | { |
594 | { |
1119 | objectlink *obl, *next; |
595 | objectlink *obl, *next; |
1120 | int counter = 0, removecount = 0; |
596 | int counter = 0, removecount = 0; |
1121 | |
597 | |
1122 | if (params == NULL) |
598 | if (!params) |
1123 | { |
599 | { |
1124 | terminate_all_pets (op); |
600 | terminate_all_pets (op); |
1125 | new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); |
601 | new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); |
1126 | } |
602 | } |
1127 | else |
603 | else |
1128 | { |
604 | { |
1129 | int target = atoi (params); |
605 | int target = atoi (params); |
1130 | |
606 | |
1131 | for (obl = first_friendly_object; obl != NULL; obl = next) |
607 | for (obl = first_friendly_object; obl; obl = next) |
1132 | { |
608 | { |
1133 | object *ob = obl->ob; |
609 | object *ob = obl->ob; |
1134 | |
610 | |
1135 | next = obl->next; |
611 | next = obl->next; |
|
|
612 | |
1136 | if (ob->owner == op) |
613 | if (ob->owner == op) |
1137 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
614 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
1138 | { |
615 | { |
1139 | ob->destroy (); |
616 | ob->destroy (); |
1140 | removecount++; |
617 | removecount++; |
1141 | } |
618 | } |
1142 | } |
619 | } |
|
|
620 | |
1143 | if (removecount != 0) |
621 | if (removecount != 0) |
1144 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
622 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
1145 | else |
623 | else |
1146 | new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
624 | new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
1147 | } |
625 | } |
|
|
626 | |
1148 | return 0; |
627 | return 0; |
1149 | } |
628 | } |