@@ -50,7 +50,7 @@ const (
5050
5151// returns true if v is bigger than w (accounting for uint32 wrap around).
5252func uintLarger (v uint32 , w uint32 ) bool {
53- return (w - v ) > (math .MaxUint32 / 2 ) //nolint:gomnd,mnd
53+ return (w - v ) > (math .MaxUint32 / 2 )
5454}
5555
5656func (g * GameServer ) getPlayerNumberByID (regID uint32 ) (byte , error ) {
@@ -76,7 +76,7 @@ func (g *GameServer) fillInput(playerNumber byte, count uint32) InputData {
7676}
7777
7878func (g * GameServer ) sendUDPInput (count uint32 , addr * net.UDPAddr , playerNumber byte , spectator bool , sendingPlayerNumber byte ) uint32 {
79- buffer := make ([]byte , 508 ) //nolint:gomnd,mnd
79+ buffer := make ([]byte , 508 )
8080 var countLag uint32
8181 if uintLarger (count , g .GameData .LeadCount ) {
8282 if ! spectator {
@@ -93,7 +93,7 @@ func (g *GameServer) sendUDPInput(count uint32, addr *net.UDPAddr, playerNumber
9393 }
9494 buffer [1 ] = playerNumber
9595 buffer [2 ] = g .GameData .Status
96- buffer [3 ] = uint8 (countLag ) //nolint:gosec
96+ buffer [3 ] = uint8 (countLag )
9797 currentByte := 5
9898 start := count
9999 end := start + g .GameData .BufferSize [sendingPlayerNumber ]
@@ -111,7 +111,7 @@ func (g *GameServer) sendUDPInput(count uint32, addr *net.UDPAddr, playerNumber
111111 }
112112
113113 if count > start {
114- buffer [4 ] = uint8 (count - start ) //nolint:gosec // number of counts in packet
114+ buffer [4 ] = uint8 (count - start ) // number of counts in packet
115115 _ , err := g .UDPListener .WriteToUDP (buffer [0 :currentByte ], addr )
116116 if err != nil {
117117 g .Logger .Error (err , "could not send input" )
@@ -122,7 +122,8 @@ func (g *GameServer) sendUDPInput(count uint32, addr *net.UDPAddr, playerNumber
122122
123123func (g * GameServer ) processUDP (addr * net.UDPAddr , buf []byte ) {
124124 playerNumber := buf [1 ]
125- if buf [0 ] == KeyInfoClient {
125+ switch buf [0 ] {
126+ case KeyInfoClient :
126127 g .GameData .PlayerAddresses [playerNumber ] = addr
127128 count := binary .BigEndian .Uint32 (buf [2 :])
128129
@@ -134,7 +135,7 @@ func (g *GameServer) processUDP(addr *net.UDPAddr, buf []byte) {
134135 g .sendUDPInput (count , g .GameData .PlayerAddresses [i ], playerNumber , true , NoRegID )
135136 }
136137 }
137- } else if buf [ 0 ] == PlayerInputRequest {
138+ case PlayerInputRequest :
138139 regID := binary .BigEndian .Uint32 (buf [2 :])
139140 count := binary .BigEndian .Uint32 (buf [6 :])
140141 spectator := buf [10 ]
@@ -154,7 +155,7 @@ func (g *GameServer) processUDP(addr *net.UDPAddr, buf []byte) {
154155 g .GameDataMutex .Unlock ()
155156
156157 g .GameData .CountLag [sendingPlayerNumber ] = countLag
157- } else if buf [ 0 ] == CP0Info {
158+ case CP0Info :
158159 if g .GameData .Status & StatusDesync == 0 {
159160 viCount := binary .BigEndian .Uint32 (buf [1 :])
160161 syncValue , ok := g .GameData .SyncValues [viCount ]
@@ -173,7 +174,7 @@ func (g *GameServer) processUDP(addr *net.UDPAddr, buf []byte) {
173174
174175func (g * GameServer ) watchUDP () {
175176 for {
176- buf := make ([]byte , 1500 ) //nolint:gomnd,mnd
177+ buf := make ([]byte , 1500 )
177178 _ , addr , err := g .UDPListener .ReadFromUDP (buf )
178179 if err != nil && ! g .isConnClosed (err ) {
179180 g .Logger .Error (err , "error from UdpListener" )
@@ -201,28 +202,28 @@ func (g *GameServer) createUDPServer() error {
201202 var err error
202203 g .UDPListener , err = net .ListenUDP ("udp" , & net.UDPAddr {Port : g .Port })
203204 if err != nil {
204- return err //nolint:wrapcheck
205+ return err
205206 }
206- if err := ipv4 .NewConn (g .UDPListener ).SetTOS (CS4 << 2 ); err != nil { //nolint:gomnd,mnd
207+ if err := ipv4 .NewConn (g .UDPListener ).SetTOS (CS4 << 2 ); err != nil {
207208 g .Logger .Error (err , "could not set IPv4 DSCP" )
208209 }
209- if err := ipv6 .NewConn (g .UDPListener ).SetTrafficClass (CS4 << 2 ); err != nil { //nolint:gomnd,mnd
210+ if err := ipv6 .NewConn (g .UDPListener ).SetTrafficClass (CS4 << 2 ); err != nil {
210211 g .Logger .Error (err , "could not set IPv6 DSCP" )
211212 }
212213 g .Logger .Info ("Created UDP server" , "port" , g .Port )
213214
214- g .GameData .PlayerAddresses = make ([]* net.UDPAddr , 4 ) //nolint:gomnd,mnd
215+ g .GameData .PlayerAddresses = make ([]* net.UDPAddr , 4 )
215216 g .GameData .BufferSize = []uint32 {3 , 3 , 3 , 3 }
216217 g .GameData .BufferHealth = []int32 {- 1 , - 1 , - 1 , - 1 }
217- g .GameData .Inputs = make ([]* lru.Cache [uint32 , InputData ], 4 ) //nolint:gomnd,mnd
218+ g .GameData .Inputs = make ([]* lru.Cache [uint32 , InputData ], 4 )
218219 for i := range 4 {
219220 g .GameData .Inputs [i ], _ = lru.New [uint32 , InputData ](InputDataMax )
220221 }
221- g .GameData .PendingInput = make ([]uint32 , 4 ) //nolint:gomnd,mnd
222- g .GameData .PendingPlugin = make ([]byte , 4 ) //nolint:gomnd,mnd
222+ g .GameData .PendingInput = make ([]uint32 , 4 )
223+ g .GameData .PendingPlugin = make ([]byte , 4 )
223224 g .GameData .SyncValues = make (map [uint32 ][]byte )
224- g .GameData .PlayerAlive = make ([]bool , 4 ) //nolint:gomnd,mnd
225- g .GameData .CountLag = make ([]uint32 , 4 ) //nolint:gomnd,mnd
225+ g .GameData .PlayerAlive = make ([]bool , 4 )
226+ g .GameData .CountLag = make ([]uint32 , 4 )
226227
227228 go g .watchUDP ()
228229 return nil
0 commit comments