[Scummvm-git-logs] scummvm master -> 933d7368b322434f21d9afc93e3c3ca599034c90
sev-
noreply at scummvm.org
Wed Sep 18 21:00:49 UTC 2024
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0ffdf9a556 QDENGINE: Refactor of ShveikShkatulka.dll minigame for unwinding goto mess
75a0c1e719 QDENGINE: Fix ShveikSkatulka minigame logic. Now it is completable
933d7368b3 QDENGINE: More cleanup to ShveikShkatulka minigame
Commit: 0ffdf9a5565d849e5b87b82e7e24535c02ac977d
https://github.com/scummvm/scummvm/commit/0ffdf9a5565d849e5b87b82e7e24535c02ac977d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-18T23:00:40+02:00
Commit Message:
QDENGINE: Refactor of ShveikShkatulka.dll minigame for unwinding goto mess
Changed paths:
engines/qdengine/minigames/shveik_shkatulka.h
diff --git a/engines/qdengine/minigames/shveik_shkatulka.h b/engines/qdengine/minigames/shveik_shkatulka.h
index c985e9e47bb..75f37435e3f 100644
--- a/engines/qdengine/minigames/shveik_shkatulka.h
+++ b/engines/qdengine/minigames/shveik_shkatulka.h
@@ -62,10 +62,10 @@ public:
_startObj = _scene->object_interface("\x24\xe7\xe0\xef\xf3\xf1\xea"); // "$запÑÑк"
_jumpSoundObj = _scene->object_interface("\xe7\xe2\xf3\xea\x20\xef\xe5\xf0\xe5\xf1\xea\xee\xea\xe0"); // "звÑк пеÑеÑкока"
- _compartment = 0;
+ _direction = kDirNone;
_cursorTakenFlag = 0;
_someVar3 = 0;
- _someFlag1 = false;
+ _needSnap = false;
if (_startObj->is_state_active("\xed\xe5\x20\xe1\xfb\xeb")) { // "не бÑл"
resetStones();
@@ -75,6 +75,14 @@ public:
return true;
}
+ enum {
+ kDirNone,
+ kDirUp,
+ kDirRight,
+ kDirDown,
+ kDirLeft
+ };
+
bool quant(float dt) {
debugC(3, kDebugMinigames, "ShveikShkatulka::quant(%f)", dt);
@@ -82,10 +90,10 @@ public:
_doneObj->set_state("\xe4\xe0"); // "да"
_cursorObj->set_state("nottaken");
_draggedStone = 0;
- _compartment = 0;
+ _direction = kDirNone;
_cursorTakenFlag = 0;
_someVar3 = 0;
- _someFlag1 = 0;
+ _needSnap = 0;
return true;
}
@@ -109,18 +117,20 @@ public:
_draggedStone = 0;
_cursorTakenFlag = 0;
_someVar3 = 0;
- _someFlag1 = 0;
- _compartment = 0;
+ _needSnap = false;
+ _direction = kDirNone;
}
char buf1[30];
mgVect2i curPos = _engine->mouse_cursor_position();
if (_cursorTakenFlag) {
- if (!_someFlag1) {
+ if (!_needSnap) {
_mouseDelta.x = curPos.x - _mousePos.x;
_mouseDelta.y = curPos.y - _mousePos.y;
+ warning("Mouse delta: %d, %d", _mouseDelta.x, _mouseDelta.y);
+
if (ABS(_mouseDelta.x) <= ABS(_mouseDelta.y)) {
const char *state = _draggedStone->current_state_name();
int draggedStonePos;
@@ -132,6 +142,8 @@ public:
else
draggedStonePos = 11;
+ warning("State is: '%s' computed: %d", state, draggedStonePos);
+
int off = 60;
if (draggedStonePos == 3 || draggedStonePos == 8) {
int delta = 0;
@@ -154,25 +166,29 @@ public:
goto LABEL_38;
if (curPos.y <= _mousePos.y)
- _compartment = 1;
+ _direction = kDirUp;
else
- _compartment = 3;
+ _direction = kDirDown;
- _someFlag1 = 1;
+ _needSnap = true;
}
if (ABS(_mouseDelta.x) > 60) {
if (curPos.x <= _mousePos.x)
- _compartment = 4;
+ _direction = kDirLeft;
else
- _compartment = 2;
+ _direction = kDirRight;
- _someFlag1 = 1;
+ _needSnap = true;
}
}
LABEL_38:
- if (_cursorTakenFlag && _someFlag1) {
+
+ if (_direction)
+ warning("Someflag: '%d' direction: %s", _needSnap, _direction == kDirUp ? "up" : _direction == kDirDown ? "down" : _direction == kDirDown ? "left" : _direction == kDirRight ? "right" : "none");
+
+ if (_cursorTakenFlag && _needSnap) {
const char *state = _draggedStone->current_state_name();
int draggedStonePos;
@@ -184,106 +200,104 @@ LABEL_38:
draggedStonePos = 11;
int side = state[0] - '0';
+ int pos = -1;
if (state[0] == '1') {
- switch (_compartment) {
- case 1:
+ switch (_direction) {
+ case kDirUp:
if (draggedStonePos != 8 || checkStonePosition(3, 1) || checkStonePosition(8, 2))
- goto LABEL_87;
- snprintf(buf1, 29, "%d%d", side, 3);
+ break;
- goto LABEL_86;
- case 2:
+ pos = 3;
+ break;
+ case kDirRight:
if (draggedStonePos == 4
|| draggedStonePos == 11
|| checkStonePosition(draggedStonePos + 1, 1)
- || checkStonePosition(draggedStonePos, 2)) {
- goto LABEL_87;
- }
- snprintf(buf1, 29, "%d%d", side, draggedStonePos + 1);
+ || checkStonePosition(draggedStonePos, 2))
+ break;
- goto LABEL_53;
- case 3:
+ pos = draggedStonePos + 1;
+ break;
+ case kDirDown:
if (draggedStonePos != 3 || checkStonePosition(8, 1) || checkStonePosition(8, 2))
- goto LABEL_87;
- snprintf(buf1, 29, "%d%d", side, 8);
+ break;
- goto LABEL_86;
- case 4:
- if (draggedStonePos == 1)
- goto LABEL_87;
- if (draggedStonePos == 5)
- goto LABEL_87;
+ pos = 8;
+ break;
+ case kDirLeft:
+ if (draggedStonePos == 1
+ || draggedStonePos == 5
+ || checkStonePosition(draggedStonePos - 1, 1)
+ || checkStonePosition(draggedStonePos - 1, 2))
+ break;
- if (checkStonePosition(draggedStonePos - 1, 1) || checkStonePosition(draggedStonePos - 1, 2))
- goto LABEL_87;
-
- snprintf(buf1, 29, "%d%d", side, draggedStonePos - 1);
-
-LABEL_53:
- _draggedStone->set_state(buf1);
- _mousePos.x = curPos.x;
- _jumpSoundObj->set_state("\xe4\xe0"); // "да"
- goto LABEL_88;
+ pos = draggedStonePos - 1;
+ break;
default:
- goto LABEL_89;
+ break;
}
- }
+ } else {
+ switch (_direction) {
+ case kDirUp:
+ if (draggedStonePos != 8 || checkStonePosition(3, 1) || checkStonePosition(3, 2))
+ break;
- switch (_compartment) {
- case 1:
- if (draggedStonePos != 8 || checkStonePosition(3, 1) || checkStonePosition(3, 2))
- goto LABEL_87;
+ pos = 3;
+ break;
- snprintf(buf1, 29, "%d%d", side, 3);
+ case kDirRight:
+ if (draggedStonePos == 4
+ || draggedStonePos == 11
+ || checkStonePosition(draggedStonePos + 1, 1)
+ || checkStonePosition(draggedStonePos + 1, 2))
+ break;
+
+ pos = draggedStonePos - 1;
+ break;
+
+ case kDirDown:
+ if (draggedStonePos != 3 || checkStonePosition(8, 2) || checkStonePosition(3, 1))
+ break;
+
+ pos = 8;
+ break;
+
+ case kDirLeft:
+ if (draggedStonePos == 1
+ || draggedStonePos == 5
+ || checkStonePosition(draggedStonePos, 1)
+ || checkStonePosition(draggedStonePos - 1, 2))
+ break;
- goto LABEL_86;
+ pos = draggedStonePos - 1;
+ break;
- case 2:
- if (draggedStonePos != 4 && draggedStonePos != 11) {
- if (!checkStonePosition(draggedStonePos + 1, 1) && !checkStonePosition(draggedStonePos + 1, 2))
- goto LABEL_72;
+ default:
+ break;
}
- goto LABEL_87;
+ }
+
+ if (pos == -1) {
+ _cursorTakenFlag = 0;
+ _someVar3 = 0;
- case 3:
- if (draggedStonePos != 3 || checkStonePosition(8, 2) || checkStonePosition(3, 1))
- goto LABEL_87;
- snprintf(buf1, 29, "%d%d", side, 8);
+ warning("State was reset");
+ } else {
+ snprintf(buf1, 29, "%d%d", side, pos);
-LABEL_86:
+ warning("New state is: '%s'", buf1);
_draggedStone->set_state(buf1);
- _mousePos.y = curPos.y;
+ _mousePos = curPos;
_jumpSoundObj->set_state("\xe4\xe0"); // "да"
- goto LABEL_88;
-
- case 4:
- if (draggedStonePos == 1
- || draggedStonePos == 5
- || checkStonePosition(draggedStonePos, 1)
- || checkStonePosition(draggedStonePos - 1, 2)) {
-LABEL_87:
- _cursorTakenFlag = 0;
- _someVar3 = 0;
- } else {
-LABEL_72:
- snprintf(buf1, 29, "%d%d", side, draggedStonePos - 1);
- _draggedStone->set_state(buf1);
- _mousePos.x = curPos.x;
- _jumpSoundObj->set_state("\xe4\xe0"); // "да"
- }
-LABEL_88:
- _compartment = 0;
- _someFlag1 = 0;
- break;
- default:
- break;
}
+
+ _direction = kDirNone;
+ _needSnap = false;
}
}
-LABEL_89:
if (_cursorTakenFlag)
_cursorObj->set_state("taken");
else
@@ -381,13 +395,13 @@ private:
const qdEngineInterface *_engine = nullptr;
qdMinigameSceneInterface *_scene = nullptr;
- int _compartment = 0;
+ int _direction = kDirNone;
bool _cursorTakenFlag = false;
mgVect2i _mousePos;
mgVect2i _mouseDelta;
int _someVar3 = 0;
- bool _someFlag1 = false;
+ bool _needSnap = false;
qdMinigameObjectInterface *_stones[14];
qdMinigameObjectInterface *_draggedStone = nullptr;
Commit: 75a0c1e719f3038139afecbc4c4f2d557bbd65ab
https://github.com/scummvm/scummvm/commit/75a0c1e719f3038139afecbc4c4f2d557bbd65ab
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-18T23:00:40+02:00
Commit Message:
QDENGINE: Fix ShveikSkatulka minigame logic. Now it is completable
Changed paths:
engines/qdengine/minigames/shveik_shkatulka.h
diff --git a/engines/qdengine/minigames/shveik_shkatulka.h b/engines/qdengine/minigames/shveik_shkatulka.h
index 75f37435e3f..c5d3331081e 100644
--- a/engines/qdengine/minigames/shveik_shkatulka.h
+++ b/engines/qdengine/minigames/shveik_shkatulka.h
@@ -129,8 +129,6 @@ public:
_mouseDelta.x = curPos.x - _mousePos.x;
_mouseDelta.y = curPos.y - _mousePos.y;
- warning("Mouse delta: %d, %d", _mouseDelta.x, _mouseDelta.y);
-
if (ABS(_mouseDelta.x) <= ABS(_mouseDelta.y)) {
const char *state = _draggedStone->current_state_name();
int draggedStonePos;
@@ -142,8 +140,6 @@ public:
else
draggedStonePos = 11;
- warning("State is: '%s' computed: %d", state, draggedStonePos);
-
int off = 60;
if (draggedStonePos == 3 || draggedStonePos == 8) {
int delta = 0;
@@ -185,9 +181,6 @@ public:
LABEL_38:
- if (_direction)
- warning("Someflag: '%d' direction: %s", _needSnap, _direction == kDirUp ? "up" : _direction == kDirDown ? "down" : _direction == kDirDown ? "left" : _direction == kDirRight ? "right" : "none");
-
if (_cursorTakenFlag && _needSnap) {
const char *state = _draggedStone->current_state_name();
int draggedStonePos;
@@ -202,7 +195,7 @@ LABEL_38:
int side = state[0] - '0';
int pos = -1;
- if (state[0] == '1') {
+ if (side == 1) {
switch (_direction) {
case kDirUp:
if (draggedStonePos != 8 || checkStonePosition(3, 1) || checkStonePosition(8, 2))
@@ -254,7 +247,7 @@ LABEL_38:
|| checkStonePosition(draggedStonePos + 1, 2))
break;
- pos = draggedStonePos - 1;
+ pos = draggedStonePos + 1;
break;
case kDirDown:
@@ -282,12 +275,8 @@ LABEL_38:
if (pos == -1) {
_cursorTakenFlag = 0;
_someVar3 = 0;
-
- warning("State was reset");
} else {
snprintf(buf1, 29, "%d%d", side, pos);
-
- warning("New state is: '%s'", buf1);
_draggedStone->set_state(buf1);
_mousePos = curPos;
_jumpSoundObj->set_state("\xe4\xe0"); // "да"
@@ -373,7 +362,7 @@ private:
bool checkStonePosition(int targetPos, int leftStones) {
int n = leftStones == 1 ? 0 : 7;
- for (int i = 0; i < 8; i++) {
+ for (int i = 0; i < 7; i++) {
const char *state = _stones[n + i]->current_state_name();
int pos;
Commit: 933d7368b322434f21d9afc93e3c3ca599034c90
https://github.com/scummvm/scummvm/commit/933d7368b322434f21d9afc93e3c3ca599034c90
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-18T23:00:40+02:00
Commit Message:
QDENGINE: More cleanup to ShveikShkatulka minigame
Changed paths:
engines/qdengine/minigames/shveik_shkatulka.h
diff --git a/engines/qdengine/minigames/shveik_shkatulka.h b/engines/qdengine/minigames/shveik_shkatulka.h
index c5d3331081e..5567ddb7253 100644
--- a/engines/qdengine/minigames/shveik_shkatulka.h
+++ b/engines/qdengine/minigames/shveik_shkatulka.h
@@ -121,7 +121,6 @@ public:
_direction = kDirNone;
}
- char buf1[30];
mgVect2i curPos = _engine->mouse_cursor_position();
if (_cursorTakenFlag) {
@@ -129,7 +128,7 @@ public:
_mouseDelta.x = curPos.x - _mousePos.x;
_mouseDelta.y = curPos.y - _mousePos.y;
- if (ABS(_mouseDelta.x) <= ABS(_mouseDelta.y)) {
+ if (ABS(_mouseDelta.x) <= ABS(_mouseDelta.y)) { // Going down
const char *state = _draggedStone->current_state_name();
int draggedStonePos;
@@ -158,18 +157,15 @@ public:
off = delta + 150;
}
- if (ABS(_mouseDelta.y) <= off)
- goto LABEL_38;
+ if (ABS(_mouseDelta.y) > off) {
+ if (curPos.y <= _mousePos.y)
+ _direction = kDirUp;
+ else
+ _direction = kDirDown;
- if (curPos.y <= _mousePos.y)
- _direction = kDirUp;
- else
- _direction = kDirDown;
-
- _needSnap = true;
- }
-
- if (ABS(_mouseDelta.x) > 60) {
+ _needSnap = true;
+ }
+ } else if (ABS(_mouseDelta.x) > 60) {
if (curPos.x <= _mousePos.x)
_direction = kDirLeft;
else
@@ -179,8 +175,6 @@ public:
}
}
-LABEL_38:
-
if (_cursorTakenFlag && _needSnap) {
const char *state = _draggedStone->current_state_name();
int draggedStonePos;
@@ -276,8 +270,7 @@ LABEL_38:
_cursorTakenFlag = 0;
_someVar3 = 0;
} else {
- snprintf(buf1, 29, "%d%d", side, pos);
- _draggedStone->set_state(buf1);
+ _draggedStone->set_state(Common::String::format("%d%d", side, pos).c_str());
_mousePos = curPos;
_jumpSoundObj->set_state("\xe4\xe0"); // "да"
}
More information about the Scummvm-git-logs
mailing list