Commit Graph

411 Commits

Author SHA1 Message Date
Gregor Richards
dcd4b3046b Making negative check_frames be "check only" mode 2016-12-18 19:28:44 -05:00
Gregor Richards
677ffa9ebd Support different forms of compression from different clients. 2016-12-18 19:28:44 -05:00
Gregor Richards
84c33634a6 Communicate paused-ness during initial connection SYNC. 2016-12-18 19:28:44 -05:00
Gregor Richards
60b81e3a51 Nominal support for server sending blank INFO 2016-12-18 19:28:44 -05:00
Gregor Richards
e79f30604f Better stall timing
We now stall not until we've reached parity (which makes no sense since
we expect latency), but only until we're not likely to stall again.
2016-12-18 19:28:44 -05:00
Gregor Richards
8195a5bcee Try to catch up if we're falling behind our peer, not anyone
In the previous catch-up system, we would only try to catch up if we
were falling behind the farthest-behind peer. However, as they would
also only try to catch up to us, everyone basically agreed to the
worst-case latency. It makes more sense to try to be in parity with your
direct peer than with indirect connections.
2016-12-18 19:28:44 -05:00
Gregor Richards
b535412914 Adding nick-changing
This is just to disambiguate multiple connections with the same nick
(usually Anonymous), which will now become e.g. Anonymous (2).
2016-12-18 19:28:44 -05:00
Gregor Richards
7c2f12fbd9 Removign some leftover debug code 2016-12-18 19:28:44 -05:00
Gregor Richards
04266cf4f7 Run synchronization even when stalled
Previously, we could be stalled by one player but still reading data
from another, which would wedge the client because we would never act
upon the newly-read data. Now we act upon data even if we're stalled.
Fixes bugs in initial connection with high latency.
2016-12-18 19:28:44 -05:00
Gregor Richards
d6d96704fd Don't panic about delta frames not being ready if we're not even fully
connected yet.
2016-12-18 19:28:43 -05:00
Gregor Richards
8b21014d07 Improvements to handshake protocol
Making the netplay handshake protocol send the core and content as an
explicit command, so that the other side can (notionally) choose to load
it. That isn't implemented, of course.
2016-12-18 19:28:43 -05:00
Gregor Richards
1fa60b396f Improvements to the communication of netplay pausing. 2016-12-18 19:28:43 -05:00
Gregor Richards
db2c8de44c Slightly changing how catch-up works to avoid spamming the console 2016-12-18 19:28:43 -05:00
Gregor Richards
1141825605 Documenting (somewhat) the new sync system. 2016-12-18 19:28:43 -05:00
Gregor Richards
a20e79bbb5 Server needs double the buffer frames since two connected clients could
be ahead and behind by the max frames
2016-12-18 19:28:43 -05:00
Gregor Richards
f7f6590156 Goodbye delay_frames! stateless_mode is the new delay_frames=0 2016-12-18 19:28:43 -05:00
Gregor Richards
45d732a014 New sync system
The idea:
   * Use a fixed number of delay_frames (eventually to be fixed at 120,
     currently still uses the config variable, 0 will still be an option)
   * Determine how long it takes to simulate a frame.
   * Stall only if resimulating the intervening frames would be
     sufficiently annoying (currently fixed at three frames worth of
     time)

