Skip to content

Commit

Permalink
Fix overlay bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystalwarrior committed Dec 19, 2024
1 parent bd702bd commit 3c7b7e8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
5 changes: 2 additions & 3 deletions server/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions server/client_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
36 changes: 31 additions & 5 deletions server/commands/areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

__all__ = [
"ooc_cmd_overlay",
"ooc_cmd_overlay_clear",
"ooc_cmd_bg",
"ooc_cmd_bgs",
"ooc_cmd_status",
Expand Down Expand Up @@ -40,15 +41,13 @@ def ooc_cmd_overlay(client, arg):
Usage: /overlay <background>
"""
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 (
Expand All @@ -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.
Expand Down

0 comments on commit 3c7b7e8

Please sign in to comment.