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.15 by root, Thu Sep 14 22:34:04 2006 UTC vs.
Revision 1.21 by root, Tue Dec 12 21:39:57 2006 UTC

42 42
43static const hook_entry plug_hooks[NR_OF_HOOKS] = { 43static const hook_entry plug_hooks[NR_OF_HOOKS] = {
44 {cfapi_system_register_global_event, 1, "cfapi_system_register_global_event"}, 44 {cfapi_system_register_global_event, 1, "cfapi_system_register_global_event"},
45 {cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event"}, 45 {cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event"},
46 {cfapi_system_check_path, 4, "cfapi_system_check_path"}, 46 {cfapi_system_check_path, 4, "cfapi_system_check_path"},
47 {cfapi_system_re_cmp, 5, "cfapi_system_re_cmp"}, 47 {NULL, 5, "cfapi_system_re_cmp"},
48 {cfapi_system_strdup_local, 6, "cfapi_system_strdup_local"}, 48 {cfapi_system_strdup_local, 6, "cfapi_system_strdup_local"},
49 {cfapi_system_directory, 7, "cfapi_system_directory"}, 49 {cfapi_system_directory, 7, "cfapi_system_directory"},
50 {cfapi_system_find_animation, 8, "cfapi_system_find_animation"}, 50 {cfapi_system_find_animation, 8, "cfapi_system_find_animation"},
51 {cfapi_object_clean_object, 9, "cfapi_object_clean_object"}, 51 {cfapi_object_clean_object, 9, "cfapi_object_clean_object"},
52 {cfapi_object_on_same_map, 10, "cfapi_object_on_same_map"}, 52 {cfapi_object_on_same_map, 10, "cfapi_object_on_same_map"},
121 121
122/* NEW PLUGIN STUFF STARTS HERE */ 122/* NEW PLUGIN STUFF STARTS HERE */
123 123
124/*****************************************************************************/ 124/*****************************************************************************/
125 125
126#ifdef WIN32
127static const char *
128plugins_dlerror (void)
129{
130 static char buf[256];
131 DWORD err;
132 char *p;
133
134 err = GetLastError ();
135 if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, buf, sizeof (buf), NULL) == 0)
136 snprintf (buf, sizeof (buf), "error %lu", err);
137 p = strchr (buf, '\0');
138 while (p > buf && (p[-1] == '\r' || p[-1] == '\n'))
139 p--;
140 *p = '\0';
141 return buf;
142}
143#endif /* WIN32 */
144
145/** 126/**
146 * Notify clients about a changed object. 127 * Notify clients about a changed object.
147 * 128 *
148 * @param op the object that has changed 129 * @param op the object that has changed
149 */ 130 */
575 *type = CFAPI_INT; 556 *type = CFAPI_INT;
576 return &rv; 557 return &rv;
577} 558}
578 559
579void * 560void *
580cfapi_system_re_cmp (int *type, ...)
581{
582 va_list args;
583 char *rv;
584 const char *str;
585 const char *regexp;
586
587 va_start (args, type);
588
589 str = va_arg (args, char *);
590 regexp = va_arg (args, char *);
591
592 rv = (char *) re_cmp (str, regexp);
593
594 va_end (args);
595 *type = CFAPI_STRING;
596 return rv;
597}
598
599void *
600cfapi_system_directory (int *type, ...) 561cfapi_system_directory (int *type, ...)
601{ 562{
602 va_list args; 563 va_list args;
603 int dirtype; 564 int dirtype;
604 565
650 611
651void * 612void *
652cfapi_map_get_map (int *type, ...) 613cfapi_map_get_map (int *type, ...)
653{ 614{
654 va_list args; 615 va_list args;
655 mapstruct *rv; 616 maptile *rv;
656 int ctype; 617 int ctype;
657 int x, y; 618 int x, y;
658 sint16 nx, ny; 619 sint16 nx, ny;
659 char *name; 620 char *name;
660 mapstruct *m; 621 maptile *m;
661 622
662 va_start (args, type); 623 va_start (args, type);
663 624
664 ctype = va_arg (args, int); 625 ctype = va_arg (args, int);
665 626
678 639
679 rv = ready_map_name (name, x); 640 rv = ready_map_name (name, x);
680 break; 641 break;
681 642
682 case 2: 643 case 2:
683 m = va_arg (args, mapstruct *); 644 m = va_arg (args, maptile *);
684 nx = va_arg (args, int); 645 nx = va_arg (args, int);
685 ny = va_arg (args, int); 646 ny = va_arg (args, int);
686 647
687 rv = get_map_from_coord (m, &nx, &ny); 648 rv = get_map_from_coord (m, &nx, &ny);
688 break; 649 break;
704 665
705void * 666void *
706cfapi_map_has_been_loaded (int *type, ...) 667cfapi_map_has_been_loaded (int *type, ...)
707{ 668{
708 va_list args; 669 va_list args;
709 mapstruct *map; 670 maptile *map;
710 char *string; 671 char *string;
711 672
712 va_start (args, type); 673 va_start (args, type);
713 string = va_arg (args, char *); 674 string = va_arg (args, char *);
714 675
760cfapi_map_get_map_property (int *type, ...) 721cfapi_map_get_map_property (int *type, ...)
761{ 722{
762 va_list args; 723 va_list args;
763 int x, y; 724 int x, y;
764 sint16 nx, ny; 725 sint16 nx, ny;
765 mapstruct *map; 726 maptile *map;
766 mapstruct *newmap; 727 maptile *newmap;
767 static int rv; 728 static int rv;
768 int property; 729 int property;
769 char *buf; 730 char *buf;
770 731
771 va_start (args, type); 732 va_start (args, type);
773 property = va_arg (args, int); 734 property = va_arg (args, int);
774 735
775 switch (property) 736 switch (property)
776 { 737 {
777 case CFAPI_MAP_PROP_FLAGS: 738 case CFAPI_MAP_PROP_FLAGS:
778 map = va_arg (args, mapstruct *); 739 map = va_arg (args, maptile *);
779 newmap = va_arg (args, mapstruct *); 740 newmap = va_arg (args, maptile *);
780 x = va_arg (args, int); 741 x = va_arg (args, int);
781 y = va_arg (args, int); 742 y = va_arg (args, int);
782 nx = va_arg (args, int); 743 nx = va_arg (args, int);
783 ny = va_arg (args, int); 744 ny = va_arg (args, int);
784 745
787 *type = CFAPI_INT; 748 *type = CFAPI_INT;
788 return &rv; 749 return &rv;
789 break; 750 break;
790 751
791 case CFAPI_MAP_PROP_DIFFICULTY: 752 case CFAPI_MAP_PROP_DIFFICULTY:
792 map = va_arg (args, mapstruct *); 753 map = va_arg (args, maptile *);
793 754
794 rv = calculate_difficulty (map); 755 rv = calculate_difficulty (map);
795 va_end (args); 756 va_end (args);
796 *type = CFAPI_INT; 757 *type = CFAPI_INT;
797 return &rv; 758 return &rv;
798 break; 759 break;
799 760
800 case CFAPI_MAP_PROP_PATH: 761 case CFAPI_MAP_PROP_PATH:
801 map = va_arg (args, mapstruct *); 762 map = va_arg (args, maptile *);
802 763
803 buf = map->path; 764 buf = map->path;
804 *type = CFAPI_STRING; 765 *type = CFAPI_STRING;
805 va_end (args); 766 va_end (args);
806 return buf; 767 return buf;
807 break; 768 break;
808 769
809 case CFAPI_MAP_PROP_TMPNAME: 770 case CFAPI_MAP_PROP_TMPNAME:
810 map = va_arg (args, mapstruct *); 771 map = va_arg (args, maptile *);
811 772
812 buf = map->tmpname; 773 buf = map->tmpname;
813 *type = CFAPI_STRING; 774 *type = CFAPI_STRING;
814 va_end (args); 775 va_end (args);
815 return buf; 776 return buf;
816 break; 777 break;
817 778
818 case CFAPI_MAP_PROP_NAME: 779 case CFAPI_MAP_PROP_NAME:
819 map = va_arg (args, mapstruct *); 780 map = va_arg (args, maptile *);
820 781
821 buf = map->name; 782 buf = map->name;
822 *type = CFAPI_STRING; 783 *type = CFAPI_STRING;
823 va_end (args); 784 va_end (args);
824 return buf; 785 return buf;
825 break; 786 break;
826 787
827 case CFAPI_MAP_PROP_RESET_TIME: 788 case CFAPI_MAP_PROP_RESET_TIME:
828 map = va_arg (args, mapstruct *); 789 map = va_arg (args, maptile *);
829 790
830 rv = map->reset_time; 791 rv = map->reset_time;
831 *type = CFAPI_INT; 792 *type = CFAPI_INT;
832 va_end (args); 793 va_end (args);
833 return &rv; 794 return &rv;
834 break; 795 break;
835 796
836 case CFAPI_MAP_PROP_RESET_TIMEOUT: 797 case CFAPI_MAP_PROP_RESET_TIMEOUT:
837 map = va_arg (args, mapstruct *); 798 map = va_arg (args, maptile *);
838 799
839 rv = map->reset_timeout; 800 rv = map->reset_timeout;
840 *type = CFAPI_INT; 801 *type = CFAPI_INT;
841 va_end (args); 802 va_end (args);
842 return &rv; 803 return &rv;
843 break; 804 break;
844 805
845 case CFAPI_MAP_PROP_PLAYERS: 806 case CFAPI_MAP_PROP_PLAYERS:
846 map = va_arg (args, mapstruct *); 807 map = va_arg (args, maptile *);
847 808
848 rv = map->players; 809 rv = map->players;
849 *type = CFAPI_INT; 810 *type = CFAPI_INT;
850 va_end (args); 811 va_end (args);
851 return &rv; 812 return &rv;
852 break; 813 break;
853 814
854 case CFAPI_MAP_PROP_DARKNESS: 815 case CFAPI_MAP_PROP_DARKNESS:
855 map = va_arg (args, mapstruct *); 816 map = va_arg (args, maptile *);
856 817
857 rv = map->darkness; 818 rv = map->darkness;
858 *type = CFAPI_INT; 819 *type = CFAPI_INT;
859 va_end (args); 820 va_end (args);
860 return &rv; 821 return &rv;
861 break; 822 break;
862 823
863 case CFAPI_MAP_PROP_WIDTH: 824 case CFAPI_MAP_PROP_WIDTH:
864 map = va_arg (args, mapstruct *); 825 map = va_arg (args, maptile *);
865 826
866 rv = map->width; 827 rv = map->width;
867 *type = CFAPI_INT; 828 *type = CFAPI_INT;
868 va_end (args); 829 va_end (args);
869 return &rv; 830 return &rv;
870 break; 831 break;
871 832
872 case CFAPI_MAP_PROP_HEIGHT: 833 case CFAPI_MAP_PROP_HEIGHT:
873 map = va_arg (args, mapstruct *); 834 map = va_arg (args, maptile *);
874 835
875 rv = map->height; 836 rv = map->height;
876 *type = CFAPI_INT; 837 *type = CFAPI_INT;
877 va_end (args); 838 va_end (args);
878 return &rv; 839 return &rv;
879 break; 840 break;
880 841
881 case CFAPI_MAP_PROP_ENTER_X: 842 case CFAPI_MAP_PROP_ENTER_X:
882 map = va_arg (args, mapstruct *); 843 map = va_arg (args, maptile *);
883 844
884 rv = map->enter_x; 845 rv = map->enter_x;
885 *type = CFAPI_INT; 846 *type = CFAPI_INT;
886 va_end (args); 847 va_end (args);
887 return &rv; 848 return &rv;
888 break; 849 break;
889 850
890 case CFAPI_MAP_PROP_ENTER_Y: 851 case CFAPI_MAP_PROP_ENTER_Y:
891 map = va_arg (args, mapstruct *); 852 map = va_arg (args, maptile *);
892 853
893 rv = map->enter_y; 854 rv = map->enter_y;
894 *type = CFAPI_INT; 855 *type = CFAPI_INT;
895 va_end (args); 856 va_end (args);
896 return &rv; 857 return &rv;
897 break; 858 break;
898 859
899 case CFAPI_MAP_PROP_TEMPERATURE: 860 case CFAPI_MAP_PROP_TEMPERATURE:
900 map = va_arg (args, mapstruct *); 861 map = va_arg (args, maptile *);
901 862
902 rv = map->temp; 863 rv = map->temp;
903 *type = CFAPI_INT; 864 *type = CFAPI_INT;
904 va_end (args); 865 va_end (args);
905 return &rv; 866 return &rv;
906 break; 867 break;
907 868
908 case CFAPI_MAP_PROP_PRESSURE: 869 case CFAPI_MAP_PROP_PRESSURE:
909 map = va_arg (args, mapstruct *); 870 map = va_arg (args, maptile *);
910 871
911 rv = map->pressure; 872 rv = map->pressure;
912 *type = CFAPI_INT; 873 *type = CFAPI_INT;
913 va_end (args); 874 va_end (args);
914 return &rv; 875 return &rv;
915 break; 876 break;
916 877
917 case CFAPI_MAP_PROP_HUMIDITY: 878 case CFAPI_MAP_PROP_HUMIDITY:
918 map = va_arg (args, mapstruct *); 879 map = va_arg (args, maptile *);
919 880
920 rv = map->humid; 881 rv = map->humid;
921 *type = CFAPI_INT; 882 *type = CFAPI_INT;
922 va_end (args); 883 va_end (args);
923 return &rv; 884 return &rv;
924 break; 885 break;
925 886
926 case CFAPI_MAP_PROP_WINDSPEED: 887 case CFAPI_MAP_PROP_WINDSPEED:
927 map = va_arg (args, mapstruct *); 888 map = va_arg (args, maptile *);
928 889
929 rv = map->windspeed; 890 rv = map->windspeed;
930 *type = CFAPI_INT; 891 *type = CFAPI_INT;
931 va_end (args); 892 va_end (args);
932 return &rv; 893 return &rv;
933 break; 894 break;
934 895
935 case CFAPI_MAP_PROP_WINDDIR: 896 case CFAPI_MAP_PROP_WINDDIR:
936 map = va_arg (args, mapstruct *); 897 map = va_arg (args, maptile *);
937 898
938 rv = map->winddir; 899 rv = map->winddir;
939 *type = CFAPI_INT; 900 *type = CFAPI_INT;
940 va_end (args); 901 va_end (args);
941 return &rv; 902 return &rv;
942 break; 903 break;
943 904
944 case CFAPI_MAP_PROP_SKY: 905 case CFAPI_MAP_PROP_SKY:
945 map = va_arg (args, mapstruct *); 906 map = va_arg (args, maptile *);
946 907
947 rv = map->sky; 908 rv = map->sky;
948 *type = CFAPI_INT; 909 *type = CFAPI_INT;
949 va_end (args); 910 va_end (args);
950 return &rv; 911 return &rv;
951 break; 912 break;
952 913
953 case CFAPI_MAP_PROP_WPARTX: 914 case CFAPI_MAP_PROP_WPARTX:
954 map = va_arg (args, mapstruct *); 915 map = va_arg (args, maptile *);
955 916
956 rv = map->wpartx; 917 rv = map->wpartx;
957 *type = CFAPI_INT; 918 *type = CFAPI_INT;
958 va_end (args); 919 va_end (args);
959 return &rv; 920 return &rv;
960 break; 921 break;
961 922
962 case CFAPI_MAP_PROP_WPARTY: 923 case CFAPI_MAP_PROP_WPARTY:
963 map = va_arg (args, mapstruct *); 924 map = va_arg (args, maptile *);
964 925
965 rv = map->wparty; 926 rv = map->wparty;
966 *type = CFAPI_INT; 927 *type = CFAPI_INT;
967 va_end (args); 928 va_end (args);
968 return &rv; 929 return &rv;
969 break; 930 break;
970 931
971 case CFAPI_MAP_PROP_MESSAGE: 932 case CFAPI_MAP_PROP_MESSAGE:
972 map = va_arg (args, mapstruct *); 933 map = va_arg (args, maptile *);
973 934
974 buf = map->msg; 935 buf = map->msg;
975 *type = CFAPI_STRING; 936 *type = CFAPI_STRING;
976 va_end (args); 937 va_end (args);
977 return buf; 938 return buf;
978 break; 939 break;
979 940
980 case CFAPI_MAP_PROP_NEXT: 941 case CFAPI_MAP_PROP_NEXT:
981 map = va_arg (args, mapstruct *); 942 map = va_arg (args, maptile *);
982 943
983 *type = CFAPI_PMAP; 944 *type = CFAPI_PMAP;
984 va_end (args); 945 va_end (args);
985 return map->next; 946 return map->next;
986 break; 947 break;
987 948
988 case CFAPI_MAP_PROP_REGION: 949 case CFAPI_MAP_PROP_REGION:
989 map = va_arg (args, mapstruct *); 950 map = va_arg (args, maptile *);
990 951
991 *type = CFAPI_PREGION; 952 *type = CFAPI_PREGION;
992 va_end (args); 953 va_end (args);
993 return get_region_by_map (map); 954 return get_region_by_map (map);
994 break; 955 break;
1004void * 965void *
1005cfapi_map_set_map_property (int *type, ...) 966cfapi_map_set_map_property (int *type, ...)
1006{ 967{
1007 va_list args; 968 va_list args;
1008 static int rv; 969 static int rv;
1009 mapstruct *map; 970 maptile *map;
1010 int val; 971 int val;
1011 int property; 972 int property;
1012 973
1013 va_start (args, type); 974 va_start (args, type);
1014 975
1015 property = va_arg (args, int); 976 property = va_arg (args, int);
1016 977
1017 switch (property) 978 switch (property)
1018 { 979 {
1019 case CFAPI_MAP_PROP_LIGHT: 980 case CFAPI_MAP_PROP_LIGHT:
1020 map = va_arg (args, mapstruct *); 981 map = va_arg (args, maptile *);
1021 val = va_arg (args, int); 982 val = va_arg (args, int);
1022 983
1023 rv = change_map_light (map, val); 984 rv = change_map_light (map, val);
1024 *type = CFAPI_INT; 985 *type = CFAPI_INT;
1025 va_end (args); 986 va_end (args);
1026 return &rv; 987 return &rv;
1027 break; 988 break;
1028 989
1029 case CFAPI_MAP_PROP_RESET_TIME: 990 case CFAPI_MAP_PROP_RESET_TIME:
1030 map = va_arg (args, mapstruct *); 991 map = va_arg (args, maptile *);
1031 992
1032 *type = CFAPI_NONE; 993 *type = CFAPI_NONE;
1033 va_end (args); 994 va_end (args);
1034 return NULL; 995 return NULL;
1035 break; 996 break;
1044void * 1005void *
1045cfapi_map_out_of_map (int *type, ...) 1006cfapi_map_out_of_map (int *type, ...)
1046{ 1007{
1047 va_list args; 1008 va_list args;
1048 static int rv; 1009 static int rv;
1049 mapstruct *map; 1010 maptile *map;
1050 int x, y; 1011 int x, y;
1051 1012
1052 va_start (args, type); 1013 va_start (args, type);
1053 map = va_arg (args, mapstruct *); 1014 map = va_arg (args, maptile *);
1054 x = va_arg (args, int); 1015 x = va_arg (args, int);
1055 y = va_arg (args, int); 1016 y = va_arg (args, int);
1056 1017
1057 rv = out_of_map (map, x, y); 1018 rv = out_of_map (map, x, y);
1058 va_end (args); 1019 va_end (args);
1062 1023
1063void * 1024void *
1064cfapi_map_update_position (int *type, ...) 1025cfapi_map_update_position (int *type, ...)
1065{ 1026{
1066 va_list args; 1027 va_list args;
1067 mapstruct *map; 1028 maptile *map;
1068 int x, y; 1029 int x, y;
1069 1030
1070 va_start (args, type); 1031 va_start (args, type);
1071 1032
1072 map = va_arg (args, mapstruct *); 1033 map = va_arg (args, maptile *);
1073 x = va_arg (args, int); 1034 x = va_arg (args, int);
1074 y = va_arg (args, int); 1035 y = va_arg (args, int);
1075 1036
1076 update_position (map, x, y); 1037 update_position (map, x, y);
1077 va_end (args); 1038 va_end (args);
1081 1042
1082void * 1043void *
1083cfapi_map_delete_map (int *type, ...) 1044cfapi_map_delete_map (int *type, ...)
1084{ 1045{
1085 va_list args; 1046 va_list args;
1086 mapstruct *map; 1047 maptile *map;
1087 1048
1088 va_start (args, type); 1049 va_start (args, type);
1089 1050
1090 map = va_arg (args, mapstruct *); 1051 map = va_arg (args, maptile *);
1091 1052
1092 delete_map (map); 1053 delete_map (map);
1093 1054
1094 va_end (args); 1055 va_end (args);
1095 *type = CFAPI_NONE; 1056 *type = CFAPI_NONE;
1098 1059
1099void * 1060void *
1100cfapi_map_message (int *type, ...) 1061cfapi_map_message (int *type, ...)
1101{ 1062{
1102 va_list args; 1063 va_list args;
1103 mapstruct *map; 1064 maptile *map;
1104 char *string; 1065 char *string;
1105 int color; 1066 int color;
1106 1067
1107 va_start (args, type); 1068 va_start (args, type);
1108 map = va_arg (args, mapstruct *); 1069 map = va_arg (args, maptile *);
1109 string = va_arg (args, char *); 1070 string = va_arg (args, char *);
1110 color = va_arg (args, int); 1071 color = va_arg (args, int);
1111 1072
1112 va_end (args); 1073 va_end (args);
1113 1074
1118 1079
1119void * 1080void *
1120cfapi_map_get_object_at (int *type, ...) 1081cfapi_map_get_object_at (int *type, ...)
1121{ 1082{
1122 va_list args; 1083 va_list args;
1123 mapstruct *map; 1084 maptile *map;
1124 int x, y; 1085 int x, y;
1125 object *rv; 1086 object *rv;
1126 1087
1127 va_start (args, type); 1088 va_start (args, type);
1128 map = va_arg (args, mapstruct *); 1089 map = va_arg (args, maptile *);
1129 x = va_arg (args, int); 1090 x = va_arg (args, int);
1130 y = va_arg (args, int); 1091 y = va_arg (args, int);
1131 1092
1132 va_end (args); 1093 va_end (args);
1133 1094
1140cfapi_map_get_flags (int *type, ...) 1101cfapi_map_get_flags (int *type, ...)
1141{ 1102{
1142 va_list args; 1103 va_list args;
1143 sint16 x, y; 1104 sint16 x, y;
1144 sint16 *nx, *ny; 1105 sint16 *nx, *ny;
1145 static mapstruct *map; 1106 static maptile *map;
1146 mapstruct **newmap; 1107 maptile **newmap;
1147 static int rv; 1108 static int rv;
1148 1109
1149 va_start (args, type); 1110 va_start (args, type);
1150 1111
1151 map = va_arg (args, mapstruct *); 1112 map = va_arg (args, maptile *);
1152 newmap = va_arg (args, mapstruct **); 1113 newmap = va_arg (args, maptile **);
1153 x = va_arg (args, int); 1114 x = va_arg (args, int);
1154 y = va_arg (args, int); 1115 y = va_arg (args, int);
1155 1116
1156 nx = va_arg (args, sint16 *); 1117 nx = va_arg (args, sint16 *);
1157 ny = va_arg (args, sint16 *); 1118 ny = va_arg (args, sint16 *);
1167cfapi_map_present_arch_by_name (int *type, ...) 1128cfapi_map_present_arch_by_name (int *type, ...)
1168{ 1129{
1169 va_list args; 1130 va_list args;
1170 object *rv; 1131 object *rv;
1171 int x, y; 1132 int x, y;
1172 mapstruct *map; 1133 maptile *map;
1173 char *msg; 1134 char *msg;
1174 1135
1175 va_start (args, type); 1136 va_start (args, type);
1176 1137
1177 msg = va_arg (args, char *); 1138 msg = va_arg (args, char *);
1178 map = va_arg (args, mapstruct *); 1139 map = va_arg (args, maptile *);
1179 x = va_arg (args, int); 1140 x = va_arg (args, int);
1180 y = va_arg (args, int); 1141 y = va_arg (args, int);
1181 1142
1182 va_end (args); 1143 va_end (args);
1183 1144
2455 if (op->contr) 2416 if (op->contr)
2456 { 2417 {
2457 oparg = va_arg (args, object *); 2418 oparg = va_arg (args, object *);
2458 2419
2459 op->contr->mark = oparg; 2420 op->contr->mark = oparg;
2460 if (oparg)
2461 op->contr->mark_count = oparg->count;
2462 } 2421 }
2463 break; 2422 break;
2464 2423
2465 case CFAPI_PLAYER_PROP_PARTY: 2424 case CFAPI_PLAYER_PROP_PARTY:
2466 if (op->contr) 2425 if (op->contr)
2645 op = va_arg (args, object *); 2604 op = va_arg (args, object *);
2646 2605
2647 va_end (args); 2606 va_end (args);
2648 2607
2649 send_removed_object (op); 2608 send_removed_object (op);
2650 remove_ob (op); 2609 op->remove ();
2651 *type = CFAPI_NONE; 2610 *type = CFAPI_NONE;
2652 return NULL; 2611 return NULL;
2653} 2612}
2654 2613
2655void * 2614void *
2662 2621
2663 op = va_arg (args, object *); 2622 op = va_arg (args, object *);
2664 2623
2665 va_end (args); 2624 va_end (args);
2666 2625
2667 free_object (op); 2626 op->destroy ();
2668 2627
2669 *type = CFAPI_NONE; 2628 *type = CFAPI_NONE;
2670 return NULL; 2629 return NULL;
2671} 2630}
2672 2631
2691 } 2650 }
2692 else 2651 else
2693 { 2652 {
2694 object *tmp; 2653 object *tmp;
2695 2654
2696 tmp = get_object (); 2655 tmp = object::create ();
2697 copy_object (op, tmp); 2656 op->copy_to (tmp);
2698 *type = CFAPI_POBJECT; 2657 *type = CFAPI_POBJECT;
2699 return tmp; 2658 return tmp;
2700 } 2659 }
2701} 2660}
2702void * 2661void *
2766 *type = CFAPI_POBJECT; 2725 *type = CFAPI_POBJECT;
2767 switch (ival) 2726 switch (ival)
2768 { 2727 {
2769 case 0: 2728 case 0:
2770 va_end (args); 2729 va_end (args);
2771 return get_object (); 2730 return object::create ();
2772 break; 2731 break;
2773 2732
2774 case 1: /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */ 2733 case 1: /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
2775 { 2734 {
2776 char *sval; 2735 char *sval;
2779 2738
2780 op = get_archetype_by_object_name (sval); 2739 op = get_archetype_by_object_name (sval);
2781 2740
2782 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) 2741 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0)
2783 { 2742 {
2784 free_object (op); 2743 op->destroy ();
2785 /* Try with archetype names... */ 2744 /* Try with archetype names... */
2786 op = get_archetype (sval); 2745 op = get_archetype (sval);
2787 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) 2746 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0)
2788 { 2747 {
2789 free_object (op); 2748 op->destroy ();
2790 *type = CFAPI_NONE; 2749 *type = CFAPI_NONE;
2791 va_end (args); 2750 va_end (args);
2792 return NULL; 2751 return NULL;
2793 } 2752 }
2794 } 2753 }
2808cfapi_object_insert (int *type, ...) 2767cfapi_object_insert (int *type, ...)
2809{ 2768{
2810 va_list args; 2769 va_list args;
2811 object *op; 2770 object *op;
2812 object *orig; 2771 object *orig;
2813 mapstruct *map; 2772 maptile *map;
2814 int flag, x, y; 2773 int flag, x, y;
2815 int itype; 2774 int itype;
2816 char *arch_string; 2775 char *arch_string;
2817 void *rv = NULL; 2776 void *rv = NULL;
2818 2777
2822 itype = va_arg (args, int); 2781 itype = va_arg (args, int);
2823 2782
2824 switch (itype) 2783 switch (itype)
2825 { 2784 {
2826 case 0: 2785 case 0:
2827 map = va_arg (args, mapstruct *); 2786 map = va_arg (args, maptile *);
2828 orig = va_arg (args, object *); 2787 orig = va_arg (args, object *);
2829 flag = va_arg (args, int); 2788 flag = va_arg (args, int);
2830 x = va_arg (args, int); 2789 x = va_arg (args, int);
2831 y = va_arg (args, int); 2790 y = va_arg (args, int);
2832 2791
2833 rv = insert_ob_in_map_at (op, map, orig, flag, x, y); 2792 rv = insert_ob_in_map_at (op, map, orig, flag, x, y);
2834 *type = CFAPI_POBJECT; 2793 *type = CFAPI_POBJECT;
2835 break; 2794 break;
2836 2795
2837 case 1: 2796 case 1:
2838 map = va_arg (args, mapstruct *); 2797 map = va_arg (args, maptile *);
2839 orig = va_arg (args, object *); 2798 orig = va_arg (args, object *);
2840 flag = va_arg (args, int); 2799 flag = va_arg (args, int);
2841 2800
2842 rv = insert_ob_in_map (op, map, orig, flag); 2801 rv = insert_ob_in_map (op, map, orig, flag);
2843 *type = CFAPI_POBJECT; 2802 *type = CFAPI_POBJECT;
3229 object *op; 3188 object *op;
3230 object *originator; 3189 object *originator;
3231 int x, y, randompos, ttype; 3190 int x, y, randompos, ttype;
3232 va_list args; 3191 va_list args;
3233 static int rv = 0; 3192 static int rv = 0;
3234 mapstruct *map; 3193 maptile *map;
3235 3194
3236 va_start (args, type); 3195 va_start (args, type);
3237 op = va_arg (args, object *); 3196 op = va_arg (args, object *);
3238 ttype = va_arg (args, int); 3197 ttype = va_arg (args, int);
3239 3198
3253 break; 3212 break;
3254 3213
3255 case 1: 3214 case 1:
3256 x = va_arg (args, int); 3215 x = va_arg (args, int);
3257 y = va_arg (args, int); 3216 y = va_arg (args, int);
3258 map = va_arg (args, mapstruct *); 3217 map = va_arg (args, maptile *);
3259 3218
3260 va_end (args); 3219 va_end (args);
3261 if (x < 0 || y < 0) 3220 if (x < 0 || y < 0)
3262 { 3221 {
3263 x = map->enter_x; 3222 x = map->enter_x;
3264 y = map->enter_y; 3223 y = map->enter_y;
3265 } 3224 }
3266 3225
3267/* 3226/*
3268 originator = get_object(); 3227 originator = object::create();
3269 EXIT_PATH(originator) = add_string(map->path); 3228 EXIT_PATH(originator) = add_string(map->path);
3270 EXIT_X(originator) = x; 3229 EXIT_X(originator) = x;
3271 EXIT_Y(originator) = y; 3230 EXIT_Y(originator) = y;
3272 printf("B Transfer: X=%d, Y=%d, OP=%s\n", x, y, op->name);*/ 3231 printf("B Transfer: X=%d, Y=%d, OP=%s\n", x, y, op->name);*/
3273 /*enter_exit(op, originator); */ 3232 /*enter_exit(op, originator); */
3274 insert_ob_in_map_at (op, map, NULL, 0, x, y); 3233 insert_ob_in_map_at (op, map, NULL, 0, x, y);
3275 /*printf("A Transfer: X=%d, Y=%d, MAP=%s\n", x, y, op->map->name); 3234 /*printf("A Transfer: X=%d, Y=%d, MAP=%s\n", x, y, op->map->name);
3276 free_object(originator); 3235 originator->destroy ();
3277 */ 3236 */
3278 *type = CFAPI_INT; 3237 *type = CFAPI_INT;
3279 return &rv; 3238 return &rv;
3280 break; 3239 break;
3281 3240
3445} 3404}
3446 3405
3447void * 3406void *
3448cfapi_object_teleport (int *type, ...) 3407cfapi_object_teleport (int *type, ...)
3449{ 3408{
3450 mapstruct *map; 3409 maptile *map;
3451 int x, y; 3410 int x, y;
3452 object *who; 3411 object *who;
3453 static int result; 3412 static int result;
3454 va_list args; 3413 va_list args;
3455 3414
3456 va_start (args, type); 3415 va_start (args, type);
3457 who = va_arg (args, object *); 3416 who = va_arg (args, object *);
3458 map = va_arg (args, mapstruct *); 3417 map = va_arg (args, maptile *);
3459 x = va_arg (args, int); 3418 x = va_arg (args, int);
3460 y = va_arg (args, int); 3419 y = va_arg (args, int);
3461 3420
3462 if (!out_of_map (map, x, y)) 3421 if (!out_of_map (map, x, y))
3463 { 3422 {
3470 result = 1; 3429 result = 1;
3471 return &result; 3430 return &result;
3472 } 3431 }
3473 3432
3474 send_removed_object (who); 3433 send_removed_object (who);
3475 remove_ob (who); 3434 who->remove ();
3476 3435
3477 for (tmp = who; tmp != NULL; tmp = tmp->more) 3436 for (tmp = who; tmp != NULL; tmp = tmp->more)
3478 tmp->x = x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x), 3437 tmp->x = x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x),
3479 tmp->y = y + freearr_y[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y); 3438 tmp->y = y + freearr_y[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y);
3480 3439

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines