mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
patch from KroArtem
This commit is contained in:
parent
c4716d0a9a
commit
0e3eae3095
@ -1458,7 +1458,6 @@ bool VCAI::moveHeroToTile(int3 dst, HeroPtr h)
|
||||
lostHero(h);
|
||||
//we need to throw, otherwise hero will be assigned to sth again
|
||||
throw std::runtime_error("Hero was lost!");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@ -2305,7 +2304,7 @@ void AIStatus::madeTurn()
|
||||
void AIStatus::waitTillFree()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
while(battle != NO_BATTLE || remainingQueries.size() || objectsBeingVisited.size() || ongoingHeroMovement)
|
||||
while(battle != NO_BATTLE || !remainingQueries.empty() || !objectsBeingVisited.empty() || ongoingHeroMovement)
|
||||
cv.timed_wait(lock, boost::posix_time::milliseconds(100));
|
||||
}
|
||||
|
||||
@ -2423,7 +2422,7 @@ void SectorMap::exploreNewSector(crint3 pos, int num)
|
||||
|
||||
std::queue<int3> toVisit;
|
||||
toVisit.push(pos);
|
||||
while(toVisit.size())
|
||||
while(!toVisit.empty())
|
||||
{
|
||||
int3 curPos = toVisit.front();
|
||||
toVisit.pop();
|
||||
@ -2513,7 +2512,6 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
|
||||
}
|
||||
}
|
||||
return true; //we don't have this quest yet
|
||||
break;
|
||||
}
|
||||
case Obj::SEER_HUT:
|
||||
case Obj::QUEST_GUARD:
|
||||
@ -2529,7 +2527,6 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
|
||||
}
|
||||
}
|
||||
return true; //we don't have this quest yet
|
||||
break;
|
||||
}
|
||||
case Obj::CREATURE_GENERATOR1:
|
||||
{
|
||||
@ -2546,7 +2543,6 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
|
||||
}
|
||||
}
|
||||
return canRecruitCreatures;
|
||||
break;
|
||||
}
|
||||
case Obj::HILL_FORT:
|
||||
{
|
||||
@ -2556,7 +2552,6 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
|
||||
return true; //TODO: check price?
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case Obj::MONOLITH1:
|
||||
case Obj::MONOLITH2:
|
||||
@ -2564,7 +2559,6 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
|
||||
case Obj::WHIRLPOOL:
|
||||
//TODO: mechanism for handling monoliths
|
||||
return false;
|
||||
break;
|
||||
case Obj::SCHOOL_OF_MAGIC:
|
||||
case Obj::SCHOOL_OF_WAR:
|
||||
{
|
||||
@ -2778,7 +2772,7 @@ void SectorMap::makeParentBFS(crint3 source)
|
||||
int mySector = retreiveTile(source);
|
||||
std::queue<int3> toVisit;
|
||||
toVisit.push(source);
|
||||
while(toVisit.size())
|
||||
while(!toVisit.empty())
|
||||
{
|
||||
int3 curPos = toVisit.front();
|
||||
toVisit.pop();
|
||||
|
@ -338,7 +338,7 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details)
|
||||
//check if user cancelled movement
|
||||
{
|
||||
boost::unique_lock<boost::mutex> un(eventsM);
|
||||
while(events.size())
|
||||
while(!events.empty())
|
||||
{
|
||||
SDL_Event ev = events.front();
|
||||
events.pop();
|
||||
@ -1075,7 +1075,7 @@ void CPlayerInterface::tileRevealed(const std::unordered_set<int3, ShashInt3> &p
|
||||
EVENT_HANDLER_CALLED_BY_CLIENT;
|
||||
for(auto & po : pos)
|
||||
adventureInt->minimap.showTile(po);
|
||||
if(pos.size())
|
||||
if(!pos.empty())
|
||||
GH.totalRedraw();
|
||||
}
|
||||
|
||||
@ -1084,7 +1084,7 @@ void CPlayerInterface::tileHidden(const std::unordered_set<int3, ShashInt3> &pos
|
||||
EVENT_HANDLER_CALLED_BY_CLIENT;
|
||||
for(auto & po : pos)
|
||||
adventureInt->minimap.hideTile(po);
|
||||
if(pos.size())
|
||||
if(!pos.empty())
|
||||
GH.totalRedraw();
|
||||
}
|
||||
|
||||
@ -1233,7 +1233,7 @@ bool CPlayerInterface::moveHero( const CGHeroInstance *h, CGPath path )
|
||||
return false; //can't find hero
|
||||
|
||||
//It shouldn't be possible to move hero with open dialog (or dialog waiting in bg)
|
||||
if(showingDialog->get() || dialogs.size())
|
||||
if(showingDialog->get() || !dialogs.empty())
|
||||
return false;
|
||||
|
||||
|
||||
@ -1578,7 +1578,7 @@ void CPlayerInterface::update()
|
||||
boost::shared_lock<boost::shared_mutex> gsLock(cb->getGsMutex());
|
||||
|
||||
//if there are any waiting dialogs, show them
|
||||
if((howManyPeople <= 1 || makingTurn) && dialogs.size() && !showingDialog->get())
|
||||
if((howManyPeople <= 1 || makingTurn) && !dialogs.empty() && !showingDialog->get())
|
||||
{
|
||||
showingDialog->set(true);
|
||||
GH.pushInt(dialogs.front());
|
||||
@ -1637,7 +1637,7 @@ int CPlayerInterface::getLastIndex( std::string namePrefix)
|
||||
}
|
||||
}
|
||||
|
||||
if(dates.size())
|
||||
if(!dates.empty())
|
||||
return (--dates.end())->second; //return latest file number
|
||||
return 0;
|
||||
}
|
||||
@ -2506,7 +2506,7 @@ void CPlayerInterface::playerStartsTurn(PlayerColor player)
|
||||
|
||||
void CPlayerInterface::waitForAllDialogs(bool unlockPim /*= true*/)
|
||||
{
|
||||
while(dialogs.size())
|
||||
while(!dialogs.empty())
|
||||
{
|
||||
auto unlock = vstd::makeUnlockGuardIf(*pim, unlockPim);
|
||||
SDL_Delay(5);
|
||||
|
@ -986,7 +986,7 @@ void CSelectionScreen::setSInfo(const StartInfo &si)
|
||||
void CSelectionScreen::processPacks()
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lll(*mx);
|
||||
while(upcomingPacks.size())
|
||||
while(!upcomingPacks.empty())
|
||||
{
|
||||
CPackForSelectionScreen *pack = upcomingPacks.front();
|
||||
upcomingPacks.pop_front();
|
||||
@ -3759,7 +3759,7 @@ ISelectionScreenInfo::ISelectionScreenInfo(const std::map<ui8, std::string> *Nam
|
||||
SEL = this;
|
||||
current = nullptr;
|
||||
|
||||
if(Names && Names->size()) //if have custom set of player names - use it
|
||||
if(Names && !Names->empty()) //if have custom set of player names - use it
|
||||
playerNames = *Names;
|
||||
else
|
||||
playerNames[1] = settings["general"]["playerName"].String(); //by default we have only one player and his name is "Player" (or whatever the last used name was)
|
||||
|
@ -758,12 +758,12 @@ void CBattleInterface::setBattleCursor(const int myNumber)
|
||||
attackingHex = myNumber - GameConstants::BFIELD_WIDTH + zigzagCorrection; //top right
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
attackingHex = myNumber + 1; //right
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
attackingHex = myNumber + GameConstants::BFIELD_WIDTH + zigzagCorrection; //bottom right
|
||||
case 5:
|
||||
break;
|
||||
case 5:
|
||||
attackingHex = myNumber + GameConstants::BFIELD_WIDTH - 1 + zigzagCorrection; //bottom left
|
||||
break;
|
||||
}
|
||||
@ -3033,7 +3033,7 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
showInterface(to);
|
||||
|
||||
//activation of next stack
|
||||
if(pendingAnims.size() == 0 && stackToActivate != nullptr)
|
||||
if(pendingAnims.empty() && stackToActivate != nullptr)
|
||||
{
|
||||
activateStack();
|
||||
|
||||
@ -3542,7 +3542,7 @@ void CBattleInterface::updateBattleAnimations()
|
||||
}
|
||||
}
|
||||
|
||||
if(preSize > 0 && pendingAnims.size() == 0)
|
||||
if(preSize > 0 && pendingAnims.empty())
|
||||
{
|
||||
//anims ended
|
||||
blockUI(activeStack == nullptr);
|
||||
|
@ -86,7 +86,7 @@ void CGuiHandler::popInt( IShowActivatable *top )
|
||||
top->deactivate();
|
||||
listInt.pop_front();
|
||||
objsToBlit -= top;
|
||||
if(listInt.size())
|
||||
if(!listInt.empty())
|
||||
listInt.front()->activate();
|
||||
totalRedraw();
|
||||
}
|
||||
@ -107,7 +107,7 @@ void CGuiHandler::pushInt( IShowActivatable *newInt )
|
||||
//a new interface will be present, we'll need to use buffer surface (unless it's advmapint that will alter screenBuf on activate anyway)
|
||||
screenBuf = screen2;
|
||||
|
||||
if(listInt.size())
|
||||
if(!listInt.empty())
|
||||
listInt.front()->deactivate();
|
||||
listInt.push_front(newInt);
|
||||
newInt->activate();
|
||||
@ -128,7 +128,7 @@ void CGuiHandler::popInts( int howMany )
|
||||
listInt.pop_front();
|
||||
}
|
||||
|
||||
if(listInt.size())
|
||||
if(!listInt.empty())
|
||||
{
|
||||
listInt.front()->activate();
|
||||
totalRedraw();
|
||||
@ -138,7 +138,7 @@ void CGuiHandler::popInts( int howMany )
|
||||
|
||||
IShowActivatable * CGuiHandler::topInt()
|
||||
{
|
||||
if(!listInt.size())
|
||||
if(listInt.empty())
|
||||
return nullptr;
|
||||
else
|
||||
return listInt.front();
|
||||
|
@ -58,7 +58,7 @@ int BattleInfo::getAvaliableHex(CreatureID creID, bool attackerOwned, int initia
|
||||
if(accessibility.accessible(i, twoHex, attackerOwned))
|
||||
occupyable.insert(i);
|
||||
|
||||
if (!occupyable.size())
|
||||
if (occupyable.empty())
|
||||
{
|
||||
return BattleHex::INVALID; //all tiles are covered
|
||||
}
|
||||
|
@ -2023,7 +2023,7 @@ std::set<const CStack*> CBattleInfoCallback::getAffectedCreatures(const CSpell *
|
||||
{
|
||||
possibleHexes.erase (hex); //can't hit same place twice
|
||||
}
|
||||
if (!possibleHexes.size()) //not enough targets
|
||||
if (possibleHexes.empty()) //not enough targets
|
||||
break;
|
||||
lightningHex = BattleHex::getClosestTile (stack->attackerOwned, destinationTile, possibleHexes);
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ public:
|
||||
}
|
||||
operator bool() const
|
||||
{
|
||||
return stacks.size() > 0;
|
||||
return !stacks.empty();
|
||||
}
|
||||
void sweep();
|
||||
};
|
||||
|
@ -1542,7 +1542,7 @@ void CGameState::initDuel()
|
||||
for(int i = 0; i < ss.heroPrimSkills.size(); i++)
|
||||
h->pushPrimSkill(static_cast<PrimarySkill::PrimarySkill>(i), ss.heroPrimSkills[i]);
|
||||
|
||||
if(ss.spells.size())
|
||||
if(!ss.spells.empty())
|
||||
{
|
||||
h->putArtifact(ArtifactPosition::SPELLBOOK, CArtifactInstance::createNewArtifactInstance(0));
|
||||
boost::copy(ss.spells, std::inserter(h->spells, h->spells.begin()));
|
||||
|
@ -1715,7 +1715,7 @@ std::vector<SecondarySkill> CGHeroInstance::levelUpProposedSkills() const
|
||||
{
|
||||
skills.push_back (obligatorySkills[0]);
|
||||
}
|
||||
else if(basicAndAdv.size())
|
||||
else if(!basicAndAdv.empty())
|
||||
{
|
||||
SecondarySkill s = type->heroClass->chooseSecSkill(basicAndAdv);//upgrade existing
|
||||
skills.push_back(s);
|
||||
@ -1736,7 +1736,7 @@ std::vector<SecondarySkill> CGHeroInstance::levelUpProposedSkills() const
|
||||
{
|
||||
skills.push_back(type->heroClass->chooseSecSkill(none)); //new skill
|
||||
}
|
||||
else if(basicAndAdv.size())
|
||||
else if(!basicAndAdv.empty())
|
||||
{
|
||||
skills.push_back(type->heroClass->chooseSecSkill(basicAndAdv)); //upgrade existing
|
||||
}
|
||||
@ -5573,7 +5573,7 @@ void CGPandoraBox::giveContentsAfterExp(const CGHeroInstance *h) const
|
||||
spellsToGive.insert(*i);
|
||||
}
|
||||
}
|
||||
if(spellsToGive.size())
|
||||
if(!spellsToGive.empty())
|
||||
{
|
||||
cb->changeSpells(h,true,spellsToGive);
|
||||
cb->showInfoDialog(&iw);
|
||||
@ -7264,7 +7264,7 @@ void CArmedInstance::updateMoraleBonusFromArmy()
|
||||
b->val = +1;
|
||||
b->description = VLC->generaltexth->arraytxt[115]; //All troops of one alignment +1
|
||||
}
|
||||
else if (factions.size()) // no bonus from empty garrison
|
||||
else if (!factions.empty()) // no bonus from empty garrison
|
||||
{
|
||||
b->val = 2 - factionsInArmy;
|
||||
b->description = boost::str(boost::format(VLC->generaltexth->arraytxt[114]) % factionsInArmy % b->val); //Troops of %d alignments %d
|
||||
|
@ -1255,10 +1255,7 @@ public:
|
||||
class DLL_LINKAGE CSaveFile
|
||||
: public COSer<CSaveFile>
|
||||
{
|
||||
void dummyMagicFunction()
|
||||
{
|
||||
*this << std::string("This function makes stuff working.");
|
||||
}
|
||||
|
||||
public:
|
||||
std::string fName;
|
||||
unique_ptr<std::ofstream> sfile;
|
||||
@ -1277,11 +1274,7 @@ public:
|
||||
class DLL_LINKAGE CLoadFile
|
||||
: public CISer<CLoadFile>
|
||||
{
|
||||
void dummyMagicFunction()
|
||||
{
|
||||
std::string dummy = "This function makes stuff working.";
|
||||
*this >> dummy;
|
||||
}
|
||||
|
||||
public:
|
||||
std::string fName;
|
||||
unique_ptr<std::ifstream> sfile;
|
||||
|
@ -488,34 +488,6 @@ ERM::TLine ERMParser::parseLine(const std::string & line)
|
||||
return AST;
|
||||
}
|
||||
|
||||
ERMParser::ELineType ERMParser::classifyLine( const std::string & line, bool inString ) const
|
||||
{
|
||||
ERMParser::ELineType ret;
|
||||
if(line[0] == '!')
|
||||
{
|
||||
if(countHatsBeforeSemicolon(line) % 2 == 1)
|
||||
ret = ERMParser::UNFINISHED;
|
||||
else
|
||||
ret = ERMParser::COMMAND_FULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(inString)
|
||||
{
|
||||
if(countHatsBeforeSemicolon(line) % 2 == 1)
|
||||
ret = ERMParser::END_OF;
|
||||
else
|
||||
ret = ERMParser::UNFINISHED;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = ERMParser::COMMENT;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ERMParser::countHatsBeforeSemicolon( const std::string & line ) const
|
||||
{
|
||||
//CHECK: omit macros? or anything else?
|
||||
@ -543,4 +515,4 @@ void ERMParser::repairEncoding( char * str, int len ) const
|
||||
for(int g=0; g<len; ++g)
|
||||
if(str[g] & 0x80)
|
||||
str[g] = '|';
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +268,6 @@ private:
|
||||
void repairEncoding(std::string & str) const; //removes nonstandard ascii characters from string
|
||||
enum ELineType{COMMAND_FULL, COMMENT, UNFINISHED, END_OF};
|
||||
int countHatsBeforeSemicolon(const std::string & line) const;
|
||||
ELineType classifyLine(const std::string & line, bool inString) const;
|
||||
ERM::TLine parseLine(const std::string & line, int realLineNo);
|
||||
|
||||
|
||||
|
@ -582,7 +582,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
|
||||
}
|
||||
}
|
||||
//Eagle Eye secondary skill handling
|
||||
if(cs.spells.size())
|
||||
if(!cs.spells.empty())
|
||||
{
|
||||
cs.learn = 1;
|
||||
cs.hid = finishingBattle->winnerHero->id;
|
||||
@ -1586,7 +1586,7 @@ void CGameHandler::giveSpells( const CGTownInstance *t, const CGHeroInstance *h
|
||||
}
|
||||
}
|
||||
}
|
||||
if(cs.spells.size())
|
||||
if(!cs.spells.empty())
|
||||
sendAndApply(&cs);
|
||||
}
|
||||
|
||||
@ -2079,7 +2079,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
|
||||
if ( h1Lvl >= it.toSpell()->level && !vstd::contains(h1->spells, it))
|
||||
cs2.spells.insert(it);
|
||||
|
||||
if (cs1.spells.size() || cs2.spells.size())//create a message
|
||||
if (!cs1.spells.empty() || !cs2.spells.empty())//create a message
|
||||
{
|
||||
InfoWindow iw;
|
||||
iw.player = h1->tempOwner;
|
||||
@ -2088,7 +2088,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
|
||||
iw.text.addTxt(MetaString::GENERAL_TXT, 139);//"%s, who has studied magic extensively,
|
||||
iw.text.addReplacement(h1->name);
|
||||
|
||||
if (cs2.spells.size())//if found new spell - apply
|
||||
if (!cs2.spells.empty())//if found new spell - apply
|
||||
{
|
||||
iw.text.addTxt(MetaString::GENERAL_TXT, 140);//learns
|
||||
int size = cs2.spells.size();
|
||||
@ -2108,12 +2108,12 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
|
||||
sendAndApply(&cs2);
|
||||
}
|
||||
|
||||
if (cs1.spells.size() && cs2.spells.size() )
|
||||
if (!cs1.spells.empty() && !cs2.spells.empty() )
|
||||
{
|
||||
iw.text.addTxt(MetaString::GENERAL_TXT, 141);//and
|
||||
}
|
||||
|
||||
if (cs1.spells.size())
|
||||
if (!cs1.spells.empty())
|
||||
{
|
||||
iw.text.addTxt(MetaString::GENERAL_TXT, 147);//teaches
|
||||
int size = cs1.spells.size();
|
||||
@ -2482,7 +2482,7 @@ bool CGameHandler::buildStructure( ObjectInstanceID tid, BuildingID requestedID,
|
||||
std::queue<const CBuilding*> buildingsToAdd;
|
||||
buildingsToAdd.push(requestedBuilding);
|
||||
|
||||
while(buildingsToAdd.size())
|
||||
while(!buildingsToAdd.empty())
|
||||
{
|
||||
auto b = buildingsToAdd.front();
|
||||
buildingsToAdd.pop();
|
||||
@ -4263,7 +4263,7 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
|
||||
for(int i = 0; i < GameConstants::BFIELD_SIZE; i += 1)
|
||||
{
|
||||
BattleHex hex = i;
|
||||
if(hex.getX() > 2 && hex.getX() < 14 && !battleGetStackByPos(hex, false) & !battleGetObstacleOnPos(hex, false))
|
||||
if(hex.getX() > 2 && hex.getX() < 14 && !battleGetStackByPos(hex, false) && !battleGetObstacleOnPos(hex, false))
|
||||
availableTiles.push_back(hex);
|
||||
}
|
||||
boost::range::random_shuffle(availableTiles);
|
||||
|
@ -119,7 +119,7 @@ void CPregameServer::handleConnection(CConnection *cpc)
|
||||
announceTxt(cpc->name + " left the game");
|
||||
toAnnounce.push_back(pl);
|
||||
|
||||
if(!connections.size())
|
||||
if(connections.empty())
|
||||
{
|
||||
logNetwork->errorStream() << "Last connection lost, server will close itself...";
|
||||
boost::this_thread::sleep(boost::posix_time::seconds(2)); //we should never be hasty when networking
|
||||
@ -141,7 +141,7 @@ void CPregameServer::run()
|
||||
{
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> myLock(mx);
|
||||
while(toAnnounce.size())
|
||||
while(!toAnnounce.empty())
|
||||
{
|
||||
processPack(toAnnounce.front());
|
||||
toAnnounce.pop_front();
|
||||
|
Loading…
Reference in New Issue
Block a user