Merge remote-tracking branch 'origin/main' into claude/f6-pannelli
# Conflicts: # client/RailEnterprise.Client/assets/i18n/strings.csv # client/RailEnterprise.Client/scripts/Main.cs # client/RailEnterprise.Client/scripts/Screens/MenuScreen.cs # docs/ARCHITECTURE.md # docs/PROTOCOL.md # docs/STATE.md # src/RailEnterprise.Protocol/Client/ClientWorld.cs
This commit is contained in:
commit
767661957b
52 files changed
+4074
-91
No files matched your search
@@ -56,6 +56,9 @@ public sealed class ClientWorld(GameData data)
|
||||
/// <summary>Quadro delle finanze (F6), su richiesta: lo usa il pannello «Finanze».</summary>
|
||||
public FinanceReport? Finance { get; private set; }
|
||||
|
||||
/// <summary>Quadro del rinnovo della flotta (F6, ADR 0020), su richiesta: lo usano i pannelli Treni e Officine.</summary>
|
||||
public FleetReport? Fleet { get; private set; }
|
||||
|
||||
/// <summary>Stato del server dall'ultimo Welcome (F6, ADR 0021): versione, sistema, attività, tick, sessioni.</summary>
|
||||
public ServerInfo? Server { get; private set; }
|
||||
|
||||
@@ -154,6 +157,10 @@ public sealed class ClientWorld(GameData data)
|
||||
Finance = m;
|
||||
DetailVersion++;
|
||||
return true;
|
||||
case FleetReport m:
|
||||
Fleet = m;
|
||||
DetailVersion++;
|
||||
return true;
|
||||
case SaveList m:
|
||||
Saves = m;
|
||||
DetailVersion++;
|
||||
@@ -180,6 +187,7 @@ public sealed class ClientWorld(GameData data)
|
||||
Market = null;
|
||||
Climb = null;
|
||||
Finance = null;
|
||||
Fleet = null;
|
||||
Alerts.Clear();
|
||||
Summary = m.Summary;
|
||||
Server = m.Server;
|
||||
|
||||
@@ -47,6 +47,8 @@ public enum MessageId : ushort
|
||||
ClimbReport = 134,
|
||||
/// <summary>Quadro delle finanze: conto economico per voce, rating spiegato, prestiti, bancarotta (F6).</summary>
|
||||
FinanceReport = 135,
|
||||
/// <summary>Quadro del rinnovo della flotta: ere, veicoli superati, successori, valori (F6).</summary>
|
||||
FleetReport = 136,
|
||||
}
|
||||
|
||||
/// <summary>Messaggio del protocollo: si serializza a mano, campo per campo.</summary>
|
||||
|
||||
@@ -243,6 +243,8 @@ public enum DetailKind : byte
|
||||
Climb = 8,
|
||||
/// <summary>Quadro delle finanze (risposta FinanceReport, F6; Id ignorato).</summary>
|
||||
Finance = 9,
|
||||
/// <summary>Quadro del rinnovo della flotta (risposta FleetReport, F6, ADR 0020; Id ignorato).</summary>
|
||||
Fleet = 10,
|
||||
}
|
||||
|
||||
/// <summary>Chiede al server un dettaglio che non viaggia con le entità (aggiunto in F4).</summary>
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
using RailEnterprise.Core.Common;
|
||||
|
||||
namespace RailEnterprise.Protocol.Messages;
|
||||
|
||||
// Messaggi della fase F6: ere e obsolescenza dei veicoli (ADR 0020). Il quadro del rinnovo della flotta
|
||||
// arriva su richiesta (RequestDetail con DetailKind.Fleet) ed è calcolato dal server con FleetOutlook: il
|
||||
// client lo mostra com'è, senza calcolare età, valori, successori o modelli in produzione.
|
||||
|
||||
/// <summary>
|
||||
/// Veicolo della compagnia per il rinnovo: modello, treno o deposito, età e vita utile, condizione media
|
||||
/// (0–1), produzione, obsolescenza (anno da cui è superato, 0 se non ha successore), successore consigliato
|
||||
/// ("" se non superato o senza successore in produzione), valore di libro e di rivendita, moltiplicatore dei
|
||||
/// costi di manutenzione.
|
||||
/// </summary>
|
||||
public sealed class FleetVehicleInfo
|
||||
{
|
||||
public int Vehicle { get; init; }
|
||||
public string Type { get; init; } = "";
|
||||
public int Train { get; init; } = -1;
|
||||
public int Depot { get; init; } = -1;
|
||||
public float AgeYears { get; init; }
|
||||
public int LifeYears { get; init; }
|
||||
public float Condition { get; init; }
|
||||
public bool InProduction { get; init; }
|
||||
public bool Superseded { get; init; }
|
||||
public int SupersededYear { get; init; }
|
||||
public string Successor { get; init; } = "";
|
||||
public Money BookValue { get; init; }
|
||||
public Money Resale { get; init; }
|
||||
public float MaintenanceFactor { get; init; }
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.I32(Vehicle); w.String(Type); w.I32(Train); w.I32(Depot); w.F32(AgeYears); w.I32(LifeYears); w.F32(Condition);
|
||||
w.Bool(InProduction); w.Bool(Superseded); w.I32(SupersededYear); w.String(Successor);
|
||||
w.Money(BookValue); w.Money(Resale); w.F32(MaintenanceFactor);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static FleetVehicleInfo Read(ref SpanReader r)
|
||||
{
|
||||
var m = new FleetVehicleInfo
|
||||
{
|
||||
Vehicle = r.I32(), Type = r.String(), Train = r.I32(), Depot = r.I32(), AgeYears = r.F32(), LifeYears = r.I32(), Condition = r.F32(),
|
||||
InProduction = r.Bool(), Superseded = r.Bool(), SupersededYear = r.I32(), Successor = r.String(),
|
||||
BookValue = r.Money(), Resale = r.Money(), MaintenanceFactor = r.F32(),
|
||||
};
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modello in produzione per il catalogo d'acquisto: superato o no, anno da cui lo è (0 se non ha
|
||||
/// successore), successore consigliato, ultimo anno di produzione (0 se non previsto).
|
||||
/// </summary>
|
||||
public sealed class VehicleModelInfo
|
||||
{
|
||||
public string Type { get; init; } = "";
|
||||
public bool Superseded { get; init; }
|
||||
public int SupersededYear { get; init; }
|
||||
public string Successor { get; init; } = "";
|
||||
public int LastYear { get; init; }
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.String(Type); w.Bool(Superseded); w.I32(SupersededYear); w.String(Successor); w.I32(LastYear);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static VehicleModelInfo Read(ref SpanReader r)
|
||||
{
|
||||
var m = new VehicleModelInfo { Type = r.String(), Superseded = r.Bool(), SupersededYear = r.I32(), Successor = r.String(), LastYear = r.I32() };
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Treno con veicoli superati da rinnovare: quanti, spesa netta (successori − rivendite + lavoro), se la cassa
|
||||
/// basta al netto degli altri rinnovi prenotati e se il rinnovo è già prenotato (in viaggio o in coda all'officina).
|
||||
/// </summary>
|
||||
public sealed class RenewalTrainInfo
|
||||
{
|
||||
public int Train { get; init; }
|
||||
public int Vehicles { get; init; }
|
||||
public Money NetCost { get; init; }
|
||||
public bool Affordable { get; init; }
|
||||
public bool Booked { get; init; }
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.I32(Train); w.I32(Vehicles); w.Money(NetCost); w.Bool(Affordable); w.Bool(Booked);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static RenewalTrainInfo Read(ref SpanReader r)
|
||||
{
|
||||
var m = new RenewalTrainInfo { Train = r.I32(), Vehicles = r.I32(), NetCost = r.Money(), Affordable = r.Bool(), Booked = r.Bool() };
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Quadro del rinnovo della flotta della compagnia della sessione (F6, ADR 0020): era in corso e prossima
|
||||
/// (con l'anno; "" e 0 all'ultima), veicoli con età, obsolescenza, successore e valori, catalogo dei
|
||||
/// modelli in produzione, treni da rinnovare con l'intervento «renewal».
|
||||
/// </summary>
|
||||
public sealed class FleetReport : IMessage
|
||||
{
|
||||
public MessageId Id => MessageId.FleetReport;
|
||||
public long Day { get; init; }
|
||||
public int Company { get; init; }
|
||||
public int Year { get; init; }
|
||||
public string Era { get; init; } = "";
|
||||
public string NextEra { get; init; } = "";
|
||||
public int NextEraYear { get; init; }
|
||||
/// <summary>Id dell'intervento di rinnovo in maintenance.json (per ScheduleService).</summary>
|
||||
public string RenewalIntervention { get; init; } = "";
|
||||
public Money BookValueTotal { get; init; }
|
||||
public List<FleetVehicleInfo> Vehicles { get; init; } = [];
|
||||
public List<VehicleModelInfo> Models { get; init; } = [];
|
||||
public List<RenewalTrainInfo> Trains { get; init; } = [];
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.I64(Day); w.I32(Company); w.I32(Year); w.String(Era); w.String(NextEra); w.I32(NextEraYear); w.String(RenewalIntervention);
|
||||
w.Money(BookValueTotal);
|
||||
w.Count(Vehicles.Count);
|
||||
foreach (var v in Vehicles) v.Write(ref w);
|
||||
w.Count(Models.Count);
|
||||
foreach (var m in Models) m.Write(ref w);
|
||||
w.Count(Trains.Count);
|
||||
foreach (var t in Trains) t.Write(ref w);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static FleetReport Read(ref SpanReader r)
|
||||
{
|
||||
long day = r.I64();
|
||||
int company = r.I32(), year = r.I32();
|
||||
string era = r.String(), next = r.String();
|
||||
int nextYear = r.I32();
|
||||
string renewal = r.String();
|
||||
var book = r.Money();
|
||||
var vehicles = new List<FleetVehicleInfo>();
|
||||
for (int n = r.Count(), i = 0; i < n; i++) vehicles.Add(FleetVehicleInfo.Read(ref r));
|
||||
var models = new List<VehicleModelInfo>();
|
||||
for (int n = r.Count(), i = 0; i < n; i++) models.Add(VehicleModelInfo.Read(ref r));
|
||||
var trains = new List<RenewalTrainInfo>();
|
||||
for (int n = r.Count(), i = 0; i < n; i++) trains.Add(RenewalTrainInfo.Read(ref r));
|
||||
var m = new FleetReport
|
||||
{
|
||||
Day = day, Company = company, Year = year, Era = era, NextEra = next, NextEraYear = nextYear, RenewalIntervention = renewal,
|
||||
BookValueTotal = book, Vehicles = vehicles, Models = models, Trains = trains,
|
||||
};
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ public static class MessageCodec
|
||||
MessageId.MarketReport => MarketReport.Read(ref r),
|
||||
MessageId.ClimbReport => ClimbReport.Read(ref r),
|
||||
MessageId.FinanceReport => FinanceReport.Read(ref r),
|
||||
MessageId.FleetReport => FleetReport.Read(ref r),
|
||||
MessageId.MarketTape => MarketTape.Read(ref r),
|
||||
MessageId.CommandResult => CommandResultMessage.Read(ref r),
|
||||
MessageId.Notification => Notification.Read(ref r),
|
||||
|
||||
Reference in new issue
Block a user