update map eco/stats

This commit is contained in:
shoopea
2021-12-05 17:08:12 +08:00
parent 0fd89991d7
commit d5bed1eecf
3 changed files with 19 additions and 7 deletions

14
ttd.go
View File

@@ -384,6 +384,13 @@ func (s *ServerTTD) Poll(stop chan struct{}) {
sp.Read(buffer[:p.PLength])
logInfoDebug("Server.Poll() : PacketServerCompanyEconomy :\n- CompanyID: %d\n- M: %d\tL: %d\tI: %d\n- Delivered now: %d\tLast: %d\tPrevious: %d\n- Performance last: %d\t Previous: %d\n- Value last: %d\t Previous: %d", sp.CompanyID, sp.Money, sp.Loan, sp.Income, sp.DeliveredCargoThisQuarter, sp.DeliveredCargoLastQuarter, sp.DeliveredCargoPreviousQuarter, sp.PerformanceLastQuarter, sp.PerformancePreviousQuarter, sp.CompanyValueLastQuarter, sp.CompanyValuePreviousQuarter)
if cfg.Stats == nil {
logInfoDebug("Server.Poll() : PacketServerCompanyEconomy : Stats : uninitialized")
cfg.Stats = make(map[uint8]map[string]*Stat)
} else {
logInfoDebug("Server.Poll() : PacketServerCompanyEconomy : Stats : initialized")
}
_, ok := cfg.Stats[sp.CompanyID]
if !ok {
cfg.Stats[sp.CompanyID] = make(map[string]*Stat)
@@ -414,6 +421,13 @@ func (s *ServerTTD) Poll(stop chan struct{}) {
sp.Read(buffer[:p.PLength])
logInfoDebug("Server.Poll() : PacketServerCompanyStats :\n- CompanyID: %d\n- Vehicles T: %d\tL: %d\tB: %d\tP: %d\tS: %d\n- Stations T: %d\tL: %d\tB: %d\tP: %d\tS: %d", sp.CompanyID, sp.Trains, sp.Lorries, sp.Busses, sp.Planes, sp.Ships, sp.TrainStations, sp.LorryStations, sp.BusStops, sp.Airports, sp.Harbours)
if cfg.Stats == nil {
logInfoDebug("Server.Poll() : PacketServerCompanyStats : Stats : uninitialized")
cfg.Stats = make(map[uint8]map[string]*Stat)
} else {
logInfoDebug("Server.Poll() : PacketServerCompanyStats : Stats : initialized")
}
_, ok := cfg.Stats[sp.CompanyID]
if !ok {
cfg.Stats[sp.CompanyID] = make(map[string]*Stat)