Skip to content

Commit

Permalink
Check that opponents really are bots.
Browse files Browse the repository at this point in the history
  • Loading branch information
vladfi1 committed Oct 31, 2024
1 parent 0371a01 commit f2c435b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
22 changes: 19 additions & 3 deletions Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,9 @@ bool CEXISlippi::shouldSkipOnlineFrame(s32 frame, s32 finalized_frame)

bool CEXISlippi::shouldAdvanceOnlineFrame(s32 frame)
{
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 @@ -1556,11 +1559,24 @@ void CEXISlippi::handleSendInputs(s32 frame, u8 delay, s32 checksum_frame, u32 c
slippi_netplay->SendSlippiPad(std::move(pad));
}

bool CEXISlippi::isFacingBots()
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].is_bot)
return false;
}

// Now check whether the bot is actually using runahead.
u8 remote_player_count = matchmaking->RemotePlayerCount();

// If the opponent is using the bot build, they will be running ahead of us.
for (int i = 0; i < remote_player_count; i++)
{
if (slippi_netplay->m_remote_dolphin_type[i] != SlippiNetplayClient::DolphinType::BOT)
Expand Down Expand Up @@ -1588,7 +1604,7 @@ void CEXISlippi::prepareOpponentInputs(s32 frame, bool should_skip)
{
frame_result = 3; // Indicates we have disconnected
}
else if (!isFacingBots() && shouldAdvanceOnlineFrame(frame))
else if (shouldAdvanceOnlineFrame(frame))
{
frame_result = 4;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class CEXISlippi : public IEXIDevice
void setMatchSelections(u8* payload);
bool shouldSkipOnlineFrame(s32 frame, s32 finalized_frame);
bool shouldAdvanceOnlineFrame(s32 frame);
bool isFacingBots();
bool opponentRunahead();
void handleLogInRequest();
void handleLogOutRequest();
void prepareOnlineStatus();
Expand Down

0 comments on commit f2c435b

Please sign in to comment.