fixed MSVC 2013 warning C4800

forcing value to bool 'true' or 'false'
pull/520/head
dteviot 10 years ago
parent 407cd50890
commit 45b6538820

@ -15,8 +15,8 @@ void printAIPackage(ESM::AIPackage p)
std::cout << " Distance: " << p.mWander.mDistance << std::endl; std::cout << " Distance: " << p.mWander.mDistance << std::endl;
std::cout << " Duration: " << p.mWander.mDuration << std::endl; std::cout << " Duration: " << p.mWander.mDuration << std::endl;
std::cout << " Time of Day: " << (int)p.mWander.mTimeOfDay << std::endl; std::cout << " Time of Day: " << (int)p.mWander.mTimeOfDay << std::endl;
if (p.mWander.mShouldRepeat != 1) if (!p.mWander.mShouldRepeat)
std::cout << " Should repeat: " << (bool)p.mWander.mShouldRepeat << std::endl; std::cout << " Should repeat: " << p.mWander.mShouldRepeat << std::endl;
std::cout << " Idle: "; std::cout << " Idle: ";
for (int i = 0; i != 8; i++) for (int i = 0; i != 8; i++)

@ -28,13 +28,13 @@ namespace ESSImport
cStats.mAttributes[i].mCurrent = acdt.mAttributes[i][0]; cStats.mAttributes[i].mCurrent = acdt.mAttributes[i][0];
} }
cStats.mGoldPool = acdt.mGoldPool; cStats.mGoldPool = acdt.mGoldPool;
cStats.mTalkedTo = acdt.mFlags & TalkedToPlayer; cStats.mTalkedTo = (acdt.mFlags & TalkedToPlayer) != 0;
cStats.mAttacked = acdt.mFlags & Attacked; cStats.mAttacked = (acdt.mFlags & Attacked) != 0;
} }
void convertACSC (const ACSC& acsc, ESM::CreatureStats& cStats) void convertACSC (const ACSC& acsc, ESM::CreatureStats& cStats)
{ {
cStats.mDead = acsc.mFlags & Dead; cStats.mDead = (acsc.mFlags & Dead) != 0;
} }
void convertNpcData (const ActorData& actorData, ESM::NpcStats& npcStats) void convertNpcData (const ActorData& actorData, ESM::NpcStats& npcStats)

@ -43,7 +43,7 @@ namespace ESSImport
{ {
unsigned int deleted; unsigned int deleted;
esm.getHT(deleted); esm.getHT(deleted);
mDeleted = (deleted >> 24) & 0x2; // the other 3 bytes seem to be uninitialized garbage mDeleted = ((deleted >> 24) & 0x2) != 0; // the other 3 bytes seem to be uninitialized garbage
} }
if (esm.isNextSub("MVRF")) if (esm.isNextSub("MVRF"))

@ -110,7 +110,7 @@ int wmain(int argc, wchar_t *wargv[]) {
std::cerr << "cfg file does not exist" << std::endl; std::cerr << "cfg file does not exist" << std::endl;
MwIniImporter importer; MwIniImporter importer;
importer.setVerbose(vm.count("verbose")); importer.setVerbose(vm.count("verbose") != 0);
// Font encoding settings // Font encoding settings
std::string encoding(vm["encoding"].as<std::string>()); std::string encoding(vm["encoding"].as<std::string>());

@ -155,7 +155,7 @@ namespace MWClass
bool Apparatus::canSell (const MWWorld::Ptr& item, int npcServices) const bool Apparatus::canSell (const MWWorld::Ptr& item, int npcServices) const
{ {
return npcServices & ESM::NPC::Apparatus; return (npcServices & ESM::NPC::Apparatus) != 0;
} }
float Apparatus::getWeight(const MWWorld::Ptr &ptr) const float Apparatus::getWeight(const MWWorld::Ptr &ptr) const

@ -164,7 +164,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
MWRender::Actors& actors = renderingInterface.getActors(); MWRender::Actors& actors = renderingInterface.getActors();
actors.insertCreature(ptr, model, ref->mBase->mFlags & ESM::Creature::Weapon); actors.insertCreature(ptr, model, (ref->mBase->mFlags & ESM::Creature::Weapon) != 0);
} }
void Creature::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWWorld::PhysicsSystem& physics) const void Creature::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWWorld::PhysicsSystem& physics) const
@ -493,7 +493,7 @@ namespace MWClass
{ {
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
return (ref->mBase->mFlags & ESM::Creature::Weapon); return (ref->mBase->mFlags & ESM::Creature::Weapon) != 0;
} }
std::string Creature::getScript (const MWWorld::Ptr& ptr) const std::string Creature::getScript (const MWWorld::Ptr& ptr) const
@ -508,7 +508,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Creature> *ref = MWWorld::LiveCellRef<ESM::Creature> *ref =
ptr.get<ESM::Creature>(); ptr.get<ESM::Creature>();
return ref->mBase->mFlags & ESM::Creature::Essential; return (ref->mBase->mFlags & ESM::Creature::Essential) != 0;
} }
void Creature::registerSelf() void Creature::registerSelf()
@ -713,7 +713,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Creature> *ref = MWWorld::LiveCellRef<ESM::Creature> *ref =
ptr.get<ESM::Creature>(); ptr.get<ESM::Creature>();
return ref->mBase->mFlags & ESM::Creature::Flies; return (ref->mBase->mFlags & ESM::Creature::Flies) != 0;
} }
bool Creature::canSwim(const MWWorld::Ptr &ptr) const bool Creature::canSwim(const MWWorld::Ptr &ptr) const

