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.40 by root, Tue Mar 6 19:02:36 2007 UTC vs.
Revision 1.67 by root, Thu Jan 1 16:05:13 2009 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game for X-windows 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * 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
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * 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,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * 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
19 * along with this program; if not, write to the Free Software 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * 20 *
22 * The authors can be reached via e-mail at <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 22 */
24 23
25#include <global.h> 24#include <global.h>
26#include <sproto.h> 25#include <sproto.h>
27#include <spells.h> 26#include <spells.h>
179command_kick (object *op, char *params) 178command_kick (object *op, char *params)
180{ 179{
181 for_all_players (pl) 180 for_all_players (pl)
182 if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) 181 if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params)))
183 { 182 {
184 object *op = pl->ob; 183 object *plop = pl->ob;
185 184
186 if (!QUERY_FLAG (op, FLAG_REMOVED) && !QUERY_FLAG (op, FLAG_FREED)) 185 if (!QUERY_FLAG (plop, FLAG_REMOVED) && !QUERY_FLAG (plop, FLAG_FREED))
187 { 186 {
188 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s is kicked out of the game.", &op->name); 187 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s is kicked out of the game.", &plop->name);
189 strcpy (op->contr->killer, "kicked"); 188 plop->contr->killer = op;
190 } 189 }
191 190
192 pl->ns->destroy (); 191 pl->ns->destroy ();
193 } 192 }
194 193
280 /* we have nowhere to send the prisoner.... */ 279 /* we have nowhere to send the prisoner.... */
281 new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them"); 280 new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them");
282 return 0; 281 return 0;
283 } 282 }
284 283
285 pl->ob->enter_exit (dummy); 284 pl->ob->player_goto (dummy->slaying, dummy->stats.hp, dummy->stats.sp);//TODO
286 dummy->destroy (); 285 dummy->destroy ();
286
287 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.");
288 new_draw_info (NDI_UNIQUE, 0, op, "OK."); 288 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
289 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);
290 return 1; 290 return 1;
291} 291}
315 { 315 {
316 new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player."); 316 new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player.");
317 return 1; 317 return 1;
318 } 318 }
319 319
320 dummy = object::create (); 320 pl->ob->player_goto (op->map->path, op->x + freearr_x[i], op->y + freearr_y[i]);
321 EXIT_PATH (dummy) = op->map->path;
322 EXIT_X (dummy) = op->x + freearr_x[i];
323 EXIT_Y (dummy) = op->y + freearr_y[i];
324 pl->ob->enter_exit (dummy);
325 dummy->destroy ();
326 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); 321 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned.");
327 new_draw_info (NDI_UNIQUE, 0, op, "OK."); 322 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
328 323
329 return 1; 324 return 1;
330} 325}
423 * we also set up spell_name which is only 418 * we also set up spell_name which is only
424 * the first word. 419 * the first word.
425 */ 420 */
426 421
427 at_spell = archetype::find (cp); 422 at_spell = archetype::find (cp);
428 if (!at_spell || at_spell->clone.type != SPELL) 423 if (!at_spell || at_spell->type != SPELL)
429 at_spell = find_archetype_by_object_name (cp); 424 at_spell = find_archetype_by_object_name (cp);
430 if (!at_spell || at_spell->clone.type != SPELL) 425 if (!at_spell || at_spell->type != SPELL)
431 { 426 {
432 assign (spell_name, cp); 427 assign (spell_name, cp);
433 fsp = strchr (spell_name, ' '); 428 fsp = strchr (spell_name, ' ');
434 if (fsp) 429 if (fsp)
435 { 430 {
436 *fsp = 0; 431 *fsp = 0;
437 fsp++; 432 fsp++;
438 at_spell = archetype::find (spell_name); 433 at_spell = archetype::find (spell_name);
439 434
440 /* Got a spell, update the first string pointer */ 435 /* Got a spell, update the first string pointer */
441 if (at_spell && at_spell->clone.type == SPELL) 436 if (at_spell && at_spell->type == SPELL)
442 bp2 = cp + strlen (spell_name) + 1; 437 bp2 = cp + strlen (spell_name) + 1;
443 else 438 else
444 at_spell = NULL; 439 at_spell = NULL;
445 } 440 }
446 } 441 }
448 /* OK - we didn't find a spell - presume the 'of' 443 /* OK - we didn't find a spell - presume the 'of'
449 * in this case means its an artifact. 444 * in this case means its an artifact.
450 */ 445 */
451 if (!at_spell) 446 if (!at_spell)
452 { 447 {
453 if (find_artifactlist (at->clone.type) == NULL) 448 if (find_artifactlist (at->type) == NULL)
454 new_draw_info_format (NDI_UNIQUE, 0, op, "No artifact list for type %d\n", at->clone.type); 449 new_draw_info_format (NDI_UNIQUE, 0, op, "No artifact list for type %d\n", at->type);
455 else 450 else
456 { 451 {
457 art = find_artifactlist (at->clone.type)->items; 452 art = find_artifactlist (at->type)->items;
458 453
459 do 454 while (art)
460 { 455 {
461 if (!strcmp (art->item->name, cp)) 456 if (!strcmp (&art->item->name, cp))
462 break; 457 break;
458
463 art = art->next; 459 art = art->next;
464 } 460 }
465 while (art != NULL);
466 461
467 if (!art) 462 if (!art)
468 new_draw_info_format (NDI_UNIQUE, 0, op, "No such artifact ([%d] of %s)", at->clone.type, cp); 463 new_draw_info_format (NDI_UNIQUE, 0, op, "No such artifact ([%d] of %s)", at->type, cp);
469 } 464 }
470 465
471 LOG (llevDebug, "%s creates: (%d) (%d) (%s) of (%s)\n", &op->name, set_nrof ? nrof : 0, set_magic ? magic : 0, bp, cp); 466 LOG (llevDebug, "%s creates: (%d) (%d) (%s) of (%s)\n", &op->name, set_nrof ? nrof : 0, set_magic ? magic : 0, bp, cp);
472 } 467 }
473 } /* if cp */ 468 } /* if cp */
474 469
475 if ((at->clone.type == ROD || at->clone.type == WAND || at->clone.type == SCROLL || 470 if ((at->type == ROD || at->type == WAND || at->type == SCROLL ||
476 at->clone.type == HORN || at->clone.type == SPELLBOOK) && !at_spell) 471 at->type == HORN || at->type == SPELLBOOK) && !at_spell)
477 { 472 {
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); 473 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);
479 return 1; 474 return 1;
480 } 475 }
481 476
483 * Rather than have two different blocks with a lot of similar code, 478 * Rather than have two different blocks with a lot of similar code,
484 * just create one object, do all the processing, and then determine 479 * just create one object, do all the processing, and then determine
485 * if that one object should be inserted or if we need to make copies. 480 * if that one object should be inserted or if we need to make copies.
486 */ 481 */
487 tmp = arch_to_object (at); 482 tmp = arch_to_object (at);
488
489 if (settings.real_wiz == FALSE)
490 SET_FLAG (tmp, FLAG_WAS_WIZ);
491 483
492 if (set_magic) 484 if (set_magic)
493 set_abs_magic (tmp, magic); 485 set_abs_magic (tmp, magic);
494 486
495 if (art) 487 if (art)
575 new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s", &tmp->name, tmp->count, bp2); 567 new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s", &tmp->name, tmp->count, bp2);
576 568
577 bp2 = bp3 + 1; 569 bp2 = bp3 + 1;
578 } 570 }
579 571
580 if (at->clone.nrof) 572 if (at->nrof)
581 { 573 {
582 if (at_spell) 574 if (at_spell)
583 insert_ob_in_ob (arch_to_object (at_spell), tmp); 575 tmp->insert (arch_to_object (at_spell));
584 576
585 tmp->x = op->x; 577 tmp->x = op->x;
586 tmp->y = op->y; 578 tmp->y = op->y;
579 tmp->map = op->map;
587 580
588 if (set_nrof) 581 if (set_nrof)
589 tmp->nrof = nrof; 582 tmp->nrof = nrof;
590 583
591 tmp->map = op->map; 584 op->insert (tmp);
592
593 tmp = insert_ob_in_ob (tmp, op);
594 esrv_send_item (op, tmp);
595 585
596 /* Let's put this created item on stack so dm can access it easily. */ 586 /* Let's put this created item on stack so dm can access it easily. */
597 dm_stack_push (op->contr, tmp->count); 587 dm_stack_push (op->contr, tmp->count);
598 588
599 return 1; 589 return 1;
600 } 590 }
601 else 591 else
602 { 592 {
603 for (i = 0; i < (set_nrof ? nrof : 1); i++) 593 for (i = 0; i < (set_nrof ? nrof : 1); i++)
604 { 594 {
605 archetype *atmp;
606 object *prev = 0, *head = 0; 595 object *prev = 0, *head = 0;
607 596
608 for (atmp = at; atmp; atmp = atmp->more) 597 for (archetype *atmp = at; atmp; atmp = (archetype *)atmp->more)
609 { 598 {
610 object *dup = arch_to_object (atmp); 599 object *dup = arch_to_object (atmp);
611 600
612 if (at_spell) 601 if (at_spell)
613 insert_ob_in_ob (arch_to_object (at_spell), dup); 602 insert_ob_in_ob (arch_to_object (at_spell), dup);
620 { 609 {
621 head = dup; 610 head = dup;
622 tmp->copy_to (dup); 611 tmp->copy_to (dup);
623 } 612 }
624 613
625 if (settings.real_wiz == FALSE)
626 SET_FLAG (dup, FLAG_WAS_WIZ);
627
628 dup->x = op->x + dup->arch->clone.x; 614 dup->x = op->x + dup->arch->x;
629 dup->y = op->y + dup->arch->clone.y; 615 dup->y = op->y + dup->arch->y;
630 dup->map = op->map; 616 dup->map = op->map;
631 617
632 if (head != dup) 618 if (head != dup)
633 { 619 {
634 dup->head = head; 620 dup->head = head;
644 int size_x = 0; 630 int size_x = 0;
645 int size_y = 0; 631 int size_y = 0;
646 632
647 while (check) 633 while (check)
648 { 634 {
649 size_x = MAX (size_x, check->arch->clone.x); 635 size_x = MAX (size_x, check->arch->x);
650 size_y = MAX (size_y, check->arch->clone.y); 636 size_y = MAX (size_y, check->arch->y);
651 check = check->more; 637 check = check->more;
652 } 638 }
653 639
654 if (out_of_map (op->map, head->x + size_x, head->y + size_y)) 640 if (out_of_map (op->map, head->x + size_x, head->y + size_y))
655 { 641 {
681 /* Wonder if we really want to push all of these, but since 667 /* Wonder if we really want to push all of these, but since
682 * things like rods have nrof 0, we want to cover those. 668 * things like rods have nrof 0, we want to cover those.
683 */ 669 */
684 dm_stack_push (op->contr, head->count); 670 dm_stack_push (op->contr, head->count);
685 671
686 if (at->clone.randomitems != NULL && !at_spell) 672 if (at->randomitems && !at_spell)
687 create_treasure (at->clone.randomitems, head, GT_APPLY, op->map->difficulty, 0); 673 create_treasure (at->randomitems, head, GT_APPLY, op->map->difficulty, 0);
688
689 esrv_send_item (op, head);
690 } 674 }
691 675
692 /* free the one we used to copy */ 676 /* free the one we used to copy */
693 tmp->destroy (); 677 tmp->destroy ();
694 } 678 }
701 */ 685 */
702 686
703int 687int
704command_inventory (object *op, char *params) 688command_inventory (object *op, char *params)
705{ 689{
690 int i;
706 object *tmp; 691 object *tmp;
707 int i;
708 692
709 if (!params) 693 if (!params || !sscanf (params, "%d", &i) || !(tmp = find_object (i)))
710 { 694 {
711 inventory (op, NULL); 695 op->contr->failmsg ("Inventory of what object (nr)?");
712 return 0; 696 return 1;
713 }
714
715 if (!sscanf (params, "%d", &i) || (tmp = find_object (i)) == NULL)
716 { 697 }
717 new_draw_info (NDI_UNIQUE, 0, op, "Inventory of what object (nr)?");
718 return 1;
719 }
720 698
721 inventory (op, tmp); 699 op->contr->infobox (MSG_CHANNEL ("examine"), tmp->query_inventory (op));
700
722 return 1; 701 return 1;
723} 702}
724 703
725/* just show player's their skills for now. Dm's can 704/* just show player's their skills for now. Dm's can
726 * already see skills w/ inventory command - b.t. 705 * already see skills w/ inventory command - b.t.
771 return 1; 750 return 1;
772 } 751 }
773 752
774 if ((arg2 = strchr (arg, ' '))) 753 if ((arg2 = strchr (arg, ' ')))
775 arg2++; 754 arg2++;
776 if (settings.real_wiz == FALSE) 755
777 SET_FLAG (tmp, FLAG_WAS_WIZ); /* To avoid cheating */
778 if (set_variable (tmp, arg) == -1) 756 if (set_variable (tmp, arg) == -1)
779 new_draw_info_format (NDI_UNIQUE, 0, op, "Unknown variable %s", arg); 757 new_draw_info_format (NDI_UNIQUE, 0, op, "Unknown variable %s", arg);
780 else 758 else
781 {
782 new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s=%s", &tmp->name, tmp->count, arg, arg2); 759 new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s=%s", &tmp->name, tmp->count, arg, arg2);
783 }
784 760
785 return 1; 761 return 1;
786} 762}
787 763
788int 764int
851 */ 827 */
852int 828int
853command_addexp (object *op, char *params) 829command_addexp (object *op, char *params)
854{ 830{
855 char buf[MAX_BUF], skill[MAX_BUF]; 831 char buf[MAX_BUF], skill[MAX_BUF];
856 int i, q; 832 int q;
833 long long i; // use sint64 and finally provide format specifiers for sint64 etc. via configure
857 object *skillob = NULL; 834 object *skillob = NULL;
858 835
859 skill[0] = '\0'; 836 skill[0] = '\0';
860 if ((params == NULL) || (strlen (params) > MAX_BUF) || ((q = sscanf (params, "%s %d %s", buf, &i, skill)) < 2)) 837 if ((params == NULL) || (strlen (params) > MAX_BUF) || ((q = sscanf (params, "%s %lld %s", buf, &i, skill)) < 2))
861 { 838 {
862 new_draw_info (NDI_UNIQUE, 0, op, "Usage: addexp <who> <how much> [<skill>]."); 839 new_draw_info (NDI_UNIQUE, 0, op, "Usage: addexp <who> <how much> [<skill>].");
863 return 1; 840 return 1;
864 } 841 }
865 842
883 860
884 pl->ob->stats.exp += i; 861 pl->ob->stats.exp += i;
885 calc_perm_exp (pl->ob); 862 calc_perm_exp (pl->ob);
886 player_lvl_adj (pl->ob, NULL); 863 player_lvl_adj (pl->ob, NULL);
887 864
888 if (settings.real_wiz == FALSE)
889 SET_FLAG (pl->ob, FLAG_WAS_WIZ);
890
891 return 1; 865 return 1;
892 } 866 }
893 867
894 new_draw_info (NDI_UNIQUE, 0, op, "No such player."); 868 new_draw_info (NDI_UNIQUE, 0, op, "No such player.");
895 return 1; 869 return 1;
915 new_draw_info (NDI_UNIQUE, 0, op, "Who?"); 889 new_draw_info (NDI_UNIQUE, 0, op, "Who?");
916 return 1; 890 return 1;
917 } 891 }
918 892
919 for_all_players (pl) 893 for_all_players (pl)
920 if (!strcmp (pl->ob->name, thing)) 894 if (!strcmp (&pl->ob->name, thing))
921 { 895 {
922 sprintf (buf, "Str : %-2d H.P. : %-4d MAX : %d", pl->ob->stats.Str, pl->ob->stats.hp, pl->ob->stats.maxhp); 896 sprintf (buf, "Str : %-2d H.P. : %-4d MAX : %d", pl->ob->stats.Str, pl->ob->stats.hp, pl->ob->stats.maxhp);
923 new_draw_info (NDI_UNIQUE, 0, op, buf); 897 new_draw_info (NDI_UNIQUE, 0, op, buf);
924 sprintf (buf, "Dex : %-2d S.P. : %-4d MAX : %d", pl->ob->stats.Dex, pl->ob->stats.sp, pl->ob->stats.maxsp); 898 sprintf (buf, "Dex : %-2d S.P. : %-4d MAX : %d", pl->ob->stats.Dex, pl->ob->stats.sp, pl->ob->stats.maxsp);
925 new_draw_info (NDI_UNIQUE, 0, op, buf); 899 new_draw_info (NDI_UNIQUE, 0, op, buf);
968 return 1; 942 return 1;
969 } 943 }
970 944
971 for_all_players (pl) 945 for_all_players (pl)
972 { 946 {
973 if (!strcmp (pl->ob->name, thing)) 947 if (!strcmp (&pl->ob->name, thing))
974 { 948 {
975 if (settings.real_wiz == FALSE)
976 SET_FLAG (pl->ob, FLAG_WAS_WIZ);
977 if (!strcmp ("str", thing2))
978 pl->ob->stats.Str = iii, pl->orig_stats.Str = iii; 949 if (!strcmp ("str", thing2)) pl->ob->stats.Str = iii, pl->orig_stats.Str = iii;
979 if (!strcmp ("dex", thing2))
980 pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii; 950 if (!strcmp ("dex", thing2)) pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii;
981 if (!strcmp ("con", thing2))
982 pl->ob->stats.Con = iii, pl->orig_stats.Con = iii; 951 if (!strcmp ("con", thing2)) pl->ob->stats.Con = iii, pl->orig_stats.Con = iii;
983 if (!strcmp ("wis", thing2))
984 pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii; 952 if (!strcmp ("wis", thing2)) pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii;
985 if (!strcmp ("cha", thing2))
986 pl->ob->stats.Cha = iii, pl->orig_stats.Cha = iii; 953 if (!strcmp ("cha", thing2)) pl->ob->stats.Cha = iii, pl->orig_stats.Cha = iii;
987 if (!strcmp ("int", thing2))
988 pl->ob->stats.Int = iii, pl->orig_stats.Int = iii; 954 if (!strcmp ("int", thing2)) pl->ob->stats.Int = iii, pl->orig_stats.Int = iii;
989 if (!strcmp ("pow", thing2))
990 pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii; 955 if (!strcmp ("pow", thing2)) pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii;
956
991 sprintf (buf, "%s has been altered.", &pl->ob->name); 957 sprintf (buf, "%s has been altered.", &pl->ob->name);
992 new_draw_info (NDI_UNIQUE, 0, op, buf); 958 new_draw_info (NDI_UNIQUE, 0, op, buf);
993 pl->ob->update_stats (); 959 pl->ob->update_stats ();
994 return 1; 960 return 1;
995 } 961 }
1003command_nowiz (object *op, char *params) 969command_nowiz (object *op, char *params)
1004{ /* 'nodm' is alias */ 970{ /* 'nodm' is alias */
1005 CLEAR_FLAG (op, FLAG_WIZ); 971 CLEAR_FLAG (op, FLAG_WIZ);
1006 CLEAR_FLAG (op, FLAG_WIZPASS); 972 CLEAR_FLAG (op, FLAG_WIZPASS);
1007 CLEAR_FLAG (op, FLAG_WIZCAST); 973 CLEAR_FLAG (op, FLAG_WIZCAST);
1008
1009 if (settings.real_wiz == TRUE)
1010 CLEAR_FLAG (op, FLAG_WAS_WIZ); 974 CLEAR_FLAG (op, FLAG_WIZLOOK);
975 op->contr->do_los = 1;
976
1011 if (op->contr->hidden) 977 if (op->contr->hidden)
1012 { 978 {
1013 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); 979 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players");
1014 op->map->players++; 980 op->map->players++;
1015 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); 981 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name);
1016 op->contr->hidden = 0; 982 op->contr->hidden = 0;
1017 op->invisible = 1; 983 op->invisible = 1;
1018 } 984 }
1019 else 985 else
1020 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master is gone.."); 986 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master is gone..");
987
1021 return 1; 988 return 1;
1022} 989}
1023 990
1024/** 991/**
1025 * object *op is trying to become dm. 992 * object *op is trying to become dm.
1077 } 1044 }
1078 1045
1079 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) 1046 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host))
1080 { 1047 {
1081 SET_FLAG (op, FLAG_WIZ); 1048 SET_FLAG (op, FLAG_WIZ);
1082 SET_FLAG (op, FLAG_WAS_WIZ);
1083 SET_FLAG (op, FLAG_WIZPASS); 1049 SET_FLAG (op, FLAG_WIZPASS);
1084 SET_FLAG (op, FLAG_WIZCAST); 1050 SET_FLAG (op, FLAG_WIZCAST);
1051 SET_FLAG (op, FLAG_WIZLOOK);
1052 op->contr->do_los = 1;
1053
1085 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); 1054 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!");
1086 /*
1087 * Remove setting flying here - that won't work, because next
1088 * fix_player() is called that will get cleared - proper solution
1089 * is probably something like a wiz_force which gives that and any
1090 * other desired abilities.
1091 */
1092 clear_los (op);
1093 op->contr->write_buf[0] = '\0'; 1055 op->contr->write_buf[0] = '\0';
1094 1056
1095 if (!silent) 1057 if (!silent)
1096 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); 1058 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!");
1097 1059
1124command_invisible (object *op, char *params) 1086command_invisible (object *op, char *params)
1125{ 1087{
1126 if (op) 1088 if (op)
1127 { 1089 {
1128 op->invisible += 100; 1090 op->invisible += 100;
1129 update_object (op, UP_OBJ_FACE); 1091 update_object (op, UP_OBJ_CHANGE);
1130 new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible."); 1092 new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible.");
1131 } 1093 }
1132 1094
1133 return 0; 1095 return 0;
1134} 1096}
1137 * Returns spell object (from archetypes) by name. 1099 * Returns spell object (from archetypes) by name.
1138 * Returns NULL if 0 or more than one spell matches. 1100 * Returns NULL if 0 or more than one spell matches.
1139 * Used for wizard's learn spell/prayer. 1101 * Used for wizard's learn spell/prayer.
1140 * 1102 *
1141 * op is the player issuing the command. 1103 * op is the player issuing the command.
1142 *
1143 * Ignores archetypes "spelldirect_xxx" since these archetypes are not used
1144 * anymore (but may still be present in some player's inventories and thus
1145 * cannot be removed). We have to ignore them here since they have the same
1146 * name than other "spell_xxx" archetypes and would always conflict.
1147 */ 1104 */
1148static object * 1105static object *
1149get_spell_by_name (object *op, const char *spell_name) 1106get_spell_by_name (object *op, shstr_cmp spell_name)
1150{ 1107{
1151 archetype *ar; 1108 archetype *at;
1152 archetype *found; 1109 archetype *found;
1153 int conflict_found; 1110 int conflict_found;
1154 size_t spell_name_length; 1111 size_t spell_name_length;
1155 1112
1156 /* First check for full name matches. */ 1113 /* First check for full name matches. */
1157 conflict_found = 0; 1114 conflict_found = 0;
1158 found = NULL; 1115 found = NULL;
1159 for (ar = first_archetype; ar != NULL; ar = ar->next) 1116 for_all_archetypes (at)
1160 { 1117 {
1161 if (ar->clone.type != SPELL) 1118 if (at->type != SPELL)
1162 continue; 1119 continue;
1163 1120
1164 if (strncmp (ar->name, "spelldirect_", 12) == 0) 1121 if (at->object::name != spell_name)
1165 continue; 1122 continue;
1166 1123
1167 if (strcmp (ar->clone.name, spell_name) != 0)
1168 continue;
1169
1170 if (found != NULL) 1124 if (found)
1171 { 1125 {
1172 if (!conflict_found) 1126 if (!conflict_found)
1173 { 1127 {
1174 conflict_found = 1; 1128 conflict_found = 1;
1175 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name); 1129 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", &spell_name);
1176 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->name); 1130 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname);
1177 } 1131 }
1132
1178 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->name); 1133 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname);
1179 continue; 1134 continue;
1180 } 1135 }
1181 1136
1182 found = ar; 1137 found = at;
1183 } 1138 }
1184 1139
1185 /* No match if more more than one archetype matches. */ 1140 /* No match if more more than one archetype matches. */
1186 if (conflict_found) 1141 if (conflict_found)
1187 return NULL; 1142 return NULL;
1192 1147
1193 /* No full match found: now check for partial matches. */ 1148 /* No full match found: now check for partial matches. */
1194 spell_name_length = strlen (spell_name); 1149 spell_name_length = strlen (spell_name);
1195 conflict_found = 0; 1150 conflict_found = 0;
1196 found = NULL; 1151 found = NULL;
1197 for (ar = first_archetype; ar != NULL; ar = ar->next) 1152 for_all_archetypes (at)
1198 { 1153 {
1199 if (ar->clone.type != SPELL) 1154 if (at->type != SPELL)
1200 continue; 1155 continue;
1201 1156
1202 if (strncmp (ar->name, "spelldirect_", 12) == 0) 1157 if (strncmp (at->archname, "spelldirect_", 12) == 0)
1203 continue; 1158 continue;
1204 1159
1205 if (strncmp (ar->clone.name, spell_name, spell_name_length) != 0) 1160 if (strncmp (at->object::name, spell_name, spell_name_length) != 0)
1206 continue; 1161 continue;
1207 1162
1208 if (found != NULL) 1163 if (found != NULL)
1209 { 1164 {
1210 if (!conflict_found) 1165 if (!conflict_found)
1211 { 1166 {
1212 conflict_found = 1; 1167 conflict_found = 1;
1213 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name); 1168 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", &spell_name);
1214 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->clone.name); 1169 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->object::name);
1215 } 1170 }
1216 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->clone.name); 1171 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->object::name);
1217 continue; 1172 continue;
1218 } 1173 }
1219 1174
1220 found = ar; 1175 found = at;
1221 } 1176 }
1222 1177
1223 /* No match if more more than one archetype matches. */ 1178 /* No match if more more than one archetype matches. */
1224 if (conflict_found) 1179 if (conflict_found)
1225 return NULL; 1180 return NULL;
1227 /* Return if exactly one archetype matches. */ 1182 /* Return if exactly one archetype matches. */
1228 if (found != NULL) 1183 if (found != NULL)
1229 return arch_to_object (found); 1184 return arch_to_object (found);
1230 1185
1231 /* No spell found: just print an error message. */ 1186 /* No spell found: just print an error message. */
1232 new_draw_info_format (NDI_UNIQUE, 0, op, "The spell %s does not exist.", spell_name); 1187 new_draw_info_format (NDI_UNIQUE, 0, op, "The spell %s does not exist.", &spell_name);
1233 return NULL; 1188 return NULL;
1234} 1189}
1235 1190
1236static int 1191static int
1237command_learn_spell_or_prayer (object *op, char *params, int special_prayer) 1192command_learn_spell_or_prayer (object *op, char *params, int special_prayer)
1290 new_draw_info_format (NDI_UNIQUE, 0, op, "You do not know the spell %s.", params); 1245 new_draw_info_format (NDI_UNIQUE, 0, op, "You do not know the spell %s.", params);
1291 return 0; 1246 return 0;
1292 } 1247 }
1293 1248
1294 do_forget_spell (op, spell->name); 1249 do_forget_spell (op, spell->name);
1295 return 1;
1296}
1297
1298/**
1299 * Lists all plugins currently loaded with their IDs and full names.
1300 */
1301int
1302command_listplugins (object *op, char *params)
1303{
1304 plugins_display_list (op);
1305 return 1;
1306}
1307
1308/**
1309 * Loads the given plugin. The DM specifies the name of the library to load (no
1310 * pathname is needed). Do not ever attempt to load the same plugin more than
1311 * once at a time, or bad things could happen.
1312 */
1313int
1314command_loadplugin (object *op, char *params)
1315{
1316 char buf[MAX_BUF];
1317
1318 if (params == NULL)
1319 {
1320 new_draw_info (NDI_UNIQUE, 0, op, "Load which plugin?");
1321 return 1;
1322 }
1323
1324 strcpy (buf, LIBDIR);
1325 strcat (buf, "/plugins/");
1326 strcat (buf, params);
1327 LOG (llevDebug, "Requested plugin file is %s\n", buf);
1328 if (plugins_init_plugin (buf) == 0)
1329 new_draw_info (NDI_UNIQUE, 0, op, "Plugin successfully loaded.");
1330 else
1331 new_draw_info (NDI_UNIQUE, 0, op, "Could not load plugin.");
1332 return 1;
1333}
1334
1335/**
1336 * Unloads the given plugin. The DM specified the ID of the library to unload.
1337 * Note that some things may behave strangely if the correct plugins are not
1338 * loaded.
1339 */
1340int
1341command_unloadplugin (object *op, char *params)
1342{
1343 if (params == NULL)
1344 {
1345 new_draw_info (NDI_UNIQUE, 0, op, "Remove which plugin?");
1346 return 1;
1347 }
1348
1349 if (plugins_remove_plugin (params) == 0)
1350 new_draw_info (NDI_UNIQUE, 0, op, "Plugin successfully removed.");
1351 else
1352 new_draw_info (NDI_UNIQUE, 0, op, "Could not remove plugin.");
1353 return 1; 1250 return 1;
1354} 1251}
1355 1252
1356/** 1253/**
1357 * A players wants to become DM and hide. 1254 * A players wants to become DM and hide.
1678 return 0; 1575 return 0;
1679 } 1576 }
1680 1577
1681 if (!QUERY_FLAG (right, FLAG_REMOVED)) 1578 if (!QUERY_FLAG (right, FLAG_REMOVED))
1682 right->remove (); 1579 right->remove ();
1580
1683 inserted = insert_ob_in_ob (right, left); 1581 insert_ob_in_ob (right, left);
1684 if (left->type == PLAYER)
1685 if (inserted == right)
1686 esrv_send_item (left, right);
1687 else
1688 esrv_update_item (UPD_WEIGHT | UPD_NAME | UPD_NROF, left, inserted);
1689 1582
1690 new_draw_info_format (NDI_UNIQUE, 0, op, "Inserted %s in %s", query_name (inserted), query_name (left)); 1583 new_draw_info_format (NDI_UNIQUE, 0, op, "Inserted %s in %s", query_name (inserted), query_name (left));
1691 1584
1692 return 0; 1585 return 0;
1693 1586

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines