From c61e2918e52e929722e5bd97ddaa1747d7ed1744 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Sat, 20 Jun 2026 22:08:57 -0300 Subject: minor cleanup --- query.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'query.go') diff --git a/query.go b/query.go index 3abca9a..70fac5a 100644 --- a/query.go +++ b/query.go @@ -2,6 +2,7 @@ package main import ( "encoding/binary" + "io" "net" "strings" "sync" @@ -41,14 +42,14 @@ const ( type ( TWorld struct { - Name string - Type string - NumPlayers int - MaxPlayers int - OnlinePeak int + Name string + Type string + NumPlayers int + MaxPlayers int + OnlinePeak int OnlinePeakTimestamp int - LastStartup int - LastShutdown int + LastStartup int + LastShutdown int } TAccountSummary struct { @@ -214,7 +215,7 @@ func (Connection *TQueryManagerConnection) ExecuteQuery(AutoReconnect bool, Writ } var Help [4]byte - if _, Err := Connection.Handle.Read(Help[:2]); Err != nil { + if _, Err := io.ReadFull(Connection.Handle, Help[:2]); Err != nil { Connection.Disconnect() if Attempt >= MaxAttempts { g_LogErr.Printf("Failed to read response size: %v", Err) @@ -225,7 +226,7 @@ func (Connection *TQueryManagerConnection) ExecuteQuery(AutoReconnect bool, Writ ResponseSize := int(binary.LittleEndian.Uint16(Help[:2])) if ResponseSize == 0xFFFF { - if _, Err := Connection.Handle.Read(Help[:]); Err != nil { + if _, Err := io.ReadFull(Connection.Handle, Help[:]); Err != nil { Connection.Disconnect() g_LogErr.Printf("Failed to read response extended size: %v", Err) return @@ -241,7 +242,7 @@ func (Connection *TQueryManagerConnection) ExecuteQuery(AutoReconnect bool, Writ return } - if _, Err := Connection.Handle.Read(Buffer[:ResponseSize]); Err != nil { + if _, Err := io.ReadFull(Connection.Handle, Buffer[:ResponseSize]); Err != nil { Connection.Disconnect() g_LogErr.Printf("Failed to read response: %v", Err) return -- cgit v1.2.3