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:
parent
faae305ec0
commit
10dbbead2d
@ -165,7 +165,7 @@ BattleAction CBattleAI::activeStack( const CStack * stack )
|
|||||||
{
|
{
|
||||||
ThreatMap threatsToUs(stack);
|
ThreatMap threatsToUs(stack);
|
||||||
auto dists = cbc->battleGetDistances(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)
|
if(distToNearestNeighbour(ei.s->position, dists) < GameConstants::BFIELD_SIZE)
|
||||||
{
|
{
|
||||||
return goTowards(stack, ei.s->position);
|
return goTowards(stack, ei.s->position);
|
||||||
@ -268,7 +268,7 @@ void CBattleAI::battleStacksRemoved(const BattleStacksRemoved & bsr)
|
|||||||
|
|
||||||
void CBattleAI::print(const std::string &text) const
|
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)
|
BattleAction CBattleAI::goTowards(const CStack * stack, BattleHex destination)
|
||||||
@ -283,7 +283,7 @@ BattleAction CBattleAI::goTowards(const CStack * stack, BattleHex destination)
|
|||||||
auto destNeighbours = destination.neighbouringTiles();
|
auto destNeighbours = destination.neighbouringTiles();
|
||||||
if(vstd::contains_if(destNeighbours, [&](BattleHex n) { return stack->coversPos(destination); }))
|
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...
|
//We shouldn't even be here...
|
||||||
return BattleAction::makeDefend(stack);
|
return BattleAction::makeDefend(stack);
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ void CStupidAI::battleStacksRemoved(const BattleStacksRemoved & bsr)
|
|||||||
|
|
||||||
void CStupidAI::print(const std::string &text) const
|
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)
|
BattleAction CStupidAI::goTowards(const CStack * stack, BattleHex destination)
|
||||||
@ -276,7 +276,7 @@ BattleAction CStupidAI::goTowards(const CStack * stack, BattleHex destination)
|
|||||||
auto destNeighbours = destination.neighbouringTiles();
|
auto destNeighbours = destination.neighbouringTiles();
|
||||||
if(vstd::contains_if(destNeighbours, [&](BattleHex n) { return stack->coversPos(destination); }))
|
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...
|
//We shouldn't even be here...
|
||||||
return BattleAction::makeDefend(stack);
|
return BattleAction::makeDefend(stack);
|
||||||
}
|
}
|
||||||
|
@ -339,7 +339,7 @@ bool isSafeToVisit(HeroPtr h, crint3 tile)
|
|||||||
{
|
{
|
||||||
if(heroStrength / SAFE_ATTACK_CONSTANT > dangerStrength)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -105,7 +105,7 @@ struct TimeCheck
|
|||||||
|
|
||||||
~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>
|
template<int id>
|
||||||
bool objWithID(const CGObjectInstance *obj)
|
bool objWithID(const CGObjectInstance *obj)
|
||||||
{
|
{
|
||||||
return obj->ID == id;
|
return obj->ID == id;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string strFromInt3(int3 pos);
|
std::string strFromInt3(int3 pos);
|
||||||
|
@ -182,8 +182,8 @@ namespace Goals
|
|||||||
|
|
||||||
//TSubgoal AbstractGoal::whatToDoToAchieve()
|
//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());
|
// return sptr (Goals::Explore());
|
||||||
//}
|
//}
|
||||||
|
|
||||||
TSubgoal Win::whatToDoToAchieve()
|
TSubgoal Win::whatToDoToAchieve()
|
||||||
@ -462,7 +462,7 @@ TSubgoal ClearWayTo::whatToDoToAchieve()
|
|||||||
assert(cb->isInTheMap(tile)); //set tile
|
assert(cb->isInTheMap(tile)); //set tile
|
||||||
if(!cb->isVisible(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());
|
return sptr (Goals::Explore());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1129,7 +1129,7 @@ TGoalVec GatherArmy::getAllPossibleSubgoals()
|
|||||||
|
|
||||||
//TSubgoal AbstractGoal::whatToDoToAchieve()
|
//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());
|
// return sptr (Goals::Explore());
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
@ -216,12 +216,12 @@ void VCAI::gameOver(PlayerColor player, const EVictoryLossCheckResult & victoryL
|
|||||||
{
|
{
|
||||||
if(victoryLossCheckResult.victory())
|
if(victoryLossCheckResult.victory())
|
||||||
{
|
{
|
||||||
logAi->debugStream() << "VCAI: I won! Incredible!";
|
logAi->debugStream() << "VCAI: I won! Incredible!";
|
||||||
logAi->debugStream() << "Turn nr " << myCb->getDate();
|
logAi->debugStream() << "Turn nr " << myCb->getDate();
|
||||||
}
|
}
|
||||||
else
|
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();
|
finish();
|
||||||
@ -843,12 +843,12 @@ void VCAI::makeTurnInternal()
|
|||||||
}
|
}
|
||||||
catch(boost::thread_interrupted &e)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
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();
|
endTurn();
|
||||||
@ -1171,7 +1171,7 @@ bool VCAI::tryBuildStructure(const CGTownInstance * t, BuildingID building, unsi
|
|||||||
{
|
{
|
||||||
if(!containsSavedRes(b->resources))
|
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);
|
cb->buildBuilding(t, buildID);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1252,7 +1252,7 @@ bool VCAI::tryBuildStructure(const CGTownInstance * t, BuildingID building, unsi
|
|||||||
// {
|
// {
|
||||||
// if(!containsSavedRes(b->resources))
|
// 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;
|
// return true;
|
||||||
// }
|
// }
|
||||||
// continue;
|
// continue;
|
||||||
@ -1638,7 +1638,7 @@ void VCAI::battleEnd(const BattleResult *br)
|
|||||||
assert(status.getBattle() == ONGOING_BATTLE);
|
assert(status.getBattle() == ONGOING_BATTLE);
|
||||||
status.setBattle(ENDING_BATTLE);
|
status.setBattle(ENDING_BATTLE);
|
||||||
bool won = br->winner == myCb->battleGetMySide();
|
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();
|
battlename.clear();
|
||||||
CAdventureAI::battleEnd(br);
|
CAdventureAI::battleEnd(br);
|
||||||
}
|
}
|
||||||
@ -1874,7 +1874,7 @@ bool VCAI::moveHeroToTile(int3 dst, HeroPtr h)
|
|||||||
cb->getPathsInfo(h.get())->getPath(path, dst);
|
cb->getPathsInfo(h.get())->getPath(path, dst);
|
||||||
if(path.nodes.empty())
|
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)));
|
throw goalFulfilledException (sptr(Goals::VisitTile(dst).sethero(h)));
|
||||||
}
|
}
|
||||||
int i = path.nodes.size()-1;
|
int i = path.nodes.size()-1;
|
||||||
@ -2150,7 +2150,7 @@ void VCAI::tryRealize(Goals::Build & g)
|
|||||||
{
|
{
|
||||||
for(const CGTownInstance *t : cb->getTownsInfo())
|
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);
|
buildStructure(t);
|
||||||
buildArmyIn(t);
|
buildArmyIn(t);
|
||||||
|
|
||||||
@ -2171,8 +2171,8 @@ void VCAI::tryRealize(Goals::Invalid & g)
|
|||||||
|
|
||||||
void VCAI::tryRealize(Goals::AbstractGoal & g)
|
void VCAI::tryRealize(Goals::AbstractGoal & g)
|
||||||
{
|
{
|
||||||
logAi->debugStream() << boost::format("Attempting realizing goal with code %s") % g.name();
|
logAi->debugStream() << boost::format("Attempting realizing goal with code %s") % g.name();
|
||||||
throw cannotFulfillGoalException("Unknown type of goal !");
|
throw cannotFulfillGoalException("Unknown type of goal !");
|
||||||
}
|
}
|
||||||
|
|
||||||
const CGTownInstance * VCAI::findTownWithTavern() const
|
const CGTownInstance * VCAI::findTownWithTavern() const
|
||||||
@ -2233,10 +2233,10 @@ HeroPtr VCAI::primaryHero() const
|
|||||||
|
|
||||||
void VCAI::endTurn()
|
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())
|
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();
|
logAi->debugStream() << "Resources at the end of turn: " << cb->getResourceAmount();
|
||||||
|
|
||||||
@ -2245,7 +2245,7 @@ void VCAI::endTurn()
|
|||||||
cb->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
|
} 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)
|
void VCAI::striveToGoal(Goals::TSubgoal ultimateGoal)
|
||||||
@ -2274,11 +2274,11 @@ Goals::TSubgoal VCAI::striveToGoalInternal(Goals::TSubgoal ultimateGoal, bool on
|
|||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
Goals::TSubgoal goal = ultimateGoal;
|
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
|
int maxGoals = searchDepth; //preventing deadlock for mutually dependent goals
|
||||||
while(!goal->isElementar && maxGoals && (onlyAbstract || !goal->isAbstract))
|
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
|
try
|
||||||
{
|
{
|
||||||
boost::this_thread::interruption_point();
|
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)
|
//it is impossible to continue some goals (like exploration, for example)
|
||||||
completeGoal (goal);
|
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());
|
return sptr(Goals::Invalid());
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
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());
|
return sptr(Goals::Invalid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2326,7 +2326,7 @@ Goals::TSubgoal VCAI::striveToGoalInternal(Goals::TSubgoal ultimateGoal, bool on
|
|||||||
if (goal->isAbstract)
|
if (goal->isAbstract)
|
||||||
{
|
{
|
||||||
abstractGoal = goal; //allow only one abstract goal per call
|
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;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2339,7 +2339,7 @@ Goals::TSubgoal VCAI::striveToGoalInternal(Goals::TSubgoal ultimateGoal, bool on
|
|||||||
}
|
}
|
||||||
catch(boost::thread_interrupted &e)
|
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
|
throw; //rethrow, we want to truly end this thread
|
||||||
}
|
}
|
||||||
catch(goalFulfilledException &e)
|
catch(goalFulfilledException &e)
|
||||||
@ -2352,8 +2352,8 @@ Goals::TSubgoal VCAI::striveToGoalInternal(Goals::TSubgoal ultimateGoal, bool on
|
|||||||
}
|
}
|
||||||
catch(std::exception &e)
|
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("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("The error message was: %s") % e.what();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2366,7 +2366,7 @@ void VCAI::striveToQuest (const QuestInfo &q)
|
|||||||
{
|
{
|
||||||
MetaString ms;
|
MetaString ms;
|
||||||
q.quest->getRolloverText(ms, false);
|
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();
|
auto heroes = cb->getHeroesInfo();
|
||||||
|
|
||||||
switch (q.quest->missionType)
|
switch (q.quest->missionType)
|
||||||
@ -2464,7 +2464,7 @@ void VCAI::striveToQuest (const QuestInfo &q)
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < q.quest->m2stats.size(); ++i)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
@ -2479,13 +2479,13 @@ void VCAI::striveToQuest (const QuestInfo &q)
|
|||||||
return;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case CQuest::MISSION_PLAYER:
|
case CQuest::MISSION_PLAYER:
|
||||||
{
|
{
|
||||||
if (playerID.getNum() != q.quest->m13489val)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case CQuest::MISSION_KEYMASTER:
|
case CQuest::MISSION_KEYMASTER:
|
||||||
@ -2501,7 +2501,7 @@ void VCAI::performTypicalActions()
|
|||||||
{
|
{
|
||||||
for(auto h : getUnblockedHeroes())
|
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);
|
makePossibleUpgrades(*h);
|
||||||
pickBestArtifacts(*h);
|
pickBestArtifacts(*h);
|
||||||
try
|
try
|
||||||
@ -2510,7 +2510,7 @@ void VCAI::performTypicalActions()
|
|||||||
}
|
}
|
||||||
catch(std::exception &e)
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2709,7 +2709,7 @@ void VCAI::checkHeroArmy (HeroPtr h)
|
|||||||
|
|
||||||
void VCAI::recruitHero(const CGTownInstance * t, bool throwing)
|
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);
|
auto heroes = cb->getAvailableHeroes(t);
|
||||||
if(heroes.size())
|
if(heroes.size())
|
||||||
@ -2745,7 +2745,7 @@ void VCAI::requestActionASAP(std::function<void()> whatToDo)
|
|||||||
|
|
||||||
void VCAI::lostHero(HeroPtr h)
|
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);
|
vstd::erase_if_present(lockedHeroes, h);
|
||||||
for(auto obj : reservedHeroesMap[h])
|
for(auto obj : reservedHeroesMap[h])
|
||||||
@ -2758,14 +2758,14 @@ void VCAI::lostHero(HeroPtr h)
|
|||||||
|
|
||||||
void VCAI::answerQuery(QueryID queryID, int selection)
|
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))
|
if(queryID != QueryID(-1))
|
||||||
{
|
{
|
||||||
cb->selectionMade(selection, queryID);
|
cb->selectionMade(selection, queryID);
|
||||||
}
|
}
|
||||||
else
|
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
|
//do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2857,7 +2857,7 @@ void AIStatus::addQuery(QueryID ID, std::string description)
|
|||||||
{
|
{
|
||||||
if(ID == QueryID(-1))
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2869,7 +2869,7 @@ void AIStatus::addQuery(QueryID ID, std::string description)
|
|||||||
remainingQueries[ID] = description;
|
remainingQueries[ID] = description;
|
||||||
|
|
||||||
cv.notify_all();
|
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)
|
void AIStatus::removeQuery(QueryID ID)
|
||||||
@ -2881,7 +2881,7 @@ void AIStatus::removeQuery(QueryID ID)
|
|||||||
remainingQueries.erase(ID);
|
remainingQueries.erase(ID);
|
||||||
|
|
||||||
cv.notify_all();
|
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()
|
int AIStatus::getQueriesCount()
|
||||||
@ -2922,7 +2922,7 @@ void AIStatus::attemptedAnsweringQuery(QueryID queryID, int answerRequestID)
|
|||||||
boost::unique_lock<boost::mutex> lock(mx);
|
boost::unique_lock<boost::mutex> lock(mx);
|
||||||
assert(vstd::contains(remainingQueries, queryID));
|
assert(vstd::contains(remainingQueries, queryID));
|
||||||
std::string description = 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;
|
requestToQueryID[answerRequestID] = queryID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2939,7 +2939,7 @@ void AIStatus::receivedAnswerConfirmation(int answerRequestID, int result)
|
|||||||
}
|
}
|
||||||
else
|
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
|
//TODO safely retry
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ int CCallback::selectionMade(int selection, QueryID queryID)
|
|||||||
ASSERT_IF_CALLED_WITH_PLAYER
|
ASSERT_IF_CALLED_WITH_PLAYER
|
||||||
if(queryID == QueryID(-1))
|
if(queryID == QueryID(-1))
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Cannot answer the query -1!";
|
logGlobal->errorStream() << "Cannot answer the query -1!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ bool CCallback::upgradeCreature(const CArmedInstance *obj, SlotID stackPos, Crea
|
|||||||
|
|
||||||
void CCallback::endTurn()
|
void CCallback::endTurn()
|
||||||
{
|
{
|
||||||
logGlobal->traceStream() << "Player " << *player << " ended his turn.";
|
logGlobal->traceStream() << "Player " << *player << " ended his turn.";
|
||||||
EndTurn pack;
|
EndTurn pack;
|
||||||
sendRequest(&pack); //report that we ended turn
|
sendRequest(&pack); //report that we ended turn
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ int CBattleCallback::sendRequest(const CPack *request)
|
|||||||
int requestID = cl->sendRequest(request, *player);
|
int requestID = cl->sendRequest(request, *player);
|
||||||
if(waitTillRealize)
|
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);
|
auto gsUnlocker = vstd::makeUnlockSharedGuardIf(getGsMutex(), unlockGsWhenWaiting);
|
||||||
cl->waitingRequest.waitWhileContains(requestID);
|
cl->waitingRequest.waitWhileContains(requestID);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ SDL_Surface * BitmapHandler::loadBitmapFromDir(std::string path, std::string fna
|
|||||||
{
|
{
|
||||||
if(!fname.size())
|
if(!fname.size())
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "Call to loadBitmap with void fname!";
|
logGlobal->warnStream() << "Call to loadBitmap with void fname!";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (!CResourceHandler::get()->existsResource(ResourceID(path + fname, EResType::IMAGE)))
|
if (!CResourceHandler::get()->existsResource(ResourceID(path + fname, EResType::IMAGE)))
|
||||||
@ -146,8 +146,8 @@ SDL_Surface * BitmapHandler::loadBitmapFromDir(std::string path, std::string fna
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logGlobal->errorStream()<<"Failed to open "<<fname<<" via SDL_Image";
|
logGlobal->errorStream() << "Failed to open " << fname << " via SDL_Image";
|
||||||
logGlobal->errorStream()<<"Reason: " << IMG_GetError();
|
logGlobal->errorStream() << "Reason: " << IMG_GetError();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,7 +173,9 @@ SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey)
|
|||||||
|
|
||||||
if (!(bitmap = loadBitmapFromDir("DATA/", fname, setKey)) &&
|
if (!(bitmap = loadBitmapFromDir("DATA/", fname, setKey)) &&
|
||||||
!(bitmap = loadBitmapFromDir("SPRITES/", 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;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ void init()
|
|||||||
loadDLLClasses();
|
loadDLLClasses();
|
||||||
const_cast<CGameInfo*>(CGI)->setFromLib();
|
const_cast<CGameInfo*>(CGI)->setFromLib();
|
||||||
|
|
||||||
logGlobal->infoStream()<<"Initializing VCMI_Lib: "<<tmh.getDiff();
|
logGlobal->infoStream()<<"Initializing VCMI_Lib: "<<tmh.getDiff();
|
||||||
|
|
||||||
|
|
||||||
if(!gNoGUI)
|
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
|
testFile("SOUNDS/G1A.WAV", "campaign music"); //technically not a music but voiced intro sounds
|
||||||
|
|
||||||
conf.init();
|
conf.init();
|
||||||
logGlobal->infoStream() <<"Loading settings: "<<pomtime.getDiff();
|
logGlobal->infoStream() << "Loading settings: " << pomtime.getDiff();
|
||||||
logGlobal->infoStream() << NAME;
|
logGlobal->infoStream() << NAME;
|
||||||
|
|
||||||
srand ( time(nullptr) );
|
srand ( time(nullptr) );
|
||||||
|
|
||||||
@ -348,11 +348,11 @@ int main(int argc, char** argv)
|
|||||||
//something is really wrong...
|
//something is really wrong...
|
||||||
if (res["width"].Float() < 100 || res["height"].Float() < 100)
|
if (res["width"].Float() < 100 || res["height"].Float() < 100)
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Fatal error: failed to load settings!";
|
logGlobal->errorStream() << "Fatal error: failed to load settings!";
|
||||||
logGlobal->errorStream() << "Possible reasons:";
|
logGlobal->errorStream() << "Possible reasons:";
|
||||||
logGlobal->errorStream() << "\tCorrupted local configuration file at " << VCMIDirs::get().userConfigPath() << "/settings.json";
|
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() << "\tMissing or corrupted global configuration file at " << VCMIDirs::get().userConfigPath() << "/schemas/settings.json";
|
||||||
logGlobal->errorStream() << "VCMI will now exit...";
|
logGlobal->errorStream() << "VCMI will now exit...";
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,7 +426,7 @@ int main(int argc, char** argv)
|
|||||||
CCS->videoh = new CEmptyVideoPlayer;
|
CCS->videoh = new CEmptyVideoPlayer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
logGlobal->infoStream()<<"\tInitializing video: "<<pomtime.getDiff();
|
logGlobal->infoStream()<<"\tInitializing video: "<<pomtime.getDiff();
|
||||||
|
|
||||||
#if defined(VCMI_ANDROID)
|
#if defined(VCMI_ANDROID)
|
||||||
//on Android threaded init is broken
|
//on Android threaded init is broken
|
||||||
@ -440,7 +440,7 @@ int main(int argc, char** argv)
|
|||||||
CCS->musich = new CMusicHandler;
|
CCS->musich = new CMusicHandler;
|
||||||
CCS->musich->init();
|
CCS->musich->init();
|
||||||
CCS->musich->setVolume(settings["general"]["music"].Float());
|
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__
|
#ifdef __APPLE__
|
||||||
// Ctrl+click should be treated as a right click on Mac OS X
|
// 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
|
#ifndef VCMI_NO_THREADED_LOAD
|
||||||
loading.join();
|
loading.join();
|
||||||
#endif
|
#endif
|
||||||
logGlobal->infoStream()<<"Initialization of VCMI (together): "<<total.getDiff();
|
logGlobal->infoStream()<<"Initialization of VCMI (together): "<<total.getDiff();
|
||||||
|
|
||||||
if(!vm.count("battle"))
|
if(!vm.count("battle"))
|
||||||
{
|
{
|
||||||
@ -484,8 +484,8 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
if(!fileToStartFrom.empty())
|
if(!fileToStartFrom.empty())
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "Warning: cannot find given file to start from (" << fileToStartFrom
|
logGlobal->warnStream() << "Warning: cannot find given file to start from (" << fileToStartFrom
|
||||||
<< "). Falling back to main menu.";
|
<< "). Falling back to main menu.";
|
||||||
}
|
}
|
||||||
GH.curInt = CGPreGame::create(); //will set CGP pointer to itself
|
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)
|
void printInfoAboutIntObject(const CIntObject *obj, int level)
|
||||||
{
|
{
|
||||||
std::stringstream sbuffer;
|
std::stringstream sbuffer;
|
||||||
sbuffer << std::string(level, '\t');
|
sbuffer << std::string(level, '\t');
|
||||||
|
|
||||||
sbuffer << typeid(*obj).name() << " *** ";
|
sbuffer << typeid(*obj).name() << " *** ";
|
||||||
if (obj->active)
|
if (obj->active)
|
||||||
{
|
{
|
||||||
#define PRINT(check, text) if (obj->active & CIntObject::check) sbuffer << text
|
#define PRINT(check, text) if (obj->active & CIntObject::check) sbuffer << text
|
||||||
@ -534,10 +534,10 @@ void printInfoAboutIntObject(const CIntObject *obj, int level)
|
|||||||
#undef PRINT
|
#undef PRINT
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sbuffer << "inactive";
|
sbuffer << "inactive";
|
||||||
sbuffer << " at " << obj->pos.x <<"x"<< obj->pos.y;
|
sbuffer << " at " << obj->pos.x <<"x"<< obj->pos.y;
|
||||||
sbuffer << " (" << obj->pos.w <<"x"<< obj->pos.h << ")";
|
sbuffer << " (" << obj->pos.w <<"x"<< obj->pos.h << ")";
|
||||||
logGlobal->infoStream() << sbuffer.str();
|
logGlobal->infoStream() << sbuffer.str();
|
||||||
|
|
||||||
for(const CIntObject *child : obj->children)
|
for(const CIntObject *child : obj->children)
|
||||||
printInfoAboutIntObject(child, level+1);
|
printInfoAboutIntObject(child, level+1);
|
||||||
@ -565,7 +565,7 @@ void processCommand(const std::string &message)
|
|||||||
{
|
{
|
||||||
if(client && client->erm)
|
if(client && client->erm)
|
||||||
client->erm->executeUserCommand(message);
|
client->erm->executeUserCommand(message);
|
||||||
std::cout << "erm>";
|
std::cout << "erm>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(message==std::string("die, fool"))
|
else if(message==std::string("die, fool"))
|
||||||
@ -575,7 +575,7 @@ void processCommand(const std::string &message)
|
|||||||
else if(cn == "erm")
|
else if(cn == "erm")
|
||||||
{
|
{
|
||||||
ermInteractiveMode = true;
|
ermInteractiveMode = true;
|
||||||
std::cout << "erm>";
|
std::cout << "erm>";
|
||||||
}
|
}
|
||||||
else if(cn==std::string("activate"))
|
else if(cn==std::string("activate"))
|
||||||
{
|
{
|
||||||
@ -600,14 +600,14 @@ void processCommand(const std::string &message)
|
|||||||
}
|
}
|
||||||
else if(cn=="screen")
|
else if(cn=="screen")
|
||||||
{
|
{
|
||||||
std::cout << "Screenbuf points to ";
|
std::cout << "Screenbuf points to ";
|
||||||
|
|
||||||
if(screenBuf == screen)
|
if(screenBuf == screen)
|
||||||
logGlobal->errorStream() << "screen";
|
logGlobal->errorStream() << "screen";
|
||||||
else if(screenBuf == screen2)
|
else if(screenBuf == screen2)
|
||||||
logGlobal->errorStream() << "screen2";
|
logGlobal->errorStream() << "screen2";
|
||||||
else
|
else
|
||||||
logGlobal->errorStream() << "?!?";
|
logGlobal->errorStream() << "?!?";
|
||||||
|
|
||||||
SDL_SaveBMP(screen, "Screen_c.bmp");
|
SDL_SaveBMP(screen, "Screen_c.bmp");
|
||||||
SDL_SaveBMP(screen2, "Screen2_c.bmp");
|
SDL_SaveBMP(screen2, "Screen2_c.bmp");
|
||||||
@ -624,10 +624,10 @@ void processCommand(const std::string &message)
|
|||||||
std::string fname;
|
std::string fname;
|
||||||
readed >> fname;
|
readed >> fname;
|
||||||
client->loadGame(fname);
|
client->loadGame(fname);
|
||||||
}
|
}
|
||||||
else if(message=="get txt")
|
else if(message=="get txt")
|
||||||
{
|
{
|
||||||
std::cout<<"Command accepted.\t";
|
std::cout << "Command accepted.\t";
|
||||||
|
|
||||||
const bfs::path outPath =
|
const bfs::path outPath =
|
||||||
VCMIDirs::get().userCachePath() / "extracted";
|
VCMIDirs::get().userCachePath() / "extracted";
|
||||||
@ -649,7 +649,7 @@ void processCommand(const std::string &message)
|
|||||||
file.write((char*)text.first.get(), text.second);
|
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";
|
std::cout << " Extracted files can be found in " << outPath << " directory\n";
|
||||||
}
|
}
|
||||||
else if(cn=="crash")
|
else if(cn=="crash")
|
||||||
@ -665,24 +665,24 @@ void processCommand(const std::string &message)
|
|||||||
else if (cn == "ai")
|
else if (cn == "ai")
|
||||||
{
|
{
|
||||||
VLC->IS_AI_ENABLED = !VLC->IS_AI_ENABLED;
|
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)
|
else if(cn == "mp" && adventureInt)
|
||||||
{
|
{
|
||||||
if(const CGHeroInstance *h = dynamic_cast<const CGHeroInstance *>(adventureInt->selection))
|
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")
|
else if(cn == "bonuses")
|
||||||
{
|
{
|
||||||
std::cout << "Bonuses of " << adventureInt->selection->getObjectName() << std::endl
|
std::cout << "Bonuses of " << adventureInt->selection->getObjectName() << std::endl
|
||||||
<< adventureInt->selection->getBonusList() << std::endl;
|
<< adventureInt->selection->getBonusList() << std::endl;
|
||||||
|
|
||||||
std::cout << "\nInherited bonuses:\n";
|
std::cout << "\nInherited bonuses:\n";
|
||||||
TCNodes parents;
|
TCNodes parents;
|
||||||
adventureInt->selection->getParents(parents);
|
adventureInt->selection->getParents(parents);
|
||||||
for(const CBonusSystemNode *parent : 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")
|
else if(cn == "not dialog")
|
||||||
@ -696,7 +696,7 @@ void processCommand(const std::string &message)
|
|||||||
if(const CIntObject *obj = dynamic_cast<const CIntObject *>(child))
|
if(const CIntObject *obj = dynamic_cast<const CIntObject *>(child))
|
||||||
printInfoAboutIntObject(obj, 0);
|
printInfoAboutIntObject(obj, 0);
|
||||||
else
|
else
|
||||||
std::cout << typeid(*obj).name() << std::endl;
|
std::cout << typeid(*obj).name() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(cn=="tell")
|
else if(cn=="tell")
|
||||||
@ -709,7 +709,7 @@ void processCommand(const std::string &message)
|
|||||||
for(const CGHeroInstance *h : LOCPLINT->cb->getHeroesInfo())
|
for(const CGHeroInstance *h : LOCPLINT->cb->getHeroesInfo())
|
||||||
if(h->type->ID.getNum() == id1)
|
if(h->type->ID.getNum() == id1)
|
||||||
if(const CArtifactInstance *a = h->getArt(ArtifactPosition(id2)))
|
if(const CArtifactInstance *a = h->getArt(ArtifactPosition(id2)))
|
||||||
std::cout << a->nodeName();
|
std::cout << a->nodeName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cn == "set")
|
else if (cn == "set")
|
||||||
@ -790,20 +790,20 @@ void processCommand(const std::string &message)
|
|||||||
{
|
{
|
||||||
std::string fname;
|
std::string fname;
|
||||||
readed >> 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
|
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
|
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"];
|
Settings neutralAI = settings.write["server"]["neutralAI"];
|
||||||
neutralAI->String() = fname;
|
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)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "Failed opening " << fname << ": " << e.what();
|
logGlobal->warnStream() << "Failed opening " << fname << ": " << e.what();
|
||||||
logGlobal->warnStream() << "Setting not changes, AI not found or invalid!";
|
logGlobal->warnStream() << "Setting not changes, AI not found or invalid!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ void CAudioBase::init()
|
|||||||
|
|
||||||
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024)==-1)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ Mix_Chunk *CSoundHandler::GetSoundChunk(std::string &sound, bool cache)
|
|||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "Cannot get sound " << sound << " chunk: " << e.what();
|
logGlobal->warnStream() << "Cannot get sound " << sound << " chunk: " << e.what();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,7 +183,7 @@ int CSoundHandler::playSound(std::string sound, int repeats, bool cache)
|
|||||||
channel = Mix_PlayChannel(-1, chunk, repeats);
|
channel = Mix_PlayChannel(-1, chunk, repeats);
|
||||||
if (channel == -1)
|
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)
|
if (!cache)
|
||||||
Mix_FreeChunk(chunk);
|
Mix_FreeChunk(chunk);
|
||||||
}
|
}
|
||||||
@ -315,7 +315,7 @@ void CMusicHandler::playMusicFromSet(std::string whichSet, bool loop)
|
|||||||
auto selectedSet = musicsSet.find(whichSet);
|
auto selectedSet = musicsSet.find(whichSet);
|
||||||
if (selectedSet == musicsSet.end())
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,14 +332,14 @@ void CMusicHandler::playMusicFromSet(std::string whichSet, int entryID, bool loo
|
|||||||
auto selectedSet = musicsSet.find(whichSet);
|
auto selectedSet = musicsSet.find(whichSet);
|
||||||
if (selectedSet == musicsSet.end())
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto selectedEntry = selectedSet->second.find(entryID);
|
auto selectedEntry = selectedSet->second.find(entryID);
|
||||||
if (selectedEntry == selectedSet->second.end())
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,10 +470,10 @@ bool MusicEntry::play()
|
|||||||
load(RandomGeneratorUtil::nextItem(set, CRandomGenerator::getDefault())->second);
|
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)
|
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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -483,7 +483,7 @@ bool MusicEntry::stop(int fade_ms)
|
|||||||
{
|
{
|
||||||
if (Mix_PlayingMusic())
|
if (Mix_PlayingMusic())
|
||||||
{
|
{
|
||||||
logGlobal->traceStream()<<"Stoping music file "<<currentName;
|
logGlobal->traceStream()<<"Stoping music file "<<currentName;
|
||||||
loop = 0;
|
loop = 0;
|
||||||
Mix_FadeOutMusic(fade_ms);
|
Mix_FadeOutMusic(fade_ms);
|
||||||
return true;
|
return true;
|
||||||
|
@ -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()>();
|
return std::function<void()>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -941,7 +941,7 @@ void CSelectionScreen::handleConnection()
|
|||||||
{
|
{
|
||||||
CPackForSelectionScreen *pack = nullptr;
|
CPackForSelectionScreen *pack = nullptr;
|
||||||
*serv >> pack;
|
*serv >> pack;
|
||||||
logNetwork->traceStream() << "Received a pack of type " << typeid(*pack).name();
|
logNetwork->traceStream() << "Received a pack of type " << typeid(*pack).name();
|
||||||
assert(pack);
|
assert(pack);
|
||||||
if(QuitMenuWithoutStarting *endingPack = dynamic_cast<QuitMenuWithoutStarting *>(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)
|
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)
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
// Unknown version. Be safe and ignore that map
|
// 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;
|
continue;
|
||||||
}
|
}
|
||||||
IImage * icon = formatIcons->getImage(frame,group);
|
IImage * icon = formatIcons->getImage(frame,group);
|
||||||
|
@ -150,7 +150,7 @@ void CClient::waitForMoveAndSend(PlayerColor color)
|
|||||||
}
|
}
|
||||||
catch(boost::thread_interrupted&)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
@ -158,7 +158,7 @@ void CClient::waitForMoveAndSend(PlayerColor color)
|
|||||||
handleException();
|
handleException();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logNetwork->errorStream() << "We should not be here!";
|
logNetwork->errorStream() << "We should not be here!";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClient::run()
|
void CClient::run()
|
||||||
@ -182,11 +182,11 @@ void CClient::run()
|
|||||||
//catch only asio exceptions
|
//catch only asio exceptions
|
||||||
catch (const boost::system::system_error& e)
|
catch (const boost::system::system_error& e)
|
||||||
{
|
{
|
||||||
logNetwork->errorStream() << "Lost connection to server, ending listening thread!";
|
logNetwork->errorStream() << "Lost connection to server, ending listening thread!";
|
||||||
logNetwork->errorStream() << e.what();
|
logNetwork->errorStream() << e.what();
|
||||||
if(!terminate) //rethrow (-> boom!) only if closing connection was unexpected
|
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;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ void CClient::save(const std::string & fname)
|
|||||||
{
|
{
|
||||||
if(gs->curB)
|
if(gs->curB)
|
||||||
{
|
{
|
||||||
logNetwork->errorStream() << "Game cannot be saved during battle!";
|
logNetwork->errorStream() << "Game cannot be saved during battle!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ void CClient::endGame( bool closeConnection /*= true*/ )
|
|||||||
// Tell the network thread to reach a stable state
|
// Tell the network thread to reach a stable state
|
||||||
if(closeConnection)
|
if(closeConnection)
|
||||||
stopConnection();
|
stopConnection();
|
||||||
logNetwork->infoStream() << "Closed connection.";
|
logNetwork->infoStream() << "Closed connection.";
|
||||||
|
|
||||||
GH.curInt = nullptr;
|
GH.curInt = nullptr;
|
||||||
{
|
{
|
||||||
@ -292,12 +292,12 @@ void CClient::loadGame(const std::string & fname, const bool server, const std::
|
|||||||
loadCommonState(checkingLoader);
|
loadCommonState(checkingLoader);
|
||||||
loader = checkingLoader.decay();
|
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 = new CMapHandler();
|
||||||
const_cast<CGameInfo*>(CGI)->mh->map = gs->map;
|
const_cast<CGameInfo*>(CGI)->mh->map = gs->map;
|
||||||
pathInfo = make_unique<CPathsInfo>(getMapSize());
|
pathInfo = make_unique<CPathsInfo>(getMapSize());
|
||||||
CGI->mh->init();
|
CGI->mh->init();
|
||||||
logNetwork->infoStream() <<"Initing maphandler: "<<tmh.getDiff();
|
logNetwork->infoStream() <<"Initing maphandler: "<<tmh.getDiff();
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
@ -310,53 +310,53 @@ void CClient::loadGame(const std::string & fname, const bool server, const std::
|
|||||||
player = PlayerColor(player_);
|
player = PlayerColor(player_);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
std::set<PlayerColor> clientPlayers;
|
std::set<PlayerColor> clientPlayers;
|
||||||
if(server)
|
if(server)
|
||||||
serv = sh.connectToServer();
|
serv = sh.connectToServer();
|
||||||
//*loader >> *this;
|
//*loader >> *this;
|
||||||
|
|
||||||
if(server)
|
if(server)
|
||||||
{
|
{
|
||||||
tmh.update();
|
tmh.update();
|
||||||
ui8 pom8;
|
ui8 pom8;
|
||||||
*serv << ui8(3) << ui8(loadNumPlayers); //load game; one client if single-player
|
*serv << ui8(3) << ui8(loadNumPlayers); //load game; one client if single-player
|
||||||
*serv << fname;
|
*serv << fname;
|
||||||
*serv >> pom8;
|
*serv >> pom8;
|
||||||
if(pom8)
|
if(pom8)
|
||||||
throw std::runtime_error("Server cannot open the savegame!");
|
throw std::runtime_error("Server cannot open the savegame!");
|
||||||
else
|
else
|
||||||
logNetwork->infoStream() << "Server opened savegame properly.";
|
logNetwork->infoStream() << "Server opened savegame properly.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(server)
|
if(server)
|
||||||
{
|
{
|
||||||
for(auto & elem : gs->scenarioOps->playerInfos)
|
for(auto & elem : gs->scenarioOps->playerInfos)
|
||||||
if(!std::count(humanplayerindices.begin(),humanplayerindices.end(),elem.first.getNum()) || elem.first==player)
|
{
|
||||||
{
|
if(!std::count(humanplayerindices.begin(),humanplayerindices.end(),elem.first.getNum()) || elem.first==player)
|
||||||
clientPlayers.insert(elem.first);
|
clientPlayers.insert(elem.first);
|
||||||
}
|
}
|
||||||
clientPlayers.insert(PlayerColor::NEUTRAL);
|
clientPlayers.insert(PlayerColor::NEUTRAL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
clientPlayers.insert(player);
|
clientPlayers.insert(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "CLIENTPLAYERS:\n";
|
std::cout << "CLIENTPLAYERS:\n";
|
||||||
for(auto x : clientPlayers)
|
for(auto x : clientPlayers)
|
||||||
std::cout << x << std::endl;
|
std::cout << x << std::endl;
|
||||||
std::cout << "ENDCLIENTPLAYERS\n";
|
std::cout << "ENDCLIENTPLAYERS\n";
|
||||||
|
|
||||||
serialize(loader->serializer,0,clientPlayers);
|
serialize(loader->serializer,0,clientPlayers);
|
||||||
*serv << ui32(clientPlayers.size());
|
*serv << ui32(clientPlayers.size());
|
||||||
for(auto & elem : clientPlayers)
|
for(auto & elem : clientPlayers)
|
||||||
*serv << ui8(elem.getNum());
|
*serv << ui8(elem.getNum());
|
||||||
serv->addStdVecItems(gs); /*why is this here?*/
|
serv->addStdVecItems(gs); /*why is this here?*/
|
||||||
|
|
||||||
//*loader >> *this;
|
//*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 << clientPlayers;
|
||||||
serv->enableStackSendingByID();
|
serv->enableStackSendingByID();
|
||||||
@ -405,7 +405,7 @@ void CClient::newGame( CConnection *con, StartInfo *si )
|
|||||||
}
|
}
|
||||||
|
|
||||||
c >> 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.enableStackSendingByID();
|
||||||
c.disableSmartPointerSerialization();
|
c.disableSmartPointerSerialization();
|
||||||
|
|
||||||
@ -415,7 +415,7 @@ void CClient::newGame( CConnection *con, StartInfo *si )
|
|||||||
|
|
||||||
gs->scenarioOps = si;
|
gs->scenarioOps = si;
|
||||||
gs->init(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.
|
// Now after possible random map gen, we know exact player count.
|
||||||
// Inform server about how many players client handles
|
// 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();
|
const_cast<CGameInfo*>(CGI)->mh = new CMapHandler();
|
||||||
CGI->mh->map = gs->map;
|
CGI->mh->map = gs->map;
|
||||||
logNetwork->infoStream() <<"Creating mapHandler: "<<tmh.getDiff();
|
logNetwork->infoStream() << "Creating mapHandler: " << tmh.getDiff();
|
||||||
CGI->mh->init();
|
CGI->mh->init();
|
||||||
pathInfo = make_unique<CPathsInfo>(getMapSize());
|
pathInfo = make_unique<CPathsInfo>(getMapSize());
|
||||||
logNetwork->infoStream() <<"Initializing mapHandler (together): "<<tmh.getDiff();
|
logNetwork->infoStream() << "Initializing mapHandler (together): " << tmh.getDiff();
|
||||||
}
|
}
|
||||||
|
|
||||||
int humanPlayers = 0;
|
int humanPlayers = 0;
|
||||||
@ -452,7 +452,7 @@ void CClient::newGame( CConnection *con, StartInfo *si )
|
|||||||
if(!vstd::contains(myPlayers, color))
|
if(!vstd::contains(myPlayers, color))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
logNetwork->traceStream() << "Preparing interface for player " << color;
|
logNetwork->traceStream() << "Preparing interface for player " << color;
|
||||||
if(si->mode != StartInfo::DUEL)
|
if(si->mode != StartInfo::DUEL)
|
||||||
{
|
{
|
||||||
if(elem.second.playerID == PlayerSettings::PLAYER_AI)
|
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(pid == PlayerColor::NEUTRAL)
|
||||||
{
|
{
|
||||||
if(playerIDs.count(pid))
|
if(playerIDs.count(pid))
|
||||||
installNewBattleInterface(CDynLibHandler::getNewBattleAI(dllname), pid);
|
installNewBattleInterface(CDynLibHandler::getNewBattleAI(dllname), pid);
|
||||||
//TODO? consider serialization
|
//TODO? consider serialization
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -639,14 +639,14 @@ void CClient::serialize(CISer & h, const int version, const std::set<PlayerColor
|
|||||||
nInt->human = isHuman;
|
nInt->human = isHuman;
|
||||||
nInt->playerID = pid;
|
nInt->playerID = pid;
|
||||||
|
|
||||||
if(playerIDs.count(pid))
|
if(playerIDs.count(pid))
|
||||||
installNewPlayerInterface(nInt, pid);
|
installNewPlayerInterface(nInt, pid);
|
||||||
|
|
||||||
nInt->loadGame(h, version);
|
nInt->loadGame(h, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(playerIDs.count(PlayerColor::NEUTRAL))
|
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);
|
boost::unique_lock<boost::recursive_mutex> guiLock(*LOCPLINT->pim);
|
||||||
apply->applyOnClBefore(this,pack);
|
apply->applyOnClBefore(this,pack);
|
||||||
logNetwork->traceStream() << "\tMade first apply on cl";
|
logNetwork->traceStream() << "\tMade first apply on cl";
|
||||||
gs->apply(pack);
|
gs->apply(pack);
|
||||||
logNetwork->traceStream() << "\tApplied on gs";
|
logNetwork->traceStream() << "\tApplied on gs";
|
||||||
apply->applyOnClAfter(this,pack);
|
apply->applyOnClAfter(this,pack);
|
||||||
logNetwork->traceStream() << "\tMade second apply on cl";
|
logNetwork->traceStream() << "\tMade second apply on cl";
|
||||||
}
|
}
|
||||||
else
|
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;
|
delete pack;
|
||||||
}
|
}
|
||||||
@ -685,11 +685,11 @@ void CClient::stopConnection()
|
|||||||
|
|
||||||
if (serv) //request closing connection
|
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);
|
boost::unique_lock<boost::mutex>(*serv->wmx);
|
||||||
CloseServer close_server;
|
CloseServer close_server;
|
||||||
sendRequest(&close_server, PlayerColor::NEUTRAL);
|
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
|
if(connectionHandler)//end connection handler
|
||||||
@ -697,7 +697,7 @@ void CClient::stopConnection()
|
|||||||
if(connectionHandler->get_id() != boost::this_thread::get_id())
|
if(connectionHandler->get_id() != boost::this_thread::get_id())
|
||||||
connectionHandler->join();
|
connectionHandler->join();
|
||||||
|
|
||||||
logNetwork->infoStream() << "Connection handler thread joined";
|
logNetwork->infoStream() << "Connection handler thread joined";
|
||||||
|
|
||||||
delete connectionHandler;
|
delete connectionHandler;
|
||||||
connectionHandler = nullptr;
|
connectionHandler = nullptr;
|
||||||
@ -708,7 +708,7 @@ void CClient::stopConnection()
|
|||||||
serv->close();
|
serv->close();
|
||||||
delete serv;
|
delete serv;
|
||||||
serv = nullptr;
|
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;
|
static ui32 requestCounter = 0;
|
||||||
|
|
||||||
ui32 requestID = requestCounter++;
|
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;
|
% typeid(*request).name() % requestID;
|
||||||
|
|
||||||
waitingRequest.pushBack(requestID);
|
waitingRequest.pushBack(requestID);
|
||||||
@ -933,7 +933,7 @@ void CServerHandler::startServer()
|
|||||||
th.update();
|
th.update();
|
||||||
serverThread = new boost::thread(&CServerHandler::callServer, this); //runs server executable;
|
serverThread = new boost::thread(&CServerHandler::callServer, this); //runs server executable;
|
||||||
if(verbose)
|
if(verbose)
|
||||||
logNetwork->infoStream() << "Setting up thread calling server: " << th.getDiff();
|
logNetwork->infoStream() << "Setting up thread calling server: " << th.getDiff();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerHandler::waitForServer()
|
void CServerHandler::waitForServer()
|
||||||
@ -950,7 +950,7 @@ void CServerHandler::waitForServer()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(verbose)
|
if(verbose)
|
||||||
logNetwork->infoStream() << "Waiting for server: " << th.getDiff();
|
logNetwork->infoStream() << "Waiting for server: " << th.getDiff();
|
||||||
}
|
}
|
||||||
|
|
||||||
CConnection * CServerHandler::connectToServer()
|
CConnection * CServerHandler::connectToServer()
|
||||||
@ -967,7 +967,7 @@ CConnection * CServerHandler::connectToServer()
|
|||||||
CConnection *ret = justConnectToServer(settings["server"]["server"].String(), port);
|
CConnection *ret = justConnectToServer(settings["server"]["server"].String(), port);
|
||||||
|
|
||||||
if(verbose)
|
if(verbose)
|
||||||
logNetwork->infoStream()<<"\tConnecting to the server: "<<th.getDiff();
|
logNetwork->infoStream()<<"\tConnecting to the server: "<<th.getDiff();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -987,13 +987,13 @@ CServerHandler::CServerHandler(bool runServer /*= false*/)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
shared = new SharedMem();
|
shared = new SharedMem();
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
logNetwork->error("Cannot open interprocess memory.");
|
logNetwork->error("Cannot open interprocess memory.");
|
||||||
handleException();
|
handleException();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1010,11 +1010,11 @@ void CServerHandler::callServer()
|
|||||||
const std::string comm = VCMIDirs::get().serverPath().string() + " --port=" + port + " > \"" + logName + '\"';
|
const std::string comm = VCMIDirs::get().serverPath().string() + " --port=" + port + " > \"" + logName + '\"';
|
||||||
int result = std::system(comm.c_str());
|
int result = std::system(comm.c_str());
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
logNetwork->infoStream() << "Server closed correctly";
|
logNetwork->infoStream() << "Server closed correctly";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logNetwork->errorStream() << "Error: server failed to close correctly or crashed!";
|
logNetwork->errorStream() << "Error: server failed to close correctly or crashed!";
|
||||||
logNetwork->errorStream() << "Check " << logName << " for more info";
|
logNetwork->errorStream() << "Check " << logName << " for more info";
|
||||||
exit(1);// exit in case of error. Othervice without working server VCMI will hang
|
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
|
try
|
||||||
{
|
{
|
||||||
logNetwork->infoStream() << "Establishing connection...";
|
logNetwork->infoStream() << "Establishing connection...";
|
||||||
ret = new CConnection( host.size() ? host : settings["server"]["server"].String(),
|
ret = new CConnection( host.size() ? host : settings["server"]["server"].String(),
|
||||||
realPort,
|
realPort,
|
||||||
NAME);
|
NAME);
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
logNetwork->errorStream() << "\nCannot establish connection! Retrying within 2 seconds";
|
logNetwork->errorStream() << "\nCannot establish connection! Retrying within 2 seconds";
|
||||||
SDL_Delay(2000);
|
SDL_Delay(2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ void Graphics::loadHeroFlags()
|
|||||||
loadHeroFlagsDetail(p,true);
|
loadHeroFlagsDetail(p,true);
|
||||||
}
|
}
|
||||||
#endif
|
#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)
|
void Graphics::blueToPlayersAdv(SDL_Surface * sur, PlayerColor player)
|
||||||
@ -334,7 +334,7 @@ void Graphics::blueToPlayersAdv(SDL_Surface * sur, PlayerColor player)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Wrong player id in blueToPlayersAdv (" << player << ")!";
|
logGlobal->errorStream() << "Wrong player id in blueToPlayersAdv (" << player << ")!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SDL_SetColors(sur, palette, 224, 32);
|
SDL_SetColors(sur, palette, 224, 32);
|
||||||
|
@ -120,7 +120,7 @@ void SetPrimSkill::applyCl( CClient *cl )
|
|||||||
const CGHeroInstance *h = cl->getHero(id);
|
const CGHeroInstance *h = cl->getHero(id);
|
||||||
if(!h)
|
if(!h)
|
||||||
{
|
{
|
||||||
logNetwork->errorStream() << "Cannot find hero with ID " << id.getNum();
|
logNetwork->errorStream() << "Cannot find hero with ID " << id.getNum();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
INTERFACE_CALL_IF_PRESENT(h->tempOwner,heroPrimarySkillChanged,h,which,val);
|
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);
|
const CGHeroInstance *h = cl->getHero(id);
|
||||||
if(!h)
|
if(!h)
|
||||||
{
|
{
|
||||||
logNetwork->errorStream() << "Cannot find hero with ID " << id;
|
logNetwork->errorStream() << "Cannot find hero with ID " << id;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
INTERFACE_CALL_IF_PRESENT(h->tempOwner,heroSecondarySkillChanged,h,which,val);
|
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();
|
CGHeroInstance *h = GS(cl)->map->heroesOnMap.back();
|
||||||
if(h->subID != hid)
|
if(h->subID != hid)
|
||||||
{
|
{
|
||||||
logNetwork->errorStream() << "Something wrong with hero recruited!";
|
logNetwork->errorStream() << "Something wrong with hero recruited!";
|
||||||
}
|
}
|
||||||
|
|
||||||
CGI->mh->printObject(h);
|
CGI->mh->printObject(h);
|
||||||
@ -533,7 +533,7 @@ void InfoWindow::applyCl( CClient *cl )
|
|||||||
if(vstd::contains(cl->playerint,player))
|
if(vstd::contains(cl->playerint,player))
|
||||||
cl->playerint.at(player)->showInfoDialog(str,comps,(soundBase::soundID)soundID);
|
cl->playerint.at(player)->showInfoDialog(str,comps,(soundBase::soundID)soundID);
|
||||||
else
|
else
|
||||||
logNetwork->warnStream() << "We received InfoWindow for not our player...";
|
logNetwork->warnStream() << "We received InfoWindow for not our player...";
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetObjectProperty::applyCl( CClient *cl )
|
void SetObjectProperty::applyCl( CClient *cl )
|
||||||
@ -576,7 +576,7 @@ void BlockingDialog::applyCl( CClient *cl )
|
|||||||
if(vstd::contains(cl->playerint,player))
|
if(vstd::contains(cl->playerint,player))
|
||||||
cl->playerint.at(player)->showBlockingDialog(str,components,queryID,(soundBase::soundID)soundID,selection(),cancel());
|
cl->playerint.at(player)->showBlockingDialog(str,components,queryID,(soundBase::soundID)soundID,selection(),cancel());
|
||||||
else
|
else
|
||||||
logNetwork->warnStream() << "We received YesNoDialog for not our player...";
|
logNetwork->warnStream() << "We received YesNoDialog for not our player...";
|
||||||
}
|
}
|
||||||
|
|
||||||
void GarrisonDialog::applyCl(CClient *cl)
|
void GarrisonDialog::applyCl(CClient *cl)
|
||||||
@ -782,7 +782,7 @@ void PackageApplied::applyCl( CClient *cl )
|
|||||||
{
|
{
|
||||||
INTERFACE_CALL_IF_PRESENT(player, requestRealized, this);
|
INTERFACE_CALL_IF_PRESENT(player, requestRealized, this);
|
||||||
if(!cl->waitingRequest.tryRemovingElement(requestID))
|
if(!cl->waitingRequest.tryRemovingElement(requestID))
|
||||||
logNetwork->warnStream() << "Surprising server message!";
|
logNetwork->warnStream() << "Surprising server message!";
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemMessage::applyCl( CClient *cl )
|
void SystemMessage::applyCl( CClient *cl )
|
||||||
@ -790,7 +790,7 @@ void SystemMessage::applyCl( CClient *cl )
|
|||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
str << "System message: " << text;
|
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)
|
if(LOCPLINT)
|
||||||
LOCPLINT->cingconsole->print(str.str());
|
LOCPLINT->cingconsole->print(str.str());
|
||||||
}
|
}
|
||||||
@ -819,7 +819,7 @@ void SaveGame::applyCl(CClient *cl)
|
|||||||
}
|
}
|
||||||
catch(std::exception &e)
|
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:
|
case Obj::TRADING_POST_SNOW:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logNetwork->warnStream() << "Shop type not supported!";
|
logNetwork->warnStream() << "Shop type not supported!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,7 @@ bool CMeleeAttackAnimation::init()
|
|||||||
group = mutPosToGroup[mutPos];
|
group = mutPosToGroup[mutPos];
|
||||||
break;
|
break;
|
||||||
default:
|
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;
|
group = CCreatureAnim::ATTACK_FRONT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -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]
|
// 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; }))
|
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;
|
attackingHex = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -758,11 +758,11 @@ void CBattleInterface::setBattleCursor(const int myNumber)
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
attackingHex = myNumber + 1; //right
|
attackingHex = myNumber + 1; //right
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
attackingHex = myNumber + GameConstants::BFIELD_WIDTH + zigzagCorrection; //bottom right
|
attackingHex = myNumber + GameConstants::BFIELD_WIDTH + zigzagCorrection; //bottom right
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
attackingHex = myNumber + GameConstants::BFIELD_WIDTH - 1 + zigzagCorrection; //bottom left
|
attackingHex = myNumber + GameConstants::BFIELD_WIDTH - 1 + zigzagCorrection; //bottom left
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1109,7 +1109,7 @@ void CBattleInterface::giveCommand(Battle::ActionType action, BattleHex tile, ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(stack && stack != activeStack)
|
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()
|
auto ba = new BattleAction(); //is deleted in CPlayerInterface::activeStack()
|
||||||
ba->side = defendingHeroInstance ? (curInt->playerID == defendingHeroInstance->tempOwner) : false;
|
ba->side = defendingHeroInstance ? (curInt->playerID == defendingHeroInstance->tempOwner) : false;
|
||||||
@ -1133,7 +1133,7 @@ void CBattleInterface::giveCommand(Battle::ActionType action, BattleHex tile, ui
|
|||||||
|
|
||||||
if(!tacticsMode)
|
if(!tacticsMode)
|
||||||
{
|
{
|
||||||
logGlobal->traceStream() << "Setting command for " << (stack ? stack->nodeName() : "hero");
|
logGlobal->traceStream() << "Setting command for " << (stack ? stack->nodeName() : "hero");
|
||||||
myTurn = false;
|
myTurn = false;
|
||||||
setActiveStack(nullptr);
|
setActiveStack(nullptr);
|
||||||
givenCommand->setn(ba);
|
givenCommand->setn(ba);
|
||||||
@ -1869,7 +1869,7 @@ void CBattleInterface::startAction(const BattleAction* action)
|
|||||||
}
|
}
|
||||||
if(!stack)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2713,13 +2713,13 @@ void CBattleInterface::obstaclePlaced(const CObstacleInstance & oi)
|
|||||||
sound = soundBase::fireWall;
|
sound = soundBase::fireWall;
|
||||||
break;
|
break;
|
||||||
default:
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(graphics->battleACToDef[effectID].empty())
|
if(graphics->battleACToDef[effectID].empty())
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Cannot find def for effect type " << effectID;
|
logGlobal->errorStream() << "Cannot find def for effect type " << effectID;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ void CCreatureAnimation::nextFrame(SDL_Surface *dest, bool attacker)
|
|||||||
case 3: return nextFrameT<3>(dest, !attacker);
|
case 3: return nextFrameT<3>(dest, !attacker);
|
||||||
case 4: return nextFrameT<4>(dest, !attacker);
|
case 4: return nextFrameT<4>(dest, !attacker);
|
||||||
default:
|
default:
|
||||||
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << " bpp is not supported!!!";
|
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << " bpp is not supported!!!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ void CDefFile::loadFrame(size_t frame, size_t group, ImageLoader &loader) const
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
logGlobal->errorStream()<<"Error: unsupported format of def file: "<<sprite.format;
|
logGlobal->errorStream()<<"Error: unsupported format of def file: "<<sprite.format;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -607,7 +607,7 @@ SDLImage::SDLImage(std::string filename, bool compressed):
|
|||||||
|
|
||||||
if (surf == nullptr)
|
if (surf == nullptr)
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Error: failed to load image "<<filename;
|
logGlobal->errorStream() << "Error: failed to load image "<<filename;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1050,8 +1050,8 @@ CDefFile * CAnimation::getFile() const
|
|||||||
|
|
||||||
void CAnimation::printError(size_t frame, size_t group, std::string type) 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! "
|
logGlobal->errorStream() << type << " error: Request for frame not present in CAnimation! "
|
||||||
<<"\tFile name: "<<name<<" Group: "<<group<<" Frame: "<<frame;
|
<< "\tFile name: " << name << " Group: " << group << " Frame: " << frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAnimation::CAnimation(std::string Name, bool Compressed):
|
CAnimation::CAnimation(std::string Name, bool Compressed):
|
||||||
@ -1080,7 +1080,7 @@ CAnimation::~CAnimation()
|
|||||||
{
|
{
|
||||||
if (!images.empty())
|
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 & elem : images)
|
||||||
for (auto & _image : elem.second)
|
for (auto & _image : elem.second)
|
||||||
delete _image.second;
|
delete _image.second;
|
||||||
@ -1171,13 +1171,12 @@ std::set<CAnimation*> CAnimation::loadedAnims;
|
|||||||
|
|
||||||
void CAnimation::getAnimInfo()
|
void CAnimation::getAnimInfo()
|
||||||
{
|
{
|
||||||
logGlobal->errorStream()<<"Animation stats: Loaded "<<loadedAnims.size()<<" total";
|
logGlobal->errorStream() << "Animation stats: Loaded " << loadedAnims.size() << " total";
|
||||||
for (auto anim : loadedAnims)
|
for(auto anim : loadedAnims)
|
||||||
{
|
{
|
||||||
|
logGlobal->errorStream() << "Name: " << anim->name << " Groups: " << anim->images.size();
|
||||||
logGlobal->errorStream()<<"Name: "<<anim->name<<" Groups: "<<anim->images.size();
|
if(!anim->images.empty())
|
||||||
if (!anim->images.empty())
|
logGlobal->errorStream() << ", " << anim->images.begin()->second.size() << " image loaded in group " << anim->images.begin()->first;
|
||||||
logGlobal->errorStream()<<", "<<anim->images.begin()->second.size()<<" image loaded in group "<< anim->images.begin()->first;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 3: return blit8bppAlphaTo24bppT<3>(src, srcRect, dst, dstRect);
|
||||||
case 4: return blit8bppAlphaTo24bppT<4>(src, srcRect, dst, dstRect);
|
case 4: return blit8bppAlphaTo24bppT<4>(src, srcRect, dst, dstRect);
|
||||||
default:
|
default:
|
||||||
logGlobal->errorStream() << (int)dst->format->BitsPerPixel << " bpp is not supported!!!";
|
logGlobal->errorStream() << (int)dst->format->BitsPerPixel << " bpp is not supported!!!";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -556,7 +556,7 @@ void CSDL_Ext::setPlayerColor(SDL_Surface * sur, PlayerColor player)
|
|||||||
SDL_SetColors(sur, color, 5, 1);
|
SDL_SetColors(sur, color, 5, 1);
|
||||||
}
|
}
|
||||||
else
|
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)
|
TColorPutter CSDL_Ext::getPutterFor(SDL_Surface * const &dest, int incrementing)
|
||||||
@ -577,7 +577,7 @@ case BytesPerPixel: \
|
|||||||
CASE_BPP(3)
|
CASE_BPP(3)
|
||||||
CASE_BPP(4)
|
CASE_BPP(4)
|
||||||
default:
|
default:
|
||||||
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << "bpp is not supported!";
|
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << "bpp is not supported!";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,7 +591,7 @@ TColorPutterAlpha CSDL_Ext::getPutterAlphaFor(SDL_Surface * const &dest, int inc
|
|||||||
CASE_BPP(3)
|
CASE_BPP(3)
|
||||||
CASE_BPP(4)
|
CASE_BPP(4)
|
||||||
default:
|
default:
|
||||||
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << "bpp is not supported!";
|
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << "bpp is not supported!";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
#undef CASE_BPP
|
#undef CASE_BPP
|
||||||
@ -675,7 +675,7 @@ BlitterWithRotationVal CSDL_Ext::getBlitterWithRotation(SDL_Surface *dest)
|
|||||||
case 3: return blitWithRotateClipVal<3>;
|
case 3: return blitWithRotateClipVal<3>;
|
||||||
case 4: return blitWithRotateClipVal<4>;
|
case 4: return blitWithRotateClipVal<4>;
|
||||||
default:
|
default:
|
||||||
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << " bpp is not supported!!!";
|
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << " bpp is not supported!!!";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,7 +691,7 @@ BlitterWithRotationVal CSDL_Ext::getBlitterWithRotationAndAlpha(SDL_Surface *des
|
|||||||
case 3: return blitWithRotateClipValWithAlpha<3>;
|
case 3: return blitWithRotateClipValWithAlpha<3>;
|
||||||
case 4: return blitWithRotateClipValWithAlpha<4>;
|
case 4: return blitWithRotateClipValWithAlpha<4>;
|
||||||
default:
|
default:
|
||||||
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << " bpp is not supported!!!";
|
logGlobal->errorStream() << (int)dest->format->BitsPerPixel << " bpp is not supported!!!";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ void CGarrisonSlot::hover (bool on)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "Warning - shouldn't be - highlighted void slot "<<owner->getSelection();
|
logGlobal->warnStream() << "Warning - shouldn't be - highlighted void slot "<<owner->getSelection();
|
||||||
logGlobal->warnStream() << "Highlighted set to nullptr";
|
logGlobal->warnStream() << "Highlighted set to nullptr";
|
||||||
owner->selectSlot(nullptr);
|
owner->selectSlot(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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):
|
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),
|
CLabel(position.x, position.y, Font, Align, Color, Text),
|
||||||
visibleSize(0, 0, position.w, position.h)
|
visibleSize(0, 0, position.w, position.h)
|
||||||
{
|
{
|
||||||
pos.w = position.w;
|
pos.w = position.w;
|
||||||
pos.h = position.h;
|
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*/):
|
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),
|
sliderStyle(SliderStyle),
|
||||||
slider(nullptr)
|
slider(nullptr)
|
||||||
{
|
{
|
||||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||||
label = new CMultiLineLabel(rect, Font, Align, Color);
|
label = new CMultiLineLabel(rect, Font, Align, Color);
|
||||||
@ -326,7 +326,7 @@ CGStatusBar::CGStatusBar(CPicture *BG, EFonts Font /*= FONT_SMALL*/, EAlignment
|
|||||||
addChild(bg);
|
addChild(bg);
|
||||||
pos = bg->pos;
|
pos = bg->pos;
|
||||||
getBorderSize();
|
getBorderSize();
|
||||||
textLock = false;
|
textLock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGStatusBar::CGStatusBar(int x, int y, std::string name/*="ADROLLVR.bmp"*/, int maxw/*=-1*/)
|
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);
|
vstd::amin(pos.w, maxw);
|
||||||
bg->srcRect = new Rect(0, 0, maxw, pos.h);
|
bg->srcRect = new Rect(0, 0, maxw, pos.h);
|
||||||
}
|
}
|
||||||
textLock = false;
|
textLock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGStatusBar::~CGStatusBar()
|
CGStatusBar::~CGStatusBar()
|
||||||
@ -351,7 +351,7 @@ CGStatusBar::~CGStatusBar()
|
|||||||
|
|
||||||
void CGStatusBar::show(SDL_Surface * to)
|
void CGStatusBar::show(SDL_Surface * to)
|
||||||
{
|
{
|
||||||
showAll(to);
|
showAll(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGStatusBar::init()
|
void CGStatusBar::init()
|
||||||
@ -377,12 +377,12 @@ Point CGStatusBar::getBorderSize()
|
|||||||
|
|
||||||
void CGStatusBar::lock(bool shouldLock)
|
void CGStatusBar::lock(bool shouldLock)
|
||||||
{
|
{
|
||||||
textLock = shouldLock;
|
textLock = shouldLock;
|
||||||
}
|
}
|
||||||
|
|
||||||
CTextInput::CTextInput(const Rect &Pos, EFonts font, const CFunctionList<void(const std::string &)> &CB):
|
CTextInput::CTextInput(const Rect &Pos, EFonts font, const CFunctionList<void(const std::string &)> &CB):
|
||||||
CLabel(Pos.x, Pos.y, font, CENTER),
|
CLabel(Pos.x, Pos.y, font, CENTER),
|
||||||
cb(CB)
|
cb(CB)
|
||||||
{
|
{
|
||||||
type |= REDRAW_PARENT;
|
type |= REDRAW_PARENT;
|
||||||
focus = false;
|
focus = false;
|
||||||
@ -570,7 +570,7 @@ void CTextInput::numberFilter(std::string & text, const std::string & oldText, i
|
|||||||
catch(boost::bad_lexical_cast &)
|
catch(boost::bad_lexical_cast &)
|
||||||
{
|
{
|
||||||
//Should never happen. Unless I missed some cases
|
//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;
|
text = oldText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ void CBuildingRect::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CDwellingInfoBox::CDwellingInfoBox(int centerX, int centerY, const CGTownInstance *Town, int level):
|
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;
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||||
|
|
||||||
@ -601,7 +601,7 @@ const CGHeroInstance* CCastleBuildings::getHero()
|
|||||||
|
|
||||||
void CCastleBuildings::buildingClicked(BuildingID building)
|
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;
|
const CBuilding *b = town->town->buildings.find(building)->second;
|
||||||
|
|
||||||
if(building >= BuildingID::DWELL_FIRST)
|
if(building >= BuildingID::DWELL_FIRST)
|
||||||
@ -877,7 +877,7 @@ void CCastleBuildings::openTownHall()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInstance * from):
|
CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInstance * from):
|
||||||
CWindowObject(PLAYER_COLORED | BORDERED),
|
CWindowObject(PLAYER_COLORED | BORDERED),
|
||||||
hall(nullptr),
|
hall(nullptr),
|
||||||
fort(nullptr),
|
fort(nullptr),
|
||||||
town(Town)
|
town(Town)
|
||||||
@ -1180,7 +1180,7 @@ void CCastleInterface::keyPressed( const SDL_KeyboardEvent & key )
|
|||||||
for(const CStructure * str : town->town->clientInfo.structures)
|
for(const CStructure * str : town->town->clientInfo.structures)
|
||||||
{
|
{
|
||||||
if (str->building)
|
if (str->building)
|
||||||
logGlobal->errorStream() << int(str->building->bid) << " -> " << int(str->pos.z);
|
logGlobal->errorStream() << int(str->building->bid) << " -> " << int(str->pos.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1196,7 +1196,7 @@ void CCastleInterface::keyPressed( const SDL_KeyboardEvent & key )
|
|||||||
for(const CStructure * str : town->town->clientInfo.structures)
|
for(const CStructure * str : town->town->clientInfo.structures)
|
||||||
{
|
{
|
||||||
if (str->building)
|
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):
|
CHallInterface::CHallInterface(const CGTownInstance *Town):
|
||||||
CWindowObject(PLAYER_COLORED | BORDERED, Town->town->clientInfo.hallBackground),
|
CWindowObject(PLAYER_COLORED | BORDERED, Town->town->clientInfo.hallBackground),
|
||||||
town(Town)
|
town(Town)
|
||||||
{
|
{
|
||||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
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):
|
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),
|
town(Town),
|
||||||
building(Building)
|
building(Building)
|
||||||
{
|
{
|
||||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||||
|
|
||||||
@ -1447,7 +1447,7 @@ std::string CFortScreen::getBgName(const CGTownInstance *town)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CFortScreen::CFortScreen(const CGTownInstance * town):
|
CFortScreen::CFortScreen(const CGTownInstance * town):
|
||||||
CWindowObject(PLAYER_COLORED | BORDERED, getBgName(town))
|
CWindowObject(PLAYER_COLORED | BORDERED, getBgName(town))
|
||||||
{
|
{
|
||||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||||
ui32 fortSize = town->creatures.size();
|
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):
|
CBlacksmithDialog::CBlacksmithDialog(bool possible, CreatureID creMachineID, ArtifactID aid, ObjectInstanceID hid):
|
||||||
CWindowObject(PLAYER_COLORED, "TPSMITH")
|
CWindowObject(PLAYER_COLORED, "TPSMITH")
|
||||||
{
|
{
|
||||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
|
|||||||
|
|
||||||
if(!hero) //something strange... no hero? it shouldn't happen
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,11 +34,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
CTradeWindow::CTradeableItem::CTradeableItem(Point pos, EType Type, int ID, bool Left, int Serial):
|
CTradeWindow::CTradeableItem::CTradeableItem(Point pos, EType Type, int ID, bool Left, int Serial):
|
||||||
CIntObject(LCLICK | HOVER | RCLICK, pos),
|
CIntObject(LCLICK | HOVER | RCLICK, pos),
|
||||||
type(EType(-1)),// set to invalid, will be corrected in setType
|
type(EType(-1)),// set to invalid, will be corrected in setType
|
||||||
id(ID),
|
id(ID),
|
||||||
serial(Serial),
|
serial(Serial),
|
||||||
left(Left)
|
left(Left)
|
||||||
{
|
{
|
||||||
downSelection = false;
|
downSelection = false;
|
||||||
hlp = nullptr;
|
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):
|
CTradeWindow::CTradeWindow(std::string bgName, const IMarket *Market, const CGHeroInstance *Hero, EMarketMode::EMarketMode Mode):
|
||||||
CWindowObject(PLAYER_COLORED, bgName),
|
CWindowObject(PLAYER_COLORED, bgName),
|
||||||
market(Market),
|
market(Market),
|
||||||
hero(Hero),
|
hero(Hero),
|
||||||
arts(nullptr),
|
arts(nullptr),
|
||||||
hLeft(nullptr),
|
hLeft(nullptr),
|
||||||
hRight(nullptr),
|
hRight(nullptr),
|
||||||
readyToTrade(false)
|
readyToTrade(false)
|
||||||
{
|
{
|
||||||
type |= BLOCK_ADV_HOTKEYS;
|
type |= BLOCK_ADV_HOTKEYS;
|
||||||
mode = Mode;
|
mode = Mode;
|
||||||
@ -657,7 +657,7 @@ std::string CMarketplaceWindow::getBackgroundForMode(EMarketMode::EMarketMode mo
|
|||||||
}
|
}
|
||||||
|
|
||||||
CMarketplaceWindow::CMarketplaceWindow(const IMarket *Market, const CGHeroInstance *Hero, EMarketMode::EMarketMode Mode)
|
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;
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||||
|
|
||||||
@ -1471,7 +1471,7 @@ bool CAltarWindow::putOnAltar(CTradeableItem* altarSlot, const CArtifactInstance
|
|||||||
{
|
{
|
||||||
if(!art->artType->isTradable()) //special art
|
if(!art->artType->isTradable()) //special art
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "Cannot put special artifact on altar!";
|
logGlobal->warnStream() << "Cannot put special artifact on altar!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1480,7 +1480,7 @@ bool CAltarWindow::putOnAltar(CTradeableItem* altarSlot, const CArtifactInstance
|
|||||||
int slotIndex = firstFreeSlot();
|
int slotIndex = firstFreeSlot();
|
||||||
if(slotIndex < 0)
|
if(slotIndex < 0)
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "No free slots on altar!";
|
logGlobal->warnStream() << "No free slots on altar!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
altarSlot = items[0][slotIndex];
|
altarSlot = items[0][slotIndex];
|
||||||
|
@ -665,7 +665,7 @@ ui8 BattleInfo::whatSide(PlayerColor player) const
|
|||||||
if(sides[i].color == player)
|
if(sides[i].color == player)
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
logGlobal->warnStream() << "BattleInfo::whatSide: Player " << player << " is not in battle!";
|
logGlobal->warnStream() << "BattleInfo::whatSide: Player " << player << " is not in battle!";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ public:
|
|||||||
else if(!army || slot == SlotID() || !army->hasStackAtSlot(slot))
|
else if(!army || slot == SlotID() || !army->hasStackAtSlot(slot))
|
||||||
{
|
{
|
||||||
base = nullptr;
|
base = nullptr;
|
||||||
logGlobal->warnStream() << type->nameSing << " doesn't have a base stack!";
|
logGlobal->warnStream() << type->nameSing << " doesn't have a base stack!";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -414,7 +414,7 @@ void CArtHandler::loadType(CArtifact * art, const JsonNode & node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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);
|
artifactList->erase(itr);
|
||||||
}
|
}
|
||||||
else
|
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
|
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 )
|
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());
|
auto possibleSlots = artType->possibleSlots.find(artSet->bearerType());
|
||||||
if(possibleSlots == artType->possibleSlots.end())
|
if(possibleSlots == artType->possibleSlots.end())
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "Warning: artifact " << artType->Name() << " doesn't have defined allowed slots for bearer of type "
|
logGlobal->warnStream() << "Warning: artifact " << artType->Name() << " doesn't have defined allowed slots for bearer of type "
|
||||||
<< artSet->bearerType();
|
<< artSet->bearerType();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1341,7 +1341,7 @@ si32 CArtifactSet::getArtTypeId(ArtifactPosition pos) const
|
|||||||
const CArtifactInstance * const a = getArt(pos);
|
const CArtifactInstance * const a = getArt(pos);
|
||||||
if(!a)
|
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 -1;
|
||||||
}
|
}
|
||||||
return a->artType->id;
|
return a->artType->id;
|
||||||
|
@ -144,7 +144,7 @@ std::vector<std::shared_ptr<const CObstacleInstance> > CBattleInfoEssentials::ba
|
|||||||
{
|
{
|
||||||
if(!!player && *perspective != battleGetMySide())
|
if(!!player && *perspective != battleGetMySide())
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Unauthorized access attempt!";
|
logGlobal->errorStream() << "Unauthorized access attempt!";
|
||||||
assert(0); //I want to notice if that happens
|
assert(0); //I want to notice if that happens
|
||||||
//perspective = battleGetMySide();
|
//perspective = battleGetMySide();
|
||||||
}
|
}
|
||||||
@ -242,8 +242,8 @@ BattlePerspective::BattlePerspective CBattleInfoEssentials::battleGetMySide() co
|
|||||||
if(*player == getBattle()->sides[1].color)
|
if(*player == getBattle()->sides[1].color)
|
||||||
return BattlePerspective::RIGHT_SIDE;
|
return BattlePerspective::RIGHT_SIDE;
|
||||||
|
|
||||||
logGlobal->errorStream() << "Cannot find player " << *player << " in battle!";
|
logGlobal->errorStream() << "Cannot find player " << *player << " in battle!";
|
||||||
return BattlePerspective::INVALID;
|
return BattlePerspective::INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CStack * CBattleInfoEssentials::battleActiveStack() const
|
const CStack * CBattleInfoEssentials::battleActiveStack() const
|
||||||
@ -291,13 +291,13 @@ const CGHeroInstance * CBattleInfoEssentials::battleGetFightingHero(ui8 side) co
|
|||||||
RETURN_IF_NOT_BATTLE(nullptr);
|
RETURN_IF_NOT_BATTLE(nullptr);
|
||||||
if(side > 1)
|
if(side > 1)
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "FIXME: " << __FUNCTION__ << " wrong argument!";
|
logGlobal->errorStream() << "FIXME: " << __FUNCTION__ << " wrong argument!";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!battleDoWeKnowAbout(side))
|
if(!battleDoWeKnowAbout(side))
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "FIXME: " << __FUNCTION__ << " access check ";
|
logGlobal->errorStream() << "FIXME: " << __FUNCTION__ << " access check ";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ InfoAboutHero CBattleInfoEssentials::battleGetHeroInfo( ui8 side ) const
|
|||||||
auto hero = getBattle()->sides[side].hero;
|
auto hero = getBattle()->sides[side].hero;
|
||||||
if(!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();
|
return InfoAboutHero();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,7 +351,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastSpell(Pla
|
|||||||
const ui8 side = playerToSide(player);
|
const ui8 side = playerToSide(player);
|
||||||
if(!battleDoWeKnowAbout(side))
|
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;
|
return ESpellCastProblem::INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +411,7 @@ ui8 CBattleInfoEssentials::playerToSide(PlayerColor player) const
|
|||||||
RETURN_IF_NOT_BATTLE(-1);
|
RETURN_IF_NOT_BATTLE(-1);
|
||||||
int ret = vstd::find_pos_if(getBattle()->sides, [=](const SideInBattle &side){ return side.color == player; });
|
int ret = vstd::find_pos_if(getBattle()->sides, [=](const SideInBattle &side){ return side.color == player; });
|
||||||
if(ret < 0)
|
if(ret < 0)
|
||||||
logGlobal->warnStream() << "Cannot find side for player " << player;
|
logGlobal->warnStream() << "Cannot find side for player " << player;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -532,7 +532,7 @@ SpellID CBattleInfoCallback::battleGetRandomStackSpell(const CStack * stack, ERa
|
|||||||
return getRandomCastedSpell(stack); //caster
|
return getRandomCastedSpell(stack); //caster
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logGlobal->errorStream() << "Incorrect mode of battleGetRandomSpell (" << mode <<")";
|
logGlobal->errorStream() << "Incorrect mode of battleGetRandomSpell (" << mode <<")";
|
||||||
return SpellID::NONE;
|
return SpellID::NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1697,13 +1697,13 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
|
|||||||
const CSpell::TargetInfo ti(spell, caster->getSpellSchoolLevel(spell));
|
const CSpell::TargetInfo ti(spell, caster->getSpellSchoolLevel(spell));
|
||||||
bool targetExists = false;
|
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 immune = ESpellCastProblem::OK != spell->isImmuneByStack(caster, stack);
|
||||||
bool casterStack = stack->owner == caster->getOwner();
|
bool casterStack = stack->owner == caster->getOwner();
|
||||||
|
|
||||||
if(!immune)
|
if(!immune)
|
||||||
{
|
{
|
||||||
switch (spell->positiveness)
|
switch (spell->positiveness)
|
||||||
{
|
{
|
||||||
case CSpell::POSITIVE:
|
case CSpell::POSITIVE:
|
||||||
@ -1724,9 +1724,9 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!targetExists)
|
if(!targetExists)
|
||||||
{
|
{
|
||||||
return ESpellCastProblem::NO_APPROPRIATE_TARGET;
|
return ESpellCastProblem::NO_APPROPRIATE_TARGET;
|
||||||
}
|
}
|
||||||
@ -1777,7 +1777,7 @@ std::vector<BattleHex> CBattleInfoCallback::battleGetPossibleTargets(PlayerColor
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
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;
|
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.
|
// All hexes that stack would cover if standing on tile have to be accessible.
|
||||||
for(auto hex : CStack::getHexes(tile, doubleWide, attackerOwned))
|
for(auto hex : CStack::getHexes(tile, doubleWide, attackerOwned))
|
||||||
{
|
{
|
||||||
// If the hex is out of range then the tile isn't accessible
|
// If the hex is out of range then the tile isn't accessible
|
||||||
if(!hex.isValid())
|
if(!hex.isValid())
|
||||||
return false;
|
return false;
|
||||||
// If we're no defender which step on gate and the hex isn't accessible, then the tile
|
// If we're no defender which step on gate and the hex isn't accessible, then the tile
|
||||||
// isn't accessible
|
// isn't accessible
|
||||||
else if(at(hex) != EAccessibility::ACCESSIBLE &&
|
else if(at(hex) != EAccessibility::ACCESSIBLE &&
|
||||||
!(at(hex) == EAccessibility::GATE && !attackerOwned))
|
!(at(hex) == EAccessibility::GATE && !attackerOwned))
|
||||||
return false;
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ MacroString::MacroString(const std::string &format)
|
|||||||
|
|
||||||
if (end_pos == std::string::npos)
|
if (end_pos == std::string::npos)
|
||||||
{
|
{
|
||||||
logBonus->warnStream() << "Format error in: " << format;
|
logBonus->warnStream() << "Format error in: " << format;
|
||||||
end_pos = start_pos;
|
end_pos = start_pos;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ std::string CBonusTypeHandler::bonusToString(const Bonus *bonus, const IBonusBea
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logBonus->warnStream() << "Unknown macro in bonus config: " << name;
|
logBonus->warnStream() << "Unknown macro in bonus config: " << name;
|
||||||
return "[error]";
|
return "[error]";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -286,14 +286,14 @@ void CBonusTypeHandler::load(const JsonNode& config)
|
|||||||
//
|
//
|
||||||
// bonusTypes.push_back(bt);
|
// bonusTypes.push_back(bt);
|
||||||
|
|
||||||
logBonus->warnStream() << "Adding new bonuses not implemented (" << node.first << ")";
|
logBonus->warnStream() << "Adding new bonuses not implemented (" << node.first << ")";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CBonusType& bt = bonusTypes[it->second];
|
CBonusType& bt = bonusTypes[it->second];
|
||||||
|
|
||||||
loadItem(node.second, bt);
|
loadItem(node.second, bt);
|
||||||
logBonus->traceStream() << "Loaded bonus type " << node.first;
|
logBonus->traceStream() << "Loaded bonus type " << node.first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,16 +57,16 @@ void printWinError()
|
|||||||
int error = GetLastError();
|
int error = GetLastError();
|
||||||
if(!error)
|
if(!error)
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "No Win error information set.";
|
logGlobal->errorStream() << "No Win error information set.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logGlobal->errorStream() << "Error " << error << " encountered:";
|
logGlobal->errorStream() << "Error " << error << " encountered:";
|
||||||
|
|
||||||
//Get error description
|
//Get error description
|
||||||
char* pTemp = nullptr;
|
char* pTemp = nullptr;
|
||||||
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
|
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
nullptr, error, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), (LPSTR)&pTemp, 1, nullptr);
|
nullptr, error, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), (LPSTR)&pTemp, 1, nullptr);
|
||||||
logGlobal->errorStream() << pTemp;
|
logGlobal->errorStream() << pTemp;
|
||||||
LocalFree( pTemp );
|
LocalFree( pTemp );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,19 +107,19 @@ const char* exceptionName(DWORD exc)
|
|||||||
|
|
||||||
LONG WINAPI onUnhandledException(EXCEPTION_POINTERS* exception)
|
LONG WINAPI onUnhandledException(EXCEPTION_POINTERS* exception)
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Disaster happened.";
|
logGlobal->errorStream() << "Disaster happened.";
|
||||||
|
|
||||||
PEXCEPTION_RECORD einfo = exception->ExceptionRecord;
|
PEXCEPTION_RECORD einfo = exception->ExceptionRecord;
|
||||||
logGlobal->errorStream() << "Reason: 0x" << std::hex << einfo->ExceptionCode << " - " << exceptionName(einfo->ExceptionCode)
|
logGlobal->errorStream() << "Reason: 0x" << std::hex << einfo->ExceptionCode << " - " << exceptionName(einfo->ExceptionCode)
|
||||||
<< " at " << std::setfill('0') << std::setw(4) << exception->ContextRecord->SegCs << ":" << (void*)einfo->ExceptionAddress;
|
<< " at " << std::setfill('0') << std::setw(4) << exception->ContextRecord->SegCs << ":" << (void*)einfo->ExceptionAddress;
|
||||||
|
|
||||||
if (einfo->ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
|
if (einfo->ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Attempt to " << (einfo->ExceptionInformation[0] == 1 ? "write to " : "read from ")
|
logGlobal->errorStream() << "Attempt to " << (einfo->ExceptionInformation[0] == 1 ? "write to " : "read from ")
|
||||||
<< "0x" << std::setw(8) << (void*)einfo->ExceptionInformation[1];
|
<< "0x" << std::setw(8) << (void*)einfo->ExceptionInformation[1];
|
||||||
}
|
}
|
||||||
const DWORD threadId = ::GetCurrentThreadId();
|
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
|
//exception info to be placed in the dump
|
||||||
MINIDUMP_EXCEPTION_INFORMATION meinfo = {threadId, exception, TRUE};
|
MINIDUMP_EXCEPTION_INFORMATION meinfo = {threadId, exception, TRUE};
|
||||||
@ -137,7 +137,7 @@ LONG WINAPI onUnhandledException(EXCEPTION_POINTERS* exception)
|
|||||||
|
|
||||||
strcat(mname, "_crashinfo.dmp");
|
strcat(mname, "_crashinfo.dmp");
|
||||||
HANDLE dfile = CreateFileA(mname, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0);
|
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);
|
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);
|
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;
|
return EXCEPTION_EXECUTE_HANDLER;
|
||||||
@ -147,35 +147,35 @@ LONG WINAPI onUnhandledException(EXCEPTION_POINTERS* exception)
|
|||||||
|
|
||||||
void CConsoleHandler::setColor(EConsoleTextColor::EConsoleTextColor color)
|
void CConsoleHandler::setColor(EConsoleTextColor::EConsoleTextColor color)
|
||||||
{
|
{
|
||||||
TColor colorCode;
|
TColor colorCode;
|
||||||
switch(color)
|
switch(color)
|
||||||
{
|
{
|
||||||
case EConsoleTextColor::DEFAULT:
|
case EConsoleTextColor::DEFAULT:
|
||||||
colorCode = defColor;
|
colorCode = defColor;
|
||||||
break;
|
break;
|
||||||
case EConsoleTextColor::GREEN:
|
case EConsoleTextColor::GREEN:
|
||||||
colorCode = CONSOLE_GREEN;
|
colorCode = CONSOLE_GREEN;
|
||||||
break;
|
break;
|
||||||
case EConsoleTextColor::RED:
|
case EConsoleTextColor::RED:
|
||||||
colorCode = CONSOLE_RED;
|
colorCode = CONSOLE_RED;
|
||||||
break;
|
break;
|
||||||
case EConsoleTextColor::MAGENTA:
|
case EConsoleTextColor::MAGENTA:
|
||||||
colorCode = CONSOLE_MAGENTA;
|
colorCode = CONSOLE_MAGENTA;
|
||||||
break;
|
break;
|
||||||
case EConsoleTextColor::YELLOW:
|
case EConsoleTextColor::YELLOW:
|
||||||
colorCode = CONSOLE_YELLOW;
|
colorCode = CONSOLE_YELLOW;
|
||||||
break;
|
break;
|
||||||
case EConsoleTextColor::WHITE:
|
case EConsoleTextColor::WHITE:
|
||||||
colorCode = CONSOLE_WHITE;
|
colorCode = CONSOLE_WHITE;
|
||||||
break;
|
break;
|
||||||
case EConsoleTextColor::GRAY:
|
case EConsoleTextColor::GRAY:
|
||||||
colorCode = CONSOLE_GRAY;
|
colorCode = CONSOLE_GRAY;
|
||||||
break;
|
break;
|
||||||
case EConsoleTextColor::TEAL:
|
case EConsoleTextColor::TEAL:
|
||||||
colorCode = CONSOLE_TEAL;
|
colorCode = CONSOLE_TEAL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
colorCode = defColor;
|
colorCode = defColor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef VCMI_WINDOWS
|
#ifdef VCMI_WINDOWS
|
||||||
@ -236,14 +236,14 @@ CConsoleHandler::CConsoleHandler() : thread(nullptr)
|
|||||||
#else
|
#else
|
||||||
defColor = "\x1b[0m";
|
defColor = "\x1b[0m";
|
||||||
#endif
|
#endif
|
||||||
cb = new std::function<void(const std::string &)>;
|
cb = new std::function<void(const std::string &)>;
|
||||||
}
|
}
|
||||||
CConsoleHandler::~CConsoleHandler()
|
CConsoleHandler::~CConsoleHandler()
|
||||||
{
|
{
|
||||||
logGlobal->infoStream() << "Killing console...";
|
logGlobal->infoStream() << "Killing console...";
|
||||||
end();
|
end();
|
||||||
delete cb;
|
delete cb;
|
||||||
logGlobal->infoStream() << "Killing console... done!";
|
logGlobal->infoStream() << "Killing console... done!";
|
||||||
}
|
}
|
||||||
void CConsoleHandler::end()
|
void CConsoleHandler::end()
|
||||||
{
|
{
|
||||||
|
@ -161,7 +161,7 @@ static void AddAbility(CCreature *cre, const JsonVector &ability_vec)
|
|||||||
cre->addBonus(-1, Bonus::LUCK);
|
cre->addBonus(-1, Bonus::LUCK);
|
||||||
cre->getBonusList().back()->effectRange = Bonus::ONLY_ENEMY_ARMY;
|
cre->getBonusList().back()->effectRange = Bonus::ONLY_ENEMY_ARMY;
|
||||||
} else
|
} else
|
||||||
logGlobal->errorStream() << "Error: invalid ability type " << type << " in creatures config";
|
logGlobal->errorStream() << "Error: invalid ability type " << type << " in creatures config";
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -242,15 +242,15 @@ void CCreatureHandler::loadBonuses(JsonNode & creature, std::string bonuses)
|
|||||||
|
|
||||||
static const std::map<std::string, JsonNode> abilityMap =
|
static const std::map<std::string, JsonNode> abilityMap =
|
||||||
{
|
{
|
||||||
{"FLYING_ARMY", makeBonusNode("FLYING")},
|
{"FLYING_ARMY", makeBonusNode("FLYING")},
|
||||||
{"SHOOTING_ARMY", makeBonusNode("SHOOTER")},
|
{"SHOOTING_ARMY", makeBonusNode("SHOOTER")},
|
||||||
{"SIEGE_WEAPON", makeBonusNode("SIEGE_WEAPON")},
|
{"SIEGE_WEAPON", makeBonusNode("SIEGE_WEAPON")},
|
||||||
{"const_free_attack", makeBonusNode("BLOCKS_RETALIATION")},
|
{"const_free_attack", makeBonusNode("BLOCKS_RETALIATION")},
|
||||||
{"IS_UNDEAD", makeBonusNode("UNDEAD")},
|
{"IS_UNDEAD", makeBonusNode("UNDEAD")},
|
||||||
{"const_no_melee_penalty", makeBonusNode("NO_MELEE_PENALTY")},
|
{"const_no_melee_penalty", makeBonusNode("NO_MELEE_PENALTY")},
|
||||||
{"const_jousting", makeBonusNode("JOUSTING")},
|
{"const_jousting", makeBonusNode("JOUSTING")},
|
||||||
{"KING_1", makeBonusNode("KING1")},
|
{"KING_1", makeBonusNode("KING1")},
|
||||||
{"KING_2", makeBonusNode("KING2")},
|
{"KING_2", makeBonusNode("KING2")},
|
||||||
{"KING_3", makeBonusNode("KING3")},
|
{"KING_3", makeBonusNode("KING3")},
|
||||||
{"const_no_wall_penalty", makeBonusNode("NO_WALL_PENALTY")},
|
{"const_no_wall_penalty", makeBonusNode("NO_WALL_PENALTY")},
|
||||||
{"CATAPULT", makeBonusNode("CATAPULT")},
|
{"CATAPULT", makeBonusNode("CATAPULT")},
|
||||||
@ -895,7 +895,7 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
|
|||||||
case 'U':
|
case 'U':
|
||||||
b.type = Bonus::UNDEAD; break;
|
b.type = Bonus::UNDEAD; break;
|
||||||
default:
|
default:
|
||||||
logGlobal->traceStream() << "Not parsed bonus " << buf << mod;
|
logGlobal->traceStream() << "Not parsed bonus " << buf << mod;
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1005,7 +1005,7 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
|
|||||||
b.type = Bonus::MIND_IMMUNITY;
|
b.type = Bonus::MIND_IMMUNITY;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logGlobal->traceStream() << "Not parsed bonus " << buf << mod;
|
logGlobal->traceStream() << "Not parsed bonus " << buf << mod;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1046,7 +1046,7 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
|
|||||||
b.valType = Bonus::INDEPENDENT_MAX;
|
b.valType = Bonus::INDEPENDENT_MAX;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logGlobal->traceStream() << "Not parsed bonus " << buf << mod;
|
logGlobal->traceStream() << "Not parsed bonus " << buf << mod;
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1141,7 +1141,7 @@ CreatureID CCreatureHandler::pickRandomMonster(CRandomGenerator & rand, int tier
|
|||||||
|
|
||||||
if(!allowed.size())
|
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;
|
return CreatureID::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,12 +45,12 @@ bool CCreatureSet::setCreature(SlotID slot, CreatureID type, TQuantity quantity)
|
|||||||
{
|
{
|
||||||
if(!slot.validSlot())
|
if(!slot.validSlot())
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Cannot set slot " << slot;
|
logGlobal->errorStream() << "Cannot set slot " << slot;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!quantity)
|
if(!quantity)
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "Using set creature to delete stack?";
|
logGlobal->warnStream() << "Using set creature to delete stack?";
|
||||||
eraseStack(slot);
|
eraseStack(slot);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ void CCreatureSet::addToSlot(SlotID slot, CreatureID cre, TQuantity count, bool
|
|||||||
}
|
}
|
||||||
else
|
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
|
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];
|
CStackInstance *ret = stacks[slot];
|
||||||
|
|
||||||
//if(CArmedInstance *armedObj = castToArmyObj())
|
//if(CArmedInstance *armedObj = castToArmyObj())
|
||||||
if(ret)
|
if(ret)
|
||||||
{
|
{
|
||||||
ret->setArmyObj(nullptr); //detaches from current armyobj
|
ret->setArmyObj(nullptr); //detaches from current armyobj
|
||||||
assert(!ret->armyObj); //we failed detaching?
|
assert(!ret->armyObj); //we failed detaching?
|
||||||
}
|
}
|
||||||
|
|
||||||
stacks.erase(slot);
|
stacks.erase(slot);
|
||||||
|
@ -113,7 +113,7 @@ const CGObjectInstance* CGameInfoCallback::getObj(ObjectInstanceID objid, bool v
|
|||||||
if(oid < 0 || oid >= gs->map->objects.size())
|
if(oid < 0 || oid >= gs->map->objects.size())
|
||||||
{
|
{
|
||||||
if(verbose)
|
if(verbose)
|
||||||
logGlobal->errorStream() << "Cannot get object with id " << oid;
|
logGlobal->errorStream() << "Cannot get object with id " << oid;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,14 +121,14 @@ const CGObjectInstance* CGameInfoCallback::getObj(ObjectInstanceID objid, bool v
|
|||||||
if(!ret)
|
if(!ret)
|
||||||
{
|
{
|
||||||
if(verbose)
|
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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isVisible(ret, player) && ret->tempOwner != player)
|
if(!isVisible(ret, player) && ret->tempOwner != player)
|
||||||
{
|
{
|
||||||
if(verbose)
|
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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ std::shared_ptr<rett> createAny(const boost::filesystem::path& libpath, const st
|
|||||||
getAI = (TGetAIFun)dlsym(dll, methodName.c_str());
|
getAI = (TGetAIFun)dlsym(dll, methodName.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
logGlobal->errorStream() << "Error: " << dlerror();
|
logGlobal->errorStream() << "Error: " << dlerror();
|
||||||
#endif // VCMI_WINDOWS
|
#endif // VCMI_WINDOWS
|
||||||
if (!dll)
|
if (!dll)
|
||||||
{
|
{
|
||||||
@ -100,12 +100,12 @@ std::shared_ptr<rett> createAny(const boost::filesystem::path& libpath, const st
|
|||||||
#endif // VCMI_ANDROID
|
#endif // VCMI_ANDROID
|
||||||
|
|
||||||
getName(temp);
|
getName(temp);
|
||||||
logGlobal->infoStream() << "Loaded " << temp;
|
logGlobal->infoStream() << "Loaded " << temp;
|
||||||
|
|
||||||
std::shared_ptr<rett> ret;
|
std::shared_ptr<rett> ret;
|
||||||
getAI(ret);
|
getAI(ret);
|
||||||
if(!ret)
|
if(!ret)
|
||||||
logGlobal->errorStream() << "Cannot get AI!";
|
logGlobal->errorStream() << "Cannot get AI!";
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -204,13 +204,13 @@ void MetaString::getLocalString(const std::pair<ui8,ui32> &txt, std::string &dst
|
|||||||
vec = &VLC->generaltexth->capColors;
|
vec = &VLC->generaltexth->capColors;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logGlobal->errorStream() << "Failed string substitution because type is " << type;
|
logGlobal->errorStream() << "Failed string substitution because type is " << type;
|
||||||
dst = "#@#";
|
dst = "#@#";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(vec->size() <= ser)
|
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 = "#!#";
|
dst = "#!#";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -373,7 +373,7 @@ CGHeroInstance * CGameState::HeroesPool::pickHeroFor(bool native, PlayerColor pl
|
|||||||
|
|
||||||
if(player>=PlayerColor::PLAYER_LIMIT)
|
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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ CGHeroInstance * CGameState::HeroesPool::pickHeroFor(bool native, PlayerColor pl
|
|||||||
}
|
}
|
||||||
if(!pool.size())
|
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);
|
return pickHeroFor(false, player, town, available, rand);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -414,7 +414,7 @@ CGHeroInstance * CGameState::HeroesPool::pickHeroFor(bool native, PlayerColor pl
|
|||||||
}
|
}
|
||||||
if(!pool.size() || sum == 0)
|
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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -747,7 +747,7 @@ BattleInfo * CGameState::setupBattle(int3 tile, const CArmedInstance *armies[2],
|
|||||||
|
|
||||||
void CGameState::init(StartInfo * si)
|
void CGameState::init(StartInfo * si)
|
||||||
{
|
{
|
||||||
logGlobal->infoStream() << "\tUsing random seed: "<< si->seedToBeUsed;
|
logGlobal->infoStream() << "\tUsing random seed: "<< si->seedToBeUsed;
|
||||||
rand.setSeed(si->seedToBeUsed);
|
rand.setSeed(si->seedToBeUsed);
|
||||||
scenarioOps = CMemorySerializer::deepCopy(*si).release();
|
scenarioOps = CMemorySerializer::deepCopy(*si).release();
|
||||||
initialOpts = CMemorySerializer::deepCopy(*si).release();
|
initialOpts = CMemorySerializer::deepCopy(*si).release();
|
||||||
@ -765,17 +765,17 @@ void CGameState::init(StartInfo * si)
|
|||||||
initDuel();
|
initDuel();
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
logGlobal->errorStream() << "Wrong mode: " << (int)scenarioOps->mode;
|
logGlobal->errorStream() << "Wrong mode: " << (int)scenarioOps->mode;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
VLC->arth->initAllowedArtifactsList(map->allowedArtifact);
|
VLC->arth->initAllowedArtifactsList(map->allowedArtifact);
|
||||||
logGlobal->infoStream() << "Map loaded!";
|
logGlobal->infoStream() << "Map loaded!";
|
||||||
|
|
||||||
checkMapChecksum();
|
checkMapChecksum();
|
||||||
|
|
||||||
day = 0;
|
day = 0;
|
||||||
|
|
||||||
logGlobal->debugStream() << "Initialization:";
|
logGlobal->debugStream() << "Initialization:";
|
||||||
|
|
||||||
initPlayerStates();
|
initPlayerStates();
|
||||||
placeCampaignHeroes();
|
placeCampaignHeroes();
|
||||||
@ -792,11 +792,11 @@ void CGameState::init(StartInfo * si)
|
|||||||
initVisitingAndGarrisonedHeroes();
|
initVisitingAndGarrisonedHeroes();
|
||||||
initFogOfWar();
|
initFogOfWar();
|
||||||
|
|
||||||
logGlobal->debugStream() << "\tChecking objectives";
|
logGlobal->debugStream() << "\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();
|
||||||
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)
|
if(scenarioOps->seedPostInit > 0)
|
||||||
{
|
{
|
||||||
//RNG must be in the same state on all machines when initialization is done (otherwise we have desync)
|
//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"))
|
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);
|
dp = DuelParameters::fromJSON(scenarioOps->mapname);
|
||||||
logGlobal->infoStream() << "JSON file has been successfully read!";
|
logGlobal->infoStream() << "JSON file has been successfully read!";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -884,7 +884,7 @@ void CGameState::initDuel()
|
|||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Cannot load duel settings from " << scenarioOps->mapname;
|
logGlobal->errorStream() << "Cannot load duel settings from " << scenarioOps->mapname;
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2109,7 +2109,7 @@ std::vector<CGObjectInstance*> CGameState::guardingCreatures (int3 pos) const
|
|||||||
if (map->isInTheMap(pos))
|
if (map->isInTheMap(pos))
|
||||||
{
|
{
|
||||||
const auto & tile = map->getTile(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)
|
for (CGObjectInstance* obj : tile.visitableObjects)
|
||||||
{
|
{
|
||||||
@ -2668,11 +2668,11 @@ void CGameState::obtainPlayersStats(SThievesGuildInfo & tgi, int level)
|
|||||||
continue;
|
continue;
|
||||||
if(g->second.human)
|
if(g->second.human)
|
||||||
{
|
{
|
||||||
tgi.personality[g->second.color] = EAiTactic::NONE;
|
tgi.personality[g->second.color] = EAiTactic::NONE;
|
||||||
}
|
}
|
||||||
else //AI
|
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;
|
auto hero = *it;
|
||||||
crossoverHeroes.removeHeroFromBothLists(hero);
|
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];
|
auto heroPlaceholder = heroPlaceholders[i];
|
||||||
if(crossoverHeroes.heroesFromPreviousScenario.size() > i)
|
if(crossoverHeroes.heroesFromPreviousScenario.size() > i)
|
||||||
{
|
{
|
||||||
auto hero = crossoverHeroes.heroesFromPreviousScenario[i];
|
auto hero = crossoverHeroes.heroesFromPreviousScenario[i];
|
||||||
campaignHeroReplacements.push_back(CampaignHeroReplacement(CMemorySerializer::deepCopy(*hero).release(), heroPlaceholder->id));
|
campaignHeroReplacements.push_back(CampaignHeroReplacement(CMemorySerializer::deepCopy(*hero).release(), heroPlaceholder->id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2948,7 +2948,7 @@ bool RumorState::update(int id, int extra)
|
|||||||
}
|
}
|
||||||
|
|
||||||
InfoAboutArmy::InfoAboutArmy():
|
InfoAboutArmy::InfoAboutArmy():
|
||||||
owner(PlayerColor::NEUTRAL)
|
owner(PlayerColor::NEUTRAL)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
InfoAboutArmy::InfoAboutArmy(const CArmedInstance *Army, bool detailed)
|
InfoAboutArmy::InfoAboutArmy(const CArmedInstance *Army, bool detailed)
|
||||||
@ -2973,13 +2973,13 @@ void InfoAboutHero::assign(const InfoAboutHero & iah)
|
|||||||
}
|
}
|
||||||
|
|
||||||
InfoAboutHero::InfoAboutHero():
|
InfoAboutHero::InfoAboutHero():
|
||||||
details(nullptr),
|
details(nullptr),
|
||||||
hclass(nullptr),
|
hclass(nullptr),
|
||||||
portrait(-1)
|
portrait(-1)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
InfoAboutHero::InfoAboutHero(const InfoAboutHero & iah):
|
InfoAboutHero::InfoAboutHero(const InfoAboutHero & iah):
|
||||||
InfoAboutArmy()
|
InfoAboutArmy()
|
||||||
{
|
{
|
||||||
assign(iah);
|
assign(iah);
|
||||||
}
|
}
|
||||||
@ -3031,10 +3031,10 @@ void InfoAboutHero::initFromHero(const CGHeroInstance *h, bool detailed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
InfoAboutTown::InfoAboutTown():
|
InfoAboutTown::InfoAboutTown():
|
||||||
details(nullptr),
|
details(nullptr),
|
||||||
tType(nullptr),
|
tType(nullptr),
|
||||||
built(0),
|
built(0),
|
||||||
fortLevel(0)
|
fortLevel(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -3071,7 +3071,7 @@ void InfoAboutTown::initFromTown(const CGTownInstance *t, bool detailed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArmyDescriptor::ArmyDescriptor(const CArmedInstance *army, bool detailed)
|
ArmyDescriptor::ArmyDescriptor(const CArmedInstance *army, bool detailed)
|
||||||
: isDetailed(detailed)
|
: isDetailed(detailed)
|
||||||
{
|
{
|
||||||
for(auto & elem : army->Slots())
|
for(auto & elem : army->Slots())
|
||||||
{
|
{
|
||||||
@ -3083,7 +3083,7 @@ ArmyDescriptor::ArmyDescriptor(const CArmedInstance *army, bool detailed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArmyDescriptor::ArmyDescriptor()
|
ArmyDescriptor::ArmyDescriptor()
|
||||||
: isDetailed(false)
|
: isDetailed(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -3120,8 +3120,8 @@ DuelParameters::SideSettings::SideSettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
DuelParameters::DuelParameters():
|
DuelParameters::DuelParameters():
|
||||||
terType(ETerrainType::DIRT),
|
terType(ETerrainType::DIRT),
|
||||||
bfieldType(BFieldType::ROCKLANDS)
|
bfieldType(BFieldType::ROCKLANDS)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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->errorStream() << "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->warnStream() << "A hero has reached unsupported amount of experience";
|
||||||
return expPerLevel[expPerLevel.size()-1];
|
return expPerLevel[expPerLevel.size()-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ CIdentifierStorage::CIdentifierStorage():
|
|||||||
void CIdentifierStorage::checkIdentifier(std::string & ID)
|
void CIdentifierStorage::checkIdentifier(std::string & ID)
|
||||||
{
|
{
|
||||||
if (boost::algorithm::ends_with(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
|
else
|
||||||
{
|
{
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
@ -43,7 +43,7 @@ void CIdentifierStorage::checkIdentifier(std::string & ID)
|
|||||||
{
|
{
|
||||||
if (std::tolower(ID[pos]) != ID[pos] ) //Not in camelCase
|
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
|
ID[pos] = std::tolower(ID[pos]);// Try to fix the ID
|
||||||
}
|
}
|
||||||
pos = ID.find('.', pos);
|
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,
|
CIdentifierStorage::ObjectCallback::ObjectCallback(std::string localScope, std::string remoteScope, std::string type,
|
||||||
std::string name, const std::function<void(si32)> & callback, bool optional):
|
std::string name, const std::function<void(si32)> & callback, bool optional):
|
||||||
localScope(localScope),
|
localScope(localScope),
|
||||||
remoteScope(remoteScope),
|
remoteScope(remoteScope),
|
||||||
type(type),
|
type(type),
|
||||||
name(name),
|
name(name),
|
||||||
callback(callback),
|
callback(callback),
|
||||||
optional(optional)
|
optional(optional)
|
||||||
{}
|
{}
|
||||||
@ -294,9 +294,9 @@ void CIdentifierStorage::finalize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CContentHandler::ContentTypeHandler::ContentTypeHandler(IHandlerBase * handler, std::string objectName):
|
CContentHandler::ContentTypeHandler::ContentTypeHandler(IHandlerBase * handler, std::string objectName):
|
||||||
handler(handler),
|
handler(handler),
|
||||||
objectName(objectName),
|
objectName(objectName),
|
||||||
originalData(handler->loadLegacyData(VLC->modh->settings.data["textData"][objectName].Float()))
|
originalData(handler->loadLegacyData(VLC->modh->settings.data["textData"][objectName].Float()))
|
||||||
{
|
{
|
||||||
for(auto & node : originalData)
|
for(auto & node : originalData)
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@ void CConnection::init()
|
|||||||
//we got connection
|
//we got connection
|
||||||
oser << std::string("Aiya!\n") << name << myEndianess; //identify ourselves
|
oser << std::string("Aiya!\n") << name << myEndianess; //identify ourselves
|
||||||
iser >> pom >> pom >> contactEndianess;
|
iser >> pom >> pom >> contactEndianess;
|
||||||
logNetwork->infoStream() << "Established connection with "<<pom;
|
logNetwork->infoStream() << "Established connection with "<<pom;
|
||||||
wmx = new boost::mutex;
|
wmx = new boost::mutex;
|
||||||
rmx = 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);
|
boost::asio::ip::tcp::resolver::iterator end, pom, endpoint_iterator = resolver.resolve(boost::asio::ip::tcp::resolver::query(host,port),error);
|
||||||
if(error)
|
if(error)
|
||||||
{
|
{
|
||||||
logNetwork->errorStream() << "Problem with resolving: \n" << error;
|
logNetwork->errorStream() << "Problem with resolving: \n" << error;
|
||||||
goto connerror1;
|
goto connerror1;
|
||||||
}
|
}
|
||||||
pom = endpoint_iterator;
|
pom = endpoint_iterator;
|
||||||
if(pom != end)
|
if(pom != end)
|
||||||
logNetwork->infoStream()<<"Found endpoints:";
|
logNetwork->infoStream()<<"Found endpoints:";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logNetwork->errorStream() << "Critical problem: No endpoints found!";
|
logNetwork->errorStream() << "Critical problem: No endpoints found!";
|
||||||
goto connerror1;
|
goto connerror1;
|
||||||
}
|
}
|
||||||
i=0;
|
i=0;
|
||||||
while(pom != end)
|
while(pom != end)
|
||||||
{
|
{
|
||||||
logNetwork->infoStream() << "\t" << i << ": " << (boost::asio::ip::tcp::endpoint&)*pom;
|
logNetwork->infoStream() << "\t" << i << ": " << (boost::asio::ip::tcp::endpoint&)*pom;
|
||||||
pom++;
|
pom++;
|
||||||
}
|
}
|
||||||
i=0;
|
i=0;
|
||||||
while(endpoint_iterator != end)
|
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);
|
socket->connect(*endpoint_iterator, error);
|
||||||
if(!error)
|
if(!error)
|
||||||
{
|
{
|
||||||
@ -106,18 +106,18 @@ CConnection::CConnection(std::string host, std::string port, std::string Name)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logNetwork->errorStream() << "Problem with connecting: " << error;
|
logNetwork->errorStream() << "Problem with connecting: " << error;
|
||||||
}
|
}
|
||||||
endpoint_iterator++;
|
endpoint_iterator++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//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->errorStream() << "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->errorStream() << "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 :(");
|
||||||
@ -135,7 +135,7 @@ CConnection::CConnection(TAcceptor * acceptor, boost::asio::io_service *Io_servi
|
|||||||
acceptor->accept(*socket,error);
|
acceptor->accept(*socket,error);
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
logNetwork->errorStream() << "Error on accepting: " << error;
|
logNetwork->errorStream() << "Error on accepting: " << error;
|
||||||
delete socket;
|
delete socket;
|
||||||
throw std::runtime_error("Can't establish connection :(");
|
throw std::runtime_error("Can't establish connection :(");
|
||||||
}
|
}
|
||||||
@ -211,11 +211,11 @@ bool CConnection::isOpen() const
|
|||||||
|
|
||||||
void CConnection::reportState(CLogger * out)
|
void CConnection::reportState(CLogger * out)
|
||||||
{
|
{
|
||||||
out->debugStream() << "CConnection";
|
out->debugStream() << "CConnection";
|
||||||
if(socket && socket->is_open())
|
if(socket && socket->is_open())
|
||||||
{
|
{
|
||||||
out->debugStream() << "\tWe have an open and valid socket";
|
out->debugStream() << "\tWe have an open and valid socket";
|
||||||
out->debugStream() << "\t" << socket->available() <<" bytes awaiting";
|
out->debugStream() << "\t" << socket->available() <<" bytes awaiting";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ CPack * CConnection::retreivePack()
|
|||||||
{
|
{
|
||||||
CPack *ret = nullptr;
|
CPack *ret = nullptr;
|
||||||
boost::unique_lock<boost::mutex> lock(*rmx);
|
boost::unique_lock<boost::mutex> lock(*rmx);
|
||||||
logNetwork->traceStream() << "Listening... ";
|
logNetwork->traceStream() << "Listening... ";
|
||||||
iser >> ret;
|
iser >> ret;
|
||||||
logNetwork->traceStream() << "\treceived server message of type " << typeid(*ret).name() << ", data: " << ret;
|
logNetwork->traceStream() << "\treceived server message of type " << typeid(*ret).name() << ", data: " << ret;
|
||||||
return ret;
|
return ret;
|
||||||
@ -232,7 +232,7 @@ CPack * CConnection::retreivePack()
|
|||||||
void CConnection::sendPackToServer(const CPack &pack, PlayerColor player, ui32 requestID)
|
void CConnection::sendPackToServer(const CPack &pack, PlayerColor player, ui32 requestID)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> lock(*wmx);
|
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!
|
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(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Failed to save to " << fname;
|
logGlobal->errorStream() << "Failed to save to " << fname;
|
||||||
clear();
|
clear();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
@ -323,10 +323,10 @@ void CSaveFile::openNextFile(const boost::filesystem::path &fname)
|
|||||||
|
|
||||||
void CSaveFile::reportState(CLogger * out)
|
void CSaveFile::reportState(CLogger * out)
|
||||||
{
|
{
|
||||||
out->debugStream() << "CSaveFile";
|
out->debugStream() << "CSaveFile";
|
||||||
if(sfile.get() && *sfile)
|
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)
|
void CLoadFile::reportState(CLogger * out)
|
||||||
{
|
{
|
||||||
out->debugStream() << "CLoadFile";
|
out->debugStream() << "CLoadFile";
|
||||||
if(!!sfile && *sfile)
|
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);
|
controlFile->read(controlData.data(), size);
|
||||||
if(std::memcmp(data, 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;
|
foundDesync = true;
|
||||||
//throw std::runtime_error("Savegame dsynchronized!");
|
//throw std::runtime_error("Savegame dsynchronized!");
|
||||||
}
|
}
|
||||||
|
@ -715,7 +715,7 @@ CBonusSystemNode::~CBonusSystemNode()
|
|||||||
|
|
||||||
if(children.size())
|
if(children.size())
|
||||||
{
|
{
|
||||||
logBonus->warnStream() << "Warning: an orphaned child!";
|
logBonus->warnStream() << "Warning: an orphaned child!";
|
||||||
while(children.size())
|
while(children.size())
|
||||||
children.front()->detachFrom(this);
|
children.front()->detachFrom(this);
|
||||||
}
|
}
|
||||||
@ -844,7 +844,7 @@ void CBonusSystemNode::unpropagateBonus(Bonus * b)
|
|||||||
bonuses -= b;
|
bonuses -= b;
|
||||||
while(vstd::contains(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;
|
bonuses -= b;
|
||||||
}
|
}
|
||||||
BONUS_LOG_LINE("#$#" << b->Description() << " #is no longer propagated to# " << nodeName());
|
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:
|
case EAlignment::EVIL:
|
||||||
return !c->isEvil();
|
return !c->isEvil();
|
||||||
default:
|
default:
|
||||||
logBonus->warnStream() << "Warning: illegal alignment in limiter!";
|
logBonus->warnStream() << "Warning: illegal alignment in limiter!";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ void CPrivilagedInfoCallback::getTilesInRange( std::unordered_set<int3, ShashInt
|
|||||||
{
|
{
|
||||||
if(!!player && *player >= PlayerColor::PLAYER_LIMIT)
|
if(!!player && *player >= PlayerColor::PLAYER_LIMIT)
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Illegal call to getTilesInRange!";
|
logGlobal->errorStream() << "Illegal call to getTilesInRange!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (radious == -1) //reveal entire map
|
if (radious == -1) //reveal entire map
|
||||||
@ -87,7 +87,7 @@ void CPrivilagedInfoCallback::getAllTiles (std::unordered_set<int3, ShashInt3> &
|
|||||||
{
|
{
|
||||||
if(!!Player && *Player >= PlayerColor::PLAYER_LIMIT)
|
if(!!Player && *Player >= PlayerColor::PLAYER_LIMIT)
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Illegal call to getAllTiles !";
|
logGlobal->errorStream() << "Illegal call to getAllTiles !";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool water = surface == 0 || surface == 2,
|
bool water = surface == 0 || surface == 2,
|
||||||
@ -150,37 +150,37 @@ CGameState * CPrivilagedInfoCallback::gameState ()
|
|||||||
template<typename Loader>
|
template<typename Loader>
|
||||||
void CPrivilagedInfoCallback::loadCommonState(Loader &in)
|
void CPrivilagedInfoCallback::loadCommonState(Loader &in)
|
||||||
{
|
{
|
||||||
logGlobal->infoStream() << "Loading lib part of game...";
|
logGlobal->infoStream() << "Loading lib part of game...";
|
||||||
in.checkMagicBytes(SAVEGAME_MAGIC);
|
in.checkMagicBytes(SAVEGAME_MAGIC);
|
||||||
|
|
||||||
CMapHeader dum;
|
CMapHeader dum;
|
||||||
StartInfo *si;
|
StartInfo *si;
|
||||||
|
|
||||||
logGlobal->infoStream() <<"\tReading header";
|
logGlobal->infoStream() <<"\tReading header";
|
||||||
in.serializer >> dum;
|
in.serializer >> dum;
|
||||||
|
|
||||||
logGlobal->infoStream() << "\tReading options";
|
logGlobal->infoStream() << "\tReading options";
|
||||||
in.serializer >> si;
|
in.serializer >> si;
|
||||||
|
|
||||||
logGlobal->infoStream() <<"\tReading handlers";
|
logGlobal->infoStream() <<"\tReading handlers";
|
||||||
in.serializer >> *VLC;
|
in.serializer >> *VLC;
|
||||||
|
|
||||||
logGlobal->infoStream() <<"\tReading gamestate";
|
logGlobal->infoStream() <<"\tReading gamestate";
|
||||||
in.serializer >> gs;
|
in.serializer >> gs;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Saver>
|
template<typename Saver>
|
||||||
void CPrivilagedInfoCallback::saveCommonState(Saver &out) const
|
void CPrivilagedInfoCallback::saveCommonState(Saver &out) const
|
||||||
{
|
{
|
||||||
logGlobal->infoStream() << "Saving lib part of game...";
|
logGlobal->infoStream() << "Saving lib part of game...";
|
||||||
out.putMagicBytes(SAVEGAME_MAGIC);
|
out.putMagicBytes(SAVEGAME_MAGIC);
|
||||||
logGlobal->infoStream() <<"\tSaving header";
|
logGlobal->infoStream() <<"\tSaving header";
|
||||||
out.serializer << static_cast<CMapHeader&>(*gs->map);
|
out.serializer << static_cast<CMapHeader&>(*gs->map);
|
||||||
logGlobal->infoStream() << "\tSaving options";
|
logGlobal->infoStream() << "\tSaving options";
|
||||||
out.serializer << gs->scenarioOps;
|
out.serializer << gs->scenarioOps;
|
||||||
logGlobal->infoStream() << "\tSaving handlers";
|
logGlobal->infoStream() << "\tSaving handlers";
|
||||||
out.serializer << *VLC;
|
out.serializer << *VLC;
|
||||||
logGlobal->infoStream() << "\tSaving gamestate";
|
logGlobal->infoStream() << "\tSaving gamestate";
|
||||||
out.serializer << gs;
|
out.serializer << gs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ Bonus * JsonUtils::parseBonus (const JsonVector &ability_vec) //TODO: merge with
|
|||||||
auto it = bonusNameMap.find(type);
|
auto it = bonusNameMap.find(type);
|
||||||
if (it == bonusNameMap.end())
|
if (it == bonusNameMap.end())
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Error: invalid ability type " << type;
|
logGlobal->errorStream() << "Error: invalid ability type " << type;
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
b->type = it->second;
|
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);
|
auto it = map.find(type);
|
||||||
if (it == map.end())
|
if (it == map.end())
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Error: invalid " << err << type;
|
logGlobal->errorStream() << "Error: invalid " << err << type;
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -395,7 +395,7 @@ void JsonUtils::resolveIdentifier (si32 &var, const JsonNode &node, std::string
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
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;
|
break;
|
||||||
default:
|
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);
|
auto it = bonusNameMap.find(type);
|
||||||
if (it == bonusNameMap.end())
|
if (it == bonusNameMap.end())
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Error: invalid ability type " << type;
|
logGlobal->errorStream() << "Error: invalid ability type " << type;
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
b->type = it->second;
|
b->type = it->second;
|
||||||
@ -472,7 +472,7 @@ Bonus * JsonUtils::parseBonus (const JsonNode &ability)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
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);
|
auto it = bonusNameMap.find (anotherBonusType);
|
||||||
if (it == bonusNameMap.end())
|
if (it == bonusNameMap.end())
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Error: invalid ability type " << anotherBonusType;
|
logGlobal->errorStream() << "Error: invalid ability type " << anotherBonusType;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
l2->type = it->second;
|
l2->type = it->second;
|
||||||
@ -684,7 +684,7 @@ const JsonNode & getSchemaByName(std::string name)
|
|||||||
return loadedSchemas[name];
|
return loadedSchemas[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
logGlobal->errorStream() << "Error: missing schema with name " << name << "!";
|
logGlobal->errorStream() << "Error: missing schema with name " << name << "!";
|
||||||
assert(0);
|
assert(0);
|
||||||
return nullNode;
|
return nullNode;
|
||||||
}
|
}
|
||||||
@ -702,7 +702,7 @@ const JsonNode & JsonUtils::getSchema(std::string URI)
|
|||||||
|
|
||||||
if (protocolName != "vcmi")
|
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;
|
return nullNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ struct DLL_LINKAGE CPack
|
|||||||
ui16 getType() const{return type;}
|
ui16 getType() const{return type;}
|
||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
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) { }
|
void applyGs(CGameState *gs) { }
|
||||||
virtual std::string toString() const { return boost::str(boost::format("{CPack: type '%d'}") % type); }
|
virtual std::string toString() const { return boost::str(boost::format("{CPack: type '%d'}") % type); }
|
||||||
|
@ -134,7 +134,7 @@ DLL_LINKAGE void AddQuest::applyGs(CGameState *gs)
|
|||||||
if (!vstd::contains(*vec, quest))
|
if (!vstd::contains(*vec, quest))
|
||||||
vec->push_back (quest);
|
vec->push_back (quest);
|
||||||
else
|
else
|
||||||
logNetwork->warnStream() << "Warning! Attempt to add duplicated quest";
|
logNetwork->warnStream() << "Warning! Attempt to add duplicated quest";
|
||||||
}
|
}
|
||||||
|
|
||||||
DLL_LINKAGE void UpdateArtHandlerLists::applyGs(CGameState *gs)
|
DLL_LINKAGE void UpdateArtHandlerLists::applyGs(CGameState *gs)
|
||||||
@ -292,7 +292,7 @@ DLL_LINKAGE void ChangeObjPos::applyGs( CGameState *gs )
|
|||||||
CGObjectInstance *obj = gs->getObjInstance(objid);
|
CGObjectInstance *obj = gs->getObjInstance(objid);
|
||||||
if(!obj)
|
if(!obj)
|
||||||
{
|
{
|
||||||
logNetwork->errorStream() << "Wrong ChangeObjPos: object " << objid.getNum() << " doesn't exist!";
|
logNetwork->errorStream() << "Wrong ChangeObjPos: object " << objid.getNum() << " doesn't exist!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gs->map->removeBlockVisTiles(obj);
|
gs->map->removeBlockVisTiles(obj);
|
||||||
@ -857,7 +857,7 @@ DLL_LINKAGE void RebalanceStacks::applyGs( CGameState *gs )
|
|||||||
//else - artifact cna be lost :/
|
//else - artifact cna be lost :/
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logNetwork->warnStream() << "Artifact is present at destination slot!";
|
logNetwork->warnStream() << "Artifact is present at destination slot!";
|
||||||
}
|
}
|
||||||
artHere->move (alHere, alDest);
|
artHere->move (alHere, alDest);
|
||||||
//TODO: choose from dialog
|
//TODO: choose from dialog
|
||||||
@ -1036,7 +1036,7 @@ DLL_LINKAGE void SetAvailableArtifacts::applyGs( CGameState *gs )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logNetwork->errorStream() << "Wrong black market id!";
|
logNetwork->errorStream() << "Wrong black market id!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1100,7 +1100,7 @@ DLL_LINKAGE void SetObjectProperty::applyGs( CGameState *gs )
|
|||||||
CGObjectInstance *obj = gs->getObjInstance(id);
|
CGObjectInstance *obj = gs->getObjInstance(id);
|
||||||
if(!obj)
|
if(!obj)
|
||||||
{
|
{
|
||||||
logNetwork->errorStream() << "Wrong object ID - property cannot be set!";
|
logNetwork->errorStream() << "Wrong object ID - property cannot be set!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1217,7 +1217,7 @@ DLL_LINKAGE void BattleTriggerEffect::applyGs( CGameState *gs )
|
|||||||
st->state.insert(EBattleStackState::FEAR);
|
st->state.insert(EBattleStackState::FEAR);
|
||||||
break;
|
break;
|
||||||
default:
|
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 )
|
DLL_LINKAGE void SetStackEffect::applyGs( CGameState *gs )
|
||||||
{
|
{
|
||||||
if (effect.empty())
|
if(effect.empty())
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Trying to apply SetStackEffect with no effects";
|
logGlobal->errorStream() << "Trying to apply SetStackEffect with no effects";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spellid = effect.begin()->sid; //effects' source ID
|
int spellid = effect.begin()->sid; //effects' source ID
|
||||||
|
|
||||||
@ -1494,7 +1494,7 @@ DLL_LINKAGE void SetStackEffect::applyGs( CGameState *gs )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
logNetwork->errorStream() << "Cannot find stack " << id;
|
logNetwork->errorStream() << "Cannot find stack " << id;
|
||||||
}
|
}
|
||||||
typedef std::pair<ui32, Bonus> p;
|
typedef std::pair<ui32, Bonus> p;
|
||||||
for(p para : uniqueBonuses)
|
for(p para : uniqueBonuses)
|
||||||
@ -1508,7 +1508,7 @@ DLL_LINKAGE void SetStackEffect::applyGs( CGameState *gs )
|
|||||||
actualizeEffect(s, effect);
|
actualizeEffect(s, effect);
|
||||||
}
|
}
|
||||||
else
|
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))
|
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
|
return; //position is already occupied
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1666,7 +1666,7 @@ DLL_LINKAGE void BattleStackAdded::applyGs(CGameState *gs)
|
|||||||
newStackID = 0;
|
newStackID = 0;
|
||||||
if (!BattleHex(pos).isValid())
|
if (!BattleHex(pos).isValid())
|
||||||
{
|
{
|
||||||
logNetwork->warnStream() << "No place found for new stack!";
|
logNetwork->warnStream() << "No place found for new stack!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ struct StartInfo
|
|||||||
{
|
{
|
||||||
if(playerInfos.find(no) != playerInfos.end())
|
if(playerInfos.find(no) != playerInfos.end())
|
||||||
return playerInfos[no];
|
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");
|
throw std::runtime_error("Cannot find info about player");
|
||||||
}
|
}
|
||||||
const PlayerSettings & getIthPlayersSettings(PlayerColor no) const
|
const PlayerSettings & getIthPlayersSettings(PlayerColor no) const
|
||||||
|
@ -47,7 +47,7 @@ static int lowestSpeed(const CGHeroInstance * chi)
|
|||||||
{
|
{
|
||||||
if(!chi->stacksCount())
|
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;
|
return 20;
|
||||||
}
|
}
|
||||||
auto i = chi->Slots().begin();
|
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
|
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;
|
elem.second = 3;
|
||||||
}
|
}
|
||||||
updateSkill(which, elem.second); //when we know final value
|
updateSkill(which, elem.second); //when we know final value
|
||||||
@ -367,7 +367,7 @@ void CGHeroInstance::initArmy(IArmyDescriptor *dst /*= nullptr*/)
|
|||||||
if(!getArt(convSlot))
|
if(!getArt(convSlot))
|
||||||
putArtifact(convSlot, CArtifactInstance::createNewArtifactInstance(aid));
|
putArtifact(convSlot, CArtifactInstance::createNewArtifactInstance(aid));
|
||||||
else
|
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
|
else
|
||||||
dst->setCreature(SlotID(stackNo-warMachinesGiven), stack.creature, count);
|
dst->setCreature(SlotID(stackNo-warMachinesGiven), stack.creature, count);
|
||||||
@ -660,7 +660,7 @@ void CGHeroInstance::initObj()
|
|||||||
hs->addNewBonus(bonus);
|
hs->addNewBonus(bonus);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logGlobal->warnStream() << "Unexpected hero specialty " << type;
|
logGlobal->warnStream() << "Unexpected hero specialty " << type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
specialty.push_back(hs); //will it work?
|
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
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -961,26 +961,26 @@ bool CGHeroInstance::canCastThisSpell(const CSpell * spell) const
|
|||||||
|
|
||||||
const bool levelBonus = hasBonusOfType(Bonus::SPELLS_OF_LEVEL, spell->level);
|
const bool levelBonus = hasBonusOfType(Bonus::SPELLS_OF_LEVEL, spell->level);
|
||||||
|
|
||||||
if (spell->isSpecialSpell())
|
if(spell->isSpecialSpell())
|
||||||
{
|
{
|
||||||
if (inSpellBook)
|
if(inSpellBook)
|
||||||
{//hero has this spell in spellbook
|
{//hero has this spell in spellbook
|
||||||
logGlobal->errorStream() << "Special spell " << spell->name << "in spellbook.";
|
logGlobal->errorStream() << "Special spell " << spell->name << "in spellbook.";
|
||||||
}
|
}
|
||||||
return specificBonus;
|
return specificBonus;
|
||||||
}
|
}
|
||||||
else if(!isAllowed)
|
else if(!isAllowed)
|
||||||
{
|
{
|
||||||
if (inSpellBook)
|
if(inSpellBook)
|
||||||
{//hero has this spell in spellbook
|
{//hero has this spell in spellbook
|
||||||
logGlobal->errorStream() << "Banned spell " << spell->name << " in spellbook.";
|
logGlobal->errorStream() << "Banned spell " << spell->name << " in spellbook.";
|
||||||
}
|
}
|
||||||
return specificBonus || schoolBonus || levelBonus;
|
return specificBonus || schoolBonus || levelBonus;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return inSpellBook || schoolBonus || specificBonus || levelBonus;
|
return inSpellBook || schoolBonus || specificBonus || levelBonus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,7 +179,7 @@ const IMarket * IMarket::castFrom(const CGObjectInstance *obj, bool verbose /*=
|
|||||||
return static_cast<const CGUniversity*>(obj);
|
return static_cast<const CGUniversity*>(obj);
|
||||||
default:
|
default:
|
||||||
if(verbose)
|
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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -305,7 +305,7 @@ void CGUniversity::initObj()
|
|||||||
}
|
}
|
||||||
if(toChoose.size() < 4)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1170,7 +1170,7 @@ void CGTownInstance::addHeroToStructureVisitors( const CGHeroInstance *h, si32 s
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//should never ever happen
|
//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);
|
assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,13 +110,13 @@ void IObjectInterface::heroLevelUpDone(const CGHeroInstance *hero) const
|
|||||||
|
|
||||||
CObjectHandler::CObjectHandler()
|
CObjectHandler::CObjectHandler()
|
||||||
{
|
{
|
||||||
logGlobal->traceStream() << "\t\tReading resources prices ";
|
logGlobal->traceStream() << "\t\tReading resources prices ";
|
||||||
const JsonNode config2(ResourceID("config/resources.json"));
|
const JsonNode config2(ResourceID("config/resources.json"));
|
||||||
for(const JsonNode &price : config2["resources_prices"].Vector())
|
for(const JsonNode &price : config2["resources_prices"].Vector())
|
||||||
{
|
{
|
||||||
resVals.push_back(price.Float());
|
resVals.push_back(price.Float());
|
||||||
}
|
}
|
||||||
logGlobal->traceStream() << "\t\tDone loading resource prices!";
|
logGlobal->traceStream() << "\t\tDone loading resource prices!";
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerColor CGObjectInstance::getOwner() const
|
PlayerColor CGObjectInstance::getOwner() const
|
||||||
|
@ -232,7 +232,7 @@ void CGCreature::initObj()
|
|||||||
|
|
||||||
if(amount == 0) //armies with 0 creatures are illegal
|
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;
|
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
|
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)
|
for(si32 i = 0; i < GameConstants::SKILL_QUANTITY; ++i)
|
||||||
if(vstd::contains(allowedAbilities, i))
|
if(vstd::contains(allowedAbilities, i))
|
||||||
@ -1589,7 +1589,7 @@ void CGShrine::onHeroVisit( const CGHeroInstance * h ) const
|
|||||||
{
|
{
|
||||||
if(spell == SpellID::NONE)
|
if(spell == SpellID::NONE)
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Not initialized shrine visited!";
|
logGlobal->errorStream() << "Not initialized shrine visited!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1637,7 +1637,7 @@ void CGShrine::initObj()
|
|||||||
|
|
||||||
if(possibilities.empty())
|
if(possibilities.empty())
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Error: cannot init shrine, no allowed spells!";
|
logGlobal->errorStream() << "Error: cannot init shrine, no allowed spells!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2032,7 +2032,7 @@ void CCartographer::onHeroVisit( const CGHeroInstance * h ) const
|
|||||||
text = 27;
|
text = 27;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logGlobal->warnStream() << "Unrecognized subtype of cartographer";
|
logGlobal->warnStream() << "Unrecognized subtype of cartographer";
|
||||||
}
|
}
|
||||||
assert(text);
|
assert(text);
|
||||||
BlockingDialog bd (true, false);
|
BlockingDialog bd (true, false);
|
||||||
|
@ -245,7 +245,7 @@ CScenarioTravel CCampaignHandler::readScenarioTravelFromMemory(CBinaryReader & r
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
logGlobal->warnStream() << "Corrupted h3c file";
|
logGlobal->warnStream() << "Corrupted h3c file";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret.bonusesToChoose.push_back(bonus);
|
ret.bonusesToChoose.push_back(bonus);
|
||||||
@ -282,8 +282,8 @@ CScenarioTravel CCampaignHandler::readScenarioTravelFromMemory(CBinaryReader & r
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "Corrupted h3c file";
|
logGlobal->warnStream() << "Corrupted h3c file";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ void CMapLoaderH3M::init()
|
|||||||
{
|
{
|
||||||
for(MapLoadingTime & mlt : times)
|
for(MapLoadingTime & mlt : times)
|
||||||
{
|
{
|
||||||
logGlobal->debugStream() << "\tReading " << mlt.name << " took " << mlt.time << " ms.";
|
logGlobal->debugStream() << "\tReading " << mlt.name << " took " << mlt.time << " ms.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
map->calculateGuardingGreaturePositions();
|
map->calculateGuardingGreaturePositions();
|
||||||
@ -873,14 +873,14 @@ bool CMapLoaderH3M::loadArtifactToSlot(CGHeroInstance * hero, int slot)
|
|||||||
{
|
{
|
||||||
if(vstd::contains(VLC->arth->bigArtifacts, aid) && slot >= GameConstants::BACKPACK_START)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
if(aid == 0 && slot == ArtifactPosition::MISC5)
|
if(aid == 0 && slot == ArtifactPosition::MISC5)
|
||||||
{
|
{
|
||||||
//TODO: check how H3 handles it -> art 0 in slot 18 in AB map
|
//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 "
|
logGlobal->warnStream() << "Spellbook to MISC5 slot? Putting it spellbook place. AB format peculiarity ? (format "
|
||||||
<< static_cast<int>(map->version) << ")";
|
<< static_cast<int>(map->version) << ")";
|
||||||
slot = ArtifactPosition::SPELLBOOK;
|
slot = ArtifactPosition::SPELLBOOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1536,7 +1536,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(ObjectInstanceID idToBeGiven, const i
|
|||||||
{
|
{
|
||||||
if(elem->subID == nhi->subID)
|
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;
|
delete nhi;
|
||||||
nhi = elem;
|
nhi = elem;
|
||||||
break;
|
break;
|
||||||
@ -2067,8 +2067,8 @@ std::set<BuildingID> CMapLoaderH3M::convertBuildings(const std::set<BuildingID>
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "Conversion warning: unknown building " << elem << " in castle "
|
logGlobal->warnStream() << "Conversion warning: unknown building " << elem << " in castle "
|
||||||
<< castleID;
|
<< castleID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -937,7 +937,7 @@ void CGameHandler::handleConnection(std::set<PlayerColor> players, CConnection &
|
|||||||
|
|
||||||
packType = typeList.getTypeID(pack); //get the id of type
|
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();
|
% requestID % player.getNum() % packType % typeid(*pack).name();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -964,7 +964,7 @@ void CGameHandler::handleConnection(std::set<PlayerColor> players, CConnection &
|
|||||||
if(!result)
|
if(!result)
|
||||||
{
|
{
|
||||||
complain((boost::format("Got false in applying %s... that request must have been fishy!")
|
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 << ")!";
|
logGlobal->traceStream() << "Message successfully applied (result=" << result << ")!";
|
||||||
sendPackageResponse(true);
|
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
|
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
|
assert(!c.connected); //make sure that connection has been marked as broken
|
||||||
logGlobal->errorStream() << e.what();
|
logGlobal->errorStream() << e.what();
|
||||||
end2 = true;
|
end2 = true;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
@ -991,7 +991,7 @@ void CGameHandler::handleConnection(std::set<PlayerColor> players, CConnection &
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
logGlobal->errorStream() << "Ended handling connection";
|
logGlobal->errorStream() << "Ended handling connection";
|
||||||
}
|
}
|
||||||
|
|
||||||
int CGameHandler::moveStack(int stack, BattleHex dest)
|
int CGameHandler::moveStack(int stack, BattleHex dest)
|
||||||
@ -1328,9 +1328,9 @@ void CGameHandler::init(StartInfo *si)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gs = new CGameState();
|
gs = new CGameState();
|
||||||
logGlobal->infoStream() << "Gamestate created!";
|
logGlobal->infoStream() << "Gamestate created!";
|
||||||
gs->init(si);
|
gs->init(si);
|
||||||
logGlobal->infoStream() << "Gamestate initialized!";
|
logGlobal->infoStream() << "Gamestate initialized!";
|
||||||
|
|
||||||
// reset seed, so that clients can't predict any following random values
|
// reset seed, so that clients can't predict any following random values
|
||||||
gs->getRandomGenerator().resetSeed();
|
gs->getRandomGenerator().resetSeed();
|
||||||
@ -1343,7 +1343,7 @@ void CGameHandler::init(StartInfo *si)
|
|||||||
|
|
||||||
static bool evntCmp(const CMapEvent &a, const CMapEvent &b)
|
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)
|
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);
|
const PlayerState *p = gs->getPlayer(town->tempOwner);
|
||||||
if(!p)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1389,7 +1389,7 @@ void CGameHandler::setPortalDwelling(const CGTownInstance * town, bool forced=fa
|
|||||||
|
|
||||||
void CGameHandler::newTurn()
|
void CGameHandler::newTurn()
|
||||||
{
|
{
|
||||||
logGlobal->traceStream() << "Turn " << gs->day+1;
|
logGlobal->traceStream() << "Turn " << gs->day+1;
|
||||||
NewTurn n;
|
NewTurn n;
|
||||||
n.specialWeek = NewTurn::NO_ACTION;
|
n.specialWeek = NewTurn::NO_ACTION;
|
||||||
n.creatureid = CreatureID::NONE;
|
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();
|
handleTimeEvents();
|
||||||
//call objects
|
//call objects
|
||||||
for(auto & elem : gs->map->objects)
|
for(auto & elem : gs->map->objects)
|
||||||
@ -1747,17 +1747,17 @@ void CGameHandler::run(bool resume)
|
|||||||
std::set<PlayerColor> players;
|
std::set<PlayerColor> players;
|
||||||
(*cc) >> players; //how many players will be handled at that client
|
(*cc) >> players; //how many players will be handled at that client
|
||||||
|
|
||||||
std::stringstream sbuffer;
|
std::stringstream sbuffer;
|
||||||
sbuffer << "Connection " << cc->connectionID << " will handle " << players.size() << " player: ";
|
sbuffer << "Connection " << cc->connectionID << " will handle " << players.size() << " player: ";
|
||||||
for(PlayerColor color : players)
|
for(PlayerColor color : players)
|
||||||
{
|
{
|
||||||
sbuffer << color << " ";
|
sbuffer << color << " ";
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::recursive_mutex> lock(gsm);
|
boost::unique_lock<boost::recursive_mutex> lock(gsm);
|
||||||
connections[color] = cc;
|
connections[color] = cc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logGlobal->infoStream() << sbuffer.str();
|
logGlobal->infoStream() << sbuffer.str();
|
||||||
|
|
||||||
cc->addStdVecItems(gs);
|
cc->addStdVecItems(gs);
|
||||||
cc->enableStackSendingByID();
|
cc->enableStackSendingByID();
|
||||||
@ -1931,7 +1931,7 @@ bool CGameHandler::removeObject( const CGObjectInstance * obj )
|
|||||||
{
|
{
|
||||||
if(!obj || !getObj(obj->id))
|
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;
|
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)
|
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;
|
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);
|
const int3 hmpos = CGHeroInstance::convertPosition(dst, false);
|
||||||
|
|
||||||
if(!gs->map->isInTheMap(hmpos))
|
if(!gs->map->isInTheMap(hmpos))
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Destination tile is outside the map!";
|
logGlobal->errorStream() << "Destination tile is outside the map!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2142,7 +2142,7 @@ bool CGameHandler::teleportHero(ObjectInstanceID hid, ObjectInstanceID dstid, ui
|
|||||||
const CGTownInstance *t = getTown(dstid);
|
const CGTownInstance *t = getTown(dstid);
|
||||||
|
|
||||||
if ( !h || !t || h->getOwner() != gs->currentPlayer )
|
if ( !h || !t || h->getOwner() != gs->currentPlayer )
|
||||||
logGlobal->errorStream()<<"Invalid call to teleportHero!";
|
logGlobal->errorStream() << "Invalid call to teleportHero!";
|
||||||
|
|
||||||
const CGTownInstance *from = h->visitedTown;
|
const CGTownInstance *from = h->visitedTown;
|
||||||
if(((h->getOwner() != t->getOwner())
|
if(((h->getOwner() != t->getOwner())
|
||||||
@ -2519,7 +2519,7 @@ void CGameHandler::heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2)
|
|||||||
|
|
||||||
void CGameHandler::sendToAllClients( CPackForClient * info )
|
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)
|
for(auto & elem : conns)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> lock(*(elem)->wmx);
|
boost::unique_lock<boost::mutex> lock(*(elem)->wmx);
|
||||||
@ -2565,13 +2565,13 @@ void CGameHandler::sendAndApply( NewStructures * info )
|
|||||||
|
|
||||||
void CGameHandler::save(const std::string & filename )
|
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 stem = FileInfo::GetPathStem(filename);
|
||||||
const auto savefname = stem.to_string() + ".vsgm1";
|
const auto savefname = stem.to_string() + ".vsgm1";
|
||||||
CResourceHandler::get("local")->createResource(savefname);
|
CResourceHandler::get("local")->createResource(savefname);
|
||||||
|
|
||||||
{
|
{
|
||||||
logGlobal->infoStream() << "Ordering clients to serialize...";
|
logGlobal->infoStream() << "Ordering clients to serialize...";
|
||||||
SaveGame sg(savefname);
|
SaveGame sg(savefname);
|
||||||
sendToAllClients(&sg);
|
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)));
|
CSaveFile save(*CResourceHandler::get("local")->getResourceName(ResourceID(stem.to_string(), EResType::SERVER_SAVEGAME)));
|
||||||
saveCommonState(save);
|
saveCommonState(save);
|
||||||
logGlobal->infoStream() << "Saving server state";
|
logGlobal->infoStream() << "Saving server state";
|
||||||
save << *this;
|
save << *this;
|
||||||
}
|
}
|
||||||
logGlobal->infoStream() << "Game has been successfully saved!";
|
logGlobal->infoStream() << "Game has been successfully saved!";
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Failed to save game: " << e.what();
|
logGlobal->errorStream() << "Failed to save game: " << e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameHandler::close()
|
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)
|
if(gs->initialOpts->mode == StartInfo::DUEL)
|
||||||
{
|
{
|
||||||
@ -3784,7 +3784,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
|||||||
BattleHex startingPos = stack->position;
|
BattleHex startingPos = stack->position;
|
||||||
int distance = moveStack(ba.stackNumber, ba.destinationTile);
|
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
|
if(stack->position != ba.destinationTile //we wasn't able to reach destination tile
|
||||||
&& !(stack->doubleWide()
|
&& !(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;
|
std::string problem = "We cannot move this stack to its destination " + stack->getCreature()->namePl;
|
||||||
logGlobal->warnStream() << problem;
|
logGlobal->warnStream() << problem;
|
||||||
complain(problem);
|
complain(problem);
|
||||||
ok = false;
|
ok = false;
|
||||||
sendAndApply(&end_action);
|
sendAndApply(&end_action);
|
||||||
@ -4024,7 +4024,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
|||||||
attack.destinationTile = gs->curB->wallPartToBattleHex(EWallPart::EWallPart(attack.attackedPart));
|
attack.destinationTile = gs->curB->wallPartToBattleHex(EWallPart::EWallPart(attack.attackedPart));
|
||||||
|
|
||||||
logGlobal->traceStream() << "Catapult attacks " << (int)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
|
//removing creatures in turrets / keep if one is destroyed
|
||||||
if(attack.damageDealt > 0 && (attackedPart == EWallPart::KEEP ||
|
if(attack.damageDealt > 0 && (attackedPart == EWallPart::KEEP ||
|
||||||
@ -4370,12 +4370,12 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
|
|||||||
const CGHeroInstance *h = gs->curB->battleGetFightingHero(ba.side);
|
const CGHeroInstance *h = gs->curB->battleGetFightingHero(ba.side);
|
||||||
if(!h)
|
if(!h)
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "Wrong caster!";
|
logGlobal->warnStream() << "Wrong caster!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(ba.additionalInfo >= VLC->spellh->objects.size())
|
if(ba.additionalInfo >= VLC->spellh->objects.size())
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "Wrong spell id (" << ba.additionalInfo << ")!";
|
logGlobal->warnStream() << "Wrong spell id (" << ba.additionalInfo << ")!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4702,7 +4702,7 @@ void CGameHandler::handleTimeEvents()
|
|||||||
|
|
||||||
ev.firstOccurence += ev.nextOccurence;
|
ev.firstOccurence += ev.nextOccurence;
|
||||||
auto it = gs->map->events.begin();
|
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++;
|
it++;
|
||||||
gs->map->events.insert(it, ev);
|
gs->map->events.insert(it, ev);
|
||||||
}
|
}
|
||||||
@ -4785,7 +4785,7 @@ void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n)
|
|||||||
|
|
||||||
ev.firstOccurence += ev.nextOccurence;
|
ev.firstOccurence += ev.nextOccurence;
|
||||||
auto it = town->events.begin();
|
auto it = town->events.begin();
|
||||||
while ( it != town->events.end() && it->earlierThanOrEqual(ev))
|
while(it != town->events.end() && it->earlierThanOrEqual(ev))
|
||||||
it++;
|
it++;
|
||||||
town->events.insert(it, ev);
|
town->events.insert(it, ev);
|
||||||
}
|
}
|
||||||
@ -4805,7 +4805,7 @@ void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n)
|
|||||||
bool CGameHandler::complain( const std::string &problem )
|
bool CGameHandler::complain( const std::string &problem )
|
||||||
{
|
{
|
||||||
sendMessageToAll("Server encountered a problem: " + problem);
|
sendMessageToAll("Server encountered a problem: " + problem);
|
||||||
logGlobal->errorStream() << problem;
|
logGlobal->errorStream() << problem;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5760,8 +5760,8 @@ void CGameHandler::runBattle()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logGlobal->traceStream() << "Activating " << next->nodeName();
|
logGlobal->traceStream() << "Activating " << next->nodeName();
|
||||||
auto nextId = next->ID;
|
auto nextId = next->ID;
|
||||||
BattleSetActiveStack sas;
|
BattleSetActiveStack sas;
|
||||||
sas.stack = nextId;
|
sas.stack = nextId;
|
||||||
sendAndApply(&sas);
|
sendAndApply(&sas);
|
||||||
@ -5935,12 +5935,12 @@ void CGameHandler::spawnWanderingMonsters(CreatureID creatureID)
|
|||||||
getFreeTiles(tiles);
|
getFreeTiles(tiles);
|
||||||
ui32 amount = tiles.size() / 200; //Chance is 0.5% for each tile
|
ui32 amount = tiles.size() / 200; //Chance is 0.5% for each tile
|
||||||
std::random_shuffle(tiles.begin(), tiles.end());
|
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);
|
const CCreature *cre = VLC->creh->creatures.at(creatureID);
|
||||||
for (int i = 0; i < amount; ++i)
|
for (int i = 0; i < amount; ++i)
|
||||||
{
|
{
|
||||||
tile = tiles.begin();
|
tile = tiles.begin();
|
||||||
logGlobal->traceStream() << "\tSpawning monster at " << *tile;
|
logGlobal->traceStream() << "\tSpawning monster at " << *tile;
|
||||||
putNewMonster(creatureID, cre->getRandomAmount(std::rand), *tile);
|
putNewMonster(creatureID, cre->getRandomAmount(std::rand), *tile);
|
||||||
tiles.erase(tile); //not use it again
|
tiles.erase(tile); //not use it again
|
||||||
}
|
}
|
||||||
@ -6134,7 +6134,7 @@ CasualtiesAfterBattle::CasualtiesAfterBattle(const CArmedInstance * _army, Battl
|
|||||||
{
|
{
|
||||||
if(st->alive() && st->count > 0)
|
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;
|
const CreatureID summonedType = st->type->idNumber;
|
||||||
summoned[summonedType] += st->count;
|
summoned[summonedType] += st->count;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ void CPregameServer::handleConnection(CConnection *cpc)
|
|||||||
CPackForSelectionScreen *cpfs = nullptr;
|
CPackForSelectionScreen *cpfs = nullptr;
|
||||||
*cpc >> cpfs;
|
*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);
|
boost::unique_lock<boost::recursive_mutex> queueLock(mx);
|
||||||
bool quitting = dynamic_ptr_cast<QuitMenuWithoutStarting>(cpfs),
|
bool quitting = dynamic_ptr_cast<QuitMenuWithoutStarting>(cpfs),
|
||||||
@ -108,7 +108,7 @@ void CPregameServer::handleConnection(CConnection *cpc)
|
|||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::recursive_mutex> queueLock(mx);
|
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);
|
boost::unique_lock<boost::recursive_mutex> queueLock(mx);
|
||||||
@ -124,13 +124,13 @@ void CPregameServer::handleConnection(CConnection *cpc)
|
|||||||
|
|
||||||
if(connections.empty())
|
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
|
boost::this_thread::sleep(boost::posix_time::seconds(2)); //we should never be hasty when networking
|
||||||
state = ENDING_WITHOUT_START;
|
state = ENDING_WITHOUT_START;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logNetwork->infoStream() << "Thread listening for " << *cpc << " ended";
|
logNetwork->infoStream() << "Thread listening for " << *cpc << " ended";
|
||||||
listeningThreads--;
|
listeningThreads--;
|
||||||
vstd::clear_pointer(cpc->handler);
|
vstd::clear_pointer(cpc->handler);
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ void CPregameServer::run()
|
|||||||
|
|
||||||
if(state != RUNNING)
|
if(state != RUNNING)
|
||||||
{
|
{
|
||||||
logNetwork->infoStream() << "Stopping listening for connections...";
|
logNetwork->infoStream() << "Stopping listening for connections...";
|
||||||
acceptor->close();
|
acceptor->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,13 +172,13 @@ void CPregameServer::run()
|
|||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(50));
|
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)
|
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));
|
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)
|
if(ec)
|
||||||
{
|
{
|
||||||
logNetwork->infoStream() << "Something wrong during accepting: " << ec.message();
|
logNetwork->infoStream() << "Something wrong during accepting: " << ec.message();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logNetwork->infoStream() << "We got a new connection! :)";
|
logNetwork->infoStream() << "We got a new connection! :)";
|
||||||
CConnection *pc = new CConnection(upcomingConnection, NAME);
|
CConnection *pc = new CConnection(upcomingConnection, NAME);
|
||||||
initConnection(pc);
|
initConnection(pc);
|
||||||
upcomingConnection = nullptr;
|
upcomingConnection = nullptr;
|
||||||
@ -232,7 +232,7 @@ void CPregameServer::start_async_accept()
|
|||||||
|
|
||||||
void CPregameServer::announceTxt(const std::string &txt, const std::string &playerName /*= "system"*/)
|
void CPregameServer::announceTxt(const std::string &txt, const std::string &playerName /*= "system"*/)
|
||||||
{
|
{
|
||||||
logNetwork->infoStream() << playerName << " says: " << txt;
|
logNetwork->infoStream() << playerName << " says: " << txt;
|
||||||
ChatMessage cm;
|
ChatMessage cm;
|
||||||
cm.playerName = playerName;
|
cm.playerName = playerName;
|
||||||
cm.message = txt;
|
cm.message = txt;
|
||||||
@ -251,7 +251,7 @@ void CPregameServer::sendPack(CConnection * pc, const CPackForSelectionScreen &
|
|||||||
{
|
{
|
||||||
if(!pc->sendStop)
|
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;
|
*pc << &pack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ void CPregameServer::initConnection(CConnection *c)
|
|||||||
{
|
{
|
||||||
*c >> c->name;
|
*c >> c->name;
|
||||||
connections.insert(c);
|
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)
|
void CPregameServer::startListeningThread(CConnection * pc)
|
||||||
@ -313,7 +313,7 @@ void CPregameServer::startListeningThread(CConnection * pc)
|
|||||||
CVCMIServer::CVCMIServer()
|
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)
|
: 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()
|
CVCMIServer::~CVCMIServer()
|
||||||
{
|
{
|
||||||
@ -410,7 +410,7 @@ void CVCMIServer::start()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
boost::system::error_code error;
|
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());
|
auto s = new boost::asio::ip::tcp::socket(acceptor->get_io_service());
|
||||||
boost::thread acc(std::bind(vaccept,acceptor,s,&error));
|
boost::thread acc(std::bind(vaccept,acceptor,s,&error));
|
||||||
#ifndef VCMI_ANDROID
|
#ifndef VCMI_ANDROID
|
||||||
@ -421,12 +421,12 @@ void CVCMIServer::start()
|
|||||||
acc.join();
|
acc.join();
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
logNetwork->warnStream()<<"Got connection but there is an error " << error;
|
logNetwork->warnStream()<<"Got connection but there is an error " << error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logNetwork->infoStream()<<"We've accepted someone... ";
|
logNetwork->infoStream()<<"We've accepted someone... ";
|
||||||
firstConnection = new CConnection(s,NAME);
|
firstConnection = new CConnection(s,NAME);
|
||||||
logNetwork->infoStream()<<"Got connection!";
|
logNetwork->infoStream()<<"Got connection!";
|
||||||
while(!end2)
|
while(!end2)
|
||||||
{
|
{
|
||||||
ui8 mode;
|
ui8 mode;
|
||||||
@ -500,7 +500,7 @@ void CVCMIServer::loadGame()
|
|||||||
acceptor->accept(*s,error);
|
acceptor->accept(*s,error);
|
||||||
if(error) //retry
|
if(error) //retry
|
||||||
{
|
{
|
||||||
logNetwork->warnStream()<<"Cannot establish connection - retrying...";
|
logNetwork->warnStream()<<"Cannot establish connection - retrying...";
|
||||||
i--;
|
i--;
|
||||||
continue;
|
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
|
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;
|
end2 = true;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
@ -630,7 +630,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
catch(boost::system::system_error &e)
|
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
|
//catch any startup errors (e.g. can't access port) errors
|
||||||
//and return non-zero status so client can detect error
|
//and return non-zero status so client can detect error
|
||||||
throw;
|
throw;
|
||||||
|
@ -16,12 +16,12 @@
|
|||||||
boost::unique_lock<boost::mutex> lock(*c->wmx); \
|
boost::unique_lock<boost::mutex> lock(*c->wmx); \
|
||||||
*c << &temp_message; \
|
*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)
|
return false;} while(0)
|
||||||
|
|
||||||
#define WRONG_PLAYER_MSG(expectedplayer) do {std::ostringstream oss;\
|
#define WRONG_PLAYER_MSG(expectedplayer) do {std::ostringstream oss;\
|
||||||
oss << "You were identified as player " << gh->getPlayerAt(c) << " while expecting " << expectedplayer;\
|
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)
|
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)
|
#define ERROR_IF_NOT_OWNS(id) do{if(!PLAYER_OWNS(id)){WRONG_PLAYER_MSG(gh->getOwner(id)); ERROR_AND_RETURN; }}while(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user