aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorCerapter <cerap@protonmail.com>2018-08-10 00:09:41 +0200
committerCerapter <cerap@protonmail.com>2018-08-10 00:09:41 +0200
commit84da730bcef71aeb0d0944261a44dc289949a74d (patch)
tree950351879eef599cfea17b9df1f17a2097a248d5 /server
parent0280f42f6ea2443757f0aa483322d60a5b2c0b6f (diff)
Music changing now shows your custom showname, if set.
Diffstat (limited to 'server')
-rw-r--r--server/aoprotocol.py11
-rw-r--r--server/area_manager.py12
2 files changed, 20 insertions, 3 deletions
diff --git a/server/aoprotocol.py b/server/aoprotocol.py
index 9b8822b..d26afc9 100644
--- a/server/aoprotocol.py
+++ b/server/aoprotocol.py
@@ -478,7 +478,7 @@ class AOProtocol(asyncio.Protocol):
if not self.client.is_dj:
self.client.send_host_message('You were blockdj\'d by a moderator.')
return
- if not self.validate_net_cmd(args, self.ArgType.STR, self.ArgType.INT):
+ if not self.validate_net_cmd(args, self.ArgType.STR, self.ArgType.INT) and not self.validate_net_cmd(args, self.ArgType.STR, self.ArgType.INT, self.ArgType.STR):
return
if args[1] != self.client.char_id:
return
@@ -487,8 +487,13 @@ class AOProtocol(asyncio.Protocol):
return
try:
name, length = self.server.get_song_data(args[0])
- self.client.area.play_music(name, self.client.char_id, length)
- self.client.area.add_music_playing(self.client, name)
+ if len(args) > 2:
+ showname = args[2]
+ self.client.area.play_music_shownamed(name, self.client.char_id, showname, length)
+ self.client.area.add_music_playing_shownamed(self.client, showname, name)
+ else:
+ self.client.area.play_music(name, self.client.char_id, length)
+ self.client.area.add_music_playing(self.client, name)
logger.log_server('[{}][{}]Changed music to {}.'
.format(self.client.area.id, self.client.get_char_name(), name), self.client)
except ServerError:
diff --git a/server/area_manager.py b/server/area_manager.py
index 3ed543d..99b4efd 100644
--- a/server/area_manager.py
+++ b/server/area_manager.py
@@ -116,6 +116,14 @@ class AreaManager:
if length > 0:
self.music_looper = asyncio.get_event_loop().call_later(length,
lambda: self.play_music(name, -1, length))
+
+ def play_music_shownamed(self, name, cid, showname, length=-1):
+ self.send_command('MC', name, cid, showname)
+ if self.music_looper:
+ self.music_looper.cancel()
+ if length > 0:
+ self.music_looper = asyncio.get_event_loop().call_later(length,
+ lambda: self.play_music(name, -1, length))
def can_send_message(self, client):
@@ -159,6 +167,10 @@ class AreaManager:
self.current_music_player = client.get_char_name()
self.current_music = name
+ def add_music_playing_shownamed(self, client, showname, name):
+ self.current_music_player = showname + " (" + client.get_char_name() + ")"
+ self.current_music = name
+
def get_evidence_list(self, client):
client.evi_list, evi_list = self.evi_list.create_evi_list(client)
return evi_list