--- deliantra/server/common/utils.C 2006/09/12 20:55:40 1.12 +++ deliantra/server/common/utils.C 2006/12/12 20:53:02 1.21 @@ -1,9 +1,3 @@ - -/* - * static char *rcsid_utils_c = - * "$Id: utils.C,v 1.12 2006/09/12 20:55:40 root Exp $"; - */ - /* CrossFire, A Multiplayer game for X-windows @@ -24,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - The authors can be reached via e-mail at crossfire-devel@real-time.com + The authors can be reached via e-mail at */ /* @@ -105,11 +99,7 @@ if (max < 1 || diff < 1) { -#ifndef WIN32 - LOG (llevError, "Calling random_roll with min=%lld max=%lld\n", min, max); -#else - LOG (llevError, "Calling random_roll with min=%I64d max=%I64d\n", min, max); -#endif + LOG (llevError, "Calling random_roll with min=%" PRId64 " max=%" PRId64 "\n", min, max); return (min); /* avoids a float exception */ } @@ -208,7 +198,7 @@ /* decay and destroy persihable items in a map */ void -decay_objects (mapstruct *m) +decay_objects (maptile *m) { int x, y, destroy; object *op, *otmp; @@ -267,8 +257,8 @@ /* adjust overall chance below */ if (destroy && rndm (0, 1)) { - remove_ob (op); - free_object (op); + op->remove (); + op->destroy (0); } } } @@ -551,18 +541,33 @@ return; } -void *alloc (int s) throw (std::bad_alloc) +///////////////////////////////////////////////////////////////////////////// + +#if 0 +refcounted *refcounted::rc_first; + +refcounted::refcounted () { - if (s) - return g_slice_alloc (s); - else - return 0; + refcnt = 0; + rc_next = rc_first; + rc_first = this; } -void dealloc (void *p, int s) throw () +refcounted::~refcounted () { - if (s) - g_slice_free1 (s, p); + assert (!rc_next); + assert (!refcnt); +} +#endif + +void *alloc (int s) throw (std::bad_alloc) +{ + void *p = g_slice_alloc (s); + + if (!p) + throw std::bad_alloc (); + + return p; } void assign (char *dst, const char *src, int maxlen) @@ -589,3 +594,4 @@ memcpy (dst, src, len + 1); } +