refactor everything again
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m51s

This commit is contained in:
matst80
2024-11-10 20:10:47 +01:00
parent 7a4d9b1540
commit 8f0e062817
7 changed files with 125 additions and 145 deletions

View File

@@ -89,11 +89,11 @@ func (m *TCPCartServerMux) handleFunction(connection net.Conn, messageType uint1
}
func (m *TCPCartServerMux) HandleConnection(connection net.Conn) error {
var packet *CartPacket
var packet CartPacket
var err error
defer connection.Close()
for {
err = ReadPacket(connection, packet)
err = ReadPacket(connection, &packet)
if err != nil {
if err == io.EOF {
return nil
@@ -101,10 +101,7 @@ func (m *TCPCartServerMux) HandleConnection(connection net.Conn) error {
log.Printf("Error receiving packet: %v\n", err)
return err
}
if packet == nil {
log.Println("Packet is nil")
continue
}
data, err := GetPacketData(connection, int(packet.DataLength))
if err != nil {
log.Printf("Error getting packet data: %v\n", err)