… | |
… | |
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 | #include <dirent.h> |
|
|
30 | |
|
|
31 | /* Handles misc. input request - things like hash table, malloc, maps, |
29 | /* Handles misc. input request - things like hash table, malloc, maps, |
32 | * who, etc. |
30 | * who, etc. |
33 | */ |
31 | */ |
34 | |
32 | |
35 | /* This command dumps the body information for object *op. |
33 | /* This command dumps the body information for object *op. |
… | |
… | |
71 | { |
69 | { |
72 | display_motd (op); |
70 | display_motd (op); |
73 | return 1; |
71 | return 1; |
74 | } |
72 | } |
75 | |
73 | |
76 | int |
|
|
77 | command_bug (object *op, char *params) |
|
|
78 | { |
|
|
79 | char buf[MAX_BUF]; |
|
|
80 | |
|
|
81 | if (params == NULL) |
|
|
82 | { |
|
|
83 | new_draw_info (NDI_UNIQUE, 0, op, "what bugs?"); |
|
|
84 | return 1; |
|
|
85 | } |
|
|
86 | strcpy (buf, op->name); |
|
|
87 | strcat (buf, " bug-reports: "); |
|
|
88 | strncat (buf, ++params, MAX_BUF - strlen (buf)); |
|
|
89 | buf[MAX_BUF - 1] = '\0'; |
|
|
90 | bug_report (buf); |
|
|
91 | LOG (llevError, "%s\n", buf); |
|
|
92 | new_draw_info (NDI_ALL | NDI_UNIQUE, 1, NULL, buf); |
|
|
93 | new_draw_info (NDI_UNIQUE, 0, op, "OK, thanks!"); |
|
|
94 | return 1; |
|
|
95 | } |
|
|
96 | |
|
|
97 | /* |
74 | /* |
98 | * 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 |
99 | * This function returns the name of the players current region, and |
76 | * This function returns the name of the players current region, and |
100 | * a description of it. It is there merely for flavour text. |
77 | * a description of it. It is there merely for flavour text. |
101 | */ |
78 | */ |
102 | void |
79 | void |
103 | current_region_info (object *op) |
80 | current_region_info (object *op) |
104 | { |
81 | { |
105 | /* |
82 | if (region *reg = op->region ()) |
106 | * Ok I /suppose/ I should write a seperate function for this, but it isn't |
|
|
107 | * going to be /that/ slow, and won't get called much |
|
|
108 | */ |
|
|
109 | region *r = get_region_by_name (get_name_of_region_for_map (op->map)); |
|
|
110 | |
|
|
111 | if (!r) |
|
|
112 | return; |
|
|
113 | /* This should only be possible if regions are not operating on this server. */ |
|
|
114 | |
|
|
115 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are in %s. \n %s", get_region_longname (r), get_region_msg (r)); |
83 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are %s.\n%s", ®->longname, ®->msg); |
116 | } |
84 | } |
117 | |
85 | |
118 | void |
86 | void |
119 | current_map_info (object *op) |
87 | current_map_info (object *op) |
120 | { |
88 | { |
121 | maptile *m = op->map; |
89 | maptile *m = op->map; |
122 | |
90 | |
123 | if (!m) |
91 | if (!m) |
124 | return; |
92 | return; |
125 | |
93 | |
126 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) in %s", &m->name, &m->path, get_name_of_region_for_map (m)); |
94 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) %s", &m->name, &m->path, &op->region ()->longname); |
127 | |
95 | |
128 | if (QUERY_FLAG (op, FLAG_WIZ)) |
96 | if (QUERY_FLAG (op, FLAG_WIZ)) |
129 | { |
|
|
130 | new_draw_info_format (NDI_UNIQUE, 0, op, |
97 | new_draw_info_format (NDI_UNIQUE, 0, op, |
131 | "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", |
132 | 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); |
133 | |
100 | |
134 | } |
|
|
135 | if (m->msg) |
101 | if (m->msg) |
136 | new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
102 | new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
137 | } |
103 | } |
138 | |
104 | |
139 | #ifdef DEBUG_MALLOC_LEVEL |
105 | #ifdef DEBUG_MALLOC_LEVEL |
… | |
… | |
151 | #endif |
117 | #endif |
152 | |
118 | |
153 | int |
119 | int |
154 | command_whereabouts (object *op, char *params) |
120 | command_whereabouts (object *op, char *params) |
155 | { |
121 | { |
156 | |
122 | //TODO: should obviously not waste space in struct region for this. |
157 | region *reg; |
|
|
158 | player *pl; |
|
|
159 | |
|
|
160 | /* |
123 | /* |
161 | * 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 |
162 | * players there. |
125 | * players there. |
163 | * 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.... |
164 | */ |
127 | */ |
165 | for (reg = first_region; reg != NULL; reg = reg->next) |
128 | for_all_regions (rgn) |
166 | { |
|
|
167 | reg->counter = 0; |
129 | rgn->counter = 0; |
168 | } |
130 | |
169 | for_all_players (pl) |
131 | for_all_players (pl) |
170 | if (pl->ob->map != NULL) |
132 | if (pl->ob->map) |
171 | get_region_by_map (pl->ob->map)->counter++; |
133 | ++pl->ob->region ()->counter; |
172 | |
134 | |
173 | /* 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... */ |
174 | for (reg = first_region; reg != NULL; reg = reg->next) |
136 | for_all_regions (rgn) |
175 | { |
137 | { |
176 | if (reg->longname == NULL && reg->counter > 0) |
138 | if (!rgn->longname && rgn->counter > 0) |
177 | { |
139 | { |
178 | if (reg->parent != NULL) |
140 | if (rgn->parent) |
179 | { |
141 | { |
180 | reg->parent->counter += reg->counter; |
142 | rgn->parent->counter += rgn->counter; |
181 | reg->counter = 0; |
143 | rgn->counter = 0; |
182 | } |
144 | } |
183 | else /*uh oh, we shouldn't be here. */ |
145 | else /*uh oh, we shouldn't be here. */ |
184 | 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); |
185 | } |
147 | } |
186 | } |
148 | } |
|
|
149 | |
187 | 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:"); |
188 | for (reg = first_region; reg != NULL; reg = reg->next) |
151 | |
|
|
152 | for_all_regions (rgn) |
189 | if (reg->counter > 0) |
153 | if (rgn->counter) |
190 | new_draw_info_format (NDI_UNIQUE, 0, op, "%u players in %s", reg->counter, get_region_longname (reg)); |
154 | new_draw_info_format (NDI_UNIQUE, 0, op, "%u players %s", rgn->counter, &rgn->longname); |
|
|
155 | |
191 | return 1; |
156 | return 1; |
192 | } |
157 | } |
193 | |
158 | |
194 | typedef struct |
159 | typedef struct |
195 | { |
160 | { |
196 | char namebuf[MAX_BUF]; |
161 | char namebuf[MAX_BUF]; |
197 | int login_order; |
162 | int login_order; |
198 | } chars_names; |
163 | } chars_names; |
199 | |
|
|
200 | int |
|
|
201 | command_afk (object *op, char *params) |
|
|
202 | { |
|
|
203 | if ((op->contr->ns->afk = !op->contr->ns->afk)) |
|
|
204 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer AFK"); |
|
|
205 | else |
|
|
206 | new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK"); |
|
|
207 | |
|
|
208 | return 1; |
|
|
209 | } |
|
|
210 | |
164 | |
211 | int |
165 | int |
212 | command_mapinfo (object *op, char *params) |
166 | command_mapinfo (object *op, char *params) |
213 | { |
167 | { |
214 | current_map_info (op); |
168 | current_map_info (op); |
… | |
… | |
361 | #endif |
315 | #endif |
362 | return 1; |
316 | return 1; |
363 | } |
317 | } |
364 | |
318 | |
365 | int |
319 | int |
366 | command_archs (object *op, char *params) |
|
|
367 | { |
|
|
368 | arch_info (op); |
|
|
369 | return 1; |
|
|
370 | } |
|
|
371 | |
|
|
372 | int |
|
|
373 | command_hiscore (object *op, char *params) |
320 | command_hiscore (object *op, char *params) |
374 | { |
321 | { |
375 | display_high_score (op, op == NULL ? 9999 : 50, params); |
322 | display_high_score (op, op == NULL ? 9999 : 50, params); |
376 | return 1; |
323 | return 1; |
377 | } |
324 | } |
… | |
… | |
384 | |
331 | |
385 | if (params == NULL || !sscanf (params, "%d", &i)) |
332 | if (params == NULL || !sscanf (params, "%d", &i)) |
386 | { |
333 | { |
387 | sprintf (buf, "Global debug level is %d.", settings.debug); |
334 | sprintf (buf, "Global debug level is %d.", settings.debug); |
388 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
335 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
389 | return 1; |
|
|
390 | } |
|
|
391 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
|
|
392 | { |
|
|
393 | new_draw_info (NDI_UNIQUE, 0, op, "Privileged command."); |
|
|
394 | return 1; |
336 | return 1; |
395 | } |
337 | } |
396 | settings.debug = (enum LogLevel) FABS (i); |
338 | settings.debug = (enum LogLevel) FABS (i); |
397 | sprintf (buf, "Set debug level to %d.", i); |
339 | sprintf (buf, "Set debug level to %d.", i); |
398 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
340 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
… | |
… | |
456 | } |
398 | } |
457 | else |
399 | else |
458 | { |
400 | { |
459 | 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)); |
460 | } |
402 | } |
461 | } |
|
|
462 | |
|
|
463 | int |
|
|
464 | command_output_sync (object *op, char *params) |
|
|
465 | { |
|
|
466 | int val; |
|
|
467 | |
|
|
468 | if (!params) |
|
|
469 | { |
|
|
470 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time is presently %d", op->contr->outputs_sync); |
|
|
471 | return 1; |
|
|
472 | } |
|
|
473 | val = atoi (params); |
|
|
474 | if (val > 0) |
|
|
475 | { |
|
|
476 | op->contr->outputs_sync = val; |
|
|
477 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time now set to %d", op->contr->outputs_sync); |
|
|
478 | } |
|
|
479 | else |
|
|
480 | new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_sync."); |
|
|
481 | |
|
|
482 | return 1; |
|
|
483 | } |
|
|
484 | |
|
|
485 | int |
|
|
486 | command_output_count (object *op, char *params) |
|
|
487 | { |
|
|
488 | int val; |
|
|
489 | |
|
|
490 | if (!params) |
|
|
491 | { |
|
|
492 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output count is presently %d", op->contr->outputs_count); |
|
|
493 | return 1; |
|
|
494 | } |
|
|
495 | val = atoi (params); |
|
|
496 | if (val > 0) |
|
|
497 | { |
|
|
498 | op->contr->outputs_count = val; |
|
|
499 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output count now set to %d", op->contr->outputs_count); |
|
|
500 | } |
|
|
501 | else |
|
|
502 | new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_count."); |
|
|
503 | |
|
|
504 | return 1; |
|
|
505 | } |
|
|
506 | |
|
|
507 | int |
|
|
508 | command_listen (object *op, char *params) |
|
|
509 | { |
|
|
510 | int i; |
|
|
511 | |
|
|
512 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
513 | { |
|
|
514 | new_draw_info_format (NDI_UNIQUE, 0, op, "Set listen to what (presently %d)?", op->contr->listening); |
|
|
515 | return 1; |
|
|
516 | } |
|
|
517 | op->contr->listening = (char) i; |
|
|
518 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your verbose level is now %d.", i); |
|
|
519 | return 1; |
|
|
520 | } |
403 | } |
521 | |
404 | |
522 | /* Prints out some useful information for the character. Everything we print |
405 | /* Prints out some useful information for the character. Everything we print |
523 | * 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 - |
524 | * 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 |
… | |
… | |
556 | int |
439 | int |
557 | command_fix_me (object *op, char *params) |
440 | command_fix_me (object *op, char *params) |
558 | { |
441 | { |
559 | sum_weight (op); |
442 | sum_weight (op); |
560 | op->update_stats (); |
443 | op->update_stats (); |
561 | return 1; |
444 | new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed."); |
562 | } |
|
|
563 | |
445 | |
564 | int |
|
|
565 | command_players (object *op, char *paramss) |
|
|
566 | { |
|
|
567 | char buf[MAX_BUF]; |
|
|
568 | char *t; |
|
|
569 | DIR *Dir; |
|
|
570 | |
|
|
571 | sprintf (buf, "%s/%s/", settings.localdir, settings.playerdir); |
|
|
572 | t = buf + strlen (buf); |
|
|
573 | if ((Dir = opendir (buf)) != NULL) |
|
|
574 | { |
|
|
575 | const struct dirent *Entry; |
|
|
576 | |
|
|
577 | while ((Entry = readdir (Dir))) |
|
|
578 | { |
|
|
579 | /* skip '.' , '..' */ |
|
|
580 | if (!((Entry->d_name[0] == '.' && Entry->d_name[1] == '\0') || |
|
|
581 | (Entry->d_name[0] == '.' && Entry->d_name[1] == '.' && Entry->d_name[2] == '\0'))) |
|
|
582 | { |
|
|
583 | struct stat Stat; |
|
|
584 | |
|
|
585 | strcpy (t, Entry->d_name); |
|
|
586 | if (stat (buf, &Stat) == 0) |
|
|
587 | { |
|
|
588 | /* This was not posix compatible |
|
|
589 | * if ((Stat.st_mode & S_IFMT)==S_IFDIR) { |
|
|
590 | */ |
|
|
591 | if (S_ISDIR (Stat.st_mode)) |
|
|
592 | { |
|
|
593 | char buf2[MAX_BUF]; |
|
|
594 | struct tm *tm = localtime (&Stat.st_mtime); |
|
|
595 | |
|
|
596 | sprintf (buf2, "%s\t%04d %02d %02d %02d %02d %02d", |
|
|
597 | Entry->d_name, 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); |
|
|
598 | new_draw_info (NDI_UNIQUE, 0, op, buf2); |
|
|
599 | } |
|
|
600 | } |
|
|
601 | } |
|
|
602 | } |
|
|
603 | } |
|
|
604 | closedir (Dir); |
|
|
605 | return 0; |
446 | return 1; |
606 | } |
447 | } |
607 | |
|
|
608 | |
|
|
609 | |
448 | |
610 | int |
449 | int |
611 | command_logs (object *op, char *params) |
450 | command_logs (object *op, char *params) |
612 | { |
451 | { |
613 | 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."); |
614 | |
453 | |
615 | return 1; |
|
|
616 | } |
|
|
617 | |
|
|
618 | int |
|
|
619 | command_applymode (object *op, char *params) |
|
|
620 | { |
|
|
621 | unapplymode unapply = op->contr->unapply; |
|
|
622 | static const char *const types[] = { "nochoice", "never", "always" }; |
|
|
623 | |
|
|
624 | if (!params) |
|
|
625 | { |
|
|
626 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode is set to %s", types[op->contr->unapply]); |
|
|
627 | return 1; |
|
|
628 | } |
|
|
629 | |
|
|
630 | if (!strcmp (params, "nochoice")) |
|
|
631 | op->contr->unapply = unapply_nochoice; |
|
|
632 | else if (!strcmp (params, "never")) |
|
|
633 | op->contr->unapply = unapply_never; |
|
|
634 | else if (!strcmp (params, "always")) |
|
|
635 | op->contr->unapply = unapply_always; |
|
|
636 | else |
|
|
637 | { |
|
|
638 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params); |
|
|
639 | return 0; |
|
|
640 | } |
|
|
641 | new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s", |
|
|
642 | (unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]); |
|
|
643 | return 1; |
454 | return 1; |
644 | } |
455 | } |
645 | |
456 | |
646 | int |
457 | int |
647 | command_bowmode (object *op, char *params) |
458 | command_bowmode (object *op, char *params) |
… | |
… | |
667 | found++; |
478 | found++; |
668 | op->contr->bowtype = (bowtype_t) i; |
479 | op->contr->bowtype = (bowtype_t) i; |
669 | break; |
480 | break; |
670 | } |
481 | } |
671 | } |
482 | } |
|
|
483 | |
672 | if (!found) |
484 | if (!found) |
673 | { |
485 | { |
674 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
486 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
675 | for (i = 0; i <= bow_bestarrow; i++) |
487 | for (i = 0; i <= bow_bestarrow; i++) |
676 | { |
488 | { |
… | |
… | |
682 | strcat (buf, "."); |
494 | strcat (buf, "."); |
683 | } |
495 | } |
684 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
496 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
685 | return 0; |
497 | return 0; |
686 | } |
498 | } |
|
|
499 | |
687 | 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]); |
688 | return 1; |
|
|
689 | } |
|
|
690 | |
|
|
691 | int |
|
|
692 | command_petmode (object *op, char *params) |
|
|
693 | { |
|
|
694 | petmode_t oldtype = op->contr->petmode; |
|
|
695 | static const char *const types[] = { "normal", "sad", "defend", "arena" }; |
|
|
696 | |
|
|
697 | if (!params) |
|
|
698 | { |
|
|
699 | new_draw_info_format (NDI_UNIQUE, 0, op, "petmode is set to %s", types[op->contr->petmode]); |
|
|
700 | return 1; |
|
|
701 | } |
|
|
702 | |
|
|
703 | if (!strcmp (params, "normal")) |
|
|
704 | op->contr->petmode = pet_normal; |
|
|
705 | else if (!strcmp (params, "sad")) |
|
|
706 | op->contr->petmode = pet_sad; |
|
|
707 | else if (!strcmp (params, "defend")) |
|
|
708 | op->contr->petmode = pet_defend; |
|
|
709 | else if (!strcmp (params, "arena")) |
|
|
710 | op->contr->petmode = pet_arena; |
|
|
711 | else |
|
|
712 | { |
|
|
713 | new_draw_info_format (NDI_UNIQUE, 0, op, |
|
|
714 | "petmode: Unknown options %s, valid options are normal," "sad (seek and destroy), defend, arena", params); |
|
|
715 | return 0; |
|
|
716 | } |
|
|
717 | new_draw_info_format (NDI_UNIQUE, 0, op, "petmode %s set to %s", (oldtype == op->contr->petmode ? "" : "now"), types[op->contr->petmode]); |
|
|
718 | return 1; |
501 | return 1; |
719 | } |
502 | } |
720 | |
503 | |
721 | int |
504 | int |
722 | command_showpets (object *op, char *params) |
505 | command_showpets (object *op, char *params) |
… | |
… | |
763 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
546 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
764 | return 0; |
547 | return 0; |
765 | } |
548 | } |
766 | |
549 | |
767 | int |
550 | int |
768 | command_usekeys (object *op, char *params) |
|
|
769 | { |
|
|
770 | usekeytype oldtype = op->contr->usekeys; |
|
|
771 | static const char *const types[] = { "inventory", "keyrings", "containers" }; |
|
|
772 | |
|
|
773 | if (!params) |
|
|
774 | { |
|
|
775 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys is set to %s", types[op->contr->usekeys]); |
|
|
776 | return 1; |
|
|
777 | } |
|
|
778 | |
|
|
779 | if (!strcmp (params, "inventory")) |
|
|
780 | op->contr->usekeys = key_inventory; |
|
|
781 | else if (!strcmp (params, "keyrings")) |
|
|
782 | op->contr->usekeys = keyrings; |
|
|
783 | else if (!strcmp (params, "containers")) |
|
|
784 | op->contr->usekeys = containers; |
|
|
785 | else |
|
|
786 | { |
|
|
787 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys: Unknown options %s, valid options are inventory, keyrings, containers", params); |
|
|
788 | return 0; |
|
|
789 | } |
|
|
790 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys %s set to %s", (oldtype == op->contr->usekeys ? "" : "now"), types[op->contr->usekeys]); |
|
|
791 | return 1; |
|
|
792 | } |
|
|
793 | |
|
|
794 | int |
|
|
795 | command_resistances (object *op, char *params) |
551 | command_resistances (object *op, char *params) |
796 | { |
552 | { |
797 | int i; |
553 | int i; |
798 | |
554 | |
799 | if (!op) |
555 | if (!op) |
… | |
… | |
865 | |
621 | |
866 | if (!(dirp = opendir (filename))) |
622 | if (!(dirp = opendir (filename))) |
867 | return; |
623 | return; |
868 | |
624 | |
869 | line[0] = '\0'; |
625 | line[0] = '\0'; |
870 | while (de = readdir (dirp)) |
626 | while ((de = readdir (dirp))) |
871 | { |
627 | { |
872 | namelen = strlen (de->d_name); |
628 | namelen = strlen (de->d_name); |
873 | 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] == '.')) |
874 | continue; |
630 | continue; |
875 | linelen += namelen + 1; |
631 | linelen += namelen + 1; |
… | |
… | |
1082 | return 0; |
838 | return 0; |
1083 | } |
839 | } |
1084 | } |
840 | } |
1085 | |
841 | |
1086 | int |
842 | int |
1087 | command_sound (object *op, char *params) |
|
|
1088 | { |
|
|
1089 | if (op->contr->ns->sound) |
|
|
1090 | { |
|
|
1091 | op->contr->ns->sound = 0; |
|
|
1092 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
|
|
1093 | } |
|
|
1094 | else |
|
|
1095 | { |
|
|
1096 | op->contr->ns->sound = 1; |
|
|
1097 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
|
|
1098 | } |
|
|
1099 | |
|
|
1100 | return 1; |
|
|
1101 | } |
|
|
1102 | |
|
|
1103 | int |
|
|
1104 | command_title (object *op, char *params) |
843 | command_title (object *op, char *params) |
1105 | { |
844 | { |
1106 | char buf[MAX_BUF]; |
845 | char buf[MAX_BUF]; |
1107 | |
846 | |
1108 | if (settings.set_title == FALSE) |
847 | if (settings.set_title == FALSE) |
… | |
… | |
1142 | new_draw_info (NDI_UNIQUE, 0, op, "Title too long."); |
881 | new_draw_info (NDI_UNIQUE, 0, op, "Title too long."); |
1143 | return 1; |
882 | return 1; |
1144 | } |
883 | } |
1145 | strcpy (op->contr->own_title, params); |
884 | strcpy (op->contr->own_title, params); |
1146 | return 1; |
885 | return 1; |
1147 | } |
|
|
1148 | |
|
|
1149 | int |
|
|
1150 | command_peaceful (object *op, char *params) |
|
|
1151 | { |
|
|
1152 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1153 | "You cannot change your peaceful setting with this command." |
|
|
1154 | " Please speak to the priest in the temple of Gorokh" |
|
|
1155 | " if you want to become hostile or in temple of Valriel" " if you want to become peaceful again."); |
|
|
1156 | |
|
|
1157 | /* |
|
|
1158 | if((op->contr->peaceful=!op->contr->peaceful)) |
|
|
1159 | new_draw_info(NDI_UNIQUE, 0,op,"You will not attack other players."); |
|
|
1160 | else |
|
|
1161 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
|
|
1162 | */ |
|
|
1163 | return 1; |
|
|
1164 | } |
|
|
1165 | |
|
|
1166 | int |
|
|
1167 | command_wimpy (object *op, char *params) |
|
|
1168 | { |
|
|
1169 | int i; |
|
|
1170 | char buf[MAX_BUF]; |
|
|
1171 | |
|
|
1172 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
1173 | { |
|
|
1174 | sprintf (buf, "Your current wimpy level is %d.", op->run_away); |
|
|
1175 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1176 | return 1; |
|
|
1177 | } |
|
|
1178 | sprintf (buf, "Your new wimpy level is %d.", i); |
|
|
1179 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1180 | op->run_away = i; |
|
|
1181 | return 1; |
|
|
1182 | } |
|
|
1183 | |
|
|
1184 | int |
|
|
1185 | command_brace (object *op, char *params) |
|
|
1186 | { |
|
|
1187 | if (!params) |
|
|
1188 | op->contr->braced = !op->contr->braced; |
|
|
1189 | else |
|
|
1190 | op->contr->braced = onoff_value (params); |
|
|
1191 | |
|
|
1192 | if (op->contr->braced) |
|
|
1193 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
|
|
1194 | else |
|
|
1195 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
|
|
1196 | |
|
|
1197 | op->update_stats (); |
|
|
1198 | return 0; |
|
|
1199 | } |
886 | } |
1200 | |
887 | |
1201 | int |
888 | int |
1202 | command_kill_pets (object *op, char *params) |
889 | command_kill_pets (object *op, char *params) |
1203 | { |
890 | { |