Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FFMQ] Fix all checks sending on hard reset + stronger read validation check #4242

Merged
merged 5 commits into from
Nov 25, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions worlds/ffmq/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ def get_flag(data, flag):
bit = int(0x80 / (2 ** (flag % 8)))
return (data[byte] & bit) > 0

def validate_read_state(data1, data2):
validation_array = bytes([0x01, 0x46, 0x46, 0x4D, 0x51, 0x52])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
validation_array = bytes([0x01, 0x46, 0x46, 0x4D, 0x51, 0x52])
validation_array = b"\x01FFMQR"

another way this could be written (not saying one should be preferred over the other)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>>> a = bytes([0x01, 0x46, 0x46, 0x4D, 0x51, 0x52])
>>> b = b"\x01FFMQR"
>>> a == b
True

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to know, i'll keep that in mind for next time


if data1 is None or data2 is None:
return False
for i in range(6):
if data1[i] != validation_array[i] or data2[i] != validation_array[i]:
return False;
return True



class FFMQClient(SNIClient):
game = "Final Fantasy Mystic Quest"
Expand All @@ -67,11 +78,11 @@ async def validate_rom(self, ctx):
async def game_watcher(self, ctx):
from SNIClient import snes_buffered_write, snes_flush_writes, snes_read

check_1 = await snes_read(ctx, 0xF53749, 1)
check_1 = await snes_read(ctx, 0xF53749, 6)
received = await snes_read(ctx, RECEIVED_DATA[0], RECEIVED_DATA[1])
data = await snes_read(ctx, READ_DATA_START, READ_DATA_END - READ_DATA_START)
check_2 = await snes_read(ctx, 0xF53749, 1)
if check_1 != b'\x01' or check_2 != b'\x01':
check_2 = await snes_read(ctx, 0xF53749, 6)
if validate_read_state(check_1, check_2) == False:
wildham0 marked this conversation as resolved.
Show resolved Hide resolved
return

def get_range(data_range):
Expand Down
Loading