fixing MSVC 2013 warning C4244: & C4305

conversion from 'const float' to 'int', possible loss of data
conversion from 'double' to 'int', possible loss of data
conversion from 'float' to 'int', possible loss of data
pull/522/head
dteviot 10 years ago
parent f2ac939e61
commit e197f5318b

@ -460,7 +460,7 @@ int clone(Arguments& info)
for (Stats::iterator it = stats.begin(); it != stats.end(); ++it) for (Stats::iterator it = stats.begin(); it != stats.end(); ++it)
{ {
name.val = it->first; name.val = it->first;
float amount = it->second; int amount = it->second;
std::cout << std::setw(digitCount) << amount << " " << name.toString() << " "; std::cout << std::setw(digitCount) << amount << " " << name.toString() << " ";
if (++i % 3 == 0) if (++i % 3 == 0)

@ -23,9 +23,9 @@ namespace ESSImport
} }
for (int i=0; i<8; ++i) for (int i=0; i<8; ++i)
{ {
cStats.mAttributes[i].mBase = acdt.mAttributes[i][1]; cStats.mAttributes[i].mBase = static_cast<int>(acdt.mAttributes[i][1]);
cStats.mAttributes[i].mMod = acdt.mAttributes[i][0]; cStats.mAttributes[i].mMod = static_cast<int>(acdt.mAttributes[i][0]);
cStats.mAttributes[i].mCurrent = acdt.mAttributes[i][0]; cStats.mAttributes[i].mCurrent = static_cast<int>(acdt.mAttributes[i][0]);
} }
cStats.mGoldPool = acdt.mGoldPool; cStats.mGoldPool = acdt.mGoldPool;
cStats.mTalkedTo = (acdt.mFlags & TalkedToPlayer) != 0; cStats.mTalkedTo = (acdt.mFlags & TalkedToPlayer) != 0;

@ -553,7 +553,7 @@ public:
ESM::WeatherState weather; ESM::WeatherState weather;
weather.mCurrentWeather = toString(mGame.mGMDT.mCurrentWeather); weather.mCurrentWeather = toString(mGame.mGMDT.mCurrentWeather);
weather.mNextWeather = toString(mGame.mGMDT.mNextWeather); weather.mNextWeather = toString(mGame.mGMDT.mNextWeather);
weather.mRemainingTransitionTime = mGame.mGMDT.mWeatherTransition/100.f*(0.015*24*3600); weather.mRemainingTransitionTime = mGame.mGMDT.mWeatherTransition/100.f*(0.015f*24*3600);
weather.mHour = mContext->mHour; weather.mHour = mContext->mHour;
weather.mWindSpeed = 0.f; weather.mWindSpeed = 0.f;
weather.mTimePassed = 0.0; weather.mTimePassed = 0.0;

@ -191,7 +191,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
, mExportFonts(false) , mExportFonts(false)
, mNewGame (false) , mNewGame (false)
{ {
std::srand ( std::time(NULL) ); std::srand ( static_cast<unsigned int>(std::time(NULL)) );
MWClass::registerClasses(); MWClass::registerClasses();
Uint32 flags = SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE|SDL_INIT_GAMECONTROLLER|SDL_INIT_JOYSTICK; Uint32 flags = SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE|SDL_INIT_GAMECONTROLLER|SDL_INIT_JOYSTICK;

@ -154,9 +154,9 @@ namespace MWClass
const MWWorld::Store<ESM::GameSetting> &gmst = const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
float iWeight = gmst.find (typeGmst)->getInt(); float iWeight = floor(gmst.find(typeGmst)->getFloat());
float epsilon = 5e-4; float epsilon = 0.0005f;
if (ref->mBase->mData.mWeight == 0) if (ref->mBase->mData.mWeight == 0)
return ESM::Skill::Unarmored; return ESM::Skill::Unarmored;
@ -262,7 +262,7 @@ namespace MWClass
info.enchant = ref->mBase->mEnchant; info.enchant = ref->mBase->mEnchant;
if (!info.enchant.empty()) if (!info.enchant.empty())
info.remainingEnchantCharge = ptr.getCellRef().getEnchantmentCharge(); info.remainingEnchantCharge = static_cast<int>(ptr.getCellRef().getEnchantmentCharge());
info.text = text; info.text = text;

@ -203,7 +203,7 @@ namespace MWClass
info.enchant = ref->mBase->mEnchant; info.enchant = ref->mBase->mEnchant;
if (!info.enchant.empty()) if (!info.enchant.empty())
info.remainingEnchantCharge = ptr.getCellRef().getEnchantmentCharge(); info.remainingEnchantCharge = static_cast<int>(ptr.getCellRef().getEnchantmentCharge());
info.text = text; info.text = text;

@ -103,9 +103,9 @@ namespace MWClass
data->mCreatureStats.setAttribute(ESM::Attribute::Endurance, ref->mBase->mData.mEndurance); data->mCreatureStats.setAttribute(ESM::Attribute::Endurance, ref->mBase->mData.mEndurance);
data->mCreatureStats.setAttribute(ESM::Attribute::Personality, ref->mBase->mData.mPersonality); data->mCreatureStats.setAttribute(ESM::Attribute::Personality, ref->mBase->mData.mPersonality);
data->mCreatureStats.setAttribute(ESM::Attribute::Luck, ref->mBase->mData.mLuck); data->mCreatureStats.setAttribute(ESM::Attribute::Luck, ref->mBase->mData.mLuck);
data->mCreatureStats.setHealth (ref->mBase->mData.mHealth); data->mCreatureStats.setHealth(static_cast<float>(ref->mBase->mData.mHealth));
data->mCreatureStats.setMagicka (ref->mBase->mData.mMana); data->mCreatureStats.setMagicka(static_cast<float>(ref->mBase->mData.mMana));
data->mCreatureStats.setFatigue (ref->mBase->mData.mFatigue); data->mCreatureStats.setFatigue(static_cast<float>(ref->mBase->mData.mFatigue));
data->mCreatureStats.setLevel(ref->mBase->mData.mLevel); data->mCreatureStats.setLevel(ref->mBase->mData.mLevel);
@ -289,7 +289,7 @@ namespace MWClass
{ {
damage = attack[0] + ((attack[1]-attack[0])*stats.getAttackStrength()); damage = attack[0] + ((attack[1]-attack[0])*stats.getAttackStrength());
damage *= gmst.find("fDamageStrengthBase")->getFloat() + damage *= gmst.find("fDamageStrengthBase")->getFloat() +
(stats.getAttribute(ESM::Attribute::Strength).getModified() * gmst.find("fDamageStrengthMult")->getFloat() * 0.1); (stats.getAttribute(ESM::Attribute::Strength).getModified() * gmst.find("fDamageStrengthMult")->getFloat() * 0.1f);
MWMechanics::adjustWeaponDamage(damage, weapon); MWMechanics::adjustWeaponDamage(damage, weapon);
MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr); MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr);
} }
@ -376,8 +376,8 @@ namespace MWClass
// Check for knockdown // Check for knockdown
float agilityTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified() * getGmst().fKnockDownMult->getFloat(); float agilityTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified() * getGmst().fKnockDownMult->getFloat();
float knockdownTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified() float knockdownTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified()
* getGmst().iKnockDownOddsMult->getInt() * 0.01 + getGmst().iKnockDownOddsBase->getInt(); * getGmst().iKnockDownOddsMult->getInt() * 0.01f + getGmst().iKnockDownOddsBase->getInt();
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99] int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 100); // [0, 99]
if (ishealth && agilityTerm <= damage && knockdownTerm <= roll) if (ishealth && agilityTerm <= damage && knockdownTerm <= roll)
{ {
getCreatureStats(ptr).setKnockedDown(true); getCreatureStats(ptr).setKnockedDown(true);
@ -528,7 +528,7 @@ namespace MWClass
MWMechanics::CreatureStats& stats = getCreatureStats(ptr); MWMechanics::CreatureStats& stats = getCreatureStats(ptr);
const GMST& gmst = getGmst(); const GMST& gmst = getGmst();
float walkSpeed = gmst.fMinWalkSpeedCreature->getFloat() + 0.01 * stats.getAttribute(ESM::Attribute::Speed).getModified() float walkSpeed = gmst.fMinWalkSpeedCreature->getFloat() + 0.01f * stats.getAttribute(ESM::Attribute::Speed).getModified()
* (gmst.fMaxWalkSpeedCreature->getFloat() - gmst.fMinWalkSpeedCreature->getFloat()); * (gmst.fMaxWalkSpeedCreature->getFloat() - gmst.fMinWalkSpeedCreature->getFloat());
const MWBase::World *world = MWBase::Environment::get().getWorld(); const MWBase::World *world = MWBase::Environment::get().getWorld();
@ -626,7 +626,7 @@ namespace MWClass
float Creature::getCapacity (const MWWorld::Ptr& ptr) const float Creature::getCapacity (const MWWorld::Ptr& ptr) const
{ {
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr); const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
return stats.getAttribute(0).getModified()*5; return static_cast<float>(stats.getAttribute(0).getModified() * 5);
} }
float Creature::getEncumbrance (const MWWorld::Ptr& ptr) const float Creature::getEncumbrance (const MWWorld::Ptr& ptr) const

@ -167,19 +167,19 @@ namespace MWClass
if (opening) if (opening)
{ {
MWBase::Environment::get().getSoundManager()->fadeOutSound3D(ptr, MWBase::Environment::get().getSoundManager()->fadeOutSound3D(ptr,
closeSound, 0.5); closeSound, 0.5f);
float offset = ptr.getRefData().getLocalRotation().rot[2]/ 3.14159265 * 2.0; float offset = ptr.getRefData().getLocalRotation().rot[2]/ 3.14159265f * 2.0f;
action->setSoundOffset(offset); action->setSoundOffset(offset);
action->setSound(openSound); action->setSound(openSound);
} }
else else
{ {
MWBase::Environment::get().getSoundManager()->fadeOutSound3D(ptr, MWBase::Environment::get().getSoundManager()->fadeOutSound3D(ptr,
openSound, 0.5); openSound, 0.5f);
float offset = 1.0 - ptr.getRefData().getLocalRotation().rot[2]/ 3.14159265 * 2.0; float offset = 1.0 - ptr.getRefData().getLocalRotation().rot[2]/ 3.14159265f * 2.0f;
//most if not all door have closing bang somewhere in the middle of the sound, //most if not all door have closing bang somewhere in the middle of the sound,
//so we divide offset by two //so we divide offset by two
action->setSoundOffset(offset * 0.5); action->setSoundOffset(offset * 0.5f);
action->setSound(closeSound); action->setSound(closeSound);
} }

@ -205,7 +205,7 @@ namespace MWClass
{ {
MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>();
if (ptr.getCellRef().getCharge() == -1) if (ptr.getCellRef().getCharge() == -1)
return ref->mBase->mData.mTime; return static_cast<float>(ref->mBase->mData.mTime);
else else
return ptr.getCellRef().getChargeFloat(); return ptr.getCellRef().getChargeFloat();
} }

@ -66,12 +66,12 @@ namespace
double i = floor(d); double i = floor(d);
d -= i; d -= i;
if(d < 0.5) if(d < 0.5)
return i; return static_cast<int>(i);
if(d > 0.5) if(d > 0.5)
return i + 1.0; return static_cast<int>(i) + 1;
if(is_even(i)) if(is_even(i))
return i; return static_cast<int>(i);
return i + 1.0; return static_cast<int>(i) + 1;
} }
void autoCalculateAttributes (const ESM::NPC* npc, MWMechanics::CreatureStats& creatureStats) void autoCalculateAttributes (const ESM::NPC* npc, MWMechanics::CreatureStats& creatureStats)
@ -116,7 +116,7 @@ namespace
continue; continue;
// is this a minor or major skill? // is this a minor or major skill?
float add=0.2; float add=0.2f;
for (int k=0; k<5; ++k) for (int k=0; k<5; ++k)
{ {
if (class_->mData.mSkills[k][0] == j) if (class_->mData.mSkills[k][0] == j)
@ -149,7 +149,7 @@ namespace
|| class_->mData.mAttribute[1] == ESM::Attribute::Endurance) || class_->mData.mAttribute[1] == ESM::Attribute::Endurance)
multiplier += 1; multiplier += 1;
creatureStats.setHealth(static_cast<int> (0.5 * (strength + endurance)) + multiplier * (creatureStats.getLevel() - 1)); creatureStats.setHealth(floor(0.5f * (strength + endurance)) + multiplier * (creatureStats.getLevel() - 1));
} }
/** /**
@ -539,7 +539,7 @@ namespace MWClass
{ {
damage = attack[0] + ((attack[1]-attack[0])*stats.getAttackStrength()); damage = attack[0] + ((attack[1]-attack[0])*stats.getAttackStrength());
damage *= gmst.fDamageStrengthBase->getFloat() + damage *= gmst.fDamageStrengthBase->getFloat() +
(stats.getAttribute(ESM::Attribute::Strength).getModified() * gmst.fDamageStrengthMult->getFloat() * 0.1); (stats.getAttribute(ESM::Attribute::Strength).getModified() * gmst.fDamageStrengthMult->getFloat() * 0.1f);
} }
MWMechanics::adjustWeaponDamage(damage, weapon); MWMechanics::adjustWeaponDamage(damage, weapon);
MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr); MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr);
@ -648,7 +648,7 @@ namespace MWClass
const GMST& gmst = getGmst(); const GMST& gmst = getGmst();
int chance = store.get<ESM::GameSetting>().find("iVoiceHitOdds")->getInt(); int chance = store.get<ESM::GameSetting>().find("iVoiceHitOdds")->getInt();
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99] int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 100); // [0, 99]
if (roll < chance) if (roll < chance)
{ {
MWBase::Environment::get().getDialogueManager()->say(ptr, "hit"); MWBase::Environment::get().getDialogueManager()->say(ptr, "hit");
@ -657,8 +657,8 @@ namespace MWClass
// Check for knockdown // Check for knockdown
float agilityTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified() * gmst.fKnockDownMult->getFloat(); float agilityTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified() * gmst.fKnockDownMult->getFloat();
float knockdownTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified() float knockdownTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified()
* gmst.iKnockDownOddsMult->getInt() * 0.01 + gmst.iKnockDownOddsBase->getInt(); * gmst.iKnockDownOddsMult->getInt() * 0.01f + gmst.iKnockDownOddsBase->getInt();
roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99] roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 100); // [0, 99]
if (ishealth && agilityTerm <= damage && knockdownTerm <= roll) if (ishealth && agilityTerm <= damage && knockdownTerm <= roll)
{ {
getCreatureStats(ptr).setKnockedDown(true); getCreatureStats(ptr).setKnockedDown(true);
@ -690,7 +690,7 @@ namespace MWClass
float unmitigatedDamage = damage; float unmitigatedDamage = damage;
float x = damage / (damage + getArmorRating(ptr)); float x = damage / (damage + getArmorRating(ptr));
damage *= std::max(gmst.fCombatArmorMinMult->getFloat(), x); damage *= std::max(gmst.fCombatArmorMinMult->getFloat(), x);
int damageDiff = unmitigatedDamage - damage; int damageDiff = static_cast<int>(unmitigatedDamage - damage);
if (damage < 1) if (damage < 1)
damage = 1; damage = 1;
@ -938,7 +938,7 @@ namespace MWClass
gmst.fJumpEncumbranceMultiplier->getFloat() * gmst.fJumpEncumbranceMultiplier->getFloat() *
(1.0f - Npc::getEncumbrance(ptr)/Npc::getCapacity(ptr)); (1.0f - Npc::getEncumbrance(ptr)/Npc::getCapacity(ptr));
float a = npcdata->mNpcStats.getSkill(ESM::Skill::Acrobatics).getModified(); float a = static_cast<float>(npcdata->mNpcStats.getSkill(ESM::Skill::Acrobatics).getModified());
float b = 0.0f; float b = 0.0f;
if(a > 50.0f) if(a > 50.0f)
{ {
@ -1097,7 +1097,7 @@ namespace MWClass
if (it == invStore.end() || it->getTypeName() != typeid(ESM::Armor).name()) if (it == invStore.end() || it->getTypeName() != typeid(ESM::Armor).name())
{ {
// unarmored // unarmored
ratings[i] = (fUnarmoredBase1 * unarmoredSkill) * (fUnarmoredBase2 * unarmoredSkill); ratings[i] = static_cast<int>((fUnarmoredBase1 * unarmoredSkill) * (fUnarmoredBase2 * unarmoredSkill));
} }
else else
{ {

@ -345,7 +345,7 @@ namespace MWClass
info.enchant = ref->mBase->mEnchant; info.enchant = ref->mBase->mEnchant;
if (!info.enchant.empty()) if (!info.enchant.empty())
info.remainingEnchantCharge = ptr.getCellRef().getEnchantmentCharge(); info.remainingEnchantCharge = static_cast<int>(ptr.getCellRef().getEnchantmentCharge());
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef()); text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());

@ -444,7 +444,7 @@ namespace MWDialogue
if (mActor.getClass().isNpc()) if (mActor.getClass().isNpc())
{ {
MWMechanics::NpcStats& npcStats = mActor.getClass().getNpcStats(mActor); MWMechanics::NpcStats& npcStats = mActor.getClass().getNpcStats(mActor);
npcStats.setBaseDisposition(npcStats.getBaseDisposition() + mPermanentDispositionChange); npcStats.setBaseDisposition(static_cast<int>(npcStats.getBaseDisposition() + mPermanentDispositionChange));
} }
mPermanentDispositionChange = 0; mPermanentDispositionChange = 0;
mTemporaryDispositionChange = 0; mTemporaryDispositionChange = 0;
@ -521,7 +521,7 @@ namespace MWDialogue
mPermanentDispositionChange += perm; mPermanentDispositionChange += perm;
// change temp disposition so that final disposition is between 0...100 // change temp disposition so that final disposition is between 0...100
int curDisp = MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mActor); float curDisp = static_cast<float>(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mActor));
if (curDisp + mTemporaryDispositionChange < 0) if (curDisp + mTemporaryDispositionChange < 0)
mTemporaryDispositionChange = -curDisp; mTemporaryDispositionChange = -curDisp;
else if (curDisp + mTemporaryDispositionChange > 100) else if (curDisp + mTemporaryDispositionChange > 100)
@ -564,7 +564,7 @@ namespace MWDialogue
int DialogueManager::getTemporaryDispositionChange() const int DialogueManager::getTemporaryDispositionChange() const
{ {
return mTemporaryDispositionChange; return static_cast<int>(mTemporaryDispositionChange);
} }
void DialogueManager::applyDispositionChange(int delta) void DialogueManager::applyDispositionChange(int delta)

@ -41,8 +41,8 @@ void BackgroundImage::adjustSize()
MyGUI::IntSize screenSize = getSize(); MyGUI::IntSize screenSize = getSize();
int leftPadding = std::max(0.0, (screenSize.width - screenSize.height * mAspect) / 2); int leftPadding = std::max(0, static_cast<int>(screenSize.width - screenSize.height * mAspect) / 2);
int topPadding = std::max(0.0, (screenSize.height - screenSize.width / mAspect) / 2); int topPadding = std::max(0, static_cast<int>(screenSize.height - screenSize.width / mAspect) / 2);
mChild->setCoord(leftPadding, topPadding, screenSize.width - leftPadding*2, screenSize.height - topPadding*2); mChild->setCoord(leftPadding, topPadding, screenSize.width - leftPadding*2, screenSize.height - topPadding*2);
} }

@ -326,7 +326,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
mLine = NULL; mLine = NULL;
} }
void sectionBreak (float margin) void sectionBreak (int margin)
{ {
add_partial_text(); add_partial_text();
@ -465,7 +465,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
{ {
MyGUI::GlyphInfo* gi = style->mFont->getGlyphInfo (stream.peek ()); MyGUI::GlyphInfo* gi = style->mFont->getGlyphInfo (stream.peek ());
if (gi) if (gi)
space_width += gi->advance + gi->bearingX; space_width += static_cast<int>(gi->advance + gi->bearingX);
stream.consume (); stream.consume ();
} }
@ -475,7 +475,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
{ {
MyGUI::GlyphInfo* gi = style->mFont->getGlyphInfo (stream.peek ()); MyGUI::GlyphInfo* gi = style->mFont->getGlyphInfo (stream.peek ());
if (gi) if (gi)
word_width += gi->advance + gi->bearingX; word_width += static_cast<int>(gi->advance + gi->bearingX);
stream.consume (); stream.consume ();
} }
@ -623,15 +623,15 @@ namespace
RenderXform (MyGUI::ICroppedRectangle* croppedParent, MyGUI::RenderTargetInfo const & renderTargetInfo) RenderXform (MyGUI::ICroppedRectangle* croppedParent, MyGUI::RenderTargetInfo const & renderTargetInfo)
{ {
clipTop = croppedParent->_getMarginTop (); clipTop = static_cast<float>(croppedParent->_getMarginTop());
clipLeft = croppedParent->_getMarginLeft (); clipLeft = static_cast<int>(croppedParent->_getMarginLeft ());
clipRight = croppedParent->getWidth () - croppedParent->_getMarginRight (); clipRight = static_cast<int>(croppedParent->getWidth () - croppedParent->_getMarginRight ());
clipBottom = croppedParent->getHeight () - croppedParent->_getMarginBottom (); clipBottom = static_cast<int>(croppedParent->getHeight() - croppedParent->_getMarginBottom());
absoluteLeft = croppedParent->getAbsoluteLeft(); absoluteLeft = static_cast<int>(croppedParent->getAbsoluteLeft());
absoluteTop = croppedParent->getAbsoluteTop(); absoluteTop = static_cast<int>(croppedParent->getAbsoluteTop());
leftOffset = renderTargetInfo.leftOffset; leftOffset = static_cast<int>(renderTargetInfo.leftOffset);
topOffset = renderTargetInfo.topOffset; topOffset = static_cast<int>(renderTargetInfo.topOffset);
pixScaleX = renderTargetInfo.pixScaleX; pixScaleX = renderTargetInfo.pixScaleX;
pixScaleY = renderTargetInfo.pixScaleY; pixScaleY = renderTargetInfo.pixScaleY;
@ -1136,7 +1136,7 @@ public:
MyGUI::Colour colour = isActive ? (this_->mItemActive ? run.mStyle->mActiveColour: run.mStyle->mHotColour) : run.mStyle->mNormalColour; MyGUI::Colour colour = isActive ? (this_->mItemActive ? run.mStyle->mActiveColour: run.mStyle->mHotColour) : run.mStyle->mNormalColour;
glyphStream.reset (section.mRect.left + line.mRect.left + run.mLeft, line.mRect.top, colour); glyphStream.reset(static_cast<float>(section.mRect.left + line.mRect.left + run.mLeft), static_cast<float>(line.mRect.top), colour);
Utf8Stream stream (run.mRange); Utf8Stream stream (run.mRange);
@ -1164,7 +1164,7 @@ public:
RenderXform renderXform (mCroppedParent, textFormat.mRenderItem->getRenderTarget()->getInfo()); RenderXform renderXform (mCroppedParent, textFormat.mRenderItem->getRenderTarget()->getInfo());
GlyphStream glyphStream (textFormat.mFont, mCoord.left, mCoord.top-mViewTop, GlyphStream glyphStream(textFormat.mFont, static_cast<float>(mCoord.left), static_cast<float>(mCoord.top - mViewTop),
-1 /*mNode->getNodeDepth()*/, vertices, renderXform); -1 /*mNode->getNodeDepth()*/, vertices, renderXform);
int visit_top = (std::max) (mViewTop, mViewTop + int (renderXform.clipTop )); int visit_top = (std::max) (mViewTop, mViewTop + int (renderXform.clipTop ));

@ -71,7 +71,7 @@ namespace MWGui
/// to begin when additional text is inserted. Pagination attempts to keep /// to begin when additional text is inserted. Pagination attempts to keep
/// sections together on a single page. The margin parameter adds additional space /// sections together on a single page. The margin parameter adds additional space
/// before the next line of text. /// before the next line of text.
virtual void sectionBreak (float margin = 0) = 0; virtual void sectionBreak (int margin = 0) = 0;
/// Changes the alignment for the current section of text. /// Changes the alignment for the current section of text.
virtual void setSectionAlignment (Alignment sectionAlignment) = 0; virtual void setSectionAlignment (Alignment sectionAlignment) = 0;

@ -129,7 +129,7 @@ void CompanionWindow::updateEncumbranceBar()
return; return;
float capacity = mPtr.getClass().getCapacity(mPtr); float capacity = mPtr.getClass().getCapacity(mPtr);
float encumbrance = mPtr.getClass().getEncumbrance(mPtr); float encumbrance = mPtr.getClass().getEncumbrance(mPtr);
mEncumbranceBar->setValue(encumbrance, capacity); mEncumbranceBar->setValue(static_cast<int>(encumbrance), static_cast<int>(capacity));
if (mModel && mModel->hasProfit(mPtr)) if (mModel && mModel->hasProfit(mPtr))
{ {

@ -9,8 +9,8 @@ namespace MWGui
{ {
ControllerRepeatEvent::ControllerRepeatEvent() : ControllerRepeatEvent::ControllerRepeatEvent() :
mInit(0.5), mInit(0.5f),
mStep(0.1), mStep(0.1f),
mEnabled(true), mEnabled(true),
mTimeLeft(0) mTimeLeft(0)
{ {

@ -549,7 +549,7 @@ namespace MWGui
size_t range = book->getSize().second - viewHeight; size_t range = book->getSize().second - viewHeight;
mScrollBar->setScrollRange(range); mScrollBar->setScrollRange(range);
mScrollBar->setScrollPosition(range-1); mScrollBar->setScrollPosition(range-1);
mScrollBar->setTrackSize(viewHeight / static_cast<float>(book->getSize().second) * mScrollBar->getLineSize()); mScrollBar->setTrackSize(static_cast<int>(viewHeight / static_cast<float>(book->getSize().second) * mScrollBar->getLineSize()));
onScrollbarMoved(mScrollBar, range-1); onScrollbarMoved(mScrollBar, range-1);
} }
else else
@ -637,14 +637,14 @@ namespace MWGui
if (dispositionVisible && !dispositionWasVisible) if (dispositionVisible && !dispositionWasVisible)
{ {
mDispositionBar->setVisible(true); mDispositionBar->setVisible(true);
float offset = mDispositionBar->getHeight()+5; int offset = mDispositionBar->getHeight()+5;
mTopicsList->setCoord(mTopicsList->getCoord() + MyGUI::IntCoord(0,offset,0,-offset)); mTopicsList->setCoord(mTopicsList->getCoord() + MyGUI::IntCoord(0,offset,0,-offset));
mTopicsList->adjustSize(); mTopicsList->adjustSize();
} }
else if (!dispositionVisible && dispositionWasVisible) else if (!dispositionVisible && dispositionWasVisible)
{ {
mDispositionBar->setVisible(false); mDispositionBar->setVisible(false);
float offset = mDispositionBar->getHeight()+5; int offset = mDispositionBar->getHeight()+5;
mTopicsList->setCoord(mTopicsList->getCoord() - MyGUI::IntCoord(0,offset,0,-offset)); mTopicsList->setCoord(mTopicsList->getCoord() - MyGUI::IntCoord(0,offset,0,-offset));
mTopicsList->adjustSize(); mTopicsList->adjustSize();
} }

@ -262,7 +262,7 @@ namespace MWGui
void HUD::setDrowningTimeLeft(float time, float maxTime) void HUD::setDrowningTimeLeft(float time, float maxTime)
{ {
size_t progress = time/maxTime*200.0; size_t progress = static_cast<size_t>(time / maxTime * 200);
mDrowning->setProgressPosition(progress); mDrowning->setProgressPosition(progress);
bool isDrowning = (progress == 0); bool isDrowning = (progress == 0);
@ -631,7 +631,7 @@ namespace MWGui
mEnemyHealth->setProgressRange(100); mEnemyHealth->setProgressRange(100);
// Health is usually cast to int before displaying. Actors die whenever they are < 1 health. // Health is usually cast to int before displaying. Actors die whenever they are < 1 health.
// Therefore any value < 1 should show as an empty health bar. We do the same in statswindow :) // Therefore any value < 1 should show as an empty health bar. We do the same in statswindow :)
mEnemyHealth->setProgressPosition(int(stats.getHealth().getCurrent()) / stats.getHealth().getModified() * 100); mEnemyHealth->setProgressPosition(static_cast<size_t>(stats.getHealth().getCurrent() / stats.getHealth().getModified() * 100));
static const float fNPCHealthBarFade = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fNPCHealthBarFade")->getFloat(); static const float fNPCHealthBarFade = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fNPCHealthBarFade")->getFloat();
if (fNPCHealthBarFade > 0.f) if (fNPCHealthBarFade > 0.f)

@ -101,7 +101,7 @@ namespace MWGui
void InventoryWindow::adjustPanes() void InventoryWindow::adjustPanes()
{ {
const float aspect = 0.5; // fixed aspect ratio for the avatar image const float aspect = 0.5; // fixed aspect ratio for the avatar image
float leftPaneWidth = (mMainWidget->getSize().height-44-mArmorRating->getHeight()) * aspect; int leftPaneWidth = static_cast<int>(mMainWidget->getSize().height - 44 - mArmorRating->getHeight()) * aspect);
mLeftPane->setSize( leftPaneWidth, mMainWidget->getSize().height-44 ); mLeftPane->setSize( leftPaneWidth, mMainWidget->getSize().height-44 );
mRightPane->setCoord( mLeftPane->getPosition().left + leftPaneWidth + 4, mRightPane->setCoord( mLeftPane->getPosition().left + leftPaneWidth + 4,
mRightPane->getPosition().top, mRightPane->getPosition().top,
@ -153,10 +153,10 @@ namespace MWGui
} }
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize(); MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
MyGUI::IntPoint pos (Settings::Manager::getFloat(setting + " x", "Windows") * viewSize.width, MyGUI::IntPoint pos(static_cast<int>(Settings::Manager::getFloat(setting + " x", "Windows") * viewSize.width),
Settings::Manager::getFloat(setting + " y", "Windows") * viewSize.height); static_cast<int>(Settings::Manager::getFloat(setting + " y", "Windows") * viewSize.height));
MyGUI::IntSize size (Settings::Manager::getFloat(setting + " w", "Windows") * viewSize.width, MyGUI::IntSize size(static_cast<int>(Settings::Manager::getFloat(setting + " w", "Windows") * viewSize.width),
Settings::Manager::getFloat(setting + " h", "Windows") * viewSize.height); static_cast<int>(Settings::Manager::getFloat(setting + " h", "Windows") * viewSize.height));
if (size.width != mMainWidget->getWidth() || size.height != mMainWidget->getHeight()) if (size.width != mMainWidget->getWidth() || size.height != mMainWidget->getHeight())
mPreviewResize = true; mPreviewResize = true;
@ -519,7 +519,7 @@ namespace MWGui
float capacity = player.getClass().getCapacity(player); float capacity = player.getClass().getCapacity(player);
float encumbrance = player.getClass().getEncumbrance(player); float encumbrance = player.getClass().getEncumbrance(player);
mTradeModel->adjustEncumbrance(encumbrance); mTradeModel->adjustEncumbrance(encumbrance);
mEncumbranceBar->setValue(encumbrance, capacity); mEncumbranceBar->setValue(static_cast<int>(encumbrance), static_cast<int>(capacity));
} }
void InventoryWindow::onFrame() void InventoryWindow::onFrame()

@ -141,10 +141,10 @@ void ItemView::onSelectedBackground(MyGUI::Widget *sender)
void ItemView::onMouseWheel(MyGUI::Widget *_sender, int _rel) void ItemView::onMouseWheel(MyGUI::Widget *_sender, int _rel)
{ {
if (mScrollView->getViewOffset().left + _rel*0.3 > 0) if (mScrollView->getViewOffset().left + _rel*0.3f > 0)
mScrollView->setViewOffset(MyGUI::IntPoint(0, 0)); mScrollView->setViewOffset(MyGUI::IntPoint(0, 0));
else else
mScrollView->setViewOffset(MyGUI::IntPoint(mScrollView->getViewOffset().left + _rel*0.3, 0)); mScrollView->setViewOffset(MyGUI::IntPoint(static_cast<int>(mScrollView->getViewOffset().left + _rel*0.3f), 0));
} }
void ItemView::setSize(const MyGUI::IntSize &_value) void ItemView::setSize(const MyGUI::IntSize &_value)

@ -17,7 +17,7 @@ namespace MWGui
{ {
JailScreen::JailScreen() JailScreen::JailScreen()
: WindowBase("openmw_jail_screen.layout"), : WindowBase("openmw_jail_screen.layout"),
mTimeAdvancer(0.01), mTimeAdvancer(0.01f),
mDays(1), mDays(1),
mFadeTimeRemaining(0) mFadeTimeRemaining(0)
{ {
@ -66,7 +66,7 @@ namespace MWGui
void JailScreen::onJailProgressChanged(int cur, int /*total*/) void JailScreen::onJailProgressChanged(int cur, int /*total*/)
{ {
mProgressBar->setScrollPosition(0); mProgressBar->setScrollPosition(0);
mProgressBar->setTrackSize(cur / (float)(mProgressBar->getScrollRange()) * mProgressBar->getLineSize()); mProgressBar->setTrackSize(static_cast<int>(cur / (float)(mProgressBar->getScrollRange()) * mProgressBar->getLineSize()));
} }
void JailScreen::onJailFinished() void JailScreen::onJailFinished()
@ -83,7 +83,7 @@ namespace MWGui
std::set<int> skills; std::set<int> skills;
for (int day=0; day<mDays; ++day) for (int day=0; day<mDays; ++day)
{ {
int skill = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * ESM::Skill::Length; int skill = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * ESM::Skill::Length);
skills.insert(skill); skills.insert(skill);
MWMechanics::SkillValue& value = player.getClass().getNpcStats(player).getSkill(skill); MWMechanics::SkillValue& value = player.getClass().getNpcStats(player).getSkill(skill);

@ -33,8 +33,8 @@ namespace MWGui
: mSceneMgr(sceneMgr) : mSceneMgr(sceneMgr)
, mWindow(rw) , mWindow(rw)
, WindowBase("openmw_loading_screen.layout") , WindowBase("openmw_loading_screen.layout")
, mLastRenderTime(0.f) , mLastRenderTime(0)
, mLastWallpaperChangeTime(0.f) , mLastWallpaperChangeTime(0)
, mProgress(0) , mProgress(0)
, mVSyncWasEnabled(false) , mVSyncWasEnabled(false)
{ {
@ -173,7 +173,7 @@ namespace MWGui
return; return;
mProgress = value; mProgress = value;
mProgressBar->setScrollPosition(0); mProgressBar->setScrollPosition(0);
mProgressBar->setTrackSize(value / (float)(mProgressBar->getScrollRange()) * mProgressBar->getLineSize()); mProgressBar->setTrackSize(static_cast<int>(value / (float)(mProgressBar->getScrollRange()) * mProgressBar->getLineSize()));
draw(); draw();
} }
@ -182,7 +182,7 @@ namespace MWGui
mProgressBar->setScrollPosition(0); mProgressBar->setScrollPosition(0);
size_t value = mProgress + increase; size_t value = mProgress + increase;
mProgress = value; mProgress = value;
mProgressBar->setTrackSize(value / (float)(mProgressBar->getScrollRange()) * mProgressBar->getLineSize()); mProgressBar->setTrackSize(static_cast<int>(value / (float)(mProgressBar->getScrollRange()) * mProgressBar->getLineSize()));
draw(); draw();
} }
@ -193,7 +193,7 @@ namespace MWGui
time = (time-2)*-1; time = (time-2)*-1;
mProgressBar->setTrackSize(50); mProgressBar->setTrackSize(50);
mProgressBar->setScrollPosition(time * (mProgressBar->getScrollRange()-1)); mProgressBar->setScrollPosition(static_cast<size_t>(time * (mProgressBar->getScrollRange() - 1)));
draw(); draw();
} }

@ -244,14 +244,14 @@ namespace MWGui
// Image space is -Y up, cells are Y up // Image space is -Y up, cells are Y up
nY = 1 - (worldY - cellSize * cellY) / cellSize; nY = 1 - (worldY - cellSize * cellY) / cellSize;
float cellDx = cellX - mCurX; float cellDx = static_cast<float>(cellX - mCurX);
float cellDy = cellY - mCurY; float cellDy = static_cast<float>(cellY - mCurY);
markerPos.cellX = cellX; markerPos.cellX = cellX;
markerPos.cellY = cellY; markerPos.cellY = cellY;
widgetPos = MyGUI::IntPoint(nX * mMapWidgetSize + (1+cellDx) * mMapWidgetSize, widgetPos = MyGUI::IntPoint(static_cast<int>(nX * mMapWidgetSize + (1 + cellDx) * mMapWidgetSize),
nY * mMapWidgetSize - (cellDy-1) * mMapWidgetSize); static_cast<int>(nY * mMapWidgetSize - (cellDy-1) * mMapWidgetSize));
} }
else else
{ {
@ -263,8 +263,8 @@ namespace MWGui
markerPos.cellY = cellY; markerPos.cellY = cellY;
// Image space is -Y up, cells are Y up // Image space is -Y up, cells are Y up
widgetPos = MyGUI::IntPoint(nX * mMapWidgetSize + (1+(cellX-mCurX)) * mMapWidgetSize, widgetPos = MyGUI::IntPoint(static_cast<int>(nX * mMapWidgetSize + (1 + (cellX - mCurX)) * mMapWidgetSize),
nY * mMapWidgetSize + (1-(cellY-mCurY)) * mMapWidgetSize); static_cast<float>(nY * mMapWidgetSize + (1-(cellY-mCurY)) * mMapWidgetSize));
} }
markerPos.nX = nX; markerPos.nX = nX;
@ -309,8 +309,8 @@ namespace MWGui
markerWidget->setUserString("ToolTipType", "Layout"); markerWidget->setUserString("ToolTipType", "Layout");
markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine");
markerWidget->setUserString("Caption_TextOneLine", MyGUI::TextIterator::toTagsString(marker.mNote)); markerWidget->setUserString("Caption_TextOneLine", MyGUI::TextIterator::toTagsString(marker.mNote));
markerWidget->setNormalColour(MyGUI::Colour(1.0,0.3,0.3)); markerWidget->setNormalColour(MyGUI::Colour(1.0f, 0.3f, 0.3f));
markerWidget->setHoverColour(MyGUI::Colour(1.0,0.5,0.5)); markerWidget->setHoverColour(MyGUI::Colour(1.0f, 0.5f, 0.5f));
markerWidget->setUserData(marker); markerWidget->setUserData(marker);
markerWidget->setNeedMouseFocus(true); markerWidget->setNeedMouseFocus(true);
customMarkerCreated(markerWidget); customMarkerCreated(markerWidget);
@ -424,7 +424,7 @@ namespace MWGui
void LocalMapBase::setPlayerPos(int cellX, int cellY, const float nx, const float ny) void LocalMapBase::setPlayerPos(int cellX, int cellY, const float nx, const float ny)
{ {
MyGUI::IntPoint pos(mMapWidgetSize+nx*mMapWidgetSize-16, mMapWidgetSize+ny*mMapWidgetSize-16); MyGUI::IntPoint pos(static_cast<int>(mMapWidgetSize + nx*mMapWidgetSize - 16), static_cast<int>(mMapWidgetSize + ny*mMapWidgetSize - 16));
pos.left += (cellX - mCurX) * mMapWidgetSize; pos.left += (cellX - mCurX) * mMapWidgetSize;
pos.top -= (cellY - mCurY) * mMapWidgetSize; pos.top -= (cellY - mCurY) * mMapWidgetSize;
@ -435,7 +435,7 @@ namespace MWGui
mCompass->setPosition(pos); mCompass->setPosition(pos);
MyGUI::IntPoint middle (pos.left+16, pos.top+16); MyGUI::IntPoint middle (pos.left+16, pos.top+16);
MyGUI::IntCoord viewsize = mLocalMap->getCoord(); MyGUI::IntCoord viewsize = mLocalMap->getCoord();
MyGUI::IntPoint viewOffset(0.5*viewsize.width - middle.left, 0.5*viewsize.height - middle.top); MyGUI::IntPoint viewOffset((viewsize.width / 2) - middle.left, (viewsize.height / 2) - middle.top);
mLocalMap->setViewOffset(viewOffset); mLocalMap->setViewOffset(viewOffset);
} }
} }
@ -668,7 +668,7 @@ namespace MWGui
else else
{ {
worldPos.x = (x + nX) * cellSize; worldPos.x = (x + nX) * cellSize;
worldPos.y = (y + (1.0-nY)) * cellSize; worldPos.y = (y + (1.0f-nY)) * cellSize;
} }
mEditingMarker.mWorldX = worldPos.x; mEditingMarker.mWorldX = worldPos.x;
@ -737,8 +737,8 @@ namespace MWGui
int markerSize = 12; int markerSize = 12;
int offset = mGlobalMapRender->getCellSize()/2 - markerSize/2; int offset = mGlobalMapRender->getCellSize()/2 - markerSize/2;
MyGUI::IntCoord widgetCoord( MyGUI::IntCoord widgetCoord(
worldX * mGlobalMapRender->getWidth()+offset, static_cast<int>(worldX * mGlobalMapRender->getWidth()+offset),
worldY * mGlobalMapRender->getHeight()+offset, static_cast<int>(worldY * mGlobalMapRender->getHeight() + offset),
markerSize, markerSize); markerSize, markerSize);
MyGUI::Widget* markerWidget = mGlobalMap->createWidget<MyGUI::Widget>("MarkerButton", MyGUI::Widget* markerWidget = mGlobalMap->createWidget<MyGUI::Widget>("MarkerButton",
@ -833,11 +833,11 @@ namespace MWGui
worldX *= mGlobalMapRender->getWidth(); worldX *= mGlobalMapRender->getWidth();
worldY *= mGlobalMapRender->getHeight(); worldY *= mGlobalMapRender->getHeight();
mPlayerArrowGlobal->setPosition(MyGUI::IntPoint(worldX - 16, worldY - 16)); mPlayerArrowGlobal->setPosition(MyGUI::IntPoint(static_cast<int>(worldX - 16), static_cast<int>(worldY - 16)));
// set the view offset so that player is in the center // set the view offset so that player is in the center
MyGUI::IntSize viewsize = mGlobalMap->getSize(); MyGUI::IntSize viewsize = mGlobalMap->getSize();
MyGUI::IntPoint viewoffs(0.5*viewsize.width - worldX, 0.5*viewsize.height - worldY); MyGUI::IntPoint viewoffs((viewsize.width / 2) - worldX, (viewsize.height / 2) - worldY);
mGlobalMap->setViewOffset(viewoffs); mGlobalMap->setViewOffset(viewoffs);
} }
} }
@ -854,11 +854,11 @@ namespace MWGui
x *= mGlobalMapRender->getWidth(); x *= mGlobalMapRender->getWidth();
y *= mGlobalMapRender->getHeight(); y *= mGlobalMapRender->getHeight();
mPlayerArrowGlobal->setPosition(MyGUI::IntPoint(x - 16, y - 16)); mPlayerArrowGlobal->setPosition(MyGUI::IntPoint(static_cast<int>(x - 16), static_cast<int>(y - 16)));
// set the view offset so that player is in the center // set the view offset so that player is in the center
MyGUI::IntSize viewsize = mGlobalMap->getSize(); MyGUI::IntSize viewsize = mGlobalMap->getSize();
MyGUI::IntPoint viewoffs(0.5*viewsize.width - x, 0.5*viewsize.height - y); MyGUI::IntPoint viewoffs((viewsize.width / 2) - x, (viewsize.height / 2) - y);
mGlobalMap->setViewOffset(viewoffs); mGlobalMap->setViewOffset(viewoffs);
} }

@ -59,11 +59,11 @@ void MerchantRepair::startRepair(const MWWorld::Ptr &actor)
float fRepairMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>() float fRepairMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
.find("fRepairMult")->getFloat(); .find("fRepairMult")->getFloat();
float p = std::max(1, basePrice); float p = static_cast<float>(std::max(1, basePrice));
float r = std::max(1, static_cast<int>(maxDurability / p)); float r = static_cast<float>(std::max(1, static_cast<int>(maxDurability / p)));
int x = ((maxDurability - durability) / r); int x = static_cast<int>((maxDurability - durability) / r);
x = (fRepairMult * x); x = static_cast<int>(fRepairMult * x);
int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mActor, x, true); int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mActor, x, true);
@ -105,10 +105,10 @@ void MerchantRepair::startRepair(const MWWorld::Ptr &actor)
void MerchantRepair::onMouseWheel(MyGUI::Widget* _sender, int _rel) void MerchantRepair::onMouseWheel(MyGUI::Widget* _sender, int _rel)
{ {
if (mList->getViewOffset().top + _rel*0.3 > 0) if (mList->getViewOffset().top + _rel*0.3f > 0)
mList->setViewOffset(MyGUI::IntPoint(0, 0)); mList->setViewOffset(MyGUI::IntPoint(0, 0));
else else
mList->setViewOffset(MyGUI::IntPoint(0, mList->getViewOffset().top + _rel*0.3)); mList->setViewOffset(MyGUI::IntPoint(0, static_cast<int>(mList->getViewOffset().top + _rel*0.3f)));
} }
void MerchantRepair::open() void MerchantRepair::open()

@ -70,7 +70,7 @@ namespace MWGui
it = mMessageBoxes.begin(); it = mMessageBoxes.begin();
while(it != mMessageBoxes.end()) while(it != mMessageBoxes.end())
{ {
(*it)->update(height); (*it)->update(static_cast<int>(height));
height += (*it)->getHeight(); height += (*it)->getHeight();
++it; ++it;
} }

@ -203,7 +203,7 @@ namespace MWGui
void RaceDialog::onHeadRotate(MyGUI::ScrollBar* scroll, size_t _position) void RaceDialog::onHeadRotate(MyGUI::ScrollBar* scroll, size_t _position)
{ {
float angle = (float(_position) / (scroll->getScrollRange()-1) - 0.5) * 3.14 * 2; float angle = (float(_position) / (scroll->getScrollRange()-1) - 0.5f) * 3.14f * 2;
mPreview->update (angle); mPreview->update (angle);
mPreviewDirty = true; mPreviewDirty = true;
mCurrentAngle = angle; mCurrentAngle = angle;
@ -404,7 +404,7 @@ namespace MWGui
skillWidget = mSkillList->createWidget<Widgets::MWSkill>("MW_StatNameValue", coord1, MyGUI::Align::Default, skillWidget = mSkillList->createWidget<Widgets::MWSkill>("MW_StatNameValue", coord1, MyGUI::Align::Default,
std::string("Skill") + MyGUI::utility::toString(i)); std::string("Skill") + MyGUI::utility::toString(i));
skillWidget->setSkillNumber(skillId); skillWidget->setSkillNumber(skillId);
skillWidget->setSkillValue(Widgets::MWSkill::SkillValue(race->mData.mBonus[i].mBonus)); skillWidget->setSkillValue(Widgets::MWSkill::SkillValue(static_cast<float>(race->mData.mBonus[i].mBonus)));
ToolTips::createSkillToolTip(skillWidget, skillId); ToolTips::createSkillToolTip(skillWidget, skillId);

@ -119,7 +119,7 @@ void Recharge::updateView()
Widgets::MWDynamicStatPtr chargeWidget = mView->createWidget<Widgets::MWDynamicStat> Widgets::MWDynamicStatPtr chargeWidget = mView->createWidget<Widgets::MWDynamicStat>
("MW_ChargeBar", MyGUI::IntCoord(72, currentY+2, 199, 20), MyGUI::Align::Default); ("MW_ChargeBar", MyGUI::IntCoord(72, currentY+2, 199, 20), MyGUI::Align::Default);
chargeWidget->setValue(iter->getCellRef().getEnchantmentCharge(), enchantment->mData.mCharge); chargeWidget->setValue(static_cast<int>(iter->getCellRef().getEnchantmentCharge()), enchantment->mData.mCharge);
chargeWidget->setNeedMouseFocus(false); chargeWidget->setNeedMouseFocus(false);
currentY += 32 + 4; currentY += 32 + 4;
@ -149,11 +149,11 @@ void Recharge::onItemClicked(MyGUI::Widget *sender)
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player); MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
MWMechanics::NpcStats& npcStats = player.getClass().getNpcStats(player); MWMechanics::NpcStats& npcStats = player.getClass().getNpcStats(player);
float luckTerm = 0.1 * stats.getAttribute(ESM::Attribute::Luck).getModified(); float luckTerm = 0.1f * stats.getAttribute(ESM::Attribute::Luck).getModified();
if (luckTerm < 1|| luckTerm > 10) if (luckTerm < 1|| luckTerm > 10)
luckTerm = 1; luckTerm = 1;
float intelligenceTerm = 0.2 * stats.getAttribute(ESM::Attribute::Intelligence).getModified(); float intelligenceTerm = 0.2f * stats.getAttribute(ESM::Attribute::Intelligence).getModified();
if (intelligenceTerm > 20) if (intelligenceTerm > 20)
intelligenceTerm = 20; intelligenceTerm = 20;
@ -161,7 +161,7 @@ void Recharge::onItemClicked(MyGUI::Widget *sender)
intelligenceTerm = 1; intelligenceTerm = 1;
float x = (npcStats.getSkill(ESM::Skill::Enchant).getModified() + intelligenceTerm + luckTerm) * stats.getFatigueTerm(); float x = (npcStats.getSkill(ESM::Skill::Enchant).getModified() + intelligenceTerm + luckTerm) * stats.getFatigueTerm();
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99] int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 100); // [0, 99]
if (roll < x) if (roll < x)
{ {
std::string soul = gem.getCellRef().getSoul(); std::string soul = gem.getCellRef().getSoul();
@ -197,10 +197,10 @@ void Recharge::onItemClicked(MyGUI::Widget *sender)
void Recharge::onMouseWheel(MyGUI::Widget* _sender, int _rel) void Recharge::onMouseWheel(MyGUI::Widget* _sender, int _rel)
{ {
if (mView->getViewOffset().top + _rel*0.3 > 0) if (mView->getViewOffset().top + _rel*0.3f > 0)
mView->setViewOffset(MyGUI::IntPoint(0, 0)); mView->setViewOffset(MyGUI::IntPoint(0, 0));
else else
mView->setViewOffset(MyGUI::IntPoint(0, mView->getViewOffset().top + _rel*0.3)); mView->setViewOffset(MyGUI::IntPoint(0, static_cast<int>(mView->getViewOffset().top + _rel*0.3f)));
} }
} }

@ -146,21 +146,21 @@ namespace MWGui
void ReviewDialog::setHealth(const MWMechanics::DynamicStat<float>& value) void ReviewDialog::setHealth(const MWMechanics::DynamicStat<float>& value)
{ {
mHealth->setValue(value.getCurrent(), value.getModified()); mHealth->setValue(static_cast<int>(value.getCurrent()), static_cast<int>(value.getModified()));
std::string valStr = MyGUI::utility::toString(value.getCurrent()) + "/" + MyGUI::utility::toString(value.getModified()); std::string valStr = MyGUI::utility::toString(value.getCurrent()) + "/" + MyGUI::utility::toString(value.getModified());
mHealth->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr); mHealth->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
} }
void ReviewDialog::setMagicka(const MWMechanics::DynamicStat<float>& value) void ReviewDialog::setMagicka(const MWMechanics::DynamicStat<float>& value)
{ {
mMagicka->setValue(value.getCurrent(), value.getModified()); mMagicka->setValue(static_cast<int>(value.getCurrent()), static_cast<int>(value.getModified()));
std::string valStr = MyGUI::utility::toString(value.getCurrent()) + "/" + MyGUI::utility::toString(value.getModified()); std::string valStr = MyGUI::utility::toString(value.getCurrent()) + "/" + MyGUI::utility::toString(value.getModified());
mMagicka->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr); mMagicka->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr);
} }
void ReviewDialog::setFatigue(const MWMechanics::DynamicStat<float>& value) void ReviewDialog::setFatigue(const MWMechanics::DynamicStat<float>& value)
{ {
mFatigue->setValue(value.getCurrent(), value.getModified()); mFatigue->setValue(static_cast<int>(value.getCurrent()), static_cast<int>(value.getModified()));
std::string valStr = MyGUI::utility::toString(value.getCurrent()) + "/" + MyGUI::utility::toString(value.getModified()); std::string valStr = MyGUI::utility::toString(value.getCurrent()) + "/" + MyGUI::utility::toString(value.getModified());
mFatigue->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr); mFatigue->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
} }
@ -180,7 +180,7 @@ namespace MWGui
MyGUI::TextBox* widget = mSkillWidgetMap[skillId]; MyGUI::TextBox* widget = mSkillWidgetMap[skillId];
if (widget) if (widget)
{ {
float modified = value.getModified(), base = value.getBase(); float modified = static_cast<float>(value.getModified()), base = static_cast<float>(value.getBase());
std::string text = MyGUI::utility::toString(std::floor(modified)); std::string text = MyGUI::utility::toString(std::floor(modified));
std::string state = "normal"; std::string state = "normal";
if (modified > base) if (modified > base)
@ -376,7 +376,7 @@ namespace MWGui
if (mSkillView->getViewOffset().top + _rel*0.3 > 0) if (mSkillView->getViewOffset().top + _rel*0.3 > 0)
mSkillView->setViewOffset(MyGUI::IntPoint(0, 0)); mSkillView->setViewOffset(MyGUI::IntPoint(0, 0));
else else
mSkillView->setViewOffset(MyGUI::IntPoint(0, mSkillView->getViewOffset().top + _rel*0.3)); mSkillView->setViewOffset(MyGUI::IntPoint(0, static_cast<int>(mSkillView->getViewOffset().top + _rel*0.3)));
} }
} }

@ -152,7 +152,7 @@ namespace MWGui
} }
else else
{ {
int value = Settings::Manager::getFloat(getSettingName(current), getSettingCategory(current)); int value = Settings::Manager::getInt(getSettingName(current), getSettingCategory(current));
scroll->setScrollPosition(value); scroll->setScrollPosition(value);
} }
scroll->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition); scroll->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
@ -557,10 +557,10 @@ namespace MWGui
void SettingsWindow::onInputTabMouseWheel(MyGUI::Widget* _sender, int _rel) void SettingsWindow::onInputTabMouseWheel(MyGUI::Widget* _sender, int _rel)
{ {
if (mControlsBox->getViewOffset().top + _rel*0.3 > 0) if (mControlsBox->getViewOffset().top + _rel*0.3f > 0)
mControlsBox->setViewOffset(MyGUI::IntPoint(0, 0)); mControlsBox->setViewOffset(MyGUI::IntPoint(0, 0));
else else
mControlsBox->setViewOffset(MyGUI::IntPoint(0, mControlsBox->getViewOffset().top + _rel*0.3)); mControlsBox->setViewOffset(MyGUI::IntPoint(0, static_cast<int>(mControlsBox->getViewOffset().top + _rel*0.3f)));
} }
void SettingsWindow::onResetDefaultBindings(MyGUI::Widget* _sender) void SettingsWindow::onResetDefaultBindings(MyGUI::Widget* _sender)

@ -46,7 +46,7 @@ namespace MWGui
MWBase::Environment::get().getWorld()->getStore(); MWBase::Environment::get().getWorld()->getStore();
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId); const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
int price = spell->mData.mCost*store.get<ESM::GameSetting>().find("fSpellValueMult")->getFloat(); int price = static_cast<int>(spell->mData.mCost*store.get<ESM::GameSetting>().find("fSpellValueMult")->getFloat());
price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true); price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true);
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
@ -187,7 +187,7 @@ namespace MWGui
if (mSpellsView->getViewOffset().top + _rel*0.3 > 0) if (mSpellsView->getViewOffset().top + _rel*0.3 > 0)
mSpellsView->setViewOffset(MyGUI::IntPoint(0, 0)); mSpellsView->setViewOffset(MyGUI::IntPoint(0, 0));
else else
mSpellsView->setViewOffset(MyGUI::IntPoint(0, mSpellsView->getViewOffset().top + _rel*0.3)); mSpellsView->setViewOffset(MyGUI::IntPoint(0, static_cast<int>(mSpellsView->getViewOffset().top + _rel*0.3f)));
} }
} }

@ -440,14 +440,14 @@ namespace MWGui
for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it)
{ {
float x = 0.5 * (it->mMagnMin + it->mMagnMax); float x = 0.5f * (it->mMagnMin + it->mMagnMax);
const ESM::MagicEffect* effect = const ESM::MagicEffect* effect =
store.get<ESM::MagicEffect>().find(it->mEffectID); store.get<ESM::MagicEffect>().find(it->mEffectID);
x *= 0.1 * effect->mData.mBaseCost; x *= 0.1f * effect->mData.mBaseCost;
x *= 1 + it->mDuration; x *= 1 + it->mDuration;
x += 0.05 * std::max(1, it->mArea) * effect->mData.mBaseCost; x += 0.05f * std::max(1, it->mArea) * effect->mData.mBaseCost;
float fEffectCostMult = float fEffectCostMult =
store.get<ESM::GameSetting>().find("fEffectCostMult")->getFloat(); store.get<ESM::GameSetting>().find("fEffectCostMult")->getFloat();
@ -471,7 +471,7 @@ namespace MWGui
float fSpellMakingValueMult = float fSpellMakingValueMult =
store.get<ESM::GameSetting>().find("fSpellMakingValueMult")->getFloat(); store.get<ESM::GameSetting>().find("fSpellMakingValueMult")->getFloat();
int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,int(y) * fSpellMakingValueMult,true); int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, static_cast<int>(y * fSpellMakingValueMult),true);
mPriceLabel->setCaption(MyGUI::utility::toString(int(price))); mPriceLabel->setCaption(MyGUI::utility::toString(int(price)));

@ -30,7 +30,7 @@ namespace MWGui
{ {
MagicEffectInfo newEffectSource; MagicEffectInfo newEffectSource;
newEffectSource.mKey = key; newEffectSource.mKey = key;
newEffectSource.mMagnitude = magnitude; newEffectSource.mMagnitude = static_cast<int>(magnitude);
newEffectSource.mPermanent = mIsPermanent; newEffectSource.mPermanent = mIsPermanent;
newEffectSource.mRemainingTime = remainingTime; newEffectSource.mRemainingTime = remainingTime;
newEffectSource.mSource = sourceName; newEffectSource.mSource = sourceName;

@ -103,7 +103,7 @@ namespace MWGui
&& item.getClass().canBeEquipped(item, mActor).first == 0) && item.getClass().canBeEquipped(item, mActor).first == 0)
continue; continue;
int castCost = MWMechanics::getEffectiveEnchantmentCastCost(enchant->mData.mCost, mActor); int castCost = MWMechanics::getEffectiveEnchantmentCastCost(static_cast<float>(enchant->mData.mCost), mActor);
std::string cost = boost::lexical_cast<std::string>(castCost); std::string cost = boost::lexical_cast<std::string>(castCost);
int currentCharge = int(item.getCellRef().getEnchantmentCharge()); int currentCharge = int(item.getCellRef().getEnchantmentCharge());

@ -236,10 +236,10 @@ namespace MWGui
void SpellView::onMouseWheel(MyGUI::Widget* _sender, int _rel) void SpellView::onMouseWheel(MyGUI::Widget* _sender, int _rel)
{ {
if (mScrollView->getViewOffset().top + _rel*0.3 > 0) if (mScrollView->getViewOffset().top + _rel*0.3f > 0)
mScrollView->setViewOffset(MyGUI::IntPoint(0, 0)); mScrollView->setViewOffset(MyGUI::IntPoint(0, 0));
else else
mScrollView->setViewOffset(MyGUI::IntPoint(0, mScrollView->getViewOffset().top + _rel*0.3)); mScrollView->setViewOffset(MyGUI::IntPoint(0, static_cast<int>(mScrollView->getViewOffset().top + _rel*0.3f)));
} }
} }

@ -80,13 +80,13 @@ namespace MWGui
if (mSkillView->getViewOffset().top + _rel*0.3 > 0) if (mSkillView->getViewOffset().top + _rel*0.3 > 0)
mSkillView->setViewOffset(MyGUI::IntPoint(0, 0)); mSkillView->setViewOffset(MyGUI::IntPoint(0, 0));
else else
mSkillView->setViewOffset(MyGUI::IntPoint(0, mSkillView->getViewOffset().top + _rel*0.3)); mSkillView->setViewOffset(MyGUI::IntPoint(0, static_cast<int>(mSkillView->getViewOffset().top + _rel*0.3)));
} }
void StatsWindow::onWindowResize(MyGUI::Window* window) void StatsWindow::onWindowResize(MyGUI::Window* window)
{ {
mLeftPane->setCoord( MyGUI::IntCoord(0, 0, 0.44*window->getSize().width, window->getSize().height) ); mLeftPane->setCoord( MyGUI::IntCoord(0, 0, static_cast<int>(0.44*window->getSize().width), window->getSize().height) );
mRightPane->setCoord( MyGUI::IntCoord(0.44*window->getSize().width, 0, 0.56*window->getSize().width, window->getSize().height) ); mRightPane->setCoord( MyGUI::IntCoord(static_cast<int>(0.44*window->getSize().width), 0, static_cast<int>(0.56*window->getSize().width), window->getSize().height) );
// Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden // Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden
mSkillView->setVisibleVScroll(false); mSkillView->setVisibleVScroll(false);
mSkillView->setCanvasSize (mSkillView->getWidth(), mSkillView->getCanvasSize().height); mSkillView->setCanvasSize (mSkillView->getWidth(), mSkillView->getCanvasSize().height);

@ -308,7 +308,7 @@ namespace MWGui
void ToolTips::position(MyGUI::IntPoint& position, MyGUI::IntSize size, MyGUI::IntSize viewportSize) void ToolTips::position(MyGUI::IntPoint& position, MyGUI::IntSize size, MyGUI::IntSize viewportSize)
{ {
position += MyGUI::IntPoint(0, 32) position += MyGUI::IntPoint(0, 32)
- MyGUI::IntPoint((MyGUI::InputManager::getInstance().getMousePosition().left / float(viewportSize.width) * size.width), 0); - MyGUI::IntPoint(static_cast<int>(MyGUI::InputManager::getInstance().getMousePosition().left / float(viewportSize.width) * size.width), 0);
if ((position.left + size.width) > viewportSize.width) if ((position.left + size.width) > viewportSize.width)
{ {
@ -413,7 +413,7 @@ namespace MWGui
{ {
MyGUI::ImageBox* icon = mDynamicToolTipBox->createWidget<MyGUI::ImageBox>("MarkerButton", MyGUI::ImageBox* icon = mDynamicToolTipBox->createWidget<MyGUI::ImageBox>("MarkerButton",
MyGUI::IntCoord(padding.left, totalSize.height+padding.top, 8, 8), MyGUI::Align::Default); MyGUI::IntCoord(padding.left, totalSize.height+padding.top, 8, 8), MyGUI::Align::Default);
icon->setColour(MyGUI::Colour(1.0,0.3,0.3)); icon->setColour(MyGUI::Colour(1.0f, 0.3f, 0.3f));
MyGUI::EditBox* edit = mDynamicToolTipBox->createWidget<MyGUI::EditBox>("SandText", MyGUI::EditBox* edit = mDynamicToolTipBox->createWidget<MyGUI::EditBox>("SandText",
MyGUI::IntCoord(padding.left+8+4, totalSize.height+padding.top, 300-padding.left-8-4, 300-totalSize.height), MyGUI::IntCoord(padding.left+8+4, totalSize.height+padding.top, 300-padding.left-8-4, 300-totalSize.height),
MyGUI::Align::Default); MyGUI::Align::Default);

@ -34,18 +34,21 @@ namespace
int getEffectiveValue (MWWorld::Ptr item, int count) int getEffectiveValue (MWWorld::Ptr item, int count)
{ {
int price = item.getClass().getValue(item) * count; float price = item.getClass().getValue(item);
if (item.getClass().hasItemHealth(item)) if (item.getClass().hasItemHealth(item))
price *= (static_cast<float>(item.getClass().getItemHealth(item)) / item.getClass().getItemMaxHealth(item)); {
return price; price *= item.getClass().getItemHealth(item);
price /= item.getClass().getItemMaxHealth(item);
}
return static_cast<int>(price * count);
} }
} }
namespace MWGui namespace MWGui
{ {
const float TradeWindow::sBalanceChangeInitialPause = 0.5; const float TradeWindow::sBalanceChangeInitialPause = 0.5f;
const float TradeWindow::sBalanceChangeInterval = 0.1; const float TradeWindow::sBalanceChangeInterval = 0.1f;
TradeWindow::TradeWindow() TradeWindow::TradeWindow()
: WindowBase("openmw_trade_window.layout") : WindowBase("openmw_trade_window.layout")
@ -340,16 +343,16 @@ namespace MWGui
else else
d = int(100 * (b - a) / a); d = int(100 * (b - a) / a);
float clampedDisposition = std::max<int>(0,std::min<int>(int(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr) float clampedDisposition = std::max<float>(0,std::min<float>(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr)
+ MWBase::Environment::get().getDialogueManager()->getTemporaryDispositionChange()),100)); + MWBase::Environment::get().getDialogueManager()->getTemporaryDispositionChange(),100));
const MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr); const MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr);
const MWMechanics::CreatureStats &playerStats = player.getClass().getCreatureStats(player); const MWMechanics::CreatureStats &playerStats = player.getClass().getCreatureStats(player);
float a1 = player.getClass().getSkill(player, ESM::Skill::Mercantile); float a1 = static_cast<float>(player.getClass().getSkill(player, ESM::Skill::Mercantile));
float b1 = 0.1f * playerStats.getAttribute(ESM::Attribute::Luck).getModified(); float b1 = 0.1f * playerStats.getAttribute(ESM::Attribute::Luck).getModified();
float c1 = 0.2f * playerStats.getAttribute(ESM::Attribute::Personality).getModified(); float c1 = 0.2f * playerStats.getAttribute(ESM::Attribute::Personality).getModified();
float d1 = mPtr.getClass().getSkill(mPtr, ESM::Skill::Mercantile); float d1 = static_cast<float>(mPtr.getClass().getSkill(mPtr, ESM::Skill::Mercantile));
float e1 = 0.1f * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(); float e1 = 0.1f * sellerStats.getAttribute(ESM::Attribute::Luck).getModified();
float f1 = 0.2f * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(); float f1 = 0.2f * sellerStats.getAttribute(ESM::Attribute::Personality).getModified();
@ -379,9 +382,9 @@ namespace MWGui
int finalPrice = std::abs(mCurrentBalance); int finalPrice = std::abs(mCurrentBalance);
int initialMerchantOffer = std::abs(mCurrentMerchantOffer); int initialMerchantOffer = std::abs(mCurrentMerchantOffer);
if (!buying && (finalPrice > initialMerchantOffer) && finalPrice > 0) if (!buying && (finalPrice > initialMerchantOffer) && finalPrice > 0)
skillGain = int(100 * (finalPrice - initialMerchantOffer) / float(finalPrice)); skillGain = floor(100 * (finalPrice - initialMerchantOffer) / float(finalPrice));
else if (buying && (finalPrice < initialMerchantOffer) && initialMerchantOffer > 0) else if (buying && (finalPrice < initialMerchantOffer) && initialMerchantOffer > 0)
skillGain = int(100 * (initialMerchantOffer - finalPrice) / float(initialMerchantOffer)); skillGain = floor(100 * (initialMerchantOffer - finalPrice) / float(initialMerchantOffer));
player.getClass().skillUsageSucceeded(player, ESM::Skill::Mercantile, 0, skillGain); player.getClass().skillUsageSucceeded(player, ESM::Skill::Mercantile, 0, skillGain);
} }

@ -40,7 +40,7 @@ namespace MWGui
TrainingWindow::TrainingWindow() TrainingWindow::TrainingWindow()
: WindowBase("openmw_trainingwindow.layout") : WindowBase("openmw_trainingwindow.layout")
, mFadeTimeRemaining(0) , mFadeTimeRemaining(0)
, mTimeAdvancer(0.05) , mTimeAdvancer(0.05f)
{ {
getWidget(mTrainingOptions, "TrainingOptions"); getWidget(mTrainingOptions, "TrainingOptions");
getWidget(mCancelButton, "CancelButton"); getWidget(mCancelButton, "CancelButton");

@ -66,13 +66,13 @@ namespace MWGui
if(interior) if(interior)
{ {
price = gmst.find("fMagesGuildTravel")->getFloat(); price = gmst.find("fMagesGuildTravel")->getInt();
} }
else else
{ {
ESM::Position PlayerPos = player.getRefData().getPosition(); ESM::Position PlayerPos = player.getRefData().getPosition();
float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) ); float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) );
price = d/gmst.find("fTravelMult")->getFloat(); price = static_cast<int>(d / gmst.find("fTravelMult")->getFloat());
} }
price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true); price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true);
@ -209,10 +209,10 @@ namespace MWGui
void TravelWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel) void TravelWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel)
{ {
if (mDestinationsView->getViewOffset().top + _rel*0.3 > 0) if (mDestinationsView->getViewOffset().top + _rel*0.3f > 0)
mDestinationsView->setViewOffset(MyGUI::IntPoint(0, 0)); mDestinationsView->setViewOffset(MyGUI::IntPoint(0, 0));
else else
mDestinationsView->setViewOffset(MyGUI::IntPoint(0, mDestinationsView->getViewOffset().top + _rel*0.3)); mDestinationsView->setViewOffset(MyGUI::IntPoint(0, static_cast<int>(mDestinationsView->getViewOffset().top + _rel*0.3f)));
} }
} }

@ -58,8 +58,8 @@ void VideoWidget::autoResize(bool stretch)
{ {
double imageaspect = static_cast<double>(getVideoWidth())/getVideoHeight(); double imageaspect = static_cast<double>(getVideoWidth())/getVideoHeight();
int leftPadding = std::max(0.0, (screenSize.width - screenSize.height * imageaspect) / 2); int leftPadding = std::max(0, static_cast<int>(screenSize.width - screenSize.height * imageaspect) / 2);
int topPadding = std::max(0.0, (screenSize.height - screenSize.width / imageaspect) / 2); int topPadding = std::max(0, static_cast<int>(screenSize.height - screenSize.width / imageaspect) / 2);
setCoord(leftPadding, topPadding, setCoord(leftPadding, topPadding,
screenSize.width - leftPadding*2, screenSize.height - topPadding*2); screenSize.width - leftPadding*2, screenSize.height - topPadding*2);

@ -49,7 +49,7 @@ namespace MWGui
WaitDialog::WaitDialog() WaitDialog::WaitDialog()
: WindowBase("openmw_wait_dialog.layout") : WindowBase("openmw_wait_dialog.layout")
, mProgressBar() , mProgressBar()
, mTimeAdvancer(0.05) , mTimeAdvancer(0.05f)
, mSleeping(false) , mSleeping(false)
, mHours(1) , mHours(1)
, mManualHours(1) , mManualHours(1)
@ -104,7 +104,7 @@ namespace MWGui
mHourSlider->setScrollPosition (0); mHourSlider->setScrollPosition (0);
std::string month = MWBase::Environment::get().getWorld ()->getMonthName(); std::string month = MWBase::Environment::get().getWorld ()->getMonthName();
int hour = MWBase::Environment::get().getWorld ()->getTimeStamp ().getHour (); int hour = static_cast<int>(MWBase::Environment::get().getWorld()->getTimeStamp().getHour());
bool pm = hour >= 12; bool pm = hour >= 12;
if (hour >= 13) hour -= 12; if (hour >= 13) hour -= 12;
if (hour == 0) hour = 12; if (hour == 0) hour = 12;
@ -135,8 +135,8 @@ namespace MWGui
MWBase::Environment::get().getStateManager()->quickSave("Autosave"); MWBase::Environment::get().getStateManager()->quickSave("Autosave");
MWBase::World* world = MWBase::Environment::get().getWorld(); MWBase::World* world = MWBase::Environment::get().getWorld();
MWBase::Environment::get().getWindowManager()->fadeScreenOut(0.2); MWBase::Environment::get().getWindowManager()->fadeScreenOut(0.2f);
mFadeTimeRemaining = 0.4; mFadeTimeRemaining = 0.4f;
setVisible(false); setVisible(false);
mHours = hoursToWait; mHours = hoursToWait;
@ -153,7 +153,7 @@ namespace MWGui
if (!region->mSleepList.empty()) if (!region->mSleepList.empty())
{ {
float fSleepRandMod = world->getStore().get<ESM::GameSetting>().find("fSleepRandMod")->getFloat(); float fSleepRandMod = world->getStore().get<ESM::GameSetting>().find("fSleepRandMod")->getFloat();
int x = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * hoursToWait; // [0, hoursRested] int x = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * hoursToWait); // [0, hoursRested]
float y = fSleepRandMod * hoursToWait; float y = fSleepRandMod * hoursToWait;
if (x > y) if (x > y)
{ {
@ -251,7 +251,7 @@ namespace MWGui
void WaitDialog::stopWaiting () void WaitDialog::stopWaiting ()
{ {
MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.2); MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.2f);
mProgressBar.setVisible (false); mProgressBar.setVisible (false);
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Rest); MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Rest);
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_RestBed); MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_RestBed);

@ -540,8 +540,8 @@ namespace MWGui
MWScrollBar::MWScrollBar() MWScrollBar::MWScrollBar()
: mEnableRepeat(true) : mEnableRepeat(true)
, mRepeatTriggerTime(0.5) , mRepeatTriggerTime(0.5f)
, mRepeatStepTime(0.1) , mRepeatStepTime(0.1f)
, mIsIncreasing(true) , mIsIncreasing(true)
{ {
} }

@ -1103,10 +1103,10 @@ namespace MWGui
for (std::map<MyGUI::Window*, std::string>::iterator it = mTrackedWindows.begin(); it != mTrackedWindows.end(); ++it) for (std::map<MyGUI::Window*, std::string>::iterator it = mTrackedWindows.begin(); it != mTrackedWindows.end(); ++it)
{ {
MyGUI::IntPoint pos (Settings::Manager::getFloat(it->second + " x", "Windows") * x, MyGUI::IntPoint pos(static_cast<int>(Settings::Manager::getFloat(it->second + " x", "Windows") * x),
Settings::Manager::getFloat(it->second+ " y", "Windows") * y); static_cast<int>( Settings::Manager::getFloat(it->second+ " y", "Windows") * y));
MyGUI::IntSize size (Settings::Manager::getFloat(it->second + " w", "Windows") * x, MyGUI::IntSize size(static_cast<int>(Settings::Manager::getFloat(it->second + " w", "Windows") * x),
Settings::Manager::getFloat(it->second + " h", "Windows") * y); static_cast<int>(Settings::Manager::getFloat(it->second + " h", "Windows") * y));
it->first->setPosition(pos); it->first->setPosition(pos);
it->first->setSize(size); it->first->setSize(size);
} }
@ -1221,7 +1221,7 @@ namespace MWGui
.find(item.getClass().getEnchantment(item)); .find(item.getClass().getEnchantment(item));
int chargePercent = (item.getCellRef().getEnchantmentCharge() == -1) ? 100 int chargePercent = (item.getCellRef().getEnchantmentCharge() == -1) ? 100
: (item.getCellRef().getEnchantmentCharge() / static_cast<float>(ench->mData.mCharge) * 100); : static_cast<int>(item.getCellRef().getEnchantmentCharge() / static_cast<float>(ench->mData.mCharge) * 100);
mHud->setSelectedEnchantItem(item, chargePercent); mHud->setSelectedEnchantItem(item, chargePercent);
mSpellWindow->setTitle(item.getClass().getName(item)); mSpellWindow->setTitle(item.getClass().getName(item));
} }
@ -1229,7 +1229,7 @@ namespace MWGui
void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item) void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item)
{ {
int durabilityPercent = int durabilityPercent =
(item.getClass().getItemHealth(item) / static_cast<float>(item.getClass().getItemMaxHealth(item)) * 100); static_cast<int>(item.getClass().getItemHealth(item) / static_cast<float>(item.getClass().getItemMaxHealth(item)) * 100);
mHud->setSelectedWeapon(item, durabilityPercent); mHud->setSelectedWeapon(item, durabilityPercent);
mInventoryWindow->setTitle(item.getClass().getName(item)); mInventoryWindow->setTitle(item.getClass().getName(item));
} }
@ -1262,8 +1262,8 @@ namespace MWGui
void WindowManager::getMousePosition(float &x, float &y) void WindowManager::getMousePosition(float &x, float &y)
{ {
const MyGUI::IntPoint& pos = MyGUI::InputManager::getInstance().getMousePosition(); const MyGUI::IntPoint& pos = MyGUI::InputManager::getInstance().getMousePosition();
x = pos.left; x = static_cast<float>(pos.left);
y = pos.top; y = static_cast<float>(pos.top);
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize(); const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
x /= viewSize.width; x /= viewSize.width;
y /= viewSize.height; y /= viewSize.height;
@ -1569,10 +1569,10 @@ namespace MWGui
void WindowManager::trackWindow(OEngine::GUI::Layout *layout, const std::string &name) void WindowManager::trackWindow(OEngine::GUI::Layout *layout, const std::string &name)
{ {
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize(); MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
MyGUI::IntPoint pos (Settings::Manager::getFloat(name + " x", "Windows") * viewSize.width, MyGUI::IntPoint pos(static_cast<int>(Settings::Manager::getFloat(name + " x", "Windows") * viewSize.width),
Settings::Manager::getFloat(name + " y", "Windows") * viewSize.height); static_cast<int>(Settings::Manager::getFloat(name + " y", "Windows") * viewSize.height));
MyGUI::IntSize size (Settings::Manager::getFloat(name + " w", "Windows") * viewSize.width, MyGUI::IntSize size (static_cast<int>(Settings::Manager::getFloat(name + " w", "Windows") * viewSize.width),
Settings::Manager::getFloat(name + " h", "Windows") * viewSize.height); static_cast<int>(Settings::Manager::getFloat(name + " h", "Windows") * viewSize.height));
layout->mMainWidget->setPosition(pos); layout->mMainWidget->setPosition(pos);
layout->mMainWidget->setSize(size); layout->mMainWidget->setSize(size);

@ -377,7 +377,7 @@ namespace MWInput
//cursor is //cursor is
if( !is_relative && was_relative != is_relative ) if( !is_relative && was_relative != is_relative )
{ {
mInputManager->warpMouse(mMouseX, mMouseY); mInputManager->warpMouse(static_cast<int>(mMouseX), static_cast<int>(mMouseY));
} }
} }
@ -415,13 +415,13 @@ namespace MWInput
// game mode does not move the position of the GUI cursor // game mode does not move the position of the GUI cursor
mMouseX += xAxis * dt * 1500.0f; mMouseX += xAxis * dt * 1500.0f;
mMouseY += yAxis * dt * 1500.0f; mMouseY += yAxis * dt * 1500.0f;
mMouseWheel -= zAxis * dt * 1500.0f; mMouseWheel -= static_cast<int>(zAxis * dt * 1500.0f);
mMouseX = std::max(0.f, std::min(mMouseX, float(viewSize.width))); mMouseX = std::max(0.f, std::min(mMouseX, float(viewSize.width)));
mMouseY = std::max(0.f, std::min(mMouseY, float(viewSize.height))); mMouseY = std::max(0.f, std::min(mMouseY, float(viewSize.height)));
MyGUI::InputManager::getInstance().injectMouseMove( mMouseX, mMouseY, mMouseWheel); MyGUI::InputManager::getInstance().injectMouseMove(static_cast<int>(mMouseX), static_cast<int>(mMouseY), mMouseWheel);
mInputManager->warpMouse(mMouseX, mMouseY); mInputManager->warpMouse(static_cast<int>(mMouseX), static_cast<int>(mMouseY));
} }
if (mMouseLookEnabled) if (mMouseLookEnabled)
{ {
@ -703,7 +703,7 @@ namespace MWInput
if (id == SDL_BUTTON_LEFT || id == SDL_BUTTON_RIGHT) // MyGUI only uses these mouse events if (id == SDL_BUTTON_LEFT || id == SDL_BUTTON_RIGHT) // MyGUI only uses these mouse events
{ {
guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode(); guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode();
guiMode = MyGUI::InputManager::getInstance().injectMousePress(mMouseX, mMouseY, sdlButtonToMyGUI(id)) && guiMode; guiMode = MyGUI::InputManager::getInstance().injectMousePress(static_cast<int>(mMouseX), static_cast<int>(mMouseY), sdlButtonToMyGUI(id)) && guiMode;
if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0) if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0)
{ {
MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false); MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false);
@ -730,7 +730,7 @@ namespace MWInput
mInputBinder->mouseReleased (arg, id); mInputBinder->mouseReleased (arg, id);
} else { } else {
bool guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode(); bool guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode();
guiMode = MyGUI::InputManager::getInstance().injectMouseRelease(mMouseX, mMouseY, sdlButtonToMyGUI(id)) && guiMode; guiMode = MyGUI::InputManager::getInstance().injectMouseRelease(static_cast<int>(mMouseX), static_cast<int>(mMouseY), sdlButtonToMyGUI(id)) && guiMode;
if(mInputBinder->detectingBindingState()) return; // don't allow same mouseup to bind as initiated bind if(mInputBinder->detectingBindingState()) return; // don't allow same mouseup to bind as initiated bind
@ -752,8 +752,8 @@ namespace MWInput
// We keep track of our own mouse position, so that moving the mouse while in // We keep track of our own mouse position, so that moving the mouse while in
// game mode does not move the position of the GUI cursor // game mode does not move the position of the GUI cursor
mMouseX = arg.x; mMouseX = static_cast<float>(arg.x);
mMouseY = arg.y; mMouseY = static_cast<float>(arg.y);
mMouseX = std::max(0.f, std::min(mMouseX, float(viewSize.width))); mMouseX = std::max(0.f, std::min(mMouseX, float(viewSize.width)));
mMouseY = std::max(0.f, std::min(mMouseY, float(viewSize.height))); mMouseY = std::max(0.f, std::min(mMouseY, float(viewSize.height)));
@ -767,8 +767,8 @@ namespace MWInput
{ {
resetIdleTime(); resetIdleTime();
double x = arg.xrel * mCameraSensitivity * (1.0f/256.f); float x = arg.xrel * mCameraSensitivity * (1.0f/256.f);
double y = arg.yrel * mCameraSensitivity * (1.0f/256.f) * (mInvertY ? -1 : 1) * mCameraYMultiplier; float y = arg.yrel * mCameraSensitivity * (1.0f/256.f) * (mInvertY ? -1 : 1) * mCameraYMultiplier;
float rot[3]; float rot[3];
rot[0] = -y; rot[0] = -y;
@ -784,10 +784,10 @@ namespace MWInput
if (arg.zrel && mControlSwitch["playerviewswitch"] && mControlSwitch["playercontrols"]) //Check to make sure you are allowed to zoomout and there is a change if (arg.zrel && mControlSwitch["playerviewswitch"] && mControlSwitch["playercontrols"]) //Check to make sure you are allowed to zoomout and there is a change
{ {
MWBase::Environment::get().getWorld()->changeVanityModeScale(arg.zrel); MWBase::Environment::get().getWorld()->changeVanityModeScale(static_cast<float>(arg.zrel));
if (Settings::Manager::getBool("allow third person zoom", "Input")) if (Settings::Manager::getBool("allow third person zoom", "Input"))
MWBase::Environment::get().getWorld()->setCameraDistance(arg.zrel, true, true); MWBase::Environment::get().getWorld()->setCameraDistance(static_cast<float>(arg.zrel), true, true);
} }
} }
} }
@ -802,7 +802,8 @@ namespace MWInput
guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode(); guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode();
if(!mInputBinder->detectingBindingState()) if(!mInputBinder->detectingBindingState())
{ {
guiMode = MyGUI::InputManager::getInstance().injectMousePress(mMouseX, mMouseY, sdlButtonToMyGUI((arg.button == SDL_CONTROLLER_BUTTON_B) ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT)) && guiMode; guiMode = MyGUI::InputManager::getInstance().injectMousePress(static_cast<int>(mMouseX), static_cast<int>(mMouseY),
sdlButtonToMyGUI((arg.button == SDL_CONTROLLER_BUTTON_B) ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT)) && guiMode;
if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0) if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0)
{ {
MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false); MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false);
@ -833,7 +834,7 @@ namespace MWInput
else if(arg.button == SDL_CONTROLLER_BUTTON_A || arg.button == SDL_CONTROLLER_BUTTON_B) else if(arg.button == SDL_CONTROLLER_BUTTON_A || arg.button == SDL_CONTROLLER_BUTTON_B)
{ {
bool guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode(); bool guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode();
guiMode = MyGUI::InputManager::getInstance().injectMouseRelease(mMouseX, mMouseY, sdlButtonToMyGUI((arg.button == SDL_CONTROLLER_BUTTON_B) ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT)) && guiMode; guiMode = MyGUI::InputManager::getInstance().injectMouseRelease(static_cast<int>(mMouseX), static_cast<int>(mMouseY), sdlButtonToMyGUI((arg.button == SDL_CONTROLLER_BUTTON_B) ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT)) && guiMode;
if(mInputBinder->detectingBindingState()) return; // don't allow same mouseup to bind as initiated bind if(mInputBinder->detectingBindingState()) return; // don't allow same mouseup to bind as initiated bind
@ -1236,10 +1237,7 @@ namespace MWInput
bool controlExists = mInputBinder->getChannel(i)->getControlsCount () != 0; bool controlExists = mInputBinder->getChannel(i)->getControlsCount () != 0;
if (!controlExists) if (!controlExists)
{ {
int inital; float inital = (defaultButtonBindings.find(i) != defaultButtonBindings.end()) ? 0.0f : 0.5f;
if (defaultButtonBindings.find(i) != defaultButtonBindings.end())
inital = 0.0f;
else inital = 0.5f;
control = new ICS::Control(boost::lexical_cast<std::string>(i), false, true, inital, ICS::ICS_MAX, ICS::ICS_MAX); control = new ICS::Control(boost::lexical_cast<std::string>(i), false, true, inital, ICS::ICS_MAX, ICS::ICS_MAX);
mInputBinder->addControl(control); mInputBinder->addControl(control);
control->attachChannel(mInputBinder->getChannel(i), ICS::Channel::DIRECT); control->attachChannel(mInputBinder->getChannel(i), ICS::Channel::DIRECT);

@ -37,19 +37,19 @@ namespace MWMechanics
float resist = 0.f; float resist = 0.f;
if (spells.hasCorprusEffect(spell)) if (spells.hasCorprusEffect(spell))
resist = 1.f - 0.01 * (actorEffects.get(ESM::MagicEffect::ResistCorprusDisease).getMagnitude() resist = 1.f - 0.01f * (actorEffects.get(ESM::MagicEffect::ResistCorprusDisease).getMagnitude()
- actorEffects.get(ESM::MagicEffect::WeaknessToCorprusDisease).getMagnitude()); - actorEffects.get(ESM::MagicEffect::WeaknessToCorprusDisease).getMagnitude());
else if (spell->mData.mType == ESM::Spell::ST_Disease) else if (spell->mData.mType == ESM::Spell::ST_Disease)
resist = 1.f - 0.01 * (actorEffects.get(ESM::MagicEffect::ResistCommonDisease).getMagnitude() resist = 1.f - 0.01f * (actorEffects.get(ESM::MagicEffect::ResistCommonDisease).getMagnitude()
- actorEffects.get(ESM::MagicEffect::WeaknessToCommonDisease).getMagnitude()); - actorEffects.get(ESM::MagicEffect::WeaknessToCommonDisease).getMagnitude());
else if (spell->mData.mType == ESM::Spell::ST_Blight) else if (spell->mData.mType == ESM::Spell::ST_Blight)
resist = 1.f - 0.01 * (actorEffects.get(ESM::MagicEffect::ResistBlightDisease).getMagnitude() resist = 1.f - 0.01f * (actorEffects.get(ESM::MagicEffect::ResistBlightDisease).getMagnitude()
- actorEffects.get(ESM::MagicEffect::WeaknessToBlightDisease).getMagnitude()); - actorEffects.get(ESM::MagicEffect::WeaknessToBlightDisease).getMagnitude());
else else
continue; continue;
int x = fDiseaseXferChance * 100 * resist; int x = static_cast<int>(fDiseaseXferChance * 100 * resist);
float roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 10000; // [0, 9999] float roll = static_cast<float>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 10000); // [0, 9999]
if (roll < x) if (roll < x)
{ {

@ -22,7 +22,7 @@ namespace MWMechanics
failChance += levItem->mChanceNone; failChance += levItem->mChanceNone;
int random = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99] int random = static_cast<int>(static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 100)); // [0, 99]
if (random < failChance) if (random < failChance)
return std::string(); return std::string();

@ -556,7 +556,7 @@ namespace MWMechanics
int MechanicsManager::getDerivedDisposition(const MWWorld::Ptr& ptr) int MechanicsManager::getDerivedDisposition(const MWWorld::Ptr& ptr)
{ {
const MWMechanics::NpcStats& npcSkill = ptr.getClass().getNpcStats(ptr); const MWMechanics::NpcStats& npcSkill = ptr.getClass().getNpcStats(ptr);
float x = npcSkill.getBaseDisposition(); float x = static_cast<float>(npcSkill.getBaseDisposition());
MWWorld::LiveCellRef<ESM::NPC>* npc = ptr.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC>* npc = ptr.get<ESM::NPC>();
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
@ -583,7 +583,7 @@ namespace MWMechanics
if (!playerStats.getExpelled(npcFaction)) if (!playerStats.getExpelled(npcFaction))
{ {
// faction reaction towards itself. yes, that exists // faction reaction towards itself. yes, that exists
reaction = MWBase::Environment::get().getDialogueManager()->getFactionReaction(npcFaction, npcFaction); reaction = static_cast<float>(MWBase::Environment::get().getDialogueManager()->getFactionReaction(npcFaction, npcFaction));
rank = playerStats.getFactionRanks().find(npcFaction)->second; rank = playerStats.getFactionRanks().find(npcFaction)->second;
} }
@ -597,7 +597,7 @@ namespace MWMechanics
int itReaction = MWBase::Environment::get().getDialogueManager()->getFactionReaction(npcFaction, itFaction); int itReaction = MWBase::Environment::get().getDialogueManager()->getFactionReaction(npcFaction, itFaction);
if (playerFactionIt == playerStats.getFactionRanks().begin() || itReaction < reaction) if (playerFactionIt == playerStats.getFactionRanks().begin() || itReaction < reaction)
reaction = itReaction; reaction = static_cast<float>(itReaction);
} }
} }
else else
@ -643,17 +643,17 @@ namespace MWMechanics
// otherwise one would get different prices when exiting and re-entering the dialogue window... // otherwise one would get different prices when exiting and re-entering the dialogue window...
int clampedDisposition = std::max(0, std::min(getDerivedDisposition(ptr) int clampedDisposition = std::max(0, std::min(getDerivedDisposition(ptr)
+ MWBase::Environment::get().getDialogueManager()->getTemporaryDispositionChange(),100)); + MWBase::Environment::get().getDialogueManager()->getTemporaryDispositionChange(),100));
float a = std::min(playerStats.getSkill(ESM::Skill::Mercantile).getModified(), 100); float a = static_cast<float>(std::min(playerStats.getSkill(ESM::Skill::Mercantile).getModified(), 100));
float b = std::min(0.1f * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f); float b = std::min(0.1f * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f);
float c = std::min(0.2f * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f); float c = std::min(0.2f * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f);
float d = std::min(sellerStats.getSkill(ESM::Skill::Mercantile).getModified(), 100); float d = static_cast<float>(std::min(sellerStats.getSkill(ESM::Skill::Mercantile).getModified(), 100));
float e = std::min(0.1f * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f); float e = std::min(0.1f * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f);
float f = std::min(0.2f * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f); float f = std::min(0.2f * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f);
float pcTerm = (clampedDisposition - 50 + a + b + c) * playerStats.getFatigueTerm(); float pcTerm = (clampedDisposition - 50 + a + b + c) * playerStats.getFatigueTerm();
float npcTerm = (d + e + f) * sellerStats.getFatigueTerm(); float npcTerm = (d + e + f) * sellerStats.getFatigueTerm();
float buyTerm = 0.01 * (100 - 0.5 * (pcTerm - npcTerm)); float buyTerm = 0.01f * (100 - 0.5f * (pcTerm - npcTerm));
float sellTerm = 0.01 * (50 - 0.5 * (npcTerm - pcTerm)); float sellTerm = 0.01f * (50 - 0.5f * (npcTerm - pcTerm));
float x; float x;
if(buying) x = buyTerm; if(buying) x = buyTerm;
@ -704,7 +704,7 @@ namespace MWMechanics
int currentDisposition = std::min(100, std::max(0, int(getDerivedDisposition(npc) + currentTemporaryDispositionDelta))); int currentDisposition = std::min(100, std::max(0, int(getDerivedDisposition(npc) + currentTemporaryDispositionDelta)));
float d = 1 - 0.02 * abs(currentDisposition - 50); float d = 1 - 0.02f * abs(currentDisposition - 50);
float target1 = d * (playerRating1 - npcRating1 + 50); float target1 = d * (playerRating1 - npcRating1 + 50);
float target2 = d * (playerRating2 - npcRating2 + 50); float target2 = d * (playerRating2 - npcRating2 + 50);
@ -715,8 +715,8 @@ namespace MWMechanics
float target3 = d * (playerRating3 - npcRating3 + 50) + bribeMod; float target3 = d * (playerRating3 - npcRating3 + 50) + bribeMod;
float iPerMinChance = gmst.find("iPerMinChance")->getInt(); float iPerMinChance = floor(gmst.find("iPerMinChance")->getFloat());
float iPerMinChange = gmst.find("iPerMinChange")->getInt(); float iPerMinChange = floor(gmst.find("iPerMinChange")->getFloat());
float fPerDieRollMult = gmst.find("fPerDieRollMult")->getFloat(); float fPerDieRollMult = gmst.find("fPerDieRollMult")->getFloat();
float fPerTempMult = gmst.find("fPerTempMult")->getFloat(); float fPerTempMult = gmst.find("fPerTempMult")->getFloat();
@ -729,7 +729,7 @@ namespace MWMechanics
{ {
target1 = std::max(iPerMinChance, target1); target1 = std::max(iPerMinChance, target1);
success = (roll <= target1); success = (roll <= target1);
float c = int(fPerDieRollMult * (target1 - roll)); float c = floor(fPerDieRollMult * (target1 - roll));
x = success ? std::max(iPerMinChange, c) : c; x = success ? std::max(iPerMinChange, c) : c;
} }
else if (type == PT_Intimidate) else if (type == PT_Intimidate)
@ -740,13 +740,13 @@ namespace MWMechanics
float r; float r;
if (roll != target2) if (roll != target2)
r = int(target2 - roll); r = floor(target2 - roll);
else else
r = 1; r = 1;
if (roll <= target2) if (roll <= target2)
{ {
float s = int(r * fPerDieRollMult * fPerTempMult); float s = floor(r * fPerDieRollMult * fPerTempMult);
int flee = npcStats.getAiSetting(MWMechanics::CreatureStats::AI_Flee).getBase(); int flee = npcStats.getAiSetting(MWMechanics::CreatureStats::AI_Flee).getBase();
int fight = npcStats.getAiSetting(MWMechanics::CreatureStats::AI_Fight).getBase(); int fight = npcStats.getAiSetting(MWMechanics::CreatureStats::AI_Fight).getBase();
@ -756,7 +756,7 @@ namespace MWMechanics
std::max(0, std::min(100, fight + int(std::min(-iPerMinChange, -s))))); std::max(0, std::min(100, fight + int(std::min(-iPerMinChange, -s)))));
} }
float c = -std::abs(int(r * fPerDieRollMult)); float c = -std::abs(floor(r * fPerDieRollMult));
if (success) if (success)
{ {
if (std::abs(c) < iPerMinChange) if (std::abs(c) < iPerMinChange)
@ -766,13 +766,13 @@ namespace MWMechanics
} }
else else
{ {
x = -int(c * fPerTempMult); x = -floor(c * fPerTempMult);
y = c; y = c;
} }
} }
else else
{ {
x = int(c * fPerTempMult); x = floor(c * fPerTempMult);
y = c; y = c;
} }
} }
@ -781,7 +781,7 @@ namespace MWMechanics
target1 = std::max(iPerMinChance, target1); target1 = std::max(iPerMinChance, target1);
success = (roll <= target1); success = (roll <= target1);
float c = std::abs(int(target1 - roll)); float c = std::abs(floor(target1 - roll));
if (success) if (success)
{ {
@ -793,7 +793,7 @@ namespace MWMechanics
npcStats.setAiSetting (CreatureStats::AI_Fight, npcStats.setAiSetting (CreatureStats::AI_Fight,
std::max(0, std::min(100, fight + std::max(int(iPerMinChange), int(s))))); std::max(0, std::min(100, fight + std::max(int(iPerMinChange), int(s)))));
} }
x = int(-c * fPerDieRollMult); x = floor(-c * fPerDieRollMult);
if (success && std::abs(x) < iPerMinChange) if (success && std::abs(x) < iPerMinChange)
x = -iPerMinChange; x = -iPerMinChange;
@ -802,7 +802,7 @@ namespace MWMechanics
{ {
target3 = std::max(iPerMinChance, target3); target3 = std::max(iPerMinChance, target3);
success = (roll <= target3); success = (roll <= target3);
float c = int((target3 - roll) * fPerDieRollMult); float c = floor((target3 - roll) * fPerDieRollMult);
x = success ? std::max(iPerMinChange, c) : c; x = success ? std::max(iPerMinChange, c) : c;
} }
@ -812,11 +812,11 @@ namespace MWMechanics
float cappedDispositionChange = tempChange; float cappedDispositionChange = tempChange;
if (currentDisposition + tempChange > 100.f) if (currentDisposition + tempChange > 100.f)
cappedDispositionChange = 100 - currentDisposition; cappedDispositionChange = static_cast<float>(100 - currentDisposition);
if (currentDisposition + tempChange < 0.f) if (currentDisposition + tempChange < 0.f)
cappedDispositionChange = -currentDisposition; cappedDispositionChange = static_cast<float>(-currentDisposition);
permChange = int(cappedDispositionChange / fPerTempMult); permChange = floor(cappedDispositionChange / fPerTempMult);
if (type == PT_Intimidate) if (type == PT_Intimidate)
{ {
permChange = success ? -int(cappedDispositionChange/ fPerTempMult) : y; permChange = success ? -int(cappedDispositionChange/ fPerTempMult) : y;
@ -1104,7 +1104,7 @@ namespace MWMechanics
if (type == OT_Trespassing || type == OT_SleepingInOwnedBed) if (type == OT_Trespassing || type == OT_SleepingInOwnedBed)
{ {
arg = store.find("iCrimeTresspass")->getInt(); arg = store.find("iCrimeTresspass")->getInt();
disp = dispVictim = store.find("iDispTresspass")->getInt(); disp = dispVictim = store.find("iDispTresspass")->getFloat();
} }
else if (type == OT_Pickpocket) else if (type == OT_Pickpocket)
{ {
@ -1114,18 +1114,18 @@ namespace MWMechanics
else if (type == OT_Assault) else if (type == OT_Assault)
{ {
arg = store.find("iCrimeAttack")->getInt(); arg = store.find("iCrimeAttack")->getInt();
disp = store.find("iDispAttackMod")->getInt(); disp = store.find("iDispAttackMod")->getFloat();
dispVictim = store.find("fDispAttacking")->getFloat(); dispVictim = store.find("fDispAttacking")->getFloat();
} }
else if (type == OT_Murder) else if (type == OT_Murder)
{ {
arg = store.find("iCrimeKilling")->getInt(); arg = store.find("iCrimeKilling")->getInt();
disp = dispVictim = store.find("iDispKilling")->getInt(); disp = dispVictim = store.find("iDispKilling")->getFloat();
} }
else if (type == OT_Theft) else if (type == OT_Theft)
{ {
disp = dispVictim = store.find("fDispStealing")->getFloat() * arg; disp = dispVictim = store.find("fDispStealing")->getFloat() * arg;
arg *= store.find("fCrimeStealing")->getFloat(); arg = static_cast<int>(arg * store.find("fCrimeStealing")->getFloat());
arg = std::max(1, arg); // Minimum bounty of 1, in case items with zero value are stolen arg = std::max(1, arg); // Minimum bounty of 1, in case items with zero value are stolen
} }
@ -1163,7 +1163,7 @@ namespace MWMechanics
else if (type == OT_Murder) else if (type == OT_Murder)
fight = fightVictim = esmStore.get<ESM::GameSetting>().find("iFightKilling")->getInt(); fight = fightVictim = esmStore.get<ESM::GameSetting>().find("iFightKilling")->getInt();
else if (type == OT_Theft) else if (type == OT_Theft)
fight = fightVictim = esmStore.get<ESM::GameSetting>().find("fFightStealing")->getFloat(); fight = fightVictim = esmStore.get<ESM::GameSetting>().find("fFightStealing")->getInt();
bool reported = false; bool reported = false;
@ -1197,21 +1197,21 @@ namespace MWMechanics
{ {
float dispTerm = (*it == victim) ? dispVictim : disp; float dispTerm = (*it == victim) ? dispVictim : disp;
float alarmTerm = 0.01 * it->getClass().getCreatureStats(*it).getAiSetting(CreatureStats::AI_Alarm).getBase(); float alarmTerm = 0.01f * it->getClass().getCreatureStats(*it).getAiSetting(CreatureStats::AI_Alarm).getBase();
if (type == OT_Pickpocket && alarmTerm <= 0) if (type == OT_Pickpocket && alarmTerm <= 0)
alarmTerm = 1.0; alarmTerm = 1.0;
if (*it != victim) if (*it != victim)
dispTerm *= alarmTerm; dispTerm *= alarmTerm;
float fightTerm = (*it == victim) ? fightVictim : fight; float fightTerm = static_cast<float>((*it == victim) ? fightVictim : fight);
fightTerm += getFightDispositionBias(dispTerm); fightTerm += getFightDispositionBias(dispTerm);
fightTerm += getFightDistanceBias(*it, player); fightTerm += getFightDistanceBias(*it, player);
fightTerm *= alarmTerm; fightTerm *= alarmTerm;
int observerFightRating = it->getClass().getCreatureStats(*it).getAiSetting(CreatureStats::AI_Fight).getBase(); int observerFightRating = it->getClass().getCreatureStats(*it).getAiSetting(CreatureStats::AI_Fight).getBase();
if (observerFightRating + fightTerm > 100) if (observerFightRating + fightTerm > 100)
fightTerm = 100 - observerFightRating; fightTerm = static_cast<float>(100 - observerFightRating);
fightTerm = std::max(0.f, fightTerm); fightTerm = std::max(0.f, fightTerm);
if (observerFightRating + fightTerm >= 100) if (observerFightRating + fightTerm >= 100)
@ -1221,9 +1221,9 @@ namespace MWMechanics
NpcStats& observerStats = it->getClass().getNpcStats(*it); NpcStats& observerStats = it->getClass().getNpcStats(*it);
// Apply aggression value to the base Fight rating, so that the actor can continue fighting // Apply aggression value to the base Fight rating, so that the actor can continue fighting
// after a Calm spell wears off // after a Calm spell wears off
observerStats.setAiSetting(CreatureStats::AI_Fight, observerFightRating + fightTerm); observerStats.setAiSetting(CreatureStats::AI_Fight, observerFightRating + static_cast<int>(fightTerm));
observerStats.setBaseDisposition(observerStats.getBaseDisposition()+dispTerm); observerStats.setBaseDisposition(observerStats.getBaseDisposition() + static_cast<int>(dispTerm));
// Set the crime ID, which we will use to calm down participants // Set the crime ID, which we will use to calm down participants
// once the bounty has been paid. // once the bounty has been paid.
@ -1334,7 +1334,7 @@ namespace MWMechanics
{ {
static float fSneakSkillMult = store.find("fSneakSkillMult")->getFloat(); static float fSneakSkillMult = store.find("fSneakSkillMult")->getFloat();
static float fSneakBootMult = store.find("fSneakBootMult")->getFloat(); static float fSneakBootMult = store.find("fSneakBootMult")->getFloat();
float sneak = ptr.getClass().getSkill(ptr, ESM::Skill::Sneak); float sneak = static_cast<float>(ptr.getClass().getSkill(ptr, ESM::Skill::Sneak));
int agility = stats.getAttribute(ESM::Attribute::Agility).getModified(); int agility = stats.getAttribute(ESM::Attribute::Agility).getModified();
int luck = stats.getAttribute(ESM::Attribute::Luck).getModified(); int luck = stats.getAttribute(ESM::Attribute::Luck).getModified();
float bootWeight = 0; float bootWeight = 0;
@ -1345,7 +1345,7 @@ namespace MWMechanics
if (it != inv.end()) if (it != inv.end())
bootWeight = it->getClass().getWeight(*it); bootWeight = it->getClass().getWeight(*it);
} }
sneakTerm = fSneakSkillMult * sneak + 0.2 * agility + 0.1 * luck + bootWeight * fSneakBootMult; sneakTerm = fSneakSkillMult * sneak + 0.2f * agility + 0.1f * luck + bootWeight * fSneakBootMult;
} }
static float fSneakDistBase = store.find("fSneakDistanceBase")->getFloat(); static float fSneakDistBase = store.find("fSneakDistanceBase")->getFloat();
@ -1364,7 +1364,7 @@ namespace MWMechanics
float obsBlind = observerStats.getMagicEffects().get(ESM::MagicEffect::Blind).getMagnitude(); float obsBlind = observerStats.getMagicEffects().get(ESM::MagicEffect::Blind).getMagnitude();
int obsSneak = observer.getClass().getSkill(observer, ESM::Skill::Sneak); int obsSneak = observer.getClass().getSkill(observer, ESM::Skill::Sneak);
float obsTerm = obsSneak + 0.2 * obsAgility + 0.1 * obsLuck - obsBlind; float obsTerm = obsSneak + 0.2f * obsAgility + 0.1f * obsLuck - obsBlind;
// is ptr behind the observer? // is ptr behind the observer?
static float fSneakNoViewMult = store.find("fSneakNoViewMult")->getFloat(); static float fSneakNoViewMult = store.find("fSneakNoViewMult")->getFloat();
@ -1378,7 +1378,7 @@ namespace MWMechanics
y = obsTerm * observerStats.getFatigueTerm() * fSneakViewMult; y = obsTerm * observerStats.getFatigueTerm() * fSneakViewMult;
float target = x - y; float target = x - y;
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99] int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 100); // [0, 99]
return (roll >= target); return (roll >= target);
} }
@ -1479,9 +1479,8 @@ namespace MWMechanics
if (ptr.getClass().isNpc()) if (ptr.getClass().isNpc())
disposition = getDerivedDisposition(ptr); disposition = getDerivedDisposition(ptr);
int fight = std::max(0.f, ptr.getClass().getCreatureStats(ptr).getAiSetting(CreatureStats::AI_Fight).getModified() int fight = std::max(0, ptr.getClass().getCreatureStats(ptr).getAiSetting(CreatureStats::AI_Fight).getModified()
+ getFightDistanceBias(ptr, target) + static_cast<int>(getFightDistanceBias(ptr, target) + getFightDispositionBias(disposition)));
+ getFightDispositionBias(disposition));
if (ptr.getClass().isNpc() && target.getClass().isNpc()) if (ptr.getClass().isNpc() && target.getClass().isNpc())
{ {

@ -251,7 +251,6 @@ namespace MWMechanics
void damage(float damage) { mDamage = std::min(mDamage + damage, (float)(mBase + mFortified)); } void damage(float damage) { mDamage = std::min(mDamage + damage, (float)(mBase + mFortified)); }
void restore(float amount) { mDamage -= std::min(mDamage, amount); } void restore(float amount) { mDamage -= std::min(mDamage, amount); }
int getDamage() const { return mDamage; }
void writeState (ESM::StatState<int>& state) const; void writeState (ESM::StatState<int>& state) const;

@ -365,7 +365,7 @@ void Animation::addExtraLight(Ogre::SceneManager *sceneMgr, NifOgre::ObjectScene
// with the standard 1 / (c + d*l + d*d*q) equation the attenuation factor never becomes zero, // with the standard 1 / (c + d*l + d*d*q) equation the attenuation factor never becomes zero,
// so we ignore lights if their attenuation falls below this factor. // so we ignore lights if their attenuation falls below this factor.
const float threshold = 0.03; const float threshold = 0.03f;
float quadraticAttenuation = 0; float quadraticAttenuation = 0;
float linearAttenuation = 0; float linearAttenuation = 0;
@ -1477,7 +1477,7 @@ void Animation::setLightEffect(float effect)
} }
mGlowLight->setType(Ogre::Light::LT_POINT); mGlowLight->setType(Ogre::Light::LT_POINT);
effect += 3; effect += 3;
mGlowLight->setAttenuation(1.0f / (0.03 * (0.5/effect)), 0, 0.5/effect, 0); mGlowLight->setAttenuation(1.0f / (0.03f * (0.5f/effect)), 0, 0.5f/effect, 0);
} }
} }

