Merge remote-tracking branch 'origin/master' into gles2_merge

This commit is contained in:
Rachael Alexanderson 2021-08-13 08:11:58 -04:00
commit 92a3731f20
58 changed files with 412 additions and 231 deletions

View file

@ -124,7 +124,7 @@ static void Shape2D_Clear(DShape2D* self, int which)
if (which & C_Verts) self->mVertices.Clear(); if (which & C_Verts) self->mVertices.Clear();
if (which & C_Coords) self->mCoords.Clear(); if (which & C_Coords) self->mCoords.Clear();
if (which & C_Indices) self->mIndices.Clear(); if (which & C_Indices) self->mIndices.Clear();
self->needsVertexUpload = true; self->bufferInfo->needsVertexUpload = true;
} }
DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, Clear, Shape2D_Clear) DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, Clear, Shape2D_Clear)
@ -138,7 +138,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, Clear, Shape2D_Clear)
static void Shape2D_PushVertex(DShape2D* self, double x, double y) static void Shape2D_PushVertex(DShape2D* self, double x, double y)
{ {
self->mVertices.Push(DVector2(x, y)); self->mVertices.Push(DVector2(x, y));
self->needsVertexUpload = true; self->bufferInfo->needsVertexUpload = true;
} }
DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushVertex, Shape2D_PushVertex) DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushVertex, Shape2D_PushVertex)
@ -153,7 +153,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushVertex, Shape2D_PushVertex)
static void Shape2D_PushCoord(DShape2D* self, double u, double v) static void Shape2D_PushCoord(DShape2D* self, double u, double v)
{ {
self->mCoords.Push(DVector2(u, v)); self->mCoords.Push(DVector2(u, v));
self->needsVertexUpload = true; self->bufferInfo->needsVertexUpload = true;
} }
DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushCoord, Shape2D_PushCoord) DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushCoord, Shape2D_PushCoord)
@ -170,7 +170,7 @@ static void Shape2D_PushTriangle(DShape2D* self, int a, int b, int c)
self->mIndices.Push(a); self->mIndices.Push(a);
self->mIndices.Push(b); self->mIndices.Push(b);
self->mIndices.Push(c); self->mIndices.Push(c);
self->needsVertexUpload = true; self->bufferInfo->needsVertexUpload = true;
} }
DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushTriangle, Shape2D_PushTriangle) DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushTriangle, Shape2D_PushTriangle)
@ -528,13 +528,15 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms)
offset = osave; offset = osave;
} }
static TArray<RefCountedPtr<DShape2DBufferInfo>> buffersToDestroy;
void DShape2D::OnDestroy() { void DShape2D::OnDestroy() {
if (lastParms) delete lastParms; if (lastParms) delete lastParms;
lastParms = nullptr; lastParms = nullptr;
mIndices.Reset(); mIndices.Reset();
mVertices.Reset(); mVertices.Reset();
mCoords.Reset(); mCoords.Reset();
buffers.Reset(); buffersToDestroy.Push(std::move(bufferInfo));
} }
//========================================================================== //==========================================================================
@ -567,11 +569,11 @@ void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms)
shape->lastParms = new DrawParms(parms); shape->lastParms = new DrawParms(parms);
} }
else if (shape->lastParms->vertexColorChange(parms)) { else if (shape->lastParms->vertexColorChange(parms)) {
shape->needsVertexUpload = true; shape->bufferInfo->needsVertexUpload = true;
if (!shape->uploadedOnce) { if (!shape->bufferInfo->uploadedOnce) {
shape->bufIndex = -1; shape->bufferInfo->bufIndex = -1;
shape->buffers.Clear(); shape->bufferInfo->buffers.Clear();
shape->lastCommand = -1; shape->bufferInfo->lastCommand = -1;
} }
delete shape->lastParms; delete shape->lastParms;
shape->lastParms = new DrawParms(parms); shape->lastParms = new DrawParms(parms);
@ -583,7 +585,7 @@ void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms)
auto osave = offset; auto osave = offset;
if (parms.nooffset) offset = { 0,0 }; if (parms.nooffset) offset = { 0,0 };
if (shape->needsVertexUpload) if (shape->bufferInfo->needsVertexUpload)
{ {
shape->minx = 16383; shape->minx = 16383;
shape->miny = 16383; shape->miny = 16383;
@ -622,15 +624,15 @@ void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms)
dg.transform = shape->transform; dg.transform = shape->transform;
dg.transform.Cells[0][2] += offset.X; dg.transform.Cells[0][2] += offset.X;
dg.transform.Cells[1][2] += offset.Y; dg.transform.Cells[1][2] += offset.Y;
dg.shape2D = shape; dg.shape2DBufInfo = shape->bufferInfo;
dg.shape2DIndexCount = shape->mIndices.Size(); dg.shape2DIndexCount = shape->mIndices.Size();
if (shape->needsVertexUpload) if (shape->bufferInfo->needsVertexUpload)
{ {
shape->bufIndex += 1; shape->bufferInfo->bufIndex += 1;
shape->buffers.Reserve(1); shape->bufferInfo->buffers.Reserve(1);
auto buf = &shape->buffers[shape->bufIndex]; auto buf = &shape->bufferInfo->buffers[shape->bufferInfo->bufIndex];
auto verts = TArray<TwoDVertex>(dg.mVertCount, true); auto verts = TArray<TwoDVertex>(dg.mVertCount, true);
for ( int i=0; i<dg.mVertCount; i++ ) for ( int i=0; i<dg.mVertCount; i++ )
@ -649,12 +651,12 @@ void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms)
} }
buf->UploadData(&verts[0], dg.mVertCount, &shape->mIndices[0], shape->mIndices.Size()); buf->UploadData(&verts[0], dg.mVertCount, &shape->mIndices[0], shape->mIndices.Size());
shape->needsVertexUpload = false; shape->bufferInfo->needsVertexUpload = false;
shape->uploadedOnce = true; shape->bufferInfo->uploadedOnce = true;
} }
dg.shape2DBufIndex = shape->bufIndex; dg.shape2DBufIndex = shape->bufferInfo->bufIndex;
shape->lastCommand += 1; shape->bufferInfo->lastCommand += 1;
dg.shape2DCommandCounter = shape->lastCommand; dg.shape2DCommandCounter = shape->bufferInfo->lastCommand;
AddCommand(&dg); AddCommand(&dg);
offset = osave; offset = osave;
} }
@ -1082,6 +1084,17 @@ void F2DDrawer::Clear()
screenFade = 1.f; screenFade = 1.f;
} }
//==========================================================================
//
//
//
//==========================================================================
void F2DDrawer::OnFrameDone()
{
buffersToDestroy.Clear();
}
F2DVertexBuffer::F2DVertexBuffer() F2DVertexBuffer::F2DVertexBuffer()
{ {
mVertexBuffer = screen->CreateVertexBuffer(); mVertexBuffer = screen->CreateVertexBuffer();

View file

@ -7,6 +7,7 @@
#include "textures.h" #include "textures.h"
#include "renderstyle.h" #include "renderstyle.h"
#include "dobject.h" #include "dobject.h"
#include "refcounted.h"
struct DrawParms; struct DrawParms;
struct FColormap; struct FColormap;
@ -49,6 +50,7 @@ struct F2DPolygons
}; };
class DShape2D; class DShape2D;
struct DShape2DBufferInfo;
class F2DDrawer class F2DDrawer
{ {
@ -123,7 +125,7 @@ public:
bool useTransform; bool useTransform;
DMatrix3x3 transform; DMatrix3x3 transform;
DShape2D* shape2D; RefCountedPtr<DShape2DBufferInfo> shape2DBufInfo;
int shape2DBufIndex; int shape2DBufIndex;
int shape2DIndexCount; int shape2DIndexCount;
int shape2DCommandCounter; int shape2DCommandCounter;
@ -136,7 +138,7 @@ public:
// If these fields match, two draw commands can be batched. // If these fields match, two draw commands can be batched.
bool isCompatible(const RenderCommand &other) const bool isCompatible(const RenderCommand &other) const
{ {
if (shape2D != nullptr || other.shape2D != nullptr) return false; if (shape2DBufInfo != nullptr || other.shape2DBufInfo != nullptr) return false;
return mTexture == other.mTexture && return mTexture == other.mTexture &&
mType == other.mType && mType == other.mType &&
mTranslationId == other.mTranslationId && mTranslationId == other.mTranslationId &&
@ -214,6 +216,7 @@ public:
void Begin(int w, int h) { isIn2D = true; Width = w; Height = h; } void Begin(int w, int h) { isIn2D = true; Width = w; Height = h; }
void End() { isIn2D = false; } void End() { isIn2D = false; }
bool HasBegun2D() { return isIn2D; } bool HasBegun2D() { return isIn2D; }
void OnFrameDone();
void ClearClipRect() { clipleft = cliptop = 0; clipwidth = clipheight = -1; } void ClearClipRect() { clipleft = cliptop = 0; clipwidth = clipheight = -1; }
void SetClipRect(int x, int y, int w, int h); void SetClipRect(int x, int y, int w, int h);
@ -240,12 +243,22 @@ public:
bool mIsFirstPass = true; bool mIsFirstPass = true;
}; };
struct DShape2DBufferInfo : NoVirtualRefCountedBase
{
TArray<F2DVertexBuffer> buffers;
bool needsVertexUpload = true;
int bufIndex = -1;
int lastCommand = -1;
bool uploadedOnce = false;
};
class DShape2D : public DObject class DShape2D : public DObject
{ {
DECLARE_CLASS(DShape2D,DObject) DECLARE_CLASS(DShape2D,DObject)
public: public:
DShape2D() DShape2D()
: bufferInfo(new DShape2DBufferInfo)
{ {
transform.Identity(); transform.Identity();
} }
@ -261,12 +274,8 @@ public:
DMatrix3x3 transform; DMatrix3x3 transform;
TArray<F2DVertexBuffer> buffers; RefCountedPtr<DShape2DBufferInfo> bufferInfo;
bool needsVertexUpload = true;
int bufIndex = -1;
int lastCommand = -1;
bool uploadedOnce = false;
DrawParms* lastParms; DrawParms* lastParms;
void OnDestroy() override; void OnDestroy() override;

View file

@ -291,7 +291,7 @@ void FCommandBuffer::AddString(FString clip)
if (clip.IsNotEmpty()) if (clip.IsNotEmpty())
{ {
// Only paste the first line. // Only paste the first line.
long brk = clip.IndexOfAny("\r\n\b"); auto brk = clip.IndexOfAny("\r\n\b");
std::u32string build; std::u32string build;
if (brk >= 0) if (brk >= 0)
{ {

View file

@ -533,7 +533,7 @@ FString BuildString (int argc, FString *argv)
else if (strchr(argv[arg], '"')) else if (strchr(argv[arg], '"'))
{ // If it contains one or more quotes, we need to escape them. { // If it contains one or more quotes, we need to escape them.
buf << '"'; buf << '"';
long substr_start = 0, quotepos; ptrdiff_t substr_start = 0, quotepos;
while ((quotepos = argv[arg].IndexOf('"', substr_start)) >= 0) while ((quotepos = argv[arg].IndexOf('"', substr_start)) >= 0)
{ {
if (substr_start < quotepos) if (substr_start < quotepos)

View file

@ -435,7 +435,7 @@ void FStringTable::InsertString(int lumpnum, int langid, FName label, const FStr
{ {
const char *strlangid = (const char *)&langid; const char *strlangid = (const char *)&langid;
TableElement te = { fileSystem.GetFileContainer(lumpnum), { string, string, string, string } }; TableElement te = { fileSystem.GetFileContainer(lumpnum), { string, string, string, string } };
long index; ptrdiff_t index;
while ((index = te.strings[0].IndexOf("@[")) >= 0) while ((index = te.strings[0].IndexOf("@[")) >= 0)
{ {
auto endindex = te.strings[0].IndexOf(']', index); auto endindex = te.strings[0].IndexOf(']', index);

View file

@ -234,6 +234,8 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter)
} }
name.ToLower(); name.ToLower();
if (name.IndexOf("filter/") == 0)
continue; // 'filter' is a reserved name of the file system.
if (name.IndexOf("__macosx") == 0) if (name.IndexOf("__macosx") == 0)
continue; // skip Apple garbage. At this stage only the root folder matters. continue; // skip Apple garbage. At this stage only the root folder matters.
if (!foundprefix) if (!foundprefix)

View file

@ -113,7 +113,20 @@ struct FileSystem::LumpRecord
if (Namespace == ns_hidden) shortName.qword = 0; if (Namespace == ns_hidden) shortName.qword = 0;
else else
{ {
long slash = longName.LastIndexOf('/'); ptrdiff_t encodedResID = longName.LastIndexOf(".{");
if (resourceId == -1 && encodedResID >= 0)
{
const char* p = longName.GetChars() + encodedResID;
char* q;
int id = (int)strtoull(p+2, &q, 10); // only decimal numbers allowed here.
if (q[0] == '}' && (q[1] == '.' || q[1] == 0))
{
FString toDelete(p, q - p + 1);
longName.Substitute(toDelete, "");
resourceId = id;
}
}
ptrdiff_t slash = longName.LastIndexOf('/');
FString base = (slash >= 0) ? longName.Mid(slash + 1) : longName; FString base = (slash >= 0) ? longName.Mid(slash + 1) : longName;
auto dot = base.LastIndexOf('.'); auto dot = base.LastIndexOf('.');
if (dot >= 0) base.Truncate(dot); if (dot >= 0) base.Truncate(dot);
@ -1533,7 +1546,7 @@ bool FileSystem::CreatePathlessCopy(const char *name, int id, int /*flags*/)
if (lump < 0) return false; // Does not exist. if (lump < 0) return false; // Does not exist.
auto oldlump = FileInfo[lump]; auto oldlump = FileInfo[lump];
int slash = oldlump.longName.LastIndexOf('/'); ptrdiff_t slash = oldlump.longName.LastIndexOf('/');
if (slash == -1) if (slash == -1)
{ {

View file

@ -348,8 +348,8 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize, LumpFilterI
uint32_t max = NumLumps; uint32_t max = NumLumps;
max -= FilterLumpsByGameType(filter, lumps, lumpsize, max); max -= FilterLumpsByGameType(filter, lumps, lumpsize, max);
long len; ptrdiff_t len;
int lastpos = -1; ptrdiff_t lastpos = -1;
FString file; FString file;
FString LumpFilter = filter->dotFilter; FString LumpFilter = filter->dotFilter;
while ((len = LumpFilter.IndexOf('.', lastpos+1)) > 0) while ((len = LumpFilter.IndexOf('.', lastpos+1)) > 0)

View file

@ -437,7 +437,7 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height
Chars[i].OriginalPic->CopySize(*lump, true); Chars[i].OriginalPic->CopySize(*lump, true);
if (Chars[i].OriginalPic != *lump) TexMan.AddGameTexture(Chars[i].OriginalPic); if (Chars[i].OriginalPic != *lump) TexMan.AddGameTexture(Chars[i].OriginalPic);
} }
Chars[i].XMove = width; Chars[i].XMove = int(width / Scale.X);
} }
if (map1252) if (map1252)

View file

@ -407,6 +407,7 @@ void FSingleLumpFont::LoadBMF(int lump, const uint8_t *data)
count = LastChar - FirstChar + 1; count = LastChar - FirstChar + 1;
Chars.Resize(count); Chars.Resize(count);
// BMF palettes are only six bits per component. Fix that. // BMF palettes are only six bits per component. Fix that.
Palette[0] = 0;
for (i = 0; i < ActiveColors; ++i) for (i = 0; i < ActiveColors; ++i)
{ {
int r = (data[17 + i * 3] << 2) | (data[17 + i * 3] >> 4); int r = (data[17 + i * 3] << 2) | (data[17 + i * 3] >> 4);

View file

@ -88,7 +88,7 @@ TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str
{ {
if (*string == '[') if (*string == '[')
{ {
const uint8_t *start = string; const uint8_t* start = string;
while (*string != ']' && *string != '\0') while (*string != ']' && *string != '\0')
{ {
string++; string++;
@ -97,11 +97,6 @@ TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str
{ {
string++; string++;
} }
lastcolor = FString((const char *)start, string - start);
}
else
{
lastcolor = *string++;
} }
} }
continue; continue;
@ -130,6 +125,33 @@ TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str
} }
auto index = Lines.Reserve(1); auto index = Lines.Reserve(1);
for (const uint8_t* pos = start; pos < space; pos++)
{
if (*pos == TEXTCOLOR_ESCAPE)
{
pos++;
if (*pos)
{
if (*pos == '[')
{
const uint8_t* cstart = pos;
while (*pos != ']' && *pos != '\0')
{
pos++;
}
if (*pos != '\0')
{
pos++;
}
lastcolor = FString((const char*)cstart, pos - start);
}
else
{
lastcolor = *pos++;
}
}
}
}
breakit (&Lines[index], font, start, space, linecolor); breakit (&Lines[index], font, start, space, linecolor);
if (c == '\n' && !preservecolor) if (c == '\n' && !preservecolor)
{ {

View file

@ -90,8 +90,8 @@ static int FindGFXFile(FString & fn)
if (lump != -1) return lump; if (lump != -1) return lump;
int best = -1; int best = -1;
int dot = fn.LastIndexOf('.'); auto dot = fn.LastIndexOf('.');
int slash = fn.LastIndexOf('/'); auto slash = fn.LastIndexOf('/');
if (dot > slash) fn.Truncate(dot); if (dot > slash) fn.Truncate(dot);
static const char * extensions[] = { ".png", ".jpg", ".tga", ".pcx", nullptr }; static const char * extensions[] = { ".png", ".jpg", ".tga", ".pcx", nullptr };

View file

@ -44,8 +44,8 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length
{ {
// Ensure usemtl statements remain intact // Ensure usemtl statements remain intact
TArray<FString> mtlUsages; TArray<FString> mtlUsages;
TArray<long> mtlUsageIdxs; TArray<ptrdiff_t> mtlUsageIdxs;
long bpos = 0, nlpos = 0, slashpos = 0; ptrdiff_t bpos = 0, nlpos = 0, slashpos = 0;
while (1) while (1)
{ {
bpos = objBuf.IndexOf("\nusemtl", bpos); bpos = objBuf.IndexOf("\nusemtl", bpos);
@ -58,7 +58,7 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length
} }
if (nlpos == -1) if (nlpos == -1)
{ {
nlpos = (long)objBuf.Len(); nlpos = objBuf.Len();
} }
FString lineStr(objBuf.GetChars() + bpos, nlpos - bpos); FString lineStr(objBuf.GetChars() + bpos, nlpos - bpos);
mtlUsages.Push(lineStr); mtlUsages.Push(lineStr);
@ -76,7 +76,7 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length
nlpos = objBuf.IndexOf('\n', bpos); nlpos = objBuf.IndexOf('\n', bpos);
if (nlpos == -1) if (nlpos == -1)
{ {
nlpos = (long)objBuf.Len(); nlpos = objBuf.Len();
} }
memcpy(wObjBuf + bpos, mtlUsages[i].GetChars(), nlpos - bpos); memcpy(wObjBuf + bpos, mtlUsages[i].GetChars(), nlpos - bpos);
} }

View file

@ -131,7 +131,7 @@ static bool ReadSystemVersionFromPlist(NSOperatingSystemVersion& version)
if (const char *patchVersionString = strstr(minorVersionString, ".")) if (const char *patchVersionString = strstr(minorVersionString, "."))
{ {
patchVersionString++; patchVersionString++;
plistVersion.patchVersion = atoi(minorVersionString); plistVersion.patchVersion = atoi(patchVersionString);
} }
} }
} }

View file

@ -204,7 +204,7 @@ void I_PrintStr(const char *cp)
{ // gray { // gray
if (v < 0.33) attrib = 0x8; if (v < 0.33) attrib = 0x8;
else if (v < 0.90) attrib = 0x7; else if (v < 0.90) attrib = 0x7;
else attrib = 0x15; else attrib = 0xF;
} }
printData.AppendFormat("\033[%um",((attrib & 0x8) ? 90 : 30) + (attrib & 0x7)); printData.AppendFormat("\033[%um",((attrib & 0x8) ? 90 : 30) + (attrib & 0x7));

View file

@ -545,6 +545,20 @@ LRESULT CALLBACK LConProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
// //
//========================================================================== //==========================================================================
bool restartrequest;
void CheckForRestart()
{
if (restartrequest)
{
HMODULE hModule = GetModuleHandleW(NULL);
WCHAR path[MAX_PATH];
GetModuleFileNameW(hModule, path, MAX_PATH);
ShellExecuteW(NULL, L"open", path, GetCommandLineW(), NULL, SW_SHOWNORMAL);
}
restartrequest = false;
}
INT_PTR CALLBACK ErrorPaneProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) INT_PTR CALLBACK ErrorPaneProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
switch (msg) switch (msg)
@ -559,11 +573,7 @@ INT_PTR CALLBACK ErrorPaneProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara
{ {
if (LOWORD(wParam) == IDC_BUTTON1) // we pressed the restart button, so run GZDoom again if (LOWORD(wParam) == IDC_BUTTON1) // we pressed the restart button, so run GZDoom again
{ {
HMODULE hModule = GetModuleHandleW(NULL); restartrequest = true;
WCHAR path[MAX_PATH];
GetModuleFileNameW(hModule, path, MAX_PATH);
ShellExecuteW(NULL, L"open", path, GetCommandLineW(), NULL, SW_SHOWNORMAL);
} }
PostQuitMessage (0); PostQuitMessage (0);
return TRUE; return TRUE;
@ -969,6 +979,8 @@ int DoMain (HINSTANCE hInstance)
atexit (UnCOM); atexit (UnCOM);
int ret = GameMain (); int ret = GameMain ();
CheckForRestart();
DestroyCustomCursor(); DestroyCustomCursor();
if (ret == 1337) // special exit code for 'norun'. if (ret == 1337) // special exit code for 'norun'.
{ {

View file

@ -52,15 +52,15 @@ static bool IsGlslWhitespace(char c)
} }
} }
static FString NextGlslToken(const char *chars, long len, long &pos) static FString NextGlslToken(const char *chars, ptrdiff_t len, ptrdiff_t &pos)
{ {
// Eat whitespace // Eat whitespace
long tokenStart = pos; ptrdiff_t tokenStart = pos;
while (tokenStart != len && IsGlslWhitespace(chars[tokenStart])) while (tokenStart != len && IsGlslWhitespace(chars[tokenStart]))
tokenStart++; tokenStart++;
// Find token end // Find token end
long tokenEnd = tokenStart; ptrdiff_t tokenEnd = tokenStart;
while (tokenEnd != len && !IsGlslWhitespace(chars[tokenEnd]) && chars[tokenEnd] != ';') while (tokenEnd != len && !IsGlslWhitespace(chars[tokenEnd]) && chars[tokenEnd] != ';')
tokenEnd++; tokenEnd++;
@ -82,13 +82,13 @@ FString RemoveLegacyUserUniforms(FString code)
// The following code searches for legacy uniform declarations in the shader itself and replaces them with whitespace. // The following code searches for legacy uniform declarations in the shader itself and replaces them with whitespace.
long len = (long)code.Len(); ptrdiff_t len = code.Len();
char *chars = code.LockBuffer(); char *chars = code.LockBuffer();
long startIndex = 0; ptrdiff_t startIndex = 0;
while (true) while (true)
{ {
long matchIndex = code.IndexOf("uniform", startIndex); ptrdiff_t matchIndex = code.IndexOf("uniform", startIndex);
if (matchIndex == -1) if (matchIndex == -1)
break; break;
@ -98,7 +98,7 @@ FString RemoveLegacyUserUniforms(FString code)
bool isKeywordEnd = matchIndex + 7 == len || IsGlslWhitespace(chars[matchIndex + 7]); bool isKeywordEnd = matchIndex + 7 == len || IsGlslWhitespace(chars[matchIndex + 7]);
if (isKeywordStart && isKeywordEnd) if (isKeywordStart && isKeywordEnd)
{ {
long pos = matchIndex + 7; ptrdiff_t pos = matchIndex + 7;
FString type = NextGlslToken(chars, len, pos); FString type = NextGlslToken(chars, len, pos);
FString identifier = NextGlslToken(chars, len, pos); FString identifier = NextGlslToken(chars, len, pos);
@ -107,10 +107,10 @@ FString RemoveLegacyUserUniforms(FString code)
if (isLegacyUniformName) if (isLegacyUniformName)
{ {
long statementEndIndex = code.IndexOf(';', matchIndex + 7); ptrdiff_t statementEndIndex = code.IndexOf(';', matchIndex + 7);
if (statementEndIndex == -1) if (statementEndIndex == -1)
statementEndIndex = len; statementEndIndex = len;
for (long i = matchIndex; i <= statementEndIndex; i++) for (ptrdiff_t i = matchIndex; i <= statementEndIndex; i++)
{ {
if (!IsGlslWhitespace(chars[i])) if (!IsGlslWhitespace(chars[i]))
chars[i] = ' '; chars[i] = ' ';
@ -127,7 +127,7 @@ FString RemoveLegacyUserUniforms(FString code)
// Modern GLSL only allows use of 'texture'. // Modern GLSL only allows use of 'texture'.
while (true) while (true)
{ {
long matchIndex = code.IndexOf("texture2d", startIndex); ptrdiff_t matchIndex = code.IndexOf("texture2d", startIndex);
if (matchIndex == -1) if (matchIndex == -1)
break; break;
@ -148,14 +148,14 @@ FString RemoveLegacyUserUniforms(FString code)
FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &samplerstobind) FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &samplerstobind)
{ {
long len = (long)code.Len(); ptrdiff_t len = code.Len();
char *chars = code.LockBuffer(); char *chars = code.LockBuffer();
long startIndex = 0; ptrdiff_t startIndex = 0;
long startpos, endpos; ptrdiff_t startpos, endpos;
while (true) while (true)
{ {
long matchIndex = code.IndexOf("layout(binding", startIndex); ptrdiff_t matchIndex = code.IndexOf("layout(binding", startIndex);
if (matchIndex == -1) if (matchIndex == -1)
break; break;
@ -165,7 +165,7 @@ FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &sam
bool isKeywordEnd = matchIndex + 14 == len || IsGlslWhitespace(chars[matchIndex + 14]) || chars[matchIndex + 14] == '='; bool isKeywordEnd = matchIndex + 14 == len || IsGlslWhitespace(chars[matchIndex + 14]) || chars[matchIndex + 14] == '=';
if (isKeywordStart && isKeywordEnd) if (isKeywordStart && isKeywordEnd)
{ {
long pos = matchIndex + 14; ptrdiff_t pos = matchIndex + 14;
startpos = matchIndex; startpos = matchIndex;
while (IsGlslWhitespace(chars[pos])) pos++; while (IsGlslWhitespace(chars[pos])) pos++;
if (chars[pos] == '=') if (chars[pos] == '=')
@ -175,7 +175,7 @@ FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &sam
auto val = strtol(&chars[pos], &p, 0); auto val = strtol(&chars[pos], &p, 0);
if (p != &chars[pos]) if (p != &chars[pos])
{ {
pos = long(p - chars); pos = (p - chars);
while (IsGlslWhitespace(chars[pos])) pos++; while (IsGlslWhitespace(chars[pos])) pos++;
if (chars[pos] == ')') if (chars[pos] == ')')
{ {
@ -216,17 +216,17 @@ FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &sam
FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword) FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword)
{ {
long len = (long)code.Len(); ptrdiff_t len = code.Len();
char *chars = code.LockBuffer(); char *chars = code.LockBuffer();
long startIndex = 0; ptrdiff_t startIndex = 0;
while (true) while (true)
{ {
long matchIndex = code.IndexOf("layout(location", startIndex); ptrdiff_t matchIndex = code.IndexOf("layout(location", startIndex);
if (matchIndex == -1) if (matchIndex == -1)
break; break;
long endIndex = matchIndex; ptrdiff_t endIndex = matchIndex;
// Find end of layout declaration // Find end of layout declaration
while (chars[endIndex] != ')' && chars[endIndex] != 0) while (chars[endIndex] != ')' && chars[endIndex] != 0)
@ -255,7 +255,7 @@ FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword)
if (keywordFound && IsGlslWhitespace(chars[endIndex + i])) if (keywordFound && IsGlslWhitespace(chars[endIndex + i]))
{ {
// yes - replace declaration with spaces // yes - replace declaration with spaces
for (long i = matchIndex; i < endIndex; i++) for (auto i = matchIndex; i < endIndex; i++)
chars[i] = ' '; chars[i] = ' ';
} }

View file

@ -98,7 +98,8 @@ bool IShadowMap::PerformUpdate()
LightsProcessed = 0; LightsProcessed = 0;
LightsShadowmapped = 0; LightsShadowmapped = 0;
if (gl_light_shadowmap && (screen->hwcaps & RFL_SHADER_STORAGE_BUFFER) && screen->mPipelineType == 0 && CollectLights != nullptr) // CollectLights will be null if the calling code decides that shadowmaps are not needed.
if (CollectLights != nullptr)
{ {
UpdateCycles.Clock(); UpdateCycles.Clock();
UploadAABBTree(); UploadAABBTree();

View file

@ -57,6 +57,11 @@ public:
mLights[index + 3] = r; mLights[index + 3] = r;
} }
bool Enabled() const
{
return mAABBTree != nullptr;
}
protected: protected:
// Upload the AABB-tree to the GPU // Upload the AABB-tree to the GPU
void UploadAABBTree(); void UploadAABBTree();

View file

@ -33,10 +33,10 @@
#include "i_interface.h" #include "i_interface.h"
// Set up 3D-specific console variables: // Set up 3D-specific console variables:
CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG) CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
// switch left and right eye views // switch left and right eye views
CVAR(Bool, vr_swap_eyes, false, CVAR_GLOBALCONFIG) CVAR(Bool, vr_swap_eyes, false, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
// intraocular distance in meters // intraocular distance in meters
CVAR(Float, vr_ipd, 0.062f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // METERS CVAR(Float, vr_ipd, 0.062f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // METERS

View file

@ -178,22 +178,22 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
state.EnableTexture(false); state.EnableTexture(false);
} }
if (cmd.shape2D != nullptr) if (cmd.shape2DBufInfo != nullptr)
{ {
state.SetVertexBuffer(&cmd.shape2D->buffers[cmd.shape2DBufIndex]); state.SetVertexBuffer(&cmd.shape2DBufInfo->buffers[cmd.shape2DBufIndex]);
state.DrawIndexed(DT_Triangles, 0, cmd.shape2DIndexCount); state.DrawIndexed(DT_Triangles, 0, cmd.shape2DIndexCount);
state.SetVertexBuffer(&vb); state.SetVertexBuffer(&vb);
if (cmd.shape2DCommandCounter == cmd.shape2D->lastCommand) if (cmd.shape2DCommandCounter == cmd.shape2DBufInfo->lastCommand)
{ {
cmd.shape2D->lastCommand = -1; cmd.shape2DBufInfo->lastCommand = -1;
if (cmd.shape2D->bufIndex > 0) if (cmd.shape2DBufInfo->bufIndex > 0)
{ {
cmd.shape2D->needsVertexUpload = true; cmd.shape2DBufInfo->needsVertexUpload = true;
cmd.shape2D->buffers.Clear(); cmd.shape2DBufInfo->buffers.Clear();
cmd.shape2D->bufIndex = -1; cmd.shape2DBufInfo->bufIndex = -1;
} }
} }
cmd.shape2D->uploadedOnce = false; cmd.shape2DBufInfo->uploadedOnce = false;
} }
else else
{ {

View file

@ -9823,6 +9823,8 @@ FxExpression *FxIfStatement::Resolve(FCompileContext &ctx)
{ {
CHECKRESOLVED(); CHECKRESOLVED();
SAFE_RESOLVE(Condition, ctx);
if (WhenTrue == nullptr && WhenFalse == nullptr) if (WhenTrue == nullptr && WhenFalse == nullptr)
{ // We don't do anything either way, so disappear { // We don't do anything either way, so disappear
delete this; delete this;
@ -9830,8 +9832,6 @@ FxExpression *FxIfStatement::Resolve(FCompileContext &ctx)
return new FxNop(ScriptPosition); return new FxNop(ScriptPosition);
} }
SAFE_RESOLVE(Condition, ctx);
if (Condition->ValueType != TypeBool) if (Condition->ValueType != TypeBool)
{ {
Condition = new FxBoolCast(Condition, false); Condition = new FxBoolCast(Condition, false);

View file

@ -419,7 +419,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, Filter, StringFilter)
static int StringIndexOf(FString *self, const FString &substr, int startIndex) static int StringIndexOf(FString *self, const FString &substr, int startIndex)
{ {
return self->IndexOf(substr, startIndex); return (int)self->IndexOf(substr, startIndex);
} }
DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, IndexOf, StringIndexOf) DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, IndexOf, StringIndexOf)
@ -427,12 +427,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, IndexOf, StringIndexOf)
PARAM_SELF_STRUCT_PROLOGUE(FString); PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(substr); PARAM_STRING(substr);
PARAM_INT(startIndex); PARAM_INT(startIndex);
ACTION_RETURN_INT(self->IndexOf(substr, startIndex)); ACTION_RETURN_INT(StringIndexOf(self, substr, startIndex));
} }
static int StringLastIndexOf(FString *self, const FString &substr, int endIndex) static int StringLastIndexOf(FString *self, const FString &substr, int endIndex)
{ {
return self->LastIndexOfBroken(substr, endIndex); return (int)self->LastIndexOfBroken(substr, endIndex);
} }
DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, LastIndexOf, StringLastIndexOf) DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, LastIndexOf, StringLastIndexOf)
@ -440,12 +440,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, LastIndexOf, StringLastIndexOf)
PARAM_SELF_STRUCT_PROLOGUE(FString); PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(substr); PARAM_STRING(substr);
PARAM_INT(endIndex); PARAM_INT(endIndex);
ACTION_RETURN_INT(self->LastIndexOfBroken(substr, endIndex)); ACTION_RETURN_INT(StringLastIndexOf(self, substr, endIndex));
} }
static int StringRightIndexOf(FString *self, const FString &substr, int endIndex) static int StringRightIndexOf(FString *self, const FString &substr, int endIndex)
{ {
return self->LastIndexOf(substr, endIndex); return (int)self->LastIndexOf(substr, endIndex);
} }
DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, RightIndexOf, StringRightIndexOf) DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, RightIndexOf, StringRightIndexOf)
@ -453,7 +453,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, RightIndexOf, StringRightIndexOf)
PARAM_SELF_STRUCT_PROLOGUE(FString); PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(substr); PARAM_STRING(substr);
PARAM_INT(endIndex); PARAM_INT(endIndex);
ACTION_RETURN_INT(self->LastIndexOf(substr, endIndex)); ACTION_RETURN_INT(StringRightIndexOf(self, substr, endIndex));
} }
static void StringToUpper(FString *self) static void StringToUpper(FString *self)

View file

@ -2,19 +2,28 @@
// Simple lightweight reference counting pointer alternative for std::shared_ptr which stores the reference counter in the handled object itself. // Simple lightweight reference counting pointer alternative for std::shared_ptr which stores the reference counter in the handled object itself.
// Base class for handled objects // Base classes for handled objects
class NoVirtualRefCountedBase
{
public:
void IncRef() { refCount++; }
void DecRef() { if (--refCount <= 0) delete this; }
private:
int refCount = 0;
};
class RefCountedBase class RefCountedBase
{ {
public: public:
void IncRef() { refCount++; } void IncRef() { refCount++; }
void DecRef() { if (--refCount <= 0) delete this; } void DecRef() { if (--refCount <= 0) delete this; }
private: private:
int refCount = 0; int refCount = 0;
protected: protected:
virtual ~RefCountedBase() = default; virtual ~RefCountedBase() = default;
}; };
// The actual pointer object // The actual pointer object
template<class T> template<class T>
class RefCountedPtr class RefCountedPtr
{ {
@ -32,9 +41,19 @@ public:
if (ptr) ptr->IncRef(); if (ptr) ptr->IncRef();
} }
RefCountedPtr(const RefCountedPtr& r) : ptr(r.ptr)
{
if (ptr) ptr->IncRef();
}
RefCountedPtr(RefCountedPtr&& r) : ptr(r.ptr)
{
r.ptr = nullptr;
}
RefCountedPtr & operator=(const RefCountedPtr& r) RefCountedPtr & operator=(const RefCountedPtr& r)
{ {
if (ptr != r.ptr) if (this != &r)
{ {
if (ptr) ptr->DecRef(); if (ptr) ptr->DecRef();
ptr = r.ptr; ptr = r.ptr;
@ -54,11 +73,14 @@ public:
return *this; return *this;
} }
RefCountedPtr & operator=(const RefCountedPtr&& r) RefCountedPtr & operator=(RefCountedPtr&& r)
{ {
if (ptr) ptr->DecRef(); if (this != &r)
ptr = r.ptr; {
r.ptr = nullptr; if (ptr) ptr->DecRef();
ptr = r.ptr;
r.ptr = nullptr;
}
return *this; return *this;
} }

View file

@ -95,7 +95,7 @@ bool FPlayList::ChangeList (const char *path)
} }
// Check for relative paths. // Check for relative paths.
long slashpos = song.IndexOf('/'); auto slashpos = song.IndexOf('/');
if (slashpos == 0) if (slashpos == 0)
{ {

View file

@ -422,7 +422,7 @@ void FString::Remove(size_t index, size_t remlen)
{ {
if (index + remlen >= Len()) if (index + remlen >= Len())
{ {
Truncate((long)index); Truncate(index);
} }
else else
{ {
@ -500,12 +500,12 @@ void FString::DeleteLastCharacter()
} }
long FString::IndexOf (const FString &substr, long startIndex) const ptrdiff_t FString::IndexOf (const FString &substr, ptrdiff_t startIndex) const
{ {
return IndexOf (substr.Chars, startIndex); return IndexOf (substr.Chars, startIndex);
} }
long FString::IndexOf (const char *substr, long startIndex) const ptrdiff_t FString::IndexOf (const char *substr, ptrdiff_t startIndex) const
{ {
if (startIndex > 0 && Len() <= (size_t)startIndex) if (startIndex > 0 && Len() <= (size_t)startIndex)
{ {
@ -516,10 +516,10 @@ long FString::IndexOf (const char *substr, long startIndex) const
{ {
return -1; return -1;
} }
return long(str - Chars); return str - Chars;
} }
long FString::IndexOf (char subchar, long startIndex) const ptrdiff_t FString::IndexOf (char subchar, ptrdiff_t startIndex) const
{ {
if (startIndex > 0 && Len() <= (size_t)startIndex) if (startIndex > 0 && Len() <= (size_t)startIndex)
{ {
@ -530,15 +530,15 @@ long FString::IndexOf (char subchar, long startIndex) const
{ {
return -1; return -1;
} }
return long(str - Chars); return str - Chars;
} }
long FString::IndexOfAny (const FString &charset, long startIndex) const ptrdiff_t FString::IndexOfAny (const FString &charset, ptrdiff_t startIndex) const
{ {
return IndexOfAny (charset.Chars, startIndex); return IndexOfAny (charset.Chars, startIndex);
} }
long FString::IndexOfAny (const char *charset, long startIndex) const ptrdiff_t FString::IndexOfAny (const char *charset, ptrdiff_t startIndex) const
{ {
if (startIndex > 0 && Len() <= (size_t)startIndex) if (startIndex > 0 && Len() <= (size_t)startIndex)
{ {
@ -549,19 +549,19 @@ long FString::IndexOfAny (const char *charset, long startIndex) const
{ {
return -1; return -1;
} }
return long(brk - Chars); return brk - Chars;
} }
long FString::LastIndexOf (char subchar) const ptrdiff_t FString::LastIndexOf (char subchar) const
{ {
return LastIndexOf (subchar, long(Len())); return LastIndexOf (subchar, Len());
} }
long FString::LastIndexOf (char subchar, long endIndex) const ptrdiff_t FString::LastIndexOf (char subchar, ptrdiff_t endIndex) const
{ {
if ((size_t)endIndex > Len()) if ((size_t)endIndex > Len())
{ {
endIndex = long(Len()); endIndex = Len();
} }
while (--endIndex >= 0) while (--endIndex >= 0)
{ {
@ -573,16 +573,16 @@ long FString::LastIndexOf (char subchar, long endIndex) const
return -1; return -1;
} }
long FString::LastIndexOfBroken (const FString &_substr, long endIndex) const ptrdiff_t FString::LastIndexOfBroken (const FString &_substr, ptrdiff_t endIndex) const
{ {
const char *substr = _substr.GetChars(); const char *substr = _substr.GetChars();
size_t substrlen = _substr.Len(); size_t substrlen = _substr.Len();
if ((size_t)endIndex > Len()) if ((size_t)endIndex > Len())
{ {
endIndex = long(Len()); endIndex = Len();
} }
substrlen--; substrlen--;
while (--endIndex >= long(substrlen)) while (--endIndex >= ptrdiff_t(substrlen))
{ {
if (strncmp (substr, Chars + endIndex - substrlen, substrlen + 1) == 0) if (strncmp (substr, Chars + endIndex - substrlen, substrlen + 1) == 0)
{ {
@ -592,26 +592,26 @@ long FString::LastIndexOfBroken (const FString &_substr, long endIndex) const
return -1; return -1;
} }
long FString::LastIndexOfAny (const FString &charset) const ptrdiff_t FString::LastIndexOfAny (const FString &charset) const
{ {
return LastIndexOfAny (charset.Chars, long(Len())); return LastIndexOfAny (charset.Chars, Len());
} }
long FString::LastIndexOfAny (const char *charset) const ptrdiff_t FString::LastIndexOfAny (const char *charset) const
{ {
return LastIndexOfAny (charset, long(Len())); return LastIndexOfAny (charset, long(Len()));
} }
long FString::LastIndexOfAny (const FString &charset, long endIndex) const ptrdiff_t FString::LastIndexOfAny (const FString &charset, ptrdiff_t endIndex) const
{ {
return LastIndexOfAny (charset.Chars, endIndex); return LastIndexOfAny (charset.Chars, endIndex);
} }
long FString::LastIndexOfAny (const char *charset, long endIndex) const ptrdiff_t FString::LastIndexOfAny (const char *charset, ptrdiff_t endIndex) const
{ {
if ((size_t)endIndex > Len()) if ((size_t)endIndex > Len())
{ {
endIndex = long(Len()); endIndex = Len();
} }
while (--endIndex >= 0) while (--endIndex >= 0)
{ {
@ -623,31 +623,31 @@ long FString::LastIndexOfAny (const char *charset, long endIndex) const
return -1; return -1;
} }
long FString::LastIndexOf (const FString &substr) const ptrdiff_t FString::LastIndexOf (const FString &substr) const
{ {
return LastIndexOf(substr.Chars, long(Len() - substr.Len()), substr.Len()); return LastIndexOf(substr.Chars, Len() - substr.Len(), substr.Len());
} }
long FString::LastIndexOf (const FString &substr, long endIndex) const ptrdiff_t FString::LastIndexOf (const FString &substr, ptrdiff_t endIndex) const
{ {
return LastIndexOf(substr.Chars, endIndex, substr.Len()); return LastIndexOf(substr.Chars, endIndex, substr.Len());
} }
long FString::LastIndexOf (const char *substr) const ptrdiff_t FString::LastIndexOf (const char *substr) const
{ {
return LastIndexOf(substr, long(Len() - strlen(substr)), strlen(substr)); return LastIndexOf(substr, Len() - strlen(substr), strlen(substr));
} }
long FString::LastIndexOf (const char *substr, long endIndex) const ptrdiff_t FString::LastIndexOf (const char *substr, ptrdiff_t endIndex) const
{ {
return LastIndexOf(substr, endIndex, strlen(substr)); return LastIndexOf(substr, endIndex, strlen(substr));
} }
long FString::LastIndexOf (const char *substr, long endIndex, size_t substrlen) const ptrdiff_t FString::LastIndexOf (const char *substr, ptrdiff_t endIndex, size_t substrlen) const
{ {
if ((size_t)endIndex + substrlen > Len()) if ((size_t)endIndex + substrlen > Len())
{ {
endIndex = long(Len() - substrlen); endIndex = Len() - substrlen;
} }
while (endIndex >= 0) while (endIndex >= 0)
{ {
@ -1256,15 +1256,15 @@ void FString::Split(TArray<FString>& tokens, const char *delimiter, EmptyTokenTy
{ {
assert(nullptr != delimiter); assert(nullptr != delimiter);
const long selfLen = static_cast<long>(Len()); const auto selfLen = static_cast<ptrdiff_t>(Len());
const long delimLen = static_cast<long>(strlen(delimiter)); const auto delimLen = static_cast<ptrdiff_t>(strlen(delimiter));
long lastPos = 0; ptrdiff_t lastPos = 0;
if (selfLen == 0) return; // Empty strings do not contain tokens, even with TOK_KEEPEMPTY. if (selfLen == 0) return; // Empty strings do not contain tokens, even with TOK_KEEPEMPTY.
while (lastPos <= selfLen) while (lastPos <= selfLen)
{ {
long pos = IndexOf(delimiter, lastPos); auto pos = IndexOf(delimiter, lastPos);
if (-1 == pos) if (-1 == pos)
{ {

View file

@ -215,28 +215,28 @@ public:
void AppendCharacter(int codepoint); void AppendCharacter(int codepoint);
void DeleteLastCharacter(); void DeleteLastCharacter();
long IndexOf (const FString &substr, long startIndex=0) const; ptrdiff_t IndexOf (const FString &substr, ptrdiff_t startIndex=0) const;
long IndexOf (const char *substr, long startIndex=0) const; ptrdiff_t IndexOf (const char *substr, ptrdiff_t startIndex=0) const;
long IndexOf (char subchar, long startIndex=0) const; ptrdiff_t IndexOf (char subchar, ptrdiff_t startIndex=0) const;
long IndexOfAny (const FString &charset, long startIndex=0) const; ptrdiff_t IndexOfAny (const FString &charset, ptrdiff_t startIndex=0) const;
long IndexOfAny (const char *charset, long startIndex=0) const; ptrdiff_t IndexOfAny (const char *charset, ptrdiff_t startIndex=0) const;
// This is only kept for backwards compatibility with old ZScript versions that used this function and depend on its bug. // This is only kept for backwards compatibility with old ZScript versions that used this function and depend on its bug.
long LastIndexOf (char subchar) const; ptrdiff_t LastIndexOf (char subchar) const;
long LastIndexOfBroken (const FString &substr, long endIndex) const; ptrdiff_t LastIndexOfBroken (const FString &substr, ptrdiff_t endIndex) const;
long LastIndexOf (char subchar, long endIndex) const; ptrdiff_t LastIndexOf (char subchar, ptrdiff_t endIndex) const;
long LastIndexOfAny (const FString &charset) const; ptrdiff_t LastIndexOfAny (const FString &charset) const;
long LastIndexOfAny (const char *charset) const; ptrdiff_t LastIndexOfAny (const char *charset) const;
long LastIndexOfAny (const FString &charset, long endIndex) const; ptrdiff_t LastIndexOfAny (const FString &charset, ptrdiff_t endIndex) const;
long LastIndexOfAny (const char *charset, long endIndex) const; ptrdiff_t LastIndexOfAny (const char *charset, ptrdiff_t endIndex) const;
long LastIndexOf (const FString &substr) const; ptrdiff_t LastIndexOf (const FString &substr) const;
long LastIndexOf (const FString &substr, long endIndex) const; ptrdiff_t LastIndexOf (const FString &substr, ptrdiff_t endIndex) const;
long LastIndexOf (const char *substr) const; ptrdiff_t LastIndexOf (const char *substr) const;
long LastIndexOf (const char *substr, long endIndex) const; ptrdiff_t LastIndexOf (const char *substr, ptrdiff_t endIndex) const;
long LastIndexOf (const char *substr, long endIndex, size_t substrlen) const; ptrdiff_t LastIndexOf (const char *substr, ptrdiff_t endIndex, size_t substrlen) const;
void ToUpper (); void ToUpper ();
void ToLower (); void ToLower ();

View file

@ -762,7 +762,7 @@ int FIWadManager::IdentifyVersion (TArray<FString> &wadfiles, const char *iwad,
FString path; FString path;
if (info.Load[i][0] != ':') if (info.Load[i][0] != ':')
{ {
long lastslash = picks[pick].mFullPath.LastIndexOf('/'); auto lastslash = picks[pick].mFullPath.LastIndexOf('/');
if (lastslash == -1) if (lastslash == -1)
{ {

View file

@ -903,6 +903,7 @@ static void End2DAndUpdate()
twod->End(); twod->End();
CheckBench(); CheckBench();
screen->Update(); screen->Update();
twod->OnFrameDone();
} }
//========================================================================== //==========================================================================
@ -2121,8 +2122,8 @@ static void AddAutoloadFiles(const char *autoname)
// Add common (global) wads // Add common (global) wads
D_AddConfigFiles(allwads, "Global.Autoload", "*.wad", GameConfig); D_AddConfigFiles(allwads, "Global.Autoload", "*.wad", GameConfig);
long len; ptrdiff_t len;
int lastpos = -1; ptrdiff_t lastpos = -1;
while ((len = LumpFilterIWAD.IndexOf('.', lastpos+1)) > 0) while ((len = LumpFilterIWAD.IndexOf('.', lastpos+1)) > 0)
{ {

View file

@ -1014,7 +1014,7 @@ bool G_Responder (event_t *ev)
{ {
if (ST_Responder (ev)) if (ST_Responder (ev))
return true; // status window ate it return true; // status window ate it
if (!viewactive && primaryLevel->automap->Responder (ev, false)) if (!viewactive && primaryLevel->automap && primaryLevel->automap->Responder (ev, false))
return true; // automap ate it return true; // automap ate it
} }
else if (gamestate == GS_FINALE) else if (gamestate == GS_FINALE)

View file

@ -378,6 +378,10 @@ void G_NewInit ()
if (primaryLevel->FraggleScriptThinker) primaryLevel->FraggleScriptThinker->Destroy(); if (primaryLevel->FraggleScriptThinker) primaryLevel->FraggleScriptThinker->Destroy();
primaryLevel->FraggleScriptThinker = nullptr; primaryLevel->FraggleScriptThinker = nullptr;
// Destroy thinkers that may remain after change level failure
// Usually, the list contains just a sentinel when such error occurred
primaryLevel->Thinkers.DestroyThinkersInList(STAT_TRAVELLING);
G_ClearSnapshots (); G_ClearSnapshots ();
netgame = false; netgame = false;
multiplayer = multiplayernext; multiplayer = multiplayernext;

View file

@ -255,7 +255,7 @@ void FGameConfigFile::DoAutoloadSetup (FIWadManager *iwad_man)
{ {
FString section = workname + ".Autoload"; FString section = workname + ".Autoload";
CreateSectionAtStart(section.GetChars()); CreateSectionAtStart(section.GetChars());
long dotpos = workname.LastIndexOf('.'); auto dotpos = workname.LastIndexOf('.');
if (dotpos < 0) break; if (dotpos < 0) break;
workname.Truncate(dotpos); workname.Truncate(dotpos);
} }

View file

@ -635,7 +635,7 @@ void M_ScreenShot (const char *filename)
if (!screenshot_quiet) if (!screenshot_quiet)
{ {
int slash = -1; ptrdiff_t slash = -1;
if (!longsavemessages) slash = autoname.LastIndexOfAny(":/\\"); if (!longsavemessages) slash = autoname.LastIndexOfAny(":/\\");
Printf ("Captured %s\n", autoname.GetChars()+slash+1); Printf ("Captured %s\n", autoname.GetChars()+slash+1);
} }

View file

@ -1001,13 +1001,13 @@ static FString CreateCacheName(MapData *map, bool create)
{ {
FString path = M_GetCachePath(create); FString path = M_GetCachePath(create);
FString lumpname = fileSystem.GetFileFullPath(map->lumpnum); FString lumpname = fileSystem.GetFileFullPath(map->lumpnum);
int separator = lumpname.IndexOf(':'); auto separator = lumpname.IndexOf(':');
path << '/' << lumpname.Left(separator); path << '/' << lumpname.Left(separator);
if (create) CreatePath(path); if (create) CreatePath(path);
lumpname.ReplaceChars('/', '%'); lumpname.ReplaceChars('/', '%');
lumpname.ReplaceChars(':', '$'); lumpname.ReplaceChars(':', '$');
path << '/' << lumpname.Right(lumpname.Len() - separator - 1) << ".gzc"; path << '/' << lumpname.Right((ptrdiff_t)lumpname.Len() - separator - 1) << ".gzc";
return path; return path;
} }

View file

@ -64,6 +64,7 @@
#include "gameconfigfile.h" #include "gameconfigfile.h"
#include "d_player.h" #include "d_player.h"
#include "teaminfo.h" #include "teaminfo.h"
#include "hwrenderer/scene/hw_drawinfo.h"
EXTERN_CVAR(Int, cl_gfxlocalization) EXTERN_CVAR(Int, cl_gfxlocalization)
EXTERN_CVAR(Bool, m_quickexit) EXTERN_CVAR(Bool, m_quickexit)
@ -295,6 +296,7 @@ CCMD (menu_quit)
{ // F10 { // F10
if (m_quickexit) if (m_quickexit)
{ {
CleanSWDrawer();
ST_Endoom(); ST_Endoom();
} }
@ -326,6 +328,7 @@ CCMD (menu_quit)
I_WaitVBL(105); I_WaitVBL(105);
} }
} }
CleanSWDrawer();
ST_Endoom(); ST_Endoom();
}); });
@ -568,8 +571,21 @@ void M_StartupEpisodeMenu(FNewGameStartup *gs)
if (y < topy) topy = y; if (y < topy) topy = y;
} }
int spacing = ld->mLinespacing;
for (unsigned i = 0; i < AllEpisodes.Size(); i++)
{
if (AllEpisodes[i].mPicName.IsNotEmpty())
{
FTextureID tex = GetMenuTexture(AllEpisodes[i].mPicName);
if (AllEpisodes[i].mEpisodeName.IsEmpty() || OkForLocalization(tex, AllEpisodes[i].mEpisodeName))
continue;
}
if ((gameinfo.gametype & GAME_DoomStrifeChex) && spacing == 16) spacing = 18;
break;
}
// center the menu on the screen if the top space is larger than the bottom space // center the menu on the screen if the top space is larger than the bottom space
int totalheight = posy + AllEpisodes.Size() * ld->mLinespacing - topy; int totalheight = posy + AllEpisodes.Size() * spacing - topy;
if (totalheight < 190 || AllEpisodes.Size() == 1) if (totalheight < 190 || AllEpisodes.Size() == 1)
{ {
@ -610,15 +626,15 @@ void M_StartupEpisodeMenu(FNewGameStartup *gs)
{ {
FTextureID tex = GetMenuTexture(AllEpisodes[i].mPicName); FTextureID tex = GetMenuTexture(AllEpisodes[i].mPicName);
if (AllEpisodes[i].mEpisodeName.IsEmpty() || OkForLocalization(tex, AllEpisodes[i].mEpisodeName)) if (AllEpisodes[i].mEpisodeName.IsEmpty() || OkForLocalization(tex, AllEpisodes[i].mEpisodeName))
it = CreateListMenuItemPatch(posx, posy, ld->mLinespacing, AllEpisodes[i].mShortcut, tex, NAME_Skillmenu, i); it = CreateListMenuItemPatch(posx, posy, spacing, AllEpisodes[i].mShortcut, tex, NAME_Skillmenu, i);
} }
if (it == nullptr) if (it == nullptr)
{ {
it = CreateListMenuItemText(posx, posy, ld->mLinespacing, AllEpisodes[i].mShortcut, it = CreateListMenuItemText(posx, posy, spacing, AllEpisodes[i].mShortcut,
AllEpisodes[i].mEpisodeName, ld->mFont, ld->mFontColor, ld->mFontColor2, NAME_Skillmenu, i); AllEpisodes[i].mEpisodeName, ld->mFont, ld->mFontColor, ld->mFontColor2, NAME_Skillmenu, i);
} }
ld->mItems.Push(it); ld->mItems.Push(it);
posy += ld->mLinespacing; posy += spacing;
} }
if (AllEpisodes.Size() == 1) if (AllEpisodes.Size() == 1)
{ {
@ -1070,9 +1086,10 @@ void M_StartupSkillMenu(FNewGameStartup *gs)
} }
} }
if (done != restart) int spacing = ld->mLinespacing;
//if (done != restart)
{ {
done = restart; //done = restart;
ld->mSelectedItem = ld->mItems.Size() + defindex; ld->mSelectedItem = ld->mItems.Size() + defindex;
int posy = y; int posy = y;
@ -1085,8 +1102,20 @@ void M_StartupSkillMenu(FNewGameStartup *gs)
if (y < topy) topy = y; if (y < topy) topy = y;
} }
for (unsigned i = 0; i < MenuSkills.Size(); i++)
{
if (MenuSkills[i]->PicName.IsNotEmpty())
{
FTextureID tex = GetMenuTexture(MenuSkills[i]->PicName);
if (MenuSkills[i]->MenuName.IsEmpty() || OkForLocalization(tex, MenuSkills[i]->MenuName))
continue;
}
if ((gameinfo.gametype & GAME_DoomStrifeChex) && spacing == 16) spacing = 18;
break;
}
// center the menu on the screen if the top space is larger than the bottom space // center the menu on the screen if the top space is larger than the bottom space
int totalheight = posy + MenuSkills.Size() * ld->mLinespacing - topy; int totalheight = posy + MenuSkills.Size() * spacing - topy;
if (totalheight < 190 || MenuSkills.Size() == 1) if (totalheight < 190 || MenuSkills.Size() == 1)
{ {
@ -1154,16 +1183,16 @@ void M_StartupSkillMenu(FNewGameStartup *gs)
{ {
FTextureID tex = GetMenuTexture(skill.PicName); FTextureID tex = GetMenuTexture(skill.PicName);
if (skill.MenuName.IsEmpty() || OkForLocalization(tex, skill.MenuName)) if (skill.MenuName.IsEmpty() || OkForLocalization(tex, skill.MenuName))
li = CreateListMenuItemPatch(posx, y, ld->mLinespacing, skill.Shortcut, tex, action, SkillIndices[i]); li = CreateListMenuItemPatch(posx, y, spacing, skill.Shortcut, tex, action, SkillIndices[i]);
} }
if (li == nullptr) if (li == nullptr)
{ {
li = CreateListMenuItemText(posx, y, ld->mLinespacing, skill.Shortcut, li = CreateListMenuItemText(posx, y, spacing, skill.Shortcut,
pItemText? *pItemText : skill.MenuName, ld->mFont, color,ld->mFontColor2, action, SkillIndices[i]); pItemText? *pItemText : skill.MenuName, ld->mFont, color,ld->mFontColor2, action, SkillIndices[i]);
} }
ld->mItems.Push(li); ld->mItems.Push(li);
GC::WriteBarrier(*desc, li); GC::WriteBarrier(*desc, li);
y += ld->mLinespacing; y += spacing;
} }
if (AllEpisodes[gs->Episode].mNoSkill || MenuSkills.Size() == 1) if (AllEpisodes[gs->Episode].mNoSkill || MenuSkills.Size() == 1)
{ {

View file

@ -175,22 +175,6 @@ void P_Ticker (void)
{ {
P_UpdateSpecials(Level); P_UpdateSpecials(Level);
} }
it = Level->GetThinkerIterator<AActor>();
// Set dynamic lights at the end of the tick, so that this catches all changes being made through the last frame.
while ((ac = it.Next()))
{
if (ac->flags8 & MF8_RECREATELIGHTS)
{
ac->flags8 &= ~MF8_RECREATELIGHTS;
ac->SetDynamicLights();
}
// This was merged from P_RunEffects to eliminate the costly duplicate ThinkerIterator loop.
if ((ac->effects || ac->fountaincolor) && !Level->isFrozen())
{
P_RunEffect(ac, ac->effects);
}
}
// for par times // for par times
Level->time++; Level->time++;

View file

@ -42,6 +42,7 @@
#include "v_text.h" #include "v_text.h"
#include "g_levellocals.h" #include "g_levellocals.h"
#include "a_dynlight.h" #include "a_dynlight.h"
#include "v_video.h"
static int ThinkCount; static int ThinkCount;
@ -106,6 +107,25 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level)
ThinkCycles.Clock(); ThinkCycles.Clock();
auto recreateLights = [=]() {
auto it = Level->GetThinkerIterator<AActor>();
// Set dynamic lights at the end of the tick, so that this catches all changes being made through the last frame.
while (auto ac = it.Next())
{
if (ac->flags8 & MF8_RECREATELIGHTS)
{
ac->flags8 &= ~MF8_RECREATELIGHTS;
ac->SetDynamicLights();
}
// This was merged from P_RunEffects to eliminate the costly duplicate ThinkerIterator loop.
if ((ac->effects || ac->fountaincolor) && !Level->isFrozen())
{
P_RunEffect(ac, ac->effects);
}
}
};
if (!profilethinkers) if (!profilethinkers)
{ {
// Tick every thinker left from last time // Tick every thinker left from last time
@ -124,11 +144,15 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level)
} }
} while (count != 0); } while (count != 0);
for (auto light = Level->lights; light;) if (Level->HasDynamicLights)
{ {
auto next = light->next; recreateLights();
light->Tick(); for (auto light = Level->lights; light;)
light = next; {
auto next = light->next;
light->Tick();
light = next;
}
} }
} }
else else
@ -150,8 +174,9 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level)
} }
} while (count != 0); } while (count != 0);
if (Level->lights) if (Level->lights && Level->HasDynamicLights)
{ {
recreateLights();
// Also profile the internal dynamic lights, even though they are not implemented as thinkers. // Also profile the internal dynamic lights, even though they are not implemented as thinkers.
auto &prof = Profiles[NAME_InternalDynamicLight]; auto &prof = Profiles[NAME_InternalDynamicLight];
prof.timer.Clock(); prof.timer.Clock();

View file

@ -648,7 +648,7 @@ bool FLevelLocals::EV_BuildStairs (int tag, DFloor::EStair type, line_t *line, d
floor->m_Instant = false; floor->m_Instant = false;
floor->m_Crush = (usespecials & DFloor::stairCrush) ? 10 : -1; //jff 2/27/98 fix uninitialized crush field floor->m_Crush = (usespecials & DFloor::stairCrush) ? 10 : -1; //jff 2/27/98 fix uninitialized crush field
floor->m_Hexencrush = false; floor->m_Hexencrush = true;
floor->m_Speed = speed; floor->m_Speed = speed;
height = sec->CenterFloor() + stairstep; height = sec->CenterFloor() + stairstep;

View file

@ -910,13 +910,13 @@ FBlockThingsIterator::FBlockThingsIterator(FLevelLocals *l, int _minx, int _miny
Reset(); Reset();
} }
void FBlockThingsIterator::init(const FBoundingBox &box) void FBlockThingsIterator::init(const FBoundingBox &box, bool clearhash)
{ {
maxy = Level->blockmap.GetBlockY(box.Top()); maxy = Level->blockmap.GetBlockY(box.Top());
miny = Level->blockmap.GetBlockY(box.Bottom()); miny = Level->blockmap.GetBlockY(box.Bottom());
maxx = Level->blockmap.GetBlockX(box.Right()); maxx = Level->blockmap.GetBlockX(box.Right());
minx = Level->blockmap.GetBlockX(box.Left()); minx = Level->blockmap.GetBlockX(box.Left());
ClearHash(); if (clearhash) ClearHash();
Reset(); Reset();
} }
@ -1139,7 +1139,7 @@ void FMultiBlockThingsIterator::startIteratorForGroup(int group)
offset.X += checkpoint.X; offset.X += checkpoint.X;
offset.Y += checkpoint.Y; offset.Y += checkpoint.Y;
bbox.setBox(offset.X, offset.Y, checkpoint.Z); bbox.setBox(offset.X, offset.Y, checkpoint.Z);
blockIterator.init(bbox); blockIterator.init(bbox, false);
} }
//=========================================================================== //===========================================================================
@ -1153,6 +1153,7 @@ void FMultiBlockThingsIterator::Reset()
index = -1; index = -1;
portalflags = 0; portalflags = 0;
startIteratorForGroup(basegroup); startIteratorForGroup(basegroup);
blockIterator.ClearHash();
} }
//=========================================================================== //===========================================================================
@ -1847,6 +1848,7 @@ AActor *P_RoughMonsterSearch(AActor *mo, int distance, bool onlyseekable, bool f
{ {
BlockCheckInfo info; BlockCheckInfo info;
info.onlyseekable = onlyseekable; info.onlyseekable = onlyseekable;
info.fov = fov;
if ((info.frontonly = frontonly)) if ((info.frontonly = frontonly))
{ {
info.frontline.x = mo->X(); info.frontline.x = mo->X();

View file

@ -319,7 +319,7 @@ public:
Level = l; Level = l;
init(box); init(box);
} }
void init(const FBoundingBox &box); void init(const FBoundingBox &box, bool clearhash = true);
AActor *Next(bool centeronly = false); AActor *Next(bool centeronly = false);
void Reset() { StartBlock(minx, miny); } void Reset() { StartBlock(minx, miny); }
}; };

View file

@ -183,7 +183,7 @@ void RenderModel(FModelRenderer *renderer, float x, float y, float z, FSpriteMod
void RenderHUDModel(FModelRenderer *renderer, DPSprite *psp, float ofsX, float ofsY) void RenderHUDModel(FModelRenderer *renderer, DPSprite *psp, float ofsX, float ofsY)
{ {
AActor * playermo = players[consoleplayer].camera; AActor * playermo = players[consoleplayer].camera;
FSpriteModelFrame *smf = FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetSprite(), psp->GetFrame(), false); FSpriteModelFrame *smf = FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false);
// [BB] No model found for this sprite, so we can't render anything. // [BB] No model found for this sprite, so we can't render anything.
if (smf == nullptr) if (smf == nullptr)
@ -216,7 +216,7 @@ void RenderHUDModel(FModelRenderer *renderer, DPSprite *psp, float ofsX, float o
renderer->BeginDrawHUDModel(playermo->RenderStyle, objectToWorldMatrix, orientation < 0); renderer->BeginDrawHUDModel(playermo->RenderStyle, objectToWorldMatrix, orientation < 0);
uint32_t trans = psp->GetTranslation() != 0 ? psp->GetTranslation() : 0; uint32_t trans = psp->GetTranslation() != 0 ? psp->GetTranslation() : 0;
if ((psp->Flags & PSPF_PLAYERTRANSLATED)) trans = psp->Owner->mo->Translation; if ((psp->Flags & PSPF_PLAYERTRANSLATED)) trans = psp->Owner->mo->Translation;
RenderFrameModels(renderer, playermo->Level, smf, psp->GetState(), psp->GetTics(), playermo->player->ReadyWeapon->GetClass(), trans); RenderFrameModels(renderer, playermo->Level, smf, psp->GetState(), psp->GetTics(), psp->Caller->GetClass(), trans);
renderer->EndDrawHUDModel(playermo->RenderStyle); renderer->EndDrawHUDModel(playermo->RenderStyle);
} }
@ -777,15 +777,14 @@ FSpriteModelFrame * FindModelFrame(const PClass * ti, int sprite, int frame, boo
bool IsHUDModelForPlayerAvailable (player_t * player) bool IsHUDModelForPlayerAvailable (player_t * player)
{ {
if (player == nullptr || player->ReadyWeapon == nullptr) if (player == nullptr || player->psprites == nullptr)
return false; return false;
DPSprite *psp = player->FindPSprite(PSP_WEAPON); // [MK] check that at least one psprite uses models
for (DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext())
if (psp == nullptr) {
return false; FSpriteModelFrame *smf = FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false);
if ( smf != nullptr ) return true;
FSpriteModelFrame *smf = FindModelFrame(player->ReadyWeapon->GetClass(), psp->GetSprite(), psp->GetFrame(), false); }
return ( smf != nullptr ); return false;
} }

View file

@ -29,6 +29,7 @@
#include "a_dynlight.h" #include "a_dynlight.h"
#include "hw_dynlightdata.h" #include "hw_dynlightdata.h"
#include"hw_cvars.h" #include"hw_cvars.h"
#include "v_video.h"
#include "hwrenderer/scene/hw_drawstructs.h" #include "hwrenderer/scene/hw_drawstructs.h"
// If we want to share the array to avoid constant allocations it needs to be thread local unless it'd be littered with expensive synchronization. // If we want to share the array to avoid constant allocations it needs to be thread local unless it'd be littered with expensive synchronization.
@ -107,7 +108,7 @@ void AddLightToList(FDynLightData &dld, int group, FDynamicLight * light, bool f
} }
float shadowIndex; float shadowIndex;
if (gl_light_shadowmap) // note: with gl_light_shadowmap switched off, we cannot rely on properly set indices anymore. if (screen->mShadowMap.Enabled()) // note: with shadowmaps switched off, we cannot rely on properly set indices anymore.
{ {
shadowIndex = light->mShadowmapIndex + 1.0f; shadowIndex = light->mShadowmapIndex + 1.0f;
} }

View file

@ -40,6 +40,7 @@
#include "flatvertices.h" #include "flatvertices.h"
#include "v_palette.h" #include "v_palette.h"
#include "d_main.h" #include "d_main.h"
#include "g_cvars.h"
#include "hw_lightbuffer.h" #include "hw_lightbuffer.h"
#include "hw_cvars.h" #include "hw_cvars.h"
@ -107,7 +108,7 @@ sector_t* RenderViewpoint(FRenderViewpoint& mainvp, AActor* camera, IntRect* bou
R_SetupFrame(mainvp, r_viewwindow, camera); R_SetupFrame(mainvp, r_viewwindow, camera);
if (mainview && toscreen && !(camera->Level->flags3 & LEVEL3_NOSHADOWMAP) && gl_light_shadowmap && screen->mPipelineType == 0 && (screen->hwcaps & RFL_SHADER_STORAGE_BUFFER)) if (mainview && toscreen && !(camera->Level->flags3 & LEVEL3_NOSHADOWMAP) && camera->Level->HasDynamicLights && gl_light_shadowmap && screen->mPipelineType == 0 && (screen->hwcaps & RFL_SHADER_STORAGE_BUFFER))
{ {
screen->SetAABBTree(camera->Level->aabbTree); screen->SetAABBTree(camera->Level->aabbTree);
screen->mShadowMap.SetCollectLights([=] { screen->mShadowMap.SetCollectLights([=] {

View file

@ -614,7 +614,7 @@ void HWDrawInfo::PreparePlayerSprites(sector_t * viewsector, area_t in_area)
for (DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext()) for (DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext())
{ {
if (!psp->GetState()) continue; if (!psp->GetState()) continue;
FSpriteModelFrame *smf = playermo->player->ReadyWeapon ? FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetSprite(), psp->GetFrame(), false) : nullptr; FSpriteModelFrame *smf = FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false);
// This is an 'either-or' proposition. This maybe needs some work to allow overlays with weapon models but as originally implemented this just won't work. // This is an 'either-or' proposition. This maybe needs some work to allow overlays with weapon models but as originally implemented this just won't work.
if (smf && !hudModelStep) continue; if (smf && !hudModelStep) continue;
if (!smf && hudModelStep) continue; if (!smf && hudModelStep) continue;

View file

@ -808,12 +808,12 @@ FxMultiNameState::FxMultiNameState(const char *_statestring, const FScriptPositi
{ {
FName scopename = NAME_None; FName scopename = NAME_None;
FString statestring = _statestring; FString statestring = _statestring;
int scopeindex = statestring.IndexOf("::"); auto scopeindex = statestring.IndexOf("::");
if (scopeindex >= 0) if (scopeindex >= 0)
{ {
scopename = FName(statestring, scopeindex, false); scopename = FName(statestring, scopeindex, false);
statestring = statestring.Right(statestring.Len() - scopeindex - 2); statestring = statestring.Right((ptrdiff_t)statestring.Len() - scopeindex - 2);
} }
names = MakeStateNameList(statestring); names = MakeStateNameList(statestring);
names.Insert(0, scopename); names.Insert(0, scopename);

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

View file

@ -0,0 +1,2 @@
CellSize 4, 6 // This implies font sheets

Binary file not shown.

View file

@ -209,6 +209,7 @@ ListMenu "EpisodeMenu"
{ {
Position 48, 63 Position 48, 63
StaticPatch 54, 38, "M_EPISOD", 0 , "$MNU_EPISODE" StaticPatch 54, 38, "M_EPISOD", 0 , "$MNU_EPISODE"
linespacing 16
} }
IfGame(Strife) IfGame(Strife)
{ {
@ -234,6 +235,7 @@ ListMenu "SkillMenu"
IfGame(Doom, Chex) IfGame(Doom, Chex)
{ {
StaticPatch 96, 14, "M_NEWG", 0, "$MNU_NEWGAME" StaticPatch 96, 14, "M_NEWG", 0, "$MNU_NEWGAME"
linespacing 16
} }
IfGame(Strife) IfGame(Strife)
{ {

View file

@ -26,7 +26,7 @@ class ExplosiveBarrel : Actor
BEXP A 5 BRIGHT; BEXP A 5 BRIGHT;
BEXP B 5 BRIGHT A_Scream; BEXP B 5 BRIGHT A_Scream;
BEXP C 5 BRIGHT; BEXP C 5 BRIGHT;
BEXP D 5 BRIGHT A_Explode; BEXP D 10 BRIGHT A_Explode;
BEXP E 10 BRIGHT; BEXP E 10 BRIGHT;
TNT1 A 1050 BRIGHT A_BarrelDestroy; TNT1 A 1050 BRIGHT A_BarrelDestroy;
TNT1 A 5 A_Respawn; TNT1 A 5 A_Respawn;

View file

@ -456,6 +456,7 @@ class PlayerPawn : Actor
virtual void CheckWeaponChange () virtual void CheckWeaponChange ()
{ {
let player = self.player; let player = self.player;
if (!player) return;
if ((player.WeaponState & WF_DISABLESWITCH) || // Weapon changing has been disabled. if ((player.WeaponState & WF_DISABLESWITCH) || // Weapon changing has been disabled.
player.morphTics != 0) // Morphed classes cannot change weapons. player.morphTics != 0) // Morphed classes cannot change weapons.
{ // ...so throw away any pending weapon requests. { // ...so throw away any pending weapon requests.

View file

@ -412,7 +412,6 @@ struct Screen native
native static Color PaletteColor(int index); native static Color PaletteColor(int index);
native static int GetWidth(); native static int GetWidth();
native static int GetHeight(); native static int GetHeight();
//native static Vector2 GetTextScreenSize();
native static void Clear(int left, int top, int right, int bottom, Color color, int palcolor = -1); native static void Clear(int left, int top, int right, int bottom, Color color, int palcolor = -1);
native static void Dim(Color col, double amount, int x, int y, int w, int h); native static void Dim(Color col, double amount, int x, int y, int w, int h);

View file

@ -328,6 +328,36 @@ class ListMenu : Menu
{ {
mFocusControl = NULL; mFocusControl = NULL;
} }
//=============================================================================
//
//
//
//=============================================================================
void ChangeLineSpacing(int newspace)
{
double top = -32767;
for (int i = 0; i < mDesc.mItems.Size(); i++)
{
let selitem = ListMenuItemSelectable(mDesc.mItems[i]);
if (selitem)
{
let y = mDesc.mItems[i].GetY();
if (top == -32767)
{
top = y;
}
else
{
let newy = top + (y - top) / mDesc.mLineSpacing * newspace;
mDesc.mItems[i].SetY(newy);
}
}
}
mDesc.mLineSpacing = newspace;
}
} }

View file

@ -40,6 +40,7 @@ class MenuItemBase : Object native ui version("2.4")
double GetY() { return mYpos; } double GetY() { return mYpos; }
double GetX() { return mXpos; } double GetX() { return mXpos; }
void SetX(double x) { mXpos = x; } void SetX(double x) { mXpos = x; }
void SetY(double x) { mYpos = x; }
virtual void OnMenuCreated() {} virtual void OnMenuCreated() {}
} }

View file

@ -66,7 +66,7 @@ class DoomStatusBar : BaseStatusBar
if (CPlayer.mo.InvSel != null && !Level.NoInventoryBar) if (CPlayer.mo.InvSel != null && !Level.NoInventoryBar)
{ {
DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198)); DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198), DI_DIMDEPLETED);
if (CPlayer.mo.InvSel.Amount > 1) if (CPlayer.mo.InvSel.Amount > 1)
{ {
DrawString(mAmountFont, FormatNumber(CPlayer.mo.InvSel.Amount), (175, 198-mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD); DrawString(mAmountFont, FormatNumber(CPlayer.mo.InvSel.Amount), (175, 198-mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD);
@ -169,7 +169,7 @@ class DoomStatusBar : BaseStatusBar
} }
if (!isInventoryBarVisible() && !Level.NoInventoryBar && CPlayer.mo.InvSel != null) if (!isInventoryBarVisible() && !Level.NoInventoryBar && CPlayer.mo.InvSel != null)
{ {
DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17)); DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17), DI_DIMDEPLETED);
DrawString(mHUDFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT); DrawString(mHUDFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT);
} }
if (deathmatch) if (deathmatch)

View file

@ -127,7 +127,7 @@ class HereticStatusBar : BaseStatusBar
//inventory box //inventory box
if (CPlayer.mo.InvSel != null) if (CPlayer.mo.InvSel != null)
{ {
DrawInventoryIcon(CPlayer.mo.InvSel, (194, 175), DI_ARTIFLASH|DI_ITEM_CENTER, boxsize:(28, 28)); DrawInventoryIcon(CPlayer.mo.InvSel, (194, 175), DI_ARTIFLASH|DI_ITEM_CENTER|DI_DIMDEPLETED, boxsize:(28, 28));
if (CPlayer.mo.InvSel.Amount > 1) if (CPlayer.mo.InvSel.Amount > 1)
{ {
DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (209, 182), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (209, 182), DI_TEXT_ALIGN_RIGHT);
@ -205,7 +205,7 @@ class HereticStatusBar : BaseStatusBar
// This code was changed to always fit the item into the box, regardless of alignment or sprite size. // This code was changed to always fit the item into the box, regardless of alignment or sprite size.
// Heretic's ARTIBOX is 30x30 pixels. // Heretic's ARTIBOX is 30x30 pixels.
DrawImage("ARTIBOX", (-46, -1), 0, HX_SHADOW); DrawImage("ARTIBOX", (-46, -1), 0, HX_SHADOW);
DrawInventoryIcon(CPlayer.mo.InvSel, (-46, -15), DI_ARTIFLASH|DI_ITEM_CENTER, boxsize:(28, 28)); DrawInventoryIcon(CPlayer.mo.InvSel, (-46, -15), DI_ARTIFLASH|DI_ITEM_CENTER|DI_DIMDEPLETED, boxsize:(28, 28));
if (CPlayer.mo.InvSel.Amount > 1) if (CPlayer.mo.InvSel.Amount > 1)
{ {
DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-32, -2 - mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-32, -2 - mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT);

View file

@ -83,7 +83,7 @@ class HexenStatusBar : BaseStatusBar
// This code was changed to always fit the item into the box, regardless of alignment or sprite size. // This code was changed to always fit the item into the box, regardless of alignment or sprite size.
// Heretic's ARTIBOX is 30x30 pixels. // Heretic's ARTIBOX is 30x30 pixels.
DrawImage("ARTIBOX", (-66, -1), 0, HX_SHADOW); DrawImage("ARTIBOX", (-66, -1), 0, HX_SHADOW);
DrawInventoryIcon(CPlayer.mo.InvSel, (-66, -15), DI_ARTIFLASH|DI_ITEM_CENTER, boxsize:(28, 28)); DrawInventoryIcon(CPlayer.mo.InvSel, (-66, -15), DI_ARTIFLASH|DI_ITEM_CENTER|DI_DIMDEPLETED, boxsize:(28, 28));
if (CPlayer.mo.InvSel.Amount > 1) if (CPlayer.mo.InvSel.Amount > 1)
{ {
DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-52, -2 - mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-52, -2 - mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT);
@ -146,7 +146,7 @@ class HexenStatusBar : BaseStatusBar
//inventory box //inventory box
if (CPlayer.mo.InvSel != null) if (CPlayer.mo.InvSel != null)
{ {
DrawInventoryIcon(CPlayer.mo.InvSel, (159.5, 177), DI_ARTIFLASH|DI_ITEM_CENTER, boxsize:(28, 28)); DrawInventoryIcon(CPlayer.mo.InvSel, (159.5, 177), DI_ARTIFLASH|DI_ITEM_CENTER|DI_DIMDEPLETED, boxsize:(28, 28));
if (CPlayer.mo.InvSel.Amount > 1) if (CPlayer.mo.InvSel.Amount > 1)
{ {
DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (174, 184), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (174, 184), DI_TEXT_ALIGN_RIGHT);

View file

@ -981,7 +981,7 @@ class BaseStatusBar : StatusBarCore native
} }
else else
{ {
DrawInventoryIcon(item, itempos + (boxsize.X * i, 0), flags | DI_ITEM_CENTER ); DrawInventoryIcon(item, itempos + (boxsize.X * i, 0), flags | DI_ITEM_CENTER | DI_DIMDEPLETED );
} }
} }