mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Do not remove hero if left only with commander
This commit is contained in:
committed by
Andrii Danylchenko
parent
e0e3787748
commit
0d15089dd4
@@ -328,7 +328,7 @@ void CGarrisonSlot::clickLeft(tribool down, bool previousState)
|
|||||||
bool lastHeroStackSelected = false;
|
bool lastHeroStackSelected = false;
|
||||||
if(selectedObj->stacksCount() == 1
|
if(selectedObj->stacksCount() == 1
|
||||||
&& owner->getSelection()->upg != upg
|
&& owner->getSelection()->upg != upg
|
||||||
&& dynamic_cast<const CGHeroInstance*>(selectedObj))
|
&& selectedObj->needsLastStack())
|
||||||
{
|
{
|
||||||
lastHeroStackSelected = true;
|
lastHeroStackSelected = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,17 +51,23 @@ static void showInfoDialog(const CGHeroInstance* h, const ui32 txtID, const ui16
|
|||||||
|
|
||||||
static int lowestSpeed(const CGHeroInstance * chi)
|
static int lowestSpeed(const CGHeroInstance * chi)
|
||||||
{
|
{
|
||||||
|
static const CSelector selectorSTACKS_SPEED = Selector::type()(Bonus::STACKS_SPEED);
|
||||||
|
static const std::string keySTACKS_SPEED = "type_" + std::to_string((si32)Bonus::STACKS_SPEED);
|
||||||
|
|
||||||
if(!chi->stacksCount())
|
if(!chi->stacksCount())
|
||||||
{
|
{
|
||||||
|
if(chi->commander && chi->commander->alive)
|
||||||
|
{
|
||||||
|
return chi->commander->valOfBonuses(selectorSTACKS_SPEED, keySTACKS_SPEED);
|
||||||
|
}
|
||||||
|
|
||||||
logGlobal->error("Hero %d (%s) has no army!", chi->id.getNum(), chi->name);
|
logGlobal->error("Hero %d (%s) has no army!", chi->id.getNum(), chi->name);
|
||||||
return 20;
|
return 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto i = chi->Slots().begin();
|
auto i = chi->Slots().begin();
|
||||||
//TODO? should speed modifiers (eg from artifacts) affect hero movement?
|
//TODO? should speed modifiers (eg from artifacts) affect hero movement?
|
||||||
|
|
||||||
static const CSelector selectorSTACKS_SPEED = Selector::type()(Bonus::STACKS_SPEED);
|
|
||||||
static const std::string keySTACKS_SPEED = "type_"+std::to_string((si32)Bonus::STACKS_SPEED);
|
|
||||||
|
|
||||||
int ret = (i++)->second->valOfBonuses(selectorSTACKS_SPEED, keySTACKS_SPEED);
|
int ret = (i++)->second->valOfBonuses(selectorSTACKS_SPEED, keySTACKS_SPEED);
|
||||||
for(; i != chi->Slots().end(); i++)
|
for(; i != chi->Slots().end(); i++)
|
||||||
ret = std::min(ret, i->second->valOfBonuses(selectorSTACKS_SPEED, keySTACKS_SPEED));
|
ret = std::min(ret, i->second->valOfBonuses(selectorSTACKS_SPEED, keySTACKS_SPEED));
|
||||||
|
|||||||
@@ -974,7 +974,8 @@ void CGameHandler::battleAfterLevelUp(const BattleResult &result)
|
|||||||
|
|
||||||
sendAndApply(&sah);
|
sendAndApply(&sah);
|
||||||
}
|
}
|
||||||
if (result.winner != 2 && finishingBattle->winnerHero && finishingBattle->winnerHero->stacks.empty())
|
if (result.winner != 2 && finishingBattle->winnerHero && finishingBattle->winnerHero->stacks.empty()
|
||||||
|
&& (!finishingBattle->winnerHero->commander || !finishingBattle->winnerHero->commander->alive))
|
||||||
{
|
{
|
||||||
RemoveObject ro(finishingBattle->winnerHero->id);
|
RemoveObject ro(finishingBattle->winnerHero->id);
|
||||||
sendAndApply(&ro);
|
sendAndApply(&ro);
|
||||||
|
|||||||
Reference in New Issue
Block a user