@ -69,13 +69,13 @@ namespace MWRender
/// \todo Read the fallback values from INIImporter (Inventory:Directional*) /// \todo Read the fallback values from INIImporter (Inventory:Directional*)
l = mSceneMgr->createLight(); l = mSceneMgr->createLight();
l->setType (Ogre::Light::LT_DIRECTIONAL); l->setType (Ogre::Light::LT_DIRECTIONAL);
l->setDirection (Ogre::Vector3(0.3, -0.7, 0.3)); l->setDirection (Ogre::Vector3(0.3f, -0.7f, 0.3f));
l->setDiffuseColour (Ogre::ColourValue(1,1,1)); l->setDiffuseColour (Ogre::ColourValue(1,1,1));
mSceneMgr->setAmbientLight (Ogre::ColourValue(0.25, 0.25, 0.25)); mSceneMgr->setAmbientLight (Ogre::ColourValue(0.25, 0.25, 0.25));
mCamera = mSceneMgr->createCamera (mName); mCamera = mSceneMgr->createCamera (mName);
mCamera->setFOVy(Ogre::Degree(12.3)); mCamera->setFOVy(Ogre::Degree(12.3f));
mCamera->setAspectRatio (float(mSizeX) / float(mSizeY)); mCamera->setAspectRatio (float(mSizeX) / float(mSizeY));
Ogre::SceneNode* renderRoot = mSceneMgr->getRootSceneNode()->createChildSceneNode("renderRoot"); Ogre::SceneNode* renderRoot = mSceneMgr->getRootSceneNode()->createChildSceneNode("renderRoot");

@ -86,8 +86,8 @@ namespace MWRender
{ {
for (int cellX=0; cellX<mCellSize; ++cellX) for (int cellX=0; cellX<mCellSize; ++cellX)
{ {
int vertexX = float(cellX)/float(mCellSize) * 9; int vertexX = static_cast<int>(float(cellX)/float(mCellSize) * 9);
int vertexY = float(cellY)/float(mCellSize) * 9; int vertexY = static_cast<int>(float(cellY) / float(mCellSize) * 9);
int texelX = (x-mMinX) * mCellSize + cellX; int texelX = (x-mMinX) * mCellSize + cellX;
@ -102,9 +102,9 @@ namespace MWRender
y = (SCHAR_MIN << 4) / 2048.f; y = (SCHAR_MIN << 4) / 2048.f;
if (y < 0) if (y < 0)
{ {
r = (14 * y + 38); r = static_cast<unsigned char>(14 * y + 38);
g = 20 * y + 56; g = static_cast<unsigned char>(20 * y + 56);
b = 18 * y + 51; b = static_cast<unsigned char>(18 * y + 51);
} }
else if (y < 0.3f) else if (y < 0.3f)
{ {
@ -112,20 +112,20 @@ namespace MWRender
y *= 8.f; y *= 8.f;
else else
{ {
y -= 0.1; y -= 0.1f;
y += 0.8; y += 0.8f;
} }
r = 66 - 32 * y; r = static_cast<unsigned char>(66 - 32 * y);
g = 48 - 23 * y; g = static_cast<unsigned char>(48 - 23 * y);
b = 33 - 16 * y; b = static_cast<unsigned char>(33 - 16 * y);
} }
else else
{ {
y -= 0.3f; y -= 0.3f;
y *= 1.428f; y *= 1.428f;
r = 34 - 29 * y; r = static_cast<unsigned char>(34 - 29 * y);
g = 25 - 20 * y; g = static_cast<unsigned char>(25 - 20 * y);
b = 17 - 12 * y; b = static_cast<unsigned char>(17 - 12 * y);
} }
data[texelY * mWidth * 3 + texelX * 3] = r; data[texelY * mWidth * 3 + texelX * 3] = r;
@ -172,9 +172,9 @@ namespace MWRender
void GlobalMap::exploreCell(int cellX, int cellY) void GlobalMap::exploreCell(int cellX, int cellY)
{ {
float originX = (cellX - mMinX) * mCellSize; float originX = static_cast<float>((cellX - mMinX) * mCellSize);
// NB y + 1, because we want the top left corner, not bottom left where the origin of the cell is // NB y + 1, because we want the top left corner, not bottom left where the origin of the cell is
float originY = mHeight - (cellY+1 - mMinY) * mCellSize; float originY = static_cast<float>(mHeight - (cellY + 1 - mMinY) * mCellSize);
if (cellX > mMaxX || cellX < mMinX || cellY > mMaxY || cellY < mMinY) if (cellX > mMaxX || cellX < mMinX || cellY > mMaxY || cellY < mMinY)
return; return;
@ -188,7 +188,8 @@ namespace MWRender
int mapHeight = localMapTexture->getHeight(); int mapHeight = localMapTexture->getHeight();
mOverlayTexture->load(); mOverlayTexture->load();
mOverlayTexture->getBuffer()->blit(localMapTexture->getBuffer(), Ogre::Image::Box(0,0,mapWidth,mapHeight), mOverlayTexture->getBuffer()->blit(localMapTexture->getBuffer(), Ogre::Image::Box(0,0,mapWidth,mapHeight),
Ogre::Image::Box(originX,originY,originX+mCellSize,originY+mCellSize)); Ogre::Image::Box(static_cast<Ogre::uint32>(originX), static_cast<Ogre::uint32>(originY),
static_cast<Ogre::uint32>(originX + mCellSize), static_cast<Ogre::uint32>(originY + mCellSize)));
Ogre::Image backup; Ogre::Image backup;
std::vector<Ogre::uchar> data; std::vector<Ogre::uchar> data;
@ -204,7 +205,7 @@ namespace MWRender
assert (originY+y < mOverlayImage.getHeight()); assert (originY+y < mOverlayImage.getHeight());
assert (x < int(backup.getWidth())); assert (x < int(backup.getWidth()));
assert (y < int(backup.getHeight())); assert (y < int(backup.getHeight()));
mOverlayImage.setColourAt(backup.getColourAt(x, y, 0), originX+x, originY+y, 0); mOverlayImage.setColourAt(backup.getColourAt(x, y, 0), static_cast<size_t>(originX + x), static_cast<size_t>(originY + y), 0);
} }
} }
} }

