From b74690da0d814e204dc8618d324dd7ab3c56ba20 Mon Sep 17 00:00:00 2001 From: howsohazard <143410553+howsohazard@users.noreply.github.com> Date: Fri, 10 May 2024 18:16:25 -0400 Subject: [PATCH] 20271: Fixes bugs when storing entities with many contained entities (#130) --- src/Amalgam/entity/Entity.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Amalgam/entity/Entity.h b/src/Amalgam/entity/Entity.h index 79b74272..51f72d3b 100644 --- a/src/Amalgam/entity/Entity.h +++ b/src/Amalgam/entity/Entity.h @@ -484,9 +484,29 @@ class Entity : bufferReference(&buffer) { } + inline EntityReferenceBufferReference(EntityReferenceBufferReference &&erbr) + { + bufferReference = erbr.bufferReference; + erbr.bufferReference = nullptr; + } + inline ~EntityReferenceBufferReference() { - bufferReference->clear(); + if(bufferReference != nullptr) + bufferReference->clear(); + } + + inline EntityReferenceBufferReference &operator=(EntityReferenceBufferReference &&erbr) + { + if(this != &erbr) + { + if(bufferReference != nullptr) + bufferReference->clear(); + + bufferReference = erbr.bufferReference; + erbr.bufferReference = nullptr; + } + return *this; } constexpr operator std::vector *()