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 | */ |
187 | static void |
131 | static void |
188 | send_changed_object (object *op) |
132 | send_changed_object (object *op) |
189 | { |
133 | { |
190 | object *tmp; |
134 | object *tmp; |
191 | player *pl; |
|
|
192 | |
135 | |
193 | if (op->env != NULL) |
136 | if (op->env) |
194 | { |
137 | { |
195 | tmp = is_player_inv (op->env); |
138 | tmp = op->in_player (); |
|
|
139 | |
196 | if (!tmp) |
140 | if (!tmp) |
197 | { |
141 | { |
198 | for (pl = first_player; pl; pl = pl->next) |
142 | for_all_players (pl) |
199 | if (pl->ob->container == op->env) |
143 | if (pl->ob->container == op->env) |
|
|
144 | { |
|
|
145 | tmp = pl->ob; |
200 | break; |
146 | break; |
201 | if (pl) |
147 | } |
202 | tmp = pl->ob; |
|
|
203 | else |
|
|
204 | tmp = NULL; |
|
|
205 | } |
148 | } |
|
|
149 | |
206 | if (tmp) |
150 | if (tmp) |
207 | esrv_send_item (tmp, op); |
151 | esrv_send_item (tmp, op); |
208 | } |
152 | } |
209 | else |
153 | else |
210 | { |
154 | { |
… | |
… | |
222 | */ |
166 | */ |
223 | static void |
167 | static void |
224 | send_removed_object (object *op) |
168 | send_removed_object (object *op) |
225 | { |
169 | { |
226 | object *tmp; |
170 | object *tmp; |
227 | player *pl; |
|
|
228 | |
171 | |
229 | if (op->env == NULL) |
172 | if (op->env == NULL) |
230 | { |
173 | { |
231 | /* no action necessary: remove_ob() notifies the client */ |
174 | /* no action necessary: remove_ob() notifies the client */ |
232 | return; |
175 | return; |
233 | } |
176 | } |
234 | |
177 | |
235 | tmp = is_player_inv (op->env); |
178 | tmp = op->in_player (); |
236 | if (!tmp) |
179 | if (!tmp) |
237 | { |
180 | { |
238 | for (pl = first_player; pl; pl = pl->next) |
181 | for_all_players (pl) |
239 | if (pl->ob->container == op->env) |
182 | if (pl->ob->container == op->env) |
|
|
183 | { |
|
|
184 | tmp = pl->ob; |
240 | break; |
185 | break; |
241 | if (pl) |
186 | } |
242 | tmp = pl->ob; |
|
|
243 | else |
|
|
244 | tmp = NULL; |
|
|
245 | } |
187 | } |
|
|
188 | |
246 | if (tmp) |
189 | if (tmp) |
247 | esrv_del_item (tmp->contr, op->count); |
190 | esrv_del_item (tmp->contr, op->count); |
248 | } |
191 | } |
249 | |
192 | |
250 | extern "C" int cfperl_initPlugin (const char *iversion, f_plug_api gethooksptr); |
193 | extern "C" int cfperl_initPlugin (const char *iversion, f_plug_api gethooksptr); |
… | |
… | |
538 | *type = CFAPI_INT; |
481 | *type = CFAPI_INT; |
539 | return &rv; |
482 | return &rv; |
540 | } |
483 | } |
541 | |
484 | |
542 | void * |
485 | void * |
543 | cfapi_system_strdup_local (int *type, ...) |
486 | cfapi_system_strdup (int *type, ...) |
544 | { |
487 | { |
545 | va_list args; |
488 | va_list args; |
546 | char *txt; |
489 | char *txt; |
547 | |
490 | |
548 | va_start (args, type); |
491 | va_start (args, type); |
549 | txt = va_arg (args, char *); |
492 | txt = va_arg (args, char *); |
550 | |
493 | |
551 | va_end (args); |
494 | va_end (args); |
552 | *type = CFAPI_STRING; |
495 | *type = CFAPI_STRING; |
553 | return strdup_local (txt); |
496 | return strdup (txt); |
554 | } |
497 | } |
555 | |
498 | |
556 | void * |
499 | void * |
557 | cfapi_system_register_global_event (int *type, ...) |
500 | cfapi_system_register_global_event (int *type, ...) |
558 | { |
501 | { |
… | |
… | |
612 | *type = CFAPI_INT; |
555 | *type = CFAPI_INT; |
613 | return &rv; |
556 | return &rv; |
614 | } |
557 | } |
615 | |
558 | |
616 | void * |
559 | 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, ...) |
560 | cfapi_system_directory (int *type, ...) |
638 | { |
561 | { |
639 | va_list args; |
562 | va_list args; |
640 | int dirtype; |
563 | int dirtype; |
641 | |
564 | |
… | |
… | |
687 | |
610 | |
688 | void * |
611 | void * |
689 | cfapi_map_get_map (int *type, ...) |
612 | cfapi_map_get_map (int *type, ...) |
690 | { |
613 | { |
691 | va_list args; |
614 | va_list args; |
692 | mapstruct *rv; |
615 | maptile *rv; |
693 | int ctype; |
616 | int ctype; |
694 | int x, y; |
617 | int x, y; |
695 | sint16 nx, ny; |
618 | sint16 nx, ny; |
696 | char *name; |
619 | char *name; |
697 | mapstruct *m; |
620 | maptile *m; |
698 | |
621 | |
699 | va_start (args, type); |
622 | va_start (args, type); |
700 | |
623 | |
701 | ctype = va_arg (args, int); |
624 | ctype = va_arg (args, int); |
702 | |
625 | |
… | |
… | |
715 | |
638 | |
716 | rv = ready_map_name (name, x); |
639 | rv = ready_map_name (name, x); |
717 | break; |
640 | break; |
718 | |
641 | |
719 | case 2: |
642 | case 2: |
720 | m = va_arg (args, mapstruct *); |
643 | m = va_arg (args, maptile *); |
721 | nx = va_arg (args, int); |
644 | nx = va_arg (args, int); |
722 | ny = va_arg (args, int); |
645 | ny = va_arg (args, int); |
723 | |
646 | |
724 | rv = get_map_from_coord (m, &nx, &ny); |
647 | rv = get_map_from_coord (m, &nx, &ny); |
725 | break; |
648 | break; |
… | |
… | |
741 | |
664 | |
742 | void * |
665 | void * |
743 | cfapi_map_has_been_loaded (int *type, ...) |
666 | cfapi_map_has_been_loaded (int *type, ...) |
744 | { |
667 | { |
745 | va_list args; |
668 | va_list args; |
746 | mapstruct *map; |
669 | maptile *map; |
747 | char *string; |
670 | char *string; |
748 | |
671 | |
749 | va_start (args, type); |
672 | va_start (args, type); |
750 | string = va_arg (args, char *); |
673 | string = va_arg (args, char *); |
751 | |
674 | |
… | |
… | |
797 | cfapi_map_get_map_property (int *type, ...) |
720 | cfapi_map_get_map_property (int *type, ...) |
798 | { |
721 | { |
799 | va_list args; |
722 | va_list args; |
800 | int x, y; |
723 | int x, y; |
801 | sint16 nx, ny; |
724 | sint16 nx, ny; |
802 | mapstruct *map; |
725 | maptile *map; |
803 | mapstruct *newmap; |
726 | maptile *newmap; |
804 | static int rv; |
727 | static int rv; |
805 | int property; |
728 | int property; |
806 | char *buf; |
729 | char *buf; |
807 | |
730 | |
808 | va_start (args, type); |
731 | va_start (args, type); |
… | |
… | |
810 | property = va_arg (args, int); |
733 | property = va_arg (args, int); |
811 | |
734 | |
812 | switch (property) |
735 | switch (property) |
813 | { |
736 | { |
814 | case CFAPI_MAP_PROP_FLAGS: |
737 | case CFAPI_MAP_PROP_FLAGS: |
815 | map = va_arg (args, mapstruct *); |
738 | map = va_arg (args, maptile *); |
816 | newmap = va_arg (args, mapstruct *); |
739 | newmap = va_arg (args, maptile *); |
817 | x = va_arg (args, int); |
740 | x = va_arg (args, int); |
818 | y = va_arg (args, int); |
741 | y = va_arg (args, int); |
819 | nx = va_arg (args, int); |
742 | nx = va_arg (args, int); |
820 | ny = va_arg (args, int); |
743 | ny = va_arg (args, int); |
821 | |
744 | |
… | |
… | |
824 | *type = CFAPI_INT; |
747 | *type = CFAPI_INT; |
825 | return &rv; |
748 | return &rv; |
826 | break; |
749 | break; |
827 | |
750 | |
828 | case CFAPI_MAP_PROP_DIFFICULTY: |
751 | case CFAPI_MAP_PROP_DIFFICULTY: |
829 | map = va_arg (args, mapstruct *); |
752 | map = va_arg (args, maptile *); |
830 | |
753 | |
831 | rv = calculate_difficulty (map); |
754 | rv = calculate_difficulty (map); |
832 | va_end (args); |
755 | va_end (args); |
833 | *type = CFAPI_INT; |
756 | *type = CFAPI_INT; |
834 | return &rv; |
757 | return &rv; |
835 | break; |
758 | break; |
836 | |
759 | |
837 | case CFAPI_MAP_PROP_PATH: |
760 | case CFAPI_MAP_PROP_PATH: |
838 | map = va_arg (args, mapstruct *); |
761 | map = va_arg (args, maptile *); |
839 | |
762 | |
840 | buf = map->path; |
763 | buf = map->path; |
841 | *type = CFAPI_STRING; |
764 | *type = CFAPI_STRING; |
842 | va_end (args); |
765 | va_end (args); |
843 | return buf; |
766 | return buf; |
844 | break; |
767 | break; |
845 | |
768 | |
846 | case CFAPI_MAP_PROP_TMPNAME: |
769 | case CFAPI_MAP_PROP_TMPNAME: |
847 | map = va_arg (args, mapstruct *); |
770 | map = va_arg (args, maptile *); |
848 | |
771 | |
849 | buf = map->tmpname; |
772 | buf = map->tmpname; |
850 | *type = CFAPI_STRING; |
773 | *type = CFAPI_STRING; |
851 | va_end (args); |
774 | va_end (args); |
852 | return buf; |
775 | return buf; |
853 | break; |
776 | break; |
854 | |
777 | |
855 | case CFAPI_MAP_PROP_NAME: |
778 | case CFAPI_MAP_PROP_NAME: |
856 | map = va_arg (args, mapstruct *); |
779 | map = va_arg (args, maptile *); |
857 | |
780 | |
858 | buf = map->name; |
781 | buf = map->name; |
859 | *type = CFAPI_STRING; |
782 | *type = CFAPI_STRING; |
860 | va_end (args); |
783 | va_end (args); |
861 | return buf; |
784 | return buf; |
862 | break; |
785 | break; |
863 | |
786 | |
864 | case CFAPI_MAP_PROP_RESET_TIME: |
787 | case CFAPI_MAP_PROP_RESET_TIME: |
865 | map = va_arg (args, mapstruct *); |
788 | map = va_arg (args, maptile *); |
866 | |
789 | |
867 | rv = map->reset_time; |
790 | rv = map->reset_time; |
868 | *type = CFAPI_INT; |
791 | *type = CFAPI_INT; |
869 | va_end (args); |
792 | va_end (args); |
870 | return &rv; |
793 | return &rv; |
871 | break; |
794 | break; |
872 | |
795 | |
873 | case CFAPI_MAP_PROP_RESET_TIMEOUT: |
796 | case CFAPI_MAP_PROP_RESET_TIMEOUT: |
874 | map = va_arg (args, mapstruct *); |
797 | map = va_arg (args, maptile *); |
875 | |
798 | |
876 | rv = map->reset_timeout; |
799 | rv = map->reset_timeout; |
877 | *type = CFAPI_INT; |
800 | *type = CFAPI_INT; |
878 | va_end (args); |
801 | va_end (args); |
879 | return &rv; |
802 | return &rv; |
880 | break; |
803 | break; |
881 | |
804 | |
882 | case CFAPI_MAP_PROP_PLAYERS: |
805 | case CFAPI_MAP_PROP_PLAYERS: |
883 | map = va_arg (args, mapstruct *); |
806 | map = va_arg (args, maptile *); |
884 | |
807 | |
885 | rv = map->players; |
808 | rv = map->players; |
886 | *type = CFAPI_INT; |
809 | *type = CFAPI_INT; |
887 | va_end (args); |
810 | va_end (args); |
888 | return &rv; |
811 | return &rv; |
889 | break; |
812 | break; |
890 | |
813 | |
891 | case CFAPI_MAP_PROP_DARKNESS: |
814 | case CFAPI_MAP_PROP_DARKNESS: |
892 | map = va_arg (args, mapstruct *); |
815 | map = va_arg (args, maptile *); |
893 | |
816 | |
894 | rv = map->darkness; |
817 | rv = map->darkness; |
895 | *type = CFAPI_INT; |
818 | *type = CFAPI_INT; |
896 | va_end (args); |
819 | va_end (args); |
897 | return &rv; |
820 | return &rv; |
898 | break; |
821 | break; |
899 | |
822 | |
900 | case CFAPI_MAP_PROP_WIDTH: |
823 | case CFAPI_MAP_PROP_WIDTH: |
901 | map = va_arg (args, mapstruct *); |
824 | map = va_arg (args, maptile *); |
902 | |
825 | |
903 | rv = map->width; |
826 | rv = map->width; |
904 | *type = CFAPI_INT; |
827 | *type = CFAPI_INT; |
905 | va_end (args); |
828 | va_end (args); |
906 | return &rv; |
829 | return &rv; |
907 | break; |
830 | break; |
908 | |
831 | |
909 | case CFAPI_MAP_PROP_HEIGHT: |
832 | case CFAPI_MAP_PROP_HEIGHT: |
910 | map = va_arg (args, mapstruct *); |
833 | map = va_arg (args, maptile *); |
911 | |
834 | |
912 | rv = map->height; |
835 | rv = map->height; |
913 | *type = CFAPI_INT; |
836 | *type = CFAPI_INT; |
914 | va_end (args); |
837 | va_end (args); |
915 | return &rv; |
838 | return &rv; |
916 | break; |
839 | break; |
917 | |
840 | |
918 | case CFAPI_MAP_PROP_ENTER_X: |
841 | case CFAPI_MAP_PROP_ENTER_X: |
919 | map = va_arg (args, mapstruct *); |
842 | map = va_arg (args, maptile *); |
920 | |
843 | |
921 | rv = map->enter_x; |
844 | rv = map->enter_x; |
922 | *type = CFAPI_INT; |
845 | *type = CFAPI_INT; |
923 | va_end (args); |
846 | va_end (args); |
924 | return &rv; |
847 | return &rv; |
925 | break; |
848 | break; |
926 | |
849 | |
927 | case CFAPI_MAP_PROP_ENTER_Y: |
850 | case CFAPI_MAP_PROP_ENTER_Y: |
928 | map = va_arg (args, mapstruct *); |
851 | map = va_arg (args, maptile *); |
929 | |
852 | |
930 | rv = map->enter_y; |
853 | rv = map->enter_y; |
931 | *type = CFAPI_INT; |
854 | *type = CFAPI_INT; |
932 | va_end (args); |
855 | va_end (args); |
933 | return &rv; |
856 | return &rv; |
934 | break; |
857 | break; |
935 | |
858 | |
936 | case CFAPI_MAP_PROP_TEMPERATURE: |
859 | case CFAPI_MAP_PROP_TEMPERATURE: |
937 | map = va_arg (args, mapstruct *); |
860 | map = va_arg (args, maptile *); |
938 | |
861 | |
939 | rv = map->temp; |
862 | rv = map->temp; |
940 | *type = CFAPI_INT; |
863 | *type = CFAPI_INT; |
941 | va_end (args); |
864 | va_end (args); |
942 | return &rv; |
865 | return &rv; |
943 | break; |
866 | break; |
944 | |
867 | |
945 | case CFAPI_MAP_PROP_PRESSURE: |
868 | case CFAPI_MAP_PROP_PRESSURE: |
946 | map = va_arg (args, mapstruct *); |
869 | map = va_arg (args, maptile *); |
947 | |
870 | |
948 | rv = map->pressure; |
871 | rv = map->pressure; |
949 | *type = CFAPI_INT; |
872 | *type = CFAPI_INT; |
950 | va_end (args); |
873 | va_end (args); |
951 | return &rv; |
874 | return &rv; |
952 | break; |
875 | break; |
953 | |
876 | |
954 | case CFAPI_MAP_PROP_HUMIDITY: |
877 | case CFAPI_MAP_PROP_HUMIDITY: |
955 | map = va_arg (args, mapstruct *); |
878 | map = va_arg (args, maptile *); |
956 | |
879 | |
957 | rv = map->humid; |
880 | rv = map->humid; |
958 | *type = CFAPI_INT; |
881 | *type = CFAPI_INT; |
959 | va_end (args); |
882 | va_end (args); |
960 | return &rv; |
883 | return &rv; |
961 | break; |
884 | break; |
962 | |
885 | |
963 | case CFAPI_MAP_PROP_WINDSPEED: |
886 | case CFAPI_MAP_PROP_WINDSPEED: |
964 | map = va_arg (args, mapstruct *); |
887 | map = va_arg (args, maptile *); |
965 | |
888 | |
966 | rv = map->windspeed; |
889 | rv = map->windspeed; |
967 | *type = CFAPI_INT; |
890 | *type = CFAPI_INT; |
968 | va_end (args); |
891 | va_end (args); |
969 | return &rv; |
892 | return &rv; |
970 | break; |
893 | break; |
971 | |
894 | |
972 | case CFAPI_MAP_PROP_WINDDIR: |
895 | case CFAPI_MAP_PROP_WINDDIR: |
973 | map = va_arg (args, mapstruct *); |
896 | map = va_arg (args, maptile *); |
974 | |
897 | |
975 | rv = map->winddir; |
898 | rv = map->winddir; |
976 | *type = CFAPI_INT; |
899 | *type = CFAPI_INT; |
977 | va_end (args); |
900 | va_end (args); |
978 | return &rv; |
901 | return &rv; |
979 | break; |
902 | break; |
980 | |
903 | |
981 | case CFAPI_MAP_PROP_SKY: |
904 | case CFAPI_MAP_PROP_SKY: |
982 | map = va_arg (args, mapstruct *); |
905 | map = va_arg (args, maptile *); |
983 | |
906 | |
984 | rv = map->sky; |
907 | rv = map->sky; |
985 | *type = CFAPI_INT; |
908 | *type = CFAPI_INT; |
986 | va_end (args); |
909 | va_end (args); |
987 | return &rv; |
910 | return &rv; |
988 | break; |
911 | break; |
989 | |
912 | |
990 | case CFAPI_MAP_PROP_WPARTX: |
913 | case CFAPI_MAP_PROP_WPARTX: |
991 | map = va_arg (args, mapstruct *); |
914 | map = va_arg (args, maptile *); |
992 | |
915 | |
993 | rv = map->wpartx; |
916 | rv = map->wpartx; |
994 | *type = CFAPI_INT; |
917 | *type = CFAPI_INT; |
995 | va_end (args); |
918 | va_end (args); |
996 | return &rv; |
919 | return &rv; |
997 | break; |
920 | break; |
998 | |
921 | |
999 | case CFAPI_MAP_PROP_WPARTY: |
922 | case CFAPI_MAP_PROP_WPARTY: |
1000 | map = va_arg (args, mapstruct *); |
923 | map = va_arg (args, maptile *); |
1001 | |
924 | |
1002 | rv = map->wparty; |
925 | rv = map->wparty; |
1003 | *type = CFAPI_INT; |
926 | *type = CFAPI_INT; |
1004 | va_end (args); |
927 | va_end (args); |
1005 | return &rv; |
928 | return &rv; |
1006 | break; |
929 | break; |
1007 | |
930 | |
1008 | case CFAPI_MAP_PROP_MESSAGE: |
931 | case CFAPI_MAP_PROP_MESSAGE: |
1009 | map = va_arg (args, mapstruct *); |
932 | map = va_arg (args, maptile *); |
1010 | |
933 | |
1011 | buf = map->msg; |
934 | buf = map->msg; |
1012 | *type = CFAPI_STRING; |
935 | *type = CFAPI_STRING; |
1013 | va_end (args); |
936 | va_end (args); |
1014 | return buf; |
937 | return buf; |
1015 | break; |
938 | break; |
1016 | |
939 | |
1017 | case CFAPI_MAP_PROP_NEXT: |
940 | case CFAPI_MAP_PROP_NEXT: |
1018 | map = va_arg (args, mapstruct *); |
941 | map = va_arg (args, maptile *); |
1019 | |
942 | |
1020 | *type = CFAPI_PMAP; |
943 | *type = CFAPI_PMAP; |
1021 | va_end (args); |
944 | va_end (args); |
1022 | return map->next; |
945 | return map->next; |
1023 | break; |
946 | break; |
1024 | |
947 | |
1025 | case CFAPI_MAP_PROP_REGION: |
948 | case CFAPI_MAP_PROP_REGION: |
1026 | map = va_arg (args, mapstruct *); |
949 | map = va_arg (args, maptile *); |
1027 | |
950 | |
1028 | *type = CFAPI_PREGION; |
951 | *type = CFAPI_PREGION; |
1029 | va_end (args); |
952 | va_end (args); |
1030 | return get_region_by_map (map); |
953 | return get_region_by_map (map); |
1031 | break; |
954 | break; |
… | |
… | |
1041 | void * |
964 | void * |
1042 | cfapi_map_set_map_property (int *type, ...) |
965 | cfapi_map_set_map_property (int *type, ...) |
1043 | { |
966 | { |
1044 | va_list args; |
967 | va_list args; |
1045 | static int rv; |
968 | static int rv; |
1046 | mapstruct *map; |
969 | maptile *map; |
1047 | int val; |
970 | int val; |
1048 | int property; |
971 | int property; |
1049 | |
972 | |
1050 | va_start (args, type); |
973 | va_start (args, type); |
1051 | |
974 | |
1052 | property = va_arg (args, int); |
975 | property = va_arg (args, int); |
1053 | |
976 | |
1054 | switch (property) |
977 | switch (property) |
1055 | { |
978 | { |
1056 | case CFAPI_MAP_PROP_LIGHT: |
979 | case CFAPI_MAP_PROP_LIGHT: |
1057 | map = va_arg (args, mapstruct *); |
980 | map = va_arg (args, maptile *); |
1058 | val = va_arg (args, int); |
981 | val = va_arg (args, int); |
1059 | |
982 | |
1060 | rv = change_map_light (map, val); |
983 | rv = change_map_light (map, val); |
1061 | *type = CFAPI_INT; |
984 | *type = CFAPI_INT; |
1062 | va_end (args); |
985 | va_end (args); |
1063 | return &rv; |
986 | return &rv; |
1064 | break; |
987 | break; |
1065 | |
988 | |
1066 | case CFAPI_MAP_PROP_RESET_TIME: |
989 | case CFAPI_MAP_PROP_RESET_TIME: |
1067 | map = va_arg (args, mapstruct *); |
990 | map = va_arg (args, maptile *); |
1068 | |
991 | |
1069 | *type = CFAPI_NONE; |
992 | *type = CFAPI_NONE; |
1070 | va_end (args); |
993 | va_end (args); |
1071 | return NULL; |
994 | return NULL; |
1072 | break; |
995 | break; |
… | |
… | |
1081 | void * |
1004 | void * |
1082 | cfapi_map_out_of_map (int *type, ...) |
1005 | cfapi_map_out_of_map (int *type, ...) |
1083 | { |
1006 | { |
1084 | va_list args; |
1007 | va_list args; |
1085 | static int rv; |
1008 | static int rv; |
1086 | mapstruct *map; |
1009 | maptile *map; |
1087 | int x, y; |
1010 | int x, y; |
1088 | |
1011 | |
1089 | va_start (args, type); |
1012 | va_start (args, type); |
1090 | map = va_arg (args, mapstruct *); |
1013 | map = va_arg (args, maptile *); |
1091 | x = va_arg (args, int); |
1014 | x = va_arg (args, int); |
1092 | y = va_arg (args, int); |
1015 | y = va_arg (args, int); |
1093 | |
1016 | |
1094 | rv = out_of_map (map, x, y); |
1017 | rv = out_of_map (map, x, y); |
1095 | va_end (args); |
1018 | va_end (args); |
… | |
… | |
1099 | |
1022 | |
1100 | void * |
1023 | void * |
1101 | cfapi_map_update_position (int *type, ...) |
1024 | cfapi_map_update_position (int *type, ...) |
1102 | { |
1025 | { |
1103 | va_list args; |
1026 | va_list args; |
1104 | mapstruct *map; |
1027 | maptile *map; |
1105 | int x, y; |
1028 | int x, y; |
1106 | |
1029 | |
1107 | va_start (args, type); |
1030 | va_start (args, type); |
1108 | |
1031 | |
1109 | map = va_arg (args, mapstruct *); |
1032 | map = va_arg (args, maptile *); |
1110 | x = va_arg (args, int); |
1033 | x = va_arg (args, int); |
1111 | y = va_arg (args, int); |
1034 | y = va_arg (args, int); |
1112 | |
1035 | |
1113 | update_position (map, x, y); |
1036 | map->at (x, y).flags_ |= P_NEED_UPDATE; |
|
|
1037 | |
1114 | va_end (args); |
1038 | va_end (args); |
1115 | *type = CFAPI_NONE; |
1039 | *type = CFAPI_NONE; |
1116 | return NULL; |
1040 | return NULL; |
1117 | } |
1041 | } |
1118 | |
1042 | |
1119 | void * |
1043 | void * |
1120 | cfapi_map_delete_map (int *type, ...) |
1044 | cfapi_map_delete_map (int *type, ...) |
1121 | { |
1045 | { |
1122 | va_list args; |
1046 | va_list args; |
1123 | mapstruct *map; |
1047 | maptile *map; |
1124 | |
1048 | |
1125 | va_start (args, type); |
1049 | va_start (args, type); |
1126 | |
1050 | |
1127 | map = va_arg (args, mapstruct *); |
1051 | map = va_arg (args, maptile *); |
1128 | |
1052 | |
1129 | delete_map (map); |
1053 | delete_map (map); |
1130 | |
1054 | |
1131 | va_end (args); |
1055 | va_end (args); |
1132 | *type = CFAPI_NONE; |
1056 | *type = CFAPI_NONE; |
… | |
… | |
1135 | |
1059 | |
1136 | void * |
1060 | void * |
1137 | cfapi_map_message (int *type, ...) |
1061 | cfapi_map_message (int *type, ...) |
1138 | { |
1062 | { |
1139 | va_list args; |
1063 | va_list args; |
1140 | mapstruct *map; |
1064 | maptile *map; |
1141 | char *string; |
1065 | char *string; |
1142 | int color; |
1066 | int color; |
1143 | |
1067 | |
1144 | va_start (args, type); |
1068 | va_start (args, type); |
1145 | map = va_arg (args, mapstruct *); |
1069 | map = va_arg (args, maptile *); |
1146 | string = va_arg (args, char *); |
1070 | string = va_arg (args, char *); |
1147 | color = va_arg (args, int); |
1071 | color = va_arg (args, int); |
1148 | |
1072 | |
1149 | va_end (args); |
1073 | va_end (args); |
1150 | |
1074 | |
… | |
… | |
1155 | |
1079 | |
1156 | void * |
1080 | void * |
1157 | cfapi_map_get_object_at (int *type, ...) |
1081 | cfapi_map_get_object_at (int *type, ...) |
1158 | { |
1082 | { |
1159 | va_list args; |
1083 | va_list args; |
1160 | mapstruct *map; |
1084 | maptile *map; |
1161 | int x, y; |
1085 | int x, y; |
1162 | object *rv; |
1086 | object *rv; |
1163 | |
1087 | |
1164 | va_start (args, type); |
1088 | va_start (args, type); |
1165 | map = va_arg (args, mapstruct *); |
1089 | map = va_arg (args, maptile *); |
1166 | x = va_arg (args, int); |
1090 | x = va_arg (args, int); |
1167 | y = va_arg (args, int); |
1091 | y = va_arg (args, int); |
1168 | |
1092 | |
1169 | va_end (args); |
1093 | va_end (args); |
1170 | |
1094 | |
1171 | rv = get_map_ob (map, x, y); |
1095 | rv = GET_MAP_OB (map, x, y); |
1172 | *type = CFAPI_POBJECT; |
1096 | *type = CFAPI_POBJECT; |
1173 | return rv; |
1097 | return rv; |
1174 | } |
1098 | } |
1175 | |
1099 | |
1176 | void * |
1100 | void * |
1177 | cfapi_map_get_flags (int *type, ...) |
1101 | cfapi_map_get_flags (int *type, ...) |
1178 | { |
1102 | { |
1179 | va_list args; |
1103 | va_list args; |
1180 | sint16 x, y; |
1104 | sint16 x, y; |
1181 | sint16 *nx, *ny; |
1105 | sint16 *nx, *ny; |
1182 | static mapstruct *map; |
1106 | static maptile *map; |
1183 | mapstruct **newmap; |
1107 | maptile **newmap; |
1184 | static int rv; |
1108 | static int rv; |
1185 | |
1109 | |
1186 | va_start (args, type); |
1110 | va_start (args, type); |
1187 | |
1111 | |
1188 | map = va_arg (args, mapstruct *); |
1112 | map = va_arg (args, maptile *); |
1189 | newmap = va_arg (args, mapstruct **); |
1113 | newmap = va_arg (args, maptile **); |
1190 | x = va_arg (args, int); |
1114 | x = va_arg (args, int); |
1191 | y = va_arg (args, int); |
1115 | y = va_arg (args, int); |
1192 | |
1116 | |
1193 | nx = va_arg (args, sint16 *); |
1117 | nx = va_arg (args, sint16 *); |
1194 | ny = va_arg (args, sint16 *); |
1118 | ny = va_arg (args, sint16 *); |
… | |
… | |
1204 | cfapi_map_present_arch_by_name (int *type, ...) |
1128 | cfapi_map_present_arch_by_name (int *type, ...) |
1205 | { |
1129 | { |
1206 | va_list args; |
1130 | va_list args; |
1207 | object *rv; |
1131 | object *rv; |
1208 | int x, y; |
1132 | int x, y; |
1209 | mapstruct *map; |
1133 | maptile *map; |
1210 | char *msg; |
1134 | char *msg; |
1211 | |
1135 | |
1212 | va_start (args, type); |
1136 | va_start (args, type); |
1213 | |
1137 | |
1214 | msg = va_arg (args, char *); |
1138 | msg = va_arg (args, char *); |
1215 | map = va_arg (args, mapstruct *); |
1139 | map = va_arg (args, maptile *); |
1216 | x = va_arg (args, int); |
1140 | x = va_arg (args, int); |
1217 | y = va_arg (args, int); |
1141 | y = va_arg (args, int); |
1218 | |
1142 | |
1219 | va_end (args); |
1143 | va_end (args); |
1220 | |
1144 | |
… | |
… | |
1713 | rv = &op->stats.exp; |
1637 | rv = &op->stats.exp; |
1714 | *type = CFAPI_LONG; |
1638 | *type = CFAPI_LONG; |
1715 | break; |
1639 | break; |
1716 | |
1640 | |
1717 | case CFAPI_OBJECT_PROP_OWNER: |
1641 | case CFAPI_OBJECT_PROP_OWNER: |
1718 | rv = get_owner (op); |
1642 | rv = op->owner; |
1719 | *type = CFAPI_POBJECT; |
1643 | *type = CFAPI_POBJECT; |
1720 | break; |
1644 | break; |
1721 | |
1645 | |
1722 | case CFAPI_OBJECT_PROP_PRESENT: |
1646 | case CFAPI_OBJECT_PROP_PRESENT: |
1723 | { |
1647 | { |
… | |
… | |
1765 | case CFAPI_OBJECT_PROP_MERGEABLE: |
1689 | case CFAPI_OBJECT_PROP_MERGEABLE: |
1766 | { |
1690 | { |
1767 | object *op2; |
1691 | object *op2; |
1768 | op2 = va_arg (args, object *); |
1692 | op2 = va_arg (args, object *); |
1769 | |
1693 | |
1770 | ri = CAN_MERGE (op, op2); |
1694 | ri = object::can_merge_slow (op, op2); |
1771 | rv = &ri; |
1695 | rv = &ri; |
1772 | } |
1696 | } |
1773 | *type = CFAPI_INT; |
1697 | *type = CFAPI_INT; |
1774 | break; |
1698 | break; |
1775 | |
1699 | |
… | |
… | |
1922 | rv = &ri; |
1846 | rv = &ri; |
1923 | *type = CFAPI_INT; |
1847 | *type = CFAPI_INT; |
1924 | break; |
1848 | break; |
1925 | |
1849 | |
1926 | case CFAPI_PLAYER_PROP_IP: |
1850 | case CFAPI_PLAYER_PROP_IP: |
1927 | rv = op->contr->socket.host; |
1851 | rv = op->contr->ns->host; |
1928 | *type = CFAPI_STRING; |
1852 | *type = CFAPI_STRING; |
1929 | break; |
1853 | break; |
1930 | |
1854 | |
1931 | case CFAPI_PLAYER_PROP_MARKED_ITEM: |
1855 | case CFAPI_PLAYER_PROP_MARKED_ITEM: |
1932 | rv = find_marked_object (op); |
1856 | rv = find_marked_object (op); |
… | |
… | |
2042 | if (op->nrof > (uint32) iarg) |
1966 | if (op->nrof > (uint32) iarg) |
2043 | decrease_ob_nr (op, op->nrof - iarg); |
1967 | decrease_ob_nr (op, op->nrof - iarg); |
2044 | else if (op->nrof < (uint32) iarg) |
1968 | else if (op->nrof < (uint32) iarg) |
2045 | { |
1969 | { |
2046 | object *tmp; |
1970 | object *tmp; |
2047 | player *pl; |
|
|
2048 | |
1971 | |
2049 | op->nrof = iarg; |
1972 | op->nrof = iarg; |
2050 | if (op->env != NULL) |
1973 | if (op->env != NULL) |
2051 | { |
1974 | { |
2052 | tmp = is_player_inv (op->env); |
1975 | tmp = op->in_player (); |
2053 | if (!tmp) |
1976 | if (!tmp) |
2054 | { |
1977 | { |
2055 | for (pl = first_player; pl; pl = pl->next) |
1978 | for_all_players (pl) |
2056 | if (pl->ob->container == op->env) |
1979 | if (pl->ob->container == op->env) |
|
|
1980 | { |
|
|
1981 | tmp = pl->ob; |
2057 | break; |
1982 | break; |
2058 | if (pl) |
|
|
2059 | tmp = pl->ob; |
|
|
2060 | else |
1983 | } |
2061 | tmp = NULL; |
|
|
2062 | } |
1984 | } |
2063 | else |
1985 | else |
2064 | { |
1986 | { |
2065 | sum_weight (tmp); |
1987 | sum_weight (tmp); |
2066 | fix_player (tmp); |
1988 | tmp->update_stats (); |
2067 | } |
1989 | } |
2068 | if (tmp) |
1990 | if (tmp) |
2069 | esrv_send_item (tmp, op); |
1991 | esrv_send_item (tmp, op); |
2070 | } |
1992 | } |
2071 | else |
1993 | else |
… | |
… | |
2203 | iarg = va_arg (args, int); |
2125 | iarg = va_arg (args, int); |
2204 | |
2126 | |
2205 | if (op->weight != iarg) |
2127 | if (op->weight != iarg) |
2206 | { |
2128 | { |
2207 | object *tmp; |
2129 | object *tmp; |
2208 | player *pl; |
|
|
2209 | |
2130 | |
2210 | op->weight = iarg; |
2131 | op->weight = iarg; |
2211 | if (op->env != NULL) |
2132 | if (op->env != NULL) |
2212 | { |
2133 | { |
2213 | tmp = is_player_inv (op->env); |
2134 | tmp = op->in_player (); |
2214 | if (!tmp) |
2135 | if (!tmp) |
2215 | { |
2136 | { |
2216 | for (pl = first_player; pl; pl = pl->next) |
2137 | for_all_players (pl) |
2217 | if (pl->ob->container == op->env) |
2138 | if (pl->ob->container == op->env) |
|
|
2139 | { |
|
|
2140 | tmp = pl->ob; |
2218 | break; |
2141 | break; |
2219 | if (pl) |
|
|
2220 | tmp = pl->ob; |
|
|
2221 | else |
2142 | } |
2222 | tmp = NULL; |
|
|
2223 | } |
2143 | } |
2224 | else |
2144 | else |
2225 | { |
2145 | { |
2226 | sum_weight (tmp); |
2146 | sum_weight (tmp); |
2227 | fix_player (tmp); |
2147 | tmp->update_stats (); |
2228 | } |
2148 | } |
2229 | if (tmp) |
2149 | if (tmp) |
2230 | esrv_send_item (tmp, op); |
2150 | esrv_send_item (tmp, op); |
2231 | } |
2151 | } |
2232 | else |
2152 | else |
… | |
… | |
2347 | break; |
2267 | break; |
2348 | |
2268 | |
2349 | case CFAPI_OBJECT_PROP_OWNER: |
2269 | case CFAPI_OBJECT_PROP_OWNER: |
2350 | oparg = va_arg (args, object *); |
2270 | oparg = va_arg (args, object *); |
2351 | |
2271 | |
2352 | set_owner (op, oparg); |
2272 | op->set_owner (oparg); |
2353 | break; |
2273 | break; |
2354 | |
2274 | |
2355 | case CFAPI_OBJECT_PROP_CHEATER: |
2275 | case CFAPI_OBJECT_PROP_CHEATER: |
2356 | set_cheat (op); |
2276 | set_cheat (op); |
2357 | break; |
2277 | break; |
… | |
… | |
2492 | if (op->contr) |
2412 | if (op->contr) |
2493 | { |
2413 | { |
2494 | oparg = va_arg (args, object *); |
2414 | oparg = va_arg (args, object *); |
2495 | |
2415 | |
2496 | op->contr->mark = oparg; |
2416 | op->contr->mark = oparg; |
2497 | if (oparg) |
|
|
2498 | op->contr->mark_count = oparg->count; |
|
|
2499 | } |
2417 | } |
2500 | break; |
2418 | break; |
2501 | |
2419 | |
2502 | case CFAPI_PLAYER_PROP_PARTY: |
2420 | case CFAPI_PLAYER_PROP_PARTY: |
2503 | if (op->contr) |
2421 | if (op->contr) |
… | |
… | |
2594 | } |
2512 | } |
2595 | |
2513 | |
2596 | void * |
2514 | void * |
2597 | cfapi_object_drain (int *type, ...) |
2515 | cfapi_object_drain (int *type, ...) |
2598 | { |
2516 | { |
2599 | va_list args; |
2517 | abort (); |
|
|
2518 | } |
2600 | |
2519 | |
|
|
2520 | void * |
|
|
2521 | cfapi_object_fix (int *type, ...) |
|
|
2522 | { |
|
|
2523 | va_list args; |
2601 | object *op; |
2524 | object *op; |
2602 | int ds; |
|
|
2603 | |
2525 | |
2604 | va_start (args, type); |
2526 | va_start (args, type); |
2605 | |
2527 | |
2606 | op = va_arg (args, object *); |
2528 | op = va_arg (args, object *); |
2607 | ds = va_arg (args, int); |
|
|
2608 | |
2529 | |
2609 | va_end (args); |
2530 | va_end (args); |
2610 | |
2531 | |
2611 | drain_specific_stat (op, ds); |
2532 | op->update_stats (); |
2612 | |
|
|
2613 | *type = CFAPI_NONE; |
|
|
2614 | return NULL; |
|
|
2615 | } |
|
|
2616 | |
|
|
2617 | void * |
|
|
2618 | cfapi_object_fix (int *type, ...) |
|
|
2619 | { |
|
|
2620 | va_list args; |
|
|
2621 | object *op; |
|
|
2622 | |
|
|
2623 | va_start (args, type); |
|
|
2624 | |
|
|
2625 | op = va_arg (args, object *); |
|
|
2626 | |
|
|
2627 | va_end (args); |
|
|
2628 | |
|
|
2629 | fix_player (op); |
|
|
2630 | |
2533 | |
2631 | *type = CFAPI_NONE; |
2534 | *type = CFAPI_NONE; |
2632 | return NULL; |
2535 | return NULL; |
2633 | } |
2536 | } |
2634 | |
2537 | |
… | |
… | |
2682 | op = va_arg (args, object *); |
2585 | op = va_arg (args, object *); |
2683 | |
2586 | |
2684 | va_end (args); |
2587 | va_end (args); |
2685 | |
2588 | |
2686 | send_removed_object (op); |
2589 | send_removed_object (op); |
2687 | remove_ob (op); |
2590 | op->remove (); |
2688 | *type = CFAPI_NONE; |
2591 | *type = CFAPI_NONE; |
2689 | return NULL; |
2592 | return NULL; |
2690 | } |
2593 | } |
2691 | |
2594 | |
2692 | void * |
2595 | void * |
… | |
… | |
2699 | |
2602 | |
2700 | op = va_arg (args, object *); |
2603 | op = va_arg (args, object *); |
2701 | |
2604 | |
2702 | va_end (args); |
2605 | va_end (args); |
2703 | |
2606 | |
2704 | free_object (op); |
2607 | op->destroy (); |
2705 | |
2608 | |
2706 | *type = CFAPI_NONE; |
2609 | *type = CFAPI_NONE; |
2707 | return NULL; |
2610 | return NULL; |
2708 | } |
2611 | } |
2709 | |
2612 | |
… | |
… | |
2726 | *type = CFAPI_POBJECT; |
2629 | *type = CFAPI_POBJECT; |
2727 | return object_create_clone (op); |
2630 | return object_create_clone (op); |
2728 | } |
2631 | } |
2729 | else |
2632 | else |
2730 | { |
2633 | { |
2731 | object *tmp; |
2634 | object *tmp = op->clone (); |
2732 | |
|
|
2733 | tmp = get_object (); |
|
|
2734 | copy_object (op, tmp); |
|
|
2735 | *type = CFAPI_POBJECT; |
2635 | *type = CFAPI_POBJECT; |
2736 | return tmp; |
2636 | return tmp; |
2737 | } |
2637 | } |
2738 | } |
2638 | } |
2739 | void * |
2639 | void * |
… | |
… | |
2775 | break; |
2675 | break; |
2776 | |
2676 | |
2777 | case 3: |
2677 | case 3: |
2778 | op = va_arg (args, object *); |
2678 | op = va_arg (args, object *); |
2779 | |
2679 | |
2780 | rv = is_player_inv (op); |
2680 | rv = op->in_player (); |
2781 | break; |
2681 | break; |
2782 | |
2682 | |
2783 | default: |
2683 | default: |
2784 | rv = NULL; |
2684 | rv = NULL; |
2785 | *type = CFAPI_NONE; |
2685 | *type = CFAPI_NONE; |
… | |
… | |
2803 | *type = CFAPI_POBJECT; |
2703 | *type = CFAPI_POBJECT; |
2804 | switch (ival) |
2704 | switch (ival) |
2805 | { |
2705 | { |
2806 | case 0: |
2706 | case 0: |
2807 | va_end (args); |
2707 | va_end (args); |
2808 | return get_object (); |
2708 | return object::create (); |
2809 | break; |
2709 | break; |
2810 | |
2710 | |
2811 | case 1: /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */ |
2711 | case 1: /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */ |
2812 | { |
2712 | { |
2813 | char *sval; |
2713 | char *sval; |
… | |
… | |
2816 | |
2716 | |
2817 | op = get_archetype_by_object_name (sval); |
2717 | op = get_archetype_by_object_name (sval); |
2818 | |
2718 | |
2819 | if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) |
2719 | if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) |
2820 | { |
2720 | { |
2821 | free_object (op); |
2721 | op->destroy (); |
2822 | /* Try with archetype names... */ |
2722 | /* Try with archetype names... */ |
2823 | op = get_archetype (sval); |
2723 | op = get_archetype (sval); |
2824 | if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) |
2724 | if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) |
2825 | { |
2725 | { |
2826 | free_object (op); |
2726 | op->destroy (); |
2827 | *type = CFAPI_NONE; |
2727 | *type = CFAPI_NONE; |
2828 | va_end (args); |
2728 | va_end (args); |
2829 | return NULL; |
2729 | return NULL; |
2830 | } |
2730 | } |
2831 | } |
2731 | } |
… | |
… | |
2845 | cfapi_object_insert (int *type, ...) |
2745 | cfapi_object_insert (int *type, ...) |
2846 | { |
2746 | { |
2847 | va_list args; |
2747 | va_list args; |
2848 | object *op; |
2748 | object *op; |
2849 | object *orig; |
2749 | object *orig; |
2850 | mapstruct *map; |
2750 | maptile *map; |
2851 | int flag, x, y; |
2751 | int flag, x, y; |
2852 | int itype; |
2752 | int itype; |
2853 | char *arch_string; |
2753 | char *arch_string; |
2854 | void *rv = NULL; |
2754 | void *rv = NULL; |
2855 | |
2755 | |
… | |
… | |
2859 | itype = va_arg (args, int); |
2759 | itype = va_arg (args, int); |
2860 | |
2760 | |
2861 | switch (itype) |
2761 | switch (itype) |
2862 | { |
2762 | { |
2863 | case 0: |
2763 | case 0: |
2864 | map = va_arg (args, mapstruct *); |
2764 | map = va_arg (args, maptile *); |
2865 | orig = va_arg (args, object *); |
2765 | orig = va_arg (args, object *); |
2866 | flag = va_arg (args, int); |
2766 | flag = va_arg (args, int); |
2867 | x = va_arg (args, int); |
2767 | x = va_arg (args, int); |
2868 | y = va_arg (args, int); |
2768 | y = va_arg (args, int); |
2869 | |
2769 | |
2870 | rv = insert_ob_in_map_at (op, map, orig, flag, x, y); |
2770 | rv = insert_ob_in_map_at (op, map, orig, flag, x, y); |
2871 | *type = CFAPI_POBJECT; |
2771 | *type = CFAPI_POBJECT; |
2872 | break; |
2772 | break; |
2873 | |
2773 | |
2874 | case 1: |
2774 | case 1: |
2875 | map = va_arg (args, mapstruct *); |
2775 | map = va_arg (args, maptile *); |
2876 | orig = va_arg (args, object *); |
2776 | orig = va_arg (args, object *); |
2877 | flag = va_arg (args, int); |
2777 | flag = va_arg (args, int); |
2878 | |
2778 | |
2879 | rv = insert_ob_in_map (op, map, orig, flag); |
2779 | rv = insert_ob_in_map (op, map, orig, flag); |
2880 | *type = CFAPI_POBJECT; |
2780 | *type = CFAPI_POBJECT; |
… | |
… | |
2990 | |
2890 | |
2991 | op = va_arg (args, object *); |
2891 | op = va_arg (args, object *); |
2992 | |
2892 | |
2993 | va_end (args); |
2893 | va_end (args); |
2994 | |
2894 | |
2995 | clear_object (op); |
2895 | op->clear (); |
2996 | *type = CFAPI_NONE; |
2896 | *type = CFAPI_NONE; |
2997 | return NULL; |
2897 | return NULL; |
2998 | } |
2898 | } |
2999 | |
2899 | |
3000 | void * |
2900 | void * |
… | |
… | |
3266 | object *op; |
3166 | object *op; |
3267 | object *originator; |
3167 | object *originator; |
3268 | int x, y, randompos, ttype; |
3168 | int x, y, randompos, ttype; |
3269 | va_list args; |
3169 | va_list args; |
3270 | static int rv = 0; |
3170 | static int rv = 0; |
3271 | mapstruct *map; |
3171 | maptile *map; |
3272 | |
3172 | |
3273 | va_start (args, type); |
3173 | va_start (args, type); |
3274 | op = va_arg (args, object *); |
3174 | op = va_arg (args, object *); |
3275 | ttype = va_arg (args, int); |
3175 | ttype = va_arg (args, int); |
3276 | |
3176 | |
… | |
… | |
3290 | break; |
3190 | break; |
3291 | |
3191 | |
3292 | case 1: |
3192 | case 1: |
3293 | x = va_arg (args, int); |
3193 | x = va_arg (args, int); |
3294 | y = va_arg (args, int); |
3194 | y = va_arg (args, int); |
3295 | map = va_arg (args, mapstruct *); |
3195 | map = va_arg (args, maptile *); |
3296 | |
3196 | |
3297 | va_end (args); |
3197 | va_end (args); |
3298 | if (x < 0 || y < 0) |
3198 | if (x < 0 || y < 0) |
3299 | { |
3199 | { |
3300 | x = map->enter_x; |
3200 | x = map->enter_x; |
3301 | y = map->enter_y; |
3201 | y = map->enter_y; |
3302 | } |
3202 | } |
3303 | |
3203 | |
3304 | /* |
3204 | /* |
3305 | originator = get_object(); |
3205 | originator = object::create(); |
3306 | EXIT_PATH(originator) = add_string(map->path); |
3206 | EXIT_PATH(originator) = add_string(map->path); |
3307 | EXIT_X(originator) = x; |
3207 | EXIT_X(originator) = x; |
3308 | EXIT_Y(originator) = y; |
3208 | EXIT_Y(originator) = y; |
3309 | printf("B Transfer: X=%d, Y=%d, OP=%s\n", x, y, op->name);*/ |
3209 | printf("B Transfer: X=%d, Y=%d, OP=%s\n", x, y, op->name);*/ |
3310 | /*enter_exit(op, originator); */ |
3210 | /*enter_exit(op, originator); */ |
3311 | insert_ob_in_map_at (op, map, NULL, 0, x, y); |
3211 | 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); |
3212 | /*printf("A Transfer: X=%d, Y=%d, MAP=%s\n", x, y, op->map->name); |
3313 | free_object(originator); |
3213 | originator->destroy (); |
3314 | */ |
3214 | */ |
3315 | *type = CFAPI_INT; |
3215 | *type = CFAPI_INT; |
3316 | return &rv; |
3216 | return &rv; |
3317 | break; |
3217 | break; |
3318 | |
3218 | |
… | |
… | |
3391 | drop (author, op); |
3291 | drop (author, op); |
3392 | |
3292 | |
3393 | if (author->type == PLAYER) |
3293 | if (author->type == PLAYER) |
3394 | { |
3294 | { |
3395 | author->contr->count = 0; |
3295 | author->contr->count = 0; |
3396 | author->contr->socket.update_look = 1; |
3296 | author->contr->ns->floorbox_update (); |
3397 | } |
3297 | } |
3398 | |
3298 | |
3399 | *type = CFAPI_NONE; |
3299 | *type = CFAPI_NONE; |
3400 | return NULL; |
3300 | return NULL; |
3401 | } |
3301 | } |
… | |
… | |
3482 | } |
3382 | } |
3483 | |
3383 | |
3484 | void * |
3384 | void * |
3485 | cfapi_object_teleport (int *type, ...) |
3385 | cfapi_object_teleport (int *type, ...) |
3486 | { |
3386 | { |
3487 | mapstruct *map; |
3387 | maptile *map; |
3488 | int x, y; |
3388 | int x, y; |
3489 | object *who; |
3389 | object *who; |
3490 | static int result; |
3390 | static int result; |
3491 | va_list args; |
3391 | va_list args; |
3492 | |
3392 | |
3493 | va_start (args, type); |
3393 | va_start (args, type); |
3494 | who = va_arg (args, object *); |
3394 | who = va_arg (args, object *); |
3495 | map = va_arg (args, mapstruct *); |
3395 | map = va_arg (args, maptile *); |
3496 | x = va_arg (args, int); |
3396 | x = va_arg (args, int); |
3497 | y = va_arg (args, int); |
3397 | y = va_arg (args, int); |
3498 | |
3398 | |
3499 | if (!out_of_map (map, x, y)) |
3399 | if (!out_of_map (map, x, y)) |
3500 | { |
3400 | { |
… | |
… | |
3507 | result = 1; |
3407 | result = 1; |
3508 | return &result; |
3408 | return &result; |
3509 | } |
3409 | } |
3510 | |
3410 | |
3511 | send_removed_object (who); |
3411 | send_removed_object (who); |
3512 | remove_ob (who); |
3412 | who->remove (); |
3513 | |
3413 | |
3514 | for (tmp = who; tmp != NULL; tmp = tmp->more) |
3414 | for (tmp = who; tmp != NULL; tmp = tmp->more) |
3515 | tmp->x = x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x), |
3415 | 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); |
3416 | tmp->y = y + freearr_y[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y); |
3517 | |
3417 | |
… | |
… | |
3634 | |
3534 | |
3635 | case CFAPI_PARTY_PROP_PLAYER: |
3535 | case CFAPI_PARTY_PROP_PLAYER: |
3636 | *type = CFAPI_PPLAYER; |
3536 | *type = CFAPI_PPLAYER; |
3637 | obarg = va_arg (args, object *); |
3537 | obarg = va_arg (args, object *); |
3638 | |
3538 | |
3639 | pl = (obarg ? obarg->contr : first_player); |
3539 | pl = (obarg ? (player *)obarg->contr : first_player); |
3640 | rv = NULL; |
3540 | rv = NULL; |
3641 | for (; pl != NULL; pl = pl->next) |
3541 | for (; pl != NULL; pl = pl->next) |
3642 | if (pl->ob->contr->party == party) |
3542 | if (pl->ob->contr->party == party) |
3643 | { |
3543 | { |
3644 | rv = (void *) pl; |
3544 | rv = (void *) pl; |