aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/star_control
diff options
context:
space:
mode:
authorDavid Fioramonti2017-08-18 20:18:27 -0700
committerDavid Fioramonti2017-08-18 20:28:16 -0700
commit82d0053f8bd472ec598645550825257ddd78d683 (patch)
tree01a08f13a73f6a7593135a40af86004f8756dedb /engines/titanic/star_control
parentb200317306370e25fb9cb0b3fbefbb5c7b538773 (diff)
downloadscummvm-rg350-82d0053f8bd472ec598645550825257ddd78d683.tar.gz
scummvm-rg350-82d0053f8bd472ec598645550825257ddd78d683.tar.bz2
scummvm-rg350-82d0053f8bd472ec598645550825257ddd78d683.zip
TITANIC: Add logic to prevent removing locked/marked stars via skymap
If you want to remove locked stars you can do so using the D key, but previously, you could also deselect a currently locked star via the skymap and it would crash. It previously crashed if: 1. You had 2 stars locked on and you tried to remove the 1st 2. Had 1 locked and 1 unlocked and you tried to unlock the 1st 3. Had 2 locked and 1 unlocked and you tried to unlock any of the other two locked stars. Refactoring would allow quicker comprehension of the logic of this section of code. Fixes #10126.
Diffstat (limited to 'engines/titanic/star_control')
-rw-r--r--engines/titanic/star_control/star_crosshairs.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/engines/titanic/star_control/star_crosshairs.cpp b/engines/titanic/star_control/star_crosshairs.cpp
index 7227a18d03..61d11bf950 100644
--- a/engines/titanic/star_control/star_crosshairs.cpp
+++ b/engines/titanic/star_control/star_crosshairs.cpp
@@ -39,9 +39,15 @@ void CStarCrosshairs::selectStar(int index, CVideoSurface *surface,
// All the stars selected so far have been matched. Only allow
// a selection addition if not all three stars have been found
if (!isSolved()) {
- // Don't allow the most recent match to be re-selected
+ // Don't allow the most recent match or the one before
+ // it to be re-selected (while they are locked/matched)
if (_positions[index] != _entries[_entryIndex]) {
- surface->lock();
+ if (_entryIndex == 1) {//2 stars are matched
+ if (_positions[index] == _entries[_entryIndex-1]) {
+ return;
+ }
+ }
+ surface->lock();
// Draw crosshairs around the selected star
CSurfaceArea surfaceArea(surface);
@@ -63,6 +69,7 @@ void CStarCrosshairs::selectStar(int index, CVideoSurface *surface,
// So we allow the user to reselect it to remove the selection, or shift
// the selection to some other star
if (_positions[index] == _entries[_entryIndex]) {
+ // Player has selected the most recent star
// Remove the crosshairs for the previously selected star
surface->lock();
CSurfaceArea surfaceArea(surface);
@@ -76,6 +83,16 @@ void CStarCrosshairs::selectStar(int index, CVideoSurface *surface,
const CBaseStarEntry *starP = starField->getDataPtr(_positions[index]._index1);
markers->addStar(starP);
} else {
+ // Player has selected some other star other than the most recent
+ // Remove/Add it if it is not one of the other star(s) already matched
+
+ // Check that it is not a previously star and don't remove it if it is
+ for (int i=0;i<_entryIndex;i++) {
+ if (_positions[index] == _entries[i]) {
+ return;
+ }
+ }
+
// Erase the prior selection and draw the new one
surface->lock();
CSurfaceArea surfaceArea(surface);