mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-02 04:53:13 +08:00
Merge pull request #35 from Dliwk/character-set-attack-protection
Character-Character-Attack protection
This commit is contained in:
commit
51468a15f6
@ -34,6 +34,9 @@ if TYPE_CHECKING:
|
||||
from typing import Optional, List, Dict, Any, Sequence, Union
|
||||
import ba
|
||||
|
||||
MAX_QUICK_CHANGE_COUNT = 30
|
||||
QUICK_CHANGE_INTERVAL = 0.05
|
||||
|
||||
|
||||
# Hmm should we move this to actors?..
|
||||
class JoinInfo:
|
||||
@ -169,6 +172,7 @@ class Chooser:
|
||||
self._profilenames: List[str] = []
|
||||
self._ready: bool = False
|
||||
self.character_names: List[str] = []
|
||||
self.last_change: Sequence[Union[float, int]] = (0, 0)
|
||||
|
||||
# Hmm does this need to be public?
|
||||
self.profiles: Dict[str, Dict[str, Any]] = {}
|
||||
@ -663,6 +667,14 @@ class Chooser:
|
||||
def handlemessage(self, msg: Any) -> Any:
|
||||
"""Standard generic message handler."""
|
||||
if isinstance(msg, ChangeMessage):
|
||||
now = _ba.time()
|
||||
count = self.last_change[1] + 1
|
||||
if (now - self.last_change[0] < QUICK_CHANGE_INTERVAL
|
||||
and count > MAX_QUICK_CHANGE_COUNT):
|
||||
# Hmm maybe we should notify client?
|
||||
_ba.disconnect_client(
|
||||
self._player.get_input_device().client_id)
|
||||
self.last_change = (now, count)
|
||||
|
||||
# If we've been removed from the lobby, ignore this stuff.
|
||||
if self._dead:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user