diff --git a/Source/monstdat.cpp b/Source/monstdat.cpp index e39a6a452..83689353f 100644 --- a/Source/monstdat.cpp +++ b/Source/monstdat.cpp @@ -487,7 +487,7 @@ void LoadMonstDat() const auto [it, inserted] = spritePathToId.emplace(assetsSuffix, spritePathToId.size()); if (inserted) MonsterSpritePaths.push_back(it->first); - monster.spriteId = it->second; + monster.spriteId = static_cast(it->second); } reader.readString("soundSuffix", monster.soundSuffix); reader.readString("trnFile", monster.trnFile); diff --git a/Source/monster.cpp b/Source/monster.cpp index 303b2b70a..f8b1ca813 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -141,7 +141,7 @@ void InitMonster(Monster &monster, Direction rd, size_t typeIndex, Point positio monster.position.tile = position; monster.position.future = position; monster.position.old = position; - monster.levelType = typeIndex; + monster.levelType = static_cast(typeIndex); monster.mode = MonsterMode::Stand; monster.animInfo = {}; monster.changeAnimationData(MonsterGraphic::Stand); @@ -231,7 +231,7 @@ bool CanPlaceMonster(Point position) && !IsTileOccupied(position); } -void PlaceMonster(int i, size_t typeIndex, Point position) +void PlaceMonster(size_t i, size_t typeIndex, Point position) { if (LevelMonsterTypes[typeIndex].type == MT_NAKRUL) { for (size_t j = 0; j < ActiveMonsterCount; j++) { @@ -247,9 +247,9 @@ void PlaceMonster(int i, size_t typeIndex, Point position) InitMonster(monster, rd, typeIndex, position); } -void PlaceGroup(size_t typeIndex, unsigned num, Monster *leader = nullptr, bool leashed = false) +void PlaceGroup(size_t typeIndex, size_t num, Monster *leader = nullptr, bool leashed = false) { - unsigned placed = 0; + uint8_t placed = 0; for (int try1 = 0; try1 < 10; try1++) { while (placed != 0) { @@ -1122,7 +1122,7 @@ void MonsterAttackMonster(Monster &attacker, Monster &target, int hper, int mind ApplyMonsterDamage(DamageType::Physical, target, dam); if (attacker.isPlayerMinion()) { - int playerId = attacker.getId(); + size_t playerId = attacker.getId(); const Player &player = Players[playerId]; target.tag(player); } @@ -1573,7 +1573,7 @@ void MonsterPetrified(Monster &monster) Monster *AddSkeleton(Point position, Direction dir, bool inMap) { - size_t typeCount = 0; + int32_t typeCount = 0; size_t skeletonIndexes[SkeletonTypes.size()]; for (size_t i = 0; i < LevelMonsterTypeCount; i++) { if (IsSkel(LevelMonsterTypes[i].type)) { @@ -2892,7 +2892,7 @@ void LachdananAi(Monster &monster) NetSendCmdQuest(true, Quests[Q_VEIL]); MonsterDeath(monster, monster.direction, true); delta_kill_monster(monster, monster.position.tile, *MyPlayer); - NetSendCmdLocParam1(false, CMD_MONSTDEATH, monster.position.tile, monster.getId()); + NetSendCmdLocParam1(false, CMD_MONSTDEATH, monster.position.tile, static_cast(monster.getId())); } } } @@ -3148,11 +3148,11 @@ MonsterSpritesData LoadMonsterSpritesData(const MonsterData &monsterData) clxData.emplace_back(); Cl2ToClx(reinterpret_cast(&result.data[begin]), end - begin, PointerOrValue { monsterData.width }, clxData.back()); - result.offsets[j] = accumulatedSize; + result.offsets[j] = static_cast(accumulatedSize); accumulatedSize += clxData.back().size(); ++j; } - result.offsets[clxData.size()] = accumulatedSize; + result.offsets[clxData.size()] = static_cast(accumulatedSize); result.data = nullptr; result.data = std::unique_ptr(new std::byte[accumulatedSize]); for (size_t i = 0; i < clxData.size(); ++i) { @@ -3278,7 +3278,7 @@ void InitLevelMonsters() totalmonsters = MaxMonsters; for (size_t i = 0; i < MaxMonsters; i++) { - ActiveMonsters[i] = i; + ActiveMonsters[i] = static_cast(i); } uniquetrans = 0; @@ -3474,13 +3474,13 @@ void InitAllMonsterGFX() if (HeadlessMode) return; - using LevelMonsterTypeIndices = StaticVector; + using LevelMonsterTypeIndices = StaticVector; std::vector monstersBySprite(GetNumMonsterSprites()); for (size_t i = 0; i < LevelMonsterTypeCount; ++i) { monstersBySprite[static_cast(LevelMonsterTypes[i].data().spriteId)].emplace_back(i); } - uint32_t totalUniqueBytes = 0; - uint32_t totalBytes = 0; + size_t totalUniqueBytes = 0; + size_t totalBytes = 0; for (const LevelMonsterTypeIndices &monsterTypes : monstersBySprite) { if (monsterTypes.empty()) continue; @@ -3543,14 +3543,14 @@ void InitMonsters() if (!setlevel) { if (!gbIsSpawn) PlaceUniqueMonsters(); - int na = 0; + size_t na = 0; for (int s = 16; s < 96; s++) { for (int t = 16; t < 96; t++) { if (!IsTileSolid({ s, t })) na++; } } - int numplacemonsters = na / 30; + size_t numplacemonsters = na / 30; if (gbIsMultiplayer) numplacemonsters += numplacemonsters / 2; if (ActiveMonsterCount + numplacemonsters > MaxMonsters - 10) @@ -3657,12 +3657,12 @@ void ApplyMonsterDamage(DamageType damageType, Monster &monster, int damage) if (monster.hitPoints >> 6 <= 0) { delta_kill_monster(monster, monster.position.tile, *MyPlayer); - NetSendCmdLocParam1(false, CMD_MONSTDEATH, monster.position.tile, monster.getId()); + NetSendCmdLocParam1(false, CMD_MONSTDEATH, monster.position.tile, static_cast(monster.getId())); return; } delta_monster_hp(monster, *MyPlayer); - NetSendCmdMonDmg(false, monster.getId(), damage); + NetSendCmdMonDmg(false, static_cast(monster.getId()), damage); } bool M_Talker(const Monster &monster) @@ -3727,7 +3727,7 @@ void M_StartHit(Monster &monster, const Player &player, int dam) { monster.tag(player); if (IsHardHit(monster, dam)) { - monster.enemy = player.getId(); + monster.enemy = static_cast(player.getId()); monster.enemyPosition = player.position.future; monster.flags &= ~MFLAG_TARGETS_MONSTER; if (monster.mode != MonsterMode::Petrified) { @@ -4686,7 +4686,7 @@ void Monster::setLeader(const Monster *leader) return; } - this->leader = leader->getId(); + this->leader = static_cast(leader->getId()); leaderRelation = LeaderRelation::Leashed; ai = leader->ai; }