Because clients always try to catch up, the actual frame delay works out
automatically to be minimally zero and maximally the latency. If one
client is underpowered but the other is fine, the powerful one will
automatically take up the slack. Seems like the most reasonable system.
2016-12-18 19:28:43 -05:00
Gregor Richards
6890456ac0 Updated error messages and fixed some stall-related disconnected-client
bugs.
2016-12-18 19:28:43 -05:00
Gregor Richards
6658826759 CRC validity checking. Ignore CRCs if they don't work. 2016-12-18 19:28:43 -05:00
Gregor Richards
a6cd8c3aa1 Error reporting when a password is refused, plus a bugfix so that
socket_receive_all_nonblocking actually reports disconnects.
2016-12-18 19:28:43 -05:00
Gregor Richards
df2600fbf4 Added error reporting when a player is not allowed to play. 2016-12-18 19:28:43 -05:00
Gregor Richards
bade067d9a Support for catching up if the netplay peer is ahead of us. 2016-12-18 19:28:43 -05:00
Gregor Richards
4e01481b39 Only allow clients to load state if there's no further synchronization 2016-12-18 19:28:43 -05:00
Gregor Richards
70d04ec6a5 Apparently the frontend gets really pissy if it can't check the flip state 2016-12-18 19:28:43 -05:00
Gregor Richards
da7efcb939 Cleaning up netplay headers. 2016-12-18 19:28:43 -05:00
Gregor Richards
9c6ac2b934 Only the server can flip users. 2016-12-18 19:28:43 -05:00
Gregor Richards
03415c261d Added netplay spectator password separate from play password 2016-12-18 19:28:43 -05:00
Gregor Richards
694b7a9723 Don't allow more players to join than are actually being polled 2016-12-18 19:28:43 -05:00
Gregor Richards
7ad4e3f115 Per-connection stalling 2016-12-18 19:28:43 -05:00
Gregor Richards
1b22191869 Deduplicating some code. 2016-12-18 19:28:43 -05:00
Gregor Richards
f619789e48 Refactoring: netplay_common.c -> netplay_handshake.c/netplay_delta.c
Refactoring netplay_common into its two actual components, the handshake
and delta-frame related functions.
2016-12-18 19:28:43 -05:00
Gregor Richards
4e905bf524 Refactoring: netplay_sync.c
Renamed netplay_net.c to netplay_sync.c, as all that remains in that
file is synchronization-related functions.
2016-12-18 19:28:43 -05:00
Gregor Richards
257c5d3188 Refactoring netplay_init.c/netplay_net.c
Split the remainder of netplay.c into netplay_init.c and netplay_net.c
(which will soon be netplay_sync.c)
2016-12-18 19:28:43 -05:00
Gregor Richards
7e2465ef1f Refactoring: Moving I/O functionality into netplay_io.c 2016-12-18 19:28:43 -05:00
Gregor Richards
8c59c7dd77 Starting to refactor: Separating frontend stuff into netplay_frontend.c 2016-12-18 19:28:43 -05:00
Gregor Richards
ab989d7f41 More careful disconnection. 2016-12-18 19:28:43 -05:00
Gregor Richards
c8bba9a981 Simplistic builtin randomizer. 2016-12-18 19:28:43 -05:00
Gregor Richards
28e331b5fd Remove some magic numbers 2016-12-18 19:28:43 -05:00
Gregor Richards
6e6f2bfdbe Use a proper password hash across the line. 2016-12-18 19:28:42 -05:00
Gregor Richards
763a657f82 Terrible first cut at password (sent in plain text D-8) 2016-12-18 19:28:42 -05:00
Gregor Richards
5a0328dc09 Transfer pad configuration over netplay. 2016-12-18 19:28:42 -05:00
Gregor Richards
888e45c88b Updates to allow the server to toggle game/watch 2016-12-18 19:28:42 -05:00
Gregor Richards
3631ff74ff Very, very partial support for the server spectating 2016-12-18 19:28:42 -05:00
Gregor Richards
3d7f1f6575 Updating Netplay README to be more true 2016-12-18 19:28:42 -05:00
Gregor Richards
f6f9905ae3 Made remote pausing connection-specific 2016-12-18 19:28:42 -05:00
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
3d34c0222f Added simple (cheesy) announcements on join/leave 2016-12-18 19:28:42 -05:00
Gregor Richards
727743aa7b Fixing a couple FIXMEs/TODOs 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
262d77546b Adding game/watch key
Adding a key to toggle between playing and spectating. This key takes
the place of the previous flip key, although player flipping does
continue to work (and must be rebound if you still want it)
2016-12-18 19:28:42 -05:00
Gregor Richards
90c15fc7a6 Still need to flush input data. 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
f6630ad85a More fixups for >2 player mode. Mostly was just sending packets that
shouldn't have been sent.
2016-12-18 19:28:42 -05:00
Gregor Richards
479955a085 More 3-player support. The initial connection is wonky with
delay_frames>0
2016-12-18 19:28:42 -05:00
Gregor Richards
d373684bd5 Off-by-one 2016-12-18 19:28:42 -05:00
Gregor Richards
b51cf8be2b Real, actual (almost) >2-player support. 2016-12-18 19:28:42 -05:00
Gregor Richards
2cc8c5c467 Removing silly foo_ names used to help migration. 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
9b2270f5d4 Say goodbye to spectator mode (for now) 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
ea722b49c8 Move other_addr from netplay to connection. 2016-12-18 19:28:42 -05:00
Gregor Richards
d1d29143b2 Move nickname field to connections. Spectate mode officially broken. 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
775584cdac Adding more README info. 2016-12-18 19:28:42 -05:00
Gregor Richards
170b590bdb Client now starts one frame after finishing connection, for easier sync. 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
f89e54fcb7 Now that we don't have to start at frame 0, use the server frame count 2016-12-18 19:28:42 -05:00
Gregor Richards
b3092f6fde Moving things that shouldn't have been public into netplay_private.h 2016-12-18 19:28:41 -05:00
Gregor Richards
9054b51f0e Finally, bringing back the first frame (in nonblocking mode) 2016-12-18 19:28:41 -05:00
Gregor Richards
ce7686104d Removing dead code 2016-12-18 19:28:41 -05:00
Gregor Richards
71e5cb756a Support for delay_frames=0 in nonblocking mode. 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
3f8f9761f6 Fixes particularly affecting delay_frames=0 mode 2016-12-18 19:28:41 -05:00
Gregor Richards
91e7db3eca This semicolon broke everything! 2016-12-18 19:28:40 -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
0f5eec9987 Use zbuffer_size instead of state_size for the packet buffer 2016-12-18 19:28:39 -05:00
Gregor Richards
1214541410 Added packet buffer resizing to cope with initialization quirks. 2016-12-18 19:28:38 -05:00
Gregor Richards
36a93e5697 Fix a few bits broken by merging. 2016-12-18 19:28:38 -05:00
Gregor Richards
900e5a79ec Use nonblocking sockets for Netplay to avoid some stalls. 2016-12-18 19:28:38 -05:00
Twinaphex
d604441cea Merge pull request #4266 from GregorR/netplay-better-simulation
Better netplay input simulation
2016-12-18 07:13:52 +01: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
Gregor Richards
17e08c7a28 When we disconnect netplay, fully deinit it
In particular, we need to disentangle the interceding netplay callbacks.
In previous versions, if you disconnected netplay but were using a core
that made netplay stall for connections (i.e., one that has no
savestates), netplay would continue to stall because it still
interceded, even though it was supposed to be off. This fixes that.
2016-12-17 23:08:59 -05:00
Gregor Richards
8c08a5399d Fix a possible NULL dereference in load_savestate
In the unlikely situation that serial_info wasn't provided and the delta
frame wasn't ready (possibly an impossible situation) it previously
would have segfaulted. This fixes that.
2016-12-15 16:19:54 -05:00
twinaphex
b4c1927e27 (MSVC 2003) Buildfixes 2006-05-18 13:31:43 +02:00
Gregor Richards
9a4b28735b HAVE_SOCKET_LEGACY -> no IPv6
I had previously assumed that if AF_INET6 is defined, IPv6 support was
present. Some psychopathic console SDKs which shall not be named
actually define AF_INET6 but none of the IPv6 structures. As there is
therefore no way to determine whether IPv6 support is present at
preprocessor time, I'm ust assuming that HAVE_SOCKET_LEGACY implies no
IPv6. This means in effect that no consoles get IPv6 support.
2016-12-10 05:27:25 -05:00
twinaphex
4bf806ef00 (Netplay) Some build fixes for PS3 and others 2016-12-10 09:41:24 +01:00
Brad Parker
d558862e21 make "Got connection from" translatable. Update JP translation. 2016-12-09 23:38:00 -05:00
Gregor Richards
a70e21f328 Suppress a warning due to weird declarations on Windows. 2016-12-05 20:50:05 -05:00
Gregor Richards
e7f20a3673 Bugfixes
Silence some Coverity warnings (including a real memory leak) and be
more careful about checking IPv6 mode (for backwards compatibility with
systems that don't support IPv6 but may run code compiled to expect IPv6)
2016-12-05 00:45:40 -05:00
Gregor Richards
2b437ccb8c Don't need to explicitly demand IPPROTO_TCP (and doing so breaks some
SOCKET_LEGACY builds)
2016-12-03 16:33:48 -05:00
Spec-Chum
7a6a0ee7af Fix MSVC compilation 2016-12-03 18:24:49 +00:00
Gregor Richards
f725f38061 Use strlcpy 2016-12-03 09:58:16 -05:00
Gregor Richards
98f0d4d45b Better error messages when the Netplay handshake fails 2016-12-03 09:46:20 -05:00
Gregor Richards
3c7fc73735 sendto fix for MSVC 2016-12-02 23:15:53 -05:00
Twinaphex
d71df5c06f Merge pull request #4138 from GregorR/netplay-port-unsigned-short
Be explicit about types
2016-12-03 05:11:02 +01:00
Gregor Richards
cc664db231 Be explicit about types. 2016-12-02 23:08:34 -05:00
Twinaphex
4b2a45a276 remove unused variables 2016-12-03 05:07:27 +01:00
Gregor Richards
8993003259 C++ fixes 2016-12-02 22:56:37 -05:00
Gregor Richards
0577749fae Netplay LAN scanning is go! (sort of) 2016-12-02 22:40:26 -05:00
Gregor Richards
077d5440ee Allow Netplay to receive a struct netplay_host to connect to rather than
using the configured setting
2016-12-02 21:16:15 -05:00
Gregor Richards
ba0985de37 Actually report the host port as the Netplay port, not the discovery port 2016-12-02 20:38:55 -05:00
Gregor Richards
3446cf09d6 Actually report discovered hosts back to the caller! 2016-12-02 20:28:22 -05:00
Gregor Richards
4c18cec752 Added Netplay discovery code (not yet in menu) 2016-12-02 19:49:42 -05:00
Gregor Richards
addff325d0 Netplay discovery LAN scanning task (incomplete) 2016-12-02 18:56:29 -05:00
Gregor Richards
a082df0027 More stripping out of NAT traversal for SOCKET_LEGACY 2016-12-02 13:18:35 -05:00
Gregor Richards
5739be5594 SOCKET_LEGACY doesn't even necessarily have inet_ntoa, so oh well, no
host for you
2016-12-01 20:40:16 -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
c7f8cd3c68 Adding NAT traversal announcement for SOCKET_LEGACY 2016-11-30 19:01:32 -05:00
Twinaphex
bb499b70be Merge pull request #4104 from GregorR/natt
NAT traversal
2016-11-30 16:09:53 +01:00
Gregor Richards
b3ababce9a Fix Netplay IPv6 support 2016-11-30 00:25:16 -05:00
Gregor Richards
c342c103ae Always get numeric host/ports instead of names. 2016-11-29 23:08:26 -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
twinaphex
d26a213971 CXX_BUILD fixes 2016-11-27 13:30:35 +01:00
Gregor Richards
225cbb387b Updating netplay to use trans_stream for compression 2016-11-26 16:06:52 -05:00
Gregor Richards
da0b958aeb Check HAVE_ZLIB and only do zlib compression if it's supported by both
sides.
2016-11-25 11:03:12 -05:00
Gregor Richards
db437047f8 Don't use z_const, which is apparently not always defined. 2016-11-25 10:40:25 -05:00
Gregor Richards
679ea058a4 Properly clean up zlib. 2016-11-25 10:40:24 -05:00
Gregor Richards
3ff22c9ed6 Fixes for C++ support. 2016-11-25 10:40:24 -05:00
Gregor Richards
9f03020af8 Change the netplay protocol version since compression isn't backwards
compatible.
2016-11-25 10:40:24 -05:00
Gregor Richards
53c6223dc6 Use zlib compression for savestates sent over netplay. 2016-11-25 10:40:24 -05:00
Diego Viola
cf0c60bb98 Fix Netplay fullscreen issue
Fixes #3936
2016-11-07 16:01:18 -02:00
Brad Parker
d1d5584d18 update copyright 2016-10-27 11:47:10 -04:00
twinaphex
0d3752e90f More translatable strings 2016-10-22 05:23:59 +02:00
twinaphex
3334060b03 Add another translatable string 2016-10-22 04:49:04 +02:00
twinaphex
9de0ebe859 Make some more strings translatable 2016-10-22 04:47:50 +02:00
twinaphex
42053a82e1 Prevent some implicit memsets 2016-10-21 19:39:51 +02:00
twinaphex
ddb4f85430 netplay_common.c - Buildfix for MSVC 2016-10-19 18:09:59 +02:00
Gregor Richards
2e432b005e Casts for C++ compatibility. 2016-10-10 11:56:43 -04:00
Gregor Richards
5c206c89f0 Add a netplay advertisement server for LAN netplay detection. 2016-10-10 11:52:54 -04:00
Gregor Richards
2c1cd0d06b Netplay should disable when it deinits, so it doesn't auto-reconnect
when loading a new game.
2016-10-09 09:42:06 -04: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
49b4143687 Reviving netplay_log_connection, i.e. connection messages on the host 2016-10-05 07:52:14 -04:00
Gregor Richards
701cc5a18c Splitting endian and other platform savestate quirks. 2016-10-04 23:07:36 -04:00
Gregor Richards
a636bac428 Style and clarity nits. 2016-10-04 23:07:36 -04:00
Gregor Richards
51683661e5 Changes to Netplay for the recent changes to quirks. 2016-10-04 23:07:36 -04:00
Gregor Richards
90bd741786 Switching serialization quirks to uint64_t for consistency with other
bitfields
2016-10-04 23:07:35 -04:00
Gregor Richards
3fa3fe0fcd Fixes for the other few Netplay initialization points 2016-10-04 23:07:35 -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
Gregor Richards
71873e8c97 Moving Netplay pre- and post-frame behavior into core_run
This (mostly) prevents other paths from accidentally side-stepping
Netplay. Netplay itself now sets an in_netplay variable to avoid
self-recursion in its own core_run calls.
2016-10-04 13:40:07 -04:00
twinaphex
19863e4174 autosave_lock/autosave_unlock - no longer require HAVE_THREADS ifdefs 2016-10-04 09:56:58 +02:00
Gregor Richards
3953018547 Clarifications to Netplay menu and removing obsolete setting
This commit:
 * Reorders the Netplay settings menu to put more useful options at the
   top.
 * Renames the swap_input setting from "Swap Netplay Input", which is
   meaningless and confusing, to "Netplay P2 Uses C1", which is oddly
   truncated but at least true.
 * Removes the is_client setting altogether, as that's no longer how
   client vs. server mode is determined (each are separate options when
   enabling Netplay)
2016-10-03 17:28:20 -04:00
Gregor Richards
e41ac34561 Get rid of global->netplay
Moved settings values into settings->netplay, and global->netplay.enable
is moved into netplay itself, and is no longer a configuration value
whatsoever, as that conflicts with the behavior of the netplay menu.
2016-10-02 22:13:34 -04:00
twinaphex
243dc139d2 Revert "Create path server and add to paths.c"
This reverts commit 00a1e3716a.
2016-10-01 08:17:44 +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
twinaphex
00a1e3716a Create path server and add to paths.c 2016-09-30 06:22:56 +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
5b62fbb355 Fix spectator mode to work with the late-serialization workaround 2016-09-29 17:28:01 -04:00
twinaphex
da5d43974a netplay_data is a void pointer no more 2016-09-29 20:11:46 +02:00
Gregor Richards
567da56048 Adding remaining netplay menu options
A couple fixes are still necessary for the client, in particular to
recover a "lost" hostname, but now it is possible to start server or
client mid-stream, and to disconnect intentionally.
2016-09-29 13:04:38 -04:00
Brad Parker
186d0d6450 fix cheevos memory leak 2016-09-28 23:05:59 -04:00
Twinaphex
9b17e4f01e Merge pull request #3680 from GregorR/netplay-sram-leniency
Make netplay lenient to differing sram sizes
2016-09-28 23:12:10 +02: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
ad4cec0b07 Make netplay lenient to differing sram sizes
Some cores can only determine the true size of sram after fully loading
the content, and so will report different values when the sram size is
queried. As a result, netplay cannot count on sram size as a reliable
verification technique. sram is still sent for the savestateless core
case.
2016-09-28 08:04:38 -04:00
Twinaphex
f0a2159f9a remove unused variable 2016-09-28 06:50:43 +02: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
c4eb12a583 Adding backend functionality to reconnect a Netplay client. 2016-09-24 23:48:42 -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
6472b0ce82 Small checks to avoid needless blocking in delay_frames=0 mode 2016-09-23 23:27:07 -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
236839e22f Reset netplay stall state upon disconnection 2016-09-23 22:20:47 -04:00
Gregor Richards
ae92cfeac2 More care in check_frames code so we don't check CRCs from a previous
connection
2016-09-23 22:18:56 -04:00
Gregor Richards
65e308c92d Reset player flip state when we lose Netplay connection
This fixes a bug whereby reconnections would be out of sync due to the
flip state of the server and client being different. The server now
resets its flip state on disconnect.
2016-09-22 21:56:19 -04:00
Gregor Richards
06550ec289 Check if setting CLOEXEC fails on the Netplay server port. 2016-09-22 21:02:26 -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
Twinaphex
b2240c5783 Merge pull request #3631 from GregorR/netplay-reconnect
Support for Netplay reconnection
2016-09-22 14:27:38 +02:00
Gregor Richards
4a83e6dee9 Both sides should send the same header so either can check the other 2016-09-22 07:06:26 -04:00
Gregor Richards
42f8ed4338 Support for Netplay reconnection
In net server mode, when the client disconnects, the server now returns
to listening mode, in anticipation of the client reconnecting.
2016-09-21 22:37:43 -04:00
twinaphex
017bf34d71 Prevent null pointer dereference defect 2016-09-22 03:59:02 +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
twinaphex
b548362869 Use encoding_crc32 2016-09-21 12:31:40 +02:00
Gregor Richards
851cd0fe6e Removing now-unused BSV-related functions from Netplay 2016-09-20 22:32:23 -04:00
twinaphex
d7e9c198e6 Cleanups to netplay 2016-09-17 18:21:29 +02:00
Twinaphex
e21662b3e9 Merge pull request #3607 from GregorR/netplay-savestates
Netplay savestate loading frontend changes
2016-09-17 18:15:49 +02:00
Alcaro
ec2fd5ebd7 Fix warning 2016-09-17 17:55:42 +02:00
Gregor Richards
d53373a5cb Netplay savestate loading frontend changes
Support for the frontend to inform Netplay when a savestate has been
loaded, so Netplay can in turn inform the peer.
2016-09-17 11:24:23 -04:00
twinaphex
a55feae619 CXX_BUILD fixes 2016-09-16 13:38:06 +02: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
4076b14568 Make Netplay flipping deterministic
The receiving side of a player-flip request now does a forced rewind to
assure that any already-computed frames are computed with the players on
the right side.
2016-09-15 23:06:32 -04:00
Gregor Richards
827009d2d3 A few corrections/clarifications in the Netplay README 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
9a91570db8 Adding new network commands to the Netplay README. 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
79eba578ff Remote state load bugfix: Don't skip an input frame 2016-09-15 23:06:32 -04:00