1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-01 05:04:32 +00:00

Address more conversion warnings in the engine

This commit is contained in:
Evil Eye 2025-09-22 18:10:34 +02:00
parent e77ce5a507
commit 5308e22f6d
28 changed files with 115 additions and 110 deletions

View file

@ -339,7 +339,7 @@ namespace MWClass
->mValue.getInteger(); ->mValue.getInteger();
if (ref->mBase->mData.mWeight == 0) if (ref->mBase->mData.mWeight == 0)
return ref->mBase->mData.mArmor; return static_cast<float>(ref->mBase->mData.mArmor);
else else
return ref->mBase->mData.mArmor * armorSkill / static_cast<float>(iBaseArmorSkill); return ref->mBase->mData.mArmor * armorSkill / static_cast<float>(iBaseArmorSkill);
} }

View file

@ -190,7 +190,7 @@ namespace MWClass
ESM::Clothing newItem = *ref->mBase; ESM::Clothing newItem = *ref->mBase;
newItem.mId = ESM::RefId(); newItem.mId = ESM::RefId();
newItem.mName = newName; newItem.mName = newName;
newItem.mData.mEnchant = enchCharge; newItem.mData.mEnchant = static_cast<uint16_t>(enchCharge);
newItem.mEnchant = enchId; newItem.mEnchant = enchId;
const ESM::Clothing* record = MWBase::Environment::get().getESMStore()->insert(newItem); const ESM::Clothing* record = MWBase::Environment::get().getESMStore()->insert(newItem);
return record->mId; return record->mId;

View file

@ -132,7 +132,8 @@ namespace MWClass
// creature stats // creature stats
for (size_t i = 0; i < ref->mBase->mData.mAttributes.size(); ++i) for (size_t i = 0; i < ref->mBase->mData.mAttributes.size(); ++i)
data->mCreatureStats.setAttribute(ESM::Attribute::indexToRefId(i), ref->mBase->mData.mAttributes[i]); data->mCreatureStats.setAttribute(ESM::Attribute::indexToRefId(static_cast<int>(i)),
static_cast<float>(ref->mBase->mData.mAttributes[i]));
data->mCreatureStats.setHealth(static_cast<float>(ref->mBase->mData.mHealth)); data->mCreatureStats.setHealth(static_cast<float>(ref->mBase->mData.mHealth));
data->mCreatureStats.setMagicka(static_cast<float>(ref->mBase->mData.mMana)); data->mCreatureStats.setMagicka(static_cast<float>(ref->mBase->mData.mMana));
data->mCreatureStats.setFatigue(static_cast<float>(ref->mBase->mData.mFatigue)); data->mCreatureStats.setFatigue(static_cast<float>(ref->mBase->mData.mFatigue));
@ -757,11 +758,11 @@ namespace MWClass
switch (skillRecord->mData.mSpecialization) switch (skillRecord->mData.mSpecialization)
{ {
case ESM::Class::Combat: case ESM::Class::Combat:
return ref->mBase->mData.mCombat; return static_cast<float>(ref->mBase->mData.mCombat);
case ESM::Class::Magic: case ESM::Class::Magic:
return ref->mBase->mData.mMagic; return static_cast<float>(ref->mBase->mData.mMagic);
case ESM::Class::Stealth: case ESM::Class::Stealth:
return ref->mBase->mData.mStealth; return static_cast<float>(ref->mBase->mData.mStealth);
default: default:
throw std::runtime_error("invalid specialisation"); throw std::runtime_error("invalid specialisation");
} }
@ -887,7 +888,7 @@ namespace MWClass
void Creature::setBaseAISetting(const ESM::RefId& id, MWMechanics::AiSetting setting, int value) const void Creature::setBaseAISetting(const ESM::RefId& id, MWMechanics::AiSetting setting, int value) const
{ {
MWMechanics::setBaseAISetting<ESM::Creature>(id, setting, value); MWMechanics::setBaseAISetting<ESM::Creature>(id, setting, static_cast<unsigned char>(value));
} }
void Creature::modifyBaseInventory(const ESM::RefId& actorId, const ESM::RefId& itemId, int amount) const void Creature::modifyBaseInventory(const ESM::RefId& actorId, const ESM::RefId& itemId, int amount) const

View file

@ -215,14 +215,14 @@ namespace MWClass
MWBase::Environment::get().getSoundManager()->fadeOutSound3D(ptr, closeSound, 0.5f); MWBase::Environment::get().getSoundManager()->fadeOutSound3D(ptr, closeSound, 0.5f);
// Doors rotate at 90 degrees per second, so start the sound at // Doors rotate at 90 degrees per second, so start the sound at
// where it would be at the current rotation. // where it would be at the current rotation.
float offset = doorRot / (osg::PI * 0.5f); float offset = doorRot / (osg::PIf * 0.5f);
action->setSoundOffset(offset); action->setSoundOffset(offset);
action->setSound(openSound); action->setSound(openSound);
} }
else else
{ {
MWBase::Environment::get().getSoundManager()->fadeOutSound3D(ptr, openSound, 0.5f); MWBase::Environment::get().getSoundManager()->fadeOutSound3D(ptr, openSound, 0.5f);
float offset = 1.0f - doorRot / (osg::PI * 0.5f); float offset = 1.0f - doorRot / (osg::PIf * 0.5f);
action->setSoundOffset(std::max(offset, 0.0f)); action->setSoundOffset(std::max(offset, 0.0f));
action->setSound(closeSound); action->setSound(closeSound);
} }

View file

@ -134,7 +134,7 @@ namespace MWClass
if (ref->mBase->mData.mEffectID[i] < 0) if (ref->mBase->mData.mEffectID[i] < 0)
continue; continue;
MWGui::Widgets::SpellEffectParams params; MWGui::Widgets::SpellEffectParams params;
params.mEffectID = ref->mBase->mData.mEffectID[i]; params.mEffectID = static_cast<short>(ref->mBase->mData.mEffectID[i]);
params.mAttribute = ESM::Attribute::indexToRefId(ref->mBase->mData.mAttributes[i]); params.mAttribute = ESM::Attribute::indexToRefId(ref->mBase->mData.mAttributes[i]);
params.mSkill = ESM::Skill::indexToRefId(ref->mBase->mData.mSkills[i]); params.mSkill = ESM::Skill::indexToRefId(ref->mBase->mData.mSkills[i]);
params.mKnown = alchemySkill >= fWortChanceValue * (i + 1); params.mKnown = alchemySkill >= fWortChanceValue * (i + 1);

View file