@ -43,9 +43,9 @@ LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWRender::RenderingManag
mLight = mRendering->getScene()->createLight(); mLight = mRendering->getScene()->createLight();
mLight->setType (Ogre::Light::LT_DIRECTIONAL); mLight->setType (Ogre::Light::LT_DIRECTIONAL);
mLight->setDirection (Ogre::Vector3(0.3, 0.3, -0.7)); mLight->setDirection (Ogre::Vector3(0.3f, 0.3f, -0.7f));
mLight->setVisible (false); mLight->setVisible (false);
mLight->setDiffuseColour (ColourValue(0.7,0.7,0.7)); mLight->setDiffuseColour (ColourValue(0.7f,0.7f,0.7f));
mRenderTexture = TextureManager::getSingleton().createManual( mRenderTexture = TextureManager::getSingleton().createManual(
"localmap/rtt", "localmap/rtt",
@ -114,8 +114,8 @@ void LocalMap::saveFogOfWar(MWWorld::CellStore* cell)
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().y); Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().y);
Vector2 max(mBounds.getMaximum().x, mBounds.getMaximum().y); Vector2 max(mBounds.getMaximum().x, mBounds.getMaximum().y);
Vector2 length = max-min; Vector2 length = max-min;
const int segsX = std::ceil( length.x / sSize ); const int segsX = static_cast<int>(std::ceil(length.x / sSize));
const int segsY = std::ceil( length.y / sSize ); const int segsY = static_cast<int>(std::ceil(length.y / sSize));
mInteriorName = cell->getCell()->mName; mInteriorName = cell->getCell()->mName;
@ -175,7 +175,7 @@ void LocalMap::requestMap(MWWorld::CellStore* cell, float zMin, float zMax)
// Note: using force=true for exterior cell maps. // Note: using force=true for exterior cell maps.
// They must be updated even if they were visited before, because the set of surrounding active cells might be different // They must be updated even if they were visited before, because the set of surrounding active cells might be different
// (and objects in a different cell can "bleed" into another cell's map if they cross the border) // (and objects in a different cell can "bleed" into another cell's map if they cross the border)
render((x+0.5)*sSize, (y+0.5)*sSize, zMin, zMax, sSize, sSize, name, true); render((x+0.5f)*sSize, (y+0.5f)*sSize, zMin, zMax, static_cast<float>(sSize), static_cast<float>(sSize), name, true);
if (mBuffers.find(name) == mBuffers.end()) if (mBuffers.find(name) == mBuffers.end())
{ {
@ -226,7 +226,7 @@ void LocalMap::requestMap(MWWorld::CellStore* cell,
// Do NOT change padding! This will break older savegames. // Do NOT change padding! This will break older savegames.
// If the padding really needs to be changed, then it must be saved in the ESM::FogState and // If the padding really needs to be changed, then it must be saved in the ESM::FogState and
// assume the old (500) value as default for older savegames. // assume the old (500) value as default for older savegames.
const int padding = 500; const Ogre::Real padding = 500.0f;
// Apply a little padding // Apply a little padding
mBounds.setMinimum (mBounds.getMinimum() - Vector3(padding,padding,0)); mBounds.setMinimum (mBounds.getMinimum() - Vector3(padding,padding,0));
@ -279,8 +279,8 @@ void LocalMap::requestMap(MWWorld::CellStore* cell,
mCameraPosNode->setPosition(Vector3(center.x, center.y, 0)); mCameraPosNode->setPosition(Vector3(center.x, center.y, 0));
// divide into segments // divide into segments
const int segsX = std::ceil( length.x / sSize ); const int segsX = static_cast<int>(std::ceil(length.x / sSize));
const int segsY = std::ceil( length.y / sSize ); const int segsY = static_cast<int>(std::ceil(length.y / sSize));
mInteriorName = cell->getCell()->mName; mInteriorName = cell->getCell()->mName;
@ -289,12 +289,12 @@ void LocalMap::requestMap(MWWorld::CellStore* cell,
{ {
for (int y=0; y<segsY; ++y) for (int y=0; y<segsY; ++y)
{ {
Vector2 start = min + Vector2(sSize*x,sSize*y); Vector2 start = min + Vector2(static_cast<Ogre::Real>(sSize*x), static_cast<Ogre::Real>(sSize*y));
Vector2 newcenter = start + sSize/2; Vector2 newcenter = start + sSize/2;
std::string texturePrefix = cell->getCell()->mName + "_" + coordStr(x,y); std::string texturePrefix = cell->getCell()->mName + "_" + coordStr(x,y);
render(newcenter.x - center.x, newcenter.y - center.y, zMin, zMax, sSize, sSize, texturePrefix); render(newcenter.x - center.x, newcenter.y - center.y, zMin, zMax, static_cast<float>(sSize), static_cast<float>(sSize), texturePrefix);
if (!cell->getFog()) if (!cell->getFog())
createFogOfWar(texturePrefix); createFogOfWar(texturePrefix);
@ -397,7 +397,7 @@ void LocalMap::render(const float x, const float y,
// set up lighting // set up lighting
Ogre::ColourValue oldAmbient = mRendering->getScene()->getAmbientLight(); Ogre::ColourValue oldAmbient = mRendering->getScene()->getAmbientLight();
mRendering->getScene()->setAmbientLight(Ogre::ColourValue(0.3, 0.3, 0.3)); mRendering->getScene()->setAmbientLight(Ogre::ColourValue(0.3f, 0.3f, 0.3f));
mRenderingManager->disableLights(true); mRenderingManager->disableLights(true);
mLight->setVisible(true); mLight->setVisible(true);
@ -439,11 +439,11 @@ void LocalMap::worldToInteriorMapPosition (Ogre::Vector2 pos, float& nX, float&
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().y); Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().y);
x = std::ceil((pos.x - min.x)/sSize)-1; x = static_cast<int>(std::ceil((pos.x - min.x) / sSize) - 1);
y = std::ceil((pos.y - min.y)/sSize)-1; y = static_cast<int>(std::ceil((pos.y - min.y) / sSize) - 1);
nX = (pos.x - min.x - sSize*x)/sSize; nX = (pos.x - min.x - sSize*x)/sSize;
nY = 1.0-(pos.y - min.y - sSize*y)/sSize; nY = 1.0f-(pos.y - min.y - sSize*y)/sSize;
} }
Ogre::Vector2 LocalMap::interiorMapToWorldPosition (float nX, float nY, int x, int y) Ogre::Vector2 LocalMap::interiorMapToWorldPosition (float nX, float nY, int x, int y)
@ -452,7 +452,7 @@ Ogre::Vector2 LocalMap::interiorMapToWorldPosition (float nX, float nY, int x, i
Ogre::Vector2 pos; Ogre::Vector2 pos;
pos.x = sSize * (nX + x) + min.x; pos.x = sSize * (nX + x) + min.x;
pos.y = sSize * (1.0-nY + y) + min.y; pos.y = sSize * (1.0f-nY + y) + min.y;
pos = rotatePoint(pos, Vector2(mBounds.getCenter().x, mBounds.getCenter().y), -mAngle); pos = rotatePoint(pos, Vector2(mBounds.getCenter().x, mBounds.getCenter().y), -mAngle);
return pos; return pos;
@ -468,8 +468,8 @@ bool LocalMap::isPositionExplored (float nX, float nY, int x, int y, bool interi
nX = std::max(0.f, std::min(1.f, nX)); nX = std::max(0.f, std::min(1.f, nX));
nY = std::max(0.f, std::min(1.f, nY)); nY = std::max(0.f, std::min(1.f, nY));
int texU = (sFogOfWarResolution-1) * nX; int texU = static_cast<int>((sFogOfWarResolution - 1) * nX);
int texV = (sFogOfWarResolution-1) * nY; int texV = static_cast<int>((sFogOfWarResolution - 1) * nY);
Ogre::uint32 clr = mBuffers[texName][texV * sFogOfWarResolution + texU]; Ogre::uint32 clr = mBuffers[texName][texV * sFogOfWarResolution + texU];
uint8 alpha = (clr >> 24); uint8 alpha = (clr >> 24);
@ -522,8 +522,8 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni
if (!mInterior) if (!mInterior)
{ {
x = std::ceil(pos.x / sSize)-1; x = static_cast<int>(std::ceil(pos.x / sSize) - 1);
y = std::ceil(pos.y / sSize)-1; y = static_cast<int>(std::ceil(pos.y / sSize) - 1);
} }
else else
MWBase::Environment::get().getWindowManager()->setActiveMap(x,y,mInterior); MWBase::Environment::get().getWindowManager()->setActiveMap(x,y,mInterior);
@ -533,7 +533,7 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni
if (!mInterior) if (!mInterior)
{ {
u = std::abs((pos.x - (sSize*x))/sSize); u = std::abs((pos.x - (sSize*x))/sSize);
v = 1.0-std::abs((pos.y - (sSize*y))/sSize); v = 1.0f-std::abs((pos.y - (sSize*y))/sSize);
texBaseName = "Cell_"; texBaseName = "Cell_";
} }
else else
@ -545,7 +545,7 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni
MWBase::Environment::get().getWindowManager()->setPlayerDir(playerdirection.x, playerdirection.y); MWBase::Environment::get().getWindowManager()->setPlayerDir(playerdirection.x, playerdirection.y);
// explore radius (squared) // explore radius (squared)
const float exploreRadius = (mInterior ? 0.1 : 0.3) * (sFogOfWarResolution-1); // explore radius from 0 to sFogOfWarResolution-1 const float exploreRadius = (mInterior ? 0.1f : 0.3f) * (sFogOfWarResolution-1); // explore radius from 0 to sFogOfWarResolution-1
const float sqrExploreRadius = Math::Sqr(exploreRadius); const float sqrExploreRadius = Math::Sqr(exploreRadius);
const float exploreRadiusUV = exploreRadius / sFogOfWarResolution; // explore radius from 0 to 1 (UV space) const float exploreRadiusUV = exploreRadius / sFogOfWarResolution; // explore radius from 0 to 1 (UV space)

@ -101,7 +101,7 @@ void HeadAnimationTime::setEnabled(bool enabled)
void HeadAnimationTime::resetBlinkTimer() void HeadAnimationTime::resetBlinkTimer()
{ {
mBlinkTimer = -(2 + (std::rand() / double(RAND_MAX*1.0)) * 6); mBlinkTimer = -(2 + (std::rand() / static_cast<float>(RAND_MAX)) * 6);
} }
void HeadAnimationTime::update(float dt) void HeadAnimationTime::update(float dt)

@ -35,7 +35,7 @@ namespace MWRender
vp->setShadowsEnabled(false); vp->setShadowsEnabled(false);
vp->setVisibilityMask(RV_Refraction); vp->setVisibilityMask(RV_Refraction);
vp->setMaterialScheme("water_refraction"); vp->setMaterialScheme("water_refraction");
vp->setBackgroundColour (Ogre::ColourValue(0.090195, 0.115685, 0.12745)); vp->setBackgroundColour (Ogre::ColourValue(0.090195f, 0.115685f, 0.12745f));
mRenderTarget->setAutoUpdated(true); mRenderTarget->setAutoUpdated(true);
mRenderTarget->addListener(this); mRenderTarget->addListener(this);
} }

@ -148,8 +148,8 @@ RenderingManager::RenderingManager(OEngine::Render::OgreRenderer& _rend, const b
sh::Factory::getInstance ().setSharedParameter ("waterEnabled", sh::makeProperty<sh::FloatValue> (new sh::FloatValue(0.0))); sh::Factory::getInstance ().setSharedParameter ("waterEnabled", sh::makeProperty<sh::FloatValue> (new sh::FloatValue(0.0)));
sh::Factory::getInstance ().setSharedParameter ("waterLevel", sh::makeProperty<sh::FloatValue>(new sh::FloatValue(0))); sh::Factory::getInstance ().setSharedParameter ("waterLevel", sh::makeProperty<sh::FloatValue>(new sh::FloatValue(0)));
sh::Factory::getInstance ().setSharedParameter ("waterTimer", sh::makeProperty<sh::FloatValue>(new sh::FloatValue(0))); sh::Factory::getInstance ().setSharedParameter ("waterTimer", sh::makeProperty<sh::FloatValue>(new sh::FloatValue(0)));
sh::Factory::getInstance ().setSharedParameter ("windDir_windSpeed", sh::makeProperty<sh::Vector3>(new sh::Vector3(0.5, -0.8, 0.2))); sh::Factory::getInstance ().setSharedParameter ("windDir_windSpeed", sh::makeProperty<sh::Vector3>(new sh::Vector3(0.5f, -0.8f, 0.2f)));
sh::Factory::getInstance ().setSharedParameter ("waterSunFade_sunHeight", sh::makeProperty<sh::Vector2>(new sh::Vector2(1, 0.6))); sh::Factory::getInstance ().setSharedParameter ("waterSunFade_sunHeight", sh::makeProperty<sh::Vector2>(new sh::Vector2(1, 0.6f)));
sh::Factory::getInstance ().setGlobalSetting ("refraction", Settings::Manager::getBool("refraction", "Water") ? "true" : "false"); sh::Factory::getInstance ().setGlobalSetting ("refraction", Settings::Manager::getBool("refraction", "Water") ? "true" : "false");
sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false");
sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makeProperty<sh::Vector4> (new sh::Vector4(0,0,0,0))); sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makeProperty<sh::Vector4> (new sh::Vector4(0,0,0,0)));
@ -346,7 +346,7 @@ void RenderingManager::update (float duration, bool paused)
MWWorld::Ptr player = world->getPlayerPtr(); MWWorld::Ptr player = world->getPlayerPtr();
int blind = player.getClass().getCreatureStats(player).getMagicEffects().get(ESM::MagicEffect::Blind).getMagnitude(); int blind = static_cast<int>(player.getClass().getCreatureStats(player).getMagicEffects().get(ESM::MagicEffect::Blind).getMagnitude());
MWBase::Environment::get().getWindowManager()->setBlindness(std::max(0, std::min(100, blind))); MWBase::Environment::get().getWindowManager()->setBlindness(std::max(0, std::min(100, blind)));
setAmbientMode(); setAmbientMode();
@ -365,7 +365,7 @@ void RenderingManager::update (float duration, bool paused)
btVector3 btOrig(orig.x, orig.y, orig.z); btVector3 btOrig(orig.x, orig.y, orig.z);
btVector3 btDest(dest.x, dest.y, dest.z); btVector3 btDest(dest.x, dest.y, dest.z);
std::pair<bool,float> test = mPhysicsEngine->sphereCast(mRendering.getCamera()->getNearClipDistance()*2.5, btOrig, btDest); std::pair<bool,float> test = mPhysicsEngine->sphereCast(mRendering.getCamera()->getNearClipDistance()*2.5f, btOrig, btDest);
if(test.first) if(test.first)
mCamera->setCameraDistance(test.second * orig.distance(dest), false, false); mCamera->setCameraDistance(test.second * orig.distance(dest), false, false);
} }
@ -375,8 +375,8 @@ void RenderingManager::update (float duration, bool paused)
bool isInAir = !world->isOnGround(player); bool isInAir = !world->isOnGround(player);
bool isSwimming = world->isSwimming(player); bool isSwimming = world->isSwimming(player);
static const int i1stPersonSneakDelta = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>() static const float i1stPersonSneakDelta = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
.find("i1stPersonSneakDelta")->getInt(); .find("i1stPersonSneakDelta")->getFloat();
if(!paused && isSneaking && !(isSwimming || isInAir)) if(!paused && isSneaking && !(isSwimming || isInAir))
mCamera->setSneakOffset(i1stPersonSneakDelta); mCamera->setSneakOffset(i1stPersonSneakDelta);
@ -538,7 +538,7 @@ void RenderingManager::applyFog (bool underwater)
} }
else else
{ {
Ogre::ColourValue clv(0.090195, 0.115685, 0.12745); Ogre::ColourValue clv(0.090195f, 0.115685f, 0.12745f);
mRendering.getScene()->setFog (FOG_LINEAR, Ogre::ColourValue(clv), 0, 0, 1000); mRendering.getScene()->setFog (FOG_LINEAR, Ogre::ColourValue(clv), 0, 0, 1000);
mRendering.getViewport()->setBackgroundColour (Ogre::ColourValue(clv)); mRendering.getViewport()->setBackgroundColour (Ogre::ColourValue(clv));
mWater->setViewportBackground (Ogre::ColourValue(clv)); mWater->setViewportBackground (Ogre::ColourValue(clv));
@ -598,9 +598,9 @@ void RenderingManager::setAmbientColour(const Ogre::ColourValue& colour)
mAmbientColor = colour; mAmbientColor = colour;
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
int nightEye = player.getClass().getCreatureStats(player).getMagicEffects().get(ESM::MagicEffect::NightEye).getMagnitude(); int nightEye = static_cast<int>(player.getClass().getCreatureStats(player).getMagicEffects().get(ESM::MagicEffect::NightEye).getMagnitude());
Ogre::ColourValue final = colour; Ogre::ColourValue final = colour;
final += Ogre::ColourValue(0.7,0.7,0.7,0) * std::min(1.f, (nightEye/100.f)); final += Ogre::ColourValue(0.7f,0.7f,0.7f,0) * std::min(1.f, (nightEye/100.f));
mRendering.getScene()->setAmbientLight(final); mRendering.getScene()->setAmbientLight(final);
} }
@ -662,7 +662,7 @@ void RenderingManager::requestMap(MWWorld::CellStore* cell)
assert(mTerrain); assert(mTerrain);
Ogre::AxisAlignedBox dims = mObjects->getDimensions(cell); Ogre::AxisAlignedBox dims = mObjects->getDimensions(cell);
Ogre::Vector2 center (cell->getCell()->getGridX() + 0.5, cell->getCell()->getGridY() + 0.5); Ogre::Vector2 center (cell->getCell()->getGridX() + 0.5f, cell->getCell()->getGridY() + 0.5f);
dims.merge(mTerrain->getWorldBoundingBox(center)); dims.merge(mTerrain->getWorldBoundingBox(center));
mLocalMap->requestMap(cell, dims.getMinimum().z, dims.getMaximum().z); mLocalMap->requestMap(cell, dims.getMinimum().z, dims.getMaximum().z);
@ -714,8 +714,8 @@ Ogre::Vector4 RenderingManager::boundingBoxToScreen(Ogre::AxisAlignedBox bounds)
// make 2D relative/normalized coords from the view-space vertex // make 2D relative/normalized coords from the view-space vertex
// by dividing out the Z (depth) factor -- this is an approximation // by dividing out the Z (depth) factor -- this is an approximation
float x = corner.x / corner.z + 0.5; float x = corner.x / corner.z + 0.5f;
float y = corner.y / corner.z + 0.5; float y = corner.y / corner.z + 0.5f;
if (x < min_x) if (x < min_x)
min_x = x; min_x = x;

@ -107,7 +107,7 @@ void RippleSimulation::update(float dt, Ogre::Vector2 position)
Ogre::Radian& rotation = created->rotation; Ogre::Radian& rotation = created->rotation;
#endif #endif
timeToLive = totalTimeToLive = mRippleLifeTime; timeToLive = totalTimeToLive = mRippleLifeTime;
colour = Ogre::ColourValue(0.f, 0.f, 0.f, 0.7); // Water_RippleAlphas.x? colour = Ogre::ColourValue(0.f, 0.f, 0.f, 0.7f); // Water_RippleAlphas.x?
direction = Ogre::Vector3(0,0,0); direction = Ogre::Vector3(0,0,0);
position = currentPos; position = currentPos;
position.z = 0; // Z is set by the Scene Node position.z = 0; // Z is set by the Scene Node

@ -21,7 +21,7 @@ using namespace MWRender;
Shadows::Shadows(OEngine::Render::OgreRenderer* rend) : Shadows::Shadows(OEngine::Render::OgreRenderer* rend) :
mRendering(rend), mSceneMgr(rend->getScene()), mPSSMSetup(NULL), mRendering(rend), mSceneMgr(rend->getScene()), mPSSMSetup(NULL),
mShadowFar(1000), mFadeStart(0.9) mShadowFar(1000), mFadeStart(0.9f)
{ {
recreate(); recreate();
} }
@ -58,7 +58,7 @@ void Shadows::recreate()
mSceneMgr->setShadowTexturePixelFormat(PF_FLOAT32_R); mSceneMgr->setShadowTexturePixelFormat(PF_FLOAT32_R);
mSceneMgr->setShadowDirectionalLightExtrusionDistance(1000000); mSceneMgr->setShadowDirectionalLightExtrusionDistance(1000000);
mShadowFar = split ? Settings::Manager::getInt("split shadow distance", "Shadows") : Settings::Manager::getInt("shadow distance", "Shadows"); mShadowFar = Settings::Manager::getFloat(split ? "split shadow distance" : "shadow distance", "Shadows");
mSceneMgr->setShadowFarDistance(mShadowFar); mSceneMgr->setShadowFarDistance(mShadowFar);
mFadeStart = Settings::Manager::getFloat("fade start", "Shadows"); mFadeStart = Settings::Manager::getFloat("fade start", "Shadows");

@ -310,22 +310,22 @@ void SkyManager::create()
// Create light used for thunderstorm // Create light used for thunderstorm
mLightning = mSceneMgr->createLight(); mLightning = mSceneMgr->createLight();
mLightning->setType (Ogre::Light::LT_DIRECTIONAL); mLightning->setType (Ogre::Light::LT_DIRECTIONAL);
mLightning->setDirection (Ogre::Vector3(0.3, -0.7, 0.3)); mLightning->setDirection (Ogre::Vector3(0.3f, -0.7f, 0.3f));
mLightning->setVisible (false); mLightning->setVisible (false);
mLightning->setDiffuseColour (ColourValue(3,3,3)); mLightning->setDiffuseColour (ColourValue(3,3,3));
const MWWorld::Fallback* fallback=MWBase::Environment::get().getWorld()->getFallback(); const MWWorld::Fallback* fallback=MWBase::Environment::get().getWorld()->getFallback();
mSecunda = new Moon("secunda_texture", fallback->getFallbackFloat("Moons_Secunda_Size")/100, Vector3(-0.4, 0.4, 0.5), mRootNode, "openmw_moon"); mSecunda = new Moon("secunda_texture", fallback->getFallbackFloat("Moons_Secunda_Size")/100, Vector3(-0.4f, 0.4f, 0.5f), mRootNode, "openmw_moon");
mSecunda->setType(Moon::Type_Secunda); mSecunda->setType(Moon::Type_Secunda);
mSecunda->setRenderQueue(RQG_SkiesEarly+4); mSecunda->setRenderQueue(RQG_SkiesEarly+4);
mMasser = new Moon("masser_texture", fallback->getFallbackFloat("Moons_Masser_Size")/100, Vector3(-0.4, 0.4, 0.5), mRootNode, "openmw_moon"); mMasser = new Moon("masser_texture", fallback->getFallbackFloat("Moons_Masser_Size")/100, Vector3(-0.4f, 0.4f, 0.5f), mRootNode, "openmw_moon");
mMasser->setRenderQueue(RQG_SkiesEarly+3); mMasser->setRenderQueue(RQG_SkiesEarly+3);
mMasser->setType(Moon::Type_Masser); mMasser->setType(Moon::Type_Masser);
mSun = new BillboardObject("textures\\tx_sun_05.dds", 1, Vector3(0.4, 0.4, 0.4), mRootNode, "openmw_sun"); mSun = new BillboardObject("textures\\tx_sun_05.dds", 1, Vector3(0.4f, 0.4f, 0.4f), mRootNode, "openmw_sun");
mSun->setRenderQueue(RQG_SkiesEarly+4); mSun->setRenderQueue(RQG_SkiesEarly+4);
mSunGlare = new BillboardObject("textures\\tx_sun_flash_grey_05.dds", 3, Vector3(0.4, 0.4, 0.4), mRootNode, "openmw_sun"); mSunGlare = new BillboardObject("textures\\tx_sun_flash_grey_05.dds", 3, Vector3(0.4f, 0.4f, 0.4f), mRootNode, "openmw_sun");
mSunGlare->setRenderQueue(RQG_SkiesLate); mSunGlare->setRenderQueue(RQG_SkiesLate);
mSunGlare->setVisibilityFlags(RV_NoReflection); mSunGlare->setVisibilityFlags(RV_NoReflection);
@ -464,8 +464,8 @@ void SkyManager::updateRain(float dt)
// TODO: handle rain settings from Morrowind.ini // TODO: handle rain settings from Morrowind.ini
const float rangeRandom = 100; const float rangeRandom = 100;
float xOffs = (std::rand()/(RAND_MAX+1.0)) * rangeRandom - (rangeRandom/2); float xOffs = (std::rand()/(RAND_MAX+1.0f)) * rangeRandom - (rangeRandom/2);
float yOffs = (std::rand()/(RAND_MAX+1.0)) * rangeRandom - (rangeRandom/2); float yOffs = (std::rand()/(RAND_MAX+1.0f)) * rangeRandom - (rangeRandom/2);
// Create a separate node to control the offset, since a node with setInheritOrientation(false) will still // Create a separate node to control the offset, since a node with setInheritOrientation(false) will still
// consider the orientation of the parent node for its position, just not for its orientation // consider the orientation of the parent node for its position, just not for its orientation
@ -680,9 +680,9 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
if (mCloudColour != weather.mSunColor) if (mCloudColour != weather.mSunColor)
{ {
ColourValue clr( weather.mSunColor.r*0.7 + weather.mAmbientColor.r*0.7, ColourValue clr( weather.mSunColor.r*0.7f + weather.mAmbientColor.r*0.7f,
weather.mSunColor.g*0.7 + weather.mAmbientColor.g*0.7, weather.mSunColor.g*0.7f + weather.mAmbientColor.g*0.7f,
weather.mSunColor.b*0.7 + weather.mAmbientColor.b*0.7); weather.mSunColor.b*0.7f + weather.mAmbientColor.b*0.7f);
sh::Factory::getInstance().setSharedParameter ("cloudColour", sh::Factory::getInstance().setSharedParameter ("cloudColour",
sh::makeProperty<sh::Vector3>(new sh::Vector3(clr.r, clr.g, clr.b))); sh::makeProperty<sh::Vector3>(new sh::Vector3(clr.r, clr.g, clr.b)));
@ -774,7 +774,7 @@ void SkyManager::setSunDirection(const Vector3& direction, bool is_night)
mSunGlare->setPosition(direction); mSunGlare->setPosition(direction);
float height = direction.z; float height = direction.z;
float fade = is_night ? 0.0 : (( height > 0.5) ? 1.0 : height * 2); float fade = is_night ? 0.0f : (( height > 0.5) ? 1.0f : height * 2);
sh::Factory::getInstance ().setSharedParameter ("waterSunFade_sunHeight", sh::makeProperty<sh::Vector2>(new sh::Vector2(fade, height))); sh::Factory::getInstance ().setSharedParameter ("waterSunFade_sunHeight", sh::makeProperty<sh::Vector2>(new sh::Vector2(fade, height)));
} }
@ -836,7 +836,7 @@ void SkyManager::setSecundaFade(const float fade)
void SkyManager::setHour(double hour) void SkyManager::setHour(double hour)
{ {
mHour = hour; mHour = static_cast<float>(hour);
} }
void SkyManager::setDate(int day, int month) void SkyManager::setDate(int day, int month)

@ -36,13 +36,13 @@ namespace MWRender
for (; it != esmStore.get<ESM::Cell>().extEnd(); ++it) for (; it != esmStore.get<ESM::Cell>().extEnd(); ++it)
{ {
if (it->getGridX() < minX) if (it->getGridX() < minX)
minX = it->getGridX(); minX = static_cast<float>(it->getGridX());
if (it->getGridX() > maxX) if (it->getGridX() > maxX)
maxX = it->getGridX(); maxX = static_cast<float>(it->getGridX());
if (it->getGridY() < minY) if (it->getGridY() < minY)
minY = it->getGridY(); minY = static_cast<float>(it->getGridY());
if (it->getGridY() > maxY) if (it->getGridY() > maxY)
maxY = it->getGridY(); maxY = static_cast<float>(it->getGridY());
} }
// since grid coords are at cell origin, we need to add 1 cell // since grid coords are at cell origin, we need to add 1 cell

@ -210,7 +210,8 @@ Water::Water (Ogre::Camera *camera, RenderingManager* rend, const MWWorld::Fallb
int waterScale = 30; int waterScale = 30;
MeshManager::getSingleton().createPlane("water", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, mWaterPlane, MeshManager::getSingleton().createPlane("water", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, mWaterPlane,
CELL_SIZE*5*waterScale, CELL_SIZE*5*waterScale, 40, 40, true, 1, 3*waterScale,3*waterScale, Vector3::UNIT_Y); static_cast<Ogre::Real>(CELL_SIZE*5*waterScale), static_cast<Ogre::Real>(CELL_SIZE*5*waterScale),
40, 40, true, 1, static_cast<Ogre::Real>(3 * waterScale), static_cast<Ogre::Real>(3 * waterScale), Vector3::UNIT_Y);
mWater = mSceneMgr->createEntity("water"); mWater = mSceneMgr->createEntity("water");
mWater->setVisibilityFlags(RV_Water); mWater->setVisibilityFlags(RV_Water);
@ -284,7 +285,7 @@ void Water::setActive(bool active)
mActive = active; mActive = active;
updateVisible(); updateVisible();
sh::Factory::getInstance ().setSharedParameter ("waterEnabled", sh::makeProperty<sh::FloatValue> (new sh::FloatValue(active ? 1.0 : 0.0))); sh::Factory::getInstance ().setSharedParameter ("waterEnabled", sh::makeProperty<sh::FloatValue> (new sh::FloatValue(active ? 1.0f : 0.0f)));
} }
Water::~Water() Water::~Water()
@ -351,7 +352,7 @@ Water::updateUnderwater(bool underwater)
Vector3 Water::getSceneNodeCoordinates(int gridX, int gridY) Vector3 Water::getSceneNodeCoordinates(int gridX, int gridY)
{ {
return Vector3(gridX * CELL_SIZE + (CELL_SIZE / 2), gridY * CELL_SIZE + (CELL_SIZE / 2), mTop); return Vector3(static_cast<Ogre::Real>(gridX * CELL_SIZE + (CELL_SIZE / 2)), static_cast<Ogre::Real>(gridY * CELL_SIZE + (CELL_SIZE / 2)), mTop);
} }
void Water::setViewportBackground(const ColourValue& bg) void Water::setViewportBackground(const ColourValue& bg)

@ -122,7 +122,7 @@ namespace MWRender {
bool mIsUnderwater; bool mIsUnderwater;
bool mActive; bool mActive;
bool mToggled; bool mToggled;
int mTop; float mTop;
float mWaterTimer; float mWaterTimer;

@ -107,7 +107,7 @@ namespace MWScript
// discard additional arguments (reset), because we have no idea what they mean. // discard additional arguments (reset), because we have no idea what they mean.
for (unsigned int i=0; i<arg0; ++i) runtime.pop(); for (unsigned int i=0; i<arg0; ++i) runtime.pop();
MWMechanics::AiEscort escortPackage(actorID, duration, x, y, z); MWMechanics::AiEscort escortPackage(actorID, static_cast<int>(duration), x, y, z);
ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(escortPackage, ptr); ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(escortPackage, ptr);
std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration
@ -145,7 +145,7 @@ namespace MWScript
// discard additional arguments (reset), because we have no idea what they mean. // discard additional arguments (reset), because we have no idea what they mean.
for (unsigned int i=0; i<arg0; ++i) runtime.pop(); for (unsigned int i=0; i<arg0; ++i) runtime.pop();
MWMechanics::AiEscort escortPackage(actorID, cellID, duration, x, y, z); MWMechanics::AiEscort escortPackage(actorID, cellID, static_cast<int>(duration), x, y, z);
ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(escortPackage, ptr); ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(escortPackage, ptr);
std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration
@ -177,13 +177,13 @@ namespace MWScript
{ {
MWWorld::Ptr ptr = R()(runtime); MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Integer range = runtime[0].mFloat; Interpreter::Type_Integer range = static_cast<Interpreter::Type_Integer>(runtime[0].mFloat);
runtime.pop(); runtime.pop();
Interpreter::Type_Integer duration = runtime[0].mFloat; Interpreter::Type_Integer duration = static_cast<Interpreter::Type_Integer>(runtime[0].mFloat);
runtime.pop(); runtime.pop();
Interpreter::Type_Integer time = runtime[0].mFloat; Interpreter::Type_Integer time = static_cast<Interpreter::Type_Integer>(runtime[0].mFloat);
runtime.pop(); runtime.pop();
std::vector<unsigned char> idleList; std::vector<unsigned char> idleList;

@ -475,7 +475,7 @@ namespace MWScript
for (int i=0; i<3; ++i) for (int i=0; i<3; ++i)
diff[i] = pos1[i] - pos2[i]; diff[i] = pos1[i] - pos2[i];
return std::sqrt (diff[0]*diff[0] + diff[1]*diff[1] + diff[2]*diff[2]); return static_cast<float>(std::sqrt(diff[0] * diff[0] + diff[1] * diff[1] + diff[2] * diff[2]));
} }
bool InterpreterContext::hasBeenActivated (const MWWorld::Ptr& ptr) bool InterpreterContext::hasBeenActivated (const MWWorld::Ptr& ptr)

@ -63,7 +63,7 @@ namespace MWScript
return mLongs.at (index); return mLongs.at (index);
case 'f': case 'f':
return mFloats.at (index); return static_cast<int>(mFloats.at(index));
default: default:
return 0; return 0;
} }
@ -87,7 +87,7 @@ namespace MWScript
mLongs.at (index) = val; break; mLongs.at (index) = val; break;
case 'f': case 'f':
mFloats.at (index) = val; break; mFloats.at(index) = static_cast<float>(val); break;
} }
return true; return true;
} }

@ -312,7 +312,7 @@ namespace MWScript
Interpreter::Type_Float time = runtime[0].mFloat; Interpreter::Type_Float time = runtime[0].mFloat;
runtime.pop(); runtime.pop();
MWBase::Environment::get().getWindowManager()->fadeScreenTo(alpha, time, false); MWBase::Environment::get().getWindowManager()->fadeScreenTo(static_cast<int>(alpha), time, false);
} }
}; };

@ -169,7 +169,7 @@ namespace MWScript
if (mIndex==0 && ptr.getClass().hasItemHealth (ptr)) if (mIndex==0 && ptr.getClass().hasItemHealth (ptr))
{ {
// health is a special case // health is a special case
value = ptr.getClass().getItemMaxHealth (ptr); value = static_cast<Interpreter::Type_Float>(ptr.getClass().getItemMaxHealth(ptr));
} else { } else {
value = value =
ptr.getClass() ptr.getClass()
@ -402,7 +402,7 @@ namespace MWScript
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr(); MWWorld::Ptr player = world->getPlayerPtr();
int bounty = runtime[0].mFloat; int bounty = static_cast<int>(runtime[0].mFloat);
runtime.pop(); runtime.pop();
player.getClass().getNpcStats (player).setBounty(bounty); player.getClass().getNpcStats (player).setBounty(bounty);
@ -420,7 +420,7 @@ namespace MWScript
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr(); MWWorld::Ptr player = world->getPlayerPtr();
player.getClass().getNpcStats (player).setBounty(runtime[0].mFloat + player.getClass().getNpcStats (player).getBounty()); player.getClass().getNpcStats(player).setBounty(static_cast<int>(runtime[0].mFloat) + player.getClass().getNpcStats(player).getBounty());
runtime.pop(); runtime.pop();
} }
}; };
@ -1195,11 +1195,10 @@ namespace MWScript
float currentValue = stats.getMagicEffects().get(mPositiveEffect).getMagnitude(); float currentValue = stats.getMagicEffects().get(mPositiveEffect).getMagnitude();
if (mNegativeEffect != -1) if (mNegativeEffect != -1)
currentValue -= stats.getMagicEffects().get(mNegativeEffect).getMagnitude(); currentValue -= stats.getMagicEffects().get(mNegativeEffect).getMagnitude();
currentValue = int(currentValue);
int arg = runtime[0].mInteger; int arg = runtime[0].mInteger;
runtime.pop(); runtime.pop();
stats.getMagicEffects().modifyBase(mPositiveEffect, (arg - currentValue)); stats.getMagicEffects().modifyBase(mPositiveEffect, (arg - static_cast<int>(currentValue)));
} }
}; };

@ -332,7 +332,7 @@ namespace MWScript
// except for when you position the player, then degrees must be used. // except for when you position the player, then degrees must be used.
// See "Morrowind Scripting for Dummies (9th Edition)" pages 50 and 54 for reference. // See "Morrowind Scripting for Dummies (9th Edition)" pages 50 and 54 for reference.
if(ptr != MWBase::Environment::get().getWorld()->getPlayerPtr()) if(ptr != MWBase::Environment::get().getWorld()->getPlayerPtr())
zRot = zRot/60.; zRot = zRot/60.0f;
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,zRot); MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,zRot);
ptr.getClass().adjustPosition(ptr, false); ptr.getClass().adjustPosition(ptr, false);
@ -389,7 +389,7 @@ namespace MWScript
// except for when you position the player, then degrees must be used. // except for when you position the player, then degrees must be used.
// See "Morrowind Scripting for Dummies (9th Edition)" pages 50 and 54 for reference. // See "Morrowind Scripting for Dummies (9th Edition)" pages 50 and 54 for reference.
if(ptr != MWBase::Environment::get().getWorld()->getPlayerPtr()) if(ptr != MWBase::Environment::get().getWorld()->getPlayerPtr())
zRot = zRot/60.; zRot = zRot/60.0f;
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,zRot); MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,zRot);
ptr.getClass().adjustPosition(ptr, false); ptr.getClass().adjustPosition(ptr, false);
} }

@ -8,7 +8,7 @@ namespace MWSound
void analyzeLoudness(const std::vector<char> &data, int sampleRate, ChannelConfig chans, void analyzeLoudness(const std::vector<char> &data, int sampleRate, ChannelConfig chans,
SampleType type, std::vector<float> &out, float valuesPerSecond) SampleType type, std::vector<float> &out, float valuesPerSecond)
{ {
int samplesPerSegment = sampleRate / valuesPerSecond; int samplesPerSegment = static_cast<int>(sampleRate / valuesPerSecond);
int numSamples = bytesToFrames(data.size(), chans, type); int numSamples = bytesToFrames(data.size(), chans, type);
int advance = framesToBytes(1, chans, type); int advance = framesToBytes(1, chans, type);

@ -801,7 +801,7 @@ const CachedSound& OpenAL_Output::getBuffer(const std::string &fname)
decoder->close(); decoder->close();
CachedSound cached; CachedSound cached;
analyzeLoudness(data, srate, chans, type, cached.mLoudnessVector, loudnessFPS); analyzeLoudness(data, srate, chans, type, cached.mLoudnessVector, static_cast<float>(loudnessFPS));
alGenBuffers(1, &buf); alGenBuffers(1, &buf);
throwALerror(); throwALerror();
@ -885,7 +885,7 @@ MWBase::SoundPtr OpenAL_Output::playSound(const std::string &fname, float vol, f
offset=1; offset=1;
alSourcei(src, AL_BUFFER, buf); alSourcei(src, AL_BUFFER, buf);
alSourcef(src, AL_SEC_OFFSET, sound->getLength()*offset/pitch); alSourcef(src, AL_SEC_OFFSET, static_cast<ALfloat>(sound->getLength()*offset / pitch));
alSourcePlay(src); alSourcePlay(src);
throwALerror(); throwALerror();
@ -910,7 +910,7 @@ MWBase::SoundPtr OpenAL_Output::playSound3D(const std::string &fname, const Ogre
sound.reset(new OpenAL_Sound3D(*this, src, buf, pos, vol, basevol, pitch, min, max, flags)); sound.reset(new OpenAL_Sound3D(*this, src, buf, pos, vol, basevol, pitch, min, max, flags));
if (extractLoudness) if (extractLoudness)
sound->setLoudnessVector(cached.mLoudnessVector, loudnessFPS); sound->setLoudnessVector(cached.mLoudnessVector, static_cast<float>(loudnessFPS));
} }
catch(std::exception&) catch(std::exception&)
{ {
@ -929,7 +929,7 @@ MWBase::SoundPtr OpenAL_Output::playSound3D(const std::string &fname, const Ogre
offset=1; offset=1;
alSourcei(src, AL_BUFFER, buf); alSourcei(src, AL_BUFFER, buf);
alSourcef(src, AL_SEC_OFFSET, sound->getLength()*offset/pitch); alSourcef(src, AL_SEC_OFFSET, static_cast<ALfloat>(sound->getLength()*offset / pitch));
alSourcePlay(src); alSourcePlay(src);
throwALerror(); throwALerror();

@ -7,7 +7,7 @@ namespace MWSound
{ {
if (mLoudnessVector.empty()) if (mLoudnessVector.empty())
return 0.f; return 0.f;
int index = getTimeOffset() * mLoudnessFPS; int index = static_cast<int>(getTimeOffset() * mLoudnessFPS);
index = std::max(0, std::min(index, int(mLoudnessVector.size()-1))); index = std::max(0, std::min(index, int(mLoudnessVector.size()-1)));

@ -106,7 +106,7 @@ namespace MWSound
MWBase::World* world = MWBase::Environment::get().getWorld(); MWBase::World* world = MWBase::Environment::get().getWorld();
const ESM::Sound *snd = world->getStore().get<ESM::Sound>().find(soundId); const ESM::Sound *snd = world->getStore().get<ESM::Sound>().find(soundId);
volume *= pow(10.0, (snd->mData.mVolume/255.0*3348.0 - 3348.0) / 2000.0); volume *= static_cast<float>(pow(10.0, (snd->mData.mVolume / 255.0*3348.0 - 3348.0) / 2000.0));
if(snd->mData.mMinRange == 0 && snd->mData.mMaxRange == 0) if(snd->mData.mMinRange == 0 && snd->mData.mMaxRange == 0)
{ {
@ -559,7 +559,7 @@ namespace MWSound
if(!cell->isExterior() || sTimePassed < sTimeToNextEnvSound) if(!cell->isExterior() || sTimePassed < sTimeToNextEnvSound)
return; return;
float a = std::rand() / (double)RAND_MAX; float a = std::rand() / static_cast<float>(RAND_MAX);
// NOTE: We should use the "Minimum Time Between Environmental Sounds" and // NOTE: We should use the "Minimum Time Between Environmental Sounds" and
// "Maximum Time Between Environmental Sounds" fallback settings here. // "Maximum Time Between Environmental Sounds" fallback settings here.
sTimeToNextEnvSound = 5.0f*a + 15.0f*(1.0f-a); sTimeToNextEnvSound = 5.0f*a + 15.0f*(1.0f-a);

@ -185,7 +185,7 @@ bool MWWorld::ContainerStore::stacks(const Ptr& ptr1, const Ptr& ptr2)
{ {
const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find( const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(
ptr1.getClass().getEnchantment(ptr1)); ptr1.getClass().getEnchantment(ptr1));
float maxCharge = enchantment->mData.mCharge; float maxCharge = static_cast<float>(enchantment->mData.mCharge);
float enchantCharge1 = ptr1.getCellRef().getEnchantmentCharge() == -1 ? maxCharge : ptr1.getCellRef().getEnchantmentCharge(); float enchantCharge1 = ptr1.getCellRef().getEnchantmentCharge() == -1 ? maxCharge : ptr1.getCellRef().getEnchantmentCharge();
float enchantCharge2 = ptr2.getCellRef().getEnchantmentCharge() == -1 ? maxCharge : ptr2.getCellRef().getEnchantmentCharge(); float enchantCharge2 = ptr2.getCellRef().getEnchantmentCharge() == -1 ? maxCharge : ptr2.getCellRef().getEnchantmentCharge();
if (enchantCharge1 != maxCharge || enchantCharge2 != maxCharge) if (enchantCharge1 != maxCharge || enchantCharge2 != maxCharge)

@ -124,7 +124,7 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener)
mIds[Misc::StringUtils::lowerCase (id)] = n.val; mIds[Misc::StringUtils::lowerCase (id)] = n.val;
} }
} }
listener->setProgress(esm.getFileOffset() / (float)esm.getFileSize() * 1000); listener->setProgress(static_cast<size_t>(esm.getFileOffset() / (float)esm.getFileSize() * 1000));
} }
} }

@ -97,13 +97,13 @@ namespace MWWorld
if (mAutoMove) if (mAutoMove)
value = 1; value = 1;
ptr.getClass().getMovementSettings (ptr).mPosition[1] = value; ptr.getClass().getMovementSettings(ptr).mPosition[1] = static_cast<float>(value);
} }
void Player::setLeftRight (int value) void Player::setLeftRight (int value)
{ {
MWWorld::Ptr ptr = getPlayer(); MWWorld::Ptr ptr = getPlayer();
ptr.getClass().getMovementSettings (ptr).mPosition[0] = value; ptr.getClass().getMovementSettings(ptr).mPosition[0] = static_cast<float>(value);
} }
void Player::setForwardBackward (int value) void Player::setForwardBackward (int value)
@ -115,13 +115,13 @@ namespace MWWorld
if (mAutoMove) if (mAutoMove)
value = 1; value = 1;
ptr.getClass().getMovementSettings (ptr).mPosition[1] = value; ptr.getClass().getMovementSettings(ptr).mPosition[1] = static_cast<float>(value);
} }
void Player::setUpDown(int value) void Player::setUpDown(int value)
{ {
MWWorld::Ptr ptr = getPlayer(); MWWorld::Ptr ptr = getPlayer();
ptr.getClass().getMovementSettings (ptr).mPosition[2] = value; ptr.getClass().getMovementSettings(ptr).mPosition[2] = static_cast<float>(value);
} }
void Player::setRunState(bool run) void Player::setRunState(bool run)

