Fixes for MSVC warnings, less overall changes

Kept some fixes from the first round of review. Found out that several
targets weren't being built with the same basic warnings disabled.
Disabled a few warnings for external libraries specifically, rather than
applying them to all targets.
deque
slothlife 11 years ago
parent c160a04ede
commit f33559fead

@ -594,6 +594,7 @@ if (WIN32)
4706 # Assignment in conditional expression 4706 # Assignment in conditional expression
4738 # Storing 32-bit float result in memory, possible loss of performance 4738 # Storing 32-bit float result in memory, possible loss of performance
4986 # Undocumented warning that occurs in the crtdbg.h file 4986 # Undocumented warning that occurs in the crtdbg.h file
4987 # nonstandard extension used (triggered by setjmp.h)
4996 # Function was declared deprecated 4996 # Function was declared deprecated
# cause by ogre extensivly # cause by ogre extensivly
@ -610,7 +611,9 @@ if (WIN32)
4305 # Truncating value (double to float, for example) 4305 # Truncating value (double to float, for example)
4309 # Variable overflow, trying to store 128 in a signed char for example 4309 # Variable overflow, trying to store 128 in a signed char for example
4355 # Using 'this' in member initialization list 4355 # Using 'this' in member initialization list
4505 # Unreferenced local function has been removed
4701 # Potentially uninitialized local variable used 4701 # Potentially uninitialized local variable used
4702 # Unreachable code
4800 # Boolean optimization warning, e.g. myBool = (myInt != 0) instead of myBool = myInt 4800 # Boolean optimization warning, e.g. myBool = (myInt != 0) instead of myBool = myInt
) )
@ -618,19 +621,31 @@ if (WIN32)
set(WARNINGS "${WARNINGS} /wd${d}") set(WARNINGS "${WARNINGS} /wd${d}")
endforeach(d) endforeach(d)
set_target_properties(shiny PROPERTIES COMPILE_FLAGS ${WARNINGS}) # boost::wave has a few issues with signed / unsigned conversions, so we suppress those here
set_target_properties(shiny.OgrePlatform PROPERTIES COMPILE_FLAGS ${WARNINGS}) set(SHINY_WARNINGS "${WARNINGS} /wd4245")
set_target_properties(shiny PROPERTIES COMPILE_FLAGS ${SHINY_WARNINGS})
# there's an unreferenced local variable in the ogre platform, suppress it
set(SHINY_OGRE_WARNINGS "${WARNINGS} /wd4101")
set_target_properties(shiny.OgrePlatform PROPERTIES COMPILE_FLAGS ${SHINY_OGRE_WARNINGS})
set_target_properties(sdl4ogre PROPERTIES COMPILE_FLAGS ${WARNINGS})
set_target_properties(oics PROPERTIES COMPILE_FLAGS ${WARNINGS})
set_target_properties(components PROPERTIES COMPILE_FLAGS ${WARNINGS}) set_target_properties(components PROPERTIES COMPILE_FLAGS ${WARNINGS})
if (BUILD_LAUNCHER) if (BUILD_LAUNCHER)
set_target_properties(omwlauncher PROPERTIES COMPILE_FLAGS ${WARNINGS}) set_target_properties(omwlauncher PROPERTIES COMPILE_FLAGS ${WARNINGS})
endif (BUILD_LAUNCHER) endif (BUILD_LAUNCHER)
set_target_properties(openmw PROPERTIES COMPILE_FLAGS ${WARNINGS}) set_target_properties(openmw PROPERTIES COMPILE_FLAGS ${WARNINGS})
if (BUILD_BSATOOL) if (BUILD_BSATOOL)
set_target_properties(bsatool PROPERTIES COMPILE_FLAGS ${WARNINGS}) set_target_properties(bsatool PROPERTIES COMPILE_FLAGS ${WARNINGS})
endif (BUILD_BSATOOL) endif (BUILD_BSATOOL)
if (BUILD_ESMTOOL) if (BUILD_ESMTOOL)
set_target_properties(esmtool PROPERTIES COMPILE_FLAGS ${WARNINGS}) set_target_properties(esmtool PROPERTIES COMPILE_FLAGS ${WARNINGS})
endif (BUILD_ESMTOOL) endif (BUILD_ESMTOOL)
if (BUILD_OPENCS)
set_target_properties(opencs PROPERTIES COMPILE_FLAGS ${WARNINGS})
endif (BUILD_OPENCS)
if (BUILD_MWINIIMPORTER)
set_target_properties(mwiniimport PROPERTIES COMPILE_FLAGS ${WARNINGS})
endif (BUILD_MWINIIMPORTER)
endif(MSVC) endif(MSVC)
# Same for MinGW # Same for MinGW

