add client extl id and fix setpasswd
This commit is contained in:
13
ttd.go
13
ttd.go
@@ -447,7 +447,7 @@ func (s *ServerTTD) Poll(stop chan struct{}) {
|
||||
Packet: p,
|
||||
}
|
||||
sp.Read(buffer[:p.PLength])
|
||||
r := regexp.MustCompile("#:(?P<CompanyID>[0-9]+)\\(.*\\) Company Name: '(?P<CompanyName>.+)'.*Value: (?P<CompanyValue>[0-9]+)( )+.*")
|
||||
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}") {
|
||||
@@ -457,6 +457,15 @@ func (s *ServerTTD) Poll(stop chan struct{}) {
|
||||
}
|
||||
}
|
||||
}
|
||||
r = regexp.MustCompile("Client #(?P<ClientID>[0-9]+).*name: '(?P<ClientName>.+)'.*company: (?P<CompanyID>[0-9]+)( )+IP: .*$")
|
||||
if r.MatchString(sp.Output) {
|
||||
for _, c := range srv.Status.Clients {
|
||||
if c.Name == r.ReplaceAllString(sp.Output, "${ClientName}") {
|
||||
c.ClientExtlID, _ = strconv.ParseInt(r.ReplaceAllString(sp.Output, "${ClientID}"), 10, 64)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
logInfoDebug("Server.Poll() : AdminPacketServerRCon :\n- ColorID: %d\n- Output: %s", sp.ColorID, sp.Output)
|
||||
|
||||
case AdminPacketServerRConEnd:
|
||||
@@ -778,7 +787,7 @@ func (s *ServerTTD) Initialize() {
|
||||
s.UpdateClients()
|
||||
}
|
||||
|
||||
func (s *ServerTTD) SetPasswd(id uint8, passwd string) {
|
||||
func (s *ServerTTD) SetPasswd(id int64, passwd string) {
|
||||
px := PacketAdminRCon{
|
||||
Packet: Packet{PType: AdminPacketAdminRCon},
|
||||
Command: fmt.Sprintf("company_pw %d %s", id, passwd),
|
||||
|
||||
Reference in New Issue
Block a user