@ -192,7 +192,7 @@ namespace MWClass
bool Ingredient::canSell (const MWWorld::Ptr& item, int npcServices) const bool Ingredient::canSell (const MWWorld::Ptr& item, int npcServices) const
{ {
return npcServices & ESM::NPC::Ingredients; return (npcServices & ESM::NPC::Ingredients) != 0;
} }

@ -50,7 +50,7 @@ namespace MWClass
assert (ref->mBase != NULL); assert (ref->mBase != NULL);
if(!model.empty()) if(!model.empty())
physics.addObject(ptr, model, ref->mBase->mData.mFlags & ESM::Light::Carry); physics.addObject(ptr, model, (ref->mBase->mData.mFlags & ESM::Light::Carry) != 0);
if (!ref->mBase->mSound.empty() && !(ref->mBase->mData.mFlags & ESM::Light::OffDefault)) if (!ref->mBase->mSound.empty() && !(ref->mBase->mData.mFlags & ESM::Light::OffDefault))
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->mBase->mSound, 1.0, 1.0, MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->mBase->mSound, 1.0, 1.0,
@ -221,7 +221,7 @@ namespace MWClass
bool Light::canSell (const MWWorld::Ptr& item, int npcServices) const bool Light::canSell (const MWWorld::Ptr& item, int npcServices) const
{ {
return npcServices & ESM::NPC::Lights; return (npcServices & ESM::NPC::Lights) != 0;
} }
float Light::getWeight(const MWWorld::Ptr &ptr) const float Light::getWeight(const MWWorld::Ptr &ptr) const

@ -173,7 +173,7 @@ namespace MWClass
bool Lockpick::canSell (const MWWorld::Ptr& item, int npcServices) const bool Lockpick::canSell (const MWWorld::Ptr& item, int npcServices) const
{ {
return npcServices & ESM::NPC::Picks; return (npcServices & ESM::NPC::Picks) != 0;
} }
int Lockpick::getItemMaxHealth (const MWWorld::Ptr& ptr) const int Lockpick::getItemMaxHealth (const MWWorld::Ptr& ptr) const

@ -259,7 +259,7 @@ namespace MWClass
{ {
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>(); ptr.get<ESM::Miscellaneous>();
return ref->mBase->mData.mIsKey; return ref->mBase->mData.mIsKey != 0;
} }
} }

@ -993,7 +993,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::NPC> *ref = MWWorld::LiveCellRef<ESM::NPC> *ref =
ptr.get<ESM::NPC>(); ptr.get<ESM::NPC>();
return ref->mBase->mFlags & ESM::NPC::Essential; return (ref->mBase->mFlags & ESM::NPC::Essential) != 0;
} }
void Npc::registerSelf() void Npc::registerSelf()

@ -185,7 +185,7 @@ namespace MWClass
bool Potion::canSell (const MWWorld::Ptr& item, int npcServices) const bool Potion::canSell (const MWWorld::Ptr& item, int npcServices) const
{ {
return npcServices & ESM::NPC::Potions; return (npcServices & ESM::NPC::Potions) != 0;
} }
float Potion::getWeight(const MWWorld::Ptr &ptr) const float Potion::getWeight(const MWWorld::Ptr &ptr) const

@ -172,7 +172,7 @@ namespace MWClass
bool Probe::canSell (const MWWorld::Ptr& item, int npcServices) const bool Probe::canSell (const MWWorld::Ptr& item, int npcServices) const
{ {
return npcServices & ESM::NPC::Probes; return (npcServices & ESM::NPC::Probes) != 0;
} }
int Probe::getItemMaxHealth (const MWWorld::Ptr& ptr) const int Probe::getItemMaxHealth (const MWWorld::Ptr& ptr) const

@ -172,7 +172,7 @@ namespace MWClass
bool Repair::canSell (const MWWorld::Ptr& item, int npcServices) const bool Repair::canSell (const MWWorld::Ptr& item, int npcServices) const
{ {
return npcServices & ESM::NPC::RepairItem; return (npcServices & ESM::NPC::RepairItem) != 0;
} }
float Repair::getWeight(const MWWorld::Ptr &ptr) const float Repair::getWeight(const MWWorld::Ptr &ptr) const

@ -114,7 +114,7 @@ namespace MWGui
void EditEffectDialog::newEffect (const ESM::MagicEffect *effect) void EditEffectDialog::newEffect (const ESM::MagicEffect *effect)
{ {
bool allowSelf = effect->mData.mFlags & ESM::MagicEffect::CastSelf; bool allowSelf = (effect->mData.mFlags & ESM::MagicEffect::CastSelf) != 0;
bool allowTouch = (effect->mData.mFlags & ESM::MagicEffect::CastTouch) && !mConstantEffect; bool allowTouch = (effect->mData.mFlags & ESM::MagicEffect::CastTouch) && !mConstantEffect;
bool allowTarget = (effect->mData.mFlags & ESM::MagicEffect::CastTarget) && !mConstantEffect; bool allowTarget = (effect->mData.mFlags & ESM::MagicEffect::CastTarget) && !mConstantEffect;
@ -226,7 +226,7 @@ namespace MWGui
// cycle through range types until we find something that's allowed // cycle through range types until we find something that's allowed
// does not handle the case where nothing is allowed (this should be prevented before opening the Add Effect dialog) // does not handle the case where nothing is allowed (this should be prevented before opening the Add Effect dialog)
bool allowSelf = mMagicEffect->mData.mFlags & ESM::MagicEffect::CastSelf; bool allowSelf = (mMagicEffect->mData.mFlags & ESM::MagicEffect::CastSelf) != 0;
bool allowTouch = (mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTouch) && !mConstantEffect; bool allowTouch = (mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTouch) && !mConstantEffect;
bool allowTarget = (mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTarget) && !mConstantEffect; bool allowTarget = (mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTarget) && !mConstantEffect;
if (mEffect.mRange == ESM::RT_Self && !allowSelf) if (mEffect.mRange == ESM::RT_Self && !allowSelf)

@ -239,7 +239,7 @@ namespace MWGui
params.mMagnMin = it->mMagnMin; params.mMagnMin = it->mMagnMin;
params.mMagnMax = it->mMagnMax; params.mMagnMax = it->mMagnMax;
params.mRange = it->mRange; params.mRange = it->mRange;
params.mIsConstant = (flags & MWEffectList::EF_Constant); params.mIsConstant = (flags & MWEffectList::EF_Constant) != 0;
params.mNoTarget = (flags & MWEffectList::EF_NoTarget); params.mNoTarget = (flags & MWEffectList::EF_NoTarget);
effect->setSpellEffect(params); effect->setSpellEffect(params);
effects.push_back(effect); effects.push_back(effect);

@ -566,10 +566,10 @@ namespace MWGui
// Show the windows we want // Show the windows we want
mMap ->setVisible(eff & GW_Map); mMap ->setVisible(eff & GW_Map);
mStatsWindow ->setVisible(eff & GW_Stats); mStatsWindow ->setVisible((eff & GW_Stats) != 0);
mInventoryWindow->setVisible(eff & GW_Inventory); mInventoryWindow->setVisible((eff & GW_Inventory) != 0);
mInventoryWindow->setGuiMode(mode); mInventoryWindow->setGuiMode(mode);
mSpellWindow ->setVisible(eff & GW_Magic); mSpellWindow ->setVisible((eff & GW_Magic) != 0);
break; break;
} }
case GM_Container: case GM_Container:
@ -1301,7 +1301,7 @@ namespace MWGui
bool WindowManager::isAllowed (GuiWindow wnd) const bool WindowManager::isAllowed (GuiWindow wnd) const
{ {
return mAllowed & wnd; return (mAllowed & wnd) != 0;
} }
void WindowManager::allow (GuiWindow wnd) void WindowManager::allow (GuiWindow wnd)

@ -277,7 +277,7 @@ namespace MWGui
virtual void enableRest() { mRestAllowed = true; } virtual void enableRest() { mRestAllowed = true; }
virtual bool getRestEnabled(); virtual bool getRestEnabled();
virtual bool getJournalAllowed() { return (mAllowed & GW_Magic); } virtual bool getJournalAllowed() { return (mAllowed & GW_Magic) != 0; }
virtual bool getPlayerSleeping(); virtual bool getPlayerSleeping();
virtual void wakeUpPlayer(); virtual void wakeUpPlayer();

@ -250,7 +250,7 @@ namespace MWInput
if (mControlSwitch["playercontrols"]) if (mControlSwitch["playercontrols"])
{ {
if (action == A_Use) if (action == A_Use)
mPlayer->getPlayer().getClass().getCreatureStats(mPlayer->getPlayer()).setAttackingOrSpell(currentValue); mPlayer->getPlayer().getClass().getCreatureStats(mPlayer->getPlayer()).setAttackingOrSpell(currentValue != 0);
else if (action == A_Jump) else if (action == A_Jump)
mAttemptJump = (currentValue == 1.0 && previousValue == 0.0); mAttemptJump = (currentValue == 1.0 && previousValue == 0.0);
} }

