Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable frame advance if facing a bot #427

Open
wants to merge 2 commits into
base: slippi
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Source/Core/Core/HW/EXI_DeviceSlippi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,11 @@ bool CEXISlippi::shouldSkipOnlineFrame(s32 frame, s32 finalizedFrame)

bool CEXISlippi::shouldAdvanceOnlineFrame(s32 frame)
{
// If the opponent is a bot running ahead to give us more inputs, we should
// just keep going at our own pace rather than trying to catch up.
if (opponentRunahead())
return false;

// Logic below is used to test frame advance by forcing it more often
// SConfig::GetInstance().m_EmulationSpeed = 0.5f;
// if (frame > 120 && frame % 10 < 3)
Expand Down Expand Up @@ -1610,6 +1615,24 @@ void CEXISlippi::handleSendInputs(s32 frame, u8 delay, s32 checksumFrame, u32 ch
slippi_netplay->SendSlippiPad(std::move(pad));
}

bool CEXISlippi::opponentRunahead()
{
// Bot players might be running ahead to "donate" their delay frames to us.

// Only registered bot accounts are allowed to do this.
auto player_info = matchmaking->GetPlayerInfo();
for (int i = 0; i < player_info.size(); i++)
{
if (i == matchmaking->LocalPlayerIndex())
continue;

if (!player_info[i].isBot)
return false;
}

return true;
}

void CEXISlippi::prepareOpponentInputs(s32 frame, bool shouldSkip)
{
m_read_queue.clear();
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/HW/EXI_DeviceSlippi.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class CEXISlippi : public IEXIDevice
void setMatchSelections(u8 *payload);
bool shouldSkipOnlineFrame(s32 frame, s32 finalizedFrame);
bool shouldAdvanceOnlineFrame(s32 frame);
bool opponentRunahead();
void handleLogInRequest();
void handleLogOutRequest();
void handleUpdateAppRequest();
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/Slippi/SlippiMatchmaking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ void SlippiMatchmaking::handleMatchmaking()
playerInfo.displayName = el.value("displayName", "");
playerInfo.connectCode = el.value("connectCode", "");
playerInfo.port = el.value("port", 0);
playerInfo.isBot = el.value("isBot", false);

if (el["chatMessages"].is_array())
{
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/Slippi/SlippiUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class SlippiUser
int port;

std::vector<std::string> chatMessages;

bool isBot = false;
};

SlippiUser(uintptr_t rs_exi_device_ptr);
Expand Down
Loading