… | |
… | |
264 | |
264 | |
265 | flags = query_flags (head); |
265 | flags = query_flags (head); |
266 | if (QUERY_FLAG (head, FLAG_NO_PICK)) |
266 | if (QUERY_FLAG (head, FLAG_NO_PICK)) |
267 | flags |= F_NOPICK; |
267 | flags |= F_NOPICK; |
268 | |
268 | |
269 | if (!(ns.faces_sent[head->face->number] & NS_FACESENT_FACE)) |
269 | ns.send_face (head->face); |
270 | esrv_send_face (&ns, head->face->number, 0); |
|
|
271 | |
270 | |
272 | if (QUERY_FLAG (head, FLAG_ANIMATE) && !ns.anims_sent[head->animation_id]) |
271 | if (QUERY_FLAG (head, FLAG_ANIMATE) && !ns.anims_sent[head->animation_id]) |
273 | esrv_send_animation (&ns, head->animation_id); |
272 | ns.send_animation (head->animation_id); |
274 | |
273 | |
275 | sl << uint32 (head->count) |
274 | sl << uint32 (head->count) |
276 | << uint32 (flags) |
275 | << uint32 (flags) |
277 | << uint32 (QUERY_FLAG (head, FLAG_NO_PICK) ? -1 : WEIGHT (head)) |
276 | << uint32 (QUERY_FLAG (head, FLAG_NO_PICK) ? -1 : WEIGHT (head)) |
278 | << uint32 (head->face->number); |
277 | << uint32 (head->face); |
279 | |
278 | |
280 | if (!head->custom_name) |
279 | if (!head->custom_name) |
281 | { |
280 | { |
282 | strncpy (item_n, query_base_name (head, 0), 127); |
281 | strncpy (item_n, query_base_name (head, 0), 127); |
283 | item_n[127] = 0; |
282 | item_n[127] = 0; |
… | |
… | |
304 | { |
303 | { |
305 | if (head->anim_speed) |
304 | if (head->anim_speed) |
306 | anim_speed = head->anim_speed; |
305 | anim_speed = head->anim_speed; |
307 | else |
306 | else |
308 | { |
307 | { |
309 | if (FABS (head->speed) < 0.001) |
308 | if (fabs (head->speed) < 0.001) |
310 | anim_speed = 255; |
309 | anim_speed = 255; |
311 | else if (FABS (head->speed) >= 1.0) |
310 | else if (fabs (head->speed) >= 1.0) |
312 | anim_speed = 1; |
311 | anim_speed = 1; |
313 | else |
312 | else |
314 | anim_speed = (int) (1.0 / FABS (head->speed)); |
313 | anim_speed = (int) (1.0 / fabs (head->speed)); |
315 | } |
314 | } |
316 | |
315 | |
317 | if (anim_speed > 255) |
316 | if (anim_speed > 255) |
318 | anim_speed = 255; |
317 | anim_speed = 255; |
319 | } |
318 | } |
… | |
… | |
334 | */ |
333 | */ |
335 | void |
334 | void |
336 | esrv_draw_look (object *pl) |
335 | esrv_draw_look (object *pl) |
337 | { |
336 | { |
338 | int got_one = 0, start_look = 0, end_look = 0; |
337 | int got_one = 0, start_look = 0, end_look = 0; |
339 | char buf[MAX_BUF]; |
|
|
340 | |
338 | |
341 | if (!pl->contr->ns->update_look) |
339 | if (!pl->contr->ns->update_look) |
342 | { |
340 | { |
343 | LOG (llevDebug, "esrv_draw_look called when update_look was not set\n"); |
341 | LOG (llevDebug, "esrv_draw_look called when update_look was not set (player %s)\n", &pl->name); |
344 | return; |
342 | return; |
345 | } |
343 | } |
346 | else |
344 | else |
347 | pl->contr->ns->update_look = 0; |
345 | pl->contr->ns->update_look = 0; |
348 | |
346 | |
… | |
… | |
357 | packet sl; |
355 | packet sl; |
358 | sl.printf ("item%d ", pl->contr->ns->itemcmd); |
356 | sl.printf ("item%d ", pl->contr->ns->itemcmd); |
359 | |
357 | |
360 | sl << uint32 (0); |
358 | sl << uint32 (0); |
361 | |
359 | |
362 | if (!(pl->contr->ns->faces_sent[empty_face->number] & NS_FACESENT_FACE)) |
360 | pl->contr->ns->send_face (empty_face); |
363 | esrv_send_face (pl->contr->ns, empty_face->number, 0); |
|
|
364 | |
361 | |
365 | if (pl->contr->ns->look_position) |
362 | if (pl->contr->ns->look_position) |
366 | { |
363 | { |
367 | char buf[80]; |
364 | char buf[80]; |
368 | snprintf (buf, 80, "Apply this to see %d previous items", FLOORBOX_PAGESIZE); |
365 | snprintf (buf, 80, "Apply this to see %d previous items", FLOORBOX_PAGESIZE); |
369 | |
366 | |
370 | sl << uint32 (0x80000000 | (pl->contr->ns->look_position - FLOORBOX_PAGESIZE)) |
367 | sl << uint32 (0x80000000 | (pl->contr->ns->look_position - FLOORBOX_PAGESIZE)) |
371 | << uint32 (0) |
368 | << uint32 (0) |
372 | << sint32 (-1) |
369 | << sint32 (-1) |
373 | << uint32 (empty_face->number) |
370 | << uint32 (empty_face) |
374 | << data8 (buf) |
371 | << data8 (buf) |
375 | << uint16 (0) |
372 | << uint16 (0) |
376 | << uint8 (0) |
373 | << uint8 (0) |
377 | << uint32 (0); |
374 | << uint32 (0); |
378 | |
375 | |
… | |
… | |
405 | * we notice the special tag the object has, and act accordingly. |
402 | * we notice the special tag the object has, and act accordingly. |
406 | */ |
403 | */ |
407 | sl << uint32 (0x80000000 | (pl->contr->ns->look_position + FLOORBOX_PAGESIZE)) |
404 | sl << uint32 (0x80000000 | (pl->contr->ns->look_position + FLOORBOX_PAGESIZE)) |
408 | << uint32 (0) |
405 | << uint32 (0) |
409 | << uint32 ((uint32) - 1) |
406 | << uint32 ((uint32) - 1) |
410 | << uint32 (empty_face->number) |
407 | << uint32 (empty_face) |
411 | << data8 ("Apply this to see next group of items") |
408 | << data8 ("Apply this to see next group of items") |
412 | << uint16 (0) |
409 | << uint16 (0) |
413 | << uint8 (0) |
410 | << uint8 (0) |
414 | << uint32 (0); |
411 | << uint32 (0); |
415 | |
412 | |
… | |
… | |
448 | * Sends whole inventory. |
445 | * Sends whole inventory. |
449 | */ |
446 | */ |
450 | void |
447 | void |
451 | esrv_send_inventory (object *pl, object *op) |
448 | esrv_send_inventory (object *pl, object *op) |
452 | { |
449 | { |
|
|
450 | if (!pl->contr->ns)//D |
|
|
451 | return; |
|
|
452 | |
453 | int got_one = 0; |
453 | int got_one = 0; |
454 | |
454 | |
455 | pl->contr->ns->send_packet_printf ("delinv %d", op->count); |
455 | pl->contr->ns->send_packet_printf ("delinv %d", op->count); |
456 | |
456 | |
457 | packet sl; |
457 | packet sl; |
… | |
… | |
499 | * |
499 | * |
500 | * flags is a list of values to update |
500 | * flags is a list of values to update |
501 | * to the client (as defined in newclient.h - might as well use the |
501 | * to the client (as defined in newclient.h - might as well use the |
502 | * same value both places. |
502 | * same value both places. |
503 | */ |
503 | */ |
504 | |
|
|
505 | void |
504 | void |
506 | esrv_update_item (int flags, object *pl, object *op) |
505 | esrv_update_item (int flags, object *pl, object *op) |
507 | { |
506 | { |
508 | /* If we have a request to send the player item, skip a few checks. */ |
507 | /* If we have a request to send the player item, skip a few checks. */ |
509 | if (op != pl) |
508 | if (op != pl) |
… | |
… | |
554 | ns->last_weight = weight; |
553 | ns->last_weight = weight; |
555 | } |
554 | } |
556 | |
555 | |
557 | if (flags & UPD_FACE) |
556 | if (flags & UPD_FACE) |
558 | { |
557 | { |
559 | if (!(ns->faces_sent[op->face->number] & NS_FACESENT_FACE)) |
558 | ns->send_face (op->face); |
560 | esrv_send_face (ns, op->face->number, 0); |
|
|
561 | |
|
|
562 | sl << uint32 (op->face->number); |
559 | sl << uint32 (op->face); |
563 | } |
560 | } |
564 | |
561 | |
565 | if (flags & UPD_NAME) |
562 | if (flags & UPD_NAME) |
566 | { |
563 | { |
567 | int len; |
564 | int len; |
… | |
… | |
601 | { |
598 | { |
602 | if (op->anim_speed) |
599 | if (op->anim_speed) |
603 | anim_speed = op->anim_speed; |
600 | anim_speed = op->anim_speed; |
604 | else |
601 | else |
605 | { |
602 | { |
606 | if (FABS (op->speed) < 0.001) |
603 | if (fabs (op->speed) < 0.001) |
607 | anim_speed = 255; |
604 | anim_speed = 255; |
608 | else if (FABS (op->speed) >= 1.0) |
605 | else if (fabs (op->speed) >= 1.0) |
609 | anim_speed = 1; |
606 | anim_speed = 1; |
610 | else |
607 | else |
611 | anim_speed = (int) (1.0 / FABS (op->speed)); |
608 | anim_speed = (int) (1.0 / fabs (op->speed)); |
612 | } |
609 | } |
613 | |
610 | |
614 | if (anim_speed > 255) |
611 | if (anim_speed > 255) |
615 | anim_speed = 255; |
612 | anim_speed = 255; |
616 | } |
613 | } |
… | |
… | |
628 | * Sends item's info to player. |
625 | * Sends item's info to player. |
629 | */ |
626 | */ |
630 | void |
627 | void |
631 | esrv_send_item (object *pl, object *op) |
628 | esrv_send_item (object *pl, object *op) |
632 | { |
629 | { |
|
|
630 | if (!pl->contr->ns) |
|
|
631 | return; |
|
|
632 | |
633 | /* If this is not the player object, do some more checks */ |
633 | /* If this is not the player object, do some more checks */ |
634 | if (op != pl) |
634 | if (op != pl) |
635 | { |
635 | { |
636 | /* We only send 'visibile' objects to the client */ |
636 | /* We only send 'visibile' objects to the client */ |
637 | if (!op->client_visible ()) |
637 | if (!op->client_visible ()) |
… | |
… | |
664 | |
664 | |
665 | /** |
665 | /** |
666 | * Tells the client to delete an item. Uses the item |
666 | * Tells the client to delete an item. Uses the item |
667 | * command with a -1 location. |
667 | * command with a -1 location. |
668 | */ |
668 | */ |
669 | |
|
|
670 | void |
669 | void |
671 | esrv_del_item (player *pl, int tag) |
670 | esrv_del_item (player *pl, int tag) |
672 | { |
671 | { |
|
|
672 | if (!pl->ns) |
|
|
673 | return; |
|
|
674 | |
673 | packet sl ("delitem"); |
675 | packet sl ("delitem"); |
674 | |
676 | |
675 | sl << uint32 (tag); |
677 | sl << uint32 (tag); |
676 | |
678 | |
677 | pl->ns->send_packet (sl); |
679 | pl->ns->send_packet (sl); |
… | |
… | |
873 | else |
875 | else |
874 | new_draw_info (NDI_UNIQUE, 0, op, "You see nothing."); |
876 | new_draw_info (NDI_UNIQUE, 0, op, "You see nothing."); |
875 | } |
877 | } |
876 | } |
878 | } |
877 | |
879 | |
878 | |
|
|
879 | |
|
|
880 | /** Client wants to look at some object. Lets do so. */ |
880 | /** Client wants to look at some object. Lets do so. */ |
881 | void |
881 | void |
882 | LookAt (char *buf, int len, player *pl) |
882 | LookAt (char *buf, int len, player *pl) |
883 | { |
883 | { |
884 | int dx, dy; |
884 | int dx, dy; |
… | |
… | |
889 | { |
889 | { |
890 | return; |
890 | return; |
891 | } |
891 | } |
892 | dy = atoi (cp); |
892 | dy = atoi (cp); |
893 | |
893 | |
894 | if (FABS (dx) > pl->ns->mapx / 2 || FABS (dy) > pl->ns->mapy / 2) |
894 | if (fabs (dx) > pl->ns->mapx / 2 || fabs (dy) > pl->ns->mapy / 2) |
895 | return; |
895 | return; |
896 | |
896 | |
897 | if (pl->blocked_los[dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2]) |
897 | if (pl->blocked_los[dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2]) |
898 | return; |
898 | return; |
899 | |
899 | |