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

Fix: Get rid of 'Tile is not visible' error message

This commit is contained in:
Dmitry Orlov 2022-01-25 14:19:48 +03:00 committed by Andrii Danylchenko
parent ccfa6359ad
commit ea2931c6ea
11 changed files with 31 additions and 17 deletions

View File

@ -79,7 +79,7 @@ void AIGateway::availableCreaturesChanged(const CGDwelling * town)
NET_EVENT_HANDLER;
}
void AIGateway::heroMoved(const TryMoveHero & details)
void AIGateway::heroMoved(const TryMoveHero & details, bool verbose)
{
LOG_TRACE(logAi);
NET_EVENT_HANDLER;
@ -89,8 +89,8 @@ void AIGateway::heroMoved(const TryMoveHero & details)
const int3 from = CGHeroInstance::convertPosition(details.start, false);
const int3 to = CGHeroInstance::convertPosition(details.end, false);
const CGObjectInstance * o1 = vstd::frontOrNull(cb->getVisitableObjs(from));
const CGObjectInstance * o2 = vstd::frontOrNull(cb->getVisitableObjs(to));
const CGObjectInstance * o1 = vstd::frontOrNull(cb->getVisitableObjs(from, verbose));
const CGObjectInstance * o2 = vstd::frontOrNull(cb->getVisitableObjs(to, verbose));
if(details.result == TryMoveHero::TELEPORTATION)
{

View File

@ -123,7 +123,7 @@ public:
void finish() override;
void availableCreaturesChanged(const CGDwelling * town) override;
void heroMoved(const TryMoveHero & details) override;
void heroMoved(const TryMoveHero & details, bool verbose = true) override;
void heroInGarrisonChange(const CGTownInstance * town) override;
void centerView(int3 pos, int focusTime) override;
void tileHidden(const std::unordered_set<int3, ShashInt3> & pos) override;

View File

@ -89,7 +89,7 @@ void VCAI::availableCreaturesChanged(const CGDwelling * town)
NET_EVENT_HANDLER;
}
void VCAI::heroMoved(const TryMoveHero & details)
void VCAI::heroMoved(const TryMoveHero & details, bool verbose)
{
LOG_TRACE(logAi);
NET_EVENT_HANDLER;
@ -99,8 +99,8 @@ void VCAI::heroMoved(const TryMoveHero & details)
const int3 from = CGHeroInstance::convertPosition(details.start, false);
const int3 to = CGHeroInstance::convertPosition(details.end, false);
const CGObjectInstance * o1 = vstd::frontOrNull(cb->getVisitableObjs(from));
const CGObjectInstance * o2 = vstd::frontOrNull(cb->getVisitableObjs(to));
const CGObjectInstance * o1 = vstd::frontOrNull(cb->getVisitableObjs(from, verbose));
const CGObjectInstance * o2 = vstd::frontOrNull(cb->getVisitableObjs(to, verbose));
if(details.result == TryMoveHero::TELEPORTATION)
{

View File

@ -153,7 +153,7 @@ public:
void finish() override;
void availableCreaturesChanged(const CGDwelling * town) override;
void heroMoved(const TryMoveHero & details) override;
void heroMoved(const TryMoveHero & details, bool verbose = true) override;
void heroInGarrisonChange(const CGTownInstance * town) override;
void centerView(int3 pos, int focusTime) override;
void tileHidden(const std::unordered_set<int3, ShashInt3> & pos) override;

View File

@ -234,7 +234,7 @@ STRONG_INLINE void delObjRect(const int & x, const int & y, const int & z, const
return;
}
}
void CPlayerInterface::heroMoved(const TryMoveHero & details)
void CPlayerInterface::heroMoved(const TryMoveHero & details, bool verbose)
{
EVENT_HANDLER_CALLED_BY_CLIENT;
waitWhileDialog();

View File

@ -135,7 +135,7 @@ public:
void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID) override;
void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override;
void heroInGarrisonChange(const CGTownInstance *town) override;
void heroMoved(const TryMoveHero & details) override;
void heroMoved(const TryMoveHero & details, bool verbose = true) override;
void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) override;
void heroSecondarySkillChanged(const CGHeroInstance * hero, int which, int val) override;
void heroManaPointsChanged(const CGHeroInstance * hero) override;

View File

@ -433,12 +433,19 @@ void TryMoveHero::applyCl(CClient *cl)
i.second->tileRevealed(fowRevealed);
//notify interfaces about move
auto gs = cl->gameState();
for(auto i=cl->playerint.begin(); i!=cl->playerint.end(); i++)
{
if(i->first != PlayerColor::SPECTATOR && gs->checkForStandardLoss(i->first)) // Do not notify vanquished player's interface
continue;
if(GS(cl)->isVisible(start - int3(1, 0, 0), i->first)
|| GS(cl)->isVisible(end - int3(1, 0, 0), i->first))
{
i->second->heroMoved(*this);
// src and dst of enemy hero move may be not visible => 'verbose' should be false
const bool verbose = cl->getPlayerRelations(i->first, player) != PlayerRelations::ENEMIES;
i->second->heroMoved(*this, verbose);
}
}

View File

@ -493,10 +493,12 @@ std::vector<const CGHeroInstance *> CGameInfoCallback::getAvailableHeroes(const
const TerrainTile * CGameInfoCallback::getTile( int3 tile, bool verbose) const
{
ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!isVisible(tile), verbose, tile.toString() + " is not visible!", nullptr);
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
if(isVisible(tile))
return &gs->map->getTile(tile);
if(verbose)
logGlobal->error("\r\n%s: %s\r\n", BOOST_CURRENT_FUNCTION, tile.toString() + " is not visible!");
return nullptr;
}
//TODO: typedef?

View File

@ -2457,8 +2457,8 @@ PlayerColor CGameState::checkForStandardWin() const
bool CGameState::checkForStandardLoss( PlayerColor player ) const
{
//std loss condition is: player lost all towns and heroes
const PlayerState &p = *CGameInfoCallback::getPlayerState(player);
return !p.heroes.size() && !p.towns.size();
const PlayerState & pState = *CGameInfoCallback::getPlayerState(player);
return pState.checkVanquished();
}
struct statsHLP

View File

@ -49,6 +49,11 @@ public:
const IBonusBearer * accessBonuses() const override;
int getResourceAmount(int type) const override;
bool checkVanquished() const
{
return heroes.empty() && towns.empty();
}
template <typename Handler> void serialize(Handler &h, const int version)
{
h & color;

View File

@ -93,7 +93,7 @@ public:
virtual void heroVisit(const CGHeroInstance *visitor, const CGObjectInstance *visitedObj, bool start){};
virtual void heroCreated(const CGHeroInstance*){};
virtual void heroInGarrisonChange(const CGTownInstance *town){};
virtual void heroMoved(const TryMoveHero & details){};
virtual void heroMoved(const TryMoveHero & details, bool verbose = true){};
virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val){};
virtual void heroSecondarySkillChanged(const CGHeroInstance * hero, int which, int val){};
virtual void heroManaPointsChanged(const CGHeroInstance * hero){} //not called at the beginning of turn and after spell casts