1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <loader.h> |
|
|
27 | #include <sproto.h> |
26 | #include <sproto.h> |
28 | |
27 | |
29 | ///////////////////////////////////////////////////////////////////////////// |
28 | ///////////////////////////////////////////////////////////////////////////// |
30 | |
29 | |
31 | extern archetype *loading_arch; |
30 | extern archetype *loading_arch; |
… | |
… | |
395 | if (ip > 2 * item_power && ip > (item_power + 3)) |
394 | if (ip > 2 * item_power && ip > (item_power + 3)) |
396 | LOG (llevDebug, "Object %s seems to have too low item power? %d > %d\n", debug_desc (), ip, item_power); |
395 | LOG (llevDebug, "Object %s seems to have too low item power? %d > %d\n", debug_desc (), ip, item_power); |
397 | #endif |
396 | #endif |
398 | } |
397 | } |
399 | |
398 | |
400 | /* old style spellcasting object (pretty common) - need to load in the appropiate object */ |
399 | /* old style spellcasting object (pretty common) - need to load in the appropriate object */ |
401 | /* (schmorp) old really doesn't mean old, imho, just a more compact way to store such objects */ |
400 | /* (schmorp) old really doesn't mean old, imho, just a more compact way to store such objects */ |
402 | if ((type == ROD |
401 | if ((type == ROD |
403 | || type == WAND |
402 | || type == WAND |
404 | || type == SCROLL |
403 | || type == SCROLL |
405 | || type == HORN |
404 | || type == HORN |
… | |
… | |
430 | randomitems = 0; /* So another spell isn't created for this object */ |
429 | randomitems = 0; /* So another spell isn't created for this object */ |
431 | /* without this, value is all screwed up */ |
430 | /* without this, value is all screwed up */ |
432 | value = arch->value * inv->value; |
431 | value = arch->value * inv->value; |
433 | } |
432 | } |
434 | |
433 | |
435 | if (QUERY_FLAG (this, FLAG_MONSTER)) |
434 | if (this->flag [FLAG_MONSTER]) |
436 | { |
435 | { |
437 | if (stats.hp > stats.maxhp) |
436 | if (stats.hp > stats.maxhp) |
438 | { |
437 | { |
439 | LOG (llevInfo, "ITEMBUG: monster %s has hp set higher than maxhp (%d>%d)\n", debug_desc (), stats.hp, stats.maxhp); |
438 | LOG (llevInfo, "ITEMBUG: monster %s has hp set higher than maxhp (%d>%d)\n", debug_desc (), stats.hp, stats.maxhp); |
440 | stats.maxhp = stats.hp; |
439 | stats.maxhp = stats.hp; |
… | |
… | |
443 | /* The archs just need to be updated for this */ |
442 | /* The archs just need to be updated for this */ |
444 | if (move_type == 0) |
443 | if (move_type == 0) |
445 | move_type = MOVE_WALK; |
444 | move_type = MOVE_WALK; |
446 | } |
445 | } |
447 | |
446 | |
448 | if ((QUERY_FLAG (this, FLAG_GENERATOR) && QUERY_FLAG (this, FLAG_CONTENT_ON_GEN)) || type == CREATOR || type == CONVERTER) |
447 | if ((this->flag [FLAG_GENERATOR] && this->flag [FLAG_CONTENT_ON_GEN]) || type == CREATOR || type == CONVERTER) |
449 | /* Object will duplicate it's content as part of the |
448 | /* Object will duplicate it's content as part of the |
450 | * generation process. To do this, we must flag inventory |
449 | * generation process. To do this, we must flag inventory |
451 | * so it remains unevaluated concerning the randomitems and |
450 | * so it remains unevaluated concerning the randomitems and |
452 | * the living (a demonlord shouldn't cast from inside generator!) |
451 | * the living (a demonlord shouldn't cast from inside generator!) |
453 | */ |
452 | */ |
… | |
… | |
589 | // was: insert_ob_in_ob (tmp, op); |
588 | // was: insert_ob_in_ob (tmp, op); |
590 | // but manually adding it can improve map loading times a lot |
589 | // but manually adding it can improve map loading times a lot |
591 | // also, appending instead of prepending keeps the |
590 | // also, appending instead of prepending keeps the |
592 | // save ordering the same between repeated load/saves. |
591 | // save ordering the same between repeated load/saves. |
593 | // and finally we do not want any funny effects |
592 | // and finally we do not want any funny effects |
594 | CLEAR_FLAG (tmp, FLAG_OBJ_ORIGINAL); |
593 | tmp->clr_flag (FLAG_OBJ_ORIGINAL); |
595 | CLEAR_FLAG (tmp, FLAG_REMOVED); |
594 | tmp->clr_flag (FLAG_REMOVED); |
596 | |
595 | |
597 | if (!op_inv) |
596 | if (!op_inv) |
598 | { |
597 | { |
599 | inv = tmp; |
598 | inv = tmp; |
600 | tmp->above = 0; |
599 | tmp->above = 0; |
… | |
… | |
633 | f.delayed_deref (this, owner, f.get_str ()); |
632 | f.delayed_deref (this, owner, f.get_str ()); |
634 | break; |
633 | break; |
635 | |
634 | |
636 | case KW_animation: |
635 | case KW_animation: |
637 | { |
636 | { |
638 | CLEAR_FLAG (this, FLAG_ANIMATE); |
637 | this->clr_flag (FLAG_ANIMATE); |
639 | animation_id = 0; |
638 | animation_id = 0; |
640 | |
639 | |
641 | if (f.has_value () && (animation_id = find_animation (f.get_str ()))) |
640 | if (f.has_value () && (animation_id = find_animation (f.get_str ()))) |
642 | SET_FLAG (this, FLAG_ANIMATE); //TODO: should not be forced to true here |
641 | this->set_flag (FLAG_ANIMATE); //TODO: should not be forced to true here |
643 | } |
642 | } |
644 | break; |
643 | break; |
645 | |
644 | |
646 | case KW_last_heal: f.get (last_heal); break; |
645 | case KW_last_heal: f.get (last_heal); break; |
647 | case KW_last_sp: f.get (last_sp); break; |
646 | case KW_last_sp: f.get (last_sp); break; |
… | |
… | |
825 | |
824 | |
826 | |
825 | |
827 | case KW_identified: |
826 | case KW_identified: |
828 | GET_FLAG (this, FLAG_IDENTIFIED); |
827 | GET_FLAG (this, FLAG_IDENTIFIED); |
829 | //TODO: move to check_object or so |
828 | //TODO: move to check_object or so |
830 | if (QUERY_FLAG (this, FLAG_IDENTIFIED)) |
829 | if (this->flag [FLAG_IDENTIFIED]) |
831 | CLEAR_FLAG (this, FLAG_KNOWN_MAGICAL); |
830 | this->clr_flag (FLAG_KNOWN_MAGICAL); |
832 | |
831 | |
833 | break; |
832 | break; |
834 | |
833 | |
835 | case KW_friendly: |
834 | case KW_friendly: |
836 | if (f.get_bool ()) |
835 | if (f.get_bool ()) |
… | |
… | |
1341 | |
1340 | |
1342 | CMP_OUT (tag); |
1341 | CMP_OUT (tag); |
1343 | CMP_OUT (custom_name); |
1342 | CMP_OUT (custom_name); |
1344 | |
1343 | |
1345 | if (object *owner = op->owner) |
1344 | if (object *owner = op->owner) |
1346 | f.put (KW(owner), static_cast<const char *>(owner->ref ())); |
1345 | if (const char *ref = owner->ref ()) |
|
|
1346 | f.put (KW(owner), ref); |
1347 | |
1347 | |
1348 | // memory, attacked_by, chosen_skill, spellitem, spell, current_weapon, arch not saved |
1348 | // memory, attacked_by, chosen_skill, spellitem, spell, current_weapon, arch not saved |
1349 | |
1349 | |
1350 | CMP_OUT (other_arch); |
1350 | CMP_OUT (other_arch); |
1351 | |
1351 | |
… | |
… | |
1451 | CMP_OUT (move_slow); |
1451 | CMP_OUT (move_slow); |
1452 | CMP_OUT (move_slow_penalty); |
1452 | CMP_OUT (move_slow_penalty); |
1453 | |
1453 | |
1454 | object::flags_t diff = (op->flag ^ arch->flag) & flagmask; |
1454 | object::flags_t diff = (op->flag ^ arch->flag) & flagmask; |
1455 | |
1455 | |
|
|
1456 | #if stdcpp // we need gcc, sorry |
1456 | if (diff [FLAG_OBJ_ORIGINAL]) |
1457 | if (diff [FLAG_OBJ_ORIGINAL]) |
1457 | f.put (flag_names [FLAG_OBJ_ORIGINAL], op->flag [FLAG_OBJ_ORIGINAL] ? CS(1) : CS(0)); |
1458 | f.put (flag_names [FLAG_OBJ_ORIGINAL], op->flag [FLAG_OBJ_ORIGINAL] ? CS(1) : CS(0)); |
1458 | |
1459 | |
1459 | diff.reset (FLAG_OBJ_ORIGINAL); |
1460 | diff.reset (FLAG_OBJ_ORIGINAL); |
1460 | |
1461 | |
1461 | // quickly test whether any other flags differ |
1462 | // quickly test whether any other flags differ |
1462 | if (expect_true (diff.any ())) |
1463 | if (expect_true (diff.any ())) |
1463 | for (int i = 0; i < NUM_FLAGS; i++) |
1464 | for (int i = 0; i < NUM_FLAGS; i++) |
1464 | if (expect_false (diff [i])) |
1465 | if (expect_false (diff [i])) |
1465 | f.put (flag_names [i], op->flag [i] ? CS(1) : CS(0)); |
1466 | f.put (flag_names [i], op->flag [i] ? CS(1) : CS(0)); |
|
|
1467 | #else |
|
|
1468 | // use sgi extensions |
|
|
1469 | for (int i = diff._Find_first (); i < diff.size (); i = diff._Find_next (i)) |
|
|
1470 | f.put (flag_names [i], op->flag [i] ? CS(1) : CS(0)); |
|
|
1471 | #endif |
1466 | |
1472 | |
1467 | // save body locations. gcc's memcmp does an abysmal job when used |
1473 | // save body locations. gcc's memcmp does an abysmal job when used |
1468 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
1474 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
1469 | if (expect_false (op->slot[i].info != arch->slot[i].info)) |
1475 | if (expect_false (op->slot[i].info != arch->slot[i].info)) |
1470 | f.put (body_locations[i].save_name, op->slot[i].info); |
1476 | f.put (body_locations[i].save_name, op->slot[i].info); |