From 501c55cc2636352645ee3004621af639438ecfa4 Mon Sep 17 00:00:00 2001
From: Fabian Dill <fabian.dill@web.de>
Date: Sat, 17 Apr 2021 21:03:57 +0200
Subject: [PATCH] add per-slot data and embed HK options in it

---
 Main.py          | 11 +++++++++--
 MultiServer.py   |  2 ++
 requirements.txt |  2 +-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/Main.py b/Main.py
index 3430d644..0fd0815d 100644
--- a/Main.py
+++ b/Main.py
@@ -492,8 +492,9 @@ def main(args, seed=None):
             for future in roms:
                 rom_name = future.result()
                 rom_names.append(rom_name)
+            slot_data = {}
             client_versions = {}
-            minimum_versions = {"server": (0, 0, 3), "clients": client_versions}
+            minimum_versions = {"server": (0, 0, 4), "clients": client_versions}
             games = {}
             for slot in world.player_ids:
                 client_versions[slot] = (0, 0, 3)
@@ -505,8 +506,14 @@ def main(args, seed=None):
                 for player, name in enumerate(team, 1):
                     if player not in world.alttp_player_ids:
                         connect_names[name] = (i, player)
-
+            for slot in world.hk_player_ids:
+                slots_data = slot_data[slot] = {}
+                slots_options = slots_data["options"] = {}
+                for option_name in Options.hollow_knight_options:
+                    option = getattr(world, option_name)[slot]
+                    slots_options[option_name] = option.value
             multidata = zlib.compress(pickle.dumps({
+                "slot_data" : slot_data,
                 "games": games,
                 "names": parsed_names,
                 "connect_names": connect_names,
diff --git a/MultiServer.py b/MultiServer.py
index 873970af..fec9aefa 100644
--- a/MultiServer.py
+++ b/MultiServer.py
@@ -146,6 +146,7 @@ class Context(Node):
         self.connect_names = decoded_obj['connect_names']
         self.remote_items = decoded_obj['remote_items']
         self.locations = decoded_obj['locations']
+        self.slot_data = decoded_obj['slot_data']
         self.er_hint_data = {int(player): {int(address): name for address, name in loc_data.items()}
                              for player, loc_data in decoded_obj["er_hint_data"].items()}
         self.games = decoded_obj["games"]
@@ -1023,6 +1024,7 @@ async def process_client_cmd(ctx: Context, client: Client, args: dict):
                 "players": ctx.get_players_package(),
                 "missing_locations": get_missing_checks(ctx, client),
                 "checked_locations": get_checked_checks(ctx, client),
+                "slot_data": ctx.slot_data.get(client.slot, {})
             }]
             items = get_received_items(ctx, client.team, client.slot)
             if items:
diff --git a/requirements.txt b/requirements.txt
index 0ba0a2b4..5309b540 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,7 +2,7 @@ colorama>=0.4.4
 websockets>=8.1
 PyYAML>=5.4.1
 fuzzywuzzy>=0.18.0
-bsdiff4>=1.2.0
+bsdiff4>=1.2.1
 prompt_toolkit>=3.0.18
 appdirs>=1.4.4
 maseya-z3pr>=1.0.0rc1