From dcf1a81e8004e39d0fc503e0100966dd1ff40f04 Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 12 Sep 2020 21:55:26 -0700 Subject: [PATCH] Fix duplicate levels in levelstats if you don't have a higher score This is a regression from 25779606b499819de50151cd20aab406256315f5 (PR #74). On the one hand, I should've thought this through carefully when implementing the fix for the lower-score overwrite bug. On the other hand, flibit didn't seem to notice either. And on the third hand, no one else seems to have noticed, when they have had over 8 months to do so. Not even the person who originally reported the lower-score overwrite bug and also reported other bugs I hadn't noticed (e.g. the "You have rescued a crewmate!" in Flip Mode) noticed this bug, which I believe was weee50. But to be fair, he does seem to be less active nowadays. On the fourth hand, I only realized the cause of the duplicate bug after stepping through it in GDB, instead of just looking at it and going "hey wait a minute" earlier. I'm surprised it didn't take me longer to realize the problem. I'm not sure what all these hands mean anymore, or where I'm getting extra hands from. Whatever. This regression is fixed now. --- desktop_version/src/Game.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 618d2102..8ad28b49 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -438,10 +438,14 @@ void Game::updatecustomlevelstats(std::string clevel, int cscore) break; } } - if(tvar>=0 && cscore > customlevelstats[tvar].score) + if(tvar>=0) { - //update existing entry - customlevelstats[tvar].score=cscore; + // We have an existing entry + // Don't update it unless it's a higher score + if (cscore > customlevelstats[tvar].score) + { + customlevelstats[tvar].score=cscore; + } } else {