mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Merge with vcmi/develop branch
This commit is contained in:
@@ -731,7 +731,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance * heroAttacker, con
|
||||
|
||||
//Check how many battle queries were created (number of players blocked by battle)
|
||||
const int queriedPlayers = battleQuery ? (int)boost::count(queries.allQueries(), battleQuery) : 0;
|
||||
finishingBattle = make_unique<FinishingBattleHelper>(battleQuery, queriedPlayers);
|
||||
finishingBattle = std::make_unique<FinishingBattleHelper>(battleQuery, queriedPlayers);
|
||||
|
||||
CasualtiesAfterBattle cab1(bEndArmy1, gs->curB), cab2(bEndArmy2, gs->curB); //calculate casualties before deleting battle
|
||||
ChangeSpells cs; //for Eagle Eye
|
||||
@@ -950,7 +950,7 @@ void CGameHandler::battleAfterLevelUp(const BattleResult &result)
|
||||
if (visitObjectAfterVictory && result.winner==0 && !finishingBattle->winnerHero->stacks.empty())
|
||||
{
|
||||
logGlobal->trace("post-victory visit");
|
||||
visitObjectOnTile(*getTile(finishingBattle->winnerHero->getPosition()), finishingBattle->winnerHero);
|
||||
visitObjectOnTile(*getTile(finishingBattle->winnerHero->visitablePos()), finishingBattle->winnerHero);
|
||||
}
|
||||
visitObjectAfterVictory = false;
|
||||
|
||||
@@ -1666,7 +1666,7 @@ CGameHandler::~CGameHandler()
|
||||
|
||||
void CGameHandler::reinitScripting()
|
||||
{
|
||||
serverEventBus = make_unique<events::EventBus>();
|
||||
serverEventBus = std::make_unique<events::EventBus>();
|
||||
#if SCRIPTING_ENABLED
|
||||
serverScripts.reset(new scripting::PoolImpl(this, spellEnv));
|
||||
#endif
|
||||
@@ -1926,9 +1926,9 @@ void CGameHandler::newTurn()
|
||||
|
||||
NewTurn::Hero hth;
|
||||
hth.id = h->id;
|
||||
auto ti = make_unique<TurnInfo>(h, 1);
|
||||
auto ti = std::make_unique<TurnInfo>(h, 1);
|
||||
// TODO: this code executed when bonuses of previous day not yet updated (this happen in NewTurn::applyGs). See issue 2356
|
||||
hth.move = h->maxMovePointsCached(gs->map->getTile(h->getPosition(false)).terType->isLand(), ti.get());
|
||||
hth.move = h->maxMovePointsCached(gs->map->getTile(h->visitablePos()).terType->isLand(), ti.get());
|
||||
hth.mana = h->getManaNewTurn();
|
||||
|
||||
n.heroes.insert(hth);
|
||||
@@ -2323,7 +2323,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
|
||||
}
|
||||
|
||||
logGlobal->trace("Player %d (%s) wants to move hero %d from %s to %s", asker, asker.getStr(), hid.getNum(), h->pos.toString(), dst.toString());
|
||||
const int3 hmpos = CGHeroInstance::convertPosition(dst, false);
|
||||
const int3 hmpos = h->convertToVisitablePos(dst);
|
||||
|
||||
if (!gs->map->isInTheMap(hmpos))
|
||||
{
|
||||
@@ -2346,14 +2346,14 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
|
||||
tmh.movePoints = h->movement;
|
||||
|
||||
//check if destination tile is available
|
||||
auto pathfinderHelper = make_unique<CPathfinderHelper>(gs, h, PathfinderOptions());
|
||||
auto pathfinderHelper = std::make_unique<CPathfinderHelper>(gs, h, PathfinderOptions());
|
||||
|
||||
pathfinderHelper->updateTurnInfo(0);
|
||||
auto ti = pathfinderHelper->getTurnInfo();
|
||||
|
||||
const bool canFly = pathfinderHelper->hasBonusOfType(Bonus::FLYING_MOVEMENT);
|
||||
const bool canWalkOnSea = pathfinderHelper->hasBonusOfType(Bonus::WATER_WALKING);
|
||||
const int cost = pathfinderHelper->getMovementCost(h->getPosition(), hmpos, nullptr, nullptr, h->movement);
|
||||
const int cost = pathfinderHelper->getMovementCost(h->visitablePos(), hmpos, nullptr, nullptr, h->movement);
|
||||
|
||||
//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)
|
||||
@@ -2523,8 +2523,8 @@ bool CGameHandler::teleportHero(ObjectInstanceID hid, ObjectInstanceID dstid, ui
|
||||
|| (!t->hasBuilt(BuildingSubID::CASTLE_GATE)
|
||||
&& complain("Cannot teleport hero to town without Castle gate in it")))
|
||||
return false;
|
||||
int3 pos = t->visitablePos();
|
||||
pos += h->getVisitableOffset();
|
||||
|
||||
int3 pos = h->convertFromVisitablePos(t->visitablePos());
|
||||
moveHero(hid,pos,1);
|
||||
return true;
|
||||
}
|
||||
@@ -3714,7 +3714,7 @@ bool CGameHandler::upgradeCreature(ObjectInstanceID objid, SlotID pos, CreatureI
|
||||
COMPLAIN_RET("Cannot upgrade, no stack at slot " + boost::to_string(pos));
|
||||
}
|
||||
UpgradeInfo ui;
|
||||
getUpgradeInfo(obj, pos, ui);
|
||||
fillUpgradeInfo(obj, pos, ui);
|
||||
PlayerColor player = obj->tempOwner;
|
||||
const PlayerState *p = getPlayerState(player);
|
||||
int crQuantity = obj->stacks.at(pos)->count;
|
||||
@@ -4350,7 +4350,7 @@ bool CGameHandler::hireHero(const CGObjectInstance *obj, ui8 hid, PlayerColor pl
|
||||
hr.tid = obj->id;
|
||||
hr.hid = nh->subID;
|
||||
hr.player = player;
|
||||
hr.tile = obj->visitablePos() + nh->getVisitableOffset();
|
||||
hr.tile = nh->convertFromVisitablePos(obj->visitablePos());
|
||||
sendAndApply(&hr);
|
||||
|
||||
std::map<ui32, ConstTransitivePtr<CGHeroInstance> > pool = gs->unusedHeroesFromPool();
|
||||
@@ -5953,7 +5953,7 @@ bool CGameHandler::dig(const CGHeroInstance *h)
|
||||
{
|
||||
for (auto i = gs->map->objects.cbegin(); i != gs->map->objects.cend(); i++) //unflag objs
|
||||
{
|
||||
if (*i && (*i)->ID == Obj::HOLE && (*i)->pos == h->getPosition())
|
||||
if (*i && (*i)->ID == Obj::HOLE && (*i)->pos == h->visitablePos())
|
||||
{
|
||||
complain("Cannot dig - there is already a hole under the hero!");
|
||||
return false;
|
||||
@@ -5966,7 +5966,7 @@ bool CGameHandler::dig(const CGHeroInstance *h)
|
||||
//create a hole
|
||||
NewObject no;
|
||||
no.ID = Obj::HOLE;
|
||||
no.pos = h->getPosition();
|
||||
no.pos = h->visitablePos();
|
||||
no.subID = 0;
|
||||
sendAndApply(&no);
|
||||
|
||||
@@ -5978,7 +5978,7 @@ bool CGameHandler::dig(const CGHeroInstance *h)
|
||||
|
||||
InfoWindow iw;
|
||||
iw.player = h->tempOwner;
|
||||
if (gs->map->grailPos == h->getPosition())
|
||||
if (gs->map->grailPos == h->visitablePos())
|
||||
{
|
||||
iw.text.addTxt(MetaString::GENERAL_TXT, 58); //"Congratulations! After spending many hours digging here, your hero has uncovered the "
|
||||
iw.text.addTxt(MetaString::ART_NAMES, ArtifactID::GRAIL);
|
||||
|
||||
Reference in New Issue
Block a user