… | |
… | |
394 | if (ip > 2 * item_power && ip > (item_power + 3)) |
394 | if (ip > 2 * item_power && ip > (item_power + 3)) |
395 | 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); |
396 | #endif |
396 | #endif |
397 | } |
397 | } |
398 | |
398 | |
399 | /* 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 */ |
400 | /* (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 */ |
401 | if ((type == ROD |
401 | if ((type == ROD |
402 | || type == WAND |
402 | || type == WAND |
403 | || type == SCROLL |
403 | || type == SCROLL |
404 | || type == HORN |
404 | || type == HORN |
… | |
… | |
429 | randomitems = 0; /* So another spell isn't created for this object */ |
429 | randomitems = 0; /* So another spell isn't created for this object */ |
430 | /* without this, value is all screwed up */ |
430 | /* without this, value is all screwed up */ |
431 | value = arch->value * inv->value; |
431 | value = arch->value * inv->value; |
432 | } |
432 | } |
433 | |
433 | |
434 | if (QUERY_FLAG (this, FLAG_MONSTER)) |
434 | if (this->flag [FLAG_MONSTER]) |
435 | { |
435 | { |
436 | if (stats.hp > stats.maxhp) |
436 | if (stats.hp > stats.maxhp) |
437 | { |
437 | { |
438 | 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); |
439 | stats.maxhp = stats.hp; |
439 | stats.maxhp = stats.hp; |
… | |
… | |
442 | /* The archs just need to be updated for this */ |
442 | /* The archs just need to be updated for this */ |
443 | if (move_type == 0) |
443 | if (move_type == 0) |
444 | move_type = MOVE_WALK; |
444 | move_type = MOVE_WALK; |
445 | } |
445 | } |
446 | |
446 | |
447 | 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) |
448 | /* Object will duplicate it's content as part of the |
448 | /* Object will duplicate it's content as part of the |
449 | * generation process. To do this, we must flag inventory |
449 | * generation process. To do this, we must flag inventory |
450 | * so it remains unevaluated concerning the randomitems and |
450 | * so it remains unevaluated concerning the randomitems and |
451 | * the living (a demonlord shouldn't cast from inside generator!) |
451 | * the living (a demonlord shouldn't cast from inside generator!) |
452 | */ |
452 | */ |
… | |
… | |
522 | { |
522 | { |
523 | negate = 1; |
523 | negate = 1; |
524 | str++; |
524 | str++; |
525 | } |
525 | } |
526 | |
526 | |
527 | for (const flagstr *f = move_flags; f < move_flags + sizeof (move_flags) / sizeof (move_flags [0]); ++f) |
527 | for (const flagstr *f = move_flags; f < move_flags + array_length (move_flags); ++f) |
528 | { |
528 | { |
529 | if (!strcmp (f->name, str)) |
529 | if (!strcmp (f->name, str)) |
530 | { |
530 | { |
531 | if (negate) |
531 | if (negate) |
532 | mt &= ~f->flags; |
532 | mt &= ~f->flags; |
… | |
… | |
588 | // was: insert_ob_in_ob (tmp, op); |
588 | // was: insert_ob_in_ob (tmp, op); |
589 | // but manually adding it can improve map loading times a lot |
589 | // but manually adding it can improve map loading times a lot |
590 | // also, appending instead of prepending keeps the |
590 | // also, appending instead of prepending keeps the |
591 | // save ordering the same between repeated load/saves. |
591 | // save ordering the same between repeated load/saves. |
592 | // and finally we do not want any funny effects |
592 | // and finally we do not want any funny effects |
593 | CLEAR_FLAG (tmp, FLAG_OBJ_ORIGINAL); |
593 | tmp->clr_flag (FLAG_OBJ_ORIGINAL); |
594 | CLEAR_FLAG (tmp, FLAG_REMOVED); |
594 | tmp->clr_flag (FLAG_REMOVED); |
595 | |
595 | |
596 | if (!op_inv) |
596 | if (!op_inv) |
597 | { |
597 | { |
598 | inv = tmp; |
598 | inv = tmp; |
599 | tmp->above = 0; |
599 | tmp->above = 0; |
… | |
… | |
632 | f.delayed_deref (this, owner, f.get_str ()); |
632 | f.delayed_deref (this, owner, f.get_str ()); |
633 | break; |
633 | break; |
634 | |
634 | |
635 | case KW_animation: |
635 | case KW_animation: |
636 | { |
636 | { |
637 | CLEAR_FLAG (this, FLAG_ANIMATE); |
637 | this->clr_flag (FLAG_ANIMATE); |
638 | animation_id = 0; |
638 | animation_id = 0; |
639 | |
639 | |
640 | if (f.has_value () && (animation_id = find_animation (f.get_str ()))) |
640 | if (f.has_value () && (animation_id = find_animation (f.get_str ()))) |
641 | 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 |
642 | } |
642 | } |
643 | break; |
643 | break; |
644 | |
644 | |
645 | case KW_last_heal: f.get (last_heal); break; |
645 | case KW_last_heal: f.get (last_heal); break; |
646 | case KW_last_sp: f.get (last_sp); break; |
646 | case KW_last_sp: f.get (last_sp); break; |
… | |
… | |
736 | case KW_invisible: f.get (invisible); break; |
736 | case KW_invisible: f.get (invisible); break; |
737 | case KW_magic: f.get (magic); break; |
737 | case KW_magic: f.get (magic); break; |
738 | case KW_state: f.get (state); break; |
738 | case KW_state: f.get (state); break; |
739 | case KW_move_slow_penalty: f.get (move_slow_penalty); break; |
739 | case KW_move_slow_penalty: f.get (move_slow_penalty); break; |
740 | case KW_material: f.get (materials); break; //TODO: nuke |
740 | case KW_material: f.get (materials); break; //TODO: nuke |
741 | |
741 | case KW_materialname: f.get (material); break; |
742 | case KW_materialname: |
|
|
743 | { |
|
|
744 | shstr sh; |
|
|
745 | f.get (sh); |
|
|
746 | material = name_to_material (sh); |
|
|
747 | } |
|
|
748 | break; |
|
|
749 | |
742 | |
750 | /* These are the new values */ |
743 | /* These are the new values */ |
751 | case KW_move_block: set_move (move_block, f); break; |
744 | case KW_move_block: set_move (move_block, f); break; |
752 | case KW_move_allow: set_move (move_allow, f); break; |
745 | case KW_move_allow: set_move (move_allow, f); break; |
753 | case KW_move_type: set_move (move_type , f); break; |
746 | case KW_move_type: set_move (move_type , f); break; |
… | |
… | |
824 | |
817 | |
825 | |
818 | |
826 | case KW_identified: |
819 | case KW_identified: |
827 | GET_FLAG (this, FLAG_IDENTIFIED); |
820 | GET_FLAG (this, FLAG_IDENTIFIED); |
828 | //TODO: move to check_object or so |
821 | //TODO: move to check_object or so |
829 | if (QUERY_FLAG (this, FLAG_IDENTIFIED)) |
822 | if (this->flag [FLAG_IDENTIFIED]) |
830 | CLEAR_FLAG (this, FLAG_KNOWN_MAGICAL); |
823 | this->clr_flag (FLAG_KNOWN_MAGICAL); |
831 | |
824 | |
832 | break; |
825 | break; |
833 | |
826 | |
834 | case KW_friendly: |
827 | case KW_friendly: |
835 | if (f.get_bool ()) |
828 | if (f.get_bool ()) |
… | |
… | |
1340 | |
1333 | |
1341 | CMP_OUT (tag); |
1334 | CMP_OUT (tag); |
1342 | CMP_OUT (custom_name); |
1335 | CMP_OUT (custom_name); |
1343 | |
1336 | |
1344 | if (object *owner = op->owner) |
1337 | if (object *owner = op->owner) |
1345 | f.put (KW(owner), static_cast<const char *>(owner->ref ())); |
1338 | if (const char *ref = owner->ref ()) |
|
|
1339 | f.put (KW(owner), ref); |
1346 | |
1340 | |
1347 | // memory, attacked_by, chosen_skill, spellitem, spell, current_weapon, arch not saved |
1341 | // memory, attacked_by, chosen_skill, spellitem, spell, current_weapon, arch not saved |
1348 | |
1342 | |
1349 | CMP_OUT (other_arch); |
1343 | CMP_OUT (other_arch); |
1350 | |
1344 | |
… | |
… | |
1450 | CMP_OUT (move_slow); |
1444 | CMP_OUT (move_slow); |
1451 | CMP_OUT (move_slow_penalty); |
1445 | CMP_OUT (move_slow_penalty); |
1452 | |
1446 | |
1453 | object::flags_t diff = (op->flag ^ arch->flag) & flagmask; |
1447 | object::flags_t diff = (op->flag ^ arch->flag) & flagmask; |
1454 | |
1448 | |
|
|
1449 | #if stdcpp // we need gcc, sorry |
1455 | if (diff [FLAG_OBJ_ORIGINAL]) |
1450 | if (diff [FLAG_OBJ_ORIGINAL]) |
1456 | f.put (flag_names [FLAG_OBJ_ORIGINAL], op->flag [FLAG_OBJ_ORIGINAL] ? CS(1) : CS(0)); |
1451 | f.put (flag_names [FLAG_OBJ_ORIGINAL], op->flag [FLAG_OBJ_ORIGINAL] ? CS(1) : CS(0)); |
1457 | |
1452 | |
1458 | diff.reset (FLAG_OBJ_ORIGINAL); |
1453 | diff.reset (FLAG_OBJ_ORIGINAL); |
1459 | |
1454 | |
1460 | // quickly test whether any other flags differ |
1455 | // quickly test whether any other flags differ |
1461 | if (expect_true (diff.any ())) |
1456 | if (expect_true (diff.any ())) |
1462 | for (int i = 0; i < NUM_FLAGS; i++) |
1457 | for (int i = 0; i < NUM_FLAGS; i++) |
1463 | if (expect_false (diff [i])) |
1458 | if (expect_false (diff [i])) |
1464 | f.put (flag_names [i], op->flag [i] ? CS(1) : CS(0)); |
1459 | f.put (flag_names [i], op->flag [i] ? CS(1) : CS(0)); |
|
|
1460 | #else |
|
|
1461 | // use sgi extensions |
|
|
1462 | for (int i = diff._Find_first (); i < diff.size (); i = diff._Find_next (i)) |
|
|
1463 | f.put (flag_names [i], op->flag [i] ? CS(1) : CS(0)); |
|
|
1464 | #endif |
1465 | |
1465 | |
1466 | // save body locations. gcc's memcmp does an abysmal job when used |
1466 | // save body locations. gcc's memcmp does an abysmal job when used |
1467 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
1467 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
1468 | if (expect_false (op->slot[i].info != arch->slot[i].info)) |
1468 | if (expect_false (op->slot[i].info != arch->slot[i].info)) |
1469 | f.put (body_locations[i].save_name, op->slot[i].info); |
1469 | f.put (body_locations[i].save_name, op->slot[i].info); |
… | |
… | |
1506 | { |
1506 | { |
1507 | object_thawer f (filename); |
1507 | object_thawer f (filename); |
1508 | |
1508 | |
1509 | for (;;) |
1509 | for (;;) |
1510 | { |
1510 | { |
|
|
1511 | coroapi::cede_to_tick (); |
|
|
1512 | |
1511 | switch (f.kw) |
1513 | switch (f.kw) |
1512 | { |
1514 | { |
1513 | case KW_region: |
1515 | case KW_region: |
1514 | if (!region::read (f)) |
1516 | if (!region::read (f)) |
1515 | return false; |
1517 | return false; |