From 7fa308158127b1c359eb5d19d336f4361c20744f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 6 Feb 2019 10:44:30 +0100 Subject: [PATCH 1/2] - fixed some remaining issues with the interpolator. Thanks to the lazy counter it used in its stat display I never noticed that the serializer was incomplete and that UnlinkFromMap did not call its super method. After changing the counter to be actively counting on each call, all the other issues became immediately apparent. --- src/r_data/r_interpolate.cpp | 48 ++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/src/r_data/r_interpolate.cpp b/src/r_data/r_interpolate.cpp index aec62630c3..6517eb2830 100644 --- a/src/r_data/r_interpolate.cpp +++ b/src/r_data/r_interpolate.cpp @@ -180,6 +180,11 @@ IMPLEMENT_CLASS(DPolyobjInterpolation, false, false) int FInterpolator::CountInterpolations () { + int count = 0; + for (DInterpolation *probe = Head; probe != nullptr; probe = probe->Next) + { + count++; + } return count; } @@ -191,7 +196,7 @@ int FInterpolator::CountInterpolations () void FInterpolator::UpdateInterpolations() { - for (DInterpolation *probe = Head; probe != NULL; probe = probe->Next) + for (DInterpolation *probe = Head; probe != nullptr; probe = probe->Next) { probe->UpdateInterpolation (); } @@ -206,10 +211,9 @@ void FInterpolator::UpdateInterpolations() void FInterpolator::AddInterpolation(DInterpolation *interp) { interp->Next = Head; - if (Head != NULL) Head->Prev = interp; + if (Head != nullptr) Head->Prev = interp; interp->Prev = nullptr; Head = interp; - count++; } //========================================================================== @@ -227,12 +231,11 @@ void FInterpolator::RemoveInterpolation(DInterpolation *interp) } else { - if (interp->Prev != NULL) interp->Prev->Next = interp->Next; - if (interp->Next != NULL) interp->Next->Prev = interp->Prev; + if (interp->Prev != nullptr) interp->Prev->Next = interp->Next; + if (interp->Next != nullptr) interp->Next->Prev = interp->Prev; } - interp->Next = nullptr; - interp->Prev = nullptr; - count--; + interp->Next = nullptr; + interp->Prev = nullptr; } //========================================================================== @@ -252,7 +255,7 @@ void FInterpolator::DoInterpolations(double smoothratio) didInterp = true; DInterpolation *probe = Head; - while (probe != NULL) + while (probe != nullptr) { DInterpolation *next = probe->Next; probe->Interpolate(smoothratio); @@ -271,7 +274,7 @@ void FInterpolator::RestoreInterpolations() if (didInterp) { didInterp = false; - for (DInterpolation *probe = Head; probe != NULL; probe = probe->Next) + for (DInterpolation *probe = Head; probe != nullptr; probe = probe->Next) { probe->Restore(); } @@ -297,6 +300,7 @@ void FInterpolator::ClearInterpolations() probe->Destroy(); probe = next; } + } FSerializer &Serialize(FSerializer &arc, const char *key, FInterpolator &rs, FInterpolator *def) @@ -304,7 +308,6 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FInterpolator &rs, FIn if (arc.BeginObject(key)) { arc("head", rs.Head) - ("count", rs.count) .EndObject(); } return arc; @@ -365,8 +368,10 @@ void DInterpolation::UnlinkFromMap() void DInterpolation::Serialize(FSerializer &arc) { Super::Serialize(arc); - arc("refcount", refcount); - arc("level", Level); + arc("refcount", refcount) + ("next", Next) + ("prev", Prev) + ("level", Level); } //========================================================================== @@ -421,6 +426,7 @@ void DSectorPlaneInterpolation::UnlinkFromMap() attached[i]->DelRef(); } attached.Reset(); + Super::UnlinkFromMap(); } //========================================================================== @@ -492,6 +498,7 @@ void DSectorPlaneInterpolation::Interpolate(double smoothratio) if (refcount == 0 && oldheight == bakheight) { + UnlinkFromMap(); Destroy(); } else @@ -576,6 +583,7 @@ void DSectorScrollInterpolation::UnlinkFromMap() } sector = nullptr; } + Super::UnlinkFromMap(); } //========================================================================== @@ -675,6 +683,7 @@ void DWallScrollInterpolation::UnlinkFromMap() side->textures[part].interpolation = nullptr; side = nullptr; } + Super::UnlinkFromMap(); } //========================================================================== @@ -773,6 +782,7 @@ void DPolyobjInterpolation::UnlinkFromMap() { poly->interpolation = nullptr; } + Super::UnlinkFromMap(); } //========================================================================== @@ -872,7 +882,7 @@ void DPolyobjInterpolation::Serialize(FSerializer &arc) DInterpolation *side_t::SetInterpolation(int position) { - if (textures[position].interpolation == NULL) + if (textures[position].interpolation == nullptr) { textures[position].interpolation = Create(this, position); } @@ -889,7 +899,7 @@ DInterpolation *side_t::SetInterpolation(int position) void side_t::StopInterpolation(int position) { - if (textures[position].interpolation != NULL) + if (textures[position].interpolation != nullptr) { textures[position].interpolation->DelRef(); } @@ -903,7 +913,7 @@ void side_t::StopInterpolation(int position) DInterpolation *sector_t::SetInterpolation(int position, bool attach) { - if (interpolations[position] == NULL) + if (interpolations[position] == nullptr) { DInterpolation *interp; switch (position) @@ -925,7 +935,7 @@ DInterpolation *sector_t::SetInterpolation(int position, bool attach) break; default: - return NULL; + return nullptr; } interpolations[position] = interp; } @@ -942,7 +952,7 @@ DInterpolation *sector_t::SetInterpolation(int position, bool attach) DInterpolation *FPolyObj::SetInterpolation() { - if (interpolation != NULL) + if (interpolation != nullptr) { interpolation->AddRef(); } @@ -963,7 +973,7 @@ DInterpolation *FPolyObj::SetInterpolation() void FPolyObj::StopInterpolation() { - if (interpolation != NULL) + if (interpolation != nullptr) { interpolation->DelRef(); } From 37a79470de53c3fc33340936bf62db45622a4e99 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 6 Feb 2019 12:22:05 +0200 Subject: [PATCH 2/2] - fixed compilation on POSIX targets src/p_acs.cpp:3250:75: error: cannot pass object of non-trivial type 'FString' through variadic constructor; call will abort at runtime [-Wnon-pod-varargs] src/p_conversation.cpp:354:56: error: cannot pass object of non-trivial type 'FString' through variadic constructor; call will abort at runtime [-Wnon-pod-varargs] src/p_conversation.cpp:438:51: error: cannot pass object of non-trivial type 'FString' through variadic constructor; call will abort at runtime [-Wnon-pod-varargs] src/p_conversation.cpp:548:58: error: cannot pass object of non-trivial type 'FString' through variadic constructor; call will abort at runtime [-Wnon-pod-varargs] src/p_conversation.cpp:572:59: error: cannot pass object of non-trivial type 'FString' through variadic constructor; call will abort at runtime [-Wnon-pod-varargs] src/p_conversation.cpp:584:58: error: cannot pass object of non-trivial type 'FString' through variadic constructor; call will abort at runtime [-Wnon-pod-varargs] --- src/p_acs.cpp | 2 +- src/p_conversation.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 40e38c690a..f33c35ed95 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -3247,7 +3247,7 @@ const char *FBehavior::LookupString (uint32_t index, bool forprint) const token.Substitute(" ", ""); token.Truncate(5); - FStringf label("TXT_ACS_%s_%d_%.5s", Level->MapName.GetChars(), index, token); + FStringf label("TXT_ACS_%s_%d_%.5s", Level->MapName.GetChars(), index, token.GetChars()); auto p = GStrings[label]; if (p) return p; } diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index 6ae26d308f..cd6b7b803a 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -351,7 +351,7 @@ static FStrifeDialogueNode *ReadRetailNode (FLevelLocals *Level, const char *nam if (name) { - FStringf label("$TXT_DLG_%s_d%d_%s", name, int(pos), TokenFromString(speech.Dialogue)); + FStringf label("$TXT_DLG_%s_d%d_%s", name, int(pos), TokenFromString(speech.Dialogue).GetChars()); node->Dialogue = label; } else @@ -435,7 +435,7 @@ static FStrifeDialogueNode *ReadTeaserNode (FLevelLocals *Level, const char *nam // Convert the rest of the data to our own internal format. if (name) { - FStringf label("$TXT_DLG_%s_d%d_%s", name, pos, TokenFromString(speech.Dialogue)); + FStringf label("$TXT_DLG_%s_d%d_%s", name, pos, TokenFromString(speech.Dialogue).GetChars()); node->Dialogue = label; } else @@ -545,7 +545,7 @@ static void ParseReplies (const char *name, int pos, FStrifeDialogueReply **repl if (name) { - FStringf label("$TXT_RPLY%d_%s_d%d_%s", j, name, pos, TokenFromString(rsp->Reply)); + FStringf label("$TXT_RPLY%d_%s_d%d_%s", j, name, pos, TokenFromString(rsp->Reply).GetChars()); reply->Reply = label; } else @@ -569,7 +569,7 @@ static void ParseReplies (const char *name, int pos, FStrifeDialogueReply **repl { if (name) { - FStringf label("$TXT_RYES%d_%s_d%d_%s", j, name, pos, TokenFromString(rsp->Yes)); + FStringf label("$TXT_RYES%d_%s_d%d_%s", j, name, pos, TokenFromString(rsp->Yes).GetChars()); reply->QuickYes = label; } else @@ -581,7 +581,7 @@ static void ParseReplies (const char *name, int pos, FStrifeDialogueReply **repl { if (name && strncmp(rsp->No, "NO. ", 4)) // All 'no' nodes starting with 'NO.' won't ever be shown and they all contain broken text. { - FStringf label("$TXT_RNO%d_%s_d%d_%s", j, name, pos, TokenFromString(rsp->No)); + FStringf label("$TXT_RNO%d_%s_d%d_%s", j, name, pos, TokenFromString(rsp->No).GetChars()); reply->QuickNo = label; } else