1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
48 | |
48 | |
49 | /** |
49 | /** |
50 | * This is a similar to query_name, but returns flags |
50 | * This is a similar to query_name, but returns flags |
51 | * to be sent to client. |
51 | * to be sent to client. |
52 | */ |
52 | */ |
53 | unsigned int |
53 | static unsigned int |
54 | query_flags (object *op) |
54 | query_flags (object *op) |
55 | { |
55 | { |
56 | unsigned int flags = 0; |
56 | unsigned int flags = 0; |
57 | |
57 | |
58 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
58 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
… | |
… | |
155 | |
155 | |
156 | sl << uint16 (head->animation_id); |
156 | sl << uint16 (head->animation_id); |
157 | |
157 | |
158 | int anim_speed = !head->flag [FLAG_ANIMATE] ? 0 |
158 | int anim_speed = !head->flag [FLAG_ANIMATE] ? 0 |
159 | : head->anim_speed ? clamp (head->anim_speed, 1, 255) |
159 | : head->anim_speed ? clamp (head->anim_speed, 1, 255) |
160 | : 1. / clamp (fabs (head->speed), 1./255., 1./1.); |
160 | : 1. / clamp (head->speed, 1./255., 1./1.); |
161 | |
161 | |
162 | sl << uint8 (anim_speed) |
162 | sl << uint8 (anim_speed) |
163 | << uint32 (head->nrof); |
163 | << uint32 (head->nrof); |
164 | |
164 | |
165 | if (ns.itemcmd == 2) |
165 | if (ns.itemcmd == 2) |
… | |
… | |
447 | { |
447 | { |
448 | if (op->anim_speed) |
448 | if (op->anim_speed) |
449 | anim_speed = op->anim_speed; |
449 | anim_speed = op->anim_speed; |
450 | else |
450 | else |
451 | { |
451 | { |
452 | if (fabs (op->speed) < 0.001) |
452 | if (op->speed < 0.001) |
453 | anim_speed = 255; |
453 | anim_speed = 255; |
454 | else if (fabs (op->speed) >= 1.0) |
454 | else if (op->speed >= 1.0) |
455 | anim_speed = 1; |
455 | anim_speed = 1; |
456 | else |
456 | else |
457 | anim_speed = (int) (1.0 / fabs (op->speed)); |
457 | anim_speed = 1. / op->speed; |
458 | } |
458 | } |
459 | |
459 | |
460 | if (anim_speed > 255) |
460 | if (anim_speed > 255) |
461 | anim_speed = 255; |
461 | anim_speed = 255; |
462 | } |
462 | } |
… | |
… | |
521 | |
521 | |
522 | /** |
522 | /** |
523 | * Takes a player and object count (tag) and returns the actual object |
523 | * Takes a player and object count (tag) and returns the actual object |
524 | * pointer, or null if it can't be found. |
524 | * pointer, or null if it can't be found. |
525 | */ |
525 | */ |
526 | object * |
526 | static object * |
527 | esrv_get_ob_from_count (object *pl, tag_t count) |
527 | esrv_get_ob_from_count (object *pl, tag_t count) |
528 | { |
528 | { |
529 | if (pl->count == count) |
529 | if (pl->count == count) |
530 | return pl; |
530 | return pl; |
531 | |
531 | |
… | |
… | |
619 | { |
619 | { |
620 | LOG (llevDebug, "Player '%s' tried to apply the unknown object (%d)\n", &pl->ob->name, tag); |
620 | LOG (llevDebug, "Player '%s' tried to apply the unknown object (%d)\n", &pl->ob->name, tag); |
621 | return; |
621 | return; |
622 | } |
622 | } |
623 | |
623 | |
624 | player_apply (pl->ob, op, 0, 0); |
624 | pl->ob->apply (op); |
625 | } |
625 | } |
626 | |
626 | |
627 | /** Client wants to lock some object. Lets do so. */ |
627 | /** Client wants to lock some object. Lets do so. */ |
628 | void |
628 | void |
629 | LockItem (char *data, int len, player *pl) |
629 | LockItem (char *data, int len, player *pl) |
… | |
… | |
689 | { |
689 | { |
690 | mapspace &ms = *pos; |
690 | mapspace &ms = *pos; |
691 | ms.update (); |
691 | ms.update (); |
692 | |
692 | |
693 | buf.printf (" map: %s%+d%+d (%+d%+d)\n" |
693 | buf.printf (" map: %s%+d%+d (%+d%+d)\n" |
694 | " smell %u/%u; flags %x; light %d; block %x; slow %x; on %x; off %x; volume %lld\n\n", |
694 | " smell %u/%u; flags %x; light %d; block %x; slow %x; on %x; off %x; items %d, volume %lld\n\n", |
695 | &pos.m->path, pos.x, pos.y, dx, dy, |
695 | &pos.m->path, pos.x, pos.y, dx, dy, |
696 | (unsigned int)ms.smell, (unsigned int)mapspace::smellcount, ms.flags (), ms.light, |
696 | (unsigned int)ms.smell, (unsigned int)mapspace::smellcount, ms.flags (), ms.light, |
697 | ms.move_block, ms.move_slow, ms.move_on, ms.move_off, (long long)ms.volume () |
697 | ms.move_block, ms.move_slow, ms.move_on, ms.move_off, (int)ms.items (), (long long)ms.volume () |
698 | ); |
698 | ); |
699 | } |
699 | } |
700 | else |
700 | else |
701 | buf << "off-map\n\n"; |
701 | buf << "off-map\n\n"; |
702 | } |
702 | } |
… | |
… | |
714 | { |
714 | { |
715 | if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ)) |
715 | if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ)) |
716 | continue; |
716 | continue; |
717 | |
717 | |
718 | if (wiz) |
718 | if (wiz) |
719 | buf.printf (" - %s (%d).\n", query_name (tmp), tmp->count); |
719 | buf.printf (" - %s (%d) %s\n", query_name (tmp), tmp->count, tmp->uuid.c_str ()); |
720 | else |
720 | else |
721 | buf.printf (" - %s.\n", query_name (tmp)); |
721 | buf.printf (" - %s.\n", query_name (tmp)); |
722 | |
722 | |
723 | object *head = tmp->head_ (); |
723 | object *head = tmp->head_ (); |
724 | |
724 | |
… | |
… | |
772 | /* If it is an active container, then we should drop all objects |
772 | /* If it is an active container, then we should drop all objects |
773 | * in the container and not the container itself. |
773 | * in the container and not the container itself. |
774 | */ |
774 | */ |
775 | if (op->inv && QUERY_FLAG (op, FLAG_APPLIED)) |
775 | if (op->inv && QUERY_FLAG (op, FLAG_APPLIED)) |
776 | { |
776 | { |
777 | int cnt = MAX_ITEM_PER_DROP; |
777 | int cnt = MAX_ITEM_PER_ACTION; |
778 | |
778 | |
779 | for (object *current = op->inv; current && cnt--; ) |
779 | for (object *current = op->inv; current && cnt--; ) |
780 | { |
780 | { |
781 | object *next = current->below; |
781 | object *next = current->below; |
782 | drop_object (pl, current, 0); |
782 | drop_object (pl, current, 0); |