Skip to content

Commit

Permalink
Apply changes meant for 4.2.5-post4 (#96)
Browse files Browse the repository at this point in the history
* Fix #86, #87, #88, #89

* Prevent <ALL> as a valid area name+Bump up version

* Remove staff check for debug+Disable debug
  • Loading branch information
Chrezm authored Sep 10, 2020
1 parent f355d5d commit 832ce7d
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 45 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,5 +482,10 @@
* Changed wording of GM login notifications and /minimap
* Added support for new colors available in DRO as well as the set position SP packet
* Removed deprecated AO commands
* Dropped Python 3.6 support
* Fixed scream_range in area list yaml files not supporting the keyword '<ALL>' to indicate all areas should be able to receive a scream coming from a particular area
* Fixed /scream, /whisper and /party_whisper raising errors if a message was sent to a deafened player with a bypass message starter. They now send messages but filtered.
* Fixed blankposts or double empty spaces being filtered out for deafened players
* Fixed wrongly formatted OOC notifications being sent if a player moves to an area where there are players bleeding and sneaking, and players bleeding but not sneaking
* Fixed GMs blinding, deafening or gagging themselves receiving two notifications
* Fixed area lists containing <ALL> as an area name loading without raising errors
* Dropped Python 3.6 support
8 changes: 7 additions & 1 deletion server/area_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,12 @@ def load_areas(self, area_list_file='config/areas.yaml'):
info = 'Area {} has no background.'.format(item['area'])
raise AreaError(info)

# Prevent <ALL> as a valid area name (it has a special meaning)
if item['area'] == '<ALL>':
info = ('An area in your area list is called `<ALL>`. This is a reserved name, '
'thus it is not a valid area name. Please change its name and try again.')
raise AreaError(info)

# Check unset optional parameters
for param in def_param:
if param not in item:
Expand Down Expand Up @@ -1023,7 +1029,7 @@ def load_areas(self, area_list_file='config/areas.yaml'):
unrecognized_areas = reachable_areas-temp_area_names
if unrecognized_areas:
info = (f'Area `{name}` has unrecognized areas {unrecognized_areas} defined as '
f'areas player can reach to. Please rename the affected areas and try '
f'areas a player can reach to. Please rename the affected areas and try '
f'again.')
raise AreaError(info)

Expand Down
8 changes: 7 additions & 1 deletion server/client_changearea.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,13 @@ def notify_me_blood(self, area, changed_visibility=True, changed_hearing=True) -
# 3. It is not the same as the visible info (To avoid double 'hear faint drops')
if vis_info:
if sne_info and sne_info != 'You smell blood' and vis_info != sne_info:
bleeding_info = '{}, and {}'.format(vis_info, sne_info.lower())
if client.is_staff():
# This has (X) no matter what courtesy of sne_info
# Move (X) to the beginning of vis_info if needed
vis_info = f'(X) {vis_info}' if not vis_info.startswith('(X)') else vis_info
sne_info = sne_info.replace('(X) ', '', 1)
sne_info = sne_info[0].lower() + sne_info[1:]
bleeding_info = '{}, and {}'.format(vis_info, sne_info)
else:
bleeding_info = vis_info
else:
Expand Down
15 changes: 9 additions & 6 deletions server/client_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ def pop_if_there(dictionary, argument):

# Change "message" parts of IC port
allowed_starters = ('(', '*', '[')
allowed_messages = (' ', ' ')

# Nerf message for deaf
# TEMPORARY: REMOVE FOR 4.3+CLIENT UPDATE
Expand Down Expand Up @@ -372,19 +373,21 @@ def pop_if_there(dictionary, argument):
self.last_ic_received_mine = (sender == self)
self.send_command('MS', *to_send)

def send_ic_others(self, params=None, sender=None, bypass_replace=False, pred=None,
not_to=None, gag_replaced=False, is_staff=None, in_area=None,
to_blind=None, to_deaf=None,
msg=None, pos=None, cid=None, ding=None, color=None, showname=None):
def send_ic_others(self, params=None, sender=None, bypass_replace=False,
bypass_deafened_starters=False, pred=None, not_to=None,
gag_replaced=False, is_staff=None, in_area=None, to_blind=None,
to_deaf=None, msg=None, pos=None, cid=None, ding=None, color=None,
showname=None):

if not_to is None:
not_to = {self}
else:
not_to = not_to.union({self})

for c in self.server.client_manager.clients:
c.send_ic(params=None, sender=sender, bypass_replace=bypass_replace, pred=pred,
not_to=not_to, gag_replaced=gag_replaced, is_staff=is_staff,
c.send_ic(params=None, sender=sender, bypass_replace=bypass_replace,
bypass_deafened_starters=bypass_deafened_starters,
pred=pred, not_to=not_to, gag_replaced=gag_replaced, is_staff=is_staff,
in_area=in_area, to_blind=to_blind, to_deaf=to_deaf,
msg=msg, pos=pos, cid=cid, ding=ding, color=color, showname=showname)

Expand Down
66 changes: 43 additions & 23 deletions server/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,12 +561,19 @@ def ooc_cmd_blind(client: ClientManager.Client, arg: str):
status = {False: 'unblinded', True: 'blinded'}
new_blind = not target.is_blind

client.send_ooc('You have {} {}.'.format(status[new_blind], target.displayname))
target.send_ooc('You have been {}.'.format(status[new_blind]))
target.send_ooc_others('(X) {} [{}] has {} {} ({}).'
.format(client.displayname, client.id, status[new_blind],
target.displayname, target.area.id),
not_to={client}, is_zstaff_flex=True)
if client != target:
client.send_ooc('You have {} {}.'.format(status[new_blind], target.displayname))
target.send_ooc('You have been {}.'.format(status[new_blind]))
target.send_ooc_others('(X) {} [{}] has {} {} ({}).'
.format(client.displayname, client.id, status[new_blind],
target.displayname, target.area.id),
not_to={client}, is_zstaff_flex=True)
else:
client.send_ooc('You have {} yourself.'.format(status[new_blind]))
client.send_ooc_others('(X) {} [{}] has {} themselves ({}).'
.format(client.displayname, client.id, status[new_blind],
client.area.id),
is_zstaff_flex=True)

target.change_blindness(new_blind)

Expand Down Expand Up @@ -1548,12 +1555,19 @@ def ooc_cmd_deafen(client: ClientManager.Client, arg: str):
status = {False: 'undeafened', True: 'deafened'}
new_deaf = not target.is_deaf

client.send_ooc('You have {} {}.'.format(status[new_deaf], target.displayname))
target.send_ooc('You have been {}.'.format(status[new_deaf]))
target.send_ooc_others('(X) {} [{}] has {} {} ({}).'
.format(client.displayname, client.id, status[new_deaf],
target.displayname, target.area.id),
is_zstaff_flex=True, not_to={client})
if client != target:
client.send_ooc('You have {} {}.'.format(status[new_deaf], target.displayname))
target.send_ooc('You have been {}.'.format(status[new_deaf]))
target.send_ooc_others('(X) {} [{}] has {} {} ({}).'
.format(client.displayname, client.id, status[new_deaf],
target.displayname, target.area.id),
is_zstaff_flex=True, not_to={client})
else:
client.send_ooc('You have {} yourself.'.format(status[new_deaf]))
client.send_ooc_others('(X) {} [{}] has {} themselves ({}).'
.format(client.displayname, client.id, status[new_deaf],
client.area.id),
is_zstaff_flex=True)

target.change_deafened(new_deaf)

Expand Down Expand Up @@ -1890,12 +1904,19 @@ def ooc_cmd_gag(client: ClientManager.Client, arg: str):
status = {False: 'ungagged', True: 'gagged'}
new_gagged = not target.is_gagged

client.send_ooc('You have {} {}.'.format(status[new_gagged], target.displayname))
target.send_ooc('You have been {}.'.format(status[new_gagged]))
target.send_ooc_others('(X) {} [{}] has {} {} ({}).'
.format(client.displayname, client.id, status[new_gagged],
target.displayname, target.area.id),
is_zstaff_flex=True, not_to={client})
if client != target:
client.send_ooc('You have {} {}.'.format(status[new_gagged], target.displayname))
target.send_ooc('You have been {}.'.format(status[new_gagged]))
target.send_ooc_others('(X) {} [{}] has {} {} ({}).'
.format(client.displayname, client.id, status[new_gagged],
target.displayname, target.area.id),
is_zstaff_flex=True, not_to={client})
else:
client.send_ooc('You have {} yourself.'.format(status[new_gagged]))
client.send_ooc_others('(X) {} [{}] has {} themselves ({}).'
.format(client.displayname, client.id, status[new_gagged],
client.area.id),
is_zstaff_flex=True)

target.change_gagged(new_gagged)

Expand Down Expand Up @@ -4373,10 +4394,12 @@ def ooc_cmd_scream(client: ClientManager.Client, arg: str):

client.send_ic(msg=arg, pos=client.pos, cid=client.char_id, showname=client.showname)
client.send_ic_others(msg=arg, to_deaf=False, showname=client.showname,
bypass_deafened_starters=True, # send_ic handles nerfing for deafened
pred=lambda c: (not c.muted_global and
(c.area == client.area or
c.area.name in client.area.scream_range)))
client.send_ic_others(msg=arg, to_deaf=True,
bypass_deafened_starters=True, # send_ic handles nerfing for deafened
pred=lambda c: (not c.muted_global and
(c.area == client.area or
c.area.name in client.area.scream_range)))
Expand Down Expand Up @@ -7612,11 +7635,8 @@ def ooc_cmd_exec(client: ClientManager.Client, arg: str):

# IF YOU WANT TO DISABLE /exec: SET debug TO 0 (debug = 0)
# IF YOU WANT TO ENABLE /exec: SET debug TO 1 (debug = 1)
try:
Constants.assert_command(client, arg, is_staff=True)
except:
return None
debug = 1

debug = 0
if not debug:
return None

Expand Down
4 changes: 2 additions & 2 deletions server/tsuserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def __init__(self, protocol=None, client_manager=None, in_test=False):
self.release = 4
self.major_version = 3
self.minor_version = 0
self.segment_version = 'a46'
self.internal_version = 'M200909a'
self.segment_version = 'a47'
self.internal_version = 'M200909b'
version_string = self.get_version_string()
self.software = 'TsuserverDR {}'.format(version_string)
self.version = 'TsuserverDR {} ({})'.format(version_string, self.internal_version)
Expand Down
17 changes: 6 additions & 11 deletions tests/test_senseblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,12 @@ def test_03_canaffectstaff(self):
def test_04_canaffectself(self):
"""
Situation: Authorized user attempts to sense block themselves and succeeds.
TODO: Figure out repetition.
"""

self.c2.ooc('/{} {}'.format(self.sense, 2))
self.c2.assert_ooc('You have {} {}.'.format(self.sense_pp, self.c2_dname))
self.c2.assert_ooc('You have been {}.'.format(self.sense_pp), ooc_over=True)
self.c1.assert_ooc('(X) {} [{}] has {} {} ({}).'
.format(self.c2.displayname, 2, self.sense_pp, self.c2_dname, 4),
self.c2.assert_ooc('You have {} yourself.'.format(self.sense_pp), ooc_over=True)
self.c1.assert_ooc('(X) {} [{}] has {} themselves ({}).'
.format(self.c2_dname, 2, self.sense_pp, 4),
over=True)
self.c0.assert_no_ooc()
self.c3.assert_no_ooc()
Expand Down Expand Up @@ -154,7 +152,6 @@ def test_06_canunaffect(self):
def test_07_canunaffectstaff(self):
"""
Situation: Authorized user attempts to sense unblock a staff member and succeeds.
TODO: Figure out repetition.
"""

self.c2.ooc('/{} {}'.format(self.sense, 1))
Expand All @@ -173,14 +170,12 @@ def test_07_canunaffectstaff(self):
def test_08_canunaffectself(self):
"""
Situation: Authorized user attempts to sense block themselves and succeeds.
TODO: Figure out repetition.
"""

self.c2.ooc('/{} {}'.format(self.sense, 2))
self.c2.assert_ooc('You have un{} {}.'.format(self.sense_pp, self.c2_dname))
self.c2.assert_ooc('You have been un{}.'.format(self.sense_pp), ooc_over=True)
self.c1.assert_ooc('(X) {} [{}] has un{} {} ({}).'
.format(self.c2.displayname, 2, self.sense_pp, self.c2_dname, 4),
self.c2.assert_ooc('You have un{} yourself.'.format(self.sense_pp), ooc_over=True)
self.c1.assert_ooc('(X) {} [{}] has un{} themselves ({}).'
.format(self.c2_dname, 2, self.sense_pp, 4),
over=True)

self.c0.assert_no_ooc()
Expand Down

0 comments on commit 832ce7d

Please sign in to comment.