… | |
… | |
43 | static const hook_entry plug_hooks[NR_OF_HOOKS] = { |
43 | static 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 | {NULL, 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"}, |
… | |
… | |
130 | */ |
130 | */ |
131 | static void |
131 | static void |
132 | send_changed_object (object *op) |
132 | send_changed_object (object *op) |
133 | { |
133 | { |
134 | object *tmp; |
134 | object *tmp; |
135 | player *pl; |
|
|
136 | |
135 | |
137 | if (op->env != NULL) |
136 | if (op->env) |
138 | { |
137 | { |
139 | tmp = is_player_inv (op->env); |
138 | tmp = op->in_player (); |
|
|
139 | |
140 | if (!tmp) |
140 | if (!tmp) |
141 | { |
141 | { |
142 | for (pl = first_player; pl; pl = pl->next) |
142 | for_all_players (pl) |
143 | if (pl->ob->container == op->env) |
143 | if (pl->ob->container == op->env) |
|
|
144 | { |
|
|
145 | tmp = pl->ob; |
144 | break; |
146 | break; |
145 | if (pl) |
147 | } |
146 | tmp = pl->ob; |
|
|
147 | else |
|
|
148 | tmp = NULL; |
|
|
149 | } |
148 | } |
|
|
149 | |
150 | if (tmp) |
150 | if (tmp) |
151 | esrv_send_item (tmp, op); |
151 | esrv_send_item (tmp, op); |
152 | } |
152 | } |
153 | else |
153 | else |
154 | { |
154 | { |
… | |
… | |
166 | */ |
166 | */ |
167 | static void |
167 | static void |
168 | send_removed_object (object *op) |
168 | send_removed_object (object *op) |
169 | { |
169 | { |
170 | object *tmp; |
170 | object *tmp; |
171 | player *pl; |
|
|
172 | |
171 | |
173 | if (op->env == NULL) |
172 | if (op->env == NULL) |
174 | { |
173 | { |
175 | /* no action necessary: remove_ob() notifies the client */ |
174 | /* no action necessary: remove_ob() notifies the client */ |
176 | return; |
175 | return; |
177 | } |
176 | } |
178 | |
177 | |
179 | tmp = is_player_inv (op->env); |
178 | tmp = op->in_player (); |
180 | if (!tmp) |
179 | if (!tmp) |
181 | { |
180 | { |
182 | for (pl = first_player; pl; pl = pl->next) |
181 | for_all_players (pl) |
183 | if (pl->ob->container == op->env) |
182 | if (pl->ob->container == op->env) |
|
|
183 | { |
|
|
184 | tmp = pl->ob; |
184 | break; |
185 | break; |
185 | if (pl) |
186 | } |
186 | tmp = pl->ob; |
|
|
187 | else |
|
|
188 | tmp = NULL; |
|
|
189 | } |
187 | } |
|
|
188 | |
190 | if (tmp) |
189 | if (tmp) |
191 | esrv_del_item (tmp->contr, op->count); |
190 | esrv_del_item (tmp->contr, op->count); |
192 | } |
191 | } |
193 | |
192 | |
194 | extern "C" int cfperl_initPlugin (const char *iversion, f_plug_api gethooksptr); |
193 | extern "C" int cfperl_initPlugin (const char *iversion, f_plug_api gethooksptr); |
… | |
… | |
482 | *type = CFAPI_INT; |
481 | *type = CFAPI_INT; |
483 | return &rv; |
482 | return &rv; |
484 | } |
483 | } |
485 | |
484 | |
486 | void * |
485 | void * |
487 | cfapi_system_strdup_local (int *type, ...) |
486 | cfapi_system_strdup (int *type, ...) |
488 | { |
487 | { |
489 | va_list args; |
488 | va_list args; |
490 | char *txt; |
489 | char *txt; |
491 | |
490 | |
492 | va_start (args, type); |
491 | va_start (args, type); |
493 | txt = va_arg (args, char *); |
492 | txt = va_arg (args, char *); |
494 | |
493 | |
495 | va_end (args); |
494 | va_end (args); |
496 | *type = CFAPI_STRING; |
495 | *type = CFAPI_STRING; |
497 | return strdup_local (txt); |
496 | return strdup (txt); |
498 | } |
497 | } |
499 | |
498 | |
500 | void * |
499 | void * |
501 | cfapi_system_register_global_event (int *type, ...) |
500 | cfapi_system_register_global_event (int *type, ...) |
502 | { |
501 | { |
… | |
… | |
910 | va_end (args); |
909 | va_end (args); |
911 | return &rv; |
910 | return &rv; |
912 | break; |
911 | break; |
913 | |
912 | |
914 | case CFAPI_MAP_PROP_WPARTX: |
913 | case CFAPI_MAP_PROP_WPARTX: |
915 | map = va_arg (args, maptile *); |
914 | abort (); |
916 | |
|
|
917 | rv = map->wpartx; |
|
|
918 | *type = CFAPI_INT; |
|
|
919 | va_end (args); |
|
|
920 | return &rv; |
|
|
921 | break; |
|
|
922 | |
|
|
923 | case CFAPI_MAP_PROP_WPARTY: |
915 | case CFAPI_MAP_PROP_WPARTY: |
924 | map = va_arg (args, maptile *); |
916 | abort (); |
925 | |
|
|
926 | rv = map->wparty; |
|
|
927 | *type = CFAPI_INT; |
|
|
928 | va_end (args); |
|
|
929 | return &rv; |
|
|
930 | break; |
|
|
931 | |
917 | |
932 | case CFAPI_MAP_PROP_MESSAGE: |
918 | case CFAPI_MAP_PROP_MESSAGE: |
933 | map = va_arg (args, maptile *); |
919 | map = va_arg (args, maptile *); |
934 | |
920 | |
935 | buf = map->msg; |
921 | buf = map->msg; |
… | |
… | |
1032 | |
1018 | |
1033 | map = va_arg (args, maptile *); |
1019 | map = va_arg (args, maptile *); |
1034 | x = va_arg (args, int); |
1020 | x = va_arg (args, int); |
1035 | y = va_arg (args, int); |
1021 | y = va_arg (args, int); |
1036 | |
1022 | |
1037 | update_position (map, x, y); |
1023 | map->at (x, y).flags_ |= P_NEED_UPDATE; |
|
|
1024 | |
1038 | va_end (args); |
1025 | va_end (args); |
1039 | *type = CFAPI_NONE; |
1026 | *type = CFAPI_NONE; |
1040 | return NULL; |
1027 | return NULL; |
1041 | } |
1028 | } |
1042 | |
1029 | |
… | |
… | |
1090 | x = va_arg (args, int); |
1077 | x = va_arg (args, int); |
1091 | y = va_arg (args, int); |
1078 | y = va_arg (args, int); |
1092 | |
1079 | |
1093 | va_end (args); |
1080 | va_end (args); |
1094 | |
1081 | |
1095 | rv = get_map_ob (map, x, y); |
1082 | rv = GET_MAP_OB (map, x, y); |
1096 | *type = CFAPI_POBJECT; |
1083 | *type = CFAPI_POBJECT; |
1097 | return rv; |
1084 | return rv; |
1098 | } |
1085 | } |
1099 | |
1086 | |
1100 | void * |
1087 | void * |
… | |
… | |
1846 | rv = &ri; |
1833 | rv = &ri; |
1847 | *type = CFAPI_INT; |
1834 | *type = CFAPI_INT; |
1848 | break; |
1835 | break; |
1849 | |
1836 | |
1850 | case CFAPI_PLAYER_PROP_IP: |
1837 | case CFAPI_PLAYER_PROP_IP: |
1851 | rv = op->contr->socket.host; |
1838 | rv = op->contr->ns->host; |
1852 | *type = CFAPI_STRING; |
1839 | *type = CFAPI_STRING; |
1853 | break; |
1840 | break; |
1854 | |
1841 | |
1855 | case CFAPI_PLAYER_PROP_MARKED_ITEM: |
1842 | case CFAPI_PLAYER_PROP_MARKED_ITEM: |
1856 | rv = find_marked_object (op); |
1843 | rv = find_marked_object (op); |
… | |
… | |
1966 | if (op->nrof > (uint32) iarg) |
1953 | if (op->nrof > (uint32) iarg) |
1967 | decrease_ob_nr (op, op->nrof - iarg); |
1954 | decrease_ob_nr (op, op->nrof - iarg); |
1968 | else if (op->nrof < (uint32) iarg) |
1955 | else if (op->nrof < (uint32) iarg) |
1969 | { |
1956 | { |
1970 | object *tmp; |
1957 | object *tmp; |
1971 | player *pl; |
|
|
1972 | |
1958 | |
1973 | op->nrof = iarg; |
1959 | op->nrof = iarg; |
1974 | if (op->env != NULL) |
1960 | if (op->env != NULL) |
1975 | { |
1961 | { |
1976 | tmp = is_player_inv (op->env); |
1962 | tmp = op->in_player (); |
1977 | if (!tmp) |
1963 | if (!tmp) |
1978 | { |
1964 | { |
1979 | for (pl = first_player; pl; pl = pl->next) |
1965 | for_all_players (pl) |
1980 | if (pl->ob->container == op->env) |
1966 | if (pl->ob->container == op->env) |
|
|
1967 | { |
|
|
1968 | tmp = pl->ob; |
1981 | break; |
1969 | break; |
1982 | if (pl) |
|
|
1983 | tmp = pl->ob; |
|
|
1984 | else |
1970 | } |
1985 | tmp = NULL; |
|
|
1986 | } |
1971 | } |
1987 | else |
1972 | else |
1988 | { |
1973 | { |
1989 | sum_weight (tmp); |
1974 | sum_weight (tmp); |
1990 | fix_player (tmp); |
1975 | tmp->update_stats (); |
1991 | } |
1976 | } |
1992 | if (tmp) |
1977 | if (tmp) |
1993 | esrv_send_item (tmp, op); |
1978 | esrv_send_item (tmp, op); |
1994 | } |
1979 | } |
1995 | else |
1980 | else |
… | |
… | |
2127 | iarg = va_arg (args, int); |
2112 | iarg = va_arg (args, int); |
2128 | |
2113 | |
2129 | if (op->weight != iarg) |
2114 | if (op->weight != iarg) |
2130 | { |
2115 | { |
2131 | object *tmp; |
2116 | object *tmp; |
2132 | player *pl; |
|
|
2133 | |
2117 | |
2134 | op->weight = iarg; |
2118 | op->weight = iarg; |
2135 | if (op->env != NULL) |
2119 | if (op->env != NULL) |
2136 | { |
2120 | { |
2137 | tmp = is_player_inv (op->env); |
2121 | tmp = op->in_player (); |
2138 | if (!tmp) |
2122 | if (!tmp) |
2139 | { |
2123 | { |
2140 | for (pl = first_player; pl; pl = pl->next) |
2124 | for_all_players (pl) |
2141 | if (pl->ob->container == op->env) |
2125 | if (pl->ob->container == op->env) |
|
|
2126 | { |
|
|
2127 | tmp = pl->ob; |
2142 | break; |
2128 | break; |
2143 | if (pl) |
|
|
2144 | tmp = pl->ob; |
|
|
2145 | else |
2129 | } |
2146 | tmp = NULL; |
|
|
2147 | } |
2130 | } |
2148 | else |
2131 | else |
2149 | { |
2132 | { |
2150 | sum_weight (tmp); |
2133 | sum_weight (tmp); |
2151 | fix_player (tmp); |
2134 | tmp->update_stats (); |
2152 | } |
2135 | } |
2153 | if (tmp) |
2136 | if (tmp) |
2154 | esrv_send_item (tmp, op); |
2137 | esrv_send_item (tmp, op); |
2155 | } |
2138 | } |
2156 | else |
2139 | else |
… | |
… | |
2516 | } |
2499 | } |
2517 | |
2500 | |
2518 | void * |
2501 | void * |
2519 | cfapi_object_drain (int *type, ...) |
2502 | cfapi_object_drain (int *type, ...) |
2520 | { |
2503 | { |
2521 | va_list args; |
2504 | abort (); |
|
|
2505 | } |
2522 | |
2506 | |
|
|
2507 | void * |
|
|
2508 | cfapi_object_fix (int *type, ...) |
|
|
2509 | { |
|
|
2510 | va_list args; |
2523 | object *op; |
2511 | object *op; |
2524 | int ds; |
|
|
2525 | |
2512 | |
2526 | va_start (args, type); |
2513 | va_start (args, type); |
2527 | |
2514 | |
2528 | op = va_arg (args, object *); |
2515 | op = va_arg (args, object *); |
2529 | ds = va_arg (args, int); |
|
|
2530 | |
2516 | |
2531 | va_end (args); |
2517 | va_end (args); |
2532 | |
2518 | |
2533 | drain_specific_stat (op, ds); |
2519 | op->update_stats (); |
2534 | |
|
|
2535 | *type = CFAPI_NONE; |
|
|
2536 | return NULL; |
|
|
2537 | } |
|
|
2538 | |
|
|
2539 | void * |
|
|
2540 | cfapi_object_fix (int *type, ...) |
|
|
2541 | { |
|
|
2542 | va_list args; |
|
|
2543 | object *op; |
|
|
2544 | |
|
|
2545 | va_start (args, type); |
|
|
2546 | |
|
|
2547 | op = va_arg (args, object *); |
|
|
2548 | |
|
|
2549 | va_end (args); |
|
|
2550 | |
|
|
2551 | fix_player (op); |
|
|
2552 | |
2520 | |
2553 | *type = CFAPI_NONE; |
2521 | *type = CFAPI_NONE; |
2554 | return NULL; |
2522 | return NULL; |
2555 | } |
2523 | } |
2556 | |
2524 | |
… | |
… | |
2694 | break; |
2662 | break; |
2695 | |
2663 | |
2696 | case 3: |
2664 | case 3: |
2697 | op = va_arg (args, object *); |
2665 | op = va_arg (args, object *); |
2698 | |
2666 | |
2699 | rv = is_player_inv (op); |
2667 | rv = op->in_player (); |
2700 | break; |
2668 | break; |
2701 | |
2669 | |
2702 | default: |
2670 | default: |
2703 | rv = NULL; |
2671 | rv = NULL; |
2704 | *type = CFAPI_NONE; |
2672 | *type = CFAPI_NONE; |
… | |
… | |
2900 | } |
2868 | } |
2901 | |
2869 | |
2902 | void * |
2870 | void * |
2903 | cfapi_object_clear (int *type, ...) |
2871 | cfapi_object_clear (int *type, ...) |
2904 | { |
2872 | { |
2905 | va_list args; |
2873 | abort (); |
2906 | object *op; |
|
|
2907 | |
|
|
2908 | va_start (args, type); |
|
|
2909 | |
|
|
2910 | op = va_arg (args, object *); |
|
|
2911 | |
|
|
2912 | va_end (args); |
|
|
2913 | |
|
|
2914 | op->clear (); |
|
|
2915 | *type = CFAPI_NONE; |
|
|
2916 | return NULL; |
|
|
2917 | } |
2874 | } |
2918 | |
2875 | |
2919 | void * |
2876 | void * |
2920 | cfapi_object_reset (int *type, ...) |
2877 | cfapi_object_reset (int *type, ...) |
2921 | { |
2878 | { |
… | |
… | |
2954 | } |
2911 | } |
2955 | |
2912 | |
2956 | void * |
2913 | void * |
2957 | cfapi_object_clean_object (int *type, ...) |
2914 | cfapi_object_clean_object (int *type, ...) |
2958 | { |
2915 | { |
2959 | va_list args; |
2916 | abort (); |
2960 | object *op; |
|
|
2961 | |
|
|
2962 | va_start (args, type); |
|
|
2963 | op = va_arg (args, object *); |
|
|
2964 | |
|
|
2965 | clean_object (op); |
|
|
2966 | va_end (args); |
|
|
2967 | *type = CFAPI_NONE; |
|
|
2968 | return NULL; |
|
|
2969 | } |
2917 | } |
2970 | |
2918 | |
2971 | void * |
2919 | void * |
2972 | cfapi_object_on_same_map (int *type, ...) |
2920 | cfapi_object_on_same_map (int *type, ...) |
2973 | { |
2921 | { |
… | |
… | |
3310 | drop (author, op); |
3258 | drop (author, op); |
3311 | |
3259 | |
3312 | if (author->type == PLAYER) |
3260 | if (author->type == PLAYER) |
3313 | { |
3261 | { |
3314 | author->contr->count = 0; |
3262 | author->contr->count = 0; |
3315 | author->contr->socket.update_look = 1; |
3263 | author->contr->ns->floorbox_update (); |
3316 | } |
3264 | } |
3317 | |
3265 | |
3318 | *type = CFAPI_NONE; |
3266 | *type = CFAPI_NONE; |
3319 | return NULL; |
3267 | return NULL; |
3320 | } |
3268 | } |
… | |
… | |
3553 | |
3501 | |
3554 | case CFAPI_PARTY_PROP_PLAYER: |
3502 | case CFAPI_PARTY_PROP_PLAYER: |
3555 | *type = CFAPI_PPLAYER; |
3503 | *type = CFAPI_PPLAYER; |
3556 | obarg = va_arg (args, object *); |
3504 | obarg = va_arg (args, object *); |
3557 | |
3505 | |
3558 | pl = (obarg ? obarg->contr : first_player); |
3506 | pl = (obarg ? (player *)obarg->contr : first_player); |
3559 | rv = NULL; |
3507 | rv = NULL; |
3560 | for (; pl != NULL; pl = pl->next) |
3508 | for (; pl != NULL; pl = pl->next) |
3561 | if (pl->ob->contr->party == party) |
3509 | if (pl->ob->contr->party == party) |
3562 | { |
3510 | { |
3563 | rv = (void *) pl; |
3511 | rv = (void *) pl; |