Map sectors show again, clients get their own machines and the train's swath, machines stay out of the ground

- Map: the sectors are wound the screen's way (most were wound the other way and culled, leaving a blank chart),
  kept inside the chart, and drawn as ball, sectors and marks layers; the scale bar is no longer sized mid-draw.
- Players' save keys are replicated, so a client's garage finds its machines and their upgrades; two players under
  one key get separate ones.
- The grass train sends its mowing to the clients; moving the depot or resizing the planet relays its line.
- A hard floor under vehicle springs: hard landings, steep rises and hand-overs no longer sink a machine.
- Tests: -demosink, -demorep host|client.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NiemandKG
2026-11-12 01:33:03 +06:00
parent 86c8403c2a
commit d61167e22b
10 changed files with 474 additions and 33 deletions

View File

@ -27,6 +27,8 @@ namespace GrassCutter
new Color(0.96f, 0.96f, 0.94f),// white
};
/// <summary>The key of this player's things in the host's save, as the host settled it: everyone needs it, the garage looks up "my machine" by it.</summary>
public readonly NetworkVariable<FixedString64Bytes> SaveKey = new NetworkVariable<FixedString64Bytes>("");
public readonly NetworkVariable<FixedString64Bytes> NetName = new NetworkVariable<FixedString64Bytes>("", NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission.Owner);
public readonly NetworkVariable<ulong> SteamId = new NetworkVariable<ulong>(0, NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission.Owner);
public readonly NetworkVariable<int> ColorIndex = new NetworkVariable<int>();
@ -75,7 +77,7 @@ namespace GrassCutter
/// <summary>Gravity boots on: Earth's pull instead of Herbaria's.</summary>
public bool BootsOn { get; set; }
/// <summary>Key of this player's tools in the host's save.</summary>
public string SaveId { get; private set; }
public string SaveId => SaveKey.Value.IsEmpty ? null : SaveKey.Value.ToString();
public bool ClaimedSave => SaveId != null;
public Vehicle Vehicle => _vehicle;
@ -215,12 +217,16 @@ namespace GrassCutter
[Rpc(SendTo.Server)]
void ClaimSaveRpc(FixedString64Bytes id)
{
SaveId = id.ToString();
if (Ts && OwnerClientId != NetworkManager.ServerClientId && Ts.Banned(SaveId))
string key = id.ToString();
if (Ts && OwnerClientId != NetworkManager.ServerClientId && Ts.Banned(key))
{
NetworkManager.DisconnectClient(OwnerClientId, Loc.Pack("You are banned from this game"));
return;
}
// two players under one key (no Steam, or one account on two copies) would share one fleet and one set of
// tools: the second one gets a key of its own
if (All.Exists(p => p && p != this && p.SaveId == key)) key += "#" + OwnerClientId;
SaveKey.Value = new FixedString64Bytes(key);
if (Ts)
{
Ts.ServerRestoreCrew(this);