… | |
… | |
304 | { |
304 | { |
305 | if (head->anim_speed) |
305 | if (head->anim_speed) |
306 | anim_speed = head->anim_speed; |
306 | anim_speed = head->anim_speed; |
307 | else |
307 | else |
308 | { |
308 | { |
309 | if (FABS (head->speed) < 0.001) |
309 | if (fabs (head->speed) < 0.001) |
310 | anim_speed = 255; |
310 | anim_speed = 255; |
311 | else if (FABS (head->speed) >= 1.0) |
311 | else if (fabs (head->speed) >= 1.0) |
312 | anim_speed = 1; |
312 | anim_speed = 1; |
313 | else |
313 | else |
314 | anim_speed = (int) (1.0 / FABS (head->speed)); |
314 | anim_speed = (int) (1.0 / fabs (head->speed)); |
315 | } |
315 | } |
316 | |
316 | |
317 | if (anim_speed > 255) |
317 | if (anim_speed > 255) |
318 | anim_speed = 255; |
318 | anim_speed = 255; |
319 | } |
319 | } |
… | |
… | |
338 | int got_one = 0, start_look = 0, end_look = 0; |
338 | int got_one = 0, start_look = 0, end_look = 0; |
339 | char buf[MAX_BUF]; |
339 | char buf[MAX_BUF]; |
340 | |
340 | |
341 | if (!pl->contr->ns->update_look) |
341 | if (!pl->contr->ns->update_look) |
342 | { |
342 | { |
343 | LOG (llevDebug, "esrv_draw_look called when update_look was not set\n"); |
343 | LOG (llevDebug, "esrv_draw_look called when update_look was not set (player %s)\n", &pl->name); |
344 | return; |
344 | return; |
345 | } |
345 | } |
346 | else |
346 | else |
347 | pl->contr->ns->update_look = 0; |
347 | pl->contr->ns->update_look = 0; |
348 | |
348 | |
… | |
… | |
448 | * Sends whole inventory. |
448 | * Sends whole inventory. |
449 | */ |
449 | */ |
450 | void |
450 | void |
451 | esrv_send_inventory (object *pl, object *op) |
451 | esrv_send_inventory (object *pl, object *op) |
452 | { |
452 | { |
|
|
453 | if (!pl->contr->ns)//D |
|
|
454 | return; |
|
|
455 | |
453 | int got_one = 0; |
456 | int got_one = 0; |
454 | |
457 | |
455 | pl->contr->ns->send_packet_printf ("delinv %d", op->count); |
458 | pl->contr->ns->send_packet_printf ("delinv %d", op->count); |
456 | |
459 | |
457 | packet sl; |
460 | packet sl; |
… | |
… | |
499 | * |
502 | * |
500 | * flags is a list of values to update |
503 | * flags is a list of values to update |
501 | * to the client (as defined in newclient.h - might as well use the |
504 | * to the client (as defined in newclient.h - might as well use the |
502 | * same value both places. |
505 | * same value both places. |
503 | */ |
506 | */ |
504 | |
|
|
505 | void |
507 | void |
506 | esrv_update_item (int flags, object *pl, object *op) |
508 | esrv_update_item (int flags, object *pl, object *op) |
507 | { |
509 | { |
508 | /* If we have a request to send the player item, skip a few checks. */ |
510 | /* If we have a request to send the player item, skip a few checks. */ |
509 | if (op != pl) |
511 | if (op != pl) |
… | |
… | |
601 | { |
603 | { |
602 | if (op->anim_speed) |
604 | if (op->anim_speed) |
603 | anim_speed = op->anim_speed; |
605 | anim_speed = op->anim_speed; |
604 | else |
606 | else |
605 | { |
607 | { |
606 | if (FABS (op->speed) < 0.001) |
608 | if (fabs (op->speed) < 0.001) |
607 | anim_speed = 255; |
609 | anim_speed = 255; |
608 | else if (FABS (op->speed) >= 1.0) |
610 | else if (fabs (op->speed) >= 1.0) |
609 | anim_speed = 1; |
611 | anim_speed = 1; |
610 | else |
612 | else |
611 | anim_speed = (int) (1.0 / FABS (op->speed)); |
613 | anim_speed = (int) (1.0 / fabs (op->speed)); |
612 | } |
614 | } |
613 | |
615 | |
614 | if (anim_speed > 255) |
616 | if (anim_speed > 255) |
615 | anim_speed = 255; |
617 | anim_speed = 255; |
616 | } |
618 | } |
… | |
… | |
628 | * Sends item's info to player. |
630 | * Sends item's info to player. |
629 | */ |
631 | */ |
630 | void |
632 | void |
631 | esrv_send_item (object *pl, object *op) |
633 | esrv_send_item (object *pl, object *op) |
632 | { |
634 | { |
|
|
635 | if (!pl->contr->ns) |
|
|
636 | return; |
|
|
637 | |
633 | /* If this is not the player object, do some more checks */ |
638 | /* If this is not the player object, do some more checks */ |
634 | if (op != pl) |
639 | if (op != pl) |
635 | { |
640 | { |
636 | /* We only send 'visibile' objects to the client */ |
641 | /* We only send 'visibile' objects to the client */ |
637 | if (!op->client_visible ()) |
642 | if (!op->client_visible ()) |
… | |
… | |
664 | |
669 | |
665 | /** |
670 | /** |
666 | * Tells the client to delete an item. Uses the item |
671 | * Tells the client to delete an item. Uses the item |
667 | * command with a -1 location. |
672 | * command with a -1 location. |
668 | */ |
673 | */ |
669 | |
|
|
670 | void |
674 | void |
671 | esrv_del_item (player *pl, int tag) |
675 | esrv_del_item (player *pl, int tag) |
672 | { |
676 | { |
|
|
677 | if (!pl->ns) |
|
|
678 | return; |
|
|
679 | |
673 | packet sl ("delitem"); |
680 | packet sl ("delitem"); |
674 | |
681 | |
675 | sl << uint32 (tag); |
682 | sl << uint32 (tag); |
676 | |
683 | |
677 | pl->ns->send_packet (sl); |
684 | pl->ns->send_packet (sl); |
… | |
… | |
873 | else |
880 | else |
874 | new_draw_info (NDI_UNIQUE, 0, op, "You see nothing."); |
881 | new_draw_info (NDI_UNIQUE, 0, op, "You see nothing."); |
875 | } |
882 | } |
876 | } |
883 | } |
877 | |
884 | |
878 | |
|
|
879 | |
|
|
880 | /** Client wants to look at some object. Lets do so. */ |
885 | /** Client wants to look at some object. Lets do so. */ |
881 | void |
886 | void |
882 | LookAt (char *buf, int len, player *pl) |
887 | LookAt (char *buf, int len, player *pl) |
883 | { |
888 | { |
884 | int dx, dy; |
889 | int dx, dy; |
… | |
… | |
889 | { |
894 | { |
890 | return; |
895 | return; |
891 | } |
896 | } |
892 | dy = atoi (cp); |
897 | dy = atoi (cp); |
893 | |
898 | |
894 | if (FABS (dx) > pl->ns->mapx / 2 || FABS (dy) > pl->ns->mapy / 2) |
899 | if (fabs (dx) > pl->ns->mapx / 2 || fabs (dy) > pl->ns->mapy / 2) |
895 | return; |
900 | return; |
896 | |
901 | |
897 | if (pl->blocked_los[dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2]) |
902 | if (pl->blocked_los[dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2]) |
898 | return; |
903 | return; |
899 | |
904 | |