1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_utils_c = |
|
|
4 | * "$Id: utils.C,v 1.12 2006/09/12 20:55:40 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* |
1 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
9 | |
3 | |
10 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
11 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
22 | |
16 | |
23 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
24 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | |
20 | |
27 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
28 | */ |
22 | */ |
29 | |
23 | |
30 | /* |
24 | /* |
31 | * General convenience functions for crossfire. |
25 | * General convenience functions for crossfire. |
32 | */ |
26 | */ |
… | |
… | |
206 | } |
200 | } |
207 | |
201 | |
208 | /* decay and destroy persihable items in a map */ |
202 | /* decay and destroy persihable items in a map */ |
209 | |
203 | |
210 | void |
204 | void |
211 | decay_objects (mapstruct *m) |
205 | decay_objects (maptile *m) |
212 | { |
206 | { |
213 | int x, y, destroy; |
207 | int x, y, destroy; |
214 | object *op, *otmp; |
208 | object *op, *otmp; |
215 | |
209 | |
216 | if (m->unique) |
210 | if (m->unique) |
… | |
… | |
549 | strcpy (input, tmp); |
543 | strcpy (input, tmp); |
550 | |
544 | |
551 | return; |
545 | return; |
552 | } |
546 | } |
553 | |
547 | |
|
|
548 | ///////////////////////////////////////////////////////////////////////////// |
|
|
549 | |
554 | void *alloc (int s) throw (std::bad_alloc) |
550 | void *alloc (int s) throw (std::bad_alloc) |
555 | { |
551 | { |
|
|
552 | void *p = g_slice_alloc (s); |
|
|
553 | |
556 | if (s) |
554 | if (!p) |
557 | return g_slice_alloc (s); |
555 | throw std::bad_alloc (); |
558 | else |
556 | |
559 | return 0; |
557 | return p; |
560 | } |
|
|
561 | |
|
|
562 | void dealloc (void *p, int s) throw () |
|
|
563 | { |
|
|
564 | if (s) |
|
|
565 | g_slice_free1 (s, p); |
|
|
566 | } |
558 | } |
567 | |
559 | |
568 | void assign (char *dst, const char *src, int maxlen) |
560 | void assign (char *dst, const char *src, int maxlen) |
569 | { |
561 | { |
570 | if (!src) |
562 | if (!src) |