Commit Graph

479 Commits

Author SHA1 Message Date
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
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
4d11b1d674 Don't misinterpret "Netplay isn't loaded" as "must pause" :) 2016-09-15 23:06:32 -04:00
Gregor Richards
c3186c57ab Don't stall if connection lost with remote paused 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
twinaphex
a71cd89379 Cleanup unused variable 2016-09-15 21:26:10 +02:00
Gregor Richards
9bc78d25a0 Minor stylistic fixes for clarity and consistency with the rest of
RetroArch.
2016-09-14 10:06:57 -04:00
Gregor Richards
b1a2e096e5 Use consistent quotes in Netplay README. 2016-09-14 10:03:26 -04:00
Gregor Richards
12bf3e4824 Rather than repeating the same sample for every frame while stalled,
just pause the sound while stalled. Both options are annoying, but this
option is less annoying.
2016-09-13 21:45:06 -04:00
Gregor Richards
ea0bb6f812 Just in case some systems don't have TCP_NODElAY, put that in an ifdef. 2016-09-13 21:39:10 -04:00
Gregor Richards
d4e074dbed Moved the advance of self_ptr to the same place as the advance of
self_frame_count, which is much clearer.
2016-09-13 21:32:57 -04:00
Gregor Richards
99b5ed92ed other should always be <= both real AND self. Before this fix, it was
possible (albeit unlikely) for the remote to get so far ahead of us that
they actually overwrote our own current data :)
2016-09-13 21:32:57 -04:00
Gregor Richards
1267e5e867 A few clarifications regarding the buffer's have_remote and used_real
data. simulation shouldn't touch 'em.
2016-09-13 21:32:57 -04:00
Gregor Richards
a0cfdb8a9c naks now cause disconnection. 2016-09-13 21:32:57 -04:00
Gregor Richards
b140b16b5d Removed Netplay positive acknowledgement messages: They didn't document
their corresponding sent message, and so couldn't be used for
acknowledgement anyway. Negative acknowledgement is sufficient.
2016-09-13 21:32:57 -04:00
Gregor Richards
6829b80c6b Reimplemented disconnection based on stalls. If we stall for 10 seconds,
disconnect.
2016-09-13 21:32:57 -04:00
Gregor Richards
8aa48cd3f9 Reinstituted "standard" timeout-based disconnection, which only works
for stall_frames==0 due to the fixes to not stall the UI.
2016-09-13 21:32:57 -04:00
Gregor Richards
0ccc39769d Adding my copyright lines to files I've touched. 2016-09-13 21:32:57 -04:00
Gregor Richards
ae8e695644 Fixing indentation to align with the rest of RetroArch. 2016-09-13 21:32:57 -04:00
Gregor Richards
f9f4e15d33 Removing commented-out code (mostly old UDP stuff) 2016-09-13 21:32:57 -04:00
Gregor Richards
c5fe0ec6be Updating the Netplay README to be true of the current implementation. 2016-09-13 21:32:57 -04:00
Gregor Richards
147d739197 Fixed stall_frames=0 mode to only block if frames are actually needed.
Rather than counting on the complexicon of used_real calculations, set
used_real when... real is used. (Problem: If the core doesn't read input
at all, used_real won't be set; todo: test with handhelds.) Minor
resilience fixes.
2016-09-13 21:32:57 -04:00
Gregor Richards
c7d0bf90f6 Bugfixes to bring Netplay Nouveau from "kinda working" to "stably
working":

(1) Fixups to the stall logic to make sure it always receives frames
while stalling :)

(2) Disused the used_real field. It was misconfigured and would
frequently claim to be using real data when real data hadn't been
used... this means more replays for now, but used_real will be readded.
(TODO)

(3) Stall duration is now related to sync frames, and thus configurable.

(4) Delta frames were having the good ol' initialization problem, as
frame==0 was indistinguishable from unused. Quickfixed by adding a
"used" field, but maybe there's a better way.

(5) If serialization fails, switch immediately to blocking mode
(stall_frames = 0). Blocking mode barely works, but if serialization
fails, no mode will work!

(6) I'm not sure which bug my replaying-from-previous-frame was trying
to fix, but the correct behavior is to replay from the last frame we had
vital information, not the frame prior. Notionally this should just be
an efficiency thing, but unsigned arithmetic at 0 made this a "just
ignore all input from now on" thing.
2016-09-13 21:32:57 -04:00
Gregor Richards
07e869ccae is_simulated was confusing and poorly named. Using have_remote in its
place, which is simply true if we've received remote data. Could also
just use read_frame_crount instead, but this keeps the info frame-local.
2016-09-13 21:32:57 -04:00
Gregor Richards
4f16a19f5e Rather than stalling by blocking and becoming unresponsive, stall by
replaying the same frame. TODO: Maybe mute the audio?
2016-09-13 21:32:57 -04:00
Gregor Richards
5edfbeafb0 Switched Netplay over to TCP. A lot of the stalling logic had to change
for this, and in particular, it now sometimes stalls in a way that makes
it very difficult to actually input anything (whoops :) ). Simply
setting the sync frames higher avoids that. With supported cores, this
is incredibly risilient, but when it fails, it mostly fails to freezing,
which is less than ideal.

TODO: Stall frames should be configurable. All the UDP code is still
there but commented out, should be gutted. The original fast-forward
code is now commented out, but really both fast-forward and stalling
should be options; the only complication is that it needs to send
simulated self-input for fast-forward.
2016-09-13 21:32:57 -04:00
Gregor Richards
9a80a1bd7e Adding a bit of Netplay documentation. 2016-09-13 21:32:57 -04:00
Gregor Richards
69b7dc0d08 Multitudinous fixes and updates to Netplay. Had to be one commit since
they're mostly related:

