… | |
… | |
253 | * animation of face to the client. |
253 | * animation of face to the client. |
254 | */ |
254 | */ |
255 | static void |
255 | static void |
256 | add_object_to_socklist (client &ns, packet &sl, object *head) |
256 | add_object_to_socklist (client &ns, packet &sl, object *head) |
257 | { |
257 | { |
258 | int flags, len, anim_speed; |
|
|
259 | char item_n[MAX_BUF]; |
258 | char item_n[MAX_BUF]; |
260 | const char *item_p; |
259 | const char *item_p; |
261 | |
260 | |
262 | flags = query_flags (head); |
261 | int flags = query_flags (head); |
263 | if (QUERY_FLAG (head, FLAG_NO_PICK)) |
262 | if (QUERY_FLAG (head, FLAG_NO_PICK)) |
264 | flags |= F_NOPICK; |
263 | flags |= F_NOPICK; |
265 | |
264 | |
266 | ns.send_face (head->face, -50); |
265 | ns.send_face (head->face, -50); |
267 | ns.flush_fx (); |
266 | ns.flush_fx (); |
… | |
… | |
272 | sl << uint32 (head->count) |
271 | sl << uint32 (head->count) |
273 | << uint32 (flags) |
272 | << uint32 (flags) |
274 | << uint32 (QUERY_FLAG (head, FLAG_NO_PICK) ? -1 : head->client_weight ()) |
273 | << uint32 (QUERY_FLAG (head, FLAG_NO_PICK) ? -1 : head->client_weight ()) |
275 | << uint32 (head->face); |
274 | << uint32 (head->face); |
276 | |
275 | |
|
|
276 | int len; |
|
|
277 | |
277 | if (!head->custom_name) |
278 | if (!head->custom_name) |
278 | { |
279 | { |
279 | strncpy (item_n, query_base_name (head, 0), 127); |
280 | strncpy (item_n, query_base_name (head, 0), 127); |
280 | item_n[127] = 0; |
281 | item_n[127] = 0; |
281 | len = strlen (item_n); |
282 | len = strlen (item_n); |
… | |
… | |
294 | len += strlen (item_n + 1 + len) + 1; |
295 | len += strlen (item_n + 1 + len) + 1; |
295 | |
296 | |
296 | sl << data8 (item_n, len) |
297 | sl << data8 (item_n, len) |
297 | << uint16 (head->animation_id); |
298 | << uint16 (head->animation_id); |
298 | |
299 | |
299 | anim_speed = 0; |
300 | int anim_speed = !head->flag [FLAG_ANIMATE] ? 0 |
300 | if (QUERY_FLAG (head, FLAG_ANIMATE)) |
301 | : head->anim_speed ? clamp (head->anim_speed, 1, 255) |
301 | { |
302 | : 1. / clamp (fabs (head->speed), 1./255., 1./1.); |
302 | if (head->anim_speed) |
|
|
303 | anim_speed = head->anim_speed; |
|
|
304 | else |
|
|
305 | { |
|
|
306 | if (fabs (head->speed) < 0.001) |
|
|
307 | anim_speed = 255; |
|
|
308 | else if (fabs (head->speed) >= 1.0) |
|
|
309 | anim_speed = 1; |
|
|
310 | else |
|
|
311 | anim_speed = (int) (1.0 / fabs (head->speed)); |
|
|
312 | } |
|
|
313 | |
|
|
314 | if (anim_speed > 255) |
|
|
315 | anim_speed = 255; |
|
|
316 | } |
|
|
317 | |
303 | |
318 | sl << uint8 (anim_speed) |
304 | sl << uint8 (anim_speed) |
319 | << uint32 (head->nrof); |
305 | << uint32 (head->nrof); |
320 | |
306 | |
321 | if (ns.itemcmd == 2) |
307 | if (ns.itemcmd == 2) |