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.43 by root, Mon Feb 5 01:24:45 2007 UTC vs.
Revision 1.52 by pippijn, Fri Mar 2 11:07:59 2007 UTC

69{ 69{
70 display_motd (op); 70 display_motd (op);
71 return 1; 71 return 1;
72} 72}
73 73
74int
75command_bug (object *op, char *params)
76{
77 char buf[MAX_BUF];
78
79 if (params == NULL)
80 {
81 new_draw_info (NDI_UNIQUE, 0, op, "what bugs?");
82 return 1;
83 }
84 assign (buf, op->name);
85 strcat (buf, " bug-reports: ");
86 strncat (buf, ++params, MAX_BUF - strlen (buf));
87 buf[MAX_BUF - 1] = '\0';
88 bug_report (buf);
89 LOG (llevError, "%s\n", buf);
90 new_draw_info (NDI_ALL | NDI_UNIQUE, 1, NULL, buf);
91 new_draw_info (NDI_UNIQUE, 0, op, "OK, thanks!");
92 return 1;
93}
94
95/* 74/*
96 * Pretty much identical to current map_info, but on a bigger scale 75 * Pretty much identical to current map_info, but on a bigger scale
97 * This function returns the name of the players current region, and 76 * This function returns the name of the players current region, and
98 * a description of it. It is there merely for flavour text. 77 * a description of it. It is there merely for flavour text.
99 */ 78 */
100void 79void
101current_region_info (object *op) 80current_region_info (object *op)
102{ 81{
103 if (region *reg = op->region ()) 82 if (region *reg = op->region ())
104 new_draw_info_format (NDI_UNIQUE, 0, op, "You are in %s.\n%s", &reg->longname, &reg->msg); 83 new_draw_info_format (NDI_UNIQUE, 0, op, "You are %s.\n%s", &reg->longname, &reg->msg);
105} 84}
106 85
107void 86void
108current_map_info (object *op) 87current_map_info (object *op)
109{ 88{
110 maptile *m = op->map; 89 maptile *m = op->map;
111 90
112 if (!m) 91 if (!m)
113 return; 92 return;
114 93
115 new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) in %s", &m->name, &m->path, &op->region ()->name); 94 new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) %s", &m->name, &m->path, &op->region ()->longname);
116 95
117 if (QUERY_FLAG (op, FLAG_WIZ)) 96 if (QUERY_FLAG (op, FLAG_WIZ))
118 new_draw_info_format (NDI_UNIQUE, 0, op, 97 new_draw_info_format (NDI_UNIQUE, 0, op,
119 "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld", 98 "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld",
120 m->players, m->difficulty, m->width, m->height, m->enter_x, m->enter_y, m->timeout); 99 m->players, m->difficulty, m->width, m->height, m->enter_x, m->enter_y, m->timeout);
170 149
171 new_draw_info_format (NDI_UNIQUE, 0, op, "In the world currently there are:"); 150 new_draw_info_format (NDI_UNIQUE, 0, op, "In the world currently there are:");
172 151
173 for_all_regions (rgn) 152 for_all_regions (rgn)
174 if (rgn->counter) 153 if (rgn->counter)
175 new_draw_info_format (NDI_UNIQUE, 0, op, "%u players in %s", rgn->counter, &rgn->longname); 154 new_draw_info_format (NDI_UNIQUE, 0, op, "%u players %s", rgn->counter, &rgn->longname);
176 155
177 return 1; 156 return 1;
178} 157}
179 158
180typedef struct 159typedef struct
181{ 160{
182 char namebuf[MAX_BUF]; 161 char namebuf[MAX_BUF];
183 int login_order; 162 int login_order;
184} chars_names; 163} chars_names;
185
186int
187command_afk (object *op, char *params)
188{
189 if ((op->contr->ns->afk = !op->contr->ns->afk))
190 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer AFK");
191 else
192 new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK");
193
194 return 1;
195}
196 164
197int 165int
198command_mapinfo (object *op, char *params) 166command_mapinfo (object *op, char *params)
199{ 167{
200 current_map_info (op); 168 current_map_info (op);
365 { 333 {
366 sprintf (buf, "Global debug level is %d.", settings.debug); 334 sprintf (buf, "Global debug level is %d.", settings.debug);
367 new_draw_info (NDI_UNIQUE, 0, op, buf); 335 new_draw_info (NDI_UNIQUE, 0, op, buf);
368 return 1; 336 return 1;
369 } 337 }
370 if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ))
371 {
372 new_draw_info (NDI_UNIQUE, 0, op, "Privileged command.");
373 return 1;
374 }
375 settings.debug = (enum LogLevel) FABS (i); 338 settings.debug = (enum LogLevel) FABS (i);
376 sprintf (buf, "Set debug level to %d.", i); 339 sprintf (buf, "Set debug level to %d.", i);
377 new_draw_info (NDI_UNIQUE, 0, op, buf); 340 new_draw_info (NDI_UNIQUE, 0, op, buf);
378 return 1; 341 return 1;
379} 342}
435 } 398 }
436 else 399 else
437 { 400 {
438 LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno)); 401 LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno));
439 } 402 }
440}
441
442int
443command_output_sync (object *op, char *params)
444{
445 int val;
446
447 if (!params)
448 {
449 new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time is presently %d", op->contr->outputs_sync);
450 return 1;
451 }
452 val = atoi (params);
453 if (val > 0)
454 {
455 op->contr->outputs_sync = val;
456 new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time now set to %d", op->contr->outputs_sync);
457 }
458 else
459 new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_sync.");
460
461 return 1;
462}
463
464int
465command_output_count (object *op, char *params)
466{
467 int val;
468
469 if (!params)
470 {
471 new_draw_info_format (NDI_UNIQUE, 0, op, "Output count is presently %d", op->contr->outputs_count);
472 return 1;
473 }
474 val = atoi (params);
475 if (val > 0)
476 {
477 op->contr->outputs_count = val;
478 new_draw_info_format (NDI_UNIQUE, 0, op, "Output count now set to %d", op->contr->outputs_count);
479 }
480 else
481 new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_count.");
482
483 return 1;
484}
485
486int
487command_listen (object *op, char *params)
488{
489 int i;
490
491 if (params == NULL || !sscanf (params, "%d", &i))
492 {
493 new_draw_info_format (NDI_UNIQUE, 0, op, "Set listen to what (presently %d)?", op->contr->listening);
494 return 1;
495 }
496 op->contr->listening = (char) i;
497 new_draw_info_format (NDI_UNIQUE, 0, op, "Your verbose level is now %d.", i);
498 return 1;
499} 403}
500 404
501/* Prints out some useful information for the character. Everything we print 405/* Prints out some useful information for the character. Everything we print
502 * out can be determined by the docs, so we aren't revealing anything extra - 406 * out can be determined by the docs, so we aren't revealing anything extra -
503 * rather, we are making it convenient to find the values. params have 407 * rather, we are making it convenient to find the values. params have
535int 439int
536command_fix_me (object *op, char *params) 440command_fix_me (object *op, char *params)
537{ 441{
538 sum_weight (op); 442 sum_weight (op);
539 op->update_stats (); 443 op->update_stats ();
444 new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed.");
445
540 return 1; 446 return 1;
541} 447}
542 448
543int 449int
544command_logs (object *op, char *params) 450command_logs (object *op, char *params)
545{ 451{
546 new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); 452 new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills.");
547 453
548 return 1;
549}
550
551int
552command_applymode (object *op, char *params)
553{
554 unapplymode unapply = op->contr->unapply;
555 static const char *const types[] = { "nochoice", "never", "always" };
556
557 if (!params)
558 {
559 new_draw_info_format (NDI_UNIQUE, 0, op, "applymode is set to %s", types[op->contr->unapply]);
560 return 1;
561 }
562
563 if (!strcmp (params, "nochoice"))
564 op->contr->unapply = unapply_nochoice;
565 else if (!strcmp (params, "never"))
566 op->contr->unapply = unapply_never;
567 else if (!strcmp (params, "always"))
568 op->contr->unapply = unapply_always;
569 else
570 {
571 new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params);
572 return 0;
573 }
574
575 new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s",
576 (unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]);
577 return 1; 454 return 1;
578} 455}
579 456
580int 457int
581command_bowmode (object *op, char *params) 458command_bowmode (object *op, char *params)
619 new_draw_info_format (NDI_UNIQUE, 0, op, buf); 496 new_draw_info_format (NDI_UNIQUE, 0, op, buf);
620 return 0; 497 return 0;
621 } 498 }
622 499
623 new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); 500 new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]);
624 return 1;
625}
626
627int
628command_petmode (object *op, char *params)
629{
630 petmode_t oldtype = op->contr->petmode;
631 static const char *const types[] = { "normal", "sad", "defend", "arena" };
632
633 if (!params)
634 {
635 new_draw_info_format (NDI_UNIQUE, 0, op, "petmode is set to %s", types[op->contr->petmode]);
636 return 1;
637 }
638
639 if (!strcmp (params, "normal"))
640 op->contr->petmode = pet_normal;
641 else if (!strcmp (params, "sad"))
642 op->contr->petmode = pet_sad;
643 else if (!strcmp (params, "defend"))
644 op->contr->petmode = pet_defend;
645 else if (!strcmp (params, "arena"))
646 op->contr->petmode = pet_arena;
647 else
648 {
649 new_draw_info_format (NDI_UNIQUE, 0, op,
650 "petmode: Unknown options %s, valid options are normal," "sad (seek and destroy), defend, arena", params);
651 return 0;
652 }
653 new_draw_info_format (NDI_UNIQUE, 0, op, "petmode %s set to %s", (oldtype == op->contr->petmode ? "" : "now"), types[op->contr->petmode]);
654 return 1; 501 return 1;
655} 502}
656 503
657int 504int
658command_showpets (object *op, char *params) 505command_showpets (object *op, char *params)
699 new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); 546 new_draw_info (NDI_UNIQUE, 0, op, "no such pet.");
700 return 0; 547 return 0;
701} 548}
702 549
703int 550int
704command_usekeys (object *op, char *params)
705{
706 usekeytype oldtype = op->contr->usekeys;
707 static const char *const types[] = { "inventory", "keyrings", "containers" };
708
709 if (!params)
710 {
711 new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys is set to %s", types[op->contr->usekeys]);
712 return 1;
713 }
714
715 if (!strcmp (params, "inventory"))
716 op->contr->usekeys = key_inventory;
717 else if (!strcmp (params, "keyrings"))
718 op->contr->usekeys = keyrings;
719 else if (!strcmp (params, "containers"))
720 op->contr->usekeys = containers;
721 else
722 {
723 new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys: Unknown options %s, valid options are inventory, keyrings, containers", params);
724 return 0;
725 }
726 new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys %s set to %s", (oldtype == op->contr->usekeys ? "" : "now"), types[op->contr->usekeys]);
727 return 1;
728}
729
730int
731command_resistances (object *op, char *params) 551command_resistances (object *op, char *params)
732{ 552{
733 int i; 553 int i;
734 554
735 if (!op) 555 if (!op)
801 621
802 if (!(dirp = opendir (filename))) 622 if (!(dirp = opendir (filename)))
803 return; 623 return;
804 624
805 line[0] = '\0'; 625 line[0] = '\0';
806 while (de = readdir (dirp)) 626 while ((de = readdir (dirp)))
807 { 627 {
808 namelen = strlen (de->d_name); 628 namelen = strlen (de->d_name);
809 if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) 629 if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.'))
810 continue; 630 continue;
811 linelen += namelen + 1; 631 linelen += namelen + 1;
1018 return 0; 838 return 0;
1019 } 839 }
1020} 840}
1021 841
1022int 842int
1023command_sound (object *op, char *params)
1024{
1025 if (op->contr->ns->sound)
1026 {
1027 op->contr->ns->sound = 0;
1028 new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden...");
1029 }
1030 else
1031 {
1032 op->contr->ns->sound = 1;
1033 new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled.");
1034 }
1035
1036 return 1;
1037}
1038
1039int
1040command_title (object *op, char *params) 843command_title (object *op, char *params)
1041{ 844{
1042 char buf[MAX_BUF]; 845 char buf[MAX_BUF];
1043 846
1044 if (settings.set_title == FALSE) 847 if (settings.set_title == FALSE)
1078 new_draw_info (NDI_UNIQUE, 0, op, "Title too long."); 881 new_draw_info (NDI_UNIQUE, 0, op, "Title too long.");
1079 return 1; 882 return 1;
1080 } 883 }
1081 strcpy (op->contr->own_title, params); 884 strcpy (op->contr->own_title, params);
1082 return 1; 885 return 1;
1083}
1084
1085int
1086command_peaceful (object *op, char *params)
1087{
1088 new_draw_info (NDI_UNIQUE, 0, op,
1089 "You cannot change your peaceful setting with this command."
1090 " Please speak to the priest in the temple of Gorokh"
1091 " if you want to become hostile or in temple of Valriel" " if you want to become peaceful again.");
1092
1093/*
1094 if((op->contr->peaceful=!op->contr->peaceful))
1095 new_draw_info(NDI_UNIQUE, 0,op,"You will not attack other players.");
1096 else
1097 new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players.");
1098*/
1099 return 1;
1100}
1101
1102int
1103command_wimpy (object *op, char *params)
1104{
1105 int i;
1106 char buf[MAX_BUF];
1107
1108 if (params == NULL || !sscanf (params, "%d", &i))
1109 {
1110 sprintf (buf, "Your current wimpy level is %d.", op->run_away);
1111 new_draw_info (NDI_UNIQUE, 0, op, buf);
1112 return 1;
1113 }
1114 sprintf (buf, "Your new wimpy level is %d.", i);
1115 new_draw_info (NDI_UNIQUE, 0, op, buf);
1116 op->run_away = i;
1117 return 1;
1118}
1119
1120int
1121command_brace (object *op, char *params)
1122{
1123 if (!params)
1124 op->contr->braced = !op->contr->braced;
1125 else
1126 op->contr->braced = onoff_value (params);
1127
1128 if (op->contr->braced)
1129 new_draw_info (NDI_UNIQUE, 0, op, "You are braced.");
1130 else
1131 new_draw_info (NDI_UNIQUE, 0, op, "Not braced.");
1132
1133 op->update_stats ();
1134 return 0;
1135} 886}
1136 887
1137int 888int
1138command_kill_pets (object *op, char *params) 889command_kill_pets (object *op, char *params)
1139{ 890{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines