forked from teamnwah/openmw-tes3coop
[Client] Long expression to lambda
This commit is contained in:
parent
58a6a8c3bc
commit
689050e1d0
1 changed files with 6 additions and 4 deletions
|
@ -195,11 +195,13 @@ void LocalPlayer::updateStatsDynamic(bool forceUpdate)
|
||||||
|
|
||||||
|
|
||||||
// Update stats when they become 0 or they have changed enough
|
// Update stats when they become 0 or they have changed enough
|
||||||
bool shouldUpdateHealth = oldHealth != health && (health.getCurrent() == 0 || abs(oldHealth.getCurrent() - health.getCurrent()) > 3);
|
auto needUpdate = [](MWMechanics::DynamicStat<float> &oldVal, MWMechanics::DynamicStat<float> &newVal, int limit) {
|
||||||
bool shouldUpdateMagicka = oldMagicka != magicka && (magicka.getCurrent() == 0 || abs(oldMagicka.getCurrent() - magicka.getCurrent()) > 10);
|
return oldVal != newVal && (newVal.getCurrent() == 0 || oldVal.getCurrent() == 0
|
||||||
bool shouldUpdateFatigue = oldFatigue != fatigue && (fatigue.getCurrent() == 0 || abs(oldFatigue.getCurrent() - fatigue.getCurrent()) > 10);
|
|| abs(oldVal.getCurrent() - newVal.getCurrent()) > limit);
|
||||||
|
};
|
||||||
|
|
||||||
if (forceUpdate || shouldUpdateHealth || shouldUpdateMagicka || shouldUpdateFatigue)
|
if (forceUpdate || needUpdate(oldHealth, health, 5) || needUpdate(oldMagicka, magicka, 10) ||
|
||||||
|
needUpdate(oldFatigue, fatigue, 10))
|
||||||
{
|
{
|
||||||
oldHealth = health;
|
oldHealth = health;
|
||||||
oldMagicka = magicka;
|
oldMagicka = magicka;
|
||||||
|
|
Loading…
Reference in a new issue