ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/c_misc.C
(Generate patch)

Comparing deliantra/server/server/c_misc.C (file contents):
Revision 1.46 by pippijn, Thu Mar 1 13:18:37 2007 UTC vs.
Revision 1.59 by root, Mon May 28 21:28:35 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game for X-windows 2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * Crossfire TRT is free software; you can redistribute it and/or modify it
9 * it under the terms of the GNU General Public License as published by 9 * under the terms of the GNU General Public License as published by the Free
10 * the Free Software Foundation; either version 2 of the License, or 10 * Software Foundation; either version 2 of the License, or (at your option)
11 * (at your option) any later version. 11 * any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful, but
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * GNU General Public License for more details. 16 * for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License along
19 * along with this program; if not, write to the Free Software 19 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * 21 *
22 * The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23 */ 23 */
24 24
25#include <global.h> 25#include <global.h>
26#include <loader.h> 26#include <loader.h>
27#include <sproto.h> 27#include <sproto.h>
28 28
29/* 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 */
37int
38command_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
67int 31int
68command_motd (object *op, char *params) 32command_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 */
79void
80current_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", &reg->longname, &reg->msg);
84}
85
86void
87current_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
106int 39int
107command_malloc_verify (object *op, char *parms) 40command_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;
159typedef struct 92typedef 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
165int
166command_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
176int
177command_mapinfo (object *op, char *params)
178{
179 current_map_info (op);
180 return 1;
181}
182
183int
184command_whereami (object *op, char *params)
185{
186 current_region_info (op);
187 return 1;
188}
189 97
190int 98int
191command_time (object *op, char *params) 99command_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)) 257
350 { 258 settings.debug = i;
351 new_draw_info (NDI_UNIQUE, 0, op, "Privileged command."); 259
352 return 1;
353 }
354 settings.debug = (enum LogLevel) FABS (i);
355 sprintf (buf, "Set debug level to %d.", i); 260 sprintf (buf, "Set debug level to %d.", i);
356 new_draw_info (NDI_UNIQUE, 0, op, buf); 261 new_draw_info (NDI_UNIQUE, 0, op, buf);
357 return 1; 262 return 1;
358} 263}
359 264
414 } 319 }
415 else 320 else
416 { 321 {
417 LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno)); 322 LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno));
418 } 323 }
419}
420
421int
422command_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
443int
444command_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
465int
466command_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} 324}
479 325
480/* Prints out some useful information for the character. Everything we print 326/* 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 - 327 * 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 328 * rather, we are making it convenient to find the values. params have
514int 360int
515command_fix_me (object *op, char *params) 361command_fix_me (object *op, char *params)
516{ 362{
517 sum_weight (op); 363 sum_weight (op);
518 op->update_stats (); 364 op->update_stats ();
365 new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed.");
366
519 return 1; 367 return 1;
520} 368}
521 369
522int 370int
523command_logs (object *op, char *params) 371command_logs (object *op, char *params)
524{ 372{
525 new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); 373 new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills.");
526 374
527 return 1;
528}
529
530int
531command_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; 375 return 1;
557} 376}
558 377
559int 378int
560command_bowmode (object *op, char *params) 379command_bowmode (object *op, char *params)
598 new_draw_info_format (NDI_UNIQUE, 0, op, buf); 417 new_draw_info_format (NDI_UNIQUE, 0, op, buf);
599 return 0; 418 return 0;
600 } 419 }
601 420
602 new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); 421 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
606int
607command_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; 422 return 1;
634} 423}
635 424
636int 425int
637command_showpets (object *op, char *params) 426command_showpets (object *op, char *params)
678 new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); 467 new_draw_info (NDI_UNIQUE, 0, op, "no such pet.");
679 return 0; 468 return 0;
680} 469}
681 470
682int 471int
683command_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
709int
710command_resistances (object *op, char *params) 472command_resistances (object *op, char *params)
711{ 473{
712 int i; 474 int i;
713 475
714 if (!op) 476 if (!op)
750 512
751/* 513/*
752 * Actual commands. 514 * Actual commands.
753 * Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) 515 * Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...)
754 */ 516 */
755
756
757static void
758help_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
805static void
806show_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
852int
853command_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 */
964nohelp:
965 sprintf (line, "No help available on '%s'", params);
966 new_draw_info (NDI_UNIQUE, 0, op, line);
967 return 0;
968}
969
970 517
971int 518int
972onoff_value (const char *line) 519onoff_value (const char *line)
973{ 520{
974 int i; 521 int i;
997 return 0; 544 return 0;
998 } 545 }
999} 546}
1000 547
1001int 548int
1002command_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
1018int
1019command_title (object *op, char *params) 549command_title (object *op, char *params)
1020{ 550{
1021 char buf[MAX_BUF]; 551 char buf[MAX_BUF];
1022 552
1023 if (settings.set_title == FALSE) 553 if (settings.set_title == FALSE)
1060 strcpy (op->contr->own_title, params); 590 strcpy (op->contr->own_title, params);
1061 return 1; 591 return 1;
1062} 592}
1063 593
1064int 594int
1065command_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
1081int
1082command_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
1099int
1100command_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
1116int
1117command_kill_pets (object *op, char *params) 595command_kill_pets (object *op, char *params)
1118{ 596{
1119 objectlink *obl, *next; 597 objectlink *obl, *next;
1120 int counter = 0, removecount = 0; 598 int counter = 0, removecount = 0;
1121 599
1122 if (params == NULL) 600 if (!params)
1123 { 601 {
1124 terminate_all_pets (op); 602 terminate_all_pets (op);
1125 new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); 603 new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed.");
1126 } 604 }
1127 else 605 else
1128 { 606 {
1129 int target = atoi (params); 607 int target = atoi (params);
1130 608
1131 for (obl = first_friendly_object; obl != NULL; obl = next) 609 for (obl = first_friendly_object; obl; obl = next)
1132 { 610 {
1133 object *ob = obl->ob; 611 object *ob = obl->ob;
1134 612
1135 next = obl->next; 613 next = obl->next;
614
1136 if (ob->owner == op) 615 if (ob->owner == op)
1137 if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) 616 if (++counter == target || (target == 0 && !strcasecmp (ob->name, params)))
1138 { 617 {
1139 ob->destroy (); 618 ob->destroy ();
1140 removecount++; 619 removecount++;
1141 } 620 }
1142 } 621 }
622
1143 if (removecount != 0) 623 if (removecount != 0)
1144 new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); 624 new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount);
1145 else 625 else
1146 new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); 626 new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n");
1147 } 627 }
628
1148 return 0; 629 return 0;
1149} 630}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines