Change dynamic_cast to static_cast to make coverity happy

openmw-35
scrawl 10 years ago
parent cda2eea906
commit de23ad5c8d

@ -246,7 +246,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
Style* createHotStyle (Style* baseStyle, Colour normalColour, Colour hoverColour, Colour activeColour, InteractiveId id, bool unique) Style* createHotStyle (Style* baseStyle, Colour normalColour, Colour hoverColour, Colour activeColour, InteractiveId id, bool unique)
{ {
StyleImpl* BaseStyle = dynamic_cast <StyleImpl*> (baseStyle); StyleImpl* BaseStyle = static_cast <StyleImpl*> (baseStyle);
if (!unique) if (!unique)
for (Styles::iterator i = mBook->mStyles.begin (); i != mBook->mStyles.end (); ++i) for (Styles::iterator i = mBook->mStyles.begin (); i != mBook->mStyles.end (); ++i)
@ -268,7 +268,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
{ {
Range range = mBook->addContent (text); Range range = mBook->addContent (text);
writeImpl (dynamic_cast <StyleImpl*> (style), range.first, range.second); writeImpl (static_cast <StyleImpl*> (style), range.first, range.second);
} }
intptr_t addContent (Utf8Span text, bool select) intptr_t addContent (Utf8Span text, bool select)
@ -295,7 +295,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
Utf8Point begin_ = &mCurrentContent->front () + begin; Utf8Point begin_ = &mCurrentContent->front () + begin;
Utf8Point end_ = &mCurrentContent->front () + end ; Utf8Point end_ = &mCurrentContent->front () + end ;
writeImpl (dynamic_cast <StyleImpl*> (style), begin_, end_); writeImpl (static_cast <StyleImpl*> (style), begin_, end_);
} }
void lineBreak (float margin) void lineBreak (float margin)

@ -131,7 +131,7 @@ void adjustCommandedActor (const MWWorld::Ptr& actor)
for (it = stats.getAiSequence().begin(); it != stats.getAiSequence().end(); ++it) for (it = stats.getAiSequence().begin(); it != stats.getAiSequence().end(); ++it)
{ {
if ((*it)->getTypeId() == MWMechanics::AiPackage::TypeIdFollow && if ((*it)->getTypeId() == MWMechanics::AiPackage::TypeIdFollow &&
dynamic_cast<MWMechanics::AiFollow*>(*it)->isCommanded()) static_cast<MWMechanics::AiFollow*>(*it)->isCommanded())
{ {
hasCommandPackage = true; hasCommandPackage = true;
break; break;
@ -355,7 +355,7 @@ namespace MWMechanics
{ {
if ((*it)->getTypeId() == MWMechanics::AiPackage::TypeIdFollow) if ((*it)->getTypeId() == MWMechanics::AiPackage::TypeIdFollow)
{ {
MWWorld::Ptr followTarget = dynamic_cast<MWMechanics::AiFollow*>(*it)->getTarget(); MWWorld::Ptr followTarget = static_cast<MWMechanics::AiFollow*>(*it)->getTarget();
if (followTarget.isEmpty()) if (followTarget.isEmpty())
continue; continue;
@ -1389,7 +1389,7 @@ namespace MWMechanics
{ {
if ((*it)->getTypeId() == MWMechanics::AiPackage::TypeIdFollow) if ((*it)->getTypeId() == MWMechanics::AiPackage::TypeIdFollow)
{ {
MWWorld::Ptr followTarget = dynamic_cast<MWMechanics::AiFollow*>(*it)->getTarget(); MWWorld::Ptr followTarget = static_cast<MWMechanics::AiFollow*>(*it)->getTarget();
if (followTarget.isEmpty()) if (followTarget.isEmpty())
continue; continue;
if (followTarget == actor) if (followTarget == actor)
@ -1419,11 +1419,11 @@ namespace MWMechanics
{ {
if ((*it)->getTypeId() == MWMechanics::AiPackage::TypeIdFollow) if ((*it)->getTypeId() == MWMechanics::AiPackage::TypeIdFollow)
{ {
MWWorld::Ptr followTarget = dynamic_cast<MWMechanics::AiFollow*>(*it)->getTarget(); MWWorld::Ptr followTarget = static_cast<MWMechanics::AiFollow*>(*it)->getTarget();
if (followTarget.isEmpty()) if (followTarget.isEmpty())
continue; continue;
if (followTarget == actor) if (followTarget == actor)
list.push_back(dynamic_cast<MWMechanics::AiFollow*>(*it)->getFollowIndex()); list.push_back(static_cast<MWMechanics::AiFollow*>(*it)->getFollowIndex());
else else
break; break;
} }

@ -342,49 +342,49 @@ void AiSequence::readState(const ESM::AiSequence::AiSequence &sequence)
case ESM::AiSequence::Ai_Wander: case ESM::AiSequence::Ai_Wander:
{ {
MWMechanics::AiWander* wander = new AiWander( MWMechanics::AiWander* wander = new AiWander(
dynamic_cast<ESM::AiSequence::AiWander*>(it->mPackage)); static_cast<ESM::AiSequence::AiWander*>(it->mPackage));
mPackages.push_back(wander); mPackages.push_back(wander);
break; break;
} }
case ESM::AiSequence::Ai_Travel: case ESM::AiSequence::Ai_Travel:
{ {
MWMechanics::AiTravel* travel = new AiTravel( MWMechanics::AiTravel* travel = new AiTravel(
dynamic_cast<ESM::AiSequence::AiTravel*>(it->mPackage)); static_cast<ESM::AiSequence::AiTravel*>(it->mPackage));
mPackages.push_back(travel); mPackages.push_back(travel);
break; break;
} }
case ESM::AiSequence::Ai_Escort: case ESM::AiSequence::Ai_Escort:
{ {
MWMechanics::AiEscort* escort = new AiEscort( MWMechanics::AiEscort* escort = new AiEscort(
dynamic_cast<ESM::AiSequence::AiEscort*>(it->mPackage)); static_cast<ESM::AiSequence::AiEscort*>(it->mPackage));
mPackages.push_back(escort); mPackages.push_back(escort);
break; break;
} }
case ESM::AiSequence::Ai_Follow: case ESM::AiSequence::Ai_Follow:
{ {
MWMechanics::AiFollow* follow = new AiFollow( MWMechanics::AiFollow* follow = new AiFollow(
dynamic_cast<ESM::AiSequence::AiFollow*>(it->mPackage)); static_cast<ESM::AiSequence::AiFollow*>(it->mPackage));
mPackages.push_back(follow); mPackages.push_back(follow);
break; break;
} }
case ESM::AiSequence::Ai_Activate: case ESM::AiSequence::Ai_Activate:
{ {
MWMechanics::AiActivate* activate = new AiActivate( MWMechanics::AiActivate* activate = new AiActivate(
dynamic_cast<ESM::AiSequence::AiActivate*>(it->mPackage)); static_cast<ESM::AiSequence::AiActivate*>(it->mPackage));
mPackages.push_back(activate); mPackages.push_back(activate);
break; break;
} }
case ESM::AiSequence::Ai_Combat: case ESM::AiSequence::Ai_Combat:
{ {
MWMechanics::AiCombat* combat = new AiCombat( MWMechanics::AiCombat* combat = new AiCombat(
dynamic_cast<ESM::AiSequence::AiCombat*>(it->mPackage)); static_cast<ESM::AiSequence::AiCombat*>(it->mPackage));
mPackages.push_back(combat); mPackages.push_back(combat);
break; break;
} }
case ESM::AiSequence::Ai_Pursue: case ESM::AiSequence::Ai_Pursue:
{ {
MWMechanics::AiPursue* pursue = new AiPursue( MWMechanics::AiPursue* pursue = new AiPursue(
dynamic_cast<ESM::AiSequence::AiPursue*>(it->mPackage)); static_cast<ESM::AiSequence::AiPursue*>(it->mPackage));
mPackages.push_back(pursue); mPackages.push_back(pursue);
break; break;
} }

@ -245,7 +245,7 @@ namespace MWRender
void GlobalMap::loadResource(Ogre::Resource *resource) void GlobalMap::loadResource(Ogre::Resource *resource)
{ {
Ogre::Texture* tex = dynamic_cast<Ogre::Texture*>(resource); Ogre::Texture* tex = static_cast<Ogre::Texture*>(resource);
Ogre::ConstImagePtrList list; Ogre::ConstImagePtrList list;
list.push_back(&mOverlayImage); list.push_back(&mOverlayImage);
tex->_loadImages(list); tex->_loadImages(list);

@ -494,7 +494,7 @@ void LocalMap::loadResource(Ogre::Resource* resource)
std::vector<uint32>& buffer = mBuffers[resourceName]; std::vector<uint32>& buffer = mBuffers[resourceName];
Ogre::Texture* tex = dynamic_cast<Ogre::Texture*>(resource); Ogre::Texture* tex = static_cast<Ogre::Texture*>(resource);
tex->createInternalResources(); tex->createInternalResources();
memcpy(tex->getBuffer()->lock(HardwareBuffer::HBL_DISCARD), &buffer[0], sFogOfWarResolution*sFogOfWarResolution*4); memcpy(tex->getBuffer()->lock(HardwareBuffer::HBL_DISCARD), &buffer[0], sFogOfWarResolution*sFogOfWarResolution*4);
tex->getBuffer()->unlock(); tex->getBuffer()->unlock();

@ -382,7 +382,7 @@ NIFMeshLoader::NIFMeshLoader(const std::string &name, const std::string &group,
void NIFMeshLoader::loadResource(Ogre::Resource *resource) void NIFMeshLoader::loadResource(Ogre::Resource *resource)
{ {
Ogre::Mesh *mesh = dynamic_cast<Ogre::Mesh*>(resource); Ogre::Mesh *mesh = static_cast<Ogre::Mesh*>(resource);
OgreAssert(mesh, "Attempting to load a mesh into a non-mesh resource!"); OgreAssert(mesh, "Attempting to load a mesh into a non-mesh resource!");
Nif::NIFFilePtr nif = Nif::Cache::getInstance().load(mName); Nif::NIFFilePtr nif = Nif::Cache::getInstance().load(mName);
@ -395,7 +395,7 @@ void NIFMeshLoader::loadResource(Ogre::Resource *resource)
} }
const Nif::Record *record = nif->getRecord(mShapeIndex); const Nif::Record *record = nif->getRecord(mShapeIndex);
createSubMesh(mesh, dynamic_cast<const Nif::NiTriShape*>(record)); createSubMesh(mesh, static_cast<const Nif::NiTriShape*>(record));
} }

@ -799,7 +799,7 @@ class NIFObjectLoader
{ {
if (ctrls->recType == Nif::RC_NiAlphaController) if (ctrls->recType == Nif::RC_NiAlphaController)
{ {
const Nif::NiAlphaController *alphaCtrl = dynamic_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, (animflags&Nif::NiNode::AnimFlag_AutoPlay));
scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength); scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength);
@ -808,7 +808,7 @@ class NIFObjectLoader
} }
else if (ctrls->recType == Nif::RC_NiMaterialColorController) else if (ctrls->recType == Nif::RC_NiMaterialColorController)
{ {
const Nif::NiMaterialColorController *matCtrl = dynamic_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, (animflags&Nif::NiNode::AnimFlag_AutoPlay));
scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength); scene->mMaxControllerLength = std::max(function->mStopTime, scene->mMaxControllerLength);
@ -826,7 +826,7 @@ class NIFObjectLoader
{ {
if (ctrls->recType == Nif::RC_NiFlipController) if (ctrls->recType == Nif::RC_NiFlipController)
{ {
const Nif::NiFlipController *flipCtrl = dynamic_cast<const Nif::NiFlipController*>(ctrls.getPtr()); const Nif::NiFlipController *flipCtrl = static_cast<const Nif::NiFlipController*>(ctrls.getPtr());
Ogre::ControllerValueRealPtr dstval(OGRE_NEW FlipController::Value( Ogre::ControllerValueRealPtr dstval(OGRE_NEW FlipController::Value(

@ -35,7 +35,7 @@ btCollisionShape *duplicateCollisionShape(btCollisionShape *shape)
if(btBvhTriangleMeshShape *trishape = dynamic_cast<btBvhTriangleMeshShape*>(shape)) if(btBvhTriangleMeshShape *trishape = dynamic_cast<btBvhTriangleMeshShape*>(shape))
{ {
btTriangleMesh* oldMesh = dynamic_cast<btTriangleMesh*>(trishape->getMeshInterface()); btTriangleMesh* oldMesh = static_cast<btTriangleMesh*>(trishape->getMeshInterface());
btTriangleMesh* newMesh = new btTriangleMesh(*oldMesh); btTriangleMesh* newMesh = new btTriangleMesh(*oldMesh);
NifBullet::TriangleMeshShape *newShape = new NifBullet::TriangleMeshShape(newMesh, true); NifBullet::TriangleMeshShape *newShape = new NifBullet::TriangleMeshShape(newMesh, true);

Loading…
Cancel
Save