From 9a298305320fb9737adf7db69ee94d179436a83e Mon Sep 17 00:00:00 2001 From: lotodore Date: Thu, 7 Jun 2007 23:24:22 +0000 Subject: [PATCH] Player action timeout - display is working, function still missing. --- docs/net_protocol.txt | 8 ++++-- src/gamedata.h | 3 +- src/gui/generic/serverguiwrapper.cpp | 2 ++ src/gui/generic/serverguiwrapper.h | 2 ++ src/gui/guiinterface.h | 3 +- src/gui/qt/guiwrapper.cpp | 2 ++ src/gui/qt/guiwrapper.h | 2 ++ src/gui/qt/mainwindow/mainwindowimpl.cpp | 24 ++++++++-------- src/gui/qt/mainwindow/mainwindowimpl.h | 7 +++-- src/gui/qt/mainwindow/mysetlabel.cpp | 6 ++-- src/net/common/clientstate.cpp | 6 ++++ src/net/common/netpacket.cpp | 36 +++++++++++++----------- 12 files changed, 65 insertions(+), 36 deletions(-) diff --git a/docs/net_protocol.txt b/docs/net_protocol.txt index 2060f3e3..9fa809e3 100644 --- a/docs/net_protocol.txt +++ b/docs/net_protocol.txt @@ -55,7 +55,7 @@ Server Reply: Join Game ACK 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Message Type = 2 | Message Length = 12 | + | Message Type = 2 | Message Length = 28 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Your Session ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ @@ -63,7 +63,9 @@ Server Reply: Join Game ACK +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Number of Players | Small Blind | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Hands before raise | Proposed GUI Speed | + | Hands before raise | Proposed GUI Speed | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Player Action Timeout | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Start Money | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ @@ -74,6 +76,8 @@ Player ID: Unique Player ID Proposed GUI Speed: 1-11 +Player Action Timeout: + # seconds Server Notification: Player Joined diff --git a/src/gamedata.h b/src/gamedata.h index f27587cb..af72e8de 100644 --- a/src/gamedata.h +++ b/src/gamedata.h @@ -26,12 +26,13 @@ struct GameData { GameData() : numberOfPlayers(0), startMoney(0), smallBlind(0), - handsBeforeRaise(1), guiSpeed(4) {} + handsBeforeRaise(1), guiSpeed(4), playerActionTimeoutSec(20) {} int numberOfPlayers; int startMoney; int smallBlind; int handsBeforeRaise; int guiSpeed; + int playerActionTimeoutSec; }; struct StartData diff --git a/src/gui/generic/serverguiwrapper.cpp b/src/gui/generic/serverguiwrapper.cpp index 0611bc2e..324b1d5c 100644 --- a/src/gui/generic/serverguiwrapper.cpp +++ b/src/gui/generic/serverguiwrapper.cpp @@ -89,6 +89,8 @@ void ServerGuiWrapper::flipHolecardsAllIn() {} void ServerGuiWrapper::nextRoundCleanGui() {} void ServerGuiWrapper::meInAction() {} +void ServerGuiWrapper::startTimeoutAnimation(int playerId, int timeoutSec) {} +void ServerGuiWrapper::stopTimeoutAnimation(int playerId) {} void ServerGuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) {} void ServerGuiWrapper::logNewGameHandMsg(int gameID, int handID) {} diff --git a/src/gui/generic/serverguiwrapper.h b/src/gui/generic/serverguiwrapper.h index 2713a6ec..614ad14d 100644 --- a/src/gui/generic/serverguiwrapper.h +++ b/src/gui/generic/serverguiwrapper.h @@ -73,6 +73,8 @@ public: void nextRoundCleanGui(); void meInAction(); + void startTimeoutAnimation(int playerId, int timeoutSec); + void stopTimeoutAnimation(int playerId); void logPlayerActionMsg(std::string playerName, int action, int setValue) ; void logNewGameHandMsg(int gameID, int handID) ; diff --git a/src/gui/guiinterface.h b/src/gui/guiinterface.h index f8cd6ac6..61663c15 100644 --- a/src/gui/guiinterface.h +++ b/src/gui/guiinterface.h @@ -82,7 +82,8 @@ public: // virtual void userWidgetsBackgroudColor() const=0; // virtual void timerBlockerFalse() const=0; virtual void meInAction()=0; - + virtual void startTimeoutAnimation(int playerId, int timeoutSec) =0; + virtual void stopTimeoutAnimation(int playerId) =0; //log.cpp virtual void logPlayerActionMsg(std::string playName, int action, int setValue) =0; diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index f73dbe47..36042e8c 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -87,6 +87,8 @@ void GuiWrapper::flipHolecardsAllIn() { myW->signalFlipHolecardsAllIn(); } void GuiWrapper::nextRoundCleanGui() { myW->signalNextRoundCleanGui(); } void GuiWrapper::meInAction() { myW->signalMeInAction(); } +void GuiWrapper::startTimeoutAnimation(int playerId, int timeoutSec) { myW->signalStartTimeoutAnimation(playerId, timeoutSec); } +void GuiWrapper::stopTimeoutAnimation(int playerId) { myW->signalStopTimeoutAnimation(playerId); } void GuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) { myLog->signalLogPlayerActionMsg(QString::fromUtf8(playerName.c_str()), action, setValue); } void GuiWrapper::logNewGameHandMsg(int gameID, int handID) { myLog->signalLogNewGameHandMsg(gameID, handID); } diff --git a/src/gui/qt/guiwrapper.h b/src/gui/qt/guiwrapper.h index 70cb0673..493c2acd 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -80,6 +80,8 @@ public: void nextRoundCleanGui(); void meInAction(); + void startTimeoutAnimation(int playerId, int timeoutSec); + void stopTimeoutAnimation(int playerId); void logPlayerActionMsg(std::string playerName, int action, int setValue) ; void logNewGameHandMsg(int gameID, int handID) ; diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index 38594f1a..42b32a84 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -585,6 +585,8 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent) connect(this, SIGNAL(signalRefreshGameLabels(int)), this, SLOT(refreshGameLabels(int))); connect(this, SIGNAL(signalMeInAction()), this, SLOT(meInAction())); + connect(this, SIGNAL(signalStartTimeoutAnimation(int, int)), this, SLOT(startTimeoutAnimation(int, int))); + connect(this, SIGNAL(signalStopTimeoutAnimation(int)), this, SLOT(stopTimeoutAnimation(int))); connect(this, SIGNAL(signalDealHoleCards()), this, SLOT(dealHoleCards())); connect(this, SIGNAL(signalDealFlopCards0()), this, SLOT(dealFlopCards0())); @@ -719,6 +721,7 @@ void mainWindowImpl::callCreateNetworkGameDialog() { //temporarely static until ai is enabled in network // gameData.guiSpeed = myCreateNetworkGameDialog->spinBox_gameSpeed->value(); gameData.guiSpeed = 4; + gameData.playerActionTimeoutSec = myCreateNetworkGameDialog->spinBox_netTimeOutPlayerAction->value(); myStartNetworkGameDialog->setSession(&myServerGuiInterface->getSession()); myStartNetworkGameDialog->treeWidget->clear(); @@ -1500,6 +1503,16 @@ void mainWindowImpl::meInAction() { } } +void mainWindowImpl::startTimeoutAnimation(int playerId, int timeoutSec) { + assert(playerId >= 0 && playerId < mySession->getCurrentGame()->getStartQuantityPlayers()); + setLabelArray[playerId]->startTimeOutAnimation(timeoutSec); +} + +void mainWindowImpl::stopTimeoutAnimation(int playerId) { + assert(playerId >= 0 && playerId < mySession->getCurrentGame()->getStartQuantityPlayers()); + setLabelArray[playerId]->stopTimeOutAnimation(); +} + void mainWindowImpl::disableMyButtons() { //clear userWidgets @@ -1758,15 +1771,6 @@ void mainWindowImpl::myAllIn(){ myActionDone(); } -void mainWindowImpl::userActionTimeOutReached() { - - //TODO -// automatic check, fold - cout << "timeoutaction" << endl; - -} - - void mainWindowImpl::myActionDone() { // If a network client is running, we need @@ -2514,8 +2518,6 @@ void mainWindowImpl::keyPressEvent ( QKeyEvent * event ) { if (event->key() == Qt::Key_F3) { pushButton_BetRaise->click(); } if (event->key() == Qt::Key_F10) { switchLeftToolBox(); } if (event->key() == Qt::Key_F11) { switchRightToolBox(); } - if (event->key() == Qt::Key_D) { setLabelArray[0]->startTimeOutAnimation(myConfig->readConfigInt("NetTimeOutPlayerAction")); } //f - if (event->key() == Qt::Key_E) { setLabelArray[0]->stopTimeOutAnimation(); } //f // if (event->key() == Qt::Key_W) { qApp->quit(); } //s if (event->key() == 16777249) { pushButton_break->click(); diff --git a/src/gui/qt/mainwindow/mainwindowimpl.h b/src/gui/qt/mainwindow/mainwindowimpl.h index 6063cad8..6ece0be9 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.h +++ b/src/gui/qt/mainwindow/mainwindowimpl.h @@ -86,6 +86,8 @@ signals: void signalRefreshGameLabels(int); void signalMeInAction(); + void signalStartTimeoutAnimation(int playerId, int timeoutSec); + void signalStopTimeoutAnimation(int playerId); void signalDealHoleCards(); void signalDealFlopCards0(); @@ -152,6 +154,9 @@ public slots: void callCreateNetworkGameDialog(); void callJoinNetworkGameDialog(); + void startTimeoutAnimation(int playerId, int timoutSec); + void stopTimeoutAnimation(int playerId); + void myBetRaise(); void myFoldAllin(); void myCallCheckSet(); @@ -251,8 +256,6 @@ public slots: void localGameModification(); void networkGameModification(); - void userActionTimeOutReached(); - void quitPokerTH(); private: diff --git a/src/gui/qt/mainwindow/mysetlabel.cpp b/src/gui/qt/mainwindow/mysetlabel.cpp index ddda4dbe..e15b4ad9 100644 --- a/src/gui/qt/mainwindow/mysetlabel.cpp +++ b/src/gui/qt/mainwindow/mysetlabel.cpp @@ -57,9 +57,9 @@ void MySetLabel::nextTimeOutAnimationFrame() { update(); } else { - stopTimeOutAnimation(); - //callback - myW->userActionTimeOutReached(); + stopTimeOutAnimation(); + // no callback is called here. + // the server initiates any action required. } } diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index 85a94637..cfe7a031 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -630,6 +630,9 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptrgetMySet() > GetHighestSet(*curGame)) SetHighestSet(*curGame, tmpPlayer->getMySet()); + // Stop the timeout for the player. + client.GetGui().stopTimeoutAnimation(tmpPlayer->getMyID()); + // Unmark last player in GUI. client.GetGui().refreshGroupbox(tmpPlayer->getMyID(), 3); @@ -668,6 +671,9 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptrgetMyID(), guiStatus); + // Start displaying the timeout for the player. + client.GetGui().startTimeoutAnimation(tmpPlayer->getMyID(), client.GetGameData().playerActionTimeoutSec); + if (tmpPlayer->getMyID() == 0) // Is this the GUI player? client.GetGui().meInAction(); } diff --git a/src/net/common/netpacket.cpp b/src/net/common/netpacket.cpp index b1b83c94..3e887126 100644 --- a/src/net/common/netpacket.cpp +++ b/src/net/common/netpacket.cpp @@ -97,6 +97,8 @@ struct GCC_PACKED NetPacketJoinGameAckData u_int16_t smallBlind; u_int16_t handsBeforeRaise; u_int16_t proposedGuiSpeed; + u_int16_t playerActionTimeout; + u_int16_t reserved; u_int32_t startMoney; }; @@ -716,14 +718,15 @@ NetPacketJoinGameAck::SetData(const NetPacketJoinGameAck::Data &inData) NetPacketJoinGameAckData *tmpData = (NetPacketJoinGameAckData *)GetRawData(); assert(tmpData); - tmpData->sessionId = htonl(inData.sessionId); - tmpData->playerId = htons(inData.yourPlayerUniqueId); - tmpData->playerNumber = htons(inData.yourPlayerNum); - tmpData->numberOfPlayers = htons(inData.gameData.numberOfPlayers); - tmpData->smallBlind = htons(inData.gameData.smallBlind); - tmpData->handsBeforeRaise = htons(inData.gameData.handsBeforeRaise); - tmpData->proposedGuiSpeed = htons(inData.gameData.guiSpeed); - tmpData->startMoney = htonl(inData.gameData.startMoney); + tmpData->sessionId = htonl(inData.sessionId); + tmpData->playerId = htons(inData.yourPlayerUniqueId); + tmpData->playerNumber = htons(inData.yourPlayerNum); + tmpData->numberOfPlayers = htons(inData.gameData.numberOfPlayers); + tmpData->smallBlind = htons(inData.gameData.smallBlind); + tmpData->handsBeforeRaise = htons(inData.gameData.handsBeforeRaise); + tmpData->proposedGuiSpeed = htons(inData.gameData.guiSpeed); + tmpData->playerActionTimeout = htons(inData.gameData.playerActionTimeoutSec); + tmpData->startMoney = htonl(inData.gameData.startMoney); } void @@ -732,14 +735,15 @@ NetPacketJoinGameAck::GetData(NetPacketJoinGameAck::Data &outData) const NetPacketJoinGameAckData *tmpData = (NetPacketJoinGameAckData *)GetRawData(); assert(tmpData); - outData.sessionId = ntohl(tmpData->sessionId); - outData.yourPlayerUniqueId = ntohs(tmpData->playerId); - outData.yourPlayerNum = ntohs(tmpData->playerNumber); - outData.gameData.numberOfPlayers = ntohs(tmpData->numberOfPlayers); - outData.gameData.smallBlind = ntohs(tmpData->smallBlind); - outData.gameData.handsBeforeRaise = ntohs(tmpData->handsBeforeRaise); - outData.gameData.guiSpeed = ntohs(tmpData->proposedGuiSpeed); - outData.gameData.startMoney = ntohl(tmpData->startMoney); + outData.sessionId = ntohl(tmpData->sessionId); + outData.yourPlayerUniqueId = ntohs(tmpData->playerId); + outData.yourPlayerNum = ntohs(tmpData->playerNumber); + outData.gameData.numberOfPlayers = ntohs(tmpData->numberOfPlayers); + outData.gameData.smallBlind = ntohs(tmpData->smallBlind); + outData.gameData.handsBeforeRaise = ntohs(tmpData->handsBeforeRaise); + outData.gameData.guiSpeed = ntohs(tmpData->proposedGuiSpeed); + outData.gameData.playerActionTimeoutSec = ntohs(tmpData->playerActionTimeout); + outData.gameData.startMoney = ntohl(tmpData->startMoney); } const NetPacketJoinGameAck *