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.35 by root, Mon Feb 5 01:32:58 2007 UTC vs.
Revision 1.61 by root, Sat Dec 20 02:32:31 2008 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>
172 171
173 become_follower (ob, god); 172 become_follower (ob, god);
174 return 1; 173 return 1;
175} 174}
176 175
177/** 176// TODO: Rewrite banish in perl and get rid of the following two functions
178 * Add player's IP to ban_file and kick them off the server
179 * I know most people have dynamic IPs but this is more of a short term
180 * solution if they have to get a new IP to play maybe they'll calm down.
181 * This uses the banish_file in the local directory *not* the ban_file
182 * The action is logged with a ! for easy searching. -tm
183 */
184int
185command_banish (object *op, char *params)
186{
187 player *pl;
188 FILE *banishfile;
189 char buf[MAX_BUF];
190 time_t now;
191
192 if (!params)
193 {
194 new_draw_info (NDI_UNIQUE, 0, op, "Usage: banish <player>.");
195 return 1;
196 }
197
198 pl = get_other_player_from_name (op, params);
199 if (!pl)
200 return 1;
201
202 sprintf (buf, "%s/%s", settings.localdir, BANISHFILE);
203
204 if ((banishfile = fopen (buf, "a")) == NULL)
205 {
206 LOG (llevDebug, "Could not find file banish_file.\n");
207 new_draw_info (NDI_UNIQUE, 0, op, "Could not find banish_file.");
208 return 0;
209 }
210
211 now = time (NULL);
212 /*
213 * Record this as a comment - then we don't have to worry about changing
214 * the parsing code.
215 */
216 fprintf (banishfile, "# %s (%s) banned by %s at %s\n", &pl->ob->name, pl->ns->host, &op->name, ctime (&now));
217 fprintf (banishfile, "*@%s\n", pl->ns->host);
218 fclose (banishfile);
219
220 LOG (llevDebug, "! %s banned %s from IP: %s.\n", &op->name, &pl->ob->name, pl->ns->host);
221 new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op, "You banish %s", &pl->ob->name);
222 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s banishes %s from the land!", &op->name, &pl->ob->name);
223 command_kick (op, (char *) &pl->ob->name);
224 return 1;
225}
226
227int 177int
228command_kick (object *op, char *params) 178command_kick (object *op, char *params)
229{ 179{
230 for_all_players (pl) 180 for_all_players (pl)
231 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)))
232 { 182 {
233 object *op = pl->ob; 183 object *plop = pl->ob;
234 184
235 if (!QUERY_FLAG (op, FLAG_REMOVED) && !QUERY_FLAG (op, FLAG_FREED)) 185 if (!QUERY_FLAG (plop, FLAG_REMOVED) && !QUERY_FLAG (plop, FLAG_FREED))
236 { 186 {
237 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);
238 strcpy (op->contr->killer, "kicked"); 188 plop->contr->killer = op;
239 } 189 }
240 190
241 pl->ns->destroy (); 191 pl->ns->destroy ();
242 } 192 }
243 193
265 ready_map_name (op->map->path, 0); 215 ready_map_name (op->map->path, 0);
266 216
267 return 1; 217 return 1;
268} 218}
269#endif 219#endif
270
271int
272command_shutdown (object *op, char *params)
273{
274 if (op && !QUERY_FLAG (op, FLAG_WIZ))
275 {
276 new_draw_info (NDI_UNIQUE, 0, op, "Sorry, you can't shutdown the server.");
277 return 1;
278 }
279
280 cleanup ("dm initiated shutdown", 0);
281
282 /* not reached */
283 return 1;
284}
285 220
286int 221int
287command_freeze (object *op, char *params) 222command_freeze (object *op, char *params)
288{ 223{
289 int ticks; 224 int ticks;
344 /* we have nowhere to send the prisoner.... */ 279 /* we have nowhere to send the prisoner.... */
345 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");
346 return 0; 281 return 0;
347 } 282 }
348 283
349 pl->ob->enter_exit (dummy); 284 pl->ob->player_goto (dummy->slaying, dummy->stats.hp, dummy->stats.sp);//TODO
350 dummy->destroy (); 285 dummy->destroy ();
286
351 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.");
352 new_draw_info (NDI_UNIQUE, 0, op, "OK."); 288 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
353 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);
354 return 1; 290 return 1;
355} 291}
379 { 315 {
380 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.");
381 return 1; 317 return 1;
382 } 318 }
383 319
384 dummy = object::create (); 320 pl->ob->player_goto (op->map->path, op->x + freearr_x[i], op->y + freearr_y[i]);
385 EXIT_PATH (dummy) = op->map->path;
386 EXIT_X (dummy) = op->x + freearr_x[i];
387 EXIT_Y (dummy) = op->y + freearr_y[i];
388 pl->ob->enter_exit (dummy);
389 dummy->destroy ();
390 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); 321 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned.");
391 new_draw_info (NDI_UNIQUE, 0, op, "OK."); 322 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
392 323
393 return 1; 324 return 1;
394} 325}
487 * we also set up spell_name which is only 418 * we also set up spell_name which is only
488 * the first word. 419 * the first word.
489 */ 420 */
490 421
491 at_spell = archetype::find (cp); 422 at_spell = archetype::find (cp);
492 if (!at_spell || at_spell->clone.type != SPELL) 423 if (!at_spell || at_spell->type != SPELL)
493 at_spell = find_archetype_by_object_name (cp); 424 at_spell = find_archetype_by_object_name (cp);
494 if (!at_spell || at_spell->clone.type != SPELL) 425 if (!at_spell || at_spell->type != SPELL)
495 { 426 {
496 assign (spell_name, cp); 427 assign (spell_name, cp);
497 fsp = strchr (spell_name, ' '); 428 fsp = strchr (spell_name, ' ');
498 if (fsp) 429 if (fsp)
499 { 430 {
500 *fsp = 0; 431 *fsp = 0;
501 fsp++; 432 fsp++;
502 at_spell = archetype::find (spell_name); 433 at_spell = archetype::find (spell_name);
503 434
504 /* Got a spell, update the first string pointer */ 435 /* Got a spell, update the first string pointer */
505 if (at_spell && at_spell->clone.type == SPELL) 436 if (at_spell && at_spell->type == SPELL)
506 bp2 = cp + strlen (spell_name) + 1; 437 bp2 = cp + strlen (spell_name) + 1;
507 else 438 else
508 at_spell = NULL; 439 at_spell = NULL;
509 } 440 }
510 } 441 }
512 /* OK - we didn't find a spell - presume the 'of' 443 /* OK - we didn't find a spell - presume the 'of'
513 * in this case means its an artifact. 444 * in this case means its an artifact.
514 */ 445 */
515 if (!at_spell) 446 if (!at_spell)
516 { 447 {
517 if (find_artifactlist (at->clone.type) == NULL) 448 if (find_artifactlist (at->type) == NULL)
518 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);
519 else 450 else
520 { 451 {
521 art = find_artifactlist (at->clone.type)->items; 452 art = find_artifactlist (at->type)->items;
522 453
523 do 454 while (art)
524 { 455 {
525 if (!strcmp (art->item->name, cp)) 456 if (!strcmp (art->item->name, cp))
526 break; 457 break;
458
527 art = art->next; 459 art = art->next;
528 } 460 }
529 while (art != NULL);
530 461
531 if (!art) 462 if (!art)
532 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);
533 } 464 }
534 465
535 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);
536 } 467 }
537 } /* if cp */ 468 } /* if cp */
538 469
539 if ((at->clone.type == ROD || at->clone.type == WAND || at->clone.type == SCROLL || 470 if ((at->type == ROD || at->type == WAND || at->type == SCROLL ||
540 at->clone.type == HORN || at->clone.type == SPELLBOOK) && !at_spell) 471 at->type == HORN || at->type == SPELLBOOK) && !at_spell)
541 { 472 {
542 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);
543 return 1; 474 return 1;
544 } 475 }
545 476
547 * 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,
548 * just create one object, do all the processing, and then determine 479 * just create one object, do all the processing, and then determine
549 * 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.
550 */ 481 */
551 tmp = arch_to_object (at); 482 tmp = arch_to_object (at);
552
553 if (settings.real_wiz == FALSE)
554 SET_FLAG (tmp, FLAG_WAS_WIZ);
555 483
556 if (set_magic) 484 if (set_magic)
557 set_abs_magic (tmp, magic); 485 set_abs_magic (tmp, magic);
558 486
559 if (art) 487 if (art)
639 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);
640 568
641 bp2 = bp3 + 1; 569 bp2 = bp3 + 1;
642 } 570 }
643 571
644 if (at->clone.nrof) 572 if (at->nrof)
645 { 573 {
646 if (at_spell) 574 if (at_spell)
647 insert_ob_in_ob (arch_to_object (at_spell), tmp); 575 tmp->insert (arch_to_object (at_spell));
648 576
649 tmp->x = op->x; 577 tmp->x = op->x;
650 tmp->y = op->y; 578 tmp->y = op->y;
579 tmp->map = op->map;
651 580
652 if (set_nrof) 581 if (set_nrof)
653 tmp->nrof = nrof; 582 tmp->nrof = nrof;
654 583
655 tmp->map = op->map; 584 op->insert (tmp);
656
657 tmp = insert_ob_in_ob (tmp, op);
658 esrv_send_item (op, tmp);
659 585
660 /* 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. */
661 dm_stack_push (op->contr, tmp->count); 587 dm_stack_push (op->contr, tmp->count);
662 588
663 return 1; 589 return 1;
664 } 590 }
665 else 591 else
666 { 592 {
667 for (i = 0; i < (set_nrof ? nrof : 1); i++) 593 for (i = 0; i < (set_nrof ? nrof : 1); i++)
668 { 594 {
669 archetype *atmp;
670 object *prev = 0, *head = 0; 595 object *prev = 0, *head = 0;
671 596
672 for (atmp = at; atmp; atmp = atmp->more) 597 for (archetype *atmp = at; atmp; atmp = (archetype *)atmp->more)
673 { 598 {
674 object *dup = arch_to_object (atmp); 599 object *dup = arch_to_object (atmp);
675 600
676 if (at_spell) 601 if (at_spell)
677 insert_ob_in_ob (arch_to_object (at_spell), dup); 602 insert_ob_in_ob (arch_to_object (at_spell), dup);
684 { 609 {
685 head = dup; 610 head = dup;
686 tmp->copy_to (dup); 611 tmp->copy_to (dup);
687 } 612 }
688 613
689 if (settings.real_wiz == FALSE)
690 SET_FLAG (dup, FLAG_WAS_WIZ);
691
692 dup->x = op->x + dup->arch->clone.x; 614 dup->x = op->x + dup->arch->x;
693 dup->y = op->y + dup->arch->clone.y; 615 dup->y = op->y + dup->arch->y;
694 dup->map = op->map; 616 dup->map = op->map;
695 617
696 if (head != dup) 618 if (head != dup)
697 { 619 {
698 dup->head = head; 620 dup->head = head;
708 int size_x = 0; 630 int size_x = 0;
709 int size_y = 0; 631 int size_y = 0;
710 632
711 while (check) 633 while (check)
712 { 634 {
713 size_x = MAX (size_x, check->arch->clone.x); 635 size_x = MAX (size_x, check->arch->x);
714 size_y = MAX (size_y, check->arch->clone.y); 636 size_y = MAX (size_y, check->arch->y);
715 check = check->more; 637 check = check->more;
716 } 638 }
717 639
718 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))
719 { 641 {
745 /* 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
746 * things like rods have nrof 0, we want to cover those. 668 * things like rods have nrof 0, we want to cover those.
747 */ 669 */
748 dm_stack_push (op->contr, head->count); 670 dm_stack_push (op->contr, head->count);
749 671
750 if (at->clone.randomitems != NULL && !at_spell) 672 if (at->randomitems && !at_spell)
751 create_treasure (at->clone.randomitems, head, GT_APPLY, op->map->difficulty, 0); 673 create_treasure (at->randomitems, head, GT_APPLY, op->map->difficulty, 0);
752
753 esrv_send_item (op, head);
754 } 674 }
755 675
756 /* free the one we used to copy */ 676 /* free the one we used to copy */
757 tmp->destroy (); 677 tmp->destroy ();
758 } 678 }
765 */ 685 */
766 686
767int 687int
768command_inventory (object *op, char *params) 688command_inventory (object *op, char *params)
769{ 689{
690 int i;
770 object *tmp; 691 object *tmp;
771 int i;
772 692
773 if (!params) 693 if (!params || !sscanf (params, "%d", &i) || !(tmp = find_object (i)))
774 { 694 {
775 inventory (op, NULL); 695 op->contr->failmsg ("Inventory of what object (nr)?");
776 return 0; 696 return 1;
777 }
778
779 if (!sscanf (params, "%d", &i) || (tmp = find_object (i)) == NULL)
780 { 697 }
781 new_draw_info (NDI_UNIQUE, 0, op, "Inventory of what object (nr)?");
782 return 1;
783 }
784 698
785 inventory (op, tmp); 699 op->contr->infobox (MSG_CHANNEL ("examine"), tmp->query_inventory (op));
700
786 return 1; 701 return 1;
787} 702}
788 703
789/* just show player's their skills for now. Dm's can 704/* just show player's their skills for now. Dm's can
790 * already see skills w/ inventory command - b.t. 705 * already see skills w/ inventory command - b.t.
811 free (dump); 726 free (dump);
812 727
813 if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL)) 728 if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL))
814 new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); 729 new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original");
815 730
816 return 1;
817}
818
819/**
820 * When DM is possessing a monster, flip aggression on and off, to allow
821 * better motion.
822 */
823int
824command_mon_aggr (object *op, char *params)
825{
826 if (op->enemy || !QUERY_FLAG (op, FLAG_UNAGGRESSIVE))
827 {
828 op->enemy = NULL;
829 SET_FLAG (op, FLAG_UNAGGRESSIVE);
830 new_draw_info (NDI_UNIQUE, 0, op, "Aggression turned OFF");
831 }
832 else
833 {
834 CLEAR_FLAG (op, FLAG_FRIENDLY);
835 CLEAR_FLAG (op, FLAG_UNAGGRESSIVE);
836 new_draw_info (NDI_UNIQUE, 0, op, "Aggression turned ON");
837 }
838
839 return 1;
840}
841
842/** DM can possess a monster. Basically, this tricks the client into thinking
843 * a given monster, is actually the player it controls. This allows a DM
844 * to inhabit a monster's body, and run around the game with it.
845 * This function is severely broken - it has tons of hardcoded values,
846 */
847int
848command_possess (object *op, char *params)
849{
850 object *victim, *curinv, *nextinv;
851 player *pl;
852 int i;
853 char buf[MAX_BUF];
854
855 victim = NULL;
856 if (params != NULL)
857 {
858 if (sscanf (params, "%d", &i))
859 victim = find_object (i);
860 else if (sscanf (params, "%s", buf))
861 victim = find_object_name (buf);
862 }
863 if (victim == NULL)
864 {
865 new_draw_info (NDI_UNIQUE, 0, op, "Patch what object (nr)?");
866 return 1;
867 }
868
869 if (victim == op)
870 {
871 new_draw_info (NDI_UNIQUE, 0, op, "As insane as you are, I cannot " "allow you to possess yourself.");
872 return 1;
873 }
874
875 /* clear out the old inventory */
876 curinv = op->inv;
877 while (curinv != NULL)
878 {
879 nextinv = curinv->below;
880 esrv_del_item (op->contr, curinv->count);
881 curinv = nextinv;
882 }
883
884 /* make the switch */
885 pl = op->contr;
886 victim->contr = pl;
887 pl->ob = victim;
888 victim->type = PLAYER;
889 SET_FLAG (victim, FLAG_WIZ);
890
891 /* send the inventory to the client */
892 curinv = victim->inv;
893 while (curinv != NULL)
894 {
895 nextinv = curinv->below;
896 esrv_send_item (victim, curinv);
897 curinv = nextinv;
898 }
899 /* basic patchup */
900 /* The use of hard coded values is terrible. Note
901 * that really, to be fair, this shouldn't get changed at
902 * all - if you are possessing a kobold, you should have the
903 * same limitations. As it is, as more body locations are added,
904 * this will give this player more locations than perhaps
905 * they should be allowed.
906 */
907 for (i = 0; i < NUM_BODY_LOCATIONS; i++)
908 if (i == 1 || i == 6 || i == 8 || i == 9)
909 victim->body_info[i] = 2;
910 else
911 victim->body_info[i] = 1;
912
913 esrv_new_player (pl, 80); /* just pick a wieght, we don't care */
914 esrv_send_inventory (victim, victim);
915
916 victim->update_stats ();
917
918 do_some_living (victim);
919 return 1; 731 return 1;
920} 732}
921 733
922int 734int
923command_patch (object *op, char *params) 735command_patch (object *op, char *params)
938 return 1; 750 return 1;
939 } 751 }
940 752
941 if ((arg2 = strchr (arg, ' '))) 753 if ((arg2 = strchr (arg, ' ')))
942 arg2++; 754 arg2++;
943 if (settings.real_wiz == FALSE) 755
944 SET_FLAG (tmp, FLAG_WAS_WIZ); /* To avoid cheating */
945 if (set_variable (tmp, arg) == -1) 756 if (set_variable (tmp, arg) == -1)
946 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);
947 else 758 else
948 {
949 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);
950 }
951 760
952 return 1; 761 return 1;
953} 762}
954 763
955int 764int
1018 */ 827 */
1019int 828int
1020command_addexp (object *op, char *params) 829command_addexp (object *op, char *params)
1021{ 830{
1022 char buf[MAX_BUF], skill[MAX_BUF]; 831 char buf[MAX_BUF], skill[MAX_BUF];
1023 int i, q; 832 int q;
833 long long i; // use sint64 and finally provide format specifiers for sint64 etc. via configure
1024 object *skillob = NULL; 834 object *skillob = NULL;
1025 835
1026 skill[0] = '\0'; 836 skill[0] = '\0';
1027 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))
1028 { 838 {
1029 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>].");
1030 return 1; 840 return 1;
1031 } 841 }
1032 842
1049 } 859 }
1050 860
1051 pl->ob->stats.exp += i; 861 pl->ob->stats.exp += i;
1052 calc_perm_exp (pl->ob); 862 calc_perm_exp (pl->ob);
1053 player_lvl_adj (pl->ob, NULL); 863 player_lvl_adj (pl->ob, NULL);
1054
1055 if (settings.real_wiz == FALSE)
1056 SET_FLAG (pl->ob, FLAG_WAS_WIZ);
1057 864
1058 return 1; 865 return 1;
1059 } 866 }
1060 867
1061 new_draw_info (NDI_UNIQUE, 0, op, "No such player."); 868 new_draw_info (NDI_UNIQUE, 0, op, "No such player.");
1110int 917int
1111command_abil (object *op, char *params) 918command_abil (object *op, char *params)
1112{ 919{
1113 char thing[20], thing2[20]; 920 char thing[20], thing2[20];
1114 int iii; 921 int iii;
1115 player *pl;
1116 char buf[MAX_BUF]; 922 char buf[MAX_BUF];
1117 923
1118 iii = 0; 924 iii = 0;
1119 thing[0] = '\0'; 925 thing[0] = '\0';
1120 thing2[0] = '\0'; 926 thing2[0] = '\0';
1138 944
1139 for_all_players (pl) 945 for_all_players (pl)
1140 { 946 {
1141 if (!strcmp (pl->ob->name, thing)) 947 if (!strcmp (pl->ob->name, thing))
1142 { 948 {
1143 if (settings.real_wiz == FALSE)
1144 SET_FLAG (pl->ob, FLAG_WAS_WIZ);
1145 if (!strcmp ("str", thing2))
1146 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;
1147 if (!strcmp ("dex", thing2))
1148 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;
1149 if (!strcmp ("con", thing2))
1150 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;
1151 if (!strcmp ("wis", thing2))
1152 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;
1153 if (!strcmp ("cha", thing2))
1154 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;
1155 if (!strcmp ("int", thing2))
1156 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;
1157 if (!strcmp ("pow", thing2))
1158 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
1159 sprintf (buf, "%s has been altered.", &pl->ob->name); 957 sprintf (buf, "%s has been altered.", &pl->ob->name);
1160 new_draw_info (NDI_UNIQUE, 0, op, buf); 958 new_draw_info (NDI_UNIQUE, 0, op, buf);
1161 pl->ob->update_stats (); 959 pl->ob->update_stats ();
1162 return 1; 960 return 1;
1163 } 961 }
1167 return 1; 965 return 1;
1168} 966}
1169 967
1170int 968int
1171command_nowiz (object *op, char *params) 969command_nowiz (object *op, char *params)
1172{ /* 'noadm' is alias */ 970{ /* 'nodm' is alias */
1173 CLEAR_FLAG (op, FLAG_WIZ); 971 CLEAR_FLAG (op, FLAG_WIZ);
1174 CLEAR_FLAG (op, FLAG_WIZPASS); 972 CLEAR_FLAG (op, FLAG_WIZPASS);
1175 CLEAR_FLAG (op, FLAG_WIZCAST); 973 CLEAR_FLAG (op, FLAG_WIZCAST);
1176 974
1177 if (settings.real_wiz == TRUE)
1178 CLEAR_FLAG (op, FLAG_WAS_WIZ);
1179 if (op->contr->hidden) 975 if (op->contr->hidden)
1180 { 976 {
1181 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); 977 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players");
1182 op->map->players++; 978 op->map->players++;
1183 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); 979 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name);
1245 } 1041 }
1246 1042
1247 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) 1043 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host))
1248 { 1044 {
1249 SET_FLAG (op, FLAG_WIZ); 1045 SET_FLAG (op, FLAG_WIZ);
1250 SET_FLAG (op, FLAG_WAS_WIZ);
1251 SET_FLAG (op, FLAG_WIZPASS); 1046 SET_FLAG (op, FLAG_WIZPASS);
1252 SET_FLAG (op, FLAG_WIZCAST); 1047 SET_FLAG (op, FLAG_WIZCAST);
1048
1253 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); 1049 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!");
1254 /* 1050 /*
1255 * Remove setting flying here - that won't work, because next 1051 * Remove setting flying here - that won't work, because next
1256 * fix_player() is called that will get cleared - proper solution 1052 * fix_player() is called that will get cleared - proper solution
1257 * is probably something like a wiz_force which gives that and any 1053 * is probably something like a wiz_force which gives that and any
1258 * other desired abilities. 1054 * other desired abilities.
1259 */ 1055 */
1260 clear_los (op); 1056 op->contr->clear_los (0);
1261 op->contr->write_buf[0] = '\0'; 1057 op->contr->write_buf[0] = '\0';
1262 1058
1263 if (!silent) 1059 if (!silent)
1264 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); 1060 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!");
1265 1061
1292command_invisible (object *op, char *params) 1088command_invisible (object *op, char *params)
1293{ 1089{
1294 if (op) 1090 if (op)
1295 { 1091 {
1296 op->invisible += 100; 1092 op->invisible += 100;
1297 update_object (op, UP_OBJ_FACE); 1093 update_object (op, UP_OBJ_CHANGE);
1298 new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible."); 1094 new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible.");
1299 } 1095 }
1300 1096
1301 return 0; 1097 return 0;
1302} 1098}
1314 * name than other "spell_xxx" archetypes and would always conflict. 1110 * name than other "spell_xxx" archetypes and would always conflict.
1315 */ 1111 */
1316static object * 1112static object *
1317get_spell_by_name (object *op, const char *spell_name) 1113get_spell_by_name (object *op, const char *spell_name)
1318{ 1114{
1319 archetype *ar; 1115 archetype *at;
1320 archetype *found; 1116 archetype *found;
1321 int conflict_found; 1117 int conflict_found;
1322 size_t spell_name_length; 1118 size_t spell_name_length;
1323 1119
1324 /* First check for full name matches. */ 1120 /* First check for full name matches. */
1325 conflict_found = 0; 1121 conflict_found = 0;
1326 found = NULL; 1122 found = NULL;
1327 for (ar = first_archetype; ar != NULL; ar = ar->next) 1123 for_all_archetypes (at)
1328 { 1124 {
1329 if (ar->clone.type != SPELL) 1125 if (at->type != SPELL)
1330 continue; 1126 continue;
1331 1127
1332 if (strncmp (ar->name, "spelldirect_", 12) == 0) 1128 if (strncmp (at->archname, "spelldirect_", 12) == 0)
1333 continue; 1129 continue;
1334 1130
1335 if (strcmp (ar->clone.name, spell_name) != 0) 1131 if (strcmp (at->object::name, spell_name) != 0)
1336 continue; 1132 continue;
1337 1133
1338 if (found != NULL) 1134 if (found != NULL)
1339 { 1135 {
1340 if (!conflict_found) 1136 if (!conflict_found)
1341 { 1137 {
1342 conflict_found = 1; 1138 conflict_found = 1;
1343 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name); 1139 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name);
1344 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->name); 1140 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname);
1345 } 1141 }
1142
1346 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->name); 1143 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname);
1347 continue; 1144 continue;
1348 } 1145 }
1349 1146
1350 found = ar; 1147 found = at;
1351 } 1148 }
1352 1149
1353 /* No match if more more than one archetype matches. */ 1150 /* No match if more more than one archetype matches. */
1354 if (conflict_found) 1151 if (conflict_found)
1355 return NULL; 1152 return NULL;
1360 1157
1361 /* No full match found: now check for partial matches. */ 1158 /* No full match found: now check for partial matches. */
1362 spell_name_length = strlen (spell_name); 1159 spell_name_length = strlen (spell_name);
1363 conflict_found = 0; 1160 conflict_found = 0;
1364 found = NULL; 1161 found = NULL;
1365 for (ar = first_archetype; ar != NULL; ar = ar->next) 1162 for_all_archetypes (at)
1366 { 1163 {
1367 if (ar->clone.type != SPELL) 1164 if (at->type != SPELL)
1368 continue; 1165 continue;
1369 1166
1370 if (strncmp (ar->name, "spelldirect_", 12) == 0) 1167 if (strncmp (at->archname, "spelldirect_", 12) == 0)
1371 continue; 1168 continue;
1372 1169
1373 if (strncmp (ar->clone.name, spell_name, spell_name_length) != 0) 1170 if (strncmp (at->object::name, spell_name, spell_name_length) != 0)
1374 continue; 1171 continue;
1375 1172
1376 if (found != NULL) 1173 if (found != NULL)
1377 { 1174 {
1378 if (!conflict_found) 1175 if (!conflict_found)
1379 { 1176 {
1380 conflict_found = 1; 1177 conflict_found = 1;
1381 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name); 1178 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name);
1382 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->clone.name); 1179 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->object::name);
1383 } 1180 }
1384 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->clone.name); 1181 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->object::name);
1385 continue; 1182 continue;
1386 } 1183 }
1387 1184
1388 found = ar; 1185 found = at;
1389 } 1186 }
1390 1187
1391 /* No match if more more than one archetype matches. */ 1188 /* No match if more more than one archetype matches. */
1392 if (conflict_found) 1189 if (conflict_found)
1393 return NULL; 1190 return NULL;
1458 new_draw_info_format (NDI_UNIQUE, 0, op, "You do not know the spell %s.", params); 1255 new_draw_info_format (NDI_UNIQUE, 0, op, "You do not know the spell %s.", params);
1459 return 0; 1256 return 0;
1460 } 1257 }
1461 1258
1462 do_forget_spell (op, spell->name); 1259 do_forget_spell (op, spell->name);
1463 return 1;
1464}
1465
1466/**
1467 * Lists all plugins currently loaded with their IDs and full names.
1468 */
1469int
1470command_listplugins (object *op, char *params)
1471{
1472 plugins_display_list (op);
1473 return 1;
1474}
1475
1476/**
1477 * Loads the given plugin. The DM specifies the name of the library to load (no
1478 * pathname is needed). Do not ever attempt to load the same plugin more than
1479 * once at a time, or bad things could happen.
1480 */
1481int
1482command_loadplugin (object *op, char *params)
1483{
1484 char buf[MAX_BUF];
1485
1486 if (params == NULL)
1487 {
1488 new_draw_info (NDI_UNIQUE, 0, op, "Load which plugin?");
1489 return 1;
1490 }
1491
1492 strcpy (buf, LIBDIR);
1493 strcat (buf, "/plugins/");
1494 strcat (buf, params);
1495 LOG (llevDebug, "Requested plugin file is %s\n", buf);
1496 if (plugins_init_plugin (buf) == 0)
1497 new_draw_info (NDI_UNIQUE, 0, op, "Plugin successfully loaded.");
1498 else
1499 new_draw_info (NDI_UNIQUE, 0, op, "Could not load plugin.");
1500 return 1;
1501}
1502
1503/**
1504 * Unloads the given plugin. The DM specified the ID of the library to unload.
1505 * Note that some things may behave strangely if the correct plugins are not
1506 * loaded.
1507 */
1508int
1509command_unloadplugin (object *op, char *params)
1510{
1511 if (params == NULL)
1512 {
1513 new_draw_info (NDI_UNIQUE, 0, op, "Remove which plugin?");
1514 return 1;
1515 }
1516
1517 if (plugins_remove_plugin (params) == 0)
1518 new_draw_info (NDI_UNIQUE, 0, op, "Plugin successfully removed.");
1519 else
1520 new_draw_info (NDI_UNIQUE, 0, op, "Could not remove plugin.");
1521 return 1; 1260 return 1;
1522} 1261}
1523 1262
1524/** 1263/**
1525 * A players wants to become DM and hide. 1264 * A players wants to become DM and hide.
1846 return 0; 1585 return 0;
1847 } 1586 }
1848 1587
1849 if (!QUERY_FLAG (right, FLAG_REMOVED)) 1588 if (!QUERY_FLAG (right, FLAG_REMOVED))
1850 right->remove (); 1589 right->remove ();
1590
1851 inserted = insert_ob_in_ob (right, left); 1591 insert_ob_in_ob (right, left);
1852 if (left->type == PLAYER)
1853 if (inserted == right)
1854 esrv_send_item (left, right);
1855 else
1856 esrv_update_item (UPD_WEIGHT | UPD_NAME | UPD_NROF, left, inserted);
1857 1592
1858 new_draw_info_format (NDI_UNIQUE, 0, op, "Inserted %s in %s", query_name (inserted), query_name (left)); 1593 new_draw_info_format (NDI_UNIQUE, 0, op, "Inserted %s in %s", query_name (inserted), query_name (left));
1859 1594
1860 return 0; 1595 return 0;
1861 1596

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines