Commit Graph

66 Commits

Author SHA1 Message Date
Gregor Richards
6556af1100 force_send_savestate is global again
We cannot send a savestate to only one player, as sending a savestate is
a synchronization event invalidating all prior input.
2016-12-18 19:28:42 -05:00
Gregor Richards
2130fd81a5 Fixed simulation for >2 players 2016-12-18 19:28:42 -05:00
Gregor Richards
e7ce01ad3b More renaming
Now that remote_input_state isn't always remote, it should just be
called real_input_state (and is).
2016-12-18 19:28:42 -05:00
Gregor Richards
53c46530aa Very first tidbits of true multiplayer support (minus actual multiple
players so far)
2016-12-18 19:28:42 -05:00
Gregor Richards
b5cd187077 Since there's now only one mode, removing netplay_callbacks entirely. 2016-12-18 19:28:42 -05:00
Gregor Richards
4768970d52 Moving force_send_savestate from netplay to connection. 2016-12-18 19:28:42 -05:00
Gregor Richards
189cc6e5d6 Moving socket buffers to per-connection (currently breaks
delay_frames=0)
2016-12-18 19:28:42 -05:00
Gregor Richards
b334f04bd5 Removing RARCH_ from Netplay stall reasons. 2016-12-18 19:28:42 -05:00
Gregor Richards
1e1abf6951 First step of multiple connections. Still only one connection actually
works.
2016-12-18 19:28:42 -05:00
Gregor Richards
3908e25895 Separating local mode from remote mode. 2016-12-18 19:28:42 -05:00
Gregor Richards
80be19a7da Renames for readability, merging frame and sram into sync packet. 2016-12-18 19:28:42 -05:00
Gregor Richards
ce7686104d Removing dead code 2016-12-18 19:28:41 -05:00
Gregor Richards
1c8f056239 Nonblocking initial connection. Haven't tested with delay_frames=0 yet 2016-12-18 19:28:41 -05:00
Gregor Richards
ba76528b8f A more sophisticated status variable for later making the initial
connection nonblocking.
2016-12-18 19:28:39 -05:00
Gregor Richards
900e5a79ec Use nonblocking sockets for Netplay to avoid some stalls. 2016-12-18 19:28:38 -05:00
Gregor Richards
1245d1b5dd Better netplay input simulation
In resimulation mode, we only copy the buttons. The reason for this
is nonobvious:

If we resimulated nothing, then the /duration/ with which any input
was pressed would be approximately correct, since the original
simulation came in as the input came in, but the /number of times/
the input was pressed would be wrong, as there would be an
advancing wavefront of real data overtaking the simulated data
(which is really just real data offset by some frames).

That's acceptable for arrows in most situations, since the amount
you move is tied to the duration, but unacceptable for buttons,
which will seem to jerkily be pressed numerous times with those
wavefronts.
2016-12-18 00:46:02 -05:00
twinaphex
b4c1927e27 (MSVC 2003) Buildfixes 2006-05-18 13:31:43 +02:00
Gregor Richards
0577749fae Netplay LAN scanning is go! (sort of) 2016-12-02 22:40:26 -05:00
Gregor Richards
22798e26c7 delay_frames naming consistency
Unifying all of the various inconsistent names of delay_frames into a
single name: delay_frames.
2016-12-01 13:34:37 -05:00
Gregor Richards
42da0a0184 NAT traversal in Netplay
For the time being, if NAT traversal is successful it simply announces
it as an OSD message. In the future it will be used to inform a
matchmaking server of the public port.

This patch also included minor fixes to the NAT traversal implementation
to make the select it demands actually doable.
2016-11-29 22:59:46 -05:00
Gregor Richards
6c15c0de3d Support for architecture-dependence serialization quirks in Netplay
As well as the implementation magic, we now send a platform magic in our
connection header. If the core reports platform dependence and the
platform magic differs relevantly, the connection will be refused.

Since netplay_send_info (client handshake) and netplay_get_info (server
handshake) were practically identical, they've also been merged into a
single netplay_handshake.
2016-10-05 21:12:42 -04:00
Gregor Richards
307ba5951e A bit more care about frame=0 input, which is always 0 2016-10-05 20:45:30 -04:00
Alcaro
46ab267f40 Merge pull request #3700 from GregorR/netplay-serialization-quirks
Serialization quirks
2016-10-06 00:59:14 +02:00
Gregor Richards
e65a63e5d5 Add support for debugging core nondeterminism
This adds a debug flag to netplay_net (DEBUG_NONDETERMINISTIC_CORES)
which helps determine if a core has nondeterminism.
2016-10-05 07:58:01 -04:00
Gregor Richards
60153e7035 Ignore check_frames if CRCs are utterly inconsistent
This effectively disables check_frames if frame 1's CRC differs between
host and client. This is necessary because some important cores have
nondeterminism in core_run, thus mandating check_frames, while some
important cores have nondeterminism in core_serialize, thus mandating no
check_frames.
2016-10-05 07:55:30 -04:00
Gregor Richards
0d661ef6a2 Fix some backwards implementation in reporting serialization quirks 2016-10-04 23:07:35 -04:00
Gregor Richards
07a4ad791d Implemented Netplay initialization quirk 2016-10-04 23:07:35 -04:00
Gregor Richards
5676d0b848 Adding Netplay quirk for untransmittable savestates 2016-10-04 23:06:50 -04:00
Gregor Richards
44931586b7 Removing Netplay workarounds which will soon be replaced by quirks 2016-10-04 23:06:50 -04:00
Gregor Richards
68cee3b409 Being more careful with serialization 2016-10-04 22:24:33 -04:00
twinaphex
19863e4174 autosave_lock/autosave_unlock - no longer require HAVE_THREADS ifdefs 2016-10-04 09:56:58 +02:00
Gregor Richards
01d379066e Removing Netplay workarounds in anticipation of quirks API 2016-09-30 16:00:49 -04:00
twinaphex
13cf804a70 Fix signed/unsigned mismatch warnings 2016-09-30 08:23:24 +02:00
Gregor Richards
f710303a40 Somewhat fixing support for savestateless cores
Without early saves we couldn't properly detect savestateless cores. We
still can't, really, but we can at least EVENTUALLY detect this
condition. netplay_net has been fixed to do so.
2016-09-29 20:48:39 -04:00
Gregor Richards
1470b6672b Fix delay_frames=0 mode to work with the recent late-loading workaround 2016-09-28 15:45:52 -04:00
Gregor Richards
f665881d6d Workarounds for cores that can't be saved early
Netplay now never serializes/unserializes cores before 60 frames have
been emulated. This is a workaround for buggy cores and documented as
such.
2016-09-27 20:49:16 -04:00
Gregor Richards
bd354cd275 Making all Netplay sockets should be cloexec
All Netplay sockets should close-on-exec. There is no reason for
xdg-screensaver to keep Netplay sockets alive.
2016-09-25 23:26:32 -04:00
Gregor Richards
60449e8928 Checks for some netplay syscall errors and NULL deref errors 2016-09-24 18:48:55 -04:00
Gregor Richards
fcd57801bd When we replay, resimulate input so that it doesn't judder between
remote states
2016-09-24 08:12:08 -04:00
Gregor Richards
fa5b75b635 Bugfixes in how we reset state on a late Netplay connection 2016-09-23 22:21:53 -04:00
Gregor Richards
1503b3d42f Don't serialize frame 0 in netplay, as the core may not yet be ready 2016-09-22 17:36:46 -04:00
Twinaphex
34944cac0f remove unused variables 2016-09-22 22:01:35 +02:00
Gregor Richards
4b370cf55e Re-add TCP_NODELAY in host mode. 2016-09-21 17:31:19 -04:00
Gregor Richards
c2d9e7a538 Support for late connection to Netplay host mode
This changes netplay host mode's behavior in net (normal) mode from
immediately blocking to waiting for a connection while allowing the game
to run, like spectator mode.
2016-09-21 17:26:02 -04:00
Gregor Richards
ad336df709 Reimplemented Netplay spectate mode
Spectate mode is now far more similar to net (normal) mode, and, more
importantly, it works. In addition, spectate mode will not fast-forward
to catch up with the server if it lags too far behind.
2016-09-15 23:06:32 -04:00
Gregor Richards
2a0202ccf5 Making Netplay check frequency configurable. 2016-09-15 23:06:32 -04:00
Gregor Richards
7271d1c3fa Support for frame CRCing
Every frame (soon to be configurable), the server does a CRC-32 hash and
sends it to the client. If the client finds that its own hash is
different from the server's, it requests a fresh savestate.

This is a last-ditch effort to sync if all else fails, and it's a
best-effort situation. The size of the buffer should assure that we
always still have the frame around to CRC, but I imagine there are edge
cases where we don't. If you're in an edge case, the CRC is ignored.
2016-09-15 23:06:32 -04:00
Gregor Richards
5f90f072ba Documentation fixup
Fixing up some of the function documentation, and documenting the packet
formats.
2016-09-15 23:06:32 -04:00
Gregor Richards
27188e102d Support for savestate loading over netplay
Assuming the core supports saving/loading states, and (crucially)
assuming the states are portable across the architectures on both sides
of the connection, Netplay now supports the transmission of savestates.
Right now the frontend doesn't actually send any such requests, as it's
not clear exactly where the code for that should be.

This works in either direction, although I'll admit I have no idea what
happens if they both load at the same time.
2016-09-15 23:06:32 -04:00
Gregor Richards
96186438ec Remote pausing
Support for remote pausing, and with it, support for Netplay pausing the
frontend correctly. With this patch alone this doesn't work, since
there's no clean way for the frontend to tell Netplay that it's paused.
2016-09-15 23:06:32 -04:00