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.31 by root, Thu Dec 21 23:37:06 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, 6, "cfapi_system_strdup"},
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"},
53 {cfapi_object_get_key, 11, "cfapi_object_get_key"}, 53 {cfapi_object_get_key, 11, "cfapi_object_get_key"},
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 */
151send_changed_object (object *op) 132send_changed_object (object *op)
152{ 133{
153 object *tmp; 134 object *tmp;
154 player *pl; 135 player *pl;
155 136
156 if (op->env != NULL) 137 if (op->env)
157 { 138 {
158 tmp = is_player_inv (op->env); 139 tmp = op->in_player ();
140
159 if (!tmp) 141 if (!tmp)
160 { 142 {
161 for (pl = first_player; pl; pl = pl->next) 143 for (pl = first_player; pl; pl = pl->next)
162 if (pl->ob->container == op->env) 144 if (pl->ob->container == op->env)
163 break; 145 break;
146
164 if (pl) 147 if (pl)
165 tmp = pl->ob; 148 tmp = pl->ob;
166 else 149 else
167 tmp = NULL; 150 tmp = NULL;
168 } 151 }
152
169 if (tmp) 153 if (tmp)
170 esrv_send_item (tmp, op); 154 esrv_send_item (tmp, op);
171 } 155 }
172 else 156 else
173 { 157 {
193 { 177 {
194 /* no action necessary: remove_ob() notifies the client */ 178 /* no action necessary: remove_ob() notifies the client */
195 return; 179 return;
196 } 180 }
197 181
198 tmp = is_player_inv (op->env); 182 tmp = op->in_player ();
199 if (!tmp) 183 if (!tmp)
200 { 184 {
201 for (pl = first_player; pl; pl = pl->next) 185 for (pl = first_player; pl; pl = pl->next)
202 if (pl->ob->container == op->env) 186 if (pl->ob->container == op->env)
203 break; 187 break;
501 *type = CFAPI_INT; 485 *type = CFAPI_INT;
502 return &rv; 486 return &rv;
503} 487}
504 488
505void * 489void *
506cfapi_system_strdup_local (int *type, ...) 490cfapi_system_strdup (int *type, ...)
507{ 491{
508 va_list args; 492 va_list args;
509 char *txt; 493 char *txt;
510 494
511 va_start (args, type); 495 va_start (args, type);
512 txt = va_arg (args, char *); 496 txt = va_arg (args, char *);
513 497
514 va_end (args); 498 va_end (args);
515 *type = CFAPI_STRING; 499 *type = CFAPI_STRING;
516 return strdup_local (txt); 500 return strdup (txt);
517} 501}
518 502
519void * 503void *
520cfapi_system_register_global_event (int *type, ...) 504cfapi_system_register_global_event (int *type, ...)
521{ 505{
575 *type = CFAPI_INT; 559 *type = CFAPI_INT;
576 return &rv; 560 return &rv;
577} 561}
578 562
579void * 563void *
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, ...) 564cfapi_system_directory (int *type, ...)
601{ 565{
602 va_list args; 566 va_list args;
603 int dirtype; 567 int dirtype;
604 568
650 614
651void * 615void *
652cfapi_map_get_map (int *type, ...) 616cfapi_map_get_map (int *type, ...)
653{ 617{
654 va_list args; 618 va_list args;
655 mapstruct *rv; 619 maptile *rv;
656 int ctype; 620 int ctype;
657 int x, y; 621 int x, y;
658 sint16 nx, ny; 622 sint16 nx, ny;
659 char *name; 623 char *name;
660 mapstruct *m; 624 maptile *m;
661 625
662 va_start (args, type); 626 va_start (args, type);
663 627
664 ctype = va_arg (args, int); 628 ctype = va_arg (args, int);
665 629
678 642
679 rv = ready_map_name (name, x); 643 rv = ready_map_name (name, x);
680 break; 644 break;
681 645
682 case 2: 646 case 2:
683 m = va_arg (args, mapstruct *); 647 m = va_arg (args, maptile *);
684 nx = va_arg (args, int); 648 nx = va_arg (args, int);
685 ny = va_arg (args, int); 649 ny = va_arg (args, int);
686 650
687 rv = get_map_from_coord (m, &nx, &ny); 651 rv = get_map_from_coord (m, &nx, &ny);
688 break; 652 break;
704 668
705void * 669void *
706cfapi_map_has_been_loaded (int *type, ...) 670cfapi_map_has_been_loaded (int *type, ...)
707{ 671{
708 va_list args; 672 va_list args;
709 mapstruct *map; 673 maptile *map;
710 char *string; 674 char *string;
711 675
712 va_start (args, type); 676 va_start (args, type);
713 string = va_arg (args, char *); 677 string = va_arg (args, char *);
714 678
760cfapi_map_get_map_property (int *type, ...) 724cfapi_map_get_map_property (int *type, ...)
761{ 725{
762 va_list args; 726 va_list args;
763 int x, y; 727 int x, y;
764 sint16 nx, ny; 728 sint16 nx, ny;
765 mapstruct *map; 729 maptile *map;
766 mapstruct *newmap; 730 maptile *newmap;
767 static int rv; 731 static int rv;
768 int property; 732 int property;
769 char *buf; 733 char *buf;
770 734
771 va_start (args, type); 735 va_start (args, type);
773 property = va_arg (args, int); 737 property = va_arg (args, int);
774 738
775 switch (property) 739 switch (property)
776 { 740 {
777 case CFAPI_MAP_PROP_FLAGS: 741 case CFAPI_MAP_PROP_FLAGS:
778 map = va_arg (args, mapstruct *); 742 map = va_arg (args, maptile *);
779 newmap = va_arg (args, mapstruct *); 743 newmap = va_arg (args, maptile *);
780 x = va_arg (args, int); 744 x = va_arg (args, int);
781 y = va_arg (args, int); 745 y = va_arg (args, int);
782 nx = va_arg (args, int); 746 nx = va_arg (args, int);
783 ny = va_arg (args, int); 747 ny = va_arg (args, int);
784 748
787 *type = CFAPI_INT; 751 *type = CFAPI_INT;
788 return &rv; 752 return &rv;
789 break; 753 break;
790 754
791 case CFAPI_MAP_PROP_DIFFICULTY: 755 case CFAPI_MAP_PROP_DIFFICULTY:
792 map = va_arg (args, mapstruct *); 756 map = va_arg (args, maptile *);
793 757
794 rv = calculate_difficulty (map); 758 rv = calculate_difficulty (map);
795 va_end (args); 759 va_end (args);
796 *type = CFAPI_INT; 760 *type = CFAPI_INT;
797 return &rv; 761 return &rv;
798 break; 762 break;
799 763
800 case CFAPI_MAP_PROP_PATH: 764 case CFAPI_MAP_PROP_PATH:
801 map = va_arg (args, mapstruct *); 765 map = va_arg (args, maptile *);
802 766
803 buf = map->path; 767 buf = map->path;
804 *type = CFAPI_STRING; 768 *type = CFAPI_STRING;
805 va_end (args); 769 va_end (args);
806 return buf; 770 return buf;
807 break; 771 break;
808 772
809 case CFAPI_MAP_PROP_TMPNAME: 773 case CFAPI_MAP_PROP_TMPNAME:
810 map = va_arg (args, mapstruct *); 774 map = va_arg (args, maptile *);
811 775
812 buf = map->tmpname; 776 buf = map->tmpname;
813 *type = CFAPI_STRING; 777 *type = CFAPI_STRING;
814 va_end (args); 778 va_end (args);
815 return buf; 779 return buf;
816 break; 780 break;
817 781
818 case CFAPI_MAP_PROP_NAME: 782 case CFAPI_MAP_PROP_NAME:
819 map = va_arg (args, mapstruct *); 783 map = va_arg (args, maptile *);
820 784
821 buf = map->name; 785 buf = map->name;
822 *type = CFAPI_STRING; 786 *type = CFAPI_STRING;
823 va_end (args); 787 va_end (args);
824 return buf; 788 return buf;
825 break; 789 break;
826 790
827 case CFAPI_MAP_PROP_RESET_TIME: 791 case CFAPI_MAP_PROP_RESET_TIME:
828 map = va_arg (args, mapstruct *); 792 map = va_arg (args, maptile *);
829 793
830 rv = map->reset_time; 794 rv = map->reset_time;
831 *type = CFAPI_INT; 795 *type = CFAPI_INT;
832 va_end (args); 796 va_end (args);
833 return &rv; 797 return &rv;
834 break; 798 break;
835 799
836 case CFAPI_MAP_PROP_RESET_TIMEOUT: 800 case CFAPI_MAP_PROP_RESET_TIMEOUT:
837 map = va_arg (args, mapstruct *); 801 map = va_arg (args, maptile *);
838 802
839 rv = map->reset_timeout; 803 rv = map->reset_timeout;
840 *type = CFAPI_INT; 804 *type = CFAPI_INT;
841 va_end (args); 805 va_end (args);
842 return &rv; 806 return &rv;
843 break; 807 break;
844 808
845 case CFAPI_MAP_PROP_PLAYERS: 809 case CFAPI_MAP_PROP_PLAYERS:
846 map = va_arg (args, mapstruct *); 810 map = va_arg (args, maptile *);
847 811
848 rv = map->players; 812 rv = map->players;
849 *type = CFAPI_INT; 813 *type = CFAPI_INT;
850 va_end (args); 814 va_end (args);
851 return &rv; 815 return &rv;
852 break; 816 break;
853 817
854 case CFAPI_MAP_PROP_DARKNESS: 818 case CFAPI_MAP_PROP_DARKNESS:
855 map = va_arg (args, mapstruct *); 819 map = va_arg (args, maptile *);
856 820
857 rv = map->darkness; 821 rv = map->darkness;
858 *type = CFAPI_INT; 822 *type = CFAPI_INT;
859 va_end (args); 823 va_end (args);
860 return &rv; 824 return &rv;
861 break; 825 break;
862 826
863 case CFAPI_MAP_PROP_WIDTH: 827 case CFAPI_MAP_PROP_WIDTH:
864 map = va_arg (args, mapstruct *); 828 map = va_arg (args, maptile *);
865 829
866 rv = map->width; 830 rv = map->width;
867 *type = CFAPI_INT; 831 *type = CFAPI_INT;
868 va_end (args); 832 va_end (args);
869 return &rv; 833 return &rv;
870 break; 834 break;
871 835
872 case CFAPI_MAP_PROP_HEIGHT: 836 case CFAPI_MAP_PROP_HEIGHT:
873 map = va_arg (args, mapstruct *); 837 map = va_arg (args, maptile *);
874 838
875 rv = map->height; 839 rv = map->height;
876 *type = CFAPI_INT; 840 *type = CFAPI_INT;
877 va_end (args); 841 va_end (args);
878 return &rv; 842 return &rv;
879 break; 843 break;
880 844
881 case CFAPI_MAP_PROP_ENTER_X: 845 case CFAPI_MAP_PROP_ENTER_X:
882 map = va_arg (args, mapstruct *); 846 map = va_arg (args, maptile *);
883 847
884 rv = map->enter_x; 848 rv = map->enter_x;
885 *type = CFAPI_INT; 849 *type = CFAPI_INT;
886 va_end (args); 850 va_end (args);
887 return &rv; 851 return &rv;
888 break; 852 break;
889 853
890 case CFAPI_MAP_PROP_ENTER_Y: 854 case CFAPI_MAP_PROP_ENTER_Y:
891 map = va_arg (args, mapstruct *); 855 map = va_arg (args, maptile *);
892 856
893 rv = map->enter_y; 857 rv = map->enter_y;
894 *type = CFAPI_INT; 858 *type = CFAPI_INT;
895 va_end (args); 859 va_end (args);
896 return &rv; 860 return &rv;
897 break; 861 break;
898 862
899 case CFAPI_MAP_PROP_TEMPERATURE: 863 case CFAPI_MAP_PROP_TEMPERATURE:
900 map = va_arg (args, mapstruct *); 864 map = va_arg (args, maptile *);
901 865
902 rv = map->temp; 866 rv = map->temp;
903 *type = CFAPI_INT; 867 *type = CFAPI_INT;
904 va_end (args); 868 va_end (args);
905 return &rv; 869 return &rv;
906 break; 870 break;
907 871
908 case CFAPI_MAP_PROP_PRESSURE: 872 case CFAPI_MAP_PROP_PRESSURE:
909 map = va_arg (args, mapstruct *); 873 map = va_arg (args, maptile *);
910 874
911 rv = map->pressure; 875 rv = map->pressure;
912 *type = CFAPI_INT; 876 *type = CFAPI_INT;
913 va_end (args); 877 va_end (args);
914 return &rv; 878 return &rv;
915 break; 879 break;
916 880
917 case CFAPI_MAP_PROP_HUMIDITY: 881 case CFAPI_MAP_PROP_HUMIDITY:
918 map = va_arg (args, mapstruct *); 882 map = va_arg (args, maptile *);
919 883
920 rv = map->humid; 884 rv = map->humid;
921 *type = CFAPI_INT; 885 *type = CFAPI_INT;
922 va_end (args); 886 va_end (args);
923 return &rv; 887 return &rv;
924 break; 888 break;
925 889
926 case CFAPI_MAP_PROP_WINDSPEED: 890 case CFAPI_MAP_PROP_WINDSPEED:
927 map = va_arg (args, mapstruct *); 891 map = va_arg (args, maptile *);
928 892
929 rv = map->windspeed; 893 rv = map->windspeed;
930 *type = CFAPI_INT; 894 *type = CFAPI_INT;
931 va_end (args); 895 va_end (args);
932 return &rv; 896 return &rv;
933 break; 897 break;
934 898
935 case CFAPI_MAP_PROP_WINDDIR: 899 case CFAPI_MAP_PROP_WINDDIR:
936 map = va_arg (args, mapstruct *); 900 map = va_arg (args, maptile *);
937 901
938 rv = map->winddir; 902 rv = map->winddir;
939 *type = CFAPI_INT; 903 *type = CFAPI_INT;
940 va_end (args); 904 va_end (args);
941 return &rv; 905 return &rv;
942 break; 906 break;
943 907
944 case CFAPI_MAP_PROP_SKY: 908 case CFAPI_MAP_PROP_SKY:
945 map = va_arg (args, mapstruct *); 909 map = va_arg (args, maptile *);
946 910
947 rv = map->sky; 911 rv = map->sky;
948 *type = CFAPI_INT; 912 *type = CFAPI_INT;
949 va_end (args); 913 va_end (args);
950 return &rv; 914 return &rv;
951 break; 915 break;
952 916
953 case CFAPI_MAP_PROP_WPARTX: 917 case CFAPI_MAP_PROP_WPARTX:
954 map = va_arg (args, mapstruct *); 918 map = va_arg (args, maptile *);
955 919
956 rv = map->wpartx; 920 rv = map->wpartx;
957 *type = CFAPI_INT; 921 *type = CFAPI_INT;
958 va_end (args); 922 va_end (args);
959 return &rv; 923 return &rv;
960 break; 924 break;
961 925
962 case CFAPI_MAP_PROP_WPARTY: 926 case CFAPI_MAP_PROP_WPARTY:
963 map = va_arg (args, mapstruct *); 927 map = va_arg (args, maptile *);
964 928
965 rv = map->wparty; 929 rv = map->wparty;
966 *type = CFAPI_INT; 930 *type = CFAPI_INT;
967 va_end (args); 931 va_end (args);
968 return &rv; 932 return &rv;
969 break; 933 break;
970 934
971 case CFAPI_MAP_PROP_MESSAGE: 935 case CFAPI_MAP_PROP_MESSAGE:
972 map = va_arg (args, mapstruct *); 936 map = va_arg (args, maptile *);
973 937
974 buf = map->msg; 938 buf = map->msg;
975 *type = CFAPI_STRING; 939 *type = CFAPI_STRING;
976 va_end (args); 940 va_end (args);
977 return buf; 941 return buf;
978 break; 942 break;
979 943
980 case CFAPI_MAP_PROP_NEXT: 944 case CFAPI_MAP_PROP_NEXT:
981 map = va_arg (args, mapstruct *); 945 map = va_arg (args, maptile *);
982 946
983 *type = CFAPI_PMAP; 947 *type = CFAPI_PMAP;
984 va_end (args); 948 va_end (args);
985 return map->next; 949 return map->next;
986 break; 950 break;
987 951
988 case CFAPI_MAP_PROP_REGION: 952 case CFAPI_MAP_PROP_REGION:
989 map = va_arg (args, mapstruct *); 953 map = va_arg (args, maptile *);
990 954
991 *type = CFAPI_PREGION; 955 *type = CFAPI_PREGION;
992 va_end (args); 956 va_end (args);
993 return get_region_by_map (map); 957 return get_region_by_map (map);
994 break; 958 break;
1004void * 968void *
1005cfapi_map_set_map_property (int *type, ...) 969cfapi_map_set_map_property (int *type, ...)
1006{ 970{
1007 va_list args; 971 va_list args;
1008 static int rv; 972 static int rv;
1009 mapstruct *map; 973 maptile *map;
1010 int val; 974 int val;
1011 int property; 975 int property;
1012 976
1013 va_start (args, type); 977 va_start (args, type);
1014 978
1015 property = va_arg (args, int); 979 property = va_arg (args, int);
1016 980
1017 switch (property) 981 switch (property)
1018 { 982 {
1019 case CFAPI_MAP_PROP_LIGHT: 983 case CFAPI_MAP_PROP_LIGHT:
1020 map = va_arg (args, mapstruct *); 984 map = va_arg (args, maptile *);
1021 val = va_arg (args, int); 985 val = va_arg (args, int);
1022 986
1023 rv = change_map_light (map, val); 987 rv = change_map_light (map, val);
1024 *type = CFAPI_INT; 988 *type = CFAPI_INT;
1025 va_end (args); 989 va_end (args);
1026 return &rv; 990 return &rv;
1027 break; 991 break;
1028 992
1029 case CFAPI_MAP_PROP_RESET_TIME: 993 case CFAPI_MAP_PROP_RESET_TIME:
1030 map = va_arg (args, mapstruct *); 994 map = va_arg (args, maptile *);
1031 995
1032 *type = CFAPI_NONE; 996 *type = CFAPI_NONE;
1033 va_end (args); 997 va_end (args);
1034 return NULL; 998 return NULL;
1035 break; 999 break;
1044void * 1008void *
1045cfapi_map_out_of_map (int *type, ...) 1009cfapi_map_out_of_map (int *type, ...)
1046{ 1010{
1047 va_list args; 1011 va_list args;
1048 static int rv; 1012 static int rv;
1049 mapstruct *map; 1013 maptile *map;
1050 int x, y; 1014 int x, y;
1051 1015
1052 va_start (args, type); 1016 va_start (args, type);
1053 map = va_arg (args, mapstruct *); 1017 map = va_arg (args, maptile *);
1054 x = va_arg (args, int); 1018 x = va_arg (args, int);
1055 y = va_arg (args, int); 1019 y = va_arg (args, int);
1056 1020
1057 rv = out_of_map (map, x, y); 1021 rv = out_of_map (map, x, y);
1058 va_end (args); 1022 va_end (args);
1062 1026
1063void * 1027void *
1064cfapi_map_update_position (int *type, ...) 1028cfapi_map_update_position (int *type, ...)
1065{ 1029{
1066 va_list args; 1030 va_list args;
1067 mapstruct *map; 1031 maptile *map;
1068 int x, y; 1032 int x, y;
1069 1033
1070 va_start (args, type); 1034 va_start (args, type);
1071 1035
1072 map = va_arg (args, mapstruct *); 1036 map = va_arg (args, maptile *);
1073 x = va_arg (args, int); 1037 x = va_arg (args, int);
1074 y = va_arg (args, int); 1038 y = va_arg (args, int);
1075 1039
1076 update_position (map, x, y); 1040 map->at (x, y).flags_ |= P_NEED_UPDATE;
1041
1077 va_end (args); 1042 va_end (args);
1078 *type = CFAPI_NONE; 1043 *type = CFAPI_NONE;
1079 return NULL; 1044 return NULL;
1080} 1045}
1081 1046
1082void * 1047void *
1083cfapi_map_delete_map (int *type, ...) 1048cfapi_map_delete_map (int *type, ...)
1084{ 1049{
1085 va_list args; 1050 va_list args;
1086 mapstruct *map; 1051 maptile *map;
1087 1052
1088 va_start (args, type); 1053 va_start (args, type);
1089 1054
1090 map = va_arg (args, mapstruct *); 1055 map = va_arg (args, maptile *);
1091 1056
1092 delete_map (map); 1057 delete_map (map);
1093 1058
1094 va_end (args); 1059 va_end (args);
1095 *type = CFAPI_NONE; 1060 *type = CFAPI_NONE;
1098 1063
1099void * 1064void *
1100cfapi_map_message (int *type, ...) 1065cfapi_map_message (int *type, ...)
1101{ 1066{
1102 va_list args; 1067 va_list args;
1103 mapstruct *map; 1068 maptile *map;
1104 char *string; 1069 char *string;
1105 int color; 1070 int color;
1106 1071
1107 va_start (args, type); 1072 va_start (args, type);
1108 map = va_arg (args, mapstruct *); 1073 map = va_arg (args, maptile *);
1109 string = va_arg (args, char *); 1074 string = va_arg (args, char *);
1110 color = va_arg (args, int); 1075 color = va_arg (args, int);
1111 1076
1112 va_end (args); 1077 va_end (args);
1113 1078
1118 1083
1119void * 1084void *
1120cfapi_map_get_object_at (int *type, ...) 1085cfapi_map_get_object_at (int *type, ...)
1121{ 1086{
1122 va_list args; 1087 va_list args;
1123 mapstruct *map; 1088 maptile *map;
1124 int x, y; 1089 int x, y;
1125 object *rv; 1090 object *rv;
1126 1091
1127 va_start (args, type); 1092 va_start (args, type);
1128 map = va_arg (args, mapstruct *); 1093 map = va_arg (args, maptile *);
1129 x = va_arg (args, int); 1094 x = va_arg (args, int);
1130 y = va_arg (args, int); 1095 y = va_arg (args, int);
1131 1096
1132 va_end (args); 1097 va_end (args);
1133 1098
1134 rv = get_map_ob (map, x, y); 1099 rv = GET_MAP_OB (map, x, y);
1135 *type = CFAPI_POBJECT; 1100 *type = CFAPI_POBJECT;
1136 return rv; 1101 return rv;
1137} 1102}
1138 1103
1139void * 1104void *
1140cfapi_map_get_flags (int *type, ...) 1105cfapi_map_get_flags (int *type, ...)
1141{ 1106{
1142 va_list args; 1107 va_list args;
1143 sint16 x, y; 1108 sint16 x, y;
1144 sint16 *nx, *ny; 1109 sint16 *nx, *ny;
1145 static mapstruct *map; 1110 static maptile *map;
1146 mapstruct **newmap; 1111 maptile **newmap;
1147 static int rv; 1112 static int rv;
1148 1113
1149 va_start (args, type); 1114 va_start (args, type);
1150 1115
1151 map = va_arg (args, mapstruct *); 1116 map = va_arg (args, maptile *);
1152 newmap = va_arg (args, mapstruct **); 1117 newmap = va_arg (args, maptile **);
1153 x = va_arg (args, int); 1118 x = va_arg (args, int);
1154 y = va_arg (args, int); 1119 y = va_arg (args, int);
1155 1120
1156 nx = va_arg (args, sint16 *); 1121 nx = va_arg (args, sint16 *);
1157 ny = va_arg (args, sint16 *); 1122 ny = va_arg (args, sint16 *);
1167cfapi_map_present_arch_by_name (int *type, ...) 1132cfapi_map_present_arch_by_name (int *type, ...)
1168{ 1133{
1169 va_list args; 1134 va_list args;
1170 object *rv; 1135 object *rv;
1171 int x, y; 1136 int x, y;
1172 mapstruct *map; 1137 maptile *map;
1173 char *msg; 1138 char *msg;
1174 1139
1175 va_start (args, type); 1140 va_start (args, type);
1176 1141
1177 msg = va_arg (args, char *); 1142 msg = va_arg (args, char *);
1178 map = va_arg (args, mapstruct *); 1143 map = va_arg (args, maptile *);
1179 x = va_arg (args, int); 1144 x = va_arg (args, int);
1180 y = va_arg (args, int); 1145 y = va_arg (args, int);
1181 1146
1182 va_end (args); 1147 va_end (args);
1183 1148
1676 rv = &op->stats.exp; 1641 rv = &op->stats.exp;
1677 *type = CFAPI_LONG; 1642 *type = CFAPI_LONG;
1678 break; 1643 break;
1679 1644
1680 case CFAPI_OBJECT_PROP_OWNER: 1645 case CFAPI_OBJECT_PROP_OWNER:
1681 rv = get_owner (op); 1646 rv = op->owner;
1682 *type = CFAPI_POBJECT; 1647 *type = CFAPI_POBJECT;
1683 break; 1648 break;
1684 1649
1685 case CFAPI_OBJECT_PROP_PRESENT: 1650 case CFAPI_OBJECT_PROP_PRESENT:
1686 { 1651 {
1728 case CFAPI_OBJECT_PROP_MERGEABLE: 1693 case CFAPI_OBJECT_PROP_MERGEABLE:
1729 { 1694 {
1730 object *op2; 1695 object *op2;
1731 op2 = va_arg (args, object *); 1696 op2 = va_arg (args, object *);
1732 1697
1733 ri = CAN_MERGE (op, op2); 1698 ri = object::can_merge_slow (op, op2);
1734 rv = &ri; 1699 rv = &ri;
1735 } 1700 }
1736 *type = CFAPI_INT; 1701 *type = CFAPI_INT;
1737 break; 1702 break;
1738 1703
1885 rv = &ri; 1850 rv = &ri;
1886 *type = CFAPI_INT; 1851 *type = CFAPI_INT;
1887 break; 1852 break;
1888 1853
1889 case CFAPI_PLAYER_PROP_IP: 1854 case CFAPI_PLAYER_PROP_IP:
1890 rv = op->contr->socket.host; 1855 rv = op->contr->ns->host;
1891 *type = CFAPI_STRING; 1856 *type = CFAPI_STRING;
1892 break; 1857 break;
1893 1858
1894 case CFAPI_PLAYER_PROP_MARKED_ITEM: 1859 case CFAPI_PLAYER_PROP_MARKED_ITEM:
1895 rv = find_marked_object (op); 1860 rv = find_marked_object (op);
2010 player *pl; 1975 player *pl;
2011 1976
2012 op->nrof = iarg; 1977 op->nrof = iarg;
2013 if (op->env != NULL) 1978 if (op->env != NULL)
2014 { 1979 {
2015 tmp = is_player_inv (op->env); 1980 tmp = op->in_player ();
2016 if (!tmp) 1981 if (!tmp)
2017 { 1982 {
2018 for (pl = first_player; pl; pl = pl->next) 1983 for (pl = first_player; pl; pl = pl->next)
2019 if (pl->ob->container == op->env) 1984 if (pl->ob->container == op->env)
2020 break; 1985 break;
2171 player *pl; 2136 player *pl;
2172 2137
2173 op->weight = iarg; 2138 op->weight = iarg;
2174 if (op->env != NULL) 2139 if (op->env != NULL)
2175 { 2140 {
2176 tmp = is_player_inv (op->env); 2141 tmp = op->in_player ();
2177 if (!tmp) 2142 if (!tmp)
2178 { 2143 {
2179 for (pl = first_player; pl; pl = pl->next) 2144 for (pl = first_player; pl; pl = pl->next)
2180 if (pl->ob->container == op->env) 2145 if (pl->ob->container == op->env)
2181 break; 2146 break;
2310 break; 2275 break;
2311 2276
2312 case CFAPI_OBJECT_PROP_OWNER: 2277 case CFAPI_OBJECT_PROP_OWNER:
2313 oparg = va_arg (args, object *); 2278 oparg = va_arg (args, object *);
2314 2279
2315 set_owner (op, oparg); 2280 op->set_owner (oparg);
2316 break; 2281 break;
2317 2282
2318 case CFAPI_OBJECT_PROP_CHEATER: 2283 case CFAPI_OBJECT_PROP_CHEATER:
2319 set_cheat (op); 2284 set_cheat (op);
2320 break; 2285 break;
2455 if (op->contr) 2420 if (op->contr)
2456 { 2421 {
2457 oparg = va_arg (args, object *); 2422 oparg = va_arg (args, object *);
2458 2423
2459 op->contr->mark = oparg; 2424 op->contr->mark = oparg;
2460 if (oparg)
2461 op->contr->mark_count = oparg->count;
2462 } 2425 }
2463 break; 2426 break;
2464 2427
2465 case CFAPI_PLAYER_PROP_PARTY: 2428 case CFAPI_PLAYER_PROP_PARTY:
2466 if (op->contr) 2429 if (op->contr)
2645 op = va_arg (args, object *); 2608 op = va_arg (args, object *);
2646 2609
2647 va_end (args); 2610 va_end (args);
2648 2611
2649 send_removed_object (op); 2612 send_removed_object (op);
2650 remove_ob (op); 2613 op->remove ();
2651 *type = CFAPI_NONE; 2614 *type = CFAPI_NONE;
2652 return NULL; 2615 return NULL;
2653} 2616}
2654 2617
2655void * 2618void *
2662 2625
2663 op = va_arg (args, object *); 2626 op = va_arg (args, object *);
2664 2627
2665 va_end (args); 2628 va_end (args);
2666 2629
2667 free_object (op); 2630 op->destroy ();
2668 2631
2669 *type = CFAPI_NONE; 2632 *type = CFAPI_NONE;
2670 return NULL; 2633 return NULL;
2671} 2634}
2672 2635
2689 *type = CFAPI_POBJECT; 2652 *type = CFAPI_POBJECT;
2690 return object_create_clone (op); 2653 return object_create_clone (op);
2691 } 2654 }
2692 else 2655 else
2693 { 2656 {
2694 object *tmp; 2657 object *tmp = op->clone ();
2695
2696 tmp = get_object ();
2697 copy_object (op, tmp);
2698 *type = CFAPI_POBJECT; 2658 *type = CFAPI_POBJECT;
2699 return tmp; 2659 return tmp;
2700 } 2660 }
2701} 2661}
2702void * 2662void *
2738 break; 2698 break;
2739 2699
2740 case 3: 2700 case 3:
2741 op = va_arg (args, object *); 2701 op = va_arg (args, object *);
2742 2702
2743 rv = is_player_inv (op); 2703 rv = op->in_player ();
2744 break; 2704 break;
2745 2705
2746 default: 2706 default:
2747 rv = NULL; 2707 rv = NULL;
2748 *type = CFAPI_NONE; 2708 *type = CFAPI_NONE;
2766 *type = CFAPI_POBJECT; 2726 *type = CFAPI_POBJECT;
2767 switch (ival) 2727 switch (ival)
2768 { 2728 {
2769 case 0: 2729 case 0:
2770 va_end (args); 2730 va_end (args);
2771 return get_object (); 2731 return object::create ();
2772 break; 2732 break;
2773 2733
2774 case 1: /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */ 2734 case 1: /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
2775 { 2735 {
2776 char *sval; 2736 char *sval;
2779 2739
2780 op = get_archetype_by_object_name (sval); 2740 op = get_archetype_by_object_name (sval);
2781 2741
2782 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) 2742 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0)
2783 { 2743 {
2784 free_object (op); 2744 op->destroy ();
2785 /* Try with archetype names... */ 2745 /* Try with archetype names... */
2786 op = get_archetype (sval); 2746 op = get_archetype (sval);
2787 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) 2747 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0)
2788 { 2748 {
2789 free_object (op); 2749 op->destroy ();
2790 *type = CFAPI_NONE; 2750 *type = CFAPI_NONE;
2791 va_end (args); 2751 va_end (args);
2792 return NULL; 2752 return NULL;
2793 } 2753 }
2794 } 2754 }
2808cfapi_object_insert (int *type, ...) 2768cfapi_object_insert (int *type, ...)
2809{ 2769{
2810 va_list args; 2770 va_list args;
2811 object *op; 2771 object *op;
2812 object *orig; 2772 object *orig;
2813 mapstruct *map; 2773 maptile *map;
2814 int flag, x, y; 2774 int flag, x, y;
2815 int itype; 2775 int itype;
2816 char *arch_string; 2776 char *arch_string;
2817 void *rv = NULL; 2777 void *rv = NULL;
2818 2778
2822 itype = va_arg (args, int); 2782 itype = va_arg (args, int);
2823 2783
2824 switch (itype) 2784 switch (itype)
2825 { 2785 {
2826 case 0: 2786 case 0:
2827 map = va_arg (args, mapstruct *); 2787 map = va_arg (args, maptile *);
2828 orig = va_arg (args, object *); 2788 orig = va_arg (args, object *);
2829 flag = va_arg (args, int); 2789 flag = va_arg (args, int);
2830 x = va_arg (args, int); 2790 x = va_arg (args, int);
2831 y = va_arg (args, int); 2791 y = va_arg (args, int);
2832 2792
2833 rv = insert_ob_in_map_at (op, map, orig, flag, x, y); 2793 rv = insert_ob_in_map_at (op, map, orig, flag, x, y);
2834 *type = CFAPI_POBJECT; 2794 *type = CFAPI_POBJECT;
2835 break; 2795 break;
2836 2796
2837 case 1: 2797 case 1:
2838 map = va_arg (args, mapstruct *); 2798 map = va_arg (args, maptile *);
2839 orig = va_arg (args, object *); 2799 orig = va_arg (args, object *);
2840 flag = va_arg (args, int); 2800 flag = va_arg (args, int);
2841 2801
2842 rv = insert_ob_in_map (op, map, orig, flag); 2802 rv = insert_ob_in_map (op, map, orig, flag);
2843 *type = CFAPI_POBJECT; 2803 *type = CFAPI_POBJECT;
2953 2913
2954 op = va_arg (args, object *); 2914 op = va_arg (args, object *);
2955 2915
2956 va_end (args); 2916 va_end (args);
2957 2917
2958 clear_object (op); 2918 op->clear ();
2959 *type = CFAPI_NONE; 2919 *type = CFAPI_NONE;
2960 return NULL; 2920 return NULL;
2961} 2921}
2962 2922
2963void * 2923void *
3229 object *op; 3189 object *op;
3230 object *originator; 3190 object *originator;
3231 int x, y, randompos, ttype; 3191 int x, y, randompos, ttype;
3232 va_list args; 3192 va_list args;
3233 static int rv = 0; 3193 static int rv = 0;
3234 mapstruct *map; 3194 maptile *map;
3235 3195
3236 va_start (args, type); 3196 va_start (args, type);
3237 op = va_arg (args, object *); 3197 op = va_arg (args, object *);
3238 ttype = va_arg (args, int); 3198 ttype = va_arg (args, int);
3239 3199
3253 break; 3213 break;
3254 3214
3255 case 1: 3215 case 1:
3256 x = va_arg (args, int); 3216 x = va_arg (args, int);
3257 y = va_arg (args, int); 3217 y = va_arg (args, int);
3258 map = va_arg (args, mapstruct *); 3218 map = va_arg (args, maptile *);
3259 3219
3260 va_end (args); 3220 va_end (args);
3261 if (x < 0 || y < 0) 3221 if (x < 0 || y < 0)
3262 { 3222 {
3263 x = map->enter_x; 3223 x = map->enter_x;
3264 y = map->enter_y; 3224 y = map->enter_y;
3265 } 3225 }
3266 3226
3267/* 3227/*
3268 originator = get_object(); 3228 originator = object::create();
3269 EXIT_PATH(originator) = add_string(map->path); 3229 EXIT_PATH(originator) = add_string(map->path);
3270 EXIT_X(originator) = x; 3230 EXIT_X(originator) = x;
3271 EXIT_Y(originator) = y; 3231 EXIT_Y(originator) = y;
3272 printf("B Transfer: X=%d, Y=%d, OP=%s\n", x, y, op->name);*/ 3232 printf("B Transfer: X=%d, Y=%d, OP=%s\n", x, y, op->name);*/
3273 /*enter_exit(op, originator); */ 3233 /*enter_exit(op, originator); */
3274 insert_ob_in_map_at (op, map, NULL, 0, x, y); 3234 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); 3235 /*printf("A Transfer: X=%d, Y=%d, MAP=%s\n", x, y, op->map->name);
3276 free_object(originator); 3236 originator->destroy ();
3277 */ 3237 */
3278 *type = CFAPI_INT; 3238 *type = CFAPI_INT;
3279 return &rv; 3239 return &rv;
3280 break; 3240 break;
3281 3241
3354 drop (author, op); 3314 drop (author, op);
3355 3315
3356 if (author->type == PLAYER) 3316 if (author->type == PLAYER)
3357 { 3317 {
3358 author->contr->count = 0; 3318 author->contr->count = 0;
3359 author->contr->socket.update_look = 1; 3319 author->contr->ns->floorbox_update ();
3360 } 3320 }
3361 3321
3362 *type = CFAPI_NONE; 3322 *type = CFAPI_NONE;
3363 return NULL; 3323 return NULL;
3364} 3324}
3445} 3405}
3446 3406
3447void * 3407void *
3448cfapi_object_teleport (int *type, ...) 3408cfapi_object_teleport (int *type, ...)
3449{ 3409{
3450 mapstruct *map; 3410 maptile *map;
3451 int x, y; 3411 int x, y;
3452 object *who; 3412 object *who;
3453 static int result; 3413 static int result;
3454 va_list args; 3414 va_list args;
3455 3415
3456 va_start (args, type); 3416 va_start (args, type);
3457 who = va_arg (args, object *); 3417 who = va_arg (args, object *);
3458 map = va_arg (args, mapstruct *); 3418 map = va_arg (args, maptile *);
3459 x = va_arg (args, int); 3419 x = va_arg (args, int);
3460 y = va_arg (args, int); 3420 y = va_arg (args, int);
3461 3421
3462 if (!out_of_map (map, x, y)) 3422 if (!out_of_map (map, x, y))
3463 { 3423 {
3470 result = 1; 3430 result = 1;
3471 return &result; 3431 return &result;
3472 } 3432 }
3473 3433
3474 send_removed_object (who); 3434 send_removed_object (who);
3475 remove_ob (who); 3435 who->remove ();
3476 3436
3477 for (tmp = who; tmp != NULL; tmp = tmp->more) 3437 for (tmp = who; tmp != NULL; tmp = tmp->more)
3478 tmp->x = x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x), 3438 tmp->x = x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x),
3479 tmp->y = y + freearr_y[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y); 3439 tmp->y = y + freearr_y[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y);
3480 3440

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines