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.31 by root, Wed Dec 27 09:28:02 2006 UTC vs.
Revision 1.49 by pippijn, Fri Mar 2 10:15:40 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
3 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 11 * (at your option) any later version.
11 12 *
12 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,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 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
18 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 21 *
21 The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail at <crossfire@schmorp.de>
22*/ 23 */
23 24
24#include <global.h> 25#include <global.h>
25#include <loader.h> 26#include <loader.h>
26#include <sproto.h> 27#include <sproto.h>
27 28
28#include <dirent.h>
29
30extern weathermap_t **weathermap;
31
32/* Handles misc. input request - things like hash table, malloc, maps, 29/* Handles misc. input request - things like hash table, malloc, maps,
33 * who, etc. 30 * who, etc.
34 */ 31 */
35
36void
37map_info (object *op, char *search)
38{
39 maptile *m;
40 char buf[MAX_BUF], map_path[MAX_BUF];
41 long sec = time (0);
42
43 new_draw_info_format (NDI_UNIQUE, 0, op, "Current time is: %02ld:%02ld:%02ld.", (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60);
44 new_draw_info (NDI_UNIQUE, 0, op, "Path Pl PlM IM TO Dif Reset");
45
46 for_all_maps (m)
47 {
48 if (search && !strstr (m->path, search))
49 continue; /* Skip unwanted maps */
50
51 /* Print out the last 18 characters of the map name... */
52 if (strlen (m->path) <= 18)
53 strcpy (map_path, m->path);
54 else
55 strcpy (map_path, m->path + strlen (m->path) - 18);
56
57 sprintf (buf, "%-18.18s %2d %2d %1d %4d %2d %02d:%02d:%02d",
58 map_path, m->players, players_on_map (m, FALSE),
59 m->in_memory, m->timeout, m->difficulty,
60 (m->reset_time % 86400) / 3600, (m->reset_time % 3600) / 60, m->reset_time % 60);
61 new_draw_info (NDI_UNIQUE, 0, op, buf);
62 }
63}
64 32
65/* This command dumps the body information for object *op. 33/* This command dumps the body information for object *op.
66 * it doesn't care what the params are. 34 * it doesn't care what the params are.
67 * This is mostly meant as a debug command. 35 * This is mostly meant as a debug command.
68 */ 36 */
101{ 69{
102 display_motd (op); 70 display_motd (op);
103 return 1; 71 return 1;
104} 72}
105 73
106int
107command_bug (object *op, char *params)
108{
109 char buf[MAX_BUF];
110
111 if (params == NULL)
112 {
113 new_draw_info (NDI_UNIQUE, 0, op, "what bugs?");
114 return 1;
115 }
116 strcpy (buf, op->name);
117 strcat (buf, " bug-reports: ");
118 strncat (buf, ++params, MAX_BUF - strlen (buf));
119 buf[MAX_BUF - 1] = '\0';
120 bug_report (buf);
121 LOG (llevError, "%s\n", buf);
122 new_draw_info (NDI_ALL | NDI_UNIQUE, 1, NULL, buf);
123 new_draw_info (NDI_UNIQUE, 0, op, "OK, thanks!");
124 return 1;
125}
126
127/* 74/*
128 * 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
129 * This function returns the name of the players current region, and 76 * This function returns the name of the players current region, and
130 * a description of it. It is there merely for flavour text. 77 * a description of it. It is there merely for flavour text.
131 */ 78 */
132void 79void
133current_region_info (object *op) 80current_region_info (object *op)
134{ 81{
135 /* 82 if (region *reg = op->region ())
136 * Ok I /suppose/ I should write a seperate function for this, but it isn't
137 * going to be /that/ slow, and won't get called much
138 */
139 region *r = get_region_by_name (get_name_of_region_for_map (op->map));
140
141 if (!r)
142 return;
143 /* This should only be possible if regions are not operating on this server. */
144
145 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", &reg->longname, &reg->msg);
146} 84}
147 85
148void 86void
149current_map_info (object *op) 87current_map_info (object *op)
150{ 88{
151 maptile *m = op->map; 89 maptile *m = op->map;
152 90
153 if (!m) 91 if (!m)
154 return; 92 return;
155 93
156 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);
157 95
158 if (QUERY_FLAG (op, FLAG_WIZ)) 96 if (QUERY_FLAG (op, FLAG_WIZ))
159 {
160 new_draw_info_format (NDI_UNIQUE, 0, op, 97 new_draw_info_format (NDI_UNIQUE, 0, op,
161 "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",
162 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);
163 100
164 }
165 if (m->msg) 101 if (m->msg)
166 new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); 102 new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg);
167} 103}
168 104
169#ifdef DEBUG_MALLOC_LEVEL 105#ifdef DEBUG_MALLOC_LEVEL
181#endif 117#endif
182 118
183int 119int
184command_whereabouts (object *op, char *params) 120command_whereabouts (object *op, char *params)
185{ 121{
186 122 //TODO: should obviously not waste space in struct region for this.
187 region *reg;
188 player *pl;
189
190 /* 123 /*
191 * 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
192 * players there. 125 * players there.
193 * 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....
194 */ 127 */
195 for (reg = first_region; reg != NULL; reg = reg->next) 128 for_all_regions (rgn)
196 {
197 reg->counter = 0; 129 rgn->counter = 0;
198 } 130
199 for_all_players (pl) 131 for_all_players (pl)
200 if (pl->ob->map != NULL) 132 if (pl->ob->map)
201 get_region_by_map (pl->ob->map)->counter++; 133 ++pl->ob->region ()->counter;
202 134
203 /* 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... */
204 for (reg = first_region; reg != NULL; reg = reg->next) 136 for_all_regions (rgn)
205 { 137 {
206 if (reg->longname == NULL && reg->counter > 0) 138 if (!rgn->longname && rgn->counter > 0)
207 { 139 {
208 if (reg->parent != NULL) 140 if (rgn->parent)
209 { 141 {
210 reg->parent->counter += reg->counter; 142 rgn->parent->counter += rgn->counter;
211 reg->counter = 0; 143 rgn->counter = 0;
212 } 144 }
213 else /*uh oh, we shouldn't be here. */ 145 else /*uh oh, we shouldn't be here. */
214 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);
215 } 147 }
216 } 148 }
149
217 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:");
218 for (reg = first_region; reg != NULL; reg = reg->next) 151
152 for_all_regions (rgn)
219 if (reg->counter > 0) 153 if (rgn->counter)
220 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
221 return 1; 156 return 1;
222} 157}
223 158
224typedef struct 159typedef struct
225{ 160{
226 char namebuf[MAX_BUF]; 161 char namebuf[MAX_BUF];
227 int login_order; 162 int login_order;
228} chars_names; 163} chars_names;
229 164
230int 165int
231command_afk (object *op, char *params)
232{
233 if ((op->contr->ns->afk = !op->contr->ns->afk))
234 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer AFK");
235 else
236 new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK");
237
238 return 1;
239}
240
241int
242command_mapinfo (object *op, char *params) 166command_mapinfo (object *op, char *params)
243{ 167{
244 current_map_info (op); 168 current_map_info (op);
245 return 1; 169 return 1;
246} 170}
251 current_region_info (op); 175 current_region_info (op);
252 return 1; 176 return 1;
253} 177}
254 178
255int 179int
256command_maps (object *op, char *params)
257{
258 map_info (op, params);
259 return 1;
260}
261
262int
263command_time (object *op, char *params) 180command_time (object *op, char *params)
264{ 181{
265 print_tod (op); 182 print_tod (op);
266 return 1; 183 return 1;
267} 184}
268 185
269int 186int
270command_weather (object *op, char *params) 187command_weather (object *op, char *params)
271{ 188{
189#if 0
272 int wx, wy, temp, sky; 190 int wx, wy, temp, sky;
273 char buf[MAX_BUF]; 191 char buf[MAX_BUF];
274 192
275 if (settings.dynamiclevel < 1) 193 if (settings.dynamiclevel < 1)
276 return 1; 194 return 1;
392 break; 310 break;
393 case SKY_BLIZZARD: 311 case SKY_BLIZZARD:
394 new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); 312 new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!");
395 break; 313 break;
396 } 314 }
397 return 1; 315#endif
398}
399
400int
401command_archs (object *op, char *params)
402{
403 arch_info (op);
404 return 1; 316 return 1;
405} 317}
406 318
407int 319int
408command_hiscore (object *op, char *params) 320command_hiscore (object *op, char *params)
419 331
420 if (params == NULL || !sscanf (params, "%d", &i)) 332 if (params == NULL || !sscanf (params, "%d", &i))
421 { 333 {
422 sprintf (buf, "Global debug level is %d.", settings.debug); 334 sprintf (buf, "Global debug level is %d.", settings.debug);
423 new_draw_info (NDI_UNIQUE, 0, op, buf); 335 new_draw_info (NDI_UNIQUE, 0, op, buf);
424 return 1;
425 }
426 if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ))
427 {
428 new_draw_info (NDI_UNIQUE, 0, op, "Privileged command.");
429 return 1; 336 return 1;
430 } 337 }
431 settings.debug = (enum LogLevel) FABS (i); 338 settings.debug = (enum LogLevel) FABS (i);
432 sprintf (buf, "Set debug level to %d.", i); 339 sprintf (buf, "Set debug level to %d.", i);
433 new_draw_info (NDI_UNIQUE, 0, op, buf); 340 new_draw_info (NDI_UNIQUE, 0, op, buf);
459 dump_friendly_objects (); 366 dump_friendly_objects ();
460 return 0; 367 return 0;
461} 368}
462 369
463int 370int
464command_dumpmap (object *op, char *params)
465{
466 if (op)
467 dump_map (op->map);
468 return 0;
469}
470
471int
472command_dumpallmaps (object *op, char *params)
473{
474 dump_all_maps ();
475 return 0;
476}
477
478int
479command_printlos (object *op, char *params) 371command_printlos (object *op, char *params)
480{ 372{
481 if (op) 373 if (op)
482 print_los (op); 374 print_los (op);
483 return 0; 375 return 0;
488command_version (object *op, char *params) 380command_version (object *op, char *params)
489{ 381{
490 version (op); 382 version (op);
491 return 0; 383 return 0;
492} 384}
493
494 385
495#ifndef BUG_LOG 386#ifndef BUG_LOG
496# define BUG_LOG "bug_log" 387# define BUG_LOG "bug_log"
497#endif 388#endif
498void 389void
550 new_draw_info_format (NDI_UNIQUE, 0, op, "Output count now set to %d", op->contr->outputs_count); 441 new_draw_info_format (NDI_UNIQUE, 0, op, "Output count now set to %d", op->contr->outputs_count);
551 } 442 }
552 else 443 else
553 new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_count."); 444 new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_count.");
554 445
555 return 1;
556}
557
558int
559command_listen (object *op, char *params)
560{
561 int i;
562
563 if (params == NULL || !sscanf (params, "%d", &i))
564 {
565 new_draw_info_format (NDI_UNIQUE, 0, op, "Set listen to what (presently %d)?", op->contr->listening);
566 return 1;
567 }
568 op->contr->listening = (char) i;
569 new_draw_info_format (NDI_UNIQUE, 0, op, "Your verbose level is now %d.", i);
570 return 1; 446 return 1;
571} 447}
572 448
573/* Prints out some useful information for the character. Everything we print 449/* Prints out some useful information for the character. Everything we print
574 * out can be determined by the docs, so we aren't revealing anything extra - 450 * out can be determined by the docs, so we aren't revealing anything extra -
611 op->update_stats (); 487 op->update_stats ();
612 return 1; 488 return 1;
613} 489}
614 490
615int 491int
616command_players (object *op, char *paramss)
617{
618 char buf[MAX_BUF];
619 char *t;
620 DIR *Dir;
621
622 sprintf (buf, "%s/%s/", settings.localdir, settings.playerdir);
623 t = buf + strlen (buf);
624 if ((Dir = opendir (buf)) != NULL)
625 {
626 const struct dirent *Entry;
627
628 while ((Entry = readdir (Dir)))
629 {
630 /* skip '.' , '..' */
631 if (!((Entry->d_name[0] == '.' && Entry->d_name[1] == '\0') ||
632 (Entry->d_name[0] == '.' && Entry->d_name[1] == '.' && Entry->d_name[2] == '\0')))
633 {
634 struct stat Stat;
635
636 strcpy (t, Entry->d_name);
637 if (stat (buf, &Stat) == 0)
638 {
639 /* This was not posix compatible
640 * if ((Stat.st_mode & S_IFMT)==S_IFDIR) {
641 */
642 if (S_ISDIR (Stat.st_mode))
643 {
644 char buf2[MAX_BUF];
645 struct tm *tm = localtime (&Stat.st_mtime);
646
647 sprintf (buf2, "%s\t%04d %02d %02d %02d %02d %02d",
648 Entry->d_name, 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
649 new_draw_info (NDI_UNIQUE, 0, op, buf2);
650 }
651 }
652 }
653 }
654 }
655 closedir (Dir);
656 return 0;
657}
658
659
660
661int
662command_logs (object *op, char *params) 492command_logs (object *op, char *params)
663{ 493{
664 new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); 494 new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills.");
665 495
666 return 1; 496 return 1;
687 else 517 else
688 { 518 {
689 new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params); 519 new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params);
690 return 0; 520 return 0;
691 } 521 }
522
692 new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s", 523 new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s",
693 (unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]); 524 (unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]);
694 return 1; 525 return 1;
695} 526}
696 527
718 found++; 549 found++;
719 op->contr->bowtype = (bowtype_t) i; 550 op->contr->bowtype = (bowtype_t) i;
720 break; 551 break;
721 } 552 }
722 } 553 }
554
723 if (!found) 555 if (!found)
724 { 556 {
725 sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); 557 sprintf (buf, "bowmode: Unknown options %s, valid options are:", params);
726 for (i = 0; i <= bow_bestarrow; i++) 558 for (i = 0; i <= bow_bestarrow; i++)
727 { 559 {
733 strcat (buf, "."); 565 strcat (buf, ".");
734 } 566 }
735 new_draw_info_format (NDI_UNIQUE, 0, op, buf); 567 new_draw_info_format (NDI_UNIQUE, 0, op, buf);
736 return 0; 568 return 0;
737 } 569 }
570
738 new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); 571 new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]);
739 return 1; 572 return 1;
740} 573}
741 574
742int 575int
916 749
917 if (!(dirp = opendir (filename))) 750 if (!(dirp = opendir (filename)))
918 return; 751 return;
919 752
920 line[0] = '\0'; 753 line[0] = '\0';
921 while (de = readdir (dirp)) 754 while ((de = readdir (dirp)))
922 { 755 {
923 namelen = strlen (de->d_name); 756 namelen = strlen (de->d_name);
924 if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) 757 if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.'))
925 continue; 758 continue;
926 linelen += namelen + 1; 759 linelen += namelen + 1;
1133 return 0; 966 return 0;
1134 } 967 }
1135} 968}
1136 969
1137int 970int
1138command_quit (object *op, char *params)
1139{
1140 new_draw_info (NDI_UNIQUE, 0, op,
1141 "Quitting will delete your character PERMANENTLY. If you are sure you want to do this, then use the quit_character command instead of quit.");
1142 return 1;
1143}
1144
1145int
1146command_real_quit (object *op, char *params)
1147{
1148 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Quitting will delete your character.\nAre you sure you want to quit (y/n):");
1149
1150 op->contr->ns->state = ST_CONFIRM_QUIT;
1151 return 1;
1152}
1153
1154/*
1155 * don't allow people to exit explore mode. It otherwise becomes
1156 * really easy to abuse this.
1157 */
1158int
1159command_explore (object *op, char *params)
1160{
1161 if (settings.explore_mode == FALSE)
1162 return 1;
1163 /*
1164 * I guess this is the best way to see if we are solo or not. Actually,
1165 * are there any cases when first_player->next==NULL and we are not solo?
1166 */
1167 if ((first_player != op->contr) || (first_player->next != NULL))
1168 {
1169 new_draw_info (NDI_UNIQUE, 0, op, "You can not enter explore mode if you are in a party");
1170 }
1171 else if (op->contr->explore)
1172 new_draw_info (NDI_UNIQUE, 0, op, "There is no return from explore mode");
1173 else
1174 {
1175 op->contr->explore = 1;
1176 new_draw_info (NDI_UNIQUE, 0, op, "You are now in explore mode");
1177 }
1178 return 1;
1179}
1180
1181int
1182command_sound (object *op, char *params) 971command_sound (object *op, char *params)
1183{ 972{
1184 if (op->contr->ns->sound) 973 if (op->contr->ns->sound)
1185 { 974 {
1186 op->contr->ns->sound = 0; 975 op->contr->ns->sound = 0;
1191 op->contr->ns->sound = 1; 980 op->contr->ns->sound = 1;
1192 new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); 981 new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled.");
1193 } 982 }
1194 983
1195 return 1; 984 return 1;
1196}
1197
1198int
1199explore_mode (void)
1200{
1201 player *pl;
1202
1203 if (settings.explore_mode == TRUE)
1204 {
1205 for (pl = first_player; pl != (player *) NULL; pl = pl->next)
1206 if (pl->explore)
1207 return 1;
1208 }
1209 return 0;
1210} 985}
1211 986
1212int 987int
1213command_title (object *op, char *params) 988command_title (object *op, char *params)
1214{ 989{
1251 new_draw_info (NDI_UNIQUE, 0, op, "Title too long."); 1026 new_draw_info (NDI_UNIQUE, 0, op, "Title too long.");
1252 return 1; 1027 return 1;
1253 } 1028 }
1254 strcpy (op->contr->own_title, params); 1029 strcpy (op->contr->own_title, params);
1255 return 1; 1030 return 1;
1256}
1257
1258int
1259command_save (object *op, char *params)
1260{
1261 if (!op->stats.exp)
1262 new_draw_info (NDI_UNIQUE, 0, op, "You don't deserve to save yet.");
1263 else
1264 {
1265 op->contr->save ();
1266 new_draw_info (NDI_UNIQUE, 0, op, "You have been saved.");
1267 }
1268
1269 return 1;
1270}
1271
1272int
1273command_peaceful (object *op, char *params)
1274{
1275 new_draw_info (NDI_UNIQUE, 0, op,
1276 "You cannot change your peaceful setting with this command."
1277 " Please speak to the priest in the temple of Gorokh"
1278 " if you want to become hostile or in temple of Valriel" " if you want to become peaceful again.");
1279
1280/*
1281 if((op->contr->peaceful=!op->contr->peaceful))
1282 new_draw_info(NDI_UNIQUE, 0,op,"You will not attack other players.");
1283 else
1284 new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players.");
1285*/
1286 return 1;
1287}
1288
1289int
1290command_wimpy (object *op, char *params)
1291{
1292 int i;
1293 char buf[MAX_BUF];
1294
1295 if (params == NULL || !sscanf (params, "%d", &i))
1296 {
1297 sprintf (buf, "Your current wimpy level is %d.", op->run_away);
1298 new_draw_info (NDI_UNIQUE, 0, op, buf);
1299 return 1;
1300 }
1301 sprintf (buf, "Your new wimpy level is %d.", i);
1302 new_draw_info (NDI_UNIQUE, 0, op, buf);
1303 op->run_away = i;
1304 return 1;
1305}
1306
1307int
1308command_brace (object *op, char *params)
1309{
1310 if (!params)
1311 op->contr->braced = !op->contr->braced;
1312 else
1313 op->contr->braced = onoff_value (params);
1314
1315 if (op->contr->braced)
1316 new_draw_info (NDI_UNIQUE, 0, op, "You are braced.");
1317 else
1318 new_draw_info (NDI_UNIQUE, 0, op, "Not braced.");
1319
1320 op->update_stats ();
1321 return 0;
1322}
1323
1324int
1325command_style_map_info (object *op, char *params)
1326{
1327 extern maptile *styles;
1328 maptile *mp;
1329 int maps_used = 0, mapmem = 0, objects_used = 0, x, y;
1330 object *tmp;
1331
1332 for (mp = styles; mp != NULL; mp = mp->next)
1333 {
1334 maps_used++;
1335 mapmem += mp->width * mp->height * (sizeof (object *) + sizeof (mapspace)) + sizeof (maptile);
1336 for (x = 0; x < mp->width; x++)
1337 {
1338 for (y = 0; y < mp->height; y++)
1339 {
1340 for (tmp = GET_MAP_OB (mp, x, y); tmp != NULL; tmp = tmp->above)
1341 objects_used++;
1342 }
1343 }
1344 }
1345 new_draw_info_format (NDI_UNIQUE, 0, op, "Style maps loaded: %d", maps_used);
1346 new_draw_info (NDI_UNIQUE, 0, op, "Memory used, not");
1347 new_draw_info_format (NDI_UNIQUE, 0, op, "including objects: %d", mapmem);
1348 new_draw_info_format (NDI_UNIQUE, 0, op, "Style objects: %d", objects_used);
1349 new_draw_info_format (NDI_UNIQUE, 0, op, "Mem for objects: %d", objects_used * sizeof (object));
1350 return 0;
1351} 1031}
1352 1032
1353int 1033int
1354command_kill_pets (object *op, char *params) 1034command_kill_pets (object *op, char *params)
1355{ 1035{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines