Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / some multiplayer discussion... what do you do?

Author
Message
SoftMotion3D
AGK Developer
20
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 20th Jun 2013 03:27
I just wanted to start a thread on multiplayer and how to handle latency issues. Im mostly wondering what other people are doing to handle over network games.

What im working on is a 2 player game however I still want to use a server...client based setup.

From what i've read and understood over the internet is that a server generally holds about a second worth of snapshots (events that have occurred) and displays graphics in a past state.

a ping test can be measured from shooting a message back and forth by measuring the system clock difference on how long it takes to get it back. Now this value indicates lag response in milliseconds.




so this is the part where im stuck....but have this idea of handling it.

While I was thinking about it... 2 ways of handling this come to mind.



[First way
-have the server save a second worth of data (snap shots of movements..etc)
-run regular ping tests
-have the server show graphic updates on past movements to appear to be behind the same spot as the client.
-have the client receive events ahead of what the server is showing.
-also holds a second worth of events to calculate lost packets if they are missing.

see image below...




now also now im thinking....ok so what if the client shoots a gun.

Well the same thing applies on the messages send except the server can look back in time further to calculate if hits infact occurred.

Any thoughts?

SoftMotion3D
AGK Developer
20
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 20th Jun 2013 03:30 Edited at: 20th Jun 2013 03:51
ok the second method I was just thinking about...

ok so what if the server held a second of data...same as above and the client does the same.

this idea the server runs in real time....whats happening is happening.

when the client asks for graphic / event updates... the server calculates where things are heading based on its second of data and based on the ping (lag response time) and sends the client an estimated graphic / event update. (estimated but calculated threw the second of data snapshots and lag)

so this would put the server in real time
client would be in estimated/calculated time

Im probably gunna try this second approach.... what do other people do? do any of you have any ideas on what works best or what you may have come up with?

thanks and it would be cool to here from some experienced coders that have delt with multiplayer coding.

Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 20th Jun 2013 04:02 Edited at: 20th Jun 2013 04:02
Take a look at these two documents, for Source Engine and Unreal Engine, respectively:

http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
http://udn.epicgames.com/Three/NetworkingOverview.html

"Sideboobs are awesome. Getting punched in the face is not." - Jerico2Day on violence and nudity
SoftMotion3D
AGK Developer
20
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 20th Jun 2013 04:19 Edited at: 20th Jun 2013 04:23
those both have some great information...thanks.

I guess a lot of this is just gunna be by testing and trying things out to make it work for your game project.

Its interesting to hear what other people have done to make there multiplayer code successful.

Anyone coded mp in darkbasic successfully using the regular commands that dbpro comes with? or do most people use a 3rd party plugin?


edit:

also im looking at packets.... I guess it would be optimal to just send memory blocks for all processes (compacted into a single mem block) of coarse not too big (relatively small to keep your message small)

my game is running at 30fps and as per valves page on multiplayer....it looks like it would be fine to send a packet every sync for my project.

How many do people suggest doing?

thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 20th Jun 2013 04:53 Edited at: 20th Jun 2013 04:56
Quote: "Anyone coded mp in darkbasic successfully using the regular commands that dbpro comes with? or do most people use a 3rd party plugin?"


I think it's pretty universally agreed that 3rd party plugins offer a better system than the pretty much broken native system. A few plugins are available, using both the TCP protocol and UDP. For people who don't already know this, TCP is a protocol that's slow and requires a stable connection to a specific target to be established before sending data. In addition, data sent by TCP is guaranteed to be receieved. Data sent through UDP, on the other hand, does not require a preestablished connection. UDP is much faster, however the data is not guaranteed to be recieved.
A few plugins here I've used:

Multisync - Uses TCP
Winsock - Features for both TCP and UDP, link is dead... I have the download if anyone wants it.
DarkNet / Mikenet - TCP, UDP, a whole range of features, but it's the only paid plugin on this list.
Matrix1 - IanM's plugin has some little-known networking commands, very low level. They're in Matrix1Util_28.

GreenDixy
17
Years of Service
User Offline
Joined: 24th Jul 2008
Location: Toronto
Posted: 20th Jun 2013 10:55
I use multisync, lua bluegui and a sql plugin for my editors/games yes I use some of the basic commands for main stuff but a lot of it is depending on what you need.

======================================
My software never has bugs. It just develops random features.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 20th Jun 2013 12:15
A specific client side technique for dealing with lag is to have other players maintain their speed and direction until the server sends a new position. It's called player movement prediction.

The screens updating possibly every 16ms and the server every 100ms. Doing this allows you to maintain fluid motion between updates, and reduces lag jumping.

SoftMotion3D
AGK Developer
20
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 20th Jun 2013 15:52
thanks for all this information guys....

so for a game over the internet ... i should probably use udp?

even though it may drop messages it sounds like udp is the way to go.

I think i will give that darknet/mikenet plugin a go

thanks

Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 20th Jun 2013 20:56 Edited at: 20th Jun 2013 20:56
It depends on the type of game you're creating. If it's something real-time like an action game then UDP is generally the best way to go.

"Sideboobs are awesome. Getting punched in the face is not." - Jerico2Day on violence and nudity
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 20th Jun 2013 21:06
Quote: "It depends on the type of game you're creating. If it's something real-time like an action game then UDP is generally the best way to go."

i have to agree with ben here.

but i saw many other engines that uses both UDP and TCP.
that is when you too far from another person, it will update his positions using TCP, and if you get close to him, for close combat fight, it will use UDP.

im happend to be an expert with lots of different internet protocols that out there.. i created about 10 different servers/clients for ppl
like HTTP server/SMTP client and such..

the advices that SMD_3D Interactive gave here are very common and basic communication methods that i highly suggest for you all to learn and understand it..

Stream SnifferTools/Plugins/Models/Games and more!
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 21st Jun 2013 01:06 Edited at: 21st Jun 2013 01:07
In my game, I use both TCP and UDP. I use TCP to transfer data such as chat messages and initial server information, but that's about it. UDP is better for pretty much anything else if you value speed. I found using TCP is easier for data that must reach its destination, because TCP handles this automatically and it's much easier than creating a system to resend UDP packets if they are never recieved. But for input and the snapshot data you describe, UDP is definitely the best solution.

SoftMotion3D
AGK Developer
20
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 28th Jun 2013 17:25 Edited at: 28th Jun 2013 17:26
well I actually got something to work well.

I decided to go with my first option of having each pc send data back and forth but display whats happening a few frames back to keep both machines in sync.

what I am doing:
-holding a second of data on both machines
-sending data every second frame (games running at 30fps)
(so 15 packets a second)
-calculating the difference on the missing frames
-calculating ping and setting each computer back x-amount of frames
-and last of all using the command (curve value)


learning this stuff is really good. I believe once you've coded something like this that it really sticks with you for your next projects and how to approach them.

oh and I decided to stick with dbpros commands for now. I figure if I can get smooth play from that....it will even be way smoother when I do eventually switch over to udp.

Login to post a reply

Server time is: 2026-07-06 16:49:48
Your offset time is: 2026-07-06 16:49:48