1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fix indentation of logging code and around it

That wouldn't be as big issue if problem affected few files, but it everywhere in codebase.
Fixed it everywhere since in most files that is the only code with wrong indentation.
This commit is contained in:
Arseniy Shestakov 2016-03-12 04:41:27 +03:00
parent faae305ec0
commit 10dbbead2d
54 changed files with 580 additions and 577 deletions

View File

@ -165,7 +165,7 @@ BattleAction CBattleAI::activeStack( const CStack * stack )
{
ThreatMap threatsToUs(stack);
auto dists = cbc->battleGetDistances(stack);
const EnemyInfo &ei= *range::min_element(targets.unreachableEnemies, std::bind(isCloser, _1, _2, std::ref(dists)));
const EnemyInfo &ei= *range::min_element(targets.unreachableEnemies, std::bind(isCloser, _1, _2, std::ref(dists)));
if(distToNearestNeighbour(ei.s->position, dists) < GameConstants::BFIELD_SIZE)
{
return goTowards(stack, ei.s->position);
@ -268,7 +268,7 @@ void CBattleAI::battleStacksRemoved(const BattleStacksRemoved & bsr)
void CBattleAI::print(const std::string &text) const
{
logAi->traceStream() << "CBattleAI [" << this <<"]: " << text;
logAi->traceStream() << "CBattleAI [" << this <<"]: " << text;
}
BattleAction CBattleAI::goTowards(const CStack * stack, BattleHex destination)
@ -283,7 +283,7 @@ BattleAction CBattleAI::goTowards(const CStack * stack, BattleHex destination)
auto destNeighbours = destination.neighbouringTiles();
if(vstd::contains_if(destNeighbours, [&](BattleHex n) { return stack->coversPos(destination); }))
{
logAi->warnStream() << "Warning: already standing on neighbouring tile!";
logAi->warnStream() << "Warning: already standing on neighbouring tile!";
//We shouldn't even be here...
return BattleAction::makeDefend(stack);
}

View File

@ -261,7 +261,7 @@ void CStupidAI::battleStacksRemoved(const BattleStacksRemoved & bsr)
void CStupidAI::print(const std::string &text) const
{
logAi->traceStream() << "CStupidAI [" << this <<"]: " << text;
logAi->traceStream() << "CStupidAI [" << this <<"]: " << text;
}
BattleAction CStupidAI::goTowards(const CStack * stack, BattleHex destination)
@ -276,7 +276,7 @@ BattleAction CStupidAI::goTowards(const CStack * stack, BattleHex destination)
auto destNeighbours = destination.neighbouringTiles();
if(vstd::contains_if(destNeighbours, [&](BattleHex n) { return stack->coversPos(destination); }))
{
logAi->warnStream() << "Warning: already standing on neighbouring tile!";
logAi->warnStream() << "Warning: already standing on neighbouring tile!";
//We shouldn't even be here...
return BattleAction::makeDefend(stack);
}

View File

@ -339,7 +339,7 @@ bool isSafeToVisit(HeroPtr h, crint3 tile)
{
if(heroStrength / SAFE_ATTACK_CONSTANT > dangerStrength)
{
logAi->traceStream() << boost::format("It's safe for %s to visit tile %s") % h->name % tile;
logAi->traceStream() << boost::format("It's safe for %s to visit tile %s") % h->name % tile;
return true;
}
else

View File

@ -105,7 +105,7 @@ struct TimeCheck
~TimeCheck()
{
logAi->traceStream() << boost::format("Time of %s was %d ms.") % txt % time.getDiff();
logAi->traceStream() << boost::format("Time of %s was %d ms.") % txt % time.getDiff();
}
};
@ -129,7 +129,7 @@ private:
template<int id>
bool objWithID(const CGObjectInstance *obj)
{
return obj->ID == id;
return obj->ID == id;
}
std::string strFromInt3(int3 pos);

View File

@ -182,8 +182,8 @@ namespace Goals
//TSubgoal AbstractGoal::whatToDoToAchieve()
//{
// logAi->debugStream() << boost::format("Decomposing goal of type %s") % name();
// return sptr (Goals::Explore());
// logAi->debugStream() << boost::format("Decomposing goal of type %s") % name();
// return sptr (Goals::Explore());
//}
TSubgoal Win::whatToDoToAchieve()
@ -462,7 +462,7 @@ TSubgoal ClearWayTo::whatToDoToAchieve()
assert(cb->isInTheMap(tile)); //set tile
if(!cb->isVisible(tile))
{
logAi->errorStream() << "Clear way should be used with visible tiles!";
logAi->errorStream() << "Clear way should be used with visible tiles!";
return sptr (Goals::Explore());
}
@ -1129,7 +1129,7 @@ TGoalVec GatherArmy::getAllPossibleSubgoals()
//TSubgoal AbstractGoal::whatToDoToAchieve()
//{
// logAi->debugStream() << boost::format("Decomposing goal of type %s") % name();
// logAi->debugStream() << boost::format("Decomposing goal of type %s") % name();
// return sptr (Goals::Explore());
//}

View File

@ -216,12 +216,12 @@ void VCAI::gameOver(PlayerColor player, const EVictoryLossCheckResult & victoryL
{
if(victoryLossCheckResult.victory())
{
logAi->debugStream() << "VCAI: I won! Incredible!";
logAi->debugStream() << "Turn nr " << myCb->getDate();
logAi->debugStream() << "VCAI: I won! Incredible!";
logAi->debugStream() << "Turn nr " << myCb->getDate();
}
else
{
logAi->debugStream() << "VCAI: Player " << player << " lost. It's me. What a disappointment! :(";
logAi->debugStream() << "VCAI: Player " << player << " lost. It's me. What a disappointment! :(";
}
finish();
@ -843,12 +843,12 @@ void VCAI::makeTurnInternal()
}
catch(boost::thread_interrupted &e)
{
logAi->debugStream() << "Making turn thread has been interrupted. We'll end without calling endTurn.";
logAi->debugStream() << "Making turn thread has been interrupted. We'll end without calling endTurn.";
return;
}
catch(std::exception &e)
{
logAi->debugStream() << "Making turn thread has caught an exception: " << e.what();
logAi->debugStream() << "Making turn thread has caught an exception: " << e.what();
}
endTurn();
@ -1171,7 +1171,7 @@ bool VCAI::tryBuildStructure(const CGTownInstance * t, BuildingID building, unsi
{
if(!containsSavedRes(b->resources))
{
logAi->debugStream() << boost::format("Player %d will build %s in town of %s at %s") % playerID % b->Name() % t->name % t->pos;
logAi->debugStream() << boost::format("Player %d will build %s in town of %s at %s") % playerID % b->Name() % t->name % t->pos;
cb->buildBuilding(t, buildID);
return true;
}
@ -1252,7 +1252,7 @@ bool VCAI::tryBuildStructure(const CGTownInstance * t, BuildingID building, unsi
// {
// if(!containsSavedRes(b->resources))
// {
// logAi->debugStream() << boost::format("Player %d will build %s in town of %s at %s") % playerID % b->Name() % t->name % t->pos;
// logAi->debugStream() << boost::format("Player %d will build %s in town of %s at %s") % playerID % b->Name() % t->name % t->pos;
// return true;
// }
// continue;
@ -1638,7 +1638,7 @@ void VCAI::battleEnd(const BattleResult *br)
assert(status.getBattle() == ONGOING_BATTLE);
status.setBattle(ENDING_BATTLE);
bool won = br->winner == myCb->battleGetMySide();
logAi->debugStream() << boost::format("Player %d: I %s the %s!") % playerID % (won ? "won" : "lost") % battlename;
logAi->debugStream() << boost::format("Player %d: I %s the %s!") % playerID % (won ? "won" : "lost") % battlename;
battlename.clear();
CAdventureAI::battleEnd(br);
}
@ -1874,7 +1874,7 @@ bool VCAI::moveHeroToTile(int3 dst, HeroPtr h)
cb->getPathsInfo(h.get())->getPath(path, dst);
if(path.nodes.empty())
{
logAi->errorStream() << "Hero " << h->name << " cannot reach " << dst;
logAi->errorStream() << "Hero " << h->name << " cannot reach " << dst;
throw goalFulfilledException (sptr(Goals::VisitTile(dst).sethero(h)));
}
int i = path.nodes.size()-1;
@ -2150,7 +2150,7 @@ void VCAI::tryRealize(Goals::Build & g)
{
for(const CGTownInstance *t : cb->getTownsInfo())
{
logAi->debugStream() << boost::format("Looking into %s") % t->name;
logAi->debugStream() << boost::format("Looking into %s") % t->name;
buildStructure(t);
buildArmyIn(t);
@ -2171,8 +2171,8 @@ void VCAI::tryRealize(Goals::Invalid & g)
void VCAI::tryRealize(Goals::AbstractGoal & g)
{
logAi->debugStream() << boost::format("Attempting realizing goal with code %s") % g.name();
throw cannotFulfillGoalException("Unknown type of goal !");
logAi->debugStream() << boost::format("Attempting realizing goal with code %s") % g.name();
throw cannotFulfillGoalException("Unknown type of goal !");
}
const CGTownInstance * VCAI::findTownWithTavern() const
@ -2233,10 +2233,10 @@ HeroPtr VCAI::primaryHero() const
void VCAI::endTurn()
{
logAi->infoStream() << "Player " << static_cast<int>(playerID.getNum()) << " ends turn";
logAi->infoStream() << "Player " << static_cast<int>(playerID.getNum()) << " ends turn";
if(!status.haveTurn())
{
logAi->errorStream() << "Not having turn at the end of turn???";
logAi->errorStream() << "Not having turn at the end of turn???";
}
logAi->debugStream() << "Resources at the end of turn: " << cb->getResourceAmount();
@ -2245,7 +2245,7 @@ void VCAI::endTurn()
cb->endTurn();
} while(status.haveTurn()); //for some reasons, our request may fail -> stop requesting end of turn only after we've received a confirmation that it's over
logGlobal->infoStream() << "Player " << static_cast<int>(playerID.getNum()) << " ended turn";
logGlobal->infoStream() << "Player " << static_cast<int>(playerID.getNum()) << " ended turn";
}
void VCAI::striveToGoal(Goals::TSubgoal ultimateGoal)
@ -2274,11 +2274,11 @@ Goals::TSubgoal VCAI::striveToGoalInternal(Goals::TSubgoal ultimateGoal, bool on
while(1)
{
Goals::TSubgoal goal = ultimateGoal;
logAi->debugStream() << boost::format("Striving to goal of type %s") % ultimateGoal->name();
logAi->debugStream() << boost::format("Striving to goal of type %s") % ultimateGoal->name();
int maxGoals = searchDepth; //preventing deadlock for mutually dependent goals
while(!goal->isElementar && maxGoals && (onlyAbstract || !goal->isAbstract))
{
logAi->debugStream() << boost::format("Considering goal %s") % goal->name();
logAi->debugStream() << boost::format("Considering goal %s") % goal->name();
try
{
boost::this_thread::interruption_point();
@ -2291,12 +2291,12 @@ Goals::TSubgoal VCAI::striveToGoalInternal(Goals::TSubgoal ultimateGoal, bool on
{
//it is impossible to continue some goals (like exploration, for example)
completeGoal (goal);
logAi->debugStream() << boost::format("Goal %s decomposition failed: goal was completed as much as possible") % goal->name();
logAi->debugStream() << boost::format("Goal %s decomposition failed: goal was completed as much as possible") % goal->name();
return sptr(Goals::Invalid());
}
catch(std::exception &e)
{
logAi->debugStream() << boost::format("Goal %s decomposition failed: %s") % goal->name() % e.what();
logAi->debugStream() << boost::format("Goal %s decomposition failed: %s") % goal->name() % e.what();
return sptr(Goals::Invalid());
}
}
@ -2326,7 +2326,7 @@ Goals::TSubgoal VCAI::striveToGoalInternal(Goals::TSubgoal ultimateGoal, bool on
if (goal->isAbstract)
{
abstractGoal = goal; //allow only one abstract goal per call
logAi->debugStream() << boost::format("Choosing abstract goal %s") % goal->name();
logAi->debugStream() << boost::format("Choosing abstract goal %s") % goal->name();
break;
}
else
@ -2339,7 +2339,7 @@ Goals::TSubgoal VCAI::striveToGoalInternal(Goals::TSubgoal ultimateGoal, bool on
}
catch(boost::thread_interrupted &e)
{
logAi->debugStream() << boost::format("Player %d: Making turn thread received an interruption!") % playerID;
logAi->debugStream() << boost::format("Player %d: Making turn thread received an interruption!") % playerID;
throw; //rethrow, we want to truly end this thread
}
catch(goalFulfilledException &e)
@ -2352,8 +2352,8 @@ Goals::TSubgoal VCAI::striveToGoalInternal(Goals::TSubgoal ultimateGoal, bool on
}
catch(std::exception &e)
{
logAi->debugStream() << boost::format("Failed to realize subgoal of type %s (greater goal type was %s), I will stop.") % goal->name() % ultimateGoal->name();
logAi->debugStream() << boost::format("The error message was: %s") % e.what();
logAi->debugStream() << boost::format("Failed to realize subgoal of type %s (greater goal type was %s), I will stop.") % goal->name() % ultimateGoal->name();
logAi->debugStream() << boost::format("The error message was: %s") % e.what();
break;
}
}
@ -2366,7 +2366,7 @@ void VCAI::striveToQuest (const QuestInfo &q)
{
MetaString ms;
q.quest->getRolloverText(ms, false);
logAi->debugStream() << boost::format("Trying to realize quest: %s") % ms.toString();
logAi->debugStream() << boost::format("Trying to realize quest: %s") % ms.toString();
auto heroes = cb->getHeroesInfo();
switch (q.quest->missionType)
@ -2464,7 +2464,7 @@ void VCAI::striveToQuest (const QuestInfo &q)
}
for (int i = 0; i < q.quest->m2stats.size(); ++i)
{
logAi->debugStream() << boost::format("Don't know how to increase primary stat %d") % i;
logAi->debugStream() << boost::format("Don't know how to increase primary stat %d") % i;
}
break;
}
@ -2479,13 +2479,13 @@ void VCAI::striveToQuest (const QuestInfo &q)
return;
}
}
logAi->debugStream() << boost::format("Don't know how to reach hero level %d") % q.quest->m13489val;
logAi->debugStream() << boost::format("Don't know how to reach hero level %d") % q.quest->m13489val;
break;
}
case CQuest::MISSION_PLAYER:
{
if (playerID.getNum() != q.quest->m13489val)
logAi->debugStream() << boost::format("Can't be player of color %d") % q.quest->m13489val;
logAi->debugStream() << boost::format("Can't be player of color %d") % q.quest->m13489val;
break;
}
case CQuest::MISSION_KEYMASTER:
@ -2501,7 +2501,7 @@ void VCAI::performTypicalActions()
{
for(auto h : getUnblockedHeroes())
{
logAi->debugStream() << boost::format("Looking into %s, MP=%d") % h->name.c_str() % h->movement;
logAi->debugStream() << boost::format("Looking into %s, MP=%d") % h->name.c_str() % h->movement;
makePossibleUpgrades(*h);
pickBestArtifacts(*h);
try
@ -2510,7 +2510,7 @@ void VCAI::performTypicalActions()
}
catch(std::exception &e)
{
logAi->debugStream() << boost::format("Cannot use this hero anymore, received exception: %s") % e.what();
logAi->debugStream() << boost::format("Cannot use this hero anymore, received exception: %s") % e.what();
continue;
}
}
@ -2709,7 +2709,7 @@ void VCAI::checkHeroArmy (HeroPtr h)
void VCAI::recruitHero(const CGTownInstance * t, bool throwing)
{
logAi->debugStream() << boost::format("Trying to recruit a hero in %s at %s") % t->name % t->visitablePos();
logAi->debugStream() << boost::format("Trying to recruit a hero in %s at %s") % t->name % t->visitablePos();
auto heroes = cb->getAvailableHeroes(t);
if(heroes.size())
@ -2745,7 +2745,7 @@ void VCAI::requestActionASAP(std::function<void()> whatToDo)
void VCAI::lostHero(HeroPtr h)
{
logAi->debugStream() << boost::format("I lost my hero %s. It's best to forget and move on.") % h.name;
logAi->debugStream() << boost::format("I lost my hero %s. It's best to forget and move on.") % h.name;
vstd::erase_if_present(lockedHeroes, h);
for(auto obj : reservedHeroesMap[h])
@ -2758,14 +2758,14 @@ void VCAI::lostHero(HeroPtr h)
void VCAI::answerQuery(QueryID queryID, int selection)
{
logAi->debugStream() << boost::format("I'll answer the query %d giving the choice %d") % queryID % selection;
logAi->debugStream() << boost::format("I'll answer the query %d giving the choice %d") % queryID % selection;
if(queryID != QueryID(-1))
{
cb->selectionMade(selection, queryID);
}
else
{
logAi->debugStream() << boost::format("Since the query ID is %d, the answer won't be sent. This is not a real query!") % queryID;
logAi->debugStream() << boost::format("Since the query ID is %d, the answer won't be sent. This is not a real query!") % queryID;
//do nothing
}
}
@ -2857,7 +2857,7 @@ void AIStatus::addQuery(QueryID ID, std::string description)
{
if(ID == QueryID(-1))
{
logAi->debugStream() << boost::format("The \"query\" has an id %d, it'll be ignored as non-query. Description: %s") % ID % description;
logAi->debugStream() << boost::format("The \"query\" has an id %d, it'll be ignored as non-query. Description: %s") % ID % description;
return;
}
@ -2869,7 +2869,7 @@ void AIStatus::addQuery(QueryID ID, std::string description)
remainingQueries[ID] = description;
cv.notify_all();
logAi->debugStream() << boost::format("Adding query %d - %s. Total queries count: %d") % ID % description % remainingQueries.size();
logAi->debugStream() << boost::format("Adding query %d - %s. Total queries count: %d") % ID % description % remainingQueries.size();
}
void AIStatus::removeQuery(QueryID ID)
@ -2881,7 +2881,7 @@ void AIStatus::removeQuery(QueryID ID)
remainingQueries.erase(ID);
cv.notify_all();
logAi->debugStream() << boost::format("Removing query %d - %s. Total queries count: %d") % ID % description % remainingQueries.size();
logAi->debugStream() << boost::format("Removing query %d - %s. Total queries count: %d") % ID % description % remainingQueries.size();
}
int AIStatus::getQueriesCount()
@ -2922,7 +2922,7 @@ void AIStatus::attemptedAnsweringQuery(QueryID queryID, int answerRequestID)
boost::unique_lock<boost::mutex> lock(mx);
assert(vstd::contains(remainingQueries, queryID));
std::string description = remainingQueries[queryID];
logAi->debugStream() << boost::format("Attempted answering query %d - %s. Request id=%d. Waiting for results...") % queryID % description % answerRequestID;
logAi->debugStream() << boost::format("Attempted answering query %d - %s. Request id=%d. Waiting for results...") % queryID % description % answerRequestID;
requestToQueryID[answerRequestID] = queryID;
}
@ -2939,7 +2939,7 @@ void AIStatus::receivedAnswerConfirmation(int answerRequestID, int result)
}
else
{
logAi->errorStream() << "Something went really wrong, failed to answer query " << query << ": " << remainingQueries[query];
logAi->errorStream() << "Something went really wrong, failed to answer query " << query << ": " << remainingQueries[query];
//TODO safely retry
}
}

View File

@ -55,7 +55,7 @@ int CCallback::selectionMade(int selection, QueryID queryID)
ASSERT_IF_CALLED_WITH_PLAYER
if(queryID == QueryID(-1))
{
logGlobal->errorStream() << "Cannot answer the query -1!";
logGlobal->errorStream() << "Cannot answer the query -1!";
return false;
}
@ -92,7 +92,7 @@ bool CCallback::upgradeCreature(const CArmedInstance *obj, SlotID stackPos, Crea
void CCallback::endTurn()
{
logGlobal->traceStream() << "Player " << *player << " ended his turn.";
logGlobal->traceStream() << "Player " << *player << " ended his turn.";
EndTurn pack;
sendRequest(&pack); //report that we ended turn
}
@ -184,7 +184,7 @@ int CBattleCallback::sendRequest(const CPack *request)
int requestID = cl->sendRequest(request, *player);
if(waitTillRealize)
{
logGlobal->traceStream() << boost::format("We'll wait till request %d is answered.\n") % requestID;
logGlobal->traceStream() << boost::format("We'll wait till request %d is answered.\n") % requestID;
auto gsUnlocker = vstd::makeUnlockSharedGuardIf(getGsMutex(), unlockGsWhenWaiting);
cl->waitingRequest.waitWhileContains(requestID);
}

View File

@ -101,7 +101,7 @@ SDL_Surface * BitmapHandler::loadBitmapFromDir(std::string path, std::string fna
{
if(!fname.size())
{
logGlobal->warnStream() << "Call to loadBitmap with void fname!";
logGlobal->warnStream() << "Call to loadBitmap with void fname!";
return nullptr;
}
if (!CResourceHandler::get()->existsResource(ResourceID(path + fname, EResType::IMAGE)))
@ -146,8 +146,8 @@ SDL_Surface * BitmapHandler::loadBitmapFromDir(std::string path, std::string fna
}
else
{
logGlobal->errorStream()<<"Failed to open "<<fname<<" via SDL_Image";
logGlobal->errorStream()<<"Reason: " << IMG_GetError();
logGlobal->errorStream() << "Failed to open " << fname << " via SDL_Image";
logGlobal->errorStream() << "Reason: " << IMG_GetError();
return nullptr;
}
}
@ -173,7 +173,9 @@ SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey)
if (!(bitmap = loadBitmapFromDir("DATA/", fname, setKey)) &&
!(bitmap = loadBitmapFromDir("SPRITES/", fname, setKey)))
logGlobal->errorStream()<<"Error: Failed to find file "<<fname;
{
logGlobal->errorStream() << "Error: Failed to find file " << fname;
}
return bitmap;
}

View File

@ -141,7 +141,7 @@ void init()
loadDLLClasses();
const_cast<CGameInfo*>(CGI)->setFromLib();
logGlobal->infoStream()<<"Initializing VCMI_Lib: "<<tmh.getDiff();
logGlobal->infoStream()<<"Initializing VCMI_Lib: "<<tmh.getDiff();
if(!gNoGUI)
@ -336,8 +336,8 @@ int main(int argc, char** argv)
testFile("SOUNDS/G1A.WAV", "campaign music"); //technically not a music but voiced intro sounds
conf.init();
logGlobal->infoStream() <<"Loading settings: "<<pomtime.getDiff();
logGlobal->infoStream() << NAME;
logGlobal->infoStream() << "Loading settings: " << pomtime.getDiff();
logGlobal->infoStream() << NAME;
srand ( time(nullptr) );
@ -348,11 +348,11 @@ int main(int argc, char** argv)
//something is really wrong...
if (res["width"].Float() < 100 || res["height"].Float() < 100)
{
logGlobal->errorStream() << "Fatal error: failed to load settings!";
logGlobal->errorStream() << "Possible reasons:";
logGlobal->errorStream() << "\tCorrupted local configuration file at " << VCMIDirs::get().userConfigPath() << "/settings.json";
logGlobal->errorStream() << "\tMissing or corrupted global configuration file at " << VCMIDirs::get().userConfigPath() << "/schemas/settings.json";
logGlobal->errorStream() << "VCMI will now exit...";
logGlobal->errorStream() << "Fatal error: failed to load settings!";
logGlobal->errorStream() << "Possible reasons:";
logGlobal->errorStream() << "\tCorrupted local configuration file at " << VCMIDirs::get().userConfigPath() << "/settings.json";
logGlobal->errorStream() << "\tMissing or corrupted global configuration file at " << VCMIDirs::get().userConfigPath() << "/schemas/settings.json";
logGlobal->errorStream() << "VCMI will now exit...";
exit(EXIT_FAILURE);
}
@ -426,7 +426,7 @@ int main(int argc, char** argv)
CCS->videoh = new CEmptyVideoPlayer;
#endif
logGlobal->infoStream()<<"\tInitializing video: "<<pomtime.getDiff();
logGlobal->infoStream()<<"\tInitializing video: "<<pomtime.getDiff();
#if defined(VCMI_ANDROID)
//on Android threaded init is broken
@ -440,7 +440,7 @@ int main(int argc, char** argv)
CCS->musich = new CMusicHandler;
CCS->musich->init();
CCS->musich->setVolume(settings["general"]["music"].Float());
logGlobal->infoStream()<<"Initializing screen and sound handling: "<<pomtime.getDiff();
logGlobal->infoStream()<<"Initializing screen and sound handling: "<<pomtime.getDiff();
#ifdef __APPLE__
// Ctrl+click should be treated as a right click on Mac OS X
@ -465,7 +465,7 @@ int main(int argc, char** argv)
#ifndef VCMI_NO_THREADED_LOAD
loading.join();
#endif
logGlobal->infoStream()<<"Initialization of VCMI (together): "<<total.getDiff();
logGlobal->infoStream()<<"Initialization of VCMI (together): "<<total.getDiff();
if(!vm.count("battle"))
{
@ -484,8 +484,8 @@ int main(int argc, char** argv)
{
if(!fileToStartFrom.empty())
{
logGlobal->warnStream() << "Warning: cannot find given file to start from (" << fileToStartFrom
<< "). Falling back to main menu.";
logGlobal->warnStream() << "Warning: cannot find given file to start from (" << fileToStartFrom
<< "). Falling back to main menu.";
}
GH.curInt = CGPreGame::create(); //will set CGP pointer to itself
}
@ -515,10 +515,10 @@ int main(int argc, char** argv)
void printInfoAboutIntObject(const CIntObject *obj, int level)
{
std::stringstream sbuffer;
sbuffer << std::string(level, '\t');
std::stringstream sbuffer;
sbuffer << std::string(level, '\t');
sbuffer << typeid(*obj).name() << " *** ";
sbuffer << typeid(*obj).name() << " *** ";
if (obj->active)
{
#define PRINT(check, text) if (obj->active & CIntObject::check) sbuffer << text
@ -534,10 +534,10 @@ void printInfoAboutIntObject(const CIntObject *obj, int level)
#undef PRINT
}
else
sbuffer << "inactive";
sbuffer << " at " << obj->pos.x <<"x"<< obj->pos.y;
sbuffer << " (" << obj->pos.w <<"x"<< obj->pos.h << ")";
logGlobal->infoStream() << sbuffer.str();
sbuffer << "inactive";
sbuffer << " at " << obj->pos.x <<"x"<< obj->pos.y;
sbuffer << " (" << obj->pos.w <<"x"<< obj->pos.h << ")";
logGlobal->infoStream() << sbuffer.str();
for(const CIntObject *child : obj->children)
printInfoAboutIntObject(child, level+1);
@ -565,7 +565,7 @@ void processCommand(const std::string &message)
{
if(client && client->erm)
client->erm->executeUserCommand(message);
std::cout << "erm>";
std::cout << "erm>";
}
}
else if(message==std::string("die, fool"))
@ -575,7 +575,7 @@ void processCommand(const std::string &message)
else if(cn == "erm")
{
ermInteractiveMode = true;
std::cout << "erm>";
std::cout << "erm>";
}
else if(cn==std::string("activate"))
{
@ -600,14 +600,14 @@ void processCommand(const std::string &message)
}
else if(cn=="screen")
{
std::cout << "Screenbuf points to ";
std::cout << "Screenbuf points to ";
if(screenBuf == screen)
logGlobal->errorStream() << "screen";
logGlobal->errorStream() << "screen";
else if(screenBuf == screen2)
logGlobal->errorStream() << "screen2";
logGlobal->errorStream() << "screen2";
else
logGlobal->errorStream() << "?!?";
logGlobal->errorStream() << "?!?";
SDL_SaveBMP(screen, "Screen_c.bmp");
SDL_SaveBMP(screen2, "Screen2_c.bmp");
@ -624,10 +624,10 @@ void processCommand(const std::string &message)
std::string fname;
readed >> fname;
client->loadGame(fname);
}
}
else if(message=="get txt")
{
std::cout<<"Command accepted.\t";
std::cout << "Command accepted.\t";
const bfs::path outPath =
VCMIDirs::get().userCachePath() / "extracted";
@ -649,7 +649,7 @@ void processCommand(const std::string &message)
file.write((char*)text.first.get(), text.second);
}
std::cout << "\rExtracting done :)\n";
std::cout << "\rExtracting done :)\n";
std::cout << " Extracted files can be found in " << outPath << " directory\n";
}
else if(cn=="crash")
@ -665,24 +665,24 @@ void processCommand(const std::string &message)
else if (cn == "ai")
{
VLC->IS_AI_ENABLED = !VLC->IS_AI_ENABLED;
std::cout << "Current AI status: " << (VLC->IS_AI_ENABLED ? "enabled" : "disabled") << std::endl;
std::cout << "Current AI status: " << (VLC->IS_AI_ENABLED ? "enabled" : "disabled") << std::endl;
}
else if(cn == "mp" && adventureInt)
{
if(const CGHeroInstance *h = dynamic_cast<const CGHeroInstance *>(adventureInt->selection))
std::cout << h->movement << "; max: " << h->maxMovePoints(true) << "/" << h->maxMovePoints(false) << std::endl;
std::cout << h->movement << "; max: " << h->maxMovePoints(true) << "/" << h->maxMovePoints(false) << std::endl;
}
else if(cn == "bonuses")
{
std::cout << "Bonuses of " << adventureInt->selection->getObjectName() << std::endl
<< adventureInt->selection->getBonusList() << std::endl;
std::cout << "\nInherited bonuses:\n";
std::cout << "\nInherited bonuses:\n";
TCNodes parents;
adventureInt->selection->getParents(parents);
for(const CBonusSystemNode *parent : parents)
{
std::cout << "\nBonuses from " << typeid(*parent).name() << std::endl << parent->getBonusList() << std::endl;
std::cout << "\nBonuses from " << typeid(*parent).name() << std::endl << parent->getBonusList() << std::endl;
}
}
else if(cn == "not dialog")
@ -696,7 +696,7 @@ void processCommand(const std::string &message)
if(const CIntObject *obj = dynamic_cast<const CIntObject *>(child))
printInfoAboutIntObject(obj, 0);
else
std::cout << typeid(*obj).name() << std::endl;
std::cout << typeid(*obj).name() << std::endl;
}
}
else if(cn=="tell")
@ -709,7 +709,7 @@ void processCommand(const std::string &message)
for(const CGHeroInstance *h : LOCPLINT->cb->getHeroesInfo())
if(h->type->ID.getNum() == id1)
if(const CArtifactInstance *a = h->getArt(ArtifactPosition(id2)))
std::cout << a->nodeName();
std::cout << a->nodeName();
}
}
else if (cn == "set")
@ -790,20 +790,20 @@ void processCommand(const std::string &message)
{
std::string fname;
readed >> fname;
std::cout << "Will try loading that AI to see if it is correct name...\n";
std::cout << "Will try loading that AI to see if it is correct name...\n";
try
{
if(auto ai = CDynLibHandler::getNewBattleAI(fname)) //test that given AI is indeed available... heavy but it is easy to make a typo and break the game
{
Settings neutralAI = settings.write["server"]["neutralAI"];
neutralAI->String() = fname;
std::cout << "Setting changed, from now the battle ai will be " << fname << "!\n";
std::cout << "Setting changed, from now the battle ai will be " << fname << "!\n";
}
}
catch(std::exception &e)
{
logGlobal->warnStream() << "Failed opening " << fname << ": " << e.what();
logGlobal->warnStream() << "Setting not changes, AI not found or invalid!";
logGlobal->warnStream() << "Failed opening " << fname << ": " << e.what();
logGlobal->warnStream() << "Setting not changes, AI not found or invalid!";
}
}

View File

@ -52,7 +52,7 @@ void CAudioBase::init()
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024)==-1)
{
logGlobal->errorStream() << "Mix_OpenAudio error: " << Mix_GetError();
logGlobal->errorStream() << "Mix_OpenAudio error: " << Mix_GetError();
return;
}
@ -155,7 +155,7 @@ Mix_Chunk *CSoundHandler::GetSoundChunk(std::string &sound, bool cache)
}
catch(std::exception &e)
{
logGlobal->warnStream() << "Cannot get sound " << sound << " chunk: " << e.what();
logGlobal->warnStream() << "Cannot get sound " << sound << " chunk: " << e.what();
return nullptr;
}
}
@ -183,7 +183,7 @@ int CSoundHandler::playSound(std::string sound, int repeats, bool cache)
channel = Mix_PlayChannel(-1, chunk, repeats);
if (channel == -1)
{
logGlobal->errorStream() << "Unable to play sound file " << sound << " , error " << Mix_GetError();
logGlobal->errorStream() << "Unable to play sound file " << sound << " , error " << Mix_GetError();
if (!cache)
Mix_FreeChunk(chunk);
}
@ -315,7 +315,7 @@ void CMusicHandler::playMusicFromSet(std::string whichSet, bool loop)
auto selectedSet = musicsSet.find(whichSet);
if (selectedSet == musicsSet.end())
{
logGlobal->errorStream() << "Error: playing music from non-existing set: " << whichSet;
logGlobal->errorStream() << "Error: playing music from non-existing set: " << whichSet;
return;
}
@ -332,14 +332,14 @@ void CMusicHandler::playMusicFromSet(std::string whichSet, int entryID, bool loo
auto selectedSet = musicsSet.find(whichSet);
if (selectedSet == musicsSet.end())
{
logGlobal->errorStream() << "Error: playing music from non-existing set: " << whichSet;
logGlobal->errorStream() << "Error: playing music from non-existing set: " << whichSet;
return;
}
auto selectedEntry = selectedSet->second.find(entryID);
if (selectedEntry == selectedSet->second.end())
{
logGlobal->errorStream() << "Error: playing non-existing entry " << entryID << " from set: " << whichSet;
logGlobal->errorStream() << "Error: playing non-existing entry " << entryID << " from set: " << whichSet;
return;
}
@ -470,10 +470,10 @@ bool MusicEntry::play()
load(RandomGeneratorUtil::nextItem(set, CRandomGenerator::getDefault())->second);
}
logGlobal->traceStream()<<"Playing music file "<<currentName;
logGlobal->traceStream()<<"Playing music file "<<currentName;
if(Mix_PlayMusic(music, 1) == -1)
{
logGlobal->errorStream() << "Unable to play music (" << Mix_GetError() << ")";
logGlobal->errorStream() << "Unable to play music (" << Mix_GetError() << ")";
return false;
}
return true;
@ -483,7 +483,7 @@ bool MusicEntry::stop(int fade_ms)
{
if (Mix_PlayingMusic())
{
logGlobal->traceStream()<<"Stoping music file "<<currentName;
logGlobal->traceStream()<<"Stoping music file "<<currentName;
loop = 0;
Mix_FadeOutMusic(fade_ms);
return true;

View File

@ -368,7 +368,7 @@ static std::function<void()> genCommand(CMenuScreen* menu, std::vector<std::stri
}
}
}
logGlobal->errorStream()<<"Failed to parse command: "<<string;
logGlobal->errorStream()<<"Failed to parse command: "<<string;
return std::function<void()>();
}
@ -941,7 +941,7 @@ void CSelectionScreen::handleConnection()
{
CPackForSelectionScreen *pack = nullptr;
*serv >> pack;
logNetwork->traceStream() << "Received a pack of type " << typeid(*pack).name();
logNetwork->traceStream() << "Received a pack of type " << typeid(*pack).name();
assert(pack);
if(QuitMenuWithoutStarting *endingPack = dynamic_cast<QuitMenuWithoutStarting *>(pack))
{
@ -1124,7 +1124,7 @@ void SelectionTab::parseMaps(const std::unordered_set<ResourceID> &files)
}
catch(std::exception & e)
{
logGlobal->errorStream() << "Map " << file.getName() << " is invalid. Message: " << e.what();
logGlobal->errorStream() << "Map " << file.getName() << " is invalid. Message: " << e.what();
}
}
}
@ -1164,7 +1164,7 @@ void SelectionTab::parseGames(const std::unordered_set<ResourceID> &files, bool
}
catch(const std::exception & e)
{
logGlobal->errorStream() << "Error: Failed to process " << file.getName() <<": " << e.what();
logGlobal->errorStream() << "Error: Failed to process " << file.getName() <<": " << e.what();
}
}
}
@ -1461,7 +1461,7 @@ void SelectionTab::printMaps(SDL_Surface *to)
break;
default:
// Unknown version. Be safe and ignore that map
logGlobal->warnStream() << "Warning: " << currentItem->fileURI << " has wrong version!";
logGlobal->warnStream() << "Warning: " << currentItem->fileURI << " has wrong version!";
continue;
}
IImage * icon = formatIcons->getImage(frame,group);

View File

@ -150,7 +150,7 @@ void CClient::waitForMoveAndSend(PlayerColor color)
}
catch(boost::thread_interrupted&)
{
logNetwork->debugStream() << "Wait for move thread was interrupted and no action will be send. Was a battle ended by spell?";
logNetwork->debugStream() << "Wait for move thread was interrupted and no action will be send. Was a battle ended by spell?";
return;
}
catch(...)
@ -158,7 +158,7 @@ void CClient::waitForMoveAndSend(PlayerColor color)
handleException();
return;
}
logNetwork->errorStream() << "We should not be here!";
logNetwork->errorStream() << "We should not be here!";
}
void CClient::run()
@ -182,11 +182,11 @@ void CClient::run()
//catch only asio exceptions
catch (const boost::system::system_error& e)
{
logNetwork->errorStream() << "Lost connection to server, ending listening thread!";
logNetwork->errorStream() << e.what();
logNetwork->errorStream() << "Lost connection to server, ending listening thread!";
logNetwork->errorStream() << e.what();
if(!terminate) //rethrow (-> boom!) only if closing connection was unexpected
{
logNetwork->errorStream() << "Something wrong, lost connection while game is still ongoing...";
logNetwork->errorStream() << "Something wrong, lost connection while game is still ongoing...";
throw;
}
}
@ -196,7 +196,7 @@ void CClient::save(const std::string & fname)
{
if(gs->curB)
{
logNetwork->errorStream() << "Game cannot be saved during battle!";
logNetwork->errorStream() << "Game cannot be saved during battle!";
return;
}
@ -214,7 +214,7 @@ void CClient::endGame( bool closeConnection /*= true*/ )
// Tell the network thread to reach a stable state
if(closeConnection)
stopConnection();
logNetwork->infoStream() << "Closed connection.";
logNetwork->infoStream() << "Closed connection.";
GH.curInt = nullptr;
{
@ -292,12 +292,12 @@ void CClient::loadGame(const std::string & fname, const bool server, const std::
loadCommonState(checkingLoader);
loader = checkingLoader.decay();
}
logNetwork->infoStream() << "Loaded common part of save " << tmh.getDiff();
logNetwork->infoStream() << "Loaded common part of save " << tmh.getDiff();
const_cast<CGameInfo*>(CGI)->mh = new CMapHandler();
const_cast<CGameInfo*>(CGI)->mh->map = gs->map;
pathInfo = make_unique<CPathsInfo>(getMapSize());
CGI->mh->init();
logNetwork->infoStream() <<"Initing maphandler: "<<tmh.getDiff();
logNetwork->infoStream() <<"Initing maphandler: "<<tmh.getDiff();
}
catch(std::exception &e)
{
@ -310,53 +310,53 @@ void CClient::loadGame(const std::string & fname, const bool server, const std::
player = PlayerColor(player_);
*/
std::set<PlayerColor> clientPlayers;
if(server)
serv = sh.connectToServer();
std::set<PlayerColor> clientPlayers;
if(server)
serv = sh.connectToServer();
//*loader >> *this;
if(server)
{
tmh.update();
ui8 pom8;
*serv << ui8(3) << ui8(loadNumPlayers); //load game; one client if single-player
*serv << fname;
*serv >> pom8;
if(pom8)
throw std::runtime_error("Server cannot open the savegame!");
else
logNetwork->infoStream() << "Server opened savegame properly.";
}
if(server)
{
tmh.update();
ui8 pom8;
*serv << ui8(3) << ui8(loadNumPlayers); //load game; one client if single-player
*serv << fname;
*serv >> pom8;
if(pom8)
throw std::runtime_error("Server cannot open the savegame!");
else
logNetwork->infoStream() << "Server opened savegame properly.";
}
if(server)
{
for(auto & elem : gs->scenarioOps->playerInfos)
if(!std::count(humanplayerindices.begin(),humanplayerindices.end(),elem.first.getNum()) || elem.first==player)
{
clientPlayers.insert(elem.first);
}
clientPlayers.insert(PlayerColor::NEUTRAL);
}
else
{
clientPlayers.insert(player);
}
if(server)
{
for(auto & elem : gs->scenarioOps->playerInfos)
{
if(!std::count(humanplayerindices.begin(),humanplayerindices.end(),elem.first.getNum()) || elem.first==player)
clientPlayers.insert(elem.first);
}
clientPlayers.insert(PlayerColor::NEUTRAL);
}
else
{
clientPlayers.insert(player);
}
std::cout << "CLIENTPLAYERS:\n";
for(auto x : clientPlayers)
std::cout << x << std::endl;
std::cout << "ENDCLIENTPLAYERS\n";
std::cout << "CLIENTPLAYERS:\n";
for(auto x : clientPlayers)
std::cout << x << std::endl;
std::cout << "ENDCLIENTPLAYERS\n";
serialize(loader->serializer,0,clientPlayers);
*serv << ui32(clientPlayers.size());
for(auto & elem : clientPlayers)
*serv << ui8(elem.getNum());
serv->addStdVecItems(gs); /*why is this here?*/
serialize(loader->serializer,0,clientPlayers);
*serv << ui32(clientPlayers.size());
for(auto & elem : clientPlayers)
*serv << ui8(elem.getNum());
serv->addStdVecItems(gs); /*why is this here?*/
//*loader >> *this;
logNetwork->infoStream() << "Loaded client part of save " << tmh.getDiff();
logNetwork->infoStream() << "Loaded client part of save " << tmh.getDiff();
logNetwork->infoStream() <<"Sent info to server: "<<tmh.getDiff();
logNetwork->infoStream() <<"Sent info to server: "<<tmh.getDiff();
//*serv << clientPlayers;
serv->enableStackSendingByID();
@ -405,7 +405,7 @@ void CClient::newGame( CConnection *con, StartInfo *si )
}
c >> si;
logNetwork->infoStream() <<"\tSending/Getting info to/from the server: "<<tmh.getDiff();
logNetwork->infoStream() <<"\tSending/Getting info to/from the server: "<<tmh.getDiff();
c.enableStackSendingByID();
c.disableSmartPointerSerialization();
@ -415,7 +415,7 @@ void CClient::newGame( CConnection *con, StartInfo *si )
gs->scenarioOps = si;
gs->init(si);
logNetwork->infoStream() <<"Initializing GameState (together): "<<tmh.getDiff();
logNetwork->infoStream() <<"Initializing GameState (together): "<<tmh.getDiff();
// Now after possible random map gen, we know exact player count.
// Inform server about how many players client handles
@ -438,10 +438,10 @@ void CClient::newGame( CConnection *con, StartInfo *si )
{
const_cast<CGameInfo*>(CGI)->mh = new CMapHandler();
CGI->mh->map = gs->map;
logNetwork->infoStream() <<"Creating mapHandler: "<<tmh.getDiff();
logNetwork->infoStream() << "Creating mapHandler: " << tmh.getDiff();
CGI->mh->init();
pathInfo = make_unique<CPathsInfo>(getMapSize());
logNetwork->infoStream() <<"Initializing mapHandler (together): "<<tmh.getDiff();
logNetwork->infoStream() << "Initializing mapHandler (together): " << tmh.getDiff();
}
int humanPlayers = 0;
@ -452,7 +452,7 @@ void CClient::newGame( CConnection *con, StartInfo *si )
if(!vstd::contains(myPlayers, color))
continue;
logNetwork->traceStream() << "Preparing interface for player " << color;
logNetwork->traceStream() << "Preparing interface for player " << color;
if(si->mode != StartInfo::DUEL)
{
if(elem.second.playerID == PlayerSettings::PLAYER_AI)
@ -618,8 +618,8 @@ void CClient::serialize(CISer & h, const int version, const std::set<PlayerColor
{
if(pid == PlayerColor::NEUTRAL)
{
if(playerIDs.count(pid))
installNewBattleInterface(CDynLibHandler::getNewBattleAI(dllname), pid);
if(playerIDs.count(pid))
installNewBattleInterface(CDynLibHandler::getNewBattleAI(dllname), pid);
//TODO? consider serialization
continue;
}
@ -639,14 +639,14 @@ void CClient::serialize(CISer & h, const int version, const std::set<PlayerColor
nInt->human = isHuman;
nInt->playerID = pid;
if(playerIDs.count(pid))
installNewPlayerInterface(nInt, pid);
if(playerIDs.count(pid))
installNewPlayerInterface(nInt, pid);
nInt->loadGame(h, version);
nInt->loadGame(h, version);
}
if(playerIDs.count(PlayerColor::NEUTRAL))
loadNeutralBattleAI();
loadNeutralBattleAI();
}
}
@ -657,15 +657,15 @@ void CClient::handlePack( CPack * pack )
{
boost::unique_lock<boost::recursive_mutex> guiLock(*LOCPLINT->pim);
apply->applyOnClBefore(this,pack);
logNetwork->traceStream() << "\tMade first apply on cl";
logNetwork->traceStream() << "\tMade first apply on cl";
gs->apply(pack);
logNetwork->traceStream() << "\tApplied on gs";
logNetwork->traceStream() << "\tApplied on gs";
apply->applyOnClAfter(this,pack);
logNetwork->traceStream() << "\tMade second apply on cl";
logNetwork->traceStream() << "\tMade second apply on cl";
}
else
{
logNetwork->errorStream() << "Message cannot be applied, cannot find applier! TypeID " << typeList.getTypeID(pack);
logNetwork->errorStream() << "Message cannot be applied, cannot find applier! TypeID " << typeList.getTypeID(pack);
}
delete pack;
}
@ -685,11 +685,11 @@ void CClient::stopConnection()
if (serv) //request closing connection
{
logNetwork->infoStream() << "Connection has been requested to be closed.";
logNetwork->infoStream() << "Connection has been requested to be closed.";
boost::unique_lock<boost::mutex>(*serv->wmx);
CloseServer close_server;
sendRequest(&close_server, PlayerColor::NEUTRAL);
logNetwork->infoStream() << "Sent closing signal to the server";
logNetwork->infoStream() << "Sent closing signal to the server";
}
if(connectionHandler)//end connection handler
@ -697,7 +697,7 @@ void CClient::stopConnection()
if(connectionHandler->get_id() != boost::this_thread::get_id())
connectionHandler->join();
logNetwork->infoStream() << "Connection handler thread joined";
logNetwork->infoStream() << "Connection handler thread joined";
delete connectionHandler;
connectionHandler = nullptr;
@ -708,7 +708,7 @@ void CClient::stopConnection()
serv->close();
delete serv;
serv = nullptr;
logNetwork->warnStream() << "Our socket has been closed.";
logNetwork->warnStream() << "Our socket has been closed.";
}
}
@ -833,7 +833,7 @@ int CClient::sendRequest(const CPack *request, PlayerColor player)
static ui32 requestCounter = 0;
ui32 requestID = requestCounter++;
logNetwork->traceStream() << boost::format("Sending a request \"%s\". It'll have an ID=%d.")
logNetwork->traceStream() << boost::format("Sending a request \"%s\". It'll have an ID=%d.")
% typeid(*request).name() % requestID;
waitingRequest.pushBack(requestID);
@ -933,7 +933,7 @@ void CServerHandler::startServer()
th.update();
serverThread = new boost::thread(&CServerHandler::callServer, this); //runs server executable;
if(verbose)
logNetwork->infoStream() << "Setting up thread calling server: " << th.getDiff();
logNetwork->infoStream() << "Setting up thread calling server: " << th.getDiff();
}
void CServerHandler::waitForServer()
@ -950,7 +950,7 @@ void CServerHandler::waitForServer()
}
#endif
if(verbose)
logNetwork->infoStream() << "Waiting for server: " << th.getDiff();
logNetwork->infoStream() << "Waiting for server: " << th.getDiff();
}
CConnection * CServerHandler::connectToServer()
@ -967,7 +967,7 @@ CConnection * CServerHandler::connectToServer()
CConnection *ret = justConnectToServer(settings["server"]["server"].String(), port);
if(verbose)
logNetwork->infoStream()<<"\tConnecting to the server: "<<th.getDiff();
logNetwork->infoStream()<<"\tConnecting to the server: "<<th.getDiff();
return ret;
}
@ -987,13 +987,13 @@ CServerHandler::CServerHandler(bool runServer /*= false*/)
try
{
shared = new SharedMem();
}
catch(...)
{
logNetwork->error("Cannot open interprocess memory.");
handleException();
throw;
}
}
catch(...)
{
logNetwork->error("Cannot open interprocess memory.");
handleException();
throw;
}
#endif
}
@ -1010,11 +1010,11 @@ void CServerHandler::callServer()
const std::string comm = VCMIDirs::get().serverPath().string() + " --port=" + port + " > \"" + logName + '\"';
int result = std::system(comm.c_str());
if (result == 0)
logNetwork->infoStream() << "Server closed correctly";
logNetwork->infoStream() << "Server closed correctly";
else
{
logNetwork->errorStream() << "Error: server failed to close correctly or crashed!";
logNetwork->errorStream() << "Check " << logName << " for more info";
logNetwork->errorStream() << "Error: server failed to close correctly or crashed!";
logNetwork->errorStream() << "Check " << logName << " for more info";
exit(1);// exit in case of error. Othervice without working server VCMI will hang
}
}
@ -1034,14 +1034,14 @@ CConnection * CServerHandler::justConnectToServer(const std::string &host, const
{
try
{
logNetwork->infoStream() << "Establishing connection...";
logNetwork->infoStream() << "Establishing connection...";
ret = new CConnection( host.size() ? host : settings["server"]["server"].String(),
realPort,
NAME);
}
catch(...)
{
logNetwork->errorStream() << "\nCannot establish connection! Retrying within 2 seconds";
logNetwork->errorStream() << "\nCannot establish connection! Retrying within 2 seconds";
SDL_Delay(2000);
}
}

View File

@ -316,7 +316,7 @@ void Graphics::loadHeroFlags()
loadHeroFlagsDetail(p,true);
}
#endif
logGlobal->infoStream() << "Loading and transforming heroes' flags: "<<th.getDiff();
logGlobal->infoStream() << "Loading and transforming heroes' flags: "<<th.getDiff();
}
void Graphics::blueToPlayersAdv(SDL_Surface * sur, PlayerColor player)
@ -334,7 +334,7 @@ void Graphics::blueToPlayersAdv(SDL_Surface * sur, PlayerColor player)
}
else
{
logGlobal->errorStream() << "Wrong player id in blueToPlayersAdv (" << player << ")!";
logGlobal->errorStream() << "Wrong player id in blueToPlayersAdv (" << player << ")!";
return;
}
SDL_SetColors(sur, palette, 224, 32);

View File

@ -120,7 +120,7 @@ void SetPrimSkill::applyCl( CClient *cl )
const CGHeroInstance *h = cl->getHero(id);
if(!h)
{
logNetwork->errorStream() << "Cannot find hero with ID " << id.getNum();
logNetwork->errorStream() << "Cannot find hero with ID " << id.getNum();
return;
}
INTERFACE_CALL_IF_PRESENT(h->tempOwner,heroPrimarySkillChanged,h,which,val);
@ -131,7 +131,7 @@ void SetSecSkill::applyCl( CClient *cl )
const CGHeroInstance *h = cl->getHero(id);
if(!h)
{
logNetwork->errorStream() << "Cannot find hero with ID " << id;
logNetwork->errorStream() << "Cannot find hero with ID " << id;
return;
}
INTERFACE_CALL_IF_PRESENT(h->tempOwner,heroSecondarySkillChanged,h,which,val);
@ -495,7 +495,7 @@ void HeroRecruited::applyCl( CClient *cl )
CGHeroInstance *h = GS(cl)->map->heroesOnMap.back();
if(h->subID != hid)
{
logNetwork->errorStream() << "Something wrong with hero recruited!";
logNetwork->errorStream() << "Something wrong with hero recruited!";
}
CGI->mh->printObject(h);
@ -533,7 +533,7 @@ void InfoWindow::applyCl( CClient *cl )
if(vstd::contains(cl->playerint,player))
cl->playerint.at(player)->showInfoDialog(str,comps,(soundBase::soundID)soundID);
else
logNetwork->warnStream() << "We received InfoWindow for not our player...";
logNetwork->warnStream() << "We received InfoWindow for not our player...";
}
void SetObjectProperty::applyCl( CClient *cl )
@ -576,7 +576,7 @@ void BlockingDialog::applyCl( CClient *cl )
if(vstd::contains(cl->playerint,player))
cl->playerint.at(player)->showBlockingDialog(str,components,queryID,(soundBase::soundID)soundID,selection(),cancel());
else
logNetwork->warnStream() << "We received YesNoDialog for not our player...";
logNetwork->warnStream() << "We received YesNoDialog for not our player...";
}
void GarrisonDialog::applyCl(CClient *cl)
@ -782,7 +782,7 @@ void PackageApplied::applyCl( CClient *cl )
{
INTERFACE_CALL_IF_PRESENT(player, requestRealized, this);
if(!cl->waitingRequest.tryRemovingElement(requestID))
logNetwork->warnStream() << "Surprising server message!";
logNetwork->warnStream() << "Surprising server message!";
}
void SystemMessage::applyCl( CClient *cl )
@ -790,7 +790,7 @@ void SystemMessage::applyCl( CClient *cl )
std::ostringstream str;
str << "System message: " << text;
logNetwork->errorStream() << str.str(); // usually used to receive error messages from server
logNetwork->errorStream() << str.str(); // usually used to receive error messages from server
if(LOCPLINT)
LOCPLINT->cingconsole->print(str.str());
}
@ -819,7 +819,7 @@ void SaveGame::applyCl(CClient *cl)
}
catch(std::exception &e)
{
logNetwork->errorStream() << "Failed to save game:" << e.what();
logNetwork->errorStream() << "Failed to save game:" << e.what();
}
}
@ -961,6 +961,6 @@ void TradeComponents::applyCl(CClient *cl)
case Obj::TRADING_POST_SNOW:
break;
default:
logNetwork->warnStream() << "Shop type not supported!";
logNetwork->warnStream() << "Shop type not supported!";
}
}

View File

@ -361,7 +361,7 @@ bool CMeleeAttackAnimation::init()
group = mutPosToGroup[mutPos];
break;
default:
logGlobal->errorStream()<<"Critical Error! Wrong dest in stackAttacking! dest: "<<dest<<" attacking stack pos: "<<attackingStackPosBeforeReturn<<" mutual pos: "<<mutPos;
logGlobal->errorStream()<<"Critical Error! Wrong dest in stackAttacking! dest: "<<dest<<" attacking stack pos: "<<attackingStackPosBeforeReturn<<" mutual pos: "<<mutPos;
group = CCreatureAnim::ATTACK_FRONT;
break;
}

View File

@ -733,7 +733,7 @@ void CBattleInterface::setBattleCursor(const int myNumber)
// Generally should NEVER happen, but to avoid the possibility of having endless loop below... [#1016]
if(!vstd::contains_if(sectorCursor, [](int sc) { return sc != -1; }))
{
logGlobal->errorStream() << "Error: for hex " << myNumber << " cannot find a hex to attack from!";
logGlobal->errorStream() << "Error: for hex " << myNumber << " cannot find a hex to attack from!";
attackingHex = -1;
return;
}
@ -758,11 +758,11 @@ void CBattleInterface::setBattleCursor(const int myNumber)
break;
case 3:
attackingHex = myNumber + 1; //right
break;
break;
case 4:
attackingHex = myNumber + GameConstants::BFIELD_WIDTH + zigzagCorrection; //bottom right
break;
case 5:
break;
case 5:
attackingHex = myNumber + GameConstants::BFIELD_WIDTH - 1 + zigzagCorrection; //bottom left
break;
}
@ -1109,7 +1109,7 @@ void CBattleInterface::giveCommand(Battle::ActionType action, BattleHex tile, ui
}
if(stack && stack != activeStack)
logGlobal->warnStream() << "Warning: giving an order to a non-active stack?";
logGlobal->warnStream() << "Warning: giving an order to a non-active stack?";
auto ba = new BattleAction(); //is deleted in CPlayerInterface::activeStack()
ba->side = defendingHeroInstance ? (curInt->playerID == defendingHeroInstance->tempOwner) : false;
@ -1133,7 +1133,7 @@ void CBattleInterface::giveCommand(Battle::ActionType action, BattleHex tile, ui
if(!tacticsMode)
{
logGlobal->traceStream() << "Setting command for " << (stack ? stack->nodeName() : "hero");
logGlobal->traceStream() << "Setting command for " << (stack ? stack->nodeName() : "hero");
myTurn = false;
setActiveStack(nullptr);
givenCommand->setn(ba);
@ -1869,7 +1869,7 @@ void CBattleInterface::startAction(const BattleAction* action)
}
if(!stack)
{
logGlobal->errorStream()<<"Something wrong with stackNumber in actionStarted. Stack number: "<<action->stackNumber;
logGlobal->errorStream()<<"Something wrong with stackNumber in actionStarted. Stack number: "<<action->stackNumber;
return;
}
@ -2713,13 +2713,13 @@ void CBattleInterface::obstaclePlaced(const CObstacleInstance & oi)
sound = soundBase::fireWall;
break;
default:
logGlobal->errorStream() << "I don't know how to animate appearing obstacle of type " << (int)oi.obstacleType;
logGlobal->errorStream() << "I don't know how to animate appearing obstacle of type " << (int)oi.obstacleType;
return;
}
if(graphics->battleACToDef[effectID].empty())
{
logGlobal->errorStream() << "Cannot find def for effect type " << effectID;
logGlobal->errorStream() << "Cannot find def for effect type " << effectID;
return;
}

View File

@ -383,7 +383,7 @@ void CCreatureAnimation::nextFrame(SDL_Surface *dest, bool attacker)
case 3: return nextFrameT<3>(dest, !attacker);
case 4: return nextFrameT<4>(dest, !attacker);
default:
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << " bpp is not supported!!!";
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << " bpp is not supported!!!";
}
}

View File

@ -311,7 +311,7 @@ void CDefFile::loadFrame(size_t frame, size_t group, ImageLoader &loader) const
break;
}
default:
logGlobal->errorStream()<<"Error: unsupported format of def file: "<<sprite.format;
logGlobal->errorStream()<<"Error: unsupported format of def file: "<<sprite.format;
break;
}
};
@ -607,7 +607,7 @@ SDLImage::SDLImage(std::string filename, bool compressed):
if (surf == nullptr)
{
logGlobal->errorStream() << "Error: failed to load image "<<filename;
logGlobal->errorStream() << "Error: failed to load image "<<filename;
return;
}
else
@ -1050,8 +1050,8 @@ CDefFile * CAnimation::getFile() const
void CAnimation::printError(size_t frame, size_t group, std::string type) const
{
logGlobal->errorStream() << type <<" error: Request for frame not present in CAnimation! "
<<"\tFile name: "<<name<<" Group: "<<group<<" Frame: "<<frame;
logGlobal->errorStream() << type << " error: Request for frame not present in CAnimation! "
<< "\tFile name: " << name << " Group: " << group << " Frame: " << frame;
}
CAnimation::CAnimation(std::string Name, bool Compressed):
@ -1080,7 +1080,7 @@ CAnimation::~CAnimation()
{
if (!images.empty())
{
logGlobal->warnStream()<<"Warning: not all frames were unloaded from "<<name;
logGlobal->warnStream()<<"Warning: not all frames were unloaded from "<<name;
for (auto & elem : images)
for (auto & _image : elem.second)
delete _image.second;
@ -1171,13 +1171,12 @@ std::set<CAnimation*> CAnimation::loadedAnims;
void CAnimation::getAnimInfo()
{
logGlobal->errorStream()<<"Animation stats: Loaded "<<loadedAnims.size()<<" total";
for (auto anim : loadedAnims)
logGlobal->errorStream() << "Animation stats: Loaded " << loadedAnims.size() << " total";
for(auto anim : loadedAnims)
{
logGlobal->errorStream()<<"Name: "<<anim->name<<" Groups: "<<anim->images.size();
if (!anim->images.empty())
logGlobal->errorStream()<<", "<<anim->images.begin()->second.size()<<" image loaded in group "<< anim->images.begin()->first;
logGlobal->errorStream() << "Name: " << anim->name << " Groups: " << anim->images.size();
if(!anim->images.empty())
logGlobal->errorStream() << ", " << anim->images.begin()->second.size() << " image loaded in group " << anim->images.begin()->first;
}
}

View File

@ -475,7 +475,7 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(const SDL_Surface * src, const SDL_Rect * src
case 3: return blit8bppAlphaTo24bppT<3>(src, srcRect, dst, dstRect);
case 4: return blit8bppAlphaTo24bppT<4>(src, srcRect, dst, dstRect);
default:
logGlobal->errorStream() << (int)dst->format->BitsPerPixel << " bpp is not supported!!!";
logGlobal->errorStream() << (int)dst->format->BitsPerPixel << " bpp is not supported!!!";
return -1;
}
}
@ -556,7 +556,7 @@ void CSDL_Ext::setPlayerColor(SDL_Surface * sur, PlayerColor player)
SDL_SetColors(sur, color, 5, 1);
}
else
logGlobal->warnStream() << "Warning, setPlayerColor called on not 8bpp surface!";
logGlobal->warnStream() << "Warning, setPlayerColor called on not 8bpp surface!";
}
TColorPutter CSDL_Ext::getPutterFor(SDL_Surface * const &dest, int incrementing)
@ -577,7 +577,7 @@ case BytesPerPixel: \
CASE_BPP(3)
CASE_BPP(4)
default:
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << "bpp is not supported!";
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << "bpp is not supported!";
return nullptr;
}
@ -591,7 +591,7 @@ TColorPutterAlpha CSDL_Ext::getPutterAlphaFor(SDL_Surface * const &dest, int inc
CASE_BPP(3)
CASE_BPP(4)
default:
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << "bpp is not supported!";
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << "bpp is not supported!";
return nullptr;
}
#undef CASE_BPP
@ -675,7 +675,7 @@ BlitterWithRotationVal CSDL_Ext::getBlitterWithRotation(SDL_Surface *dest)
case 3: return blitWithRotateClipVal<3>;
case 4: return blitWithRotateClipVal<4>;
default:
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << " bpp is not supported!!!";
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << " bpp is not supported!!!";
break;
}
@ -691,7 +691,7 @@ BlitterWithRotationVal CSDL_Ext::getBlitterWithRotationAndAlpha(SDL_Surface *des
case 3: return blitWithRotateClipValWithAlpha<3>;
case 4: return blitWithRotateClipValWithAlpha<4>;
default:
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << " bpp is not supported!!!";
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << " bpp is not supported!!!";
break;
}

View File

@ -64,8 +64,8 @@ void CGarrisonSlot::hover (bool on)
}
else
{
logGlobal->warnStream() << "Warning - shouldn't be - highlighted void slot "<<owner->getSelection();
logGlobal->warnStream() << "Highlighted set to nullptr";
logGlobal->warnStream() << "Warning - shouldn't be - highlighted void slot "<<owner->getSelection();
logGlobal->warnStream() << "Highlighted set to nullptr";
owner->selectSlot(nullptr);
}
}

View File

@ -73,8 +73,8 @@ void CLabel::setText(const std::string &Txt)
}
CMultiLineLabel::CMultiLineLabel(Rect position, EFonts Font, EAlignment Align, const SDL_Color &Color, const std::string &Text):
CLabel(position.x, position.y, Font, Align, Color, Text),
visibleSize(0, 0, position.w, position.h)
CLabel(position.x, position.y, Font, Align, Color, Text),
visibleSize(0, 0, position.w, position.h)
{
pos.w = position.w;
pos.h = position.h;
@ -245,8 +245,8 @@ void CLabelGroup::add(int x, int y, const std::string &text)
}
CTextBox::CTextBox(std::string Text, const Rect &rect, int SliderStyle, EFonts Font /*= FONT_SMALL*/, EAlignment Align /*= TOPLEFT*/, const SDL_Color &Color /*= Colors::WHITE*/):
sliderStyle(SliderStyle),
slider(nullptr)
sliderStyle(SliderStyle),
slider(nullptr)
{
OBJ_CONSTRUCTION_CAPTURING_ALL;
label = new CMultiLineLabel(rect, Font, Align, Color);
@ -326,7 +326,7 @@ CGStatusBar::CGStatusBar(CPicture *BG, EFonts Font /*= FONT_SMALL*/, EAlignment
addChild(bg);
pos = bg->pos;
getBorderSize();
textLock = false;
textLock = false;
}
CGStatusBar::CGStatusBar(int x, int y, std::string name/*="ADROLLVR.bmp"*/, int maxw/*=-1*/)
@ -341,7 +341,7 @@ CGStatusBar::CGStatusBar(int x, int y, std::string name/*="ADROLLVR.bmp"*/, int
vstd::amin(pos.w, maxw);
bg->srcRect = new Rect(0, 0, maxw, pos.h);
}
textLock = false;
textLock = false;
}
CGStatusBar::~CGStatusBar()
@ -351,7 +351,7 @@ CGStatusBar::~CGStatusBar()
void CGStatusBar::show(SDL_Surface * to)
{
showAll(to);
showAll(to);
}
void CGStatusBar::init()
@ -377,12 +377,12 @@ Point CGStatusBar::getBorderSize()
void CGStatusBar::lock(bool shouldLock)
{
textLock = shouldLock;
textLock = shouldLock;
}
CTextInput::CTextInput(const Rect &Pos, EFonts font, const CFunctionList<void(const std::string &)> &CB):
CLabel(Pos.x, Pos.y, font, CENTER),
cb(CB)
CLabel(Pos.x, Pos.y, font, CENTER),
cb(CB)
{
type |= REDRAW_PARENT;
focus = false;
@ -570,7 +570,7 @@ void CTextInput::numberFilter(std::string & text, const std::string & oldText, i
catch(boost::bad_lexical_cast &)
{
//Should never happen. Unless I missed some cases
logGlobal->warnStream() << "Warning: failed to convert "<< text << " to number!";
logGlobal->warnStream() << "Warning: failed to convert "<< text << " to number!";
text = oldText;
}
}

View File

@ -261,7 +261,7 @@ void CBuildingRect::mouseMoved (const SDL_MouseMotionEvent & sEvent)
}
CDwellingInfoBox::CDwellingInfoBox(int centerX, int centerY, const CGTownInstance *Town, int level):
CWindowObject(RCLICK_POPUP | PLAYER_COLORED, "CRTOINFO", Point(centerX, centerY))
CWindowObject(RCLICK_POPUP | PLAYER_COLORED, "CRTOINFO", Point(centerX, centerY))
{
OBJ_CONSTRUCTION_CAPTURING_ALL;
@ -601,7 +601,7 @@ const CGHeroInstance* CCastleBuildings::getHero()
void CCastleBuildings::buildingClicked(BuildingID building)
{
logGlobal->traceStream()<<"You've clicked on "<<building;
logGlobal->traceStream()<<"You've clicked on "<<building;
const CBuilding *b = town->town->buildings.find(building)->second;
if(building >= BuildingID::DWELL_FIRST)
@ -877,7 +877,7 @@ void CCastleBuildings::openTownHall()
}
CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInstance * from):
CWindowObject(PLAYER_COLORED | BORDERED),
CWindowObject(PLAYER_COLORED | BORDERED),
hall(nullptr),
fort(nullptr),
town(Town)
@ -1180,7 +1180,7 @@ void CCastleInterface::keyPressed( const SDL_KeyboardEvent & key )
for(const CStructure * str : town->town->clientInfo.structures)
{
if (str->building)
logGlobal->errorStream() << int(str->building->bid) << " -> " << int(str->pos.z);
logGlobal->errorStream() << int(str->building->bid) << " -> " << int(str->pos.z);
}
}
break;
@ -1196,7 +1196,7 @@ void CCastleInterface::keyPressed( const SDL_KeyboardEvent & key )
for(const CStructure * str : town->town->clientInfo.structures)
{
if (str->building)
logGlobal->errorStream() << int(str->building->bid) << " -> " << int(str->pos.z);
logGlobal->errorStream() << int(str->building->bid) << " -> " << int(str->pos.z);
}
}
@ -1311,7 +1311,7 @@ CHallInterface::CBuildingBox::CBuildingBox(int x, int y, const CGTownInstance *
}
CHallInterface::CHallInterface(const CGTownInstance *Town):
CWindowObject(PLAYER_COLORED | BORDERED, Town->town->clientInfo.hallBackground),
CWindowObject(PLAYER_COLORED | BORDERED, Town->town->clientInfo.hallBackground),
town(Town)
{
OBJ_CONSTRUCTION_CAPTURING_ALL;
@ -1392,9 +1392,9 @@ std::string CBuildWindow::getTextForState(int state)
}
CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Building, int state, bool rightClick):
CWindowObject(PLAYER_COLORED | (rightClick ? RCLICK_POPUP : 0), "TPUBUILD"),
CWindowObject(PLAYER_COLORED | (rightClick ? RCLICK_POPUP : 0), "TPUBUILD"),
town(Town),
building(Building)
building(Building)
{
OBJ_CONSTRUCTION_CAPTURING_ALL;
@ -1447,7 +1447,7 @@ std::string CFortScreen::getBgName(const CGTownInstance *town)
}
CFortScreen::CFortScreen(const CGTownInstance * town):
CWindowObject(PLAYER_COLORED | BORDERED, getBgName(town))
CWindowObject(PLAYER_COLORED | BORDERED, getBgName(town))
{
OBJ_CONSTRUCTION_CAPTURING_ALL;
ui32 fortSize = town->creatures.size();
@ -1729,7 +1729,7 @@ void CMageGuildScreen::Scroll::hover(bool on)
}
CBlacksmithDialog::CBlacksmithDialog(bool possible, CreatureID creMachineID, ArtifactID aid, ObjectInstanceID hid):
CWindowObject(PLAYER_COLORED, "TPSMITH")
CWindowObject(PLAYER_COLORED, "TPSMITH")
{
OBJ_CONSTRUCTION_CAPTURING_ALL;

View File

@ -186,7 +186,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
if(!hero) //something strange... no hero? it shouldn't happen
{
logGlobal->errorStream() << "Set nullptr hero? no way...";
logGlobal->errorStream() << "Set nullptr hero? no way...";
return;
}

View File

@ -34,11 +34,11 @@
*/
CTradeWindow::CTradeableItem::CTradeableItem(Point pos, EType Type, int ID, bool Left, int Serial):
CIntObject(LCLICK | HOVER | RCLICK, pos),
type(EType(-1)),// set to invalid, will be corrected in setType
id(ID),
serial(Serial),
left(Left)
CIntObject(LCLICK | HOVER | RCLICK, pos),
type(EType(-1)),// set to invalid, will be corrected in setType
id(ID),
serial(Serial),
left(Left)
{
downSelection = false;
hlp = nullptr;
@ -320,13 +320,13 @@ void CTradeWindow::CTradeableItem::setArtInstance(const CArtifactInstance *art)
}
CTradeWindow::CTradeWindow(std::string bgName, const IMarket *Market, const CGHeroInstance *Hero, EMarketMode::EMarketMode Mode):
CWindowObject(PLAYER_COLORED, bgName),
CWindowObject(PLAYER_COLORED, bgName),
market(Market),
hero(Hero),
arts(nullptr),
hLeft(nullptr),
hRight(nullptr),
readyToTrade(false)
hero(Hero),
arts(nullptr),
hLeft(nullptr),
hRight(nullptr),
readyToTrade(false)
{
type |= BLOCK_ADV_HOTKEYS;
mode = Mode;
@ -657,7 +657,7 @@ std::string CMarketplaceWindow::getBackgroundForMode(EMarketMode::EMarketMode mo
}
CMarketplaceWindow::CMarketplaceWindow(const IMarket *Market, const CGHeroInstance *Hero, EMarketMode::EMarketMode Mode)
: CTradeWindow(getBackgroundForMode(Mode), Market, Hero, Mode)
: CTradeWindow(getBackgroundForMode(Mode), Market, Hero, Mode)
{
OBJ_CONSTRUCTION_CAPTURING_ALL;
@ -1471,7 +1471,7 @@ bool CAltarWindow::putOnAltar(CTradeableItem* altarSlot, const CArtifactInstance
{
if(!art->artType->isTradable()) //special art
{
logGlobal->warnStream() << "Cannot put special artifact on altar!";
logGlobal->warnStream() << "Cannot put special artifact on altar!";
return false;
}
@ -1480,7 +1480,7 @@ bool CAltarWindow::putOnAltar(CTradeableItem* altarSlot, const CArtifactInstance
int slotIndex = firstFreeSlot();
if(slotIndex < 0)
{
logGlobal->warnStream() << "No free slots on altar!";
logGlobal->warnStream() << "No free slots on altar!";
return false;
}
altarSlot = items[0][slotIndex];

View File

@ -665,7 +665,7 @@ ui8 BattleInfo::whatSide(PlayerColor player) const
if(sides[i].color == player)
return i;
logGlobal->warnStream() << "BattleInfo::whatSide: Player " << player << " is not in battle!";
logGlobal->warnStream() << "BattleInfo::whatSide: Player " << player << " is not in battle!";
return -1;
}

View File

@ -276,7 +276,7 @@ public:
else if(!army || slot == SlotID() || !army->hasStackAtSlot(slot))
{
base = nullptr;
logGlobal->warnStream() << type->nameSing << " doesn't have a base stack!";
logGlobal->warnStream() << type->nameSing << " doesn't have a base stack!";
}
else
{

View File

@ -414,7 +414,7 @@ void CArtHandler::loadType(CArtifact * art, const JsonNode & node)
}
}
else
logGlobal->warnStream() << "Warning! Artifact type " << b.String() << " not recognized!";
logGlobal->warnStream() << "Warning! Artifact type " << b.String() << " not recognized!";
}
}
@ -693,11 +693,11 @@ void CArtHandler::erasePickedArt(ArtifactID id)
artifactList->erase(itr);
}
else
logGlobal->warnStream() << "Problem: cannot erase artifact " << art->Name() << " from list, it was not present";
logGlobal->warnStream() << "Problem: cannot erase artifact " << art->Name() << " from list, it was not present";
}
else
logGlobal->warnStream() << "Problem: cannot find list for artifact " << art->Name() << ", strange class. (special?)";
logGlobal->warnStream() << "Problem: cannot find list for artifact " << art->Name() << ", strange class. (special?)";
}
boost::optional<std::vector<CArtifact*>&> CArtHandler::listFromClass( CArtifact::EartClass artifactClass )
@ -883,8 +883,8 @@ bool CArtifactInstance::canBePutAt(const CArtifactSet *artSet, ArtifactPosition
auto possibleSlots = artType->possibleSlots.find(artSet->bearerType());
if(possibleSlots == artType->possibleSlots.end())
{
logGlobal->warnStream() << "Warning: artifact " << artType->Name() << " doesn't have defined allowed slots for bearer of type "
<< artSet->bearerType();
logGlobal->warnStream() << "Warning: artifact " << artType->Name() << " doesn't have defined allowed slots for bearer of type "
<< artSet->bearerType();
return false;
}
@ -1341,7 +1341,7 @@ si32 CArtifactSet::getArtTypeId(ArtifactPosition pos) const
const CArtifactInstance * const a = getArt(pos);
if(!a)
{
logGlobal->warnStream() << (dynamic_cast<const CGHeroInstance*>(this))->name << " has no artifact at " << pos << " (getArtTypeId)";
logGlobal->warnStream() << (dynamic_cast<const CGHeroInstance*>(this))->name << " has no artifact at " << pos << " (getArtTypeId)";
return -1;
}
return a->artType->id;

View File

@ -144,7 +144,7 @@ std::vector<std::shared_ptr<const CObstacleInstance> > CBattleInfoEssentials::ba
{
if(!!player && *perspective != battleGetMySide())
{
logGlobal->errorStream() << "Unauthorized access attempt!";
logGlobal->errorStream() << "Unauthorized access attempt!";
assert(0); //I want to notice if that happens
//perspective = battleGetMySide();
}
@ -242,8 +242,8 @@ BattlePerspective::BattlePerspective CBattleInfoEssentials::battleGetMySide() co
if(*player == getBattle()->sides[1].color)
return BattlePerspective::RIGHT_SIDE;
logGlobal->errorStream() << "Cannot find player " << *player << " in battle!";
return BattlePerspective::INVALID;
logGlobal->errorStream() << "Cannot find player " << *player << " in battle!";
return BattlePerspective::INVALID;
}
const CStack * CBattleInfoEssentials::battleActiveStack() const
@ -291,13 +291,13 @@ const CGHeroInstance * CBattleInfoEssentials::battleGetFightingHero(ui8 side) co
RETURN_IF_NOT_BATTLE(nullptr);
if(side > 1)
{
logGlobal->errorStream() << "FIXME: " << __FUNCTION__ << " wrong argument!";
logGlobal->errorStream() << "FIXME: " << __FUNCTION__ << " wrong argument!";
return nullptr;
}
if(!battleDoWeKnowAbout(side))
{
logGlobal->errorStream() << "FIXME: " << __FUNCTION__ << " access check ";
logGlobal->errorStream() << "FIXME: " << __FUNCTION__ << " access check ";
return nullptr;
}
@ -327,7 +327,7 @@ InfoAboutHero CBattleInfoEssentials::battleGetHeroInfo( ui8 side ) const
auto hero = getBattle()->sides[side].hero;
if(!hero)
{
logGlobal->warnStream() << __FUNCTION__ << ": side " << (int)side << " does not have hero!";
logGlobal->warnStream() << __FUNCTION__ << ": side " << (int)side << " does not have hero!";
return InfoAboutHero();
}
@ -351,7 +351,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastSpell(Pla
const ui8 side = playerToSide(player);
if(!battleDoWeKnowAbout(side))
{
logGlobal->warnStream() << "You can't check if enemy can cast given spell!";
logGlobal->warnStream() << "You can't check if enemy can cast given spell!";
return ESpellCastProblem::INVALID;
}
@ -411,7 +411,7 @@ ui8 CBattleInfoEssentials::playerToSide(PlayerColor player) const
RETURN_IF_NOT_BATTLE(-1);
int ret = vstd::find_pos_if(getBattle()->sides, [=](const SideInBattle &side){ return side.color == player; });
if(ret < 0)
logGlobal->warnStream() << "Cannot find side for player " << player;
logGlobal->warnStream() << "Cannot find side for player " << player;
return ret;
}
@ -532,7 +532,7 @@ SpellID CBattleInfoCallback::battleGetRandomStackSpell(const CStack * stack, ERa
return getRandomCastedSpell(stack); //caster
break;
default:
logGlobal->errorStream() << "Incorrect mode of battleGetRandomSpell (" << mode <<")";
logGlobal->errorStream() << "Incorrect mode of battleGetRandomSpell (" << mode <<")";
return SpellID::NONE;
}
}
@ -1697,13 +1697,13 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
const CSpell::TargetInfo ti(spell, caster->getSpellSchoolLevel(spell));
bool targetExists = false;
for(const CStack * stack : battleGetAllStacks()) //dead stacks will be immune anyway
for(const CStack * stack : battleGetAllStacks()) //dead stacks will be immune anyway
{
bool immune = ESpellCastProblem::OK != spell->isImmuneByStack(caster, stack);
bool casterStack = stack->owner == caster->getOwner();
if(!immune)
{
if(!immune)
{
switch (spell->positiveness)
{
case CSpell::POSITIVE:
@ -1724,9 +1724,9 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
}
break;
}
}
}
}
if(!targetExists)
if(!targetExists)
{
return ESpellCastProblem::NO_APPROPRIATE_TARGET;
}
@ -1777,7 +1777,7 @@ std::vector<BattleHex> CBattleInfoCallback::battleGetPossibleTargets(PlayerColor
}
break;
default:
logGlobal->errorStream() << "FIXME " << __FUNCTION__ << " doesn't work with target type " << spell->getTargetType();
logGlobal->errorStream() << "FIXME " << __FUNCTION__ << " doesn't work with target type " << spell->getTargetType();
}
return ret;
@ -2152,14 +2152,16 @@ bool AccessibilityInfo::accessible(BattleHex tile, bool doubleWide, bool attacke
// All hexes that stack would cover if standing on tile have to be accessible.
for(auto hex : CStack::getHexes(tile, doubleWide, attackerOwned))
{
// If the hex is out of range then the tile isn't accessible
if(!hex.isValid())
return false;
// If we're no defender which step on gate and the hex isn't accessible, then the tile
// isn't accessible
else if(at(hex) != EAccessibility::ACCESSIBLE &&
!(at(hex) == EAccessibility::GATE && !attackerOwned))
return false;
// If the hex is out of range then the tile isn't accessible
if(!hex.isValid())
return false;
// If we're no defender which step on gate and the hex isn't accessible, then the tile
// isn't accessible
else if(at(hex) != EAccessibility::ACCESSIBLE &&
!(at(hex) == EAccessibility::GATE && !attackerOwned))
{
return false;
}
}
return true;
}

