1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-17 11:56:46 +02:00

try to plug a few coverity false positives

This commit is contained in:
AlexVinS 2016-11-28 02:09:24 +03:00
parent 9094c99759
commit 2dd6a47764
7 changed files with 13 additions and 13 deletions

View File

@ -2251,7 +2251,7 @@ void InfoCard::changeSelection( const CMapInfo *to )
void InfoCard::clickRight( tribool down, bool previousState ) void InfoCard::clickRight( tribool down, bool previousState )
{ {
static const Rect flagArea(19, 397, 335, 23); static const Rect flagArea(19, 397, 335, 23);
if(down && SEL->current && isItInLoc(flagArea, GH.current->motion.x, GH.current->motion.y)) if(SEL->current && down && SEL->current && isItInLoc(flagArea, GH.current->motion.x, GH.current->motion.y))
showTeamsPopup(); showTeamsPopup();
} }

View File

@ -191,7 +191,7 @@ void CBattleHero::clickLeft(tribool down, bool previousState)
if(myOwner->spellDestSelectMode) //we are casting a spell if(myOwner->spellDestSelectMode) //we are casting a spell
return; return;
if(!down && myHero != nullptr && myOwner->myTurn && myOwner->getCurrentPlayerInterface()->cb->battleCanCastSpell()) //check conditions if(myHero != nullptr && !down && myOwner->myTurn && myOwner->getCurrentPlayerInterface()->cb->battleCanCastSpell()) //check conditions
{ {
for(int it=0; it<GameConstants::BFIELD_SIZE; ++it) //do nothing when any hex is hovered - hero's animation overlaps battlefield for(int it=0; it<GameConstants::BFIELD_SIZE; ++it) //do nothing when any hex is hovered - hero's animation overlaps battlefield
{ {

View File

@ -239,7 +239,7 @@ bool CHeroArtPlace::askToAssemble(const CArtifactInstance *art, ArtifactPosition
void CHeroArtPlace::clickRight(tribool down, bool previousState) void CHeroArtPlace::clickRight(tribool down, bool previousState)
{ {
if(down && ourArt && !locked && text.size() && !picked) //if there is no description or it's a lock, do nothing ;] if(ourArt && down && ourArt && !locked && text.size() && !picked) //if there is no description or it's a lock, do nothing ;]
{ {
if (slotID < GameConstants::BACKPACK_START) if (slotID < GameConstants::BACKPACK_START)
{ {

View File

@ -269,7 +269,7 @@ bool CGarrisonSlot::mustForceReselection() const
void CGarrisonSlot::clickRight(tribool down, bool previousState) void CGarrisonSlot::clickRight(tribool down, bool previousState)
{ {
if(down && creature) if(creature && down)
{ {
GH.pushInt(new CStackWindow(myStack, true)); GH.pushInt(new CStackWindow(myStack, true));
} }

View File

@ -134,13 +134,13 @@ CHeroArea::CHeroArea(int x, int y, const CGHeroInstance * _hero):hero(_hero)
void CHeroArea::clickLeft(tribool down, bool previousState) void CHeroArea::clickLeft(tribool down, bool previousState)
{ {
if((!down) && previousState && hero) if(hero && (!down) && previousState)
LOCPLINT->openHeroWindow(hero); LOCPLINT->openHeroWindow(hero);
} }
void CHeroArea::clickRight(tribool down, bool previousState) void CHeroArea::clickRight(tribool down, bool previousState)
{ {
if((!down) && previousState && hero) if(hero && (!down) && previousState)
LOCPLINT->openHeroWindow(hero); LOCPLINT->openHeroWindow(hero);
} }
@ -154,19 +154,19 @@ void CHeroArea::hover(bool on)
void LRClickableAreaOpenTown::clickLeft(tribool down, bool previousState) void LRClickableAreaOpenTown::clickLeft(tribool down, bool previousState)
{ {
if((!down) && previousState && town) if(town && (!down) && previousState)
{ {
LOCPLINT->openTownWindow(town); LOCPLINT->openTownWindow(town);
if ( type == 2 ) if ( type == 2 )
LOCPLINT->castleInt->builds->buildingClicked(BuildingID::VILLAGE_HALL); LOCPLINT->castleInt->builds->buildingClicked(BuildingID::VILLAGE_HALL);
else if ( type == 3 && town->fortLevel() ) else if ( type == 3 && town->fortLevel() )
LOCPLINT->castleInt->builds->buildingClicked(BuildingID::FORT); LOCPLINT->castleInt->builds->buildingClicked(BuildingID::FORT);
} }
} }
void LRClickableAreaOpenTown::clickRight(tribool down, bool previousState) void LRClickableAreaOpenTown::clickRight(tribool down, bool previousState)
{ {
if((!down) && previousState && town) if(town && (!down) && previousState)
LOCPLINT->openTownWindow(town);//TODO: popup? LOCPLINT->openTownWindow(town);//TODO: popup?
} }

View File

@ -109,7 +109,7 @@ void CBuildingRect::hover(bool on)
void CBuildingRect::clickLeft(tribool down, bool previousState) void CBuildingRect::clickLeft(tribool down, bool previousState)
{ {
if( previousState && !down && area && (parent->selectedBuilding==this) && getBuilding() ) if( previousState && getBuilding() && area && !down && (parent->selectedBuilding==this))
if (!CSDL_Ext::isTransparent(area, GH.current->motion.x-pos.x, GH.current->motion.y-pos.y) ) //inside building image if (!CSDL_Ext::isTransparent(area, GH.current->motion.x-pos.x, GH.current->motion.y-pos.y) ) //inside building image
parent->buildingClicked(getBuilding()->bid); parent->buildingClicked(getBuilding()->bid);
} }

View File

@ -788,13 +788,13 @@ void CTavernWindow::show(SDL_Surface * to)
void CTavernWindow::HeroPortrait::clickLeft(tribool down, bool previousState) void CTavernWindow::HeroPortrait::clickLeft(tribool down, bool previousState)
{ {
if(previousState && !down && h) if(h && previousState && !down)
*_sel = _id; *_sel = _id;
} }
void CTavernWindow::HeroPortrait::clickRight(tribool down, bool previousState) void CTavernWindow::HeroPortrait::clickRight(tribool down, bool previousState)
{ {
if(down && h) if(h && down)
{ {
GH.pushInt(new CRClickPopupInt(new CHeroWindow(h), true)); GH.pushInt(new CRClickPopupInt(new CHeroWindow(h), true));
} }