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