- Backend update from Raze.

Mainly optimizations for the sound system and texture manager.
This commit is contained in:
Christoph Oelckers 2022-12-18 16:19:18 +01:00
commit 941c0850ba
30 changed files with 323 additions and 261 deletions

View file

@ -44,8 +44,6 @@
#include "gamestate.h"
#include "i_interface.h"
bool G_Responder(event_t* ev);
int eventhead;
int eventtail;
event_t events[MAXEVENTS];
@ -86,12 +84,16 @@ void D_ProcessEvents (void)
if (ev->type == EV_DeviceChange)
UpdateJoystickMenu(I_UpdateDeviceList());
if (gamestate != GS_INTRO) // GS_INTRO blocks the UI.
// allow the game to intercept Escape before dispatching it.
if (ev->type != EV_KeyDown || ev->data1 != KEY_ESCAPE || !sysCallbacks.WantEscape || !sysCallbacks.WantEscape())
{
if (C_Responder(ev))
continue; // console ate the event
if (M_Responder(ev))
continue; // menu ate the event
if (gamestate != GS_INTRO) // GS_INTRO blocks the UI.
{
if (C_Responder(ev))
continue; // console ate the event
if (M_Responder(ev))
continue; // menu ate the event
}
}
if (sysCallbacks.G_Responder(ev) && ev->type == EV_KeyDown) keywasdown.Set(ev->data1);

View file

@ -46,6 +46,7 @@ struct SystemCallbacks
void (*LanguageChanged)(const char*);
bool (*OkForLocalization)(FTextureID, const char*);
FConfigFile* (*GetConfig)();
bool (*WantEscape)();
};
extern SystemCallbacks sysCallbacks;

View file

@ -184,6 +184,7 @@ xx(IsNull)
xx(Exists)
xx(SetInvalid)
xx(SetNull)
xx(Key)
// color channels
xx(a)

View file

@ -99,106 +99,23 @@ void VersionInfo::operator=(const char *string)
//
//==========================================================================
FScanner::FScanner()
FScanner::FScanner(TMap<FName, Symbol>* extsymbols) : symbols(extsymbols? *extsymbols : mysymbols)
{
ScriptOpen = false;
}
//==========================================================================
//
// FScanner Destructor
//
//==========================================================================
FScanner::~FScanner()
{
// Humm... Nothing to do in here.
}
//==========================================================================
//
// FScanner Copy Constructor
//
//==========================================================================
FScanner::FScanner(const FScanner &other)
{
ScriptOpen = false;
*this = other;
}
//==========================================================================
//
// FScanner OpenLumpNum Constructor
//
//==========================================================================
FScanner::FScanner(int lumpnum)
FScanner::FScanner(int lumpnum, TMap<FName, Symbol>* extsymbols) : symbols(extsymbols ? *extsymbols : mysymbols)
{
ScriptOpen = false;
OpenLumpNum(lumpnum);
}
//==========================================================================
//
// FScanner :: operator =
//
//==========================================================================
FScanner &FScanner::operator=(const FScanner &other)
{
if (this == &other)
{
return *this;
}
if (!other.ScriptOpen)
{
Close();
return *this;
}
// Copy protected members
ScriptOpen = true;
ScriptName = other.ScriptName;
ScriptBuffer = other.ScriptBuffer;
ScriptPtr = other.ScriptPtr;
ScriptEndPtr = other.ScriptEndPtr;
AlreadyGot = other.AlreadyGot;
AlreadyGotLine = other.AlreadyGotLine;
LastGotToken = other.LastGotToken;
LastGotPtr = other.LastGotPtr;
LastGotLine = other.LastGotLine;
CMode = other.CMode;
Escape = other.Escape;
StateMode = other.StateMode;
StateOptions = other.StateOptions;
// Copy public members
if (other.String == other.StringBuffer)
{
memcpy(StringBuffer, other.StringBuffer, sizeof(StringBuffer));
BigStringBuffer = "";
String = StringBuffer;
}
else
{
// Past practice means the string buffer must be writeable, which
// removes some of the benefit from using an FString to store
// the big string buffer.
BigStringBuffer = other.BigStringBuffer;
String = BigStringBuffer.LockBuffer();
}
StringLen = other.StringLen;
TokenType = other.TokenType;
Number = other.Number;
Float = other.Float;
Line = other.Line;
End = other.End;
Crossed = other.Crossed;
return *this;
}
//==========================================================================
//
// FScanner :: Open
@ -1229,7 +1146,7 @@ void FScanner::AddSymbol(const char *name, int64_t value)
{
Symbol sym;
sym.tokenType = TK_IntConst;
sym.Number = int(value);
sym.Number = value;
sym.Float = double(value);
symbols.Insert(name, sym);
}

View file

@ -54,16 +54,18 @@ public:
double Float;
};
using SymbolMap = TMap<FName, Symbol>;
TMap<FName, Symbol> symbols;
SymbolMap mysymbols;
SymbolMap& symbols;
TMap<FName, Symbol>& GetSymbols() { return symbols; }
// Methods ------------------------------------------------------
FScanner();
FScanner(const FScanner &other);
FScanner(int lumpnum);
~FScanner();
FScanner &operator=(const FScanner &other);
FScanner(TMap<FName, Symbol>* extsymbols = nullptr);
FScanner(const FScanner& other) = delete;
FScanner& operator=(const FScanner& other) = delete;
FScanner(int lumpnum, TMap<FName, Symbol>* extsymbols = nullptr);
~FScanner() = default;
void Open(const char *lumpname);
bool OpenFile(const char *filename);
@ -115,6 +117,13 @@ public:
void MustGetNumber(bool evaluate = false);
bool CheckNumber(bool evaluate = false);
bool GetNumber(int16_t& var, bool evaluate = false)
{
if (!GetNumber(evaluate)) return false;
var = Number;
return true;
}
bool GetNumber(int& var, bool evaluate = false)
{
if (!GetNumber(evaluate)) return false;
@ -155,9 +164,9 @@ public:
void MustGetFloat(bool evaluate = false);
bool CheckFloat(bool evaluate = false);
double *LookupConstant(FName name)
Symbol *LookupSymbol(FName name)
{
return constants.CheckKey(name);
return symbols.CheckKey(name);
}
// Token based variant