Commit Graph

162 Commits

Author SHA1 Message Date
Gregor Richards a96eb24247 Support for keyboards over netplay. 2018-01-05 14:27:02 -05:00
Gregor Richards c01a199493 Netplay input device abstraction, support for mice
This abstracts away the details of particular input devices for netplay,
and adds support for mice and (similar) lightguns. Unfortunately, in
practice, no core handles mice or lightguns in a savestate-safe way, so
they need to be used in stateless mode to be reliable, but they do work.
2018-01-05 14:27:02 -05:00
Gregor Richards 8d5a79fc69 Removing long-obsolete now-disfunctional "netplay flip players" feature 2018-01-05 14:27:02 -05:00
Gregor Richards f7dba84c67 Netplay mode change improvements
(1) All mode change code unified, so server mode changes and client mode
changes and announcements go through the same functions

(2) New messages which are translateable and work with multiple input
devices
2018-01-05 14:26:19 -05:00
Gregor Richards 74901e6161 Whoops, missed one refactor rename. 2018-01-05 14:24:43 -05:00
Gregor Richards ed320fd914 Adding and removing players
The new input handling makes adding and removing players more
complicated, since data can be present that's not expected from the
connected clients list, or absent that's expected in the list but
actually shouldn't be there.
2018-01-05 14:24:43 -05:00
Gregor Richards 39243a8d40 Configurable sharing mode. 2018-01-05 14:24:43 -05:00
Gregor Richards abf045ef0e Made device requests (badly) configurable. 2018-01-05 14:24:43 -05:00
Gregor Richards fe80c4ce2c Added real pad sharing modes. 2018-01-05 14:24:43 -05:00
Gregor Richards e4029b72c1 Rename things back after renaming for refactoring. 2018-01-05 14:24:42 -05:00
Gregor Richards b897ba4e30 Re-fixed input simulation. 2018-01-05 14:24:42 -05:00
Gregor Richards d1ca90e136 Get rid of this FIXME. 2018-01-05 14:24:42 -05:00
Gregor Richards ed69916e59 First cut of input changes (not yet working) 2018-01-05 14:24:42 -05:00
Gregor Richards 6d4119690d First step (not yet compiling) of changing around Netplay input. 2018-01-05 14:24:42 -05:00
gblues 6904101c44 Clean up trailing whitespace
== DETAILS

Really simple code cleanup, because my editor flags trailing whitespaces
and it's pretty annoying.
2017-12-12 00:24:18 -08:00
Gregor Richards fb3c35dc9f Handle forwarding of netplay state demotions correctly.
Netplay state demotions, i.e. changes from playing to spectating or
disconnected states, could cause chain disconnections of all other
clients. This was due to a bug in when MODE change messages were sent.
Clients rely on the server sending all messages in its own order, and as
a consequence, the server typically holds messages for retransmission
until they can be retransmitted at the correct time. MODE messages were
not held, so could be sent early. When they were sent early, this caused
other clients to panic and disconnect.

A smaller but much stupider secondary bug was also fixed, in which the
first connection could be dropped due simply to writing connections[0]
instead of connections[i] somewhere.
2017-06-06 21:35:09 -04:00
radius 1de95c6413 further refinement of the netplay workflow 2017-05-16 00:18:29 -05:00
Gregor Richards fbb508ab5e Make rewind compatible with netplay.
This commit adds support for temporary desync in netplay. When frontend
features that can't be truly synced, in particular rewind, are used,
netplay is momentarily disabled. As soon as the feature finished, e.g. a
rewind ending, netplay resumes with a state load. For rewind, netplay
peers won't actually experience the effect of rewind, but they will load
the rewound state.
2017-04-18 15:25:58 -04:00
Gregor Richards 3ff9a43b7d Spectator and slave mode are rewind-free
This commit makes spectator mode and slave mode in netplay always stay
ahead of the input, thereby avoiding rewinds, which is sort of the
point. This also changes catch-up detection to be a bit less eager, so
that they hopefully don't flap between stalling for server input and
catching up with that input.
2017-02-23 19:05:43 -05:00
Gregor Richards e495671563 In spectator mode, we should never be ahead of our peer. 2017-02-22 23:19:22 -05:00
Gregor Richards e70ee045bf Initial implementation of Netplay master/slave mode. 2017-02-22 20:34:17 -05:00
Gregor Richards 972b41f803 Fix race condition in NAT traversal task. 2017-02-20 20:16:53 -05:00
Gregor Richards 4c1abfaa71 Support for reset in netplay
This patch transfers core_reset across netplay. Resets effectively
worked before thanks to check_frames, but this makes resets work even
without check_frames, and in particular should allow resets to force
sync in savestateless cores, bringing them one step closer to actually
being usable by non-experts.
2017-02-15 14:40:37 -05:00
Gregor Richards 2ea3936d16 Renaming input_ptr/input_frame_count back to self_. 2017-02-01 22:54:03 -05:00
Gregor Richards 55157e934d input_latency_frames is now configurable and has a range 2017-02-01 22:54:03 -05:00
Gregor Richards c4cb94db19 New approach to input latency 2017-02-01 22:54:03 -05:00
twinaphex 96c8ca5a09 Header update #1 2017-01-22 13:40:32 +01:00
Gregor Richards cd281d5757 Reverse catch-up, i.e., server-demanded stalling
Previously, if two clients were connected to the same server and one of
them was ahead of the server, the only way to rectify that situation was
for the client to get so far ahead that it stalled, as the server could
only catch up with an ahead client if all clients were ahead. That's
unrealistic. This gives the server the alternate option of demanding
that a client stall. This keeps things nicely in line even with >2
players.
2016-12-24 15:25:03 -05:00
Gregor Richards f0bb0a77f8 Make netplay no longer cache passwords
Netplay now always loads passwords from the configuration, so that
passwords can be changed mid-session.
2016-12-21 09:51:50 -05:00
Gregor Richards c780e7db43 Accept the variable size quirk
Since the quirks protocol was that a core could report variable
savestate size, but the host then tells it "no", we should actually
accept the variable size quirk in netplay, since RetroArch refuses to
allow cores to actually produce variable-size states.
2016-12-20 22:17:15 -05:00
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 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 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 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 6658826759 CRC validity checking. Ignore CRCs if they don't work. 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 da7efcb939 Cleaning up netplay headers. 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 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 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 3631ff74ff Very, very partial support for the server spectating 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 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 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 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 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 1214541410 Added packet buffer resizing to cope with initialization quirks. 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
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 0577749fae Netplay LAN scanning is go! (sort of) 2016-12-02 22:40:26 -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 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 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 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
Gregor Richards 5c206c89f0 Add a netplay advertisement server for LAN netplay detection. 2016-10-10 11:52:54 -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 701cc5a18c Splitting endian and other platform savestate quirks. 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 07a4ad791d Implemented Netplay initialization quirk 2016-10-04 23:07:35 -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 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 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
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 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
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 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 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