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.35 by root, Sun Jan 7 02:39:14 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
25#include <loader.h> 26#include <loader.h>
26#include <sproto.h> 27#include <sproto.h>
27 28
28#include <dirent.h> 29#include <dirent.h>
29 30
30extern weathermap_t **weathermap;
31
32/* Handles misc. input request - things like hash table, malloc, maps, 31/* Handles misc. input request - things like hash table, malloc, maps,
33 * who, etc. 32 * who, etc.
34 */ 33 */
35 34
35//TODO
36#if 0
36void 37void
37map_info (object *op, char *search) 38map_info (object *op, char *search)
38{ 39{
39 maptile *m; 40 maptile *m;
40 char buf[MAX_BUF], map_path[MAX_BUF]; 41 char buf[MAX_BUF], map_path[31];
41 long sec = time (0); 42 long sec = time (0);
42 43
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_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 new_draw_info (NDI_UNIQUE, 0, op, "Path Pl PlM IM TO Dif Reset");
45 46
46 for_all_maps (m) 47 for (maps_container::iterator i = maps.begin (); i != maps.end (); ++i)
47 { 48 {
49 maptile *m = i->second;
50
48 if (search && !strstr (m->path, search)) 51 if (search && !strstr (m->path, search))
49 continue; /* Skip unwanted maps */ 52 continue; /* Skip unwanted maps */
50 53
51 /* Print out the last 18 characters of the map name... */ 54 /* Print out the last 30 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); 55 strcpy (map_path, m->path + max (0, (int)strlen (m->path) - 30));
56 56
57 sprintf (buf, "%-18.18s %2d %2d %1d %4d %2d %02d:%02d:%02d", 57 sprintf (buf, "%-30.30s %2d %2d %1d %4d %2d %02d:%02d:%02d",
58 map_path, m->players, players_on_map (m, FALSE), 58 map_path, m->players, players_on_map (m, FALSE),
59 m->in_memory, m->timeout, m->difficulty, 59 m->in_memory, m->timeout, m->difficulty,
60 (m->reset_time % 86400) / 3600, (m->reset_time % 3600) / 60, m->reset_time % 60); 60 (m->reset_time % 86400) / 3600, (m->reset_time % 3600) / 60, m->reset_time % 60);
61 new_draw_info (NDI_UNIQUE, 0, op, buf); 61 new_draw_info (NDI_UNIQUE, 0, op, buf);
62 } 62 }
63} 63}
64
65int
66command_style_map_info (object *op, char *params)
67{
68 extern maptile *styles;
69 maptile *mp;
70 int maps_used = 0, mapmem = 0, objects_used = 0, x, y;
71 object *tmp;
72
73 for (mp = styles; mp != NULL; mp = mp->next)
74 {
75 maps_used++;
76 mapmem += mp->width * mp->height * (sizeof (object *) + sizeof (mapspace)) + sizeof (maptile);
77 for (x = 0; x < mp->width; x++)
78 {
79 for (y = 0; y < mp->height; y++)
80 {
81 for (tmp = GET_MAP_OB (mp, x, y); tmp != NULL; tmp = tmp->above)
82 objects_used++;
83 }
84 }
85 }
86 new_draw_info_format (NDI_UNIQUE, 0, op, "Style maps loaded: %d", maps_used);
87 new_draw_info (NDI_UNIQUE, 0, op, "Memory used, not");
88 new_draw_info_format (NDI_UNIQUE, 0, op, "including objects: %d", mapmem);
89 new_draw_info_format (NDI_UNIQUE, 0, op, "Style objects: %d", objects_used);
90 new_draw_info_format (NDI_UNIQUE, 0, op, "Mem for objects: %d", objects_used * sizeof (object));
91 return 0;
92}
93#endif
64 94
65/* This command dumps the body information for object *op. 95/* This command dumps the body information for object *op.
66 * it doesn't care what the params are. 96 * it doesn't care what the params are.
67 * This is mostly meant as a debug command. 97 * This is mostly meant as a debug command.
68 */ 98 */
151 maptile *m = op->map; 181 maptile *m = op->map;
152 182
153 if (!m) 183 if (!m)
154 return; 184 return;
155 185
156 new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) in %s", m->name, m->path, get_name_of_region_for_map (m)); 186 new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) in %s", &m->name, &m->path, get_name_of_region_for_map (m));
157 187
158 if (QUERY_FLAG (op, FLAG_WIZ)) 188 if (QUERY_FLAG (op, FLAG_WIZ))
159 { 189 {
160 new_draw_info_format (NDI_UNIQUE, 0, op, 190 new_draw_info_format (NDI_UNIQUE, 0, op,
161 "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld", 191 "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld",
251 current_region_info (op); 281 current_region_info (op);
252 return 1; 282 return 1;
253} 283}
254 284
255int 285int
256command_maps (object *op, char *params)
257{
258 map_info (op, params);
259 return 1;
260}
261
262int
263command_time (object *op, char *params) 286command_time (object *op, char *params)
264{ 287{
265 print_tod (op); 288 print_tod (op);
266 return 1; 289 return 1;
267} 290}
268 291
269int 292int
270command_weather (object *op, char *params) 293command_weather (object *op, char *params)
271{ 294{
295#if 0
272 int wx, wy, temp, sky; 296 int wx, wy, temp, sky;
273 char buf[MAX_BUF]; 297 char buf[MAX_BUF];
274 298
275 if (settings.dynamiclevel < 1) 299 if (settings.dynamiclevel < 1)
276 return 1; 300 return 1;
392 break; 416 break;
393 case SKY_BLIZZARD: 417 case SKY_BLIZZARD:
394 new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); 418 new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!");
395 break; 419 break;
396 } 420 }
421#endif
397 return 1; 422 return 1;
398} 423}
399 424
400int 425int
401command_archs (object *op, char *params) 426command_archs (object *op, char *params)
459 dump_friendly_objects (); 484 dump_friendly_objects ();
460 return 0; 485 return 0;
461} 486}
462 487
463int 488int
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) 489command_printlos (object *op, char *params)
480{ 490{
481 if (op) 491 if (op)
482 print_los (op); 492 print_los (op);
483 return 0; 493 return 0;
488command_version (object *op, char *params) 498command_version (object *op, char *params)
489{ 499{
490 version (op); 500 version (op);
491 return 0; 501 return 0;
492} 502}
493
494 503
495#ifndef BUG_LOG 504#ifndef BUG_LOG
496# define BUG_LOG "bug_log" 505# define BUG_LOG "bug_log"
497#endif 506#endif
498void 507void
1133 return 0; 1142 return 0;
1134 } 1143 }
1135} 1144}
1136 1145
1137int 1146int
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) 1147command_sound (object *op, char *params)
1183{ 1148{
1184 if (op->contr->ns->sound) 1149 if (op->contr->ns->sound)
1185 { 1150 {
1186 op->contr->ns->sound = 0; 1151 op->contr->ns->sound = 0;
1191 op->contr->ns->sound = 1; 1156 op->contr->ns->sound = 1;
1192 new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); 1157 new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled.");
1193 } 1158 }
1194 1159
1195 return 1; 1160 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} 1161}
1211 1162
1212int 1163int
1213command_title (object *op, char *params) 1164command_title (object *op, char *params)
1214{ 1165{
1254 strcpy (op->contr->own_title, params); 1205 strcpy (op->contr->own_title, params);
1255 return 1; 1206 return 1;
1256} 1207}
1257 1208
1258int 1209int
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) 1210command_peaceful (object *op, char *params)
1274{ 1211{
1275 new_draw_info (NDI_UNIQUE, 0, op, 1212 new_draw_info (NDI_UNIQUE, 0, op,
1276 "You cannot change your peaceful setting with this command." 1213 "You cannot change your peaceful setting with this command."
1277 " Please speak to the priest in the temple of Gorokh" 1214 " Please speak to the priest in the temple of Gorokh"
1316 new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); 1253 new_draw_info (NDI_UNIQUE, 0, op, "You are braced.");
1317 else 1254 else
1318 new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); 1255 new_draw_info (NDI_UNIQUE, 0, op, "Not braced.");
1319 1256
1320 op->update_stats (); 1257 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; 1258 return 0;
1351} 1259}
1352 1260
1353int 1261int
1354command_kill_pets (object *op, char *params) 1262command_kill_pets (object *op, char *params)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines