Skip to content

[Feature]: Verify mod file sync on game start #6929

@lL1l1

Description

@lL1l1

Describe the Feature

This feature would check that all players have the same files by comparing hashes sent by a hidden chat message at game start. If players have different files it is logged and a window similar to the desync window can pop up to inform the player of what mods have different files.

Expected Behavior

  1. The function would start from gamemain CreateUI.
  2. Use DiskGetFileInfo to get the byte count of a file and also use the filepath as a salt.
  3. Calculate a hash from the two values.
  4. Repeat 1-2 for all files from a mod, then add up the hashes.
  5. Repeat for all sim mods, saving the data to a table.
  6. Send the table to other users.

Now that we send the data, we need to handle it.
0. We can receive the data from either UI or sim:

  • RegisterChatFunc in WldUIProvider.StartWaitingDialog seems to be the most reliable to me.
  • In CreateUI it could miss a message from someone else if the load times aren't synced up?
  • A sim callback would save the data to the replay and guarantee everyone gets it, but I'm not sure how useful it is to have that in the replay.
  1. If we do not yet have our own file info then store the data so it can be checked against once we do have file info.
  2. Once we have file info, compare hashes. Save any mismatched files.
  3. Once all players have sent file info, display mismatched files if there are any (this avoids spamming the window if you mismatch with 5 players for example). If someone disconnects it should remove them as a requirement (uimain UpdateDisconnectDialog).

Screenshots

No response

Additional context

This is inspired by mods that implement file verification:

  • Patch19 by F19: Uses a CRC algorithm UI-side and quits the game if files of active mods mismatch hardcoded values. Gives permission for "any free use"?
  • Total Mayhem: Has sim-side file verification with hardcoded file/byte counts. Also checks for duplicate Total Mayhem mod folders existing (this part doesn't make sense to me). Its code is used by multiple other mods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: uiAnything to do with the User Interface of the Gamefeature: mod compatibilityrelated to FAF compatibility with mods

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions