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
|
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) {
|
if !r.MatchString(m.Text) {
|
||||||
bot.SendChat(m.Chat.ID, "Wrong usage.")
|
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])
|
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)
|
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 {
|
if !ok {
|
||||||
cStats = make(map[string]*Stat)
|
stats = &Stat{
|
||||||
cfg.Stats[sp.CompanyID] = cStats
|
|
||||||
}
|
|
||||||
dStats, ok := cStats[s.Status.GameDate.Format("20060102")]
|
|
||||||
if !ok {
|
|
||||||
dStats = &Stat{
|
|
||||||
CompanyID: sp.CompanyID,
|
CompanyID: sp.CompanyID,
|
||||||
Date: s.Status.GameDate,
|
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)
|
stats.Money = int64(sp.Money)
|
||||||
dStats.Income = sp.Income
|
stats.Loan = int64(sp.Loan)
|
||||||
dStats.DeliveredCargoThisQuarter = int(sp.DeliveredCargoThisQuarter)
|
stats.Income = sp.Income
|
||||||
dStats.DeliveredCargoLastQuarter = int(sp.DeliveredCargoLastQuarter)
|
stats.DeliveredCargoThisQuarter = int(sp.DeliveredCargoThisQuarter)
|
||||||
dStats.DeliveredCargoPreviousQuarter = int(sp.DeliveredCargoPreviousQuarter)
|
stats.DeliveredCargoLastQuarter = int(sp.DeliveredCargoLastQuarter)
|
||||||
dStats.PerformanceLastQuarter = int(sp.PerformanceLastQuarter)
|
stats.DeliveredCargoPreviousQuarter = int(sp.DeliveredCargoPreviousQuarter)
|
||||||
dStats.PerformancePreviousQuarter = int(sp.PerformancePreviousQuarter)
|
stats.PerformanceLastQuarter = int(sp.PerformanceLastQuarter)
|
||||||
dStats.CompanyValueLastQuarter = int64(sp.CompanyValueLastQuarter)
|
stats.PerformancePreviousQuarter = int(sp.PerformancePreviousQuarter)
|
||||||
dStats.CompanyValuePreviousQuarter = int64(sp.CompanyValuePreviousQuarter)
|
stats.CompanyValueLastQuarter = int64(sp.CompanyValueLastQuarter)
|
||||||
|
stats.CompanyValuePreviousQuarter = int64(sp.CompanyValuePreviousQuarter)
|
||||||
case AdminPacketServerCompanyStats:
|
case AdminPacketServerCompanyStats:
|
||||||
sp := PacketServerCompanyStats{
|
sp := PacketServerCompanyStats{
|
||||||
Packet: p,
|
Packet: p,
|
||||||
}
|
}
|
||||||
sp.Read(buffer[:p.PLength])
|
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)
|
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 {
|
if !ok {
|
||||||
cStats = make(map[string]*Stat)
|
stats = &Stat{
|
||||||
cfg.Stats[sp.CompanyID] = cStats
|
|
||||||
}
|
|
||||||
dStats, ok := cStats[s.Status.GameDate.Format("20060102")]
|
|
||||||
if !ok {
|
|
||||||
dStats = &Stat{
|
|
||||||
CompanyID: sp.CompanyID,
|
CompanyID: sp.CompanyID,
|
||||||
Date: s.Status.GameDate,
|
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)
|
stats.Trains = int(sp.Trains)
|
||||||
dStats.Busses = int(sp.Busses)
|
stats.TrainStations = int(sp.TrainStations)
|
||||||
dStats.BusStops = int(sp.BusStops)
|
stats.Busses = int(sp.Busses)
|
||||||
dStats.Lorries = int(sp.Lorries)
|
stats.BusStops = int(sp.BusStops)
|
||||||
dStats.LorryStations = int(sp.LorryStations)
|
stats.Lorries = int(sp.Lorries)
|
||||||
dStats.Planes = int(sp.Planes)
|
stats.LorryStations = int(sp.LorryStations)
|
||||||
dStats.Airports = int(sp.Airports)
|
stats.Planes = int(sp.Planes)
|
||||||
dStats.Ships = int(sp.Ships)
|
stats.Airports = int(sp.Airports)
|
||||||
dStats.Harbours = int(sp.Harbours)
|
stats.Ships = int(sp.Ships)
|
||||||
|
stats.Harbours = int(sp.Harbours)
|
||||||
|
|
||||||
case AdminPacketServerChat:
|
case AdminPacketServerChat:
|
||||||
sp := PacketServerChat{
|
sp := PacketServerChat{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by version.sh (@generated) DO NOT EDIT.
|
// Code generated by version.sh (@generated) DO NOT EDIT.
|
||||||
package main
|
package main
|
||||||
var githash = "6533e87"
|
var githash = "565c710"
|
||||||
var buildstamp = "2021-12-05_07:48:27"
|
var buildstamp = "2021-12-05_07:54:35"
|
||||||
var commits = "223"
|
var commits = "224"
|
||||||
var version = "6533e87-b223 - 2021-12-05_07:48:27"
|
var version = "565c710-b224 - 2021-12-05_07:54:35"
|
||||||
|
Loading…
Reference in New Issue
Block a user