Skip to content

Commit

Permalink
4.2.5-post5: 4.3.0 backport (#110)
Browse files Browse the repository at this point in the history
* Basic backporting

* Finish backporting

* Update date
  • Loading branch information
Chrezm authored Dec 17, 2020
1 parent 726013e commit 10aea5a
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 54 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,4 +474,7 @@

### 201215a (4.2.5-post4)
* Fixed allowing zero-width characters in OOC names and shownames
* Fixed illegal OOC names being associated with clients, even after being notified they are invalid
* Fixed illegal OOC names being associated with clients, even after being notified they are invalid

### 201217a (4.2.5-post5)
* Backported 4.3.0 recognition of DRO 1.0.0 protocol and clearing of IC on area changes/blinding
92 changes: 44 additions & 48 deletions server/aoprotocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,28 @@ def net_cmd_id(self, args):
"""

self.client.can_join += 1 # One of two conditions to allow joining
def check_client_version():
self.client.is_ao2 = False
self.client.can_join += 1 # One of two conditions to allow joining

def check_client_version():
if len(args) < 2:
self.client.version = ('AO2', '2.4.x')
self.client.version = ('DRO', '1.0.0')
return False

self.client.version = (args[0], args[1])

software = args[0]
version_list = args[1].split('.')
if len(version_list) < 3:

# Identify version number
if len(version_list) >= 3:
# Such versions include DRO and AO
release = int(version_list[0])
major = int(version_list[1])
minor = int(version_list[2])

if args[0] not in ['DRO', 'AO2']:
return False
else:
# Only such version recognized now is CC
# CC has args[1] == 'CC - Update (\d+\.)*\d+'
if args[1].startswith('CC'):
Expand All @@ -241,59 +252,44 @@ def check_client_version():
minor = 0
else:
return False
else:
release = int(version_list[0])
major = int(version_list[1])
minor = int(version_list[2])

# Versions of Attorney Online prior to 2.2.5 should not receive the new client
# instructions implemented in 2.2.5
if args[0] != 'AO2':
return False
if release < 2:
return False
if software == 'DRO':
self.client.packet_handler = Clients.ClientDRO1d0d0
else: # AO2 protocol
if release == 2:
if major < 2:
return False
if major == 2:
if minor < 5:
return False

self.client.is_ao2 = True
self.client.send_command('FL', 'yellowtext', 'customobjections', 'flipping',
'fastloading', 'noencryption', 'deskmod', 'evidence',
'cccc_ic_support', 'looping_sfx', 'additive', 'effects')

if release == 2:
if major >= 8 and major >= 4:
self.client.packet_handler = Clients.ClientAO2d8d4
elif major >= 8: # KFO
self.client.packet_handler = Clients.ClientKFO2d8
elif major == 7: # AO 2.7
self.client.packet_handler = Clients.ClientAO2d7
elif major == 6: # AO 2.6
self.client.packet_handler = Clients.ClientAO2d6
elif major == 4 and minor >= 8: # DRO
self.client.packet_handler = Clients.ClientDRO
else:
return False # Unrecognized
elif release == 'CC':
if major >= 24:
self.client.packet_handler = Clients.ClientCC24
elif major >= 22:
self.client.packet_handler = Clients.ClientCC22
else:
return False # Unrecognized
if major >= 8 and major >= 4:
self.client.packet_handler = Clients.ClientAO2d8d4
elif major >= 8: # KFO
self.client.packet_handler = Clients.ClientKFO2d8
elif major == 7: # AO 2.7
self.client.packet_handler = Clients.ClientAO2d7
elif major == 6: # AO 2.6
self.client.packet_handler = Clients.ClientAO2d6
elif major == 4 and minor == 8: # Older DRO
self.client.packet_handler = Clients.ClientDROLegacy
else:
return False # Unrecognized
elif release == 'CC':
if major >= 24:
self.client.packet_handler = Clients.ClientCC24
elif major >= 22:
self.client.packet_handler = Clients.ClientCC22
else:
return False # Unrecognized
# The only way to make it here is if we have not returned False
# If that is the case, we have successfully found a version
return True

if not check_client_version():
# Warn player they are using an unknown client.
# Assume a DRO client instruction set.
self.client.packet_handler = Clients.ClientDRO
self.client.packet_handler = Clients.ClientDRO1d0d0
self.client.bad_version = True

self.client.send_command('FL', 'yellowtext', 'customobjections', 'flipping',
'fastloading', 'noencryption', 'deskmod', 'evidence',
'cccc_ic_support', 'looping_sfx', 'additive', 'effects')

def net_cmd_ch(self, _):
""" Periodically checks the connection.
Expand Down Expand Up @@ -755,7 +751,7 @@ def net_cmd_mc(self, args):
# We have to use fallback protocols for AO2d6 like clients, because if for whatever
# reason if they don't set an in-client showname, they send less arguments. In
# particular, they behave like DRO.
pargs = self.process_arguments('MC', args, fallback_protocols=[Clients.ClientDRO])
pargs = self.process_arguments('MC', args, fallback_protocols=[Clients.ClientDROLegacy])
if not pargs:
return

Expand Down
6 changes: 5 additions & 1 deletion server/client_changearea.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,12 @@ def change_area(self, area, override_all=False, override_passages=False,

client.send_command('HP', 1, client.area.hp_def)
client.send_command('HP', 2, client.area.hp_pro)
client.send_background(name=client.area.background)
if client.is_blind:
client.send_background(name=client.server.config['blackout_background'])
else:
client.send_background(name=client.area.background)
client.send_command('LE', *client.area.get_evidence_list(client))
client.send_ic_blankpost()

if client.followedby and not ignore_followers and not override_all:
for c in client.followedby:
Expand Down
7 changes: 6 additions & 1 deletion server/client_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, server, transport, user_id, ipid, my_protocol=None, ip=None):
self.can_join = 0 # Needs to be 2 to actually connect
self.can_askchaa = True # Needs to be true to process an askchaa packet
self.version = ('Undefined', 'Undefined') # AO version used, established through ID pack
self.packet_handler = Clients.ClientDRO
self.packet_handler = Clients.ClientDROLegacy
self.bad_version = False

self.hdid = ''
Expand Down Expand Up @@ -374,6 +374,10 @@ def send_ic_others(self, ic_params=None, params=None, sender=None, bypass_replac
in_area=in_area, to_blind=to_blind, to_deaf=to_deaf,
msg=msg, pos=pos, cid=cid, ding=ding, color=color, showname=showname)

def send_ic_blankpost(self):
if self.packet_handler == Clients.ClientDRO1d0d0:
self.send_ic(msg='', bypass_replace=True)

def send_background(self, name=None, pos=None):
"""
Send a background packet to a client.
Expand Down Expand Up @@ -553,6 +557,7 @@ def change_blindness(self, blind):

if self.is_blind:
self.send_background(name=self.server.config['blackout_background'])
self.send_ic_blankpost() # Clear screen
else:
self.send_background(name=self.area.background)

Expand Down
55 changes: 54 additions & 1 deletion server/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,60 @@ def async_name(self):
return 'as_effect_{}'.format(self.name.lower())

class Clients():
class ClientDRO(Enum):
class ClientDRO1d0d0(Enum):
MS_INBOUND = [
('msg_type', ArgType.STR), # 0
('pre', ArgType.STR_OR_EMPTY), # 1
('folder', ArgType.STR), # 2
('anim', ArgType.STR), # 3
('text', ArgType.STR), # 4
('pos', ArgType.STR), # 5
('sfx', ArgType.STR), # 6
('anim_type', ArgType.INT), # 7
('cid', ArgType.INT), # 8
('sfx_delay', ArgType.INT), # 9
('button', ArgType.INT), # 10
('evidence', ArgType.INT), # 11
('flip', ArgType.INT), # 12
('ding', ArgType.INT), # 13
('color', ArgType.INT), # 14
]

MS_OUTBOUND = [
('msg_type', 0), # 0
('pre', '-'), # 1
('folder', '<NOCHAR>'), # 2
('anim', '../../misc/blank'), # 3
('msg', ''), # 4
('pos', 'jud'), # 5
('sfx', 0), # 6
('anim_type', 0), # 7
('cid', -1), # 8
('sfx_delay', 0), # 9
('button', 0), # 10
('evidence', 0), # 11
('flip', 0), # 12
('ding', -1), # 13
('color', 0), # 14
('showname', ' '), # 15
]

MC_INBOUND = [
('name', ArgType.STR), # 0
('cid', ArgType.INT), # 1
]

MC_OUTBOUND = [
('name', ''), # 0
('cid', -1), # 1
('showname', ''), # 2
]

BN_OUTBOUND = [
('name', ''), # 0
]

class ClientDROLegacy(Enum):
MS_INBOUND = [
('msg_type', ArgType.STR), #0
('pre', ArgType.STR_OR_EMPTY), #1
Expand Down
4 changes: 2 additions & 2 deletions server/tsuserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def __init__(self, protocol=None, client_manager=None, in_test=False):
self.release = 4
self.major_version = 2
self.minor_version = 5
self.segment_version = 'post4'
self.internal_version = '201215a'
self.segment_version = 'post5'
self.internal_version = '201217a'
version_string = self.get_version_string()
self.software = 'TsuserverDR {}'.format(version_string)
self.version = 'TsuserverDR {} ({})'.format(version_string, self.internal_version)
Expand Down

0 comments on commit 10aea5a

Please sign in to comment.