Does anyone know about networking?

Ask here for technical assistance with installing, running, etc. Forum related issues should be reported here, too.
MildewMan1
Colonist
Colonist
Posts: 37
Joined: Sat Jun 27, 2020 3:02 pm
Favourite Race: Tarth
Location: St. Louis, Missouri, USA

Does anyone know about networking?

Post by MildewMan1 »

As many of you know, Deadlock 1 uses NetBios for its multiplayer stuff, which doesn't work after Windows XP. I have been trying to figure out how the DLNET dlls that contain their networking code work because I'd like to try and make a replacement DLL that would accept the same information from the game when called, but wouldn't use NetBios, so that maybe we could get multiplayer working on more recent machines.

I don't really know anything about networking, so I was wondering if there is anyone here that does know it and would want to work on creating something with me because I'd like to understand more about it.

Without me really understanding networking, this doesn't seem like it would be too hard to do.
User avatar
Ubergeneral Grunt
Site Admin
Site Admin
Posts: 189
Joined: Fri Nov 19, 2010 10:20 am
Favourite Race: Tarth
Location: Perth, Western Australia
Contact:

Re: Does anyone know about networking?

Post by Ubergeneral Grunt »

Maybe if you encapsulated the library calls in the DLNET32.DLL it would be possible to pass the IPX commands through to TCP/IP ones, similar to what you did with the WAIL32.DLL. I don't know much about network programming, I only did it at a very basic level in my Computer Science degree.

But maybe it would be easier to go the route Tggtt mentioned of networking VMs running older OSes? The Mac version could hypothetically be networkable using emulators, since it supports TCP/IP already, but the Mac version has never run well in any emulator (Basilisk II, SheepShaver or QEMU) in my experience.

P.S. Welcome to the forum.
Tarth cooks make best strudel, barbecue, bean dip, fish, cat food, smelt, piston rings, tofu and cam shafts...
MildewMan1
Colonist
Colonist
Posts: 37
Joined: Sat Jun 27, 2020 3:02 pm
Favourite Race: Tarth
Location: St. Louis, Missouri, USA

Re: Does anyone know about networking?

Post by MildewMan1 »

Yeah that was my thought. I've already got a DLNET dll setup that Deadlock loads up and then it forwards all of the function calls to the real dll that I renamed something else. I have a rough idea of what data is being passed to it from looking through pseudo code of it, and I am able to look at the data while debugging it. All I need to do at this point is figure out what the full purpose of the dll functions are, so I can try to make something comparable.

My thought was instead of making one player the server and other players the clients, maybe make an independent server that can be run outside of Deadlock and then have the players connect to that, so all players are clients. Not sure if that would be possible, but I'll keep digging into the dll more and when I figure more of it out, I'll see what I can do.
MildewMan1
Colonist
Colonist
Posts: 37
Joined: Sat Jun 27, 2020 3:02 pm
Favourite Race: Tarth
Location: St. Louis, Missouri, USA

Re: Does anyone know about networking?

Post by MildewMan1 »

It's been about a month since I last posted this, so I thought I'd give an update...

I think I'm pretty close to figuring out sockets. I was able to hijack some of the Deadlock functions and dialog boxes, and I'm currently able to get an IP address and port as a client and then start the connection process. I have gotten a TCP socket to connect to another one on my computer and got it to post an update to the MasterWaitDialog box when it connected, but it doesn't work that well....I think it's because I'm trying to connect to myself.

I have almost finished creating a simple debug networking app that will hopefully allow me to test the sockets better than what I'm currently doing.

I am also going to implement UDP sockets for LAN play... depending on how they work compared to TCP sockets, I may use them for LAN and Network play. I've read that UDP sockets can be unreliable though. Sometimes data can get lost or partially lost, whereas TCP sockets are very reliable.

I'll see how it goes and maybe post some screenshots if anyone is interested in seeing what I have so far.
User avatar
Tggtt
Ancient
Ancient
Posts: 259
Joined: Sun Oct 06, 2013 8:08 pm

Re: Does anyone know about networking?

Post by Tggtt »

Hello MildewMan1 ,

Sorry, I have been busy, but here are my suggestions for you.

First of all, great idea, I really hope you succeed in your plans.
It is very interesting that I have been trying to "decode" the rest of Deadlock, not the networking.

Each DLNET is loaded according to the OS, and it's done very late. this could increase your success chances, but only if you focus on only one of DLNETs.
If you are focusing on Windows NT4,2000,XP and newer, you should focus on DLNETNT.DLL.

And then, you should try to reimplement the "net" functions of DLNETNT.DLL, which I try to dump their names from debugging:

Code: Select all

IsNetQueueEmpty
NetAckSlave
NetBroadcastPending
NetClearBroadcastPending
NetDebug
NetEnterGame
NetGetGameInfo
NetGetNetMode
NetGetNumPlayers
NetGetSlaveNumber
NetInitAllReceives
NetInitDispatcherFunc
NetInitDLLPtrs
NetInitialize
NetMasterGame
NetNewMasterSetup
NetProbeInit
NetSendCapsule
NetSendGameInfo
NetShutdown
NetSwitchMasters
NetSync
NetTest
I think they all use binary structures, I don't know the sizes of their parameters. After you learn their sizes, you shouldn't need to decode their data at all, just pass the data as is.

My suggestion is to create a wrapper DLL that is named DLNETNT.DLL and then rename the original to something else.
All unrelated calls could be simply redirected to the original DLL.

I think you should use TCP at first (session based).
Upon loading your wrapper DLL, make it read some kind of config file that stores the IP address of the host and/or the port to serve.
Once it tries to probe the NetBios LAN, capture the call and create a socket connection instead. Then pass the data as is to the other side.

You might have more luck trying with one master and one slave, because you wouldn't need to know how to cope with the "slave numbers".

I know it's easier said than done.

Regardless, best of luck (again).

MildewMan1 wrote: Sat Jul 25, 2020 5:01 pmMy thought was instead of making one player the server and other players the clients, maybe make an independent server that can be run outside of Deadlock and then have the players connect to that, so all players are clients. Not sure if that would be possible, but I'll keep digging into the dll more and when I figure more of it out, I'll see what I can do.
Sorry, but I find it very hard to be done. It looks like Deadlock was built starting from a single player game, there is no clear separation for what a "server" would be able to do. If you ever manage to do that, there would probably be a "dead" colony for the host.
MildewMan1
Colonist
Colonist
Posts: 37
Joined: Sat Jun 27, 2020 3:02 pm
Favourite Race: Tarth
Location: St. Louis, Missouri, USA

Re: Does anyone know about networking?

Post by MildewMan1 »

Some of those functions are never actually called from Deadlock (at least not in version 1.20).

The ones that I know of off the top of my head are NetAckSlave, NetClearBroadcastPending, NetDebug, and NetGetNumPlayers (was only used for MPlayer games).

I've created a class that handles the sockets (still a work in progress), and I don't even load the real dll anymore, not that it really does anything anyway (Oddly enough though, if you just remove the real dll from the folder without handing the calls to it, the game crashes at the main menu screen, so the game can't run without some dll being there.).

I believe they have 3 different structures that they used. One them is used to send actions done by the players. Another one is used to send the game information to the slaves when they first connect. I can't recall off the top of my head what the last one is for, but they are all 0x50 bytes in size I believe.
MildewMan1
Colonist
Colonist
Posts: 37
Joined: Sat Jun 27, 2020 3:02 pm
Favourite Race: Tarth
Location: St. Louis, Missouri, USA

Re: Does anyone know about networking?

Post by MildewMan1 »

Ok made a big breakthrough today. I was able to get UDP sockets to work for LAN games and successfully received and sent some of Deadlock's Net Messages between the game and my network debugging app that I made. I got to the player selection screen before I stopped working on it.

I'll see if I can work on it more this weekend and do more testing by playing a whole multiplayer game (alone haha). Need to do more work on the TCP socket side and test that too.

Maybe I can have multiplayer games running for deadlock within a couple of weeks.
User avatar
Tggtt
Ancient
Ancient
Posts: 259
Joined: Sun Oct 06, 2013 8:08 pm

Re: Does anyone know about networking?

Post by Tggtt »

Best of luck! I am sure that your success would be well accepted by everyone!
User avatar
Ubergeneral Grunt
Site Admin
Site Admin
Posts: 189
Joined: Fri Nov 19, 2010 10:20 am
Favourite Race: Tarth
Location: Perth, Western Australia
Contact:

Re: Does anyone know about networking?

Post by Ubergeneral Grunt »

MildewMan1 wrote: Wed Aug 26, 2020 12:05 am I've read that UDP sockets can be unreliable though.
UDP isn't designed to be completely reliable, it's mainly design for speed. TCP would be essential for any sort of reliability.
Tarth cooks make best strudel, barbecue, bean dip, fish, cat food, smelt, piston rings, tofu and cam shafts...
User avatar
Tggtt
Ancient
Ancient
Posts: 259
Joined: Sun Oct 06, 2013 8:08 pm

Re: Does anyone know about networking?

Post by Tggtt »

I believe that UDP packets are called datagrams, while TCP packets are called segments, but that is mostly derived from OSI layers.

UDP does not need sockets to transfer data, they only need to send the datagram without connection setup.
And yes, I also agree that TCP should be better in this case because since UDP is unreliable, your DLL may become unstable using real internet connections.

When I tested playing both DL1 (using VirtualBox networking) and DL2 (using VPN, such as Hamachi) over the internet, I noticed that when I used TCP tunnels I had much more lag, but the game was stable enough to be played completely.

For instance, DL2 uses UDP, but it feels like they didn't really bother much about the risk of loosing packets, which eventually causes some strange connection losses. Maybe they tested it mostly for LAN games.

This also reminds me of another detail: MildewMan1, while I appreciate your work on Deadlock 1.20, you should really try to work on 1.31.
Mostly because 1.31 has the capability of restoring saved games for multiplayer. Loading saved multiplayer games saves a lot of headaches (pun intended).

In conclusion: Keep it up!
Post Reply