1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_c_wiz_c = |
|
|
4 | * "$Id: c_wiz.C,v 1.9 2006/09/10 14:15:34 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> |
… | |
… | |
73 | if (pl->ob == op) |
67 | if (pl->ob == op) |
74 | { |
68 | { |
75 | new_draw_info (NDI_UNIQUE, 0, op, "You can't do that to yourself."); |
69 | new_draw_info (NDI_UNIQUE, 0, op, "You can't do that to yourself."); |
76 | return NULL; |
70 | return NULL; |
77 | } |
71 | } |
|
|
72 | |
78 | if (pl->state != ST_PLAYING) |
73 | if (pl->ns->state != ST_PLAYING) |
79 | { |
74 | { |
80 | new_draw_info (NDI_UNIQUE, 0, op, "That player is in no state for that right now."); |
75 | new_draw_info (NDI_UNIQUE, 0, op, "That player is in no state for that right now."); |
81 | return NULL; |
76 | return NULL; |
82 | } |
77 | } |
|
|
78 | |
83 | return pl; |
79 | 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 | } |
80 | } |
121 | |
81 | |
122 | /** |
82 | /** |
123 | * Actually hides specified player (obviously a DM). |
83 | * Actually hides specified player (obviously a DM). |
124 | * If 'silent_dm' is non zero, other players are informed of DM entering/leaving, |
84 | * If 'silent_dm' is non zero, other players are informed of DM entering/leaving, |
… | |
… | |
258 | now = time (NULL); |
218 | now = time (NULL); |
259 | /* |
219 | /* |
260 | * Record this as a comment - then we don't have to worry about changing |
220 | * Record this as a comment - then we don't have to worry about changing |
261 | * the parsing code. |
221 | * the parsing code. |
262 | */ |
222 | */ |
263 | fprintf (banishfile, "# %s (%s) banned by %s at %s\n", &pl->ob->name, pl->socket.host, &op->name, ctime (&now)); |
223 | 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); |
224 | fprintf (banishfile, "*@%s\n", pl->ns->host); |
265 | fclose (banishfile); |
225 | fclose (banishfile); |
266 | |
226 | |
267 | LOG (llevDebug, "! %s banned %s from IP: %s.\n", &op->name, &pl->ob->name, pl->socket.host); |
227 | 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); |
228 | 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); |
229 | 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); |
230 | command_kick (op, (char *) &pl->ob->name); |
271 | return 1; |
231 | return 1; |
272 | } |
232 | } |
273 | |
233 | |
274 | int |
234 | int |
275 | command_kick (object *op, char *params) |
235 | command_kick (object *op, char *params) |
276 | { |
236 | { |
277 | struct pl *pl; |
|
|
278 | |
|
|
279 | for (pl = first_player; pl != NULL; pl = pl->next) |
237 | 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))) |
238 | if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) |
281 | { |
239 | { |
282 | object *op = pl->ob; |
240 | object *op = pl->ob; |
283 | |
241 | |
284 | if (!QUERY_FLAG (op, FLAG_REMOVED) && !QUERY_FLAG (op, FLAG_FREED)) |
242 | if (!QUERY_FLAG (op, FLAG_REMOVED) && !QUERY_FLAG (op, FLAG_FREED)) |
285 | { |
243 | { |
286 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s is kicked out of the game.", &op->name); |
244 | 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"); |
245 | strcpy (op->contr->killer, "kicked"); |
288 | } |
246 | } |
289 | |
247 | |
290 | pl->socket.status = Ns_Dead; |
248 | pl->ns->destroy (); |
291 | } |
249 | } |
292 | |
250 | |
293 | return 1; |
251 | return 1; |
294 | } |
252 | } |
295 | |
253 | |
… | |
… | |
315 | } |
273 | } |
316 | |
274 | |
317 | int |
275 | int |
318 | command_shutdown (object *op, char *params) |
276 | command_shutdown (object *op, char *params) |
319 | { |
277 | { |
320 | struct pl *pl; |
|
|
321 | |
|
|
322 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
278 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
323 | { |
279 | { |
324 | new_draw_info (NDI_UNIQUE, 0, op, "Sorry, you can't shutdown the server."); |
280 | new_draw_info (NDI_UNIQUE, 0, op, "Sorry, you can't shutdown the server."); |
325 | return 1; |
281 | return 1; |
326 | } |
282 | } |
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 | |
283 | |
335 | cleanup (); |
284 | cleanup (); |
336 | /* not reached */ |
285 | /* 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; |
286 | return 1; |
397 | } |
287 | } |
398 | |
288 | |
399 | int |
289 | int |
400 | command_freeze (object *op, char *params) |
290 | command_freeze (object *op, char *params) |
… | |
… | |
454 | /* we have nowhere to send the prisoner.... */ |
344 | /* 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"); |
345 | new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them"); |
456 | return 0; |
346 | return 0; |
457 | } |
347 | } |
458 | enter_exit (pl->ob, dummy); |
348 | enter_exit (pl->ob, dummy); |
459 | free_object (dummy); |
349 | dummy->destroy (); |
460 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You have been arrested."); |
350 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You have been arrested."); |
461 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
351 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
462 | LOG (llevInfo, "Player %s arrested by %s\n", &pl->ob->name, &op->name); |
352 | LOG (llevInfo, "Player %s arrested by %s\n", &pl->ob->name, &op->name); |
463 | return 1; |
353 | return 1; |
464 | } |
354 | } |
… | |
… | |
488 | { |
378 | { |
489 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player."); |
379 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player."); |
490 | return 1; |
380 | return 1; |
491 | } |
381 | } |
492 | |
382 | |
493 | dummy = get_object (); |
383 | dummy = object::create (); |
494 | EXIT_PATH (dummy) = op->map->path; |
384 | EXIT_PATH (dummy) = op->map->path; |
495 | EXIT_X (dummy) = op->x + freearr_x[i]; |
385 | EXIT_X (dummy) = op->x + freearr_x[i]; |
496 | EXIT_Y (dummy) = op->y + freearr_y[i]; |
386 | EXIT_Y (dummy) = op->y + freearr_y[i]; |
497 | enter_exit (pl->ob, dummy); |
387 | enter_exit (pl->ob, dummy); |
498 | free_object (dummy); |
388 | dummy->destroy (); |
499 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); |
389 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); |
500 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
390 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
501 | |
391 | |
502 | return 1; |
392 | return 1; |
503 | } |
393 | } |
… | |
… | |
532 | { |
422 | { |
533 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to teleport to."); |
423 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to teleport to."); |
534 | return 1; |
424 | return 1; |
535 | } |
425 | } |
536 | |
426 | |
537 | dummy = get_object (); |
427 | dummy = object::create (); |
538 | EXIT_PATH (dummy) = pl->ob->map->path; |
428 | EXIT_PATH (dummy) = pl->ob->map->path; |
539 | EXIT_X (dummy) = pl->ob->x + freearr_x[i]; |
429 | EXIT_X (dummy) = pl->ob->x + freearr_x[i]; |
540 | EXIT_Y (dummy) = pl->ob->y + freearr_y[i]; |
430 | EXIT_Y (dummy) = pl->ob->y + freearr_y[i]; |
541 | enter_exit (op, dummy); |
431 | enter_exit (op, dummy); |
542 | free_object (dummy); |
432 | dummy->destroy (); |
543 | if (!op->contr->hidden) |
433 | if (!op->contr->hidden) |
544 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You see a portal open."); |
434 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You see a portal open."); |
545 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
435 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
546 | return 1; |
436 | return 1; |
547 | } |
437 | } |
… | |
… | |
623 | bp2++; |
513 | bp2++; |
624 | break; |
514 | break; |
625 | } |
515 | } |
626 | } |
516 | } |
627 | |
517 | |
628 | if ((at = find_archetype (bp)) == NULL) |
518 | if ((at = archetype::find (bp)) == NULL) |
629 | { |
519 | { |
630 | new_draw_info (NDI_UNIQUE, 0, op, "No such archetype."); |
520 | new_draw_info (NDI_UNIQUE, 0, op, "No such archetype."); |
631 | return 1; |
521 | return 1; |
632 | } |
522 | } |
633 | |
523 | |
… | |
… | |
639 | * Try to find a spell object for this. Note that |
529 | * Try to find a spell object for this. Note that |
640 | * we also set up spell_name which is only |
530 | * we also set up spell_name which is only |
641 | * the first word. |
531 | * the first word. |
642 | */ |
532 | */ |
643 | |
533 | |
644 | at_spell = find_archetype (cp); |
534 | at_spell = archetype::find (cp); |
645 | if (!at_spell || at_spell->clone.type != SPELL) |
535 | if (!at_spell || at_spell->clone.type != SPELL) |
646 | at_spell = find_archetype_by_object_name (cp); |
536 | at_spell = find_archetype_by_object_name (cp); |
647 | if (!at_spell || at_spell->clone.type != SPELL) |
537 | if (!at_spell || at_spell->clone.type != SPELL) |
648 | { |
538 | { |
649 | strcpy (spell_name, cp); |
539 | strcpy (spell_name, cp); |
650 | fsp = strchr (spell_name, ' '); |
540 | fsp = strchr (spell_name, ' '); |
651 | if (fsp) |
541 | if (fsp) |
652 | { |
542 | { |
653 | *fsp = 0; |
543 | *fsp = 0; |
654 | fsp++; |
544 | fsp++; |
655 | at_spell = find_archetype (spell_name); |
545 | at_spell = archetype::find (spell_name); |
656 | |
546 | |
657 | /* Got a spell, update the first string pointer */ |
547 | /* Got a spell, update the first string pointer */ |
658 | if (at_spell && at_spell->clone.type == SPELL) |
548 | if (at_spell && at_spell->clone.type == SPELL) |
659 | bp2 = cp + strlen (spell_name) + 1; |
549 | bp2 = cp + strlen (spell_name) + 1; |
660 | else |
550 | else |
… | |
… | |
818 | else |
708 | else |
819 | { |
709 | { |
820 | for (i = 0; i < (set_nrof ? nrof : 1); i++) |
710 | for (i = 0; i < (set_nrof ? nrof : 1); i++) |
821 | { |
711 | { |
822 | archetype *atmp; |
712 | archetype *atmp; |
823 | object *prev = NULL, *head = NULL, *dup; |
713 | object *prev = 0, *head = 0; |
824 | |
714 | |
825 | for (atmp = at; atmp != NULL; atmp = atmp->more) |
715 | for (atmp = at; atmp; atmp = atmp->more) |
826 | { |
716 | { |
827 | dup = arch_to_object (atmp); |
717 | object *dup = arch_to_object (atmp); |
828 | |
718 | |
829 | if (at_spell) |
719 | if (at_spell) |
830 | insert_ob_in_ob (arch_to_object (at_spell), dup); |
720 | insert_ob_in_ob (arch_to_object (at_spell), dup); |
831 | |
721 | |
832 | /* |
722 | /* |
833 | * The head is what contains all the important bits, |
723 | * The head is what contains all the important bits, |
834 | * so just copying it over should be fine. |
724 | * so just copying it over should be fine. |
835 | */ |
725 | */ |
836 | if (head == NULL) |
726 | if (!head) |
837 | { |
727 | { |
838 | head = dup; |
728 | head = dup; |
839 | copy_object (tmp, dup); |
729 | tmp->copy_to (dup); |
840 | } |
730 | } |
841 | |
731 | |
842 | if (settings.real_wiz == FALSE) |
732 | if (settings.real_wiz == FALSE) |
843 | SET_FLAG (dup, FLAG_WAS_WIZ); |
733 | SET_FLAG (dup, FLAG_WAS_WIZ); |
844 | |
734 | |
… | |
… | |
871 | if (out_of_map (op->map, head->x + size_x, head->y + size_y)) |
761 | if (out_of_map (op->map, head->x + size_x, head->y + size_y)) |
872 | { |
762 | { |
873 | if (head->x < size_x || head->y < size_y) |
763 | if (head->x < size_x || head->y < size_y) |
874 | { |
764 | { |
875 | dm_stack_pop (op->contr); |
765 | dm_stack_pop (op->contr); |
876 | free_object (head); |
766 | head->destroy (); |
877 | new_draw_info (NDI_UNIQUE, 0, op, "Object too big to insert in map, or wrong position."); |
767 | new_draw_info (NDI_UNIQUE, 0, op, "Object too big to insert in map, or wrong position."); |
878 | free_object (tmp); |
768 | tmp->destroy (); |
879 | return 1; |
769 | return 1; |
880 | } |
770 | } |
881 | |
771 | |
882 | check = head; |
772 | check = head; |
883 | |
773 | |
… | |
… | |
905 | |
795 | |
906 | esrv_send_item (op, head); |
796 | esrv_send_item (op, head); |
907 | } |
797 | } |
908 | |
798 | |
909 | /* free the one we used to copy */ |
799 | /* free the one we used to copy */ |
910 | free_object (tmp); |
800 | tmp->destroy (); |
911 | } |
801 | } |
912 | |
802 | |
913 | return 1; |
803 | return 1; |
914 | } |
804 | } |
915 | |
805 | |
… | |
… | |
957 | |
847 | |
958 | tmp = get_dm_object (op->contr, ¶ms, NULL); |
848 | tmp = get_dm_object (op->contr, ¶ms, NULL); |
959 | if (!tmp) |
849 | if (!tmp) |
960 | return 1; |
850 | return 1; |
961 | |
851 | |
962 | dump_object (tmp); |
852 | char *dump = dump_object (tmp); |
963 | new_draw_info (NDI_UNIQUE, 0, op, errmsg); |
853 | new_draw_info (NDI_UNIQUE, 0, op, dump); |
|
|
854 | free (dump); |
|
|
855 | |
964 | if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL)) |
856 | if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL)) |
965 | new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); |
857 | new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); |
|
|
858 | |
966 | return 1; |
859 | return 1; |
967 | } |
860 | } |
968 | |
861 | |
969 | /** |
862 | /** |
970 | * When DM is possessing a monster, flip aggression on and off, to allow |
863 | * When DM is possessing a monster, flip aggression on and off, to allow |
… | |
… | |
1132 | dm_stack_pop (op->contr); |
1025 | dm_stack_pop (op->contr); |
1133 | |
1026 | |
1134 | /* Always work on the head - otherwise object will get in odd state */ |
1027 | /* Always work on the head - otherwise object will get in odd state */ |
1135 | if (tmp->head) |
1028 | if (tmp->head) |
1136 | tmp = tmp->head; |
1029 | tmp = tmp->head; |
1137 | remove_ob (tmp); |
1030 | tmp->remove (); |
1138 | return 1; |
1031 | return 1; |
1139 | } |
1032 | } |
1140 | |
1033 | |
1141 | int |
1034 | int |
1142 | command_free (object *op, char *params) |
1035 | command_free (object *op, char *params) |
… | |
… | |
1157 | dm_stack_pop (op->contr); |
1050 | dm_stack_pop (op->contr); |
1158 | |
1051 | |
1159 | if (!QUERY_FLAG (tmp, FLAG_REMOVED)) |
1052 | if (!QUERY_FLAG (tmp, FLAG_REMOVED)) |
1160 | { |
1053 | { |
1161 | new_draw_info (NDI_UNIQUE, 0, op, "Warning, item wasn't removed."); |
1054 | new_draw_info (NDI_UNIQUE, 0, op, "Warning, item wasn't removed."); |
1162 | remove_ob (tmp); |
1055 | tmp->remove (); |
1163 | } |
1056 | } |
1164 | |
1057 | |
1165 | if (tmp->head) |
1058 | if (tmp->head) |
1166 | tmp = tmp->head; |
1059 | tmp = tmp->head; |
1167 | free_object (tmp); |
1060 | |
|
|
1061 | tmp->destroy (); |
1168 | return 1; |
1062 | return 1; |
1169 | } |
1063 | } |
1170 | |
1064 | |
1171 | /** |
1065 | /** |
1172 | * This adds exp to a player. We now allow adding to a specific skill. |
1066 | * This adds exp to a player. We now allow adding to a specific skill. |
… | |
… | |
1251 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1145 | 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); |
1146 | 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); |
1147 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1254 | sprintf (buf, "Int : %-2d Damage : %d", pl->ob->stats.Int, pl->ob->stats.dam); |
1148 | sprintf (buf, "Int : %-2d Damage : %d", pl->ob->stats.Int, pl->ob->stats.dam); |
1255 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1149 | 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); |
1150 | sprintf (buf, "Wis : %-2d EXP : %" PRId64, pl->ob->stats.Wis, pl->ob->stats.exp); |
1257 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1151 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1258 | sprintf (buf, "Pow : %-2d Grace : %d", pl->ob->stats.Pow, pl->ob->stats.grace); |
1152 | sprintf (buf, "Pow : %-2d Grace : %d", pl->ob->stats.Pow, pl->ob->stats.grace); |
1259 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1153 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1260 | sprintf (buf, "Cha : %-2d Food : %d", pl->ob->stats.Cha, pl->ob->stats.food); |
1154 | sprintf (buf, "Cha : %-2d Food : %d", pl->ob->stats.Cha, pl->ob->stats.food); |
1261 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1155 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
… | |
… | |
1327 | } |
1221 | } |
1328 | |
1222 | |
1329 | int |
1223 | int |
1330 | command_reset (object *op, char *params) |
1224 | command_reset (object *op, char *params) |
1331 | { |
1225 | { |
1332 | mapstruct *m; |
1226 | maptile *m; |
1333 | object *dummy = NULL, *tmp = NULL; |
1227 | object *dummy = NULL, *tmp = NULL; |
1334 | |
1228 | |
1335 | if (params == NULL) |
1229 | if (params == NULL) |
1336 | { |
1230 | { |
1337 | new_draw_info (NDI_UNIQUE, 0, op, "Reset what map [name]?"); |
1231 | new_draw_info (NDI_UNIQUE, 0, op, "Reset what map [name]?"); |
1338 | return 1; |
1232 | return 1; |
1339 | } |
1233 | } |
1340 | |
1234 | |
1341 | if (strcmp (params, ".") == 0) |
1235 | if (strcmp (params, ".") == 0) |
1342 | params = op->map->path; |
1236 | params = op->map->path; |
|
|
1237 | |
1343 | m = has_been_loaded (params); |
1238 | m = has_been_loaded (params); |
1344 | if (m == NULL) |
1239 | if (m == NULL) |
1345 | { |
1240 | { |
1346 | new_draw_info (NDI_UNIQUE, 0, op, "No such map."); |
1241 | new_draw_info (NDI_UNIQUE, 0, op, "No such map."); |
1347 | return 1; |
1242 | return 1; |
… | |
… | |
1359 | * Only attempt to remove the player that is doing the reset, and not other |
1254 | * Only attempt to remove the player that is doing the reset, and not other |
1360 | * players or wiz's. |
1255 | * players or wiz's. |
1361 | */ |
1256 | */ |
1362 | if (op->map == m) |
1257 | if (op->map == m) |
1363 | { |
1258 | { |
1364 | dummy = get_object (); |
1259 | dummy = object::create (); |
1365 | dummy->map = NULL; |
1260 | dummy->map = NULL; |
1366 | EXIT_X (dummy) = op->x; |
1261 | EXIT_X (dummy) = op->x; |
1367 | EXIT_Y (dummy) = op->y; |
1262 | EXIT_Y (dummy) = op->y; |
1368 | EXIT_PATH (dummy) = op->map->path; |
1263 | EXIT_PATH (dummy) = op->map->path; |
1369 | remove_ob (op); |
1264 | op->remove (); |
1370 | op->map = NULL; |
1265 | op->map = NULL; |
1371 | tmp = op; |
1266 | tmp = op; |
1372 | } |
1267 | } |
1373 | swap_map (m); |
1268 | swap_map (m); |
1374 | } |
1269 | } |
… | |
… | |
1379 | |
1274 | |
1380 | /* setting this effectively causes an immediate reload */ |
1275 | /* setting this effectively causes an immediate reload */ |
1381 | m->reset_time = 1; |
1276 | m->reset_time = 1; |
1382 | flush_old_maps (); |
1277 | flush_old_maps (); |
1383 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
1278 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
|
|
1279 | |
1384 | if (tmp) |
1280 | if (tmp) |
1385 | { |
1281 | { |
1386 | enter_exit (tmp, dummy); |
1282 | enter_exit (tmp, dummy); |
1387 | free_object (dummy); |
1283 | dummy->destroy (); |
1388 | } |
1284 | } |
|
|
1285 | |
1389 | return 1; |
1286 | return 1; |
1390 | } |
1287 | } |
1391 | else |
1288 | else |
1392 | { |
1289 | { |
1393 | player *pl; |
1290 | player *pl; |
… | |
… | |
1395 | |
1292 | |
1396 | /* Need to re-insert player if swap failed for some reason */ |
1293 | /* Need to re-insert player if swap failed for some reason */ |
1397 | if (tmp) |
1294 | if (tmp) |
1398 | { |
1295 | { |
1399 | insert_ob_in_map (op, m, NULL, 0); |
1296 | insert_ob_in_map (op, m, NULL, 0); |
1400 | free_object (dummy); |
1297 | dummy->destroy (); |
1401 | } |
1298 | } |
1402 | |
1299 | |
1403 | new_draw_info (NDI_UNIQUE, 0, op, "Reset failed, couldn't swap map, the following players are on it:"); |
1300 | 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) |
1301 | for (pl = first_player; pl != NULL; pl = pl->next) |
1405 | { |
1302 | { |
… | |
… | |
1490 | { |
1387 | { |
1491 | new_draw_info (NDI_UNIQUE, 0, op, "You are already the Dungeon Master!"); |
1388 | new_draw_info (NDI_UNIQUE, 0, op, "You are already the Dungeon Master!"); |
1492 | return 0; |
1389 | return 0; |
1493 | } |
1390 | } |
1494 | |
1391 | |
1495 | if (checkdm (op, op->name, (params ? params : "*"), op->contr->socket.host)) |
1392 | if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) |
1496 | { |
1393 | { |
1497 | SET_FLAG (op, FLAG_WIZ); |
1394 | SET_FLAG (op, FLAG_WIZ); |
1498 | SET_FLAG (op, FLAG_WAS_WIZ); |
1395 | SET_FLAG (op, FLAG_WAS_WIZ); |
1499 | SET_FLAG (op, FLAG_WIZPASS); |
1396 | SET_FLAG (op, FLAG_WIZPASS); |
1500 | SET_FLAG (op, FLAG_WIZCAST); |
1397 | SET_FLAG (op, FLAG_WIZCAST); |
… | |
… | |
1671 | new_draw_info_format (NDI_UNIQUE, 0, op, "You already know the spell %s.", &tmp->name); |
1568 | new_draw_info_format (NDI_UNIQUE, 0, op, "You already know the spell %s.", &tmp->name); |
1672 | return 0; |
1569 | return 0; |
1673 | } |
1570 | } |
1674 | |
1571 | |
1675 | do_learn_spell (op, tmp, special_prayer); |
1572 | do_learn_spell (op, tmp, special_prayer); |
1676 | free_object (tmp); |
1573 | tmp->destroy (); |
1677 | return 1; |
1574 | return 1; |
1678 | } |
1575 | } |
1679 | |
1576 | |
1680 | int |
1577 | int |
1681 | command_learn_spell (object *op, char *params) |
1578 | command_learn_spell (object *op, char *params) |
… | |
… | |
2093 | new_draw_info (NDI_UNIQUE, 0, op, "Can't insert a player into something!"); |
1990 | new_draw_info (NDI_UNIQUE, 0, op, "Can't insert a player into something!"); |
2094 | return 0; |
1991 | return 0; |
2095 | } |
1992 | } |
2096 | |
1993 | |
2097 | if (!QUERY_FLAG (right, FLAG_REMOVED)) |
1994 | if (!QUERY_FLAG (right, FLAG_REMOVED)) |
2098 | remove_ob (right); |
1995 | right->remove (); |
2099 | inserted = insert_ob_in_ob (right, left); |
1996 | inserted = insert_ob_in_ob (right, left); |
2100 | if (left->type == PLAYER) |
1997 | if (left->type == PLAYER) |
2101 | if (inserted == right) |
1998 | if (inserted == right) |
2102 | esrv_send_item (left, right); |
1999 | esrv_send_item (left, right); |
2103 | else |
2000 | else |