Make chat spam protection more configurable
As it stands right now, the SRB2 chat spam protection kinda sucks. The spam rate was so short (4 tics, or ~0.11 seconds) that you wouldn't even notice a difference between it being enabled or not. So, to fix this, I went ahead and implemented the Token bucket algorithm and made it more configurable, so you can tweak how sensitive the spam protection should be.
For this, two new variables has been implemented: chatspamspeed
and chatspamburst
. chatspamspeed
affects how fast a player is allowed to send messages in ticks. It defaults to 35, which means that a player can send 1 message per second. chatspamburst
affects how many messages are allowed to be sent in a burst. This effectively means that you can send multiple messages faster than chatspamspeed
, which avoids blocking fast typists that might type faster than a second (a typical example is correcting a typo, in which a single word might be written faster than a second). It defaults to 3, which means 3 messages can be sent in a sequence before spam protection starts blocking messages.
The final change is that spam protection is now configured server-side, which is what you'd want since otherwise you might run into communications problems where some clients have configured their spam protection to be more aggressive than others.