CompanyExtlID

This commit is contained in:
shoopea 2021-11-10 14:35:50 +08:00
parent 6e092ea3b2
commit bcc20d3402
2 changed files with 17 additions and 6 deletions

15
ttd.go
View File

@ -13,7 +13,7 @@ import (
type ClientTTD struct { type ClientTTD struct {
ClientID uint32 ClientID uint32
ClientExtlID uint ClientExtlID int64
Name string Name string
Address string Address string
CompanyID uint8 CompanyID uint8
@ -23,8 +23,9 @@ type ClientTTD struct {
type CompanyTTD struct { type CompanyTTD struct {
CompanyID uint8 CompanyID uint8
CompanyExtlID uint CompanyExtlID int64
Name string Name string
Value int64
Protected bool Protected bool
ClientID uint32 ClientID uint32
FirstSeen time.Time FirstSeen time.Time
@ -446,6 +447,16 @@ func (s *ServerTTD) Poll(stop chan struct{}) {
Packet: p, Packet: p,
} }
sp.Read(buffer[:p.PLength]) sp.Read(buffer[:p.PLength])
r := regexp.MustCompile("#:(?P<CompanyID>[0-9]+)\\(.*\\) Company Name: '(?P<CompanyName>.+)'.*Value: (?P<CompanyValue>[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) logInfoDebug("Server.Poll() : AdminPacketServerRCon :\n- ColorID: %d\n- Output: %s", sp.ColorID, sp.Output)
case AdminPacketServerRConEnd: case AdminPacketServerRConEnd:

View File

@ -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 = "fe292ba" var githash = "6e092ea"
var buildstamp = "2021-11-10_06:16:28" var buildstamp = "2021-11-10_06:35:44"
var commits = "182" var commits = "183"
var version = "fe292ba-b182 - 2021-11-10_06:16:28" var version = "6e092ea-b183 - 2021-11-10_06:35:44"