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 | |
30 | extern 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 |
36 | void |
37 | void |
37 | map_info (object *op, char *search) |
38 | map_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 | for (m = first_map; m != NULL; m = m->next) |
|
|
46 | { |
|
|
47 | |
46 | |
|
|
47 | for (maps_container::iterator i = maps.begin (); i != maps.end (); ++i) |
|
|
48 | { |
|
|
49 | maptile *m = i->second; |
|
|
50 | |
48 | if (search && strstr (m->path, search) == NULL) |
51 | if (search && !strstr (m->path, search)) |
49 | continue; /* Skip unwanted maps */ |
52 | continue; /* Skip unwanted maps */ |
|
|
53 | |
50 | /* Print out the last 18 characters of the map name... */ |
54 | /* 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); |
55 | strcpy (map_path, m->path + max (0, (int)strlen (m->path) - 30)); |
|
|
56 | |
55 | 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", |
56 | map_path, m->players, players_on_map (m, FALSE), |
58 | map_path, m->players, players_on_map (m, FALSE), |
57 | m->in_memory, m->timeout, m->difficulty, |
59 | m->in_memory, m->timeout, m->difficulty, |
58 | (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); |
59 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
61 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
60 | } |
62 | } |
61 | } |
63 | } |
|
|
64 | |
|
|
65 | int |
|
|
66 | command_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 |
62 | |
94 | |
63 | /* This command dumps the body information for object *op. |
95 | /* This command dumps the body information for object *op. |
64 | * it doesn't care what the params are. |
96 | * it doesn't care what the params are. |
65 | * This is mostly meant as a debug command. |
97 | * This is mostly meant as a debug command. |
66 | */ |
98 | */ |
… | |
… | |
149 | maptile *m = op->map; |
181 | maptile *m = op->map; |
150 | |
182 | |
151 | if (!m) |
183 | if (!m) |
152 | return; |
184 | return; |
153 | |
185 | |
154 | 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)); |
155 | |
187 | |
156 | if (QUERY_FLAG (op, FLAG_WIZ)) |
188 | if (QUERY_FLAG (op, FLAG_WIZ)) |
157 | { |
189 | { |
158 | new_draw_info_format (NDI_UNIQUE, 0, op, |
190 | new_draw_info_format (NDI_UNIQUE, 0, op, |
159 | "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", |
… | |
… | |
249 | current_region_info (op); |
281 | current_region_info (op); |
250 | return 1; |
282 | return 1; |
251 | } |
283 | } |
252 | |
284 | |
253 | int |
285 | int |
254 | command_maps (object *op, char *params) |
|
|
255 | { |
|
|
256 | map_info (op, params); |
|
|
257 | return 1; |
|
|
258 | } |
|
|
259 | |
|
|
260 | int |
|
|
261 | command_time (object *op, char *params) |
286 | command_time (object *op, char *params) |
262 | { |
287 | { |
263 | print_tod (op); |
288 | print_tod (op); |
264 | return 1; |
289 | return 1; |
265 | } |
290 | } |
266 | |
291 | |
267 | int |
292 | int |
268 | command_weather (object *op, char *params) |
293 | command_weather (object *op, char *params) |
269 | { |
294 | { |
|
|
295 | #if 0 |
270 | int wx, wy, temp, sky; |
296 | int wx, wy, temp, sky; |
271 | char buf[MAX_BUF]; |
297 | char buf[MAX_BUF]; |
272 | |
298 | |
273 | if (settings.dynamiclevel < 1) |
299 | if (settings.dynamiclevel < 1) |
274 | return 1; |
300 | return 1; |
… | |
… | |
390 | break; |
416 | break; |
391 | case SKY_BLIZZARD: |
417 | case SKY_BLIZZARD: |
392 | 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!"); |
393 | break; |
419 | break; |
394 | } |
420 | } |
|
|
421 | #endif |
395 | return 1; |
422 | return 1; |
396 | } |
423 | } |
397 | |
424 | |
398 | int |
425 | int |
399 | command_archs (object *op, char *params) |
426 | command_archs (object *op, char *params) |
… | |
… | |
457 | dump_friendly_objects (); |
484 | dump_friendly_objects (); |
458 | return 0; |
485 | return 0; |
459 | } |
486 | } |
460 | |
487 | |
461 | int |
488 | int |
462 | command_dumpmap (object *op, char *params) |
|
|
463 | { |
|
|
464 | if (op) |
|
|
465 | dump_map (op->map); |
|
|
466 | return 0; |
|
|
467 | } |
|
|
468 | |
|
|
469 | int |
|
|
470 | command_dumpallmaps (object *op, char *params) |
|
|
471 | { |
|
|
472 | dump_all_maps (); |
|
|
473 | return 0; |
|
|
474 | } |
|
|
475 | |
|
|
476 | int |
|
|
477 | command_printlos (object *op, char *params) |
489 | command_printlos (object *op, char *params) |
478 | { |
490 | { |
479 | if (op) |
491 | if (op) |
480 | print_los (op); |
492 | print_los (op); |
481 | return 0; |
493 | return 0; |
… | |
… | |
486 | command_version (object *op, char *params) |
498 | command_version (object *op, char *params) |
487 | { |
499 | { |
488 | version (op); |
500 | version (op); |
489 | return 0; |
501 | return 0; |
490 | } |
502 | } |
491 | |
|
|
492 | |
503 | |
493 | #ifndef BUG_LOG |
504 | #ifndef BUG_LOG |
494 | # define BUG_LOG "bug_log" |
505 | # define BUG_LOG "bug_log" |
495 | #endif |
506 | #endif |
496 | void |
507 | void |
… | |
… | |
1131 | return 0; |
1142 | return 0; |
1132 | } |
1143 | } |
1133 | } |
1144 | } |
1134 | |
1145 | |
1135 | int |
1146 | int |
1136 | command_quit (object *op, char *params) |
|
|
1137 | { |
|
|
1138 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1139 | "Quitting will delete your character PERMANENTLY. If you are sure you want to do this, then use the quit_character command instead of quit."); |
|
|
1140 | return 1; |
|
|
1141 | } |
|
|
1142 | |
|
|
1143 | int |
|
|
1144 | command_real_quit (object *op, char *params) |
|
|
1145 | { |
|
|
1146 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Quitting will delete your character.\nAre you sure you want to quit (y/n):"); |
|
|
1147 | |
|
|
1148 | op->contr->ns->state = ST_CONFIRM_QUIT; |
|
|
1149 | return 1; |
|
|
1150 | } |
|
|
1151 | |
|
|
1152 | /* |
|
|
1153 | * don't allow people to exit explore mode. It otherwise becomes |
|
|
1154 | * really easy to abuse this. |
|
|
1155 | */ |
|
|
1156 | int |
|
|
1157 | command_explore (object *op, char *params) |
|
|
1158 | { |
|
|
1159 | if (settings.explore_mode == FALSE) |
|
|
1160 | return 1; |
|
|
1161 | /* |
|
|
1162 | * I guess this is the best way to see if we are solo or not. Actually, |
|
|
1163 | * are there any cases when first_player->next==NULL and we are not solo? |
|
|
1164 | */ |
|
|
1165 | if ((first_player != op->contr) || (first_player->next != NULL)) |
|
|
1166 | { |
|
|
1167 | new_draw_info (NDI_UNIQUE, 0, op, "You can not enter explore mode if you are in a party"); |
|
|
1168 | } |
|
|
1169 | else if (op->contr->explore) |
|
|
1170 | new_draw_info (NDI_UNIQUE, 0, op, "There is no return from explore mode"); |
|
|
1171 | else |
|
|
1172 | { |
|
|
1173 | op->contr->explore = 1; |
|
|
1174 | new_draw_info (NDI_UNIQUE, 0, op, "You are now in explore mode"); |
|
|
1175 | } |
|
|
1176 | return 1; |
|
|
1177 | } |
|
|
1178 | |
|
|
1179 | int |
|
|
1180 | command_sound (object *op, char *params) |
1147 | command_sound (object *op, char *params) |
1181 | { |
1148 | { |
1182 | if (op->contr->ns->sound) |
1149 | if (op->contr->ns->sound) |
1183 | { |
1150 | { |
1184 | op->contr->ns->sound = 0; |
1151 | op->contr->ns->sound = 0; |
… | |
… | |
1189 | op->contr->ns->sound = 1; |
1156 | op->contr->ns->sound = 1; |
1190 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
1157 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
1191 | } |
1158 | } |
1192 | |
1159 | |
1193 | return 1; |
1160 | return 1; |
1194 | } |
|
|
1195 | |
|
|
1196 | int |
|
|
1197 | explore_mode (void) |
|
|
1198 | { |
|
|
1199 | player *pl; |
|
|
1200 | |
|
|
1201 | if (settings.explore_mode == TRUE) |
|
|
1202 | { |
|
|
1203 | for (pl = first_player; pl != (player *) NULL; pl = pl->next) |
|
|
1204 | if (pl->explore) |
|
|
1205 | return 1; |
|
|
1206 | } |
|
|
1207 | return 0; |
|
|
1208 | } |
1161 | } |
1209 | |
1162 | |
1210 | int |
1163 | int |
1211 | command_title (object *op, char *params) |
1164 | command_title (object *op, char *params) |
1212 | { |
1165 | { |
… | |
… | |
1252 | strcpy (op->contr->own_title, params); |
1205 | strcpy (op->contr->own_title, params); |
1253 | return 1; |
1206 | return 1; |
1254 | } |
1207 | } |
1255 | |
1208 | |
1256 | int |
1209 | int |
1257 | command_save (object *op, char *params) |
|
|
1258 | { |
|
|
1259 | if (!op->stats.exp) |
|
|
1260 | new_draw_info (NDI_UNIQUE, 0, op, "You don't deserve to save yet."); |
|
|
1261 | else |
|
|
1262 | { |
|
|
1263 | op->contr->save (); |
|
|
1264 | new_draw_info (NDI_UNIQUE, 0, op, "You have been saved."); |
|
|
1265 | } |
|
|
1266 | |
|
|
1267 | return 1; |
|
|
1268 | } |
|
|
1269 | |
|
|
1270 | int |
|
|
1271 | command_peaceful (object *op, char *params) |
1210 | command_peaceful (object *op, char *params) |
1272 | { |
1211 | { |
1273 | new_draw_info (NDI_UNIQUE, 0, op, |
1212 | new_draw_info (NDI_UNIQUE, 0, op, |
1274 | "You cannot change your peaceful setting with this command." |
1213 | "You cannot change your peaceful setting with this command." |
1275 | " Please speak to the priest in the temple of Gorokh" |
1214 | " Please speak to the priest in the temple of Gorokh" |
… | |
… | |
1314 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
1253 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
1315 | else |
1254 | else |
1316 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
1255 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
1317 | |
1256 | |
1318 | op->update_stats (); |
1257 | op->update_stats (); |
1319 | return 0; |
|
|
1320 | } |
|
|
1321 | |
|
|
1322 | int |
|
|
1323 | command_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; |
1258 | return 0; |
1349 | } |
1259 | } |
1350 | |
1260 | |
1351 | int |
1261 | int |
1352 | command_kill_pets (object *op, char *params) |
1262 | command_kill_pets (object *op, char *params) |