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.39 by root, Mon Jan 29 14:46:01 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 strcpy (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);
144 /* 123 /*
145 * reset the counter on the region, then use it to store the number of 124 * reset the counter on the region, then use it to store the number of
146 * players there. 125 * players there.
147 * I don't know how thread-safe this would be, I suspect not very.... 126 * I don't know how thread-safe this would be, I suspect not very....
148 */ 127 */
149 for (region *reg = first_region; reg; reg = reg->next) 128 for_all_regions (rgn)
150 reg->counter = 0; 129 rgn->counter = 0;
151 130
152 for_all_players (pl) 131 for_all_players (pl)
153 if (pl->ob->map) 132 if (pl->ob->map)
154 ++pl->ob->region ()->counter; 133 ++pl->ob->region ()->counter;
155 134
156 /* we only want to print out by places with a 'longname' field... */ 135 /* we only want to print out by places with a 'longname' field... */
157 for (region *reg = first_region; reg; reg = reg->next) 136 for_all_regions (rgn)
158 { 137 {
159 if (reg->longname == NULL && reg->counter > 0) 138 if (!rgn->longname && rgn->counter > 0)
160 { 139 {
161 if (reg->parent) 140 if (rgn->parent)
162 { 141 {
163 reg->parent->counter += reg->counter; 142 rgn->parent->counter += rgn->counter;
164 reg->counter = 0; 143 rgn->counter = 0;
165 } 144 }
166 else /*uh oh, we shouldn't be here. */ 145 else /*uh oh, we shouldn't be here. */
167 LOG (llevError, "command_whereabouts() Region %s with no longname has no parent", &reg->name); 146 LOG (llevError, "command_whereabouts() Region %s with no longname has no parent", &rgn->name);
168 } 147 }
169 } 148 }
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 (region *reg = first_region; reg; reg = reg->next) 152 for_all_regions (rgn)
174 if (reg->counter) 153 if (rgn->counter)
175 new_draw_info_format (NDI_UNIQUE, 0, op, "%u players in %s", reg->counter, reg->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);
347#endif 315#endif
348 return 1; 316 return 1;
349} 317}
350 318
351int 319int
352command_archs (object *op, char *params)
353{
354 arch_info (op);
355 return 1;
356}
357
358int
359command_hiscore (object *op, char *params) 320command_hiscore (object *op, char *params)
360{ 321{
361 display_high_score (op, op == NULL ? 9999 : 50, params); 322 display_high_score (op, op == NULL ? 9999 : 50, params);
362 return 1; 323 return 1;
363} 324}
370 331
371 if (params == NULL || !sscanf (params, "%d", &i)) 332 if (params == NULL || !sscanf (params, "%d", &i))
372 { 333 {
373 sprintf (buf, "Global debug level is %d.", settings.debug); 334 sprintf (buf, "Global debug level is %d.", settings.debug);
374 new_draw_info (NDI_UNIQUE, 0, op, buf); 335 new_draw_info (NDI_UNIQUE, 0, op, buf);
375 return 1;
376 }
377 if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ))
378 {
379 new_draw_info (NDI_UNIQUE, 0, op, "Privileged command.");
380 return 1; 336 return 1;
381 } 337 }
382 settings.debug = (enum LogLevel) FABS (i); 338 settings.debug = (enum LogLevel) FABS (i);
383 sprintf (buf, "Set debug level to %d.", i); 339 sprintf (buf, "Set debug level to %d.", i);
384 new_draw_info (NDI_UNIQUE, 0, op, buf); 340 new_draw_info (NDI_UNIQUE, 0, op, buf);
442 } 398 }
443 else 399 else
444 { 400 {
445 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));
446 } 402 }
447}
448
449int
450command_output_sync (object *op, char *params)
451{
452 int val;
453
454 if (!params)
455 {
456 new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time is presently %d", op->contr->outputs_sync);
457 return 1;
458 }
459 val = atoi (params);
460 if (val > 0)
461 {
462 op->contr->outputs_sync = val;
463 new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time now set to %d", op->contr->outputs_sync);
464 }
465 else
466 new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_sync.");
467
468 return 1;
469}
470
471int
472command_output_count (object *op, char *params)
473{
474 int val;
475
476 if (!params)
477 {
478 new_draw_info_format (NDI_UNIQUE, 0, op, "Output count is presently %d", op->contr->outputs_count);
479 return 1;
480 }
481 val = atoi (params);
482 if (val > 0)
483 {
484 op->contr->outputs_count = val;
485 new_draw_info_format (NDI_UNIQUE, 0, op, "Output count now set to %d", op->contr->outputs_count);
486 }
487 else
488 new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_count.");
489
490 return 1;
491}
492
493int
494command_listen (object *op, char *params)
495{
496 int i;
497
498 if (params == NULL || !sscanf (params, "%d", &i))
499 {
500 new_draw_info_format (NDI_UNIQUE, 0, op, "Set listen to what (presently %d)?", op->contr->listening);
501 return 1;
502 }
503 op->contr->listening = (char) i;
504 new_draw_info_format (NDI_UNIQUE, 0, op, "Your verbose level is now %d.", i);
505 return 1;
506} 403}
507 404
508/* Prints out some useful information for the character. Everything we print 405/* Prints out some useful information for the character. Everything we print
509 * 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 -
510 * 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
542int 439int
543command_fix_me (object *op, char *params) 440command_fix_me (object *op, char *params)
544{ 441{
545 sum_weight (op); 442 sum_weight (op);
546 op->update_stats (); 443 op->update_stats ();
444 new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed.");
445
547 return 1; 446 return 1;
548} 447}
549 448
550int 449int
551command_logs (object *op, char *params) 450command_logs (object *op, char *params)
552{ 451{
553 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.");
554 453
555 return 1;
556}
557
558int
559command_applymode (object *op, char *params)
560{
561 unapplymode unapply = op->contr->unapply;
562 static const char *const types[] = { "nochoice", "never", "always" };
563
564 if (!params)
565 {
566 new_draw_info_format (NDI_UNIQUE, 0, op, "applymode is set to %s", types[op->contr->unapply]);
567 return 1;
568 }
569
570 if (!strcmp (params, "nochoice"))
571 op->contr->unapply = unapply_nochoice;
572 else if (!strcmp (params, "never"))
573 op->contr->unapply = unapply_never;
574 else if (!strcmp (params, "always"))
575 op->contr->unapply = unapply_always;
576 else
577 {
578 new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params);
579 return 0;
580 }
581
582 new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s",
583 (unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]);
584 return 1; 454 return 1;
585} 455}
586 456
587int 457int
588command_bowmode (object *op, char *params) 458command_bowmode (object *op, char *params)
626 new_draw_info_format (NDI_UNIQUE, 0, op, buf); 496 new_draw_info_format (NDI_UNIQUE, 0, op, buf);
627 return 0; 497 return 0;
628 } 498 }
629 499
630 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]);
631 return 1;
632}
633
634int
635command_petmode (object *op, char *params)
636{
637 petmode_t oldtype = op->contr->petmode;
638 static const char *const types[] = { "normal", "sad", "defend", "arena" };
639
640 if (!params)
641 {
642 new_draw_info_format (NDI_UNIQUE, 0, op, "petmode is set to %s", types[op->contr->petmode]);
643 return 1;
644 }
645
646 if (!strcmp (params, "normal"))
647 op->contr->petmode = pet_normal;
648 else if (!strcmp (params, "sad"))
649 op->contr->petmode = pet_sad;
650 else if (!strcmp (params, "defend"))
651 op->contr->petmode = pet_defend;
652 else if (!strcmp (params, "arena"))
653 op->contr->petmode = pet_arena;
654 else
655 {
656 new_draw_info_format (NDI_UNIQUE, 0, op,
657 "petmode: Unknown options %s, valid options are normal," "sad (seek and destroy), defend, arena", params);
658 return 0;
659 }
660 new_draw_info_format (NDI_UNIQUE, 0, op, "petmode %s set to %s", (oldtype == op->contr->petmode ? "" : "now"), types[op->contr->petmode]);
661 return 1; 501 return 1;
662} 502}
663 503
664int 504int
665command_showpets (object *op, char *params) 505command_showpets (object *op, char *params)
706 new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); 546 new_draw_info (NDI_UNIQUE, 0, op, "no such pet.");
707 return 0; 547 return 0;
708} 548}
709 549
710int 550int
711command_usekeys (object *op, char *params)
712{
713 usekeytype oldtype = op->contr->usekeys;
714 static const char *const types[] = { "inventory", "keyrings", "containers" };
715
716 if (!params)
717 {
718 new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys is set to %s", types[op->contr->usekeys]);
719 return 1;
720 }
721
722 if (!strcmp (params, "inventory"))
723 op->contr->usekeys = key_inventory;
724 else if (!strcmp (params, "keyrings"))
725 op->contr->usekeys = keyrings;
726 else if (!strcmp (params, "containers"))
727 op->contr->usekeys = containers;
728 else
729 {
730 new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys: Unknown options %s, valid options are inventory, keyrings, containers", params);
731 return 0;
732 }
733 new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys %s set to %s", (oldtype == op->contr->usekeys ? "" : "now"), types[op->contr->usekeys]);
734 return 1;
735}
736
737int
738command_resistances (object *op, char *params) 551command_resistances (object *op, char *params)
739{ 552{
740 int i; 553 int i;
741 554
742 if (!op) 555 if (!op)
808 621
809 if (!(dirp = opendir (filename))) 622 if (!(dirp = opendir (filename)))
810 return; 623 return;
811 624
812 line[0] = '\0'; 625 line[0] = '\0';
813 while (de = readdir (dirp)) 626 while ((de = readdir (dirp)))
814 { 627 {
815 namelen = strlen (de->d_name); 628 namelen = strlen (de->d_name);
816 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] == '.'))
817 continue; 630 continue;
818 linelen += namelen + 1; 631 linelen += namelen + 1;
1025 return 0; 838 return 0;
1026 } 839 }
1027} 840}
1028 841
1029int 842int
1030command_sound (object *op, char *params)
1031{
1032 if (op->contr->ns->sound)
1033 {
1034 op->contr->ns->sound = 0;
1035 new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden...");
1036 }
1037 else
1038 {
1039 op->contr->ns->sound = 1;
1040 new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled.");
1041 }
1042
1043 return 1;
1044}
1045
1046int
1047command_title (object *op, char *params) 843command_title (object *op, char *params)
1048{ 844{
1049 char buf[MAX_BUF]; 845 char buf[MAX_BUF];
1050 846
1051 if (settings.set_title == FALSE) 847 if (settings.set_title == FALSE)
1085 new_draw_info (NDI_UNIQUE, 0, op, "Title too long."); 881 new_draw_info (NDI_UNIQUE, 0, op, "Title too long.");
1086 return 1; 882 return 1;
1087 } 883 }
1088 strcpy (op->contr->own_title, params); 884 strcpy (op->contr->own_title, params);
1089 return 1; 885 return 1;
1090}
1091
1092int
1093command_peaceful (object *op, char *params)
1094{
1095 new_draw_info (NDI_UNIQUE, 0, op,
1096 "You cannot change your peaceful setting with this command."
1097 " Please speak to the priest in the temple of Gorokh"
1098 " if you want to become hostile or in temple of Valriel" " if you want to become peaceful again.");
1099
1100/*
1101 if((op->contr->peaceful=!op->contr->peaceful))
1102 new_draw_info(NDI_UNIQUE, 0,op,"You will not attack other players.");
1103 else
1104 new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players.");
1105*/
1106 return 1;
1107}
1108
1109int
1110command_wimpy (object *op, char *params)
1111{
1112 int i;
1113 char buf[MAX_BUF];
1114
1115 if (params == NULL || !sscanf (params, "%d", &i))
1116 {
1117 sprintf (buf, "Your current wimpy level is %d.", op->run_away);
1118 new_draw_info (NDI_UNIQUE, 0, op, buf);
1119 return 1;
1120 }
1121 sprintf (buf, "Your new wimpy level is %d.", i);
1122 new_draw_info (NDI_UNIQUE, 0, op, buf);
1123 op->run_away = i;
1124 return 1;
1125}
1126
1127int
1128command_brace (object *op, char *params)
1129{
1130 if (!params)
1131 op->contr->braced = !op->contr->braced;
1132 else
1133 op->contr->braced = onoff_value (params);
1134
1135 if (op->contr->braced)
1136 new_draw_info (NDI_UNIQUE, 0, op, "You are braced.");
1137 else
1138 new_draw_info (NDI_UNIQUE, 0, op, "Not braced.");
1139
1140 op->update_stats ();
1141 return 0;
1142} 886}
1143 887
1144int 888int
1145command_kill_pets (object *op, char *params) 889command_kill_pets (object *op, char *params)
1146{ 890{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines