1 | |
|
|
2 | /* |
1 | /* |
3 | * static char *rcsid_c_wiz_c = |
|
|
4 | * "$Id: c_wiz.C,v 1.11 2006/09/14 21:16:12 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* |
|
|
8 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game for X-windows |
9 | |
3 | * |
|
|
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
10 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
11 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
12 | |
7 | * |
13 | 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 |
14 | 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 |
15 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
16 | (at your option) any later version. |
11 | * (at your option) any later version. |
17 | |
12 | * |
18 | 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, |
19 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
22 | |
17 | * |
23 | 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 |
24 | along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | |
21 | * |
27 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
28 | */ |
23 | */ |
29 | |
24 | |
30 | #include <global.h> |
25 | #include <global.h> |
31 | #ifndef __CEXTRACT__ |
|
|
32 | # include <sproto.h> |
26 | #include <sproto.h> |
33 | #endif |
|
|
34 | #include <spells.h> |
27 | #include <spells.h> |
35 | #include <treasure.h> |
28 | #include <treasure.h> |
36 | #include <skills.h> |
29 | #include <skills.h> |
37 | |
30 | |
38 | /** Defines for DM item stack **/ |
31 | /** Defines for DM item stack **/ |
… | |
… | |
53 | * other player, or NULL otherwise. |
46 | * other player, or NULL otherwise. |
54 | */ |
47 | */ |
55 | static player * |
48 | static player * |
56 | get_other_player_from_name (object *op, char *name) |
49 | get_other_player_from_name (object *op, char *name) |
57 | { |
50 | { |
58 | player *pl; |
|
|
59 | |
|
|
60 | if (!name) |
51 | if (!name) |
61 | return NULL; |
52 | return NULL; |
62 | |
53 | |
63 | for (pl = first_player; pl != NULL; pl = pl->next) |
54 | for_all_players (pl) |
64 | if (!strncmp (pl->ob->name, name, MAX_NAME)) |
55 | if (!strncmp (pl->ob->name, name, MAX_NAME)) |
65 | break; |
|
|
66 | |
|
|
67 | if (pl == NULL) |
|
|
68 | { |
56 | { |
69 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
|
|
70 | return NULL; |
|
|
71 | } |
|
|
72 | |
|
|
73 | if (pl->ob == op) |
57 | if (pl->ob == op) |
74 | { |
58 | { |
75 | new_draw_info (NDI_UNIQUE, 0, op, "You can't do that to yourself."); |
59 | new_draw_info (NDI_UNIQUE, 0, op, "You can't do that to yourself."); |
76 | return NULL; |
60 | return NULL; |
77 | } |
61 | } |
|
|
62 | |
78 | if (pl->state != ST_PLAYING) |
63 | if (pl->ns->state != ST_PLAYING) |
79 | { |
64 | { |
80 | new_draw_info (NDI_UNIQUE, 0, op, "That player is in no state for that right now."); |
65 | new_draw_info (NDI_UNIQUE, 0, op, "That player is in no state for that right now."); |
81 | return NULL; |
66 | return NULL; |
82 | } |
|
|
83 | 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 | } |
67 | } |
|
|
68 | |
|
|
69 | return pl; |
117 | } |
70 | } |
118 | |
71 | |
|
|
72 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
119 | return 0; |
73 | return 0; |
120 | } |
74 | } |
121 | |
75 | |
122 | /** |
76 | /** |
123 | * Actually hides specified player (obviously a DM). |
77 | * Actually hides specified player (obviously a DM). |
… | |
… | |
258 | now = time (NULL); |
212 | now = time (NULL); |
259 | /* |
213 | /* |
260 | * Record this as a comment - then we don't have to worry about changing |
214 | * Record this as a comment - then we don't have to worry about changing |
261 | * the parsing code. |
215 | * the parsing code. |
262 | */ |
216 | */ |
263 | fprintf (banishfile, "# %s (%s) banned by %s at %s\n", &pl->ob->name, pl->socket.host, &op->name, ctime (&now)); |
217 | fprintf (banishfile, "# %s (%s) banned by %s at %s\n", &pl->ob->name, pl->ns->host, &op->name, ctime (&now)); |
264 | fprintf (banishfile, "*@%s\n", pl->socket.host); |
218 | fprintf (banishfile, "*@%s\n", pl->ns->host); |
265 | fclose (banishfile); |
219 | fclose (banishfile); |
266 | |
220 | |
267 | LOG (llevDebug, "! %s banned %s from IP: %s.\n", &op->name, &pl->ob->name, pl->socket.host); |
221 | LOG (llevDebug, "! %s banned %s from IP: %s.\n", &op->name, &pl->ob->name, pl->ns->host); |
268 | new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op, "You banish %s", &pl->ob->name); |
222 | new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op, "You banish %s", &pl->ob->name); |
269 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s banishes %s from the land!", &op->name, &pl->ob->name); |
223 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s banishes %s from the land!", &op->name, &pl->ob->name); |
270 | command_kick (op, (char *) &pl->ob->name); |
224 | command_kick (op, (char *) &pl->ob->name); |
271 | return 1; |
225 | return 1; |
272 | } |
226 | } |
273 | |
227 | |
274 | int |
228 | int |
275 | command_kick (object *op, char *params) |
229 | command_kick (object *op, char *params) |
276 | { |
230 | { |
277 | struct pl *pl; |
231 | for_all_players (pl) |
278 | |
|
|
279 | for (pl = first_player; pl != NULL; pl = pl->next) |
|
|
280 | if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) |
232 | if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) |
281 | { |
233 | { |
282 | object *op = pl->ob; |
234 | object *op = pl->ob; |
283 | |
235 | |
284 | if (!QUERY_FLAG (op, FLAG_REMOVED) && !QUERY_FLAG (op, FLAG_FREED)) |
236 | if (!QUERY_FLAG (op, FLAG_REMOVED) && !QUERY_FLAG (op, FLAG_FREED)) |
285 | { |
237 | { |
286 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s is kicked out of the game.", &op->name); |
238 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s is kicked out of the game.", &op->name); |
287 | strcpy (op->contr->killer, "kicked"); |
239 | strcpy (op->contr->killer, "kicked"); |
288 | } |
240 | } |
289 | |
241 | |
290 | pl->socket.status = Ns_Dead; |
242 | pl->ns->destroy (); |
291 | } |
243 | } |
292 | |
244 | |
293 | return 1; |
245 | return 1; |
294 | } |
246 | } |
295 | |
247 | |
|
|
248 | //TODO |
|
|
249 | #if 0 |
296 | int |
250 | int |
297 | command_save_overlay (object *op, char *params) |
251 | command_save_overlay (object *op, char *params) |
298 | { |
252 | { |
299 | if (!op) |
253 | if (!op) |
300 | return 0; |
254 | return 0; |
… | |
… | |
311 | |
265 | |
312 | ready_map_name (op->map->path, 0); |
266 | ready_map_name (op->map->path, 0); |
313 | |
267 | |
314 | return 1; |
268 | return 1; |
315 | } |
269 | } |
|
|
270 | #endif |
316 | |
271 | |
317 | int |
272 | int |
318 | command_shutdown (object *op, char *params) |
273 | command_shutdown (object *op, char *params) |
319 | { |
274 | { |
320 | struct pl *pl; |
|
|
321 | |
|
|
322 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
275 | if (op && !QUERY_FLAG (op, FLAG_WIZ)) |
323 | { |
276 | { |
324 | new_draw_info (NDI_UNIQUE, 0, op, "Sorry, you can't shutdown the server."); |
277 | new_draw_info (NDI_UNIQUE, 0, op, "Sorry, you can't shutdown the server."); |
325 | return 1; |
278 | return 1; |
326 | } |
279 | } |
327 | |
280 | |
328 | for (pl = first_player; pl != NULL; pl = pl->next) |
281 | cleanup ("dm initiated shutdown", 0); |
329 | save_player (pl->ob, 0); |
|
|
330 | |
282 | |
331 | for (pl = first_player; pl != NULL; pl = pl->next) |
|
|
332 | if (!QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
|
|
333 | leave_map (pl->ob); |
|
|
334 | |
|
|
335 | 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) |
… | |
… | |
438 | object *dummy; |
326 | object *dummy; |
439 | player *pl; |
327 | player *pl; |
440 | |
328 | |
441 | if (!op) |
329 | if (!op) |
442 | return 0; |
330 | return 0; |
|
|
331 | |
443 | if (params == NULL) |
332 | if (params == NULL) |
444 | { |
333 | { |
445 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: arrest <player>."); |
334 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: arrest <player>."); |
446 | return 1; |
335 | return 1; |
447 | } |
336 | } |
|
|
337 | |
448 | pl = get_other_player_from_name (op, params); |
338 | pl = get_other_player_from_name (op, params); |
449 | if (!pl) |
339 | if (!pl) |
450 | return 1; |
340 | return 1; |
|
|
341 | |
451 | dummy = get_jail_exit (pl->ob); |
342 | dummy = get_jail_exit (pl->ob); |
452 | if (!dummy) |
343 | if (!dummy) |
453 | { |
344 | { |
454 | /* we have nowhere to send the prisoner.... */ |
345 | /* we have nowhere to send the prisoner.... */ |
455 | new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them"); |
346 | new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them"); |
456 | return 0; |
347 | return 0; |
457 | } |
348 | } |
458 | enter_exit (pl->ob, dummy); |
349 | |
459 | free_object (dummy); |
350 | pl->ob->enter_exit (dummy); |
|
|
351 | dummy->destroy (); |
460 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You have been arrested."); |
352 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You have been arrested."); |
461 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
353 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
462 | LOG (llevInfo, "Player %s arrested by %s\n", &pl->ob->name, &op->name); |
354 | LOG (llevInfo, "Player %s arrested by %s\n", &pl->ob->name, &op->name); |
463 | return 1; |
355 | return 1; |
464 | } |
356 | } |
… | |
… | |
488 | { |
380 | { |
489 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player."); |
381 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player."); |
490 | return 1; |
382 | return 1; |
491 | } |
383 | } |
492 | |
384 | |
493 | dummy = get_object (); |
385 | dummy = object::create (); |
494 | EXIT_PATH (dummy) = op->map->path; |
386 | EXIT_PATH (dummy) = op->map->path; |
495 | EXIT_X (dummy) = op->x + freearr_x[i]; |
387 | EXIT_X (dummy) = op->x + freearr_x[i]; |
496 | EXIT_Y (dummy) = op->y + freearr_y[i]; |
388 | EXIT_Y (dummy) = op->y + freearr_y[i]; |
497 | enter_exit (pl->ob, dummy); |
389 | pl->ob->enter_exit (dummy); |
498 | free_object (dummy); |
390 | dummy->destroy (); |
499 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); |
391 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); |
500 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
392 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
501 | |
393 | |
502 | return 1; |
|
|
503 | } |
|
|
504 | |
|
|
505 | /** |
|
|
506 | * Teleport next to target player. |
|
|
507 | */ |
|
|
508 | |
|
|
509 | /* mids 01/16/2002 */ |
|
|
510 | int |
|
|
511 | command_teleport (object *op, char *params) |
|
|
512 | { |
|
|
513 | int i; |
|
|
514 | object *dummy; |
|
|
515 | player *pl; |
|
|
516 | |
|
|
517 | if (!op) |
|
|
518 | return 0; |
|
|
519 | |
|
|
520 | if (params == NULL) |
|
|
521 | { |
|
|
522 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: teleport <player>."); |
|
|
523 | return 1; |
|
|
524 | } |
|
|
525 | |
|
|
526 | pl = get_other_player_from_name (op, params); |
|
|
527 | if (!pl) |
|
|
528 | return 1; |
|
|
529 | |
|
|
530 | i = find_free_spot (pl->ob, pl->ob->map, pl->ob->x, pl->ob->y, 1, 9); |
|
|
531 | if (i == -1) |
|
|
532 | { |
|
|
533 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to teleport to."); |
|
|
534 | return 1; |
|
|
535 | } |
|
|
536 | |
|
|
537 | dummy = get_object (); |
|
|
538 | EXIT_PATH (dummy) = pl->ob->map->path; |
|
|
539 | EXIT_X (dummy) = pl->ob->x + freearr_x[i]; |
|
|
540 | EXIT_Y (dummy) = pl->ob->y + freearr_y[i]; |
|
|
541 | enter_exit (op, dummy); |
|
|
542 | free_object (dummy); |
|
|
543 | if (!op->contr->hidden) |
|
|
544 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You see a portal open."); |
|
|
545 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
|
|
546 | return 1; |
394 | return 1; |
547 | } |
395 | } |
548 | |
396 | |
549 | /** |
397 | /** |
550 | * This function is a real mess, because we're stucking getting |
398 | * This function is a real mess, because we're stucking getting |
… | |
… | |
644 | at_spell = archetype::find (cp); |
492 | at_spell = archetype::find (cp); |
645 | if (!at_spell || at_spell->clone.type != SPELL) |
493 | if (!at_spell || at_spell->clone.type != SPELL) |
646 | at_spell = find_archetype_by_object_name (cp); |
494 | at_spell = find_archetype_by_object_name (cp); |
647 | if (!at_spell || at_spell->clone.type != SPELL) |
495 | if (!at_spell || at_spell->clone.type != SPELL) |
648 | { |
496 | { |
649 | strcpy (spell_name, cp); |
497 | assign (spell_name, cp); |
650 | fsp = strchr (spell_name, ' '); |
498 | fsp = strchr (spell_name, ' '); |
651 | if (fsp) |
499 | if (fsp) |
652 | { |
500 | { |
653 | *fsp = 0; |
501 | *fsp = 0; |
654 | fsp++; |
502 | fsp++; |
… | |
… | |
834 | * so just copying it over should be fine. |
682 | * so just copying it over should be fine. |
835 | */ |
683 | */ |
836 | if (!head) |
684 | if (!head) |
837 | { |
685 | { |
838 | head = dup; |
686 | head = dup; |
839 | copy_object (tmp, dup); |
687 | tmp->copy_to (dup); |
840 | } |
688 | } |
841 | |
689 | |
842 | if (settings.real_wiz == FALSE) |
690 | if (settings.real_wiz == FALSE) |
843 | SET_FLAG (dup, FLAG_WAS_WIZ); |
691 | SET_FLAG (dup, FLAG_WAS_WIZ); |
844 | |
692 | |
… | |
… | |
871 | if (out_of_map (op->map, head->x + size_x, head->y + size_y)) |
719 | if (out_of_map (op->map, head->x + size_x, head->y + size_y)) |
872 | { |
720 | { |
873 | if (head->x < size_x || head->y < size_y) |
721 | if (head->x < size_x || head->y < size_y) |
874 | { |
722 | { |
875 | dm_stack_pop (op->contr); |
723 | dm_stack_pop (op->contr); |
876 | free_object (head); |
724 | head->destroy (); |
877 | new_draw_info (NDI_UNIQUE, 0, op, "Object too big to insert in map, or wrong position."); |
725 | new_draw_info (NDI_UNIQUE, 0, op, "Object too big to insert in map, or wrong position."); |
878 | free_object (tmp); |
726 | tmp->destroy (); |
879 | return 1; |
727 | return 1; |
880 | } |
728 | } |
881 | |
729 | |
882 | check = head; |
730 | check = head; |
883 | |
731 | |
… | |
… | |
905 | |
753 | |
906 | esrv_send_item (op, head); |
754 | esrv_send_item (op, head); |
907 | } |
755 | } |
908 | |
756 | |
909 | /* free the one we used to copy */ |
757 | /* free the one we used to copy */ |
910 | free_object (tmp); |
758 | tmp->destroy (); |
911 | } |
759 | } |
912 | |
760 | |
913 | return 1; |
761 | return 1; |
914 | } |
762 | } |
915 | |
763 | |
… | |
… | |
957 | |
805 | |
958 | tmp = get_dm_object (op->contr, ¶ms, NULL); |
806 | tmp = get_dm_object (op->contr, ¶ms, NULL); |
959 | if (!tmp) |
807 | if (!tmp) |
960 | return 1; |
808 | return 1; |
961 | |
809 | |
962 | dump_object (tmp); |
810 | char *dump = dump_object (tmp); |
963 | new_draw_info (NDI_UNIQUE, 0, op, errmsg); |
811 | new_draw_info (NDI_UNIQUE, 0, op, dump); |
|
|
812 | free (dump); |
|
|
813 | |
964 | if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL)) |
814 | if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL)) |
965 | new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); |
815 | new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); |
|
|
816 | |
966 | return 1; |
817 | return 1; |
967 | } |
818 | } |
968 | |
819 | |
969 | /** |
820 | /** |
970 | * When DM is possessing a monster, flip aggression on and off, to allow |
821 | * When DM is possessing a monster, flip aggression on and off, to allow |
… | |
… | |
1061 | victim->body_info[i] = 1; |
912 | victim->body_info[i] = 1; |
1062 | |
913 | |
1063 | esrv_new_player (pl, 80); /* just pick a wieght, we don't care */ |
914 | esrv_new_player (pl, 80); /* just pick a wieght, we don't care */ |
1064 | esrv_send_inventory (victim, victim); |
915 | esrv_send_inventory (victim, victim); |
1065 | |
916 | |
1066 | fix_player (victim); |
917 | victim->update_stats (); |
1067 | |
918 | |
1068 | do_some_living (victim); |
919 | do_some_living (victim); |
1069 | return 1; |
920 | return 1; |
1070 | } |
921 | } |
1071 | |
922 | |
… | |
… | |
1132 | dm_stack_pop (op->contr); |
983 | dm_stack_pop (op->contr); |
1133 | |
984 | |
1134 | /* Always work on the head - otherwise object will get in odd state */ |
985 | /* Always work on the head - otherwise object will get in odd state */ |
1135 | if (tmp->head) |
986 | if (tmp->head) |
1136 | tmp = tmp->head; |
987 | tmp = tmp->head; |
1137 | remove_ob (tmp); |
988 | tmp->remove (); |
1138 | return 1; |
989 | return 1; |
1139 | } |
990 | } |
1140 | |
991 | |
1141 | int |
992 | int |
1142 | command_free (object *op, char *params) |
993 | command_free (object *op, char *params) |
… | |
… | |
1154 | |
1005 | |
1155 | if (from != STACK_FROM_STACK) |
1006 | if (from != STACK_FROM_STACK) |
1156 | /* Item is either stack top, or is a number thus is now stack top, let's remove it */ |
1007 | /* Item is either stack top, or is a number thus is now stack top, let's remove it */ |
1157 | dm_stack_pop (op->contr); |
1008 | dm_stack_pop (op->contr); |
1158 | |
1009 | |
1159 | if (!QUERY_FLAG (tmp, FLAG_REMOVED)) |
|
|
1160 | { |
|
|
1161 | new_draw_info (NDI_UNIQUE, 0, op, "Warning, item wasn't removed."); |
|
|
1162 | remove_ob (tmp); |
|
|
1163 | } |
|
|
1164 | |
|
|
1165 | if (tmp->head) |
1010 | if (tmp->head) |
1166 | tmp = tmp->head; |
1011 | tmp = tmp->head; |
1167 | free_object (tmp); |
1012 | |
|
|
1013 | tmp->destroy (); |
1168 | return 1; |
1014 | return 1; |
1169 | } |
1015 | } |
1170 | |
1016 | |
1171 | /** |
1017 | /** |
1172 | * This adds exp to a player. We now allow adding to a specific skill. |
1018 | * This adds exp to a player. We now allow adding to a specific skill. |
… | |
… | |
1175 | command_addexp (object *op, char *params) |
1021 | command_addexp (object *op, char *params) |
1176 | { |
1022 | { |
1177 | char buf[MAX_BUF], skill[MAX_BUF]; |
1023 | char buf[MAX_BUF], skill[MAX_BUF]; |
1178 | int i, q; |
1024 | int i, q; |
1179 | object *skillob = NULL; |
1025 | object *skillob = NULL; |
1180 | player *pl; |
|
|
1181 | |
1026 | |
1182 | skill[0] = '\0'; |
1027 | skill[0] = '\0'; |
1183 | if ((params == NULL) || (strlen (params) > MAX_BUF) || ((q = sscanf (params, "%s %d %s", buf, &i, skill)) < 2)) |
1028 | if ((params == NULL) || (strlen (params) > MAX_BUF) || ((q = sscanf (params, "%s %d %s", buf, &i, skill)) < 2)) |
1184 | { |
1029 | { |
1185 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: addexp <who> <how much> [<skill>]."); |
1030 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: addexp <who> <how much> [<skill>]."); |
1186 | return 1; |
1031 | return 1; |
1187 | } |
1032 | } |
1188 | |
1033 | |
1189 | for (pl = first_player; pl != NULL; pl = pl->next) |
1034 | for_all_players (pl) |
1190 | if (!strncmp (pl->ob->name, buf, MAX_NAME)) |
1035 | if (!strncmp (pl->ob->name, buf, MAX_NAME)) |
1191 | break; |
|
|
1192 | |
|
|
1193 | if (pl == NULL) |
|
|
1194 | { |
1036 | { |
1195 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
|
|
1196 | return 1; |
|
|
1197 | } |
|
|
1198 | |
|
|
1199 | if (q >= 3) |
1037 | if (q >= 3) |
1200 | { |
1038 | { |
1201 | skillob = find_skill_by_name (pl->ob, skill); |
1039 | skillob = find_skill_by_name (pl->ob, skill); |
1202 | if (!skillob) |
1040 | if (!skillob) |
1203 | { |
1041 | { |
1204 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unable to find skill %s in %s", skill, buf); |
1042 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unable to find skill %s in %s", skill, buf); |
|
|
1043 | return 1; |
|
|
1044 | } |
|
|
1045 | |
|
|
1046 | i = check_exp_adjust (skillob, i); |
|
|
1047 | skillob->stats.exp += i; |
|
|
1048 | calc_perm_exp (skillob); |
|
|
1049 | player_lvl_adj (pl->ob, skillob); |
|
|
1050 | } |
|
|
1051 | |
|
|
1052 | pl->ob->stats.exp += i; |
|
|
1053 | calc_perm_exp (pl->ob); |
|
|
1054 | player_lvl_adj (pl->ob, NULL); |
|
|
1055 | |
|
|
1056 | if (settings.real_wiz == FALSE) |
|
|
1057 | SET_FLAG (pl->ob, FLAG_WAS_WIZ); |
|
|
1058 | |
1205 | return 1; |
1059 | return 1; |
1206 | } |
1060 | } |
1207 | |
1061 | |
1208 | i = check_exp_adjust (skillob, i); |
1062 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
1209 | skillob->stats.exp += i; |
|
|
1210 | calc_perm_exp (skillob); |
|
|
1211 | player_lvl_adj (pl->ob, skillob); |
|
|
1212 | } |
|
|
1213 | |
|
|
1214 | pl->ob->stats.exp += i; |
|
|
1215 | calc_perm_exp (pl->ob); |
|
|
1216 | player_lvl_adj (pl->ob, NULL); |
|
|
1217 | |
|
|
1218 | if (settings.real_wiz == FALSE) |
|
|
1219 | SET_FLAG (pl->ob, FLAG_WAS_WIZ); |
|
|
1220 | return 1; |
1063 | return 1; |
1221 | } |
1064 | } |
1222 | |
1065 | |
1223 | /**************************************************************************/ |
1066 | /**************************************************************************/ |
1224 | |
1067 | |
… | |
… | |
1230 | |
1073 | |
1231 | int |
1074 | int |
1232 | command_stats (object *op, char *params) |
1075 | command_stats (object *op, char *params) |
1233 | { |
1076 | { |
1234 | char thing[20]; |
1077 | char thing[20]; |
1235 | player *pl; |
|
|
1236 | char buf[MAX_BUF]; |
1078 | char buf[MAX_BUF]; |
1237 | |
1079 | |
1238 | thing[0] = '\0'; |
1080 | thing[0] = '\0'; |
1239 | if (params == NULL || !sscanf (params, "%s", thing) || thing == NULL) |
1081 | if (params == NULL || !sscanf (params, "%s", thing) || thing == NULL) |
1240 | { |
1082 | { |
1241 | new_draw_info (NDI_UNIQUE, 0, op, "Who?"); |
1083 | new_draw_info (NDI_UNIQUE, 0, op, "Who?"); |
1242 | return 1; |
1084 | return 1; |
1243 | } |
1085 | } |
1244 | |
1086 | |
1245 | for (pl = first_player; pl != NULL; pl = pl->next) |
1087 | for_all_players (pl) |
1246 | if (!strcmp (pl->ob->name, thing)) |
1088 | if (!strcmp (pl->ob->name, thing)) |
1247 | { |
1089 | { |
1248 | sprintf (buf, "Str : %-2d H.P. : %-4d MAX : %d", pl->ob->stats.Str, pl->ob->stats.hp, pl->ob->stats.maxhp); |
1090 | sprintf (buf, "Str : %-2d H.P. : %-4d MAX : %d", pl->ob->stats.Str, pl->ob->stats.hp, pl->ob->stats.maxhp); |
1249 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1091 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1250 | sprintf (buf, "Dex : %-2d S.P. : %-4d MAX : %d", pl->ob->stats.Dex, pl->ob->stats.sp, pl->ob->stats.maxsp); |
1092 | sprintf (buf, "Dex : %-2d S.P. : %-4d MAX : %d", pl->ob->stats.Dex, pl->ob->stats.sp, pl->ob->stats.maxsp); |
1251 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1093 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1252 | sprintf (buf, "Con : %-2d AC : %-4d WC : %d", pl->ob->stats.Con, pl->ob->stats.ac, pl->ob->stats.wc); |
1094 | sprintf (buf, "Con : %-2d AC : %-4d WC : %d", pl->ob->stats.Con, pl->ob->stats.ac, pl->ob->stats.wc); |
1253 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1095 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1254 | sprintf (buf, "Int : %-2d Damage : %d", pl->ob->stats.Int, pl->ob->stats.dam); |
1096 | sprintf (buf, "Int : %-2d Damage : %d", pl->ob->stats.Int, pl->ob->stats.dam); |
1255 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1097 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1256 | sprintf (buf, "Wis : %-2d EXP : %lld", pl->ob->stats.Wis, (long long) pl->ob->stats.exp); |
1098 | sprintf (buf, "Wis : %-2d EXP : %" PRId64, pl->ob->stats.Wis, pl->ob->stats.exp); |
1257 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1099 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1258 | sprintf (buf, "Pow : %-2d Grace : %d", pl->ob->stats.Pow, pl->ob->stats.grace); |
1100 | sprintf (buf, "Pow : %-2d Grace : %d", pl->ob->stats.Pow, pl->ob->stats.grace); |
1259 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1101 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1260 | sprintf (buf, "Cha : %-2d Food : %d", pl->ob->stats.Cha, pl->ob->stats.food); |
1102 | sprintf (buf, "Cha : %-2d Food : %d", pl->ob->stats.Cha, pl->ob->stats.food); |
1261 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1103 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1262 | break; |
1104 | return 1; |
1263 | } |
1105 | } |
1264 | if (pl == NULL) |
1106 | |
1265 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
1107 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
1266 | return 1; |
1108 | return 1; |
1267 | } |
1109 | } |
1268 | |
1110 | |
1269 | int |
1111 | int |
1270 | command_abil (object *op, char *params) |
1112 | command_abil (object *op, char *params) |
… | |
… | |
1293 | { |
1135 | { |
1294 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal range of stat.\n"); |
1136 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal range of stat.\n"); |
1295 | return 1; |
1137 | return 1; |
1296 | } |
1138 | } |
1297 | |
1139 | |
1298 | for (pl = first_player; pl != NULL; pl = pl->next) |
1140 | for_all_players (pl) |
1299 | { |
1141 | { |
1300 | if (!strcmp (pl->ob->name, thing)) |
1142 | if (!strcmp (pl->ob->name, thing)) |
1301 | { |
1143 | { |
1302 | if (settings.real_wiz == FALSE) |
1144 | if (settings.real_wiz == FALSE) |
1303 | SET_FLAG (pl->ob, FLAG_WAS_WIZ); |
1145 | SET_FLAG (pl->ob, FLAG_WAS_WIZ); |
… | |
… | |
1315 | pl->ob->stats.Int = iii, pl->orig_stats.Int = iii; |
1157 | pl->ob->stats.Int = iii, pl->orig_stats.Int = iii; |
1316 | if (!strcmp ("pow", thing2)) |
1158 | if (!strcmp ("pow", thing2)) |
1317 | pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii; |
1159 | pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii; |
1318 | sprintf (buf, "%s has been altered.", &pl->ob->name); |
1160 | sprintf (buf, "%s has been altered.", &pl->ob->name); |
1319 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1161 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1320 | fix_player (pl->ob); |
1162 | pl->ob->update_stats (); |
1321 | return 1; |
1163 | return 1; |
1322 | } |
1164 | } |
1323 | } |
1165 | } |
1324 | |
1166 | |
1325 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
1167 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
1326 | return 1; |
1168 | return 1; |
1327 | } |
|
|
1328 | |
|
|
1329 | int |
|
|
1330 | command_reset (object *op, char *params) |
|
|
1331 | { |
|
|
1332 | mapstruct *m; |
|
|
1333 | object *dummy = NULL, *tmp = NULL; |
|
|
1334 | |
|
|
1335 | if (params == NULL) |
|
|
1336 | { |
|
|
1337 | new_draw_info (NDI_UNIQUE, 0, op, "Reset what map [name]?"); |
|
|
1338 | return 1; |
|
|
1339 | } |
|
|
1340 | |
|
|
1341 | if (strcmp (params, ".") == 0) |
|
|
1342 | params = op->map->path; |
|
|
1343 | m = has_been_loaded (params); |
|
|
1344 | if (m == NULL) |
|
|
1345 | { |
|
|
1346 | new_draw_info (NDI_UNIQUE, 0, op, "No such map."); |
|
|
1347 | return 1; |
|
|
1348 | } |
|
|
1349 | |
|
|
1350 | if (m->in_memory != MAP_SWAPPED) |
|
|
1351 | { |
|
|
1352 | if (m->in_memory != MAP_IN_MEMORY) |
|
|
1353 | { |
|
|
1354 | LOG (llevError, "Tried to swap out map which was not in memory.\n"); |
|
|
1355 | return 0; |
|
|
1356 | } |
|
|
1357 | |
|
|
1358 | /* |
|
|
1359 | * Only attempt to remove the player that is doing the reset, and not other |
|
|
1360 | * players or wiz's. |
|
|
1361 | */ |
|
|
1362 | if (op->map == m) |
|
|
1363 | { |
|
|
1364 | dummy = get_object (); |
|
|
1365 | dummy->map = NULL; |
|
|
1366 | EXIT_X (dummy) = op->x; |
|
|
1367 | EXIT_Y (dummy) = op->y; |
|
|
1368 | EXIT_PATH (dummy) = op->map->path; |
|
|
1369 | remove_ob (op); |
|
|
1370 | op->map = NULL; |
|
|
1371 | tmp = op; |
|
|
1372 | } |
|
|
1373 | swap_map (m); |
|
|
1374 | } |
|
|
1375 | |
|
|
1376 | if (m->in_memory == MAP_SWAPPED) |
|
|
1377 | { |
|
|
1378 | LOG (llevDebug, "Resetting map %s.\n", m->path); |
|
|
1379 | |
|
|
1380 | /* setting this effectively causes an immediate reload */ |
|
|
1381 | m->reset_time = 1; |
|
|
1382 | flush_old_maps (); |
|
|
1383 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
|
|
1384 | if (tmp) |
|
|
1385 | { |
|
|
1386 | enter_exit (tmp, dummy); |
|
|
1387 | free_object (dummy); |
|
|
1388 | } |
|
|
1389 | return 1; |
|
|
1390 | } |
|
|
1391 | else |
|
|
1392 | { |
|
|
1393 | player *pl; |
|
|
1394 | int playercount = 0; |
|
|
1395 | |
|
|
1396 | /* Need to re-insert player if swap failed for some reason */ |
|
|
1397 | if (tmp) |
|
|
1398 | { |
|
|
1399 | insert_ob_in_map (op, m, NULL, 0); |
|
|
1400 | free_object (dummy); |
|
|
1401 | } |
|
|
1402 | |
|
|
1403 | new_draw_info (NDI_UNIQUE, 0, op, "Reset failed, couldn't swap map, the following players are on it:"); |
|
|
1404 | for (pl = first_player; pl != NULL; pl = pl->next) |
|
|
1405 | { |
|
|
1406 | if (pl->ob->map == m && pl->ob != op) |
|
|
1407 | { |
|
|
1408 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s", &pl->ob->name); |
|
|
1409 | playercount++; |
|
|
1410 | } |
|
|
1411 | } |
|
|
1412 | if (!playercount) |
|
|
1413 | new_draw_info (NDI_UNIQUE, 0, op, "hmm, I don't see any other players on this map, something else is the problem."); |
|
|
1414 | return 1; |
|
|
1415 | } |
|
|
1416 | } |
1169 | } |
1417 | |
1170 | |
1418 | int |
1171 | int |
1419 | command_nowiz (object *op, char *params) |
1172 | command_nowiz (object *op, char *params) |
1420 | { /* 'noadm' is alias */ |
1173 | { /* 'noadm' is alias */ |
… | |
… | |
1490 | { |
1243 | { |
1491 | new_draw_info (NDI_UNIQUE, 0, op, "You are already the Dungeon Master!"); |
1244 | new_draw_info (NDI_UNIQUE, 0, op, "You are already the Dungeon Master!"); |
1492 | return 0; |
1245 | return 0; |
1493 | } |
1246 | } |
1494 | |
1247 | |
1495 | if (checkdm (op, op->name, (params ? params : "*"), op->contr->socket.host)) |
1248 | if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) |
1496 | { |
1249 | { |
1497 | SET_FLAG (op, FLAG_WIZ); |
1250 | SET_FLAG (op, FLAG_WIZ); |
1498 | SET_FLAG (op, FLAG_WAS_WIZ); |
1251 | SET_FLAG (op, FLAG_WAS_WIZ); |
1499 | SET_FLAG (op, FLAG_WIZPASS); |
1252 | SET_FLAG (op, FLAG_WIZPASS); |
1500 | SET_FLAG (op, FLAG_WIZCAST); |
1253 | SET_FLAG (op, FLAG_WIZCAST); |
… | |
… | |
1671 | new_draw_info_format (NDI_UNIQUE, 0, op, "You already know the spell %s.", &tmp->name); |
1424 | new_draw_info_format (NDI_UNIQUE, 0, op, "You already know the spell %s.", &tmp->name); |
1672 | return 0; |
1425 | return 0; |
1673 | } |
1426 | } |
1674 | |
1427 | |
1675 | do_learn_spell (op, tmp, special_prayer); |
1428 | do_learn_spell (op, tmp, special_prayer); |
1676 | free_object (tmp); |
1429 | tmp->destroy (); |
1677 | return 1; |
1430 | return 1; |
1678 | } |
1431 | } |
1679 | |
1432 | |
1680 | int |
1433 | int |
1681 | command_learn_spell (object *op, char *params) |
1434 | command_learn_spell (object *op, char *params) |
… | |
… | |
2093 | new_draw_info (NDI_UNIQUE, 0, op, "Can't insert a player into something!"); |
1846 | new_draw_info (NDI_UNIQUE, 0, op, "Can't insert a player into something!"); |
2094 | return 0; |
1847 | return 0; |
2095 | } |
1848 | } |
2096 | |
1849 | |
2097 | if (!QUERY_FLAG (right, FLAG_REMOVED)) |
1850 | if (!QUERY_FLAG (right, FLAG_REMOVED)) |
2098 | remove_ob (right); |
1851 | right->remove (); |
2099 | inserted = insert_ob_in_ob (right, left); |
1852 | inserted = insert_ob_in_ob (right, left); |
2100 | if (left->type == PLAYER) |
1853 | if (left->type == PLAYER) |
2101 | if (inserted == right) |
1854 | if (inserted == right) |
2102 | esrv_send_item (left, right); |
1855 | esrv_send_item (left, right); |
2103 | else |
1856 | else |