@ -90,13 +90,13 @@ namespace MWClass
if (Settings::game().mRebalanceSoulGemValues) if (Settings::game().mRebalanceSoulGemValues)
{ {
// use the 'soul gem value rebalance' formula from the Morrowind Code Patch // use the 'soul gem value rebalance' formula from the Morrowind Code Patch
float soulValue = 0.0001 * pow(soul, 3) + 2 * soul; double soulValue = 0.0001 * std::pow(soul, 3) + 2 * soul;
// for Azura's star add the unfilled value // for Azura's star add the unfilled value
if (ptr.getCellRef().getRefId() == "Misc_SoulGem_Azura") if (ptr.getCellRef().getRefId() == "Misc_SoulGem_Azura")
value += soulValue; value += static_cast<int>(soulValue);
else else
value = soulValue; value = static_cast<int>(soulValue);
} }
else else
value *= soul; value *= soul;

View file

@ -85,24 +85,24 @@ namespace
const NpcParts npcParts; const NpcParts npcParts;
int is_even(double d) bool isEven(double d)
{ {
double intPart; double intPart;
modf(d / 2.0, &intPart); std::modf(d / 2.0, &intPart);
return 2.0 * intPart == d; return 2.0 * intPart == d;
} }
int round_ieee_754(double d) float round_ieee_754(double d)
{ {
double i = floor(d); double i = std::floor(d);
d -= i; d -= i;
if (d < 0.5) if (d < 0.5)
return static_cast<int>(i); return float(static_cast<int>(i));
if (d > 0.5) if (d > 0.5)
return static_cast<int>(i) + 1; return static_cast<int>(i) + 1.f;
if (is_even(i)) if (isEven(i))
return static_cast<int>(i); return float(static_cast<int>(i));
return static_cast<int>(i) + 1; return static_cast<int>(i) + 1.f;
} }
void autoCalculateAttributes(const ESM::NPC* npc, MWMechanics::CreatureStats& creatureStats) void autoCalculateAttributes(const ESM::NPC* npc, MWMechanics::CreatureStats& creatureStats)
@ -115,7 +115,8 @@ namespace
const auto& attributes = MWBase::Environment::get().getESMStore()->get<ESM::Attribute>(); const auto& attributes = MWBase::Environment::get().getESMStore()->get<ESM::Attribute>();
int level = creatureStats.getLevel(); int level = creatureStats.getLevel();
for (const ESM::Attribute& attribute : attributes) for (const ESM::Attribute& attribute : attributes)
creatureStats.setAttribute(attribute.mId, race->mData.getAttribute(attribute.mId, male)); creatureStats.setAttribute(
attribute.mId, static_cast<float>(race->mData.getAttribute(attribute.mId, male)));
// class bonus // class bonus
const ESM::Class* npcClass = MWBase::Environment::get().getESMStore()->get<ESM::Class>().find(npc->mClass); const ESM::Class* npcClass = MWBase::Environment::get().getESMStore()->get<ESM::Class>().find(npc->mClass);
@ -155,7 +156,7 @@ namespace
creatureStats.setAttribute(attribute.mId, creatureStats.setAttribute(attribute.mId,
std::min( std::min(
round_ieee_754(creatureStats.getAttribute(attribute.mId).getBase() + (level - 1) * modifierSum), round_ieee_754(creatureStats.getAttribute(attribute.mId).getBase() + (level - 1) * modifierSum),
100)); 100.f));
} }
// initial health // initial health
@ -248,7 +249,7 @@ namespace
npcStats.getSkill(skill.mId).setBase( npcStats.getSkill(skill.mId).setBase(
std::min(round_ieee_754(npcStats.getSkill(skill.mId).getBase() + 5 + raceBonus + specBonus std::min(round_ieee_754(npcStats.getSkill(skill.mId).getBase() + 5 + raceBonus + specBonus
+ (int(level) - 1) * (majorMultiplier + specMultiplier)), + (int(level) - 1) * (majorMultiplier + specMultiplier)),
100)); // Must gracefully handle level 0 100.f)); // Must gracefully handle level 0
} }
if (!spellsInitialised) if (!spellsInitialised)
@ -334,10 +335,12 @@ namespace MWClass
gold = ref->mBase->mNpdt.mGold; gold = ref->mBase->mNpdt.mGold;
for (size_t i = 0; i < ref->mBase->mNpdt.mSkills.size(); ++i) for (size_t i = 0; i < ref->mBase->mNpdt.mSkills.size(); ++i)
data->mNpcStats.getSkill(ESM::Skill::indexToRefId(i)).setBase(ref->mBase->mNpdt.mSkills[i]); data->mNpcStats.getSkill(ESM::Skill::indexToRefId(static_cast<int>(i)))
.setBase(ref->mBase->mNpdt.mSkills[i]);
for (size_t i = 0; i < ref->mBase->mNpdt.mAttributes.size(); ++i) for (size_t i = 0; i < ref->mBase->mNpdt.mAttributes.size(); ++i)
data->mNpcStats.setAttribute(ESM::Attribute::indexToRefId(i), ref->mBase->mNpdt.mAttributes[i]); data->mNpcStats.setAttribute(
ESM::Attribute::indexToRefId(static_cast<int>(i)), ref->mBase->mNpdt.mAttributes[i]);
data->mNpcStats.setHealth(ref->mBase->mNpdt.mHealth); data->mNpcStats.setHealth(ref->mBase->mNpdt.mHealth);
data->mNpcStats.setMagicka(ref->mBase->mNpdt.mMana); data->mNpcStats.setMagicka(ref->mBase->mNpdt.mMana);
@ -589,7 +592,7 @@ namespace MWClass
if (!weapon.isEmpty()) if (!weapon.isEmpty())
weapskill = weapon.getClass().getEquipmentSkill(weapon); weapskill = weapon.getClass().getEquipmentSkill(weapon);
float hitchance = MWMechanics::getHitChance(ptr, victim, getSkill(ptr, weapskill)); float hitchance = MWMechanics::getHitChance(ptr, victim, static_cast<int>(getSkill(ptr, weapskill)));
return Misc::Rng::roll0to99(world->getPrng()) < hitchance; return Misc::Rng::roll0to99(world->getPrng()) < hitchance;
} }
@ -1405,7 +1408,7 @@ namespace MWClass
void Npc::setBaseAISetting(const ESM::RefId& id, MWMechanics::AiSetting setting, int value) const void Npc::setBaseAISetting(const ESM::RefId& id, MWMechanics::AiSetting setting, int value) const
{ {
MWMechanics::setBaseAISetting<ESM::NPC>(id, setting, value); MWMechanics::setBaseAISetting<ESM::NPC>(id, setting, static_cast<unsigned char>(value));
} }
void Npc::modifyBaseInventory(const ESM::RefId& actorId, const ESM::RefId& itemId, int amount) const void Npc::modifyBaseInventory(const ESM::RefId& actorId, const ESM::RefId& itemId, int amount) const

View file

@ -261,7 +261,7 @@ namespace MWClass
ESM::Weapon newItem = *ref->mBase; ESM::Weapon newItem = *ref->mBase;
newItem.mId = ESM::RefId(); newItem.mId = ESM::RefId();
newItem.mName = newName; newItem.mName = newName;
newItem.mData.mEnchant = enchCharge; newItem.mData.mEnchant = static_cast<uint16_t>(enchCharge);
newItem.mEnchant = enchId; newItem.mEnchant = enchId;
newItem.mData.mFlags |= ESM::Weapon::Magical; newItem.mData.mFlags |= ESM::Weapon::Magical;
const ESM::Weapon* record = MWBase::Environment::get().getESMStore()->insert(newItem); const ESM::Weapon* record = MWBase::Environment::get().getESMStore()->insert(newItem);

View file

@ -127,7 +127,7 @@ namespace MWGui
getWidget(mFavoriteAttribute[0], "FavoriteAttribute0"); getWidget(mFavoriteAttribute[0], "FavoriteAttribute0");
getWidget(mFavoriteAttribute[1], "FavoriteAttribute1"); getWidget(mFavoriteAttribute[1], "FavoriteAttribute1");
for (int i = 0; i < 5; i++) for (char i = 0; i < 5; i++)
{ {
char theIndex = '0' + i; char theIndex = '0' + i;
getWidget(mMajorSkill[i], std::string("MajorSkill").append(1, theIndex)); getWidget(mMajorSkill[i], std::string("MajorSkill").append(1, theIndex));
@ -483,7 +483,7 @@ namespace MWGui
return true; return true;
setControllerFocus(mButtons, mControllerFocus, false); setControllerFocus(mButtons, mControllerFocus, false);
mControllerFocus = wrap(mControllerFocus - 1, mButtons.size()); mControllerFocus = wrap(mControllerFocus, mButtons.size(), -1);
setControllerFocus(mButtons, mControllerFocus, true); setControllerFocus(mButtons, mControllerFocus, true);
} }
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN) else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
@ -494,7 +494,7 @@ namespace MWGui
return true; return true;
setControllerFocus(mButtons, mControllerFocus, false); setControllerFocus(mButtons, mControllerFocus, false);
mControllerFocus = wrap(mControllerFocus + 1, mButtons.size()); mControllerFocus = wrap(mControllerFocus, mButtons.size(), 1);
setControllerFocus(mButtons, mControllerFocus, true); setControllerFocus(mButtons, mControllerFocus, true);
} }
@ -546,7 +546,7 @@ namespace MWGui
"MajorSkillT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sSkillClassMajor", {})); "MajorSkillT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sSkillClassMajor", {}));
setText( setText(
"MinorSkillT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sSkillClassMinor", {})); "MinorSkillT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sSkillClassMinor", {}));
for (int i = 0; i < 5; i++) for (char i = 0; i < 5; i++)
{ {
char theIndex = '0' + i; char theIndex = '0' + i;
getWidget(mMajorSkill[i], std::string("MajorSkill").append(1, theIndex)); getWidget(mMajorSkill[i], std::string("MajorSkill").append(1, theIndex));
@ -713,13 +713,13 @@ namespace MWGui
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT) else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT)
{ {
setControllerFocus(mButtons, mControllerFocus, false); setControllerFocus(mButtons, mControllerFocus, false);
mControllerFocus = wrap(mControllerFocus - 1, mButtons.size()); mControllerFocus = wrap(mControllerFocus, mButtons.size(), -1);
setControllerFocus(mButtons, mControllerFocus, true); setControllerFocus(mButtons, mControllerFocus, true);
} }
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT) else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
{ {
setControllerFocus(mButtons, mControllerFocus, false); setControllerFocus(mButtons, mControllerFocus, false);
mControllerFocus = wrap(mControllerFocus + 1, mButtons.size()); mControllerFocus = wrap(mControllerFocus, mButtons.size(), 1);
setControllerFocus(mButtons, mControllerFocus, true); setControllerFocus(mButtons, mControllerFocus, true);
} }
return true; return true;
@ -1001,13 +1001,13 @@ namespace MWGui
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP) else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
{ {
mAttributeButtons[mControllerFocus]->setStateSelected(false); mAttributeButtons[mControllerFocus]->setStateSelected(false);
mControllerFocus = wrap(mControllerFocus - 1, mAttributeButtons.size()); mControllerFocus = wrap(mControllerFocus, mAttributeButtons.size(), -1);
mAttributeButtons[mControllerFocus]->setStateSelected(true); mAttributeButtons[mControllerFocus]->setStateSelected(true);
} }
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN) else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
{ {
mAttributeButtons[mControllerFocus]->setStateSelected(false); mAttributeButtons[mControllerFocus]->setStateSelected(false);
mControllerFocus = wrap(mControllerFocus + 1, mAttributeButtons.size()); mControllerFocus = wrap(mControllerFocus, mAttributeButtons.size(), 1);
mAttributeButtons[mControllerFocus]->setStateSelected(true); mAttributeButtons[mControllerFocus]->setStateSelected(true);
} }
@ -1103,13 +1103,13 @@ namespace MWGui
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP) else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
{ {
mSkillButtons[mControllerFocus]->setStateSelected(false); mSkillButtons[mControllerFocus]->setStateSelected(false);
mControllerFocus = wrap(mControllerFocus - 1, mSkillButtons.size()); mControllerFocus = wrap(mControllerFocus, mSkillButtons.size(), -1);
mSkillButtons[mControllerFocus]->setStateSelected(true); mSkillButtons[mControllerFocus]->setStateSelected(true);
} }
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN) else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
{ {
mSkillButtons[mControllerFocus]->setStateSelected(false); mSkillButtons[mControllerFocus]->setStateSelected(false);
mControllerFocus = wrap(mControllerFocus + 1, mSkillButtons.size()); mControllerFocus = wrap(mControllerFocus, mSkillButtons.size(), 1);
mSkillButtons[mControllerFocus]->setStateSelected(true); mSkillButtons[mControllerFocus]->setStateSelected(true);
} }
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT || arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT) else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT || arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)

View file

