[Feature]: Verify mod file sync on game start
- Dominant language
- Lua
- Stars
- 264
- Forks
- 260
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 21
Description
### 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
0. The function would start from `gamemain` `CreateUI`.
1. Use `DiskGetFileInfo` to get the byte count of a file and also use the filepath as a salt.
2. Calculate a hash from the two values.
3. Repeat 1-2 for all files from a mod, then add up the hashes.
4. Repeat for all sim mods, saving the data to a table.
5. 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](https://en.wikipedia.org/wiki/Cyclic_redundancy_check) 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.
Contributor guide
Assessment
This issue has not been assessed yet.