diff options
author | Strangerke | 2013-12-10 08:20:28 +0100 |
---|---|---|
committer | Strangerke | 2013-12-10 08:20:28 +0100 |
commit | 28a09a43dce56f5cd1fba3bdef1dfa142459e6ab (patch) | |
tree | 9fbb3957a8a99b22e051aa203f1723f4fa227801 /engines/tsage/ringworld2 | |
parent | 66ff931fb9f15dbea4e0d4eb3490d333f756642b (diff) | |
download | scummvm-rg350-28a09a43dce56f5cd1fba3bdef1dfa142459e6ab.tar.gz scummvm-rg350-28a09a43dce56f5cd1fba3bdef1dfa142459e6ab.tar.bz2 scummvm-rg350-28a09a43dce56f5cd1fba3bdef1dfa142459e6ab.zip |
TSAGE: R2R - Renaming and reordering in scene 1337
Diffstat (limited to 'engines/tsage/ringworld2')
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_scenes1.cpp | 838 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_scenes1.h | 18 |
2 files changed, 428 insertions, 428 deletions
diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.cpp b/engines/tsage/ringworld2/ringworld2_scenes1.cpp index f1b907e254..68eab82ab9 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes1.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes1.cpp @@ -2257,7 +2257,7 @@ Scene1337::Scene1337() { _actionIdx2 = 0; _showPlayerTurn = false; _field4246 = false; - _field424A = 0; + _winnerId = 0; _instructionsDisplayedFl = false; _instructionsWaitCount = 0; @@ -3373,7 +3373,7 @@ void Scene1337::Action3::signal() { scene->_currentPlayerNumb = 0; R2_GLOBALS._sceneObjects->draw(); scene->actionDisplay(1330, 0, 159, 10, 1, 200, 0, 7, 0, 154, 154); - scene->subC20F9(); + scene->handleNextTurn(); } else if (_actionIndex >= 1) { scene->_availableCardsPile[scene->_cardsAvailableNumb] = 0; scene->_cardsAvailableNumb--; @@ -3532,16 +3532,16 @@ void Scene1337::Action4::signal() { scene->_animatedCard._card.hide(); switch (scene->_currentPlayerNumb) { case 0: - scene->subCF979(); + scene->handlePlayer0(); break; case 1: - scene->subCF31D(); + scene->handlePlayer1(); break; case 2: scene->subD0281(); break; case 3: - scene->subC2C2F(); + scene->handlePlayer3(); break; default: break; @@ -3590,7 +3590,7 @@ void Scene1337::Action5::signal() { scene->_animatedCard._card.hide(); scene->setAnimationInfo(&scene->_discardPile); scene->_aSound2.play(61); - scene->subC20F9(); + scene->handleNextTurn(); break; default: break; @@ -3630,7 +3630,7 @@ void Scene1337::Action6::signal() { scene->setCursorData(5, 1, 4); scene->subC4CEC(); } - scene->subC20F9(); + scene->handleNextTurn(); break; default: break; @@ -3739,7 +3739,7 @@ void Scene1337::Action9::signal() { scene->subC4CEC(); } - scene->subC20F9(); + scene->handleNextTurn(); break; default: break; @@ -4539,24 +4539,24 @@ void Scene1337::actionDisplay(int resNum, int lineNum, int x, int y, int keepOnS SET_EXT_FGCOLOR, colFGExt, LIST_END); } -void Scene1337::setAnimationInfo(Card *subObj) { - if (!subObj) +void Scene1337::setAnimationInfo(Card *card) { + if (!card) return; - if (subObj->_cardId > 9) { - if (subObj->_cardId > 25) { - subObj->_card.setStrip2(4); - subObj->_card.setFrame(subObj->_cardId - 25); + if (card->_cardId > 9) { + if (card->_cardId > 25) { + card->_card.setStrip2(4); + card->_card.setFrame(card->_cardId - 25); } else { - subObj->_card.setStrip2(3); - subObj->_card.setFrame(subObj->_cardId - 9); + card->_card.setStrip2(3); + card->_card.setFrame(card->_cardId - 9); } } else { - subObj->_card.setStrip2(2); - subObj->_card.setFrame(subObj->_cardId); + card->_card.setStrip2(2); + card->_card.setFrame(card->_cardId); } - subObj->_card.show(); + card->_card.show(); R2_GLOBALS._sceneObjects->draw(); } @@ -4564,8 +4564,8 @@ void Scene1337::subC20E5() { subC2586(); } -void Scene1337::subC20F9() { - switch (_field424A) { +void Scene1337::handleNextTurn() { + switch (_winnerId) { case -1: ++_currentPlayerNumb; if (_currentPlayerNumb > 3) @@ -4636,7 +4636,7 @@ void Scene1337::subC20F9() { break; } - if (_field424A != -1) + if (_winnerId != -1) R2_GLOBALS._sceneManager.changeScene(125); } @@ -4712,18 +4712,18 @@ int Scene1337::subC26CB(int arg1, int arg2) { return -1; } -int Scene1337::subC2719(int arg1) { +int Scene1337::findNormalCardInHand(int playerId) { for (int i = 0; i <= 3; i++) { - if (_gameBoardSide[arg1]._handCard[i]._cardId == 1) + if (_gameBoardSide[playerId]._handCard[i]._cardId == 1) return i; } return -1; } -int Scene1337::subC274D(int arg1) { +int Scene1337::subC274D(int playerId) { for (int i = 0; i <= 3; i++) { - if (_gameBoardSide[arg1]._handCard[i]._cardId == 13) + if (_gameBoardSide[playerId]._handCard[i]._cardId == 13) return i; } @@ -4927,188 +4927,6 @@ void Scene1337::subC2835(int arg1) { discardCard(&_gameBoardSide[arg1]._handCard[i]); } -void Scene1337::subC2C2F() { - bool found = true; - - if (_gameBoardSide[3]._delayCard._cardId != 0) { - switch (_gameBoardSide[3]._delayCard._cardId) { - case 10: - // No break on purpose - case 12: - // No break on purpose - case 15: - // No break on purpose - case 17: - // No break on purpose - case 18: - // No break on purpose - case 19: - // No break on purpose - case 20: - // No break on purpose - case 21: - discardCard(&_gameBoardSide[3]._delayCard); - found = false; - break; - default: - found = false; - int i; - for (i = 0; i <= 3; i++) { - if (subC3386(_gameBoardSide[3]._delayCard._cardId, _gameBoardSide[3]._handCard[i]._cardId)) { - found = true; - break; - } - } - - if (found) { - found = false; - subC34A1(&_gameBoardSide[3]._handCard[i], &_gameBoardSide[3]._delayCard); - } - break; - } - } - - if (!found) - return; - - int randIndx = R2_GLOBALS._randomSource.getRandomNumber(3); - - if (_gameBoardSide[3]._handCard[randIndx]._cardId == 1) { - found = false; - - for (int i = 0; i <= 7; i++) { - if ((_gameBoardSide[3]._outpostStation[i]._cardId == 0) && (!subC2687(_gameBoardSide[3]._delayCard._cardId))) { - subC340B(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[3]._outpostStation[i]); - found = true; - break; - } - } - - if (found) { - return; - } - } else if (_gameBoardSide[3]._handCard[randIndx]._cardId <= 9) { - found = false; - - for (int i = 0; i <= 7; i++) { - if (_gameBoardSide[3]._outpostStation[i]._cardId == _gameBoardSide[3]._handCard[randIndx]._cardId) { - found = true; - break; - } - } - - if (!found) { - for (int i = 0; i <= 7; i++) { - if ((_gameBoardSide[3]._outpostStation[i]._cardId == 1) && (!subC2687(_gameBoardSide[3]._delayCard._cardId))) { - int tmpVal = 0; - - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[3]._outpostStation[j]._cardId > 1) && (_gameBoardSide[3]._outpostStation[j]._cardId <= 9)) - ++tmpVal; - } - - if (tmpVal == 7) - _field424A = 3; - - subC33C0(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[3]._outpostStation[i]); - found = true; - break; - } - } - if (found) - return; - } - } else if (_gameBoardSide[3]._handCard[randIndx]._cardId == 13) { - int tmpVal = subC331B(3); - - if (tmpVal != -1) { - subC358E(&_gameBoardSide[3]._handCard[randIndx], tmpVal); - return; - } - } else if (_gameBoardSide[3]._handCard[randIndx]._cardId == 25) { - int tmpVal = -1; - found = false; - int tmpRandIndx = R2_GLOBALS._randomSource.getRandomNumber(3); - - for (int i = 0; i <= 3; i++) { - if ( (tmpRandIndx != 3) - && ( (_gameBoardSide[tmpRandIndx]._handCard[0]._cardId != 0) - || (_gameBoardSide[tmpRandIndx]._handCard[1]._cardId != 0) - || (_gameBoardSide[tmpRandIndx]._handCard[2]._cardId != 0) - || (_gameBoardSide[tmpRandIndx]._handCard[3]._cardId != 0) )) { - tmpVal = tmpRandIndx; - break; - } - - ++tmpRandIndx; - if (tmpRandIndx > 3) - tmpRandIndx = 0; - } - - if (tmpVal != -1) { - subC318B(3, &_gameBoardSide[3]._handCard[randIndx], tmpVal); - return; - } - } else { - switch (_gameBoardSide[3]._handCard[randIndx]._cardId) { - case 10: - // No break on purpose - case 11: - // No break on purpose - case 12: - // No break on purpose - case 14: - // No break on purpose - case 15: - // No break on purpose - case 16: - // No break on purpose - case 17: - // No break on purpose - case 18: - // No break on purpose - case 19: - // No break on purpose - case 20: - // No break on purpose - case 21: - // No break on purpose - case 24: { - int tmpVal = -1; - int tmpRandIndx = R2_GLOBALS._randomSource.getRandomNumber(3); - - for (int i = 0; i <= 3; i++) { - if (tmpRandIndx != 3) { - // The variable 'j' is not used in the inner code of the loop, which is suspicious. - // 'i' is used indirectly to increment tmpRandIndx. - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[tmpRandIndx]._delayCard._cardId == 0) && subC32B1(tmpRandIndx, _gameBoardSide[3]._handCard[randIndx]._cardId)) - tmpVal = tmpRandIndx; - } - } - - ++tmpRandIndx; - if (tmpRandIndx > 3) - tmpRandIndx = 0; - - if (tmpVal != -1) - break; - } - - if (tmpVal != -1) { - // Useless second identical check skipped - subC3456(&_gameBoardSide[tmpVal]._handCard[randIndx], &_gameBoardSide[tmpVal]._delayCard); - return; - } - } - default: - break; - } - } - - discardCard(&_gameBoardSide[3]._handCard[randIndx]); -} - void Scene1337::subC318B(int arg1, Card *subObj1, int arg3) { _actionIdx1 = arg1; _actionIdx2 = arg3; @@ -5237,16 +5055,16 @@ int Scene1337::subC3E92(int playerId) { return randIndx; } -void Scene1337::subC340B(Card *subObj1, Card *subObj2) { - _actionCard1 = subObj1; - _actionCard2 = subObj2; +void Scene1337::playCard(Card *card, Card *dest) { + _actionCard1 = card; + _actionCard2 = dest; _item1.setAction(&_action6); } -void Scene1337::subC3456(Card *subObj1, Card *subObj2) { - _actionCard1 = subObj1; - _actionCard2 = subObj2; +void Scene1337::playDelayCard(Card *card, Card *dest) { + _actionCard1 = card; + _actionCard2 = dest; _item1.setAction(&_action9); } @@ -5553,7 +5371,7 @@ void Scene1337::subPostInit() { _showPlayerTurn = true; _field4246 = false; - _field424A = -1; + _winnerId = -1; _helpIcon.postInit(); _helpIcon.setup(9531, 1, 1); @@ -5949,7 +5767,260 @@ void Scene1337::handleClick(int arg1, Common::Point pt) { } } -void Scene1337::subCF31D() { +void Scene1337::handlePlayer0() { + bool found = true; + + if (_gameBoardSide[0]._delayCard._cardId != 0) { + switch (_gameBoardSide[0]._delayCard._cardId) { + case 10: + //No break on purpose + case 12: + //No break on purpose + case 15: + //No break on purpose + case 17: + //No break on purpose + case 18: + //No break on purpose + case 19: + //No break on purpose + case 20: + //No break on purpose + case 21: + discardCard(&_gameBoardSide[0]._delayCard); + found = false; + break; + default: + int i; + found = false; + + for (i = 0; i <= 3; i++) { + if (subC3386(_gameBoardSide[0]._delayCard._cardId, _gameBoardSide[0]._handCard[i]._cardId)) { + found = true; + break; + } + } + + if (found) { + found = false; + subC34A1(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[0]._delayCard); + } + break; + } + } + + if (found) + return; + + int tmpVal; + found = false; + for (int i = 0; i <= 3; i++) { + tmpVal = subC26CB(0, i); + + if (tmpVal != -1) { + bool flag = false; + for (int j = 0; j <= 7; j++) { + if (_gameBoardSide[0]._outpostStation[j]._cardId == _gameBoardSide[0]._handCard[tmpVal]._cardId) { + flag = true; + break; + } + } + + if (!flag) { + for (int j = 0; j <= 7; j++) { + if ((_gameBoardSide[0]._outpostStation[j]._cardId == 1) && (!subC2687(_gameBoardSide[0]._delayCard._cardId))) { + int count = 0; + for (int k = 0; k <= 7; k++) { + if ((_gameBoardSide[0]._outpostStation[k]._cardId > 1) && (_gameBoardSide[0]._outpostStation[k]._cardId <= 9)) { + ++count; + } + } + + if (count == 7) + _winnerId = 0; + + subC33C0(&_gameBoardSide[0]._handCard[tmpVal], &_gameBoardSide[0]._outpostStation[j]); + found = true; + } + } + } + } + + if (found) + break; + } + + if (found) + return; + + found = false; + tmpVal = findNormalCardInHand(0); + + if (tmpVal != -1) { + for (int i = 0; i <= 7; i++) { + if ((_gameBoardSide[0]._outpostStation[i]._cardId == 0) && (!subC2687(_gameBoardSide[0]._delayCard._cardId))) { + playCard(&_gameBoardSide[0]._handCard[tmpVal], &_gameBoardSide[0]._outpostStation[i]); + found = true; + break; + } + } + } + + if (found) + return; + + tmpVal = subC274D(0); + if (tmpVal != -1) { + for (int i = 0; i <= 7; i++) { + if (_gameBoardSide[2]._outpostStation[i]._cardId != 0) { + subC358E(&_gameBoardSide[0]._handCard[tmpVal], 2); + found = true; + break; + } + } + } + + if (found) + return; + + tmpVal = subC2781(0); + if (tmpVal != -1) { + if ( (_gameBoardSide[2]._handCard[0]._cardId != 0) + || (_gameBoardSide[2]._handCard[1]._cardId != 0) + || (_gameBoardSide[2]._handCard[2]._cardId != 0) + || (_gameBoardSide[2]._handCard[3]._cardId != 0) ) { + subC318B(0, &_gameBoardSide[0]._handCard[tmpVal], 2); + found = true; + } + } + + if (found) + return; + + for (int i = 0; i <= 3; i++) { + if (subC27B5(_gameBoardSide[0]._handCard[i]._cardId) != -1) { + // The variable 'j' is not used in the inner code of the loop. It's suspect + for (int j = 0; j <= 7; j++) { + if ((_gameBoardSide[2]._delayCard._cardId == 0) && (subC32B1(2, _gameBoardSide[0]._handCard[i]._cardId))) { + playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[2]._delayCard); + found = true; + break; + } + } + + if (found) + break; + } + } + + if (found) + return; + + for (int i = 0; i <= 3; i++) { + if (subC27F9(_gameBoardSide[0]._handCard[i]._cardId) != -1) { + // The variable 'j' is not used in the inner code of the loop. It's suspect + for (int j = 0; j <= 7; j++) { + if ((_gameBoardSide[2]._delayCard._cardId == 0) && (subC32B1(2, _gameBoardSide[0]._handCard[i]._cardId))) { + playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[2]._delayCard); + found = true; + } + } + + if (found) + break; + } + } + + if (found) + return; + + tmpVal = subC274D(0); + int tmpVal2 = subC331B(0); + + if ((tmpVal != -1) && (tmpVal2 != -1)) { + subC358E(&_gameBoardSide[0]._handCard[tmpVal], tmpVal2); + found = true; + } + + if (found) + return; + + tmpVal = subC2781(0); + if (tmpVal != -1) { + if ( (_gameBoardSide[1]._handCard[0]._cardId != 0) + || (_gameBoardSide[1]._handCard[1]._cardId != 0) + || (_gameBoardSide[1]._handCard[2]._cardId != 0) + || (_gameBoardSide[1]._handCard[3]._cardId != 0) ) { + subC318B(0, &_gameBoardSide[0]._handCard[tmpVal], 1); + found = true; + } + } + + if (found) + return; + + for (int i = 0; i <= 3; i++) { + tmpVal = subC27F9(_gameBoardSide[0]._handCard[i]._cardId); + if (tmpVal != -1) { + // The variable 'j' is not used in the inner code of the loop. It's suspect. + for (int j = 0; j <= 7; j++) { + if ((_gameBoardSide[1]._delayCard._cardId == 0) && (subC32B1(1, _gameBoardSide[0]._handCard[i]._cardId))) { + playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[1]._delayCard); + found = true; + } + } + + if (!found) { + // The variable 'j' is not used in the inner code of the loop. It's suspect. + for (int j = 0; j <= 7; j++) { + if ((_gameBoardSide[3]._delayCard._cardId == 0) && (subC32B1(3, _gameBoardSide[0]._handCard[i]._cardId))) { + playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[3]._delayCard); + found = true; + } + } + } + + if (found) + break; + } + } + + if (found) + return; + + for (int i = 0; i <= 3; i++) { + tmpVal = subC27B5(_gameBoardSide[0]._handCard[i]._cardId); + if (tmpVal != -1) { + // The variable 'j' is not used in the inner code of the loop. It's suspect. + for (int j = 0; j <= 7; j++) { + if ((_gameBoardSide[1]._delayCard._cardId == 0) && (subC32B1(1, _gameBoardSide[0]._handCard[i]._cardId))) { + playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[1]._delayCard); + found = true; + } + } + + if (!found) { + // The variable 'j' is not used in the inner code of the loop. It's suspect. + for (int j = 0; j <= 7; j++) { + if ((_gameBoardSide[3]._delayCard._cardId == 0) && (subC32B1(3, _gameBoardSide[0]._handCard[i]._cardId))) { + playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[3]._delayCard); + found = true; + } + } + } + + if (found) + break; + } + } + + if (found) + return; + + subC2835(0); +} + +void Scene1337::handlePlayer1() { int tmpVal = 1; bool found; int count; @@ -5957,19 +6028,19 @@ void Scene1337::subCF31D() { if (this->_gameBoardSide[1]._delayCard._cardId != 0) { switch (_gameBoardSide[1]._delayCard._cardId) { case 10: - // No break on purpose + // No break on purpose case 12: - // No break on purpose + // No break on purpose case 15: - // No break on purpose + // No break on purpose case 17: - // No break on purpose + // No break on purpose case 18: - // No break on purpose + // No break on purpose case 19: - // No break on purpose + // No break on purpose case 20: - // No break on purpose + // No break on purpose case 21: tmpVal = 0; discardCard(&_gameBoardSide[1]._delayCard); @@ -6021,7 +6092,7 @@ void Scene1337::subCF31D() { } if (count == 7) - _field424A = 1; + _winnerId = 1; subC33C0(&_gameBoardSide[1]._handCard[tmpIndx], &_gameBoardSide[1]._outpostStation[j]); found = true; @@ -6034,11 +6105,11 @@ void Scene1337::subCF31D() { if (found) return; - tmpVal = subC2719(1); + tmpVal = findNormalCardInHand(1); if (tmpVal != -1) { for (int i = 0; i <= 7; i++) { if ((_gameBoardSide[1]._outpostStation[i]._cardId == 0) && (!subC2687(_gameBoardSide[1]._delayCard._cardId))) { - subC340B(&_gameBoardSide[1]._handCard[tmpVal], &_gameBoardSide[1]._outpostStation[i]); + playCard(&_gameBoardSide[1]._handCard[tmpVal], &_gameBoardSide[1]._outpostStation[i]); found = true; break; } @@ -6066,11 +6137,11 @@ void Scene1337::subCF31D() { for (int i = 0; i <= 3; i++) { if (rndVal != 1) { if ( (_gameBoardSide[rndVal]._handCard[0]._cardId != 0) - || (_gameBoardSide[rndVal]._handCard[1]._cardId != 0) - || (_gameBoardSide[rndVal]._handCard[2]._cardId != 0) - || (_gameBoardSide[rndVal]._handCard[3]._cardId == 0)) { - count = rndVal; - break; + || (_gameBoardSide[rndVal]._handCard[1]._cardId != 0) + || (_gameBoardSide[rndVal]._handCard[2]._cardId != 0) + || (_gameBoardSide[rndVal]._handCard[3]._cardId == 0)) { + count = rndVal; + break; } // CHECKME: inside the check on rndVal? rndVal--; @@ -6124,7 +6195,7 @@ void Scene1337::subCF31D() { } if (found) - subC3456(&_gameBoardSide[1]._handCard[i], &_gameBoardSide[count]._delayCard); + playDelayCard(&_gameBoardSide[1]._handCard[i], &_gameBoardSide[count]._delayCard); else { int j; for (j = 0; j <= 3; j++) { @@ -6156,42 +6227,41 @@ void Scene1337::subCF31D() { } if (found) - subC3456(&_gameBoardSide[1]._handCard[j], &_gameBoardSide[count]._delayCard); + playDelayCard(&_gameBoardSide[1]._handCard[j], &_gameBoardSide[count]._delayCard); else subC2835(1); } } -void Scene1337::subCF979() { +void Scene1337::handlePlayer3() { bool found = true; - if (_gameBoardSide[0]._delayCard._cardId != 0) { - switch (_gameBoardSide[0]._delayCard._cardId) { + if (_gameBoardSide[3]._delayCard._cardId != 0) { + switch (_gameBoardSide[3]._delayCard._cardId) { case 10: - //No break on purpose + // No break on purpose case 12: - //No break on purpose + // No break on purpose case 15: - //No break on purpose + // No break on purpose case 17: - //No break on purpose + // No break on purpose case 18: - //No break on purpose + // No break on purpose case 19: - //No break on purpose + // No break on purpose case 20: - //No break on purpose + // No break on purpose case 21: - discardCard(&_gameBoardSide[0]._delayCard); + discardCard(&_gameBoardSide[3]._delayCard); found = false; break; default: - int i; found = false; - + int i; for (i = 0; i <= 3; i++) { - if (subC3386(_gameBoardSide[0]._delayCard._cardId, _gameBoardSide[0]._handCard[i]._cardId)) { + if (subC3386(_gameBoardSide[3]._delayCard._cardId, _gameBoardSide[3]._handCard[i]._cardId)) { found = true; break; } @@ -6199,221 +6269,151 @@ void Scene1337::subCF979() { if (found) { found = false; - subC34A1(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[0]._delayCard); + subC34A1(&_gameBoardSide[3]._handCard[i], &_gameBoardSide[3]._delayCard); } break; } } - if (found) + if (!found) return; - int tmpVal; - found = false; - for (int i = 0; i <= 3; i++) { - tmpVal = subC26CB(0, i); - - if (tmpVal != -1) { - bool flag = false; - for (int j = 0; j <= 7; j++) { - if (_gameBoardSide[0]._outpostStation[j]._cardId == _gameBoardSide[0]._handCard[tmpVal]._cardId) { - flag = true; - break; - } - } - - if (!flag) { - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[0]._outpostStation[j]._cardId == 1) && (!subC2687(_gameBoardSide[0]._delayCard._cardId))) { - int count = 0; - for (int k = 0; k <= 7; k++) { - if ((_gameBoardSide[0]._outpostStation[k]._cardId > 1) && (_gameBoardSide[0]._outpostStation[k]._cardId <= 9)) { - ++count; - } - } - - if (count == 7) - _field424A = 0; - - subC33C0(&_gameBoardSide[0]._handCard[tmpVal], &_gameBoardSide[0]._outpostStation[j]); - found = true; - } - } - } - } - - if (found) - break; - } - - if (found) - return; + int randIndx = R2_GLOBALS._randomSource.getRandomNumber(3); - found = false; - tmpVal = subC2719(0); + if (_gameBoardSide[3]._handCard[randIndx]._cardId == 1) { + found = false; - if (tmpVal != -1) { for (int i = 0; i <= 7; i++) { - if ((_gameBoardSide[0]._outpostStation[i]._cardId == 0) && (!subC2687(_gameBoardSide[0]._delayCard._cardId))) { - subC340B(&_gameBoardSide[0]._handCard[tmpVal], &_gameBoardSide[0]._outpostStation[i]); + if ((_gameBoardSide[3]._outpostStation[i]._cardId == 0) && (!subC2687(_gameBoardSide[3]._delayCard._cardId))) { + playCard(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[3]._outpostStation[i]); found = true; break; } } - } - if (found) - return; + if (found) { + return; + } + } else if (_gameBoardSide[3]._handCard[randIndx]._cardId <= 9) { + found = false; - tmpVal = subC274D(0); - if (tmpVal != -1) { for (int i = 0; i <= 7; i++) { - if (_gameBoardSide[2]._outpostStation[i]._cardId != 0) { - subC358E(&_gameBoardSide[0]._handCard[tmpVal], 2); + if (_gameBoardSide[3]._outpostStation[i]._cardId == _gameBoardSide[3]._handCard[randIndx]._cardId) { found = true; break; } } - } - if (found) - return; + if (!found) { + for (int i = 0; i <= 7; i++) { + if ((_gameBoardSide[3]._outpostStation[i]._cardId == 1) && (!subC2687(_gameBoardSide[3]._delayCard._cardId))) { + int tmpVal = 0; - tmpVal = subC2781(0); - if (tmpVal != -1) { - if ( (_gameBoardSide[2]._handCard[0]._cardId != 0) - || (_gameBoardSide[2]._handCard[1]._cardId != 0) - || (_gameBoardSide[2]._handCard[2]._cardId != 0) - || (_gameBoardSide[2]._handCard[3]._cardId != 0) ) { - subC318B(0, &_gameBoardSide[0]._handCard[tmpVal], 2); - found = true; - } - } + for (int j = 0; j <= 7; j++) { + if ((_gameBoardSide[3]._outpostStation[j]._cardId > 1) && (_gameBoardSide[3]._outpostStation[j]._cardId <= 9)) + ++tmpVal; + } - if (found) - return; + if (tmpVal == 7) + _winnerId = 3; - for (int i = 0; i <= 3; i++) { - if (subC27B5(_gameBoardSide[0]._handCard[i]._cardId) != -1) { - // The variable 'j' is not used in the inner code of the loop. It's suspect - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[2]._delayCard._cardId == 0) && (subC32B1(2, _gameBoardSide[0]._handCard[i]._cardId))) { - subC3456(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[2]._delayCard); + subC33C0(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[3]._outpostStation[i]); found = true; break; } } - if (found) - break; + return; } - } - - if (found) - return; - - for (int i = 0; i <= 3; i++) { - if (subC27F9(_gameBoardSide[0]._handCard[i]._cardId) != -1) { - // The variable 'j' is not used in the inner code of the loop. It's suspect - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[2]._delayCard._cardId == 0) && (subC32B1(2, _gameBoardSide[0]._handCard[i]._cardId))) { - subC3456(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[2]._delayCard); - found = true; - } - } + } else if (_gameBoardSide[3]._handCard[randIndx]._cardId == 13) { + int tmpVal = subC331B(3); - if (found) - break; + if (tmpVal != -1) { + subC358E(&_gameBoardSide[3]._handCard[randIndx], tmpVal); + return; } - } - - if (found) - return; - - tmpVal = subC274D(0); - int tmpVal2 = subC331B(0); - - if ((tmpVal != -1) && (tmpVal2 != -1)) { - subC358E(&_gameBoardSide[0]._handCard[tmpVal], tmpVal2); - found = true; - } + } else if (_gameBoardSide[3]._handCard[randIndx]._cardId == 25) { + int tmpVal = -1; + found = false; + int tmpRandIndx = R2_GLOBALS._randomSource.getRandomNumber(3); - if (found) - return; + for (int i = 0; i <= 3; i++) { + if ( (tmpRandIndx != 3) + && ( (_gameBoardSide[tmpRandIndx]._handCard[0]._cardId != 0) + || (_gameBoardSide[tmpRandIndx]._handCard[1]._cardId != 0) + || (_gameBoardSide[tmpRandIndx]._handCard[2]._cardId != 0) + || (_gameBoardSide[tmpRandIndx]._handCard[3]._cardId != 0) )) { + tmpVal = tmpRandIndx; + break; + } - tmpVal = subC2781(0); - if (tmpVal != -1) { - if ( (_gameBoardSide[1]._handCard[0]._cardId != 0) - || (_gameBoardSide[1]._handCard[1]._cardId != 0) - || (_gameBoardSide[1]._handCard[2]._cardId != 0) - || (_gameBoardSide[1]._handCard[3]._cardId != 0) ) { - subC318B(0, &_gameBoardSide[0]._handCard[tmpVal], 1); - found = true; + ++tmpRandIndx; + if (tmpRandIndx > 3) + tmpRandIndx = 0; } - } - if (found) - return; - - for (int i = 0; i <= 3; i++) { - tmpVal = subC27F9(_gameBoardSide[0]._handCard[i]._cardId); if (tmpVal != -1) { - // The variable 'j' is not used in the inner code of the loop. It's suspect. - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[1]._delayCard._cardId == 0) && (subC32B1(1, _gameBoardSide[0]._handCard[i]._cardId))) { - subC3456(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[1]._delayCard); - found = true; - } - } + subC318B(3, &_gameBoardSide[3]._handCard[randIndx], tmpVal); + return; + } + } else { + switch (_gameBoardSide[3]._handCard[randIndx]._cardId) { + case 10: + // No break on purpose + case 11: + // No break on purpose + case 12: + // No break on purpose + case 14: + // No break on purpose + case 15: + // No break on purpose + case 16: + // No break on purpose + case 17: + // No break on purpose + case 18: + // No break on purpose + case 19: + // No break on purpose + case 20: + // No break on purpose + case 21: + // No break on purpose + case 24: { + int tmpVal = -1; + int tmpRandIndx = R2_GLOBALS._randomSource.getRandomNumber(3); - if (!found) { - // The variable 'j' is not used in the inner code of the loop. It's suspect. - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[3]._delayCard._cardId == 0) && (subC32B1(3, _gameBoardSide[0]._handCard[i]._cardId))) { - subC3456(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[3]._delayCard); - found = true; + for (int i = 0; i <= 3; i++) { + if (tmpRandIndx != 3) { + // The variable 'j' is not used in the inner code of the loop, which is suspicious. + // 'i' is used indirectly to increment tmpRandIndx. + for (int j = 0; j <= 7; j++) { + if ((_gameBoardSide[tmpRandIndx]._delayCard._cardId == 0) && subC32B1(tmpRandIndx, _gameBoardSide[3]._handCard[randIndx]._cardId)) + tmpVal = tmpRandIndx; } } - } - if (found) - break; - } - } - - if (found) - return; + ++tmpRandIndx; + if (tmpRandIndx > 3) + tmpRandIndx = 0; - for (int i = 0; i <= 3; i++) { - tmpVal = subC27B5(_gameBoardSide[0]._handCard[i]._cardId); - if (tmpVal != -1) { - // The variable 'j' is not used in the inner code of the loop. It's suspect. - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[1]._delayCard._cardId == 0) && (subC32B1(1, _gameBoardSide[0]._handCard[i]._cardId))) { - subC3456(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[1]._delayCard); - found = true; - } + if (tmpVal != -1) + break; } - if (!found) { - // The variable 'j' is not used in the inner code of the loop. It's suspect. - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[3]._delayCard._cardId == 0) && (subC32B1(3, _gameBoardSide[0]._handCard[i]._cardId))) { - subC3456(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[3]._delayCard); - found = true; - } - } + if (tmpVal != -1) { + // Useless second identical check skipped + playDelayCard(&_gameBoardSide[tmpVal]._handCard[randIndx], &_gameBoardSide[tmpVal]._delayCard); + return; } - - if (found) - break; + } + default: + break; } } - if (found) - return; - - subC2835(0); + discardCard(&_gameBoardSide[3]._handCard[randIndx]); } void Scene1337::subD026D() { @@ -6542,7 +6542,7 @@ void Scene1337::subD02CA() { found = true; _currentPlayerNumb--; _showPlayerTurn = false; - subC20F9(); + handleNextTurn(); } else { actionDisplay(1330, 127, 159, 10, 1, 200, 0, 7, 0, 154, 154); found_di = true; @@ -6570,7 +6570,7 @@ void Scene1337::subD02CA() { if (subC27B5(_gameBoardSide[2]._delayCard._cardId) != -1) { actionDisplay(1330, 55, 159, 10, 1, 200, 0, 7, 0, 154, 154); } else { - subC340B(&_selectedCard, &_gameBoardSide[2]._outpostStation[i]); + playCard(&_selectedCard, &_gameBoardSide[2]._outpostStation[i]); return; } } else { @@ -6599,7 +6599,7 @@ void Scene1337::subD02CA() { actionDisplay(1330, 35, 159, 10, 1, 200, 0, 7, 0, 154, 154); } else { if (j == 7) - _field424A = 2; + _winnerId = 2; subC33C0(&_selectedCard, &_gameBoardSide[2]._outpostStation[i]); return; @@ -6758,7 +6758,7 @@ void Scene1337::subD02CA() { break; } } else { - subC3456(&_selectedCard, &_gameBoardSide[0]._delayCard); + playDelayCard(&_selectedCard, &_gameBoardSide[0]._delayCard); found = true; } } else if (_gameBoardSide[3]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { @@ -6794,7 +6794,7 @@ void Scene1337::subD02CA() { break; } } else { - subC3456(&_selectedCard, &_gameBoardSide[3]._delayCard); + playDelayCard(&_selectedCard, &_gameBoardSide[3]._delayCard); found = true; } } else if (_gameBoardSide[1]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { @@ -6830,7 +6830,7 @@ void Scene1337::subD02CA() { break; } } else { - subC3456(&_selectedCard, &_gameBoardSide[1]._delayCard); + playDelayCard(&_selectedCard, &_gameBoardSide[1]._delayCard); found = true; } } else { diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.h b/engines/tsage/ringworld2/ringworld2_scenes1.h index 8e09a40733..c8615ab78e 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes1.h +++ b/engines/tsage/ringworld2/ringworld2_scenes1.h @@ -315,7 +315,7 @@ public: int _actionIdx2; bool _showPlayerTurn; bool _field4246; - int _field424A; + int _winnerId; bool _instructionsDisplayedFl; int _instructionsWaitCount; int _cursorCurRes; @@ -329,28 +329,27 @@ public: virtual void synchronize(Serializer &s); void actionDisplay(int resNum, int lineNum, int x, int y, int keepOnScreen, int width, int textMode, int fontNum, int colFG, int colBGExt, int colFGExt); - void setAnimationInfo(Card *subObj); + void setAnimationInfo(Card *card); void subC20E5(); - void subC20F9(); + void handleNextTurn(); void subC2586(); bool subC264B(int arg1); bool subC2687(int arg1); int subC26CB(int arg1, int arg2); - int subC2719(int arg1); + int findNormalCardInHand(int playerId); int subC274D(int arg1); int subC2781(int arg1); int subC27B5(int arg1); int subC27F9(int arg1); void subC2835(int arg1); - void subC2C2F(); void subC318B(int arg1, Card *subObj2, int arg3); int subC3257(int arg1); bool subC32B1(int arg1, int arg2); int subC331B(int arg1); bool subC3386(int arg1, int arg2); void subC33C0(Card *subObj1, Card *subObj2); - void subC3456(Card *subObj1, Card *subObj2); - void subC340B(Card *subObj1, Card *subObj2); + void playDelayCard(Card *card, Card *dest); + void playCard(Card *card, Card *dest); void subC34A1(Card *subObj1, Card *subObj2); Card *subC34EC(int arg1); void subC358E(Card *subObj1, int arg2); @@ -367,8 +366,9 @@ public: void dealCards(); void subCD193(); void handleClick(int arg1, Common::Point pt); - void subCF31D(); - void subCF979(); + void handlePlayer0(); + void handlePlayer1(); + void handlePlayer3(); void subD026D(); void subD0281(); void subD02CA(); |