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.37 by root, Wed Jan 17 22:13:10 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#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
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 34
65/* This command dumps the body information for object *op. 35/* This command dumps the body information for object *op.
66 * it doesn't care what the params are. 36 * it doesn't care what the params are.
67 * This is mostly meant as a debug command. 37 * This is mostly meant as a debug command.
68 */ 38 */
151 maptile *m = op->map; 121 maptile *m = op->map;
152 122
153 if (!m) 123 if (!m)
154 return; 124 return;
155 125
156 new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) in %s", m->name, m->path, get_name_of_region_for_map (m)); 126 new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) in %s", &m->name, &m->path, get_name_of_region_for_map (m));
157 127
158 if (QUERY_FLAG (op, FLAG_WIZ)) 128 if (QUERY_FLAG (op, FLAG_WIZ))
159 { 129 {
160 new_draw_info_format (NDI_UNIQUE, 0, op, 130 new_draw_info_format (NDI_UNIQUE, 0, op,
161 "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld", 131 "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld",
251 current_region_info (op); 221 current_region_info (op);
252 return 1; 222 return 1;
253} 223}
254 224
255int 225int
256command_maps (object *op, char *params)
257{
258 map_info (op, params);
259 return 1;
260}
261
262int
263command_time (object *op, char *params) 226command_time (object *op, char *params)
264{ 227{
265 print_tod (op); 228 print_tod (op);
266 return 1; 229 return 1;
267} 230}
268 231
269int 232int
270command_weather (object *op, char *params) 233command_weather (object *op, char *params)
271{ 234{
235#if 0
272 int wx, wy, temp, sky; 236 int wx, wy, temp, sky;
273 char buf[MAX_BUF]; 237 char buf[MAX_BUF];
274 238
275 if (settings.dynamiclevel < 1) 239 if (settings.dynamiclevel < 1)
276 return 1; 240 return 1;
392 break; 356 break;
393 case SKY_BLIZZARD: 357 case SKY_BLIZZARD:
394 new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); 358 new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!");
395 break; 359 break;
396 } 360 }
361#endif
397 return 1; 362 return 1;
398} 363}
399 364
400int 365int
401command_archs (object *op, char *params) 366command_archs (object *op, char *params)
459 dump_friendly_objects (); 424 dump_friendly_objects ();
460 return 0; 425 return 0;
461} 426}
462 427
463int 428int
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) 429command_printlos (object *op, char *params)
480{ 430{
481 if (op) 431 if (op)
482 print_los (op); 432 print_los (op);
483 return 0; 433 return 0;
488command_version (object *op, char *params) 438command_version (object *op, char *params)
489{ 439{
490 version (op); 440 version (op);
491 return 0; 441 return 0;
492} 442}
493
494 443
495#ifndef BUG_LOG 444#ifndef BUG_LOG
496# define BUG_LOG "bug_log" 445# define BUG_LOG "bug_log"
497#endif 446#endif
498void 447void
1133 return 0; 1082 return 0;
1134 } 1083 }
1135} 1084}
1136 1085
1137int 1086int
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) 1087command_sound (object *op, char *params)
1183{ 1088{
1184 if (op->contr->ns->sound) 1089 if (op->contr->ns->sound)
1185 { 1090 {
1186 op->contr->ns->sound = 0; 1091 op->contr->ns->sound = 0;
1191 op->contr->ns->sound = 1; 1096 op->contr->ns->sound = 1;
1192 new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); 1097 new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled.");
1193 } 1098 }
1194 1099
1195 return 1; 1100 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} 1101}
1211 1102
1212int 1103int
1213command_title (object *op, char *params) 1104command_title (object *op, char *params)
1214{ 1105{
1254 strcpy (op->contr->own_title, params); 1145 strcpy (op->contr->own_title, params);
1255 return 1; 1146 return 1;
1256} 1147}
1257 1148
1258int 1149int
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) 1150command_peaceful (object *op, char *params)
1274{ 1151{
1275 new_draw_info (NDI_UNIQUE, 0, op, 1152 new_draw_info (NDI_UNIQUE, 0, op,
1276 "You cannot change your peaceful setting with this command." 1153 "You cannot change your peaceful setting with this command."
1277 " Please speak to the priest in the temple of Gorokh" 1154 " Please speak to the priest in the temple of Gorokh"
1316 new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); 1193 new_draw_info (NDI_UNIQUE, 0, op, "You are braced.");
1317 else 1194 else
1318 new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); 1195 new_draw_info (NDI_UNIQUE, 0, op, "Not braced.");
1319 1196
1320 op->update_stats (); 1197 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; 1198 return 0;
1351} 1199}
1352 1200
1353int 1201int
1354command_kill_pets (object *op, char *params) 1202command_kill_pets (object *op, char *params)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines