1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-31 22:05:10 +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; env = ENV;
CCS->musich->loadTerrainMusicThemes(); CCS->musich->loadTerrainMusicThemes();
initializeHeroTownList(); initializeHeroTownList();
adventureInt.reset(new AdventureMapInterface());
} }
void CPlayerInterface::playerEndsTurn(PlayerColor player) void CPlayerInterface::playerEndsTurn(PlayerColor player)
@ -207,9 +208,6 @@ void CPlayerInterface::playerStartsTurn(PlayerColor player)
if(GH.windows().findWindows<AdventureMapInterface>().empty()) if(GH.windows().findWindows<AdventureMapInterface>().empty())
{ {
// after map load - remove all active windows and replace them with adventure map // 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().clear();
GH.windows().pushWindow(adventureInt); GH.windows().pushWindow(adventureInt);
} }

View File

@ -487,7 +487,7 @@ void CGHeroInstance::onHeroVisit(const CGHeroInstance * h) const
if (!boat) if (!boat)
{ {
//Create a new boat for hero //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; boatId = cb->getTopObj(boatPos)->id;
} }
} }

View File

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

View File

@ -425,7 +425,7 @@ void CMapLoaderH3M::readVictoryLossConditions()
case EVictoryConditionType::BEATHERO: case EVictoryConditionType::BEATHERO:
{ {
if (!allowNormalVictory) 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 allowNormalVictory = true; // H3 behavior
assert(appliesToAI == false); // not selectable in editor assert(appliesToAI == false); // not selectable in editor
EventCondition cond(EventCondition::DESTROY); 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 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 int cost = pathfinderHelper->getMovementCost(h->visitablePos(), hmpos, nullptr, nullptr, h->movementPointsRemaining());
const bool standAtObstacle = t.blocked && !t.visitable; const bool movingOntoObstacle = t.blocked && !t.visitable;
const bool standAtWater = !h->boat && t.terType->isWater() && (objectToVisit || !objectToVisit->isCoastVisitable()); const bool objectCoastVisitable = objectToVisit && objectToVisit->isCoastVisitable();
const bool movingOntoWater = !h->boat && t.terType->isWater() && !objectCoastVisitable;
const auto complainRet = [&](const std::string & message) 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 //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) //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!"); 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) //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!"); return complainRet("Cannot move hero, destination tile is on water!");
if(h->boat && h->boat->layer == EPathfindingLayer::SAIL && t.terType->isLand() && t.blocked) 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) if(h->boat && !h->boat->onboardAssaultAllowed)
lookForGuards = IGNORE_GUARDS; lookForGuards = IGNORE_GUARDS;
turnTimerHandler.setEndTurnAllowed(h->getOwner(), !standAtWater && !standAtObstacle); turnTimerHandler.setEndTurnAllowed(h->getOwner(), !movingOntoWater && !movingOntoObstacle);
doMove(TryMoveHero::SUCCESS, lookForGuards, visitDest, LEAVING_TILE); doMove(TryMoveHero::SUCCESS, lookForGuards, visitDest, LEAVING_TILE);
return true; return true;
} }