Passenger: player colliders off while riding (they pushed seats/parts out, physics crashed); last position: not overwritten by the save's start point, invalid positions ignored, saved when a player leaves

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-27 09:51:37 +02:00
co-authored by Claude Opus 5.5
parent 4d58b776cd
commit ba396146f2
3 changed files with 38 additions and 6 deletions
+11 -1
View File
@@ -30,6 +30,12 @@ public sealed class GameServer
/// <summary>SteamID von Steam bestätigt (Ticket per Web API geprüft). Nur dann gibt es Admin-Rechte.</summary>
public bool SteamVerified;
public bool IsAdmin;
/// <summary>
/// Ab wann die Position des Spielers gespeichert wird: erst nachdem er seinen Weltzustand (mit seiner letzten
/// Position) bekommen und sich dorthin gesetzt hat - sonst überschreibt der Startpunkt des Spielstands
/// (Toilette) die gespeicherte Position, bevor er sie zurückbekommt.
/// </summary>
public DateTime TrackPositionFrom = DateTime.MaxValue;
public Task<string> Verification;
}
@@ -181,6 +187,7 @@ public sealed class GameServer
Log($"{c.Name} left ({c.Conn.CloseReason})");
Broadcast(MsgType.PlayerLeft, Wire.Build(w => w.Write(c.Id)));
HeartbeatSoon();
if (world.Dirty) SaveWorld(); // letzte Position gleich sichern, nicht erst beim nächsten Autosave
}
}
@@ -268,6 +275,7 @@ public sealed class GameServer
case MsgType.Ready:
if (c.State != ClientState.Joined) return;
c.TrackPositionFrom = DateTime.UtcNow.AddSeconds(8);
c.Conn.Send(MsgType.WorldSnapshot, world.BuildSnapshot(c.SteamId));
// Letzter Stand von Uhrzeit und Wetter, damit der Neue nicht bis zum nächsten Update warten muss
if (lastWorldTime != null) c.Conn.Send(MsgType.WorldTime, Wire.WithSender(ServerId, lastWorldTime));
@@ -325,7 +333,9 @@ public sealed class GameServer
case MsgType.ObjStates: world.ApplyObjStates(m.Payload); break;
case MsgType.ObjRelease: world.ApplyObjRelease(m.Payload); break;
case MsgType.FsmEvent: world.AddFsmEvent(m.Payload); break;
case MsgType.Player: world.ApplyPlayer(c.SteamId, m.Payload); break;
case MsgType.Player:
if (DateTime.UtcNow >= c.TrackPositionFrom) world.ApplyPlayer(c.SteamId, m.Payload);
break;
case MsgType.MoneyDelta: world.ApplyMoney(m.Payload); break;
case MsgType.DoorState: world.ApplyDoor(m.Payload); break;
case MsgType.VarSync: world.ApplyVars(m.Payload); break;