mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Added workaround for no longer accessible hero in MoveHero
This commit is contained in:
@ -92,8 +92,9 @@ void AIGateway::heroMoved(const TryMoveHero & details, bool verbose)
|
|||||||
validateObject(details.id); //enemy hero may have left visible area
|
validateObject(details.id); //enemy hero may have left visible area
|
||||||
auto hero = cb->getHero(details.id);
|
auto hero = cb->getHero(details.id);
|
||||||
|
|
||||||
const int3 from = hero->convertToVisitablePos(details.start);
|
const int3 from = hero ? hero->convertToVisitablePos(details.start) : (details.start - int3(0,1,0));;
|
||||||
const int3 to = hero->convertToVisitablePos(details.end);
|
const int3 to = hero ? hero->convertToVisitablePos(details.end) : (details.end - int3(0,1,0));
|
||||||
|
|
||||||
const CGObjectInstance * o1 = vstd::frontOrNull(cb->getVisitableObjs(from, verbose));
|
const CGObjectInstance * o1 = vstd::frontOrNull(cb->getVisitableObjs(from, verbose));
|
||||||
const CGObjectInstance * o2 = vstd::frontOrNull(cb->getVisitableObjs(to, verbose));
|
const CGObjectInstance * o2 = vstd::frontOrNull(cb->getVisitableObjs(to, verbose));
|
||||||
|
|
||||||
|
@ -98,11 +98,13 @@ void VCAI::heroMoved(const TryMoveHero & details, bool verbose)
|
|||||||
LOG_TRACE(logAi);
|
LOG_TRACE(logAi);
|
||||||
NET_EVENT_HANDLER;
|
NET_EVENT_HANDLER;
|
||||||
|
|
||||||
validateObject(details.id); //enemy hero may have left visible area
|
//enemy hero may have left visible area
|
||||||
|
validateObject(details.id);
|
||||||
auto hero = cb->getHero(details.id);
|
auto hero = cb->getHero(details.id);
|
||||||
|
|
||||||
const int3 from = hero->convertToVisitablePos(details.start);
|
const int3 from = hero ? hero->convertToVisitablePos(details.start) : (details.start - int3(0,1,0));;
|
||||||
const int3 to = hero->convertToVisitablePos(details.end);
|
const int3 to = hero ? hero->convertToVisitablePos(details.end) : (details.end - int3(0,1,0));
|
||||||
|
|
||||||
const CGObjectInstance * o1 = vstd::frontOrNull(cb->getVisitableObjs(from, verbose));
|
const CGObjectInstance * o1 = vstd::frontOrNull(cb->getVisitableObjs(from, verbose));
|
||||||
const CGObjectInstance * o2 = vstd::frontOrNull(cb->getVisitableObjs(to, verbose));
|
const CGObjectInstance * o2 = vstd::frontOrNull(cb->getVisitableObjs(to, verbose));
|
||||||
|
|
||||||
@ -753,13 +755,13 @@ void makePossibleUpgrades(const CArmedInstance * obj)
|
|||||||
|
|
||||||
for(int i = 0; i < GameConstants::ARMY_SIZE; i++)
|
for(int i = 0; i < GameConstants::ARMY_SIZE; i++)
|
||||||
{
|
{
|
||||||
if(const CStackInstance * s = obj->getStackPtr(SlotID(i)))
|
if(const CStackInstance * s = obj->getStackPtr(SlotID(i)))
|
||||||
{
|
{
|
||||||
UpgradeInfo ui;
|
UpgradeInfo ui;
|
||||||
cb->fillUpgradeInfo(obj, SlotID(i), ui);
|
cb->fillUpgradeInfo(obj, SlotID(i), ui);
|
||||||
if(ui.oldID >= 0 && cb->getResourceAmount().canAfford(ui.cost[0] * s->count))
|
if(ui.oldID >= 0 && cb->getResourceAmount().canAfford(ui.cost[0] * s->count))
|
||||||
{
|
{
|
||||||
cb->upgradeCreature(obj, SlotID(i), ui.newID[0]);
|
cb->upgradeCreature(obj, SlotID(i), ui.newID[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user