Merge branch 'new_local_game' of github.com:/pokerth/pokerth into gocode
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user