Skip to content

Commit

Permalink
fix(state/train): make sure to call the function on engine train
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
AvarianKnight committed Nov 1, 2024
1 parent 990f4dd commit 561b703
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<sync::SyncEntityPtr&>(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;
}
Expand Down

0 comments on commit 561b703

Please sign in to comment.