From b2e98b9d28c0d22f81607d18cfea841c11c2c54c Mon Sep 17 00:00:00 2001 From: Dario Date: Sat, 18 May 2024 21:25:51 -0300 Subject: [PATCH] Fix division by zero possibility during frame matching. --- src/hle/rt64_game_frame.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/hle/rt64_game_frame.cpp b/src/hle/rt64_game_frame.cpp index 3fe8973..da03727 100644 --- a/src/hle/rt64_game_frame.cpp +++ b/src/hle/rt64_game_frame.cpp @@ -644,11 +644,16 @@ namespace RT64 { const GameFrameMap::TileMap &prevTileMap = firstPrevWorkloadMap->tiles[indices.second]; curTileMap = prevTileMap; } - + auto modulo = [](int a, int b) { - int r = a % b; - return r < 0 ? r + b : r; - }; + if (b != 0) { + int r = a % b; + return r < 0 ? r + b : r; + } + else { + return 0; + } + }; const float deltaUls = curTile.uls - prevTile.uls; const float deltaUlt = curTile.ult - prevTile.ult;