View File

@ -43,7 +43,7 @@ MacroString::MacroString(const std::string &format)
if (end_pos == std::string::npos)
{
logBonus->warnStream() << "Format error in: " << format;
logBonus->warnStream() << "Format error in: " << format;
end_pos = start_pos;
break;
}
@ -150,7 +150,7 @@ std::string CBonusTypeHandler::bonusToString(const Bonus *bonus, const IBonusBea
}
else
{
logBonus->warnStream() << "Unknown macro in bonus config: " << name;
logBonus->warnStream() << "Unknown macro in bonus config: " << name;
return "[error]";
}
};
@ -286,14 +286,14 @@ void CBonusTypeHandler::load(const JsonNode& config)
//
// bonusTypes.push_back(bt);
logBonus->warnStream() << "Adding new bonuses not implemented (" << node.first << ")";
logBonus->warnStream() << "Adding new bonuses not implemented (" << node.first << ")";
}
else
{
CBonusType& bt = bonusTypes[it->second];
loadItem(node.second, bt);
logBonus->traceStream() << "Loaded bonus type " << node.first;
logBonus->traceStream() << "Loaded bonus type " << node.first;
}
}
}

View File

@ -57,16 +57,16 @@ void printWinError()
int error = GetLastError();
if(!error)
{
logGlobal->errorStream() << "No Win error information set.";
logGlobal->errorStream() << "No Win error information set.";
return;
}
logGlobal->errorStream() << "Error " << error << " encountered:";
logGlobal->errorStream() << "Error " << error << " encountered:";
//Get error description
char* pTemp = nullptr;
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
nullptr, error, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), (LPSTR)&pTemp, 1, nullptr);
logGlobal->errorStream() << pTemp;
logGlobal->errorStream() << pTemp;
LocalFree( pTemp );
}
@ -107,19 +107,19 @@ const char* exceptionName(DWORD exc)
LONG WINAPI onUnhandledException(EXCEPTION_POINTERS* exception)
{
logGlobal->errorStream() << "Disaster happened.";
logGlobal->errorStream() << "Disaster happened.";
PEXCEPTION_RECORD einfo = exception->ExceptionRecord;
logGlobal->errorStream() << "Reason: 0x" << std::hex << einfo->ExceptionCode << " - " << exceptionName(einfo->ExceptionCode)
<< " at " << std::setfill('0') << std::setw(4) << exception->ContextRecord->SegCs << ":" << (void*)einfo->ExceptionAddress;
logGlobal->errorStream() << "Reason: 0x" << std::hex << einfo->ExceptionCode << " - " << exceptionName(einfo->ExceptionCode)
<< " at " << std::setfill('0') << std::setw(4) << exception->ContextRecord->SegCs << ":" << (void*)einfo->ExceptionAddress;
if (einfo->ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
{
logGlobal->errorStream() << "Attempt to " << (einfo->ExceptionInformation[0] == 1 ? "write to " : "read from ")
<< "0x" << std::setw(8) << (void*)einfo->ExceptionInformation[1];
logGlobal->errorStream() << "Attempt to " << (einfo->ExceptionInformation[0] == 1 ? "write to " : "read from ")
<< "0x" << std::setw(8) << (void*)einfo->ExceptionInformation[1];
}
const DWORD threadId = ::GetCurrentThreadId();
logGlobal->errorStream() << "Thread ID: " << threadId << " [" << std::dec << std::setw(0) << threadId << "]";
logGlobal->errorStream() << "Thread ID: " << threadId << " [" << std::dec << std::setw(0) << threadId << "]";
//exception info to be placed in the dump
MINIDUMP_EXCEPTION_INFORMATION meinfo = {threadId, exception, TRUE};
@ -137,7 +137,7 @@ LONG WINAPI onUnhandledException(EXCEPTION_POINTERS* exception)
strcat(mname, "_crashinfo.dmp");
HANDLE dfile = CreateFileA(mname, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0);
logGlobal->errorStream() << "Crash info will be put in " << mname;
logGlobal->errorStream() << "Crash info will be put in " << mname;
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), dfile, MiniDumpWithDataSegs, &meinfo, 0, 0);
MessageBoxA(0, "VCMI has crashed. We are sorry. File with information about encountered problem has been created.", "VCMI Crashhandler", MB_OK | MB_ICONERROR);
return EXCEPTION_EXECUTE_HANDLER;
@ -147,35 +147,35 @@ LONG WINAPI onUnhandledException(EXCEPTION_POINTERS* exception)
void CConsoleHandler::setColor(EConsoleTextColor::EConsoleTextColor color)
{
TColor colorCode;
switch(color)
TColor colorCode;
switch(color)
{
case EConsoleTextColor::DEFAULT:
colorCode = defColor;
case EConsoleTextColor::DEFAULT:
colorCode = defColor;
break;
case EConsoleTextColor::GREEN:
colorCode = CONSOLE_GREEN;
case EConsoleTextColor::GREEN:
colorCode = CONSOLE_GREEN;
break;
case EConsoleTextColor::RED:
colorCode = CONSOLE_RED;
case EConsoleTextColor::RED:
colorCode = CONSOLE_RED;
break;
case EConsoleTextColor::MAGENTA:
colorCode = CONSOLE_MAGENTA;
case EConsoleTextColor::MAGENTA:
colorCode = CONSOLE_MAGENTA;
break;
case EConsoleTextColor::YELLOW:
colorCode = CONSOLE_YELLOW;
case EConsoleTextColor::YELLOW:
colorCode = CONSOLE_YELLOW;
break;
case EConsoleTextColor::WHITE:
colorCode = CONSOLE_WHITE;
case EConsoleTextColor::WHITE:
colorCode = CONSOLE_WHITE;
break;
case EConsoleTextColor::GRAY:
colorCode = CONSOLE_GRAY;
case EConsoleTextColor::GRAY:
colorCode = CONSOLE_GRAY;
break;
case EConsoleTextColor::TEAL:
colorCode = CONSOLE_TEAL;
case EConsoleTextColor::TEAL:
colorCode = CONSOLE_TEAL;
break;
default:
colorCode = defColor;
colorCode = defColor;
break;
}
#ifdef VCMI_WINDOWS
@ -236,14 +236,14 @@ CConsoleHandler::CConsoleHandler() : thread(nullptr)
#else
defColor = "\x1b[0m";
#endif
cb = new std::function<void(const std::string &)>;
cb = new std::function<void(const std::string &)>;
}
CConsoleHandler::~CConsoleHandler()
{
logGlobal->infoStream() << "Killing console...";
logGlobal->infoStream() << "Killing console...";
end();
delete cb;
logGlobal->infoStream() << "Killing console... done!";
logGlobal->infoStream() << "Killing console... done!";
}
void CConsoleHandler::end()
{

View File

@ -161,7 +161,7 @@ static void AddAbility(CCreature *cre, const JsonVector &ability_vec)
cre->addBonus(-1, Bonus::LUCK);
cre->getBonusList().back()->effectRange = Bonus::ONLY_ENEMY_ARMY;
} else
logGlobal->errorStream() << "Error: invalid ability type " << type << " in creatures config";
logGlobal->errorStream() << "Error: invalid ability type " << type << " in creatures config";
return;
}
@ -242,15 +242,15 @@ void CCreatureHandler::loadBonuses(JsonNode & creature, std::string bonuses)
static const std::map<std::string, JsonNode> abilityMap =
{
{"FLYING_ARMY", makeBonusNode("FLYING")},
{"SHOOTING_ARMY", makeBonusNode("SHOOTER")},
{"SIEGE_WEAPON", makeBonusNode("SIEGE_WEAPON")},
{"const_free_attack", makeBonusNode("BLOCKS_RETALIATION")},
{"IS_UNDEAD", makeBonusNode("UNDEAD")},
{"const_no_melee_penalty", makeBonusNode("NO_MELEE_PENALTY")},
{"const_jousting", makeBonusNode("JOUSTING")},
{"KING_1", makeBonusNode("KING1")},
{"KING_2", makeBonusNode("KING2")},
{"FLYING_ARMY", makeBonusNode("FLYING")},
{"SHOOTING_ARMY", makeBonusNode("SHOOTER")},
{"SIEGE_WEAPON", makeBonusNode("SIEGE_WEAPON")},
{"const_free_attack", makeBonusNode("BLOCKS_RETALIATION")},
{"IS_UNDEAD", makeBonusNode("UNDEAD")},
{"const_no_melee_penalty", makeBonusNode("NO_MELEE_PENALTY")},
{"const_jousting", makeBonusNode("JOUSTING")},
{"KING_1", makeBonusNode("KING1")},
{"KING_2", makeBonusNode("KING2")},
{"KING_3", makeBonusNode("KING3")},
{"const_no_wall_penalty", makeBonusNode("NO_WALL_PENALTY")},
{"CATAPULT", makeBonusNode("CATAPULT")},
@ -895,7 +895,7 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
case 'U':
b.type = Bonus::UNDEAD; break;
default:
logGlobal->traceStream() << "Not parsed bonus " << buf << mod;
logGlobal->traceStream() << "Not parsed bonus " << buf << mod;
return;
break;
}
@ -1005,7 +1005,7 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
b.type = Bonus::MIND_IMMUNITY;
break;
default:
logGlobal->traceStream() << "Not parsed bonus " << buf << mod;
logGlobal->traceStream() << "Not parsed bonus " << buf << mod;
return;
}
break;
@ -1046,7 +1046,7 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
b.valType = Bonus::INDEPENDENT_MAX;
break;
default:
logGlobal->traceStream() << "Not parsed bonus " << buf << mod;
logGlobal->traceStream() << "Not parsed bonus " << buf << mod;
return;
break;
}
@ -1141,7 +1141,7 @@ CreatureID CCreatureHandler::pickRandomMonster(CRandomGenerator & rand, int tier
if(!allowed.size())
{
logGlobal->warnStream() << "Cannot pick a random creature of tier " << tier << "!";
logGlobal->warnStream() << "Cannot pick a random creature of tier " << tier << "!";
return CreatureID::NONE;
}

View File

@ -45,12 +45,12 @@ bool CCreatureSet::setCreature(SlotID slot, CreatureID type, TQuantity quantity)
{
if(!slot.validSlot())
{
logGlobal->errorStream() << "Cannot set slot " << slot;
logGlobal->errorStream() << "Cannot set slot " << slot;
return false;
}
if(!quantity)
{
logGlobal->warnStream() << "Using set creature to delete stack?";
logGlobal->warnStream() << "Using set creature to delete stack?";
eraseStack(slot);
return true;
}
@ -171,7 +171,7 @@ void CCreatureSet::addToSlot(SlotID slot, CreatureID cre, TQuantity count, bool
}
else
{
logGlobal->errorStream() << "Failed adding to slot!";
logGlobal->errorStream() << "Failed adding to slot!";
}
}
@ -189,7 +189,7 @@ void CCreatureSet::addToSlot(SlotID slot, CStackInstance *stack, bool allowMergi
}
else
{
logGlobal->errorStream() << "Cannot add to slot " << slot << " stack " << *stack;
logGlobal->errorStream() << "Cannot add to slot " << slot << " stack " << *stack;
}
}
@ -413,10 +413,10 @@ CStackInstance * CCreatureSet::detachStack(SlotID slot)
CStackInstance *ret = stacks[slot];
//if(CArmedInstance *armedObj = castToArmyObj())
if(ret)
if(ret)
{
ret->setArmyObj(nullptr); //detaches from current armyobj
assert(!ret->armyObj); //we failed detaching?
assert(!ret->armyObj); //we failed detaching?
}
stacks.erase(slot);

View File

@ -113,7 +113,7 @@ const CGObjectInstance* CGameInfoCallback::getObj(ObjectInstanceID objid, bool v
if(oid < 0 || oid >= gs->map->objects.size())
{
if(verbose)
logGlobal->errorStream() << "Cannot get object with id " << oid;
logGlobal->errorStream() << "Cannot get object with id " << oid;
return nullptr;
}
@ -121,14 +121,14 @@ const CGObjectInstance* CGameInfoCallback::getObj(ObjectInstanceID objid, bool v
if(!ret)
{
if(verbose)
logGlobal->errorStream() << "Cannot get object with id " << oid << ". Object was removed.";
logGlobal->errorStream() << "Cannot get object with id " << oid << ". Object was removed.";
return nullptr;
}
if(!isVisible(ret, player) && ret->tempOwner != player)
{
if(verbose)
logGlobal->errorStream() << "Cannot get object with id " << oid << ". Object is not visible.";
logGlobal->errorStream() << "Cannot get object with id " << oid << ". Object is not visible.";
return nullptr;
}

View File

@ -80,7 +80,7 @@ std::shared_ptr<rett> createAny(const boost::filesystem::path& libpath, const st
getAI = (TGetAIFun)dlsym(dll, methodName.c_str());
}
else
logGlobal->errorStream() << "Error: " << dlerror();
logGlobal->errorStream() << "Error: " << dlerror();
#endif // VCMI_WINDOWS
if (!dll)
{
@ -100,12 +100,12 @@ std::shared_ptr<rett> createAny(const boost::filesystem::path& libpath, const st
#endif // VCMI_ANDROID
getName(temp);
logGlobal->infoStream() << "Loaded " << temp;
logGlobal->infoStream() << "Loaded " << temp;
std::shared_ptr<rett> ret;
getAI(ret);
if(!ret)
logGlobal->errorStream() << "Cannot get AI!";
logGlobal->errorStream() << "Cannot get AI!";
return ret;
}

View File

@ -204,13 +204,13 @@ void MetaString::getLocalString(const std::pair<ui8,ui32> &txt, std::string &dst
vec = &VLC->generaltexth->capColors;
break;
default:
logGlobal->errorStream() << "Failed string substitution because type is " << type;
logGlobal->errorStream() << "Failed string substitution because type is " << type;
dst = "#@#";
return;
}
if(vec->size() <= ser)
{
logGlobal->errorStream() << "Failed string substitution with type " << type << " because index " << ser << " is out of bounds!";
logGlobal->errorStream() << "Failed string substitution with type " << type << " because index " << ser << " is out of bounds!";
dst = "#!#";
}
else
@ -373,7 +373,7 @@ CGHeroInstance * CGameState::HeroesPool::pickHeroFor(bool native, PlayerColor pl
if(player>=PlayerColor::PLAYER_LIMIT)
{
logGlobal->errorStream() << "Cannot pick hero for " << town->faction->index << ". Wrong owner!";
logGlobal->errorStream() << "Cannot pick hero for " << town->faction->index << ". Wrong owner!";
return nullptr;
}
@ -391,7 +391,7 @@ CGHeroInstance * CGameState::HeroesPool::pickHeroFor(bool native, PlayerColor pl
}
if(!pool.size())
{
logGlobal->errorStream() << "Cannot pick native hero for " << player << ". Picking any...";
logGlobal->errorStream() << "Cannot pick native hero for " << player << ". Picking any...";
return pickHeroFor(false, player, town, available, rand);
}
else
@ -414,7 +414,7 @@ CGHeroInstance * CGameState::HeroesPool::pickHeroFor(bool native, PlayerColor pl
}
if(!pool.size() || sum == 0)
{
logGlobal->errorStream() << "There are no heroes available for player " << player<<"!";
logGlobal->errorStream() << "There are no heroes available for player " << player<<"!";
return nullptr;
}
@ -747,7 +747,7 @@ BattleInfo * CGameState::setupBattle(int3 tile, const CArmedInstance *armies[2],
void CGameState::init(StartInfo * si)
{
logGlobal->infoStream() << "\tUsing random seed: "<< si->seedToBeUsed;
logGlobal->infoStream() << "\tUsing random seed: "<< si->seedToBeUsed;
rand.setSeed(si->seedToBeUsed);
scenarioOps = CMemorySerializer::deepCopy(*si).release();
initialOpts = CMemorySerializer::deepCopy(*si).release();
@ -765,17 +765,17 @@ void CGameState::init(StartInfo * si)
initDuel();
return;
default:
logGlobal->errorStream() << "Wrong mode: " << (int)scenarioOps->mode;
logGlobal->errorStream() << "Wrong mode: " << (int)scenarioOps->mode;
return;
}
VLC->arth->initAllowedArtifactsList(map->allowedArtifact);
logGlobal->infoStream() << "Map loaded!";
logGlobal->infoStream() << "Map loaded!";
checkMapChecksum();
day = 0;
logGlobal->debugStream() << "Initialization:";
logGlobal->debugStream() << "Initialization:";
initPlayerStates();
placeCampaignHeroes();
@ -792,11 +792,11 @@ void CGameState::init(StartInfo * si)
initVisitingAndGarrisonedHeroes();
initFogOfWar();
logGlobal->debugStream() << "\tChecking objectives";
logGlobal->debugStream() << "\tChecking objectives";
map->checkForObjectives(); //needs to be run when all objects are properly placed
auto seedAfterInit = rand.nextInt();
logGlobal->infoStream() << "Seed after init is " << seedAfterInit << " (before was " << scenarioOps->seedToBeUsed << ")";
logGlobal->infoStream() << "Seed after init is " << seedAfterInit << " (before was " << scenarioOps->seedToBeUsed << ")";
if(scenarioOps->seedPostInit > 0)
{
//RNG must be in the same state on all machines when initialization is done (otherwise we have desync)
@ -872,9 +872,9 @@ void CGameState::initDuel()
{
if(boost::algorithm::ends_with(scenarioOps->mapname, ".json"))
{
logGlobal->infoStream() << "Loading duel settings from JSON file: " << scenarioOps->mapname;
logGlobal->infoStream() << "Loading duel settings from JSON file: " << scenarioOps->mapname;
dp = DuelParameters::fromJSON(scenarioOps->mapname);
logGlobal->infoStream() << "JSON file has been successfully read!";
logGlobal->infoStream() << "JSON file has been successfully read!";
}
else
{
@ -884,7 +884,7 @@ void CGameState::initDuel()
}
catch(...)
{
logGlobal->errorStream() << "Cannot load duel settings from " << scenarioOps->mapname;
logGlobal->errorStream() << "Cannot load duel settings from " << scenarioOps->mapname;
throw;
}
@ -2109,7 +2109,7 @@ std::vector<CGObjectInstance*> CGameState::guardingCreatures (int3 pos) const
if (map->isInTheMap(pos))
{
const auto & tile = map->getTile(pos);
if (tile.visitable && (tile.isWater() == posTile.isWater()))
if (tile.visitable && (tile.isWater() == posTile.isWater()))
{
for (CGObjectInstance* obj : tile.visitableObjects)
{
@ -2668,11 +2668,11 @@ void CGameState::obtainPlayersStats(SThievesGuildInfo & tgi, int level)
continue;
if(g->second.human)
{
tgi.personality[g->second.color] = EAiTactic::NONE;
tgi.personality[g->second.color] = EAiTactic::NONE;
}
else //AI
{
tgi.personality[g->second.color] = map->players[g->second.color.getNum()].aiTactic;
tgi.personality[g->second.color] = map->players[g->second.color.getNum()].aiTactic;
}
}
@ -2809,7 +2809,7 @@ std::vector<CGameState::CampaignHeroReplacement> CGameState::generateCampaignHer
{
auto hero = *it;
crossoverHeroes.removeHeroFromBothLists(hero);
campaignHeroReplacements.push_back(CampaignHeroReplacement(CMemorySerializer::deepCopy(*hero).release(), heroPlaceholder->id));
campaignHeroReplacements.push_back(CampaignHeroReplacement(CMemorySerializer::deepCopy(*hero).release(), heroPlaceholder->id));
}
}
}
@ -2844,8 +2844,8 @@ std::vector<CGameState::CampaignHeroReplacement> CGameState::generateCampaignHer
auto heroPlaceholder = heroPlaceholders[i];
if(crossoverHeroes.heroesFromPreviousScenario.size() > i)
{
auto hero = crossoverHeroes.heroesFromPreviousScenario[i];
campaignHeroReplacements.push_back(CampaignHeroReplacement(CMemorySerializer::deepCopy(*hero).release(), heroPlaceholder->id));
auto hero = crossoverHeroes.heroesFromPreviousScenario[i];
campaignHeroReplacements.push_back(CampaignHeroReplacement(CMemorySerializer::deepCopy(*hero).release(), heroPlaceholder->id));
}
}
@ -2948,7 +2948,7 @@ bool RumorState::update(int id, int extra)
}
InfoAboutArmy::InfoAboutArmy():
owner(PlayerColor::NEUTRAL)
owner(PlayerColor::NEUTRAL)
{}
InfoAboutArmy::InfoAboutArmy(const CArmedInstance *Army, bool detailed)
@ -2973,13 +2973,13 @@ void InfoAboutHero::assign(const InfoAboutHero & iah)
}
InfoAboutHero::InfoAboutHero():
details(nullptr),
hclass(nullptr),
portrait(-1)
details(nullptr),
hclass(nullptr),
portrait(-1)
{}
InfoAboutHero::InfoAboutHero(const InfoAboutHero & iah):
InfoAboutArmy()
InfoAboutArmy()
{
assign(iah);
}
@ -3031,10 +3031,10 @@ void InfoAboutHero::initFromHero(const CGHeroInstance *h, bool detailed)
}
InfoAboutTown::InfoAboutTown():
details(nullptr),
tType(nullptr),
built(0),
fortLevel(0)
details(nullptr),
tType(nullptr),
built(0),
fortLevel(0)
{
}
@ -3071,7 +3071,7 @@ void InfoAboutTown::initFromTown(const CGTownInstance *t, bool detailed)
}
ArmyDescriptor::ArmyDescriptor(const CArmedInstance *army, bool detailed)
: isDetailed(detailed)
: isDetailed(detailed)
{
for(auto & elem : army->Slots())
{
@ -3083,7 +3083,7 @@ ArmyDescriptor::ArmyDescriptor(const CArmedInstance *army, bool detailed)
}
ArmyDescriptor::ArmyDescriptor()
: isDetailed(false)
: isDetailed(false)
{
}
@ -3120,8 +3120,8 @@ DuelParameters::SideSettings::SideSettings()
}
DuelParameters::DuelParameters():
terType(ETerrainType::DIRT),
bfieldType(BFieldType::ROCKLANDS)
terType(ETerrainType::DIRT),
bfieldType(BFieldType::ROCKLANDS)
{
}

View File

@ -80,7 +80,7 @@ std::vector<BattleHex> CObstacleInfo::getBlocked(BattleHex hex) const
toBlock += BattleHex::LEFT;
if(!toBlock.isValid())
logGlobal->errorStream() << "Misplaced obstacle!";
logGlobal->errorStream() << "Misplaced obstacle!";
else
ret.push_back(toBlock);
}
@ -577,7 +577,7 @@ ui64 CHeroHandler::reqExp (ui32 level) const
}
else
{
logGlobal->warnStream() << "A hero has reached unsupported amount of experience";
logGlobal->warnStream() << "A hero has reached unsupported amount of experience";
return expPerLevel[expPerLevel.size()-1];
}
}

View File

@ -35,7 +35,7 @@ CIdentifierStorage::CIdentifierStorage():
void CIdentifierStorage::checkIdentifier(std::string & ID)
{
if (boost::algorithm::ends_with(ID, "."))
logGlobal->warnStream() << "BIG WARNING: identifier " << ID << " seems to be broken!";
logGlobal->warnStream() << "BIG WARNING: identifier " << ID << " seems to be broken!";
else
{
size_t pos = 0;
@ -43,7 +43,7 @@ void CIdentifierStorage::checkIdentifier(std::string & ID)
{
if (std::tolower(ID[pos]) != ID[pos] ) //Not in camelCase
{
logGlobal->warnStream() << "Warning: identifier " << ID << " is not in camelCase!";
logGlobal->warnStream() << "Warning: identifier " << ID << " is not in camelCase!";
ID[pos] = std::tolower(ID[pos]);// Try to fix the ID
}
pos = ID.find('.', pos);
@ -54,10 +54,10 @@ void CIdentifierStorage::checkIdentifier(std::string & ID)
CIdentifierStorage::ObjectCallback::ObjectCallback(std::string localScope, std::string remoteScope, std::string type,
std::string name, const std::function<void(si32)> & callback, bool optional):
localScope(localScope),
remoteScope(remoteScope),
type(type),
name(name),
localScope(localScope),
remoteScope(remoteScope),
type(type),
name(name),
callback(callback),
optional(optional)
{}
@ -294,9 +294,9 @@ void CIdentifierStorage::finalize()
}
CContentHandler::ContentTypeHandler::ContentTypeHandler(IHandlerBase * handler, std::string objectName):
handler(handler),
objectName(objectName),
originalData(handler->loadLegacyData(VLC->modh->settings.data["textData"][objectName].Float()))
handler(handler),
objectName(objectName),
originalData(handler->loadLegacyData(VLC->modh->settings.data["textData"][objectName].Float()))
{
for(auto & node : originalData)
{

View File

@ -57,7 +57,7 @@ void CConnection::init()
//we got connection
oser << std::string("Aiya!\n") << name << myEndianess; //identify ourselves
iser >> pom >> pom >> contactEndianess;
logNetwork->infoStream() << "Established connection with "<<pom;
logNetwork->infoStream() << "Established connection with "<<pom;
wmx = new boost::mutex;
rmx = new boost::mutex;
@ -77,27 +77,27 @@ CConnection::CConnection(std::string host, std::string port, std::string Name)
boost::asio::ip::tcp::resolver::iterator end, pom, endpoint_iterator = resolver.resolve(boost::asio::ip::tcp::resolver::query(host,port),error);
if(error)
{
logNetwork->errorStream() << "Problem with resolving: \n" << error;
logNetwork->errorStream() << "Problem with resolving: \n" << error;
goto connerror1;
}
pom = endpoint_iterator;
if(pom != end)
logNetwork->infoStream()<<"Found endpoints:";
logNetwork->infoStream()<<"Found endpoints:";
else
{
logNetwork->errorStream() << "Critical problem: No endpoints found!";
logNetwork->errorStream() << "Critical problem: No endpoints found!";
goto connerror1;
}
i=0;
while(pom != end)
{
logNetwork->infoStream() << "\t" << i << ": " << (boost::asio::ip::tcp::endpoint&)*pom;
logNetwork->infoStream() << "\t" << i << ": " << (boost::asio::ip::tcp::endpoint&)*pom;
pom++;
}
i=0;
while(endpoint_iterator != end)
{
logNetwork->infoStream() << "Trying connection to " << (boost::asio::ip::tcp::endpoint&)*endpoint_iterator << " (" << i++ << ")";
logNetwork->infoStream() << "Trying connection to " << (boost::asio::ip::tcp::endpoint&)*endpoint_iterator << " (" << i++ << ")";
socket->connect(*endpoint_iterator, error);
if(!error)
{
@ -106,18 +106,18 @@ CConnection::CConnection(std::string host, std::string port, std::string Name)
}
else
{
logNetwork->errorStream() << "Problem with connecting: " << error;
logNetwork->errorStream() << "Problem with connecting: " << error;
}
endpoint_iterator++;
}
//we shouldn't be here - error handling
connerror1:
logNetwork->errorStream() << "Something went wrong... checking for error info";
logNetwork->errorStream() << "Something went wrong... checking for error info";
if(error)
logNetwork->errorStream() << error;
logNetwork->errorStream() << error;
else
logNetwork->errorStream() << "No error info. ";
logNetwork->errorStream() << "No error info. ";
delete io_service;
//delete socket;
throw std::runtime_error("Can't establish connection :(");
@ -135,7 +135,7 @@ CConnection::CConnection(TAcceptor * acceptor, boost::asio::io_service *Io_servi
acceptor->accept(*socket,error);
if (error)
{
logNetwork->errorStream() << "Error on accepting: " << error;
logNetwork->errorStream() << "Error on accepting: " << error;
delete socket;
throw std::runtime_error("Can't establish connection :(");
}
@ -211,11 +211,11 @@ bool CConnection::isOpen() const
void CConnection::reportState(CLogger * out)
{
out->debugStream() << "CConnection";
out->debugStream() << "CConnection";
if(socket && socket->is_open())
{
out->debugStream() << "\tWe have an open and valid socket";
out->debugStream() << "\t" << socket->available() <<" bytes awaiting";
out->debugStream() << "\tWe have an open and valid socket";
out->debugStream() << "\t" << socket->available() <<" bytes awaiting";
}
}
@ -223,7 +223,7 @@ CPack * CConnection::retreivePack()
{
CPack *ret = nullptr;
boost::unique_lock<boost::mutex> lock(*rmx);
logNetwork->traceStream() << "Listening... ";
logNetwork->traceStream() << "Listening... ";
iser >> ret;
logNetwork->traceStream() << "\treceived server message of type " << typeid(*ret).name() << ", data: " << ret;
return ret;
@ -232,7 +232,7 @@ CPack * CConnection::retreivePack()
void CConnection::sendPackToServer(const CPack &pack, PlayerColor player, ui32 requestID)
{
boost::unique_lock<boost::mutex> lock(*wmx);
logNetwork->traceStream() << "Sending to server a pack of type " << typeid(pack).name();
logNetwork->traceStream() << "Sending to server a pack of type " << typeid(pack).name();
oser << player << requestID << &pack; //packs has to be sent as polymorphic pointers!
}
@ -315,7 +315,7 @@ void CSaveFile::openNextFile(const boost::filesystem::path &fname)
}
catch(...)
{
logGlobal->errorStream() << "Failed to save to " << fname;
logGlobal->errorStream() << "Failed to save to " << fname;
clear();
throw;
}
@ -323,10 +323,10 @@ void CSaveFile::openNextFile(const boost::filesystem::path &fname)
void CSaveFile::reportState(CLogger * out)
{
out->debugStream() << "CSaveFile";
out->debugStream() << "CSaveFile";
if(sfile.get() && *sfile)
{
out->debugStream() << "\tOpened " << fName << "\n\tPosition: " << sfile->tellp();
out->debugStream() << "\tOpened " << fName << "\n\tPosition: " << sfile->tellp();
}
}
@ -407,10 +407,10 @@ void CLoadFile::openNextFile(const boost::filesystem::path & fname, int minimalV
void CLoadFile::reportState(CLogger * out)
{
out->debugStream() << "CLoadFile";
out->debugStream() << "CLoadFile";
if(!!sfile && *sfile)
{
out->debugStream() << "\tOpened " << fName << "\n\tPosition: " << sfile->tellg();
out->debugStream() << "\tOpened " << fName << "\n\tPosition: " << sfile->tellg();
}
}
@ -597,7 +597,7 @@ int CLoadIntegrityValidator::read( void * data, unsigned size )
controlFile->read(controlData.data(), size);
if(std::memcmp(data, controlData.data(), size))
{
logGlobal->errorStream() << "Desync found! Position: " << primaryFile->sfile->tellg();
logGlobal->errorStream() << "Desync found! Position: " << primaryFile->sfile->tellg();
foundDesync = true;
//throw std::runtime_error("Savegame dsynchronized!");
}

View File

@ -715,7 +715,7 @@ CBonusSystemNode::~CBonusSystemNode()
if(children.size())
{
logBonus->warnStream() << "Warning: an orphaned child!";
logBonus->warnStream() << "Warning: an orphaned child!";
while(children.size())
children.front()->detachFrom(this);
}
@ -844,7 +844,7 @@ void CBonusSystemNode::unpropagateBonus(Bonus * b)
bonuses -= b;
while(vstd::contains(bonuses, b))
{
logBonus->errorStream() << "Bonus was duplicated (" << b->Description() << ") at " << nodeName();
logBonus->errorStream() << "Bonus was duplicated (" << b->Description() << ") at " << nodeName();
bonuses -= b;
}
BONUS_LOG_LINE("#$#" << b->Description() << " #is no longer propagated to# " << nodeName());
@ -1480,8 +1480,8 @@ int CreatureAlignmentLimiter::limit(const BonusLimitationContext &context) const
case EAlignment::EVIL:
return !c->isEvil();
default:
logBonus->warnStream() << "Warning: illegal alignment in limiter!";
return true;
logBonus->warnStream() << "Warning: illegal alignment in limiter!";
return true;
}
}

View File

@ -51,7 +51,7 @@ void CPrivilagedInfoCallback::getTilesInRange( std::unordered_set<int3, ShashInt
{
if(!!player && *player >= PlayerColor::PLAYER_LIMIT)
{
logGlobal->errorStream() << "Illegal call to getTilesInRange!";
logGlobal->errorStream() << "Illegal call to getTilesInRange!";
return;
}
if (radious == -1) //reveal entire map
@ -87,7 +87,7 @@ void CPrivilagedInfoCallback::getAllTiles (std::unordered_set<int3, ShashInt3> &
{
if(!!Player && *Player >= PlayerColor::PLAYER_LIMIT)
{
logGlobal->errorStream() << "Illegal call to getAllTiles !";
logGlobal->errorStream() << "Illegal call to getAllTiles !";
return;
}
bool water = surface == 0 || surface == 2,
@ -150,37 +150,37 @@ CGameState * CPrivilagedInfoCallback::gameState ()
template<typename Loader>
void CPrivilagedInfoCallback::loadCommonState(Loader &in)
{
logGlobal->infoStream() << "Loading lib part of game...";
logGlobal->infoStream() << "Loading lib part of game...";
in.checkMagicBytes(SAVEGAME_MAGIC);
CMapHeader dum;
StartInfo *si;
logGlobal->infoStream() <<"\tReading header";
logGlobal->infoStream() <<"\tReading header";
in.serializer >> dum;
logGlobal->infoStream() << "\tReading options";
logGlobal->infoStream() << "\tReading options";
in.serializer >> si;
logGlobal->infoStream() <<"\tReading handlers";
logGlobal->infoStream() <<"\tReading handlers";
in.serializer >> *VLC;
logGlobal->infoStream() <<"\tReading gamestate";
logGlobal->infoStream() <<"\tReading gamestate";
in.serializer >> gs;
}
template<typename Saver>
void CPrivilagedInfoCallback::saveCommonState(Saver &out) const
{
logGlobal->infoStream() << "Saving lib part of game...";
logGlobal->infoStream() << "Saving lib part of game...";
out.putMagicBytes(SAVEGAME_MAGIC);
logGlobal->infoStream() <<"\tSaving header";
logGlobal->infoStream() <<"\tSaving header";
out.serializer << static_cast<CMapHeader&>(*gs->map);
logGlobal->infoStream() << "\tSaving options";
logGlobal->infoStream() << "\tSaving options";
out.serializer << gs->scenarioOps;
logGlobal->infoStream() << "\tSaving handlers";
logGlobal->infoStream() << "\tSaving handlers";
out.serializer << *VLC;
logGlobal->infoStream() << "\tSaving gamestate";
logGlobal->infoStream() << "\tSaving gamestate";
out.serializer << gs;
}

View File

@ -348,7 +348,7 @@ Bonus * JsonUtils::parseBonus (const JsonVector &ability_vec) //TODO: merge with
auto it = bonusNameMap.find(type);
if (it == bonusNameMap.end())
{
logGlobal->errorStream() << "Error: invalid ability type " << type;
logGlobal->errorStream() << "Error: invalid ability type " << type;
return b;
}
b->type = it->second;
@ -366,7 +366,7 @@ const T & parseByMap(const std::map<std::string, T> & map, const JsonNode * val,
auto it = map.find(type);
if (it == map.end())
{
logGlobal->errorStream() << "Error: invalid " << err << type;
logGlobal->errorStream() << "Error: invalid " << err << type;
return defaultValue;
}
else
@ -395,7 +395,7 @@ void JsonUtils::resolveIdentifier (si32 &var, const JsonNode &node, std::string
});
break;
default:
logGlobal->errorStream() << "Error! Wrong identifier used for value of " << name;
logGlobal->errorStream() << "Error! Wrong identifier used for value of " << name;
}
}
}
@ -414,7 +414,7 @@ void JsonUtils::resolveIdentifier (const JsonNode &node, si32 &var)
});
break;
default:
logGlobal->errorStream() << "Error! Wrong identifier used for identifier!";
logGlobal->errorStream() << "Error! Wrong identifier used for identifier!";
}
}
@ -428,7 +428,7 @@ Bonus * JsonUtils::parseBonus (const JsonNode &ability)
auto it = bonusNameMap.find(type);
if (it == bonusNameMap.end())
{
logGlobal->errorStream() << "Error: invalid ability type " << type;
logGlobal->errorStream() << "Error: invalid ability type " << type;
return b;
}
b->type = it->second;
@ -472,7 +472,7 @@ Bonus * JsonUtils::parseBonus (const JsonNode &ability)
}
break;
default:
logGlobal->errorStream() << "Error! Wrong bonus duration format.";
logGlobal->errorStream() << "Error! Wrong bonus duration format.";
}
}
@ -519,7 +519,7 @@ Bonus * JsonUtils::parseBonus (const JsonNode &ability)
auto it = bonusNameMap.find (anotherBonusType);
if (it == bonusNameMap.end())
{
logGlobal->errorStream() << "Error: invalid ability type " << anotherBonusType;
logGlobal->errorStream() << "Error: invalid ability type " << anotherBonusType;
continue;
}
l2->type = it->second;
@ -684,7 +684,7 @@ const JsonNode & getSchemaByName(std::string name)
return loadedSchemas[name];
}
logGlobal->errorStream() << "Error: missing schema with name " << name << "!";
logGlobal->errorStream() << "Error: missing schema with name " << name << "!";
assert(0);
return nullNode;
}
@ -702,7 +702,7 @@ const JsonNode & JsonUtils::getSchema(std::string URI)
if (protocolName != "vcmi")
{
logGlobal->errorStream() << "Error: unsupported URI protocol for schema: " << segments[0];
logGlobal->errorStream() << "Error: unsupported URI protocol for schema: " << segments[0];
return nullNode;
}

View File

@ -34,7 +34,7 @@ struct DLL_LINKAGE CPack
ui16 getType() const{return type;}
template <typename Handler> void serialize(Handler &h, const int version)
{
logNetwork->errorStream() << "CPack serialized... this should not happen!";
logNetwork->errorStream() << "CPack serialized... this should not happen!";
}
void applyGs(CGameState *gs) { }
virtual std::string toString() const { return boost::str(boost::format("{CPack: type '%d'}") % type); }

View File

@ -134,7 +134,7 @@ DLL_LINKAGE void AddQuest::applyGs(CGameState *gs)
if (!vstd::contains(*vec, quest))
vec->push_back (quest);
else
logNetwork->warnStream() << "Warning! Attempt to add duplicated quest";
logNetwork->warnStream() << "Warning! Attempt to add duplicated quest";
}
DLL_LINKAGE void UpdateArtHandlerLists::applyGs(CGameState *gs)
@ -292,7 +292,7 @@ DLL_LINKAGE void ChangeObjPos::applyGs( CGameState *gs )
CGObjectInstance *obj = gs->getObjInstance(objid);
if(!obj)
{
logNetwork->errorStream() << "Wrong ChangeObjPos: object " << objid.getNum() << " doesn't exist!";
logNetwork->errorStream() << "Wrong ChangeObjPos: object " << objid.getNum() << " doesn't exist!";
return;
}
gs->map->removeBlockVisTiles(obj);
@ -857,7 +857,7 @@ DLL_LINKAGE void RebalanceStacks::applyGs( CGameState *gs )
//else - artifact cna be lost :/
else
{
logNetwork->warnStream() << "Artifact is present at destination slot!";
logNetwork->warnStream() << "Artifact is present at destination slot!";
}
artHere->move (alHere, alDest);
//TODO: choose from dialog
@ -1036,7 +1036,7 @@ DLL_LINKAGE void SetAvailableArtifacts::applyGs( CGameState *gs )
}
else
{
logNetwork->errorStream() << "Wrong black market id!";
logNetwork->errorStream() << "Wrong black market id!";
}
}
else
@ -1100,7 +1100,7 @@ DLL_LINKAGE void SetObjectProperty::applyGs( CGameState *gs )
CGObjectInstance *obj = gs->getObjInstance(id);
if(!obj)
{
logNetwork->errorStream() << "Wrong object ID - property cannot be set!";
logNetwork->errorStream() << "Wrong object ID - property cannot be set!";
return;
}
@ -1217,7 +1217,7 @@ DLL_LINKAGE void BattleTriggerEffect::applyGs( CGameState *gs )
st->state.insert(EBattleStackState::FEAR);
break;
default:
logNetwork->warnStream() << "Unrecognized trigger effect type "<< type;
logNetwork->warnStream() << "Unrecognized trigger effect type "<< type;
}
}
@ -1467,11 +1467,11 @@ void actualizeEffect(CStack * s, const std::vector<Bonus> & ef)
DLL_LINKAGE void SetStackEffect::applyGs( CGameState *gs )
{
if (effect.empty())
{
logGlobal->errorStream() << "Trying to apply SetStackEffect with no effects";
return;
}
if(effect.empty())
{
logGlobal->errorStream() << "Trying to apply SetStackEffect with no effects";
return;
}
int spellid = effect.begin()->sid; //effects' source ID
@ -1494,7 +1494,7 @@ DLL_LINKAGE void SetStackEffect::applyGs( CGameState *gs )
}
}
else
logNetwork->errorStream() << "Cannot find stack " << id;
logNetwork->errorStream() << "Cannot find stack " << id;
}
typedef std::pair<ui32, Bonus> p;
for(p para : uniqueBonuses)
@ -1508,7 +1508,7 @@ DLL_LINKAGE void SetStackEffect::applyGs( CGameState *gs )
actualizeEffect(s, effect);
}
else
logNetwork->errorStream() << "Cannot find stack " << para.first;
logNetwork->errorStream() << "Cannot find stack " << para.first;
}
}
@ -1529,7 +1529,7 @@ DLL_LINKAGE void StacksHealedOrResurrected::applyGs( CGameState *gs )
if(!changedStack->alive() && !accessibility.accessible(changedStack->position, changedStack))
{
logNetwork->errorStream() << "Cannot resurrect " << changedStack->nodeName() << " because hex " << changedStack->position << " is occupied!";
logNetwork->errorStream() << "Cannot resurrect " << changedStack->nodeName() << " because hex " << changedStack->position << " is occupied!";
return; //position is already occupied
}
@ -1666,7 +1666,7 @@ DLL_LINKAGE void BattleStackAdded::applyGs(CGameState *gs)
newStackID = 0;
if (!BattleHex(pos).isValid())
{
logNetwork->warnStream() << "No place found for new stack!";
logNetwork->warnStream() << "No place found for new stack!";
return;
}

View File

@ -90,7 +90,7 @@ struct StartInfo
{
if(playerInfos.find(no) != playerInfos.end())
return playerInfos[no];
logGlobal->errorStream() << "Cannot find info about player " << no <<". Throwing...";
logGlobal->errorStream() << "Cannot find info about player " << no <<". Throwing...";
throw std::runtime_error("Cannot find info about player");
}
const PlayerSettings & getIthPlayersSettings(PlayerColor no) const

View File

@ -47,7 +47,7 @@ static int lowestSpeed(const CGHeroInstance * chi)
{
if(!chi->stacksCount())
{
logGlobal->errorStream() << "Error! Hero " << chi->id.getNum() << " ("<<chi->name<<") has no army!";
logGlobal->errorStream() << "Error! Hero " << chi->id.getNum() << " ("<<chi->name<<") has no army!";
return 20;
}
auto i = chi->Slots().begin();
@ -171,7 +171,7 @@ void CGHeroInstance::setSecSkillLevel(SecondarySkill which, int val, bool abs)
if(elem.second > 3) //workaround to avoid crashes when same sec skill is given more than once
{
logGlobal->warnStream() << "Warning: Skill " << which << " increased over limit! Decreasing to Expert.";
logGlobal->warnStream() << "Warning: Skill " << which << " increased over limit! Decreasing to Expert.";
elem.second = 3;
}
updateSkill(which, elem.second); //when we know final value
@ -367,7 +367,7 @@ void CGHeroInstance::initArmy(IArmyDescriptor *dst /*= nullptr*/)
if(!getArt(convSlot))
putArtifact(convSlot, CArtifactInstance::createNewArtifactInstance(aid));
else
logGlobal->warnStream() << "Hero " << name << " already has artifact at " << slot << ", omitting giving " << aid;
logGlobal->warnStream() << "Hero " << name << " already has artifact at " << slot << ", omitting giving " << aid;
}
else
dst->setCreature(SlotID(stackNo-warMachinesGiven), stack.creature, count);
@ -660,7 +660,7 @@ void CGHeroInstance::initObj()
hs->addNewBonus(bonus);
break;
default:
logGlobal->warnStream() << "Unexpected hero specialty " << type;
logGlobal->warnStream() << "Unexpected hero specialty " << type;
}
}
specialty.push_back(hs); //will it work?
@ -717,7 +717,7 @@ void CGHeroInstance::Updatespecialty() //TODO: calculate special value of bonuse
}
else //no creature found, can't calculate value
{
logGlobal->warnStream() << "Primary skill specialty growth supported only with creature type limiters";
logGlobal->warnStream() << "Primary skill specialty growth supported only with creature type limiters";
break;
}
@ -961,26 +961,26 @@ bool CGHeroInstance::canCastThisSpell(const CSpell * spell) const
const bool levelBonus = hasBonusOfType(Bonus::SPELLS_OF_LEVEL, spell->level);
if (spell->isSpecialSpell())
{
if (inSpellBook)
{//hero has this spell in spellbook
logGlobal->errorStream() << "Special spell " << spell->name << "in spellbook.";
}
return specificBonus;
}
else if(!isAllowed)
{
if (inSpellBook)
{//hero has this spell in spellbook
logGlobal->errorStream() << "Banned spell " << spell->name << " in spellbook.";
}
return specificBonus || schoolBonus || levelBonus;
}
else
{
if(spell->isSpecialSpell())
{
if(inSpellBook)
{//hero has this spell in spellbook
logGlobal->errorStream() << "Special spell " << spell->name << "in spellbook.";
}
return specificBonus;
}
else if(!isAllowed)
{
if(inSpellBook)
{//hero has this spell in spellbook
logGlobal->errorStream() << "Banned spell " << spell->name << " in spellbook.";
}
return specificBonus || schoolBonus || levelBonus;
}
else
{
return inSpellBook || schoolBonus || specificBonus || levelBonus;
}
}
}
/**

View File

@ -179,7 +179,7 @@ const IMarket * IMarket::castFrom(const CGObjectInstance *obj, bool verbose /*=
return static_cast<const CGUniversity*>(obj);
default:
if(verbose)
logGlobal->errorStream() << "Cannot cast to IMarket object with ID " << obj->ID;
logGlobal->errorStream() << "Cannot cast to IMarket object with ID " << obj->ID;
return nullptr;
}
}
@ -305,7 +305,7 @@ void CGUniversity::initObj()
}
if(toChoose.size() < 4)
{
logGlobal->warnStream()<<"Warning: less then 4 available skills was found by University initializer!";
logGlobal->warnStream()<<"Warning: less then 4 available skills was found by University initializer!";
return;
}

View File

@ -1170,7 +1170,7 @@ void CGTownInstance::addHeroToStructureVisitors( const CGHeroInstance *h, si32 s
else
{
//should never ever happen
logGlobal->errorStream() << "Cannot add hero " << h->name << " to visitors of structure #" << structureInstanceID;
logGlobal->errorStream() << "Cannot add hero " << h->name << " to visitors of structure #" << structureInstanceID;
assert(0);
}
}

View File

@ -110,13 +110,13 @@ void IObjectInterface::heroLevelUpDone(const CGHeroInstance *hero) const
CObjectHandler::CObjectHandler()
{
logGlobal->traceStream() << "\t\tReading resources prices ";
logGlobal->traceStream() << "\t\tReading resources prices ";
const JsonNode config2(ResourceID("config/resources.json"));
for(const JsonNode &price : config2["resources_prices"].Vector())
{
resVals.push_back(price.Float());
}
logGlobal->traceStream() << "\t\tDone loading resource prices!";
logGlobal->traceStream() << "\t\tDone loading resource prices!";
}
PlayerColor CGObjectInstance::getOwner() const

View File

@ -232,7 +232,7 @@ void CGCreature::initObj()
if(amount == 0) //armies with 0 creatures are illegal
{
logGlobal->warnStream() << "Problem: stack " << nodeName() << " cannot have 0 creatures. Check properties of " << c.nodeName();
logGlobal->warnStream() << "Problem: stack " << nodeName() << " cannot have 0 creatures. Check properties of " << c.nodeName();
amount = 1;
}
}
@ -1507,7 +1507,7 @@ void CGWitchHut::serializeJsonOptions(JsonSerializeFormat & handler)
auto standard = VLC->heroh->getDefaultAllowedAbilities(); //todo: for WitchHut default is all except Leadership and Necromancy
if(handler.saving)
if(handler.saving)
{
for(si32 i = 0; i < GameConstants::SKILL_QUANTITY; ++i)
if(vstd::contains(allowedAbilities, i))
@ -1589,7 +1589,7 @@ void CGShrine::onHeroVisit( const CGHeroInstance * h ) const
{
if(spell == SpellID::NONE)
{
logGlobal->errorStream() << "Not initialized shrine visited!";
logGlobal->errorStream() << "Not initialized shrine visited!";
return;
}
@ -1637,7 +1637,7 @@ void CGShrine::initObj()
if(possibilities.empty())
{
logGlobal->errorStream() << "Error: cannot init shrine, no allowed spells!";
logGlobal->errorStream() << "Error: cannot init shrine, no allowed spells!";
return;
}
@ -2032,7 +2032,7 @@ void CCartographer::onHeroVisit( const CGHeroInstance * h ) const
text = 27;
break;
default:
logGlobal->warnStream() << "Unrecognized subtype of cartographer";
logGlobal->warnStream() << "Unrecognized subtype of cartographer";
}
assert(text);
BlockingDialog bd (true, false);

View File

@ -245,7 +245,7 @@ CScenarioTravel CCampaignHandler::readScenarioTravelFromMemory(CBinaryReader & r
break;
}
default:
logGlobal->warnStream() << "Corrupted h3c file";
logGlobal->warnStream() << "Corrupted h3c file";
break;
}
ret.bonusesToChoose.push_back(bonus);
@ -282,8 +282,8 @@ CScenarioTravel CCampaignHandler::readScenarioTravelFromMemory(CBinaryReader & r
}
default:
{
logGlobal->warnStream() << "Corrupted h3c file";
break;
logGlobal->warnStream() << "Corrupted h3c file";
break;
}
}

View File

@ -126,7 +126,7 @@ void CMapLoaderH3M::init()
{
for(MapLoadingTime & mlt : times)
{
logGlobal->debugStream() << "\tReading " << mlt.name << " took " << mlt.time << " ms.";
logGlobal->debugStream() << "\tReading " << mlt.name << " took " << mlt.time << " ms.";
}
}
map->calculateGuardingGreaturePositions();
@ -873,14 +873,14 @@ bool CMapLoaderH3M::loadArtifactToSlot(CGHeroInstance * hero, int slot)
{
if(vstd::contains(VLC->arth->bigArtifacts, aid) && slot >= GameConstants::BACKPACK_START)
{
logGlobal->warnStream() << "Warning: A big artifact (war machine) in hero's backpack, ignoring...";
logGlobal->warnStream() << "Warning: A big artifact (war machine) in hero's backpack, ignoring...";
return false;
}
if(aid == 0 && slot == ArtifactPosition::MISC5)
{
//TODO: check how H3 handles it -> art 0 in slot 18 in AB map
logGlobal->warnStream() << "Spellbook to MISC5 slot? Putting it spellbook place. AB format peculiarity ? (format "
<< static_cast<int>(map->version) << ")";
logGlobal->warnStream() << "Spellbook to MISC5 slot? Putting it spellbook place. AB format peculiarity ? (format "
<< static_cast<int>(map->version) << ")";
slot = ArtifactPosition::SPELLBOOK;
}
@ -1536,7 +1536,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(ObjectInstanceID idToBeGiven, const i
{
if(elem->subID == nhi->subID)
{
logGlobal->debugStream() << "Hero " << nhi->subID << " will be taken from the predefined heroes list.";
logGlobal->debugStream() << "Hero " << nhi->subID << " will be taken from the predefined heroes list.";
delete nhi;
nhi = elem;
break;
@ -2067,8 +2067,8 @@ std::set<BuildingID> CMapLoaderH3M::convertBuildings(const std::set<BuildingID>
}
else
{
logGlobal->warnStream() << "Conversion warning: unknown building " << elem << " in castle "
<< castleID;
logGlobal->warnStream() << "Conversion warning: unknown building " << elem << " in castle "
<< castleID;
}
}

View File

@ -937,7 +937,7 @@ void CGameHandler::handleConnection(std::set<PlayerColor> players, CConnection &
packType = typeList.getTypeID(pack); //get the id of type
logGlobal->traceStream() << boost::format("Received client message (request %d by player %d) of type with ID=%d (%s).\n")
logGlobal->traceStream() << boost::format("Received client message (request %d by player %d) of type with ID=%d (%s).\n")
% requestID % player.getNum() % packType % typeid(*pack).name();
}
@ -964,7 +964,7 @@ void CGameHandler::handleConnection(std::set<PlayerColor> players, CConnection &
if(!result)
{
complain((boost::format("Got false in applying %s... that request must have been fishy!")
% typeid(*pack).name()).str());
% typeid(*pack).name()).str());
}
logGlobal->traceStream() << "Message successfully applied (result=" << result << ")!";
sendPackageResponse(true);
@ -981,7 +981,7 @@ void CGameHandler::handleConnection(std::set<PlayerColor> players, CConnection &
catch(boost::system::system_error &e) //for boost errors just log, not crash - probably client shut down connection
{
assert(!c.connected); //make sure that connection has been marked as broken
logGlobal->errorStream() << e.what();
logGlobal->errorStream() << e.what();
end2 = true;
}
catch(...)
@ -991,7 +991,7 @@ void CGameHandler::handleConnection(std::set<PlayerColor> players, CConnection &
throw;
}
logGlobal->errorStream() << "Ended handling connection";
logGlobal->errorStream() << "Ended handling connection";
}
int CGameHandler::moveStack(int stack, BattleHex dest)
@ -1328,9 +1328,9 @@ void CGameHandler::init(StartInfo *si)
}
gs = new CGameState();
logGlobal->infoStream() << "Gamestate created!";
logGlobal->infoStream() << "Gamestate created!";
gs->init(si);
logGlobal->infoStream() << "Gamestate initialized!";
logGlobal->infoStream() << "Gamestate initialized!";
// reset seed, so that clients can't predict any following random values
gs->getRandomGenerator().resetSeed();
@ -1343,7 +1343,7 @@ void CGameHandler::init(StartInfo *si)
static bool evntCmp(const CMapEvent &a, const CMapEvent &b)
{
return a.earlierThan(b);
return a.earlierThan(b);
}
void CGameHandler::setPortalDwelling(const CGTownInstance * town, bool forced=false, bool clear = false)
@ -1351,7 +1351,7 @@ void CGameHandler::setPortalDwelling(const CGTownInstance * town, bool forced=fa
const PlayerState *p = gs->getPlayer(town->tempOwner);
if(!p)
{
logGlobal->warnStream() << "There is no player owner of town " << town->name << " at " << town->pos;
logGlobal->warnStream() << "There is no player owner of town " << town->name << " at " << town->pos;
return;
}
@ -1389,7 +1389,7 @@ void CGameHandler::setPortalDwelling(const CGTownInstance * town, bool forced=fa
void CGameHandler::newTurn()
{
logGlobal->traceStream() << "Turn " << gs->day+1;
logGlobal->traceStream() << "Turn " << gs->day+1;
NewTurn n;
n.specialWeek = NewTurn::NO_ACTION;
n.creatureid = CreatureID::NONE;
@ -1702,7 +1702,7 @@ void CGameHandler::newTurn()
}
}
logGlobal->traceStream() << "Info about turn " << n.day << "has been sent!";
logGlobal->traceStream() << "Info about turn " << n.day << "has been sent!";
handleTimeEvents();
//call objects
for(auto & elem : gs->map->objects)
@ -1747,17 +1747,17 @@ void CGameHandler::run(bool resume)
std::set<PlayerColor> players;
(*cc) >> players; //how many players will be handled at that client
std::stringstream sbuffer;
sbuffer << "Connection " << cc->connectionID << " will handle " << players.size() << " player: ";
std::stringstream sbuffer;
sbuffer << "Connection " << cc->connectionID << " will handle " << players.size() << " player: ";
for(PlayerColor color : players)
{
sbuffer << color << " ";
sbuffer << color << " ";
{
boost::unique_lock<boost::recursive_mutex> lock(gsm);
connections[color] = cc;
}
}
logGlobal->infoStream() << sbuffer.str();
logGlobal->infoStream() << sbuffer.str();
cc->addStdVecItems(gs);
cc->enableStackSendingByID();
@ -1931,7 +1931,7 @@ bool CGameHandler::removeObject( const CGObjectInstance * obj )
{
if(!obj || !getObj(obj->id))
{
logGlobal->errorStream() << "Something wrong, that object already has been removed or hasn't existed!";
logGlobal->errorStream() << "Something wrong, that object already has been removed or hasn't existed!";
return false;
}
@ -1956,16 +1956,16 @@ bool CGameHandler::moveHero( ObjectInstanceID hid, int3 dst, ui8 teleporting, bo
if(!h || (asker != PlayerColor::NEUTRAL && (teleporting || h->getOwner() != gs->currentPlayer)) //not turn of that hero or player can't simply teleport hero (at least not with this function)
)
{
logGlobal->errorStream() << "Illegal call to move hero!";
logGlobal->errorStream() << "Illegal call to move hero!";
return false;
}
logGlobal->traceStream() << "Player " << asker << " wants to move hero "<< hid.getNum() << " from "<< h->pos << " to " << dst;
logGlobal->traceStream() << "Player " << asker << " wants to move hero "<< hid.getNum() << " from "<< h->pos << " to " << dst;
const int3 hmpos = CGHeroInstance::convertPosition(dst, false);
if(!gs->map->isInTheMap(hmpos))
{
logGlobal->errorStream() << "Destination tile is outside the map!";
logGlobal->errorStream() << "Destination tile is outside the map!";
return false;
}
@ -2142,7 +2142,7 @@ bool CGameHandler::teleportHero(ObjectInstanceID hid, ObjectInstanceID dstid, ui
const CGTownInstance *t = getTown(dstid);
if ( !h || !t || h->getOwner() != gs->currentPlayer )
logGlobal->errorStream()<<"Invalid call to teleportHero!";
logGlobal->errorStream() << "Invalid call to teleportHero!";
const CGTownInstance *from = h->visitedTown;
if(((h->getOwner() != t->getOwner())
@ -2519,7 +2519,7 @@ void CGameHandler::heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2)
void CGameHandler::sendToAllClients( CPackForClient * info )
{
logGlobal->traceStream() << "Sending to all clients a package of type " << typeid(*info).name();
logGlobal->traceStream() << "Sending to all clients a package of type " << typeid(*info).name();
for(auto & elem : conns)
{
boost::unique_lock<boost::mutex> lock(*(elem)->wmx);
@ -2565,13 +2565,13 @@ void CGameHandler::sendAndApply( NewStructures * info )
void CGameHandler::save(const std::string & filename )
{
logGlobal->infoStream() << "Saving to " << filename;
logGlobal->infoStream() << "Saving to " << filename;
const auto stem = FileInfo::GetPathStem(filename);
const auto savefname = stem.to_string() + ".vsgm1";
CResourceHandler::get("local")->createResource(savefname);
{
logGlobal->infoStream() << "Ordering clients to serialize...";
logGlobal->infoStream() << "Ordering clients to serialize...";
SaveGame sg(savefname);
sendToAllClients(&sg);
}
@ -2589,20 +2589,20 @@ void CGameHandler::save(const std::string & filename )
{
CSaveFile save(*CResourceHandler::get("local")->getResourceName(ResourceID(stem.to_string(), EResType::SERVER_SAVEGAME)));
saveCommonState(save);
logGlobal->infoStream() << "Saving server state";
logGlobal->infoStream() << "Saving server state";
save << *this;
}
logGlobal->infoStream() << "Game has been successfully saved!";
logGlobal->infoStream() << "Game has been successfully saved!";
}
catch(std::exception &e)
{
logGlobal->errorStream() << "Failed to save game: " << e.what();
logGlobal->errorStream() << "Failed to save game: " << e.what();
}
}
void CGameHandler::close()
{
logGlobal->infoStream() << "We have been requested to close.";
logGlobal->infoStream() << "We have been requested to close.";
if(gs->initialOpts->mode == StartInfo::DUEL)
{
@ -3784,7 +3784,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
BattleHex startingPos = stack->position;
int distance = moveStack(ba.stackNumber, ba.destinationTile);
logGlobal->traceStream() << stack->nodeName() << " will attack " << destinationStack->nodeName();
logGlobal->traceStream() << stack->nodeName() << " will attack " << destinationStack->nodeName();
if(stack->position != ba.destinationTile //we wasn't able to reach destination tile
&& !(stack->doubleWide()
@ -3793,7 +3793,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
)
{
std::string problem = "We cannot move this stack to its destination " + stack->getCreature()->namePl;
logGlobal->warnStream() << problem;
logGlobal->warnStream() << problem;
complain(problem);
ok = false;
sendAndApply(&end_action);
@ -4024,7 +4024,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
attack.destinationTile = gs->curB->wallPartToBattleHex(EWallPart::EWallPart(attack.attackedPart));
logGlobal->traceStream() << "Catapult attacks " << (int)attack.attackedPart
<< " dealing " << (int)attack.damageDealt << " damage";
<< " dealing " << (int)attack.damageDealt << " damage";
//removing creatures in turrets / keep if one is destroyed
if(attack.damageDealt > 0 && (attackedPart == EWallPart::KEEP ||
@ -4370,12 +4370,12 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
const CGHeroInstance *h = gs->curB->battleGetFightingHero(ba.side);
if(!h)
{
logGlobal->warnStream() << "Wrong caster!";
logGlobal->warnStream() << "Wrong caster!";
return false;
}
if(ba.additionalInfo >= VLC->spellh->objects.size())
{
logGlobal->warnStream() << "Wrong spell id (" << ba.additionalInfo << ")!";
logGlobal->warnStream() << "Wrong spell id (" << ba.additionalInfo << ")!";
return false;
}
@ -4702,7 +4702,7 @@ void CGameHandler::handleTimeEvents()
ev.firstOccurence += ev.nextOccurence;
auto it = gs->map->events.begin();
while ( it !=gs->map->events.end() && it->earlierThanOrEqual(ev))
while(it != gs->map->events.end() && it->earlierThanOrEqual(ev))
it++;
gs->map->events.insert(it, ev);
}
@ -4785,7 +4785,7 @@ void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n)
ev.firstOccurence += ev.nextOccurence;
auto it = town->events.begin();
while ( it != town->events.end() && it->earlierThanOrEqual(ev))
while(it != town->events.end() && it->earlierThanOrEqual(ev))
it++;
town->events.insert(it, ev);
}
@ -4805,7 +4805,7 @@ void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n)
bool CGameHandler::complain( const std::string &problem )
{
sendMessageToAll("Server encountered a problem: " + problem);
logGlobal->errorStream() << problem;
logGlobal->errorStream() << problem;
return true;
}
@ -5760,8 +5760,8 @@ void CGameHandler::runBattle()
}
else
{
logGlobal->traceStream() << "Activating " << next->nodeName();
auto nextId = next->ID;
logGlobal->traceStream() << "Activating " << next->nodeName();
auto nextId = next->ID;
BattleSetActiveStack sas;
sas.stack = nextId;
sendAndApply(&sas);
@ -5935,12 +5935,12 @@ void CGameHandler::spawnWanderingMonsters(CreatureID creatureID)
getFreeTiles(tiles);
ui32 amount = tiles.size() / 200; //Chance is 0.5% for each tile
std::random_shuffle(tiles.begin(), tiles.end());
logGlobal->traceStream() << "Spawning wandering monsters. Found " << tiles.size() << " free tiles. Creature type: " << creatureID;
logGlobal->traceStream() << "Spawning wandering monsters. Found " << tiles.size() << " free tiles. Creature type: " << creatureID;
const CCreature *cre = VLC->creh->creatures.at(creatureID);
for (int i = 0; i < amount; ++i)
{
tile = tiles.begin();
logGlobal->traceStream() << "\tSpawning monster at " << *tile;
logGlobal->traceStream() << "\tSpawning monster at " << *tile;
putNewMonster(creatureID, cre->getRandomAmount(std::rand), *tile);
tiles.erase(tile); //not use it again
}
@ -6134,7 +6134,7 @@ CasualtiesAfterBattle::CasualtiesAfterBattle(const CArmedInstance * _army, Battl
{
if(st->alive() && st->count > 0)
{
logGlobal->debugStream() << "Permanently summoned " + st->count << " units.";
logGlobal->debugStream() << "Permanently summoned " << st->count << " units.";
const CreatureID summonedType = st->type->idNumber;
summoned[summonedType] += st->count;
}

View File

@ -80,7 +80,7 @@ void CPregameServer::handleConnection(CConnection *cpc)
CPackForSelectionScreen *cpfs = nullptr;
*cpc >> cpfs;
logNetwork->infoStream() << "Got package to announce " << typeid(*cpfs).name() << " from " << *cpc;
logNetwork->infoStream() << "Got package to announce " << typeid(*cpfs).name() << " from " << *cpc;
boost::unique_lock<boost::recursive_mutex> queueLock(mx);
bool quitting = dynamic_ptr_cast<QuitMenuWithoutStarting>(cpfs),
@ -108,7 +108,7 @@ void CPregameServer::handleConnection(CConnection *cpc)
catch (const std::exception& e)
{
boost::unique_lock<boost::recursive_mutex> queueLock(mx);
logNetwork->errorStream() << *cpc << " dies... \nWhat happened: " << e.what();
logNetwork->errorStream() << *cpc << " dies... \nWhat happened: " << e.what();
}
boost::unique_lock<boost::recursive_mutex> queueLock(mx);
@ -124,13 +124,13 @@ void CPregameServer::handleConnection(CConnection *cpc)
if(connections.empty())
{
logNetwork->errorStream() << "Last connection lost, server will close itself...";
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
state = ENDING_WITHOUT_START;
}
}
logNetwork->infoStream() << "Thread listening for " << *cpc << " ended";
logNetwork->infoStream() << "Thread listening for " << *cpc << " ended";
listeningThreads--;
vstd::clear_pointer(cpc->handler);
}
@ -158,7 +158,7 @@ void CPregameServer::run()
if(state != RUNNING)
{
logNetwork->infoStream() << "Stopping listening for connections...";
logNetwork->infoStream() << "Stopping listening for connections...";
acceptor->close();
}
@ -172,13 +172,13 @@ void CPregameServer::run()
boost::this_thread::sleep(boost::posix_time::milliseconds(50));
}
logNetwork->infoStream() << "Thread handling connections ended";
logNetwork->infoStream() << "Thread handling connections ended";
if(state == ENDING_AND_STARTING_GAME)
{
logNetwork->infoStream() << "Waiting for listening thread to finish...";
logNetwork->infoStream() << "Waiting for listening thread to finish...";
while(listeningThreads) boost::this_thread::sleep(boost::posix_time::milliseconds(50));
logNetwork->infoStream() << "Preparing new game";
logNetwork->infoStream() << "Preparing new game";
}
}
@ -199,11 +199,11 @@ void CPregameServer::connectionAccepted(const boost::system::error_code& ec)
{
if(ec)
{
logNetwork->infoStream() << "Something wrong during accepting: " << ec.message();
logNetwork->infoStream() << "Something wrong during accepting: " << ec.message();
return;
}
logNetwork->infoStream() << "We got a new connection! :)";
logNetwork->infoStream() << "We got a new connection! :)";
CConnection *pc = new CConnection(upcomingConnection, NAME);
initConnection(pc);
upcomingConnection = nullptr;
@ -232,7 +232,7 @@ void CPregameServer::start_async_accept()
void CPregameServer::announceTxt(const std::string &txt, const std::string &playerName /*= "system"*/)
{
logNetwork->infoStream() << playerName << " says: " << txt;
logNetwork->infoStream() << playerName << " says: " << txt;
ChatMessage cm;
cm.playerName = playerName;
cm.message = txt;
@ -251,7 +251,7 @@ void CPregameServer::sendPack(CConnection * pc, const CPackForSelectionScreen &
{
if(!pc->sendStop)
{
logNetwork->infoStream() << "\tSending pack of type " << typeid(pack).name() << " to " << *pc;
logNetwork->infoStream() << "\tSending pack of type " << typeid(pack).name() << " to " << *pc;
*pc << &pack;
}
@ -300,7 +300,7 @@ void CPregameServer::initConnection(CConnection *c)
{
*c >> c->name;
connections.insert(c);
logNetwork->infoStream() << "Pregame connection with player " << c->name << " established!";
logNetwork->infoStream() << "Pregame connection with player " << c->name << " established!";
}
void CPregameServer::startListeningThread(CConnection * pc)
@ -313,7 +313,7 @@ void CPregameServer::startListeningThread(CConnection * pc)
CVCMIServer::CVCMIServer()
: io(new boost::asio::io_service()), acceptor(new TAcceptor(*io, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port))), firstConnection(nullptr)
{
logNetwork->debugStream() << "CVCMIServer created!";
logNetwork->debugStream() << "CVCMIServer created!";
}
CVCMIServer::~CVCMIServer()
{
@ -410,7 +410,7 @@ void CVCMIServer::start()
#endif
boost::system::error_code error;
logNetwork->infoStream()<<"Listening for connections at port " << acceptor->local_endpoint().port();
logNetwork->infoStream()<<"Listening for connections at port " << acceptor->local_endpoint().port();
auto s = new boost::asio::ip::tcp::socket(acceptor->get_io_service());
boost::thread acc(std::bind(vaccept,acceptor,s,&error));
#ifndef VCMI_ANDROID
@ -421,12 +421,12 @@ void CVCMIServer::start()
acc.join();
if (error)
{
logNetwork->warnStream()<<"Got connection but there is an error " << error;
logNetwork->warnStream()<<"Got connection but there is an error " << error;
return;
}
logNetwork->infoStream()<<"We've accepted someone... ";
logNetwork->infoStream()<<"We've accepted someone... ";
firstConnection = new CConnection(s,NAME);
logNetwork->infoStream()<<"Got connection!";
logNetwork->infoStream()<<"Got connection!";
while(!end2)
{
ui8 mode;
@ -500,7 +500,7 @@ void CVCMIServer::loadGame()
acceptor->accept(*s,error);
if(error) //retry
{
logNetwork->warnStream()<<"Cannot establish connection - retrying...";
logNetwork->warnStream()<<"Cannot establish connection - retrying...";
i--;
continue;
}
@ -620,7 +620,7 @@ int main(int argc, char** argv)
}
catch(boost::system::system_error &e) //for boost errors just log, not crash - probably client shut down connection
{
logNetwork->errorStream() << e.what();
logNetwork->errorStream() << e.what();
end2 = true;
}
catch(...)
@ -630,7 +630,7 @@ int main(int argc, char** argv)
}
catch(boost::system::system_error &e)
{
logNetwork->errorStream() << e.what();
logNetwork->errorStream() << e.what();
//catch any startup errors (e.g. can't access port) errors
//and return non-zero status so client can detect error
throw;

View File

@ -16,12 +16,12 @@
boost::unique_lock<boost::mutex> lock(*c->wmx); \
*c << &temp_message; \
} \
logNetwork->errorStream()<<"Player is not allowed to perform this action!"; \
logNetwork->errorStream()<<"Player is not allowed to perform this action!"; \
return false;} while(0)
#define WRONG_PLAYER_MSG(expectedplayer) do {std::ostringstream oss;\
oss << "You were identified as player " << gh->getPlayerAt(c) << " while expecting " << expectedplayer;\
logNetwork->errorStream() << oss.str(); \
logNetwork->errorStream() << oss.str(); \
if(c) { SystemMessage temp_message(oss.str()); boost::unique_lock<boost::mutex> lock(*c->wmx); *c << &temp_message; } } while(0)
#define ERROR_IF_NOT_OWNS(id) do{if(!PLAYER_OWNS(id)){WRONG_PLAYER_MSG(gh->getOwner(id)); ERROR_AND_RETURN; }}while(0)