1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_plugins_c = |
|
|
4 | * "$Id: plugins.C,v 1.14 2006/09/14 21:16:12 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /*****************************************************************************/ |
1 | /*****************************************************************************/ |
8 | |
|
|
9 | /* CrossFire, A Multiplayer game for X-windows */ |
2 | /* CrossFire, A Multiplayer game for X-windows */ |
10 | |
|
|
11 | /* */ |
3 | /* */ |
12 | |
|
|
13 | /* Copyright (C) 2000 Mark Wedel */ |
4 | /* Copyright (C) 2000 Mark Wedel */ |
14 | |
|
|
15 | /* Copyright (C) 1992 Frank Tore Johansen */ |
5 | /* Copyright (C) 1992 Frank Tore Johansen */ |
16 | |
|
|
17 | /* */ |
6 | /* */ |
18 | |
|
|
19 | /* This program is free software; you can redistribute it and/or modify */ |
7 | /* This program is free software; you can redistribute it and/or modify */ |
20 | |
|
|
21 | /* it under the terms of the GNU General Public License as published by */ |
8 | /* it under the terms of the GNU General Public License as published by */ |
22 | |
|
|
23 | /* the Free Software Foundation; either version 2 of the License, or */ |
9 | /* the Free Software Foundation; either version 2 of the License, or */ |
24 | |
|
|
25 | /* (at your option) any later version. */ |
10 | /* (at your option) any later version. */ |
26 | |
|
|
27 | /* */ |
11 | /* */ |
28 | |
|
|
29 | /* This program is distributed in the hope that it will be useful, */ |
12 | /* This program is distributed in the hope that it will be useful, */ |
30 | |
|
|
31 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
32 | |
|
|
33 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
34 | |
|
|
35 | /* GNU General Public License for more details. */ |
15 | /* GNU General Public License for more details. */ |
36 | |
|
|
37 | /* */ |
16 | /* */ |
38 | |
|
|
39 | /* You should have received a copy of the GNU General Public License */ |
17 | /* You should have received a copy of the GNU General Public License */ |
40 | |
|
|
41 | /* along with this program; if not, write to the Free Software */ |
18 | /* along with this program; if not, write to the Free Software */ |
42 | |
|
|
43 | /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
19 | /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
44 | |
|
|
45 | /* */ |
20 | /* */ |
46 | |
|
|
47 | /*****************************************************************************/ |
21 | /*****************************************************************************/ |
48 | |
|
|
49 | /* This is the server-side plugin management part. */ |
22 | /* This is the server-side plugin management part. */ |
50 | |
|
|
51 | /*****************************************************************************/ |
23 | /*****************************************************************************/ |
52 | |
|
|
53 | /* Original code by Yann Chachkoff (yann.chachkoff@mailandnews.com). */ |
24 | /* Original code by Yann Chachkoff (yann.chachkoff@mailandnews.com). */ |
54 | |
|
|
55 | /* Special thanks to: */ |
25 | /* Special thanks to: */ |
56 | |
|
|
57 | /* David Delbecq (david.delbecq@mailandnews.com); */ |
26 | /* David Delbecq (david.delbecq@mailandnews.com); */ |
58 | |
|
|
59 | /* Joris Bontje (jbontje@suespammers.org); */ |
27 | /* Joris Bontje (jbontje@suespammers.org); */ |
60 | |
|
|
61 | /* Philip Currlin (?); */ |
28 | /* Philip Currlin (?); */ |
62 | |
|
|
63 | /*****************************************************************************/ |
29 | /*****************************************************************************/ |
64 | |
|
|
65 | /*****************************************************************************/ |
30 | /*****************************************************************************/ |
66 | |
|
|
67 | /* First, the headers. We only include plugin.h, because all other includes */ |
31 | /* First, the headers. We only include plugin.h, because all other includes */ |
68 | |
|
|
69 | /* are done into it, and plugproto.h (which is used only by this file). */ |
32 | /* are done into it, and plugproto.h (which is used only by this file). */ |
70 | |
|
|
71 | /*****************************************************************************/ |
33 | /*****************************************************************************/ |
|
|
34 | |
72 | #include <plugin.h> |
35 | #include <plugin.h> |
73 | |
36 | |
74 | #ifndef __CEXTRACT__ |
37 | #ifndef __CEXTRACT__ |
75 | # include <sproto.h> |
38 | # include <sproto.h> |
76 | #endif |
39 | #endif |
… | |
… | |
79 | |
42 | |
80 | static const hook_entry plug_hooks[NR_OF_HOOKS] = { |
43 | static const hook_entry plug_hooks[NR_OF_HOOKS] = { |
81 | {cfapi_system_register_global_event, 1, "cfapi_system_register_global_event"}, |
44 | {cfapi_system_register_global_event, 1, "cfapi_system_register_global_event"}, |
82 | {cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event"}, |
45 | {cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event"}, |
83 | {cfapi_system_check_path, 4, "cfapi_system_check_path"}, |
46 | {cfapi_system_check_path, 4, "cfapi_system_check_path"}, |
84 | {cfapi_system_re_cmp, 5, "cfapi_system_re_cmp"}, |
47 | {NULL, 5, "cfapi_system_re_cmp"}, |
85 | {cfapi_system_strdup_local, 6, "cfapi_system_strdup_local"}, |
48 | {cfapi_system_strdup, 6, "cfapi_system_strdup"}, |
86 | {cfapi_system_directory, 7, "cfapi_system_directory"}, |
49 | {cfapi_system_directory, 7, "cfapi_system_directory"}, |
87 | {cfapi_system_find_animation, 8, "cfapi_system_find_animation"}, |
50 | {cfapi_system_find_animation, 8, "cfapi_system_find_animation"}, |
88 | {cfapi_object_clean_object, 9, "cfapi_object_clean_object"}, |
51 | {cfapi_object_clean_object, 9, "cfapi_object_clean_object"}, |
89 | {cfapi_object_on_same_map, 10, "cfapi_object_on_same_map"}, |
52 | {cfapi_object_on_same_map, 10, "cfapi_object_on_same_map"}, |
90 | {cfapi_object_get_key, 11, "cfapi_object_get_key"}, |
53 | {cfapi_object_get_key, 11, "cfapi_object_get_key"}, |
… | |
… | |
158 | |
121 | |
159 | /* NEW PLUGIN STUFF STARTS HERE */ |
122 | /* NEW PLUGIN STUFF STARTS HERE */ |
160 | |
123 | |
161 | /*****************************************************************************/ |
124 | /*****************************************************************************/ |
162 | |
125 | |
163 | #ifdef WIN32 |
|
|
164 | static const char * |
|
|
165 | plugins_dlerror (void) |
|
|
166 | { |
|
|
167 | static char buf[256]; |
|
|
168 | DWORD err; |
|
|
169 | char *p; |
|
|
170 | |
|
|
171 | err = GetLastError (); |
|
|
172 | if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, buf, sizeof (buf), NULL) == 0) |
|
|
173 | snprintf (buf, sizeof (buf), "error %lu", err); |
|
|
174 | p = strchr (buf, '\0'); |
|
|
175 | while (p > buf && (p[-1] == '\r' || p[-1] == '\n')) |
|
|
176 | p--; |
|
|
177 | *p = '\0'; |
|
|
178 | return buf; |
|
|
179 | } |
|
|
180 | #endif /* WIN32 */ |
|
|
181 | |
|
|
182 | /** |
126 | /** |
183 | * Notify clients about a changed object. |
127 | * Notify clients about a changed object. |
184 | * |
128 | * |
185 | * @param op the object that has changed |
129 | * @param op the object that has changed |
186 | */ |
130 | */ |
… | |
… | |
188 | send_changed_object (object *op) |
132 | send_changed_object (object *op) |
189 | { |
133 | { |
190 | object *tmp; |
134 | object *tmp; |
191 | player *pl; |
135 | player *pl; |
192 | |
136 | |
193 | if (op->env != NULL) |
137 | if (op->env) |
194 | { |
138 | { |
195 | tmp = is_player_inv (op->env); |
139 | tmp = op->in_player (); |
|
|
140 | |
196 | if (!tmp) |
141 | if (!tmp) |
197 | { |
142 | { |
198 | for (pl = first_player; pl; pl = pl->next) |
143 | for (pl = first_player; pl; pl = pl->next) |
199 | if (pl->ob->container == op->env) |
144 | if (pl->ob->container == op->env) |
200 | break; |
145 | break; |
|
|
146 | |
201 | if (pl) |
147 | if (pl) |
202 | tmp = pl->ob; |
148 | tmp = pl->ob; |
203 | else |
149 | else |
204 | tmp = NULL; |
150 | tmp = NULL; |
205 | } |
151 | } |
|
|
152 | |
206 | if (tmp) |
153 | if (tmp) |
207 | esrv_send_item (tmp, op); |
154 | esrv_send_item (tmp, op); |
208 | } |
155 | } |
209 | else |
156 | else |
210 | { |
157 | { |
… | |
… | |
230 | { |
177 | { |
231 | /* no action necessary: remove_ob() notifies the client */ |
178 | /* no action necessary: remove_ob() notifies the client */ |
232 | return; |
179 | return; |
233 | } |
180 | } |
234 | |
181 | |
235 | tmp = is_player_inv (op->env); |
182 | tmp = op->in_player (); |
236 | if (!tmp) |
183 | if (!tmp) |
237 | { |
184 | { |
238 | for (pl = first_player; pl; pl = pl->next) |
185 | for (pl = first_player; pl; pl = pl->next) |
239 | if (pl->ob->container == op->env) |
186 | if (pl->ob->container == op->env) |
240 | break; |
187 | break; |
… | |
… | |
538 | *type = CFAPI_INT; |
485 | *type = CFAPI_INT; |
539 | return &rv; |
486 | return &rv; |
540 | } |
487 | } |
541 | |
488 | |
542 | void * |
489 | void * |
543 | cfapi_system_strdup_local (int *type, ...) |
490 | cfapi_system_strdup (int *type, ...) |
544 | { |
491 | { |
545 | va_list args; |
492 | va_list args; |
546 | char *txt; |
493 | char *txt; |
547 | |
494 | |
548 | va_start (args, type); |
495 | va_start (args, type); |
549 | txt = va_arg (args, char *); |
496 | txt = va_arg (args, char *); |
550 | |
497 | |
551 | va_end (args); |
498 | va_end (args); |
552 | *type = CFAPI_STRING; |
499 | *type = CFAPI_STRING; |
553 | return strdup_local (txt); |
500 | return strdup (txt); |
554 | } |
501 | } |
555 | |
502 | |
556 | void * |
503 | void * |
557 | cfapi_system_register_global_event (int *type, ...) |
504 | cfapi_system_register_global_event (int *type, ...) |
558 | { |
505 | { |
… | |
… | |
612 | *type = CFAPI_INT; |
559 | *type = CFAPI_INT; |
613 | return &rv; |
560 | return &rv; |
614 | } |
561 | } |
615 | |
562 | |
616 | void * |
563 | void * |
617 | cfapi_system_re_cmp (int *type, ...) |
|
|
618 | { |
|
|
619 | va_list args; |
|
|
620 | char *rv; |
|
|
621 | const char *str; |
|
|
622 | const char *regexp; |
|
|
623 | |
|
|
624 | va_start (args, type); |
|
|
625 | |
|
|
626 | str = va_arg (args, char *); |
|
|
627 | regexp = va_arg (args, char *); |
|
|
628 | |
|
|
629 | rv = (char *) re_cmp (str, regexp); |
|
|
630 | |
|
|
631 | va_end (args); |
|
|
632 | *type = CFAPI_STRING; |
|
|
633 | return rv; |
|
|
634 | } |
|
|
635 | |
|
|
636 | void * |
|
|
637 | cfapi_system_directory (int *type, ...) |
564 | cfapi_system_directory (int *type, ...) |
638 | { |
565 | { |
639 | va_list args; |
566 | va_list args; |
640 | int dirtype; |
567 | int dirtype; |
641 | |
568 | |
… | |
… | |
687 | |
614 | |
688 | void * |
615 | void * |
689 | cfapi_map_get_map (int *type, ...) |
616 | cfapi_map_get_map (int *type, ...) |
690 | { |
617 | { |
691 | va_list args; |
618 | va_list args; |
692 | mapstruct *rv; |
619 | maptile *rv; |
693 | int ctype; |
620 | int ctype; |
694 | int x, y; |
621 | int x, y; |
695 | sint16 nx, ny; |
622 | sint16 nx, ny; |
696 | char *name; |
623 | char *name; |
697 | mapstruct *m; |
624 | maptile *m; |
698 | |
625 | |
699 | va_start (args, type); |
626 | va_start (args, type); |
700 | |
627 | |
701 | ctype = va_arg (args, int); |
628 | ctype = va_arg (args, int); |
702 | |
629 | |
… | |
… | |
715 | |
642 | |
716 | rv = ready_map_name (name, x); |
643 | rv = ready_map_name (name, x); |
717 | break; |
644 | break; |
718 | |
645 | |
719 | case 2: |
646 | case 2: |
720 | m = va_arg (args, mapstruct *); |
647 | m = va_arg (args, maptile *); |
721 | nx = va_arg (args, int); |
648 | nx = va_arg (args, int); |
722 | ny = va_arg (args, int); |
649 | ny = va_arg (args, int); |
723 | |
650 | |
724 | rv = get_map_from_coord (m, &nx, &ny); |
651 | rv = get_map_from_coord (m, &nx, &ny); |
725 | break; |
652 | break; |
… | |
… | |
741 | |
668 | |
742 | void * |
669 | void * |
743 | cfapi_map_has_been_loaded (int *type, ...) |
670 | cfapi_map_has_been_loaded (int *type, ...) |
744 | { |
671 | { |
745 | va_list args; |
672 | va_list args; |
746 | mapstruct *map; |
673 | maptile *map; |
747 | char *string; |
674 | char *string; |
748 | |
675 | |
749 | va_start (args, type); |
676 | va_start (args, type); |
750 | string = va_arg (args, char *); |
677 | string = va_arg (args, char *); |
751 | |
678 | |
… | |
… | |
797 | cfapi_map_get_map_property (int *type, ...) |
724 | cfapi_map_get_map_property (int *type, ...) |
798 | { |
725 | { |
799 | va_list args; |
726 | va_list args; |
800 | int x, y; |
727 | int x, y; |
801 | sint16 nx, ny; |
728 | sint16 nx, ny; |
802 | mapstruct *map; |
729 | maptile *map; |
803 | mapstruct *newmap; |
730 | maptile *newmap; |
804 | static int rv; |
731 | static int rv; |
805 | int property; |
732 | int property; |
806 | char *buf; |
733 | char *buf; |
807 | |
734 | |
808 | va_start (args, type); |
735 | va_start (args, type); |
… | |
… | |
810 | property = va_arg (args, int); |
737 | property = va_arg (args, int); |
811 | |
738 | |
812 | switch (property) |
739 | switch (property) |
813 | { |
740 | { |
814 | case CFAPI_MAP_PROP_FLAGS: |
741 | case CFAPI_MAP_PROP_FLAGS: |
815 | map = va_arg (args, mapstruct *); |
742 | map = va_arg (args, maptile *); |
816 | newmap = va_arg (args, mapstruct *); |
743 | newmap = va_arg (args, maptile *); |
817 | x = va_arg (args, int); |
744 | x = va_arg (args, int); |
818 | y = va_arg (args, int); |
745 | y = va_arg (args, int); |
819 | nx = va_arg (args, int); |
746 | nx = va_arg (args, int); |
820 | ny = va_arg (args, int); |
747 | ny = va_arg (args, int); |
821 | |
748 | |
… | |
… | |
824 | *type = CFAPI_INT; |
751 | *type = CFAPI_INT; |
825 | return &rv; |
752 | return &rv; |
826 | break; |
753 | break; |
827 | |
754 | |
828 | case CFAPI_MAP_PROP_DIFFICULTY: |
755 | case CFAPI_MAP_PROP_DIFFICULTY: |
829 | map = va_arg (args, mapstruct *); |
756 | map = va_arg (args, maptile *); |
830 | |
757 | |
831 | rv = calculate_difficulty (map); |
758 | rv = calculate_difficulty (map); |
832 | va_end (args); |
759 | va_end (args); |
833 | *type = CFAPI_INT; |
760 | *type = CFAPI_INT; |
834 | return &rv; |
761 | return &rv; |
835 | break; |
762 | break; |
836 | |
763 | |
837 | case CFAPI_MAP_PROP_PATH: |
764 | case CFAPI_MAP_PROP_PATH: |
838 | map = va_arg (args, mapstruct *); |
765 | map = va_arg (args, maptile *); |
839 | |
766 | |
840 | buf = map->path; |
767 | buf = map->path; |
841 | *type = CFAPI_STRING; |
768 | *type = CFAPI_STRING; |
842 | va_end (args); |
769 | va_end (args); |
843 | return buf; |
770 | return buf; |
844 | break; |
771 | break; |
845 | |
772 | |
846 | case CFAPI_MAP_PROP_TMPNAME: |
773 | case CFAPI_MAP_PROP_TMPNAME: |
847 | map = va_arg (args, mapstruct *); |
774 | map = va_arg (args, maptile *); |
848 | |
775 | |
849 | buf = map->tmpname; |
776 | buf = map->tmpname; |
850 | *type = CFAPI_STRING; |
777 | *type = CFAPI_STRING; |
851 | va_end (args); |
778 | va_end (args); |
852 | return buf; |
779 | return buf; |
853 | break; |
780 | break; |
854 | |
781 | |
855 | case CFAPI_MAP_PROP_NAME: |
782 | case CFAPI_MAP_PROP_NAME: |
856 | map = va_arg (args, mapstruct *); |
783 | map = va_arg (args, maptile *); |
857 | |
784 | |
858 | buf = map->name; |
785 | buf = map->name; |
859 | *type = CFAPI_STRING; |
786 | *type = CFAPI_STRING; |
860 | va_end (args); |
787 | va_end (args); |
861 | return buf; |
788 | return buf; |
862 | break; |
789 | break; |
863 | |
790 | |
864 | case CFAPI_MAP_PROP_RESET_TIME: |
791 | case CFAPI_MAP_PROP_RESET_TIME: |
865 | map = va_arg (args, mapstruct *); |
792 | map = va_arg (args, maptile *); |
866 | |
793 | |
867 | rv = map->reset_time; |
794 | rv = map->reset_time; |
868 | *type = CFAPI_INT; |
795 | *type = CFAPI_INT; |
869 | va_end (args); |
796 | va_end (args); |
870 | return &rv; |
797 | return &rv; |
871 | break; |
798 | break; |
872 | |
799 | |
873 | case CFAPI_MAP_PROP_RESET_TIMEOUT: |
800 | case CFAPI_MAP_PROP_RESET_TIMEOUT: |
874 | map = va_arg (args, mapstruct *); |
801 | map = va_arg (args, maptile *); |
875 | |
802 | |
876 | rv = map->reset_timeout; |
803 | rv = map->reset_timeout; |
877 | *type = CFAPI_INT; |
804 | *type = CFAPI_INT; |
878 | va_end (args); |
805 | va_end (args); |
879 | return &rv; |
806 | return &rv; |
880 | break; |
807 | break; |
881 | |
808 | |
882 | case CFAPI_MAP_PROP_PLAYERS: |
809 | case CFAPI_MAP_PROP_PLAYERS: |
883 | map = va_arg (args, mapstruct *); |
810 | map = va_arg (args, maptile *); |
884 | |
811 | |
885 | rv = map->players; |
812 | rv = map->players; |
886 | *type = CFAPI_INT; |
813 | *type = CFAPI_INT; |
887 | va_end (args); |
814 | va_end (args); |
888 | return &rv; |
815 | return &rv; |
889 | break; |
816 | break; |
890 | |
817 | |
891 | case CFAPI_MAP_PROP_DARKNESS: |
818 | case CFAPI_MAP_PROP_DARKNESS: |
892 | map = va_arg (args, mapstruct *); |
819 | map = va_arg (args, maptile *); |
893 | |
820 | |
894 | rv = map->darkness; |
821 | rv = map->darkness; |
895 | *type = CFAPI_INT; |
822 | *type = CFAPI_INT; |
896 | va_end (args); |
823 | va_end (args); |
897 | return &rv; |
824 | return &rv; |
898 | break; |
825 | break; |
899 | |
826 | |
900 | case CFAPI_MAP_PROP_WIDTH: |
827 | case CFAPI_MAP_PROP_WIDTH: |
901 | map = va_arg (args, mapstruct *); |
828 | map = va_arg (args, maptile *); |
902 | |
829 | |
903 | rv = map->width; |
830 | rv = map->width; |
904 | *type = CFAPI_INT; |
831 | *type = CFAPI_INT; |
905 | va_end (args); |
832 | va_end (args); |
906 | return &rv; |
833 | return &rv; |
907 | break; |
834 | break; |
908 | |
835 | |
909 | case CFAPI_MAP_PROP_HEIGHT: |
836 | case CFAPI_MAP_PROP_HEIGHT: |
910 | map = va_arg (args, mapstruct *); |
837 | map = va_arg (args, maptile *); |
911 | |
838 | |
912 | rv = map->height; |
839 | rv = map->height; |
913 | *type = CFAPI_INT; |
840 | *type = CFAPI_INT; |
914 | va_end (args); |
841 | va_end (args); |
915 | return &rv; |
842 | return &rv; |
916 | break; |
843 | break; |
917 | |
844 | |
918 | case CFAPI_MAP_PROP_ENTER_X: |
845 | case CFAPI_MAP_PROP_ENTER_X: |
919 | map = va_arg (args, mapstruct *); |
846 | map = va_arg (args, maptile *); |
920 | |
847 | |
921 | rv = map->enter_x; |
848 | rv = map->enter_x; |
922 | *type = CFAPI_INT; |
849 | *type = CFAPI_INT; |
923 | va_end (args); |
850 | va_end (args); |
924 | return &rv; |
851 | return &rv; |
925 | break; |
852 | break; |
926 | |
853 | |
927 | case CFAPI_MAP_PROP_ENTER_Y: |
854 | case CFAPI_MAP_PROP_ENTER_Y: |
928 | map = va_arg (args, mapstruct *); |
855 | map = va_arg (args, maptile *); |
929 | |
856 | |
930 | rv = map->enter_y; |
857 | rv = map->enter_y; |
931 | *type = CFAPI_INT; |
858 | *type = CFAPI_INT; |
932 | va_end (args); |
859 | va_end (args); |
933 | return &rv; |
860 | return &rv; |
934 | break; |
861 | break; |
935 | |
862 | |
936 | case CFAPI_MAP_PROP_TEMPERATURE: |
863 | case CFAPI_MAP_PROP_TEMPERATURE: |
937 | map = va_arg (args, mapstruct *); |
864 | map = va_arg (args, maptile *); |
938 | |
865 | |
939 | rv = map->temp; |
866 | rv = map->temp; |
940 | *type = CFAPI_INT; |
867 | *type = CFAPI_INT; |
941 | va_end (args); |
868 | va_end (args); |
942 | return &rv; |
869 | return &rv; |
943 | break; |
870 | break; |
944 | |
871 | |
945 | case CFAPI_MAP_PROP_PRESSURE: |
872 | case CFAPI_MAP_PROP_PRESSURE: |
946 | map = va_arg (args, mapstruct *); |
873 | map = va_arg (args, maptile *); |
947 | |
874 | |
948 | rv = map->pressure; |
875 | rv = map->pressure; |
949 | *type = CFAPI_INT; |
876 | *type = CFAPI_INT; |
950 | va_end (args); |
877 | va_end (args); |
951 | return &rv; |
878 | return &rv; |
952 | break; |
879 | break; |
953 | |
880 | |
954 | case CFAPI_MAP_PROP_HUMIDITY: |
881 | case CFAPI_MAP_PROP_HUMIDITY: |
955 | map = va_arg (args, mapstruct *); |
882 | map = va_arg (args, maptile *); |
956 | |
883 | |
957 | rv = map->humid; |
884 | rv = map->humid; |
958 | *type = CFAPI_INT; |
885 | *type = CFAPI_INT; |
959 | va_end (args); |
886 | va_end (args); |
960 | return &rv; |
887 | return &rv; |
961 | break; |
888 | break; |
962 | |
889 | |
963 | case CFAPI_MAP_PROP_WINDSPEED: |
890 | case CFAPI_MAP_PROP_WINDSPEED: |
964 | map = va_arg (args, mapstruct *); |
891 | map = va_arg (args, maptile *); |
965 | |
892 | |
966 | rv = map->windspeed; |
893 | rv = map->windspeed; |
967 | *type = CFAPI_INT; |
894 | *type = CFAPI_INT; |
968 | va_end (args); |
895 | va_end (args); |
969 | return &rv; |
896 | return &rv; |
970 | break; |
897 | break; |
971 | |
898 | |
972 | case CFAPI_MAP_PROP_WINDDIR: |
899 | case CFAPI_MAP_PROP_WINDDIR: |
973 | map = va_arg (args, mapstruct *); |
900 | map = va_arg (args, maptile *); |
974 | |
901 | |
975 | rv = map->winddir; |
902 | rv = map->winddir; |
976 | *type = CFAPI_INT; |
903 | *type = CFAPI_INT; |
977 | va_end (args); |
904 | va_end (args); |
978 | return &rv; |
905 | return &rv; |
979 | break; |
906 | break; |
980 | |
907 | |
981 | case CFAPI_MAP_PROP_SKY: |
908 | case CFAPI_MAP_PROP_SKY: |
982 | map = va_arg (args, mapstruct *); |
909 | map = va_arg (args, maptile *); |
983 | |
910 | |
984 | rv = map->sky; |
911 | rv = map->sky; |
985 | *type = CFAPI_INT; |
912 | *type = CFAPI_INT; |
986 | va_end (args); |
913 | va_end (args); |
987 | return &rv; |
914 | return &rv; |
988 | break; |
915 | break; |
989 | |
916 | |
990 | case CFAPI_MAP_PROP_WPARTX: |
917 | case CFAPI_MAP_PROP_WPARTX: |
991 | map = va_arg (args, mapstruct *); |
918 | map = va_arg (args, maptile *); |
992 | |
919 | |
993 | rv = map->wpartx; |
920 | rv = map->wpartx; |
994 | *type = CFAPI_INT; |
921 | *type = CFAPI_INT; |
995 | va_end (args); |
922 | va_end (args); |
996 | return &rv; |
923 | return &rv; |
997 | break; |
924 | break; |
998 | |
925 | |
999 | case CFAPI_MAP_PROP_WPARTY: |
926 | case CFAPI_MAP_PROP_WPARTY: |
1000 | map = va_arg (args, mapstruct *); |
927 | map = va_arg (args, maptile *); |
1001 | |
928 | |
1002 | rv = map->wparty; |
929 | rv = map->wparty; |
1003 | *type = CFAPI_INT; |
930 | *type = CFAPI_INT; |
1004 | va_end (args); |
931 | va_end (args); |
1005 | return &rv; |
932 | return &rv; |
1006 | break; |
933 | break; |
1007 | |
934 | |
1008 | case CFAPI_MAP_PROP_MESSAGE: |
935 | case CFAPI_MAP_PROP_MESSAGE: |
1009 | map = va_arg (args, mapstruct *); |
936 | map = va_arg (args, maptile *); |
1010 | |
937 | |
1011 | buf = map->msg; |
938 | buf = map->msg; |
1012 | *type = CFAPI_STRING; |
939 | *type = CFAPI_STRING; |
1013 | va_end (args); |
940 | va_end (args); |
1014 | return buf; |
941 | return buf; |
1015 | break; |
942 | break; |
1016 | |
943 | |
1017 | case CFAPI_MAP_PROP_NEXT: |
944 | case CFAPI_MAP_PROP_NEXT: |
1018 | map = va_arg (args, mapstruct *); |
945 | map = va_arg (args, maptile *); |
1019 | |
946 | |
1020 | *type = CFAPI_PMAP; |
947 | *type = CFAPI_PMAP; |
1021 | va_end (args); |
948 | va_end (args); |
1022 | return map->next; |
949 | return map->next; |
1023 | break; |
950 | break; |
1024 | |
951 | |
1025 | case CFAPI_MAP_PROP_REGION: |
952 | case CFAPI_MAP_PROP_REGION: |
1026 | map = va_arg (args, mapstruct *); |
953 | map = va_arg (args, maptile *); |
1027 | |
954 | |
1028 | *type = CFAPI_PREGION; |
955 | *type = CFAPI_PREGION; |
1029 | va_end (args); |
956 | va_end (args); |
1030 | return get_region_by_map (map); |
957 | return get_region_by_map (map); |
1031 | break; |
958 | break; |
… | |
… | |
1041 | void * |
968 | void * |
1042 | cfapi_map_set_map_property (int *type, ...) |
969 | cfapi_map_set_map_property (int *type, ...) |
1043 | { |
970 | { |
1044 | va_list args; |
971 | va_list args; |
1045 | static int rv; |
972 | static int rv; |
1046 | mapstruct *map; |
973 | maptile *map; |
1047 | int val; |
974 | int val; |
1048 | int property; |
975 | int property; |
1049 | |
976 | |
1050 | va_start (args, type); |
977 | va_start (args, type); |
1051 | |
978 | |
1052 | property = va_arg (args, int); |
979 | property = va_arg (args, int); |
1053 | |
980 | |
1054 | switch (property) |
981 | switch (property) |
1055 | { |
982 | { |
1056 | case CFAPI_MAP_PROP_LIGHT: |
983 | case CFAPI_MAP_PROP_LIGHT: |
1057 | map = va_arg (args, mapstruct *); |
984 | map = va_arg (args, maptile *); |
1058 | val = va_arg (args, int); |
985 | val = va_arg (args, int); |
1059 | |
986 | |
1060 | rv = change_map_light (map, val); |
987 | rv = change_map_light (map, val); |
1061 | *type = CFAPI_INT; |
988 | *type = CFAPI_INT; |
1062 | va_end (args); |
989 | va_end (args); |
1063 | return &rv; |
990 | return &rv; |
1064 | break; |
991 | break; |
1065 | |
992 | |
1066 | case CFAPI_MAP_PROP_RESET_TIME: |
993 | case CFAPI_MAP_PROP_RESET_TIME: |
1067 | map = va_arg (args, mapstruct *); |
994 | map = va_arg (args, maptile *); |
1068 | |
995 | |
1069 | *type = CFAPI_NONE; |
996 | *type = CFAPI_NONE; |
1070 | va_end (args); |
997 | va_end (args); |
1071 | return NULL; |
998 | return NULL; |
1072 | break; |
999 | break; |
… | |
… | |
1081 | void * |
1008 | void * |
1082 | cfapi_map_out_of_map (int *type, ...) |
1009 | cfapi_map_out_of_map (int *type, ...) |
1083 | { |
1010 | { |
1084 | va_list args; |
1011 | va_list args; |
1085 | static int rv; |
1012 | static int rv; |
1086 | mapstruct *map; |
1013 | maptile *map; |
1087 | int x, y; |
1014 | int x, y; |
1088 | |
1015 | |
1089 | va_start (args, type); |
1016 | va_start (args, type); |
1090 | map = va_arg (args, mapstruct *); |
1017 | map = va_arg (args, maptile *); |
1091 | x = va_arg (args, int); |
1018 | x = va_arg (args, int); |
1092 | y = va_arg (args, int); |
1019 | y = va_arg (args, int); |
1093 | |
1020 | |
1094 | rv = out_of_map (map, x, y); |
1021 | rv = out_of_map (map, x, y); |
1095 | va_end (args); |
1022 | va_end (args); |
… | |
… | |
1099 | |
1026 | |
1100 | void * |
1027 | void * |
1101 | cfapi_map_update_position (int *type, ...) |
1028 | cfapi_map_update_position (int *type, ...) |
1102 | { |
1029 | { |
1103 | va_list args; |
1030 | va_list args; |
1104 | mapstruct *map; |
1031 | maptile *map; |
1105 | int x, y; |
1032 | int x, y; |
1106 | |
1033 | |
1107 | va_start (args, type); |
1034 | va_start (args, type); |
1108 | |
1035 | |
1109 | map = va_arg (args, mapstruct *); |
1036 | map = va_arg (args, maptile *); |
1110 | x = va_arg (args, int); |
1037 | x = va_arg (args, int); |
1111 | y = va_arg (args, int); |
1038 | y = va_arg (args, int); |
1112 | |
1039 | |
1113 | update_position (map, x, y); |
1040 | map->at (x, y).flags_ |= P_NEED_UPDATE; |
|
|
1041 | |
1114 | va_end (args); |
1042 | va_end (args); |
1115 | *type = CFAPI_NONE; |
1043 | *type = CFAPI_NONE; |
1116 | return NULL; |
1044 | return NULL; |
1117 | } |
1045 | } |
1118 | |
1046 | |
1119 | void * |
1047 | void * |
1120 | cfapi_map_delete_map (int *type, ...) |
1048 | cfapi_map_delete_map (int *type, ...) |
1121 | { |
1049 | { |
1122 | va_list args; |
1050 | va_list args; |
1123 | mapstruct *map; |
1051 | maptile *map; |
1124 | |
1052 | |
1125 | va_start (args, type); |
1053 | va_start (args, type); |
1126 | |
1054 | |
1127 | map = va_arg (args, mapstruct *); |
1055 | map = va_arg (args, maptile *); |
1128 | |
1056 | |
1129 | delete_map (map); |
1057 | delete_map (map); |
1130 | |
1058 | |
1131 | va_end (args); |
1059 | va_end (args); |
1132 | *type = CFAPI_NONE; |
1060 | *type = CFAPI_NONE; |
… | |
… | |
1135 | |
1063 | |
1136 | void * |
1064 | void * |
1137 | cfapi_map_message (int *type, ...) |
1065 | cfapi_map_message (int *type, ...) |
1138 | { |
1066 | { |
1139 | va_list args; |
1067 | va_list args; |
1140 | mapstruct *map; |
1068 | maptile *map; |
1141 | char *string; |
1069 | char *string; |
1142 | int color; |
1070 | int color; |
1143 | |
1071 | |
1144 | va_start (args, type); |
1072 | va_start (args, type); |
1145 | map = va_arg (args, mapstruct *); |
1073 | map = va_arg (args, maptile *); |
1146 | string = va_arg (args, char *); |
1074 | string = va_arg (args, char *); |
1147 | color = va_arg (args, int); |
1075 | color = va_arg (args, int); |
1148 | |
1076 | |
1149 | va_end (args); |
1077 | va_end (args); |
1150 | |
1078 | |
… | |
… | |
1155 | |
1083 | |
1156 | void * |
1084 | void * |
1157 | cfapi_map_get_object_at (int *type, ...) |
1085 | cfapi_map_get_object_at (int *type, ...) |
1158 | { |
1086 | { |
1159 | va_list args; |
1087 | va_list args; |
1160 | mapstruct *map; |
1088 | maptile *map; |
1161 | int x, y; |
1089 | int x, y; |
1162 | object *rv; |
1090 | object *rv; |
1163 | |
1091 | |
1164 | va_start (args, type); |
1092 | va_start (args, type); |
1165 | map = va_arg (args, mapstruct *); |
1093 | map = va_arg (args, maptile *); |
1166 | x = va_arg (args, int); |
1094 | x = va_arg (args, int); |
1167 | y = va_arg (args, int); |
1095 | y = va_arg (args, int); |
1168 | |
1096 | |
1169 | va_end (args); |
1097 | va_end (args); |
1170 | |
1098 | |
1171 | rv = get_map_ob (map, x, y); |
1099 | rv = GET_MAP_OB (map, x, y); |
1172 | *type = CFAPI_POBJECT; |
1100 | *type = CFAPI_POBJECT; |
1173 | return rv; |
1101 | return rv; |
1174 | } |
1102 | } |
1175 | |
1103 | |
1176 | void * |
1104 | void * |
1177 | cfapi_map_get_flags (int *type, ...) |
1105 | cfapi_map_get_flags (int *type, ...) |
1178 | { |
1106 | { |
1179 | va_list args; |
1107 | va_list args; |
1180 | sint16 x, y; |
1108 | sint16 x, y; |
1181 | sint16 *nx, *ny; |
1109 | sint16 *nx, *ny; |
1182 | static mapstruct *map; |
1110 | static maptile *map; |
1183 | mapstruct **newmap; |
1111 | maptile **newmap; |
1184 | static int rv; |
1112 | static int rv; |
1185 | |
1113 | |
1186 | va_start (args, type); |
1114 | va_start (args, type); |
1187 | |
1115 | |
1188 | map = va_arg (args, mapstruct *); |
1116 | map = va_arg (args, maptile *); |
1189 | newmap = va_arg (args, mapstruct **); |
1117 | newmap = va_arg (args, maptile **); |
1190 | x = va_arg (args, int); |
1118 | x = va_arg (args, int); |
1191 | y = va_arg (args, int); |
1119 | y = va_arg (args, int); |
1192 | |
1120 | |
1193 | nx = va_arg (args, sint16 *); |
1121 | nx = va_arg (args, sint16 *); |
1194 | ny = va_arg (args, sint16 *); |
1122 | ny = va_arg (args, sint16 *); |
… | |
… | |
1204 | cfapi_map_present_arch_by_name (int *type, ...) |
1132 | cfapi_map_present_arch_by_name (int *type, ...) |
1205 | { |
1133 | { |
1206 | va_list args; |
1134 | va_list args; |
1207 | object *rv; |
1135 | object *rv; |
1208 | int x, y; |
1136 | int x, y; |
1209 | mapstruct *map; |
1137 | maptile *map; |
1210 | char *msg; |
1138 | char *msg; |
1211 | |
1139 | |
1212 | va_start (args, type); |
1140 | va_start (args, type); |
1213 | |
1141 | |
1214 | msg = va_arg (args, char *); |
1142 | msg = va_arg (args, char *); |
1215 | map = va_arg (args, mapstruct *); |
1143 | map = va_arg (args, maptile *); |
1216 | x = va_arg (args, int); |
1144 | x = va_arg (args, int); |
1217 | y = va_arg (args, int); |
1145 | y = va_arg (args, int); |
1218 | |
1146 | |
1219 | va_end (args); |
1147 | va_end (args); |
1220 | |
1148 | |
… | |
… | |
1713 | rv = &op->stats.exp; |
1641 | rv = &op->stats.exp; |
1714 | *type = CFAPI_LONG; |
1642 | *type = CFAPI_LONG; |
1715 | break; |
1643 | break; |
1716 | |
1644 | |
1717 | case CFAPI_OBJECT_PROP_OWNER: |
1645 | case CFAPI_OBJECT_PROP_OWNER: |
1718 | rv = get_owner (op); |
1646 | rv = op->owner; |
1719 | *type = CFAPI_POBJECT; |
1647 | *type = CFAPI_POBJECT; |
1720 | break; |
1648 | break; |
1721 | |
1649 | |
1722 | case CFAPI_OBJECT_PROP_PRESENT: |
1650 | case CFAPI_OBJECT_PROP_PRESENT: |
1723 | { |
1651 | { |
… | |
… | |
1765 | case CFAPI_OBJECT_PROP_MERGEABLE: |
1693 | case CFAPI_OBJECT_PROP_MERGEABLE: |
1766 | { |
1694 | { |
1767 | object *op2; |
1695 | object *op2; |
1768 | op2 = va_arg (args, object *); |
1696 | op2 = va_arg (args, object *); |
1769 | |
1697 | |
1770 | ri = CAN_MERGE (op, op2); |
1698 | ri = object::can_merge_slow (op, op2); |
1771 | rv = &ri; |
1699 | rv = &ri; |
1772 | } |
1700 | } |
1773 | *type = CFAPI_INT; |
1701 | *type = CFAPI_INT; |
1774 | break; |
1702 | break; |
1775 | |
1703 | |
… | |
… | |
1922 | rv = &ri; |
1850 | rv = &ri; |
1923 | *type = CFAPI_INT; |
1851 | *type = CFAPI_INT; |
1924 | break; |
1852 | break; |
1925 | |
1853 | |
1926 | case CFAPI_PLAYER_PROP_IP: |
1854 | case CFAPI_PLAYER_PROP_IP: |
1927 | rv = op->contr->socket.host; |
1855 | rv = op->contr->ns->host; |
1928 | *type = CFAPI_STRING; |
1856 | *type = CFAPI_STRING; |
1929 | break; |
1857 | break; |
1930 | |
1858 | |
1931 | case CFAPI_PLAYER_PROP_MARKED_ITEM: |
1859 | case CFAPI_PLAYER_PROP_MARKED_ITEM: |
1932 | rv = find_marked_object (op); |
1860 | rv = find_marked_object (op); |
… | |
… | |
2047 | player *pl; |
1975 | player *pl; |
2048 | |
1976 | |
2049 | op->nrof = iarg; |
1977 | op->nrof = iarg; |
2050 | if (op->env != NULL) |
1978 | if (op->env != NULL) |
2051 | { |
1979 | { |
2052 | tmp = is_player_inv (op->env); |
1980 | tmp = op->in_player (); |
2053 | if (!tmp) |
1981 | if (!tmp) |
2054 | { |
1982 | { |
2055 | for (pl = first_player; pl; pl = pl->next) |
1983 | for (pl = first_player; pl; pl = pl->next) |
2056 | if (pl->ob->container == op->env) |
1984 | if (pl->ob->container == op->env) |
2057 | break; |
1985 | break; |
… | |
… | |
2208 | player *pl; |
2136 | player *pl; |
2209 | |
2137 | |
2210 | op->weight = iarg; |
2138 | op->weight = iarg; |
2211 | if (op->env != NULL) |
2139 | if (op->env != NULL) |
2212 | { |
2140 | { |
2213 | tmp = is_player_inv (op->env); |
2141 | tmp = op->in_player (); |
2214 | if (!tmp) |
2142 | if (!tmp) |
2215 | { |
2143 | { |
2216 | for (pl = first_player; pl; pl = pl->next) |
2144 | for (pl = first_player; pl; pl = pl->next) |
2217 | if (pl->ob->container == op->env) |
2145 | if (pl->ob->container == op->env) |
2218 | break; |
2146 | break; |
… | |
… | |
2347 | break; |
2275 | break; |
2348 | |
2276 | |
2349 | case CFAPI_OBJECT_PROP_OWNER: |
2277 | case CFAPI_OBJECT_PROP_OWNER: |
2350 | oparg = va_arg (args, object *); |
2278 | oparg = va_arg (args, object *); |
2351 | |
2279 | |
2352 | set_owner (op, oparg); |
2280 | op->set_owner (oparg); |
2353 | break; |
2281 | break; |
2354 | |
2282 | |
2355 | case CFAPI_OBJECT_PROP_CHEATER: |
2283 | case CFAPI_OBJECT_PROP_CHEATER: |
2356 | set_cheat (op); |
2284 | set_cheat (op); |
2357 | break; |
2285 | break; |
… | |
… | |
2492 | if (op->contr) |
2420 | if (op->contr) |
2493 | { |
2421 | { |
2494 | oparg = va_arg (args, object *); |
2422 | oparg = va_arg (args, object *); |
2495 | |
2423 | |
2496 | op->contr->mark = oparg; |
2424 | op->contr->mark = oparg; |
2497 | if (oparg) |
|
|
2498 | op->contr->mark_count = oparg->count; |
|
|
2499 | } |
2425 | } |
2500 | break; |
2426 | break; |
2501 | |
2427 | |
2502 | case CFAPI_PLAYER_PROP_PARTY: |
2428 | case CFAPI_PLAYER_PROP_PARTY: |
2503 | if (op->contr) |
2429 | if (op->contr) |
… | |
… | |
2682 | op = va_arg (args, object *); |
2608 | op = va_arg (args, object *); |
2683 | |
2609 | |
2684 | va_end (args); |
2610 | va_end (args); |
2685 | |
2611 | |
2686 | send_removed_object (op); |
2612 | send_removed_object (op); |
2687 | remove_ob (op); |
2613 | op->remove (); |
2688 | *type = CFAPI_NONE; |
2614 | *type = CFAPI_NONE; |
2689 | return NULL; |
2615 | return NULL; |
2690 | } |
2616 | } |
2691 | |
2617 | |
2692 | void * |
2618 | void * |
… | |
… | |
2699 | |
2625 | |
2700 | op = va_arg (args, object *); |
2626 | op = va_arg (args, object *); |
2701 | |
2627 | |
2702 | va_end (args); |
2628 | va_end (args); |
2703 | |
2629 | |
2704 | free_object (op); |
2630 | op->destroy (); |
2705 | |
2631 | |
2706 | *type = CFAPI_NONE; |
2632 | *type = CFAPI_NONE; |
2707 | return NULL; |
2633 | return NULL; |
2708 | } |
2634 | } |
2709 | |
2635 | |
… | |
… | |
2726 | *type = CFAPI_POBJECT; |
2652 | *type = CFAPI_POBJECT; |
2727 | return object_create_clone (op); |
2653 | return object_create_clone (op); |
2728 | } |
2654 | } |
2729 | else |
2655 | else |
2730 | { |
2656 | { |
2731 | object *tmp; |
2657 | object *tmp = op->clone (); |
2732 | |
|
|
2733 | tmp = get_object (); |
|
|
2734 | copy_object (op, tmp); |
|
|
2735 | *type = CFAPI_POBJECT; |
2658 | *type = CFAPI_POBJECT; |
2736 | return tmp; |
2659 | return tmp; |
2737 | } |
2660 | } |
2738 | } |
2661 | } |
2739 | void * |
2662 | void * |
… | |
… | |
2775 | break; |
2698 | break; |
2776 | |
2699 | |
2777 | case 3: |
2700 | case 3: |
2778 | op = va_arg (args, object *); |
2701 | op = va_arg (args, object *); |
2779 | |
2702 | |
2780 | rv = is_player_inv (op); |
2703 | rv = op->in_player (); |
2781 | break; |
2704 | break; |
2782 | |
2705 | |
2783 | default: |
2706 | default: |
2784 | rv = NULL; |
2707 | rv = NULL; |
2785 | *type = CFAPI_NONE; |
2708 | *type = CFAPI_NONE; |
… | |
… | |
2803 | *type = CFAPI_POBJECT; |
2726 | *type = CFAPI_POBJECT; |
2804 | switch (ival) |
2727 | switch (ival) |
2805 | { |
2728 | { |
2806 | case 0: |
2729 | case 0: |
2807 | va_end (args); |
2730 | va_end (args); |
2808 | return get_object (); |
2731 | return object::create (); |
2809 | break; |
2732 | break; |
2810 | |
2733 | |
2811 | case 1: /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */ |
2734 | case 1: /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */ |
2812 | { |
2735 | { |
2813 | char *sval; |
2736 | char *sval; |
… | |
… | |
2816 | |
2739 | |
2817 | op = get_archetype_by_object_name (sval); |
2740 | op = get_archetype_by_object_name (sval); |
2818 | |
2741 | |
2819 | if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) |
2742 | if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) |
2820 | { |
2743 | { |
2821 | free_object (op); |
2744 | op->destroy (); |
2822 | /* Try with archetype names... */ |
2745 | /* Try with archetype names... */ |
2823 | op = get_archetype (sval); |
2746 | op = get_archetype (sval); |
2824 | if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) |
2747 | if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) |
2825 | { |
2748 | { |
2826 | free_object (op); |
2749 | op->destroy (); |
2827 | *type = CFAPI_NONE; |
2750 | *type = CFAPI_NONE; |
2828 | va_end (args); |
2751 | va_end (args); |
2829 | return NULL; |
2752 | return NULL; |
2830 | } |
2753 | } |
2831 | } |
2754 | } |
… | |
… | |
2845 | cfapi_object_insert (int *type, ...) |
2768 | cfapi_object_insert (int *type, ...) |
2846 | { |
2769 | { |
2847 | va_list args; |
2770 | va_list args; |
2848 | object *op; |
2771 | object *op; |
2849 | object *orig; |
2772 | object *orig; |
2850 | mapstruct *map; |
2773 | maptile *map; |
2851 | int flag, x, y; |
2774 | int flag, x, y; |
2852 | int itype; |
2775 | int itype; |
2853 | char *arch_string; |
2776 | char *arch_string; |
2854 | void *rv = NULL; |
2777 | void *rv = NULL; |
2855 | |
2778 | |
… | |
… | |
2859 | itype = va_arg (args, int); |
2782 | itype = va_arg (args, int); |
2860 | |
2783 | |
2861 | switch (itype) |
2784 | switch (itype) |
2862 | { |
2785 | { |
2863 | case 0: |
2786 | case 0: |
2864 | map = va_arg (args, mapstruct *); |
2787 | map = va_arg (args, maptile *); |
2865 | orig = va_arg (args, object *); |
2788 | orig = va_arg (args, object *); |
2866 | flag = va_arg (args, int); |
2789 | flag = va_arg (args, int); |
2867 | x = va_arg (args, int); |
2790 | x = va_arg (args, int); |
2868 | y = va_arg (args, int); |
2791 | y = va_arg (args, int); |
2869 | |
2792 | |
2870 | rv = insert_ob_in_map_at (op, map, orig, flag, x, y); |
2793 | rv = insert_ob_in_map_at (op, map, orig, flag, x, y); |
2871 | *type = CFAPI_POBJECT; |
2794 | *type = CFAPI_POBJECT; |
2872 | break; |
2795 | break; |
2873 | |
2796 | |
2874 | case 1: |
2797 | case 1: |
2875 | map = va_arg (args, mapstruct *); |
2798 | map = va_arg (args, maptile *); |
2876 | orig = va_arg (args, object *); |
2799 | orig = va_arg (args, object *); |
2877 | flag = va_arg (args, int); |
2800 | flag = va_arg (args, int); |
2878 | |
2801 | |
2879 | rv = insert_ob_in_map (op, map, orig, flag); |
2802 | rv = insert_ob_in_map (op, map, orig, flag); |
2880 | *type = CFAPI_POBJECT; |
2803 | *type = CFAPI_POBJECT; |
… | |
… | |
2990 | |
2913 | |
2991 | op = va_arg (args, object *); |
2914 | op = va_arg (args, object *); |
2992 | |
2915 | |
2993 | va_end (args); |
2916 | va_end (args); |
2994 | |
2917 | |
2995 | clear_object (op); |
2918 | op->clear (); |
2996 | *type = CFAPI_NONE; |
2919 | *type = CFAPI_NONE; |
2997 | return NULL; |
2920 | return NULL; |
2998 | } |
2921 | } |
2999 | |
2922 | |
3000 | void * |
2923 | void * |
… | |
… | |
3266 | object *op; |
3189 | object *op; |
3267 | object *originator; |
3190 | object *originator; |
3268 | int x, y, randompos, ttype; |
3191 | int x, y, randompos, ttype; |
3269 | va_list args; |
3192 | va_list args; |
3270 | static int rv = 0; |
3193 | static int rv = 0; |
3271 | mapstruct *map; |
3194 | maptile *map; |
3272 | |
3195 | |
3273 | va_start (args, type); |
3196 | va_start (args, type); |
3274 | op = va_arg (args, object *); |
3197 | op = va_arg (args, object *); |
3275 | ttype = va_arg (args, int); |
3198 | ttype = va_arg (args, int); |
3276 | |
3199 | |
… | |
… | |
3290 | break; |
3213 | break; |
3291 | |
3214 | |
3292 | case 1: |
3215 | case 1: |
3293 | x = va_arg (args, int); |
3216 | x = va_arg (args, int); |
3294 | y = va_arg (args, int); |
3217 | y = va_arg (args, int); |
3295 | map = va_arg (args, mapstruct *); |
3218 | map = va_arg (args, maptile *); |
3296 | |
3219 | |
3297 | va_end (args); |
3220 | va_end (args); |
3298 | if (x < 0 || y < 0) |
3221 | if (x < 0 || y < 0) |
3299 | { |
3222 | { |
3300 | x = map->enter_x; |
3223 | x = map->enter_x; |
3301 | y = map->enter_y; |
3224 | y = map->enter_y; |
3302 | } |
3225 | } |
3303 | |
3226 | |
3304 | /* |
3227 | /* |
3305 | originator = get_object(); |
3228 | originator = object::create(); |
3306 | EXIT_PATH(originator) = add_string(map->path); |
3229 | EXIT_PATH(originator) = add_string(map->path); |
3307 | EXIT_X(originator) = x; |
3230 | EXIT_X(originator) = x; |
3308 | EXIT_Y(originator) = y; |
3231 | EXIT_Y(originator) = y; |
3309 | printf("B Transfer: X=%d, Y=%d, OP=%s\n", x, y, op->name);*/ |
3232 | printf("B Transfer: X=%d, Y=%d, OP=%s\n", x, y, op->name);*/ |
3310 | /*enter_exit(op, originator); */ |
3233 | /*enter_exit(op, originator); */ |
3311 | insert_ob_in_map_at (op, map, NULL, 0, x, y); |
3234 | insert_ob_in_map_at (op, map, NULL, 0, x, y); |
3312 | /*printf("A Transfer: X=%d, Y=%d, MAP=%s\n", x, y, op->map->name); |
3235 | /*printf("A Transfer: X=%d, Y=%d, MAP=%s\n", x, y, op->map->name); |
3313 | free_object(originator); |
3236 | originator->destroy (); |
3314 | */ |
3237 | */ |
3315 | *type = CFAPI_INT; |
3238 | *type = CFAPI_INT; |
3316 | return &rv; |
3239 | return &rv; |
3317 | break; |
3240 | break; |
3318 | |
3241 | |
… | |
… | |
3391 | drop (author, op); |
3314 | drop (author, op); |
3392 | |
3315 | |
3393 | if (author->type == PLAYER) |
3316 | if (author->type == PLAYER) |
3394 | { |
3317 | { |
3395 | author->contr->count = 0; |
3318 | author->contr->count = 0; |
3396 | author->contr->socket.update_look = 1; |
3319 | author->contr->ns->floorbox_update (); |
3397 | } |
3320 | } |
3398 | |
3321 | |
3399 | *type = CFAPI_NONE; |
3322 | *type = CFAPI_NONE; |
3400 | return NULL; |
3323 | return NULL; |
3401 | } |
3324 | } |
… | |
… | |
3482 | } |
3405 | } |
3483 | |
3406 | |
3484 | void * |
3407 | void * |
3485 | cfapi_object_teleport (int *type, ...) |
3408 | cfapi_object_teleport (int *type, ...) |
3486 | { |
3409 | { |
3487 | mapstruct *map; |
3410 | maptile *map; |
3488 | int x, y; |
3411 | int x, y; |
3489 | object *who; |
3412 | object *who; |
3490 | static int result; |
3413 | static int result; |
3491 | va_list args; |
3414 | va_list args; |
3492 | |
3415 | |
3493 | va_start (args, type); |
3416 | va_start (args, type); |
3494 | who = va_arg (args, object *); |
3417 | who = va_arg (args, object *); |
3495 | map = va_arg (args, mapstruct *); |
3418 | map = va_arg (args, maptile *); |
3496 | x = va_arg (args, int); |
3419 | x = va_arg (args, int); |
3497 | y = va_arg (args, int); |
3420 | y = va_arg (args, int); |
3498 | |
3421 | |
3499 | if (!out_of_map (map, x, y)) |
3422 | if (!out_of_map (map, x, y)) |
3500 | { |
3423 | { |
… | |
… | |
3507 | result = 1; |
3430 | result = 1; |
3508 | return &result; |
3431 | return &result; |
3509 | } |
3432 | } |
3510 | |
3433 | |
3511 | send_removed_object (who); |
3434 | send_removed_object (who); |
3512 | remove_ob (who); |
3435 | who->remove (); |
3513 | |
3436 | |
3514 | for (tmp = who; tmp != NULL; tmp = tmp->more) |
3437 | for (tmp = who; tmp != NULL; tmp = tmp->more) |
3515 | tmp->x = x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x), |
3438 | tmp->x = x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x), |
3516 | tmp->y = y + freearr_y[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y); |
3439 | tmp->y = y + freearr_y[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y); |
3517 | |
3440 | |