1 | /* |
1 | /* |
2 | * static char *rcsid_utils_c = |
2 | * static char *rcsid_utils_c = |
3 | * "$Id: utils.C,v 1.2 2006/08/29 08:01:36 root Exp $"; |
3 | * "$Id: utils.C,v 1.8 2006/09/09 21:48:28 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 |
… | |
… | |
284 | if (!IS_ARMOR(op)) |
286 | if (!IS_ARMOR(op)) |
285 | return; |
287 | return; |
286 | |
288 | |
287 | mt = name_to_material(op->materialname); |
289 | mt = name_to_material(op->materialname); |
288 | if (!mt) { |
290 | if (!mt) { |
289 | LOG(llevError, "archetype '%s>%s' uses nonexistent material '%s'\n", op->arch->name, op->name, op->materialname); |
291 | LOG(llevError, "archetype '%s>%s' uses nonexistent material '%s'\n", &op->arch->name, &op->name, &op->materialname); |
290 | return; |
292 | return; |
291 | } |
293 | } |
292 | |
294 | |
293 | for (j=0; j < NROFATTACKS; j++) |
295 | for (j=0; j < NROFATTACKS; j++) |
294 | if (op->resist[j] == 0 && change->resist[j] != 0) { |
296 | if (op->resist[j] == 0 && change->resist[j] != 0) { |
… | |
… | |
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 | |
… | |
… | |
336 | lmt = nmt; |
340 | lmt = nmt; |
337 | } |
341 | } |
338 | |
342 | |
339 | if (lmt != NULL) { |
343 | if (lmt != NULL) { |
340 | #ifndef NEW_MATERIAL_CODE |
344 | #ifndef NEW_MATERIAL_CODE |
341 | op->materialname = add_string(lmt->name); |
345 | op->materialname = lmt->name; |
342 | return; |
346 | return; |
343 | #else |
347 | #else |
344 | |
348 | |
345 | if (op->stats.dam && IS_WEAPON(op)) { |
349 | if (op->stats.dam && IS_WEAPON(op)) { |
346 | op->stats.dam += lmt->damage; |
350 | op->stats.dam += lmt->damage; |
… | |
… | |
480 | strcat(input, p); |
484 | strcat(input, p); |
481 | } |
485 | } |
482 | else strcpy(input, tmp); |
486 | else strcpy(input, tmp); |
483 | return; |
487 | return; |
484 | } |
488 | } |
|
|
489 | |
|
|
490 | void * |
|
|
491 | zero_initialised::operator new (size_t s) |
|
|
492 | { |
|
|
493 | //return calloc (1, s); |
|
|
494 | return g_slice_alloc0 (s); |
|
|
495 | } |
|
|
496 | |
|
|
497 | void * |
|
|
498 | zero_initialised::operator new [] (size_t s) |
|
|
499 | { |
|
|
500 | //return calloc (1, s); |
|
|
501 | return g_slice_alloc0 (s); |
|
|
502 | } |
|
|
503 | |
|
|
504 | void |
|
|
505 | zero_initialised::operator delete (void *p, size_t s) |
|
|
506 | { |
|
|
507 | //free (p); return; |
|
|
508 | g_slice_free1 (s, p); |
|
|
509 | } |
|
|
510 | |
|
|
511 | void |
|
|
512 | zero_initialised::operator delete [] (void *p, size_t s) |
|
|
513 | { |
|
|
514 | //free (p); return; |
|
|
515 | g_slice_free1 (s, p); |
|
|
516 | } |
|
|
517 | |