@ -67,7 +67,7 @@ void MWMechanics::Alchemy::applyTools (int flags, float& value) const
{ {
bool magnitude = !(flags & ESM::MagicEffect::NoMagnitude); bool magnitude = !(flags & ESM::MagicEffect::NoMagnitude);
bool duration = !(flags & ESM::MagicEffect::NoDuration); bool duration = !(flags & ESM::MagicEffect::NoDuration);
bool negative = flags & (ESM::MagicEffect::Harmful); bool negative = (flags & ESM::MagicEffect::Harmful) != 0;
int tool = negative ? ESM::Apparatus::Retort : ESM::Apparatus::Albemic; int tool = negative ? ESM::Apparatus::Retort : ESM::Apparatus::Albemic;

@ -439,7 +439,7 @@ namespace MWMechanics
bool CreatureStats::getMovementFlag (Flag flag) const bool CreatureStats::getMovementFlag (Flag flag) const
{ {
return mMovementFlags & flag; return (mMovementFlags & flag) != 0;
} }
void CreatureStats::setMovementFlag (Flag flag, bool state) void CreatureStats::setMovementFlag (Flag flag, bool state)

@ -35,7 +35,7 @@ namespace MWMechanics
} }
// For levelled creatures, the flags are swapped. This file format just makes so much sense. // For levelled creatures, the flags are swapped. This file format just makes so much sense.
bool allLevels = levItem->mFlags & ESM::ItemLevList::AllLevels; bool allLevels = (levItem->mFlags & ESM::ItemLevList::AllLevels) != 0;
if (creature) if (creature)
allLevels = levItem->mFlags & ESM::CreatureLevList::AllLevels; allLevels = levItem->mFlags & ESM::CreatureLevList::AllLevels;

@ -573,7 +573,7 @@ namespace MWMechanics
castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find ("VFX_DefaultHit"); castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find ("VFX_DefaultHit");
// TODO: VFX are no longer active after saving/reloading the game // TODO: VFX are no longer active after saving/reloading the game
bool loop = magicEffect->mData.mFlags & ESM::MagicEffect::ContinuousVfx; bool loop = (magicEffect->mData.mFlags & ESM::MagicEffect::ContinuousVfx) != 0;
// Note: in case of non actor, a free effect should be fine as well // Note: in case of non actor, a free effect should be fine as well
MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(target); MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(target);
if (anim) if (anim)

@ -377,7 +377,7 @@ void NpcAnimation::updateParts()
}; };
static const size_t slotlistsize = sizeof(slotlist)/sizeof(slotlist[0]); static const size_t slotlistsize = sizeof(slotlist)/sizeof(slotlist[0]);
bool wasArrowAttached = (mAmmunition.get()); bool wasArrowAttached = (mAmmunition.get() != NULL);
MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr); MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
for(size_t i = 0;i < slotlistsize && mViewMode != VM_HeadOnly;i++) for(size_t i = 0;i < slotlistsize && mViewMode != VM_HeadOnly;i++)
@ -941,7 +941,7 @@ void NpcAnimation::permanentEffectAdded(const ESM::MagicEffect *magicEffect, boo
if (!magicEffect->mHit.empty()) if (!magicEffect->mHit.empty())
{ {
const ESM::Static* castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find (magicEffect->mHit); const ESM::Static* castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find (magicEffect->mHit);
bool loop = magicEffect->mData.mFlags & ESM::MagicEffect::ContinuousVfx; bool loop = (magicEffect->mData.mFlags & ESM::MagicEffect::ContinuousVfx) != 0;
// Don't play particle VFX unless the effect is new or it should be looping. // Don't play particle VFX unless the effect is new or it should be looping.
if (isNew || loop) if (isNew || loop)
addEffect("meshes\\" + castStatic->mModel, magicEffect->mIndex, loop, ""); addEffect("meshes\\" + castStatic->mModel, magicEffect->mIndex, loop, "");

@ -81,7 +81,7 @@ namespace MWScript
std::string name = runtime.getStringLiteral (runtime[0].mInteger); std::string name = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop(); runtime.pop();
bool allowSkipping = runtime[0].mInteger; bool allowSkipping = runtime[0].mInteger != 0;
runtime.pop(); runtime.pop();
MWBase::Environment::get().getWindowManager()->playVideo (name, allowSkipping); MWBase::Environment::get().getWindowManager()->playVideo (name, allowSkipping);

@ -59,7 +59,7 @@ namespace MWWorld
} }
RefData::RefData (const ESM::ObjectState& objectState) RefData::RefData (const ESM::ObjectState& objectState)
: mBaseNode (0), mHasLocals (false), mEnabled (objectState.mEnabled), : mBaseNode (0), mHasLocals (false), mEnabled (objectState.mEnabled != 0),
mCount (objectState.mCount), mPosition (objectState.mPosition), mCustomData (0), mCount (objectState.mCount), mPosition (objectState.mPosition), mCustomData (0),
mChanged(true), // Loading from a savegame -> assume changed mChanged(true), // Loading from a savegame -> assume changed
mDeleted(false) mDeleted(false)

@ -32,7 +32,7 @@ namespace ESM
short mDuration; short mDuration;
unsigned char mTimeOfDay; unsigned char mTimeOfDay;
unsigned char mIdle[8]; unsigned char mIdle[8];
unsigned char mShouldRepeat; bool mShouldRepeat;
}; };
struct AITravel struct AITravel

