efrenmanuel / SacredServer

Trying to make a new lobbying system for sacred games
8 stars 1 forks source link

Is this still being developed? #2

Open pnobbe opened 5 years ago

pnobbe commented 5 years ago

Hi there!

I came across this repo through Steam and I was wondering if you are still working on it since it's been about a month since the last commit.

Would be awesome to see this working eventually :)

efrenmanuel commented 4 years ago

Hi, sorry, yes, it's still on the works, but very slowly as I started classes and I don’t have as much time.

zocker-160 commented 2 years ago

I know this has been a while, but could you give an update on this project state?

Would be willing to help / take over if viable.

EDIT: also what is the license of this project?

efrenmanuel commented 2 years ago

Hi! I guess I did forget to include a license! I am not really working on it, not that I don't intend to never do it but for now I haven't been working on it.

If you feel like you want to work with it, go ahead! I have also found a project similar to this one that had gone quite a bit further with the whole networking stuff... (Altough it was a hub-less approach, just client->server connection). I was completely lost trying to understand the network packets and it turned out to just have been zipped... Hahaha.

If I can find that other project I'll share a link, to see if it'll help.

zocker-160 commented 2 years ago

oh I did not expect such a fast answer on a 2 year old issue, that is great :)

I personally have experience in reverse engineering and was planning to recreate TinCat server for the Settlers games when I came across your project linked over at the darkmatters.org forums in the Scared multiplayer thread while searching for ppl trying to achieve something similar.

There is also a link to one other project https://gitlab.com/drazzle/SacredLTI/-/tree/master which I forked.

Network packages seem to be just compressed by zlib, so it should not be too hard to get things working.

Currently I am planning to do a programming marathon on this around Feb / March next year, so we could work together if you feel like it / have the time (no pressure though, if not then it is all good ;) ).

PS: Sadly darkmatters.org seems dead / unmaintained, as it has an invalid SSL cert since 2018, so I did not post there.

efrenmanuel commented 2 years ago

Sure!

Post here whenever you start and I'll try to join.

I would've liked to recreate Tincat but sadly since all servers are dead I couldn't check the packets, and my reverse engineering skills from a DLL are nonexistent.

This project aimed to use the play on lan feature using an external hub that relayed all the sacred packets between all the players and the server. So pretty much a pseudo VPN .

Something that really halted my progress back then was me not recognizing that the packets were compressed with zlib. Otherwise I do believe that this is quite close to working.

It would certainly be much better to emulate the tincat servers, the url for the hub server is luckily not hardcoded so, if we got one working it should be as easy as telling players to just change a url for another.

pnxr commented 2 years ago

Hello. Appearently watching old issues is totally worth it.

I was about to look into said topic a while ago, but ditched that seeing the SAC client[0] already does a good job for the community. Which I think is pretty much the thing you, efrenmanuel, wanted to build, right?. It's currently down for a few days now and that is pretty much my fault for not finding the issue with my nginx after an update (hope to get it up again soon), but the programming behind it by Alby87 (you can find him btw. on darkmatters or in a discord[1]) is pretty well done and also based on the idea you had. For a few months it was working pretty well and I am sure it will again soon enough. So feel happy knowing your approach works, efrenmanuel :)

Considering the great effort it would have ment for me, as I am software developer, but not with much experience in reverse engineering and usually short on time anyway, I was kind of happy i did not have to look into Tincat2, for me that was the perfect excuse... ;) However, if you are able to do it, it would still be awesome to have the real thing back, without client side changes or like in this case additional software clients needed which would be possible having the code and getting the related domain still hardcoded in every sacred installations config file.

And one more thing: Darkmatters may not be maintained best, but it's far from dead - if you search people for working on something like this, there and maybe in previously linked discord are imho your best bets. I was asking at darkmatters round about two years ago for some information regarding reverse engineering the lobby for Sacred 2 and how to maybe even start it - and the guy who finally responded, had already done the job which was a massive surprise to me and since then I am just hosting his lobby code. There are certainly a few skilled people on that board to find, even if they don't care well for their forums cert :D

Also, not sure if it helps, but maybe some network packet related stuff from Tincat3/Sacred2 is similar in some regards to Tincat2/Sacred? Because you could use this then maybe as a helpful reference [2]

[0] https://github.com/Alby1987/SacredAncariaConnection , https://sac.s2cm.net/ [1] https://discord.gg/Duu4B8tgjv [2] https://github.com/pnxr/sacred2-lobby-emulator/tree/development/S2Library/Protocol

efrenmanuel commented 2 years ago

Now that's fun!

I'm happy to see someone managed to make it!

I do think that the most interesting part of what you said is the tincat3 emulator... I hope it is similar to tincat2, but I doubt so... nevertheless, worth looking into.

I'll do some research to see if someone worked in tincat2, it would be really interesting to get native lobbies working again.

zocker-160 commented 2 years ago

interesting, thank you for the links @pnxr I will check it out. \ I personally am only really interested in doing a "proper" server implementation without VPN like solutions, because SII AdK does not have a LAN mode and thus relies on a full server reimplementation.

The games I personally am interested in are The Settlers II DNG and AdK, which use tincat2 and 3 respectively.

After doing some first analysis, it looks like that the tincat DLLs are very similar to the ones used by Scared and Scared 2 so everybody would benefit if we manage to pull this off.

PS: I would love to reach out in the Darkmatters forum, but how am I supposed to trust a server my data, when they don't even manage to setup a valid SSL cert.....

zocker-160 commented 2 years ago

dear @efrenmanuel and @pnxr small update from my side. After one month of work my lobby project is done!

Based on the code on @pnxr 's repo I managed to recreate a fully working Settlers II DNG online lobby. The tincat version used by Settlers was very different for some packages but overall similar enough to not require a rewrite.

I also managed to implement a TCP bridge in order to bypass NAT restrictions, maybe that could be used for sacred as well?

Link to the repo / source code in case you want to check it out: https://github.com/zocker-160/settlers2-10th-lobby-emulator

pnxr commented 2 years ago

Hey @zocker-160 , thats great! Nice you got a lobby implemented for Settlers II despite the differences, looks like a lot of effort of yours went into it.

Also big thanks for reporting back! Will definitely look closer into your code, even without owning or playing Settlers II as it seems like you (aside from changes due to the game related stuff itself) also fixed quite a few more general things glancing at your commits.

Your bridge sounds very interesting. For understanding, I looked into your main.py script and get how it is determing free ports and reporting them, but who is calling this /api/request, is the client asking for it by itself?

zocker-160 commented 2 years ago

awesome to see you answering @pnxr !

Your bridge sounds very interesting. For understanding, I looked into your main.py script and get how it is determing free ports and reporting them, but who is calling this /api/request, is the client asking for it by itself?

The port is requested by the game itself. I am achieving that by injecting a custom function into the CreateGamePayload function inside matchmaking.dll and then sending that port to the lobby as part of the package.

You can find the source code here:

https://github.com/zocker-160/the-settlers-10th-anniversary-widescreen-fix/blob/c8f36040de081e782ba4a5f9d468d4d9d5648207/source/Lobby.cpp#L37

together with the injector code, everything is open source :)

I think a setup like this could work for other games as well.