… | |
… | |
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->socket->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; |
… | |
… | |
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; |
… | |
… | |
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; |
… | |
… | |
2648 | *type = CFAPI_POBJECT; |
2652 | *type = CFAPI_POBJECT; |
2649 | return object_create_clone (op); |
2653 | return object_create_clone (op); |
2650 | } |
2654 | } |
2651 | else |
2655 | else |
2652 | { |
2656 | { |
2653 | object *tmp; |
2657 | object *tmp = op->clone (); |
2654 | |
|
|
2655 | tmp = object::create (); |
|
|
2656 | op->copy_to (tmp); |
|
|
2657 | *type = CFAPI_POBJECT; |
2658 | *type = CFAPI_POBJECT; |
2658 | return tmp; |
2659 | return tmp; |
2659 | } |
2660 | } |
2660 | } |
2661 | } |
2661 | void * |
2662 | void * |
… | |
… | |
2697 | break; |
2698 | break; |
2698 | |
2699 | |
2699 | case 3: |
2700 | case 3: |
2700 | op = va_arg (args, object *); |
2701 | op = va_arg (args, object *); |
2701 | |
2702 | |
2702 | rv = is_player_inv (op); |
2703 | rv = op->in_player (); |
2703 | break; |
2704 | break; |
2704 | |
2705 | |
2705 | default: |
2706 | default: |
2706 | rv = NULL; |
2707 | rv = NULL; |
2707 | *type = CFAPI_NONE; |
2708 | *type = CFAPI_NONE; |
… | |
… | |
2912 | |
2913 | |
2913 | op = va_arg (args, object *); |
2914 | op = va_arg (args, object *); |
2914 | |
2915 | |
2915 | va_end (args); |
2916 | va_end (args); |
2916 | |
2917 | |
2917 | clear_object (op); |
2918 | op->clear (); |
2918 | *type = CFAPI_NONE; |
2919 | *type = CFAPI_NONE; |
2919 | return NULL; |
2920 | return NULL; |
2920 | } |
2921 | } |
2921 | |
2922 | |
2922 | void * |
2923 | void * |
… | |
… | |
3313 | drop (author, op); |
3314 | drop (author, op); |
3314 | |
3315 | |
3315 | if (author->type == PLAYER) |
3316 | if (author->type == PLAYER) |
3316 | { |
3317 | { |
3317 | author->contr->count = 0; |
3318 | author->contr->count = 0; |
3318 | author->contr->socket.update_look = 1; |
3319 | author->contr->socket->floorbox_update (); |
3319 | } |
3320 | } |
3320 | |
3321 | |
3321 | *type = CFAPI_NONE; |
3322 | *type = CFAPI_NONE; |
3322 | return NULL; |
3323 | return NULL; |
3323 | } |
3324 | } |