1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Logging cleanup

This commit is contained in:
AlexVinS 2017-08-10 19:39:27 +03:00
parent 18b8e1c7ad
commit 61e241308d
52 changed files with 188 additions and 188 deletions

View File

@ -2326,11 +2326,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->debug("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->debug("Considering goal %s", goal->name());
try
{
boost::this_thread::interruption_point();
@ -2343,7 +2343,7 @@ 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->debug("Goal %s decomposition failed: goal was completed as much as possible", goal->name());
return sptr(Goals::Invalid());
}
catch(std::exception &e)
@ -2375,7 +2375,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->debug("Choosing abstract goal %s", goal->name());
break;
}
else
@ -2388,7 +2388,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->debug("Player %d: Making turn thread received an interruption!", playerID);
throw; //rethrow, we want to truly end this thread
}
catch(goalFulfilledException &e)
@ -2402,7 +2402,7 @@ 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->debug("The error message was: %s", e.what());
break;
}
}
@ -2415,7 +2415,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->debug("Trying to realize quest: %s", ms.toString());
auto heroes = cb->getHeroesInfo();
switch (q.quest->missionType)
@ -2513,7 +2513,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->debug("Don't know how to increase primary stat %d", i);
}
break;
}
@ -2528,13 +2528,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->debug("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->debug("Can't be player of color %d", q.quest->m13489val);
break;
}
case CQuest::MISSION_KEYMASTER:
@ -2562,7 +2562,7 @@ void VCAI::performTypicalActions()
}
catch(std::exception &e)
{
logAi->debugStream() << boost::format("Cannot use this hero anymore, received exception: %s") % e.what();
logAi->debug("Cannot use this hero anymore, received exception: %s", e.what());
continue;
}
}
@ -2811,7 +2811,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->debug("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])
@ -2831,7 +2831,7 @@ void VCAI::answerQuery(QueryID queryID, int selection)
}
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->debug("Since the query ID is %d, the answer won't be sent. This is not a real query!", queryID);
//do nothing
}
}
@ -2876,9 +2876,9 @@ TResources VCAI::freeResources() const
{
TResources myRes = cb->getResourceAmount();
auto iterator = cb->getTownsInfo();
if(std::none_of(iterator.begin(), iterator.end(), [](const CGTownInstance * x)->bool
{
return x->builtBuildings.find(BuildingID::CAPITOL) != x->builtBuildings.end();
if(std::none_of(iterator.begin(), iterator.end(), [](const CGTownInstance * x)->bool
{
return x->builtBuildings.find(BuildingID::CAPITOL) != x->builtBuildings.end();
})
/*|| std::all_of(iterator.begin(), iterator.end(), [](const CGTownInstance * x) -> bool { return x->forbiddenBuildings.find(BuildingID::CAPITOL) != x->forbiddenBuildings.end(); })*/ )
myRes[Res::GOLD] -= GOLD_RESERVE; //what if capitol is blocked from building in all possessed towns (set in map editor)? What about reserve for city hall or something similar in that case?

View File

@ -55,7 +55,7 @@ int CCallback::sendQueryReply(const JsonNode & reply, QueryID queryID)
ASSERT_IF_CALLED_WITH_PLAYER
if(queryID == QueryID(-1))
{
logGlobal->errorStream() << "Cannot answer the query -1!";
logGlobal->error("Cannot answer the query -1!");
return -1;
}
@ -185,7 +185,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->trace("We'll wait till request %d is answered.\n", requestID);
auto gsUnlocker = vstd::makeUnlockSharedGuardIf(CGameState::mutex, unlockGsWhenWaiting);
CClient::waitingRequest.waitWhileContains(requestID);
}

View File

@ -106,7 +106,7 @@ SDL_Surface * BitmapHandler::loadBitmapFromDir(std::string path, std::string fna
{
if(!fname.size())
{
logGlobal->warnStream() << "Call to loadBitmap with void fname!";
logGlobal->warn("Call to loadBitmap with void fname!");
return nullptr;
}
if (!CResourceHandler::get()->existsResource(ResourceID(path + fname, EResType::IMAGE)))

View File

@ -381,11 +381,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->error("Fatal error: failed to load settings!");
logGlobal->error("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->error("VCMI will now exit...");
exit(EXIT_FAILURE);
}
@ -438,7 +438,7 @@ int main(int argc, char * argv[])
logGlobal->errorStream() << "Selected resolution " << resPair.first << "x" << resPair.second << " was not found!";
if (conf.guiOptions.empty())
{
logGlobal->errorStream() << "Unable to continue - no valid resolutions found! Please reinstall VCMI to fix this";
logGlobal->error("Unable to continue - no valid resolutions found! Please reinstall VCMI to fix this");
exit(1);
}
else
@ -607,7 +607,7 @@ void removeGUI()
GH.listInt.clear();
GH.objsToBlit.clear();
GH.statusbar = nullptr;
logGlobal->infoStream() << "Removed GUI.";
logGlobal->info("Removed GUI.");
LOCPLINT = nullptr;
}
@ -672,11 +672,11 @@ void processCommand(const std::string &message)
std::cout << "Screenbuf points to ";
if(screenBuf == screen)
logGlobal->errorStream() << "screen";
logGlobal->error("screen");
else if(screenBuf == screen2)
logGlobal->errorStream() << "screen2";
logGlobal->error("screen2");
else
logGlobal->errorStream() << "?!?";
logGlobal->error("?!?");
SDL_SaveBMP(screen, "Screen_c.bmp");
SDL_SaveBMP(screen2, "Screen2_c.bmp");
@ -844,7 +844,7 @@ void processCommand(const std::string &message)
outFile.write((char*)data.first.get(), data.second);
}
else
logGlobal->errorStream() << "File not found!";
logGlobal->error("File not found!");
}
else if(cn == "setBattleAI")
{
@ -863,7 +863,7 @@ void processCommand(const std::string &message)
catch(std::exception &e)
{
logGlobal->warnStream() << "Failed opening " << fname << ": " << e.what();
logGlobal->warnStream() << "Setting not changes, AI not found or invalid!";
logGlobal->warn("Setting not changes, AI not found or invalid!");
}
}
@ -1134,7 +1134,7 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen, int displayIn
screen = SDL_CreateRGBSurface(0,w,h,bpp,rmask,gmask,bmask,amask);
if(nullptr == screen)
{
logGlobal->errorStream() << "Unable to create surface";
logGlobal->error("Unable to create surface");
logGlobal->errorStream() << w << " "<< h << " "<< bpp;
logGlobal->errorStream() << SDL_GetError();
@ -1150,7 +1150,7 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen, int displayIn
if(nullptr == screenTexture)
{
logGlobal->errorStream() << "Unable to create screen texture";
logGlobal->error("Unable to create screen texture");
logGlobal->errorStream() << SDL_GetError();
throw std::runtime_error("Unable to create screen texture");
}

View File

@ -830,7 +830,7 @@ BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when i
if(CBattleInterface::givenCommand.get())
{
logGlobal->errorStream() << "Command buffer must be clean! (we don't want to use old command)";
logGlobal->error("Command buffer must be clean! (we don't want to use old command)");
vstd::clear_pointer(CBattleInterface::givenCommand.data);
}
@ -1594,7 +1594,7 @@ void CPlayerInterface::waitWhileDialog(bool unlockPim)
{
if (GH.amIGuiThread())
{
logGlobal->warnStream() << "Cannot wait for dialogs in gui thread (deadlock risk)!";
logGlobal->warn("Cannot wait for dialogs in gui thread (deadlock risk)!");
return;
}
@ -2314,7 +2314,7 @@ CGPath * CPlayerInterface::getAndVerifyPath(const CGHeroInstance * h)
CGPath &path = paths[h];
if (!path.nodes.size())
{
logGlobal->warnStream() << "Warning: empty path found...";
logGlobal->warn("Warning: empty path found...");
paths.erase(h);
}
else

View File

@ -209,7 +209,7 @@ template <> class CApplyOnPG<CPack> : public CBaseForPGApply
public:
void applyOnPG(CSelectionScreen *selScr, void *pack) const override
{
logGlobal->errorStream() << "Cannot apply on PG plain CPack!";
logGlobal->error("Cannot apply on PG plain CPack!");
assert(0);
}
};
@ -3662,7 +3662,7 @@ void CBonusSelection::updateBonusSelection()
case CScenarioTravel::STravelBonus::HEROES_FROM_PREVIOUS_SCENARIO:
{
auto superhero = ourCampaign->camp->scenarios[bonDescs[i].info2].strongestHero(PlayerColor(bonDescs[i].info1));
if (!superhero) logGlobal->warnStream() << "No superhero! How could it be transferred?";
if (!superhero) logGlobal->warn("No superhero! How could it be transferred?");
picNumber = superhero ? superhero->portrait : 0;
desc = CGI->generaltexth->allTexts[719];

View File

@ -95,12 +95,12 @@ template <> class CApplyOnCL<CPack> : public CBaseForCLApply
public:
void applyOnClAfter(CClient *cl, void *pack) const override
{
logGlobal->errorStream() << "Cannot apply on CL plain CPack!";
logGlobal->error("Cannot apply on CL plain CPack!");
assert(0);
}
void applyOnClBefore(CClient *cl, void *pack) const override
{
logGlobal->errorStream() << "Cannot apply on CL plain CPack!";
logGlobal->error("Cannot apply on CL plain CPack!");
assert(0);
}
};
@ -159,7 +159,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->debug("Wait for move thread was interrupted and no action will be send. Was a battle ended by spell?");
}
catch(...)
{
@ -188,11 +188,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->error("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->error("Something wrong, lost connection while game is still ongoing...");
throw;
}
}
@ -202,7 +202,7 @@ void CClient::save(const std::string & fname)
{
if(gs->curB)
{
logNetwork->errorStream() << "Game cannot be saved during battle!";
logNetwork->error("Game cannot be saved during battle!");
return;
}
@ -220,12 +220,12 @@ void CClient::endGame(bool closeConnection)
// Tell the network thread to reach a stable state
if (closeConnection)
stopConnection();
logNetwork->infoStream() << "Closed connection.";
logNetwork->info("Closed connection.");
GH.curInt = nullptr;
{
boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim);
logNetwork->infoStream() << "Ending current game!";
logNetwork->info("Ending current game!");
if(GH.topInt())
{
GH.topInt()->deactivate();
@ -233,12 +233,12 @@ void CClient::endGame(bool closeConnection)
GH.listInt.clear();
GH.objsToBlit.clear();
GH.statusbar = nullptr;
logNetwork->infoStream() << "Removed GUI.";
logNetwork->info("Removed GUI.");
vstd::clear_pointer(const_cast<CGameInfo*>(CGI)->mh);
vstd::clear_pointer(gs);
logNetwork->infoStream() << "Deleted mapHandler and gameState.";
logNetwork->info("Deleted mapHandler and gameState.");
LOCPLINT = nullptr;
}
@ -249,15 +249,15 @@ void CClient::endGame(bool closeConnection)
CGKeys::reset();
CGMagi::reset();
CGObelisk::reset();
logNetwork->infoStream() << "Deleted playerInts.";
logNetwork->infoStream() << "Client stopped.";
logNetwork->info("Deleted playerInts.");
logNetwork->info("Client stopped.");
}
#if 1
void CClient::loadGame(const std::string & fname, const bool server, const std::vector<int>& humanplayerindices, const int loadNumPlayers, int player_, const std::string & ipaddr, const ui16 port)
{
PlayerColor player(player_); //intentional shadowing
logNetwork->infoStream() << "Loading procedure started!";
logNetwork->info("Loading procedure started!");
CServerHandler sh;
if(server)
@ -325,7 +325,7 @@ void CClient::loadGame(const std::string & fname, const bool server, const std::
if(pom8)
throw std::runtime_error("Server cannot open the savegame!");
else
logNetwork->infoStream() << "Server opened savegame properly.";
logNetwork->info("Server opened savegame properly.");
}
if(server)
@ -362,14 +362,14 @@ void CClient::loadGame(const std::string & fname, const bool server, const std::
serv->enableStackSendingByID();
serv->disableSmartPointerSerialization();
// logGlobal->traceStream() << "Objects:";
// logGlobal->trace("Objects:");
// for(int i = 0; i < gs->map->objects.size(); i++)
// {
// auto o = gs->map->objects[i];
// if(o)
// logGlobal->traceStream() << boost::format("\tindex=%5d, id=%5d; address=%5d, pos=%s, name=%s") % i % o->id % (int)o.get() % o->pos % o->getHoverText();
// else
// logGlobal->traceStream() << boost::format("\tindex=%5d --- nullptr") % i;
// logGlobal->trace("\tindex=%5d --- nullptr", i);
// }
}
#endif
@ -392,7 +392,7 @@ void CClient::newGame( CConnection *con, StartInfo *si )
CConnection &c = *serv;
////////////////////////////////////////////////////
logNetwork->infoStream() <<"\tWill send info to server...";
logNetwork->info("\tWill send info to server...");
CStopWatch tmh;
if(networkMode == SINGLE)
@ -707,16 +707,16 @@ void CClient::stopConnection()
boost::unique_lock<boost::mutex>(*serv->wmx);
if(serv->isHost()) //request closing connection
{
logNetwork->infoStream() << "Connection has been requested to be closed.";
logNetwork->info("Connection has been requested to be closed.");
CloseServer close_server;
sendRequest(&close_server, PlayerColor::NEUTRAL);
logNetwork->infoStream() << "Sent closing signal to the server";
logNetwork->info("Sent closing signal to the server");
}
else
{
LeaveGame leave_Game;
sendRequest(&leave_Game, PlayerColor::NEUTRAL);
logNetwork->infoStream() << "Sent leaving signal to the server";
logNetwork->info("Sent leaving signal to the server");
}
}
@ -727,7 +727,7 @@ void CClient::stopConnection()
if(connectionHandler->get_id() != boost::this_thread::get_id())
connectionHandler->join();
logNetwork->infoStream() << "Connection handler thread joined";
logNetwork->info("Connection handler thread joined");
connectionHandler.reset();
}
}
@ -737,7 +737,7 @@ void CClient::stopConnection()
{
serv->close();
vstd::clear_pointer(serv);
logNetwork->warnStream() << "Our socket has been closed.";
logNetwork->warn("Our socket has been closed.");
}
}
@ -926,7 +926,7 @@ void CClient::installNewPlayerInterface(std::shared_ptr<CGameInterface> gameInte
playerint[colorUsed] = gameInterface;
logGlobal->traceStream() << boost::format("\tInitializing the interface for player %s") % colorUsed;
logGlobal->trace("\tInitializing the interface for player %s", colorUsed);
auto cb = std::make_shared<CCallback>(gs, color, this);
callbacks[colorUsed] = cb;
battleCallbacks[colorUsed] = cb;
@ -947,7 +947,7 @@ void CClient::installNewBattleInterface(std::shared_ptr<CBattleGameInterface> ba
if(needCallback)
{
logGlobal->traceStream() << boost::format("\tInitializing the battle interface for player %s") % *color;
logGlobal->trace("\tInitializing the battle interface for player %s", *color);
auto cbc = std::make_shared<CBattleCallback>(gs, color, this);
battleCallbacks[colorUsed] = cbc;
battleInterface->init(cbc);
@ -1011,13 +1011,13 @@ void CServerHandler::waitForServer()
if(shared)
shared->sr->waitTillReady();
#else
logNetwork->infoStream() << "waiting for server";
logNetwork->info("waiting for server");
while (!androidTestServerReadyFlag.load())
{
logNetwork->infoStream() << "still waiting...";
logNetwork->info("still waiting...");
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
}
logNetwork->infoStream() << "waiting for server finished...";
logNetwork->info("waiting for server finished...");
androidTestServerReadyFlag = false;
#endif
if(verbose)
@ -1112,12 +1112,12 @@ void CServerHandler::callServer()
int result = std::system(comm.c_str());
if (result == 0)
{
logNetwork->infoStream() << "Server closed correctly";
logNetwork->info("Server closed correctly");
serverAlive.setn(false);
}
else
{
logNetwork->errorStream() << "Error: server failed to close correctly or crashed!";
logNetwork->error("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
}
@ -1131,7 +1131,7 @@ CConnection * CServerHandler::justConnectToServer(const std::string &host, const
{
try
{
logNetwork->infoStream() << "Establishing connection...";
logNetwork->info("Establishing connection...");
ret = new CConnection( host.size() ? host : settings["server"]["server"].String(),
port ? port : getDefaultPort(),
NAME);
@ -1139,7 +1139,7 @@ CConnection * CServerHandler::justConnectToServer(const std::string &host, const
}
catch(...)
{
logNetwork->errorStream() << "\nCannot establish connection! Retrying within 2 seconds";
logNetwork->error("\nCannot establish connection! Retrying within 2 seconds");
SDL_Delay(2000);
}
}
@ -1149,13 +1149,13 @@ CConnection * CServerHandler::justConnectToServer(const std::string &host, const
#ifdef VCMI_ANDROID
extern "C" JNIEXPORT void JNICALL Java_eu_vcmi_vcmi_NativeMethods_notifyServerReady(JNIEnv * env, jobject cls)
{
logNetwork->infoStream() << "Received server ready signal";
logNetwork->info("Received server ready signal");
androidTestServerReadyFlag.store(true);
}
extern "C" JNIEXPORT bool JNICALL Java_eu_vcmi_vcmi_NativeMethods_tryToSaveTheGame(JNIEnv * env, jobject cls)
{
logGlobal->infoStream() << "Received emergency save game request";
logGlobal->info("Received emergency save game request");
if(!LOCPLINT || !LOCPLINT->cb)
{
return false;

View File

@ -302,7 +302,7 @@ void Graphics::blueToPlayersAdv(SDL_Surface * sur, PlayerColor player)
// Add some kind of player-colored overlay?
// Or keep palette approach here and replace only colors of specific value(s)
// Or just wait for OpenGL support?
logGlobal->warnStream() << "Image must have palette to be player-colored!";
logGlobal->warn("Image must have palette to be player-colored!");
}
}

View File

@ -480,7 +480,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->error("Something wrong with hero recruited!");
}
bool needsPrinting = true;
@ -524,7 +524,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->warn("We received InfoWindow for not our player...");
}
void SetObjectProperty::applyCl(CClient *cl)
@ -567,7 +567,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->warn("We received YesNoDialog for not our player...");
}
void GarrisonDialog::applyCl(CClient *cl)
@ -776,7 +776,7 @@ void PackageApplied::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(player, requestRealized, this);
if(!CClient::waitingRequest.tryRemovingElement(requestID))
logNetwork->warnStream() << "Surprising server message!";
logNetwork->warn("Surprising server message!");
}
void SystemMessage::applyCl(CClient *cl)

View File

@ -852,7 +852,7 @@ void CBattleInterface::bAutofightf()
{
assert(curInt->autofightingAI);
curInt->isAutoFightOn = false;
logGlobal->traceStream() << "Stopping the autofight...";
logGlobal->trace("Stopping the autofight...");
}
else
{
@ -1119,7 +1119,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->warn("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;
@ -1799,7 +1799,7 @@ void CBattleInterface::endAction(const BattleAction* action)
if (activeStack && !animsAreDisplayed.get() && pendingAnims.empty() && !active)
{
logGlobal->warnStream() << "Something wrong... interface was deactivated but there is no animation. Reactivating...";
logGlobal->warn("Something wrong... interface was deactivated but there is no animation. Reactivating...");
blockUI(false);
}
else

View File

@ -1573,7 +1573,7 @@ void CFadeAnimation::init(EMode mode, SDL_Surface * sourceSurface, bool freeSurf
{
// in that case, immediately finish the previous fade
// (alternatively, we could just return here to ignore the new fade request until this one finished (but we'd need to free the passed bitmap to avoid leaks))
logGlobal->warnStream() << "Tried to init fading animation that is already running.";
logGlobal->warn("Tried to init fading animation that is already running.");
if (fadingSurface && shouldFreeSurface)
SDL_FreeSurface(fadingSurface);
}

View File

@ -85,7 +85,7 @@ void CIntObject::activate()
return;
else
{
logGlobal->warnStream() << "Warning: IntObject re-activated with mismatching used and active";
logGlobal->warn("Warning: IntObject re-activated with mismatching used and active");
deactivate(); //FIXME: better to avoid such possibility at all
}
}
@ -366,9 +366,9 @@ void CKeyShortcut::keyPressed(const SDL_KeyboardEvent & key)
if(vstd::contains(assignedKeys,key.keysym.sym)
|| vstd::contains(assignedKeys, CGuiHandler::numToDigit(key.keysym.sym)))
{
bool prev = mouseState(EIntObjMouseBtnType::LEFT);
bool prev = mouseState(EIntObjMouseBtnType::LEFT);
updateMouseState(EIntObjMouseBtnType::LEFT, key.state == SDL_PRESSED);
clickLeft(key.state == SDL_PRESSED, prev);
}
}

View File

@ -407,7 +407,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->warn("Warning, setPlayerColor called on not 8bpp surface!");
}
TColorPutter CSDL_Ext::getPutterFor(SDL_Surface * const &dest, int incrementing)

View File

@ -762,7 +762,7 @@ void CMapHandler::CMapBlitter::drawObjects(SDL_Surface * targetSurf, const Terra
const CGObjectInstance * obj = object.obj;
if (!obj)
{
logGlobal->errorStream() << "Stray map object that isn't fading";
logGlobal->error("Stray map object that isn't fading");
continue;
}
@ -1164,7 +1164,7 @@ bool CMapHandler::startObjectFade(TerrainTileObject & obj, bool in, int3 pos)
{
if (objData.isMoving) // ignore fading of moving objects (for now?)
{
logAnim->debugStream() << "Ignoring fade of moving object";
logAnim->debug("Ignoring fade of moving object");
return false;
}

View File

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

View File

@ -550,7 +550,7 @@ CAdvMapInt::CAdvMapInt():
infoBar(Rect(ADVOPT.infoboxX, ADVOPT.infoboxY, 192, 192)), state(NA),
spellBeingCasted(nullptr), position(int3(0, 0, 0)), selection(nullptr),
updateScreen(false), anim(0), animValHitCount(0), heroAnim(0), heroAnimValHitCount(0),
activeMapPanel(nullptr), duringAITurn(false), scrollingDir(0), scrollingState(false),
activeMapPanel(nullptr), duringAITurn(false), scrollingDir(0), scrollingState(false),
swipeEnabled(settings["general"]["swipe"].Bool()), swipeMovementRequested(false),
swipeTargetPosition(int3(-1, -1, -1))
{
@ -1044,7 +1044,7 @@ void CAdvMapInt::show(SDL_Surface * to)
int3 betterPos = LOCPLINT->repairScreenPos(position);
if (betterPos != position)
{
logGlobal->warnStream() << "Incorrect position for adventure map!";
logGlobal->warn("Incorrect position for adventure map!");
position = betterPos;
}

View File

@ -502,7 +502,7 @@ void CCastleBuildings::recreate()
{
auto bayPos = town->bestLocation();
if(!bayPos.valid())
logGlobal->warnStream() << "Shipyard in non-coastal town!";
logGlobal->warn("Shipyard in non-coastal town!");
std::vector <const CGObjectInstance *> vobjs = LOCPLINT->cb->getVisitableObjs(bayPos, false);
//there is visitable obj at shipyard output tile and it's a boat or hero (on boat)
if(!vobjs.empty() && (vobjs.front()->ID == Obj::BOAT || vobjs.front()->ID == Obj::HERO))

View File

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

View File

@ -1493,7 +1493,7 @@ bool CAltarWindow::putOnAltar(CTradeableItem* altarSlot, const CArtifactInstance
{
if(!art->artType->isTradable()) //special art
{
logGlobal->warnStream() << "Cannot put special artifact on altar!";
logGlobal->warn("Cannot put special artifact on altar!");
return false;
}
@ -1502,7 +1502,7 @@ bool CAltarWindow::putOnAltar(CTradeableItem* altarSlot, const CArtifactInstance
int slotIndex = firstFreeSlot();
if(slotIndex < 0)
{
logGlobal->warnStream() << "No free slots on altar!";
logGlobal->warn("No free slots on altar!");
return false;
}
altarSlot = items[0][slotIndex];

View File

@ -1459,7 +1459,7 @@ void CArtifactSet::serializeJsonSlot(JsonSerializeFormat & handler, const Artifa
}
else
{
logGlobal->debugStream() << "Artifact can't be put at the specified location."; //TODO add more debugging information
logGlobal->debug("Artifact can't be put at the specified location."); //TODO add more debugging information
}
}
}

View File

@ -56,7 +56,7 @@ void printWinError()
int error = GetLastError();
if(!error)
{
logGlobal->errorStream() << "No Win error information set.";
logGlobal->error("No Win error information set.");
return;
}
logGlobal->errorStream() << "Error " << error << " encountered:";
@ -106,7 +106,7 @@ const char* exceptionName(DWORD exc)
LONG WINAPI onUnhandledException(EXCEPTION_POINTERS* exception)
{
logGlobal->errorStream() << "Disaster happened.";
logGlobal->error("Disaster happened.");
PEXCEPTION_RECORD einfo = exception->ExceptionRecord;
logGlobal->errorStream() << "Reason: 0x" << std::hex << einfo->ExceptionCode << " - " << exceptionName(einfo->ExceptionCode)
@ -242,10 +242,10 @@ CConsoleHandler::CConsoleHandler() : thread(nullptr)
}
CConsoleHandler::~CConsoleHandler()
{
logGlobal->infoStream() << "Killing console...";
logGlobal->info("Killing console...");
end();
delete cb;
logGlobal->infoStream() << "Killing console... done!";
logGlobal->info("Killing console... done!");
}
void CConsoleHandler::end()
{

View File

@ -50,7 +50,7 @@ bool CCreatureSet::setCreature(SlotID slot, CreatureID type, TQuantity quantity)
}
if(!quantity)
{
logGlobal->warnStream() << "Using set creature to delete stack?";
logGlobal->warn("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->error("Failed adding to slot!");
}
}

View File

@ -833,7 +833,7 @@ void CGameState::initNewGame(bool allowSavingRandomMap)
}
}
logGlobal->infoStream() << boost::format("Generated random map in %i ms.") % sw.getDiff();
logGlobal->info("Generated random map in %i ms.", sw.getDiff());
}
else
{

View File

@ -274,9 +274,9 @@ bool CIdentifierStorage::resolveIdentifier(const ObjectCallback & request)
// error found. Try to generate some debug info
if (identifiers.size() == 0)
logGlobal->errorStream() << "Unknown identifier!";
logGlobal->error("Unknown identifier!");
else
logGlobal->errorStream() << "Ambiguous identifier request!";
logGlobal->error("Ambiguous identifier request!");
logGlobal->errorStream() << "Request for " << request.type << "." << request.name << " from mod " << request.localScope;
@ -304,7 +304,7 @@ void CIdentifierStorage::finalize()
{
logGlobal->traceStream() << object.second.scope << " : " << object.first << " -> " << object.second.id;
}
logGlobal->errorStream() << "All known identifiers were dumped into log file";
logGlobal->error("All known identifiers were dumped into log file");
}
assert(errorsFound == false);
state = FINISHED;
@ -661,7 +661,7 @@ bool CModHandler::hasCircularDependency(TModID modID, std::set <TModID> currentL
// Mod already present? We found a loop
if (vstd::contains(currentList, modID))
{
logGlobal->errorStream() << "Error: Circular dependency detected! Printing dependency list:";
logGlobal->error("Error: Circular dependency detected! Printing dependency list:");
logGlobal->errorStream() << "\t" << mod.name << " -> ";
return true;
}

View File

@ -51,7 +51,7 @@ CPathfinder::CPathfinder(CPathsInfo & _out, CGameState * _gs, const CGHeroInstan
out.hpos = hero->getPosition(false);
if(!isInTheMap(out.hpos)/* || !gs->map->isInTheMap(dest)*/) //check input
{
logGlobal->errorStream() << "CGameState::calculatePaths: Hero outside the gs->map? How dare you...";
logGlobal->error("CGameState::calculatePaths: Hero outside the gs->map? How dare you...");
throw std::runtime_error("Wrong checksum");
}

View File

@ -748,7 +748,7 @@ void CTownHandler::loadObject(std::string scope, std::string name, const JsonNod
auto & advMap = data["town"]["adventureMap"];
if (!advMap.isNull())
{
logGlobal->warnStream() << "Outdated town mod. Will try to generate valid templates out of fort";
logGlobal->warn("Outdated town mod. Will try to generate valid templates out of fort");
JsonNode config;
config["animation"] = advMap["castle"];
VLC->objtypeh->getHandlerFor(index, object->index)->addTemplate(config);

View File

@ -1422,7 +1422,7 @@ int CreatureAlignmentLimiter::limit(const BonusLimitationContext &context) const
case EAlignment::EVIL:
return !c->isEvil();
default:
logBonus->warnStream() << "Warning: illegal alignment in limiter!";
logBonus->warn("Warning: illegal alignment in limiter!");
return true;
}
}

View File

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

View File

@ -465,7 +465,7 @@ void JsonUtils::resolveIdentifier(const JsonNode &node, si32 &var)
});
break;
default:
logGlobal->errorStream() << "Error! Wrong identifier used for identifier!";
logGlobal->error("Error! Wrong identifier used for identifier!");
}
}
@ -531,7 +531,7 @@ bool JsonUtils::parseBonus(const JsonNode &ability, Bonus *b)
}
break;
default:
logGlobal->errorStream() << "Error! Wrong bonus duration format.";
logGlobal->error("Error! Wrong bonus duration format.");
}
}

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->warn("Warning! Attempt to add duplicated quest");
}
DLL_LINKAGE void UpdateArtHandlerLists::applyGs(CGameState *gs)
@ -804,7 +804,7 @@ DLL_LINKAGE const CArtifactInstance *ArtifactLocation::getArt() const
return s->artifact;
else
{
logNetwork->warnStream() << "ArtifactLocation::getArt: This location is locked!";
logNetwork->warn("ArtifactLocation::getArt: This location is locked!");
return nullptr;
}
}
@ -895,7 +895,7 @@ DLL_LINKAGE void RebalanceStacks::applyGs(CGameState *gs)
//else - artifact cna be lost :/
else
{
logNetwork->warnStream() << "Artifact is present at destination slot!";
logNetwork->warn("Artifact is present at destination slot!");
}
artHere->move (alHere, alDest);
//TODO: choose from dialog
@ -1078,7 +1078,7 @@ DLL_LINKAGE void SetAvailableArtifacts::applyGs(CGameState *gs)
}
else
{
logNetwork->errorStream() << "Wrong black market id!";
logNetwork->error("Wrong black market id!");
}
}
else
@ -1162,7 +1162,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->error("Wrong object ID - property cannot be set!");
return;
}
@ -1560,7 +1560,7 @@ DLL_LINKAGE void SetStackEffect::applyGs(CGameState *gs)
{
if(effect.empty() && cumulativeEffects.empty())
{
logGlobal->errorStream() << "Trying to apply SetStackEffect with no effects";
logGlobal->error("Trying to apply SetStackEffect with no effects");
return;
}
@ -1788,7 +1788,7 @@ DLL_LINKAGE void BattleStackAdded::applyGs(CGameState *gs)
newStackID = 0;
if(!BattleHex(pos).isValid())
{
logNetwork->warnStream() << "No place found for new stack!";
logNetwork->warn("No place found for new stack!");
return;
}

View File

@ -108,7 +108,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastSpell(con
return ESpellCastProblem::INVALID;
if(!battleDoWeKnowAbout(side.get()))
{
logGlobal->warnStream() << "You can't check if enemy can cast given spell!";
logGlobal->warn("You can't check if enemy can cast given spell!");
return ESpellCastProblem::INVALID;
}

View File

@ -141,11 +141,11 @@ bool CFilesystemList::createResource(std::string filename, bool update)
// b) in update mode, call with filename that does not exists
assert(load(ResourceID(filename)));
logGlobal->traceStream()<< "Resource created successfully";
logGlobal->trace("Resource created successfully");
return true;
}
}
logGlobal->traceStream()<< "Failed to create resource";
logGlobal->trace("Failed to create resource");
return false;
}

View File

@ -71,7 +71,7 @@ template <class _Stream> inline int streamProxyClose(voidpf opaque, voidpf strea
_Stream * actualStream = static_cast<_Stream *>(stream);
logGlobal->traceStream() << "Proxy stream closed";
logGlobal->trace("Proxy stream closed");
actualStream->seek(0);
@ -229,7 +229,7 @@ uLong ZCALLBACK CProxyROIOApi::readFileProxy(voidpf opaque, voidpf stream, void
uLong ZCALLBACK CProxyROIOApi::writeFileProxy(voidpf opaque, voidpf stream, const void* buf, uLong size)
{
logGlobal->errorStream() << "Attempt to write to read-only stream";
logGlobal->error("Attempt to write to read-only stream");
return 0;
}

View File

@ -740,7 +740,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->warn("Primary skill specialty growth supported only with creature type limiters");
break;
}

View File

@ -308,7 +308,7 @@ void CGUniversity::initObj(CRandomGenerator & rand)
}
if(toChoose.size() < 4)
{
logGlobal->warnStream()<<"Warning: less then 4 available skills was found by University initializer!";
logGlobal->warn("Warning: less then 4 available skills was found by University initializer!");
return;
}

View File

@ -1155,7 +1155,7 @@ void CGTownInstance::setVisitingHero(CGHeroInstance *h)
//if (!(!!visitingHero == !h))
//{
// logGlobal->warnStream() << boost::format("Hero visiting town %s is %s ") % name % (visitingHero.get() ? visitingHero->name : "NULL");
// logGlobal->warnStream() << boost::format("New hero will be %s ") % (h ? h->name : "NULL");
// logGlobal->warn("New hero will be %s ", (h ? h->name : "NULL"));
//
//}
assert(!!visitingHero == !h);

View File

@ -110,13 +110,13 @@ void IObjectInterface::heroLevelUpDone(const CGHeroInstance *hero) const
CObjectHandler::CObjectHandler()
{
logGlobal->traceStream() << "\t\tReading resources prices ";
logGlobal->trace("\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->trace("\t\tDone loading resource prices!");
}
PlayerColor CGObjectInstance::getOwner() const

View File

@ -179,7 +179,7 @@ void CRewardableObject::onHeroVisit(const CGHeroInstance *h) const
}
else
{
logGlobal->debugStream() << "Revisiting already visited object";
logGlobal->debug("Revisiting already visited object");
InfoWindow iw;
iw.player = h->tempOwner;
iw.soundID = soundID;

View File

@ -1579,7 +1579,7 @@ void CGShrine::onHeroVisit( const CGHeroInstance * h ) const
{
if(spell == SpellID::NONE)
{
logGlobal->errorStream() << "Not initialized shrine visited!";
logGlobal->error("Not initialized shrine visited!");
return;
}
@ -1627,7 +1627,7 @@ void CGShrine::initObj(CRandomGenerator & rand)
if(possibilities.empty())
{
logGlobal->errorStream() << "Error: cannot init shrine, no allowed spells!";
logGlobal->error("Error: cannot init shrine, no allowed spells!");
return;
}
@ -2023,7 +2023,7 @@ void CCartographer::onHeroVisit( const CGHeroInstance * h ) const
text = 27;
break;
default:
logGlobal->warnStream() << "Unrecognized subtype of cartographer";
logGlobal->warn("Unrecognized subtype of cartographer");
}
assert(text);
BlockingDialog bd (true, false);

View File

@ -258,7 +258,7 @@ void ObjectTemplate::readJson(const JsonNode &node, const bool withTerrain)
}
if(withTerrain && allowedTerrains.empty())
logGlobal->warnStream() << "Loaded template without allowed terrains!";
logGlobal->warn("Loaded template without allowed terrains!");
auto charToTile = [&](const char & ch) -> ui8
@ -507,7 +507,7 @@ int3 ObjectTemplate::getVisitableOffset() const
if (isVisitableAt(x, y))
return int3(x,y,0);
//logGlobal->warnStream() << "Warning: getVisitableOffset called on non-visitable obj!";
//logGlobal->warn("Warning: getVisitableOffset called on non-visitable obj!");
return int3(0,0,0);
}

View File

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

View File

@ -489,7 +489,7 @@ const CGObjectInstance * CMap::getObjectiveObjectFrom(int3 pos, Obj::EObj type)
// Try to workaround that and find closest object that we can use
logGlobal->errorStream() << "Failed to find object of type " << int(type) << " at " << pos;
logGlobal->errorStream() << "Will try to find closest matching object";
logGlobal->error("Will try to find closest matching object");
CGObjectInstance * bestMatch = nullptr;
for (CGObjectInstance * object : objects)

View File

@ -648,7 +648,7 @@ void CDrawTerrainOperation::updateTerrainTypes()
{
//if(!suitableTiles.empty())
//{
// logGlobal->debugStream() << "Clear suitables tiles.";
// logGlobal->debug("Clear suitables tiles.");
//}
invalidNativeTilesCnt = nativeTilesCntNorm;
@ -730,7 +730,7 @@ void CDrawTerrainOperation::updateTerrainViews()
if(bestPattern == -1)
{
// This shouldn't be the case
logGlobal->warnStream() << boost::format("No pattern detected at pos '%s'.") % pos;
logGlobal->warn("No pattern detected at pos '%s'.", pos);
CTerrainViewPatternUtils::printDebuggingInfoAboutTile(map, pos);
continue;
}

View File

@ -876,13 +876,13 @@ bool CMapLoaderH3M::loadArtifactToSlot(CGHeroInstance * hero, int slot)
if(nullptr == art)
{
logGlobal->warnStream() << "Invalid artifact in hero's backpack, ignoring...";
logGlobal->warn("Invalid artifact in hero's backpack, ignoring...");
return false;
}
if(art->isBig() && slot >= GameConstants::BACKPACK_START)
{
logGlobal->warnStream() << "A big artifact (war machine) in hero's backpack, ignoring...";
logGlobal->warn("A big artifact (war machine) in hero's backpack, ignoring...");
return false;
}
if(aid == 0 && slot == ArtifactPosition::MISC5)
@ -902,7 +902,7 @@ bool CMapLoaderH3M::loadArtifactToSlot(CGHeroInstance * hero, int slot)
}
else
{
logGlobal->debugStream() << "Artifact can't be put at the specified location."; //TODO add more debugging information
logGlobal->debug("Artifact can't be put at the specified location."); //TODO add more debugging information
}
}

View File

@ -524,7 +524,7 @@ void CMapFormatJson::readTeams(JsonDeserializer & handler)
{
// No alliances
if(src.getType() != JsonNode::DATA_NULL)
logGlobal->errorStream() << "Invalid teams field type";
logGlobal->error("Invalid teams field type");
mapHeader->howManyTeams = 0;
for(int i = 0; i < PlayerColor::PLAYER_LIMIT_I; i++)
@ -1061,7 +1061,7 @@ void CMapLoaderJson::MapObjectLoader::construct()
std::string typeName = configuration["type"].String(), subtypeName = configuration["subtype"].String();
if(typeName.empty())
{
logGlobal->errorStream() << "Object type missing";
logGlobal->error("Object type missing");
logGlobal->debugStream() << configuration;
return;
}
@ -1081,7 +1081,7 @@ void CMapLoaderJson::MapObjectLoader::construct()
}
else if(subtypeName.empty())
{
logGlobal->errorStream() << "Object subtype missing";
logGlobal->error("Object subtype missing");
logGlobal->debugStream() << configuration;
return;
}

View File

@ -270,7 +270,7 @@ void CMapGenOptions::finalize(CRandomGenerator & rand)
//setHeight(20);
//setWidth(50);
logGlobal->traceStream() << "Player config:";
logGlobal->trace("Player config:");
int humanPlayers = 0, cpuOnlyPlayers = 0, AIplayers = 0;
for (auto player : players)
{
@ -378,7 +378,7 @@ PlayerColor CMapGenOptions::getNextPlayerColor() const
return i;
}
}
logGlobal->errorStream() << "Failed to get next player color";
logGlobal->error("Failed to get next player color");
assert(false);
return PlayerColor(0);
}

View File

@ -253,7 +253,7 @@ void CMapGenerator::addPlayerInfo()
if (teamNumbers[j].empty())
{
logGlobal->errorStream() << boost::format("Not enough places in team for %s player") % ((j == CPUONLY) ? "CPU" : "CPU or human");
logGlobal->error("Not enough places in team for %s player", ((j == CPUONLY) ? "CPU" : "CPU or human"));
assert (teamNumbers[j].size());
}
auto itTeam = RandomGeneratorUtil::nextItem(teamNumbers[j], rand);
@ -279,7 +279,7 @@ void CMapGenerator::genZones()
placer.placeZones(mapGenOptions, &rand);
placer.assignZones(mapGenOptions);
logGlobal->infoStream() << "Zones generated successfully";
logGlobal->info("Zones generated successfully");
}
void CMapGenerator::fillZones()
@ -290,7 +290,7 @@ void CMapGenerator::fillZones()
findZonesForQuestArts();
logGlobal->infoStream() << "Started filling zones";
logGlobal->info("Started filling zones");
//we need info about all town types to evaluate dwellings and pandoras with creatures properly
//place main town in the middle
@ -378,7 +378,7 @@ void CMapGenerator::fillZones()
map->grailPos = *RandomGeneratorUtil::nextItem(*grailZone->getFreePaths(), rand);
logGlobal->infoStream() << "Zones filled successfully";
logGlobal->info("Zones filled successfully");
}
void CMapGenerator::createObstaclesCommon1()

View File

@ -637,7 +637,7 @@ void CRmgTemplateZone::connectLater(CMapGenerator* gen)
for (const int3 node : tilesToConnectLater)
{
if (!connectWithCenter(gen, node, true))
logGlobal->errorStream() << boost::format("Failed to connect node %s with center of the zone") % node;
logGlobal->error("Failed to connect node %s with center of the zone", node);
}
}
@ -788,7 +788,7 @@ bool CRmgTemplateZone::createRoad(CMapGenerator* gen, const int3& src, const int
// add node to path
roads.insert (backTracking);
gen->setRoad (backTracking, ERoadType::COBBLESTONE_ROAD);
//logGlobal->traceStream() << boost::format("Setting road at tile %s") % backTracking;
//logGlobal->trace("Setting road at tile %s", backTracking);
// do the same for the predecessor
backTracking = cameFrom[backTracking];
}
@ -1386,7 +1386,7 @@ void CRmgTemplateZone::initTownType (CMapGenerator* gen)
if ((type == ETemplateZoneType::CPU_START) || (type == ETemplateZoneType::PLAYER_START))
{
//set zone types to player faction, generate main town
logGlobal->infoStream() << "Preparing playing zone";
logGlobal->info("Preparing playing zone");
int player_id = *owner - 1;
auto & playerInfo = gen->map->players[player_id];
PlayerColor player(player_id);
@ -1577,12 +1577,12 @@ EObjectPlacingResult::EObjectPlacingResult CRmgTemplateZone::tryToPlaceObjectAnd
int3 accessibleOffset = getAccessibleOffset(gen, obj->appearance, pos);
if (!accessibleOffset.valid())
{
logGlobal->warnStream() << boost::format("Cannot access required object at position %s, retrying") % pos;
logGlobal->warn("Cannot access required object at position %s, retrying", pos);
return EObjectPlacingResult::CANNOT_FIT;
}
if (!connectPath(gen, accessibleOffset, true))
{
logGlobal->traceStream() << boost::format("Failed to create path to required object at position %s, retrying") % pos;
logGlobal->trace("Failed to create path to required object at position %s, retrying", pos);
return EObjectPlacingResult::SEALED_OFF;
}
else
@ -1591,7 +1591,7 @@ EObjectPlacingResult::EObjectPlacingResult CRmgTemplateZone::tryToPlaceObjectAnd
bool CRmgTemplateZone::createRequiredObjects(CMapGenerator* gen)
{
logGlobal->traceStream() << "Creating required objects";
logGlobal->trace("Creating required objects");
for(const auto &object : requiredObjects)
{
@ -1601,7 +1601,7 @@ bool CRmgTemplateZone::createRequiredObjects(CMapGenerator* gen)
{
if (!findPlaceForObject(gen, obj, 3, pos))
{
logGlobal->errorStream() << boost::format("Failed to fill zone %d due to lack of space") % id;
logGlobal->error("Failed to fill zone %d due to lack of space", id);
return false;
}
if (tryToPlaceObjectAndConnectToPath(gen, obj, pos) == EObjectPlacingResult::SUCCESS)
@ -1646,7 +1646,7 @@ bool CRmgTemplateZone::createRequiredObjects(CMapGenerator* gen)
if (tiles.empty())
{
logGlobal->errorStream() << boost::format("Failed to fill zone %d due to lack of space") % id;
logGlobal->error("Failed to fill zone %d due to lack of space", id);
return false;
}
for (auto tile : tiles)
@ -2195,11 +2195,11 @@ bool CRmgTemplateZone::guardObject(CMapGenerator* gen, CGObjectInstance* object,
{
//guardTile = tiles.front();
guardTile = getAccessibleOffset(gen, object->appearance, object->pos);
logGlobal->traceStream() << boost::format("Guard object at %s") % object->pos();
logGlobal->trace("Guard object at %s", object->pos());
}
else
{
logGlobal->errorStream() << boost::format("Failed to guard object at %s") % object->pos();
logGlobal->error("Failed to guard object at %s", object->pos());
return false;
}

View File

@ -47,7 +47,7 @@ float CZonePlacer::getDistance (float distance) const
void CZonePlacer::placeZones(const CMapGenOptions * mapGenOptions, CRandomGenerator * rand)
{
logGlobal->infoStream() << "Starting zone placement";
logGlobal->info("Starting zone placement");
width = mapGenOptions->getWidth();
height = mapGenOptions->getHeight();
@ -184,7 +184,7 @@ void CZonePlacer::prepareZones(TZoneMap &zones, TZoneVector &zonesVector, const
if (vstd::contains(playerSettings, player))
faction = playerSettings[player].getStartingTown();
else
logGlobal->errorStream() << boost::format("Can't find info for player %d (starting zone)") % player.getNum();
logGlobal->error("Can't find info for player %d (starting zone)", player.getNum());
if (faction == CMapGenOptions::CPlayerSettings::RANDOM_TOWN) //TODO: check this after a town has already been randomized
zonesToPlace.push_back(zone);
@ -375,7 +375,7 @@ void CZonePlacer::moveOneZone(TZoneMap &zones, TForceVector &totalForces, TDista
misplacedZone = zone.first;
}
}
logGlobal->traceStream() << boost::format("Worst misplacement/movement ratio: %3.2f") % maxRatio;
logGlobal->trace("Worst misplacement/movement ratio: %3.2f", maxRatio);
if (maxRatio > maxDistanceMovementRatio && misplacedZone)
{
@ -402,10 +402,10 @@ void CZonePlacer::moveOneZone(TZoneMap &zones, TForceVector &totalForces, TDista
float newDistanceBetweenZones = (std::max(misplacedZone->getSize(), targetZone->getSize())) / mapSize;
logGlobal->traceStream() << boost::format("Trying to move zone %d %s towards %d %s. Old distance %f") %
misplacedZone->getId() % ourCenter() % targetZone->getId() % targetZone->getCenter()() % maxDistance;
logGlobal->traceStream() << boost::format("direction is %s") % vec();
logGlobal->trace("direction is %s", vec());
misplacedZone->setCenter(targetZone->getCenter() - vec.unitVector() * newDistanceBetweenZones); //zones should now overlap by half size
logGlobal->traceStream() << boost::format("New distance %f") % targetZone->getCenter().dist2d(misplacedZone->getCenter());
logGlobal->trace("New distance %f", targetZone->getCenter().dist2d(misplacedZone->getCenter()));
}
}
else
@ -431,10 +431,10 @@ void CZonePlacer::moveOneZone(TZoneMap &zones, TForceVector &totalForces, TDista
float newDistanceBetweenZones = (misplacedZone->getSize() + targetZone->getSize()) / mapSize;
logGlobal->traceStream() << boost::format("Trying to move zone %d %s away from %d %s. Old distance %f") %
misplacedZone->getId() % ourCenter() % targetZone->getId() % targetZone->getCenter()() % maxOverlap;
logGlobal->traceStream() << boost::format("direction is %s") % vec();
logGlobal->trace("direction is %s", vec());
misplacedZone->setCenter(targetZone->getCenter() + vec.unitVector() * newDistanceBetweenZones); //zones should now be just separated
logGlobal->traceStream() << boost::format("New distance %f") % targetZone->getCenter().dist2d(misplacedZone->getCenter());
logGlobal->trace("New distance %f", targetZone->getCenter().dist2d(misplacedZone->getCenter()));
}
}
}
@ -462,7 +462,7 @@ d = 0.01 * dx^3 - 0.1618 * dx^2 + 1 * dx + ...
void CZonePlacer::assignZones(const CMapGenOptions * mapGenOptions)
{
logGlobal->infoStream() << "Starting zone colouring";
logGlobal->info("Starting zone colouring");
auto width = mapGenOptions->getWidth();
auto height = mapGenOptions->getHeight();
@ -571,5 +571,5 @@ void CZonePlacer::assignZones(const CMapGenOptions * mapGenOptions)
zone.second->paintZoneTerrain (gen, ETerrainType::SUBTERRANEAN);
}
}
logGlobal->infoStream() << "Finished zone colouring";
logGlobal->info("Finished zone colouring");
}

View File

@ -81,7 +81,7 @@ void CLoadFile::openNextFile(const boost::filesystem::path & fname, int minimalV
void CLoadFile::reportState(CLogger * out)
{
out->debugStream() << "CLoadFile";
out->debug("CLoadFile");
if(!!sfile && *sfile)
{
out->debugStream() << "\tOpened " << fName << "\n\tPosition: " << sfile->tellg();

View File

@ -55,7 +55,7 @@ void CSaveFile::openNextFile(const boost::filesystem::path &fname)
void CSaveFile::reportState(CLogger * out)
{
out->debugStream() << "CSaveFile";
out->debug("CSaveFile");
if(sfile.get() && *sfile)
{
out->debugStream() << "\tOpened " << fName << "\n\tPosition: " << sfile->tellp();

View File

@ -75,10 +75,10 @@ CConnection::CConnection(std::string host, ui16 port, std::string Name)
}
pom = endpoint_iterator;
if(pom != end)
logNetwork->infoStream()<<"Found endpoints:";
logNetwork->info("Found endpoints:");
else
{
logNetwork->errorStream() << "Critical problem: No endpoints found!";
logNetwork->error("Critical problem: No endpoints found!");
goto connerror1;
}
i=0;
@ -106,11 +106,11 @@ CConnection::CConnection(std::string host, ui16 port, std::string Name)
//we shouldn't be here - error handling
connerror1:
logNetwork->errorStream() << "Something went wrong... checking for error info";
logNetwork->error("Something went wrong... checking for error info");
if(error)
logNetwork->errorStream() << error;
else
logNetwork->errorStream() << "No error info. ";
logNetwork->error("No error info. ");
delete io_service;
//delete socket;
throw std::runtime_error("Can't establish connection :(");
@ -206,10 +206,10 @@ bool CConnection::isHost() const
void CConnection::reportState(CLogger * out)
{
out->debugStream() << "CConnection";
out->debug("CConnection");
if(socket && socket->is_open())
{
out->debugStream() << "\tWe have an open and valid socket";
out->debug("\tWe have an open and valid socket");
out->debugStream() << "\t" << socket->available() <<" bytes awaiting";
}
}
@ -218,7 +218,7 @@ CPack * CConnection::retreivePack()
{
CPack *ret = nullptr;
boost::unique_lock<boost::mutex> lock(*rmx);
logNetwork->traceStream() << "Listening... ";
logNetwork->trace("Listening... ");
iser & ret;
logNetwork->traceStream() << "\treceived server message of type " << (ret? typeid(*ret).name() : "nullptr") << ", data: " << ret;
return ret;