Fix crash on server chat messages

This commit is contained in:
ChillerDragon 2024-06-21 10:31:43 +08:00
parent 759d37658b
commit ac347f1f39

View file

@ -112,6 +112,10 @@ func (connection *Connection) OnSystemMsg(msg int, chunk chunk7.Chunk, u *packer
} }
func (client *Connection) OnChatMessage(msg *messages7.SvChat) { func (client *Connection) OnChatMessage(msg *messages7.SvChat) {
if msg.ClientId < 0 || msg.ClientId > network7.MaxClients {
fmt.Printf("[chat] *** %s\n", msg.Message)
return
}
name := client.Players[msg.ClientId].Info.Name name := client.Players[msg.ClientId].Info.Name
fmt.Printf("[chat] <%s> %s\n", name, msg.Message) fmt.Printf("[chat] <%s> %s\n", name, msg.Message)
} }