add all stats and tie stats to user rather than company
This commit is contained in:
95
ttd.go
95
ttd.go
@@ -385,32 +385,35 @@ func (s *ServerTTD) Poll(stop chan struct{}) {
|
||||
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 {
|
||||
cfg.Stats = make(map[uint8]map[string]*Stat)
|
||||
cfg.Stats = make(map[int]map[string]*Stat)
|
||||
}
|
||||
|
||||
_, ok := cfg.Stats[sp.CompanyID]
|
||||
if !ok {
|
||||
cfg.Stats[sp.CompanyID] = make(map[string]*Stat)
|
||||
}
|
||||
stats, ok := cfg.Stats[sp.CompanyID][s.Status.GameDate.Format("20060102")]
|
||||
if !ok {
|
||||
stats = &Stat{
|
||||
CompanyID: sp.CompanyID,
|
||||
Date: s.Status.GameDate,
|
||||
if cfg.CompanyIsRegistered(sp.CompanyID) {
|
||||
cc := cfg.GetCompanyClient(sp.CompanyID)
|
||||
_, ok := cfg.Stats[cc.UserID]
|
||||
if !ok {
|
||||
cfg.Stats[cc.UserID] = make(map[string]*Stat)
|
||||
}
|
||||
stats, ok := cfg.Stats[cc.UserID][s.Status.GameDate.Format("20060102")]
|
||||
if !ok {
|
||||
stats = &Stat{
|
||||
CompanyID: sp.CompanyID,
|
||||
Date: s.Status.GameDate,
|
||||
}
|
||||
cfg.Stats[cc.UserID][s.Status.GameDate.Format("20060102")] = stats
|
||||
}
|
||||
cfg.Stats[sp.CompanyID][s.Status.GameDate.Format("20060102")] = stats
|
||||
}
|
||||
|
||||
stats.Money = int64(sp.Money)
|
||||
stats.Loan = int64(sp.Loan)
|
||||
stats.Income = sp.Income
|
||||
stats.DeliveredCargoThisQuarter = int(sp.DeliveredCargoThisQuarter)
|
||||
stats.DeliveredCargoLastQuarter = int(sp.DeliveredCargoLastQuarter)
|
||||
stats.DeliveredCargoPreviousQuarter = int(sp.DeliveredCargoPreviousQuarter)
|
||||
stats.PerformanceLastQuarter = int(sp.PerformanceLastQuarter)
|
||||
stats.PerformancePreviousQuarter = int(sp.PerformancePreviousQuarter)
|
||||
stats.CompanyValueLastQuarter = int64(sp.CompanyValueLastQuarter)
|
||||
stats.CompanyValuePreviousQuarter = int64(sp.CompanyValuePreviousQuarter)
|
||||
stats.Money = int64(sp.Money)
|
||||
stats.Loan = int64(sp.Loan)
|
||||
stats.Income = sp.Income
|
||||
stats.DeliveredCargoThisQuarter = int(sp.DeliveredCargoThisQuarter)
|
||||
stats.DeliveredCargoLastQuarter = int(sp.DeliveredCargoLastQuarter)
|
||||
stats.DeliveredCargoPreviousQuarter = int(sp.DeliveredCargoPreviousQuarter)
|
||||
stats.PerformanceLastQuarter = int(sp.PerformanceLastQuarter)
|
||||
stats.PerformancePreviousQuarter = int(sp.PerformancePreviousQuarter)
|
||||
stats.CompanyValueLastQuarter = int64(sp.CompanyValueLastQuarter)
|
||||
stats.CompanyValuePreviousQuarter = int64(sp.CompanyValuePreviousQuarter)
|
||||
}
|
||||
case AdminPacketServerCompanyStats:
|
||||
sp := PacketServerCompanyStats{
|
||||
Packet: p,
|
||||
@@ -419,33 +422,35 @@ func (s *ServerTTD) Poll(stop chan struct{}) {
|
||||
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 {
|
||||
cfg.Stats = make(map[uint8]map[string]*Stat)
|
||||
cfg.Stats = make(map[int]map[string]*Stat)
|
||||
}
|
||||
|
||||
_, ok := cfg.Stats[sp.CompanyID]
|
||||
if !ok {
|
||||
cfg.Stats[sp.CompanyID] = make(map[string]*Stat)
|
||||
}
|
||||
stats, ok := cfg.Stats[sp.CompanyID][s.Status.GameDate.Format("20060102")]
|
||||
if !ok {
|
||||
stats = &Stat{
|
||||
CompanyID: sp.CompanyID,
|
||||
Date: s.Status.GameDate,
|
||||
if cfg.CompanyIsRegistered(sp.CompanyID) {
|
||||
cc := cfg.GetCompanyClient(sp.CompanyID)
|
||||
_, ok := cfg.Stats[cc.UserID]
|
||||
if !ok {
|
||||
cfg.Stats[cc.UserID] = make(map[string]*Stat)
|
||||
}
|
||||
cfg.Stats[sp.CompanyID][s.Status.GameDate.Format("20060102")] = stats
|
||||
stats, ok := cfg.Stats[cc.UserID][s.Status.GameDate.Format("20060102")]
|
||||
if !ok {
|
||||
stats = &Stat{
|
||||
CompanyID: sp.CompanyID,
|
||||
Date: s.Status.GameDate,
|
||||
}
|
||||
cfg.Stats[cc.UserID][s.Status.GameDate.Format("20060102")] = stats
|
||||
}
|
||||
|
||||
stats.Trains = int(sp.Trains)
|
||||
stats.TrainStations = int(sp.TrainStations)
|
||||
stats.Busses = int(sp.Busses)
|
||||
stats.BusStops = int(sp.BusStops)
|
||||
stats.Lorries = int(sp.Lorries)
|
||||
stats.LorryStations = int(sp.LorryStations)
|
||||
stats.Planes = int(sp.Planes)
|
||||
stats.Airports = int(sp.Airports)
|
||||
stats.Ships = int(sp.Ships)
|
||||
stats.Harbours = int(sp.Harbours)
|
||||
}
|
||||
|
||||
stats.Trains = int(sp.Trains)
|
||||
stats.TrainStations = int(sp.TrainStations)
|
||||
stats.Busses = int(sp.Busses)
|
||||
stats.BusStops = int(sp.BusStops)
|
||||
stats.Lorries = int(sp.Lorries)
|
||||
stats.LorryStations = int(sp.LorryStations)
|
||||
stats.Planes = int(sp.Planes)
|
||||
stats.Airports = int(sp.Airports)
|
||||
stats.Ships = int(sp.Ships)
|
||||
stats.Harbours = int(sp.Harbours)
|
||||
|
||||
case AdminPacketServerChat:
|
||||
sp := PacketServerChat{
|
||||
Packet: p,
|
||||
|
||||
Reference in New Issue
Block a user