@ -79,7 +79,7 @@ void CSVWorld::VarTypeDelegateFactory::add (ESM::VarType type)
std::vector<std::string> enums = std::vector<std::string> enums =
CSMWorld::Columns::getEnums (CSMWorld::Columns::ColumnId_ValueType); CSMWorld::Columns::getEnums (CSMWorld::Columns::ColumnId_ValueType);
if (type<0 && type>=enums.size()) if (static_cast<size_t>(type) >= enums.size())
throw std::logic_error ("Unsupported variable type"); throw std::logic_error ("Unsupported variable type");
mValues.push_back (std::make_pair (type, QString::fromUtf8 (enums[type].c_str()))); mValues.push_back (std::make_pair (type, QString::fromUtf8 (enums[type].c_str())));

@ -695,6 +695,8 @@ protected:
typedef TypesetBookImpl::Section Section; typedef TypesetBookImpl::Section Section;
typedef TypesetBookImpl::Line Line; typedef TypesetBookImpl::Line Line;
typedef TypesetBookImpl::Run Run; typedef TypesetBookImpl::Run Run;
bool mIsPageReset;
size_t mPage;
struct TextFormat : ISubWidget struct TextFormat : ISubWidget
{ {
@ -745,6 +747,23 @@ protected:
void destroyDrawItem() {}; void destroyDrawItem() {};
}; };
void resetPage()
{
mIsPageReset = true;
mPage = 0;
}
void setPage(size_t page)
{
mIsPageReset = false;
mPage = page;
}
bool isPageDifferent(size_t page)
{
return mIsPageReset || (mPage != page);
}
public: public:
typedef TypesetBookImpl::StyleImpl Style; typedef TypesetBookImpl::StyleImpl Style;
@ -760,14 +779,13 @@ public:
boost::shared_ptr <TypesetBookImpl> mBook; boost::shared_ptr <TypesetBookImpl> mBook;
size_t mPage;
MyGUI::ILayerNode* mNode; MyGUI::ILayerNode* mNode;
ActiveTextFormats mActiveTextFormats; ActiveTextFormats mActiveTextFormats;
PageDisplay () PageDisplay ()
{ {
mPage = -1; resetPage ();
mViewTop = 0; mViewTop = 0;
mViewBottom = 0; mViewBottom = 0;
mFocusItem = NULL; mFocusItem = NULL;
@ -901,7 +919,7 @@ public:
createActiveFormats (newBook); createActiveFormats (newBook);
mBook = newBook; mBook = newBook;
mPage = newPage; setPage (newPage);
if (newPage < mBook->mPages.size ()) if (newPage < mBook->mPages.size ())
{ {
@ -917,19 +935,19 @@ public:
else else
{ {
mBook.reset (); mBook.reset ();
mPage = -1; resetPage ();
mViewTop = 0; mViewTop = 0;
mViewBottom = 0; mViewBottom = 0;
} }
} }
else else
if (mBook && mPage != newPage) if (mBook && isPageDifferent (newPage))
{ {
if (mNode != NULL) if (mNode != NULL)
for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i) for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i)
mNode->outOfDate(i->second->mRenderItem); mNode->outOfDate(i->second->mRenderItem);
mPage = newPage; setPage (newPage);
if (newPage < mBook->mPages.size ()) if (newPage < mBook->mPages.size ())
{ {

@ -25,7 +25,7 @@ namespace MWGui
ItemView* mItemView; ItemView* mItemView;
SortFilterItemModel* mSortModel; SortFilterItemModel* mSortModel;
CompanionItemModel* mModel; CompanionItemModel* mModel;
size_t mSelectedItem; int mSelectedItem;
DragAndDrop* mDragAndDrop; DragAndDrop* mDragAndDrop;

@ -62,7 +62,7 @@ namespace MWGui
MWGui::ItemView* mItemView; MWGui::ItemView* mItemView;
SortFilterItemModel* mSortModel; SortFilterItemModel* mSortModel;
ItemModel* mModel; ItemModel* mModel;
size_t mSelectedItem; int mSelectedItem;
MyGUI::Button* mDisposeCorpseButton; MyGUI::Button* mDisposeCorpseButton;
MyGUI::Button* mTakeButton; MyGUI::Button* mTakeButton;

@ -510,7 +510,7 @@ namespace MWGui
void DialogueWindow::onScrollbarMoved(MyGUI::ScrollBar *sender, size_t pos) void DialogueWindow::onScrollbarMoved(MyGUI::ScrollBar *sender, size_t pos)
{ {
mHistory->setPosition(0,-pos); mHistory->setPosition(0, pos * -1);
} }
void DialogueWindow::addResponse(const std::string &text, const std::string &title) void DialogueWindow::addResponse(const std::string &text, const std::string &title)

@ -52,7 +52,7 @@ namespace MWGui
DragAndDrop* mDragAndDrop; DragAndDrop* mDragAndDrop;
bool mPreviewDirty; bool mPreviewDirty;
size_t mSelectedItem; int mSelectedItem;
MWWorld::Ptr mPtr; MWWorld::Ptr mPtr;

@ -42,6 +42,8 @@ namespace MWGui
std::map <int, std::vector<MagicEffectInfo> > mEffectSources; std::map <int, std::vector<MagicEffectInfo> > mEffectSources;
virtual ~EffectSourceVisitor() {}
virtual void visit (MWMechanics::EffectKey key, virtual void visit (MWMechanics::EffectKey key,
const std::string& sourceName, const std::string& casterHandle, const std::string& sourceName, const std::string& casterHandle,
float magnitude, float remainingTime = -1); float magnitude, float remainingTime = -1);

@ -146,8 +146,8 @@ namespace MWMechanics
|| weapon.get<ESM::Weapon>()->mBase->mData.mFlags & ESM::Weapon::Magical)) || weapon.get<ESM::Weapon>()->mBase->mData.mFlags & ESM::Weapon::Magical))
damage *= multiplier; damage *= multiplier;
if (weapon.get<ESM::Weapon>()->mBase->mData.mFlags & ESM::Weapon::Silver if ((weapon.get<ESM::Weapon>()->mBase->mData.mFlags & ESM::Weapon::Silver)
& actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) && actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
damage *= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fWereWolfSilverWeaponDamageMult")->getFloat(); damage *= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fWereWolfSilverWeaponDamageMult")->getFloat();
if (damage == 0 && attacker.getRefData().getHandle() == "player") if (damage == 0 && attacker.getRefData().getHandle() == "player")

