ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/plugins.C
(Generate patch)

Comparing deliantra/server/server/plugins.C (file contents):
Revision 1.14 by root, Thu Sep 14 21:16:12 2006 UTC vs.
Revision 1.23 by root, Wed Dec 13 03:28:42 2006 UTC

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
80static const hook_entry plug_hooks[NR_OF_HOOKS] = { 43static 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_local, 6, "cfapi_system_strdup_local"},
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"},
158 121
159/* NEW PLUGIN STUFF STARTS HERE */ 122/* NEW PLUGIN STUFF STARTS HERE */
160 123
161/*****************************************************************************/ 124/*****************************************************************************/
162 125
163#ifdef WIN32
164static const char *
165plugins_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 */
612 *type = CFAPI_INT; 556 *type = CFAPI_INT;
613 return &rv; 557 return &rv;
614} 558}
615 559
616void * 560void *
617cfapi_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
636void *
637cfapi_system_directory (int *type, ...) 561cfapi_system_directory (int *type, ...)
638{ 562{
639 va_list args; 563 va_list args;
640 int dirtype; 564 int dirtype;
641 565
687 611
688void * 612void *
689cfapi_map_get_map (int *type, ...) 613cfapi_map_get_map (int *type, ...)
690{ 614{
691 va_list args; 615 va_list args;
692 mapstruct *rv; 616 maptile *rv;
693 int ctype; 617 int ctype;
694 int x, y; 618 int x, y;
695 sint16 nx, ny; 619 sint16 nx, ny;
696 char *name; 620 char *name;
697 mapstruct *m; 621 maptile *m;
698 622
699 va_start (args, type); 623 va_start (args, type);
700 624
701 ctype = va_arg (args, int); 625 ctype = va_arg (args, int);
702 626
715 639
716 rv = ready_map_name (name, x); 640 rv = ready_map_name (name, x);
717 break; 641 break;
718 642
719 case 2: 643 case 2:
720 m = va_arg (args, mapstruct *); 644 m = va_arg (args, maptile *);
721 nx = va_arg (args, int); 645 nx = va_arg (args, int);
722 ny = va_arg (args, int); 646 ny = va_arg (args, int);
723 647
724 rv = get_map_from_coord (m, &nx, &ny); 648 rv = get_map_from_coord (m, &nx, &ny);
725 break; 649 break;
741 665
742void * 666void *
743cfapi_map_has_been_loaded (int *type, ...) 667cfapi_map_has_been_loaded (int *type, ...)
744{ 668{
745 va_list args; 669 va_list args;
746 mapstruct *map; 670 maptile *map;
747 char *string; 671 char *string;
748 672
749 va_start (args, type); 673 va_start (args, type);
750 string = va_arg (args, char *); 674 string = va_arg (args, char *);
751 675
797cfapi_map_get_map_property (int *type, ...) 721cfapi_map_get_map_property (int *type, ...)
798{ 722{
799 va_list args; 723 va_list args;
800 int x, y; 724 int x, y;
801 sint16 nx, ny; 725 sint16 nx, ny;
802 mapstruct *map; 726 maptile *map;
803 mapstruct *newmap; 727 maptile *newmap;
804 static int rv; 728 static int rv;
805 int property; 729 int property;
806 char *buf; 730 char *buf;
807 731
808 va_start (args, type); 732 va_start (args, type);
810 property = va_arg (args, int); 734 property = va_arg (args, int);
811 735
812 switch (property) 736 switch (property)
813 { 737 {
814 case CFAPI_MAP_PROP_FLAGS: 738 case CFAPI_MAP_PROP_FLAGS:
815 map = va_arg (args, mapstruct *); 739 map = va_arg (args, maptile *);
816 newmap = va_arg (args, mapstruct *); 740 newmap = va_arg (args, maptile *);
817 x = va_arg (args, int); 741 x = va_arg (args, int);
818 y = va_arg (args, int); 742 y = va_arg (args, int);
819 nx = va_arg (args, int); 743 nx = va_arg (args, int);
820 ny = va_arg (args, int); 744 ny = va_arg (args, int);
821 745
824 *type = CFAPI_INT; 748 *type = CFAPI_INT;
825 return &rv; 749 return &rv;
826 break; 750 break;
827 751
828 case CFAPI_MAP_PROP_DIFFICULTY: 752 case CFAPI_MAP_PROP_DIFFICULTY:
829 map = va_arg (args, mapstruct *); 753 map = va_arg (args, maptile *);
830 754
831 rv = calculate_difficulty (map); 755 rv = calculate_difficulty (map);
832 va_end (args); 756 va_end (args);
833 *type = CFAPI_INT; 757 *type = CFAPI_INT;
834 return &rv; 758 return &rv;
835 break; 759 break;
836 760
837 case CFAPI_MAP_PROP_PATH: 761 case CFAPI_MAP_PROP_PATH:
838 map = va_arg (args, mapstruct *); 762 map = va_arg (args, maptile *);
839 763
840 buf = map->path; 764 buf = map->path;
841 *type = CFAPI_STRING; 765 *type = CFAPI_STRING;
842 va_end (args); 766 va_end (args);
843 return buf; 767 return buf;
844 break; 768 break;
845 769
846 case CFAPI_MAP_PROP_TMPNAME: 770 case CFAPI_MAP_PROP_TMPNAME:
847 map = va_arg (args, mapstruct *); 771 map = va_arg (args, maptile *);
848 772
849 buf = map->tmpname; 773 buf = map->tmpname;
850 *type = CFAPI_STRING; 774 *type = CFAPI_STRING;
851 va_end (args); 775 va_end (args);
852 return buf; 776 return buf;
853 break; 777 break;
854 778
855 case CFAPI_MAP_PROP_NAME: 779 case CFAPI_MAP_PROP_NAME:
856 map = va_arg (args, mapstruct *); 780 map = va_arg (args, maptile *);
857 781
858 buf = map->name; 782 buf = map->name;
859 *type = CFAPI_STRING; 783 *type = CFAPI_STRING;
860 va_end (args); 784 va_end (args);
861 return buf; 785 return buf;
862 break; 786 break;
863 787
864 case CFAPI_MAP_PROP_RESET_TIME: 788 case CFAPI_MAP_PROP_RESET_TIME:
865 map = va_arg (args, mapstruct *); 789 map = va_arg (args, maptile *);
866 790
867 rv = map->reset_time; 791 rv = map->reset_time;
868 *type = CFAPI_INT; 792 *type = CFAPI_INT;
869 va_end (args); 793 va_end (args);
870 return &rv; 794 return &rv;
871 break; 795 break;
872 796
873 case CFAPI_MAP_PROP_RESET_TIMEOUT: 797 case CFAPI_MAP_PROP_RESET_TIMEOUT:
874 map = va_arg (args, mapstruct *); 798 map = va_arg (args, maptile *);
875 799
876 rv = map->reset_timeout; 800 rv = map->reset_timeout;
877 *type = CFAPI_INT; 801 *type = CFAPI_INT;
878 va_end (args); 802 va_end (args);
879 return &rv; 803 return &rv;
880 break; 804 break;
881 805
882 case CFAPI_MAP_PROP_PLAYERS: 806 case CFAPI_MAP_PROP_PLAYERS:
883 map = va_arg (args, mapstruct *); 807 map = va_arg (args, maptile *);
884 808
885 rv = map->players; 809 rv = map->players;
886 *type = CFAPI_INT; 810 *type = CFAPI_INT;
887 va_end (args); 811 va_end (args);
888 return &rv; 812 return &rv;
889 break; 813 break;
890 814
891 case CFAPI_MAP_PROP_DARKNESS: 815 case CFAPI_MAP_PROP_DARKNESS:
892 map = va_arg (args, mapstruct *); 816 map = va_arg (args, maptile *);
893 817
894 rv = map->darkness; 818 rv = map->darkness;
895 *type = CFAPI_INT; 819 *type = CFAPI_INT;
896 va_end (args); 820 va_end (args);
897 return &rv; 821 return &rv;
898 break; 822 break;
899 823
900 case CFAPI_MAP_PROP_WIDTH: 824 case CFAPI_MAP_PROP_WIDTH:
901 map = va_arg (args, mapstruct *); 825 map = va_arg (args, maptile *);
902 826
903 rv = map->width; 827 rv = map->width;
904 *type = CFAPI_INT; 828 *type = CFAPI_INT;
905 va_end (args); 829 va_end (args);
906 return &rv; 830 return &rv;
907 break; 831 break;
908 832
909 case CFAPI_MAP_PROP_HEIGHT: 833 case CFAPI_MAP_PROP_HEIGHT:
910 map = va_arg (args, mapstruct *); 834 map = va_arg (args, maptile *);
911 835
912 rv = map->height; 836 rv = map->height;
913 *type = CFAPI_INT; 837 *type = CFAPI_INT;
914 va_end (args); 838 va_end (args);
915 return &rv; 839 return &rv;
916 break; 840 break;
917 841
918 case CFAPI_MAP_PROP_ENTER_X: 842 case CFAPI_MAP_PROP_ENTER_X:
919 map = va_arg (args, mapstruct *); 843 map = va_arg (args, maptile *);
920 844
921 rv = map->enter_x; 845 rv = map->enter_x;
922 *type = CFAPI_INT; 846 *type = CFAPI_INT;
923 va_end (args); 847 va_end (args);
924 return &rv; 848 return &rv;
925 break; 849 break;
926 850
927 case CFAPI_MAP_PROP_ENTER_Y: 851 case CFAPI_MAP_PROP_ENTER_Y:
928 map = va_arg (args, mapstruct *); 852 map = va_arg (args, maptile *);
929 853
930 rv = map->enter_y; 854 rv = map->enter_y;
931 *type = CFAPI_INT; 855 *type = CFAPI_INT;
932 va_end (args); 856 va_end (args);
933 return &rv; 857 return &rv;
934 break; 858 break;
935 859
936 case CFAPI_MAP_PROP_TEMPERATURE: 860 case CFAPI_MAP_PROP_TEMPERATURE:
937 map = va_arg (args, mapstruct *); 861 map = va_arg (args, maptile *);
938 862
939 rv = map->temp; 863 rv = map->temp;
940 *type = CFAPI_INT; 864 *type = CFAPI_INT;
941 va_end (args); 865 va_end (args);
942 return &rv; 866 return &rv;
943 break; 867 break;
944 868
945 case CFAPI_MAP_PROP_PRESSURE: 869 case CFAPI_MAP_PROP_PRESSURE:
946 map = va_arg (args, mapstruct *); 870 map = va_arg (args, maptile *);
947 871
948 rv = map->pressure; 872 rv = map->pressure;
949 *type = CFAPI_INT; 873 *type = CFAPI_INT;
950 va_end (args); 874 va_end (args);
951 return &rv; 875 return &rv;
952 break; 876 break;
953 877
954 case CFAPI_MAP_PROP_HUMIDITY: 878 case CFAPI_MAP_PROP_HUMIDITY:
955 map = va_arg (args, mapstruct *); 879 map = va_arg (args, maptile *);
956 880
957 rv = map->humid; 881 rv = map->humid;
958 *type = CFAPI_INT; 882 *type = CFAPI_INT;
959 va_end (args); 883 va_end (args);
960 return &rv; 884 return &rv;
961 break; 885 break;
962 886
963 case CFAPI_MAP_PROP_WINDSPEED: 887 case CFAPI_MAP_PROP_WINDSPEED:
964 map = va_arg (args, mapstruct *); 888 map = va_arg (args, maptile *);
965 889
966 rv = map->windspeed; 890 rv = map->windspeed;
967 *type = CFAPI_INT; 891 *type = CFAPI_INT;
968 va_end (args); 892 va_end (args);
969 return &rv; 893 return &rv;
970 break; 894 break;
971 895
972 case CFAPI_MAP_PROP_WINDDIR: 896 case CFAPI_MAP_PROP_WINDDIR:
973 map = va_arg (args, mapstruct *); 897 map = va_arg (args, maptile *);
974 898
975 rv = map->winddir; 899 rv = map->winddir;
976 *type = CFAPI_INT; 900 *type = CFAPI_INT;
977 va_end (args); 901 va_end (args);
978 return &rv; 902 return &rv;
979 break; 903 break;
980 904
981 case CFAPI_MAP_PROP_SKY: 905 case CFAPI_MAP_PROP_SKY:
982 map = va_arg (args, mapstruct *); 906 map = va_arg (args, maptile *);
983 907
984 rv = map->sky; 908 rv = map->sky;
985 *type = CFAPI_INT; 909 *type = CFAPI_INT;
986 va_end (args); 910 va_end (args);
987 return &rv; 911 return &rv;
988 break; 912 break;
989 913
990 case CFAPI_MAP_PROP_WPARTX: 914 case CFAPI_MAP_PROP_WPARTX:
991 map = va_arg (args, mapstruct *); 915 map = va_arg (args, maptile *);
992 916
993 rv = map->wpartx; 917 rv = map->wpartx;
994 *type = CFAPI_INT; 918 *type = CFAPI_INT;
995 va_end (args); 919 va_end (args);
996 return &rv; 920 return &rv;
997 break; 921 break;
998 922
999 case CFAPI_MAP_PROP_WPARTY: 923 case CFAPI_MAP_PROP_WPARTY:
1000 map = va_arg (args, mapstruct *); 924 map = va_arg (args, maptile *);
1001 925
1002 rv = map->wparty; 926 rv = map->wparty;
1003 *type = CFAPI_INT; 927 *type = CFAPI_INT;
1004 va_end (args); 928 va_end (args);
1005 return &rv; 929 return &rv;
1006 break; 930 break;
1007 931
1008 case CFAPI_MAP_PROP_MESSAGE: 932 case CFAPI_MAP_PROP_MESSAGE:
1009 map = va_arg (args, mapstruct *); 933 map = va_arg (args, maptile *);
1010 934
1011 buf = map->msg; 935 buf = map->msg;
1012 *type = CFAPI_STRING; 936 *type = CFAPI_STRING;
1013 va_end (args); 937 va_end (args);
1014 return buf; 938 return buf;
1015 break; 939 break;
1016 940
1017 case CFAPI_MAP_PROP_NEXT: 941 case CFAPI_MAP_PROP_NEXT:
1018 map = va_arg (args, mapstruct *); 942 map = va_arg (args, maptile *);
1019 943
1020 *type = CFAPI_PMAP; 944 *type = CFAPI_PMAP;
1021 va_end (args); 945 va_end (args);
1022 return map->next; 946 return map->next;
1023 break; 947 break;
1024 948
1025 case CFAPI_MAP_PROP_REGION: 949 case CFAPI_MAP_PROP_REGION:
1026 map = va_arg (args, mapstruct *); 950 map = va_arg (args, maptile *);
1027 951
1028 *type = CFAPI_PREGION; 952 *type = CFAPI_PREGION;
1029 va_end (args); 953 va_end (args);
1030 return get_region_by_map (map); 954 return get_region_by_map (map);
1031 break; 955 break;
1041void * 965void *
1042cfapi_map_set_map_property (int *type, ...) 966cfapi_map_set_map_property (int *type, ...)
1043{ 967{
1044 va_list args; 968 va_list args;
1045 static int rv; 969 static int rv;
1046 mapstruct *map; 970 maptile *map;
1047 int val; 971 int val;
1048 int property; 972 int property;
1049 973
1050 va_start (args, type); 974 va_start (args, type);
1051 975
1052 property = va_arg (args, int); 976 property = va_arg (args, int);
1053 977
1054 switch (property) 978 switch (property)
1055 { 979 {
1056 case CFAPI_MAP_PROP_LIGHT: 980 case CFAPI_MAP_PROP_LIGHT:
1057 map = va_arg (args, mapstruct *); 981 map = va_arg (args, maptile *);
1058 val = va_arg (args, int); 982 val = va_arg (args, int);
1059 983
1060 rv = change_map_light (map, val); 984 rv = change_map_light (map, val);
1061 *type = CFAPI_INT; 985 *type = CFAPI_INT;
1062 va_end (args); 986 va_end (args);
1063 return &rv; 987 return &rv;
1064 break; 988 break;
1065 989
1066 case CFAPI_MAP_PROP_RESET_TIME: 990 case CFAPI_MAP_PROP_RESET_TIME:
1067 map = va_arg (args, mapstruct *); 991 map = va_arg (args, maptile *);
1068 992
1069 *type = CFAPI_NONE; 993 *type = CFAPI_NONE;
1070 va_end (args); 994 va_end (args);
1071 return NULL; 995 return NULL;
1072 break; 996 break;
1081void * 1005void *
1082cfapi_map_out_of_map (int *type, ...) 1006cfapi_map_out_of_map (int *type, ...)
1083{ 1007{
1084 va_list args; 1008 va_list args;
1085 static int rv; 1009 static int rv;
1086 mapstruct *map; 1010 maptile *map;
1087 int x, y; 1011 int x, y;
1088 1012
1089 va_start (args, type); 1013 va_start (args, type);
1090 map = va_arg (args, mapstruct *); 1014 map = va_arg (args, maptile *);
1091 x = va_arg (args, int); 1015 x = va_arg (args, int);
1092 y = va_arg (args, int); 1016 y = va_arg (args, int);
1093 1017
1094 rv = out_of_map (map, x, y); 1018 rv = out_of_map (map, x, y);
1095 va_end (args); 1019 va_end (args);
1099 1023
1100void * 1024void *
1101cfapi_map_update_position (int *type, ...) 1025cfapi_map_update_position (int *type, ...)
1102{ 1026{
1103 va_list args; 1027 va_list args;
1104 mapstruct *map; 1028 maptile *map;
1105 int x, y; 1029 int x, y;
1106 1030
1107 va_start (args, type); 1031 va_start (args, type);
1108 1032
1109 map = va_arg (args, mapstruct *); 1033 map = va_arg (args, maptile *);
1110 x = va_arg (args, int); 1034 x = va_arg (args, int);
1111 y = va_arg (args, int); 1035 y = va_arg (args, int);
1112 1036
1113 update_position (map, x, y); 1037 update_position (map, x, y);
1114 va_end (args); 1038 va_end (args);
1118 1042
1119void * 1043void *
1120cfapi_map_delete_map (int *type, ...) 1044cfapi_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
1136void * 1060void *
1137cfapi_map_message (int *type, ...) 1061cfapi_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
1156void * 1080void *
1157cfapi_map_get_object_at (int *type, ...) 1081cfapi_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
1177cfapi_map_get_flags (int *type, ...) 1101cfapi_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 *);
1204cfapi_map_present_arch_by_name (int *type, ...) 1128cfapi_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
2347 break; 2271 break;
2348 2272
2349 case CFAPI_OBJECT_PROP_OWNER: 2273 case CFAPI_OBJECT_PROP_OWNER:
2350 oparg = va_arg (args, object *); 2274 oparg = va_arg (args, object *);
2351 2275
2352 set_owner (op, oparg); 2276 op->set_owner (oparg);
2353 break; 2277 break;
2354 2278
2355 case CFAPI_OBJECT_PROP_CHEATER: 2279 case CFAPI_OBJECT_PROP_CHEATER:
2356 set_cheat (op); 2280 set_cheat (op);
2357 break; 2281 break;
2492 if (op->contr) 2416 if (op->contr)
2493 { 2417 {
2494 oparg = va_arg (args, object *); 2418 oparg = va_arg (args, object *);
2495 2419
2496 op->contr->mark = oparg; 2420 op->contr->mark = oparg;
2497 if (oparg)
2498 op->contr->mark_count = oparg->count;
2499 } 2421 }
2500 break; 2422 break;
2501 2423
2502 case CFAPI_PLAYER_PROP_PARTY: 2424 case CFAPI_PLAYER_PROP_PARTY:
2503 if (op->contr) 2425 if (op->contr)
2682 op = va_arg (args, object *); 2604 op = va_arg (args, object *);
2683 2605
2684 va_end (args); 2606 va_end (args);
2685 2607
2686 send_removed_object (op); 2608 send_removed_object (op);
2687 remove_ob (op); 2609 op->remove ();
2688 *type = CFAPI_NONE; 2610 *type = CFAPI_NONE;
2689 return NULL; 2611 return NULL;
2690} 2612}
2691 2613
2692void * 2614void *
2699 2621
2700 op = va_arg (args, object *); 2622 op = va_arg (args, object *);
2701 2623
2702 va_end (args); 2624 va_end (args);
2703 2625
2704 free_object (op); 2626 op->destroy ();
2705 2627
2706 *type = CFAPI_NONE; 2628 *type = CFAPI_NONE;
2707 return NULL; 2629 return NULL;
2708} 2630}
2709 2631
2726 *type = CFAPI_POBJECT; 2648 *type = CFAPI_POBJECT;
2727 return object_create_clone (op); 2649 return object_create_clone (op);
2728 } 2650 }
2729 else 2651 else
2730 { 2652 {
2731 object *tmp; 2653 object *tmp = op->clone ();
2732
2733 tmp = get_object ();
2734 copy_object (op, tmp);
2735 *type = CFAPI_POBJECT; 2654 *type = CFAPI_POBJECT;
2736 return tmp; 2655 return tmp;
2737 } 2656 }
2738} 2657}
2739void * 2658void *
2803 *type = CFAPI_POBJECT; 2722 *type = CFAPI_POBJECT;
2804 switch (ival) 2723 switch (ival)
2805 { 2724 {
2806 case 0: 2725 case 0:
2807 va_end (args); 2726 va_end (args);
2808 return get_object (); 2727 return object::create ();
2809 break; 2728 break;
2810 2729
2811 case 1: /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */ 2730 case 1: /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
2812 { 2731 {
2813 char *sval; 2732 char *sval;
2816 2735
2817 op = get_archetype_by_object_name (sval); 2736 op = get_archetype_by_object_name (sval);
2818 2737
2819 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) 2738 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0)
2820 { 2739 {
2821 free_object (op); 2740 op->destroy ();
2822 /* Try with archetype names... */ 2741 /* Try with archetype names... */
2823 op = get_archetype (sval); 2742 op = get_archetype (sval);
2824 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) 2743 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0)
2825 { 2744 {
2826 free_object (op); 2745 op->destroy ();
2827 *type = CFAPI_NONE; 2746 *type = CFAPI_NONE;
2828 va_end (args); 2747 va_end (args);
2829 return NULL; 2748 return NULL;
2830 } 2749 }
2831 } 2750 }
2845cfapi_object_insert (int *type, ...) 2764cfapi_object_insert (int *type, ...)
2846{ 2765{
2847 va_list args; 2766 va_list args;
2848 object *op; 2767 object *op;
2849 object *orig; 2768 object *orig;
2850 mapstruct *map; 2769 maptile *map;
2851 int flag, x, y; 2770 int flag, x, y;
2852 int itype; 2771 int itype;
2853 char *arch_string; 2772 char *arch_string;
2854 void *rv = NULL; 2773 void *rv = NULL;
2855 2774
2859 itype = va_arg (args, int); 2778 itype = va_arg (args, int);
2860 2779
2861 switch (itype) 2780 switch (itype)
2862 { 2781 {
2863 case 0: 2782 case 0:
2864 map = va_arg (args, mapstruct *); 2783 map = va_arg (args, maptile *);
2865 orig = va_arg (args, object *); 2784 orig = va_arg (args, object *);
2866 flag = va_arg (args, int); 2785 flag = va_arg (args, int);
2867 x = va_arg (args, int); 2786 x = va_arg (args, int);
2868 y = va_arg (args, int); 2787 y = va_arg (args, int);
2869 2788
2870 rv = insert_ob_in_map_at (op, map, orig, flag, x, y); 2789 rv = insert_ob_in_map_at (op, map, orig, flag, x, y);
2871 *type = CFAPI_POBJECT; 2790 *type = CFAPI_POBJECT;
2872 break; 2791 break;
2873 2792
2874 case 1: 2793 case 1:
2875 map = va_arg (args, mapstruct *); 2794 map = va_arg (args, maptile *);
2876 orig = va_arg (args, object *); 2795 orig = va_arg (args, object *);
2877 flag = va_arg (args, int); 2796 flag = va_arg (args, int);
2878 2797
2879 rv = insert_ob_in_map (op, map, orig, flag); 2798 rv = insert_ob_in_map (op, map, orig, flag);
2880 *type = CFAPI_POBJECT; 2799 *type = CFAPI_POBJECT;
2990 2909
2991 op = va_arg (args, object *); 2910 op = va_arg (args, object *);
2992 2911
2993 va_end (args); 2912 va_end (args);
2994 2913
2995 clear_object (op); 2914 op->clear ();
2996 *type = CFAPI_NONE; 2915 *type = CFAPI_NONE;
2997 return NULL; 2916 return NULL;
2998} 2917}
2999 2918
3000void * 2919void *
3266 object *op; 3185 object *op;
3267 object *originator; 3186 object *originator;
3268 int x, y, randompos, ttype; 3187 int x, y, randompos, ttype;
3269 va_list args; 3188 va_list args;
3270 static int rv = 0; 3189 static int rv = 0;
3271 mapstruct *map; 3190 maptile *map;
3272 3191
3273 va_start (args, type); 3192 va_start (args, type);
3274 op = va_arg (args, object *); 3193 op = va_arg (args, object *);
3275 ttype = va_arg (args, int); 3194 ttype = va_arg (args, int);
3276 3195
3290 break; 3209 break;
3291 3210
3292 case 1: 3211 case 1:
3293 x = va_arg (args, int); 3212 x = va_arg (args, int);
3294 y = va_arg (args, int); 3213 y = va_arg (args, int);
3295 map = va_arg (args, mapstruct *); 3214 map = va_arg (args, maptile *);
3296 3215
3297 va_end (args); 3216 va_end (args);
3298 if (x < 0 || y < 0) 3217 if (x < 0 || y < 0)
3299 { 3218 {
3300 x = map->enter_x; 3219 x = map->enter_x;
3301 y = map->enter_y; 3220 y = map->enter_y;
3302 } 3221 }
3303 3222
3304/* 3223/*
3305 originator = get_object(); 3224 originator = object::create();
3306 EXIT_PATH(originator) = add_string(map->path); 3225 EXIT_PATH(originator) = add_string(map->path);
3307 EXIT_X(originator) = x; 3226 EXIT_X(originator) = x;
3308 EXIT_Y(originator) = y; 3227 EXIT_Y(originator) = y;
3309 printf("B Transfer: X=%d, Y=%d, OP=%s\n", x, y, op->name);*/ 3228 printf("B Transfer: X=%d, Y=%d, OP=%s\n", x, y, op->name);*/
3310 /*enter_exit(op, originator); */ 3229 /*enter_exit(op, originator); */
3311 insert_ob_in_map_at (op, map, NULL, 0, x, y); 3230 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); 3231 /*printf("A Transfer: X=%d, Y=%d, MAP=%s\n", x, y, op->map->name);
3313 free_object(originator); 3232 originator->destroy ();
3314 */ 3233 */
3315 *type = CFAPI_INT; 3234 *type = CFAPI_INT;
3316 return &rv; 3235 return &rv;
3317 break; 3236 break;
3318 3237
3482} 3401}
3483 3402
3484void * 3403void *
3485cfapi_object_teleport (int *type, ...) 3404cfapi_object_teleport (int *type, ...)
3486{ 3405{
3487 mapstruct *map; 3406 maptile *map;
3488 int x, y; 3407 int x, y;
3489 object *who; 3408 object *who;
3490 static int result; 3409 static int result;
3491 va_list args; 3410 va_list args;
3492 3411
3493 va_start (args, type); 3412 va_start (args, type);
3494 who = va_arg (args, object *); 3413 who = va_arg (args, object *);
3495 map = va_arg (args, mapstruct *); 3414 map = va_arg (args, maptile *);
3496 x = va_arg (args, int); 3415 x = va_arg (args, int);
3497 y = va_arg (args, int); 3416 y = va_arg (args, int);
3498 3417
3499 if (!out_of_map (map, x, y)) 3418 if (!out_of_map (map, x, y))
3500 { 3419 {
3507 result = 1; 3426 result = 1;
3508 return &result; 3427 return &result;
3509 } 3428 }
3510 3429
3511 send_removed_object (who); 3430 send_removed_object (who);
3512 remove_ob (who); 3431 who->remove ();
3513 3432
3514 for (tmp = who; tmp != NULL; tmp = tmp->more) 3433 for (tmp = who; tmp != NULL; tmp = tmp->more)
3515 tmp->x = x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x), 3434 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); 3435 tmp->y = y + freearr_y[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y);
3517 3436

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines