Merge branch 'main' into multishop
This commit is contained in:
commit
e2be997866
|
@ -14,6 +14,7 @@ import typing
|
|||
import os
|
||||
import subprocess
|
||||
import re
|
||||
import shutil
|
||||
|
||||
from random import randrange
|
||||
|
||||
|
@ -37,6 +38,8 @@ import WebUI
|
|||
import Regions
|
||||
import Utils
|
||||
|
||||
# logging note:
|
||||
# logging.* gets send to only the text console, logger.* gets send to the WebUI as well, if it's initialized.
|
||||
logger = logging.getLogger("Client")
|
||||
|
||||
|
||||
|
@ -1085,7 +1088,9 @@ class ClientCommandProcessor(CommandProcessor):
|
|||
"""List all missing location checks, from your local game state"""
|
||||
count = 0
|
||||
checked_count = 0
|
||||
for location in Regions.lookup_name_to_id.keys():
|
||||
for location, location_id in Regions.lookup_name_to_id.items():
|
||||
if location_id < 0:
|
||||
continue
|
||||
if location not in self.ctx.locations_checked:
|
||||
if location in self.ctx.items_missing:
|
||||
self.output('Missing: ' + location)
|
||||
|
@ -1186,7 +1191,7 @@ async def track_locations(ctx : Context, roomid, roomdata):
|
|||
if location not in ctx.locations_checked and loc_roomid == roomid and (roomdata << 4) & loc_mask != 0:
|
||||
new_check(location)
|
||||
except Exception as e:
|
||||
logger.info(f"Exception: {e}")
|
||||
logger.exception(f"Exception: {e}")
|
||||
|
||||
uw_begin = 0x129
|
||||
uw_end = 0
|
||||
|
@ -1437,7 +1442,7 @@ async def main():
|
|||
adjustedromfile, adjusted = Utils.get_adjuster_settings(romfile)
|
||||
if adjusted:
|
||||
try:
|
||||
os.replace(adjustedromfile, romfile)
|
||||
shutil.move(adjustedromfile, romfile)
|
||||
adjustedromfile = romfile
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
|
|
|
@ -114,6 +114,7 @@ class Context(Node):
|
|||
self.tags = ['Berserker']
|
||||
self.minimum_client_versions: typing.Dict[typing.Tuple[int, int], Utils.Version] = {}
|
||||
self.lookup_items_id_to_name = Items.lookup_id_to_name
|
||||
self.lookup_items_name_to_id = {value: key for key, value in Items.lookup_id_to_name.items()}
|
||||
self.lookup_region_id_to_name = Regions.lookup_id_to_name
|
||||
self.lookup_region_name_to_id = Regions.lookup_name_to_id
|
||||
self.console_names = console_names
|
||||
|
@ -160,6 +161,7 @@ class Context(Node):
|
|||
if "lookup_items_id_to_name" in jsonobj:
|
||||
lookups["lookup_items_id_to_name"] = True
|
||||
self.lookup_items_id_to_name = jsonobj["lookup_items_id_to_name"]
|
||||
self.lookup_items_name_to_id = {value: key for key, value in self.lookup_items_id_to_name.items()}
|
||||
new_console_names |= set(self.lookup_items_id_to_name.values())
|
||||
|
||||
if "lookup_region_id_to_name" in jsonobj:
|
||||
|
@ -540,8 +542,8 @@ def register_location_checks(ctx: Context, team: int, slot: int, locations):
|
|||
if slot != target_player:
|
||||
ctx.broadcast_team(team, [['ItemSent', (slot, location, target_player, target_item)]])
|
||||
logging.info('(Team #%d) %s sent %s to %s (%s)' % (
|
||||
team + 1, ctx.player_names[(team, slot)], get_item_name_from_id(target_item),
|
||||
ctx.player_names[(team, target_player)], get_location_name_from_address(location)))
|
||||
team + 1, ctx.player_names[(team, slot)], ctx.lookup_items_id_to_name(target_item, f"Unknown item (ID: {target_item})"),
|
||||
ctx.player_names[(team, target_player)], ctx.lookup_region_id_to_name.get(location, f"Unknown location (ID: {location})")))
|
||||
found_items = True
|
||||
elif target_player == slot: # local pickup, notify clients of the pickup
|
||||
if location not in ctx.location_checks[team, slot]:
|
||||
|
@ -595,8 +597,8 @@ def collect_hints_location(ctx: Context, team: int, slot: int, location: str) ->
|
|||
|
||||
def format_hint(ctx: Context, team: int, hint: Utils.Hint) -> str:
|
||||
text = f"[Hint]: {ctx.player_names[team, hint.receiving_player]}'s " \
|
||||
f"{ctx.lookup_items_id_to_name[hint.item]} is " \
|
||||
f"at {get_location_name_from_address(hint.location)} " \
|
||||
f"{ctx.lookup_items_id_to_name.get(hint.item, f'Unknown item (ID:{hint.item})')} is " \
|
||||
f"at {ctx.lookup_region_id_to_name.get(hint.location, f'Unknown location (ID:{hint.location})')} " \
|
||||
f"in {ctx.player_names[team, hint.finding_player]}'s World"
|
||||
|
||||
if hint.entrance:
|
||||
|
@ -900,7 +902,7 @@ class ClientMessageProcessor(CommonCommandProcessor):
|
|||
if self.ctx.item_cheat:
|
||||
item_name, usable, response = get_intended_text(item_name, self.ctx.lookup_items_id_to_name.values())
|
||||
if usable:
|
||||
new_item = ReceivedItem(Items.item_table[item_name][3], -1, self.client.slot)
|
||||
new_item = ReceivedItem(self.ctx.lookup_items_name_to_id[item_name], -1, self.client.slot)
|
||||
get_received_items(self.ctx, self.client.team, self.client.slot).append(new_item)
|
||||
self.ctx.notify_all('Cheat console: sending "' + item_name + '" to ' + self.ctx.get_aliased_name(self.client.team, self.client.slot))
|
||||
send_new_items(self.ctx)
|
||||
|
|
Loading…
Reference in New Issue