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.36 by pippijn, Thu Mar 1 12:28:16 2007 UTC vs.
Revision 1.62 by root, Fri Dec 26 10:14:01 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.");
1137 944
1138 for_all_players (pl) 945 for_all_players (pl)
1139 { 946 {
1140 if (!strcmp (pl->ob->name, thing)) 947 if (!strcmp (pl->ob->name, thing))
1141 { 948 {
1142 if (settings.real_wiz == FALSE)
1143 SET_FLAG (pl->ob, FLAG_WAS_WIZ);
1144 if (!strcmp ("str", thing2))
1145 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;
1146 if (!strcmp ("dex", thing2))
1147 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;
1148 if (!strcmp ("con", thing2))
1149 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;
1150 if (!strcmp ("wis", thing2))
1151 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;
1152 if (!strcmp ("cha", thing2))
1153 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;
1154 if (!strcmp ("int", thing2))
1155 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;
1156 if (!strcmp ("pow", thing2))
1157 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
1158 sprintf (buf, "%s has been altered.", &pl->ob->name); 957 sprintf (buf, "%s has been altered.", &pl->ob->name);
1159 new_draw_info (NDI_UNIQUE, 0, op, buf); 958 new_draw_info (NDI_UNIQUE, 0, op, buf);
1160 pl->ob->update_stats (); 959 pl->ob->update_stats ();
1161 return 1; 960 return 1;
1162 } 961 }
1166 return 1; 965 return 1;
1167} 966}
1168 967
1169int 968int
1170command_nowiz (object *op, char *params) 969command_nowiz (object *op, char *params)
1171{ /* 'noadm' is alias */ 970{ /* 'nodm' is alias */
1172 CLEAR_FLAG (op, FLAG_WIZ); 971 CLEAR_FLAG (op, FLAG_WIZ);
1173 CLEAR_FLAG (op, FLAG_WIZPASS); 972 CLEAR_FLAG (op, FLAG_WIZPASS);
1174 CLEAR_FLAG (op, FLAG_WIZCAST); 973 CLEAR_FLAG (op, FLAG_WIZCAST);
1175 974
1176 if (settings.real_wiz == TRUE)
1177 CLEAR_FLAG (op, FLAG_WAS_WIZ);
1178 if (op->contr->hidden) 975 if (op->contr->hidden)
1179 { 976 {
1180 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");
1181 op->map->players++; 978 op->map->players++;
1182 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);
1244 } 1041 }
1245 1042
1246 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) 1043 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host))
1247 { 1044 {
1248 SET_FLAG (op, FLAG_WIZ); 1045 SET_FLAG (op, FLAG_WIZ);
1249 SET_FLAG (op, FLAG_WAS_WIZ);
1250 SET_FLAG (op, FLAG_WIZPASS); 1046 SET_FLAG (op, FLAG_WIZPASS);
1251 SET_FLAG (op, FLAG_WIZCAST); 1047 SET_FLAG (op, FLAG_WIZCAST);
1048 SET_FLAG (op, FLAG_WIZLOOK);
1049
1252 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); 1050 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!");
1253 /*
1254 * Remove setting flying here - that won't work, because next
1255 * fix_player() is called that will get cleared - proper solution
1256 * is probably something like a wiz_force which gives that and any
1257 * other desired abilities.
1258 */
1259 clear_los (op);
1260 op->contr->write_buf[0] = '\0'; 1051 op->contr->write_buf[0] = '\0';
1261 1052
1262 if (!silent) 1053 if (!silent)
1263 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); 1054 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!");
1264 1055
1291command_invisible (object *op, char *params) 1082command_invisible (object *op, char *params)
1292{ 1083{
1293 if (op) 1084 if (op)
1294 { 1085 {
1295 op->invisible += 100; 1086 op->invisible += 100;
1296 update_object (op, UP_OBJ_FACE); 1087 update_object (op, UP_OBJ_CHANGE);
1297 new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible."); 1088 new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible.");
1298 } 1089 }
1299 1090
1300 return 0; 1091 return 0;
1301} 1092}
1313 * name than other "spell_xxx" archetypes and would always conflict. 1104 * name than other "spell_xxx" archetypes and would always conflict.
1314 */ 1105 */
1315static object * 1106static object *
1316get_spell_by_name (object *op, const char *spell_name) 1107get_spell_by_name (object *op, const char *spell_name)
1317{ 1108{
1318 archetype *ar; 1109 archetype *at;
1319 archetype *found; 1110 archetype *found;
1320 int conflict_found; 1111 int conflict_found;
1321 size_t spell_name_length; 1112 size_t spell_name_length;
1322 1113
1323 /* First check for full name matches. */ 1114 /* First check for full name matches. */
1324 conflict_found = 0; 1115 conflict_found = 0;
1325 found = NULL; 1116 found = NULL;
1326 for (ar = first_archetype; ar != NULL; ar = ar->next) 1117 for_all_archetypes (at)
1327 { 1118 {
1328 if (ar->clone.type != SPELL) 1119 if (at->type != SPELL)
1329 continue; 1120 continue;
1330 1121
1331 if (strncmp (ar->name, "spelldirect_", 12) == 0) 1122 if (strncmp (at->archname, "spelldirect_", 12) == 0)
1332 continue; 1123 continue;
1333 1124
1334 if (strcmp (ar->clone.name, spell_name) != 0) 1125 if (strcmp (at->object::name, spell_name) != 0)
1335 continue; 1126 continue;
1336 1127
1337 if (found != NULL) 1128 if (found != NULL)
1338 { 1129 {
1339 if (!conflict_found) 1130 if (!conflict_found)
1340 { 1131 {
1341 conflict_found = 1; 1132 conflict_found = 1;
1342 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name); 1133 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name);
1343 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->name); 1134 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname);
1344 } 1135 }
1136
1345 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->name); 1137 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname);
1346 continue; 1138 continue;
1347 } 1139 }
1348 1140
1349 found = ar; 1141 found = at;
1350 } 1142 }
1351 1143
1352 /* No match if more more than one archetype matches. */ 1144 /* No match if more more than one archetype matches. */
1353 if (conflict_found) 1145 if (conflict_found)
1354 return NULL; 1146 return NULL;
1359 1151
1360 /* No full match found: now check for partial matches. */ 1152 /* No full match found: now check for partial matches. */
1361 spell_name_length = strlen (spell_name); 1153 spell_name_length = strlen (spell_name);
1362 conflict_found = 0; 1154 conflict_found = 0;
1363 found = NULL; 1155 found = NULL;
1364 for (ar = first_archetype; ar != NULL; ar = ar->next) 1156 for_all_archetypes (at)
1365 { 1157 {
1366 if (ar->clone.type != SPELL) 1158 if (at->type != SPELL)
1367 continue; 1159 continue;
1368 1160
1369 if (strncmp (ar->name, "spelldirect_", 12) == 0) 1161 if (strncmp (at->archname, "spelldirect_", 12) == 0)
1370 continue; 1162 continue;
1371 1163
1372 if (strncmp (ar->clone.name, spell_name, spell_name_length) != 0) 1164 if (strncmp (at->object::name, spell_name, spell_name_length) != 0)
1373 continue; 1165 continue;
1374 1166
1375 if (found != NULL) 1167 if (found != NULL)
1376 { 1168 {
1377 if (!conflict_found) 1169 if (!conflict_found)
1378 { 1170 {
1379 conflict_found = 1; 1171 conflict_found = 1;
1380 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name); 1172 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name);
1381 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->clone.name); 1173 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->object::name);
1382 } 1174 }
1383 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->clone.name); 1175 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->object::name);
1384 continue; 1176 continue;
1385 } 1177 }
1386 1178
1387 found = ar; 1179 found = at;
1388 } 1180 }
1389 1181
1390 /* No match if more more than one archetype matches. */ 1182 /* No match if more more than one archetype matches. */
1391 if (conflict_found) 1183 if (conflict_found)
1392 return NULL; 1184 return NULL;
1457 new_draw_info_format (NDI_UNIQUE, 0, op, "You do not know the spell %s.", params); 1249 new_draw_info_format (NDI_UNIQUE, 0, op, "You do not know the spell %s.", params);
1458 return 0; 1250 return 0;
1459 } 1251 }
1460 1252
1461 do_forget_spell (op, spell->name); 1253 do_forget_spell (op, spell->name);
1462 return 1;
1463}
1464
1465/**
1466 * Lists all plugins currently loaded with their IDs and full names.
1467 */
1468int
1469command_listplugins (object *op, char *params)
1470{
1471 plugins_display_list (op);
1472 return 1;
1473}
1474
1475/**
1476 * Loads the given plugin. The DM specifies the name of the library to load (no
1477 * pathname is needed). Do not ever attempt to load the same plugin more than
1478 * once at a time, or bad things could happen.
1479 */
1480int
1481command_loadplugin (object *op, char *params)
1482{
1483 char buf[MAX_BUF];
1484
1485 if (params == NULL)
1486 {
1487 new_draw_info (NDI_UNIQUE, 0, op, "Load which plugin?");
1488 return 1;
1489 }
1490
1491 strcpy (buf, LIBDIR);
1492 strcat (buf, "/plugins/");
1493 strcat (buf, params);
1494 LOG (llevDebug, "Requested plugin file is %s\n", buf);
1495 if (plugins_init_plugin (buf) == 0)
1496 new_draw_info (NDI_UNIQUE, 0, op, "Plugin successfully loaded.");
1497 else
1498 new_draw_info (NDI_UNIQUE, 0, op, "Could not load plugin.");
1499 return 1;
1500}
1501
1502/**
1503 * Unloads the given plugin. The DM specified the ID of the library to unload.
1504 * Note that some things may behave strangely if the correct plugins are not
1505 * loaded.
1506 */
1507int
1508command_unloadplugin (object *op, char *params)
1509{
1510 if (params == NULL)
1511 {
1512 new_draw_info (NDI_UNIQUE, 0, op, "Remove which plugin?");
1513 return 1;
1514 }
1515
1516 if (plugins_remove_plugin (params) == 0)
1517 new_draw_info (NDI_UNIQUE, 0, op, "Plugin successfully removed.");
1518 else
1519 new_draw_info (NDI_UNIQUE, 0, op, "Could not remove plugin.");
1520 return 1; 1254 return 1;
1521} 1255}
1522 1256
1523/** 1257/**
1524 * A players wants to become DM and hide. 1258 * A players wants to become DM and hide.
1845 return 0; 1579 return 0;
1846 } 1580 }
1847 1581
1848 if (!QUERY_FLAG (right, FLAG_REMOVED)) 1582 if (!QUERY_FLAG (right, FLAG_REMOVED))
1849 right->remove (); 1583 right->remove ();
1584
1850 inserted = insert_ob_in_ob (right, left); 1585 insert_ob_in_ob (right, left);
1851 if (left->type == PLAYER)
1852 if (inserted == right)
1853 esrv_send_item (left, right);
1854 else
1855 esrv_update_item (UPD_WEIGHT | UPD_NAME | UPD_NROF, left, inserted);
1856 1586
1857 new_draw_info_format (NDI_UNIQUE, 0, op, "Inserted %s in %s", query_name (inserted), query_name (left)); 1587 new_draw_info_format (NDI_UNIQUE, 0, op, "Inserted %s in %s", query_name (inserted), query_name (left));
1858 1588
1859 return 0; 1589 return 0;
1860 1590

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines