MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / LoadMonster

Function LoadMonster

Source/loadsave.cpp:599–706  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

597bool gbSkipSync = false;
598
599void LoadMonster(LoadHelper *file, Monster &monster, MonsterConversionData *monsterConversionData = nullptr)
600{
601 monster.levelType = file->NextLE<int32_t>();
602 monster.mode = static_cast<MonsterMode>(file->NextLE<int32_t>());
603 monster.goal = static_cast<MonsterGoal>(file->NextLE<uint8_t>());
604 file->Skip(3); // Alignment
605 monster.goalVar1 = file->NextLENarrow<int32_t, int16_t>();
606 monster.goalVar2 = file->NextLENarrow<int32_t, int8_t>();
607 monster.goalVar3 = file->NextLENarrow<int32_t, int8_t>();
608 file->Skip(4); // Unused
609 monster.pathCount = file->NextLE<uint8_t>();
610 file->Skip(3); // Alignment
611 monster.position.tile.x = file->NextLE<int32_t>();
612 monster.position.tile.y = file->NextLE<int32_t>();
613 monster.position.future.x = file->NextLE<int32_t>();
614 monster.position.future.y = file->NextLE<int32_t>();
615 monster.position.old.x = file->NextLE<int32_t>();
616 monster.position.old.y = file->NextLE<int32_t>();
617 file->Skip<int32_t>(4); // Skip offset and velocity
618 monster.direction = static_cast<Direction>(file->NextLE<int32_t>());
619 monster.enemy = file->NextLE<int32_t>();
620 monster.enemyPosition.x = file->NextLE<uint8_t>();
621 monster.enemyPosition.y = file->NextLE<uint8_t>();
622 file->Skip(2); // Unused
623
624 file->Skip(4); // Skip pointer _mAnimData
625 monster.animInfo = {};
626 monster.animInfo.ticksPerFrame = file->NextLENarrow<int32_t, int8_t>();
627 // Ensure that we can increase the tickCounterOfCurrentFrame at least once without overflow (needed for backwards compatibility for sitting gargoyles)
628 monster.animInfo.tickCounterOfCurrentFrame = file->NextLENarrow<int32_t, int8_t>(1) - 1;
629 monster.animInfo.numberOfFrames = file->NextLENarrow<int32_t, int8_t>();
630 monster.animInfo.currentFrame = file->NextLENarrow<int32_t, int8_t>(-1);
631 file->Skip(4); // Skip _meflag
632 monster.isInvalid = file->NextBool32();
633 monster.var1 = file->NextLENarrow<int32_t, int16_t>();
634 monster.var2 = file->NextLENarrow<int32_t, int16_t>();
635 monster.var3 = file->NextLENarrow<int32_t, int8_t>();
636 monster.position.temp.x = file->NextLENarrow<int32_t, WorldTileCoord>();
637 monster.position.temp.y = file->NextLENarrow<int32_t, WorldTileCoord>();
638 file->Skip<int32_t>(2); // skip offset2;
639 file->Skip(4); // Skip actionFrame
640 monster.maxHitPoints = file->NextLE<int32_t>();
641 monster.hitPoints = file->NextLE<int32_t>();
642
643 monster.ai = static_cast<MonsterAIID>(file->NextLE<uint8_t>());
644 monster.intelligence = file->NextLE<uint8_t>();
645 file->Skip(2); // Alignment
646 monster.flags = file->NextLE<uint32_t>();
647 monster.activeForTicks = file->NextLE<uint8_t>();
648 file->Skip(3); // Alignment
649 file->Skip(4); // Unused
650 monster.position.last.x = file->NextLE<int32_t>();
651 monster.position.last.y = file->NextLE<int32_t>();
652 monster.rndItemSeed = file->NextLE<uint32_t>();
653 monster.aiSeed = file->NextLE<uint32_t>();
654 file->Skip(4); // Unused
655
656 monster.uniqueType = static_cast<UniqueMonsterType>(file->NextLE<uint8_t>() - 1);

Callers 2

LoadLevelFunction · 0.85
LoadGameFunction · 0.85

Calls 3

NextBool32Method · 0.80
isPlayerMinionMethod · 0.80
SkipMethod · 0.45

Tested by

no test coverage detected