Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Fix testimony recording #197

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions server/area_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,15 @@ def navigate_testimony(self, client: ClientManager.Client, command: str, index:
except ValueError:
client.send_ooc("That does not look like a valid statement number!")
return False
self.send_command('MS', *self.testimony.statements[self.examine_index])
return True
if self.examine_index >= len(self.testimony.statements):
client.send_ooc("There aren't that many statements in the testimony!")
return False
elif self.examine_index <= 0:
client.send_ooc("This statement doesn't exist!")
return False
else:
self.send_command('MS', *self.testimony.statements[self.examine_index])
return True
Comment on lines +799 to +801
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
else:
self.send_command('MS', *self.testimony.statements[self.examine_index])
return True
self.send_command('MS', *self.testimony.statements[self.examine_index])
return True

ah yes, good old bounds checking. no need for else here


class JukeboxVote:
"""Represents a single vote cast for the jukebox."""
Expand Down
91 changes: 53 additions & 38 deletions server/network/aoprotocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,47 @@ def net_cmd_ms(self, args):
"While that is not a blankpost, it is still pretty spammy. Try forming sentences."
)
return

# Here, we check the pair stuff, and save info about it to the client.
# Notably, while we only get a charid_pair and an offset, we send back a chair_pair, an emote, a talker offset
# and an other offset.

self.client.charid_pair = charid_pair
self.client.offset_pair = offset_pair
if anim_type not in (5, 6):
self.client.last_sprite = anim
self.client.flip = flip
self.client.claimed_folder = folder
other_offset = '0'
other_emote = ''
other_flip = 0
other_folder = ''

confirmed = False
if charid_pair > -1:
for target in self.client.area.clients:
if not confirmed and target.char_id == self.client.charid_pair and target.charid_pair == self.client.char_id and target != self.client and target.pos == self.client.pos:
confirmed = True
other_offset = target.offset_pair
other_emote = target.last_sprite
other_flip = target.flip
other_folder = target.claimed_folder
if (pair_order != ""):
charid_pair = "{}^{}".format(charid_pair, pair_order)
break

if not confirmed:
charid_pair = -1
send_args = [msg_type, pre, folder, anim, text,
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, nonint_pre,
sfx_looping, screenshake, frames_shake,
frames_realization, frames_sfx,
additive, effect]
Comment on lines +559 to +567
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the chat args should be turned into a dataclass, it is becoming a hot mess


if text.startswith('/a '): # Send a message to a specific area the client is CM in
part = text.split(' ')
try:
Expand All @@ -536,6 +577,7 @@ def net_cmd_ms(self, args):
self.client.send_ooc(f'You don\'t own {area.name}!')
return
text = ' '.join(part[2:])
send_args[4] = text
except ValueError:
self.client.send_ooc(
"That does not look like a valid area ID!")
Expand All @@ -549,31 +591,36 @@ def net_cmd_ms(self, args):
self.client.send_ooc('You don\'t any areas!')
return
text = ' '.join(part[1:])
send_args[4] = text
elif text.startswith('/testify '): # Start a new testimony in this area.
part = text.split(' ')
text = ' '.join(part[1:]) # remove command
send_args[4] = text
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this line meaningful if send_args[4] is modified immediately afterward again

if not self.client.area.start_testimony(self.client, text):
return
text = '~~-- ' + text + ' --'
send_args[4] = text
color = 3 # orange
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you need to write the color to the recording as well

Copy link
Contributor Author

@Lernos Lernos Jun 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, because the recording doesn't ever replay the testimony title the way it was said, instead the person who issues the /examine command in IC "says" the title which is passed in plain text, and the orange color is automatically applied to that

elif text.startswith('/examine'): # Start an examination of this area's testimony.
if not self.client.area.start_examination(self.client):
return
text = '~~-- ' + self.client.area.testimony.title + ' --'
send_args[4] = text
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this line meaningful if nothing is done with send_args here, it will be overshadowed by a new send_args below

color = 3
if self.client.area.is_testifying or self.client.area.is_examining:
if text.startswith('/end'): # End the current testimony or examination.
if not self.client.area.end_testimony(self.client):
return
text = ''
send_args[4] = text
elif text.startswith('/amend '):
part = text.split(' ')
text = ' '.join(part[2:])
args[4] = text
send_args[4] = text
color = 1
try:
index = int(part[1])
if not self.client.area.amend_testimony(self.client, index, args):
if not self.client.area.amend_testimony(self.client, index, send_args):
return
if self.client.area.is_testifying:
return # don't send it again or it'll be rerecorded
Expand All @@ -586,11 +633,11 @@ def net_cmd_ms(self, args):
elif text.startswith('/insert '):
part = text.split(' ')
text = ' '.join(part[2:])
args[4] = text
send_args[4] = text
color = 1
try:
index = int(part[1])
if not self.client.area.insert_testimony(self.client, index, args):
if not self.client.area.insert_testimony(self.client, index, send_args):
return
if self.client.area.is_testifying:
return # don't send it again or it'll be rerecorded
Expand All @@ -603,8 +650,8 @@ def net_cmd_ms(self, args):
elif text.startswith('/add ') and self.client.area.is_examining:
part = text.split(' ')
text = ' '.join(part[1:])
args[4] = text
self.client.area.testimony.add_statement(tuple(args))
send_args[4] = text
self.client.area.testimony.add_statement(tuple(send_args))
color = 1 # green
self.client.area.examine_index = len(self.client.area.testimony.statements) - 1 # jump to the new statement
elif text.startswith('/remove '):
Expand Down Expand Up @@ -699,38 +746,6 @@ def net_cmd_ms(self, args):
self.client.area.evi_list.evidences[self.client.evi_list[evidence] - 1].pos = 'all'
self.client.area.broadcast_evidence_list()


# Here, we check the pair stuff, and save info about it to the client.
# Notably, while we only get a charid_pair and an offset, we send back a chair_pair, an emote, a talker offset
# and an other offset.

self.client.charid_pair = charid_pair
self.client.offset_pair = offset_pair
if anim_type not in (5, 6):
self.client.last_sprite = anim
self.client.flip = flip
self.client.claimed_folder = folder
other_offset = '0'
other_emote = ''
other_flip = 0
other_folder = ''

confirmed = False
if charid_pair > -1:
for target in self.client.area.clients:
if not confirmed and target.char_id == self.client.charid_pair and target.charid_pair == self.client.char_id and target != self.client and target.pos == self.client.pos:
confirmed = True
other_offset = target.offset_pair
other_emote = target.last_sprite
other_flip = target.flip
other_folder = target.claimed_folder
if (pair_order != ""):
charid_pair = "{}^{}".format(charid_pair, pair_order)
break

if not confirmed:
charid_pair = -1

if self.client in self.client.area.afkers:
self.client.server.client_manager.toggle_afk(self.client)

Expand Down