nomnomab / lc-project-patcher

A tool to generate a usable Unity project for Lethal Company modding.
GNU General Public License v3.0
33 stars 4 forks source link

[INTERNAL QUESTION NOT AN ISSUE] - How does the game comunicates when LAN? #6

Closed Cuphead74832 closed 5 months ago

Cuphead74832 commented 6 months ago

I am posting this here because if someone managed to make a decompiler they might know the answer. Basically i am wondering how does lethal LAN communicates. By that i mean how does the client handshakes the host? Is it in JSON? and how does it communicate.

I am trying to create a NodeJS short program that will just make the game think its an actual game server and atleast make it to the ship. Then try to land that ship and do stuff but we start basic by making it to lobby.

If you creator or someone else knows this answer please leave the handshake request as JSON (if its a JSON of course otherwise i wont mind if you tell me the request type) and the way to communicate to game in your comment so i can try.

nomnomab commented 6 months ago

For LAN the game uses Unity's Transport (and for online it uses the Facepunch Transport instead).

image

I'm not super network savvy, so not sure about the handshake stuff, but hopefully that helps you find info into what you are wanting.

ArjixWasTaken commented 6 months ago

I am also interested in making a dedicated server!

But would NodeJS be the best for such a thing? A compiled language like Go or Rust might be better.

Edit: since we know nothing about the unity transport, ig a prototype in nodejs would be ok.

ArjixWasTaken commented 6 months ago

I made the game connect to my udp server (using a custom made mod), and this is what it sends when it tries to connect. image

It is displayed in hex because it is not a string. Note that the payload is different after every connection, indicating that it is a generated value, like an ID.

ArjixWasTaken commented 6 months ago

From my small investigation, it appears to be sending this structure. image

Or at least that is what unity provides to the developer upon a request.

ArjixWasTaken commented 6 months ago

I failed to parse that structure, it may be encoded in some way I am not aware of. Nevermind, that structure is initialised in code, the payload can be anything the game developer wants it to be! Nevermind yet again, it is serialized/deserialized by unity.

ArjixWasTaken commented 6 months ago

Aha!

The 10 byte message is a UDP Header!

namespace Unity.Networking.Transport.Protocols
{
    // Token: 0x020000A6 RID: 166
    internal struct UdpCHeader
    {
        // Token: 0x0400022C RID: 556
        public const int Length = 10;

        // Token: 0x0400022D RID: 557
        public byte Type;

        // Token: 0x0400022E RID: 558
        public UdpCHeader.HeaderFlags Flags;

        // Token: 0x0400022F RID: 559
        public SessionIdToken SessionToken;

        // Token: 0x020000A7 RID: 167
        [Flags]
        public enum HeaderFlags : byte
        {
            // Token: 0x04000231 RID: 561
            HasConnectToken = 1,
            // Token: 0x04000232 RID: 562
            HasPipeline = 2
        }
    }
}
ArjixWasTaken commented 6 months ago

Now I call this some progress, hehe image

I made a discord server for further progress reports and general communication. https://discord.gg/UhtkBJv9dQ

Edit: Here is the repo as well!

Cuphead74832 commented 6 months ago

Now I call this some progress, hehe image

I made a discord server for further progress reports and general communication. https://discord.gg/UhtkBJv9dQ

Edit: Here is the repo as well!

HOLY ** DUDE.

Cuphead74832 commented 6 months ago

Guys keep this issue opened this is indeed not an issue this is progress that shows the power of the project. Someone is managing to make a dedicated (somehow) server and i want this to be opened for him to keep updating its progress.