@ -68,7 +68,7 @@ namespace MWWorld
{ {
float height = 0; float height = 0;
if (OEngine::Physic::PhysicActor* actor = mPhysEngine.getCharacter(caster.getRefData().getHandle())) if (OEngine::Physic::PhysicActor* actor = mPhysEngine.getCharacter(caster.getRefData().getHandle()))
height = actor->getHalfExtents().z * 2 * 0.75; // Spawn at 0.75 * ActorHeight height = actor->getHalfExtents().z * 2 * 0.75f; // Spawn at 0.75 * ActorHeight
Ogre::Vector3 pos(caster.getRefData().getPosition().pos); Ogre::Vector3 pos(caster.getRefData().getPosition().pos);
pos.z += height; pos.z += height;

@ -33,7 +33,7 @@ namespace MWWorld
mHour = static_cast<float> (std::fmod (hours, 24)); mHour = static_cast<float> (std::fmod (hours, 24));
mDay += hours / 24; mDay += static_cast<int>(hours / 24);
return *this; return *this;
} }

@ -142,7 +142,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering,MWWorld::Fa
* These values are fallbacks attached to weather. * These values are fallbacks attached to weather.
*/ */
mNightStart = mSunsetTime + mSunsetDuration; mNightStart = mSunsetTime + mSunsetDuration;
mNightEnd = mSunriseTime - 0.5; mNightEnd = mSunriseTime - 0.5f;
mDayStart = mSunriseTime + mSunriseDuration; mDayStart = mSunriseTime + mSunriseDuration;
mDayEnd = mSunsetTime; mDayEnd = mSunsetTime;
@ -368,7 +368,7 @@ void WeatherManager::transition(float factor)
mResult.mParticleEffect = other.mParticleEffect; mResult.mParticleEffect = other.mParticleEffect;
mResult.mRainSpeed = other.mRainSpeed; mResult.mRainSpeed = other.mRainSpeed;
mResult.mRainFrequency = other.mRainFrequency; mResult.mRainFrequency = other.mRainFrequency;
mResult.mAmbientSoundVolume = 2*(factor-0.5); mResult.mAmbientSoundVolume = 2*(factor-0.5f);
mResult.mEffectFade = mResult.mAmbientSoundVolume; mResult.mEffectFade = mResult.mAmbientSoundVolume;
mResult.mAmbientLoopSoundID = other.mAmbientLoopSoundID; mResult.mAmbientLoopSoundID = other.mAmbientLoopSoundID;
} }
@ -376,7 +376,7 @@ void WeatherManager::transition(float factor)
void WeatherManager::update(float duration, bool paused) void WeatherManager::update(float duration, bool paused)
{ {
float timePassed = mTimePassed; float timePassed = static_cast<float>(mTimePassed);
mTimePassed = 0; mTimePassed = 0;
mWeatherUpdateTime -= timePassed; mWeatherUpdateTime -= timePassed;
@ -454,9 +454,9 @@ void WeatherManager::update(float duration, bool paused)
} }
Vector3 final( Vector3 final(
cos( theta ), static_cast<float>(cos(theta)),
-0.268f, // approx tan( -15 degrees ) -0.268f, // approx tan( -15 degrees )
sin( theta ) ); static_cast<float>(sin(theta)));
mRendering->setSunDirection( final, is_night ); mRendering->setSunDirection( final, is_night );
} }
@ -488,8 +488,8 @@ void WeatherManager::update(float duration, bool paused)
moonHeight); moonHeight);
Vector3 secunda( Vector3 secunda(
(moonHeight - 1) * facing * 1.25, (moonHeight - 1) * facing * 1.25f,
(1 - moonHeight) * facing * 0.8, (1 - moonHeight) * facing * 0.8f,
moonHeight); moonHeight);
mRendering->getSkyManager()->setMasserDirection(masser); mRendering->getSkyManager()->setMasserDirection(masser);
@ -542,7 +542,7 @@ void WeatherManager::update(float duration, bool paused)
mRendering->getSkyManager()->setLightningStrength( mThunderFlash / mThunderThreshold ); mRendering->getSkyManager()->setLightningStrength( mThunderFlash / mThunderThreshold );
else else
{ {
mThunderChanceNeeded = rand() % 100; mThunderChanceNeeded = static_cast<float>(rand() % 100);
mThunderChance = 0; mThunderChance = 0;
mRendering->getSkyManager()->setLightningStrength( 0.f ); mRendering->getSkyManager()->setLightningStrength( 0.f );
} }

