Skip to content

Commit

Permalink
Core: remove "names" from multidata (ArchipelagoMW#1928)
Browse files Browse the repository at this point in the history
  • Loading branch information
Berserker66 authored Jul 5, 2023
1 parent e920692 commit d8a8997
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
1 change: 0 additions & 1 deletion Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ def precollect_hint(location):
multidata = {
"slot_data": slot_data,
"slot_info": slot_info,
"names": names, # TODO: remove after 0.3.9
"connect_names": {name: (0, player) for player, name in world.player_name.items()},
"locations": locations_data,
"checks_in_area": checks_in_area,
Expand Down
28 changes: 15 additions & 13 deletions WebHostLib/tracker.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import collections
import datetime
import typing
from typing import Counter, Optional, Dict, Any, Tuple
from typing import Counter, Optional, Dict, Any, Tuple, List
from uuid import UUID

from flask import render_template
from jinja2 import pass_context, runtime
from werkzeug.exceptions import abort

from MultiServer import Context, get_saving_second
from NetUtils import SlotType
from NetUtils import SlotType, NetworkSlot
from Utils import restricted_loads
from worlds import lookup_any_item_id_to_name, lookup_any_location_id_to_name, network_data_package
from worlds.alttp import Items
Expand Down Expand Up @@ -264,16 +264,17 @@ def get_static_room_data(room: Room):
multidata = Context.decompress(room.seed.multidata)
# in > 100 players this can take a bit of time and is the main reason for the cache
locations: Dict[int, Dict[int, Tuple[int, int, int]]] = multidata['locations']
names: Dict[int, Dict[int, str]] = multidata["names"]
games = {}
names: List[List[str]] = multidata.get("names", [])
games = multidata.get("games", {})
groups = {}
custom_locations = {}
custom_items = {}
if "slot_info" in multidata:
games = {slot: slot_info.game for slot, slot_info in multidata["slot_info"].items()}
groups = {slot: slot_info.group_members for slot, slot_info in multidata["slot_info"].items()
slot_info_dict: Dict[int, NetworkSlot] = multidata["slot_info"]
games = {slot: slot_info.game for slot, slot_info in slot_info_dict.items()}
groups = {slot: slot_info.group_members for slot, slot_info in slot_info_dict.items()
if slot_info.type == SlotType.group}

names = [[slot_info.name for slot, slot_info in sorted(slot_info_dict.items())]]
for game in games.values():
if game not in multidata["datapackage"]:
continue
Expand All @@ -290,8 +291,7 @@ def get_static_room_data(room: Room):
{id_: name for name, id_ in game_data["location_name_to_id"].items()})
custom_items.update(
{id_: name for name, id_ in game_data["item_name_to_id"].items()})
elif "games" in multidata:
games = multidata["games"]

seed_checks_in_area = checks_in_area.copy()

use_door_tracker = False
Expand Down Expand Up @@ -341,7 +341,7 @@ def _get_player_tracker(tracker: UUID, tracked_team: int, tracked_player: int, w
precollected_items, games, slot_data, groups, saving_second, custom_locations, custom_items = \
get_static_room_data(room)
player_name = names[tracked_team][tracked_player - 1]
location_to_area = player_location_to_area[tracked_player]
location_to_area = player_location_to_area.get(tracked_player, {})
inventory = collections.Counter()
checks_done = {loc_name: 0 for loc_name in default_locations}

Expand Down Expand Up @@ -373,7 +373,9 @@ def _get_player_tracker(tracker: UUID, tracked_team: int, tracked_player: int, w
if recipient in slots_aimed_at_player: # a check done for the tracked player
attribute_item_solo(inventory, item)
if ms_player == tracked_player: # a check done by the tracked player
checks_done[location_to_area[location]] += 1
area_name = location_to_area.get(location, None)
if area_name:
checks_done[area_name] += 1
checks_done["Total"] += 1
specific_tracker = game_specific_trackers.get(games[tracked_player], None)
if specific_tracker and not want_generic:
Expand Down Expand Up @@ -1508,8 +1510,8 @@ def attribute_item(team: int, recipient: int, item: int):
checks_done[team][player][player_location_to_area[player][location]] += 1
checks_done[team][player]["Total"] += 1
percent_total_checks_done[team][player] = int(
checks_done[team][player]["Total"] / seed_checks_in_area[player]["Total"] * 100) if \
seed_checks_in_area[player]["Total"] else 100
checks_done[team][player]["Total"] / len(player_locations) * 100) if \
player_locations else 100

for (team, player), game_state in multisave.get("client_game_state", {}).items():
if player in groups:
Expand Down

0 comments on commit d8a8997

Please sign in to comment.