even with 6e7b30d5d7d8b3a545dd412100401299ae8ada8d

This commit is contained in:
R2DLiu 2021-11-26 19:37:32 -05:00
commit 7665a31bb8
8 changed files with 106 additions and 91 deletions

View file

@ -19,9 +19,9 @@ namespace Common
#endif
#ifndef IS_PLAYBACK
#define SLIPPI_REV_STR "2.3.0"
#define SLIPPI_REV_STR "2.3.2"
#else
#define SLIPPI_REV_STR "2.3.0"
#define SLIPPI_REV_STR "2.3.2"
#endif
const std::string scm_slippi_semver_str = SLIPPI_REV_STR;

View file

@ -62,6 +62,7 @@
#include "Core/PatchEngine.h"
#include "Core/PowerPC/JitInterface.h"
#include "Core/PowerPC/PowerPC.h"
#include "Core/Slippi/SlippiNetplay.h"
#include "Core/State.h"
#include "Core/WiiRoot.h"
@ -642,6 +643,10 @@ void SetState(State state)
if (!IsRunningAndStarted())
return;
// Do not allow any kind of cpu pause/resum if we are connected to someone on slippi
if (IsOnline())
return;
switch (state)
{
case State::Paused:
@ -720,6 +725,9 @@ static std::string GenerateScreenshotName()
void SaveScreenShot()
{
if (IsOnline())
return;
const bool bPaused = GetState() == State::Paused;
SetState(State::Paused);

View file

@ -1667,10 +1667,8 @@ void CEXISlippi::prepareOpponentInputs(u8* payload)
void CEXISlippi::handleCaptureSavestate(u8* payload)
{
#ifndef IS_PLAYBACK
if (isDisconnected())
return;
#endif
s32 frame = payload[0] << 24 | payload[1] << 16 | payload[2] << 8 | payload[3];

View file

@ -3,39 +3,35 @@
// Refer to the license.txt file included.
#include "Core/Slippi/SlippiNetplay.h"
#include "Common/Common.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
#include "Common/Config/Config.h"
#include "Common/ENetUtil.h"
#include "Common/MD5.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/Timer.h"
#include "Core/Config/NetplaySettings.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/NetPlayProto.h"
//#include "Core/HW/EXI_DeviceIPL.h"
//#include "Core/HW/SI.h"
//#include "Core/HW/SI_DeviceGCController.h"
#include "Core/HW/Sram.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
#include "Core/HW/WiimoteReal/WiimoteReal.h"
//#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h"
#include <SlippiGame.h>
#include <algorithm>
#include <fstream>
#include <mbedtls/md5.h>
#include <memory>
#include <thread>
#include "Core/Movie.h"
#include "InputCommon/GCAdapter.h"
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/VideoConfig.h"
#include <SlippiGame.h>
#include <algorithm>
#include <fstream>
#include <memory>
#include <thread>
static std::mutex pad_mutex;
static std::mutex ack_mutex;
SlippiNetplayClient* SLIPPI_NETPLAY = nullptr;
static bool IsOnline()
{
return SLIPPI_NETPLAY != nullptr;
}
// called from ---GUI--- thread
SlippiNetplayClient::~SlippiNetplayClient()
{
@ -58,6 +54,8 @@ SlippiNetplayClient::~SlippiNetplayClient()
m_client = nullptr;
}
SLIPPI_NETPLAY = nullptr;
WARN_LOG(SLIPPI_ONLINE, "Netplay client cleanup complete");
}
@ -68,11 +66,11 @@ SlippiNetplayClient::SlippiNetplayClient(const std::string& address, const u16 r
: m_qos_handle(nullptr), m_qos_flow_id(0)
#endif
{
WARN_LOG(SLIPPI_ONLINE, "Initializing Slippi Netplay for port: %d, with host: %s", localPort,
isDecider ? "true" : "false");
WARN_LOG_FMT(SLIPPI_ONLINE, "Initializing Slippi Netplay for port: %d, with host: %s", localPort,
isDecider ? "true" : "false");
this->isDecider = isDecider;
// this->playerIdx = isDecider ? 0 : 1;
SLIPPI_NETPLAY = std::move(this);
// Local address
ENetAddress* localAddr = nullptr;
@ -121,6 +119,7 @@ SlippiNetplayClient::SlippiNetplayClient(const std::string& address, const u16 r
SlippiNetplayClient::SlippiNetplayClient(bool isDecider)
{
this->isDecider = isDecider;
SLIPPI_NETPLAY = std::move(this);
slippiConnectStatus = SlippiConnectStatus::NET_CONNECT_STATUS_FAILED;
}
@ -292,7 +291,7 @@ unsigned int SlippiNetplayClient::OnData(sf::Packet& packet)
break;
default:
WARN_LOG(SLIPPI_ONLINE, "Unknown message received with id : %d", mid);
WARN_LOG_FMT(SLIPPI_ONLINE, "Unknown message received with id : %d", mid);
break;
}
@ -384,6 +383,7 @@ void SlippiNetplayClient::Disconnect()
// didn't disconnect gracefully force disconnect
enet_peer_reset(m_server);
m_server = nullptr;
SLIPPI_NETPLAY = nullptr;
}
void SlippiNetplayClient::SendAsync(std::unique_ptr<sf::Packet> packet)
@ -422,7 +422,8 @@ void SlippiNetplayClient::ThreadFunc()
break;
}
WARN_LOG(SLIPPI_ONLINE, "[Netplay] Not yet connected. Res: %d, Type: %d", net, netEvent.type);
WARN_LOG_FMT(SLIPPI_ONLINE, "[Netplay] Not yet connected. Res: %d, Type: %d", net,
netEvent.type);
// Time out after enough time has passed
attemptCount++;

View file

@ -127,14 +127,14 @@ public:
u64 GetSlippiPing();
s32 GetSlippiLatestRemoteFrame();
u8 GetSlippiRemoteChatMessage();
u8 GetSlippiRemoteSentChatMessage();
u8 GetSlippiRemoteSentChatMessage();
s32 CalcTimeOffsetUs();
void WriteChatMessageToPacket(sf::Packet &packet, int messageId);
std::unique_ptr<SlippiPlayerSelections> ReadChatMessageFromPacket(sf::Packet &packet);
void WriteChatMessageToPacket(sf::Packet& packet, int messageId);
std::unique_ptr<SlippiPlayerSelections> ReadChatMessageFromPacket(sf::Packet& packet);
u8 remoteChatMessageId = 0; // most recent chat message id from opponent
u8 remoteSentChatMessageId = 0; // most recent chat message id that current player sent
u8 remoteChatMessageId = 0; // most recent chat message id from opponent
u8 remoteSentChatMessageId = 0; // most recent chat message id that current player sent
protected:
struct
@ -204,3 +204,7 @@ private:
u32 m_timebase_frame = 0;
};
extern SlippiNetplayClient* SLIPPI_NETPLAY; // singleton static pointer
static bool IsOnline();

View file

@ -23,8 +23,9 @@
#include "Core/HotkeyManager.h"
#include "Core/IOS/IOS.h"
#include "Core/IOS/USB/Bluetooth/BTBase.h"
#include "Core/State.h"
#include "Core/Slippi/SlippiNetplay.h"
#include "Core/Slippi/SlippiPlayback.h"
#include "Core/State.h"
#include "DolphinQt/Settings.h"
@ -236,7 +237,7 @@ void HotkeyScheduler::Run()
if (device != nullptr)
std::static_pointer_cast<IOS::HLE::Device::BluetoothBase>(device)->UpdateSyncButtonState(
IsHotkey(HK_TRIGGER_SYNC_BUTTON, true));
IsHotkey(HK_TRIGGER_SYNC_BUTTON, true));
}
if (SConfig::GetInstance().bEnableDebugging)
@ -269,7 +270,7 @@ void HotkeyScheduler::Run()
if (IsHotkey(HK_TOGGLE_USB_KEYBOARD))
{
Settings::Instance().SetUSBKeyboardConnected(
!Settings::Instance().IsUSBKeyboardConnected());
!Settings::Instance().IsUSBKeyboardConnected());
}
}
@ -315,9 +316,9 @@ void HotkeyScheduler::Run()
auto ShowVolume = []() {
OSD::AddMessage(std::string("Volume: ") +
(SConfig::GetInstance().m_IsMuted ?
"Muted" :
std::to_string(SConfig::GetInstance().m_Volume) + "%"));
(SConfig::GetInstance().m_IsMuted ?
"Muted" :
std::to_string(SConfig::GetInstance().m_Volume) + "%"));
};
// Volume
@ -415,20 +416,20 @@ void HotkeyScheduler::Run()
auto ShowXFBCopies = []() {
OSD::AddMessage(StringFromFormat(
"Copy XFB: %s%s", Config::Get(Config::GFX_HACK_IMMEDIATE_XFB) ? " (Immediate)" : "",
Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM) ? "to Texture" : "to RAM"));
"Copy XFB: %s%s", Config::Get(Config::GFX_HACK_IMMEDIATE_XFB) ? " (Immediate)" : "",
Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM) ? "to Texture" : "to RAM"));
};
if (IsHotkey(HK_TOGGLE_XFBCOPIES))
{
Config::SetCurrent(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM,
!Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM));
!Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM));
ShowXFBCopies();
}
if (IsHotkey(HK_TOGGLE_IMMEDIATE_XFB))
{
Config::SetCurrent(Config::GFX_HACK_IMMEDIATE_XFB,
!Config::Get(Config::GFX_HACK_IMMEDIATE_XFB));
!Config::Get(Config::GFX_HACK_IMMEDIATE_XFB));
ShowXFBCopies();
}
if (IsHotkey(HK_TOGGLE_FOG))
@ -448,26 +449,29 @@ void HotkeyScheduler::Run()
auto ShowEmulationSpeed = []() {
OSD::AddMessage(
SConfig::GetInstance().m_EmulationSpeed <= 0 ?
"Speed Limit: Unlimited" :
StringFromFormat("Speed Limit: %li%%",
std::lround(SConfig::GetInstance().m_EmulationSpeed * 100.f)));
SConfig::GetInstance().m_EmulationSpeed <= 0 ?
"Speed Limit: Unlimited" :
StringFromFormat("Speed Limit: %li%%",
std::lround(SConfig::GetInstance().m_EmulationSpeed * 100.f)));
};
if (IsHotkey(HK_DECREASE_EMULATION_SPEED))
if (!IsOnline())
{
auto speed = SConfig::GetInstance().m_EmulationSpeed - 0.1;
speed = (speed <= 0 || (speed >= 0.95 && speed <= 1.05)) ? 1.0 : speed;
SConfig::GetInstance().m_EmulationSpeed = speed;
ShowEmulationSpeed();
}
if (IsHotkey(HK_DECREASE_EMULATION_SPEED))
{
auto speed = SConfig::GetInstance().m_EmulationSpeed - 0.1;
speed = (speed <= 0 || (speed >= 0.95 && speed <= 1.05)) ? 1.0 : speed;
SConfig::GetInstance().m_EmulationSpeed = speed;
ShowEmulationSpeed();
}
if (IsHotkey(HK_INCREASE_EMULATION_SPEED))
{
auto speed = SConfig::GetInstance().m_EmulationSpeed + 0.1;
speed = (speed >= 0.95 && speed <= 1.05) ? 1.0 : speed;
SConfig::GetInstance().m_EmulationSpeed = speed;
ShowEmulationSpeed();
if (IsHotkey(HK_INCREASE_EMULATION_SPEED))
{
auto speed = SConfig::GetInstance().m_EmulationSpeed + 0.1;
speed = (speed >= 0.95 && speed <= 1.05) ? 1.0 : speed;
SConfig::GetInstance().m_EmulationSpeed = speed;
ShowEmulationSpeed();
}
}
// Slot Saving / Loading
@ -530,7 +534,8 @@ void HotkeyScheduler::Run()
if (IsHotkey(HK_SLIPPI_JUMP_BACK))
{
INFO_LOG(SLIPPI, "jump back");
if (g_playbackStatus->targetFrameNum == INT_MAX) {
if (g_playbackStatus->targetFrameNum == INT_MAX)
{
g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame - 1200;
Host_PlaybackSeek();
}
@ -539,7 +544,8 @@ void HotkeyScheduler::Run()
if (IsHotkey(HK_SLIPPI_STEP_BACK))
{
INFO_LOG(SLIPPI, "step back");
if (g_playbackStatus->targetFrameNum == INT_MAX) {
if (g_playbackStatus->targetFrameNum == INT_MAX)
{
g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame - 300;
Host_PlaybackSeek();
}
@ -548,7 +554,8 @@ void HotkeyScheduler::Run()
if (IsHotkey(HK_SLIPPI_STEP_FORWARD))
{
INFO_LOG(SLIPPI, "step forward");
if (g_playbackStatus->targetFrameNum == INT_MAX) {
if (g_playbackStatus->targetFrameNum == INT_MAX)
{
g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame + 300;
Host_PlaybackSeek();
}
@ -557,7 +564,8 @@ void HotkeyScheduler::Run()
if (IsHotkey(HK_SLIPPI_JUMP_FORWARD))
{
INFO_LOG(SLIPPI, "jump forward");
if (g_playbackStatus->targetFrameNum == INT_MAX) {
if (g_playbackStatus->targetFrameNum == INT_MAX)
{
g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame + 1200;
Host_PlaybackSeek();
}
@ -571,7 +579,7 @@ void HotkeyScheduler::Run()
if (IsHotkey(HK_INCREASE_DEPTH, true))
Config::SetCurrent(Config::GFX_STEREO_DEPTH,
std::min(stereo_depth + 1, Config::GFX_STEREO_DEPTH_MAXIMUM));
std::min(stereo_depth + 1, Config::GFX_STEREO_DEPTH_MAXIMUM));
const auto stereo_convergence = Config::Get(Config::GFX_STEREO_CONVERGENCE);
@ -580,7 +588,7 @@ void HotkeyScheduler::Run()
if (IsHotkey(HK_INCREASE_CONVERGENCE, true))
Config::SetCurrent(Config::GFX_STEREO_CONVERGENCE,
std::min(stereo_convergence + 5, Config::GFX_STEREO_CONVERGENCE_MAXIMUM));
std::min(stereo_convergence + 5, Config::GFX_STEREO_CONVERGENCE_MAXIMUM));
// Freelook
static float fl_speed = 1.0;

View file

@ -22,6 +22,7 @@
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/PowerPC/PowerPC.h"
#include "Core/Slippi/SlippiNetplay.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/Settings.h"
@ -359,7 +360,8 @@ void GeneralPane::OnSaveConfig()
m_checkbox_override_region_settings->isChecked());
Config::SetBase(Config::MAIN_AUTO_DISC_CHANGE, m_checkbox_auto_disc_change->isChecked());
Config::SetBaseOrCurrent(Config::MAIN_ENABLE_CHEATS, m_checkbox_cheats->isChecked());
settings.m_EmulationSpeed = m_combobox_speedlimit->currentIndex() * 0.1f;
if (!IsOnline())
settings.m_EmulationSpeed = m_combobox_speedlimit->currentIndex() * 0.1f;
Settings::Instance().SetFallbackRegion(
UpdateFallbackRegionFromIndex(m_combobox_fallback_region->currentIndex()));

View file

@ -14,9 +14,9 @@
#include <sys/stat.h>
#include <vector>
#include "Core/ConfigManager.h"
#include "Common/FileUtil.h"
#include "Common/StringUtil.h"
#include "Core/ConfigManager.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/ControllerInterface/Pipes/Pipes.h"
@ -51,15 +51,14 @@ void PopulateDevices()
for (uint32_t i = 0; i < 4; i++)
{
std::string pipename = "\\\\.\\pipe\\slippibot" + std::to_string(i + 1);
pipes[i] = CreateNamedPipeA(
pipename.data(), // pipe name
PIPE_ACCESS_INBOUND, // read access, inward only
PIPE_TYPE_BYTE | PIPE_NOWAIT, // byte mode, nonblocking
1, // number of clients
256, // output buffer size
256, // input buffer size
0, // timeout value
NULL // security attributes
pipes[i] = CreateNamedPipeA(pipename.data(), // pipe name
PIPE_ACCESS_INBOUND, // read access, inward only
PIPE_TYPE_BYTE | PIPE_NOWAIT, // byte mode, nonblocking
1, // number of clients
256, // output buffer size
256, // input buffer size
0, // timeout value
NULL // security attributes
);
// We're in nonblocking mode, so this won't wait for clients
@ -124,14 +123,8 @@ s32 PipeDevice::readFromPipe(PIPE_FD file_descriptor, char* in_buffer, size_t si
u32 bytes_available = 0;
DWORD bytesread = 0;
bool peek_success = PeekNamedPipe(
file_descriptor,
NULL,
0,
NULL,
(LPDWORD)&bytes_available,
NULL
);
bool peek_success =
PeekNamedPipe(file_descriptor, NULL, 0, NULL, (LPDWORD)&bytes_available, NULL);
if (!peek_success && (GetLastError() == ERROR_BROKEN_PIPE))
{
@ -142,12 +135,11 @@ s32 PipeDevice::readFromPipe(PIPE_FD file_descriptor, char* in_buffer, size_t si
if (peek_success && (bytes_available > 0))
{
bool success = ReadFile(
file_descriptor, // pipe handle
in_buffer, // buffer to receive reply
(DWORD)std::min(bytes_available, (u32)size), // size of buffer
&bytesread, // number of bytes read
NULL); // not overlapped
bool success = ReadFile(file_descriptor, // pipe handle
in_buffer, // buffer to receive reply
(DWORD)std::min(bytes_available, (u32)size), // size of buffer
&bytesread, // number of bytes read
NULL); // not overlapped
if (!success)
{
return -1;
@ -173,12 +165,14 @@ s32 PipeDevice::readFromPipe(PIPE_FD file_descriptor, char* in_buffer, size_t si
void PipeDevice::UpdateInput()
{
bool finished = false;
do {
do
{
// Read any pending characters off the pipe. If we hit a newline,
// then dequeue a command off the front of m_buf and parse it.
char buf[32];
s32 bytes_read = readFromPipe(m_fd, buf, sizeof buf);
if (bytes_read == 0) {
if (bytes_read == 0)
{
// Pipe died, so just quit out
return;
}