Merge remote-tracking branch 'origin/master'

This commit is contained in:
Fabian Dill 2020-05-01 16:05:38 +02:00
commit b7b85e1956
5 changed files with 17 additions and 9 deletions

2
.gitignore vendored
View File

@ -20,3 +20,5 @@ weights/
/Players/
/QUsb2Snes/
/options.yaml
_persistent_storage.yaml
mystery_result_*.yaml

View File

@ -597,8 +597,11 @@ async def server_loop(ctx : Context, address = None):
if address is None: # set through CLI or BMBP
address = ctx.server_address
if address is None: # see if this is an old connection
await asyncio.sleep(0.5) # wait for snes connection to succeed if possible.
rom = "".join(chr(x) for x in ctx.rom) if ctx.rom is not None else None
try:
address = Utils.persistent_load()["servers"]["default"]
servers = Utils.persistent_load()["servers"]
address = servers[rom] if rom is not None and rom in servers else servers["default"]
except Exception as e:
logging.debug(f"Could not find cached server address. {e}")
else:
@ -611,8 +614,6 @@ async def server_loop(ctx : Context, address = None):
logging.info('Enter multiworld server address')
address = await console_input(ctx)
Utils.persistent_store("servers", "default", address)
address = f"ws://{address}" if "://" not in address else address
port = urllib.parse.urlparse(address).port or 38281
@ -705,6 +706,8 @@ async def process_server_cmd(ctx : Context, cmd, args):
raise Exception('Connection refused by the multiworld host')
elif cmd == 'Connected':
Utils.persistent_store("servers", "default", ctx.server_address)
Utils.persistent_store("servers", "".join(chr(x) for x in ctx.rom), ctx.server_address)
ctx.team, ctx.slot = args[0]
ctx.player_names = {p: n for p, n in args[1]}
msgs = []

View File

@ -265,7 +265,7 @@ async def on_client_joined(ctx: Context, client: Client):
client.tags))
async def on_client_left(ctx: Context, client: Client):
notify_all(ctx, "%s (Team #%d) has left the game" % (client.name, client.team + 1))
notify_all(ctx, "%s (Team #%d) has left the game" % (ctx.get_aliased_name(client.team, client.slot), client.team + 1))
async def countdown(ctx: Context, timer):
notify_all(ctx, f'[Server]: Starting countdown of {timer}s')
@ -641,7 +641,7 @@ class ClientMessageProcessor(CommandProcessor):
if usable:
new_item = ReceivedItem(Items.item_table[item_name][3], -1, self.client.slot)
get_received_items(self.ctx, self.client.team, self.client.slot).append(new_item)
notify_all(self.ctx, 'Cheat console: sending "' + item_name + '" to ' + self.client.name)
notify_all(self.ctx, 'Cheat console: sending "' + item_name + '" to ' + self.ctx.get_aliased_name(self.client.team, self.client.slot))
send_new_items(self.ctx)
return True
else:
@ -801,7 +801,7 @@ async def process_client_cmd(ctx: Context, client: Client, cmd, args):
elif cmd == 'GameFinished':
if ctx.client_game_state[client.team, client.slot] != CLIENT_GOAL:
finished_msg = f'{client.name} (Team #{client.team + 1}) has found the triforce.'
finished_msg = f'{ctx.get_aliased_name(client.team, client.slot)} (Team #{client.team + 1}) has found the triforce.'
notify_all(ctx, finished_msg)
ctx.client_game_state[client.team, client.slot] = CLIENT_GOAL
@ -836,7 +836,7 @@ class ServerCommandProcessor(CommandProcessor):
for client in self.ctx.clients:
if client.auth and client.name.lower() == player_name.lower() and client.socket and not client.socket.closed:
asyncio.create_task(client.socket.close())
self.output(f"Kicked {client.name}")
self.output(f"Kicked {self.ctx.get_aliased_name(client.team, client.slot)}")
return True
self.output(f"Could not find player {player_name} to kick")
@ -912,7 +912,7 @@ class ServerCommandProcessor(CommandProcessor):
if client.name == seeked_player:
new_item = ReceivedItem(Items.item_table[item][3], -1, client.slot)
get_received_items(self.ctx, client.team, client.slot).append(new_item)
notify_all(self.ctx, 'Cheat console: sending "' + item + '" to ' + client.name)
notify_all(self.ctx, 'Cheat console: sending "' + item + '" to ' + self.ctx.get_aliased_name(client.team, client.slot))
send_new_items(self.ctx)
return True
else:

View File

@ -171,6 +171,7 @@ Ganon1_texts = [
"When I conquer\nthe Light\nWorld, I'll\nhold a parade\nof all my\nmonsters to\ndemonstrate my\nmight to the\npeople!",
"Life, dreams,\nhope...\nWhere'd they\ncome from? And\nwhere are they\nheaded? These\nthings... I am\ngoing to\ndestroy!",
"My minions all\nfailed to\nguard those\nitems?!\n\nWhy am I\nsurrounded by\nincompetent\nfools?!",
"Goose is\nactually the\nterm for\nfemale geese,\nmale geese are\ncalled\nganders.",
]
TavernMan_texts = [
"What do you\ncall a blind\ndinosaur?\na doyouthink-\nhesaurus.",
@ -248,7 +249,7 @@ junk_texts = [
"{C:GREEN}\n> race roms\ndont have\nspoiler logs",
"{C:GREEN}\nI bet a nice\ncup of tea\nwould help! >",
"{C:GREEN}\nI bet you\nexpected help,\ndidn't you? >",
"{C:GREEN}\nLearn to make\nplogues, easy\nand yummy! >"
"{C:GREEN}\nLearn to make\nplogues, easy\nand yummy! >",
]
KingsReturn_texts = [

View File

@ -231,6 +231,8 @@ def persistent_load() -> typing.Dict[dict]:
except Exception as e:
import logging
logging.debug(f"Could not read store: {e}")
if storage is None:
storage = {}
return storage