mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
commit
aaefc07182
@ -890,11 +890,12 @@ bool BattleExchangeEvaluator::checkPositionBlocksOurStacks(HypotheticBattle & hb
|
||||
auto ratio = blockedUnitDamage / (blockedUnitDamage + activeUnitDamage);
|
||||
|
||||
auto unitReachability = turnBattle.getReachability(unit);
|
||||
auto unitSpeed = unit->speed(turn); // Cached value, to avoid performance hit
|
||||
|
||||
for(BattleHex hex = BattleHex::TOP_LEFT; hex.isValid(); hex = hex + 1)
|
||||
{
|
||||
bool enemyUnit = false;
|
||||
bool reachable = unitReachability.distances[hex] <= unit->speed(turn);
|
||||
bool reachable = unitReachability.distances[hex] <= unitSpeed;
|
||||
|
||||
if(!reachable && unitReachability.accessibility[hex] == EAccessibility::ALIVE_STACK)
|
||||
{
|
||||
@ -906,7 +907,7 @@ bool BattleExchangeEvaluator::checkPositionBlocksOurStacks(HypotheticBattle & hb
|
||||
|
||||
for(BattleHex neighbor : hex.neighbouringTiles())
|
||||
{
|
||||
reachable = unitReachability.distances[neighbor] <= unit->speed(turn);
|
||||
reachable = unitReachability.distances[neighbor] <= unitSpeed;
|
||||
|
||||
if(reachable) break;
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ std::shared_ptr<StackWithBonuses> HypotheticBattle::getForUpdate(uint32_t id)
|
||||
}
|
||||
}
|
||||
|
||||
battle::Units HypotheticBattle::getUnitsIf(battle::UnitFilter predicate) const
|
||||
battle::Units HypotheticBattle::getUnitsIf(const battle::UnitFilter & predicate) const
|
||||
{
|
||||
battle::Units proxyed = BattleProxy::getUnitsIf(predicate);
|
||||
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
|
||||
int32_t getActiveStackID() const override;
|
||||
|
||||
battle::Units getUnitsIf(battle::UnitFilter predicate) const override;
|
||||
battle::Units getUnitsIf(const battle::UnitFilter & predicate) const override;
|
||||
|
||||
void nextRound() override;
|
||||
void nextTurn(uint32_t unitId) override;
|
||||
|
@ -119,12 +119,16 @@ void CGuiHandler::renderFrame()
|
||||
|
||||
if (settings["video"]["showfps"].Bool())
|
||||
drawFPSCounter();
|
||||
}
|
||||
|
||||
SDL_UpdateTexture(screenTexture, nullptr, screen->pixels, screen->pitch);
|
||||
|
||||
SDL_RenderClear(mainRenderer);
|
||||
SDL_RenderCopy(mainRenderer, screenTexture, nullptr, nullptr);
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(GH.interfaceMutex);
|
||||
|
||||
CCS->curh->render();
|
||||
|
||||
windows().onFrameRendered();
|
||||
|
@ -562,14 +562,14 @@ int32_t BattleInfo::getActiveStackID() const
|
||||
return activeStack;
|
||||
}
|
||||
|
||||
TStacks BattleInfo::getStacksIf(TStackFilter predicate) const
|
||||
TStacks BattleInfo::getStacksIf(const TStackFilter & predicate) const
|
||||
{
|
||||
TStacks ret;
|
||||
vstd::copy_if(stacks, std::back_inserter(ret), predicate);
|
||||
return ret;
|
||||
}
|
||||
|
||||
battle::Units BattleInfo::getUnitsIf(battle::UnitFilter predicate) const
|
||||
battle::Units BattleInfo::getUnitsIf(const battle::UnitFilter & predicate) const
|
||||
{
|
||||
battle::Units ret;
|
||||
vstd::copy_if(stacks, std::back_inserter(ret), predicate);
|
||||
|
@ -85,9 +85,9 @@ public:
|
||||
|
||||
int32_t getActiveStackID() const override;
|
||||
|
||||
TStacks getStacksIf(TStackFilter predicate) const override;
|
||||
TStacks getStacksIf(const TStackFilter & predicate) const override;
|
||||
|
||||
battle::Units getUnitsIf(battle::UnitFilter predicate) const override;
|
||||
battle::Units getUnitsIf(const battle::UnitFilter & predicate) const override;
|
||||
|
||||
BattleField getBattlefieldType() const override;
|
||||
TerrainId getTerrainType() const override;
|
||||
|
@ -40,12 +40,12 @@ int32_t BattleProxy::getActiveStackID() const
|
||||
return -1;
|
||||
}
|
||||
|
||||
TStacks BattleProxy::getStacksIf(TStackFilter predicate) const
|
||||
TStacks BattleProxy::getStacksIf(const TStackFilter & predicate) const
|
||||
{
|
||||
return subject->battleGetStacksIf(predicate);
|
||||
}
|
||||
|
||||
battle::Units BattleProxy::getUnitsIf(battle::UnitFilter predicate) const
|
||||
battle::Units BattleProxy::getUnitsIf(const battle::UnitFilter & predicate) const
|
||||
{
|
||||
return subject->battleGetUnitsIf(predicate);
|
||||
}
|
||||
|
@ -29,9 +29,9 @@ public:
|
||||
|
||||
int32_t getActiveStackID() const override;
|
||||
|
||||
TStacks getStacksIf(TStackFilter predicate) const override;
|
||||
TStacks getStacksIf(const TStackFilter & predicate) const override;
|
||||
|
||||
battle::Units getUnitsIf(battle::UnitFilter predicate) const override;
|
||||
battle::Units getUnitsIf(const battle::UnitFilter & predicate) const override;
|
||||
|
||||
BattleField getBattlefieldType() const override;
|
||||
TerrainId getTerrainType() const override;
|
||||
|
@ -357,7 +357,7 @@ const battle::Unit * CBattleInfoCallback::battleGetUnitByPos(BattleHex pos, bool
|
||||
auto ret = battleGetUnitsIf([=](const battle::Unit * unit)
|
||||
{
|
||||
return !unit->isGhost()
|
||||
&& vstd::contains(battle::Unit::getHexes(unit->getPosition(), unit->doubleWide(), unit->unitSide()), pos)
|
||||
&& unit->coversPos(pos)
|
||||
&& (!onlyAlive || unit->alive());
|
||||
});
|
||||
|
||||
|
@ -109,13 +109,13 @@ TStacks CBattleInfoEssentials::battleGetAllStacks(bool includeTurrets) const
|
||||
});
|
||||
}
|
||||
|
||||
TStacks CBattleInfoEssentials::battleGetStacksIf(TStackFilter predicate) const
|
||||
TStacks CBattleInfoEssentials::battleGetStacksIf(const TStackFilter & predicate) const
|
||||
{
|
||||
RETURN_IF_NOT_BATTLE(TStacks());
|
||||
return getBattle()->getStacksIf(std::move(predicate));
|
||||
}
|
||||
|
||||
battle::Units CBattleInfoEssentials::battleGetUnitsIf(battle::UnitFilter predicate) const
|
||||
battle::Units CBattleInfoEssentials::battleGetUnitsIf(const battle::UnitFilter & predicate) const
|
||||
{
|
||||
RETURN_IF_NOT_BATTLE(battle::Units());
|
||||
return getBattle()->getUnitsIf(predicate);
|
||||
|
@ -62,8 +62,8 @@ public:
|
||||
* @return filtered stacks
|
||||
*
|
||||
*/
|
||||
TStacks battleGetStacksIf(TStackFilter predicate) const; //deprecated
|
||||
battle::Units battleGetUnitsIf(battle::UnitFilter predicate) const override;
|
||||
TStacks battleGetStacksIf(const TStackFilter & predicate) const; //deprecated
|
||||
battle::Units battleGetUnitsIf(const battle::UnitFilter & predicate) const override;
|
||||
|
||||
const battle::Unit * battleGetUnitByID(uint32_t ID) const override;
|
||||
const battle::Unit * battleActiveUnit() const override;
|
||||
|
@ -46,7 +46,7 @@ int32_t CAmmo::available() const
|
||||
|
||||
bool CAmmo::canUse(int32_t amount) const
|
||||
{
|
||||
return !isLimited() || (available() - amount >= 0);
|
||||
return (available() - amount >= 0) || !isLimited();
|
||||
}
|
||||
|
||||
bool CAmmo::isLimited() const
|
||||
@ -99,7 +99,7 @@ CShots & CShots::operator=(const CShots & other)
|
||||
|
||||
bool CShots::isLimited() const
|
||||
{
|
||||
return !env->unitHasAmmoCart(owner) || !shooter.getHasBonus();
|
||||
return !shooter.getHasBonus() || !env->unitHasAmmoCart(owner);
|
||||
}
|
||||
|
||||
void CShots::setEnv(const IUnitEnvironment * env_)
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
|
||||
virtual uint32_t battleNextUnitId() const = 0;
|
||||
|
||||
virtual battle::Units battleGetUnitsIf(battle::UnitFilter predicate) const = 0;
|
||||
virtual battle::Units battleGetUnitsIf(const battle::UnitFilter & predicate) const = 0;
|
||||
|
||||
virtual const battle::Unit * battleGetUnitByID(uint32_t ID) const = 0;
|
||||
virtual const battle::Unit * battleGetUnitByPos(BattleHex pos, bool onlyAlive = true) const = 0;
|
||||
|
@ -42,9 +42,9 @@ public:
|
||||
|
||||
virtual int32_t getActiveStackID() const = 0;
|
||||
|
||||
virtual TStacks getStacksIf(TStackFilter predicate) const = 0;
|
||||
virtual TStacks getStacksIf(const TStackFilter & predicate) const = 0;
|
||||
|
||||
virtual battle::Units getUnitsIf(battle::UnitFilter predicate) const = 0;
|
||||
virtual battle::Units getUnitsIf(const battle::UnitFilter & predicate) const = 0;
|
||||
|
||||
virtual BattleField getBattlefieldType() const = 0;
|
||||
virtual TerrainId getTerrainType() const = 0;
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
|
||||
MOCK_CONST_METHOD0(battleNextUnitId, uint32_t());
|
||||
|
||||
MOCK_CONST_METHOD1(battleGetUnitsIf, battle::Units(battle::UnitFilter));
|
||||
MOCK_CONST_METHOD1(battleGetUnitsIf, battle::Units(const battle::UnitFilter &));
|
||||
|
||||
MOCK_CONST_METHOD1(battleGetUnitByID, const battle::Unit *(uint32_t));
|
||||
MOCK_CONST_METHOD2(battleGetUnitByPos, const battle::Unit *(BattleHex, bool));
|
||||
|
@ -17,8 +17,8 @@ class BattleStateMock : public IBattleState
|
||||
{
|
||||
public:
|
||||
MOCK_CONST_METHOD0(getActiveStackID, int32_t());
|
||||
MOCK_CONST_METHOD1(getStacksIf, TStacks(TStackFilter));
|
||||
MOCK_CONST_METHOD1(getUnitsIf, battle::Units(battle::UnitFilter));
|
||||
MOCK_CONST_METHOD1(getStacksIf, TStacks(const TStackFilter&));
|
||||
MOCK_CONST_METHOD1(getUnitsIf, battle::Units(const battle::UnitFilter &));
|
||||
MOCK_CONST_METHOD0(getBattlefieldType, BattleField());
|
||||
MOCK_CONST_METHOD0(getTerrainType, TerrainId());
|
||||
MOCK_CONST_METHOD0(getAllObstacles, IBattleInfo::ObstacleCList());
|
||||
|
Loading…
x
Reference in New Issue
Block a user