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.66 by root, Wed Dec 13 03:28:42 2006 UTC vs.
Revision 1.73 by root, Wed Dec 20 01:19:11 2006 UTC

29#include <sys/types.h> 29#include <sys/types.h>
30#include <sys/uio.h> 30#include <sys/uio.h>
31#include <object.h> 31#include <object.h>
32#include <funcpoint.h> 32#include <funcpoint.h>
33#include <loader.h> 33#include <loader.h>
34
35#include <bitset>
34 36
35int nrofallocobjects = 0; 37int nrofallocobjects = 0;
36static UUID uuid; 38static UUID uuid;
37const uint64 UUID_SKIP = 1<<19; 39const uint64 UUID_SKIP = 1<<19;
38 40
219 SET_FLAG (ob1, FLAG_BEEN_APPLIED); 221 SET_FLAG (ob1, FLAG_BEEN_APPLIED);
220 222
221 if (QUERY_FLAG (ob2, FLAG_IDENTIFIED)) 223 if (QUERY_FLAG (ob2, FLAG_IDENTIFIED))
222 SET_FLAG (ob2, FLAG_BEEN_APPLIED); 224 SET_FLAG (ob2, FLAG_BEEN_APPLIED);
223 225
224 226 if ((ob1->flags ^ ob2->flags).reset (FLAG_INV_LOCKED).reset (FLAG_CLIENT_SENT).any ()
225 /* the 0x400000 on flags2 is FLAG_INV_LOCK. I don't think something 227 || ob1->arch != ob2->arch
226 * being locked in inventory should prevent merging.
227 * 0x4 in flags3 is CLIENT_SENT
228 */
229 if ((ob1->arch != ob2->arch) ||
230 (ob1->flags[0] != ob2->flags[0]) ||
231 (ob1->flags[1] != ob2->flags[1]) ||
232 ((ob1->flags[2] & ~0x400000) != (ob2->flags[2] & ~0x400000)) ||
233 ((ob1->flags[3] & ~0x4) != (ob2->flags[3] & ~0x4)) ||
234 (ob1->name != ob2->name) || 228 || ob1->name != ob2->name
235 (ob1->title != ob2->title) || 229 || ob1->title != ob2->title
236 (ob1->msg != ob2->msg) || 230 || ob1->msg != ob2->msg
237 (ob1->weight != ob2->weight) || 231 || ob1->weight != ob2->weight
238 (memcmp (&ob1->resist, &ob2->resist, sizeof (ob1->resist)) != 0) || 232 || memcmp (&ob1->resist, &ob2->resist, sizeof (ob1->resist))
239 (memcmp (&ob1->stats, &ob2->stats, sizeof (ob1->stats)) != 0) || 233 || memcmp (&ob1->stats , &ob2->stats , sizeof (ob1->stats) )
240 (ob1->attacktype != ob2->attacktype) || 234 || ob1->attacktype != ob2->attacktype
241 (ob1->magic != ob2->magic) || 235 || ob1->magic != ob2->magic
242 (ob1->slaying != ob2->slaying) || 236 || ob1->slaying != ob2->slaying
243 (ob1->skill != ob2->skill) || 237 || ob1->skill != ob2->skill
244 (ob1->value != ob2->value) || 238 || ob1->value != ob2->value
245 (ob1->animation_id != ob2->animation_id) || 239 || ob1->animation_id != ob2->animation_id
246 (ob1->client_type != ob2->client_type) || 240 || ob1->client_type != ob2->client_type
247 (ob1->materialname != ob2->materialname) || 241 || ob1->materialname != ob2->materialname
248 (ob1->lore != ob2->lore) || 242 || ob1->lore != ob2->lore
249 (ob1->subtype != ob2->subtype) || 243 || ob1->subtype != ob2->subtype
250 (ob1->move_type != ob2->move_type) || 244 || ob1->move_type != ob2->move_type
251 (ob1->move_block != ob2->move_block) || 245 || ob1->move_block != ob2->move_block
252 (ob1->move_allow != ob2->move_allow) || 246 || ob1->move_allow != ob2->move_allow
253 (ob1->move_on != ob2->move_on) || 247 || ob1->move_on != ob2->move_on
254 (ob1->move_off != ob2->move_off) || (ob1->move_slow != ob2->move_slow) || (ob1->move_slow_penalty != ob2->move_slow_penalty)) 248 || ob1->move_off != ob2->move_off
249 || ob1->move_slow != ob2->move_slow
250 || ob1->move_slow_penalty != ob2->move_slow_penalty)
255 return 0; 251 return 0;
256 252
257 /* This is really a spellbook check - really, we should 253 /* This is really a spellbook check - really, we should
258 * check all objects in the inventory. 254 * check all objects in the inventory.
259 */ 255 */
1140 { 1136 {
1141 CLEAR_FLAG (this, FLAG_APPLIED); 1137 CLEAR_FLAG (this, FLAG_APPLIED);
1142 tmp->container = 0; 1138 tmp->container = 0;
1143 } 1139 }
1144 1140
1145 tmp->contr->socket.update_look = 1; 1141 tmp->contr->socket->floorbox_update ();
1146 } 1142 }
1147 1143
1148 /* See if player moving off should effect something */ 1144 /* See if player moving off should effect something */
1149 if (check_walk_off 1145 if (check_walk_off
1150 && ((move_type & tmp->move_off) 1146 && ((move_type & tmp->move_off)
1487 * it, so save a few ticks and start from there. 1483 * it, so save a few ticks and start from there.
1488 */ 1484 */
1489 if (!(flag & INS_MAP_LOAD)) 1485 if (!(flag & INS_MAP_LOAD))
1490 for (tmp = floor ? floor : GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 1486 for (tmp = floor ? floor : GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
1491 if (tmp->type == PLAYER) 1487 if (tmp->type == PLAYER)
1492 tmp->contr->socket.update_look = 1; 1488 tmp->contr->socket->floorbox_update ();
1493 1489
1494 /* If this object glows, it may affect lighting conditions that are 1490 /* If this object glows, it may affect lighting conditions that are
1495 * visible to others on this map. But update_all_los is really 1491 * visible to others on this map. But update_all_los is really
1496 * an inefficient way to do this, as it means los for all players 1492 * an inefficient way to do this, as it means los for all players
1497 * on the map will get recalculated. The players could very well 1493 * on the map will get recalculated. The players could very well
1505 1501
1506 /* updates flags (blocked, alive, no magic, etc) for this map space */ 1502 /* updates flags (blocked, alive, no magic, etc) for this map space */
1507 update_object (op, UP_OBJ_INSERT); 1503 update_object (op, UP_OBJ_INSERT);
1508 1504
1509 /* Don't know if moving this to the end will break anything. However, 1505 /* Don't know if moving this to the end will break anything. However,
1510 * we want to have update_look set above before calling this. 1506 * we want to have floorbox_update called before calling this.
1511 * 1507 *
1512 * check_move_on() must be after this because code called from 1508 * check_move_on() must be after this because code called from
1513 * check_move_on() depends on correct map flags (so functions like 1509 * check_move_on() depends on correct map flags (so functions like
1514 * blocked() and wall() work properly), and these flags are updated by 1510 * blocked() and wall() work properly), and these flags are updated by
1515 * update_object(). 1511 * update_object().
1618 if (i > op->nrof) 1614 if (i > op->nrof)
1619 i = op->nrof; 1615 i = op->nrof;
1620 1616
1621 if (QUERY_FLAG (op, FLAG_REMOVED)) 1617 if (QUERY_FLAG (op, FLAG_REMOVED))
1622 op->nrof -= i; 1618 op->nrof -= i;
1623 else if (op->env != NULL) 1619 else if (op->env)
1624 { 1620 {
1625 /* is this object in the players inventory, or sub container 1621 /* is this object in the players inventory, or sub container
1626 * therein? 1622 * therein?
1627 */ 1623 */
1628 tmp = is_player_inv (op->env); 1624 tmp = is_player_inv (op->env);
1634 */ 1630 */
1635 if (!tmp) 1631 if (!tmp)
1636 { 1632 {
1637 for (pl = first_player; pl; pl = pl->next) 1633 for (pl = first_player; pl; pl = pl->next)
1638 if (pl->ob->container == op->env) 1634 if (pl->ob->container == op->env)
1635 {
1636 tmp = pl->ob;
1639 break; 1637 break;
1640 if (pl) 1638 }
1641 tmp = pl->ob;
1642 else
1643 tmp = NULL;
1644 } 1639 }
1645 1640
1646 if (i < op->nrof) 1641 if (i < op->nrof)
1647 { 1642 {
1648 sub_weight (op->env, op->weight * i); 1643 sub_weight (op->env, op->weight * i);
1649 op->nrof -= i; 1644 op->nrof -= i;
1650 if (tmp) 1645 if (tmp)
1651 {
1652 esrv_send_item (tmp, op); 1646 esrv_send_item (tmp, op);
1653 }
1654 } 1647 }
1655 else 1648 else
1656 { 1649 {
1657 op->remove (); 1650 op->remove ();
1658 op->nrof = 0; 1651 op->nrof = 0;
1659 if (tmp) 1652 if (tmp)
1660 {
1661 esrv_del_item (tmp->contr, op->count); 1653 esrv_del_item (tmp->contr, op->count);
1662 }
1663 } 1654 }
1664 } 1655 }
1665 else 1656 else
1666 { 1657 {
1667 object *above = op->above; 1658 object *above = op->above;
1673 op->remove (); 1664 op->remove ();
1674 op->nrof = 0; 1665 op->nrof = 0;
1675 } 1666 }
1676 1667
1677 /* Since we just removed op, op->above is null */ 1668 /* Since we just removed op, op->above is null */
1678 for (tmp = above; tmp != NULL; tmp = tmp->above) 1669 for (tmp = above; tmp; tmp = tmp->above)
1679 if (tmp->type == PLAYER) 1670 if (tmp->type == PLAYER)
1680 { 1671 {
1681 if (op->nrof) 1672 if (op->nrof)
1682 esrv_send_item (tmp, op); 1673 esrv_send_item (tmp, op);
1683 else 1674 else
1688 if (op->nrof) 1679 if (op->nrof)
1689 return op; 1680 return op;
1690 else 1681 else
1691 { 1682 {
1692 op->destroy (); 1683 op->destroy ();
1693 return NULL; 1684 return 0;
1694 } 1685 }
1695} 1686}
1696 1687
1697/* 1688/*
1698 * add_weight(object, weight) adds the specified weight to an object, 1689 * add_weight(object, weight) adds the specified weight to an object,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines