… | |
… | |
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_mapinfo (object *op, char *params) |
|
|
167 | { |
|
|
168 | current_map_info (op); |
|
|
169 | return 1; |
|
|
170 | } |
|
|
171 | |
|
|
172 | int |
|
|
173 | command_whereami (object *op, char *params) |
|
|
174 | { |
|
|
175 | current_region_info (op); |
|
|
176 | return 1; |
|
|
177 | } |
|
|
178 | |
97 | |
179 | int |
98 | int |
180 | command_time (object *op, char *params) |
99 | command_time (object *op, char *params) |
181 | { |
100 | { |
182 | print_tod (op); |
101 | print_tod (op); |
… | |
… | |
398 | } |
317 | } |
399 | else |
318 | else |
400 | { |
319 | { |
401 | 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)); |
402 | } |
321 | } |
403 | } |
|
|
404 | |
|
|
405 | int |
|
|
406 | command_output_sync (object *op, char *params) |
|
|
407 | { |
|
|
408 | int val; |
|
|
409 | |
|
|
410 | if (!params) |
|
|
411 | { |
|
|
412 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time is presently %d", op->contr->outputs_sync); |
|
|
413 | return 1; |
|
|
414 | } |
|
|
415 | val = atoi (params); |
|
|
416 | if (val > 0) |
|
|
417 | { |
|
|
418 | op->contr->outputs_sync = val; |
|
|
419 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time now set to %d", op->contr->outputs_sync); |
|
|
420 | } |
|
|
421 | else |
|
|
422 | new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_sync."); |
|
|
423 | |
|
|
424 | return 1; |
|
|
425 | } |
|
|
426 | |
|
|
427 | int |
|
|
428 | command_output_count (object *op, char *params) |
|
|
429 | { |
|
|
430 | int val; |
|
|
431 | |
|
|
432 | if (!params) |
|
|
433 | { |
|
|
434 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output count is presently %d", op->contr->outputs_count); |
|
|
435 | return 1; |
|
|
436 | } |
|
|
437 | val = atoi (params); |
|
|
438 | if (val > 0) |
|
|
439 | { |
|
|
440 | op->contr->outputs_count = val; |
|
|
441 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output count now set to %d", op->contr->outputs_count); |
|
|
442 | } |
|
|
443 | else |
|
|
444 | new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_count."); |
|
|
445 | |
|
|
446 | return 1; |
|
|
447 | } |
|
|
448 | |
|
|
449 | int |
|
|
450 | command_listen (object *op, char *params) |
|
|
451 | { |
|
|
452 | int i; |
|
|
453 | |
|
|
454 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
455 | { |
|
|
456 | new_draw_info_format (NDI_UNIQUE, 0, op, "Set listen to what (presently %d)?", op->contr->listening); |
|
|
457 | return 1; |
|
|
458 | } |
|
|
459 | op->contr->listening = (char) i; |
|
|
460 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your verbose level is now %d.", i); |
|
|
461 | return 1; |
|
|
462 | } |
322 | } |
463 | |
323 | |
464 | /* Prints out some useful information for the character. Everything we print |
324 | /* Prints out some useful information for the character. Everything we print |
465 | * 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 - |
466 | * 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 |
… | |
… | |
498 | int |
358 | int |
499 | command_fix_me (object *op, char *params) |
359 | command_fix_me (object *op, char *params) |
500 | { |
360 | { |
501 | sum_weight (op); |
361 | sum_weight (op); |
502 | op->update_stats (); |
362 | op->update_stats (); |
|
|
363 | new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed."); |
|
|
364 | |
503 | return 1; |
365 | return 1; |
504 | } |
366 | } |
505 | |
367 | |
506 | int |
368 | int |
507 | command_logs (object *op, char *params) |
369 | command_logs (object *op, char *params) |
508 | { |
370 | { |
509 | 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."); |
510 | |
372 | |
511 | return 1; |
|
|
512 | } |
|
|
513 | |
|
|
514 | int |
|
|
515 | command_applymode (object *op, char *params) |
|
|
516 | { |
|
|
517 | unapplymode unapply = op->contr->unapply; |
|
|
518 | static const char *const types[] = { "nochoice", "never", "always" }; |
|
|
519 | |
|
|
520 | if (!params) |
|
|
521 | { |
|
|
522 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode is set to %s", types[op->contr->unapply]); |
|
|
523 | return 1; |
|
|
524 | } |
|
|
525 | |
|
|
526 | if (!strcmp (params, "nochoice")) |
|
|
527 | op->contr->unapply = unapply_nochoice; |
|
|
528 | else if (!strcmp (params, "never")) |
|
|
529 | op->contr->unapply = unapply_never; |
|
|
530 | else if (!strcmp (params, "always")) |
|
|
531 | op->contr->unapply = unapply_always; |
|
|
532 | else |
|
|
533 | { |
|
|
534 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params); |
|
|
535 | return 0; |
|
|
536 | } |
|
|
537 | |
|
|
538 | new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s", |
|
|
539 | (unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]); |
|
|
540 | return 1; |
373 | return 1; |
541 | } |
374 | } |
542 | |
375 | |
543 | int |
376 | int |
544 | command_bowmode (object *op, char *params) |
377 | command_bowmode (object *op, char *params) |
… | |
… | |
582 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
415 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
583 | return 0; |
416 | return 0; |
584 | } |
417 | } |
585 | |
418 | |
586 | 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]); |
587 | return 1; |
|
|
588 | } |
|
|
589 | |
|
|
590 | int |
|
|
591 | command_petmode (object *op, char *params) |
|
|
592 | { |
|
|
593 | petmode_t oldtype = op->contr->petmode; |
|
|
594 | static const char *const types[] = { "normal", "sad", "defend", "arena" }; |
|
|
595 | |
|
|
596 | if (!params) |
|
|
597 | { |
|
|
598 | new_draw_info_format (NDI_UNIQUE, 0, op, "petmode is set to %s", types[op->contr->petmode]); |
|
|
599 | return 1; |
|
|
600 | } |
|
|
601 | |
|
|
602 | if (!strcmp (params, "normal")) |
|
|
603 | op->contr->petmode = pet_normal; |
|
|
604 | else if (!strcmp (params, "sad")) |
|
|
605 | op->contr->petmode = pet_sad; |
|
|
606 | else if (!strcmp (params, "defend")) |
|
|
607 | op->contr->petmode = pet_defend; |
|
|
608 | else if (!strcmp (params, "arena")) |
|
|
609 | op->contr->petmode = pet_arena; |
|
|
610 | else |
|
|
611 | { |
|
|
612 | new_draw_info_format (NDI_UNIQUE, 0, op, |
|
|
613 | "petmode: Unknown options %s, valid options are normal," "sad (seek and destroy), defend, arena", params); |
|
|
614 | return 0; |
|
|
615 | } |
|
|
616 | new_draw_info_format (NDI_UNIQUE, 0, op, "petmode %s set to %s", (oldtype == op->contr->petmode ? "" : "now"), types[op->contr->petmode]); |
|
|
617 | return 1; |
420 | return 1; |
618 | } |
421 | } |
619 | |
422 | |
620 | int |
423 | int |
621 | command_showpets (object *op, char *params) |
424 | command_showpets (object *op, char *params) |
… | |
… | |
662 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
465 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
663 | return 0; |
466 | return 0; |
664 | } |
467 | } |
665 | |
468 | |
666 | int |
469 | int |
667 | command_usekeys (object *op, char *params) |
|
|
668 | { |
|
|
669 | usekeytype oldtype = op->contr->usekeys; |
|
|
670 | static const char *const types[] = { "inventory", "keyrings", "containers" }; |
|
|
671 | |
|
|
672 | if (!params) |
|
|
673 | { |
|
|
674 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys is set to %s", types[op->contr->usekeys]); |
|
|
675 | return 1; |
|
|
676 | } |
|
|
677 | |
|
|
678 | if (!strcmp (params, "inventory")) |
|
|
679 | op->contr->usekeys = key_inventory; |
|
|
680 | else if (!strcmp (params, "keyrings")) |
|
|
681 | op->contr->usekeys = keyrings; |
|
|
682 | else if (!strcmp (params, "containers")) |
|
|
683 | op->contr->usekeys = containers; |
|
|
684 | else |
|
|
685 | { |
|
|
686 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys: Unknown options %s, valid options are inventory, keyrings, containers", params); |
|
|
687 | return 0; |
|
|
688 | } |
|
|
689 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys %s set to %s", (oldtype == op->contr->usekeys ? "" : "now"), types[op->contr->usekeys]); |
|
|
690 | return 1; |
|
|
691 | } |
|
|
692 | |
|
|
693 | int |
|
|
694 | command_resistances (object *op, char *params) |
470 | command_resistances (object *op, char *params) |
695 | { |
471 | { |
696 | int i; |
472 | int i; |
697 | |
473 | |
698 | if (!op) |
474 | if (!op) |
… | |
… | |
734 | |
510 | |
735 | /* |
511 | /* |
736 | * Actual commands. |
512 | * Actual commands. |
737 | * 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,...) |
738 | */ |
514 | */ |
739 | |
|
|
740 | |
|
|
741 | static void |
|
|
742 | help_topics (object *op, int what) |
|
|
743 | { |
|
|
744 | DIR *dirp; |
|
|
745 | struct dirent *de; |
|
|
746 | char filename[MAX_BUF], line[80]; |
|
|
747 | int namelen, linelen = 0; |
|
|
748 | |
|
|
749 | switch (what) |
|
|
750 | { |
|
|
751 | case 1: |
|
|
752 | sprintf (filename, "%s/wizhelp", settings.datadir); |
|
|
753 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
|
|
754 | break; |
|
|
755 | case 3: |
|
|
756 | sprintf (filename, "%s/mischelp", settings.datadir); |
|
|
757 | new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
|
|
758 | break; |
|
|
759 | default: |
|
|
760 | sprintf (filename, "%s/help", settings.datadir); |
|
|
761 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
|
|
762 | break; |
|
|
763 | } |
|
|
764 | |
|
|
765 | if (!(dirp = opendir (filename))) |
|
|
766 | return; |
|
|
767 | |
|
|
768 | line[0] = '\0'; |
|
|
769 | while ((de = readdir (dirp))) |
|
|
770 | { |
|
|
771 | namelen = strlen (de->d_name); |
|
|
772 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
|
|
773 | continue; |
|
|
774 | linelen += namelen + 1; |
|
|
775 | if (linelen > 42) |
|
|
776 | { |
|
|
777 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
778 | sprintf (line, " %s", de->d_name); |
|
|
779 | linelen = namelen + 1; |
|
|
780 | continue; |
|
|
781 | } |
|
|
782 | strcat (line, " "); |
|
|
783 | strcat (line, de->d_name); |
|
|
784 | } |
|
|
785 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
786 | closedir (dirp); |
|
|
787 | } |
|
|
788 | |
|
|
789 | static void |
|
|
790 | show_commands (object *op, int what) |
|
|
791 | { |
|
|
792 | char line[80]; |
|
|
793 | int i, size, namelen, linelen = 0; |
|
|
794 | CommArray_s *ap; |
|
|
795 | extern CommArray_s Commands[], WizCommands[]; |
|
|
796 | extern const int CommandsSize, WizCommandsSize; |
|
|
797 | |
|
|
798 | switch (what) |
|
|
799 | { |
|
|
800 | case 1: |
|
|
801 | ap = WizCommands; |
|
|
802 | size = WizCommandsSize; |
|
|
803 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
|
|
804 | break; |
|
|
805 | case 2: |
|
|
806 | ap = CommunicationCommands; |
|
|
807 | size = CommunicationCommandSize; |
|
|
808 | new_draw_info (NDI_UNIQUE, 0, op, " Communication commands:"); |
|
|
809 | break; |
|
|
810 | default: |
|
|
811 | ap = Commands; |
|
|
812 | size = CommandsSize; |
|
|
813 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
|
|
814 | break; |
|
|
815 | } |
|
|
816 | |
|
|
817 | line[0] = '\0'; |
|
|
818 | for (i = 0; i < size; i++) |
|
|
819 | { |
|
|
820 | namelen = strlen (ap[i].name); |
|
|
821 | linelen += namelen + 1; |
|
|
822 | if (linelen > 42) |
|
|
823 | { |
|
|
824 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
825 | sprintf (line, " %s", ap[i].name); |
|
|
826 | linelen = namelen + 1; |
|
|
827 | continue; |
|
|
828 | } |
|
|
829 | strcat (line, " "); |
|
|
830 | strcat (line, ap[i].name); |
|
|
831 | } |
|
|
832 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
833 | } |
|
|
834 | |
|
|
835 | |
|
|
836 | int |
|
|
837 | command_help (object *op, char *params) |
|
|
838 | { |
|
|
839 | struct stat st; |
|
|
840 | FILE *fp; |
|
|
841 | char filename[MAX_BUF], line[MAX_BUF]; |
|
|
842 | int len; |
|
|
843 | |
|
|
844 | if (op != NULL) |
|
|
845 | clear_win_info (op); |
|
|
846 | |
|
|
847 | /* |
|
|
848 | * Main help page? |
|
|
849 | */ |
|
|
850 | if (!params) |
|
|
851 | { |
|
|
852 | sprintf (filename, "%s/def_help", settings.datadir); |
|
|
853 | if ((fp = fopen (filename, "r")) == NULL) |
|
|
854 | { |
|
|
855 | LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
|
|
856 | return 0; |
|
|
857 | } |
|
|
858 | while (fgets (line, MAX_BUF, fp)) |
|
|
859 | { |
|
|
860 | line[MAX_BUF - 1] = '\0'; |
|
|
861 | len = strlen (line) - 1; |
|
|
862 | if (line[len] == '\n') |
|
|
863 | line[len] = '\0'; |
|
|
864 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
865 | } |
|
|
866 | fclose (fp); |
|
|
867 | return 0; |
|
|
868 | } |
|
|
869 | |
|
|
870 | /* |
|
|
871 | * Topics list |
|
|
872 | */ |
|
|
873 | if (!strcmp (params, "topics")) |
|
|
874 | { |
|
|
875 | help_topics (op, 3); |
|
|
876 | help_topics (op, 0); |
|
|
877 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
878 | help_topics (op, 1); |
|
|
879 | return 0; |
|
|
880 | } |
|
|
881 | |
|
|
882 | /* |
|
|
883 | * Commands list |
|
|
884 | */ |
|
|
885 | if (!strcmp (params, "commands")) |
|
|
886 | { |
|
|
887 | show_commands (op, 0); |
|
|
888 | show_commands (op, 2); /* show comm commands */ |
|
|
889 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
890 | show_commands (op, 1); |
|
|
891 | return 0; |
|
|
892 | } |
|
|
893 | |
|
|
894 | /* |
|
|
895 | * User wants info about command |
|
|
896 | */ |
|
|
897 | if (strchr (params, '.') || strchr (params, ' ') || strchr (params, '/')) |
|
|
898 | { |
|
|
899 | sprintf (line, "Illegal characters in '%s'", params); |
|
|
900 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
901 | return 0; |
|
|
902 | } |
|
|
903 | |
|
|
904 | sprintf (filename, "%s/mischelp/%s", settings.datadir, params); |
|
|
905 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
906 | { |
|
|
907 | if (op) |
|
|
908 | { |
|
|
909 | sprintf (filename, "%s/help/%s", settings.datadir, params); |
|
|
910 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
911 | { |
|
|
912 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
913 | { |
|
|
914 | sprintf (filename, "%s/wizhelp/%s", settings.datadir, params); |
|
|
915 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
916 | goto nohelp; |
|
|
917 | } |
|
|
918 | else |
|
|
919 | goto nohelp; |
|
|
920 | } |
|
|
921 | } |
|
|
922 | } |
|
|
923 | |
|
|
924 | /* |
|
|
925 | * Found that. Just cat it to screen. |
|
|
926 | */ |
|
|
927 | if ((fp = fopen (filename, "r")) == NULL) |
|
|
928 | { |
|
|
929 | LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
|
|
930 | return 0; |
|
|
931 | } |
|
|
932 | sprintf (line, "Help about '%s'", params); |
|
|
933 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
934 | while (fgets (line, MAX_BUF, fp)) |
|
|
935 | { |
|
|
936 | line[MAX_BUF - 1] = '\0'; |
|
|
937 | len = strlen (line) - 1; |
|
|
938 | if (line[len] == '\n') |
|
|
939 | line[len] = '\0'; |
|
|
940 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
941 | } |
|
|
942 | fclose (fp); |
|
|
943 | return 0; |
|
|
944 | |
|
|
945 | /* |
|
|
946 | * No_help -escape |
|
|
947 | */ |
|
|
948 | nohelp: |
|
|
949 | sprintf (line, "No help available on '%s'", params); |
|
|
950 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
951 | return 0; |
|
|
952 | } |
|
|
953 | |
|
|
954 | |
515 | |
955 | int |
516 | int |
956 | onoff_value (const char *line) |
517 | onoff_value (const char *line) |
957 | { |
518 | { |
958 | int i; |
519 | int i; |
… | |
… | |
981 | return 0; |
542 | return 0; |
982 | } |
543 | } |
983 | } |
544 | } |
984 | |
545 | |
985 | int |
546 | int |
986 | command_sound (object *op, char *params) |
|
|
987 | { |
|
|
988 | if (op->contr->ns->sound) |
|
|
989 | { |
|
|
990 | op->contr->ns->sound = 0; |
|
|
991 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
|
|
992 | } |
|
|
993 | else |
|
|
994 | { |
|
|
995 | op->contr->ns->sound = 1; |
|
|
996 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
|
|
997 | } |
|
|
998 | |
|
|
999 | return 1; |
|
|
1000 | } |
|
|
1001 | |
|
|
1002 | int |
|
|
1003 | command_title (object *op, char *params) |
547 | command_title (object *op, char *params) |
1004 | { |
548 | { |
1005 | char buf[MAX_BUF]; |
549 | char buf[MAX_BUF]; |
1006 | |
550 | |
1007 | if (settings.set_title == FALSE) |
551 | if (settings.set_title == FALSE) |
… | |
… | |
1044 | strcpy (op->contr->own_title, params); |
588 | strcpy (op->contr->own_title, params); |
1045 | return 1; |
589 | return 1; |
1046 | } |
590 | } |
1047 | |
591 | |
1048 | int |
592 | int |
1049 | command_peaceful (object *op, char *params) |
|
|
1050 | { |
|
|
1051 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1052 | "You cannot change your peaceful setting with this command." |
|
|
1053 | " Please speak to the priest in the temple of Gorokh" |
|
|
1054 | " if you want to become hostile or in temple of Valriel" " if you want to become peaceful again."); |
|
|
1055 | |
|
|
1056 | /* |
|
|
1057 | if((op->contr->peaceful=!op->contr->peaceful)) |
|
|
1058 | new_draw_info(NDI_UNIQUE, 0,op,"You will not attack other players."); |
|
|
1059 | else |
|
|
1060 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
|
|
1061 | */ |
|
|
1062 | return 1; |
|
|
1063 | } |
|
|
1064 | |
|
|
1065 | int |
|
|
1066 | command_wimpy (object *op, char *params) |
|
|
1067 | { |
|
|
1068 | int i; |
|
|
1069 | char buf[MAX_BUF]; |
|
|
1070 | |
|
|
1071 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
1072 | { |
|
|
1073 | sprintf (buf, "Your current wimpy level is %d.", op->run_away); |
|
|
1074 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1075 | return 1; |
|
|
1076 | } |
|
|
1077 | sprintf (buf, "Your new wimpy level is %d.", i); |
|
|
1078 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1079 | op->run_away = i; |
|
|
1080 | return 1; |
|
|
1081 | } |
|
|
1082 | |
|
|
1083 | int |
|
|
1084 | command_brace (object *op, char *params) |
|
|
1085 | { |
|
|
1086 | if (!params) |
|
|
1087 | op->contr->braced = !op->contr->braced; |
|
|
1088 | else |
|
|
1089 | op->contr->braced = onoff_value (params); |
|
|
1090 | |
|
|
1091 | if (op->contr->braced) |
|
|
1092 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
|
|
1093 | else |
|
|
1094 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
|
|
1095 | |
|
|
1096 | op->update_stats (); |
|
|
1097 | return 0; |
|
|
1098 | } |
|
|
1099 | |
|
|
1100 | int |
|
|
1101 | command_kill_pets (object *op, char *params) |
593 | command_kill_pets (object *op, char *params) |
1102 | { |
594 | { |
1103 | objectlink *obl, *next; |
595 | objectlink *obl, *next; |
1104 | int counter = 0, removecount = 0; |
596 | int counter = 0, removecount = 0; |
1105 | |
597 | |
1106 | if (params == NULL) |
598 | if (!params) |
1107 | { |
599 | { |
1108 | terminate_all_pets (op); |
600 | terminate_all_pets (op); |
1109 | 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."); |
1110 | } |
602 | } |
1111 | else |
603 | else |
1112 | { |
604 | { |
1113 | int target = atoi (params); |
605 | int target = atoi (params); |
1114 | |
606 | |
1115 | for (obl = first_friendly_object; obl != NULL; obl = next) |
607 | for (obl = first_friendly_object; obl; obl = next) |
1116 | { |
608 | { |
1117 | object *ob = obl->ob; |
609 | object *ob = obl->ob; |
1118 | |
610 | |
1119 | next = obl->next; |
611 | next = obl->next; |
|
|
612 | |
1120 | if (ob->owner == op) |
613 | if (ob->owner == op) |
1121 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
614 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
1122 | { |
615 | { |
1123 | ob->destroy (); |
616 | ob->destroy (); |
1124 | removecount++; |
617 | removecount++; |
1125 | } |
618 | } |
1126 | } |
619 | } |
|
|
620 | |
1127 | if (removecount != 0) |
621 | if (removecount != 0) |
1128 | 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); |
1129 | else |
623 | else |
1130 | 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"); |
1131 | } |
625 | } |
|
|
626 | |
1132 | return 0; |
627 | return 0; |
1133 | } |
628 | } |