Skip to content

Commit

Permalink
reset foreign id when a journey is removed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
derklaro committed Dec 31, 2024
1 parent 2486cb0 commit b668aae
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand All @@ -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());
Expand Down

0 comments on commit b668aae

Please sign in to comment.