This commit is contained in:
shoopea 2021-11-10 14:06:49 +08:00
parent e185eff578
commit 6079431dda

46
ttd.go
View File

@ -21,12 +21,13 @@ type ClientTTD struct {
} }
type CompanyTTD struct { type CompanyTTD struct {
CompanyID uint8 CompanyID uint8
Name string CompanyExtlID uint
Protected bool Name string
ClientID uint32 Protected bool
FirstSeen time.Time ClientID uint32
LastSeen time.Time FirstSeen time.Time
LastSeen time.Time
} }
type ServerTTD struct { type ServerTTD struct {
@ -318,9 +319,10 @@ func (s *ServerTTD) Poll(stop chan struct{}) {
sp.Read(buffer[:p.PLength]) sp.Read(buffer[:p.PLength])
logInfoDebug("Server.Poll() : PacketServerCompanyNew :\n- CompanyID: %d", sp.CompanyID) logInfoDebug("Server.Poll() : PacketServerCompanyNew :\n- CompanyID: %d", sp.CompanyID)
c := &CompanyTTD{ c := &CompanyTTD{
CompanyID: sp.CompanyID, CompanyID: sp.CompanyID,
FirstSeen: time.Now(), CompanyExtlID: 256,
ClientID: 0, FirstSeen: time.Now(),
ClientID: 0,
} }
s.Status.Companies[sp.CompanyID] = c s.Status.Companies[sp.CompanyID] = c
case AdminPacketServerCompanyInfo: case AdminPacketServerCompanyInfo:
@ -330,9 +332,10 @@ func (s *ServerTTD) Poll(stop chan struct{}) {
sp.Read(buffer[:p.PLength]) sp.Read(buffer[:p.PLength])
//logInfoDebug("Server.Poll() : PacketServerCompanyInfo :\n- CompanyID: %d\n- Name: %s\n- President: %s\n- Protected: %t\n- Inauguration: %d\n- AI: %t", sp.CompanyID, sp.Name, sp.President, sp.Protected, sp.Inauguration, sp.AI) //logInfoDebug("Server.Poll() : PacketServerCompanyInfo :\n- CompanyID: %d\n- Name: %s\n- President: %s\n- Protected: %t\n- Inauguration: %d\n- AI: %t", sp.CompanyID, sp.Name, sp.President, sp.Protected, sp.Inauguration, sp.AI)
c := &CompanyTTD{ c := &CompanyTTD{
CompanyID: sp.CompanyID, CompanyID: sp.CompanyID,
FirstSeen: time.Now(), CompanyExtlID: 256,
ClientID: 0, FirstSeen: time.Now(),
ClientID: 0,
} }
if _, ok := s.Status.Companies[sp.CompanyID]; !ok { if _, ok := s.Status.Companies[sp.CompanyID]; !ok {
s.Status.Companies[sp.CompanyID] = c s.Status.Companies[sp.CompanyID] = c
@ -349,9 +352,10 @@ func (s *ServerTTD) Poll(stop chan struct{}) {
sp.Read(buffer[:p.PLength]) sp.Read(buffer[:p.PLength])
logInfoDebug("Server.Poll() : PacketServerCompanyUpdate :\n- CompanyID: %d\n- Name: %s\n- President: %s\n- Protected: %t", sp.CompanyID, sp.Name, sp.President, sp.Protected) logInfoDebug("Server.Poll() : PacketServerCompanyUpdate :\n- CompanyID: %d\n- Name: %s\n- President: %s\n- Protected: %t", sp.CompanyID, sp.Name, sp.President, sp.Protected)
c := &CompanyTTD{ c := &CompanyTTD{
CompanyID: sp.CompanyID, CompanyID: sp.CompanyID,
FirstSeen: time.Now(), CompanyExtlID: 256,
ClientID: 0, FirstSeen: time.Now(),
ClientID: 0,
} }
if _, ok := s.Status.Companies[sp.CompanyID]; !ok { if _, ok := s.Status.Companies[sp.CompanyID]; !ok {
s.Status.Companies[sp.CompanyID] = c s.Status.Companies[sp.CompanyID] = c
@ -427,12 +431,12 @@ func (s *ServerTTD) Poll(stop chan struct{}) {
} }
break break
} }
/*
command, err := regexp.MatchString("\\[admin\\] Rcon command from 'gottdad' \\(.*\\): .*", sp.Text) command, err := regexp.MatchString("\\[admin\\] Rcon command from 'gottdad' \\(.*\\): .*", sp.Text)
if command && sp.Origin == "net" { if command && sp.Origin == "net" {
break break
} }
*/
logInfoDebug("Server.Poll() : AdminPacketServerConsole :\n- Origin: %q\n- Text: %s", sp.Origin, sp.Text) logInfoDebug("Server.Poll() : AdminPacketServerConsole :\n- Origin: %q\n- Text: %s", sp.Origin, sp.Text)
case AdminPacketServerRCon: case AdminPacketServerRCon: