Commit Graph

47 Commits

Author SHA1 Message Date
Twinaphex
08a54e45f2 Get rid of a lot of implicit conversions 2018-04-09 15:56:45 +02:00
Gregor Richards
a39bff6e03 Remove an incorrect double-check
Netplay sync incorrectly checked whether the replay pointer was behind
the unread pointer twice, when in the second check it should only have
been checking if it was behind the current execution pointer. Because of
how resimulation works with device sharing, I THINK this could affect
sync. Even if it can't, it's wrong.
2018-03-03 23:03:35 -05:00
aliaspider
700fce3bd2 various fixes for CXX_BUILD. 2018-02-04 20:03:27 +01:00
Twinaphex
8bc1d9965d Fix unused variables/etc. 2018-01-23 07:29:04 +01:00
twinaphex
6437e4b4a9 remove tons of unreferenced local variables 2018-01-23 05:49:03 +01:00
Gregor Richards
984f763d75 Only do our careful resimulation with joypads 2018-01-05 14:27:02 -05:00
Gregor Richards
50de28b1a1 Netplay keyboard hack for keydown/keyup support
An unfortunate hack for cores that translate the keyboard input device
into keydown/keyup events without saving that in the savestate. We
simply replay the previous frame's input before loading the rewound
frame's state, to assure that both the state and the keyup/down state
are correct.

Ideally, cores would save this as part of the state, but it's a bit
proximal and a fairly significant change for those that use it, so it's
easier to fix in netplay.
2018-01-05 14:27:02 -05:00
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
6eaaaef995 Minor bugfixes in input resolution. 2018-01-05 14:24:43 -05:00
Gregor Richards
2794031d12 Improved reemulation to not replay unread frames if they haven't changed. 2018-01-05 14:24:43 -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
8c551f3990 Fixing some counters. 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
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
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
d1ab288d73 Fix update_unread_ptr to handle the case of only slaves connected 2017-02-22 21:10:02 -05:00
Gregor Richards
e70ee045bf Initial implementation of Netplay master/slave mode. 2017-02-22 20:34:17 -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
twinaphex
768ce0854c Make driver_set_nonblock_state a public function 2017-01-22 12:47:17 +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
twinaphex
70a1a5f38e Buildfixes 2016-12-24 01:48:36 +01:00
twinaphex
64dc7daeca (MSVC) MSVC build fixes 2016-12-24 01:45:37 +01:00
Gregor Richards
dcd4b3046b Making negative check_frames be "check only" mode 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
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
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
db2c8de44c Slightly changing how catch-up works to avoid spamming the console 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
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
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