ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/object.C
(Generate patch)

Comparing deliantra/server/common/object.C (file contents):
Revision 1.284 by root, Sat Jun 27 08:35:03 2009 UTC vs.
Revision 1.289 by root, Sun Oct 11 05:31:54 2009 UTC

328 // the player inventory itself is always visible 328 // the player inventory itself is always visible
329 if (env->is_player ()) 329 if (env->is_player ())
330 return env; 330 return env;
331 331
332 // else a player could have our env open 332 // else a player could have our env open
333 object *envest = env->outer_env (); 333 object *envest = env->outer_env_or_self ();
334 334
335 // the player itself is always on a map, so we will find him here 335 // the player itself is always on a map, so we will find him here
336 // even if our inv is in a player. 336 // even if our inv is in a player.
337 if (envest->is_on_map ()) 337 if (envest->is_on_map ())
338 if (object *pl = envest->ms ().player ()) 338 if (object *pl = envest->ms ().player ())
431 object_freezer freezer; 431 object_freezer freezer;
432 op->write (freezer); 432 op->write (freezer);
433 return freezer.as_string (); 433 return freezer.as_string ();
434} 434}
435 435
436char *
437object::as_string ()
438{
439 return dump_object (this);
440}
441
436/* 442/*
437 * get_nearest_part(multi-object, object 2) returns the part of the 443 * get_nearest_part(multi-object, object 2) returns the part of the
438 * multi-object 1 which is closest to the second object. 444 * multi-object 1 which is closest to the second object.
439 * If it's not a multi-object, it is returned. 445 * If it's not a multi-object, it is returned.
440 */ 446 */
555 update_stats (); 561 update_stats ();
556 562
557 new_draw_info_format (NDI_UNIQUE, 0, this, 563 new_draw_info_format (NDI_UNIQUE, 0, this,
558 "You try to balance all your items at once, " 564 "You try to balance all your items at once, "
559 "but the %s is just too much for your body. " 565 "but the %s is just too much for your body. "
560 "[You need to unapply some items first.]", &ob->name); 566 "[You need to unapply some items first - use the 'body' command to see "
567 "how many items you cna wera on a specific body part.]", &ob->name);
561 return false; 568 return false;
562 } 569 }
563 570
564 //new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name); 571 //new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name);
565 } 572 }
831{ 838{
832 /* If already on active list, don't do anything */ 839 /* If already on active list, don't do anything */
833 if (active) 840 if (active)
834 return; 841 return;
835 842
836 if (has_active_speed () && flag [FLAG_FREED]) LOG (llevError | logBacktrace, "BUG: tried to activate freed object %s\n", debug_desc ());//D
837 if (has_active_speed () && flag [FLAG_DEBUG]) LOG (llevError | logBacktrace, "BUG: tried to activate DEBUG object %s\n", debug_desc ());//D temp
838
839 if (has_active_speed ()) 843 if (has_active_speed ())
844 {
845 if (flag [FLAG_FREED])
846 LOG (llevError | logBacktrace, "BUG: tried to activate freed object %s\n", debug_desc ());//D
847
840 actives.insert (this); 848 actives.insert (this);
849 }
841} 850}
842 851
843void 852void
844object::activate_recursive () 853object::activate_recursive ()
845{ 854{
1477 * blocked() and wall() work properly), and these flags are updated by 1486 * blocked() and wall() work properly), and these flags are updated by
1478 * update_object(). 1487 * update_object().
1479 */ 1488 */
1480 1489
1481 /* if this is not the head or flag has been passed, don't check walk on status */ 1490 /* if this is not the head or flag has been passed, don't check walk on status */
1482 if (!(flag & INS_NO_WALK_ON) && op->head_ () == op) 1491 if (!(flag & INS_NO_WALK_ON) && op->is_head ())
1483 { 1492 {
1484 if (check_move_on (op, originator)) 1493 if (check_move_on (op, originator))
1485 return 0; 1494 return 0;
1486 1495
1487 /* If we are a multi part object, lets work our way through the check 1496 /* If we are a multi part object, lets work our way through the check
1702 * on top. 1711 * on top.
1703 */ 1712 */
1704int 1713int
1705check_move_on (object *op, object *originator) 1714check_move_on (object *op, object *originator)
1706{ 1715{
1716 if (QUERY_FLAG (op, FLAG_NO_APPLY))
1717 return 0;
1718
1707 object *tmp; 1719 object *tmp;
1708 maptile *m = op->map; 1720 maptile *m = op->map;
1709 int x = op->x, y = op->y; 1721 int x = op->x, y = op->y;
1710 1722
1711 MoveType move_on, move_slow, move_block; 1723 mapspace &ms = m->at (x, y);
1712 1724
1713 if (QUERY_FLAG (op, FLAG_NO_APPLY)) 1725 ms.update ();
1714 return 0;
1715 1726
1716 move_on = GET_MAP_MOVE_ON (op->map, op->x, op->y); 1727 MoveType move_on = ms.move_on;
1717 move_slow = GET_MAP_MOVE_SLOW (op->map, op->x, op->y); 1728 MoveType move_slow = ms.move_slow;
1718 move_block = GET_MAP_MOVE_BLOCK (op->map, op->x, op->y); 1729 MoveType move_block = ms.move_block;
1719 1730
1720 /* if nothing on this space will slow op down or be applied, 1731 /* if nothing on this space will slow op down or be applied,
1721 * no need to do checking below. have to make sure move_type 1732 * no need to do checking below. have to make sure move_type
1722 * is set, as lots of objects don't have it set - we treat that 1733 * is set, as lots of objects don't have it set - we treat that
1723 * as walking. 1734 * as walking.
1734 return 0; 1745 return 0;
1735 1746
1736 /* The objects have to be checked from top to bottom. 1747 /* The objects have to be checked from top to bottom.
1737 * Hence, we first go to the top: 1748 * Hence, we first go to the top:
1738 */ 1749 */
1739 1750 for (object *next, *tmp = ms.top; tmp; tmp = next)
1740 for (tmp = op->ms ().bot; tmp && tmp->above; tmp = tmp->above)
1741 {
1742 /* Trim the search when we find the first other spell effect
1743 * this helps performance so that if a space has 50 spell objects,
1744 * we don't need to check all of them.
1745 */
1746 if ((tmp->move_type & MOVE_FLY_LOW) && QUERY_FLAG (tmp, FLAG_NO_PICK))
1747 break;
1748 } 1751 {
1752 next = tmp->below;
1749 1753
1750 for (; tmp; tmp = tmp->below)
1751 {
1752 if (tmp == op) 1754 if (tmp == op)
1753 continue; /* Can't apply yourself */ 1755 continue; /* Can't apply yourself */
1754 1756
1755 /* Check to see if one of the movement types should be slowed down. 1757 /* Check to see if one of the movement types should be slowed down.
1756 * Second check makes sure that the movement types not being slowed 1758 * Second check makes sure that the movement types not being slowed
1761 if (!QUERY_FLAG (op, FLAG_WIZPASS)) 1763 if (!QUERY_FLAG (op, FLAG_WIZPASS))
1762 { 1764 {
1763 if ((!op->move_type && tmp->move_slow & MOVE_WALK) || 1765 if ((!op->move_type && tmp->move_slow & MOVE_WALK) ||
1764 ((op->move_type & tmp->move_slow) && (op->move_type & ~tmp->move_slow & ~tmp->move_block) == 0)) 1766 ((op->move_type & tmp->move_slow) && (op->move_type & ~tmp->move_slow & ~tmp->move_block) == 0))
1765 { 1767 {
1766
1767 float
1768 diff = tmp->move_slow_penalty * fabs (op->speed); 1768 float diff = tmp->move_slow_penalty * fabs (op->speed);
1769 1769
1770 if (op->is_player ()) 1770 if (op->is_player ())
1771 if ((QUERY_FLAG (tmp, FLAG_IS_HILLY) && find_skill_by_number (op, SK_CLIMBING)) || 1771 if ((tmp->flag [FLAG_IS_HILLY ] && find_skill_by_number (op, SK_CLIMBING)) ||
1772 (QUERY_FLAG (tmp, FLAG_IS_WOODED) && find_skill_by_number (op, SK_WOODSMAN))) 1772 (tmp->flag [FLAG_IS_WOODED] && find_skill_by_number (op, SK_WOODSMAN)))
1773 diff /= 4.0; 1773 diff /= 4.0;
1774 1774
1775 op->speed_left -= diff; 1775 op->speed_left -= diff;
1776 } 1776 }
1777 } 1777 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines