ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/c_wiz.C
(Generate patch)

Comparing deliantra/server/server/c_wiz.C (file contents):
Revision 1.27 by root, Sat Dec 23 13:56:25 2006 UTC vs.
Revision 1.48 by root, Tue Jun 5 13:05:02 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * Crossfire TRT is free software; you can redistribute it and/or modify it
8 it under the terms of the GNU General Public License as published by 9 * under the terms of the GNU General Public License as published by the Free
9 the Free Software Foundation; either version 2 of the License, or 10 * Software Foundation; either version 2 of the License, or (at your option)
10 (at your option) any later version. 11 * 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, but
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 GNU General Public License for more details. 16 * 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 along
18 along with this program; if not, write to the Free Software 19 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 to <crossfire@schmorp.de>
22*/ 23 */
23 24
24#include <global.h> 25#include <global.h>
25#ifndef __CEXTRACT__
26# include <sproto.h> 26#include <sproto.h>
27#endif
28#include <spells.h> 27#include <spells.h>
29#include <treasure.h> 28#include <treasure.h>
30#include <skills.h> 29#include <skills.h>
31 30
32/** Defines for DM item stack **/ 31/** Defines for DM item stack **/
87 op->contr->hidden = 0; 86 op->contr->hidden = 0;
88 op->invisible = 1; 87 op->invisible = 1;
89 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); 88 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players");
90 op->map->players++; 89 op->map->players++;
91 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); 90 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name);
91
92 if (!silent_dm) 92 if (!silent_dm)
93 {
94 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); 93 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!");
95 }
96 } 94 }
97 else 95 else
98 { 96 {
99 op->contr->hidden = 1; 97 op->contr->hidden = 1;
100 new_draw_info (NDI_UNIQUE, 0, op, "Other players will no longer see you."); 98 new_draw_info (NDI_UNIQUE, 0, op, "Other players will no longer see you.");
101 op->map->players--; 99 op->map->players--;
100
102 if (!silent_dm) 101 if (!silent_dm)
103 {
104 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master is gone.."); 102 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master is gone..");
105 } 103
106 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s leaves the game.", &op->name); 104 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s leaves the game.", &op->name);
107 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s left the game.", &op->name); 105 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s left the game.", &op->name);
108 } 106 }
109} 107}
110 108
174 172
175 become_follower (ob, god); 173 become_follower (ob, god);
176 return 1; 174 return 1;
177} 175}
178 176
179/** 177// TODO: Rewrite banish in perl and get rid of the following two functions
180 * Add player's IP to ban_file and kick them off the server
181 * I know most people have dynamic IPs but this is more of a short term
182 * solution if they have to get a new IP to play maybe they'll calm down.
183 * This uses the banish_file in the local directory *not* the ban_file
184 * The action is logged with a ! for easy searching. -tm
185 */
186int
187command_banish (object *op, char *params)
188{
189 player *pl;
190 FILE *banishfile;
191 char buf[MAX_BUF];
192 time_t now;
193
194 if (!params)
195 {
196 new_draw_info (NDI_UNIQUE, 0, op, "Usage: banish <player>.");
197 return 1;
198 }
199
200 pl = get_other_player_from_name (op, params);
201 if (!pl)
202 return 1;
203
204 sprintf (buf, "%s/%s", settings.localdir, BANISHFILE);
205
206 if ((banishfile = fopen (buf, "a")) == NULL)
207 {
208 LOG (llevDebug, "Could not find file banish_file.\n");
209 new_draw_info (NDI_UNIQUE, 0, op, "Could not find banish_file.");
210 return 0;
211 }
212
213 now = time (NULL);
214 /*
215 * Record this as a comment - then we don't have to worry about changing
216 * the parsing code.
217 */
218 fprintf (banishfile, "# %s (%s) banned by %s at %s\n", &pl->ob->name, pl->ns->host, &op->name, ctime (&now));
219 fprintf (banishfile, "*@%s\n", pl->ns->host);
220 fclose (banishfile);
221
222 LOG (llevDebug, "! %s banned %s from IP: %s.\n", &op->name, &pl->ob->name, pl->ns->host);
223 new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op, "You banish %s", &pl->ob->name);
224 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s banishes %s from the land!", &op->name, &pl->ob->name);
225 command_kick (op, (char *) &pl->ob->name);
226 return 1;
227}
228
229int 178int
230command_kick (object *op, char *params) 179command_kick (object *op, char *params)
231{ 180{
232 for_all_players (pl) 181 for_all_players (pl)
233 if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) 182 if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params)))
244 } 193 }
245 194
246 return 1; 195 return 1;
247} 196}
248 197
198//TODO
199#if 0
249int 200int
250command_save_overlay (object *op, char *params) 201command_save_overlay (object *op, char *params)
251{ 202{
252 if (!op) 203 if (!op)
253 return 0; 204 return 0;
264 215
265 ready_map_name (op->map->path, 0); 216 ready_map_name (op->map->path, 0);
266 217
267 return 1; 218 return 1;
268} 219}
269 220#endif
270int
271command_shutdown (object *op, char *params)
272{
273 if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ))
274 {
275 new_draw_info (NDI_UNIQUE, 0, op, "Sorry, you can't shutdown the server.");
276 return 1;
277 }
278
279 cleanup ();
280 /* not reached */
281 return 1;
282}
283 221
284int 222int
285command_freeze (object *op, char *params) 223command_freeze (object *op, char *params)
286{ 224{
287 int ticks; 225 int ticks;
323 object *dummy; 261 object *dummy;
324 player *pl; 262 player *pl;
325 263
326 if (!op) 264 if (!op)
327 return 0; 265 return 0;
266
328 if (params == NULL) 267 if (params == NULL)
329 { 268 {
330 new_draw_info (NDI_UNIQUE, 0, op, "Usage: arrest <player>."); 269 new_draw_info (NDI_UNIQUE, 0, op, "Usage: arrest <player>.");
331 return 1; 270 return 1;
332 } 271 }
272
333 pl = get_other_player_from_name (op, params); 273 pl = get_other_player_from_name (op, params);
334 if (!pl) 274 if (!pl)
335 return 1; 275 return 1;
276
336 dummy = get_jail_exit (pl->ob); 277 dummy = get_jail_exit (pl->ob);
337 if (!dummy) 278 if (!dummy)
338 { 279 {
339 /* we have nowhere to send the prisoner.... */ 280 /* we have nowhere to send the prisoner.... */
340 new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them"); 281 new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them");
341 return 0; 282 return 0;
342 } 283 }
343 enter_exit (pl->ob, dummy); 284
285 pl->ob->enter_exit (dummy);
344 dummy->destroy (); 286 dummy->destroy ();
345 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You have been arrested."); 287 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You have been arrested.");
346 new_draw_info (NDI_UNIQUE, 0, op, "OK."); 288 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
347 LOG (llevInfo, "Player %s arrested by %s\n", &pl->ob->name, &op->name); 289 LOG (llevInfo, "Player %s arrested by %s\n", &pl->ob->name, &op->name);
348 return 1; 290 return 1;
377 319
378 dummy = object::create (); 320 dummy = object::create ();
379 EXIT_PATH (dummy) = op->map->path; 321 EXIT_PATH (dummy) = op->map->path;
380 EXIT_X (dummy) = op->x + freearr_x[i]; 322 EXIT_X (dummy) = op->x + freearr_x[i];
381 EXIT_Y (dummy) = op->y + freearr_y[i]; 323 EXIT_Y (dummy) = op->y + freearr_y[i];
382 enter_exit (pl->ob, dummy); 324 pl->ob->enter_exit (dummy);
383 dummy->destroy (); 325 dummy->destroy ();
384 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); 326 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned.");
385 new_draw_info (NDI_UNIQUE, 0, op, "OK."); 327 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
386 328
387 return 1;
388}
389
390/**
391 * Teleport next to target player.
392 */
393
394/* mids 01/16/2002 */
395int
396command_teleport (object *op, char *params)
397{
398 int i;
399 object *dummy;
400 player *pl;
401
402 if (!op)
403 return 0;
404
405 if (params == NULL)
406 {
407 new_draw_info (NDI_UNIQUE, 0, op, "Usage: teleport <player>.");
408 return 1;
409 }
410
411 pl = get_other_player_from_name (op, params);
412 if (!pl)
413 return 1;
414
415 i = find_free_spot (pl->ob, pl->ob->map, pl->ob->x, pl->ob->y, 1, 9);
416 if (i == -1)
417 {
418 new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to teleport to.");
419 return 1;
420 }
421
422 dummy = object::create ();
423 EXIT_PATH (dummy) = pl->ob->map->path;
424 EXIT_X (dummy) = pl->ob->x + freearr_x[i];
425 EXIT_Y (dummy) = pl->ob->y + freearr_y[i];
426 enter_exit (op, dummy);
427 dummy->destroy ();
428 if (!op->contr->hidden)
429 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You see a portal open.");
430 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
431 return 1; 329 return 1;
432} 330}
433 331
434/** 332/**
435 * This function is a real mess, because we're stucking getting 333 * This function is a real mess, because we're stucking getting
525 * we also set up spell_name which is only 423 * we also set up spell_name which is only
526 * the first word. 424 * the first word.
527 */ 425 */
528 426
529 at_spell = archetype::find (cp); 427 at_spell = archetype::find (cp);
530 if (!at_spell || at_spell->clone.type != SPELL) 428 if (!at_spell || at_spell->type != SPELL)
531 at_spell = find_archetype_by_object_name (cp); 429 at_spell = find_archetype_by_object_name (cp);
532 if (!at_spell || at_spell->clone.type != SPELL) 430 if (!at_spell || at_spell->type != SPELL)
533 { 431 {
534 strcpy (spell_name, cp); 432 assign (spell_name, cp);
535 fsp = strchr (spell_name, ' '); 433 fsp = strchr (spell_name, ' ');
536 if (fsp) 434 if (fsp)
537 { 435 {
538 *fsp = 0; 436 *fsp = 0;
539 fsp++; 437 fsp++;
540 at_spell = archetype::find (spell_name); 438 at_spell = archetype::find (spell_name);
541 439
542 /* Got a spell, update the first string pointer */ 440 /* Got a spell, update the first string pointer */
543 if (at_spell && at_spell->clone.type == SPELL) 441 if (at_spell && at_spell->type == SPELL)
544 bp2 = cp + strlen (spell_name) + 1; 442 bp2 = cp + strlen (spell_name) + 1;
545 else 443 else
546 at_spell = NULL; 444 at_spell = NULL;
547 } 445 }
548 } 446 }
550 /* OK - we didn't find a spell - presume the 'of' 448 /* OK - we didn't find a spell - presume the 'of'
551 * in this case means its an artifact. 449 * in this case means its an artifact.
552 */ 450 */
553 if (!at_spell) 451 if (!at_spell)
554 { 452 {
555 if (find_artifactlist (at->clone.type) == NULL) 453 if (find_artifactlist (at->type) == NULL)
556 new_draw_info_format (NDI_UNIQUE, 0, op, "No artifact list for type %d\n", at->clone.type); 454 new_draw_info_format (NDI_UNIQUE, 0, op, "No artifact list for type %d\n", at->type);
557 else 455 else
558 { 456 {
559 art = find_artifactlist (at->clone.type)->items; 457 art = find_artifactlist (at->type)->items;
560 458
561 do 459 while (art)
562 { 460 {
563 if (!strcmp (art->item->name, cp)) 461 if (!strcmp (art->item->name, cp))
564 break; 462 break;
463
565 art = art->next; 464 art = art->next;
566 } 465 }
567 while (art != NULL);
568 466
569 if (!art) 467 if (!art)
570 new_draw_info_format (NDI_UNIQUE, 0, op, "No such artifact ([%d] of %s)", at->clone.type, cp); 468 new_draw_info_format (NDI_UNIQUE, 0, op, "No such artifact ([%d] of %s)", at->type, cp);
571 } 469 }
572 470
573 LOG (llevDebug, "%s creates: (%d) (%d) (%s) of (%s)\n", &op->name, set_nrof ? nrof : 0, set_magic ? magic : 0, bp, cp); 471 LOG (llevDebug, "%s creates: (%d) (%d) (%s) of (%s)\n", &op->name, set_nrof ? nrof : 0, set_magic ? magic : 0, bp, cp);
574 } 472 }
575 } /* if cp */ 473 } /* if cp */
576 474
577 if ((at->clone.type == ROD || at->clone.type == WAND || at->clone.type == SCROLL || 475 if ((at->type == ROD || at->type == WAND || at->type == SCROLL ||
578 at->clone.type == HORN || at->clone.type == SPELLBOOK) && !at_spell) 476 at->type == HORN || at->type == SPELLBOOK) && !at_spell)
579 { 477 {
580 new_draw_info_format (NDI_UNIQUE, 0, op, "Unable to find spell %s for object that needs it, or it is of wrong type", cp); 478 new_draw_info_format (NDI_UNIQUE, 0, op, "Unable to find spell %s for object that needs it, or it is of wrong type", cp);
581 return 1; 479 return 1;
582 } 480 }
583 481
585 * Rather than have two different blocks with a lot of similar code, 483 * Rather than have two different blocks with a lot of similar code,
586 * just create one object, do all the processing, and then determine 484 * just create one object, do all the processing, and then determine
587 * if that one object should be inserted or if we need to make copies. 485 * if that one object should be inserted or if we need to make copies.
588 */ 486 */
589 tmp = arch_to_object (at); 487 tmp = arch_to_object (at);
590
591 if (settings.real_wiz == FALSE)
592 SET_FLAG (tmp, FLAG_WAS_WIZ);
593 488
594 if (set_magic) 489 if (set_magic)
595 set_abs_magic (tmp, magic); 490 set_abs_magic (tmp, magic);
596 491
597 if (art) 492 if (art)
677 new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s", &tmp->name, tmp->count, bp2); 572 new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s", &tmp->name, tmp->count, bp2);
678 573
679 bp2 = bp3 + 1; 574 bp2 = bp3 + 1;
680 } 575 }
681 576
682 if (at->clone.nrof) 577 if (at->nrof)
683 { 578 {
684 if (at_spell) 579 if (at_spell)
685 insert_ob_in_ob (arch_to_object (at_spell), tmp); 580 insert_ob_in_ob (arch_to_object (at_spell), tmp);
686 581
687 tmp->x = op->x; 582 tmp->x = op->x;
702 } 597 }
703 else 598 else
704 { 599 {
705 for (i = 0; i < (set_nrof ? nrof : 1); i++) 600 for (i = 0; i < (set_nrof ? nrof : 1); i++)
706 { 601 {
707 archetype *atmp;
708 object *prev = 0, *head = 0; 602 object *prev = 0, *head = 0;
709 603
710 for (atmp = at; atmp; atmp = atmp->more) 604 for (archetype *atmp = at; atmp; atmp = (archetype *)atmp->more)
711 { 605 {
712 object *dup = arch_to_object (atmp); 606 object *dup = arch_to_object (atmp);
713 607
714 if (at_spell) 608 if (at_spell)
715 insert_ob_in_ob (arch_to_object (at_spell), dup); 609 insert_ob_in_ob (arch_to_object (at_spell), dup);
722 { 616 {
723 head = dup; 617 head = dup;
724 tmp->copy_to (dup); 618 tmp->copy_to (dup);
725 } 619 }
726 620
727 if (settings.real_wiz == FALSE)
728 SET_FLAG (dup, FLAG_WAS_WIZ);
729
730 dup->x = op->x + dup->arch->clone.x; 621 dup->x = op->x + dup->arch->x;
731 dup->y = op->y + dup->arch->clone.y; 622 dup->y = op->y + dup->arch->y;
732 dup->map = op->map; 623 dup->map = op->map;
733 624
734 if (head != dup) 625 if (head != dup)
735 { 626 {
736 dup->head = head; 627 dup->head = head;
746 int size_x = 0; 637 int size_x = 0;
747 int size_y = 0; 638 int size_y = 0;
748 639
749 while (check) 640 while (check)
750 { 641 {
751 size_x = MAX (size_x, check->arch->clone.x); 642 size_x = MAX (size_x, check->arch->x);
752 size_y = MAX (size_y, check->arch->clone.y); 643 size_y = MAX (size_y, check->arch->y);
753 check = check->more; 644 check = check->more;
754 } 645 }
755 646
756 if (out_of_map (op->map, head->x + size_x, head->y + size_y)) 647 if (out_of_map (op->map, head->x + size_x, head->y + size_y))
757 { 648 {
783 /* Wonder if we really want to push all of these, but since 674 /* Wonder if we really want to push all of these, but since
784 * things like rods have nrof 0, we want to cover those. 675 * things like rods have nrof 0, we want to cover those.
785 */ 676 */
786 dm_stack_push (op->contr, head->count); 677 dm_stack_push (op->contr, head->count);
787 678
788 if (at->clone.randomitems != NULL && !at_spell) 679 if (at->randomitems != NULL && !at_spell)
789 create_treasure (at->clone.randomitems, head, GT_APPLY, op->map->difficulty, 0); 680 create_treasure (at->randomitems, head, GT_APPLY, op->map->difficulty, 0);
790 681
791 esrv_send_item (op, head); 682 esrv_send_item (op, head);
792 } 683 }
793 684
794 /* free the one we used to copy */ 685 /* free the one we used to copy */
849 free (dump); 740 free (dump);
850 741
851 if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL)) 742 if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL))
852 new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); 743 new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original");
853 744
854 return 1;
855}
856
857/**
858 * When DM is possessing a monster, flip aggression on and off, to allow
859 * better motion.
860 */
861int
862command_mon_aggr (object *op, char *params)
863{
864 if (op->enemy || !QUERY_FLAG (op, FLAG_UNAGGRESSIVE))
865 {
866 op->enemy = NULL;
867 SET_FLAG (op, FLAG_UNAGGRESSIVE);
868 new_draw_info (NDI_UNIQUE, 0, op, "Aggression turned OFF");
869 }
870 else
871 {
872 CLEAR_FLAG (op, FLAG_FRIENDLY);
873 CLEAR_FLAG (op, FLAG_UNAGGRESSIVE);
874 new_draw_info (NDI_UNIQUE, 0, op, "Aggression turned ON");
875 }
876
877 return 1;
878}
879
880/** DM can possess a monster. Basically, this tricks the client into thinking
881 * a given monster, is actually the player it controls. This allows a DM
882 * to inhabit a monster's body, and run around the game with it.
883 * This function is severely broken - it has tons of hardcoded values,
884 */
885int
886command_possess (object *op, char *params)
887{
888 object *victim, *curinv, *nextinv;
889 player *pl;
890 int i;
891 char buf[MAX_BUF];
892
893 victim = NULL;
894 if (params != NULL)
895 {
896 if (sscanf (params, "%d", &i))
897 victim = find_object (i);
898 else if (sscanf (params, "%s", buf))
899 victim = find_object_name (buf);
900 }
901 if (victim == NULL)
902 {
903 new_draw_info (NDI_UNIQUE, 0, op, "Patch what object (nr)?");
904 return 1;
905 }
906
907 if (victim == op)
908 {
909 new_draw_info (NDI_UNIQUE, 0, op, "As insane as you are, I cannot " "allow you to possess yourself.");
910 return 1;
911 }
912
913 /* clear out the old inventory */
914 curinv = op->inv;
915 while (curinv != NULL)
916 {
917 nextinv = curinv->below;
918 esrv_del_item (op->contr, curinv->count);
919 curinv = nextinv;
920 }
921
922 /* make the switch */
923 pl = op->contr;
924 victim->contr = pl;
925 pl->ob = victim;
926 victim->type = PLAYER;
927 SET_FLAG (victim, FLAG_WIZ);
928
929 /* send the inventory to the client */
930 curinv = victim->inv;
931 while (curinv != NULL)
932 {
933 nextinv = curinv->below;
934 esrv_send_item (victim, curinv);
935 curinv = nextinv;
936 }
937 /* basic patchup */
938 /* The use of hard coded values is terrible. Note
939 * that really, to be fair, this shouldn't get changed at
940 * all - if you are possessing a kobold, you should have the
941 * same limitations. As it is, as more body locations are added,
942 * this will give this player more locations than perhaps
943 * they should be allowed.
944 */
945 for (i = 0; i < NUM_BODY_LOCATIONS; i++)
946 if (i == 1 || i == 6 || i == 8 || i == 9)
947 victim->body_info[i] = 2;
948 else
949 victim->body_info[i] = 1;
950
951 esrv_new_player (pl, 80); /* just pick a wieght, we don't care */
952 esrv_send_inventory (victim, victim);
953
954 victim->update_stats ();
955
956 do_some_living (victim);
957 return 1; 745 return 1;
958} 746}
959 747
960int 748int
961command_patch (object *op, char *params) 749command_patch (object *op, char *params)
976 return 1; 764 return 1;
977 } 765 }
978 766
979 if ((arg2 = strchr (arg, ' '))) 767 if ((arg2 = strchr (arg, ' ')))
980 arg2++; 768 arg2++;
981 if (settings.real_wiz == FALSE) 769
982 SET_FLAG (tmp, FLAG_WAS_WIZ); /* To avoid cheating */
983 if (set_variable (tmp, arg) == -1) 770 if (set_variable (tmp, arg) == -1)
984 new_draw_info_format (NDI_UNIQUE, 0, op, "Unknown variable %s", arg); 771 new_draw_info_format (NDI_UNIQUE, 0, op, "Unknown variable %s", arg);
985 else 772 else
986 {
987 new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s=%s", &tmp->name, tmp->count, arg, arg2); 773 new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s=%s", &tmp->name, tmp->count, arg, arg2);
988 }
989 774
990 return 1; 775 return 1;
991} 776}
992 777
993int 778int
1041 } 826 }
1042 827
1043 if (from != STACK_FROM_STACK) 828 if (from != STACK_FROM_STACK)
1044 /* Item is either stack top, or is a number thus is now stack top, let's remove it */ 829 /* Item is either stack top, or is a number thus is now stack top, let's remove it */
1045 dm_stack_pop (op->contr); 830 dm_stack_pop (op->contr);
1046
1047 if (!QUERY_FLAG (tmp, FLAG_REMOVED))
1048 {
1049 new_draw_info (NDI_UNIQUE, 0, op, "Warning, item wasn't removed.");
1050 tmp->remove ();
1051 }
1052 831
1053 if (tmp->head) 832 if (tmp->head)
1054 tmp = tmp->head; 833 tmp = tmp->head;
1055 834
1056 tmp->destroy (); 835 tmp->destroy ();
1093 } 872 }
1094 873
1095 pl->ob->stats.exp += i; 874 pl->ob->stats.exp += i;
1096 calc_perm_exp (pl->ob); 875 calc_perm_exp (pl->ob);
1097 player_lvl_adj (pl->ob, NULL); 876 player_lvl_adj (pl->ob, NULL);
1098
1099 if (settings.real_wiz == FALSE)
1100 SET_FLAG (pl->ob, FLAG_WAS_WIZ);
1101 877
1102 return 1; 878 return 1;
1103 } 879 }
1104 880
1105 new_draw_info (NDI_UNIQUE, 0, op, "No such player."); 881 new_draw_info (NDI_UNIQUE, 0, op, "No such player.");
1154int 930int
1155command_abil (object *op, char *params) 931command_abil (object *op, char *params)
1156{ 932{
1157 char thing[20], thing2[20]; 933 char thing[20], thing2[20];
1158 int iii; 934 int iii;
1159 player *pl;
1160 char buf[MAX_BUF]; 935 char buf[MAX_BUF];
1161 936
1162 iii = 0; 937 iii = 0;
1163 thing[0] = '\0'; 938 thing[0] = '\0';
1164 thing2[0] = '\0'; 939 thing2[0] = '\0';
1182 957
1183 for_all_players (pl) 958 for_all_players (pl)
1184 { 959 {
1185 if (!strcmp (pl->ob->name, thing)) 960 if (!strcmp (pl->ob->name, thing))
1186 { 961 {
1187 if (settings.real_wiz == FALSE)
1188 SET_FLAG (pl->ob, FLAG_WAS_WIZ);
1189 if (!strcmp ("str", thing2))
1190 pl->ob->stats.Str = iii, pl->orig_stats.Str = iii; 962 if (!strcmp ("str", thing2)) pl->ob->stats.Str = iii, pl->orig_stats.Str = iii;
1191 if (!strcmp ("dex", thing2))
1192 pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii; 963 if (!strcmp ("dex", thing2)) pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii;
1193 if (!strcmp ("con", thing2))
1194 pl->ob->stats.Con = iii, pl->orig_stats.Con = iii; 964 if (!strcmp ("con", thing2)) pl->ob->stats.Con = iii, pl->orig_stats.Con = iii;
1195 if (!strcmp ("wis", thing2))
1196 pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii; 965 if (!strcmp ("wis", thing2)) pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii;
1197 if (!strcmp ("cha", thing2))
1198 pl->ob->stats.Cha = iii, pl->orig_stats.Cha = iii; 966 if (!strcmp ("cha", thing2)) pl->ob->stats.Cha = iii, pl->orig_stats.Cha = iii;
1199 if (!strcmp ("int", thing2))
1200 pl->ob->stats.Int = iii, pl->orig_stats.Int = iii; 967 if (!strcmp ("int", thing2)) pl->ob->stats.Int = iii, pl->orig_stats.Int = iii;
1201 if (!strcmp ("pow", thing2))
1202 pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii; 968 if (!strcmp ("pow", thing2)) pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii;
969
1203 sprintf (buf, "%s has been altered.", &pl->ob->name); 970 sprintf (buf, "%s has been altered.", &pl->ob->name);
1204 new_draw_info (NDI_UNIQUE, 0, op, buf); 971 new_draw_info (NDI_UNIQUE, 0, op, buf);
1205 pl->ob->update_stats (); 972 pl->ob->update_stats ();
1206 return 1; 973 return 1;
1207 } 974 }
1210 new_draw_info (NDI_UNIQUE, 0, op, "No such player."); 977 new_draw_info (NDI_UNIQUE, 0, op, "No such player.");
1211 return 1; 978 return 1;
1212} 979}
1213 980
1214int 981int
1215command_reset (object *op, char *params)
1216{
1217 maptile *m;
1218 object *dummy = NULL, *tmp = NULL;
1219
1220 if (params == NULL)
1221 {
1222 new_draw_info (NDI_UNIQUE, 0, op, "Reset what map [name]?");
1223 return 1;
1224 }
1225
1226 if (strcmp (params, ".") == 0)
1227 params = op->map->path;
1228
1229 m = has_been_loaded (params);
1230 if (m == NULL)
1231 {
1232 new_draw_info (NDI_UNIQUE, 0, op, "No such map.");
1233 return 1;
1234 }
1235
1236 if (m->in_memory != MAP_SWAPPED)
1237 {
1238 if (m->in_memory != MAP_IN_MEMORY)
1239 {
1240 LOG (llevError, "Tried to swap out map which was not in memory.\n");
1241 return 0;
1242 }
1243
1244 /*
1245 * Only attempt to remove the player that is doing the reset, and not other
1246 * players or wiz's.
1247 */
1248 if (op->map == m)
1249 {
1250 dummy = object::create ();
1251 dummy->map = NULL;
1252 EXIT_X (dummy) = op->x;
1253 EXIT_Y (dummy) = op->y;
1254 EXIT_PATH (dummy) = op->map->path;
1255 op->remove ();
1256 op->map = NULL;
1257 tmp = op;
1258 }
1259 swap_map (m);
1260 }
1261
1262 if (m->in_memory == MAP_SWAPPED)
1263 {
1264 LOG (llevDebug, "Resetting map %s.\n", m->path);
1265
1266 /* setting this effectively causes an immediate reload */
1267 m->reset_time = 1;
1268 flush_old_maps ();
1269 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
1270
1271 if (tmp)
1272 {
1273 enter_exit (tmp, dummy);
1274 dummy->destroy ();
1275 }
1276
1277 return 1;
1278 }
1279 else
1280 {
1281 player *pl;
1282 int playercount = 0;
1283
1284 /* Need to re-insert player if swap failed for some reason */
1285 if (tmp)
1286 {
1287 insert_ob_in_map (op, m, NULL, 0);
1288 dummy->destroy ();
1289 }
1290
1291 new_draw_info (NDI_UNIQUE, 0, op, "Reset failed, couldn't swap map, the following players are on it:");
1292
1293 for_all_players (pl)
1294 if (pl->ob->map == m && pl->ob != op)
1295 {
1296 new_draw_info_format (NDI_UNIQUE, 0, op, "%s", &pl->ob->name);
1297 playercount++;
1298 }
1299
1300 if (!playercount)
1301 new_draw_info (NDI_UNIQUE, 0, op, "hmm, I don't see any other players on this map, something else is the problem.");
1302 return 1;
1303 }
1304}
1305
1306int
1307command_nowiz (object *op, char *params) 982command_nowiz (object *op, char *params)
1308{ /* 'noadm' is alias */ 983{ /* 'nodm' is alias */
1309 CLEAR_FLAG (op, FLAG_WIZ); 984 CLEAR_FLAG (op, FLAG_WIZ);
1310 CLEAR_FLAG (op, FLAG_WIZPASS); 985 CLEAR_FLAG (op, FLAG_WIZPASS);
1311 CLEAR_FLAG (op, FLAG_WIZCAST); 986 CLEAR_FLAG (op, FLAG_WIZCAST);
1312 987
1313 if (settings.real_wiz == TRUE)
1314 CLEAR_FLAG (op, FLAG_WAS_WIZ);
1315 if (op->contr->hidden) 988 if (op->contr->hidden)
1316 { 989 {
1317 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); 990 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players");
1318 op->map->players++; 991 op->map->players++;
1319 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); 992 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name);
1381 } 1054 }
1382 1055
1383 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) 1056 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host))
1384 { 1057 {
1385 SET_FLAG (op, FLAG_WIZ); 1058 SET_FLAG (op, FLAG_WIZ);
1386 SET_FLAG (op, FLAG_WAS_WIZ);
1387 SET_FLAG (op, FLAG_WIZPASS); 1059 SET_FLAG (op, FLAG_WIZPASS);
1388 SET_FLAG (op, FLAG_WIZCAST); 1060 SET_FLAG (op, FLAG_WIZCAST);
1061
1389 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); 1062 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!");
1390 /* 1063 /*
1391 * Remove setting flying here - that won't work, because next 1064 * Remove setting flying here - that won't work, because next
1392 * fix_player() is called that will get cleared - proper solution 1065 * fix_player() is called that will get cleared - proper solution
1393 * is probably something like a wiz_force which gives that and any 1066 * is probably something like a wiz_force which gives that and any
1394 * other desired abilities. 1067 * other desired abilities.
1395 */ 1068 */
1396 clear_los (op); 1069 clear_los (op->contr);
1397 op->contr->write_buf[0] = '\0'; 1070 op->contr->write_buf[0] = '\0';
1398 1071
1399 if (!silent) 1072 if (!silent)
1400 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); 1073 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!");
1401 1074
1428command_invisible (object *op, char *params) 1101command_invisible (object *op, char *params)
1429{ 1102{
1430 if (op) 1103 if (op)
1431 { 1104 {
1432 op->invisible += 100; 1105 op->invisible += 100;
1433 update_object (op, UP_OBJ_FACE); 1106 update_object (op, UP_OBJ_CHANGE);
1434 new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible."); 1107 new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible.");
1435 } 1108 }
1436 1109
1437 return 0; 1110 return 0;
1438} 1111}
1450 * name than other "spell_xxx" archetypes and would always conflict. 1123 * name than other "spell_xxx" archetypes and would always conflict.
1451 */ 1124 */
1452static object * 1125static object *
1453get_spell_by_name (object *op, const char *spell_name) 1126get_spell_by_name (object *op, const char *spell_name)
1454{ 1127{
1455 archetype *ar; 1128 archetype *at;
1456 archetype *found; 1129 archetype *found;
1457 int conflict_found; 1130 int conflict_found;
1458 size_t spell_name_length; 1131 size_t spell_name_length;
1459 1132
1460 /* First check for full name matches. */ 1133 /* First check for full name matches. */
1461 conflict_found = 0; 1134 conflict_found = 0;
1462 found = NULL; 1135 found = NULL;
1463 for (ar = first_archetype; ar != NULL; ar = ar->next) 1136 for_all_archetypes (at)
1464 { 1137 {
1465 if (ar->clone.type != SPELL) 1138 if (at->type != SPELL)
1466 continue; 1139 continue;
1467 1140
1468 if (strncmp (ar->name, "spelldirect_", 12) == 0) 1141 if (strncmp (at->archname, "spelldirect_", 12) == 0)
1469 continue; 1142 continue;
1470 1143
1471 if (strcmp (ar->clone.name, spell_name) != 0) 1144 if (strcmp (at->object::name, spell_name) != 0)
1472 continue; 1145 continue;
1473 1146
1474 if (found != NULL) 1147 if (found != NULL)
1475 { 1148 {
1476 if (!conflict_found) 1149 if (!conflict_found)
1477 { 1150 {
1478 conflict_found = 1; 1151 conflict_found = 1;
1479 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name); 1152 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name);
1480 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->name); 1153 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname);
1481 } 1154 }
1155
1482 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->name); 1156 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname);
1483 continue; 1157 continue;
1484 } 1158 }
1485 1159
1486 found = ar; 1160 found = at;
1487 } 1161 }
1488 1162
1489 /* No match if more more than one archetype matches. */ 1163 /* No match if more more than one archetype matches. */
1490 if (conflict_found) 1164 if (conflict_found)
1491 return NULL; 1165 return NULL;
1496 1170
1497 /* No full match found: now check for partial matches. */ 1171 /* No full match found: now check for partial matches. */
1498 spell_name_length = strlen (spell_name); 1172 spell_name_length = strlen (spell_name);
1499 conflict_found = 0; 1173 conflict_found = 0;
1500 found = NULL; 1174 found = NULL;
1501 for (ar = first_archetype; ar != NULL; ar = ar->next) 1175 for_all_archetypes (at)
1502 { 1176 {
1503 if (ar->clone.type != SPELL) 1177 if (at->type != SPELL)
1504 continue; 1178 continue;
1505 1179
1506 if (strncmp (ar->name, "spelldirect_", 12) == 0) 1180 if (strncmp (at->archname, "spelldirect_", 12) == 0)
1507 continue; 1181 continue;
1508 1182
1509 if (strncmp (ar->clone.name, spell_name, spell_name_length) != 0) 1183 if (strncmp (at->object::name, spell_name, spell_name_length) != 0)
1510 continue; 1184 continue;
1511 1185
1512 if (found != NULL) 1186 if (found != NULL)
1513 { 1187 {
1514 if (!conflict_found) 1188 if (!conflict_found)
1515 { 1189 {
1516 conflict_found = 1; 1190 conflict_found = 1;
1517 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name); 1191 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name);
1518 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->clone.name); 1192 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->object::name);
1519 } 1193 }
1520 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->clone.name); 1194 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->object::name);
1521 continue; 1195 continue;
1522 } 1196 }
1523 1197
1524 found = ar; 1198 found = at;
1525 } 1199 }
1526 1200
1527 /* No match if more more than one archetype matches. */ 1201 /* No match if more more than one archetype matches. */
1528 if (conflict_found) 1202 if (conflict_found)
1529 return NULL; 1203 return NULL;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines