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.69 by root, Mon Dec 18 03:00:02 2006 UTC vs.
Revision 1.74 by root, Wed Dec 20 09:14:21 2006 UTC

352 op = op->env; 352 op = op->env;
353 return op; 353 return op;
354} 354}
355 355
356/* 356/*
357 * Eneq(@csd.uu.se): Since we can have items buried in a character we need
358 * a better check. We basically keeping traversing up until we can't
359 * or find a player.
360 */
361
362object *
363is_player_inv (object *op)
364{
365 for (; op != NULL && op->type != PLAYER; op = op->env)
366 if (op->env == op)
367 op->env = NULL;
368 return op;
369}
370
371/*
372 * Used by: Crossedit: dump. Server DM commands: dumpbelow, dump. 357 * Used by: Crossedit: dump. Server DM commands: dumpbelow, dump.
373 * Some error messages. 358 * Some error messages.
374 * The result of the dump is stored in the static global errmsg array. 359 * The result of the dump is stored in the static global errmsg array.
375 */ 360 */
376 361
1055 1040
1056 /* NO_FIX_PLAYER is set when a great many changes are being 1041 /* NO_FIX_PLAYER is set when a great many changes are being
1057 * made to players inventory. If set, avoiding the call 1042 * made to players inventory. If set, avoiding the call
1058 * to save cpu time. 1043 * to save cpu time.
1059 */ 1044 */
1060 if ((otmp = is_player_inv (env)) != NULL && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) 1045 if ((otmp = in_player ()) && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER))
1061 fix_player (otmp); 1046 fix_player (otmp);
1062 1047
1063 if (above != NULL) 1048 if (above != NULL)
1064 above->below = below; 1049 above->below = below;
1065 else 1050 else
1136 { 1121 {
1137 CLEAR_FLAG (this, FLAG_APPLIED); 1122 CLEAR_FLAG (this, FLAG_APPLIED);
1138 tmp->container = 0; 1123 tmp->container = 0;
1139 } 1124 }
1140 1125
1141 tmp->contr->socket->update_look = 1; 1126 tmp->contr->socket->floorbox_update ();
1142 } 1127 }
1143 1128
1144 /* See if player moving off should effect something */ 1129 /* See if player moving off should effect something */
1145 if (check_walk_off 1130 if (check_walk_off
1146 && ((move_type & tmp->move_off) 1131 && ((move_type & tmp->move_off)
1483 * it, so save a few ticks and start from there. 1468 * it, so save a few ticks and start from there.
1484 */ 1469 */
1485 if (!(flag & INS_MAP_LOAD)) 1470 if (!(flag & INS_MAP_LOAD))
1486 for (tmp = floor ? floor : GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 1471 for (tmp = floor ? floor : GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
1487 if (tmp->type == PLAYER) 1472 if (tmp->type == PLAYER)
1488 tmp->contr->socket->update_look = 1; 1473 tmp->contr->socket->floorbox_update ();
1489 1474
1490 /* If this object glows, it may affect lighting conditions that are 1475 /* If this object glows, it may affect lighting conditions that are
1491 * visible to others on this map. But update_all_los is really 1476 * visible to others on this map. But update_all_los is really
1492 * an inefficient way to do this, as it means los for all players 1477 * an inefficient way to do this, as it means los for all players
1493 * on the map will get recalculated. The players could very well 1478 * on the map will get recalculated. The players could very well
1501 1486
1502 /* updates flags (blocked, alive, no magic, etc) for this map space */ 1487 /* updates flags (blocked, alive, no magic, etc) for this map space */
1503 update_object (op, UP_OBJ_INSERT); 1488 update_object (op, UP_OBJ_INSERT);
1504 1489
1505 /* Don't know if moving this to the end will break anything. However, 1490 /* Don't know if moving this to the end will break anything. However,
1506 * we want to have update_look set above before calling this. 1491 * we want to have floorbox_update called before calling this.
1507 * 1492 *
1508 * check_move_on() must be after this because code called from 1493 * check_move_on() must be after this because code called from
1509 * check_move_on() depends on correct map flags (so functions like 1494 * check_move_on() depends on correct map flags (so functions like
1510 * blocked() and wall() work properly), and these flags are updated by 1495 * blocked() and wall() work properly), and these flags are updated by
1511 * update_object(). 1496 * update_object().
1614 if (i > op->nrof) 1599 if (i > op->nrof)
1615 i = op->nrof; 1600 i = op->nrof;
1616 1601
1617 if (QUERY_FLAG (op, FLAG_REMOVED)) 1602 if (QUERY_FLAG (op, FLAG_REMOVED))
1618 op->nrof -= i; 1603 op->nrof -= i;
1619 else if (op->env != NULL) 1604 else if (op->env)
1620 { 1605 {
1621 /* is this object in the players inventory, or sub container 1606 /* is this object in the players inventory, or sub container
1622 * therein? 1607 * therein?
1623 */ 1608 */
1624 tmp = is_player_inv (op->env); 1609 tmp = op->in_player ();
1625 /* nope. Is this a container the player has opened? 1610 /* nope. Is this a container the player has opened?
1626 * If so, set tmp to that player. 1611 * If so, set tmp to that player.
1627 * IMO, searching through all the players will mostly 1612 * IMO, searching through all the players will mostly
1628 * likely be quicker than following op->env to the map, 1613 * likely be quicker than following op->env to the map,
1629 * and then searching the map for a player. 1614 * and then searching the map for a player.
1630 */ 1615 */
1631 if (!tmp) 1616 if (!tmp)
1632 { 1617 {
1633 for (pl = first_player; pl; pl = pl->next) 1618 for (pl = first_player; pl; pl = pl->next)
1634 if (pl->ob->container == op->env) 1619 if (pl->ob->container == op->env)
1620 {
1621 tmp = pl->ob;
1635 break; 1622 break;
1636 if (pl) 1623 }
1637 tmp = pl->ob;
1638 else
1639 tmp = NULL;
1640 } 1624 }
1641 1625
1642 if (i < op->nrof) 1626 if (i < op->nrof)
1643 { 1627 {
1644 sub_weight (op->env, op->weight * i); 1628 sub_weight (op->env, op->weight * i);
1645 op->nrof -= i; 1629 op->nrof -= i;
1646 if (tmp) 1630 if (tmp)
1647 {
1648 esrv_send_item (tmp, op); 1631 esrv_send_item (tmp, op);
1649 }
1650 } 1632 }
1651 else 1633 else
1652 { 1634 {
1653 op->remove (); 1635 op->remove ();
1654 op->nrof = 0; 1636 op->nrof = 0;
1655 if (tmp) 1637 if (tmp)
1656 {
1657 esrv_del_item (tmp->contr, op->count); 1638 esrv_del_item (tmp->contr, op->count);
1658 }
1659 } 1639 }
1660 } 1640 }
1661 else 1641 else
1662 { 1642 {
1663 object *above = op->above; 1643 object *above = op->above;
1669 op->remove (); 1649 op->remove ();
1670 op->nrof = 0; 1650 op->nrof = 0;
1671 } 1651 }
1672 1652
1673 /* Since we just removed op, op->above is null */ 1653 /* Since we just removed op, op->above is null */
1674 for (tmp = above; tmp != NULL; tmp = tmp->above) 1654 for (tmp = above; tmp; tmp = tmp->above)
1675 if (tmp->type == PLAYER) 1655 if (tmp->type == PLAYER)
1676 { 1656 {
1677 if (op->nrof) 1657 if (op->nrof)
1678 esrv_send_item (tmp, op); 1658 esrv_send_item (tmp, op);
1679 else 1659 else
1684 if (op->nrof) 1664 if (op->nrof)
1685 return op; 1665 return op;
1686 else 1666 else
1687 { 1667 {
1688 op->destroy (); 1668 op->destroy ();
1689 return NULL; 1669 return 0;
1690 } 1670 }
1691} 1671}
1692 1672
1693/* 1673/*
1694 * add_weight(object, weight) adds the specified weight to an object, 1674 * add_weight(object, weight) adds the specified weight to an object,
1782 add_weight (this, op->weight * op->nrof); 1762 add_weight (this, op->weight * op->nrof);
1783 } 1763 }
1784 else 1764 else
1785 add_weight (this, (op->weight + op->carrying)); 1765 add_weight (this, (op->weight + op->carrying));
1786 1766
1787 otmp = is_player_inv (this); 1767 otmp = this->in_player ();
1788 if (otmp && otmp->contr) 1768 if (otmp && otmp->contr)
1789 if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) 1769 if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER))
1790 fix_player (otmp); 1770 fix_player (otmp);
1791 1771
1792 op->map = NULL; 1772 op->map = 0;
1793 op->env = this; 1773 op->env = this;
1794 op->above = NULL; 1774 op->above = 0;
1795 op->below = NULL; 1775 op->below = 0;
1796 op->x = 0, op->y = 0; 1776 op->x = 0, op->y = 0;
1797 1777
1798 /* reset the light list and los of the players on the map */ 1778 /* reset the light list and los of the players on the map */
1799 if ((op->glow_radius != 0) && map) 1779 if ((op->glow_radius != 0) && map)
1800 { 1780 {
2137 * if the space being examined only has a wall to the north and empty 2117 * if the space being examined only has a wall to the north and empty
2138 * spaces in all the other directions, this will reduce the search space 2118 * spaces in all the other directions, this will reduce the search space
2139 * to only the spaces immediately surrounding the target area, and 2119 * to only the spaces immediately surrounding the target area, and
2140 * won't look 2 spaces south of the target space. 2120 * won't look 2 spaces south of the target space.
2141 */ 2121 */
2142 else if ((flag & AB_NO_PASS) && maxfree[i] < stop) 2122 else if ((flag & P_NO_PASS) && maxfree[i] < stop)
2143 stop = maxfree[i]; 2123 stop = maxfree[i];
2144 } 2124 }
2125
2145 if (!index) 2126 if (!index)
2146 return -1; 2127 return -1;
2128
2147 return altern[RANDOM () % index]; 2129 return altern[RANDOM () % index];
2148} 2130}
2149 2131
2150/* 2132/*
2151 * find_first_free_spot(archetype, maptile, x, y) works like 2133 * find_first_free_spot(archetype, maptile, x, y) works like

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines