diff --git a/ttd.go b/ttd.go index 67dee95..9823f30 100644 --- a/ttd.go +++ b/ttd.go @@ -13,7 +13,7 @@ import ( type ClientTTD struct { ClientID uint32 - ClientExtlID uint + ClientExtlID int64 Name string Address string CompanyID uint8 @@ -23,8 +23,9 @@ type ClientTTD struct { type CompanyTTD struct { CompanyID uint8 - CompanyExtlID uint + CompanyExtlID int64 Name string + Value int64 Protected bool ClientID uint32 FirstSeen time.Time @@ -446,6 +447,16 @@ func (s *ServerTTD) Poll(stop chan struct{}) { Packet: p, } sp.Read(buffer[:p.PLength]) + r := regexp.MustCompile("#:(?P[0-9]+)\\(.*\\) Company Name: '(?P.+)'.*Value: (?P[0-9]+)( )+.*") + if r.MatchString(sp.Output) { + for _, co := range srv.Status.Companies { + if co.Name == r.ReplaceAllString(sp.Output, "${CompanyName}") { + co.CompanyExtlID, _ = strconv.ParseInt(r.ReplaceAllString(sp.Output, "${CompanyID}"), 10, 64) + co.Value, _ = strconv.ParseInt(r.ReplaceAllString(sp.Output, "${CompanyValue}"), 10, 64) + break + } + } + } logInfoDebug("Server.Poll() : AdminPacketServerRCon :\n- ColorID: %d\n- Output: %s", sp.ColorID, sp.Output) case AdminPacketServerRConEnd: diff --git a/version.go b/version.go index 0c69534..da5283f 100644 --- a/version.go +++ b/version.go @@ -1,6 +1,6 @@ // Code generated by version.sh (@generated) DO NOT EDIT. package main -var githash = "fe292ba" -var buildstamp = "2021-11-10_06:16:28" -var commits = "182" -var version = "fe292ba-b182 - 2021-11-10_06:16:28" +var githash = "6e092ea" +var buildstamp = "2021-11-10_06:35:44" +var commits = "183" +var version = "6e092ea-b183 - 2021-11-10_06:35:44"