- Backend update from Raze.

This commit is contained in:
Christoph Oelckers 2023-02-11 12:05:45 +01:00
parent 68d3f474ce
commit f6bfc48d9f
16 changed files with 59 additions and 43 deletions

View File

@ -131,7 +131,7 @@ public:
void SetMusicVolume (float volume)
{
}
SoundHandle LoadSound(uint8_t *sfxdata, int length)
SoundHandle LoadSound(uint8_t *sfxdata, int length, int def_loop_start, int def_loop_end)
{
SoundHandle retval = { NULL };
return retval;

View File

@ -105,7 +105,7 @@ public:
virtual bool IsNull() { return false; }
virtual void SetSfxVolume (float volume) = 0;
virtual void SetMusicVolume (float volume) = 0;
virtual SoundHandle LoadSound(uint8_t *sfxdata, int length) = 0;
virtual SoundHandle LoadSound(uint8_t *sfxdata, int length, int def_loop_start, int def_loop_end) = 0;
SoundHandle LoadSoundVoc(uint8_t *sfxdata, int length);
virtual SoundHandle LoadSoundRaw(uint8_t *sfxdata, int length, int frequency, int channels, int bits, int loopstart, int loopend = -1) = 0;
virtual void UnloadSound (SoundHandle sfx) = 0; // unloads a sound from memory

View File

@ -1096,7 +1096,7 @@ SoundHandle OpenALSoundRenderer::LoadSoundRaw(uint8_t *sfxdata, int length, int
return retval;
}
SoundHandle OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int length)
SoundHandle OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int length, int def_loop_start, int def_loop_end)
{
SoundHandle retval = { NULL };
ALenum format = AL_NONE;
@ -1106,7 +1106,16 @@ SoundHandle OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int length)
uint32_t loop_start = 0, loop_end = ~0u;
zmusic_bool startass = false, endass = false;
FindLoopTags(sfxdata, length, &loop_start, &startass, &loop_end, &endass);
if (def_loop_start < 0)
{
FindLoopTags(sfxdata, length, &loop_start, &startass, &loop_end, &endass);
}
else
{
loop_start = def_loop_start;
loop_end = def_loop_end;
startass = endass = true;
}
auto decoder = CreateDecoder(sfxdata, length, true);
if (!decoder)
return retval;

View File

@ -34,7 +34,7 @@ public:
virtual void SetSfxVolume(float volume);
virtual void SetMusicVolume(float volume);
virtual SoundHandle LoadSound(uint8_t *sfxdata, int length);
virtual SoundHandle LoadSound(uint8_t *sfxdata, int length, int def_loop_start, int def_loop_end);
virtual SoundHandle LoadSoundRaw(uint8_t *sfxdata, int length, int frequency, int channels, int bits, int loopstart, int loopend = -1);
virtual void UnloadSound(SoundHandle sfx);
virtual unsigned int GetMSLength(SoundHandle sfx);

View File

@ -382,7 +382,7 @@ static float CalcPitch(int pitchmask, float defpitch, float defpitchmax)
{
if (defpitchmax > 0.0 && defpitch != defpitchmax)
{
defpitch = pr_soundpitch.GenRand_Real1() * (defpitchmax - defpitch) + defpitch;
defpitch = (float)pr_soundpitch.GenRand_Real1() * (defpitchmax - defpitch) + defpitch;
}
return defpitch;
}
@ -769,7 +769,7 @@ sfxinfo_t *SoundEngine::LoadSound(sfxinfo_t *sfx)
// If that fails, let the sound system try and figure it out.
else
{
sfx->data = GSnd->LoadSound(sfxdata.Data(), size);
sfx->data = GSnd->LoadSound(sfxdata.Data(), size, sfx->LoopStart, sfx->LoopEnd);
}
}

View File

@ -97,11 +97,13 @@ constexpr FSoundID INVALID_SOUND = FSoundID::fromInt(-1);
bool bUsed = false;
bool bSingular = false;
bool bTentative = true;
bool bExternal = false;
TArray<int> UserData;
int RawRate = 0; // Sample rate to use when bLoadRAW is true
int LoopStart = -1; // -1 means no specific loop defined
int LoopEnd = -1; // -1 means no specific loop defined
FSoundID link = NO_LINK;
constexpr static FSoundID NO_LINK = FSoundID::fromInt(-1);

