Browse Source

Fixes small AC malus of less than 1 resulting in a bonus of 1 AC

pull/1719/head
thebigMuh 5 years ago committed by Anders Jenbo
parent
commit
5f288cbd43
  1. 3
      Source/items.cpp
  2. 24
      Source/utils/math.h

3
Source/items.cpp

@ -16,6 +16,7 @@
#include "options.h"
#include "stores.h"
#include "utils/language.h"
#include "utils/math.h"
namespace devilution {
@ -600,7 +601,7 @@ void CalcPlrItemVals(int p, bool Loadgfx)
tmpac *= itm->_iPLAC;
tmpac /= 100;
if (tmpac == 0)
tmpac = 1;
tmpac = math::Sign(itm->_iPLAC);
bac += tmpac;
}
iflgs |= itm->_iFlags;

24
Source/utils/math.h

@ -0,0 +1,24 @@
/**
* @file math.h
*
* Math utility functions
*/
#pragma once
namespace devilution {
namespace math {
/**
* @brief Compute sign of t
* @tparam T Any arithmetic type
* @param t Value to compute sign of
* @return -1 if t < 0, 1 if t > 0, 0 if t == 0
*/
template<typename T>
int Sign(T t)
{
return (t > T(0)) - (t < T(0));
}
} // namespace math
} // namespace devilution
Loading…
Cancel
Save