mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
More logging cleanup
This commit is contained in:
parent
7bdcd209e6
commit
1c292205df
@ -105,7 +105,7 @@ std::shared_ptr<rett> createAny(const boost::filesystem::path& libpath, const st
|
|||||||
std::shared_ptr<rett> ret;
|
std::shared_ptr<rett> ret;
|
||||||
getAI(ret);
|
getAI(ret);
|
||||||
if(!ret)
|
if(!ret)
|
||||||
logGlobal->errorStream() << "Cannot get AI!";
|
logGlobal->error("Cannot get AI!");
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -490,12 +490,12 @@ int CGameState::pickUnusedHeroTypeRandomly(PlayerColor owner)
|
|||||||
return RandomGeneratorUtil::nextItem(otherHeroes, rand)->getNum();
|
return RandomGeneratorUtil::nextItem(otherHeroes, rand)->getNum();
|
||||||
}
|
}
|
||||||
|
|
||||||
logGlobal->errorStream() << "No free allowed heroes!";
|
logGlobal->error("No free allowed heroes!");
|
||||||
auto notAllowedHeroesButStillBetterThanCrash = getUnusedAllowedHeroes(true);
|
auto notAllowedHeroesButStillBetterThanCrash = getUnusedAllowedHeroes(true);
|
||||||
if(notAllowedHeroesButStillBetterThanCrash.size())
|
if(notAllowedHeroesButStillBetterThanCrash.size())
|
||||||
return notAllowedHeroesButStillBetterThanCrash.begin()->getNum();
|
return notAllowedHeroesButStillBetterThanCrash.begin()->getNum();
|
||||||
|
|
||||||
logGlobal->errorStream() << "No free heroes at all!";
|
logGlobal->error("No free heroes at all!");
|
||||||
assert(0); //current code can't handle this situation
|
assert(0); //current code can't handle this situation
|
||||||
return -1; // no available heroes at all
|
return -1; // no available heroes at all
|
||||||
}
|
}
|
||||||
@ -769,13 +769,13 @@ void CGameState::init(StartInfo * si)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
VLC->arth->initAllowedArtifactsList(map->allowedArtifact);
|
VLC->arth->initAllowedArtifactsList(map->allowedArtifact);
|
||||||
logGlobal->infoStream() << "Map loaded!";
|
logGlobal->info("Map loaded!");
|
||||||
|
|
||||||
checkMapChecksum();
|
checkMapChecksum();
|
||||||
|
|
||||||
day = 0;
|
day = 0;
|
||||||
|
|
||||||
logGlobal->debugStream() << "Initialization:";
|
logGlobal->debug("Initialization:");
|
||||||
|
|
||||||
initPlayerStates();
|
initPlayerStates();
|
||||||
placeCampaignHeroes();
|
placeCampaignHeroes();
|
||||||
@ -792,7 +792,7 @@ void CGameState::init(StartInfo * si)
|
|||||||
initVisitingAndGarrisonedHeroes();
|
initVisitingAndGarrisonedHeroes();
|
||||||
initFogOfWar();
|
initFogOfWar();
|
||||||
|
|
||||||
logGlobal->debugStream() << "\tChecking objectives";
|
logGlobal->debug("\tChecking objectives");
|
||||||
map->checkForObjectives(); //needs to be run when all objects are properly placed
|
map->checkForObjectives(); //needs to be run when all objects are properly placed
|
||||||
|
|
||||||
auto seedAfterInit = rand.nextInt();
|
auto seedAfterInit = rand.nextInt();
|
||||||
@ -812,7 +812,7 @@ void CGameState::initNewGame()
|
|||||||
{
|
{
|
||||||
if(scenarioOps->createRandomMap())
|
if(scenarioOps->createRandomMap())
|
||||||
{
|
{
|
||||||
logGlobal->infoStream() << "Create random map.";
|
logGlobal->info("Create random map.");
|
||||||
CStopWatch sw;
|
CStopWatch sw;
|
||||||
|
|
||||||
// Gen map
|
// Gen map
|
||||||
@ -874,7 +874,7 @@ void CGameState::initDuel()
|
|||||||
{
|
{
|
||||||
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);
|
dp = DuelParameters::fromJSON(scenarioOps->mapname);
|
||||||
logGlobal->infoStream() << "JSON file has been successfully read!";
|
logGlobal->info("JSON file has been successfully read!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -974,7 +974,7 @@ void CGameState::checkMapChecksum()
|
|||||||
logGlobal->infoStream() << "\tServer checksum for " << scenarioOps->mapname <<": "<< scenarioOps->mapfileChecksum;
|
logGlobal->infoStream() << "\tServer checksum for " << scenarioOps->mapname <<": "<< scenarioOps->mapfileChecksum;
|
||||||
if(map->checksum != scenarioOps->mapfileChecksum)
|
if(map->checksum != scenarioOps->mapfileChecksum)
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Wrong map checksum!!!";
|
logGlobal->error("Wrong map checksum!!!");
|
||||||
throw std::runtime_error("Wrong checksum");
|
throw std::runtime_error("Wrong checksum");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -986,7 +986,7 @@ void CGameState::checkMapChecksum()
|
|||||||
|
|
||||||
void CGameState::initGrailPosition()
|
void CGameState::initGrailPosition()
|
||||||
{
|
{
|
||||||
logGlobal->debugStream() << "\tPicking grail position";
|
logGlobal->debug("\tPicking grail position");
|
||||||
//pick grail location
|
//pick grail location
|
||||||
if(map->grailPos.x < 0 || map->grailRadius) //grail not set or set within a radius around some place
|
if(map->grailPos.x < 0 || map->grailRadius) //grail not set or set within a radius around some place
|
||||||
{
|
{
|
||||||
@ -1025,14 +1025,14 @@ void CGameState::initGrailPosition()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "Warning: Grail cannot be placed, no appropriate tile found!";
|
logGlobal->warn("Grail cannot be placed, no appropriate tile found!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameState::initRandomFactionsForPlayers()
|
void CGameState::initRandomFactionsForPlayers()
|
||||||
{
|
{
|
||||||
logGlobal->debugStream() << "\tPicking random factions for players";
|
logGlobal->debug("\tPicking random factions for players");
|
||||||
for(auto & elem : scenarioOps->playerInfos)
|
for(auto & elem : scenarioOps->playerInfos)
|
||||||
{
|
{
|
||||||
if(elem.second.castle==-1)
|
if(elem.second.castle==-1)
|
||||||
@ -1048,7 +1048,7 @@ void CGameState::initRandomFactionsForPlayers()
|
|||||||
|
|
||||||
void CGameState::randomizeMapObjects()
|
void CGameState::randomizeMapObjects()
|
||||||
{
|
{
|
||||||
logGlobal->debugStream() << "\tRandomizing objects";
|
logGlobal->debug("\tRandomizing objects");
|
||||||
for(CGObjectInstance *obj : map->objects)
|
for(CGObjectInstance *obj : map->objects)
|
||||||
{
|
{
|
||||||
if(!obj) continue;
|
if(!obj) continue;
|
||||||
@ -1072,7 +1072,7 @@ void CGameState::randomizeMapObjects()
|
|||||||
|
|
||||||
void CGameState::initPlayerStates()
|
void CGameState::initPlayerStates()
|
||||||
{
|
{
|
||||||
logGlobal->debugStream() << "\tCreating player entries in gs";
|
logGlobal->debug("\tCreating player entries in gs");
|
||||||
for(auto & elem : scenarioOps->playerInfos)
|
for(auto & elem : scenarioOps->playerInfos)
|
||||||
{
|
{
|
||||||
std::pair<PlayerColor, PlayerState> ins(elem.first,PlayerState());
|
std::pair<PlayerColor, PlayerState> ins(elem.first,PlayerState());
|
||||||
@ -1114,10 +1114,10 @@ void CGameState::placeCampaignHeroes()
|
|||||||
|
|
||||||
if(!crossoverHeroes.heroesFromAnyPreviousScenarios.empty())
|
if(!crossoverHeroes.heroesFromAnyPreviousScenarios.empty())
|
||||||
{
|
{
|
||||||
logGlobal->debugStream() << "\tGenerate list of hero placeholders";
|
logGlobal->debug("\tGenerate list of hero placeholders");
|
||||||
auto campaignHeroReplacements = generateCampaignHeroesToReplace(crossoverHeroes);
|
auto campaignHeroReplacements = generateCampaignHeroesToReplace(crossoverHeroes);
|
||||||
|
|
||||||
logGlobal->debugStream() << "\tPrepare crossover heroes";
|
logGlobal->debug("\tPrepare crossover heroes");
|
||||||
prepareCrossoverHeroes(campaignHeroReplacements, scenarioOps->campState->getCurrentScenario().travelOptions);
|
prepareCrossoverHeroes(campaignHeroReplacements, scenarioOps->campState->getCurrentScenario().travelOptions);
|
||||||
|
|
||||||
// remove same heroes on the map which will be added through crossover heroes
|
// remove same heroes on the map which will be added through crossover heroes
|
||||||
@ -1137,7 +1137,7 @@ void CGameState::placeCampaignHeroes()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logGlobal->debugStream() << "\tReplace placeholders with heroes";
|
logGlobal->debug("\tReplace placeholders with heroes");
|
||||||
replaceHeroesPlaceholders(campaignHeroReplacements);
|
replaceHeroesPlaceholders(campaignHeroReplacements);
|
||||||
|
|
||||||
// remove hero placeholders on map
|
// remove hero placeholders on map
|
||||||
@ -1169,7 +1169,7 @@ void CGameState::placeCampaignHeroes()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "No free hero type ID found to replace prison.";
|
logGlobal->error("No free hero type ID found to replace prison.");
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1365,7 +1365,7 @@ void CGameState::prepareCrossoverHeroes(std::vector<CGameState::CampaignHeroRepl
|
|||||||
|
|
||||||
void CGameState::placeStartingHeroes()
|
void CGameState::placeStartingHeroes()
|
||||||
{
|
{
|
||||||
logGlobal->debugStream() << "\tGiving starting hero";
|
logGlobal->debug("\tGiving starting hero");
|
||||||
|
|
||||||
for(auto & playerSettingPair : scenarioOps->playerInfos)
|
for(auto & playerSettingPair : scenarioOps->playerInfos)
|
||||||
{
|
{
|
||||||
@ -1393,7 +1393,7 @@ void CGameState::placeStartingHeroes()
|
|||||||
|
|
||||||
void CGameState::initStartingResources()
|
void CGameState::initStartingResources()
|
||||||
{
|
{
|
||||||
logGlobal->debugStream() << "\tSetting up resources";
|
logGlobal->debug("\tSetting up resources");
|
||||||
const JsonNode config(ResourceID("config/startres.json"));
|
const JsonNode config(ResourceID("config/startres.json"));
|
||||||
const JsonVector &vector = config["difficulty"].Vector();
|
const JsonVector &vector = config["difficulty"].Vector();
|
||||||
const JsonNode &level = vector[scenarioOps->difficulty];
|
const JsonNode &level = vector[scenarioOps->difficulty];
|
||||||
@ -1465,7 +1465,7 @@ void CGameState::initHeroes()
|
|||||||
{
|
{
|
||||||
if (hero->getOwner() == PlayerColor::UNFLAGGABLE)
|
if (hero->getOwner() == PlayerColor::UNFLAGGABLE)
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "Warning - hero with uninitialized owner!";
|
logGlobal->warn("Hero with uninitialized owner!");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1539,7 +1539,7 @@ void CGameState::initHeroes()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(maxB < 0)
|
if(maxB < 0)
|
||||||
logGlobal->warnStream() << "Warning - cannot give bonus to hero cause there are no heroes!";
|
logGlobal->warn("Cannot give bonus to hero cause there are no heroes!");
|
||||||
else
|
else
|
||||||
giveCampaignBonusToHero(heroes[maxB]);
|
giveCampaignBonusToHero(heroes[maxB]);
|
||||||
}
|
}
|
||||||
@ -1617,7 +1617,7 @@ void CGameState::giveCampaignBonusToHero(CGHeroInstance * hero)
|
|||||||
|
|
||||||
void CGameState::initFogOfWar()
|
void CGameState::initFogOfWar()
|
||||||
{
|
{
|
||||||
logGlobal->debugStream() << "\tFog of war"; //FIXME: should be initialized after all bonuses are set
|
logGlobal->debug("\tFog of war"); //FIXME: should be initialized after all bonuses are set
|
||||||
for(auto & elem : teams)
|
for(auto & elem : teams)
|
||||||
{
|
{
|
||||||
elem.second.fogOfWarMap.resize(map->width);
|
elem.second.fogOfWarMap.resize(map->width);
|
||||||
@ -1649,7 +1649,7 @@ void CGameState::initFogOfWar()
|
|||||||
|
|
||||||
void CGameState::initStartingBonus()
|
void CGameState::initStartingBonus()
|
||||||
{
|
{
|
||||||
logGlobal->debugStream() << "\tStarting bonuses";
|
logGlobal->debug("\tStarting bonuses");
|
||||||
for(auto & elem : players)
|
for(auto & elem : players)
|
||||||
{
|
{
|
||||||
//starting bonus
|
//starting bonus
|
||||||
@ -1679,7 +1679,7 @@ void CGameState::initStartingBonus()
|
|||||||
{
|
{
|
||||||
if(!elem.second.heroes.size())
|
if(!elem.second.heroes.size())
|
||||||
{
|
{
|
||||||
logGlobal->debugStream() << "Cannot give starting artifact - no heroes!";
|
logGlobal->error("Cannot give starting artifact - no heroes!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CArtifact *toGive;
|
CArtifact *toGive;
|
||||||
@ -1695,7 +1695,7 @@ void CGameState::initStartingBonus()
|
|||||||
|
|
||||||
void CGameState::initTowns()
|
void CGameState::initTowns()
|
||||||
{
|
{
|
||||||
logGlobal->debugStream() << "\tTowns";
|
logGlobal->debug("\tTowns");
|
||||||
|
|
||||||
//campaign bonuses for towns
|
//campaign bonuses for towns
|
||||||
if (scenarioOps->mode == StartInfo::CAMPAIGN)
|
if (scenarioOps->mode == StartInfo::CAMPAIGN)
|
||||||
@ -1846,7 +1846,7 @@ void CGameState::initTowns()
|
|||||||
|
|
||||||
void CGameState::initMapObjects()
|
void CGameState::initMapObjects()
|
||||||
{
|
{
|
||||||
logGlobal->debugStream() << "\tObject initialization";
|
logGlobal->debug("\tObject initialization");
|
||||||
// objCaller->preInit();
|
// objCaller->preInit();
|
||||||
for(CGObjectInstance *obj : map->objects)
|
for(CGObjectInstance *obj : map->objects)
|
||||||
{
|
{
|
||||||
|
@ -142,7 +142,7 @@ void Unicode::trimRight(std::string & text, const size_t amount/* =1 */)
|
|||||||
|
|
||||||
if(!isValidCharacter(&(*b),e-b))
|
if(!isValidCharacter(&(*b),e-b))
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Invalid UTF8 sequence";
|
logGlobal->error("Invalid UTF8 sequence");
|
||||||
break;//invalid sequence will be trimmed
|
break;//invalid sequence will be trimmed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ std::vector<BattleHex> CObstacleInfo::getBlocked(BattleHex hex) const
|
|||||||
toBlock += BattleHex::LEFT;
|
toBlock += BattleHex::LEFT;
|
||||||
|
|
||||||
if(!toBlock.isValid())
|
if(!toBlock.isValid())
|
||||||
logGlobal->errorStream() << "Misplaced obstacle!";
|
logGlobal->error("Misplaced obstacle!");
|
||||||
else
|
else
|
||||||
ret.push_back(toBlock);
|
ret.push_back(toBlock);
|
||||||
}
|
}
|
||||||
@ -577,7 +577,7 @@ ui64 CHeroHandler::reqExp (ui32 level) const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "A hero has reached unsupported amount of experience";
|
logGlobal->warn("A hero has reached unsupported amount of experience");
|
||||||
return expPerLevel[expPerLevel.size()-1];
|
return expPerLevel[expPerLevel.size()-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,11 +113,11 @@ CConnection::CConnection(std::string host, std::string port, std::string Name)
|
|||||||
|
|
||||||
//we shouldn't be here - error handling
|
//we shouldn't be here - error handling
|
||||||
connerror1:
|
connerror1:
|
||||||
logNetwork->errorStream() << "Something went wrong... checking for error info";
|
logNetwork->error("Something went wrong... checking for error info");
|
||||||
if(error)
|
if(error)
|
||||||
logNetwork->errorStream() << error;
|
logNetwork->errorStream() << error;
|
||||||
else
|
else
|
||||||
logNetwork->errorStream() << "No error info. ";
|
logNetwork->error("No error info.");
|
||||||
delete io_service;
|
delete io_service;
|
||||||
//delete socket;
|
//delete socket;
|
||||||
throw std::runtime_error("Can't establish connection :(");
|
throw std::runtime_error("Can't establish connection :(");
|
||||||
|
Loading…
Reference in New Issue
Block a user