View File

@ -120,7 +120,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
sc.MustGetValue(false);
GlobalKerning = sc.Number;
}
if (sc.Compare("Altfont"))
else if (sc.Compare("Altfont"))
{
sc.MustGetString();
AltFontName = sc.String;
@ -179,6 +179,11 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
sc.ScriptError("Unknown translation type %s", sc.String);
}
}
else if (sc.Compare("lowercaselatinonly"))
{
lowercaselatinonly = true;
}
}
}
}
@ -755,7 +760,7 @@ int FFont::GetCharCode(int code, bool needpic) const
// Use different substitution logic based on the fonts content:
// In a font which has both upper and lower case, prefer unaccented small characters over capital ones.
// In a pure upper-case font, do not check for lower case replacements.
if (!MixedCase)
if (!MixedCase || (lowercaselatinonly && code >= 0x380 && code < 0x500))
{
// Try converting lowercase characters to uppercase.
if (myislower(code))

View File

@ -167,6 +167,7 @@ public:
forceremap = other.forceremap;
Chars = other.Chars;
Translations = other.Translations;
lowercaselatinonly = other.lowercaselatinonly;
Lump = other.Lump;
}
@ -189,6 +190,7 @@ protected:
bool noTranslate = false;
bool MixedCase = false;
bool forceremap = false;
bool lowercaselatinonly = false;
struct CharData
{
FGameTexture *OriginalPic = nullptr;

View File

@ -924,10 +924,16 @@ void M_Init (void)
}
catch (CVMAbortException &err)
{
menuDelegate = nullptr;
err.MaybePrintMessage();
Printf(PRINT_NONOTIFY | PRINT_BOLD, "%s", err.stacktrace.GetChars());
I_FatalError("Failed to initialize menus");
}
catch (...)
{
menuDelegate = nullptr;
throw;
}
M_CreateMenus();
}

View File

@ -150,13 +150,13 @@ void DeinitMenus()
pair->Value = nullptr;
}
}
MenuDescriptors.Clear();
OptionValues.Clear();
if (menuDelegate)
{
menuDelegate->Destroy();
menuDelegate = nullptr;
}
MenuDescriptors.Clear();
OptionValues.Clear();
}
FTextureID GetMenuTexture(const char* const name)

View File

@ -275,13 +275,13 @@ bool AreCompatiblePointerTypes(PType *dest, PType *source, bool forcompare)
auto fromtype = source->toPointer();
auto totype = dest->toPointer();
// implicit pointer casts
if( fromtype->isClassPointer() && !totype->isClassPointer() ) totype->toClassPointer(fromtype); // just to make sure they're compatible pointer types
else if( !fromtype->isClassPointer() && totype->isClassPointer() ) fromtype->toClassPointer(totype); // just to make sure they're compatible pointer types
else if( fromtype->PointedType != totype->PointedType )
{
auto res = fromtype->PointedType->toClass(totype->PointedType);
if(!res || res != totype->PointedType) return false;
}
if( fromtype->isClassPointer() && !totype->isClassPointer() ) totype->toClassPointer(fromtype); // just to make sure they're compatible pointer types
else if( !fromtype->isClassPointer() && totype->isClassPointer() ) fromtype->toClassPointer(totype); // just to make sure they're compatible pointer types
else if( fromtype->PointedType != totype->PointedType )
{
auto res = fromtype->PointedType->toClass(totype->PointedType);
if(!res || res != totype->PointedType) return false;
}
// null pointers can be assigned to everything, everything can be assigned to void pointers.
if (fromtype == nullptr || totype == TypeVoidPtr) return true;
// when comparing const-ness does not matter.

View File

@ -368,7 +368,7 @@ void DStatusBarCore::SetScale()
double screenaspect = w / double(h);
double aspectscale = 1.0;
double ViewportAspect = ViewportPixelAspect();
const double ViewportAspect = 1. / ViewportPixelAspect();
if ((horz == 320 && vert == 200) || (horz == 640 && vert == 400))
{
@ -387,9 +387,9 @@ void DStatusBarCore::SetScale()
refw = h * refaspect;
}
refw *= hud_scalefactor;
refh *= hud_scalefactor * aspectscale / ViewportAspect;
refh *= hud_scalefactor * aspectscale * ViewportAspect;
int sby = vert - int(RelTop * hud_scalefactor * aspectscale / ViewportAspect);
int sby = vert - int(RelTop * hud_scalefactor * aspectscale * ViewportAspect);
// Use full pixels for destination size.
ST_X = xs_CRoundToInt((w - refw) / 2);

View File

@ -210,17 +210,12 @@ void I_ResetFrameTime()
FirstFrameStartTime += (CurrentFrameStartTime - ft);
}
double I_GetInputFrac(bool const synchronised)
double I_GetInputFrac()
{
if (!synchronised)
{
const double now = I_msTimeF();
const double result = (now - lastinputtime) * GameTicRate * (1. / 1000.);
lastinputtime = now;
return result;
}
return 1;
const double now = I_msTimeF();
const double result = (now - lastinputtime) * GameTicRate * (1. / 1000.);
lastinputtime = now;
return result;
}
void I_ResetInputTime()

View File

@ -42,7 +42,7 @@ uint64_t I_nsTime();
void I_ResetFrameTime();
// Return a decimal fraction to scale input operations at framerate
double I_GetInputFrac(bool const synchronised);
double I_GetInputFrac();
// Reset the last input check to after a lengthy operation
void I_ResetInputTime();

View File

@ -230,7 +230,7 @@ struct TVector2
// Vector length
vec_t Length() const
{
return (vec_t)g_sqrt (X*X + Y*Y);
return (vec_t)g_sqrt (LengthSquared());
}
vec_t LengthSquared() const
@ -613,7 +613,7 @@ struct TVector3
// Vector length
double Length() const
{
return g_sqrt (X*X + Y*Y + Z*Z);
return g_sqrt (LengthSquared());
}
double LengthSquared() const
@ -928,7 +928,7 @@ struct TVector4
// Vector length
double Length() const
{
return g_sqrt(X*X + Y*Y + Z*Z + W*W);
return g_sqrt(LengthSquared());
}
double LengthSquared() const
@ -1450,7 +1450,7 @@ public:
double Tan() const
{
auto bam = BAMs();
const auto bam = BAMs();
return g_sinbam(bam) / g_cosbam(bam);
}
@ -1487,7 +1487,7 @@ inline TAngle<T> deltaangle(const TAngle<T> &a1, const TAngle<T> &a2)
template<class T>
inline TAngle<T> absangle(const TAngle<T> &a1, const TAngle<T> &a2)
{
return fabs((a1 - a2).Normalized180());
return fabs(deltaangle(a2, a1));
}
template<class T>
@ -1528,7 +1528,7 @@ TAngle<T> TVector3<T>::Angle() const
template<class T>
TAngle<T> TVector3<T>::Pitch() const
{
return -VecToAngle(TVector2<T>(X, Y).Length(), Z);
return -VecToAngle(XY().Length(), Z);
}
template<class T>
@ -1694,13 +1694,10 @@ struct TRotator
};
// Create a forward vector from a rotation (ignoring roll)
template<class T>
inline TVector3<T>::TVector3 (const TRotator<T> &rot)
{
double pcos = rot.Pitch.Cos();
X = pcos * rot.Yaw.Cos();
Y = pcos * rot.Yaw.Sin();
XY() = rot.Pitch.Cos() * rot.Yaw.ToVector();
Z = rot.Pitch.Sin();
}

View File

@ -843,7 +843,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
}
// [MR] Get the input fraction, even if we don't need it this frame. Must run every frame.
const auto scaleAdjust = I_GetInputFrac(false);
const auto scaleAdjust = I_GetInputFrac();
// [MR] Process player angle changes if permitted to do so.
if (player && (player->cheats & CF_SCALEDNOLERP) && P_NoInterpolation(player, viewpoint.camera))