1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-29 21:56:54 +02:00

Merge pull request #2967 from IvanSavenko/bugfixing

Miscellaneous bugfixing
This commit is contained in:
Ivan Savenko 2023-09-28 12:11:51 +03:00 committed by GitHub
commit 9ba1aa652d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 15 deletions

View File

@ -166,8 +166,9 @@ void CPlayerInterface::initGameInterface(std::shared_ptr<Environment> ENV, std::
env = ENV;
CCS->musich->loadTerrainMusicThemes();
initializeHeroTownList();
adventureInt.reset(new AdventureMapInterface());
}
void CPlayerInterface::playerEndsTurn(PlayerColor player)
@ -207,9 +208,6 @@ void CPlayerInterface::playerStartsTurn(PlayerColor player)
if(GH.windows().findWindows<AdventureMapInterface>().empty())
{
// after map load - remove all active windows and replace them with adventure map
// always recreate advmap interface to avoid possible memory-corruption bugs
adventureInt.reset(new AdventureMapInterface());
GH.windows().clear();
GH.windows().pushWindow(adventureInt);
}

View File

@ -487,7 +487,7 @@ void CGHeroInstance::onHeroVisit(const CGHeroInstance * h) const
if (!boat)
{
//Create a new boat for hero
cb->createObject(boatPos, Obj::BOAT, getBoatType().getNum());
cb->createObject(boatPos, h->getOwner(), Obj::BOAT, getBoatType().getNum());
boatId = cb->getTopObj(boatPos)->id;
}
}

View File

@ -557,6 +557,10 @@ void CGSeerHut::setObjToKill()
quest->heroName = getHeroToKill(false)->getNameTranslated();
quest->heroPortrait = getHeroToKill(false)->portrait;
}
quest->getCompletionText(configuration.onSelect);
for(auto & i : configuration.info)
quest->getCompletionText(i.message);
}
void CGSeerHut::init(CRandomGenerator & rand)
@ -596,10 +600,6 @@ void CGSeerHut::initObj(CRandomGenerator & rand)
quest->progress = CQuest::COMPLETE;
quest->firstVisitText = VLC->generaltexth->seerEmpty[quest->completedOption];
}
quest->getCompletionText(configuration.onSelect);
for(auto & i : configuration.info)
quest->getCompletionText(i.message);
}
void CGSeerHut::getRolloverText(MetaString &text, bool onHover) const

View File

@ -425,7 +425,7 @@ void CMapLoaderH3M::readVictoryLossConditions()
case EVictoryConditionType::BEATHERO:
{
if (!allowNormalVictory)
logGlobal->warn("Map %s: Has 'beat hero' as victory condition, but 'allow normal victory' not set. Ignoring", mapName);
logGlobal->debug("Map %s: Has 'beat hero' as victory condition, but 'allow normal victory' not set. Ignoring", mapName);
allowNormalVictory = true; // H3 behavior
assert(appliesToAI == false); // not selectable in editor
EventCondition cond(EventCondition::DESTROY);

View File

@ -1119,8 +1119,9 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
const bool canWalkOnSea = pathfinderHelper->hasBonusOfType(BonusType::WATER_WALKING) || (h->boat && h->boat->layer == EPathfindingLayer::WATER);
const int cost = pathfinderHelper->getMovementCost(h->visitablePos(), hmpos, nullptr, nullptr, h->movementPointsRemaining());
const bool standAtObstacle = t.blocked && !t.visitable;
const bool standAtWater = !h->boat && t.terType->isWater() && (objectToVisit || !objectToVisit->isCoastVisitable());
const bool movingOntoObstacle = t.blocked && !t.visitable;
const bool objectCoastVisitable = objectToVisit && objectToVisit->isCoastVisitable();
const bool movingOntoWater = !h->boat && t.terType->isWater() && !objectCoastVisitable;
const auto complainRet = [&](const std::string & message)
{
@ -1144,11 +1145,11 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
//it's a rock or blocked and not visitable tile
//OR hero is on land and dest is water and (there is not present only one object - boat)
if (!t.terType->isPassable() || (standAtObstacle && !canFly))
if (!t.terType->isPassable() || (movingOntoObstacle && !canFly))
return complainRet("Cannot move hero, destination tile is blocked!");
//hero is not on boat/water walking and dst water tile doesn't contain boat/hero (objs visitable from land) -> we test back cause boat may be on top of another object (#276)
if(standAtWater && !canFly && !canWalkOnSea)
if(movingOntoWater && !canFly && !canWalkOnSea)
return complainRet("Cannot move hero, destination tile is on water!");
if(h->boat && h->boat->layer == EPathfindingLayer::SAIL && t.terType->isLand() && t.blocked)
@ -1294,7 +1295,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
if(h->boat && !h->boat->onboardAssaultAllowed)
lookForGuards = IGNORE_GUARDS;
turnTimerHandler.setEndTurnAllowed(h->getOwner(), !standAtWater && !standAtObstacle);
turnTimerHandler.setEndTurnAllowed(h->getOwner(), !movingOntoWater && !movingOntoObstacle);
doMove(TryMoveHero::SUCCESS, lookForGuards, visitDest, LEAVING_TILE);
return true;
}