Merge branch 'new_local_game' of github.com:/pokerth/pokerth into gocode
This commit is contained in:
@@ -46,8 +46,6 @@
|
||||
|
||||
#define SQLITE_LOG_VERSION 1
|
||||
|
||||
//#define NEW_LOCAL_GAME
|
||||
|
||||
#define RANKING_GAME_START_CASH 10000
|
||||
#define RANKING_GAME_NUMBER_OF_PLAYERS 10
|
||||
#define RANKING_GAME_START_SBLIND 50
|
||||
|
||||
@@ -256,11 +256,9 @@ startWindowImpl::startWindowImpl(ConfigFile *c, Log *l)
|
||||
connect(this, SIGNAL(signalPlayerGameInvitation(unsigned, unsigned, unsigned)), myGameLobbyDialog, SLOT(chatInfoPlayerInvitation(unsigned, unsigned, unsigned)));
|
||||
connect(this, SIGNAL(signalRejectedGameInvitation(unsigned, unsigned, DenyGameInvitationReason)), myGameLobbyDialog, SLOT(chatInfoPlayerRejectedInvitation(unsigned, unsigned, DenyGameInvitationReason)));
|
||||
|
||||
#ifdef NEW_LOCAL_GAME
|
||||
QAction *actionStart_Local_Game_new = new QAction("Start (new) local game ...",this);
|
||||
menuPokerTH->addAction(actionStart_Local_Game_new);
|
||||
connect( actionStart_Local_Game_new, SIGNAL( triggered() ), this, SLOT( callNewGameDialogNew() ) );
|
||||
#endif
|
||||
|
||||
this->show();
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ public slots:
|
||||
void callLogFileDialog();
|
||||
|
||||
void startNewLocalGame(newGameDialogImpl* =0);
|
||||
void startNewLocalGameNew(newGameDialogImpl* =0);
|
||||
void startNewLocalGameNew(newGameDialogImpl* =0);
|
||||
|
||||
void showTimeoutDialog(int msgID, unsigned duration);
|
||||
void hideTimeoutDialog();
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
#include "serverdelaytime.h"
|
||||
|
||||
//#define POKERTH_SERVER_TEST
|
||||
|
||||
#ifdef POKERTH_SERVER_TEST
|
||||
#define SERVER_DELAY_NEXT_GAME_SEC 0
|
||||
#define SERVER_DEAL_FLOP_CARDS_DELAY_SEC 0
|
||||
#define SERVER_DEAL_TURN_CARD_DELAY_SEC 0
|
||||
#define SERVER_DEAL_RIVER_CARD_DELAY_SEC 0
|
||||
#define SERVER_DEAL_ADD_ALL_IN_DELAY_SEC 0
|
||||
#define SERVER_SHOW_CARDS_DELAY_SEC 0
|
||||
#define SERVER_COMPUTER_ACTION_DELAY_SEC 0
|
||||
#define SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC 1
|
||||
#else
|
||||
#define SERVER_DELAY_NEXT_GAME_SEC 10
|
||||
#define SERVER_DEAL_FLOP_CARDS_DELAY_SEC 5
|
||||
#define SERVER_DEAL_TURN_CARD_DELAY_SEC 2
|
||||
#define SERVER_DEAL_RIVER_CARD_DELAY_SEC 2
|
||||
#define SERVER_DEAL_ADD_ALL_IN_DELAY_SEC 2
|
||||
#define SERVER_SHOW_CARDS_DELAY_SEC 2
|
||||
#define SERVER_COMPUTER_ACTION_DELAY_SEC 2
|
||||
#define SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC 2
|
||||
#endif
|
||||
|
||||
ServerDelayTime::ServerDelayTime(const ServerMode mode)
|
||||
{
|
||||
if(mode == SERVER_MODE_LAN_LOCAL) {
|
||||
nextGameDelay = 0;
|
||||
dealFlopCardsDelay = 0;
|
||||
dealTurnCardsDelay = 0;
|
||||
dealRiverCardsDelay = 0;
|
||||
dealAddAllInDelay = 0;
|
||||
showCardsDelay = 0;
|
||||
computerActionDelay = 0;
|
||||
playerTimeoutAddDelay = 0;
|
||||
} else {
|
||||
nextGameDelay = SERVER_DELAY_NEXT_GAME_SEC;
|
||||
dealFlopCardsDelay = SERVER_DEAL_FLOP_CARDS_DELAY_SEC;
|
||||
dealTurnCardsDelay = SERVER_DEAL_TURN_CARD_DELAY_SEC;
|
||||
dealRiverCardsDelay = SERVER_DEAL_RIVER_CARD_DELAY_SEC;
|
||||
dealAddAllInDelay = SERVER_DEAL_ADD_ALL_IN_DELAY_SEC;
|
||||
showCardsDelay = SERVER_SHOW_CARDS_DELAY_SEC;
|
||||
computerActionDelay = SERVER_COMPUTER_ACTION_DELAY_SEC;
|
||||
playerTimeoutAddDelay = SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int ServerDelayTime::getNextGameDelay() const
|
||||
{
|
||||
return nextGameDelay;
|
||||
}
|
||||
|
||||
int ServerDelayTime::getDealFlopCardsDelay() const
|
||||
{
|
||||
return dealFlopCardsDelay;
|
||||
}
|
||||
|
||||
int ServerDelayTime::getDealTurnCardsDelay() const
|
||||
{
|
||||
return dealTurnCardsDelay;
|
||||
}
|
||||
|
||||
int ServerDelayTime::getDealRiverCardsDelay() const
|
||||
{
|
||||
return dealRiverCardsDelay;
|
||||
}
|
||||
|
||||
int ServerDelayTime::getDealAddAllInDelay() const
|
||||
{
|
||||
return dealAddAllInDelay;
|
||||
}
|
||||
|
||||
int ServerDelayTime::getShowCardsDelay() const
|
||||
{
|
||||
return showCardsDelay;
|
||||
}
|
||||
|
||||
int ServerDelayTime::getComputerActionDelay() const
|
||||
{
|
||||
return computerActionDelay;
|
||||
}
|
||||
|
||||
int ServerDelayTime::getPlayerTimeoutAddDelay() const
|
||||
{
|
||||
return playerTimeoutAddDelay;
|
||||
}
|
||||
@@ -66,13 +66,13 @@ static bool LessThanPlayerHandStartMoney(const boost::shared_ptr<PlayerInterface
|
||||
|
||||
|
||||
ServerGame::ServerGame(boost::shared_ptr<ServerLobbyThread> lobbyThread, u_int32_t id, const string &name, const string &pwd, const GameData &gameData,
|
||||
unsigned adminPlayerId, unsigned creatorPlayerDBId, GuiInterface &gui, ConfigFile &playerConfig)
|
||||
unsigned adminPlayerId, unsigned creatorPlayerDBId, GuiInterface &gui, ConfigFile &playerConfig, const ServerMode mode)
|
||||
: m_adminPlayerId(adminPlayerId), m_lobbyThread(lobbyThread), m_gui(gui),
|
||||
m_gameData(gameData), m_curState(NULL), m_id(id), m_name(name),
|
||||
m_password(pwd), m_creatorPlayerDBId(creatorPlayerDBId), m_playerConfig(playerConfig),
|
||||
m_gameNum(1), m_curPetitionId(1), m_voteKickTimer(lobbyThread->GetIOService()),
|
||||
m_stateTimer1(lobbyThread->GetIOService()), m_stateTimer2(lobbyThread->GetIOService()),
|
||||
m_isNameReported(false)
|
||||
m_isNameReported(false), m_serverDelayTime(mode)
|
||||
{
|
||||
LOG_VERBOSE("Game object " << GetId() << " created.");
|
||||
}
|
||||
@@ -1042,6 +1042,12 @@ ServerGame::GetSessionManager() const
|
||||
return m_sessionManager;
|
||||
}
|
||||
|
||||
const ServerDelayTime
|
||||
ServerGame::GetServerDelayTime() const
|
||||
{
|
||||
return m_serverDelayTime;
|
||||
}
|
||||
|
||||
ServerDBInterface &
|
||||
ServerGame::GetDatabase()
|
||||
{
|
||||
|
||||
@@ -58,39 +58,6 @@ using namespace std::chrono;
|
||||
using namespace boost::chrono;
|
||||
#endif
|
||||
|
||||
//#define POKERTH_SERVER_TEST
|
||||
|
||||
#ifdef POKERTH_SERVER_TEST
|
||||
#define SERVER_DELAY_NEXT_GAME_SEC 0
|
||||
#define SERVER_DEAL_FLOP_CARDS_DELAY_SEC 0
|
||||
#define SERVER_DEAL_TURN_CARD_DELAY_SEC 0
|
||||
#define SERVER_DEAL_RIVER_CARD_DELAY_SEC 0
|
||||
#define SERVER_DEAL_ADD_ALL_IN_DELAY_SEC 0
|
||||
#define SERVER_SHOW_CARDS_DELAY_SEC 0
|
||||
#define SERVER_COMPUTER_ACTION_DELAY_SEC 0
|
||||
#define SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC 1
|
||||
#else
|
||||
#define SERVER_DELAY_NEXT_GAME_SEC 10
|
||||
#define SERVER_DEAL_FLOP_CARDS_DELAY_SEC 5
|
||||
#define SERVER_DEAL_TURN_CARD_DELAY_SEC 2
|
||||
#define SERVER_DEAL_RIVER_CARD_DELAY_SEC 2
|
||||
#define SERVER_DEAL_ADD_ALL_IN_DELAY_SEC 2
|
||||
#define SERVER_SHOW_CARDS_DELAY_SEC 2
|
||||
#define SERVER_COMPUTER_ACTION_DELAY_SEC 2
|
||||
#define SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC 2
|
||||
#endif
|
||||
|
||||
#ifdef NEW_LOCAL_GAME
|
||||
#define LAN_LOCAL_SERVER_DELAY_NEXT_GAME_SEC 0
|
||||
#define LAN_LOCAL_SERVER_DEAL_FLOP_CARDS_DELAY_SEC 0
|
||||
#define LAN_LOCAL_SERVER_DEAL_TURN_CARD_DELAY_SEC 0
|
||||
#define LAN_LOCAL_SERVER_DEAL_RIVER_CARD_DELAY_SEC 0
|
||||
#define LAN_LOCAL_SERVER_DEAL_ADD_ALL_IN_DELAY_SEC 0
|
||||
#define LAN_LOCAL_SERVER_SHOW_CARDS_DELAY_SEC 0
|
||||
#define LAN_LOCAL_SERVER_COMPUTER_ACTION_DELAY_SEC 0
|
||||
#define LAN_LOCAL_SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC 0
|
||||
#endif
|
||||
|
||||
#define SERVER_START_GAME_TIMEOUT_SEC 10
|
||||
#define SERVER_AUTOSTART_GAME_DELAY_SEC 6
|
||||
#define SERVER_GAME_ADMIN_WARNING_REMAINING_SEC 60
|
||||
@@ -1018,12 +985,9 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr<ServerGame> server)
|
||||
server->SendToAllPlayers(allIn, SessionData::Game | SessionData::Spectating);
|
||||
curGame.getCurrentHand()->setCardsShown(true);
|
||||
|
||||
#ifdef NEW_LOCAL_GAME
|
||||
if(server->getLanLocal()) server->GetStateTimer1().expires_from_now(seconds(LAN_LOCAL_SERVER_SHOW_CARDS_DELAY_SEC));
|
||||
else server->GetStateTimer1().expires_from_now(seconds(SERVER_SHOW_CARDS_DELAY_SEC));
|
||||
#else
|
||||
server->GetStateTimer1().expires_from_now(seconds(SERVER_SHOW_CARDS_DELAY_SEC));
|
||||
#endif
|
||||
server->GetStateTimer1().expires_from_now(
|
||||
seconds(server->GetServerDelayTime().getShowCardsDelay()));
|
||||
|
||||
server->GetStateTimer1().async_wait(
|
||||
boost::bind(
|
||||
&ServerGameStateHand::TimerShowCards, this, boost::asio::placeholders::error, server));
|
||||
@@ -1058,12 +1022,9 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr<ServerGame> server)
|
||||
|
||||
// If the player is computer controlled, let the engine act.
|
||||
if (curPlayer->getMyType() == PLAYER_TYPE_COMPUTER) {
|
||||
#ifdef NEW_LOCAL_GAME
|
||||
if(server->getLanLocal()) server->GetStateTimer1().expires_from_now(seconds(LAN_LOCAL_SERVER_COMPUTER_ACTION_DELAY_SEC));
|
||||
else server->GetStateTimer1().expires_from_now(seconds(SERVER_COMPUTER_ACTION_DELAY_SEC));
|
||||
#else
|
||||
server->GetStateTimer1().expires_from_now(seconds(SERVER_COMPUTER_ACTION_DELAY_SEC));
|
||||
#endif
|
||||
server->GetStateTimer1().expires_from_now(
|
||||
seconds(server->GetServerDelayTime().getComputerActionDelay()));
|
||||
|
||||
server->GetStateTimer1().async_wait(
|
||||
boost::bind(
|
||||
&ServerGameStateHand::TimerComputerAction, this, boost::asio::placeholders::error, server));
|
||||
@@ -1141,18 +1102,8 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr<ServerGame> server)
|
||||
server->InternalEndGame();
|
||||
|
||||
// View a dialog for a new game - delayed.
|
||||
#ifdef NEW_LOCAL_GAME
|
||||
if(server->getLanLocal()) {
|
||||
server->GetStateTimer1().expires_from_now(
|
||||
seconds(LAN_LOCAL_SERVER_DELAY_NEXT_GAME_SEC));
|
||||
} else {
|
||||
server->GetStateTimer1().expires_from_now(
|
||||
seconds(SERVER_DELAY_NEXT_GAME_SEC));
|
||||
}
|
||||
#else
|
||||
server->GetStateTimer1().expires_from_now(
|
||||
seconds(SERVER_DELAY_NEXT_GAME_SEC));
|
||||
#endif
|
||||
seconds(server->GetServerDelayTime().getNextGameDelay()));
|
||||
|
||||
server->GetStateTimer1().async_wait(
|
||||
boost::bind(
|
||||
@@ -1230,42 +1181,18 @@ int
|
||||
ServerGameStateHand::GetDealCardsDelaySec(ServerGame &server)
|
||||
{
|
||||
Game &curGame = server.GetGame();
|
||||
#ifdef NEW_LOCAL_GAME
|
||||
int allInDelay;
|
||||
if(server.getLanLocal()) {
|
||||
allInDelay = curGame.getCurrentHand()->getAllInCondition() ? LAN_LOCAL_SERVER_DEAL_ADD_ALL_IN_DELAY_SEC : 0;
|
||||
} else {
|
||||
allInDelay = curGame.getCurrentHand()->getAllInCondition() ? SERVER_DEAL_ADD_ALL_IN_DELAY_SEC : 0;
|
||||
}
|
||||
#else
|
||||
int allInDelay = curGame.getCurrentHand()->getAllInCondition() ? SERVER_DEAL_ADD_ALL_IN_DELAY_SEC : 0;
|
||||
#endif
|
||||
int allInDelay = curGame.getCurrentHand()->getAllInCondition() ? server.GetServerDelayTime().getDealAddAllInDelay() : 0;
|
||||
int delay = 0;
|
||||
|
||||
switch(curGame.getCurrentHand()->getCurrentRound()) {
|
||||
case GAME_STATE_FLOP:
|
||||
#ifdef NEW_LOCAL_GAME
|
||||
if(server.getLanLocal()) delay = LAN_LOCAL_SERVER_DEAL_FLOP_CARDS_DELAY_SEC;
|
||||
else delay = SERVER_DEAL_FLOP_CARDS_DELAY_SEC;
|
||||
#else
|
||||
delay = SERVER_DEAL_FLOP_CARDS_DELAY_SEC;
|
||||
#endif
|
||||
delay = server.GetServerDelayTime().getDealFlopCardsDelay();
|
||||
break;
|
||||
case GAME_STATE_TURN:
|
||||
#ifdef NEW_LOCAL_GAME
|
||||
if(server.getLanLocal()) delay = LAN_LOCAL_SERVER_DEAL_TURN_CARD_DELAY_SEC + allInDelay;
|
||||
else delay = SERVER_DEAL_TURN_CARD_DELAY_SEC + allInDelay;
|
||||
#else
|
||||
delay = SERVER_DEAL_TURN_CARD_DELAY_SEC + allInDelay;
|
||||
#endif
|
||||
delay = server.GetServerDelayTime().getDealTurnCardsDelay() + allInDelay;
|
||||
break;
|
||||
case GAME_STATE_RIVER:
|
||||
#ifdef NEW_LOCAL_GAME
|
||||
if(server.getLanLocal()) delay = LAN_LOCAL_SERVER_DEAL_RIVER_CARD_DELAY_SEC;
|
||||
else delay = SERVER_DEAL_RIVER_CARD_DELAY_SEC;
|
||||
#else
|
||||
delay = SERVER_DEAL_RIVER_CARD_DELAY_SEC;
|
||||
#endif
|
||||
delay = server.GetServerDelayTime().getDealRiverCardsDelay();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -1562,15 +1489,9 @@ ServerGameStateWaitPlayerAction::Enter(boost::shared_ptr<ServerGame> server)
|
||||
{
|
||||
if (server->GetGameData().playerActionTimeoutSec > 0) { // zero means unlimited thinking time
|
||||
#ifdef POKERTH_SERVER_TEST
|
||||
int timeoutSec = SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC;
|
||||
int timeoutSec = server->GetServerDelayTime().getPlayerTimeoutAddDelay();
|
||||
#else
|
||||
#ifdef NEW_LOCAL_GAME
|
||||
int timeoutSec;
|
||||
if(server->getLanLocal()) timeoutSec = server->GetGameData().playerActionTimeoutSec + LAN_LOCAL_SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC;
|
||||
else timeoutSec = server->GetGameData().playerActionTimeoutSec + SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC;
|
||||
#else
|
||||
int timeoutSec = server->GetGameData().playerActionTimeoutSec + SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC;
|
||||
#endif
|
||||
int timeoutSec = server->GetServerDelayTime().getPlayerTimeoutAddDelay() + server->GetGameData().playerActionTimeoutSec;
|
||||
#endif
|
||||
|
||||
server->GetStateTimer1().expires_from_now(seconds(timeoutSec));
|
||||
|
||||
@@ -1353,10 +1353,9 @@ ServerLobbyThread::HandleNetPacketCreateGame(boost::shared_ptr<SessionData> sess
|
||||
session->GetPlayerData()->GetUniqueId(),
|
||||
session->GetPlayerData()->GetDBId(),
|
||||
GetGui(),
|
||||
m_serverConfig));
|
||||
#ifdef NEW_LOCAL_GAME
|
||||
if(m_mode == SERVER_MODE_LAN_LOCAL) game->setLanLocal(true);
|
||||
#endif
|
||||
m_serverConfig,
|
||||
m_mode));
|
||||
|
||||
game->Init();
|
||||
|
||||
// Add game to list of games.
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef SERVERDELAYTIME_H
|
||||
#define SERVERDELAYTIME_H
|
||||
|
||||
#include <game_defs.h>
|
||||
|
||||
class ServerDelayTime
|
||||
{
|
||||
public:
|
||||
ServerDelayTime(const ServerMode mode);
|
||||
|
||||
int getNextGameDelay() const;
|
||||
int getDealFlopCardsDelay() const;
|
||||
int getDealTurnCardsDelay() const;
|
||||
int getDealRiverCardsDelay() const;
|
||||
int getDealAddAllInDelay() const;
|
||||
int getShowCardsDelay() const;
|
||||
int getComputerActionDelay() const;
|
||||
int getPlayerTimeoutAddDelay() const;
|
||||
|
||||
private:
|
||||
|
||||
int nextGameDelay;
|
||||
int dealFlopCardsDelay;
|
||||
int dealTurnCardsDelay;
|
||||
int dealRiverCardsDelay;
|
||||
int dealAddAllInDelay;
|
||||
int showCardsDelay;
|
||||
int computerActionDelay;
|
||||
int playerTimeoutAddDelay;
|
||||
|
||||
};
|
||||
|
||||
#endif // SERVERDELAYTIME_H
|
||||
+5
-14
@@ -39,6 +39,7 @@
|
||||
#include <map>
|
||||
|
||||
#include <net/sessionmanager.h>
|
||||
#include <net/serverdelaytime.h>
|
||||
#include <db/serverdbcallback.h>
|
||||
#include <gui/guiinterface.h>
|
||||
#include <gamedata.h>
|
||||
@@ -57,7 +58,7 @@ class ServerGame : public boost::enable_shared_from_this<ServerGame>
|
||||
public:
|
||||
ServerGame(
|
||||
boost::shared_ptr<ServerLobbyThread> lobbyThread, u_int32_t id, const std::string &name, const std::string &pwd, const GameData &gameData,
|
||||
unsigned adminPlayerId, unsigned creatorPlayerDBId, GuiInterface &gui, ConfigFile &playerConfig);
|
||||
unsigned adminPlayerId, unsigned creatorPlayerDBId, GuiInterface &gui, ConfigFile &playerConfig, const ServerMode mode);
|
||||
virtual ~ServerGame();
|
||||
|
||||
void Init();
|
||||
@@ -126,15 +127,6 @@ public:
|
||||
|
||||
void KickPlayer(unsigned playerId);
|
||||
|
||||
#ifdef NEW_LOCAL_GAME
|
||||
bool getLanLocal() {
|
||||
return lan_local;
|
||||
}
|
||||
void setLanLocal(bool theValue) {
|
||||
lan_local = theValue;
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
struct RankingData {
|
||||
@@ -200,6 +192,7 @@ protected:
|
||||
const SessionManager &GetSessionManager() const;
|
||||
SessionManager &GetSessionManager();
|
||||
ServerDBInterface &GetDatabase();
|
||||
const ServerDelayTime GetServerDelayTime() const;
|
||||
|
||||
private:
|
||||
ServerGame(const ServerGame &other);
|
||||
@@ -235,6 +228,8 @@ private:
|
||||
boost::shared_ptr<ServerDBInterface> m_database;
|
||||
GuiInterface &m_gui;
|
||||
|
||||
ServerDelayTime m_serverDelayTime;
|
||||
|
||||
const GameData m_gameData;
|
||||
StartData m_startData;
|
||||
boost::shared_ptr<Game> m_game;
|
||||
@@ -262,10 +257,6 @@ private:
|
||||
friend class ServerGameStateWaitPlayerAction;
|
||||
friend class ServerGameStateWaitNextHand;
|
||||
|
||||
#ifdef NEW_LOCAL_GAME
|
||||
bool lan_local;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user