@ -70,7 +70,7 @@ namespace MWMechanics
return getLevelledItem(ref.getPtr().get<ESM::CreatureLevList>()->mBase, failChance); return getLevelledItem(ref.getPtr().get<ESM::CreatureLevList>()->mBase, failChance);
} }
} }
catch (std::logic_error& e) catch (std::logic_error&)
{ {
// Vanilla doesn't fail on nonexistent items in levelled lists // Vanilla doesn't fail on nonexistent items in levelled lists
std::cerr << "Warning: ignoring nonexistent item '" << item << "'" << std::endl; std::cerr << "Warning: ignoring nonexistent item '" << item << "'" << std::endl;

@ -267,7 +267,7 @@ void LocalMap::render(const float x, const float y,
// initialize to (0, 0, 0, 1) // initialize to (0, 0, 0, 1)
for (int p=0; p<sFogOfWarResolution*sFogOfWarResolution; ++p) for (int p=0; p<sFogOfWarResolution*sFogOfWarResolution; ++p)
{ {
buffer[p] = (255 << 24); buffer[p] = 0xFF000000;
} }
memcpy(tex2->getBuffer()->lock(HardwareBuffer::HBL_DISCARD), &buffer[0], sFogOfWarResolution*sFogOfWarResolution*4); memcpy(tex2->getBuffer()->lock(HardwareBuffer::HBL_DISCARD), &buffer[0], sFogOfWarResolution*sFogOfWarResolution*4);

@ -35,7 +35,7 @@ OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNod
mSupported = (mSunTotalAreaQuery != 0) && (mSunVisibleAreaQuery != 0); mSupported = (mSunTotalAreaQuery != 0) && (mSunVisibleAreaQuery != 0);
} }
catch (Ogre::Exception& e) catch (Ogre::Exception&)
{ {
mSupported = false; mSupported = false;
} }

@ -33,6 +33,7 @@ namespace MWRender
{ {
public: public:
WeaponAnimation() : mPitchFactor(0) {} WeaponAnimation() : mPitchFactor(0) {}
virtual ~WeaponAnimation() {}
virtual void attachArrow(MWWorld::Ptr actor); virtual void attachArrow(MWWorld::Ptr actor);
virtual void releaseArrow(MWWorld::Ptr actor); virtual void releaseArrow(MWWorld::Ptr actor);

@ -295,7 +295,7 @@ namespace MWScript
{ {
store = MWBase::Environment::get().getWorld()->getInterior(cellID); store = MWBase::Environment::get().getWorld()->getInterior(cellID);
} }
catch(std::exception &e) catch(std::exception&)
{ {
const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getExterior(cellID); const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getExterior(cellID);
if(cell) if(cell)
@ -395,7 +395,7 @@ namespace MWScript
{ {
store = MWBase::Environment::get().getWorld()->getInterior(cellID); store = MWBase::Environment::get().getWorld()->getInterior(cellID);
} }
catch(std::exception &e) catch(std::exception&)
{ {
const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getExterior(cellID); const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getExterior(cellID);
if(cell) if(cell)

@ -204,7 +204,7 @@ void FFmpeg_Decoder::open(const std::string &fname)
mFrame = avcodec_alloc_frame(); mFrame = avcodec_alloc_frame();
} }
catch(std::exception &e) catch(std::exception&)
{ {
if (mFormatCtx->pb->buffer != NULL) if (mFormatCtx->pb->buffer != NULL)
{ {

@ -288,7 +288,7 @@ OpenAL_SoundStream::OpenAL_SoundStream(OpenAL_Output &output, ALuint src, Decode
mOutput.mActiveSounds.push_back(this); mOutput.mActiveSounds.push_back(this);
} }
catch(std::exception &e) catch(std::exception&)
{ {
alDeleteBuffers(sNumBuffers, mBuffers); alDeleteBuffers(sNumBuffers, mBuffers);
alGetError(); alGetError();
@ -471,7 +471,7 @@ bool OpenAL_SoundStream::process()
mIsFinished = finished; mIsFinished = finished;
} }
catch(std::exception &e) { catch(std::exception&) {
std::cout<< "Error updating stream \""<<mDecoder->getName()<<"\"" <<std::endl; std::cout<< "Error updating stream \""<<mDecoder->getName()<<"\"" <<std::endl;
mSamplesQueued = 0; mSamplesQueued = 0;
mIsFinished = true; mIsFinished = true;
@ -781,7 +781,7 @@ ALuint OpenAL_Output::getBuffer(const std::string &fname)
{ {
decoder->open(fname); decoder->open(fname);
} }
catch(Ogre::FileNotFoundException &e) catch(Ogre::FileNotFoundException&)
{ {
std::string::size_type pos = fname.rfind('.'); std::string::size_type pos = fname.rfind('.');
if(pos == std::string::npos) if(pos == std::string::npos)
@ -859,7 +859,7 @@ MWBase::SoundPtr OpenAL_Output::playSound(const std::string &fname, float vol, f
buf = getBuffer(fname); buf = getBuffer(fname);
sound.reset(new OpenAL_Sound(*this, src, buf, Ogre::Vector3(0.0f), vol, basevol, pitch, 1.0f, 1000.0f, flags)); sound.reset(new OpenAL_Sound(*this, src, buf, Ogre::Vector3(0.0f), vol, basevol, pitch, 1.0f, 1000.0f, flags));
} }
catch(std::exception &e) catch(std::exception&)
{ {
mFreeSources.push_back(src); mFreeSources.push_back(src);
if(buf && alIsBuffer(buf)) if(buf && alIsBuffer(buf))
@ -898,7 +898,7 @@ MWBase::SoundPtr OpenAL_Output::playSound3D(const std::string &fname, const Ogre
buf = getBuffer(fname); buf = getBuffer(fname);
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));
} }
catch(std::exception &e) catch(std::exception&)
{ {
mFreeSources.push_back(src); mFreeSources.push_back(src);
if(buf && alIsBuffer(buf)) if(buf && alIsBuffer(buf))
@ -940,7 +940,7 @@ MWBase::SoundPtr OpenAL_Output::streamSound(DecoderPtr decoder, float volume, fl
{ {
sound.reset(new OpenAL_SoundStream(*this, src, decoder, volume, pitch, flags)); sound.reset(new OpenAL_SoundStream(*this, src, decoder, volume, pitch, flags));
} }
catch(std::exception &e) catch(std::exception&)
{ {
mFreeSources.push_back(src); mFreeSources.push_back(src);
throw; throw;

@ -321,7 +321,7 @@ namespace MWSound
sound = mOutput->playSound(file, volume, basevol, pitch, mode|type, offset); sound = mOutput->playSound(file, volume, basevol, pitch, mode|type, offset);
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId); mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId);
} }
catch(std::exception &e) catch(std::exception&)
{ {
//std::cout <<"Sound Error: "<<e.what()<< std::endl; //std::cout <<"Sound Error: "<<e.what()<< std::endl;
} }
@ -349,7 +349,7 @@ namespace MWSound
else else
mActiveSounds[sound] = std::make_pair(ptr, soundId); mActiveSounds[sound] = std::make_pair(ptr, soundId);
} }
catch(std::exception &e) catch(std::exception&)
{ {
//std::cout <<"Sound Error: "<<e.what()<< std::endl; //std::cout <<"Sound Error: "<<e.what()<< std::endl;
} }

@ -20,6 +20,8 @@ namespace ESM
// lights (slot) // lights (slot)
std::vector<std::pair<LightState, int> > mLights; std::vector<std::pair<LightState, int> > mLights;
virtual ~InventoryState() {}
virtual void load (ESMReader &esm); virtual void load (ESMReader &esm);
virtual void save (ESMWriter &esm) const; virtual void save (ESMWriter &esm) const;
}; };

@ -181,7 +181,7 @@ namespace Terrain
// shadow. TODO: repeated, put in function // shadow. TODO: repeated, put in function
if (mShadows) if (mShadows)
{ {
for (Ogre::uint i = 0; i < (mSplitShadows ? 3 : 1); ++i) for (int i = 0; i < (mSplitShadows ? 3 : 1); ++i)
{ {
sh::MaterialInstanceTextureUnit* shadowTex = p->createTextureUnit ("shadowMap" + Ogre::StringConverter::toString(i)); sh::MaterialInstanceTextureUnit* shadowTex = p->createTextureUnit ("shadowMap" + Ogre::StringConverter::toString(i));
shadowTex->setProperty ("content_type", sh::makeProperty<sh::StringValue> (new sh::StringValue("shadow"))); shadowTex->setProperty ("content_type", sh::makeProperty<sh::StringValue> (new sh::StringValue("shadow")));
@ -334,7 +334,7 @@ namespace Terrain
// shadow // shadow
if (shadows) if (shadows)
{ {
for (Ogre::uint i = 0; i < (mSplitShadows ? 3 : 1); ++i) for (int i = 0; i < (mSplitShadows ? 3 : 1); ++i)
{ {
sh::MaterialInstanceTextureUnit* shadowTex = p->createTextureUnit ("shadowMap" + Ogre::StringConverter::toString(i)); sh::MaterialInstanceTextureUnit* shadowTex = p->createTextureUnit ("shadowMap" + Ogre::StringConverter::toString(i));
shadowTex->setProperty ("content_type", sh::makeProperty<sh::StringValue> (new sh::StringValue("shadow"))); shadowTex->setProperty ("content_type", sh::makeProperty<sh::StringValue> (new sh::StringValue("shadow")));

Loading…
Cancel
Save