Infrastruttura: nome «Rail Enterprise», CI e rilasci su Gitea, documentazione
Il progetto adotta il nome «Rail Enterprise» ovunque (codice RailEnterprise.*, variabili RE_*, intestazioni RESV/RECL, immagine rail-enterprise-server) per allinearsi al repository Gitea. Aggiunge Gitea Actions sul modello di Chronos: CI su PR e main, rilascio da tag con gioco Windows (client Godot + server in server/), server Windows/Linux e immagine Docker nel registro Gitea, nightly. Aggiunge i riferimenti visivi 06–09, i modelli di PR e issue, l'ADR 0014 e aggiorna README (comandi locali), STATE e CLAUDE.md. 120 test verdi. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f6c2a17b4d
commit
c1a0049bcf
300 files changed
+1602
-1045
No files matched your search
@@ -0,0 +1,262 @@
|
||||
using RailEnterprise.Core.Commands;
|
||||
|
||||
namespace RailEnterprise.Protocol.Messages;
|
||||
|
||||
/// <summary>Apertura della sessione: versione, token, sessione da riprendere (0 = nuova) e hash dei dati del client.</summary>
|
||||
public sealed class Hello : IMessage
|
||||
{
|
||||
public MessageId Id => MessageId.Hello;
|
||||
public ushort ProtocolVersion { get; init; } = Frame.ProtocolVersion;
|
||||
public string ClientVersion { get; init; } = "";
|
||||
public string Token { get; init; } = "";
|
||||
public ulong ResumeSessionId { get; init; }
|
||||
/// <summary>Hash dei dati del client (0 = non verificare).</summary>
|
||||
public ulong DataHash { get; init; }
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.U16(ProtocolVersion);
|
||||
w.String(ClientVersion);
|
||||
w.String(Token);
|
||||
w.U64(ResumeSessionId);
|
||||
w.U64(DataHash);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static Hello Read(ref SpanReader r)
|
||||
{
|
||||
var m = new Hello { ProtocolVersion = r.U16(), ClientVersion = r.String(), Token = r.String(), ResumeSessionId = r.U64(), DataHash = r.U64() };
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class Ping : IMessage
|
||||
{
|
||||
public MessageId Id => MessageId.Ping;
|
||||
public ulong Nonce { get; init; }
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.U64(Nonce);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static Ping Read(ref SpanReader r)
|
||||
{
|
||||
var m = new Ping { Nonce = r.U64() };
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Area di interesse in celle (estremi inclusi) e livello di dettaglio (0 pieno, 1 medio, 2 lontano).</summary>
|
||||
public sealed class Subscribe : IMessage
|
||||
{
|
||||
public MessageId Id => MessageId.Subscribe;
|
||||
public int X0 { get; init; }
|
||||
public int Y0 { get; init; }
|
||||
public int X1 { get; init; }
|
||||
public int Y1 { get; init; }
|
||||
public byte Lod { get; init; }
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.I32(X0);
|
||||
w.I32(Y0);
|
||||
w.I32(X1);
|
||||
w.I32(Y1);
|
||||
w.U8(Lod);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static Subscribe Read(ref SpanReader r)
|
||||
{
|
||||
var m = new Subscribe { X0 = r.I32(), Y0 = r.I32(), X1 = r.I32(), Y1 = r.I32(), Lod = r.U8() };
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Comando di gioco con il numero di sequenza del client; il payload segue <see cref="CommandCodec"/>.</summary>
|
||||
public sealed class CommandMessage : IMessage
|
||||
{
|
||||
public MessageId Id => MessageId.Command;
|
||||
public uint Seq { get; init; }
|
||||
public required GameCommand Command { get; init; }
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.U32(Seq);
|
||||
w.U16((ushort)Command.Type);
|
||||
// payload con lunghezza: un lettore vecchio può saltarlo anche se il comando cresce
|
||||
var inner = new SpanWriter(64);
|
||||
CommandCodec.Write(ref inner, Command);
|
||||
w.Bytes(inner.Written);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static CommandMessage Read(ref SpanReader r)
|
||||
{
|
||||
uint seq = r.U32();
|
||||
var type = (CommandType)r.U16();
|
||||
byte[] payload = r.Bytes();
|
||||
var inner = new SpanReader(payload);
|
||||
var command = CommandCodec.Read(type, ref inner) with { Seq = seq };
|
||||
r.Flags();
|
||||
return new CommandMessage { Seq = seq, Command = command };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Velocità della simulazione: 0 (pausa), 1, 2, 4, 8.</summary>
|
||||
public sealed class SetSpeed : IMessage
|
||||
{
|
||||
public MessageId Id => MessageId.SetSpeed;
|
||||
public byte Speed { get; init; }
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.U8(Speed);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static SetSpeed Read(ref SpanReader r)
|
||||
{
|
||||
var m = new SetSpeed { Speed = r.U8() };
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ListSaves : IMessage
|
||||
{
|
||||
public MessageId Id => MessageId.ListSaves;
|
||||
|
||||
public void Write(ref SpanWriter w) => w.Flags(0);
|
||||
|
||||
public static ListSaves Read(ref SpanReader r)
|
||||
{
|
||||
r.Flags();
|
||||
return new ListSaves();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class Save : IMessage
|
||||
{
|
||||
public MessageId Id => MessageId.Save;
|
||||
public string Name { get; init; } = "";
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.String(Name);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static Save Read(ref SpanReader r)
|
||||
{
|
||||
var m = new Save { Name = r.String() };
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class Load : IMessage
|
||||
{
|
||||
public MessageId Id => MessageId.Load;
|
||||
public string SaveId { get; init; } = "";
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.String(SaveId);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static Load Read(ref SpanReader r)
|
||||
{
|
||||
var m = new Load { SaveId = r.String() };
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Nuova partita: seme, lato della mappa (km), anno d'inizio (0 = predefinito), difficoltà, ritocchi e opzioni del gioco infinito.</summary>
|
||||
public sealed class NewGame : IMessage
|
||||
{
|
||||
public MessageId Id => MessageId.NewGame;
|
||||
public ulong Seed { get; init; }
|
||||
public int SizeKm { get; init; }
|
||||
public int StartYear { get; init; }
|
||||
public string DifficultyPreset { get; init; } = "";
|
||||
/// <summary>Ritocchi della difficoltà «Personalizzata»: nome del campo (camelCase) e valore.</summary>
|
||||
public List<(string Key, double Value)> Overrides { get; init; } = [];
|
||||
public uint EndlessFlags { get; init; }
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.U64(Seed);
|
||||
w.I32(SizeKm);
|
||||
w.I32(StartYear);
|
||||
w.String(DifficultyPreset);
|
||||
w.Count(Overrides.Count);
|
||||
foreach (var (key, value) in Overrides)
|
||||
{
|
||||
w.String(key);
|
||||
w.F64(value);
|
||||
}
|
||||
w.U32(EndlessFlags);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static NewGame Read(ref SpanReader r)
|
||||
{
|
||||
ulong seed = r.U64();
|
||||
int size = r.I32();
|
||||
int year = r.I32();
|
||||
string preset = r.String();
|
||||
int n = r.Count();
|
||||
var overrides = new List<(string, double)>(n);
|
||||
for (int i = 0; i < n; i++) overrides.Add((r.String(), r.F64()));
|
||||
var m = new NewGame { Seed = seed, SizeKm = size, StartYear = year, DifficultyPreset = preset, Overrides = overrides, EndlessFlags = r.U32() };
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Dettaglio richiesto dal client (F4).</summary>
|
||||
public enum DetailKind : byte
|
||||
{
|
||||
/// <summary>Cartella di manutenzione di un treno (risposta MaintenanceCard).</summary>
|
||||
TrainCard = 1,
|
||||
/// <summary>Registro officina di un deposito (risposta WorkshopRegister).</summary>
|
||||
Workshop = 2,
|
||||
/// <summary>Registro degli impieghi della compagnia (risposta EmploymentReport; Id ignorato).</summary>
|
||||
Employment = 3,
|
||||
/// <summary>Scheda di una compagnia (risposta CompanyCard, F5).</summary>
|
||||
Company = 4,
|
||||
/// <summary>Scheda del proprietario di un'industria (risposta IndustryCard, F5).</summary>
|
||||
Industry = 5,
|
||||
/// <summary>Cronaca finale (risposta Chronicle, F5; Id ignorato).</summary>
|
||||
Chronicle = 6,
|
||||
}
|
||||
|
||||
/// <summary>Chiede al server un dettaglio che non viaggia con le entità (aggiunto in F4).</summary>
|
||||
public sealed class RequestDetail : IMessage
|
||||
{
|
||||
public MessageId Id => MessageId.RequestDetail;
|
||||
public DetailKind Kind { get; init; }
|
||||
public int Target { get; init; }
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.U8((byte)Kind);
|
||||
w.I32(Target);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static RequestDetail Read(ref SpanReader r)
|
||||
{
|
||||
var m = new RequestDetail { Kind = (DetailKind)r.U8(), Target = r.I32() };
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user