fix save and eco/stats storage
This commit is contained in:
parent
565c7101d8
commit
e043820273
2
bot.go
2
bot.go
@ -521,7 +521,7 @@ func botSave(m *tb.Message) {
|
||||
return
|
||||
}
|
||||
|
||||
r := regexp.MustCompile("^\\/save @(?P<Filename>[a-zA-Z0-9._]+)")
|
||||
r := regexp.MustCompile("^\\/save (?P<Filename>[a-zA-Z0-9._]+)")
|
||||
|
||||
if !r.MatchString(m.Text) {
|
||||
bot.SendChat(m.Chat.ID, "Wrong usage.")
|
||||
|
66
ttd.go
66
ttd.go
@ -383,58 +383,52 @@ 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)
|
||||
cStats, ok := cfg.Stats[sp.CompanyID]
|
||||
|
||||
stats, ok := cfg.Stats[sp.CompanyID][s.Status.GameDate.Format("20060102")]
|
||||
if !ok {
|
||||
cStats = make(map[string]*Stat)
|
||||
cfg.Stats[sp.CompanyID] = cStats
|
||||
}
|
||||
dStats, ok := cStats[s.Status.GameDate.Format("20060102")]
|
||||
if !ok {
|
||||
dStats = &Stat{
|
||||
stats = &Stat{
|
||||
CompanyID: sp.CompanyID,
|
||||
Date: s.Status.GameDate,
|
||||
}
|
||||
cStats[s.Status.GameDate.Format("20060102")] = dStats
|
||||
cfg.Stats[sp.CompanyID][s.Status.GameDate.Format("20060102")] = stats
|
||||
}
|
||||
dStats.Money = int64(sp.Money)
|
||||
dStats.Loan = int64(sp.Loan)
|
||||
dStats.Income = sp.Income
|
||||
dStats.DeliveredCargoThisQuarter = int(sp.DeliveredCargoThisQuarter)
|
||||
dStats.DeliveredCargoLastQuarter = int(sp.DeliveredCargoLastQuarter)
|
||||
dStats.DeliveredCargoPreviousQuarter = int(sp.DeliveredCargoPreviousQuarter)
|
||||
dStats.PerformanceLastQuarter = int(sp.PerformanceLastQuarter)
|
||||
dStats.PerformancePreviousQuarter = int(sp.PerformancePreviousQuarter)
|
||||
dStats.CompanyValueLastQuarter = int64(sp.CompanyValueLastQuarter)
|
||||
dStats.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,
|
||||
}
|
||||
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)
|
||||
cStats, ok := cfg.Stats[sp.CompanyID]
|
||||
|
||||
stats, ok := cfg.Stats[sp.CompanyID][s.Status.GameDate.Format("20060102")]
|
||||
if !ok {
|
||||
cStats = make(map[string]*Stat)
|
||||
cfg.Stats[sp.CompanyID] = cStats
|
||||
}
|
||||
dStats, ok := cStats[s.Status.GameDate.Format("20060102")]
|
||||
if !ok {
|
||||
dStats = &Stat{
|
||||
stats = &Stat{
|
||||
CompanyID: sp.CompanyID,
|
||||
Date: s.Status.GameDate,
|
||||
}
|
||||
cStats[s.Status.GameDate.Format("20060102")] = dStats
|
||||
cfg.Stats[sp.CompanyID][s.Status.GameDate.Format("20060102")] = stats
|
||||
}
|
||||
dStats.Trains = int(sp.Trains)
|
||||
dStats.TrainStations = int(sp.TrainStations)
|
||||
dStats.Busses = int(sp.Busses)
|
||||
dStats.BusStops = int(sp.BusStops)
|
||||
dStats.Lorries = int(sp.Lorries)
|
||||
dStats.LorryStations = int(sp.LorryStations)
|
||||
dStats.Planes = int(sp.Planes)
|
||||
dStats.Airports = int(sp.Airports)
|
||||
dStats.Ships = int(sp.Ships)
|
||||
dStats.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{
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by version.sh (@generated) DO NOT EDIT.
|
||||
package main
|
||||
var githash = "6533e87"
|
||||
var buildstamp = "2021-12-05_07:48:27"
|
||||
var commits = "223"
|
||||
var version = "6533e87-b223 - 2021-12-05_07:48:27"
|
||||
var githash = "565c710"
|
||||
var buildstamp = "2021-12-05_07:54:35"
|
||||
var commits = "224"
|
||||
var version = "565c710-b224 - 2021-12-05_07:54:35"
|
||||
|
Loading…
Reference in New Issue
Block a user