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.209 by root, Mon Apr 21 06:35:26 2008 UTC vs.
Revision 1.210 by root, Mon Apr 21 07:01:40 2008 UTC

1550 return 0; 1550 return 0;
1551 } 1551 }
1552} 1552}
1553 1553
1554/* 1554/*
1555 * get_split_ob(ob,nr) splits up ob into two parts. The part which 1555 * split(ob,nr) splits up ob into two parts. The part which
1556 * is returned contains nr objects, and the remaining parts contains 1556 * is returned contains nr objects, and the remaining parts contains
1557 * the rest (or is removed and freed if that number is 0). 1557 * the rest (or is removed and returned if that number is 0).
1558 * On failure, NULL is returned, and the reason put into the 1558 * On failure, NULL is returned.
1559 * global static errmsg array.
1560 */ 1559 */
1561object * 1560object *
1562object::split (sint32 nr) 1561object::split (sint32 nr)
1563{ 1562{
1564 if (nrof < nr) 1563 if (nrof < nr)
1574 1573
1575 object *op = object_create_clone (this); 1574 object *op = object_create_clone (this);
1576 op->nrof = nr; 1575 op->nrof = nr;
1577 return op; 1576 return op;
1578 } 1577 }
1579}
1580
1581//TODO: remove, but semantics differs from split_nr
1582object *
1583get_split_ob (object *orig_ob, uint32 nr)
1584{
1585 if (orig_ob->nrof < nr)
1586 {
1587 sprintf (errmsg, "There are only %d %ss.", orig_ob->nrof ? orig_ob->nrof : 1, &orig_ob->name);
1588 return 0;
1589 }
1590
1591 return orig_ob->split (nr);
1592} 1578}
1593 1579
1594object * 1580object *
1595insert_ob_in_ob (object *op, object *where) 1581insert_ob_in_ob (object *op, object *where)
1596{ 1582{
1637 if (object::can_merge (tmp, op)) 1623 if (object::can_merge (tmp, op))
1638 { 1624 {
1639 /* return the original object and remove inserted object 1625 /* return the original object and remove inserted object
1640 (client needs the original object) */ 1626 (client needs the original object) */
1641 tmp->nrof += op->nrof; 1627 tmp->nrof += op->nrof;
1628 adjust_weight (this, op->total_weight ());
1629
1642 op->destroy (1); 1630 op->destroy (1);
1643 op = tmp; 1631 op = tmp;
1644 goto inserted; 1632 goto inserted;
1645 } 1633 }
1646 1634

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines