diff --git a/bot.go b/bot.go index c48c268..744f2f1 100644 --- a/bot.go +++ b/bot.go @@ -521,7 +521,7 @@ func botSave(m *tb.Message) { return } - r := regexp.MustCompile("^\\/save (?P[a-zA-Z0-9._]+)") + r := regexp.MustCompile("^\\/save (?P[a-zA-Z0-9._\\/]+)") if !r.MatchString(m.Text) { bot.SendChat(m.Chat.ID, "Wrong usage.") diff --git a/ttd.go b/ttd.go index d0fa7ed..0af30df 100644 --- a/ttd.go +++ b/ttd.go @@ -384,6 +384,10 @@ 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) + _, 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{ @@ -410,6 +414,10 @@ 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) + _, 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{ diff --git a/version.go b/version.go index 91261ee..1d42b95 100644 --- a/version.go +++ b/version.go @@ -1,6 +1,6 @@ // Code generated by version.sh (@generated) DO NOT EDIT. package main -var githash = "565c710" -var buildstamp = "2021-12-05_07:54:35" -var commits = "224" -var version = "565c710-b224 - 2021-12-05_07:54:35" +var githash = "e043820" +var buildstamp = "2021-12-05_08:19:58" +var commits = "225" +var version = "e043820-b225 - 2021-12-05_08:19:58"