1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_c_wiz_c = |
|
|
4 | * "$Id: c_wiz.C,v 1.10 2006/09/10 14:54:02 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* |
1 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
9 | |
3 | |
10 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
11 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
22 | |
16 | |
23 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
24 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | |
20 | |
27 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
28 | */ |
22 | */ |
29 | |
23 | |
30 | #include <global.h> |
24 | #include <global.h> |
31 | #ifndef __CEXTRACT__ |
25 | #ifndef __CEXTRACT__ |
32 | # include <sproto.h> |
26 | # include <sproto.h> |
… | |
… | |
79 | { |
73 | { |
80 | new_draw_info (NDI_UNIQUE, 0, op, "That player is in no state for that right now."); |
74 | new_draw_info (NDI_UNIQUE, 0, op, "That player is in no state for that right now."); |
81 | return NULL; |
75 | return NULL; |
82 | } |
76 | } |
83 | return pl; |
77 | return pl; |
84 | } |
|
|
85 | |
|
|
86 | /** |
|
|
87 | * This command will stress server. |
|
|
88 | */ |
|
|
89 | int |
|
|
90 | command_loadtest (object *op, char *params) |
|
|
91 | { |
|
|
92 | uint32 x, y; |
|
|
93 | char buf[1024]; |
|
|
94 | |
|
|
95 | new_draw_info (NDI_UNIQUE, 0, op, "loadtest will stress server through teleporting"); |
|
|
96 | new_draw_info (NDI_UNIQUE, 0, op, "at different map places."); |
|
|
97 | new_draw_info (NDI_UNIQUE, 0, op, "use at your own risks."); |
|
|
98 | new_draw_info (NDI_UNIQUE, 0, op, "Very long loop used so server may have to be reset."); |
|
|
99 | new_draw_info (NDI_UNIQUE, 0, op, "type loadtest TRUE to run"); |
|
|
100 | new_draw_info_format (NDI_UNIQUE, 0, op, "{%s}", params); |
|
|
101 | |
|
|
102 | if (!params) |
|
|
103 | return 0; |
|
|
104 | |
|
|
105 | if (strncmp (params, "TRUE", 4)) |
|
|
106 | return 0; |
|
|
107 | |
|
|
108 | new_draw_info_format (NDI_UNIQUE, 0, op, "gogogo"); |
|
|
109 | |
|
|
110 | for (x = 0; x < settings.worldmaptilesx; x++) |
|
|
111 | { |
|
|
112 | for (y = 0; y < settings.worldmaptilesy; y++) |
|
|
113 | { |
|
|
114 | sprintf (buf, "/world/world_%d_%d", x + settings.worldmapstartx, y + settings.worldmapstarty); |
|
|
115 | command_goto (op, buf); |
|
|
116 | } |
|
|
117 | } |
|
|
118 | |
|
|
119 | return 0; |
|
|
120 | } |
78 | } |
121 | |
79 | |
122 | /** |
80 | /** |
123 | * Actually hides specified player (obviously a DM). |
81 | * Actually hides specified player (obviously a DM). |
124 | * If 'silent_dm' is non zero, other players are informed of DM entering/leaving, |
82 | * If 'silent_dm' is non zero, other players are informed of DM entering/leaving, |
… | |
… | |
272 | } |
230 | } |
273 | |
231 | |
274 | int |
232 | int |
275 | command_kick (object *op, char *params) |
233 | command_kick (object *op, char *params) |
276 | { |
234 | { |
277 | struct pl *pl; |
|
|
278 | |
|
|
279 | for (pl = first_player; pl != NULL; pl = pl->next) |
235 | for (player *pl = first_player; pl; pl = pl->next) |
280 | if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) |
236 | if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) |
281 | { |
237 | { |
282 | object *op = pl->ob; |
238 | object *op = pl->ob; |
283 | |
239 | |
284 | if (!QUERY_FLAG (op, FLAG_REMOVED) && !QUERY_FLAG (op, FLAG_FREED)) |
240 | if (!QUERY_FLAG (op, FLAG_REMOVED) && !QUERY_FLAG (op, FLAG_FREED)) |
… | |
… | |
315 | } |
271 | } |
316 | |
272 | |
317 | int |
273 | int |
318 | command_shutdown (object *op, char *params) |
274 | command_shutdown (object *op, char *params) |
319 | { |
275 | { |
320 | struct pl *pl; |
|
|
321 | |
|
|
322 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
276 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
323 | { |
277 | { |
324 | new_draw_info (NDI_UNIQUE, 0, op, "Sorry, you can't shutdown the server."); |
278 | new_draw_info (NDI_UNIQUE, 0, op, "Sorry, you can't shutdown the server."); |
325 | return 1; |
279 | return 1; |
326 | } |
280 | } |
327 | |
|
|
328 | for (pl = first_player; pl != NULL; pl = pl->next) |
|
|
329 | save_player (pl->ob, 0); |
|
|
330 | |
|
|
331 | for (pl = first_player; pl != NULL; pl = pl->next) |
|
|
332 | if (!QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
|
|
333 | leave_map (pl->ob); |
|
|
334 | |
281 | |
335 | cleanup (); |
282 | cleanup (); |
336 | /* not reached */ |
283 | /* not reached */ |
337 | return 1; |
|
|
338 | } |
|
|
339 | |
|
|
340 | int |
|
|
341 | command_goto (object *op, char *params) |
|
|
342 | { |
|
|
343 | char *name; |
|
|
344 | object *dummy; |
|
|
345 | |
|
|
346 | if (!op) |
|
|
347 | return 0; |
|
|
348 | |
|
|
349 | if (params == NULL) |
|
|
350 | { |
|
|
351 | new_draw_info (NDI_UNIQUE, 0, op, "Go to what level?"); |
|
|
352 | return 1; |
|
|
353 | } |
|
|
354 | |
|
|
355 | name = params; |
|
|
356 | dummy = get_object (); |
|
|
357 | dummy->map = op->map; |
|
|
358 | EXIT_PATH (dummy) = name; |
|
|
359 | dummy->name = name; |
|
|
360 | |
|
|
361 | enter_exit (op, dummy); |
|
|
362 | free_object (dummy); |
|
|
363 | if (op->contr->loading == NULL) |
|
|
364 | { |
|
|
365 | new_draw_info_format (NDI_UNIQUE, 0, op, "Difficulty: %d.", op->map->difficulty); |
|
|
366 | } |
|
|
367 | |
|
|
368 | return 1; |
|
|
369 | } |
|
|
370 | |
|
|
371 | /* is this function called from somewhere ? -Tero */ |
|
|
372 | int |
|
|
373 | command_generate (object *op, char *params) |
|
|
374 | { |
|
|
375 | object *tmp; |
|
|
376 | int nr = 1, i, retry; |
|
|
377 | |
|
|
378 | if (!op) |
|
|
379 | return 0; |
|
|
380 | |
|
|
381 | if (params != NULL) |
|
|
382 | sscanf (params, "%d", &nr); |
|
|
383 | for (i = 0; i < nr; i++) |
|
|
384 | { |
|
|
385 | retry = 50; |
|
|
386 | while ((tmp = generate_treasure (0, op->map->difficulty)) == NULL && --retry) |
|
|
387 | ; |
|
|
388 | if (tmp != NULL) |
|
|
389 | { |
|
|
390 | tmp = insert_ob_in_ob (tmp, op); |
|
|
391 | if (op->type == PLAYER) |
|
|
392 | esrv_send_item (op, tmp); |
|
|
393 | } |
|
|
394 | } |
|
|
395 | |
|
|
396 | return 1; |
284 | return 1; |
397 | } |
285 | } |
398 | |
286 | |
399 | int |
287 | int |
400 | command_freeze (object *op, char *params) |
288 | command_freeze (object *op, char *params) |
… | |
… | |
623 | bp2++; |
511 | bp2++; |
624 | break; |
512 | break; |
625 | } |
513 | } |
626 | } |
514 | } |
627 | |
515 | |
628 | if ((at = find_archetype (bp)) == NULL) |
516 | if ((at = archetype::find (bp)) == NULL) |
629 | { |
517 | { |
630 | new_draw_info (NDI_UNIQUE, 0, op, "No such archetype."); |
518 | new_draw_info (NDI_UNIQUE, 0, op, "No such archetype."); |
631 | return 1; |
519 | return 1; |
632 | } |
520 | } |
633 | |
521 | |
… | |
… | |
639 | * Try to find a spell object for this. Note that |
527 | * Try to find a spell object for this. Note that |
640 | * we also set up spell_name which is only |
528 | * we also set up spell_name which is only |
641 | * the first word. |
529 | * the first word. |
642 | */ |
530 | */ |
643 | |
531 | |
644 | at_spell = find_archetype (cp); |
532 | at_spell = archetype::find (cp); |
645 | if (!at_spell || at_spell->clone.type != SPELL) |
533 | if (!at_spell || at_spell->clone.type != SPELL) |
646 | at_spell = find_archetype_by_object_name (cp); |
534 | at_spell = find_archetype_by_object_name (cp); |
647 | if (!at_spell || at_spell->clone.type != SPELL) |
535 | if (!at_spell || at_spell->clone.type != SPELL) |
648 | { |
536 | { |
649 | strcpy (spell_name, cp); |
537 | strcpy (spell_name, cp); |
650 | fsp = strchr (spell_name, ' '); |
538 | fsp = strchr (spell_name, ' '); |
651 | if (fsp) |
539 | if (fsp) |
652 | { |
540 | { |
653 | *fsp = 0; |
541 | *fsp = 0; |
654 | fsp++; |
542 | fsp++; |
655 | at_spell = find_archetype (spell_name); |
543 | at_spell = archetype::find (spell_name); |
656 | |
544 | |
657 | /* Got a spell, update the first string pointer */ |
545 | /* Got a spell, update the first string pointer */ |
658 | if (at_spell && at_spell->clone.type == SPELL) |
546 | if (at_spell && at_spell->clone.type == SPELL) |
659 | bp2 = cp + strlen (spell_name) + 1; |
547 | bp2 = cp + strlen (spell_name) + 1; |
660 | else |
548 | else |
… | |
… | |
957 | |
845 | |
958 | tmp = get_dm_object (op->contr, ¶ms, NULL); |
846 | tmp = get_dm_object (op->contr, ¶ms, NULL); |
959 | if (!tmp) |
847 | if (!tmp) |
960 | return 1; |
848 | return 1; |
961 | |
849 | |
962 | dump_object (tmp); |
850 | char *dump = dump_object (tmp); |
963 | new_draw_info (NDI_UNIQUE, 0, op, errmsg); |
851 | new_draw_info (NDI_UNIQUE, 0, op, dump); |
|
|
852 | free (dump); |
|
|
853 | |
964 | if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL)) |
854 | if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL)) |
965 | new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); |
855 | new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); |
|
|
856 | |
966 | return 1; |
857 | return 1; |
967 | } |
858 | } |
968 | |
859 | |
969 | /** |
860 | /** |
970 | * When DM is possessing a monster, flip aggression on and off, to allow |
861 | * When DM is possessing a monster, flip aggression on and off, to allow |
… | |
… | |
1327 | } |
1218 | } |
1328 | |
1219 | |
1329 | int |
1220 | int |
1330 | command_reset (object *op, char *params) |
1221 | command_reset (object *op, char *params) |
1331 | { |
1222 | { |
1332 | mapstruct *m; |
1223 | maptile *m; |
1333 | object *dummy = NULL, *tmp = NULL; |
1224 | object *dummy = NULL, *tmp = NULL; |
1334 | |
1225 | |
1335 | if (params == NULL) |
1226 | if (params == NULL) |
1336 | { |
1227 | { |
1337 | new_draw_info (NDI_UNIQUE, 0, op, "Reset what map [name]?"); |
1228 | new_draw_info (NDI_UNIQUE, 0, op, "Reset what map [name]?"); |
1338 | return 1; |
1229 | return 1; |
1339 | } |
1230 | } |
1340 | |
1231 | |
1341 | if (strcmp (params, ".") == 0) |
1232 | if (strcmp (params, ".") == 0) |
1342 | params = op->map->path; |
1233 | params = op->map->path; |
|
|
1234 | |
1343 | m = has_been_loaded (params); |
1235 | m = has_been_loaded (params); |
1344 | if (m == NULL) |
1236 | if (m == NULL) |
1345 | { |
1237 | { |
1346 | new_draw_info (NDI_UNIQUE, 0, op, "No such map."); |
1238 | new_draw_info (NDI_UNIQUE, 0, op, "No such map."); |
1347 | return 1; |
1239 | return 1; |