… | |
… | |
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) |
136 | if (op->env) |
138 | { |
137 | { |
139 | tmp = op->in_player (); |
138 | tmp = op->in_player (); |
140 | |
139 | |
141 | if (!tmp) |
140 | if (!tmp) |
142 | { |
141 | { |
143 | for (pl = first_player; pl; pl = pl->next) |
142 | for_all_players (pl) |
144 | if (pl->ob->container == op->env) |
143 | if (pl->ob->container == op->env) |
|
|
144 | { |
|
|
145 | tmp = pl->ob; |
145 | break; |
146 | break; |
146 | |
147 | } |
147 | if (pl) |
|
|
148 | tmp = pl->ob; |
|
|
149 | else |
|
|
150 | tmp = NULL; |
|
|
151 | } |
148 | } |
152 | |
149 | |
153 | if (tmp) |
150 | if (tmp) |
154 | esrv_send_item (tmp, op); |
151 | esrv_send_item (tmp, op); |
155 | } |
152 | } |
… | |
… | |
169 | */ |
166 | */ |
170 | static void |
167 | static void |
171 | send_removed_object (object *op) |
168 | send_removed_object (object *op) |
172 | { |
169 | { |
173 | object *tmp; |
170 | object *tmp; |
174 | player *pl; |
|
|
175 | |
171 | |
176 | if (op->env == NULL) |
172 | if (op->env == NULL) |
177 | { |
173 | { |
178 | /* no action necessary: remove_ob() notifies the client */ |
174 | /* no action necessary: remove_ob() notifies the client */ |
179 | return; |
175 | return; |
180 | } |
176 | } |
181 | |
177 | |
182 | tmp = op->in_player (); |
178 | tmp = op->in_player (); |
183 | if (!tmp) |
179 | if (!tmp) |
184 | { |
180 | { |
185 | for (pl = first_player; pl; pl = pl->next) |
181 | for_all_players (pl) |
186 | if (pl->ob->container == op->env) |
182 | if (pl->ob->container == op->env) |
|
|
183 | { |
|
|
184 | tmp = pl->ob; |
187 | break; |
185 | break; |
188 | if (pl) |
186 | } |
189 | tmp = pl->ob; |
|
|
190 | else |
|
|
191 | tmp = NULL; |
|
|
192 | } |
187 | } |
|
|
188 | |
193 | if (tmp) |
189 | if (tmp) |
194 | esrv_del_item (tmp->contr, op->count); |
190 | esrv_del_item (tmp->contr, op->count); |
195 | } |
191 | } |
196 | |
192 | |
197 | 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); |
… | |
… | |
1035 | |
1031 | |
1036 | map = va_arg (args, maptile *); |
1032 | map = va_arg (args, maptile *); |
1037 | x = va_arg (args, int); |
1033 | x = va_arg (args, int); |
1038 | y = va_arg (args, int); |
1034 | y = va_arg (args, int); |
1039 | |
1035 | |
1040 | update_position (map, x, y); |
1036 | map->at (x, y).flags_ |= P_NEED_UPDATE; |
|
|
1037 | |
1041 | va_end (args); |
1038 | va_end (args); |
1042 | *type = CFAPI_NONE; |
1039 | *type = CFAPI_NONE; |
1043 | return NULL; |
1040 | return NULL; |
1044 | } |
1041 | } |
1045 | |
1042 | |
… | |
… | |
1849 | rv = &ri; |
1846 | rv = &ri; |
1850 | *type = CFAPI_INT; |
1847 | *type = CFAPI_INT; |
1851 | break; |
1848 | break; |
1852 | |
1849 | |
1853 | case CFAPI_PLAYER_PROP_IP: |
1850 | case CFAPI_PLAYER_PROP_IP: |
1854 | rv = op->contr->socket->host; |
1851 | rv = op->contr->ns->host; |
1855 | *type = CFAPI_STRING; |
1852 | *type = CFAPI_STRING; |
1856 | break; |
1853 | break; |
1857 | |
1854 | |
1858 | case CFAPI_PLAYER_PROP_MARKED_ITEM: |
1855 | case CFAPI_PLAYER_PROP_MARKED_ITEM: |
1859 | rv = find_marked_object (op); |
1856 | rv = find_marked_object (op); |
… | |
… | |
1969 | if (op->nrof > (uint32) iarg) |
1966 | if (op->nrof > (uint32) iarg) |
1970 | decrease_ob_nr (op, op->nrof - iarg); |
1967 | decrease_ob_nr (op, op->nrof - iarg); |
1971 | else if (op->nrof < (uint32) iarg) |
1968 | else if (op->nrof < (uint32) iarg) |
1972 | { |
1969 | { |
1973 | object *tmp; |
1970 | object *tmp; |
1974 | player *pl; |
|
|
1975 | |
1971 | |
1976 | op->nrof = iarg; |
1972 | op->nrof = iarg; |
1977 | if (op->env != NULL) |
1973 | if (op->env != NULL) |
1978 | { |
1974 | { |
1979 | tmp = op->in_player (); |
1975 | tmp = op->in_player (); |
1980 | if (!tmp) |
1976 | if (!tmp) |
1981 | { |
1977 | { |
1982 | for (pl = first_player; pl; pl = pl->next) |
1978 | for_all_players (pl) |
1983 | if (pl->ob->container == op->env) |
1979 | if (pl->ob->container == op->env) |
|
|
1980 | { |
|
|
1981 | tmp = pl->ob; |
1984 | break; |
1982 | break; |
1985 | if (pl) |
|
|
1986 | tmp = pl->ob; |
|
|
1987 | else |
1983 | } |
1988 | tmp = NULL; |
|
|
1989 | } |
1984 | } |
1990 | else |
1985 | else |
1991 | { |
1986 | { |
1992 | sum_weight (tmp); |
1987 | sum_weight (tmp); |
1993 | fix_player (tmp); |
1988 | tmp->update_stats (); |
1994 | } |
1989 | } |
1995 | if (tmp) |
1990 | if (tmp) |
1996 | esrv_send_item (tmp, op); |
1991 | esrv_send_item (tmp, op); |
1997 | } |
1992 | } |
1998 | else |
1993 | else |
… | |
… | |
2130 | iarg = va_arg (args, int); |
2125 | iarg = va_arg (args, int); |
2131 | |
2126 | |
2132 | if (op->weight != iarg) |
2127 | if (op->weight != iarg) |
2133 | { |
2128 | { |
2134 | object *tmp; |
2129 | object *tmp; |
2135 | player *pl; |
|
|
2136 | |
2130 | |
2137 | op->weight = iarg; |
2131 | op->weight = iarg; |
2138 | if (op->env != NULL) |
2132 | if (op->env != NULL) |
2139 | { |
2133 | { |
2140 | tmp = op->in_player (); |
2134 | tmp = op->in_player (); |
2141 | if (!tmp) |
2135 | if (!tmp) |
2142 | { |
2136 | { |
2143 | for (pl = first_player; pl; pl = pl->next) |
2137 | for_all_players (pl) |
2144 | if (pl->ob->container == op->env) |
2138 | if (pl->ob->container == op->env) |
|
|
2139 | { |
|
|
2140 | tmp = pl->ob; |
2145 | break; |
2141 | break; |
2146 | if (pl) |
|
|
2147 | tmp = pl->ob; |
|
|
2148 | else |
2142 | } |
2149 | tmp = NULL; |
|
|
2150 | } |
2143 | } |
2151 | else |
2144 | else |
2152 | { |
2145 | { |
2153 | sum_weight (tmp); |
2146 | sum_weight (tmp); |
2154 | fix_player (tmp); |
2147 | tmp->update_stats (); |
2155 | } |
2148 | } |
2156 | if (tmp) |
2149 | if (tmp) |
2157 | esrv_send_item (tmp, op); |
2150 | esrv_send_item (tmp, op); |
2158 | } |
2151 | } |
2159 | else |
2152 | else |
… | |
… | |
2519 | } |
2512 | } |
2520 | |
2513 | |
2521 | void * |
2514 | void * |
2522 | cfapi_object_drain (int *type, ...) |
2515 | cfapi_object_drain (int *type, ...) |
2523 | { |
2516 | { |
2524 | va_list args; |
2517 | abort (); |
|
|
2518 | } |
2525 | |
2519 | |
|
|
2520 | void * |
|
|
2521 | cfapi_object_fix (int *type, ...) |
|
|
2522 | { |
|
|
2523 | va_list args; |
2526 | object *op; |
2524 | object *op; |
2527 | int ds; |
|
|
2528 | |
2525 | |
2529 | va_start (args, type); |
2526 | va_start (args, type); |
2530 | |
2527 | |
2531 | op = va_arg (args, object *); |
2528 | op = va_arg (args, object *); |
2532 | ds = va_arg (args, int); |
|
|
2533 | |
2529 | |
2534 | va_end (args); |
2530 | va_end (args); |
2535 | |
2531 | |
2536 | drain_specific_stat (op, ds); |
2532 | op->update_stats (); |
2537 | |
|
|
2538 | *type = CFAPI_NONE; |
|
|
2539 | return NULL; |
|
|
2540 | } |
|
|
2541 | |
|
|
2542 | void * |
|
|
2543 | cfapi_object_fix (int *type, ...) |
|
|
2544 | { |
|
|
2545 | va_list args; |
|
|
2546 | object *op; |
|
|
2547 | |
|
|
2548 | va_start (args, type); |
|
|
2549 | |
|
|
2550 | op = va_arg (args, object *); |
|
|
2551 | |
|
|
2552 | va_end (args); |
|
|
2553 | |
|
|
2554 | fix_player (op); |
|
|
2555 | |
2533 | |
2556 | *type = CFAPI_NONE; |
2534 | *type = CFAPI_NONE; |
2557 | return NULL; |
2535 | return NULL; |
2558 | } |
2536 | } |
2559 | |
2537 | |
… | |
… | |
3313 | drop (author, op); |
3291 | drop (author, op); |
3314 | |
3292 | |
3315 | if (author->type == PLAYER) |
3293 | if (author->type == PLAYER) |
3316 | { |
3294 | { |
3317 | author->contr->count = 0; |
3295 | author->contr->count = 0; |
3318 | author->contr->socket->floorbox_update (); |
3296 | author->contr->ns->floorbox_update (); |
3319 | } |
3297 | } |
3320 | |
3298 | |
3321 | *type = CFAPI_NONE; |
3299 | *type = CFAPI_NONE; |
3322 | return NULL; |
3300 | return NULL; |
3323 | } |
3301 | } |
… | |
… | |
3556 | |
3534 | |
3557 | case CFAPI_PARTY_PROP_PLAYER: |
3535 | case CFAPI_PARTY_PROP_PLAYER: |
3558 | *type = CFAPI_PPLAYER; |
3536 | *type = CFAPI_PPLAYER; |
3559 | obarg = va_arg (args, object *); |
3537 | obarg = va_arg (args, object *); |
3560 | |
3538 | |
3561 | pl = (obarg ? obarg->contr : first_player); |
3539 | pl = (obarg ? (player *)obarg->contr : first_player); |
3562 | rv = NULL; |
3540 | rv = NULL; |
3563 | for (; pl != NULL; pl = pl->next) |
3541 | for (; pl != NULL; pl = pl->next) |
3564 | if (pl->ob->contr->party == party) |
3542 | if (pl->ob->contr->party == party) |
3565 | { |
3543 | { |
3566 | rv = (void *) pl; |
3544 | rv = (void *) pl; |