Skip to content

Commit 415ba40

Browse files
committed
move purge
1 parent db1357a commit 415ba40

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

internal/gameServer/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ func (g *GameServer) isConnClosed(err error) bool {
9494
}
9595

9696
func (g *GameServer) bufferHealthAverage(playerNumber int) (float32, error) {
97+
defer g.GameData.BufferHealth[playerNumber].Purge()
98+
9799
if g.GameData.BufferHealth[playerNumber].Len() > 0 {
98100
var bufferHealth float32
99101
for _, k := range g.GameData.BufferHealth[playerNumber].Keys() {
@@ -129,7 +131,6 @@ func (g *GameServer) ManageBuffer() {
129131
leadPlayer = i + 1
130132
}
131133
}
132-
g.GameData.BufferHealth[i].Purge()
133134
}
134135
g.GameDataMutex.Unlock()
135136

0 commit comments

Comments
 (0)