PocketRelay / Server

Mass Effect 3 Rust Server Emulator, LAN and WAN private server
https://pocket-relay.pages.dev/
MIT License
12 stars 4 forks source link

Calculate Game Protocol Version Hash #59

Closed Aim4kill closed 9 months ago

Aim4kill commented 9 months ago

https://github.com/PocketRelay/Server/blob/b616a71fa916d6e237119178d16823ed0b30a3a7/src/session/models/game_manager.rs#L643

In my own blaze emulator i am using this to calculate the game protocol version hash, here you can see it in C#. It appears to be FNV1 hash but in a bit different way. When i tested this against EA generated hashes, they were matching.

I am not familiar with Rust at all, so it is better i let it up to you to implement it :D

        public static ulong GetGameProtocolVersionHash(string protocolVersion)
        {
            protocolVersion ??= string.Empty;
            //FNV1 HASH - the same hashing logic is used in ea blaze for game protocol versions
            byte[] buf = Encoding.UTF8.GetBytes(protocolVersion);
            ulong hash = 2166136261UL;
            foreach (byte c in buf)
                hash = (hash * 16777619) ^ c;
            return hash;
        }
jacobtread commented 9 months ago

Thanks, implemented in https://github.com/PocketRelay/Server/commit/398410d7237c8da073a7b8ffa67fe6cf82c4f505