@ -570,9 +570,9 @@ namespace MWWorld
if (name=="gamehour") if (name=="gamehour")
setHour (value); setHour (value);
else if (name=="day") else if (name=="day")
setDay (value); setDay(static_cast<int>(value));
else if (name=="month") else if (name=="month")
setMonth (value); setMonth(static_cast<int>(value));
else else
mGlobalVariables[name].setFloat (value); mGlobalVariables[name].setFloat (value);
} }
@ -800,7 +800,7 @@ namespace MWWorld
void World::advanceTime (double hours) void World::advanceTime (double hours)
{ {
MWBase::Environment::get().getMechanicsManager()->advanceTime(hours*3600); MWBase::Environment::get().getMechanicsManager()->advanceTime(static_cast<float>(hours * 3600));
mWeatherManager->advanceTime (hours); mWeatherManager->advanceTime (hours);
@ -808,7 +808,7 @@ namespace MWWorld
setHour (hours); setHour (hours);
int days = hours / 24; int days = static_cast<int>(hours / 24);
if (days>0) if (days>0)
mGlobalVariables["dayspassed"].setInteger ( mGlobalVariables["dayspassed"].setInteger (
@ -820,15 +820,15 @@ namespace MWWorld
if (hour<0) if (hour<0)
hour = 0; hour = 0;
int days = hour / 24; int days = static_cast<int>(hour / 24);
hour = std::fmod (hour, 24); hour = std::fmod (hour, 24);
mGlobalVariables["gamehour"].setFloat (hour); mGlobalVariables["gamehour"].setFloat(static_cast<float>(hour));
mRendering->skySetHour (hour); mRendering->skySetHour (hour);
mWeatherManager->setHour (hour); mWeatherManager->setHour(static_cast<float>(hour));
if (days>0) if (days>0)
setDay (days + mGlobalVariables["day"].getInteger()); setDay (days + mGlobalVariables["day"].getInteger());
@ -1015,25 +1015,9 @@ namespace MWWorld
float World::getMaxActivationDistance () float World::getMaxActivationDistance ()
{ {
if (mActivationDistanceOverride >= 0) if (mActivationDistanceOverride >= 0)
return mActivationDistanceOverride; return static_cast<float>(mActivationDistanceOverride);
return (std::max) (getNpcActivationDistance (), getObjectActivationDistance ());
}
float World::getNpcActivationDistance ()
{
if (mActivationDistanceOverride >= 0)
return mActivationDistanceOverride;
return getStore().get<ESM::GameSetting>().find ("iMaxActivateDist")->getInt()*5/4;
}
float World::getObjectActivationDistance ()
{
if (mActivationDistanceOverride >= 0)
return mActivationDistanceOverride;
return getStore().get<ESM::GameSetting>().find ("iMaxActivateDist")->getInt(); return getStore().get<ESM::GameSetting>().find("iMaxActivateDist")->getFloat() * 5 / 4;
} }
MWWorld::Ptr World::getFacedObject() MWWorld::Ptr World::getFacedObject()
@ -1387,8 +1371,8 @@ namespace MWWorld
{ {
const int cellSize = 8192; const int cellSize = 8192;
x = cellSize * cellX; x = static_cast<float>(cellSize * cellX);
y = cellSize * cellY; y = static_cast<float>(cellSize * cellY);
if (centre) if (centre)
{ {
@ -1401,8 +1385,8 @@ namespace MWWorld
{ {
const int cellSize = 8192; const int cellSize = 8192;
cellX = std::floor(x/cellSize); cellX = static_cast<int>(std::floor(x / cellSize));
cellY = std::floor(y/cellSize); cellY = static_cast<int>(std::floor(y / cellSize));
} }
void World::queueMovement(const Ptr &ptr, const Vector3 &velocity) void World::queueMovement(const Ptr &ptr, const Vector3 &velocity)
@ -1621,7 +1605,7 @@ namespace MWWorld
{ {
Ogre::Vector3 playerPos = mPlayer->getPlayer().getRefData().getBaseNode()->getPosition(); Ogre::Vector3 playerPos = mPlayer->getPlayer().getRefData().getBaseNode()->getPosition();
const OEngine::Physic::PhysicActor *actor = mPhysEngine->getCharacter(getPlayerPtr().getRefData().getHandle()); const OEngine::Physic::PhysicActor *actor = mPhysEngine->getCharacter(getPlayerPtr().getRefData().getHandle());
if(actor) playerPos.z += 1.85*actor->getHalfExtents().z; if(actor) playerPos.z += 1.85f * actor->getHalfExtents().z;
Ogre::Quaternion playerOrient = Ogre::Quaternion(Ogre::Radian(getPlayerPtr().getRefData().getPosition().rot[2]), Ogre::Vector3::NEGATIVE_UNIT_Z) * Ogre::Quaternion playerOrient = Ogre::Quaternion(Ogre::Radian(getPlayerPtr().getRefData().getPosition().rot[2]), Ogre::Vector3::NEGATIVE_UNIT_Z) *
Ogre::Quaternion(Ogre::Radian(getPlayerPtr().getRefData().getPosition().rot[0]), Ogre::Vector3::NEGATIVE_UNIT_X) * Ogre::Quaternion(Ogre::Radian(getPlayerPtr().getRefData().getPosition().rot[0]), Ogre::Vector3::NEGATIVE_UNIT_X) *
Ogre::Quaternion(Ogre::Radian(getPlayerPtr().getRefData().getPosition().rot[1]), Ogre::Vector3::NEGATIVE_UNIT_Y); Ogre::Quaternion(Ogre::Radian(getPlayerPtr().getRefData().getPosition().rot[1]), Ogre::Vector3::NEGATIVE_UNIT_Y);
@ -2013,7 +1997,7 @@ namespace MWWorld
bool World::isSubmerged(const MWWorld::Ptr &object) const bool World::isSubmerged(const MWWorld::Ptr &object) const
{ {
return isUnderwater(object, 1.0/mSwimHeightScale); return isUnderwater(object, 1.0f/mSwimHeightScale);
} }
bool World::isSwimming(const MWWorld::Ptr &object) const bool World::isSwimming(const MWWorld::Ptr &object) const
@ -2371,8 +2355,8 @@ namespace MWWorld
Ogre::Vector3 halfExt2 = actor2->getHalfExtents(); Ogre::Vector3 halfExt2 = actor2->getHalfExtents();
const float* pos2 = targetActor.getRefData().getPosition().pos; const float* pos2 = targetActor.getRefData().getPosition().pos;
btVector3 from(pos1[0],pos1[1],pos1[2]+halfExt1.z*2*0.9); // eye level btVector3 from(pos1[0],pos1[1],pos1[2]+halfExt1.z*2*0.9f); // eye level
btVector3 to(pos2[0],pos2[1],pos2[2]+halfExt2.z*2*0.9); btVector3 to(pos2[0],pos2[1],pos2[2]+halfExt2.z*2*0.9f);
std::pair<std::string, float> result = mPhysEngine->rayTest(from, to,false); std::pair<std::string, float> result = mPhysEngine->rayTest(from, to,false);
if(result.first == "") return true; if(result.first == "") return true;
@ -2591,7 +2575,7 @@ namespace MWWorld
const Store<ESM::GameSetting> &gmst = getStore().get<ESM::GameSetting>(); const Store<ESM::GameSetting> &gmst = getStore().get<ESM::GameSetting>();
MWMechanics::NpcStats &stats = actor.getClass().getNpcStats(actor); MWMechanics::NpcStats &stats = actor.getClass().getNpcStats(actor);
stats.getSkill(ESM::Skill::Acrobatics).setBase(gmst.find("fWerewolfAcrobatics")->getFloat()); stats.getSkill(ESM::Skill::Acrobatics).setBase(gmst.find("fWerewolfAcrobatics")->getInt());
} }
bool World::getGodModeState() bool World::getGodModeState()
@ -3071,8 +3055,8 @@ namespace MWWorld
float fCrimeGoldDiscountMult = getStore().get<ESM::GameSetting>().find("fCrimeGoldDiscountMult")->getFloat(); float fCrimeGoldDiscountMult = getStore().get<ESM::GameSetting>().find("fCrimeGoldDiscountMult")->getFloat();
float fCrimeGoldTurnInMult = getStore().get<ESM::GameSetting>().find("fCrimeGoldTurnInMult")->getFloat(); float fCrimeGoldTurnInMult = getStore().get<ESM::GameSetting>().find("fCrimeGoldTurnInMult")->getFloat();
int discount = bounty * fCrimeGoldDiscountMult; int discount = static_cast<int>(bounty * fCrimeGoldDiscountMult);
int turnIn = bounty * fCrimeGoldTurnInMult; int turnIn = static_cast<int>(bounty * fCrimeGoldTurnInMult);
if (bounty > 0) if (bounty > 0)
{ {
@ -3153,7 +3137,7 @@ namespace MWWorld
const ESM::CreatureLevList* list = getStore().get<ESM::CreatureLevList>().find(creatureList); const ESM::CreatureLevList* list = getStore().get<ESM::CreatureLevList>().find(creatureList);
int iNumberCreatures = getStore().get<ESM::GameSetting>().find("iNumberCreatures")->getInt(); int iNumberCreatures = getStore().get<ESM::GameSetting>().find("iNumberCreatures")->getInt();
int numCreatures = 1 + std::rand()/ (static_cast<double> (RAND_MAX) + 1) * iNumberCreatures; // [1, iNumberCreatures] int numCreatures = static_cast<int>(1 + std::rand() / (static_cast<double> (RAND_MAX)+1) * iNumberCreatures); // [1, iNumberCreatures]
for (int i=0; i<numCreatures; ++i) for (int i=0; i<numCreatures; ++i)
{ {
@ -3204,7 +3188,7 @@ namespace MWWorld
std::stringstream modelName; std::stringstream modelName;
modelName << "Blood_Model_"; modelName << "Blood_Model_";
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 3; // [0, 2] int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 3); // [0, 2]
modelName << roll; modelName << roll;
std::string model = "meshes\\" + getFallback()->getFallbackString(modelName.str()); std::string model = "meshes\\" + getFallback()->getFallbackString(modelName.str());
@ -3235,7 +3219,7 @@ namespace MWWorld
else else
areaStatic = getStore().get<ESM::Static>().find ("VFX_DefaultArea"); areaStatic = getStore().get<ESM::Static>().find ("VFX_DefaultArea");
mRendering->spawnEffect("meshes\\" + areaStatic->mModel, "", origin, effectIt->mArea); mRendering->spawnEffect("meshes\\" + areaStatic->mModel, "", origin, static_cast<float>(effectIt->mArea));
// Play explosion sound (make sure to use NoTrack, since we will delete the projectile now) // Play explosion sound (make sure to use NoTrack, since we will delete the projectile now)
static const std::string schools[] = { static const std::string schools[] = {
@ -3251,7 +3235,7 @@ namespace MWWorld
// Get the actors in range of the effect // Get the actors in range of the effect
std::vector<MWWorld::Ptr> objects; std::vector<MWWorld::Ptr> objects;
MWBase::Environment::get().getMechanicsManager()->getObjectsInRange( MWBase::Environment::get().getMechanicsManager()->getObjectsInRange(
origin, feetToGameUnits(effectIt->mArea), objects); origin, feetToGameUnits(static_cast<float>(effectIt->mArea)), objects);
for (std::vector<MWWorld::Ptr>::iterator affected = objects.begin(); affected != objects.end(); ++affected) for (std::vector<MWWorld::Ptr>::iterator affected = objects.begin(); affected != objects.end(); ++affected)
toApply[*affected].push_back(*effectIt); toApply[*affected].push_back(*effectIt);
} }

@ -115,9 +115,6 @@ namespace MWWorld
void performUpdateSceneQueries (); void performUpdateSceneQueries ();
void getFacedHandle(std::string& facedHandle, float maxDistance, bool ignorePlayer=true); void getFacedHandle(std::string& facedHandle, float maxDistance, bool ignorePlayer=true);
float getNpcActivationDistance ();
float getObjectActivationDistance ();
void removeContainerScripts(const Ptr& reference); void removeContainerScripts(const Ptr& reference);
void addContainerScripts(const Ptr& reference, CellStore* cell); void addContainerScripts(const Ptr& reference, CellStore* cell);
void PCDropped (const Ptr& item); void PCDropped (const Ptr& item);

@ -10,22 +10,22 @@ namespace ESM
Pathgrid::Point& Pathgrid::Point::operator=(const float rhs[3]) Pathgrid::Point& Pathgrid::Point::operator=(const float rhs[3])
{ {
mX = rhs[0]; mX = static_cast<int>(rhs[0]);
mY = rhs[1]; mY = static_cast<int>(rhs[1]);
mZ = rhs[2]; mZ = static_cast<int>(rhs[2]);
mAutogenerated = 0; mAutogenerated = 0;
mConnectionNum = 0; mConnectionNum = 0;
mUnknown = 0; mUnknown = 0;
return *this; return *this;
} }
Pathgrid::Point::Point(const float rhs[3]) Pathgrid::Point::Point(const float rhs[3])
: mAutogenerated(0), : mX(static_cast<int>(rhs[0])),
mY(static_cast<int>(rhs[1])),
mZ(static_cast<int>(rhs[2])),
mAutogenerated(0),
mConnectionNum(0), mConnectionNum(0),
mUnknown(0) mUnknown(0)
{ {
mX = rhs[0];
mY = rhs[1];
mZ = rhs[2];
} }
Pathgrid::Point::Point():mX(0),mY(0),mZ(0),mAutogenerated(0), Pathgrid::Point::Point():mX(0),mY(0),mZ(0),mAutogenerated(0),
mConnectionNum(0),mUnknown(0) mConnectionNum(0),mUnknown(0)

@ -15,7 +15,7 @@ namespace ESM
int Race::MaleFemaleF::getValue (bool male) const int Race::MaleFemaleF::getValue (bool male) const
{ {
return male ? mMale : mFemale; return static_cast<int>(male ? mMale : mFemale);
} }
void Race::load(ESMReader &esm) void Race::load(ESMReader &esm)

@ -40,7 +40,7 @@ namespace ESM
// mDamage was changed to a float; ensure backwards compatibility // mDamage was changed to a float; ensure backwards compatibility
T oldDamage = 0; T oldDamage = 0;
esm.getHNOT(oldDamage, "STDA"); esm.getHNOT(oldDamage, "STDA");
mDamage = oldDamage; mDamage = static_cast<float>(oldDamage);
esm.getHNOT (mDamage, "STDF"); esm.getHNOT (mDamage, "STDF");

@ -128,7 +128,7 @@ int ESM::VariantIntegerData::getInteger (bool default_) const
float ESM::VariantIntegerData::getFloat (bool default_) const float ESM::VariantIntegerData::getFloat (bool default_) const
{ {
return mValue; return static_cast<float>(mValue);
} }
void ESM::VariantIntegerData::setInteger (int value) void ESM::VariantIntegerData::setInteger (int value)
@ -202,7 +202,7 @@ void ESM::VariantIntegerData::write (ESMWriter& esm, Variant::Format format, Var
{ {
if (type==VT_Short || type==VT_Long) if (type==VT_Short || type==VT_Long)
{ {
float value = mValue; float value = static_cast<float>(mValue);
esm.writeHNString ("FNAM", type==VT_Short ? "s" : "l"); esm.writeHNString ("FNAM", type==VT_Short ? "s" : "l");
esm.writeHNT ("FLTV", value); esm.writeHNT ("FLTV", value);
} }
@ -262,7 +262,7 @@ float ESM::VariantFloatData::getFloat (bool default_) const
void ESM::VariantFloatData::setInteger (int value) void ESM::VariantFloatData::setInteger (int value)
{ {
mValue = value; mValue = static_cast<float>(value);
} }
void ESM::VariantFloatData::setFloat (float value) void ESM::VariantFloatData::setFloat (float value)

@ -27,8 +27,8 @@ namespace ESMTerrain
assert(origin.x == (int) origin.x); assert(origin.x == (int) origin.x);
assert(origin.y == (int) origin.y); assert(origin.y == (int) origin.y);
int cellX = origin.x; int cellX = static_cast<int>(origin.x);
int cellY = origin.y; int cellY = static_cast<int>(origin.y);
const ESM::Land* land = getLand(cellX, cellY); const ESM::Land* land = getLand(cellX, cellY);
if (!land || !(land->mDataTypes&ESM::Land::DATA_VHGT)) if (!land || !(land->mDataTypes&ESM::Land::DATA_VHGT))
@ -135,10 +135,10 @@ namespace ESMTerrain
assert(origin.x == (int) origin.x); assert(origin.x == (int) origin.x);
assert(origin.y == (int) origin.y); assert(origin.y == (int) origin.y);
int startX = origin.x; int startX = static_cast<int>(origin.x);
int startY = origin.y; int startY = static_cast<int>(origin.y);
size_t numVerts = size*(ESM::Land::LAND_SIZE-1)/increment + 1; size_t numVerts = static_cast<size_t>(size*(ESM::Land::LAND_SIZE - 1) / increment + 1);
colours.resize(numVerts*numVerts*4); colours.resize(numVerts*numVerts*4);
positions.resize(numVerts*numVerts*3); positions.resize(numVerts*numVerts*3);
@ -175,12 +175,12 @@ namespace ESMTerrain
vertX = vertX_; vertX = vertX_;
for (int row=rowStart; row<ESM::Land::LAND_SIZE; row += increment) for (int row=rowStart; row<ESM::Land::LAND_SIZE; row += increment)
{ {
positions[vertX*numVerts*3 + vertY*3] = ((vertX/float(numVerts-1)-0.5) * size * 8192); positions[static_cast<unsigned int>(vertX*numVerts * 3 + vertY * 3)] = ((vertX / float(numVerts - 1) - 0.5f) * size * 8192);
positions[vertX*numVerts*3 + vertY*3 + 1] = ((vertY/float(numVerts-1)-0.5) * size * 8192); positions[static_cast<unsigned int>(vertX*numVerts * 3 + vertY * 3 + 1)] = ((vertY / float(numVerts - 1) - 0.5f) * size * 8192);
if (land) if (land)
positions[vertX*numVerts*3 + vertY*3 + 2] = land->mLandData->mHeights[col*ESM::Land::LAND_SIZE+row]; positions[static_cast<unsigned int>(vertX*numVerts * 3 + vertY * 3 + 2)] = land->mLandData->mHeights[col*ESM::Land::LAND_SIZE + row];
else else
positions[vertX*numVerts*3 + vertY*3 + 2] = -2048; positions[static_cast<unsigned int>(vertX*numVerts * 3 + vertY * 3 + 2)] = -2048;
if (land && land->mDataTypes&ESM::Land::DATA_VNML) if (land && land->mDataTypes&ESM::Land::DATA_VNML)
{ {
@ -202,9 +202,9 @@ namespace ESMTerrain
assert(normal.z > 0); assert(normal.z > 0);
normals[vertX*numVerts*3 + vertY*3] = normal.x; normals[static_cast<unsigned int>(vertX*numVerts * 3 + vertY * 3)] = normal.x;
normals[vertX*numVerts*3 + vertY*3 + 1] = normal.y; normals[static_cast<unsigned int>(vertX*numVerts * 3 + vertY * 3 + 1)] = normal.y;
normals[vertX*numVerts*3 + vertY*3 + 2] = normal.z; normals[static_cast<unsigned int>(vertX*numVerts * 3 + vertY * 3 + 2)] = normal.z;
if (land && land->mDataTypes&ESM::Land::DATA_VCLR) if (land && land->mDataTypes&ESM::Land::DATA_VCLR)
{ {
@ -226,7 +226,7 @@ namespace ESMTerrain
color.a = 1; color.a = 1;
Ogre::uint32 rsColor; Ogre::uint32 rsColor;
Ogre::Root::getSingleton().getRenderSystem()->convertColourValue(color, &rsColor); Ogre::Root::getSingleton().getRenderSystem()->convertColourValue(color, &rsColor);
memcpy(&colours[vertX*numVerts*4 + vertY*4], &rsColor, sizeof(Ogre::uint32)); memcpy(&colours[static_cast<unsigned int>(vertX*numVerts * 4 + vertY * 4)], &rsColor, sizeof(Ogre::uint32));
++vertX; ++vertX;
} }
@ -293,7 +293,7 @@ namespace ESMTerrain
{ {
out.push_back(Terrain::LayerCollection()); out.push_back(Terrain::LayerCollection());
out.back().mTarget = *it; out.back().mTarget = *it;
getBlendmapsImpl((*it)->getSize(), (*it)->getCenter(), pack, out.back().mBlendmaps, out.back().mLayers); getBlendmapsImpl(static_cast<float>((*it)->getSize()), (*it)->getCenter(), pack, out.back().mBlendmaps, out.back().mLayers);
} }
} }
@ -311,8 +311,8 @@ namespace ESMTerrain
// and interpolate the rest of the cell by hand? :/ // and interpolate the rest of the cell by hand? :/
Ogre::Vector2 origin = chunkCenter - Ogre::Vector2(chunkSize/2.f, chunkSize/2.f); Ogre::Vector2 origin = chunkCenter - Ogre::Vector2(chunkSize/2.f, chunkSize/2.f);
int cellX = origin.x; int cellX = static_cast<int>(origin.x);
int cellY = origin.y; int cellY = static_cast<int>(origin.y);
// Save the used texture indices so we know the total number of textures // Save the used texture indices so we know the total number of textures
// and number of required blend maps // and number of required blend maps
@ -343,7 +343,7 @@ namespace ESMTerrain
int numTextures = textureIndices.size(); int numTextures = textureIndices.size();
// numTextures-1 since the base layer doesn't need blending // numTextures-1 since the base layer doesn't need blending
int numBlendmaps = pack ? std::ceil((numTextures-1) / 4.f) : (numTextures-1); int numBlendmaps = pack ? static_cast<int>(std::ceil((numTextures - 1) / 4.f)) : (numTextures - 1);
int channels = pack ? 4 : 1; int channels = pack ? 4 : 1;
@ -364,7 +364,7 @@ namespace ESMTerrain
{ {
UniqueTextureId id = getVtexIndexAt(cellX, cellY, x, y); UniqueTextureId id = getVtexIndexAt(cellX, cellY, x, y);
int layerIndex = textureIndicesMap.find(id)->second; int layerIndex = textureIndicesMap.find(id)->second;
int blendIndex = (pack ? std::floor((layerIndex-1)/4.f) : layerIndex-1); int blendIndex = (pack ? static_cast<int>(std::floor((layerIndex - 1) / 4.f)) : layerIndex - 1);
int channel = pack ? std::max(0, (layerIndex-1) % 4) : 0; int channel = pack ? std::max(0, (layerIndex-1) % 4) : 0;
if (blendIndex == i) if (blendIndex == i)
@ -379,8 +379,8 @@ namespace ESMTerrain
float Storage::getHeightAt(const Ogre::Vector3 &worldPos) float Storage::getHeightAt(const Ogre::Vector3 &worldPos)
{ {
int cellX = std::floor(worldPos.x / 8192.f); int cellX = static_cast<int>(std::floor(worldPos.x / 8192.f));
int cellY = std::floor(worldPos.y / 8192.f); int cellY = static_cast<int>(std::floor(worldPos.y / 8192.f));
ESM::Land* land = getLand(cellX, cellY); ESM::Land* land = getLand(cellX, cellY);
if (!land || !(land->mDataTypes&ESM::Land::DATA_VHGT)) if (!land || !(land->mDataTypes&ESM::Land::DATA_VHGT))
@ -519,7 +519,7 @@ namespace ESMTerrain
float Storage::getCellWorldSize() float Storage::getCellWorldSize()
{ {
return ESM::Land::REAL_SIZE; return static_cast<float>(ESM::Land::REAL_SIZE);
} }
int Storage::getCellVertices() int Storage::getCellVertices()

@ -288,7 +288,7 @@ namespace Gui
code->addAttribute("advance", data[i].width); code->addAttribute("advance", data[i].width);
code->addAttribute("bearing", MyGUI::utility::toString(data[i].kerning) + " " code->addAttribute("bearing", MyGUI::utility::toString(data[i].kerning) + " "
+ MyGUI::utility::toString((fontSize-data[i].ascent))); + MyGUI::utility::toString((fontSize-data[i].ascent)));
code->addAttribute("size", MyGUI::IntSize(data[i].width, data[i].height)); code->addAttribute("size", MyGUI::IntSize(static_cast<int>(data[i].width), static_cast<int>(data[i].height)));
// More hacks! The french game uses several win1252 characters that are not included // More hacks! The french game uses several win1252 characters that are not included
// in the cp437 encoding of the font. Fall back to similar available characters. // in the cp437 encoding of the font. Fall back to similar available characters.
@ -334,7 +334,7 @@ namespace Gui
code->addAttribute("advance", data[i].width); code->addAttribute("advance", data[i].width);
code->addAttribute("bearing", MyGUI::utility::toString(data[i].kerning) + " " code->addAttribute("bearing", MyGUI::utility::toString(data[i].kerning) + " "
+ MyGUI::utility::toString((fontSize-data[i].ascent))); + MyGUI::utility::toString((fontSize-data[i].ascent)));
code->addAttribute("size", MyGUI::IntSize(data[i].width, data[i].height)); code->addAttribute("size", MyGUI::IntSize(static_cast<int>(data[i].width), static_cast<int>(data[i].height)));
} }
} }
@ -350,7 +350,7 @@ namespace Gui
cursorCode->addAttribute("advance", data[i].width); cursorCode->addAttribute("advance", data[i].width);
cursorCode->addAttribute("bearing", MyGUI::utility::toString(data[i].kerning) + " " cursorCode->addAttribute("bearing", MyGUI::utility::toString(data[i].kerning) + " "
+ MyGUI::utility::toString((fontSize-data[i].ascent))); + MyGUI::utility::toString((fontSize-data[i].ascent)));
cursorCode->addAttribute("size", MyGUI::IntSize(data[i].width, data[i].height)); cursorCode->addAttribute("size", MyGUI::IntSize(static_cast<int>(data[i].width), static_cast<int>(data[i].height)));
} }
// Question mark, use for NotDefined marker (used for glyphs not existing in the font) // Question mark, use for NotDefined marker (used for glyphs not existing in the font)
@ -365,7 +365,7 @@ namespace Gui
cursorCode->addAttribute("advance", data[i].width); cursorCode->addAttribute("advance", data[i].width);
cursorCode->addAttribute("bearing", MyGUI::utility::toString(data[i].kerning) + " " cursorCode->addAttribute("bearing", MyGUI::utility::toString(data[i].kerning) + " "
+ MyGUI::utility::toString((fontSize-data[i].ascent))); + MyGUI::utility::toString((fontSize-data[i].ascent)));
cursorCode->addAttribute("size", MyGUI::IntSize(data[i].width, data[i].height)); cursorCode->addAttribute("size", MyGUI::IntSize(static_cast<int>(data[i].width), static_cast<int>(data[i].height)));
} }
} }

@ -108,8 +108,8 @@ namespace Terrain
storage->getBounds(mMinX, mMaxX, mMinY, mMaxY); storage->getBounds(mMinX, mMaxX, mMinY, mMaxY);
int origSizeX = mMaxX-mMinX; int origSizeX = static_cast<int>(mMaxX - mMinX);
int origSizeY = mMaxY-mMinY; int origSizeY = static_cast<int>(mMaxY - mMinY);
// Dividing a quad tree only works well for powers of two, so round up to the nearest one // Dividing a quad tree only works well for powers of two, so round up to the nearest one
int size = nextPowerOfTwo(std::max(origSizeX, origSizeY)); int size = nextPowerOfTwo(std::max(origSizeX, origSizeY));
@ -124,7 +124,7 @@ namespace Terrain
LayersRequestData data; LayersRequestData data;
data.mPack = getShadersEnabled(); data.mPack = getShadersEnabled();
mRootNode = new QuadTreeNode(this, Root, size, Ogre::Vector2(centerX, centerY), NULL); mRootNode = new QuadTreeNode(this, Root, static_cast<float>(size), Ogre::Vector2(centerX, centerY), NULL);
buildQuadTree(mRootNode, data.mNodes); buildQuadTree(mRootNode, data.mNodes);
//loadingListener->indicateProgress(); //loadingListener->indicateProgress();
mRootNode->initAabb(); mRootNode->initAabb();
@ -160,7 +160,7 @@ namespace Terrain
float minZ,maxZ; float minZ,maxZ;
Ogre::Vector2 center = node->getCenter(); Ogre::Vector2 center = node->getCenter();
float cellWorldSize = getStorage()->getCellWorldSize(); float cellWorldSize = getStorage()->getCellWorldSize();
if (mStorage->getMinMaxHeights(node->getSize(), center, minZ, maxZ)) if (mStorage->getMinMaxHeights(static_cast<float>(node->getSize()), center, minZ, maxZ))
{ {
Ogre::AxisAlignedBox bounds(Ogre::Vector3(-halfSize*cellWorldSize, -halfSize*cellWorldSize, minZ), Ogre::AxisAlignedBox bounds(Ogre::Vector3(-halfSize*cellWorldSize, -halfSize*cellWorldSize, minZ),
Ogre::Vector3(halfSize*cellWorldSize, halfSize*cellWorldSize, maxZ)); Ogre::Vector3(halfSize*cellWorldSize, halfSize*cellWorldSize, maxZ));
@ -275,7 +275,7 @@ namespace Terrain
LoadResponseData* responseData = new LoadResponseData(); LoadResponseData* responseData = new LoadResponseData();
getStorage()->fillVertexBuffers(node->getNativeLodLevel(), node->getSize(), node->getCenter(), getAlign(), getStorage()->fillVertexBuffers(node->getNativeLodLevel(), static_cast<float>(node->getSize()), node->getCenter(), getAlign(),
responseData->mPositions, responseData->mNormals, responseData->mColours); responseData->mPositions, responseData->mNormals, responseData->mColours);
return OGRE_NEW Ogre::WorkQueue::Response(req, true, Ogre::Any(responseData)); return OGRE_NEW Ogre::WorkQueue::Response(req, true, Ogre::Any(responseData));

@ -84,7 +84,7 @@ namespace Terrain
/// adding or removing passes. This can only be achieved by a full rebuild.) /// adding or removing passes. This can only be achieved by a full rebuild.)
virtual void applyMaterials(bool shadows, bool splitShadows); virtual void applyMaterials(bool shadows, bool splitShadows);
int getMaxBatchSize() { return mMaxBatchSize; } int getMaxBatchSize() { return static_cast<int>(mMaxBatchSize); }
/// Wait until all background loading is complete. /// Wait until all background loading is complete.
void syncLoad(); void syncLoad();

@ -36,7 +36,7 @@ namespace
int getBlendmapIndexForLayer (int layerIndex) int getBlendmapIndexForLayer (int layerIndex)
{ {
return std::floor((layerIndex-1)/4.f); return static_cast<int>(std::floor((layerIndex - 1) / 4.f));
} }
std::string getBlendmapComponentForLayer (int layerIndex) std::string getBlendmapComponentForLayer (int layerIndex)

@ -135,7 +135,7 @@ QuadTreeNode::QuadTreeNode(DefaultWorld* terrain, ChildDirection dir, float size
: mMaterialGenerator(NULL) : mMaterialGenerator(NULL)
, mIsDummy(false) , mIsDummy(false)
, mSize(size) , mSize(size)
, mLodLevel(Log2(mSize)) , mLodLevel(Log2(static_cast<int>(mSize)))
, mBounds(Ogre::AxisAlignedBox::BOX_NULL) , mBounds(Ogre::AxisAlignedBox::BOX_NULL)
, mWorldBounds(Ogre::AxisAlignedBox::BOX_NULL) , mWorldBounds(Ogre::AxisAlignedBox::BOX_NULL)
, mDirection(dir) , mDirection(dir)

@ -95,7 +95,7 @@ namespace Terrain
Ogre::SceneNode* getSceneNode() { return mSceneNode; } Ogre::SceneNode* getSceneNode() { return mSceneNode; }
int getSize() { return mSize; } int getSize() { return static_cast<int>(mSize); }
Ogre::Vector2 getCenter() { return mCenter; } Ogre::Vector2 getCenter() { return mCenter; }
bool hasChildren() { return mChildren[0] != 0; } bool hasChildren() { return mChildren[0] != 0; }

@ -56,16 +56,16 @@ void TerrainGrid::loadCell(int x, int y)
if (mGrid.find(std::make_pair(x, y)) != mGrid.end()) if (mGrid.find(std::make_pair(x, y)) != mGrid.end())
return; // already loaded return; // already loaded
Ogre::Vector2 center(x+0.5, y+0.5); Ogre::Vector2 center(x+0.5f, y+0.5f);
float minH, maxH; float minH, maxH;
if (!mStorage->getMinMaxHeights(1, center, minH, maxH)) if (!mStorage->getMinMaxHeights(1, center, minH, maxH))
return; // no terrain defined return; // no terrain defined
Ogre::Vector3 min (-0.5*mStorage->getCellWorldSize(), Ogre::Vector3 min (-0.5f*mStorage->getCellWorldSize(),
-0.5*mStorage->getCellWorldSize(), -0.5f*mStorage->getCellWorldSize(),
minH); minH);
Ogre::Vector3 max (0.5*mStorage->getCellWorldSize(), Ogre::Vector3 max (0.5f*mStorage->getCellWorldSize(),
0.5*mStorage->getCellWorldSize(), 0.5f*mStorage->getCellWorldSize(),
maxH); maxH);
Ogre::AxisAlignedBox bounds(min, max); Ogre::AxisAlignedBox bounds(min, max);
@ -163,8 +163,8 @@ void TerrainGrid::setVisible(bool visible)
Ogre::AxisAlignedBox TerrainGrid::getWorldBoundingBox (const Ogre::Vector2& center) Ogre::AxisAlignedBox TerrainGrid::getWorldBoundingBox (const Ogre::Vector2& center)
{ {
int cellX = std::floor(center.x); int cellX = static_cast<int>(std::floor(center.x));
int cellY = std::floor(center.y); int cellY = static_cast<int>(std::floor(center.y));
Grid::iterator it = mGrid.find(std::make_pair(cellX, cellY)); Grid::iterator it = mGrid.find(std::make_pair(cellX, cellY));
if (it == mGrid.end()) if (it == mGrid.end())

@ -138,10 +138,10 @@ namespace Gui
void MWList::onMouseWheel(MyGUI::Widget* _sender, int _rel) void MWList::onMouseWheel(MyGUI::Widget* _sender, int _rel)
{ {
//NB view offset is negative //NB view offset is negative
if (mScrollView->getViewOffset().top + _rel*0.3 > 0) if (mScrollView->getViewOffset().top + _rel*0.3f > 0)
mScrollView->setViewOffset(MyGUI::IntPoint(0, 0)); mScrollView->setViewOffset(MyGUI::IntPoint(0, 0));
else else
mScrollView->setViewOffset(MyGUI::IntPoint(0, mScrollView->getViewOffset().top + _rel*0.3)); mScrollView->setViewOffset(MyGUI::IntPoint(0, static_cast<int>(mScrollView->getViewOffset().top + _rel*0.3)));
} }
void MWList::onItemSelected(MyGUI::Widget* _sender) void MWList::onItemSelected(MyGUI::Widget* _sender)

@ -91,7 +91,7 @@ namespace SFO
// we use a render target to uncompress the DDS texture // we use a render target to uncompress the DDS texture
// just blitting doesn't seem to work on D3D9 // just blitting doesn't seem to work on D3D9
OEngine::Render::ImageRotate::rotate(tex->getName(), tempName, -rotDegrees); OEngine::Render::ImageRotate::rotate(tex->getName(), tempName, static_cast<float>(-rotDegrees));
Ogre::TexturePtr resultTexture = Ogre::TextureManager::getSingleton().getByName(tempName); Ogre::TexturePtr resultTexture = Ogre::TextureManager::getSingleton().getByName(tempName);
@ -110,7 +110,8 @@ namespace SFO
Ogre::ColourValue clr = destImage.getColourAt(x, y, 0); Ogre::ColourValue clr = destImage.getColourAt(x, y, 0);
//set the pixel on the SDL surface to the same value as the Ogre texture's //set the pixel on the SDL surface to the same value as the Ogre texture's
_putPixel(surf, x, y, SDL_MapRGBA(surf->format, clr.r*255, clr.g*255, clr.b*255, clr.a*255)); _putPixel(surf, x, y, SDL_MapRGBA(surf->format, static_cast<Uint8>(clr.r * 255),
static_cast<Uint8>(clr.g * 255), static_cast<Uint8>(clr.b * 255), static_cast<Uint8>(clr.a * 255)));
} }
} }

@ -93,7 +93,8 @@ void SDLWindowHelper::setWindowIcon(const std::string &name)
int bpp = surface->format->BytesPerPixel; int bpp = surface->format->BytesPerPixel;
/* Here p is the address to the pixel we want to set */ /* Here p is the address to the pixel we want to set */
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
Uint32 pixel = SDL_MapRGBA(surface->format, clr.r*255, clr.g*255, clr.b*255, clr.a*255); Uint32 pixel = SDL_MapRGBA(surface->format, static_cast<Uint8>(clr.r * 255),
static_cast<Uint8>(clr.g * 255), static_cast<Uint8>(clr.b * 255), static_cast<Uint8>(clr.a * 255));
switch(bpp) { switch(bpp) {
case 1: case 1:
*p = pixel; *p = pixel;

@ -215,7 +215,7 @@ namespace BtOgre {
if (mBoundRadius == (-1)) if (mBoundRadius == (-1))
{ {
getSize(); getSize();
mBoundRadius = (std::max(mBounds.x,std::max(mBounds.y,mBounds.z)) * 0.5); mBoundRadius = (std::max(mBounds.x,std::max(mBounds.y,mBounds.z)) * 0.5f);
} }
return mBoundRadius; return mBoundRadius;
} }
@ -737,7 +737,7 @@ namespace BtOgre {
{ {
box_kCenter += vertices[c]; box_kCenter += vertices[c];
} }
const Ogre::Real invVertexCount = 1.0 / vertex_count; const Ogre::Real invVertexCount = 1.0f / vertex_count;
box_kCenter *= invVertexCount; box_kCenter *= invVertexCount;
} }
Quaternion orient = boneOrientation; Quaternion orient = boneOrientation;
@ -782,9 +782,9 @@ namespace BtOgre {
box_afExtent.y = ((Real)0.5)*(fY1Max - fY1Min); box_afExtent.y = ((Real)0.5)*(fY1Max - fY1Min);
box_afExtent.z = ((Real)0.5)*(fY2Max - fY2Min); box_afExtent.z = ((Real)0.5)*(fY2Max - fY2Min);
box_kCenter += (0.5*(fY0Max+fY0Min))*box_akAxis[0] + box_kCenter += (0.5f*(fY0Max+fY0Min))*box_akAxis[0] +
(0.5*(fY1Max+fY1Min))*box_akAxis[1] + (0.5f*(fY1Max+fY1Min))*box_akAxis[1] +
(0.5*(fY2Max+fY2Min))*box_akAxis[2]; (0.5f*(fY2Max+fY2Min))*box_akAxis[2];
box_afExtent *= 2.0; box_afExtent *= 2.0;

@ -385,7 +385,7 @@ namespace Physic
} }
btHeightfieldTerrainShape* hfShape = new btHeightfieldTerrainShape( btHeightfieldTerrainShape* hfShape = new btHeightfieldTerrainShape(
sqrtVerts, sqrtVerts, heights, 1, static_cast<int>(sqrtVerts), static_cast<int>(sqrtVerts), heights, 1,
minh, maxh, 2, minh, maxh, 2,
PHY_FLOAT,true); PHY_FLOAT,true);
@ -396,7 +396,7 @@ namespace Physic
btRigidBody::btRigidBodyConstructionInfo CI = btRigidBody::btRigidBodyConstructionInfo(0,0,hfShape); btRigidBody::btRigidBodyConstructionInfo CI = btRigidBody::btRigidBodyConstructionInfo(0,0,hfShape);
RigidBody* body = new RigidBody(CI,name); RigidBody* body = new RigidBody(CI,name);
body->getWorldTransform().setOrigin(btVector3( (x+0.5)*triSize*(sqrtVerts-1), (y+0.5)*triSize*(sqrtVerts-1), (maxh+minh)/2.f)); body->getWorldTransform().setOrigin(btVector3( (x+0.5f)*triSize*(sqrtVerts-1), (y+0.5f)*triSize*(sqrtVerts-1), (maxh+minh)/2.f));
HeightField hf; HeightField hf;
hf.mBody = body; hf.mBody = body;
@ -720,7 +720,7 @@ namespace Physic
void PhysicEngine::stepSimulation(double deltaT) void PhysicEngine::stepSimulation(double deltaT)
{ {
// This seems to be needed for character controller objects // This seems to be needed for character controller objects
mDynamicsWorld->stepSimulation(deltaT,10, 1/60.0); mDynamicsWorld->stepSimulation(static_cast<btScalar>(deltaT), 10, 1 / 60.0f);
if(isDebugCreated) if(isDebugCreated)
{ {
mDebugDrawer->step(); mDebugDrawer->step();

@ -74,16 +74,16 @@ Ogre::Real LightFunction::calculate(Ogre::Real value)
if(mType == LT_Normal) if(mType == LT_Normal)
{ {
// Less than 1/255 light modifier for a constant light: // Less than 1/255 light modifier for a constant light:
brightness = 1.0 + flickerAmplitude(mDeltaCount*slow)/255.0f; brightness = 1.0f + flickerAmplitude(mDeltaCount*slow)/255.0f;
} }
else if(mType == LT_Flicker) else if(mType == LT_Flicker)
brightness = 0.75 + flickerAmplitude(mDeltaCount*fast)*0.25; brightness = 0.75f + flickerAmplitude(mDeltaCount*fast)*0.25f;
else if(mType == LT_FlickerSlow) else if(mType == LT_FlickerSlow)
brightness = 0.75 + flickerAmplitude(mDeltaCount*slow)*0.25; brightness = 0.75f + flickerAmplitude(mDeltaCount*slow)*0.25f;
else if(mType == LT_Pulse) else if(mType == LT_Pulse)
brightness = 1.0 + pulseAmplitude(mDeltaCount*fast)*0.25; brightness = 1.0f + pulseAmplitude(mDeltaCount*fast)*0.25f;
else if(mType == LT_PulseSlow) else if(mType == LT_PulseSlow)
brightness = 1.0 + pulseAmplitude(mDeltaCount*slow)*0.25; brightness = 1.0f + pulseAmplitude(mDeltaCount*slow)*0.25f;
return brightness; return brightness;
} }

@ -184,7 +184,7 @@ void OgreRenderer::setWindowGammaContrast(float gamma, float contrast)
if (value > 65535) value = 65535; if (value > 65535) value = 65535;
else if (value < 0) value = 0; else if (value < 0) value = 0;
red[i] = green[i] = blue[i] = value; red[i] = green[i] = blue[i] = static_cast<Uint16>(value);
} }
if (SDL_SetWindowGammaRamp(mSDLWindow, red, green, blue) < 0) if (SDL_SetWindowGammaRamp(mSDLWindow, red, green, blue) < 0)
std::cout << "Couldn't set gamma: " << SDL_GetError() << std::endl; std::cout << "Couldn't set gamma: " << SDL_GetError() << std::endl;

@ -26,7 +26,7 @@ namespace Render
setupRenderTarget(); setupRenderTarget();
mCurrentColour = Ogre::ColourValue(0.3, 0.3, 0.3); mCurrentColour = Ogre::ColourValue(0.3f, 0.3f, 0.3f);
} }
void SelectionBuffer::setupRenderTarget() void SelectionBuffer::setupRenderTarget()
@ -145,7 +145,7 @@ namespace Render
void SelectionBuffer::getNextColour () void SelectionBuffer::getNextColour ()
{ {
Ogre::ARGB color = (float(rand()) / float(RAND_MAX)) * std::numeric_limits<Ogre::uint32>::max(); Ogre::ARGB color = static_cast<Ogre::ARGB>((float(rand()) / float(RAND_MAX)) * std::numeric_limits<Ogre::uint32>::max());
if (mCurrentColour.getAsARGB () == color) if (mCurrentColour.getAsARGB () == color)
{ {

Loading…
Cancel
Save