D27716: Fix accidental revealing of items when the game is restarted after lost from a middle click.
Yichao Yu
noreply at phabricator.kde.org
Fri Feb 28 02:56:20 GMT 2020
yuyichao created this revision.
yuyichao added reviewers: mlaurent, yurchor.
Herald added a reviewer: KDE Games.
Herald added a subscriber: kde-games-devel.
yuyichao requested review of this revision.
REVISION SUMMARY
When a flag is misplaced, a middle click could cause the game to lost.
Currently, if the user choose to restart the game in this case, there is a high chance
that a few pieces around the one middle clicked are revealed right after the game restarted.
The reason is that when the user restart the game in such case,
it happens within `checkLost`/`onItemRevealed` which means that the
game might not be the same one anymore after `onItemRevealed` returns
and the loop handling all neighboring pieces are now operating on the now restarted game.
The fix is to make sure the loop stops when the game is finished. Checking `m_gameOver` is
unreliable and won't work in this case since the restart of the game would have restarted it.
Instead, the finished status is returned from all functions that triggers such a condition
and the information is propagated back to the caller to terminate the loop appropriately.
This also improved another unreliable use of `m_gameOver` that is currently harmless.
Debugging was possible thanks to `rr`.
REPOSITORY
R404 KMines
BRANCH
master
REVISION DETAIL
https://phabricator.kde.org/D27716
AFFECTED FILES
minefielditem.cpp
minefielditem.h
To: yuyichao, mlaurent, yurchor, #kde_games
Cc: kde-games-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-games-devel/attachments/20200228/b05377c0/attachment.html>
More information about the kde-games-devel
mailing list