Skip to content

Commit

Permalink
Against bots, don't frame advance if we're behind.
Browse files Browse the repository at this point in the history
  • Loading branch information
vladfi1 committed Nov 1, 2024
1 parent 1ceafe2 commit 16313d5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
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

0 comments on commit 16313d5

Please sign in to comment.