From 561b703475582cb1680d09f65ea50e596186a3a4 Mon Sep 17 00:00:00 2001 From: Dillon Skaggs Date: Fri, 1 Nov 2024 10:33:33 -0500 Subject: [PATCH] fix(state/train): make sure to call the function on engine train - this fixes a previous oversight when updating the implementation that removed the original call to the train engine, this was already done before for train migration --- .../citizen-server-impl/src/state/ServerGameState.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/code/components/citizen-server-impl/src/state/ServerGameState.cpp b/code/components/citizen-server-impl/src/state/ServerGameState.cpp index c894736b00..a025aba567 100644 --- a/code/components/citizen-server-impl/src/state/ServerGameState.cpp +++ b/code/components/citizen-server-impl/src/state/ServerGameState.cpp @@ -2657,11 +2657,18 @@ void ServerGameState::IterateTrainLink(const sync::SyncEntityPtr& initialTrain, { auto recurseTrain = [=](const fx::sync::SyncEntityPtr& train) { + // make sure we call for the train if its not the initial train, this should only ever happen of + // the function this is called on is a carriage instead of the train engine + if (train->handle != initialTrain->handle) + { + fn(const_cast(train)); + } for (auto link = GetNextTrain(this, train); link; link = GetNextTrain(this, link)) { // IterateTrainLink is expected to make sure that the initial train & the link trains are not called twice // since this could lead to double locking the client mutex in ReassignEntity - if (link->handle == initialTrain->handle) + // we also ignore the train sent via the call to `recurseTrain` as we should've called `fn` before here + if (link->handle == initialTrain->handle || link->handle == train->handle) { continue; }