- Backend update from Raze.

This is mainly code cleanup from setting the compiler to a stricter warning level.
This commit is contained in:
Christoph Oelckers 2021-12-29 10:25:31 +01:00
commit 1c517d19fa
102 changed files with 493 additions and 590 deletions

View file

@ -736,7 +736,7 @@ bool HostGame (int i)
{
// If we send the packets eight times to each guest,
// hopefully at least one of them will get through.
for (int i = 8; i != 0; --i)
for (int ii = 8; ii != 0; --ii)
{
PreSend (&packet, 2, &sendaddress[node]);
}

View file

@ -234,7 +234,7 @@ void PaletteContainer::UpdateTranslation(int trans, FRemapTable* remap)
int PaletteContainer::AddTranslation(int slot, FRemapTable* remap, int count)
{
uint32_t id;
uint32_t id = 0;
for (int i = 0; i < count; i++)
{
auto newremap = AddRemap(&remap[i]);
@ -265,7 +265,7 @@ FRemapTable *PaletteContainer::TranslationToTable(int translation)
unsigned int type = GetTranslationType(translation);
unsigned int index = GetTranslationIndex(translation);
if (type < 0 || type >= TranslationTables.Size() || index >= NumTranslations(type))
if (type >= TranslationTables.Size() || index >= NumTranslations(type))
{
return uniqueRemaps[0]; // this is the identity table.
}
@ -649,7 +649,6 @@ bool FRemapTable::AddTint(int start, int end, int r, int g, int b, int amount)
bool FRemapTable::AddToTranslation(const char *range)
{
int start,end;
bool desaturated = false;
FScanner sc;
sc.OpenMem("translation", range, int(strlen(range)));

View file

@ -1131,9 +1131,7 @@ FString FScanner::TokenName (int token, const char *string)
}
else
{
FString work;
work.Format ("Unknown(%d)", token);
return work;
work.Format("Unknown(%d)", token);
}
return work;
}

View file

@ -290,6 +290,28 @@ bool FSerializer::BeginObject(const char *name)
//
//==========================================================================
bool FSerializer::HasObject(const char* name)
{
if (isReading())
{
auto val = r->FindKey(name);
if (val != nullptr)
{
if (val->IsObject())
{
return true;
}
}
}
return false;
}
//==========================================================================
//
//
//
//==========================================================================
void FSerializer::EndObject()
{
if (isWriting())
@ -619,7 +641,6 @@ void FSerializer::ReadObjects(bool hubtravel)
if (BeginObject(nullptr))
{
FString clsname; // do not deserialize the class type directly so that we can print appropriate errors.
int pindex = -1;
Serialize(*this, "classtype", clsname, nullptr);
PClass *cls = PClass::FindClass(clsname);
@ -643,6 +664,7 @@ void FSerializer::ReadObjects(bool hubtravel)
if (!founderrors)
{
// Reset to start;
unsigned size = r->mObjects.Size();
r->mObjects.Last().mIndex = 0;
for (unsigned i = 0; i < r->mDObjects.Size(); i++)
@ -652,7 +674,6 @@ void FSerializer::ReadObjects(bool hubtravel)
{
if (obj != nullptr)
{
int pindex = -1;
try
{
obj->SerializeUserVars(*this);
@ -660,6 +681,7 @@ void FSerializer::ReadObjects(bool hubtravel)
}
catch (CRecoverableError &err)
{
r->mObjects.Clamp(size); // close all inner objects.
// In case something in here throws an error, let's continue and deal with it later.
Printf(TEXTCOLOR_RED "'%s'\n while restoring %s\n", err.GetMessage(), obj ? obj->GetClass()->TypeName.GetChars() : "invalid object");
mErrors++;

View file

@ -85,6 +85,7 @@ public:
void ReadObjects(bool hubtravel);
bool BeginObject(const char *name);
void EndObject();
bool HasObject(const char* name);
bool BeginArray(const char *name);
void EndArray();
unsigned GetSize(const char *group);
@ -234,7 +235,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FSoundID &sid, FSoundI
FSerializer &Serialize(FSerializer &arc, const char *key, FString &sid, FString *def);
FSerializer &Serialize(FSerializer &arc, const char *key, NumericValue &sid, NumericValue *def);
template<class T>
template <typename T/*, typename = std::enable_if_t<std::is_base_of_v<DObject, T>>*/>
FSerializer &Serialize(FSerializer &arc, const char *key, T *&value, T **)
{
DObject *v = static_cast<DObject*>(value);
@ -301,6 +302,11 @@ FSerializer& Serialize(FSerializer& arc, const char* key, FixedBitArray<size>& v
return arc.SerializeMemory(key, value.Storage(), value.StorageSize());
}
inline FSerializer& Serialize(FSerializer& arc, const char* key, BitArray& value, BitArray* def)
{
return arc.SerializeMemory(key, value.Storage().Data(), value.Storage().Size());
}
template<> FSerializer& Serialize(FSerializer& arc, const char* key, PClass*& clst, PClass** def);
template<> FSerializer& Serialize(FSerializer& arc, const char* key, FFont*& font, FFont** def);
template<> FSerializer &Serialize(FSerializer &arc, const char *key, Dictionary *&dict, Dictionary **def);