… | |
… | |
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"}, |
… | |
… | |
132 | send_changed_object (object *op) |
132 | send_changed_object (object *op) |
133 | { |
133 | { |
134 | object *tmp; |
134 | object *tmp; |
135 | player *pl; |
135 | player *pl; |
136 | |
136 | |
137 | if (op->env != NULL) |
137 | if (op->env) |
138 | { |
138 | { |
139 | tmp = is_player_inv (op->env); |
139 | tmp = op->in_player (); |
|
|
140 | |
140 | if (!tmp) |
141 | if (!tmp) |
141 | { |
142 | { |
142 | for (pl = first_player; pl; pl = pl->next) |
143 | for (pl = first_player; pl; pl = pl->next) |
143 | if (pl->ob->container == op->env) |
144 | if (pl->ob->container == op->env) |
144 | break; |
145 | break; |
|
|
146 | |
145 | if (pl) |
147 | if (pl) |
146 | tmp = pl->ob; |
148 | tmp = pl->ob; |
147 | else |
149 | else |
148 | tmp = NULL; |
150 | tmp = NULL; |
149 | } |
151 | } |
|
|
152 | |
150 | if (tmp) |
153 | if (tmp) |
151 | esrv_send_item (tmp, op); |
154 | esrv_send_item (tmp, op); |
152 | } |
155 | } |
153 | else |
156 | else |
154 | { |
157 | { |
… | |
… | |
174 | { |
177 | { |
175 | /* no action necessary: remove_ob() notifies the client */ |
178 | /* no action necessary: remove_ob() notifies the client */ |
176 | return; |
179 | return; |
177 | } |
180 | } |
178 | |
181 | |
179 | tmp = is_player_inv (op->env); |
182 | tmp = op->in_player (); |
180 | if (!tmp) |
183 | if (!tmp) |
181 | { |
184 | { |
182 | for (pl = first_player; pl; pl = pl->next) |
185 | for (pl = first_player; pl; pl = pl->next) |
183 | if (pl->ob->container == op->env) |
186 | if (pl->ob->container == op->env) |
184 | break; |
187 | break; |
… | |
… | |
482 | *type = CFAPI_INT; |
485 | *type = CFAPI_INT; |
483 | return &rv; |
486 | return &rv; |
484 | } |
487 | } |
485 | |
488 | |
486 | void * |
489 | void * |
487 | cfapi_system_strdup_local (int *type, ...) |
490 | cfapi_system_strdup (int *type, ...) |
488 | { |
491 | { |
489 | va_list args; |
492 | va_list args; |
490 | char *txt; |
493 | char *txt; |
491 | |
494 | |
492 | va_start (args, type); |
495 | va_start (args, type); |
493 | txt = va_arg (args, char *); |
496 | txt = va_arg (args, char *); |
494 | |
497 | |
495 | va_end (args); |
498 | va_end (args); |
496 | *type = CFAPI_STRING; |
499 | *type = CFAPI_STRING; |
497 | return strdup_local (txt); |
500 | return strdup (txt); |
498 | } |
501 | } |
499 | |
502 | |
500 | void * |
503 | void * |
501 | cfapi_system_register_global_event (int *type, ...) |
504 | cfapi_system_register_global_event (int *type, ...) |
502 | { |
505 | { |
… | |
… | |
1032 | |
1035 | |
1033 | map = va_arg (args, maptile *); |
1036 | map = va_arg (args, maptile *); |
1034 | x = va_arg (args, int); |
1037 | x = va_arg (args, int); |
1035 | y = va_arg (args, int); |
1038 | y = va_arg (args, int); |
1036 | |
1039 | |
1037 | update_position (map, x, y); |
1040 | map->at (x, y).flags_ |= P_NEED_UPDATE; |
|
|
1041 | |
1038 | va_end (args); |
1042 | va_end (args); |
1039 | *type = CFAPI_NONE; |
1043 | *type = CFAPI_NONE; |
1040 | return NULL; |
1044 | return NULL; |
1041 | } |
1045 | } |
1042 | |
1046 | |
… | |
… | |
1090 | x = va_arg (args, int); |
1094 | x = va_arg (args, int); |
1091 | y = va_arg (args, int); |
1095 | y = va_arg (args, int); |
1092 | |
1096 | |
1093 | va_end (args); |
1097 | va_end (args); |
1094 | |
1098 | |
1095 | rv = get_map_ob (map, x, y); |
1099 | rv = GET_MAP_OB (map, x, y); |
1096 | *type = CFAPI_POBJECT; |
1100 | *type = CFAPI_POBJECT; |
1097 | return rv; |
1101 | return rv; |
1098 | } |
1102 | } |
1099 | |
1103 | |
1100 | void * |
1104 | void * |
… | |
… | |
1846 | rv = &ri; |
1850 | rv = &ri; |
1847 | *type = CFAPI_INT; |
1851 | *type = CFAPI_INT; |
1848 | break; |
1852 | break; |
1849 | |
1853 | |
1850 | case CFAPI_PLAYER_PROP_IP: |
1854 | case CFAPI_PLAYER_PROP_IP: |
1851 | rv = op->contr->socket.host; |
1855 | rv = op->contr->ns->host; |
1852 | *type = CFAPI_STRING; |
1856 | *type = CFAPI_STRING; |
1853 | break; |
1857 | break; |
1854 | |
1858 | |
1855 | case CFAPI_PLAYER_PROP_MARKED_ITEM: |
1859 | case CFAPI_PLAYER_PROP_MARKED_ITEM: |
1856 | rv = find_marked_object (op); |
1860 | rv = find_marked_object (op); |
… | |
… | |
1971 | player *pl; |
1975 | player *pl; |
1972 | |
1976 | |
1973 | op->nrof = iarg; |
1977 | op->nrof = iarg; |
1974 | if (op->env != NULL) |
1978 | if (op->env != NULL) |
1975 | { |
1979 | { |
1976 | tmp = is_player_inv (op->env); |
1980 | tmp = op->in_player (); |
1977 | if (!tmp) |
1981 | if (!tmp) |
1978 | { |
1982 | { |
1979 | for (pl = first_player; pl; pl = pl->next) |
1983 | for (pl = first_player; pl; pl = pl->next) |
1980 | if (pl->ob->container == op->env) |
1984 | if (pl->ob->container == op->env) |
1981 | break; |
1985 | break; |
… | |
… | |
1985 | tmp = NULL; |
1989 | tmp = NULL; |
1986 | } |
1990 | } |
1987 | else |
1991 | else |
1988 | { |
1992 | { |
1989 | sum_weight (tmp); |
1993 | sum_weight (tmp); |
1990 | fix_player (tmp); |
1994 | tmp->update_stats (); |
1991 | } |
1995 | } |
1992 | if (tmp) |
1996 | if (tmp) |
1993 | esrv_send_item (tmp, op); |
1997 | esrv_send_item (tmp, op); |
1994 | } |
1998 | } |
1995 | else |
1999 | else |
… | |
… | |
2132 | player *pl; |
2136 | player *pl; |
2133 | |
2137 | |
2134 | op->weight = iarg; |
2138 | op->weight = iarg; |
2135 | if (op->env != NULL) |
2139 | if (op->env != NULL) |
2136 | { |
2140 | { |
2137 | tmp = is_player_inv (op->env); |
2141 | tmp = op->in_player (); |
2138 | if (!tmp) |
2142 | if (!tmp) |
2139 | { |
2143 | { |
2140 | for (pl = first_player; pl; pl = pl->next) |
2144 | for (pl = first_player; pl; pl = pl->next) |
2141 | if (pl->ob->container == op->env) |
2145 | if (pl->ob->container == op->env) |
2142 | break; |
2146 | break; |
… | |
… | |
2146 | tmp = NULL; |
2150 | tmp = NULL; |
2147 | } |
2151 | } |
2148 | else |
2152 | else |
2149 | { |
2153 | { |
2150 | sum_weight (tmp); |
2154 | sum_weight (tmp); |
2151 | fix_player (tmp); |
2155 | tmp->update_stats (); |
2152 | } |
2156 | } |
2153 | if (tmp) |
2157 | if (tmp) |
2154 | esrv_send_item (tmp, op); |
2158 | esrv_send_item (tmp, op); |
2155 | } |
2159 | } |
2156 | else |
2160 | else |
… | |
… | |
2516 | } |
2520 | } |
2517 | |
2521 | |
2518 | void * |
2522 | void * |
2519 | cfapi_object_drain (int *type, ...) |
2523 | cfapi_object_drain (int *type, ...) |
2520 | { |
2524 | { |
2521 | va_list args; |
2525 | abort (); |
|
|
2526 | } |
2522 | |
2527 | |
|
|
2528 | void * |
|
|
2529 | cfapi_object_fix (int *type, ...) |
|
|
2530 | { |
|
|
2531 | va_list args; |
2523 | object *op; |
2532 | object *op; |
2524 | int ds; |
|
|
2525 | |
2533 | |
2526 | va_start (args, type); |
2534 | va_start (args, type); |
2527 | |
2535 | |
2528 | op = va_arg (args, object *); |
2536 | op = va_arg (args, object *); |
2529 | ds = va_arg (args, int); |
|
|
2530 | |
2537 | |
2531 | va_end (args); |
2538 | va_end (args); |
2532 | |
2539 | |
2533 | drain_specific_stat (op, ds); |
2540 | 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 | |
2541 | |
2553 | *type = CFAPI_NONE; |
2542 | *type = CFAPI_NONE; |
2554 | return NULL; |
2543 | return NULL; |
2555 | } |
2544 | } |
2556 | |
2545 | |
… | |
… | |
2694 | break; |
2683 | break; |
2695 | |
2684 | |
2696 | case 3: |
2685 | case 3: |
2697 | op = va_arg (args, object *); |
2686 | op = va_arg (args, object *); |
2698 | |
2687 | |
2699 | rv = is_player_inv (op); |
2688 | rv = op->in_player (); |
2700 | break; |
2689 | break; |
2701 | |
2690 | |
2702 | default: |
2691 | default: |
2703 | rv = NULL; |
2692 | rv = NULL; |
2704 | *type = CFAPI_NONE; |
2693 | *type = CFAPI_NONE; |
… | |
… | |
3310 | drop (author, op); |
3299 | drop (author, op); |
3311 | |
3300 | |
3312 | if (author->type == PLAYER) |
3301 | if (author->type == PLAYER) |
3313 | { |
3302 | { |
3314 | author->contr->count = 0; |
3303 | author->contr->count = 0; |
3315 | author->contr->socket.update_look = 1; |
3304 | author->contr->ns->floorbox_update (); |
3316 | } |
3305 | } |
3317 | |
3306 | |
3318 | *type = CFAPI_NONE; |
3307 | *type = CFAPI_NONE; |
3319 | return NULL; |
3308 | return NULL; |
3320 | } |
3309 | } |