… | |
… | |
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 * |
… | |
… | |
1637 | rv = &op->stats.exp; |
1641 | rv = &op->stats.exp; |
1638 | *type = CFAPI_LONG; |
1642 | *type = CFAPI_LONG; |
1639 | break; |
1643 | break; |
1640 | |
1644 | |
1641 | case CFAPI_OBJECT_PROP_OWNER: |
1645 | case CFAPI_OBJECT_PROP_OWNER: |
1642 | rv = get_owner (op); |
1646 | rv = op->owner; |
1643 | *type = CFAPI_POBJECT; |
1647 | *type = CFAPI_POBJECT; |
1644 | break; |
1648 | break; |
1645 | |
1649 | |
1646 | case CFAPI_OBJECT_PROP_PRESENT: |
1650 | case CFAPI_OBJECT_PROP_PRESENT: |
1647 | { |
1651 | { |
… | |
… | |
1689 | case CFAPI_OBJECT_PROP_MERGEABLE: |
1693 | case CFAPI_OBJECT_PROP_MERGEABLE: |
1690 | { |
1694 | { |
1691 | object *op2; |
1695 | object *op2; |
1692 | op2 = va_arg (args, object *); |
1696 | op2 = va_arg (args, object *); |
1693 | |
1697 | |
1694 | ri = CAN_MERGE (op, op2); |
1698 | ri = object::can_merge_slow (op, op2); |
1695 | rv = &ri; |
1699 | rv = &ri; |
1696 | } |
1700 | } |
1697 | *type = CFAPI_INT; |
1701 | *type = CFAPI_INT; |
1698 | break; |
1702 | break; |
1699 | |
1703 | |
… | |
… | |
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 |
… | |
… | |
2271 | break; |
2275 | break; |
2272 | |
2276 | |
2273 | case CFAPI_OBJECT_PROP_OWNER: |
2277 | case CFAPI_OBJECT_PROP_OWNER: |
2274 | oparg = va_arg (args, object *); |
2278 | oparg = va_arg (args, object *); |
2275 | |
2279 | |
2276 | set_owner (op, oparg); |
2280 | op->set_owner (oparg); |
2277 | break; |
2281 | break; |
2278 | |
2282 | |
2279 | case CFAPI_OBJECT_PROP_CHEATER: |
2283 | case CFAPI_OBJECT_PROP_CHEATER: |
2280 | set_cheat (op); |
2284 | set_cheat (op); |
2281 | break; |
2285 | break; |
… | |
… | |
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 | |
… | |
… | |
2648 | *type = CFAPI_POBJECT; |
2637 | *type = CFAPI_POBJECT; |
2649 | return object_create_clone (op); |
2638 | return object_create_clone (op); |
2650 | } |
2639 | } |
2651 | else |
2640 | else |
2652 | { |
2641 | { |
2653 | object *tmp; |
2642 | object *tmp = op->clone (); |
2654 | |
|
|
2655 | tmp = object::create (); |
|
|
2656 | op->copy_to (tmp); |
|
|
2657 | *type = CFAPI_POBJECT; |
2643 | *type = CFAPI_POBJECT; |
2658 | return tmp; |
2644 | return tmp; |
2659 | } |
2645 | } |
2660 | } |
2646 | } |
2661 | void * |
2647 | void * |
… | |
… | |
2697 | break; |
2683 | break; |
2698 | |
2684 | |
2699 | case 3: |
2685 | case 3: |
2700 | op = va_arg (args, object *); |
2686 | op = va_arg (args, object *); |
2701 | |
2687 | |
2702 | rv = is_player_inv (op); |
2688 | rv = op->in_player (); |
2703 | break; |
2689 | break; |
2704 | |
2690 | |
2705 | default: |
2691 | default: |
2706 | rv = NULL; |
2692 | rv = NULL; |
2707 | *type = CFAPI_NONE; |
2693 | *type = CFAPI_NONE; |
… | |
… | |
2912 | |
2898 | |
2913 | op = va_arg (args, object *); |
2899 | op = va_arg (args, object *); |
2914 | |
2900 | |
2915 | va_end (args); |
2901 | va_end (args); |
2916 | |
2902 | |
2917 | clear_object (op); |
2903 | op->clear (); |
2918 | *type = CFAPI_NONE; |
2904 | *type = CFAPI_NONE; |
2919 | return NULL; |
2905 | return NULL; |
2920 | } |
2906 | } |
2921 | |
2907 | |
2922 | void * |
2908 | void * |
… | |
… | |
3313 | drop (author, op); |
3299 | drop (author, op); |
3314 | |
3300 | |
3315 | if (author->type == PLAYER) |
3301 | if (author->type == PLAYER) |
3316 | { |
3302 | { |
3317 | author->contr->count = 0; |
3303 | author->contr->count = 0; |
3318 | author->contr->socket.update_look = 1; |
3304 | author->contr->ns->floorbox_update (); |
3319 | } |
3305 | } |
3320 | |
3306 | |
3321 | *type = CFAPI_NONE; |
3307 | *type = CFAPI_NONE; |
3322 | return NULL; |
3308 | return NULL; |
3323 | } |
3309 | } |