@ -44,7 +44,7 @@ namespace ESM
short mDuration; short mDuration;
unsigned char mTimeOfDay; unsigned char mTimeOfDay;
unsigned char mIdle[8]; unsigned char mIdle[8];
unsigned char mShouldRepeat; bool mShouldRepeat;
}; };
struct AiTravelData struct AiTravelData
{ {

@ -10,7 +10,7 @@ namespace ESM {
void Creature::load(ESMReader &esm) void Creature::load(ESMReader &esm)
{ {
mPersistent = esm.getRecordFlags() & 0x0400; mPersistent = (esm.getRecordFlags() & 0x0400) != 0;
mAiPackage.mList.clear(); mAiPackage.mList.clear();
mInventory.mList.clear(); mInventory.mList.clear();

@ -10,7 +10,7 @@ namespace ESM
void NPC::load(ESMReader &esm) void NPC::load(ESMReader &esm)
{ {
mPersistent = esm.getRecordFlags() & 0x0400; mPersistent = (esm.getRecordFlags() & 0x0400) != 0;
mSpells.mList.clear(); mSpells.mList.clear();
mInventory.mList.clear(); mInventory.mList.clear();

@ -10,7 +10,7 @@ namespace ESM
void Static::load(ESMReader &esm) void Static::load(ESMReader &esm)
{ {
mPersistent = esm.getRecordFlags() & 0x0400; mPersistent = (esm.getRecordFlags() & 0x0400) != 0;
mModel = esm.getHNString("MODL"); mModel = esm.getHNString("MODL");
} }

@ -234,7 +234,7 @@ class NiVisData : public Record
public: public:
struct VisData { struct VisData {
float time; float time;
char isSet; bool isSet;
}; };
std::vector<VisData> mVis; std::vector<VisData> mVis;
@ -245,7 +245,7 @@ public:
for(size_t i = 0;i < mVis.size();i++) for(size_t i = 0;i < mVis.size();i++)
{ {
mVis[i].time = nif->getFloat(); mVis[i].time = nif->getFloat();
mVis[i].isSet = nif->getChar(); mVis[i].isSet = nif->getChar() != 0;
} }
} }
}; };

@ -379,7 +379,7 @@ public:
return mData.back().isSet; return mData.back().isSet;
} }
static void setVisible(Ogre::Node *node, int vis) static void setVisible(Ogre::Node *node, bool vis)
{ {
// Skinned meshes are attached to the scene node, not the bone. // Skinned meshes are attached to the scene node, not the bone.
// We use the Node's user data to connect it with the mesh. // We use the Node's user data to connect it with the mesh.
@ -746,16 +746,17 @@ private:
{ {
if (ctrl->flags & Nif::NiNode::ControllerFlag_Active) if (ctrl->flags & Nif::NiNode::ControllerFlag_Active)
{ {
bool isAnimationAutoPlay = (animflags & Nif::NiNode::AnimFlag_AutoPlay) != 0;
if(ctrl->recType == Nif::RC_NiUVController) if(ctrl->recType == Nif::RC_NiUVController)
{ {
const Nif::NiUVController *uv = static_cast<const Nif::NiUVController*>(ctrl.getPtr()); const Nif::NiUVController *uv = static_cast<const Nif::NiUVController*>(ctrl.getPtr());
Ogre::ControllerValueRealPtr srcval((animflags&Nif::NiNode::AnimFlag_AutoPlay) ? Ogre::ControllerValueRealPtr srcval(isAnimationAutoPlay ?
Ogre::ControllerManager::getSingleton().getFrameTimeSource() : Ogre::ControllerManager::getSingleton().getFrameTimeSource() :
Ogre::ControllerValueRealPtr()); Ogre::ControllerValueRealPtr());
Ogre::ControllerValueRealPtr dstval(OGRE_NEW UVController::Value(entity, uv->data.getPtr(), &scene->mMaterialControllerMgr)); Ogre::ControllerValueRealPtr dstval(OGRE_NEW UVController::Value(entity, uv->data.getPtr(), &scene->mMaterialControllerMgr));
UVController::Function* function = OGRE_NEW UVController::Function(uv, (animflags&Nif::NiNode::AnimFlag_AutoPlay)); UVController::Function* function = OGRE_NEW UVController::Function(uv, isAnimationAutoPlay);
scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength); scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength);
Ogre::ControllerFunctionRealPtr func(function); Ogre::ControllerFunctionRealPtr func(function);
@ -765,13 +766,13 @@ private:
{ {
const Nif::NiGeomMorpherController *geom = static_cast<const Nif::NiGeomMorpherController*>(ctrl.getPtr()); const Nif::NiGeomMorpherController *geom = static_cast<const Nif::NiGeomMorpherController*>(ctrl.getPtr());
Ogre::ControllerValueRealPtr srcval((animflags&Nif::NiNode::AnimFlag_AutoPlay) ? Ogre::ControllerValueRealPtr srcval(isAnimationAutoPlay ?
Ogre::ControllerManager::getSingleton().getFrameTimeSource() : Ogre::ControllerManager::getSingleton().getFrameTimeSource() :
Ogre::ControllerValueRealPtr()); Ogre::ControllerValueRealPtr());
Ogre::ControllerValueRealPtr dstval(OGRE_NEW GeomMorpherController::Value( Ogre::ControllerValueRealPtr dstval(OGRE_NEW GeomMorpherController::Value(
entity, geom->data.getPtr(), geom->recIndex)); entity, geom->data.getPtr(), geom->recIndex));
GeomMorpherController::Function* function = OGRE_NEW GeomMorpherController::Function(geom, (animflags&Nif::NiNode::AnimFlag_AutoPlay)); GeomMorpherController::Function* function = OGRE_NEW GeomMorpherController::Function(geom, isAnimationAutoPlay);
scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength); scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength);
Ogre::ControllerFunctionRealPtr func(function); Ogre::ControllerFunctionRealPtr func(function);
@ -796,7 +797,8 @@ private:
const Nif::NiStencilProperty *stencilprop = NULL; const Nif::NiStencilProperty *stencilprop = NULL;
node->getProperties(texprop, matprop, alphaprop, vertprop, zprop, specprop, wireprop, stencilprop); node->getProperties(texprop, matprop, alphaprop, vertprop, zprop, specprop, wireprop, stencilprop);
Ogre::ControllerValueRealPtr srcval((animflags&Nif::NiNode::AnimFlag_AutoPlay) ? bool isAnimationAutoPlay = (animflags & Nif::NiNode::AnimFlag_AutoPlay) != 0;
Ogre::ControllerValueRealPtr srcval(isAnimationAutoPlay ?
Ogre::ControllerManager::getSingleton().getFrameTimeSource() : Ogre::ControllerManager::getSingleton().getFrameTimeSource() :
Ogre::ControllerValueRealPtr()); Ogre::ControllerValueRealPtr());
@ -809,7 +811,7 @@ private:
{ {
const Nif::NiAlphaController *alphaCtrl = static_cast<const Nif::NiAlphaController*>(ctrls.getPtr()); const Nif::NiAlphaController *alphaCtrl = static_cast<const Nif::NiAlphaController*>(ctrls.getPtr());
Ogre::ControllerValueRealPtr dstval(OGRE_NEW AlphaController::Value(movable, alphaCtrl->data.getPtr(), &scene->mMaterialControllerMgr)); Ogre::ControllerValueRealPtr dstval(OGRE_NEW AlphaController::Value(movable, alphaCtrl->data.getPtr(), &scene->mMaterialControllerMgr));
AlphaController::Function* function = OGRE_NEW AlphaController::Function(alphaCtrl, (animflags&Nif::NiNode::AnimFlag_AutoPlay)); AlphaController::Function* function = OGRE_NEW AlphaController::Function(alphaCtrl, isAnimationAutoPlay);
scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength); scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength);
Ogre::ControllerFunctionRealPtr func(function); Ogre::ControllerFunctionRealPtr func(function);
scene->mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func)); scene->mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func));
@ -818,7 +820,7 @@ private:
{ {
const Nif::NiMaterialColorController *matCtrl = static_cast<const Nif::NiMaterialColorController*>(ctrls.getPtr()); const Nif::NiMaterialColorController *matCtrl = static_cast<const Nif::NiMaterialColorController*>(ctrls.getPtr());
Ogre::ControllerValueRealPtr dstval(OGRE_NEW MaterialColorController::Value(movable, matCtrl->data.getPtr(), &scene->mMaterialControllerMgr)); Ogre::ControllerValueRealPtr dstval(OGRE_NEW MaterialColorController::Value(movable, matCtrl->data.getPtr(), &scene->mMaterialControllerMgr));
MaterialColorController::Function* function = OGRE_NEW MaterialColorController::Function(matCtrl, (animflags&Nif::NiNode::AnimFlag_AutoPlay)); MaterialColorController::Function* function = OGRE_NEW MaterialColorController::Function(matCtrl, isAnimationAutoPlay);
scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength); scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength);
Ogre::ControllerFunctionRealPtr func(function); Ogre::ControllerFunctionRealPtr func(function);
scene->mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func)); scene->mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func));
@ -839,7 +841,7 @@ private:
Ogre::ControllerValueRealPtr dstval(OGRE_NEW FlipController::Value( Ogre::ControllerValueRealPtr dstval(OGRE_NEW FlipController::Value(
movable, flipCtrl, &scene->mMaterialControllerMgr)); movable, flipCtrl, &scene->mMaterialControllerMgr));
FlipController::Function* function = OGRE_NEW FlipController::Function(flipCtrl, (animflags&Nif::NiNode::AnimFlag_AutoPlay)); FlipController::Function* function = OGRE_NEW FlipController::Function(flipCtrl, isAnimationAutoPlay);
scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength); scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength);
Ogre::ControllerFunctionRealPtr func(function); Ogre::ControllerFunctionRealPtr func(function);
scene->mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func)); scene->mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func));
@ -967,7 +969,7 @@ private:
partsys->setCullIndividually(false); partsys->setCullIndividually(false);
partsys->setParticleQuota(particledata->numParticles); partsys->setParticleQuota(particledata->numParticles);
partsys->setKeepParticlesInLocalSpace(partflags & (Nif::NiNode::ParticleFlag_LocalSpace)); partsys->setKeepParticlesInLocalSpace((partflags & Nif::NiNode::ParticleFlag_LocalSpace) != 0);
int trgtid = NIFSkeletonLoader::lookupOgreBoneHandle(name, partnode->recIndex); int trgtid = NIFSkeletonLoader::lookupOgreBoneHandle(name, partnode->recIndex);
Ogre::Bone *trgtbone = scene->mSkelBase->getSkeleton()->getBone(trgtid); Ogre::Bone *trgtbone = scene->mSkelBase->getSkeleton()->getBone(trgtid);
@ -1017,13 +1019,14 @@ private:
createParticleInitialState(partsys, particledata, partctrl); createParticleInitialState(partsys, particledata, partctrl);
Ogre::ControllerValueRealPtr srcval((partflags&Nif::NiNode::ParticleFlag_AutoPlay) ? bool isParticleAutoPlay = (partflags&Nif::NiNode::ParticleFlag_AutoPlay) != 0;
Ogre::ControllerValueRealPtr srcval(isParticleAutoPlay ?
Ogre::ControllerManager::getSingleton().getFrameTimeSource() : Ogre::ControllerManager::getSingleton().getFrameTimeSource() :
Ogre::ControllerValueRealPtr()); Ogre::ControllerValueRealPtr());
Ogre::ControllerValueRealPtr dstval(OGRE_NEW ParticleSystemController::Value(partsys, partctrl)); Ogre::ControllerValueRealPtr dstval(OGRE_NEW ParticleSystemController::Value(partsys, partctrl));
ParticleSystemController::Function* function = ParticleSystemController::Function* function =
OGRE_NEW ParticleSystemController::Function(partctrl, (partflags&Nif::NiNode::ParticleFlag_AutoPlay)); OGRE_NEW ParticleSystemController::Function(partctrl, isParticleAutoPlay);
scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength); scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength);
Ogre::ControllerFunctionRealPtr func(function); Ogre::ControllerFunctionRealPtr func(function);
@ -1032,7 +1035,7 @@ private:
// Emitting state will be overwritten on frame update by the ParticleSystemController, // Emitting state will be overwritten on frame update by the ParticleSystemController,
// but set up an initial value anyway so the user can fast-forward particle systems // but set up an initial value anyway so the user can fast-forward particle systems
// immediately after creation if desired. // immediately after creation if desired.
partsys->setEmitting(partflags&Nif::NiNode::ParticleFlag_AutoPlay); partsys->setEmitting(isParticleAutoPlay);
} }
ctrl = ctrl->next; ctrl = ctrl->next;
} }
@ -1094,18 +1097,19 @@ private:
do { do {
if (ctrl->flags & Nif::NiNode::ControllerFlag_Active) if (ctrl->flags & Nif::NiNode::ControllerFlag_Active)
{ {
bool isAnimationAutoPlay = (animflags & Nif::NiNode::AnimFlag_AutoPlay) != 0;
if(ctrl->recType == Nif::RC_NiVisController) if(ctrl->recType == Nif::RC_NiVisController)
{ {
const Nif::NiVisController *vis = static_cast<const Nif::NiVisController*>(ctrl.getPtr()); const Nif::NiVisController *vis = static_cast<const Nif::NiVisController*>(ctrl.getPtr());
int trgtid = NIFSkeletonLoader::lookupOgreBoneHandle(name, ctrl->target->recIndex); int trgtid = NIFSkeletonLoader::lookupOgreBoneHandle(name, ctrl->target->recIndex);
Ogre::Bone *trgtbone = scene->mSkelBase->getSkeleton()->getBone(trgtid); Ogre::Bone *trgtbone = scene->mSkelBase->getSkeleton()->getBone(trgtid);
Ogre::ControllerValueRealPtr srcval((animflags&Nif::NiNode::AnimFlag_AutoPlay) ? Ogre::ControllerValueRealPtr srcval(isAnimationAutoPlay ?
Ogre::ControllerManager::getSingleton().getFrameTimeSource() : Ogre::ControllerManager::getSingleton().getFrameTimeSource() :
Ogre::ControllerValueRealPtr()); Ogre::ControllerValueRealPtr());
Ogre::ControllerValueRealPtr dstval(OGRE_NEW VisController::Value(trgtbone, vis->data.getPtr())); Ogre::ControllerValueRealPtr dstval(OGRE_NEW VisController::Value(trgtbone, vis->data.getPtr()));
VisController::Function* function = OGRE_NEW VisController::Function(vis, (animflags&Nif::NiNode::AnimFlag_AutoPlay)); VisController::Function* function = OGRE_NEW VisController::Function(vis, isAnimationAutoPlay);
scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength); scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength);
Ogre::ControllerFunctionRealPtr func(function); Ogre::ControllerFunctionRealPtr func(function);
@ -1120,11 +1124,11 @@ private:
Ogre::Bone *trgtbone = scene->mSkelBase->getSkeleton()->getBone(trgtid); Ogre::Bone *trgtbone = scene->mSkelBase->getSkeleton()->getBone(trgtid);
// The keyframe controller will control this bone manually // The keyframe controller will control this bone manually
trgtbone->setManuallyControlled(true); trgtbone->setManuallyControlled(true);
Ogre::ControllerValueRealPtr srcval((animflags&Nif::NiNode::AnimFlag_AutoPlay) ? Ogre::ControllerValueRealPtr srcval(isAnimationAutoPlay ?
Ogre::ControllerManager::getSingleton().getFrameTimeSource() : Ogre::ControllerManager::getSingleton().getFrameTimeSource() :
Ogre::ControllerValueRealPtr()); Ogre::ControllerValueRealPtr());
Ogre::ControllerValueRealPtr dstval(OGRE_NEW KeyframeController::Value(trgtbone, nif, key->data.getPtr())); Ogre::ControllerValueRealPtr dstval(OGRE_NEW KeyframeController::Value(trgtbone, nif, key->data.getPtr()));
KeyframeController::Function* function = OGRE_NEW KeyframeController::Function(key, (animflags&Nif::NiNode::AnimFlag_AutoPlay)); KeyframeController::Function* function = OGRE_NEW KeyframeController::Function(key, isAnimationAutoPlay);
scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength); scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength);
Ogre::ControllerFunctionRealPtr func(function); Ogre::ControllerFunctionRealPtr func(function);

@ -35,7 +35,7 @@ namespace Terrain
MaterialGenerator (); MaterialGenerator ();
void setLayerList (const std::vector<LayerInfo>& layerList) { mLayerList = layerList; } void setLayerList (const std::vector<LayerInfo>& layerList) { mLayerList = layerList; }
bool hasLayers() { return mLayerList.size(); } bool hasLayers() { return mLayerList.size() > 0; }
void setBlendmapList (const std::vector<Ogre::TexturePtr>& blendmapList) { mBlendmapList = blendmapList; } void setBlendmapList (const std::vector<Ogre::TexturePtr>& blendmapList) { mBlendmapList = blendmapList; }
const std::vector<Ogre::TexturePtr>& getBlendmapList() { return mBlendmapList; } const std::vector<Ogre::TexturePtr>& getBlendmapList() { return mBlendmapList; }
void setCompositeMap (const std::string& name) { mCompositeMap = name; } void setCompositeMap (const std::string& name) { mCompositeMap = name; }

@ -201,12 +201,12 @@ namespace SFO
bool InputWrapper::isModifierHeld(SDL_Keymod mod) bool InputWrapper::isModifierHeld(SDL_Keymod mod)
{ {
return SDL_GetModState() & mod; return (SDL_GetModState() & mod) != 0;
} }
bool InputWrapper::isKeyDown(SDL_Scancode key) bool InputWrapper::isKeyDown(SDL_Scancode key)
{ {
return SDL_GetKeyboardState(NULL)[key]; return (SDL_GetKeyboardState(NULL)[key]) != 0;
} }
/// \brief Moves the mouse to the specified point within the viewport /// \brief Moves the mouse to the specified point within the viewport

@ -283,14 +283,14 @@ namespace Physic
} }
} }
void PhysicEngine::setDebugRenderingMode(int mode) void PhysicEngine::setDebugRenderingMode(bool isDebug)
{ {
if(!isDebugCreated) if(!isDebugCreated)
{ {
createDebugRendering(); createDebugRendering();
} }
mDebugDrawer->setDebugMode(mode); mDebugDrawer->setDebugMode(isDebug);
mDebugActive = mode; mDebugActive = isDebug;
} }
bool PhysicEngine::toggleDebugRendering() bool PhysicEngine::toggleDebugRendering()

@ -283,7 +283,7 @@ namespace Physic
* Set the debug rendering mode. 0 to turn it off. * Set the debug rendering mode. 0 to turn it off.
* Important Note: this will crash if the Render is not yet initialise! * Important Note: this will crash if the Render is not yet initialise!
*/ */
void setDebugRenderingMode(int mode); void setDebugRenderingMode(bool isDebug);
bool toggleDebugRendering(); bool toggleDebugRendering();

Loading…
Cancel
Save