1 | |
1 | |
2 | /* |
2 | /* |
3 | * static char *rcsid_c_wiz_c = |
3 | * static char *rcsid_c_wiz_c = |
4 | * "$Id: c_wiz.C,v 1.8 2006/09/10 13:20:27 root Exp $"; |
4 | * "$Id: c_wiz.C,v 1.9 2006/09/10 14:15:34 root Exp $"; |
5 | */ |
5 | */ |
6 | |
6 | |
7 | /* |
7 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
8 | CrossFire, A Multiplayer game for X-windows |
9 | |
9 | |
… | |
… | |
96 | new_draw_info (NDI_UNIQUE, 0, op, "at different map places."); |
96 | new_draw_info (NDI_UNIQUE, 0, op, "at different map places."); |
97 | new_draw_info (NDI_UNIQUE, 0, op, "use at your own risks."); |
97 | new_draw_info (NDI_UNIQUE, 0, op, "use at your own risks."); |
98 | new_draw_info (NDI_UNIQUE, 0, op, "Very long loop used so server may have to be reset."); |
98 | new_draw_info (NDI_UNIQUE, 0, op, "Very long loop used so server may have to be reset."); |
99 | new_draw_info (NDI_UNIQUE, 0, op, "type loadtest TRUE to run"); |
99 | new_draw_info (NDI_UNIQUE, 0, op, "type loadtest TRUE to run"); |
100 | new_draw_info_format (NDI_UNIQUE, 0, op, "{%s}", params); |
100 | new_draw_info_format (NDI_UNIQUE, 0, op, "{%s}", params); |
|
|
101 | |
101 | if (!params) |
102 | if (!params) |
102 | return 0; |
103 | return 0; |
|
|
104 | |
103 | if (strncmp (params, "TRUE", 4)) |
105 | if (strncmp (params, "TRUE", 4)) |
104 | return 0; |
106 | return 0; |
105 | |
107 | |
106 | new_draw_info_format (NDI_UNIQUE, 0, op, "gogogo"); |
108 | new_draw_info_format (NDI_UNIQUE, 0, op, "gogogo"); |
|
|
109 | |
107 | for (x = 0; x < settings.worldmaptilesx; x++) |
110 | for (x = 0; x < settings.worldmaptilesx; x++) |
108 | { |
111 | { |
109 | for (y = 0; y < settings.worldmaptilesy; y++) |
112 | for (y = 0; y < settings.worldmaptilesy; y++) |
110 | { |
113 | { |
111 | sprintf (buf, "/world/world_%d_%d", x + settings.worldmapstartx, y + settings.worldmapstarty); |
114 | sprintf (buf, "/world/world_%d_%d", x + settings.worldmapstartx, y + settings.worldmapstarty); |
… | |
… | |
164 | static object * |
167 | static object * |
165 | find_object_both (char *params) |
168 | find_object_both (char *params) |
166 | { |
169 | { |
167 | if (!params) |
170 | if (!params) |
168 | return NULL; |
171 | return NULL; |
|
|
172 | |
169 | if (params[0] == '#') |
173 | if (params[0] == '#') |
170 | return find_object (atol (params + 1)); |
174 | return find_object (atol (params + 1)); |
171 | else |
175 | else |
172 | return find_object_name (params); |
176 | return find_object_name (params); |
173 | } |
177 | } |
… | |
… | |
572 | if (params == NULL) |
576 | if (params == NULL) |
573 | { |
577 | { |
574 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: create [nr] [magic] <archetype> [ of <artifact>]" " [variable_to_patch setting]"); |
578 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: create [nr] [magic] <archetype> [ of <artifact>]" " [variable_to_patch setting]"); |
575 | return 1; |
579 | return 1; |
576 | } |
580 | } |
|
|
581 | |
577 | bp = params; |
582 | bp = params; |
578 | |
583 | |
579 | /* We need to know where the line ends */ |
584 | /* We need to know where the line ends */ |
580 | endline = bp + strlen (bp); |
585 | endline = bp + strlen (bp); |
581 | |
586 | |
… | |
… | |
588 | } |
593 | } |
589 | bp++; |
594 | bp++; |
590 | set_nrof = 1; |
595 | set_nrof = 1; |
591 | LOG (llevDebug, "%s creates: (%d) %s\n", &op->name, nrof, bp); |
596 | LOG (llevDebug, "%s creates: (%d) %s\n", &op->name, nrof, bp); |
592 | } |
597 | } |
|
|
598 | |
593 | if (sscanf (bp, "%d ", &magic)) |
599 | if (sscanf (bp, "%d ", &magic)) |
594 | { |
600 | { |
595 | if ((bp = strchr (bp, ' ')) == NULL) |
601 | if ((bp = strchr (bp, ' ')) == NULL) |
596 | { |
602 | { |
597 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: create [nr] [magic] <archetype> [ of <artifact>]" " [variable_to_patch setting]"); |
603 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: create [nr] [magic] <archetype> [ of <artifact>]" " [variable_to_patch setting]"); |
598 | return 1; |
604 | return 1; |
599 | } |
605 | } |
|
|
606 | |
600 | bp++; |
607 | bp++; |
601 | set_magic = 1; |
608 | set_magic = 1; |
602 | LOG (llevDebug, "%s creates: (%d) (%d) %s\n", &op->name, nrof, magic, bp); |
609 | LOG (llevDebug, "%s creates: (%d) (%d) %s\n", &op->name, nrof, magic, bp); |
603 | } |
610 | } |
|
|
611 | |
604 | if ((cp = strstr (bp, " of ")) != NULL) |
612 | if ((cp = strstr (bp, " of ")) != NULL) |
605 | { |
613 | { |
606 | *cp = '\0'; |
614 | *cp = '\0'; |
607 | cp += 4; |
615 | cp += 4; |
608 | } |
616 | } |
|
|
617 | |
609 | for (bp2 = bp; *bp2; bp2++) |
618 | for (bp2 = bp; *bp2; bp2++) |
610 | { |
619 | { |
611 | if (*bp2 == ' ') |
620 | if (*bp2 == ' ') |
612 | { |
621 | { |
613 | *bp2 = '\0'; |
622 | *bp2 = '\0'; |
… | |
… | |
657 | * in this case means its an artifact. |
666 | * in this case means its an artifact. |
658 | */ |
667 | */ |
659 | if (!at_spell) |
668 | if (!at_spell) |
660 | { |
669 | { |
661 | if (find_artifactlist (at->clone.type) == NULL) |
670 | if (find_artifactlist (at->clone.type) == NULL) |
662 | { |
|
|
663 | new_draw_info_format (NDI_UNIQUE, 0, op, "No artifact list for type %d\n", at->clone.type); |
671 | new_draw_info_format (NDI_UNIQUE, 0, op, "No artifact list for type %d\n", at->clone.type); |
664 | } |
|
|
665 | else |
672 | else |
666 | { |
673 | { |
667 | art = find_artifactlist (at->clone.type)->items; |
674 | art = find_artifactlist (at->clone.type)->items; |
668 | |
675 | |
669 | do |
676 | do |
… | |
… | |
671 | if (!strcmp (art->item->name, cp)) |
678 | if (!strcmp (art->item->name, cp)) |
672 | break; |
679 | break; |
673 | art = art->next; |
680 | art = art->next; |
674 | } |
681 | } |
675 | while (art != NULL); |
682 | while (art != NULL); |
|
|
683 | |
676 | if (!art) |
684 | if (!art) |
677 | { |
|
|
678 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such artifact ([%d] of %s)", at->clone.type, cp); |
685 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such artifact ([%d] of %s)", at->clone.type, cp); |
679 | } |
|
|
680 | } |
686 | } |
|
|
687 | |
681 | LOG (llevDebug, "%s creates: (%d) (%d) (%s) of (%s)\n", &op->name, set_nrof ? nrof : 0, set_magic ? magic : 0, bp, cp); |
688 | LOG (llevDebug, "%s creates: (%d) (%d) (%s) of (%s)\n", &op->name, set_nrof ? nrof : 0, set_magic ? magic : 0, bp, cp); |
682 | } |
689 | } |
683 | } /* if cp */ |
690 | } /* if cp */ |
684 | |
691 | |
685 | if ((at->clone.type == ROD || at->clone.type == WAND || at->clone.type == SCROLL || |
692 | if ((at->clone.type == ROD || at->clone.type == WAND || at->clone.type == SCROLL || |
… | |
… | |
693 | * Rather than have two different blocks with a lot of similar code, |
700 | * Rather than have two different blocks with a lot of similar code, |
694 | * just create one object, do all the processing, and then determine |
701 | * just create one object, do all the processing, and then determine |
695 | * if that one object should be inserted or if we need to make copies. |
702 | * if that one object should be inserted or if we need to make copies. |
696 | */ |
703 | */ |
697 | tmp = arch_to_object (at); |
704 | tmp = arch_to_object (at); |
|
|
705 | |
698 | if (settings.real_wiz == FALSE) |
706 | if (settings.real_wiz == FALSE) |
699 | SET_FLAG (tmp, FLAG_WAS_WIZ); |
707 | SET_FLAG (tmp, FLAG_WAS_WIZ); |
|
|
708 | |
700 | if (set_magic) |
709 | if (set_magic) |
701 | set_abs_magic (tmp, magic); |
710 | set_abs_magic (tmp, magic); |
|
|
711 | |
702 | if (art) |
712 | if (art) |
703 | give_artifact_abilities (tmp, art->item); |
713 | give_artifact_abilities (tmp, art->item); |
|
|
714 | |
704 | if (need_identify (tmp)) |
715 | if (need_identify (tmp)) |
705 | { |
716 | { |
706 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
717 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
707 | CLEAR_FLAG (tmp, FLAG_KNOWN_MAGICAL); |
718 | CLEAR_FLAG (tmp, FLAG_KNOWN_MAGICAL); |
708 | } |
719 | } |
… | |
… | |
717 | while (*bp2 && bp2 <= endline) |
728 | while (*bp2 && bp2 <= endline) |
718 | { |
729 | { |
719 | bp4 = NULL; |
730 | bp4 = NULL; |
720 | gotspace = 0; |
731 | gotspace = 0; |
721 | gotquote = 0; |
732 | gotquote = 0; |
|
|
733 | |
722 | /* find the first quote */ |
734 | /* find the first quote */ |
723 | for (bp3 = bp2; *bp3 && gotspace < 2 && gotquote < 2; bp3++) |
735 | for (bp3 = bp2; *bp3 && gotspace < 2 && gotquote < 2; bp3++) |
724 | { |
736 | { |
725 | |
737 | |
726 | /* Found a quote - now lets find the second one */ |
738 | /* Found a quote - now lets find the second one */ |
… | |
… | |
740 | else |
752 | else |
741 | bp3++; |
753 | bp3++; |
742 | } |
754 | } |
743 | } |
755 | } |
744 | else if (*bp3 == ' ') |
756 | else if (*bp3 == ' ') |
745 | { |
|
|
746 | gotspace++; |
757 | gotspace++; |
747 | } |
|
|
748 | } |
758 | } |
749 | |
759 | |
750 | /* |
760 | /* |
751 | * If we got two spaces, send the second one to null. |
761 | * If we got two spaces, send the second one to null. |
752 | * if we've reached the end of the line, increase gotspace - |
762 | * if we've reached the end of the line, increase gotspace - |
… | |
… | |
770 | * anyways. |
780 | * anyways. |
771 | */ |
781 | */ |
772 | new_draw_info_format (NDI_UNIQUE, 0, op, "Malformed create line: %s", bp2); |
782 | new_draw_info_format (NDI_UNIQUE, 0, op, "Malformed create line: %s", bp2); |
773 | break; |
783 | break; |
774 | } |
784 | } |
|
|
785 | |
775 | /* bp2 should still point to the start of this line, |
786 | /* bp2 should still point to the start of this line, |
776 | * with bp3 pointing to the end |
787 | * with bp3 pointing to the end |
777 | */ |
788 | */ |
778 | if (set_variable (tmp, bp2) == -1) |
789 | if (set_variable (tmp, bp2) == -1) |
779 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unknown variable %s", bp2); |
790 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unknown variable %s", bp2); |
780 | else |
791 | else |
781 | new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s", &tmp->name, tmp->count, bp2); |
792 | new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s", &tmp->name, tmp->count, bp2); |
|
|
793 | |
782 | bp2 = bp3 + 1; |
794 | bp2 = bp3 + 1; |
783 | } |
795 | } |
784 | |
796 | |
785 | if (at->clone.nrof) |
797 | if (at->clone.nrof) |
786 | { |
798 | { |
787 | if (at_spell) |
799 | if (at_spell) |
788 | insert_ob_in_ob (arch_to_object (at_spell), tmp); |
800 | insert_ob_in_ob (arch_to_object (at_spell), tmp); |
789 | |
801 | |
790 | tmp->x = op->x; |
802 | tmp->x = op->x; |
791 | tmp->y = op->y; |
803 | tmp->y = op->y; |
|
|
804 | |
792 | if (set_nrof) |
805 | if (set_nrof) |
793 | tmp->nrof = nrof; |
806 | tmp->nrof = nrof; |
|
|
807 | |
794 | tmp->map = op->map; |
808 | tmp->map = op->map; |
795 | |
809 | |
796 | tmp = insert_ob_in_ob (tmp, op); |
810 | tmp = insert_ob_in_ob (tmp, op); |
797 | esrv_send_item (op, tmp); |
811 | esrv_send_item (op, tmp); |
798 | |
812 | |
… | |
… | |
822 | if (head == NULL) |
836 | if (head == NULL) |
823 | { |
837 | { |
824 | head = dup; |
838 | head = dup; |
825 | copy_object (tmp, dup); |
839 | copy_object (tmp, dup); |
826 | } |
840 | } |
|
|
841 | |
827 | if (settings.real_wiz == FALSE) |
842 | if (settings.real_wiz == FALSE) |
828 | SET_FLAG (dup, FLAG_WAS_WIZ); |
843 | SET_FLAG (dup, FLAG_WAS_WIZ); |
|
|
844 | |
829 | dup->x = op->x + dup->arch->clone.x; |
845 | dup->x = op->x + dup->arch->clone.x; |
830 | dup->y = op->y + dup->arch->clone.y; |
846 | dup->y = op->y + dup->arch->clone.y; |
831 | dup->map = op->map; |
847 | dup->map = op->map; |
832 | |
848 | |
833 | if (head != dup) |
849 | if (head != dup) |
834 | { |
850 | { |
835 | dup->head = head; |
851 | dup->head = head; |
836 | prev->more = dup; |
852 | prev->more = dup; |
837 | } |
853 | } |
|
|
854 | |
838 | prev = dup; |
855 | prev = dup; |
839 | } |
856 | } |
840 | |
857 | |
841 | if (QUERY_FLAG (head, FLAG_ALIVE)) |
858 | if (QUERY_FLAG (head, FLAG_ALIVE)) |
842 | { |
859 | { |
… | |
… | |
861 | free_object (tmp); |
878 | free_object (tmp); |
862 | return 1; |
879 | return 1; |
863 | } |
880 | } |
864 | |
881 | |
865 | check = head; |
882 | check = head; |
|
|
883 | |
866 | while (check) |
884 | while (check) |
867 | { |
885 | { |
868 | check->x -= size_x; |
886 | check->x -= size_x; |
869 | check->y -= size_y; |
887 | check->y -= size_y; |
870 | check = check->more; |
888 | check = check->more; |
… | |
… | |
882 | */ |
900 | */ |
883 | dm_stack_push (op->contr, head->count); |
901 | dm_stack_push (op->contr, head->count); |
884 | |
902 | |
885 | if (at->clone.randomitems != NULL && !at_spell) |
903 | if (at->clone.randomitems != NULL && !at_spell) |
886 | create_treasure (at->clone.randomitems, head, GT_APPLY, op->map->difficulty, 0); |
904 | create_treasure (at->clone.randomitems, head, GT_APPLY, op->map->difficulty, 0); |
|
|
905 | |
887 | esrv_send_item (op, head); |
906 | esrv_send_item (op, head); |
888 | } |
907 | } |
889 | |
908 | |
890 | /* free the one we used to copy */ |
909 | /* free the one we used to copy */ |
891 | free_object (tmp); |
910 | free_object (tmp); |