@ -84,7 +84,7 @@ namespace MWGui
} }
MWWorld::Ptr object = item.mBase; MWWorld::Ptr object = item.mBase;
int count = item.mCount; size_t count = item.mCount;
bool shift = MyGUI::InputManager::getInstance().isShiftPressed(); bool shift = MyGUI::InputManager::getInstance().isShiftPressed();
if (MyGUI::InputManager::getInstance().isControlPressed()) if (MyGUI::InputManager::getInstance().isControlPressed())
count = 1; count = 1;
@ -96,7 +96,7 @@ namespace MWGui
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog(); CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
std::string name{ object.getClass().getName(object) }; std::string name{ object.getClass().getName(object) };
name += MWGui::ToolTips::getSoulString(object.getCellRef()); name += MWGui::ToolTips::getSoulString(object.getCellRef());
dialog->openCountDialog(name, "#{sTake}", count); dialog->openCountDialog(name, "#{sTake}", static_cast<int>(count));
dialog->eventOkClicked.clear(); dialog->eventOkClicked.clear();
if (Settings::gui().mControllerMenus || MyGUI::InputManager::getInstance().isAltPressed()) if (Settings::gui().mControllerMenus || MyGUI::InputManager::getInstance().isAltPressed())
dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerWindow::transferItem); dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerWindow::transferItem);
@ -116,7 +116,7 @@ namespace MWGui
const ItemStack item = mModel->getItem(mSelectedItem); const ItemStack item = mModel->getItem(mSelectedItem);
if (!mModel->onTakeItem(item.mBase, count)) if (!mModel->onTakeItem(item.mBase, static_cast<int>(count)))
return; return;
mDragAndDrop->startDrag(mSelectedItem, mSortModel, mModel, mItemView, count); mDragAndDrop->startDrag(mSelectedItem, mSortModel, mModel, mItemView, count);
@ -129,7 +129,7 @@ namespace MWGui
const ItemStack item = mModel->getItem(mSelectedItem); const ItemStack item = mModel->getItem(mSelectedItem);
if (!mModel->onTakeItem(item.mBase, count)) if (!mModel->onTakeItem(item.mBase, static_cast<int>(count)))
return; return;
mItemTransfer->apply(item, count, *mItemView); mItemTransfer->apply(item, count, *mItemView);
@ -140,7 +140,7 @@ namespace MWGui
if (mModel == nullptr) if (mModel == nullptr)
return; return;
bool success = mModel->onDropItem(mDragAndDrop->mItem.mBase, mDragAndDrop->mDraggedCount); bool success = mModel->onDropItem(mDragAndDrop->mItem.mBase, static_cast<int>(mDragAndDrop->mDraggedCount));
if (success) if (success)
mDragAndDrop->drop(mModel, mItemView); mDragAndDrop->drop(mModel, mItemView);
@ -248,7 +248,7 @@ namespace MWGui
MWWorld::InventoryStore& invStore = mPtr.getClass().getInventoryStore(mPtr); MWWorld::InventoryStore& invStore = mPtr.getClass().getInventoryStore(mPtr);
for (size_t i = 0; i < mModel->getItemCount(); ++i) for (size_t i = 0; i < mModel->getItemCount(); ++i)
{ {
const ItemStack& item = mModel->getItem(i); const ItemStack& item = mModel->getItem(static_cast<ItemModel::ModelIndex>(i));
if (invStore.isEquipped(item.mBase) == false) if (invStore.isEquipped(item.mBase) == false)
continue; continue;
@ -263,14 +263,14 @@ namespace MWGui
if (i == 0) if (i == 0)
{ {
// play the sound of the first object // play the sound of the first object
MWWorld::Ptr item = mModel->getItem(i).mBase; MWWorld::Ptr item = mModel->getItem(static_cast<ItemModel::ModelIndex>(i)).mBase;
const ESM::RefId& sound = item.getClass().getUpSoundId(item); const ESM::RefId& sound = item.getClass().getUpSoundId(item);
MWBase::Environment::get().getWindowManager()->playSound(sound); MWBase::Environment::get().getWindowManager()->playSound(sound);
} }
const ItemStack item = mModel->getItem(i); const ItemStack item = mModel->getItem(static_cast<ItemModel::ModelIndex>(i));
if (!mModel->onTakeItem(item.mBase, item.mCount)) if (!mModel->onTakeItem(item.mBase, static_cast<int>(item.mCount)))
break; break;
mModel->moveItem(item, item.mCount, playerModel); mModel->moveItem(item, item.mCount, playerModel);

View file

@ -166,8 +166,8 @@ namespace MWLua
return completion; return completion;
return sol::nullopt; return sol::nullopt;
}; };
api["getLoopCount"] = [](const LObject& object, std::string groupname) -> sol::optional<size_t> { api["getLoopCount"] = [](const LObject& object, std::string groupname) -> sol::optional<uint32_t> {
size_t loops = 0; uint32_t loops = 0;
if (getConstAnimationOrThrow(object)->getInfo(groupname, nullptr, nullptr, &loops)) if (getConstAnimationOrThrow(object)->getInfo(groupname, nullptr, nullptr, &loops))
return loops; return loops;
return sol::nullopt; return sol::nullopt;

View file

@ -268,7 +268,7 @@ namespace MWLua
auto setOwnerFactionRank = [](const OwnerT& o, sol::optional<int64_t> factionRank) { auto setOwnerFactionRank = [](const OwnerT& o, sol::optional<int64_t> factionRank) {
if (std::is_same_v<ObjectT, LObject> && !dynamic_cast<const SelfObject*>(&o.mObj)) if (std::is_same_v<ObjectT, LObject> && !dynamic_cast<const SelfObject*>(&o.mObj))
throw std::runtime_error("Local scripts can set an owner faction rank only on self"); throw std::runtime_error("Local scripts can set an owner faction rank only on self");
int64_t rank = std::max(0, LuaUtil::fromLuaIndex(factionRank.value_or(0))); int64_t rank = std::max<int64_t>(0, LuaUtil::fromLuaIndex(factionRank.value_or(0)));
o.mObj.ptr().getCellRef().setFactionRank(static_cast<int>(rank)); o.mObj.ptr().getCellRef().setFactionRank(static_cast<int>(rank));
}; };
ownerT["factionRank"] = sol::property(getOwnerFactionRank, setOwnerFactionRank); ownerT["factionRank"] = sol::property(getOwnerFactionRank, setOwnerFactionRank);

View file

@ -61,7 +61,7 @@ namespace
if (rec["baseArmor"] != sol::nil) if (rec["baseArmor"] != sol::nil)
armor.mData.mArmor = rec["baseArmor"]; armor.mData.mArmor = rec["baseArmor"];
if (rec["enchantCapacity"] != sol::nil) if (rec["enchantCapacity"] != sol::nil)
armor.mData.mEnchant = std::round(rec["enchantCapacity"].get<float>() * 10); armor.mData.mEnchant = static_cast<int32_t>(std::round(rec["enchantCapacity"].get<float>() * 10));
return armor; return armor;
} }

View file

@ -49,7 +49,7 @@ namespace
} }
if (rec["enchantCapacity"] != sol::nil) if (rec["enchantCapacity"] != sol::nil)
book.mData.mEnchant = std::round(rec["enchantCapacity"].get<float>() * 10); book.mData.mEnchant = static_cast<int32_t>(std::round(rec["enchantCapacity"].get<float>() * 10));
if (rec["mwscript"] != sol::nil) if (rec["mwscript"] != sol::nil)
{ {
std::string_view scriptId = rec["mwscript"].get<std::string_view>(); std::string_view scriptId = rec["mwscript"].get<std::string_view>();

View file

@ -46,7 +46,7 @@ namespace
clothing.mEnchant = ESM::RefId::deserializeText(enchantId); clothing.mEnchant = ESM::RefId::deserializeText(enchantId);
} }
if (rec["enchantCapacity"] != sol::nil) if (rec["enchantCapacity"] != sol::nil)
clothing.mData.mEnchant = std::round(rec["enchantCapacity"].get<float>() * 10); clothing.mData.mEnchant = static_cast<int16_t>(std::round(rec["enchantCapacity"].get<float>() * 10));
if (rec["weight"] != sol::nil) if (rec["weight"] != sol::nil)
clothing.mData.mWeight = rec["weight"]; clothing.mData.mWeight = rec["weight"];
if (rec["value"] != sol::nil) if (rec["value"] != sol::nil)