(1) Renamed frame_count to self_frame_count to be consistent with all
other names.

(2) Previously, it was possible to overwrite data in the ring buffer
that hadn't yet been used. Now that's not possible, but that just
changes one breakage for another: It's now possible to miss the NEW
data. The final resolution for this will probably be requesting stalls.
This is accomplished simply by storing frame numbers in the ring buffer
and checking them against the 'other' head.

(3) In TCP packets, separated cmd_size from cmd. It was beyond pointless
for these to be combined, and restricted cmd_size to 16 bits, which
will probably fail when/if state loading is supported.

(4) Readahead is now allowed. In the past, if the peer got ahead of us,
we would simply ignore their data. Thus, if they got too far ahead of
us, we'd stop reading their data altogether. Fabulous. Now, we're happy
to read future input.

(5) If the peer gets too far ahead of us (currently an unconfigurable 10
frames), fast forward to catch up. This should prevent desync due to
clock drift or stutter.

(6) Used frame_count in a few places where ptr was used. Doing a
comparison of pointers on a ring buffer is a far more dangerous way to
assure we're done with a task than simply using the count, since the
ring buffer is... well, a ring.

(7) Renamed tmp_{ptr,frame_count} to replay_{ptr,frame_count} for
clarity.

(8) Slightly changed the protocol version hash, just to assure that
other clients wouldn't think they were compatible with this one.

(9) There was an off-by-one error which, under some circumstances, could
allow the replay engine to run a complete round through the ring buffer,
replaying stale data. Fixed.
2016-09-13 21:32:57 -04:00
twinaphex
b0e372432f Cleanups 2016-09-12 18:18:20 +02:00
twinaphex
6f23a8ac0d Move httpserver to network/ 2016-09-12 17:21:00 +02:00
twinaphex
db6171676a Use retro_assert everywhere 2016-09-08 11:59:44 +02:00
twinaphex
c3ba0ba4e9 Revert "Refactor core_system_info_* functions"
This reverts commit f637805c9e.
2016-09-06 08:38:26 +02:00
twinaphex
f637805c9e Refactor core_system_info_* functions 2016-09-06 07:08:38 +02:00
twinaphex
82d82110ae Merge system.h with core.h 2016-09-06 06:11:54 +02:00
twinaphex
e6524f961a header include cleanups 2016-09-06 01:02:25 +02:00
twinaphex
075aea2289 Header include cleanups 2016-09-06 00:56:00 +02:00
twinaphex
acd4dd527b Header include cleanups 2016-09-05 18:31:32 +02:00
twinaphex
9191bfa3c0 Header include cleanups 2016-09-03 07:51:11 +02:00
twinaphex
23612cb26f Header include cleanups 2016-09-03 07:48:25 +02:00
twinaphex
50563d255f Header cleanups 2016-09-03 07:45:51 +02:00
sergiobenrocha2
7ba35a9929 Fix some spelling errors (pendantic info lintian warnings). 2016-07-20 23:28:29 -03:00
twinaphex
982dd47f01 Translate a bunch of log strings 2016-06-29 03:06:15 +02:00
twinaphex
13dd8e4905 Add translations 2016-06-28 12:08:30 +02:00
twinaphex
aabb1e409c Move netplay code to network/netplay dir 2016-05-19 11:46:54 +02:00
twinaphex
cba281052a Rename np_ functions 2016-05-12 12:03:43 +02:00
twinaphex
a7d4379011 Rename np_is_server to netplay_is_server 2016-05-12 10:20:14 +02:00
twinaphex
df3b090d7a Revert "Create runloop_get_system_info/runloop_free_system_info/runloop_init_system_info"
This reverts commit 35bf38e05c.
2016-05-12 09:37:21 +02:00
twinaphex
35bf38e05c Create runloop_get_system_info/runloop_free_system_info/runloop_init_system_info 2016-05-12 09:25:52 +02:00
twinaphex
9aed52ac65 Move performance.c to libretro-common/features/features_cpu.c 2016-05-10 20:31:27 +02:00
twinaphex
4a7ab8366b Move libretro.h headers to libretro-common/include 2016-05-10 19:03:53 +02:00
twinaphex
35ea37b37f Revert "Move cpu_features to libretro-common"
This reverts commit 2b8ff3bf38.
2016-05-10 09:32:24 +02:00
twinaphex
2b8ff3bf38 Move cpu_features to libretro-common 2016-05-10 09:27:29 +02:00
twinaphex
0d371def5c Refactor performance.c code 2016-05-10 09:17:04 +02:00
twinaphex
b79b2dca13 Create performance_counters 2016-05-10 08:53:14 +02:00
twinaphex
2691ab0c7d Rename command_event enums 2016-05-09 20:51:53 +02:00
twinaphex
523ebed112 Combine command_event.c and command.c 2016-05-09 20:30:47 +02:00
twinaphex
a98ef36d36 Rename event_cmd_ctl to command_event 2016-05-09 20:20:50 +02:00
twinaphex
1cd98f1cf7 (Androd) Buildfix 2016-05-09 19:21:40 +02:00
twinaphex
7ca75d46f8 Move net_http_special to network/ 2016-05-09 17:47:45 +02:00
twinaphex
751872afa4 Move netlogger.c to network/ 2016-05-09 17:45:21 +02:00
twinaphex
3722826e0a Rename netplay/ to network/ 2016-05-09 17:43:38 +02:00