--- deliantra/server/common/object.C 2008/04/21 06:16:01 1.208 +++ deliantra/server/common/object.C 2008/04/21 06:35:26 1.209 @@ -1479,46 +1479,6 @@ return where->map->insert (this, where->x, where->y, originator, flags); } -/* - * get_split_ob(ob,nr) splits up ob into two parts. The part which - * is returned contains nr objects, and the remaining parts contains - * the rest (or is removed and freed if that number is 0). - * On failure, NULL is returned, and the reason put into the - * global static errmsg array. - */ -object * -object::split_nr (sint32 nr) -{ - if (nrof < nr) - return 0; - else if (nrof == nr) - { - remove (); - return this; - } - else - { - decrease_nr (nr); - - object *op = object_create_clone (this); - op->nrof = nr; - return op; - } -} - -//TODO: remove, but semantics differs from split_nr -object * -get_split_ob (object *orig_ob, uint32 nr) -{ - if (orig_ob->nrof < nr) - { - sprintf (errmsg, "There are only %d %ss.", orig_ob->nrof ? orig_ob->nrof : 1, &orig_ob->name); - return 0; - } - - return orig_ob->split_nr (nr); -} - // find player who can see this object static object * visible_to (object *op) @@ -1554,14 +1514,14 @@ } /* - * decrease_ob_nr(object, number) decreases a specified number from + * decrease(object, number) decreases a specified number from * the amount of an object. If the amount reaches 0, the object * is subsequently removed and freed. * * Return value: 'op' if something is left, NULL if the amount reached 0 */ bool -object::decrease_nr (sint32 nr) +object::decrease (sint32 nr) { nr = min (nr, nrof); @@ -1591,11 +1551,44 @@ } } -//TODO: remove +/* + * get_split_ob(ob,nr) splits up ob into two parts. The part which + * is returned contains nr objects, and the remaining parts contains + * the rest (or is removed and freed if that number is 0). + * On failure, NULL is returned, and the reason put into the + * global static errmsg array. + */ object * -decrease_ob_nr (object *op, uint32 i) +object::split (sint32 nr) { - return op->decrease_nr (i) ? op : 0; + if (nrof < nr) + return 0; + else if (nrof == nr) + { + remove (); + return this; + } + else + { + decrease (nr); + + object *op = object_create_clone (this); + op->nrof = nr; + return op; + } +} + +//TODO: remove, but semantics differs from split_nr +object * +get_split_ob (object *orig_ob, uint32 nr) +{ + if (orig_ob->nrof < nr) + { + sprintf (errmsg, "There are only %d %ss.", orig_ob->nrof ? orig_ob->nrof : 1, &orig_ob->name); + return 0; + } + + return orig_ob->split (nr); } object *