View file

@ -45,14 +45,14 @@ namespace MWLua
record["value"] = sol::readonly_property([](const ESM::Ingredient& rec) -> int { return rec.mData.mValue; }); record["value"] = sol::readonly_property([](const ESM::Ingredient& rec) -> int { return rec.mData.mValue; });
record["effects"] = sol::readonly_property([lua = lua.lua_state()](const ESM::Ingredient& rec) -> sol::table { record["effects"] = sol::readonly_property([lua = lua.lua_state()](const ESM::Ingredient& rec) -> sol::table {
sol::table res(lua, sol::create); sol::table res(lua, sol::create);
for (size_t i = 0; i < 4; ++i) for (uint32_t i = 0; i < 4; ++i)
{ {
if (rec.mData.mEffectID[i] < 0) if (rec.mData.mEffectID[i] < 0)
continue; continue;
ESM::IndexedENAMstruct effect; ESM::IndexedENAMstruct effect;
effect.mData.mEffectID = rec.mData.mEffectID[i]; effect.mData.mEffectID = static_cast<int16_t>(rec.mData.mEffectID[i]);
effect.mData.mSkill = rec.mData.mSkills[i]; effect.mData.mSkill = static_cast<signed char>(rec.mData.mSkills[i]);
effect.mData.mAttribute = rec.mData.mAttributes[i]; effect.mData.mAttribute = static_cast<signed char>(rec.mData.mAttributes[i]);
effect.mData.mRange = ESM::RT_Self; effect.mData.mRange = ESM::RT_Self;
effect.mData.mArea = 0; effect.mData.mArea = 0;
effect.mData.mDuration = 0; effect.mData.mDuration = 0;

View file

@ -120,7 +120,7 @@ namespace
} }
if (rec["baseDisposition"] != sol::nil) if (rec["baseDisposition"] != sol::nil)
npc.mNpdt.mDisposition = rec["baseDisposition"].get<int>(); npc.mNpdt.mDisposition = rec["baseDisposition"].get<unsigned char>();
if (rec["baseGold"] != sol::nil) if (rec["baseGold"] != sol::nil)
npc.mNpdt.mGold = rec["baseGold"].get<int>(); npc.mNpdt.mGold = rec["baseGold"].get<int>();
@ -136,7 +136,7 @@ namespace
= MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(npc.mFaction); = MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(npc.mFaction);
int luaValue = rec["primaryFactionRank"]; int luaValue = rec["primaryFactionRank"];
int rank = LuaUtil::fromLuaIndex(luaValue); int64_t rank = LuaUtil::fromLuaIndex(luaValue);
int maxRank = static_cast<int>(getValidRanksCount(faction)); int maxRank = static_cast<int>(getValidRanksCount(faction));
@ -144,7 +144,7 @@ namespace
throw std::runtime_error("primaryFactionRank: Requested rank " + std::to_string(rank) throw std::runtime_error("primaryFactionRank: Requested rank " + std::to_string(rank)
+ " is out of bounds for faction " + npc.mFaction.toDebugString()); + " is out of bounds for faction " + npc.mFaction.toDebugString());
npc.mNpdt.mRank = rank; npc.mNpdt.mRank = static_cast<unsigned char>(rank);
} }
} }
@ -218,7 +218,7 @@ namespace MWLua
= sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mHead.serializeText(); }); = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mHead.serializeText(); });
record["primaryFaction"] = sol::readonly_property( record["primaryFaction"] = sol::readonly_property(
[](const ESM::NPC& rec) -> sol::optional<std::string> { return LuaUtil::serializeRefId(rec.mFaction); }); [](const ESM::NPC& rec) -> sol::optional<std::string> { return LuaUtil::serializeRefId(rec.mFaction); });
record["primaryFactionRank"] = sol::readonly_property([](const ESM::NPC& rec, sol::this_state s) -> int { record["primaryFactionRank"] = sol::readonly_property([](const ESM::NPC& rec, sol::this_state s) -> int64_t {
if (rec.mFaction.empty()) if (rec.mFaction.empty())
return 0; return 0;
return LuaUtil::toLuaIndex(rec.mNpdt.mRank); return LuaUtil::toLuaIndex(rec.mNpdt.mRank);
@ -332,7 +332,7 @@ namespace MWLua
if (!npcStats.isInFaction(factionId)) if (!npcStats.isInFaction(factionId))
throw std::runtime_error("Target actor is not a member of faction " + factionId.toDebugString()); throw std::runtime_error("Target actor is not a member of faction " + factionId.toDebugString());
npcStats.setFactionRank(factionId, targetRank); npcStats.setFactionRank(factionId, static_cast<int>(targetRank));
}; };
npc["modifyFactionRank"] = [](Object& actor, std::string_view faction, int value) { npc["modifyFactionRank"] = [](Object& actor, std::string_view faction, int value) {

View file

@ -64,7 +64,7 @@ namespace
{ {
int weaponType = rec["type"].get<int>(); int weaponType = rec["type"].get<int>();
if (weaponType >= 0 && weaponType <= ESM::Weapon::Last) if (weaponType >= 0 && weaponType <= ESM::Weapon::Last)
weapon.mData.mType = weaponType; weapon.mData.mType = static_cast<int16_t>(weaponType);
else else
throw std::runtime_error("Invalid Weapon Type provided: " + std::to_string(weaponType)); throw std::runtime_error("Invalid Weapon Type provided: " + std::to_string(weaponType));
} }
@ -79,7 +79,7 @@ namespace
if (rec["reach"] != sol::nil) if (rec["reach"] != sol::nil)
weapon.mData.mReach = rec["reach"]; weapon.mData.mReach = rec["reach"];
if (rec["enchantCapacity"] != sol::nil) if (rec["enchantCapacity"] != sol::nil)
weapon.mData.mEnchant = std::round(rec["enchantCapacity"].get<float>() * 10); weapon.mData.mEnchant = static_cast<uint16_t>(std::round(rec["enchantCapacity"].get<float>() * 10));
if (rec["chopMinDamage"] != sol::nil) if (rec["chopMinDamage"] != sol::nil)
weapon.mData.mChop[0] = rec["chopMinDamage"]; weapon.mData.mChop[0] = rec["chopMinDamage"];
if (rec["chopMaxDamage"] != sol::nil) if (rec["chopMaxDamage"] != sol::nil)

View file

@ -514,7 +514,7 @@ MWMechanics::Alchemy::TEffectsIterator MWMechanics::Alchemy::endEffects() const
return mEffects.end(); return mEffects.end();
} }
bool MWMechanics::Alchemy::knownEffect(unsigned int potionEffectIndex, const MWWorld::Ptr& npc) bool MWMechanics::Alchemy::knownEffect(size_t potionEffectIndex, const MWWorld::Ptr& npc)
{ {
float alchemySkill = npc.getClass().getSkill(npc, ESM::Skill::Alchemy); float alchemySkill = npc.getClass().getSkill(npc, ESM::Skill::Alchemy);
static const float fWortChanceValue static const float fWortChanceValue

View file

@ -86,7 +86,7 @@ namespace MWMechanics
int countPotionsToBrew() const; int countPotionsToBrew() const;
///< calculates maximum amount of potions, which you can make from selected ingredients ///< calculates maximum amount of potions, which you can make from selected ingredients
static bool knownEffect(unsigned int potionEffectIndex, const MWWorld::Ptr& npc); static bool knownEffect(size_t potionEffectIndex, const MWWorld::Ptr& npc);
///< Does npc have sufficient alchemy skill to know about this potion effect? ///< Does npc have sufficient alchemy skill to know about this potion effect?
void setAlchemist(const MWWorld::Ptr& npc); void setAlchemist(const MWWorld::Ptr& npc);

View file

@ -828,8 +828,8 @@ namespace MWMechanics
clearStateAnimation(mCurrentIdle); clearStateAnimation(mCurrentIdle);
mCurrentIdle = std::move(idleGroup); mCurrentIdle = std::move(idleGroup);
playBlendedAnimation( playBlendedAnimation(mCurrentIdle, priority, MWRender::BlendMask_All, false, 1.0f, "start", "stop", startPoint,
mCurrentIdle, priority, MWRender::BlendMask_All, false, 1.0f, "start", "stop", startPoint, numLoops, true); static_cast<uint32_t>(numLoops), true);
} }
void CharacterController::refreshCurrentAnims( void CharacterController::refreshCurrentAnims(
@ -851,7 +851,8 @@ namespace MWMechanics
{ {
mDeathState = death; mDeathState = death;
mCurrentDeath = deathStateToAnimGroup(mDeathState); mCurrentDeath = deathStateToAnimGroup(mDeathState);
mPtr.getClass().getCreatureStats(mPtr).setDeathAnimation(mDeathState - CharState_Death1); mPtr.getClass().getCreatureStats(mPtr).setDeathAnimation(
static_cast<signed char>(mDeathState - CharState_Death1));
// For dead actors, refreshCurrentAnims is no longer called, so we need to disable the movement state manually. // For dead actors, refreshCurrentAnims is no longer called, so we need to disable the movement state manually.
// Note that these animations wouldn't actually be visible (due to the Death animation's priority being higher). // Note that these animations wouldn't actually be visible (due to the Death animation's priority being higher).
@ -1924,7 +1925,7 @@ namespace MWMechanics
else else
{ {
float complete; float complete;
size_t loopcount; uint32_t loopcount;
mAnimation->getInfo(mAnimQueue.front().mGroup, &complete, nullptr, &loopcount); mAnimation->getInfo(mAnimQueue.front().mGroup, &complete, nullptr, &loopcount);
mAnimQueue.front().mLoopCount = loopcount; mAnimQueue.front().mLoopCount = loopcount;
mAnimQueue.front().mTime = complete; mAnimQueue.front().mTime = complete;
@ -2010,10 +2011,10 @@ namespace MWMechanics
{ {
// Force Jump // Force Jump
if (stats.getMovementFlag(MWMechanics::CreatureStats::Flag_ForceJump)) if (stats.getMovementFlag(MWMechanics::CreatureStats::Flag_ForceJump))
movementSettings.mPosition[2] = onground ? 1 : 0; movementSettings.mPosition[2] = onground ? 1.f : 0.f;
// Force Move Jump, only jump if they're otherwise moving // Force Move Jump, only jump if they're otherwise moving
if (stats.getMovementFlag(MWMechanics::CreatureStats::Flag_ForceMoveJump) && isMoving) if (stats.getMovementFlag(MWMechanics::CreatureStats::Flag_ForceMoveJump) && isMoving)
movementSettings.mPosition[2] = onground ? 1 : 0; movementSettings.mPosition[2] = onground ? 1.f : 0.f;
} }
osg::Vec3f rot = cls.getRotationVector(mPtr); osg::Vec3f rot = cls.getRotationVector(mPtr);
@ -2036,7 +2037,7 @@ namespace MWMechanics
maxDelta = 1; maxDelta = 1;
else if (std::abs(speedDelta) < deltaLen / 2) else if (std::abs(speedDelta) < deltaLen / 2)
// Turning is smooth for player and less smooth for NPCs (otherwise NPC can miss a path point). // Turning is smooth for player and less smooth for NPCs (otherwise NPC can miss a path point).
maxDelta = duration * (isPlayer ? 1.0 / Settings::game().mSmoothMovementPlayerTurningDelay : 6.f); maxDelta = duration * (isPlayer ? 1.0f / Settings::game().mSmoothMovementPlayerTurningDelay : 6.f);
else if (isPlayer && speedDelta < -deltaLen / 2) else if (isPlayer && speedDelta < -deltaLen / 2)
// As soon as controls are released, mwinput switches player from running to walking. // As soon as controls are released, mwinput switches player from running to walking.
// So stopping should be instant for player, otherwise it causes a small twitch. // So stopping should be instant for player, otherwise it causes a small twitch.
@ -2094,7 +2095,7 @@ namespace MWMechanics
if (std::abs(delta) < osg::DegreesToRadians(20.0f)) if (std::abs(delta) < osg::DegreesToRadians(20.0f))
mIsMovingBackward = vec.y() < 0; mIsMovingBackward = vec.y() < 0;
float maxDelta = osg::PI * duration * (2.5f - cosDelta); float maxDelta = osg::PIf * duration * (2.5f - cosDelta);
delta = std::clamp(delta, -maxDelta, maxDelta); delta = std::clamp(delta, -maxDelta, maxDelta);
stats.setSideMovementAngle(stats.getSideMovementAngle() + delta); stats.setSideMovementAngle(stats.getSideMovementAngle() + delta);
effectiveRotation += delta; effectiveRotation += delta;
@ -2520,7 +2521,7 @@ namespace MWMechanics
if (iter == mAnimQueue.begin() && mAnimation) if (iter == mAnimQueue.begin() && mAnimation)
{ {
float complete; float complete;
size_t loopcount; uint32_t loopcount;
mAnimation->getInfo(anim.mGroup, &complete, nullptr, &loopcount); mAnimation->getInfo(anim.mGroup, &complete, nullptr, &loopcount);
anim.mTime = complete; anim.mTime = complete;
anim.mLoopCount = loopcount; anim.mLoopCount = loopcount;
@ -2542,24 +2543,23 @@ namespace MWMechanics
if (!state.mScriptedAnims.empty()) if (!state.mScriptedAnims.empty())
{ {
clearAnimQueue(); clearAnimQueue();
for (ESM::AnimationState::ScriptedAnimations::const_iterator iter = state.mScriptedAnims.begin(); for (const ESM::AnimationState::ScriptedAnimation& animation : state.mScriptedAnims)
iter != state.mScriptedAnims.end(); ++iter)
{ {
AnimationQueueEntry entry; AnimationQueueEntry entry;
entry.mGroup = iter->mGroup; entry.mGroup = animation.mGroup;
entry.mLoopCount entry.mLoopCount = static_cast<uint32_t>(
= static_cast<uint32_t>(std::min<uint64_t>(iter->mLoopCount, std::numeric_limits<uint32_t>::max())); std::min<uint64_t>(animation.mLoopCount, std::numeric_limits<uint32_t>::max()));
entry.mLooping = mAnimation->isLoopingAnimation(entry.mGroup); entry.mLooping = mAnimation->isLoopingAnimation(entry.mGroup);
entry.mScripted = true; entry.mScripted = true;
entry.mStartKey = "start"; entry.mStartKey = "start";
entry.mStopKey = "stop"; entry.mStopKey = "stop";
entry.mSpeed = 1.f; entry.mSpeed = 1.f;
entry.mTime = iter->mTime; entry.mTime = animation.mTime;
if (iter->mAbsolute) if (animation.mAbsolute)
{ {
float start = mAnimation->getTextKeyTime(iter->mGroup + ": start"); float start = mAnimation->getTextKeyTime(animation.mGroup + ": start");
float stop = mAnimation->getTextKeyTime(iter->mGroup + ": stop"); float stop = mAnimation->getTextKeyTime(animation.mGroup + ": stop");
float time = std::clamp(iter->mTime, start, stop); float time = std::clamp(animation.mTime, start, stop);
entry.mTime = (time - start) / (stop - start); entry.mTime = (time - start) / (stop - start);
} }
@ -3087,8 +3087,8 @@ namespace MWMechanics
if (!head) if (!head)
return; return;
double zAngleRadians = 0.f; float zAngleRadians = 0.f;
double xAngleRadians = 0.f; float xAngleRadians = 0.f;
if (!mHeadTrackTarget.isEmpty()) if (!mHeadTrackTarget.isEmpty())
{ {
@ -3122,14 +3122,15 @@ namespace MWMechanics
zAngleRadians zAngleRadians
= std::atan2(actorDirection.x(), actorDirection.y()) - std::atan2(direction.x(), direction.y()); = std::atan2(actorDirection.x(), actorDirection.y()) - std::atan2(direction.x(), direction.y());
zAngleRadians = Misc::normalizeAngle(zAngleRadians - mAnimation->getHeadYaw()) + mAnimation->getHeadYaw(); zAngleRadians = static_cast<float>(
Misc::normalizeAngle(zAngleRadians - mAnimation->getHeadYaw()) + mAnimation->getHeadYaw());
zAngleRadians *= (1 - direction.z() * direction.z()); zAngleRadians *= (1 - direction.z() * direction.z());
xAngleRadians = std::asin(direction.z()); xAngleRadians = std::asin(direction.z());
} }
const double xLimit = osg::DegreesToRadians(40.0); const float xLimit = osg::DegreesToRadians(40.f);
const double zLimit = osg::DegreesToRadians(30.0); const float zLimit = osg::DegreesToRadians(30.f);
double zLimitOffset = mAnimation->getUpperBodyYawRadians(); float zLimitOffset = mAnimation->getUpperBodyYawRadians();
xAngleRadians = std::clamp(xAngleRadians, -xLimit, xLimit); xAngleRadians = std::clamp(xAngleRadians, -xLimit, xLimit);
zAngleRadians = std::clamp(zAngleRadians, -zLimit + zLimitOffset, zLimit + zLimitOffset); zAngleRadians = std::clamp(zAngleRadians, -zLimit + zLimitOffset, zLimit + zLimitOffset);

View file

@ -12,7 +12,7 @@
namespace MWMechanics namespace MWMechanics
{ {
template <class T> template <class T>
void setBaseAISetting(const ESM::RefId& id, MWMechanics::AiSetting setting, int value) void setBaseAISetting(const ESM::RefId& id, MWMechanics::AiSetting setting, unsigned char value)
{ {
T copy = *MWBase::Environment::get().getESMStore()->get<T>().find(id); T copy = *MWBase::Environment::get().getESMStore()->get<T>().find(id);
switch (setting) switch (setting)

View file

@ -50,9 +50,9 @@ namespace MWPhysics
btVector3 max; btVector3 max;
shape->mCollisionShape->getAabb(transform, min, max); shape->mCollisionShape->getAabb(transform, min, max);
mOriginalHalfExtents.x() = (max[0] - min[0]) / 2.f; mOriginalHalfExtents.x() = static_cast<float>((max[0] - min[0]) / 2.f);
mOriginalHalfExtents.y() = (max[1] - min[1]) / 2.f; mOriginalHalfExtents.y() = static_cast<float>((max[1] - min[1]) / 2.f);
mOriginalHalfExtents.z() = (max[2] - min[2]) / 2.f; mOriginalHalfExtents.z() = static_cast<float>((max[2] - min[2]) / 2.f);
mMeshTranslation = osg::Vec3f(0.f, 0.f, mOriginalHalfExtents.z()); mMeshTranslation = osg::Vec3f(0.f, 0.f, mOriginalHalfExtents.z());
} }

View file

@ -1223,7 +1223,7 @@ namespace MWRender
return false; return false;
} }
bool Animation::getInfo(std::string_view groupname, float* complete, float* speedmult, size_t* loopcount) const bool Animation::getInfo(std::string_view groupname, float* complete, float* speedmult, uint32_t* loopcount) const
{ {
AnimStateMap::const_iterator iter = mStates.find(groupname); AnimStateMap::const_iterator iter = mStates.find(groupname);
if (iter == mStates.end()) if (iter == mStates.end())

View file

@ -411,7 +411,7 @@ namespace MWRender
* \return True if the animation is active, false otherwise. * \return True if the animation is active, false otherwise.
*/ */
bool getInfo(std::string_view groupname, float* complete = nullptr, float* speedmult = nullptr, bool getInfo(std::string_view groupname, float* complete = nullptr, float* speedmult = nullptr,
size_t* loopcount = nullptr) const; uint32_t* loopcount = nullptr) const;
/// Returns the group name of the animation currently active on that bone group. /// Returns the group name of the animation currently active on that bone group.
std::string_view getActiveGroup(BoneGroup boneGroup) const; std::string_view getActiveGroup(BoneGroup boneGroup) const;

View file

@ -93,8 +93,8 @@ namespace MWWorld
else else
{ {
effect.mMagnitude = 0.f; effect.mMagnitude = 0.f;
effect.mMinMagnitude = enam.mData.mMagnMin; effect.mMinMagnitude = static_cast<float>(enam.mData.mMagnMin);
effect.mMaxMagnitude = enam.mData.mMagnMax; effect.mMaxMagnitude = static_cast<float>(enam.mData.mMagnMax);
effect.mFlags = ESM::ActiveEffect::Flag_None; effect.mFlags = ESM::ActiveEffect::Flag_None;
} }
params.mEffects.emplace_back(effect); params.mEffects.emplace_back(effect);
@ -106,7 +106,7 @@ namespace MWWorld
for (std::size_t i = 0; i < inventory.mItems.size(); ++i) for (std::size_t i = 0; i < inventory.mItems.size(); ++i)
{ {
ESM::ObjectState& item = inventory.mItems[i]; ESM::ObjectState& item = inventory.mItems[i];
auto slot = inventory.mEquipmentSlots.find(i); auto slot = inventory.mEquipmentSlots.find(static_cast<uint32_t>(i));
if (slot != inventory.mEquipmentSlots.end()) if (slot != inventory.mEquipmentSlots.end())
{ {
MWBase::Environment::get().getWorldModel()->assignSaveFileRefNum(item.mRef); MWBase::Environment::get().getWorldModel()->assignSaveFileRefNum(item.mRef);
@ -216,7 +216,7 @@ namespace MWWorld
dynamic.mMod = 0.f; dynamic.mMod = 0.f;
} }
for (auto& setting : creatureStats.mAiSettings) for (auto& setting : creatureStats.mAiSettings)
setting.mMod = 0.f; setting.mMod = 0;
if (npcStats) if (npcStats)
{ {
for (auto& skill : npcStats->mSkills) for (auto& skill : npcStats->mSkills)
@ -231,7 +231,7 @@ namespace MWWorld
for (auto& dynamic : creatureStats.mDynamic) for (auto& dynamic : creatureStats.mDynamic)
dynamic.mMod = 0.f; dynamic.mMod = 0.f;
for (auto& setting : creatureStats.mAiSettings) for (auto& setting : creatureStats.mAiSettings)
setting.mMod = 0.f; setting.mMod = 0;
} }
// Versions 17-27 wrote an equipment slot index to mItem // Versions 17-27 wrote an equipment slot index to mItem

View file

@ -68,9 +68,9 @@ namespace MWWorld
MWMechanics::NpcStats& stats = getPlayer().getClass().getNpcStats(getPlayer()); MWMechanics::NpcStats& stats = getPlayer().getClass().getNpcStats(getPlayer());
for (size_t i = 0; i < mSaveSkills.size(); ++i) for (size_t i = 0; i < mSaveSkills.size(); ++i)
mSaveSkills[i] = stats.getSkill(ESM::Skill::indexToRefId(i)).getModified(); mSaveSkills[i] = stats.getSkill(ESM::Skill::indexToRefId(static_cast<int>(i))).getModified();
for (size_t i = 0; i < mSaveAttributes.size(); ++i) for (size_t i = 0; i < mSaveAttributes.size(); ++i)
mSaveAttributes[i] = stats.getAttribute(ESM::Attribute::indexToRefId(i)).getModified(); mSaveAttributes[i] = stats.getAttribute(ESM::Attribute::indexToRefId(static_cast<int>(i))).getModified();
} }
void Player::restoreStats() void Player::restoreStats()
@ -83,13 +83,13 @@ namespace MWWorld
creatureStats.setHealth(health.getBase() / gmst.find("fWereWolfHealth")->mValue.getFloat()); creatureStats.setHealth(health.getBase() / gmst.find("fWereWolfHealth")->mValue.getFloat());
for (size_t i = 0; i < mSaveSkills.size(); ++i) for (size_t i = 0; i < mSaveSkills.size(); ++i)
{ {
auto& skill = npcStats.getSkill(ESM::Skill::indexToRefId(i)); auto& skill = npcStats.getSkill(ESM::Skill::indexToRefId(static_cast<int>(i)));
skill.restore(skill.getDamage()); skill.restore(skill.getDamage());
skill.setModifier(mSaveSkills[i] - skill.getBase()); skill.setModifier(mSaveSkills[i] - skill.getBase());
} }
for (size_t i = 0; i < mSaveAttributes.size(); ++i) for (size_t i = 0; i < mSaveAttributes.size(); ++i)
{ {
auto id = ESM::Attribute::indexToRefId(i); auto id = ESM::Attribute::indexToRefId(static_cast<int>(i));
auto attribute = npcStats.getAttribute(id); auto attribute = npcStats.getAttribute(id);
attribute.restore(attribute.getDamage()); attribute.restore(attribute.getDamage());
attribute.setModifier(mSaveAttributes[i] - attribute.getBase()); attribute.setModifier(mSaveAttributes[i] - attribute.getBase());

View file

@ -591,7 +591,7 @@ namespace Gui
// Underscore, use for NotDefined marker (used for glyphs not existing in the font) // Underscore, use for NotDefined marker (used for glyphs not existing in the font)
additional.emplace(95, MyGUI::FontCodeType::NotDefined); additional.emplace(95, MyGUI::FontCodeType::NotDefined);
for (unsigned char i = 0; i < 256; i++) for (unsigned i = 0; i < 256; i++)
{ {
float x1 = data[i].top_left.x * width; float x1 = data[i].top_left.x * width;
float y1 = data[i].top_left.y * height; float y1 = data[i].top_left.y * height;
@ -599,7 +599,7 @@ namespace Gui
float h = data[i].bottom_left.y * height - y1; float h = data[i].bottom_left.y * height - y1;
ToUTF8::Utf8Encoder encoder(mEncoding); ToUTF8::Utf8Encoder encoder(mEncoding);
unsigned long unicodeVal = getUnicode(i, encoder, mEncoding); unsigned long unicodeVal = getUnicode(static_cast<unsigned char>(i), encoder, mEncoding);
const std::string coord = MyGUI::utility::toString(x1) + " " + MyGUI::utility::toString(y1) + " " const std::string coord = MyGUI::utility::toString(x1) + " " + MyGUI::utility::toString(y1) + " "
+ MyGUI::utility::toString(w) + " " + MyGUI::utility::toString(h); + MyGUI::utility::toString(w) + " " + MyGUI::utility::toString(h);
float advance = data[i].width + data[i].kerningRight; float advance = data[i].width + data[i].kerningRight;