diff options
| author | Cerapter <cerap@protonmail.com> | 2018-09-05 17:21:27 +0200 |
|---|---|---|
| committer | Cerapter <cerap@protonmail.com> | 2018-09-05 17:21:27 +0200 |
| commit | 93cd2ad3747ff609e0aa2175a2622afe9ef6b56d (patch) | |
| tree | fbf526448212aeaee293e77ab59e78db8989bc8b /server | |
| parent | 78c339869d64295da3d6aef5577a16f7fdc49b78 (diff) | |
Non-interrupting pres.
Diffstat (limited to 'server')
| -rw-r--r-- | server/aoprotocol.py | 26 | ||||
| -rw-r--r-- | server/area_manager.py | 7 |
2 files changed, 28 insertions, 5 deletions
diff --git a/server/aoprotocol.py b/server/aoprotocol.py index d7a2c6c3..d8d91d2c 100644 --- a/server/aoprotocol.py +++ b/server/aoprotocol.py @@ -346,6 +346,7 @@ class AOProtocol(asyncio.Protocol): showname = "" charid_pair = -1 offset_pair = 0 + nonint_pre = '' elif self.validate_net_cmd(args, self.ArgType.STR, self.ArgType.STR_OR_EMPTY, self.ArgType.STR, self.ArgType.STR, self.ArgType.STR, self.ArgType.STR, self.ArgType.STR, self.ArgType.INT, @@ -355,6 +356,7 @@ class AOProtocol(asyncio.Protocol): msg_type, pre, folder, anim, text, pos, sfx, anim_type, cid, sfx_delay, button, evidence, flip, ding, color, showname = args charid_pair = -1 offset_pair = 0 + nonint_pre = '' if len(showname) > 0 and not self.client.area.showname_changes_allowed: self.client.send_host_message("Showname changes are forbidden in this area!") return @@ -363,8 +365,19 @@ class AOProtocol(asyncio.Protocol): self.ArgType.STR, self.ArgType.STR, self.ArgType.STR, self.ArgType.INT, self.ArgType.INT, self.ArgType.INT, self.ArgType.INT, self.ArgType.INT, self.ArgType.INT, self.ArgType.INT, self.ArgType.INT, self.ArgType.STR_OR_EMPTY, self.ArgType.INT, self.ArgType.INT): - # 1.4.0 validation monstrosity. + # 1.3.5 validation monstrosity. msg_type, pre, folder, anim, text, pos, sfx, anim_type, cid, sfx_delay, button, evidence, flip, ding, color, showname, charid_pair, offset_pair = args + nonint_pre = '' + if len(showname) > 0 and not self.client.area.showname_changes_allowed: + self.client.send_host_message("Showname changes are forbidden in this area!") + return + elif self.validate_net_cmd(args, self.ArgType.STR, self.ArgType.STR_OR_EMPTY, self.ArgType.STR, + self.ArgType.STR, + self.ArgType.STR, self.ArgType.STR, self.ArgType.STR, self.ArgType.INT, + self.ArgType.INT, self.ArgType.INT, self.ArgType.INT, self.ArgType.INT, + self.ArgType.INT, self.ArgType.INT, self.ArgType.INT, self.ArgType.STR_OR_EMPTY, self.ArgType.INT, self.ArgType.INT, self.ArgType.INT): + # 1.4.0 validation monstrosity. + msg_type, pre, folder, anim, text, pos, sfx, anim_type, cid, sfx_delay, button, evidence, flip, ding, color, showname, charid_pair, offset_pair, nonint_pre = args if len(showname) > 0 and not self.client.area.showname_changes_allowed: self.client.send_host_message("Showname changes are forbidden in this area!") return @@ -383,7 +396,7 @@ class AOProtocol(asyncio.Protocol): if text.isspace(): self.client.send_host_message("Blankposting is forbidden in this area, and putting more spaces in does not make it not blankposting.") return - if len(text.replace(' ', '')) < 3 and text != '<' and text != '>': + if len(re.sub(r'[{}\\`|]','', text).replace(' ', '')) < 3 and text != '<' and text != '>': self.client.send_host_message("While that is not a blankpost, it is still pretty spammy. Try forming sentences.") return if msg_type not in ('chat', '0', '1'): @@ -405,6 +418,13 @@ class AOProtocol(asyncio.Protocol): if len(showname) > 15: self.client.send_host_message("Your IC showname is way too long!") return + if self.client.area.non_int_pres_only: + if anim_type == 1 or anim_type == 2: + anim_type = 0 + nonint_pre = 1 + elif anim_type == 6: + anim_type = 5 + nonint_pre = 1 if not self.client.area.shouts_allowed: # Old clients communicate the objecting in anim_type. if anim_type == 2: @@ -471,7 +491,7 @@ class AOProtocol(asyncio.Protocol): self.client.area.send_command('MS', msg_type, pre, folder, anim, msg, pos, sfx, anim_type, cid, sfx_delay, button, self.client.evi_list[evidence], flip, ding, color, showname, - charid_pair, other_folder, other_emote, offset_pair, other_offset, other_flip) + charid_pair, other_folder, other_emote, offset_pair, other_offset, other_flip, nonint_pre) self.client.area.set_next_msg_delay(len(msg)) logger.log_server('[IC][{}][{}]{}'.format(self.client.area.abbreviation, self.client.get_char_name(), msg), self.client) diff --git a/server/area_manager.py b/server/area_manager.py index 6e024f6d..23c43397 100644 --- a/server/area_manager.py +++ b/server/area_manager.py @@ -26,7 +26,7 @@ from server.evidence import EvidenceList class AreaManager: class Area: - def __init__(self, area_id, server, name, background, bg_lock, evidence_mod = 'FFA', locking_allowed = False, iniswap_allowed = True, showname_changes_allowed = False, shouts_allowed = True, jukebox = False, abbreviation = ''): + def __init__(self, area_id, server, name, background, bg_lock, evidence_mod = 'FFA', locking_allowed = False, iniswap_allowed = True, showname_changes_allowed = False, shouts_allowed = True, jukebox = False, abbreviation = '', non_int_pres_only = False): self.iniswap_allowed = iniswap_allowed self.clients = set() self.invite_list = {} @@ -65,6 +65,7 @@ class AreaManager: self.is_locked = False self.blankposting_allowed = True + self.non_int_pres_only = non_int_pres_only self.jukebox = jukebox self.jukebox_votes = [] self.jukebox_prev_char_id = -1 @@ -305,10 +306,12 @@ class AreaManager: item['shouts_allowed'] = True if 'jukebox' not in item: item['jukebox'] = False + if 'noninterrupting_pres' not in item: + item['noninterrupting_pres'] = False if 'abbreviation' not in item: item['abbreviation'] = self.get_generated_abbreviation(item['area']) self.areas.append( - self.Area(self.cur_id, self.server, item['area'], item['background'], item['bglock'], item['evidence_mod'], item['locking_allowed'], item['iniswap_allowed'], item['showname_changes_allowed'], item['shouts_allowed'], item['jukebox'], item['abbreviation'])) + self.Area(self.cur_id, self.server, item['area'], item['background'], item['bglock'], item['evidence_mod'], item['locking_allowed'], item['iniswap_allowed'], item['showname_changes_allowed'], item['shouts_allowed'], item['jukebox'], item['abbreviation'], item['noninterrupting_pres'])) self.cur_id += 1 def default_area(self): |
