From 2ce34524c4ed6c551370be981f4b893374939381 Mon Sep 17 00:00:00 2001 From: Silent Date: Mon, 14 Oct 2024 21:35:03 +0200 Subject: [PATCH] Don't use std::forward on a variable multiple times The previous usage was just wrong, it may have been subtly broken. --- SilentPatch/RWUtils.hpp | 24 ++++++++++++------------ SilentPatch/Utils | 2 +- SilentPatchSA/VehicleSA.cpp | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/SilentPatch/RWUtils.hpp b/SilentPatch/RWUtils.hpp index 5b8344d..abe0653 100644 --- a/SilentPatch/RWUtils.hpp +++ b/SilentPatch/RWUtils.hpp @@ -26,46 +26,46 @@ private: }; template -Pred RwFrameForAllChildren(RwFrame* frame, Pred&& callback) +Pred RwFrameForAllChildren(RwFrame* frame, Pred callback) { for ( RwFrame* curFrame = frame->child; curFrame != nullptr; curFrame = curFrame->next ) { - if ( std::forward(callback)(curFrame) == nullptr ) + if ( callback(curFrame) == nullptr ) break; } - return std::forward(callback); + return callback; } template -Pred RwFrameForAllObjects(RwFrame* frame, Pred&& callback) +Pred RwFrameForAllObjects(RwFrame* frame, Pred callback) { for ( RwLLLink* link = rwLinkListGetFirstLLLink(&frame->objectList); link != rwLinkListGetTerminator(&frame->objectList); link = rwLLLinkGetNext(link) ) { - if ( std::forward(callback)(&rwLLLinkGetData(link, RwObjectHasFrame, lFrame)->object) == nullptr ) + if ( callback(&rwLLLinkGetData(link, RwObjectHasFrame, lFrame)->object) == nullptr ) break; } - return std::forward(callback); + return callback; } template -Pred RpClumpForAllAtomics(RpClump* clump, Pred&& callback) +Pred RpClumpForAllAtomics(RpClump* clump, Pred callback) { for ( RwLLLink* link = rwLinkListGetFirstLLLink(&clump->atomicList); link != rwLinkListGetTerminator(&clump->atomicList); link = rwLLLinkGetNext(link) ) { - if ( std::forward(callback)(rwLLLinkGetData(link, RpAtomic, inClumpLink)) == nullptr ) + if ( callback(rwLLLinkGetData(link, RpAtomic, inClumpLink)) == nullptr ) break; } - return std::forward(callback); + return callback; } template -Pred RpGeometryForAllMaterials(RpGeometry* geometry, Pred&& callback) +Pred RpGeometryForAllMaterials(RpGeometry* geometry, Pred callback) { for ( RwInt32 i = 0, j = geometry->matList.numMaterials; i < j; i++ ) { - if ( std::forward(callback)(geometry->matList.materials[i]) == nullptr ) + if ( callback(geometry->matList.materials[i]) == nullptr ) break; } - return std::forward(callback); + return callback; } \ No newline at end of file diff --git a/SilentPatch/Utils b/SilentPatch/Utils index cc5c9df..d70ae68 160000 --- a/SilentPatch/Utils +++ b/SilentPatch/Utils @@ -1 +1 @@ -Subproject commit cc5c9df5895e7c0ca0dc087a716f4782635ddcfe +Subproject commit d70ae68a8e20c4cbd43f60e45586ce65304c1741 diff --git a/SilentPatchSA/VehicleSA.cpp b/SilentPatchSA/VehicleSA.cpp index 1ab5632..cc3bc10 100644 --- a/SilentPatchSA/VehicleSA.cpp +++ b/SilentPatchSA/VehicleSA.cpp @@ -159,7 +159,7 @@ RwFrame* GetFrameFromName( RwFrame* topFrame, const char* name ) foundFrame = frame; return nullptr; } - RwFrameForAllChildren( frame, std::forward(*this) ); + RwFrameForAllChildren(frame, std::ref(*this)); return foundFrame != nullptr ? nullptr : frame; } @@ -189,7 +189,7 @@ RwFrame* GetFrameFromID( RwFrame* topFrame, int32_t ID ) foundFrame = frame; return nullptr; } - RwFrameForAllChildren( frame, std::forward(*this) ); + RwFrameForAllChildren(frame, std::ref(*this)); return foundFrame != nullptr ? nullptr : frame; }