diff options
author | Strangerke | 2013-12-14 13:06:27 +0100 |
---|---|---|
committer | Strangerke | 2013-12-14 13:07:01 +0100 |
commit | 876dee6f93172d3f22fed5ac98364ee0c25d080b (patch) | |
tree | f970a7888e0338ac303f5374f9fcae504a3e29cc /engines | |
parent | 094c378217d0af49d92c3be4dc1733e68a7f248a (diff) | |
download | scummvm-rg350-876dee6f93172d3f22fed5ac98364ee0c25d080b.tar.gz scummvm-rg350-876dee6f93172d3f22fed5ac98364ee0c25d080b.tar.bz2 scummvm-rg350-876dee6f93172d3f22fed5ac98364ee0c25d080b.zip |
TSAGE: R2R - Renaming, refactoring in handlePlayer0()
Diffstat (limited to 'engines')
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_scenes1.cpp | 182 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_scenes1.h | 10 |
2 files changed, 63 insertions, 129 deletions
diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.cpp b/engines/tsage/ringworld2/ringworld2_scenes1.cpp index 478674f1b8..0e7e70c13b 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes1.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes1.cpp @@ -4725,7 +4725,7 @@ int Scene1337::findNormalCardInHand(int playerId) { return -1; } -int Scene1337::subC274D(int playerId) { +int Scene1337::findCard13InHand(int playerId) { for (int i = 0; i <= 3; i++) { if (_gameBoardSide[playerId]._handCard[i]._cardId == 13) return i; @@ -4734,9 +4734,9 @@ int Scene1337::subC274D(int playerId) { return -1; } -int Scene1337::subC2781(int arg1) { +int Scene1337::checkThieftCard(int playerId) { for (int i = 0; i <= 3; i++) { - if (_gameBoardSide[arg1]._handCard[i]._cardId == 25) + if (_gameBoardSide[playerId]._handCard[i]._cardId == 25) return i; } @@ -4950,10 +4950,10 @@ void Scene1337::playThieftCard(int playerId, Card *card, int victimId) { _item1.setAction(&_action11); } -int Scene1337::subC3257(int arg1) { +int Scene1337::subC3257(int cardId) { int retVal; - switch (arg1) { + switch (cardId) { case 10: retVal = 2; break; @@ -4985,35 +4985,35 @@ int Scene1337::subC3257(int arg1) { return retVal; } -bool Scene1337::subC32B1(int arg1, int arg2) { +bool Scene1337::subC32B1(int victimId, int cardId) { for (int i = 0; i <= 7; i++) { - if (_gameBoardSide[arg1]._outpostStation[i]._cardId != 0) { - if (subC3257(arg2) == _gameBoardSide[arg1]._outpostStation[i]._cardId) + if (_gameBoardSide[victimId]._outpostStation[i]._cardId != 0) { + if (subC3257(cardId) == _gameBoardSide[victimId]._outpostStation[i]._cardId) return false; } } return true; } -int Scene1337::subC331B(int arg1) { - int randIndx = R2_GLOBALS._randomSource.getRandomNumber(3); +int Scene1337::getPlayerWithOutpost(int playerId) { + int randPlayerId = R2_GLOBALS._randomSource.getRandomNumber(3); for (int i = 0; i <= 3; i++) { - if (randIndx != arg1) { + if (randPlayerId != playerId) { for (int j = 0; j <= 7; j++) { - if (_gameBoardSide[randIndx]._outpostStation[j]._cardId != 0) - return randIndx; + if (_gameBoardSide[randPlayerId]._outpostStation[j]._cardId != 0) + return randPlayerId; } } - if (arg1 == 1) { - randIndx--; - if (randIndx < 0) - randIndx = 3; + if (playerId == 1) { + randPlayerId--; + if (randPlayerId < 0) + randPlayerId = 3; } else { - ++randIndx; - if (randIndx > 3) - randIndx = 0; + ++randPlayerId; + if (randPlayerId > 3) + randPlayerId = 0; } } @@ -5765,8 +5765,6 @@ void Scene1337::handleClick(int arg1, Common::Point pt) { } void Scene1337::handlePlayer0() { - bool found = true; - if (_gameBoardSide[0]._delayCard._cardId != 0) { switch (_gameBoardSide[0]._delayCard._cardId) { case 10: @@ -5785,32 +5783,21 @@ void Scene1337::handlePlayer0() { //No break on purpose case 21: discardCard(&_gameBoardSide[0]._delayCard); - found = false; break; default: - int i; - found = false; - - for (i = 0; i <= 3; i++) { + for (int i = 0; i <= 3; i++) { if (checkAntiDelayCard(_gameBoardSide[0]._delayCard._cardId, _gameBoardSide[0]._handCard[i]._cardId)) { - found = true; - break; + playAntiDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[0]._delayCard); + return; } } - if (found) { - found = false; - playAntiDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[0]._delayCard); - } break; } } - if (found) - return; - int tmpVal; - found = false; + bool found = false; for (int i = 0; i <= 3; i++) { tmpVal = subC26CB(0, i); @@ -5837,183 +5824,130 @@ void Scene1337::handlePlayer0() { _winnerId = 0; subC33C0(&_gameBoardSide[0]._handCard[tmpVal], &_gameBoardSide[0]._outpostStation[j]); - found = true; + return; } } } } - - 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; + return; } } } - if (found) - return; - - tmpVal = subC274D(0); - if (tmpVal != -1) { + int card13Id = findCard13InHand(0); + if (card13Id != -1) { for (int i = 0; i <= 7; i++) { if (_gameBoardSide[2]._outpostStation[i]._cardId != 0) { - playCounterTrickCard(&_gameBoardSide[0]._handCard[tmpVal], 2); - found = true; - break; + playCounterTrickCard(&_gameBoardSide[0]._handCard[card13Id], 2); + return; } } } - if (found) - return; - - tmpVal = subC2781(0); - if (tmpVal != -1) { + int thieftId = checkThieftCard(0); + if (thieftId != -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) ) { - playThieftCard(0, &_gameBoardSide[0]._handCard[tmpVal], 2); - found = true; + playThieftCard(0, &_gameBoardSide[0]._handCard[thieftId], 2); + return; } } - 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))) { + if ((_gameBoardSide[2]._delayCard._cardId == 0) && subC32B1(2, _gameBoardSide[0]._handCard[i]._cardId)) { playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[2]._delayCard); - found = true; - break; + return; } } - - if (found) - break; } } - if (found) - return; - for (int i = 0; i <= 3; i++) { if (isSlowCard(_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))) { + if ((_gameBoardSide[2]._delayCard._cardId == 0) && subC32B1(2, _gameBoardSide[0]._handCard[i]._cardId)) { playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[2]._delayCard); - found = true; + return; } } - - if (found) - break; } } - if (found) - return; - - tmpVal = subC274D(0); - int tmpVal2 = subC331B(0); + tmpVal = findCard13InHand(0); + int tmpVal2 = getPlayerWithOutpost(0); if ((tmpVal != -1) && (tmpVal2 != -1)) { playCounterTrickCard(&_gameBoardSide[0]._handCard[tmpVal], tmpVal2); - found = true; - } - - if (found) return; + } - tmpVal = subC2781(0); + tmpVal = checkThieftCard(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) ) { playThieftCard(0, &_gameBoardSide[0]._handCard[tmpVal], 1); - found = true; + return; } } - if (found) - return; - for (int i = 0; i <= 3; i++) { tmpVal = isSlowCard(_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))) { + if ((_gameBoardSide[1]._delayCard._cardId == 0) && subC32B1(1, _gameBoardSide[0]._handCard[i]._cardId)) { playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[1]._delayCard); - found = true; + return; } } - 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))) { + 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; - } + return; } } - - 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))) { + if ((_gameBoardSide[1]._delayCard._cardId == 0) && subC32B1(1, _gameBoardSide[0]._handCard[i]._cardId)) { playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[1]._delayCard); - found = true; + return; } } - 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))) { + 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; - } + return; } } - - if (found) - break; } } - if (found) - return; - subC2835(0); } @@ -6114,8 +6048,8 @@ void Scene1337::handlePlayer1() { if (found) return; - tmpVal = subC274D(1); - int tmpVal2 = subC331B(1); + tmpVal = findCard13InHand(1); + int tmpVal2 = getPlayerWithOutpost(1); if ((tmpVal != -1) && ( tmpVal2 != -1)) { playCounterTrickCard(&_gameBoardSide[1]._handCard[tmpVal], tmpVal2); @@ -6125,7 +6059,7 @@ void Scene1337::handlePlayer1() { if (found) return; - tmpVal = subC2781(1); + tmpVal = checkThieftCard(1); if (tmpVal != -1) { count = -1; int rndVal = R2_GLOBALS._randomSource.getRandomNumber(3); @@ -6167,7 +6101,7 @@ void Scene1337::handlePlayer1() { for (int k = 0; k <= 7; k++) { // CHECKME: 'k' is not used in that loop. // It looks suspicious. - if ((_gameBoardSide[tmpVal]._delayCard._cardId == 0) && (subC32B1(tmpVal, _gameBoardSide[1]._handCard[i]._cardId))) { + if ((_gameBoardSide[tmpVal]._delayCard._cardId == 0) && subC32B1(tmpVal, _gameBoardSide[1]._handCard[i]._cardId)) { count = tmpVal; break; } @@ -6321,7 +6255,7 @@ void Scene1337::handlePlayer3() { return; } } else if (_gameBoardSide[3]._handCard[randIndx]._cardId == 13) { - int tmpVal = subC331B(3); + int tmpVal = getPlayerWithOutpost(3); if (tmpVal != -1) { playCounterTrickCard(&_gameBoardSide[3]._handCard[randIndx], tmpVal); diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.h b/engines/tsage/ringworld2/ringworld2_scenes1.h index 6cbc617578..bd8159d615 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes1.h +++ b/engines/tsage/ringworld2/ringworld2_scenes1.h @@ -337,15 +337,15 @@ public: bool subC2687(int cardId); int subC26CB(int playerId, int handCardId); int findNormalCardInHand(int playerId); - int subC274D(int arg1); - int subC2781(int arg1); + int findCard13InHand(int playerId); + int checkThieftCard(int playerId); int subC27B5(int arg1); int isSlowCard(int cardId); void subC2835(int arg1); void playThieftCard(int playerId, Card *card, int victimId); - int subC3257(int arg1); - bool subC32B1(int arg1, int arg2); - int subC331B(int arg1); + int subC3257(int cardId); + bool subC32B1(int victimId, int cardId); + int getPlayerWithOutpost(int playerId); bool checkAntiDelayCard(int delayCardId, int cardId); void subC33C0(Card *subObj1, Card *subObj2); void playDelayCard(Card *card, Card *dest); |