From 3c7b7e8fe463da8885e8c54e7a41028ea254ca21 Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Thu, 19 Dec 2024 03:04:57 +0300 Subject: [PATCH] Fix overlay bugs --- server/area.py | 5 ++--- server/client_manager.py | 9 +++++---- server/commands/areas.py | 36 +++++++++++++++++++++++++++++++----- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/server/area.py b/server/area.py index bd3a23a1..29c86308 100644 --- a/server/area.py +++ b/server/area.py @@ -1676,7 +1676,7 @@ def change_hp(self, side, val): self.hp_pro = val self.send_command("HP", side, val) - def change_background(self, bg, overlay="", mode=2): + def change_background(self, bg, overlay="", mode=1): """ Set the background and/or overlay. @@ -1729,8 +1729,7 @@ def change_background(self, bg, overlay="", mode=2): if client.pos not in self.pos_lock: client.change_position(self.pos_lock[0]) - if overlay != "": - self.overlay = overlay + self.overlay = overlay for client in self.clients: client.send_command("BN", bg, client.pos, self.overlay, mode) diff --git a/server/client_manager.py b/server/client_manager.py index 36f658bc..e68e2111 100644 --- a/server/client_manager.py +++ b/server/client_manager.py @@ -939,9 +939,10 @@ def set_area(self, area, target_pos=""): # Send the background information if self.area.dark: - self.send_command("BN", self.area.background_dark, self.pos) + # TODO: separate dark area overlays + self.send_command("BN", self.area.background_dark, self.pos, self.area.overlay, 1) else: - self.send_command("BN", self.area.background, self.pos) + self.send_command("BN", self.area.background, self.pos, self.area.overlay, 1) if len(self.area.pos_lock) > 0: # set that juicy pos dropdown @@ -1714,9 +1715,9 @@ def send_done(self): self.send_command("HP", 2, self.area.hp_pro) if self.area.dark: self.send_command( - "BN", self.area.background_dark, self.area.pos_dark) + "BN", self.area.background_dark, self.area.pos_dark, self.area.overlay, 1) else: - self.send_command("BN", self.area.background, self.pos) + self.send_command("BN", self.area.background, self.pos, self.area.overlay, 1) self.send_command("LE", *self.area.get_evidence_list(self)) self.send_command("MM", 1) diff --git a/server/commands/areas.py b/server/commands/areas.py index 4783cd26..9f78ab4a 100644 --- a/server/commands/areas.py +++ b/server/commands/areas.py @@ -8,6 +8,7 @@ __all__ = [ "ooc_cmd_overlay", + "ooc_cmd_overlay_clear", "ooc_cmd_bg", "ooc_cmd_bgs", "ooc_cmd_status", @@ -40,15 +41,13 @@ def ooc_cmd_overlay(client, arg): Usage: /overlay """ if len(arg) == 0: - pos_lock = "" - if len(client.area.pos_lock) > 0: - pos = ", ".join(str(lpos) for lpos in client.area.pos_lock) - pos_lock = f"\nAvailable positions: {pos}." client.send_ooc( - f"Current overlay is {client.area.overlay}.{pos_lock}") + f"Current overlay is {client.area.overlay}. Use /overlay_clear to clear it.") return if client not in client.area.owners and not client.is_mod and client.area.overlay_lock: raise AreaError("This area's overlay system is locked!") + if client not in client.area.owners and not client.is_mod and client.area.bg_lock: + raise AreaError("This area's background is locked!") if client.area.cannot_ic_interact(client): raise AreaError("You are not on the area's invite list!") if ( @@ -67,6 +66,33 @@ def ooc_cmd_overlay(client, arg): f"{client.showname} changed the overlay to {arg}.") database.log_area("overlay", client, client.area, message=arg) +def ooc_cmd_overlay_clear(client, arg): + """ + Clear the overlay of an area. + Usage: /overlay_clear + """ + if client not in client.area.owners and not client.is_mod and client.area.overlay_lock: + raise AreaError("This area's overlay system is locked!") + if client not in client.area.owners and not client.is_mod and client.area.bg_lock: + raise AreaError("This area's background is locked!") + if client.area.cannot_ic_interact(client): + raise AreaError("You are not on the area's invite list!") + if ( + not client.is_mod + and not (client in client.area.owners) + and client.char_id == -1 + ): + raise ClientError("You may not do that while spectating!") + if client.area.dark and not client.is_mod and not (client in client.area.owners): + raise ClientError("You must be authorized to do that.") + try: + client.area.change_background(client.area.background, overlay="") + except AreaError: + raise + client.area.broadcast_ooc( + f"{client.showname} cleared the overlay.") + database.log_area("overlay_clear", client, client.area) + def ooc_cmd_bg(client, arg): """ Set the background of an area.