From b668aae6ccd40e76b3ba5a9ee9feb30c35ebf3ed Mon Sep 17 00:00:00 2001 From: Pasqual Koschmieder Date: Tue, 31 Dec 2024 17:20:28 +0100 Subject: [PATCH] reset foreign id when a journey is removed It can happen that a train is marked as removed but respawns later, for example if it derails right before a server restart close to the starting point. In that case the respawn is not properly recorded anymore due to the fact that the foreign id is already set. With this patch the foreign id of the journey is reset to ensure that a respawn gets recorded if one occurs. The last seen time gets removed on spawn too, as the journey wasn't really seen for the last time if it respawns. --- .../backend/collector/journey/JourneyDirtyStateRecorder.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/info-collector/src/main/java/tools/simrail/backend/collector/journey/JourneyDirtyStateRecorder.java b/info-collector/src/main/java/tools/simrail/backend/collector/journey/JourneyDirtyStateRecorder.java index 33d9a4a..c8be5a6 100644 --- a/info-collector/src/main/java/tools/simrail/backend/collector/journey/JourneyDirtyStateRecorder.java +++ b/info-collector/src/main/java/tools/simrail/backend/collector/journey/JourneyDirtyStateRecorder.java @@ -189,6 +189,7 @@ public boolean isDirty() { if (this.removed) { this.original.setSpeed(null); this.original.setPosition(null); + this.original.setForeignId(null); this.original.setNextSignal(null); this.original.setDriverSteamId(null); this.original.setLastSeenTime(OffsetDateTime.now(this.server.timezoneOffset())); @@ -199,6 +200,7 @@ public boolean isDirty() { if (this.foreignId != null) { this.original.setForeignId(this.foreignId.value()); this.original.setFirstSeenTime(OffsetDateTime.now(this.server.timezoneOffset())); + this.original.setLastSeenTime(null); } if (this.speed != null) { this.original.setSpeed(this.speed.value());