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.30 by root, Mon Dec 25 14:54:44 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[MAX_BUF]; 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 for (m = first_map; m != NULL; m = m->next)
46 {
47 45
46 for (maps_container::iterator i = maps.begin (); i != maps.end (); ++i)
47 {
48 maptile *m = i->second;
49
48 if (search && strstr (m->path, search) == NULL) 50 if (search && !strstr (m->path, search))
49 continue; /* Skip unwanted maps */ 51 continue; /* Skip unwanted maps */
52
50 /* Print out the last 18 characters of the map name... */ 53 /* Print out the last 30 characters of the map name... */
51 if (strlen (m->path) <= 18)
52 strcpy (map_path, m->path);
53 else
54 strcpy (map_path, m->path + strlen (m->path) - 18); 54 strcpy (map_path, m->path + max (0, (int)strlen (m->path) - 30));
55
55 sprintf (buf, "%-18.18s %2d %2d %1d %4d %2d %02d:%02d:%02d", 56 sprintf (buf, "%-30.30s %2d %2d %1d %4d %2d %02d:%02d:%02d",
56 map_path, m->players, players_on_map (m, FALSE), 57 map_path, m->players, players_on_map (m, FALSE),
57 m->in_memory, m->timeout, m->difficulty, 58 m->in_memory, m->timeout, m->difficulty,
58 (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);
59 new_draw_info (NDI_UNIQUE, 0, op, buf); 60 new_draw_info (NDI_UNIQUE, 0, op, buf);
60 } 61 }
61} 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
62 93
63/* This command dumps the body information for object *op. 94/* This command dumps the body information for object *op.
64 * it doesn't care what the params are. 95 * it doesn't care what the params are.
65 * This is mostly meant as a debug command. 96 * This is mostly meant as a debug command.
66 */ 97 */
149 maptile *m = op->map; 180 maptile *m = op->map;
150 181
151 if (!m) 182 if (!m)
152 return; 183 return;
153 184
154 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));
155 186
156 if (QUERY_FLAG (op, FLAG_WIZ)) 187 if (QUERY_FLAG (op, FLAG_WIZ))
157 { 188 {
158 new_draw_info_format (NDI_UNIQUE, 0, op, 189 new_draw_info_format (NDI_UNIQUE, 0, op,
159 "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",
249 current_region_info (op); 280 current_region_info (op);
250 return 1; 281 return 1;
251} 282}
252 283
253int 284int
254command_maps (object *op, char *params)
255{
256 map_info (op, params);
257 return 1;
258}
259
260int
261command_time (object *op, char *params) 285command_time (object *op, char *params)
262{ 286{
263 print_tod (op); 287 print_tod (op);
264 return 1; 288 return 1;
265} 289}
266 290
267int 291int
268command_weather (object *op, char *params) 292command_weather (object *op, char *params)
269{ 293{
294#if 0
270 int wx, wy, temp, sky; 295 int wx, wy, temp, sky;
271 char buf[MAX_BUF]; 296 char buf[MAX_BUF];
272 297
273 if (settings.dynamiclevel < 1) 298 if (settings.dynamiclevel < 1)
274 return 1; 299 return 1;
390 break; 415 break;
391 case SKY_BLIZZARD: 416 case SKY_BLIZZARD:
392 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!");
393 break; 418 break;
394 } 419 }
420#endif
395 return 1; 421 return 1;
396} 422}
397 423
398int 424int
399command_archs (object *op, char *params) 425command_archs (object *op, char *params)
457 dump_friendly_objects (); 483 dump_friendly_objects ();
458 return 0; 484 return 0;
459} 485}
460 486
461int 487int
462command_dumpmap (object *op, char *params)
463{
464 if (op)
465 dump_map (op->map);
466 return 0;
467}
468
469int
470command_dumpallmaps (object *op, char *params)
471{
472 dump_all_maps ();
473 return 0;
474}
475
476int
477command_printlos (object *op, char *params) 488command_printlos (object *op, char *params)
478{ 489{
479 if (op) 490 if (op)
480 print_los (op); 491 print_los (op);
481 return 0; 492 return 0;
486command_version (object *op, char *params) 497command_version (object *op, char *params)
487{ 498{
488 version (op); 499 version (op);
489 return 0; 500 return 0;
490} 501}
491
492 502
493#ifndef BUG_LOG 503#ifndef BUG_LOG
494# define BUG_LOG "bug_log" 504# define BUG_LOG "bug_log"
495#endif 505#endif
496void 506void
1318 op->update_stats (); 1328 op->update_stats ();
1319 return 0; 1329 return 0;
1320} 1330}
1321 1331
1322int 1332int
1323command_style_map_info (object *op, char *params)
1324{
1325 extern maptile *styles;
1326 maptile *mp;
1327 int maps_used = 0, mapmem = 0, objects_used = 0, x, y;
1328 object *tmp;
1329
1330 for (mp = styles; mp != NULL; mp = mp->next)
1331 {
1332 maps_used++;
1333 mapmem += mp->width * mp->height * (sizeof (object *) + sizeof (mapspace)) + sizeof (maptile);
1334 for (x = 0; x < mp->width; x++)
1335 {
1336 for (y = 0; y < mp->height; y++)
1337 {
1338 for (tmp = GET_MAP_OB (mp, x, y); tmp != NULL; tmp = tmp->above)
1339 objects_used++;
1340 }
1341 }
1342 }
1343 new_draw_info_format (NDI_UNIQUE, 0, op, "Style maps loaded: %d", maps_used);
1344 new_draw_info (NDI_UNIQUE, 0, op, "Memory used, not");
1345 new_draw_info_format (NDI_UNIQUE, 0, op, "including objects: %d", mapmem);
1346 new_draw_info_format (NDI_UNIQUE, 0, op, "Style objects: %d", objects_used);
1347 new_draw_info_format (NDI_UNIQUE, 0, op, "Mem for objects: %d", objects_used * sizeof (object));
1348 return 0;
1349}
1350
1351int
1352command_kill_pets (object *op, char *params) 1333command_kill_pets (object *op, char *params)
1353{ 1334{
1354 objectlink *obl, *next; 1335 objectlink *obl, *next;
1355 int counter = 0, removecount = 0; 1336 int counter = 0, removecount = 0;
1356 1337

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines