mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Merge pull request #4454 from IvanSavenko/hotfix
[1.5.X] Changes for a potential hotfix
This commit is contained in:
commit
fb37b9e08b
@ -265,7 +265,7 @@ BattleAction BattleEvaluator::goTowardsNearest(const CStack * stack, std::vector
|
||||
{
|
||||
std::sort(targetHexes.begin(), targetHexes.end(), [&](BattleHex h1, BattleHex h2) -> bool
|
||||
{
|
||||
return reachability.distances[h1] < reachability.distances[h2];
|
||||
return reachability.distances.at(h1) < reachability.distances.at(h2);
|
||||
});
|
||||
|
||||
for(auto hex : targetHexes)
|
||||
@ -283,7 +283,7 @@ BattleAction BattleEvaluator::goTowardsNearest(const CStack * stack, std::vector
|
||||
}
|
||||
}
|
||||
|
||||
if(reachability.distances[targetHexes.front()] <= GameConstants::BFIELD_SIZE)
|
||||
if(reachability.distances.at(targetHexes.front()) <= GameConstants::BFIELD_SIZE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -291,16 +291,15 @@ BattleAction BattleEvaluator::goTowardsNearest(const CStack * stack, std::vector
|
||||
std::vector<BattleHex> copy = targetHexes;
|
||||
|
||||
for(auto hex : copy)
|
||||
{
|
||||
vstd::concatenate(targetHexes, hex.allNeighbouringTiles());
|
||||
}
|
||||
|
||||
vstd::erase_if(targetHexes, [](const BattleHex & hex) {return !hex.isValid();});
|
||||
vstd::removeDuplicates(targetHexes);
|
||||
}
|
||||
|
||||
BattleHex bestNeighbor = targetHexes.front();
|
||||
|
||||
if(reachability.distances[bestNeighbor] > GameConstants::BFIELD_SIZE)
|
||||
if(reachability.distances.at(bestNeighbor) > GameConstants::BFIELD_SIZE)
|
||||
{
|
||||
return BattleAction::makeDefend(stack);
|
||||
}
|
||||
|
@ -764,7 +764,7 @@ std::vector<const battle::Unit *> BattleExchangeEvaluator::getOneTurnReachableUn
|
||||
|
||||
ReachabilityInfo unitReachability = reachabilityIter != reachabilityCache.end() ? reachabilityIter->second : turnBattle.getReachability(unit);
|
||||
|
||||
bool reachable = unitReachability.distances[hex] <= radius;
|
||||
bool reachable = unitReachability.distances.at(hex) <= radius;
|
||||
|
||||
if(!reachable && unitReachability.accessibility[hex] == EAccessibility::ALIVE_STACK)
|
||||
{
|
||||
@ -774,7 +774,7 @@ std::vector<const battle::Unit *> BattleExchangeEvaluator::getOneTurnReachableUn
|
||||
{
|
||||
for(BattleHex neighbor : hex.neighbouringTiles())
|
||||
{
|
||||
reachable = unitReachability.distances[neighbor] <= radius;
|
||||
reachable = unitReachability.distances.at(neighbor) <= radius;
|
||||
|
||||
if(reachable) break;
|
||||
}
|
||||
@ -824,7 +824,7 @@ bool BattleExchangeEvaluator::checkPositionBlocksOurStacks(HypotheticBattle & hb
|
||||
for(BattleHex hex = BattleHex::TOP_LEFT; hex.isValid(); hex = hex + 1)
|
||||
{
|
||||
bool enemyUnit = false;
|
||||
bool reachable = unitReachability.distances[hex] <= unitSpeed;
|
||||
bool reachable = unitReachability.distances.at(hex) <= unitSpeed;
|
||||
|
||||
if(!reachable && unitReachability.accessibility[hex] == EAccessibility::ALIVE_STACK)
|
||||
{
|
||||
@ -836,7 +836,7 @@ bool BattleExchangeEvaluator::checkPositionBlocksOurStacks(HypotheticBattle & hb
|
||||
|
||||
for(BattleHex neighbor : hex.neighbouringTiles())
|
||||
{
|
||||
reachable = unitReachability.distances[neighbor] <= unitSpeed;
|
||||
reachable = unitReachability.distances.at(neighbor) <= unitSpeed;
|
||||
|
||||
if(reachable) break;
|
||||
}
|
||||
|
@ -620,8 +620,6 @@ void CPlayerInterface::battleStartBefore(const BattleID & battleID, const CCreat
|
||||
{
|
||||
movementController->onBattleStarted();
|
||||
|
||||
//Don't wait for dialogs when we are non-active hot-seat player
|
||||
if (LOCPLINT == this)
|
||||
waitForAllDialogs();
|
||||
}
|
||||
|
||||
@ -645,8 +643,6 @@ void CPlayerInterface::battleStart(const BattleID & battleID, const CCreatureSet
|
||||
cb->registerBattleInterface(autofightingAI);
|
||||
}
|
||||
|
||||
//Don't wait for dialogs when we are non-active hot-seat player
|
||||
if (LOCPLINT == this)
|
||||
waitForAllDialogs();
|
||||
|
||||
BATTLE_EVENT_POSSIBLE_RETURN;
|
||||
@ -1830,6 +1826,9 @@ void CPlayerInterface::artifactDisassembled(const ArtifactLocation &al)
|
||||
|
||||
void CPlayerInterface::waitForAllDialogs()
|
||||
{
|
||||
if (!makingTurn)
|
||||
return;
|
||||
|
||||
while(!dialogs.empty())
|
||||
{
|
||||
auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex);
|
||||
|
@ -68,7 +68,10 @@ GlobalLobbyLoginWindow::GlobalLobbyLoginWindow()
|
||||
onLoginModeChanged(0); // call it manually to disable widgets - toggleMode will not emit this call if this is currenly selected option
|
||||
}
|
||||
else
|
||||
{
|
||||
toggleMode->setSelected(1);
|
||||
onLoginModeChanged(1);
|
||||
}
|
||||
|
||||
filledBackground->playerColored(PlayerColor(1));
|
||||
inputUsername->setCallback([this](const std::string & text)
|
||||
|
@ -286,5 +286,5 @@ GlobalLobbyMatchCard::GlobalLobbyMatchCard(GlobalLobbyWindow * window, const Glo
|
||||
opponentDescription.replaceNumber(matchDescription.participants.size());
|
||||
}
|
||||
|
||||
labelMatchOpponent = std::make_shared<CLabel>(5, 30, FONT_SMALL, ETextAlignment::CENTERLEFT, Colors::YELLOW, opponentDescription.toString());
|
||||
labelMatchOpponent = std::make_shared<CLabel>(5, 30, FONT_SMALL, ETextAlignment::CENTERLEFT, Colors::YELLOW, opponentDescription.toString(), 120);
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ std::string CComponent::getDescription() const
|
||||
return description;
|
||||
}
|
||||
case ComponentType::SPELL:
|
||||
return VLC->spells()->getById(data.subType.as<SpellID>())->getDescriptionTranslated(data.value.value_or(0));
|
||||
return VLC->spells()->getById(data.subType.as<SpellID>())->getDescriptionTranslated(std::max(0, data.value.value_or(0)));
|
||||
case ComponentType::MORALE:
|
||||
return CGI->generaltexth->heroscrn[ 4 - (data.value.value_or(0)>0) + (data.value.value_or(0)<0)];
|
||||
case ComponentType::LUCK:
|
||||
@ -290,7 +290,7 @@ std::string CComponent::getSubtitle() const
|
||||
return CGI->artifacts()->getById(data.subType.as<ArtifactID>())->getNameTranslated();
|
||||
case ComponentType::SPELL_SCROLL:
|
||||
case ComponentType::SPELL:
|
||||
if (data.value < 0)
|
||||
if (data.value.value_or(0) < 0)
|
||||
return "{#A9A9A9|" + CGI->spells()->getById(data.subType.as<SpellID>())->getNameTranslated() + "}";
|
||||
else
|
||||
return CGI->spells()->getById(data.subType.as<SpellID>())->getNameTranslated();
|
||||
|
@ -1035,7 +1035,7 @@ ReachabilityInfo CBattleInfoCallback::makeBFS(const AccessibilityInfo &accessibi
|
||||
if(isInObstacle(curHex, obstacles, checkParams))
|
||||
continue;
|
||||
|
||||
const int costToNeighbour = ret.distances[curHex.hex] + 1;
|
||||
const int costToNeighbour = ret.distances.at(curHex.hex) + 1;
|
||||
for(BattleHex neighbour : BattleHex::neighbouringTilesCache[curHex.hex])
|
||||
{
|
||||
if(neighbour.isValid())
|
||||
|
@ -312,6 +312,27 @@ void CGameState::initNewGame(const IMapService * mapService, bool allowSavingRan
|
||||
std::unique_ptr<CMap> randomMap = mapGenerator.generate();
|
||||
progressTracking.exclude(mapGenerator);
|
||||
|
||||
// Update starting options
|
||||
for(int i = 0; i < randomMap->players.size(); ++i)
|
||||
{
|
||||
const auto & playerInfo = randomMap->players[i];
|
||||
if(playerInfo.canAnyonePlay())
|
||||
{
|
||||
PlayerSettings & playerSettings = scenarioOps->playerInfos[PlayerColor(i)];
|
||||
playerSettings.compOnly = !playerInfo.canHumanPlay;
|
||||
playerSettings.castle = playerInfo.defaultCastle();
|
||||
if(playerSettings.isControlledByAI() && playerSettings.name.empty())
|
||||
{
|
||||
playerSettings.name = VLC->generaltexth->allTexts[468];
|
||||
}
|
||||
playerSettings.color = PlayerColor(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
scenarioOps->playerInfos.erase(PlayerColor(i));
|
||||
}
|
||||
}
|
||||
|
||||
if(allowSavingRandomMap)
|
||||
{
|
||||
try
|
||||
@ -342,26 +363,6 @@ void CGameState::initNewGame(const IMapService * mapService, bool allowSavingRan
|
||||
}
|
||||
|
||||
map = randomMap.release();
|
||||
// Update starting options
|
||||
for(int i = 0; i < map->players.size(); ++i)
|
||||
{
|
||||
const auto & playerInfo = map->players[i];
|
||||
if(playerInfo.canAnyonePlay())
|
||||
{
|
||||
PlayerSettings & playerSettings = scenarioOps->playerInfos[PlayerColor(i)];
|
||||
playerSettings.compOnly = !playerInfo.canHumanPlay;
|
||||
playerSettings.castle = playerInfo.defaultCastle();
|
||||
if(playerSettings.isControlledByAI() && playerSettings.name.empty())
|
||||
{
|
||||
playerSettings.name = VLC->generaltexth->allTexts[468];
|
||||
}
|
||||
playerSettings.color = PlayerColor(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
scenarioOps->playerInfos.erase(PlayerColor(i));
|
||||
}
|
||||
}
|
||||
|
||||
logGlobal->info("Generated random map in %i ms.", sw.getDiff());
|
||||
}
|
||||
|
@ -2696,10 +2696,11 @@ bool CGameHandler::garrisonSwap(ObjectInstanceID tid)
|
||||
}
|
||||
else if (town->garrisonHero && !town->visitingHero) //move hero out of the garrison
|
||||
{
|
||||
//check if moving hero out of town will break 8 wandering heroes limit
|
||||
if (getHeroCount(town->garrisonHero->tempOwner,false) >= 8)
|
||||
int mapCap = VLC->settings()->getInteger(EGameSettings::HEROES_PER_PLAYER_ON_MAP_CAP);
|
||||
//check if moving hero out of town will break wandering heroes limit
|
||||
if (getHeroCount(town->garrisonHero->tempOwner,false) >= mapCap)
|
||||
{
|
||||
complain("Cannot move hero out of the garrison, there are already 8 wandering heroes!");
|
||||
complain("Cannot move hero out of the garrison, there are already " + std::to_string(mapCap) + " wandering heroes!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user