- Backend update from Raze

* fix for serializing vector arrays.
* a few adjustments for asan on Windows.
* NOMUSICCUTOFF flag for movie player.
* a bit of cleanup.
This commit is contained in:
Christoph Oelckers 2022-10-20 20:12:06 +02:00
parent ca8897028f
commit 70df444660
7 changed files with 33 additions and 36 deletions

View file

@ -159,7 +159,7 @@ public:
template<class T>
FSerializer &Array(const char *key, T *obj, T *def, int count, bool fullcompare = false)
{
if (!save_full && fullcompare && isWriting() && def != nullptr && !memcmp(obj, def, count * sizeof(T)))
if (!save_full && fullcompare && isWriting() && key != nullptr && def != nullptr && !memcmp(obj, def, count * sizeof(T)))
{
return *this;
}

View file

@ -47,6 +47,12 @@
#define NO_SANITIZE
#endif
#if defined _MSC_VER
#define NO_SANITIZE_M __declspec(no_sanitize_address)
#else
#define NO_SANITIZE_M
#endif
class FAutoSeg
{
const char *name;
@ -102,14 +108,14 @@ public:
}
template <typename Func>
void ForEach(Func func, std::enable_if_t<HasReturnTypeV<Func, void>> * = nullptr)
void NO_SANITIZE_M ForEach(Func func, std::enable_if_t<HasReturnTypeV<Func, void>> * = nullptr)
{
using CallableType = decltype(&Func::operator());
using ArgType = typename ArgumentType<CallableType>::Type;
for (void **it = begin; it < end; ++it)
{
if (*it)
if (intptr_t(it) > 0xffff && *it && intptr_t(*it) > 0xffff)
{
func(reinterpret_cast<ArgType>(*it));
}
@ -117,14 +123,14 @@ public:
}
template <typename Func>
void ForEach(Func func, std::enable_if_t<HasReturnTypeV<Func, bool>> * = nullptr)
void NO_SANITIZE_M ForEach(Func func, std::enable_if_t<HasReturnTypeV<Func, bool>> * = nullptr)
{
using CallableType = decltype(&Func::operator());
using ArgType = typename ArgumentType<CallableType>::Type;
for (void **it = begin; it < end; ++it)
{
if (*it)
if (intptr_t(it) > 0xffff && *it && intptr_t(*it) > 0xffff)
{
if (!func(reinterpret_cast<ArgType>(*it)))
{

View file

@ -187,7 +187,7 @@ bool PClass::ReadAllFields(FSerializer &ar, void *addr) const
//
//==========================================================================
static int cregcmp (const void *a, const void *b) NO_SANITIZE
static NO_SANITIZE_M int cregcmp (const void *a, const void *b) NO_SANITIZE
{
const PClass *class1 = *(const PClass **)a;
const PClass *class2 = *(const PClass **)b;

View file

@ -217,16 +217,7 @@ double I_GetInputFrac(bool const synchronised)
const double now = I_msTimeF();
const double result = (now - lastinputtime) * GameTicRate * (1. / 1000.);
lastinputtime = now;
if (result < 1)
{
// Calculate an amplification to apply to the result before returning,
// factoring in the game's ticrate and the value of the result.
// This rectifies a deviation of 100+ ms or more depending on the length
// of the operation to be within 1-2 ms of synchronised input
// from 60 fps to at least 1000 fps at ticrates of 30 and 40 Hz.
return result * (1. + 0.35 * (1. - GameTicRate * (1. / 50.)) * (1. - result));
}
return result;
}
return 1;

View file

@ -16,9 +16,9 @@ __forceinline constexpr int64_t DivScaleL(int64_t a, int64_t b, int shift) { ret
#include "xs_Float.h"
template<int b = 16>
inline fixed_t FloatToFixed(double f)
constexpr fixed_t FloatToFixed(double f)
{
return xs_Fix<b>::ToFix(f);
return int(f * (1 << b));
}
template<int b = 16>

View file

@ -272,6 +272,11 @@ struct TVector2
return X*other.X + Y*other.Y;
}
vec_t dot(const TVector2 &other) const
{
return X*other.X + Y*other.Y;
}
// Returns the angle that the ray (0,0)-(X,Y) faces
TAngle<vec_t> Angle() const;
@ -1307,6 +1312,11 @@ public:
return Degrees_ / other;
}
constexpr double operator/ (TAngle other) const
{
return Degrees_ / other.Degrees_;
}
// Should the comparisons consider an epsilon value?
constexpr bool operator< (TAngle other) const
{
@ -1486,27 +1496,15 @@ inline TVector2<T> clamp(const TVector2<T> &vec, const TVector2<T> &min, const T
}
template<class T>
inline TVector2<T> interpolatedvec2(const TVector2<T> &ovec, const TVector2<T> &vec, const double scale)
inline TAngle<T> interpolatedvalue(const TAngle<T> &oang, const TAngle<T> &ang, const double interpfrac)
{
return ovec + ((vec - ovec) * scale);
return oang + (deltaangle(oang, ang) * interpfrac);
}
template<class T>
inline TVector3<T> interpolatedvec3(const TVector3<T> &ovec, const TVector3<T> &vec, const double scale)
template <class T>
inline T interpolatedvalue(const T& oval, const T& val, const double interpfrac)
{
return ovec + ((vec - ovec) * scale);
}
template<class T>
inline TVector4<T> interpolatedvec4(const TVector4<T> &ovec, const TVector4<T> &vec, const double scale)
{
return ovec + ((vec - ovec) * scale);
}
template<class T>
inline TAngle<T> interpolatedangle(const TAngle<T> &oang, const TAngle<T> &ang, const double scale)
{
return oang + (deltaangle(oang, ang) * scale);
return T(oval + (val - oval) * interpfrac);
}
// Much of this is copied from TVector3. Is all that functionality really appropriate?
@ -1692,6 +1690,7 @@ typedef TMatrix3x3<double> DMatrix3x3;
typedef TAngle<double> DAngle;
constexpr DAngle nullAngle = DAngle::fromDeg(0.);
constexpr DAngle minAngle = DAngle::fromDeg(1. / 65536.);
constexpr FAngle nullFAngle = FAngle::fromDeg(0.);
constexpr DAngle DAngle22_5 = DAngle::fromDeg(22.5);

View file

@ -204,6 +204,7 @@ struct MoviePlayer native
{
NOSOUNDCUTOFF = 1,
FIXEDVIEWPORT = 2, // Forces fixed 640x480 screen size like for Blood's intros.
NOMUSICCUTOFF = 4,
}
native static MoviePlayer Create(String filename, Array<int> soundinfo, int flags, int frametime, int firstframetime, int lastframetime);
@ -236,7 +237,7 @@ class MoviePlayerJob : SkippableScreenJob
override void Start()
{
System.StopMusic();
if (!(flag & MoviePlayer.NOMUSICCUTOFF)) System.StopMusic();
}