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.32 by root, Wed Dec 27 13:13:47 2006 UTC vs.
Revision 1.33 by root, Sat Dec 30 10:16:11 2006 UTC

25#include <loader.h> 25#include <loader.h>
26#include <sproto.h> 26#include <sproto.h>
27 27
28#include <dirent.h> 28#include <dirent.h>
29 29
30extern weathermap_t **weathermap;
31
32/* Handles misc. input request - things like hash table, malloc, maps, 30/* Handles misc. input request - things like hash table, malloc, maps,
33 * who, etc. 31 * who, etc.
34 */ 32 */
35 33
34//TODO
35#if 0
36void 36void
37map_info (object *op, char *search) 37map_info (object *op, char *search)
38{ 38{
39 maptile *m; 39 maptile *m;
40 char buf[MAX_BUF], map_path[31]; 40 char buf[MAX_BUF], map_path[31];
41 long sec = time (0); 41 long sec = time (0);
42 42
43 new_draw_info_format (NDI_UNIQUE, 0, op, "Current time is: %02ld:%02ld:%02ld.", (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60); 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"); 44 new_draw_info (NDI_UNIQUE, 0, op, "Path Pl PlM IM TO Dif Reset");
45 45
46 for_all_maps (m) 46 for (maps_container::iterator i = maps.begin (); i != maps.end (); ++i)
47 { 47 {
48 maptile *m = i->second;
49
48 if (search && !strstr (m->path, search)) 50 if (search && !strstr (m->path, search))
49 continue; /* Skip unwanted maps */ 51 continue; /* Skip unwanted maps */
50 52
51 /* Print out the last 30 characters of the map name... */ 53 /* Print out the last 30 characters of the map name... */
52 strcpy (map_path, m->path + max (0, (int)strlen (m->path) - 30)); 54 strcpy (map_path, m->path + max (0, (int)strlen (m->path) - 30));
56 m->in_memory, m->timeout, m->difficulty, 58 m->in_memory, m->timeout, m->difficulty,
57 (m->reset_time % 86400) / 3600, (m->reset_time % 3600) / 60, m->reset_time % 60); 59 (m->reset_time % 86400) / 3600, (m->reset_time % 3600) / 60, m->reset_time % 60);
58 new_draw_info (NDI_UNIQUE, 0, op, buf); 60 new_draw_info (NDI_UNIQUE, 0, op, buf);
59 } 61 }
60} 62}
63
64int
65command_style_map_info (object *op, char *params)
66{
67 extern maptile *styles;
68 maptile *mp;
69 int maps_used = 0, mapmem = 0, objects_used = 0, x, y;
70 object *tmp;
71
72 for (mp = styles; mp != NULL; mp = mp->next)
73 {
74 maps_used++;
75 mapmem += mp->width * mp->height * (sizeof (object *) + sizeof (mapspace)) + sizeof (maptile);
76 for (x = 0; x < mp->width; x++)
77 {
78 for (y = 0; y < mp->height; y++)
79 {
80 for (tmp = GET_MAP_OB (mp, x, y); tmp != NULL; tmp = tmp->above)
81 objects_used++;
82 }
83 }
84 }
85 new_draw_info_format (NDI_UNIQUE, 0, op, "Style maps loaded: %d", maps_used);
86 new_draw_info (NDI_UNIQUE, 0, op, "Memory used, not");
87 new_draw_info_format (NDI_UNIQUE, 0, op, "including objects: %d", mapmem);
88 new_draw_info_format (NDI_UNIQUE, 0, op, "Style objects: %d", objects_used);
89 new_draw_info_format (NDI_UNIQUE, 0, op, "Mem for objects: %d", objects_used * sizeof (object));
90 return 0;
91}
92#endif
61 93
62/* This command dumps the body information for object *op. 94/* This command dumps the body information for object *op.
63 * it doesn't care what the params are. 95 * it doesn't care what the params are.
64 * This is mostly meant as a debug command. 96 * This is mostly meant as a debug command.
65 */ 97 */
148 maptile *m = op->map; 180 maptile *m = op->map;
149 181
150 if (!m) 182 if (!m)
151 return; 183 return;
152 184
153 new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) in %s", m->name, m->path, get_name_of_region_for_map (m)); 185 new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) in %s", &m->name, &m->path, get_name_of_region_for_map (m));
154 186
155 if (QUERY_FLAG (op, FLAG_WIZ)) 187 if (QUERY_FLAG (op, FLAG_WIZ))
156 { 188 {
157 new_draw_info_format (NDI_UNIQUE, 0, op, 189 new_draw_info_format (NDI_UNIQUE, 0, op,
158 "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld", 190 "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld",
248 current_region_info (op); 280 current_region_info (op);
249 return 1; 281 return 1;
250} 282}
251 283
252int 284int
253command_maps (object *op, char *params)
254{
255 map_info (op, params);
256 return 1;
257}
258
259int
260command_time (object *op, char *params) 285command_time (object *op, char *params)
261{ 286{
262 print_tod (op); 287 print_tod (op);
263 return 1; 288 return 1;
264} 289}
265 290
266int 291int
267command_weather (object *op, char *params) 292command_weather (object *op, char *params)
268{ 293{
294#if 0
269 int wx, wy, temp, sky; 295 int wx, wy, temp, sky;
270 char buf[MAX_BUF]; 296 char buf[MAX_BUF];
271 297
272 if (settings.dynamiclevel < 1) 298 if (settings.dynamiclevel < 1)
273 return 1; 299 return 1;
389 break; 415 break;
390 case SKY_BLIZZARD: 416 case SKY_BLIZZARD:
391 new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); 417 new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!");
392 break; 418 break;
393 } 419 }
420#endif
394 return 1; 421 return 1;
395} 422}
396 423
397int 424int
398command_archs (object *op, char *params) 425command_archs (object *op, char *params)
456 dump_friendly_objects (); 483 dump_friendly_objects ();
457 return 0; 484 return 0;
458} 485}
459 486
460int 487int
461command_dumpmap (object *op, char *params)
462{
463 if (op)
464 dump_map (op->map);
465 return 0;
466}
467
468int
469command_dumpallmaps (object *op, char *params)
470{
471 dump_all_maps ();
472 return 0;
473}
474
475int
476command_printlos (object *op, char *params) 488command_printlos (object *op, char *params)
477{ 489{
478 if (op) 490 if (op)
479 print_los (op); 491 print_los (op);
480 return 0; 492 return 0;
485command_version (object *op, char *params) 497command_version (object *op, char *params)
486{ 498{
487 version (op); 499 version (op);
488 return 0; 500 return 0;
489} 501}
490
491 502
492#ifndef BUG_LOG 503#ifndef BUG_LOG
493# define BUG_LOG "bug_log" 504# define BUG_LOG "bug_log"
494#endif 505#endif
495void 506void
1317 op->update_stats (); 1328 op->update_stats ();
1318 return 0; 1329 return 0;
1319} 1330}
1320 1331
1321int 1332int
1322command_style_map_info (object *op, char *params)
1323{
1324 extern maptile *styles;
1325 maptile *mp;
1326 int maps_used = 0, mapmem = 0, objects_used = 0, x, y;
1327 object *tmp;
1328
1329 for (mp = styles; mp != NULL; mp = mp->next)
1330 {
1331 maps_used++;
1332 mapmem += mp->width * mp->height * (sizeof (object *) + sizeof (mapspace)) + sizeof (maptile);
1333 for (x = 0; x < mp->width; x++)
1334 {
1335 for (y = 0; y < mp->height; y++)
1336 {
1337 for (tmp = GET_MAP_OB (mp, x, y); tmp != NULL; tmp = tmp->above)
1338 objects_used++;
1339 }
1340 }
1341 }
1342 new_draw_info_format (NDI_UNIQUE, 0, op, "Style maps loaded: %d", maps_used);
1343 new_draw_info (NDI_UNIQUE, 0, op, "Memory used, not");
1344 new_draw_info_format (NDI_UNIQUE, 0, op, "including objects: %d", mapmem);
1345 new_draw_info_format (NDI_UNIQUE, 0, op, "Style objects: %d", objects_used);
1346 new_draw_info_format (NDI_UNIQUE, 0, op, "Mem for objects: %d", objects_used * sizeof (object));
1347 return 0;
1348}
1349
1350int
1351command_kill_pets (object *op, char *params) 1333command_kill_pets (object *op, char *params)
1352{ 1334{
1353 objectlink *obl, *next; 1335 objectlink *obl, *next;
1354 int counter = 0, removecount = 0; 1336 int counter = 0, removecount = 0;
1355 1337

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines