Conversation
Notices
-
Embed this notice
how the fuck do games using raylib handle multiplayer stuff anyways like say you have 2 players to manage at once, you are bound to run into race condition problems when using normal multithreading libraries, and i cant think off the top of my head how i would solve that stuff
-
Embed this notice
like you could just do it in the worst way possible and just call recv while you are in the middle of operations before redrawing the window but it would obviously cause major lag as reading from socket takes a little while
-
Embed this notice
got me thinking a bit, i recall an asynchronous http library in c would make you call a function over and over again to get progress of if connection has succeeded or not
could set up a timeout for reading from socket, then maybe have a mutex that counts the attempted recvs made and if its equal to a certain number assume connection has died?
idk
-
Embed this notice
@kirby
I think networked multiplayer games just ignore race conditions and process inputs when it's convenient.
-
Embed this notice
@BOB is that like an industry standard
-
Embed this notice
you wouldn't need a mutex actually just a normal variable
-
Embed this notice
idk why mutex came up in my head
-
Embed this notice
the timeout would have to be super small tho
-
Embed this notice
@BOB this is mostly just theoretical so i can get settled into raylib a bit i spose, but p2p preferably [partially considering just writing an entire dedicated server for some projects]
local
-
Embed this notice
@kirby
What are you trying to accomplish? P2p or server/client? Network or local?
-
Embed this notice
@kirby
Idk about raylib, I mostly use sdl. I wouldn't think too much about it. I'd just read the inputs in my tick function like normal.
-
Embed this notice
@kirby Deleted my last post cuz I misread your response lol. Look up rollback. It's how networked games deal with lag.
-
Embed this notice
@kirby
A great resource for me was Quake's source code. It's server client but a lot of the theory is the same
-
Embed this notice
@kirby
On top of dealing with lag you also have to deal with floating point operations being non-reproducable across a network (unless all nodes are the exact same hardware)
-
Embed this notice
@BOB oh that sounds terrible
-
Embed this notice
@kirby
Ya. It means your game state has to be all integers or your nodes need to sync their states periodically. The latter solution is probably not possible in p2p unless you have very little state