1 | /* |
1 | /* |
2 | * static char *rcsid_utils_c = |
2 | * static char *rcsid_utils_c = |
3 | * "$Id: utils.C,v 1.3 2006/09/03 00:18:40 root Exp $"; |
3 | * "$Id: utils.C,v 1.7 2006/09/08 17:34:02 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
31 | */ |
31 | */ |
32 | |
32 | |
33 | #include <global.h> |
33 | #include <global.h> |
34 | #include <funcpoint.h> |
34 | #include <funcpoint.h> |
35 | #include <material.h> |
35 | #include <material.h> |
|
|
36 | |
|
|
37 | #include <glib.h> |
36 | |
38 | |
37 | /* |
39 | /* |
38 | * The random functions here take luck into account when rolling random |
40 | * The random functions here take luck into account when rolling random |
39 | * dice or numbers. This function has less of an impact the larger the |
41 | * dice or numbers. This function has less of an impact the larger the |
40 | * difference becomes in the random numbers. IE, the effect is lessened |
42 | * difference becomes in the random numbers. IE, the effect is lessened |
… | |
… | |
302 | |
304 | |
303 | /* set the materialname and type for an item */ |
305 | /* set the materialname and type for an item */ |
304 | void set_materialname(object *op, int difficulty, materialtype_t *nmt) |
306 | void set_materialname(object *op, int difficulty, materialtype_t *nmt) |
305 | { |
307 | { |
306 | materialtype_t *mt, *lmt; |
308 | materialtype_t *mt, *lmt; |
|
|
309 | #ifdef NEW_MATERIAL_CODE |
307 | int j; |
310 | int j; |
|
|
311 | #endif |
308 | |
312 | |
309 | if (op->materialname != NULL) |
313 | if (op->materialname != NULL) |
310 | return; |
314 | return; |
311 | |
315 | |
312 | |
316 | |
… | |
… | |
484 | } |
488 | } |
485 | |
489 | |
486 | void * |
490 | void * |
487 | zero_initialised::operator new (size_t s) |
491 | zero_initialised::operator new (size_t s) |
488 | { |
492 | { |
489 | void *p = malloc (s); |
493 | return g_slice_alloc0 (s); |
490 | |
494 | } |
491 | memset (p, 0, s); |
495 | |
492 | return p; |
496 | void * |
|
|
497 | zero_initialised::operator new [] (size_t s) |
|
|
498 | { |
|
|
499 | return g_slice_alloc0 (s); |
493 | } |
500 | } |
494 | |
501 | |
495 | void |
502 | void |
496 | zero_initialised::operator delete (void *p, size_t s) |
503 | zero_initialised::operator delete (void *p, size_t s) |
497 | { |
504 | { |
498 | free (p); |
505 | g_slice_free1 (s, p); |
499 | } |
506 | } |
500 | |
507 | |
|
|
508 | void |
|
|
509 | zero_initialised::operator delete [] (void *p, size_t s) |
|
|
510 | { |
|
|
511 | g_slice_free1 (s, p); |
|
|
512 | } |
|
|
513 | |