Skip to content

Commit

Permalink
#63. Celerity::Assembly: Fix bug where id replacement state wasn't cl…
Browse files Browse the repository at this point in the history
…eared sometimes.
  • Loading branch information
KonstantinTomashevich committed Mar 20, 2023
1 parent 48c562f commit bbe58cd
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,14 @@ AssemblyExecutionResult Assembler::AssembleObject (PrototypeAssemblyComponent *_
}
};

auto clearIntermediateIdReplacement = [this] ()
{
for (auto &keyState : keyStates)
{
keyState.idReplacement.clear ();
}
};

const bool immediate = (isFixed ? _assembly->fixedAssemblyState : _assembly->normalAssemblyState) ==
AssemblyState::IN_NEED_OF_IMMEDIATE_ASSEMBLY;
GetObjectIdKeyState ().idReplacement.emplace (ASSEMBLY_ROOT_OBJECT_ID, _assembly->objectId);
Expand Down Expand Up @@ -400,6 +408,7 @@ AssemblyExecutionResult Assembler::AssembleObject (PrototypeAssemblyComponent *_
if (index < descriptor->components.size ())
{
saveIntermediateIdReplacement ();
clearIntermediateIdReplacement ();
return AssemblyExecutionResult::OUT_OF_TIME;
}

Expand All @@ -416,11 +425,8 @@ AssemblyExecutionResult Assembler::AssembleObject (PrototypeAssemblyComponent *_
}

(isFixed ? _assembly->fixedAssemblyState : _assembly->normalAssemblyState) = AssemblyState::ASSEMBLED;
for (auto &keyState : keyStates)
{
keyState.idReplacement.clear ();
}

clearIntermediateIdReplacement ();

auto eventCursor = insertFinishedEvent.Execute ();
void *event = ++eventCursor;
*static_cast<UniqueId *> (event) = _assembly->objectId;
Expand Down

0 comments on commit bbe58cd

Please sign in to comment.