Core: prepare server for removal of names in multidata (#1430)
This commit is contained in:
parent
803d7105a1
commit
f528175d8a
5
Main.py
5
Main.py
|
@ -13,7 +13,7 @@ from BaseClasses import Item, MultiWorld, CollectionState, Region, RegionType, L
|
||||||
import worlds
|
import worlds
|
||||||
from worlds.alttp.Regions import is_main_entrance
|
from worlds.alttp.Regions import is_main_entrance
|
||||||
from Fill import distribute_items_restrictive, flood_items, balance_multiworld_progression, distribute_planned
|
from Fill import distribute_items_restrictive, flood_items, balance_multiworld_progression, distribute_planned
|
||||||
from worlds.alttp.Shops import SHOP_ID_START, total_shop_slots, FillDisabledShopSlots
|
from worlds.alttp.Shops import FillDisabledShopSlots
|
||||||
from Utils import output_path, get_options, __version__, version_tuple
|
from Utils import output_path, get_options, __version__, version_tuple
|
||||||
from worlds.generic.Rules import locality_rules, exclusion_rules
|
from worlds.generic.Rules import locality_rules, exclusion_rules
|
||||||
from worlds import AutoWorld
|
from worlds import AutoWorld
|
||||||
|
@ -365,8 +365,7 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No
|
||||||
multidata = {
|
multidata = {
|
||||||
"slot_data": slot_data,
|
"slot_data": slot_data,
|
||||||
"slot_info": slot_info,
|
"slot_info": slot_info,
|
||||||
"names": names, # TODO: remove around 0.2.5 in favor of slot_info
|
"names": names, # TODO: remove after 0.3.9
|
||||||
"games": games, # TODO: remove around 0.2.5 in favor of slot_info
|
|
||||||
"connect_names": {name: (0, player) for player, name in world.player_name.items()},
|
"connect_names": {name: (0, player) for player, name in world.player_name.items()},
|
||||||
"locations": locations_data,
|
"locations": locations_data,
|
||||||
"checks_in_area": checks_in_area,
|
"checks_in_area": checks_in_area,
|
||||||
|
|
|
@ -158,6 +158,7 @@ class Context:
|
||||||
stored_data: typing.Dict[str, object]
|
stored_data: typing.Dict[str, object]
|
||||||
read_data: typing.Dict[str, object]
|
read_data: typing.Dict[str, object]
|
||||||
stored_data_notification_clients: typing.Dict[str, typing.Set[Client]]
|
stored_data_notification_clients: typing.Dict[str, typing.Set[Client]]
|
||||||
|
slot_info: typing.Dict[int, NetworkSlot]
|
||||||
|
|
||||||
item_names: typing.Dict[int, str] = Utils.KeyedDefaultDict(lambda code: f'Unknown item (ID:{code})')
|
item_names: typing.Dict[int, str] = Utils.KeyedDefaultDict(lambda code: f'Unknown item (ID:{code})')
|
||||||
item_name_groups: typing.Dict[str, typing.Dict[str, typing.Set[str]]]
|
item_name_groups: typing.Dict[str, typing.Dict[str, typing.Set[str]]]
|
||||||
|
@ -170,7 +171,7 @@ class Context:
|
||||||
remaining_mode: str = "disabled", auto_shutdown: typing.SupportsFloat = 0, compatibility: int = 2,
|
remaining_mode: str = "disabled", auto_shutdown: typing.SupportsFloat = 0, compatibility: int = 2,
|
||||||
log_network: bool = False):
|
log_network: bool = False):
|
||||||
super(Context, self).__init__()
|
super(Context, self).__init__()
|
||||||
self.slot_info: typing.Dict[int, NetworkSlot] = {}
|
self.slot_info = {}
|
||||||
self.log_network = log_network
|
self.log_network = log_network
|
||||||
self.endpoints = []
|
self.endpoints = []
|
||||||
self.clients = {}
|
self.clients = {}
|
||||||
|
@ -378,15 +379,23 @@ class Context:
|
||||||
for player, version in clients_ver.items():
|
for player, version in clients_ver.items():
|
||||||
self.minimum_client_versions[player] = max(Utils.Version(*version), min_client_version)
|
self.minimum_client_versions[player] = max(Utils.Version(*version), min_client_version)
|
||||||
|
|
||||||
self.clients = {}
|
self.slot_info = decoded_obj["slot_info"]
|
||||||
for team, names in enumerate(decoded_obj['names']):
|
self.games = {slot: slot_info.game for slot, slot_info in self.slot_info.items()}
|
||||||
self.clients[team] = {}
|
self.groups = {slot: slot_info.group_members for slot, slot_info in self.slot_info.items()
|
||||||
for player, name in enumerate(names, 1):
|
if slot_info.type == SlotType.group}
|
||||||
self.clients[team][player] = []
|
|
||||||
self.player_names[team, player] = name
|
self.clients = {0: {}}
|
||||||
self.player_name_lookup[name] = team, player
|
slot_info: NetworkSlot
|
||||||
self.read_data[f"hints_{team}_{player}"] = lambda local_team=team, local_player=player: \
|
slot_id: int
|
||||||
list(self.get_rechecked_hints(local_team, local_player))
|
|
||||||
|
team_0 = self.clients[0]
|
||||||
|
for slot_id, slot_info in self.slot_info.items():
|
||||||
|
team_0[slot_id] = []
|
||||||
|
self.player_names[0, slot_id] = slot_info.name
|
||||||
|
self.player_name_lookup[slot_info.name] = 0, slot_id
|
||||||
|
self.read_data[f"hints_{0}_{slot_id}"] = lambda local_team=0, local_player=slot_id: \
|
||||||
|
list(self.get_rechecked_hints(local_team, local_player))
|
||||||
|
|
||||||
self.seed_name = decoded_obj["seed_name"]
|
self.seed_name = decoded_obj["seed_name"]
|
||||||
self.random.seed(self.seed_name)
|
self.random.seed(self.seed_name)
|
||||||
self.connect_names = decoded_obj['connect_names']
|
self.connect_names = decoded_obj['connect_names']
|
||||||
|
@ -401,29 +410,9 @@ class Context:
|
||||||
for slot, item_codes in decoded_obj["precollected_items"].items():
|
for slot, item_codes in decoded_obj["precollected_items"].items():
|
||||||
self.start_inventory[slot] = [NetworkItem(item_code, -2, 0) for item_code in item_codes]
|
self.start_inventory[slot] = [NetworkItem(item_code, -2, 0) for item_code in item_codes]
|
||||||
|
|
||||||
for team in range(len(decoded_obj['names'])):
|
for slot, hints in decoded_obj["precollected_hints"].items():
|
||||||
for slot, hints in decoded_obj["precollected_hints"].items():
|
self.hints[0, slot].update(hints)
|
||||||
self.hints[team, slot].update(hints)
|
|
||||||
if "slot_info" in decoded_obj:
|
|
||||||
self.slot_info = decoded_obj["slot_info"]
|
|
||||||
self.games = {slot: slot_info.game for slot, slot_info in self.slot_info.items()}
|
|
||||||
self.groups = {slot: slot_info.group_members for slot, slot_info in self.slot_info.items()
|
|
||||||
if slot_info.type == SlotType.group}
|
|
||||||
else:
|
|
||||||
self.games = decoded_obj["games"]
|
|
||||||
self.groups = {}
|
|
||||||
self.slot_info = {
|
|
||||||
slot: NetworkSlot(
|
|
||||||
self.player_names[0, slot],
|
|
||||||
self.games[slot],
|
|
||||||
SlotType(int(bool(locations))))
|
|
||||||
for slot, locations in self.locations.items()
|
|
||||||
}
|
|
||||||
# locations may need converting
|
|
||||||
for slot, locations in self.locations.items():
|
|
||||||
for location, item_data in locations.items():
|
|
||||||
if len(item_data) < 3:
|
|
||||||
locations[location] = (*item_data, 0)
|
|
||||||
# declare slots that aren't players as done
|
# declare slots that aren't players as done
|
||||||
for slot, slot_info in self.slot_info.items():
|
for slot, slot_info in self.slot_info.items():
|
||||||
if slot_info.type.always_goal:
|
if slot_info.type.always_goal:
|
||||||
|
|
4
Utils.py
4
Utils.py
|
@ -12,7 +12,7 @@ import io
|
||||||
import collections
|
import collections
|
||||||
import importlib
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
from typing import BinaryIO, ClassVar, Coroutine, Optional, Set
|
from typing import BinaryIO, Coroutine, Optional, Set
|
||||||
|
|
||||||
from yaml import load, load_all, dump, SafeLoader
|
from yaml import load, load_all, dump, SafeLoader
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class Version(typing.NamedTuple):
|
||||||
build: int
|
build: int
|
||||||
|
|
||||||
|
|
||||||
__version__ = "0.3.8"
|
__version__ = "0.3.9"
|
||||||
version_tuple = tuplize_version(__version__)
|
version_tuple = tuplize_version(__version__)
|
||||||
|
|
||||||
is_linux = sys.platform.startswith("linux")
|
is_linux = sys.platform.startswith("linux")
|
||||||
|
|
Loading…
Reference in New Issue