Skip to content

Commit

Permalink
Fix 'Replay with UID of lu' error
Browse files Browse the repository at this point in the history
- Correctly format the log to display the actual UID
- Fix getReplaydIdByUid being called with an UID of 0, when no replay to compare has been selected
  • Loading branch information
Alayan-stk-2 committed Dec 6, 2023
1 parent 4ca872f commit 6d38bfe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/replay/replay_play.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,6 @@ unsigned int ReplayPlay::getReplayIdByUID(uint64_t uid)
}
}

Log::error("Replay", "Replay with UID of " PRIu64 " not found.", uid);
Log::error("Replay", "Replay with UID of %" PRIu64 " not found.", uid);
return 0;
} //setReplayFileByUID
} //getReplayIdByUID
13 changes: 9 additions & 4 deletions src/states_screens/ghost_replay_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,15 @@ void GhostReplaySelection::loadList()

unsigned int best_index = 0;

// getReplayIdByUID will send 0 if the UID is incorrect,
// and m_is_comparing will be false if it is incorrect,
// so it always work
unsigned int compare_index = ReplayPlay::get()->getReplayIdByUID(m_replay_to_compare_uid);
// Only compute the compare index if we are actually going to compare.
// This avoids spurious errors trying to find a replay with UID 0.
unsigned int compare_index = 0;
if (m_is_comparing)
// In case the requested replay is not found, compare_index will be 0.
compare_index = ReplayPlay::get()->getReplayIdByUID(m_replay_to_compare_uid);

// It's better to do this when not comparing than to do it repeatedly in the loop,
// it will simply be unused if not comparing.
const ReplayPlay::ReplayData& rd_compare = ReplayPlay::get()->getReplayData(compare_index);

for (unsigned int i = 0; i < ReplayPlay::get()->getNumReplayFile() ; i++)
Expand Down

0 comments on commit 6d38bfe

Please sign in to comment.