From 0795c79a3ac1ccc7558ebce005a958a0f011dc9a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Sep 2020 10:03:53 +0200 Subject: [PATCH] - engine updates from GZDoom. --- source/common/engine/d_event.cpp | 1 - source/common/engine/i_interface.cpp | 1 + source/common/engine/i_interface.h | 1 + source/common/engine/namedef.h | 4 +++ source/common/engine/palettecontainer.cpp | 14 +-------- source/common/engine/serializer.cpp | 1 + source/common/engine/serializer.h | 3 +- source/common/engine/serializer_internal.h | 35 ++++++++++++++++++++-- source/common/engine/stats.h | 3 ++ source/common/engine/stringtable.cpp | 6 +--- 10 files changed, 46 insertions(+), 23 deletions(-) diff --git a/source/common/engine/d_event.cpp b/source/common/engine/d_event.cpp index 5f0db5418..bb0ef5dae 100644 --- a/source/common/engine/d_event.cpp +++ b/source/common/engine/d_event.cpp @@ -41,7 +41,6 @@ #include "utf8.h" #include "m_joy.h" #include "vm.h" -#include "cheathandler.h" #include "gamestate.h" bool G_Responder(event_t* ev); diff --git a/source/common/engine/i_interface.cpp b/source/common/engine/i_interface.cpp index fbeb4dfaa..90d0df385 100644 --- a/source/common/engine/i_interface.cpp +++ b/source/common/engine/i_interface.cpp @@ -4,4 +4,5 @@ SystemCallbacks *sysCallbacks; FString endoomName; bool batchrun; +float menuBlurAmount; diff --git a/source/common/engine/i_interface.h b/source/common/engine/i_interface.h index db46eb885..cf77c743e 100644 --- a/source/common/engine/i_interface.h +++ b/source/common/engine/i_interface.h @@ -32,3 +32,4 @@ struct WadStuff extern FString endoomName; extern bool batchrun; +extern float menuBlurAmount; diff --git a/source/common/engine/namedef.h b/source/common/engine/namedef.h index f822e98a7..53fca85d0 100644 --- a/source/common/engine/namedef.h +++ b/source/common/engine/namedef.h @@ -1039,6 +1039,9 @@ xx(AttackZOffset) xx(SpawnMask) xx(ScoreIcon) xx(ViewHeight) +xx(ViewAngle) +xx(ViewPitch) +xx(ViewRoll) xx(FallingScreamMinSpeed) xx(FallingScreamMaxSpeed) xx(GruntSpeed) @@ -1072,3 +1075,4 @@ xx(PlayerSkin) xx(NewPlayerMenu) xx(AltHud) xx(GameScreen) + diff --git a/source/common/engine/palettecontainer.cpp b/source/common/engine/palettecontainer.cpp index 6c9f81c37..4cd4a28bc 100644 --- a/source/common/engine/palettecontainer.cpp +++ b/source/common/engine/palettecontainer.cpp @@ -40,7 +40,6 @@ #include "templates.h" #include "palettecontainer.h" #include "files.h" -#include "c_dispatch.h" PaletteContainer GPalette; FColorMatcher ColorMatcher; @@ -821,15 +820,4 @@ bool FRemapTable::AddColors(int start, int count, const uint8_t*colors, int tran } -CCMD(exportpalette) -{ - FILE* f = fopen("palette.pal", "wb"); - if (!f) return; - for (int i = 0; i < 256; i++) - { - fputc(GPalette.BaseColors[i].r, f); - fputc(GPalette.BaseColors[i].g, f); - fputc(GPalette.BaseColors[i].b, f); - } - fclose(f); -} \ No newline at end of file + diff --git a/source/common/engine/serializer.cpp b/source/common/engine/serializer.cpp index 058b073b5..1b56bba2c 100644 --- a/source/common/engine/serializer.cpp +++ b/source/common/engine/serializer.cpp @@ -676,6 +676,7 @@ void FSerializer::ReadObjects(bool hubtravel) { Printf(TEXTCOLOR_RED "Failed to restore all objects in savegame\n"); mErrors++; + mObjectErrors++; } } catch(...) diff --git a/source/common/engine/serializer.h b/source/common/engine/serializer.h index 3d331567a..b25aeeb0f 100644 --- a/source/common/engine/serializer.h +++ b/source/common/engine/serializer.h @@ -182,6 +182,7 @@ public: } int mErrors = 0; + int mObjectErrors = 0; }; FSerializer& Serialize(FSerializer& arc, const char* key, char& value, char* defval); @@ -242,7 +243,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, TArray &value, template FSerializer& Serialize(FSerializer& arc, const char* key, FixedBitArray& value, FixedBitArray* def) { - return arc.Array(key, value.Storage(), def ? def->Storage() : nullptr, value.StorageSize()); + return arc.SerializeMemory(key, value.Storage(), value.StorageSize()); } template<> FSerializer& Serialize(FSerializer& arc, const char* key, PClass*& clst, PClass** def); diff --git a/source/common/engine/serializer_internal.h b/source/common/engine/serializer_internal.h index 7323f23f7..161d2ebdf 100644 --- a/source/common/engine/serializer_internal.h +++ b/source/common/engine/serializer_internal.h @@ -226,15 +226,44 @@ struct FReader //========================================================================== template -FSerializer &SerializePointer(FSerializer &arc, const char *key, T *&value, T **defval, T *base) +FSerializer &SerializePointer(FSerializer &arc, const char *key, T *&value, T **defval, T *base, const int64_t count) { assert(base != nullptr); + assert(count > 0); if (arc.isReading() || !arc.w->inObject() || defval == nullptr || value != *defval) { - int64_t vv = value == nullptr ? -1 : value - base; + int64_t vv = -1; + if (value != nullptr) + { + vv = value - base; + if (vv < 0 || vv >= count) + { + Printf("Trying to serialize out-of-bounds array value with key '%s', index = %lli, size = %lli\n", key, vv, count); + vv = -1; + } + } Serialize(arc, key, vv, nullptr); - value = vv < 0 ? nullptr : base + vv; + if (vv == -1) + value = nullptr; + else if (vv < 0 || vv >= count) + { + Printf("Trying to serialize out-of-bounds array value with key '%s', index = %lli, size = %lli\n", key, vv, count); + value = nullptr; + } + else + value = base + vv; } return arc; } +template +FSerializer &SerializePointer(FSerializer &arc, const char *key, T *&value, T **defval, TArray &array) +{ + if (array.Size() == 0) + { + Printf("Trying to serialize a value with key '%s' from empty array\n", key); + return arc; + } + return SerializePointer(arc, key, value, defval, array.Data(), array.Size()); +} + diff --git a/source/common/engine/stats.h b/source/common/engine/stats.h index 6734bfe72..563fc9529 100644 --- a/source/common/engine/stats.h +++ b/source/common/engine/stats.h @@ -132,6 +132,9 @@ inline uint64_t rdtsc() } while (upper != temp); return (static_cast(upper) << 32) | lower; +#elif defined __aarch64__ + // TODO: Implement and test on ARM64 + return 0; #else // i386 if (CPU.bRDTSC) { diff --git a/source/common/engine/stringtable.cpp b/source/common/engine/stringtable.cpp index ab1570d39..8927011dc 100644 --- a/source/common/engine/stringtable.cpp +++ b/source/common/engine/stringtable.cpp @@ -93,10 +93,6 @@ TArray> FStringTable::parseCSV(const TArray &buffer) for (size_t i = 0; i < bufLength; ++i) { - if (buffer[i] == '#') - { - int a = 0; - } if (buffer[i] == '"') { // Double quotes inside a quoted string count as an escaped quotation mark. @@ -454,7 +450,7 @@ void FStringTable::InsertString(int lumpnum, int langid, FName label, const FStr auto replace = allMacros.CheckKey(lookupname); for (int i = 0; i < 4; i++) { - const char *replacement = replace ? replace->Replacements[i].GetChars() : ""; + const char *replacement = replace? replace->Replacements[i].GetChars() : ""; te.strings[i].Substitute(replacee, replacement); } }