OoT: add version check to lua script + client
This commit is contained in:
parent
ac87629550
commit
8184e99409
21
OoTClient.py
21
OoTClient.py
|
@ -48,6 +48,7 @@ deathlink_sent_this_death: we interacted with the multiworld on this death, wait
|
||||||
|
|
||||||
oot_loc_name_to_id = network_data_package["games"]["Ocarina of Time"]["location_name_to_id"]
|
oot_loc_name_to_id = network_data_package["games"]["Ocarina of Time"]["location_name_to_id"]
|
||||||
|
|
||||||
|
script_version: int = 1
|
||||||
|
|
||||||
def get_item_value(ap_id):
|
def get_item_value(ap_id):
|
||||||
return ap_id - 66000
|
return ap_id - 66000
|
||||||
|
@ -78,6 +79,7 @@ class OoTContext(CommonContext):
|
||||||
self.deathlink_enabled = False
|
self.deathlink_enabled = False
|
||||||
self.deathlink_pending = False
|
self.deathlink_pending = False
|
||||||
self.deathlink_sent_this_death = False
|
self.deathlink_sent_this_death = False
|
||||||
|
self.version_warning = False
|
||||||
|
|
||||||
async def server_auth(self, password_requested: bool = False):
|
async def server_auth(self, password_requested: bool = False):
|
||||||
if password_requested and not self.password:
|
if password_requested and not self.password:
|
||||||
|
@ -166,14 +168,17 @@ async def n64_sync_task(ctx: OoTContext):
|
||||||
try:
|
try:
|
||||||
await asyncio.wait_for(writer.drain(), timeout=1.5)
|
await asyncio.wait_for(writer.drain(), timeout=1.5)
|
||||||
try:
|
try:
|
||||||
# Data will return a dict with up to five fields:
|
# Data will return a dict with up to six fields:
|
||||||
# 1. str: player name (always)
|
# 1. str: player name (always)
|
||||||
# 2. bool: deathlink active (always)
|
# 2. int: script version (always)
|
||||||
# 3. dict[str, bool]: checked locations
|
# 3. bool: deathlink active (always)
|
||||||
# 4. bool: whether Link is currently at 0 HP
|
# 4. dict[str, bool]: checked locations
|
||||||
# 5. bool: whether the game currently registers as complete
|
# 5. bool: whether Link is currently at 0 HP
|
||||||
|
# 6. bool: whether the game currently registers as complete
|
||||||
data = await asyncio.wait_for(reader.readline(), timeout=10)
|
data = await asyncio.wait_for(reader.readline(), timeout=10)
|
||||||
data_decoded = json.loads(data.decode())
|
data_decoded = json.loads(data.decode())
|
||||||
|
reported_version = data_decoded.get('scriptVersion', 0)
|
||||||
|
if reported_version == script_version:
|
||||||
if ctx.game is not None and 'locations' in data_decoded:
|
if ctx.game is not None and 'locations' in data_decoded:
|
||||||
# Not just a keep alive ping, parse
|
# Not just a keep alive ping, parse
|
||||||
asyncio.create_task(parse_payload(data_decoded, ctx, False))
|
asyncio.create_task(parse_payload(data_decoded, ctx, False))
|
||||||
|
@ -181,6 +186,12 @@ async def n64_sync_task(ctx: OoTContext):
|
||||||
ctx.auth = data_decoded['playerName']
|
ctx.auth = data_decoded['playerName']
|
||||||
if ctx.awaiting_rom:
|
if ctx.awaiting_rom:
|
||||||
await ctx.server_auth(False)
|
await ctx.server_auth(False)
|
||||||
|
else:
|
||||||
|
if not ctx.version_warning:
|
||||||
|
logger.warning(f"Your Lua script is version {reported_version}, expected {script_version}. "
|
||||||
|
"Please update to the latest version. "
|
||||||
|
"Your connection to the Archipelago server will not be accepted.")
|
||||||
|
ctx.version_warning = True
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
logger.debug("Read Timed Out, Reconnecting")
|
logger.debug("Read Timed Out, Reconnecting")
|
||||||
error_status = CONNECTION_TIMING_OUT_STATUS
|
error_status = CONNECTION_TIMING_OUT_STATUS
|
||||||
|
|
|
@ -2,7 +2,8 @@ local socket = require("socket")
|
||||||
local json = require('json')
|
local json = require('json')
|
||||||
local math = require('math')
|
local math = require('math')
|
||||||
|
|
||||||
local script_version = '2022-03-22' -- Should be the last modified date
|
local last_modified_date = '2022-05-25' -- Should be the last modified date
|
||||||
|
local script_version = 1
|
||||||
|
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
-- Heavily modified form of RiptideSage's tracker
|
-- Heavily modified form of RiptideSage's tracker
|
||||||
|
@ -1781,6 +1782,7 @@ function receive()
|
||||||
-- Determine message to send back
|
-- Determine message to send back
|
||||||
local retTable = {}
|
local retTable = {}
|
||||||
retTable["playerName"] = get_player_name()
|
retTable["playerName"] = get_player_name()
|
||||||
|
retTable["scriptVersion"] = script_version
|
||||||
retTable["deathlinkActive"] = deathlink_enabled()
|
retTable["deathlinkActive"] = deathlink_enabled()
|
||||||
if InSafeState() then
|
if InSafeState() then
|
||||||
retTable["locations"] = check_all_locations(master_quest_table_address)
|
retTable["locations"] = check_all_locations(master_quest_table_address)
|
||||||
|
|
Loading…
Reference in New Issue