Compare commits
16
Commits
android
...
rejoin_rebuy
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d16705cfb | ||
|
|
44c9da90ab | ||
|
|
ecfc8693b2 | ||
|
|
df0a5625f9 | ||
|
|
a333185525 | ||
|
|
7d116d7294 | ||
|
|
0cd9ba6f99 | ||
|
|
99ad7ffd71 | ||
|
|
eccb3f404e | ||
|
|
63fb9bc287 | ||
|
|
1e3253a18d | ||
|
|
2827f7d36c | ||
|
|
9b36c9863c | ||
|
|
20793e24a1 | ||
|
|
382b533488 | ||
|
|
7c538fc436 |
No files matched your search
+5
-4
@@ -8,14 +8,15 @@ Makefile.pokerth_protocol
|
||||
Makefile.pokerth_server
|
||||
Makefile.pokerth_dbofficial
|
||||
bin/
|
||||
chatcleaner
|
||||
/chatcleaner
|
||||
lib/
|
||||
mocs/
|
||||
obj/
|
||||
pokerth
|
||||
/pokerth
|
||||
qrc_pokerth.cpp
|
||||
uics/
|
||||
make.sh
|
||||
gitpush_serverstuff_stable
|
||||
pokerth_server
|
||||
|
||||
.vscode/
|
||||
.project
|
||||
.classpath
|
||||
@@ -112,6 +112,11 @@ message NetGameInfo {
|
||||
required uint32 startMoney = 13;
|
||||
repeated uint32 manualBlinds = 14 [packed = true];
|
||||
optional bool allowSpectators = 15 [default = true];
|
||||
//new data
|
||||
optional bool allowLateReg = 16 [default = false];
|
||||
optional bool allowReentries = 17 [default = false];
|
||||
optional uint32 numReentries = 18 [default = 0];
|
||||
optional uint32 maxTimeLateReg = 19 [default = 0];
|
||||
}
|
||||
|
||||
// Message Part containing player result.
|
||||
@@ -419,6 +424,7 @@ message StartEventMessage {
|
||||
enum StartEventType {
|
||||
startEvent = 0;
|
||||
rejoinEvent = 1;
|
||||
reentryEvent = 2;
|
||||
}
|
||||
required StartEventType startEventType = 2;
|
||||
optional bool fillWithComputerPlayers = 3;
|
||||
@@ -445,6 +451,17 @@ message GameStartRejoinMessage {
|
||||
repeated RejoinPlayerData rejoinPlayerData = 4;
|
||||
}
|
||||
|
||||
message GameStartReentryMessage {
|
||||
required uint32 gameId = 1;
|
||||
required uint32 startDealerPlayerId = 2;
|
||||
required uint32 handNum = 3;
|
||||
message ReentryPlayerData {
|
||||
required uint32 playerId = 1;
|
||||
required uint32 playerMoney = 2;
|
||||
}
|
||||
repeated ReentryPlayerData reentryPlayerData = 4;
|
||||
}
|
||||
|
||||
message HandStartMessage {
|
||||
required uint32 gameId = 1;
|
||||
message PlainCards {
|
||||
@@ -835,6 +852,7 @@ message PokerTHMessage {
|
||||
Type_GameListSpectatorLeftMessage = 79;
|
||||
Type_GameSpectatorJoinedMessage = 80;
|
||||
Type_GameSpectatorLeftMessage = 81;
|
||||
Type_GameStartReentryMessage = 82;
|
||||
}
|
||||
required PokerTHMessageType messageType = 1;
|
||||
|
||||
@@ -919,4 +937,5 @@ message PokerTHMessage {
|
||||
optional GameListSpectatorLeftMessage gameListSpectatorLeftMessage = 80;
|
||||
optional GameSpectatorJoinedMessage gameSpectatorJoinedMessage = 81;
|
||||
optional GameSpectatorLeftMessage gameSpectatorLeftMessage = 82;
|
||||
optional GameStartReentryMessage gameStartReentryMessage = 83;
|
||||
}
|
||||
@@ -42,6 +42,7 @@ HEADERS += src/dbofficial/asyncdbauth.h \
|
||||
src/dbofficial/asyncdbavatarblacklist.h \
|
||||
src/dbofficial/asyncdbadminplayers.h \
|
||||
src/dbofficial/asyncdbblockplayer.h \
|
||||
src/dbofficial/asyncdbplayerlastgames.h \
|
||||
src/dbofficial/dbidmanager.h
|
||||
SOURCES += src/dbofficial/asyncdbauth.cpp \
|
||||
src/dbofficial/asyncdbcreategame.cpp \
|
||||
@@ -60,6 +61,7 @@ SOURCES += src/dbofficial/asyncdbauth.cpp \
|
||||
src/dbofficial/asyncdbavatarblacklist.cpp \
|
||||
src/dbofficial/asyncdbadminplayers.cpp \
|
||||
src/dbofficial/asyncdbblockplayer.cpp \
|
||||
src/dbofficial/asyncdbplayerlastgames.cpp \
|
||||
src/dbofficial/dbidmanager.cpp
|
||||
win32 {
|
||||
DEFINES += _WIN32_WINNT=0x0501
|
||||
|
||||
@@ -312,6 +312,8 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
|
||||
configList.push_back(ConfigInfo("DBServerEncryptionKey", CONFIG_TYPE_STRING, ""));
|
||||
configList.push_back(ConfigInfo("GameNameBadWordList", CONFIG_TYPE_STRING_LIST, "Regex"));
|
||||
configList.push_back(ConfigInfo("ServerRestrictGuestLogin", CONFIG_TYPE_INT, "0"));
|
||||
configList.push_back(ConfigInfo("ServerLimitRankNum", CONFIG_TYPE_INT, "4"));
|
||||
configList.push_back(ConfigInfo("ServerLimitRankPeriod", CONFIG_TYPE_INT, "60"));
|
||||
|
||||
//fill tempList firstTime
|
||||
configBufferList = configList;
|
||||
|
||||
@@ -35,10 +35,11 @@
|
||||
|
||||
#include <core/loghelper.h>
|
||||
#include <iostream>
|
||||
#include <boost/date_time.hpp>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
using namespace boost::posix_time;
|
||||
|
||||
static int g_logLevel = 1;
|
||||
|
||||
@@ -52,20 +53,20 @@ loghelper_init(const std::string & /*logDir*/, int logLevel)
|
||||
void
|
||||
internal_log_err(const string &msg)
|
||||
{
|
||||
cerr << msg;
|
||||
cerr << second_clock::local_time() << " " << msg;
|
||||
}
|
||||
|
||||
void
|
||||
internal_log_msg(const std::string &msg)
|
||||
{
|
||||
if (g_logLevel)
|
||||
cout << msg;
|
||||
cout << second_clock::local_time() << " " << msg;
|
||||
}
|
||||
|
||||
void
|
||||
internal_log_level(const std::string &msg, int logLevel)
|
||||
{
|
||||
if (g_logLevel >= logLevel)
|
||||
cout << msg;
|
||||
cout << second_clock::local_time() << " " << msg;
|
||||
}
|
||||
|
||||
@@ -93,6 +93,11 @@ ServerDBGeneric::SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/,
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBGeneric::SetPlayerLastGames(unsigned /*requestId*/, DB_id /*playerId*/, std::vector<long> /*last_games*/, std::string /*playerIp*/)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBGeneric::EndGame(unsigned /*requestId*/)
|
||||
{
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include <vector>
|
||||
|
||||
typedef unsigned DB_id;
|
||||
#define DB_ID_INVALID 0
|
||||
@@ -45,6 +46,8 @@ struct DBPlayerData {
|
||||
std::string secret;
|
||||
std::string country;
|
||||
std::string last_login;
|
||||
std::string last_games;
|
||||
std::string last_ip;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
|
||||
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName);
|
||||
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place);
|
||||
virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> last_games, std::string playerIp);
|
||||
virtual void EndGame(unsigned requestId);
|
||||
|
||||
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId);
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <db/serverdbcallback.h>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
typedef std::list<DB_id> db_list;
|
||||
|
||||
@@ -57,6 +58,7 @@ public:
|
||||
|
||||
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName) = 0;
|
||||
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place) = 0;
|
||||
virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> last_games, std::string playerIp) = 0;
|
||||
virtual void EndGame(unsigned requestId) = 0;
|
||||
|
||||
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId) = 0;
|
||||
|
||||
@@ -55,6 +55,7 @@ public:
|
||||
|
||||
virtual void AsyncCreateGame(unsigned /*requestId*/, const std::string &/*gameName*/) {}
|
||||
virtual void SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/, unsigned /*place*/) {}
|
||||
virtual void SetPlayerLastGames(unsigned /*requestId*/, DB_id /*playerId*/, std::vector<long> /*last_games*/, std::string /*playerIp*/) {}
|
||||
virtual void EndGame(unsigned /*requestId*/) {}
|
||||
|
||||
virtual void AsyncReportAvatar(unsigned /*requestId*/, unsigned /*replyId*/, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id * /*byPlayerId*/) {}
|
||||
|
||||
@@ -52,19 +52,25 @@ AsyncDBAuth::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/,
|
||||
service.post(boost::bind(&ServerDBCallback::PlayerLoginFailed, &cb, GetId()));
|
||||
} else {
|
||||
int blocked = result[0][2];
|
||||
int active = result[0][5];
|
||||
int active = result[0][7];
|
||||
if ((active != 1) || (blocked != 0)) {
|
||||
service.post(boost::bind(&ServerDBCallback::PlayerLoginBlocked, &cb, GetId()));
|
||||
} else {
|
||||
mysqlpp::String secret(result[0][1]);
|
||||
mysqlpp::String country(result[0][3]);
|
||||
mysqlpp::String last_login(result[0][4]);
|
||||
mysqlpp::String last_games(result[0][5]);
|
||||
mysqlpp::String last_ip(result[0][6]);
|
||||
boost::shared_ptr<DBPlayerData> tmpData(new DBPlayerData);
|
||||
tmpData->id = result[0][0];
|
||||
secret.to_string(tmpData->secret);
|
||||
if (!country.is_null())
|
||||
country.to_string(tmpData->country);
|
||||
last_login.to_string(tmpData->last_login);
|
||||
if (!last_games.is_null())
|
||||
last_games.to_string(tmpData->last_games);
|
||||
if (!last_ip.is_null())
|
||||
last_ip.to_string(tmpData->last_ip);
|
||||
|
||||
service.post(boost::bind(&ServerDBCallback::PlayerLoginSuccess, &cb, GetId(), tmpData));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/asyncdbplayerlastgames.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBPlayerLastGames::AsyncDBPlayerLastGames(unsigned queryId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBPlayerLastGames::~AsyncDBPlayerLastGames()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBPlayerLastGames::HandleResult(mysqlpp::Query &/*query*/, DBIdManager &/*idManager*/, mysqlpp::StoreQueryResult &/*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBPlayerLastGames::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBPlayerLastGames::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database update to block a player. */
|
||||
|
||||
#ifndef _ASYNCDBPLAYERLASTGAMES_H_
|
||||
#define _ASYNCDBPLAYERLASTGAMES_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBPlayerLastGames : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBPlayerLastGames(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBPlayerLastGames();
|
||||
|
||||
virtual void Init(DBIdManager& /*idManager*/) {}
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -42,6 +42,8 @@
|
||||
#define DB_TABLE_PLAYER_COL_ACTIVE "active"
|
||||
#define DB_TABLE_PLAYER_COL_AVATARHASH "avatar_hash"
|
||||
#define DB_TABLE_PLAYER_COL_AVATARTYPE "avatar_mime"
|
||||
#define DB_TABLE_PLAYER_COL_LASTGAMES "last_games"
|
||||
#define DB_TABLE_PLAYER_COL_LASTIP "last_ip"
|
||||
|
||||
#define DB_TABLE_GAME "game"
|
||||
#define DB_TABLE_GAME_COL_ID "idgame"
|
||||
|
||||
@@ -41,12 +41,15 @@
|
||||
#include <dbofficial/asyncdbreportgame.h>
|
||||
#include <dbofficial/asyncdbadminplayers.h>
|
||||
#include <dbofficial/asyncdbblockplayer.h>
|
||||
#include <dbofficial/asyncdbplayerlastgames.h>
|
||||
#include <dbofficial/compositeasyncdbquery.h>
|
||||
#include <dbofficial/db_table_defs.h>
|
||||
#include <ctime>
|
||||
#include <sstream>
|
||||
#include <mysql++.h>
|
||||
|
||||
#include <core/loghelper.h> // @TODO: remove in productive
|
||||
|
||||
#define QUERY_NICK_PREPARE "nick_template"
|
||||
#define QUERY_LOGIN_PREPARE "login_template"
|
||||
#define QUERY_AVATAR_BLACKLIST_PREPARE "avatar_blacklist_template"
|
||||
@@ -58,6 +61,7 @@
|
||||
#define QUERY_REPORT_GAME_PREPARE "report_game_template"
|
||||
#define QUERY_ADMIN_PLAYER_PREPARE "admin_player_template"
|
||||
#define QUERY_BLOCK_PLAYER_PREPARE "block_player_template"
|
||||
#define QUERY_PLAYER_LASTGAMES_PREPARE "player_lastgames_template"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -230,6 +234,33 @@ ServerDBThread::SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> last_games, std::string playerIp)
|
||||
{
|
||||
LOG_ERROR("ServerDBThread::SetPlayerLastGames() entered.");
|
||||
|
||||
std::ostringstream oss;
|
||||
std::copy(last_games.begin(), last_games.end(), std::ostream_iterator<int>(oss, ","));
|
||||
std::string last_gamesFieldValue( oss.str() );
|
||||
list<string> params;
|
||||
ostringstream paramStream;
|
||||
params.push_back(last_gamesFieldValue);
|
||||
params.push_back(playerIp);
|
||||
paramStream << playerId;
|
||||
params.push_back(paramStream.str());
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBPlayerLastGames(
|
||||
requestId,
|
||||
QUERY_PLAYER_LASTGAMES_PREPARE,
|
||||
params));
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
LOG_ERROR("Query posted.");
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::EndGame(unsigned requestId)
|
||||
{
|
||||
@@ -432,7 +463,7 @@ ServerDBThread::EstablishDBConnection()
|
||||
*/
|
||||
prepareNick
|
||||
<< "PREPARE " QUERY_NICK_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "SELECT " DB_TABLE_PLAYER_COL_ID ", AES_DECRYPT(" DB_TABLE_PLAYER_COL_PASSWORD ", ?), " DB_TABLE_PLAYER_COL_VALID ", TRIM(" DB_TABLE_PLAYER_COL_COUNTRY "), " DB_TABLE_PLAYER_COL_LASTLOGIN ", " DB_TABLE_PLAYER_COL_ACTIVE " FROM " DB_TABLE_PLAYER " WHERE " DB_TABLE_PLAYER_COL_USERNAME " = ?";
|
||||
<< "SELECT " DB_TABLE_PLAYER_COL_ID ", AES_DECRYPT(" DB_TABLE_PLAYER_COL_PASSWORD ", ?), " DB_TABLE_PLAYER_COL_VALID ", TRIM(" DB_TABLE_PLAYER_COL_COUNTRY "), " DB_TABLE_PLAYER_COL_LASTLOGIN ", " DB_TABLE_PLAYER_COL_LASTGAMES ", " DB_TABLE_PLAYER_COL_LASTIP ", " DB_TABLE_PLAYER_COL_ACTIVE " FROM " DB_TABLE_PLAYER " WHERE " DB_TABLE_PLAYER_COL_USERNAME " = ?";
|
||||
|
||||
mysqlpp::Query prepareAvatarBlacklist = m_connData->conn.query();
|
||||
prepareAvatarBlacklist
|
||||
@@ -479,12 +510,16 @@ ServerDBThread::EstablishDBConnection()
|
||||
prepareBlockPlayer
|
||||
<< "PREPARE " QUERY_BLOCK_PLAYER_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "UPDATE " DB_TABLE_PLAYER " SET " DB_TABLE_PLAYER_COL_VALID " = ?, " DB_TABLE_PLAYER_COL_ACTIVE " = ? WHERE " DB_TABLE_PLAYER_COL_ID " = ?";
|
||||
mysqlpp::Query preparePlayerLastGames = m_connData->conn.query();
|
||||
preparePlayerLastGames
|
||||
<< "PREPARE " QUERY_PLAYER_LASTGAMES_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "UPDATE " DB_TABLE_PLAYER " SET " DB_TABLE_PLAYER_COL_LASTGAMES " = ?, " DB_TABLE_PLAYER_COL_LASTIP " = ? WHERE " DB_TABLE_PLAYER_COL_ID " = ?";
|
||||
if (!prepareNick.exec() || !prepareAvatarBlacklist.exec() || !prepareLogin.exec() || !prepareCreateGame.exec()
|
||||
|| !prepareEndGame.exec() || !prepareRelation.exec() || !prepareScore.exec() || !prepareReportAvatar.exec()
|
||||
|| !prepareReportGame.exec() || !prepareAdminPlayer.exec() || !prepareBlockPlayer.exec()) {
|
||||
|| !prepareReportGame.exec() || !prepareAdminPlayer.exec() || !prepareBlockPlayer.exec() || !preparePlayerLastGames.exec()) {
|
||||
string tmpError = string(prepareNick.error()) + prepareAvatarBlacklist.error() + prepareLogin.error() + prepareCreateGame.error() +
|
||||
prepareEndGame.error() + prepareRelation.error() + prepareScore.error() + prepareReportAvatar.error() +
|
||||
prepareReportGame.error() + prepareAdminPlayer.error() + prepareBlockPlayer.error();
|
||||
prepareReportGame.error() + prepareAdminPlayer.error() + prepareBlockPlayer.error() + preparePlayerLastGames.error();
|
||||
m_connData->conn.disconnect();
|
||||
m_ioService->post(boost::bind(&ServerDBCallback::ConnectFailed, &m_callback, tmpError));
|
||||
m_permanentError = true;
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
#include <core/thread.h>
|
||||
|
||||
|
||||
struct DBConnectionData;
|
||||
class AsyncDBQuery;
|
||||
|
||||
@@ -66,6 +67,7 @@ public:
|
||||
|
||||
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName);
|
||||
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place);
|
||||
virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> last_games, std::string playerIp);
|
||||
virtual void EndGame(unsigned requestId);
|
||||
|
||||
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId);
|
||||
|
||||
+21
-1
@@ -33,6 +33,7 @@
|
||||
|
||||
#include <enginefactory.h>
|
||||
#include <guiinterface.h>
|
||||
#include <core/loghelper.h>
|
||||
#include "log.h"
|
||||
|
||||
#include "localexception.h"
|
||||
@@ -87,6 +88,9 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
// create player
|
||||
player_i = playerDataList.begin();
|
||||
player_end = playerDataList.end();
|
||||
|
||||
LOG_MSG("Starting game... PLAYERS:");
|
||||
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
|
||||
string myName;
|
||||
@@ -120,7 +124,6 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
activePlayerList->push_back(tmpPlayer);
|
||||
}
|
||||
(*runningPlayerList) = (*activePlayerList);
|
||||
|
||||
}
|
||||
|
||||
currentBoard->setPlayerLists(seatsList, activePlayerList, runningPlayerList);
|
||||
@@ -312,3 +315,20 @@ void Game::raiseBlinds()
|
||||
currentSmallBlind = min(currentSmallBlind,startQuantityPlayers*startCash/2);
|
||||
}
|
||||
}
|
||||
|
||||
boost::shared_ptr<PlayerInterface>
|
||||
Game::addNewPlayer(boost::shared_ptr<PlayerData> player)
|
||||
{
|
||||
|
||||
// TODO (albmed): We must think how:
|
||||
// also add to seatList (or replace a free slot if 10 players tops)
|
||||
|
||||
int i = 0; // ERROR. Thik about approppiate value (probably this should be set after a seat is found)
|
||||
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = myFactory->createPlayer(i, player->GetUniqueId(), player->GetType(), player->GetName(), player->GetAvatarFile(), player->GetStartCash(), startQuantityPlayers > i, PLAYER_TYPE_HUMAN, 0);
|
||||
tmpPlayer->setIsSessionActive(true); // ??? Really ???
|
||||
tmpPlayer->setMyGuid(player->GetGuid());
|
||||
|
||||
|
||||
return tmpPlayer;
|
||||
}
|
||||
@@ -142,6 +142,8 @@ public:
|
||||
boost::shared_ptr<PlayerInterface> getPlayerByName(const std::string &name);
|
||||
boost::shared_ptr<PlayerInterface> getCurrentPlayer();
|
||||
|
||||
boost::shared_ptr<PlayerInterface> addNewPlayer(boost::shared_ptr<PlayerData> player);
|
||||
|
||||
void raiseBlinds();
|
||||
|
||||
private:
|
||||
|
||||
@@ -66,7 +66,12 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
|
||||
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
|
||||
50, 51
|
||||
};
|
||||
|
||||
// Shuffle three times
|
||||
Tools::ShuffleArrayNonDeterministic(cardsArray, NumCards);
|
||||
Tools::ShuffleArrayNonDeterministic(cardsArray, NumCards);
|
||||
Tools::ShuffleArrayNonDeterministic(cardsArray, NumCards);
|
||||
|
||||
int tempBoardArray[5];
|
||||
int tempPlayerArray[2];
|
||||
int tempPlayerAndBoardArray[7];
|
||||
|
||||
@@ -93,6 +93,12 @@ struct GameData {
|
||||
int guiSpeed;
|
||||
int delayBetweenHandsSec;
|
||||
int playerActionTimeoutSec;
|
||||
|
||||
// new data
|
||||
bool allowLateReg;
|
||||
bool allowReentries;
|
||||
int numReentries;
|
||||
int maxTimeLateReg;
|
||||
};
|
||||
|
||||
struct GameInfo {
|
||||
|
||||
@@ -6,246 +6,256 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>293</width>
|
||||
<height>410</height>
|
||||
<width>395</width>
|
||||
<height>573</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Create Internet Game</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Internet Game Settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_23">
|
||||
<property name="text">
|
||||
<string>Default game name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_gameName">
|
||||
<property name="maxLength">
|
||||
<number>48</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Game type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_gameType">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Standard</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/pokerth.qrc">
|
||||
<normaloff>:/gfx/player_play.png</normaloff>:/gfx/player_play.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Registered players only</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/pokerth.qrc">
|
||||
<normaloff>:/gfx/registered.png</normaloff>:/gfx/registered.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Invited players only</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/pokerth.qrc">
|
||||
<normaloff>:/gfx/list_add_user.png</normaloff>:/gfx/list_add_user.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Ranking game</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/pokerth.qrc">
|
||||
<normaloff>:/gfx/cup.png</normaloff>:/gfx/cup.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_Password">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/pokerth.qrc">
|
||||
<normaloff>:/gfx/lock.png</normaloff>:/gfx/lock.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_Password">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>9</y>
|
||||
<width>388</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Internet Game Settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_23">
|
||||
<property name="text">
|
||||
<string>Default game name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_gameName">
|
||||
<property name="maxLength">
|
||||
<number>48</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Maximum number of players:</string>
|
||||
<string>Game type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_gameType">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Standard</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/pokerth.qrc">
|
||||
<normaloff>:/gfx/player_play.png</normaloff>:/gfx/player_play.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Registered players only</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/pokerth.qrc">
|
||||
<normaloff>:/gfx/registered.png</normaloff>:/gfx/registered.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Invited players only</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/pokerth.qrc">
|
||||
<normaloff>:/gfx/list_add_user.png</normaloff>:/gfx/list_add_user.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Ranking game</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/pokerth.qrc">
|
||||
<normaloff>:/gfx/cup.png</normaloff>:/gfx/cup.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_Password">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/pokerth.qrc">
|
||||
<normaloff>:/gfx/lock.png</normaloff>:/gfx/lock.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_Password">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBox_allowSpectators">
|
||||
<property name="text">
|
||||
<string>Allow spectators to watch the game</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_allowLateReg">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Allow late registration</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_reentries">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Allow re-entries</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_numReentries">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Maximum number of re-entries:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBox_quantityPlayers</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_quantityPlayers">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_numReentries">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Start Cash:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBox_startCash</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_startCash">
|
||||
<property name="suffix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string>$</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>2000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_blinds">
|
||||
<property name="title">
|
||||
<string>Blinds</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="radioButton_useSavedBlindsSettings">
|
||||
<property name="text">
|
||||
<string>Use saved blinds settings</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="radioButton_changeBlindsSettings">
|
||||
<property name="text">
|
||||
<string>Change blinds settings ...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_timeLateReg">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Timeout for player action:</string>
|
||||
<string>Maximum time for late registration/re-entry:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBox_netTimeOutPlayerAction</cstring>
|
||||
<cstring>spinBox_quantityPlayers</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_netTimeOutPlayerAction">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>13</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_timeLateReg">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> s</string>
|
||||
<string>min</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>5</number>
|
||||
@@ -254,99 +264,208 @@
|
||||
<number>60</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Delay between hands:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBox_netDelayBetweenHands</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_netDelayBetweenHands">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> s</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>7</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBox_allowSpectators">
|
||||
<property name="text">
|
||||
<string>Allow spectators to watch the game</string>
|
||||
<number>15</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Maximum number of players:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBox_quantityPlayers</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_quantityPlayers">
|
||||
<property name="minimum">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Start Cash:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBox_startCash</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_startCash">
|
||||
<property name="suffix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string>€</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_blinds">
|
||||
<property name="title">
|
||||
<string>Blinds</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>181</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_createGame">
|
||||
<property name="text">
|
||||
<string>Create Game</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="radioButton_useSavedBlindsSettings">
|
||||
<property name="text">
|
||||
<string>Use saved blinds settings</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="radioButton_changeBlindsSettings">
|
||||
<property name="text">
|
||||
<string>Change blinds settings ...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Timeout for player action:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBox_netTimeOutPlayerAction</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_netTimeOutPlayerAction">
|
||||
<property name="suffix">
|
||||
<string> s</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>60</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Delay between hands:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBox_netDelayBetweenHands</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_netDelayBetweenHands">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> s</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>7</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>540</y>
|
||||
<width>381</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="_2">
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>115</width>
|
||||
<height>17</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_createGame">
|
||||
<property name="text">
|
||||
<string>Create Game</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>lineEdit_gameName</tabstop>
|
||||
|
||||
@@ -68,6 +68,11 @@ createInternetGameDialogImpl::createInternetGameDialogImpl(QWidget *parent, Conf
|
||||
connect( pushButton_createGame, SIGNAL( clicked() ), this, SLOT( createGame() ) );
|
||||
connect( checkBox_Password, SIGNAL( toggled(bool) ), this, SLOT( clearGamePassword(bool)) );
|
||||
connect( comboBox_gameType, SIGNAL(currentIndexChanged(int)), this, SLOT( gameTypeChanged() ) );
|
||||
|
||||
// new connections
|
||||
connect(checkBox_allowLateReg, SIGNAL(toggled(bool)), this, SLOT(switchAllowReg(bool)));
|
||||
connect(checkBox_reentries, SIGNAL(toggled(bool)), this, SLOT(switchReentries(bool)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -165,6 +170,7 @@ void createInternetGameDialogImpl::gameTypeChanged()
|
||||
raiseMode->hide();
|
||||
checkBox_allowSpectators->setEnabled(true);
|
||||
checkBox_allowSpectators->setChecked(myConfig->readConfigInt("InternetGameAllowSpectators"));
|
||||
switchLateReg(true); // allow late reg & reentries
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -180,6 +186,7 @@ void createInternetGameDialogImpl::gameTypeChanged()
|
||||
raiseMode->hide();
|
||||
checkBox_allowSpectators->setEnabled(true);
|
||||
checkBox_allowSpectators->setChecked(myConfig->readConfigInt("InternetGameAllowSpectators"));
|
||||
switchLateReg(true); // allow late reg & reentries
|
||||
}
|
||||
break;
|
||||
case GAME_TYPE_INVITE_ONLY-1: {
|
||||
@@ -195,6 +202,7 @@ void createInternetGameDialogImpl::gameTypeChanged()
|
||||
raiseMode->hide();
|
||||
checkBox_allowSpectators->setEnabled(true);
|
||||
checkBox_allowSpectators->setChecked(myConfig->readConfigInt("InternetGameAllowSpectators"));
|
||||
switchLateReg(false); // don't allow late reg & reentries
|
||||
}
|
||||
break;
|
||||
case GAME_TYPE_RANKING-1: {
|
||||
@@ -211,6 +219,7 @@ void createInternetGameDialogImpl::gameTypeChanged()
|
||||
raiseMode->show();
|
||||
checkBox_allowSpectators->setDisabled(true);
|
||||
checkBox_allowSpectators->setChecked(true);
|
||||
switchLateReg(false); // don't allow late reg & reentries
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -252,6 +261,51 @@ void createInternetGameDialogImpl::gameTypeChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void createInternetGameDialogImpl::switchLateReg(bool enable) {
|
||||
if (enable) {
|
||||
checkBox_allowLateReg->setDisabled(false);
|
||||
checkBox_allowLateReg->setChecked(true);
|
||||
checkBox_reentries->setDisabled(false);
|
||||
checkBox_reentries->setChecked(true);
|
||||
}
|
||||
else {
|
||||
checkBox_allowLateReg->setDisabled(true);
|
||||
checkBox_allowLateReg->setChecked(false);
|
||||
checkBox_reentries->setDisabled(true);
|
||||
checkBox_reentries->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
void createInternetGameDialogImpl::switchReentries(bool enable) {
|
||||
if (enable) {
|
||||
label_numReentries->setDisabled(false);
|
||||
spinBox_numReentries->setDisabled(false);
|
||||
label_timeLateReg->setDisabled(false);
|
||||
spinBox_timeLateReg->setDisabled(false);
|
||||
}
|
||||
else {
|
||||
label_numReentries->setDisabled(true);
|
||||
spinBox_numReentries->setDisabled(true);
|
||||
if (!(checkBox_allowLateReg->isEnabled() && checkBox_allowLateReg->isChecked())) {
|
||||
label_timeLateReg->setDisabled(true);
|
||||
spinBox_timeLateReg->setDisabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void createInternetGameDialogImpl::switchAllowReg(bool enable) {
|
||||
if (enable) {
|
||||
label_timeLateReg->setDisabled(false);
|
||||
spinBox_timeLateReg->setDisabled(false);
|
||||
}
|
||||
else {
|
||||
if (!(checkBox_reentries->isEnabled() && checkBox_reentries->isChecked())) {
|
||||
label_timeLateReg->setDisabled(true);
|
||||
spinBox_timeLateReg->setDisabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool createInternetGameDialogImpl::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
#ifdef ANDROID
|
||||
|
||||
@@ -67,8 +67,13 @@ public slots:
|
||||
void gameTypeChanged();
|
||||
|
||||
void callChangeBlindsDialog(bool);
|
||||
|
||||
void switchAllowReg(bool);
|
||||
void switchReentries(bool);
|
||||
private:
|
||||
|
||||
void switchLateReg(bool);
|
||||
|
||||
ConfigFile *myConfig;
|
||||
changeCompleteBlindsDialogImpl *myChangeCompleteBlindsDialog;
|
||||
bool currentGuestMode;
|
||||
|
||||
@@ -352,6 +352,17 @@ void gameLobbyDialogImpl::createGame()
|
||||
}
|
||||
}
|
||||
|
||||
if (myCreateInternetGameDialog->checkBox_allowLateReg->isEnabled() && myCreateInternetGameDialog->checkBox_allowLateReg->isChecked()) {
|
||||
gameData.allowLateReg = true;
|
||||
gameData.maxTimeLateReg = myCreateInternetGameDialog->spinBox_timeLateReg->value();
|
||||
}
|
||||
if (myCreateInternetGameDialog->checkBox_reentries->isEnabled() && myCreateInternetGameDialog->checkBox_reentries->isChecked()) {
|
||||
gameData.allowReentries = true;
|
||||
gameData.numReentries = myCreateInternetGameDialog->spinBox_numReentries->value();
|
||||
gameData.maxTimeLateReg = myCreateInternetGameDialog->spinBox_timeLateReg->value();
|
||||
}
|
||||
|
||||
|
||||
gameData.guiSpeed = myConfig->readConfigInt("GameSpeed");
|
||||
gameData.delayBetweenHandsSec = myCreateInternetGameDialog->spinBox_netDelayBetweenHands->value();
|
||||
gameData.playerActionTimeoutSec = myCreateInternetGameDialog->spinBox_netTimeOutPlayerAction->value();
|
||||
|
||||
@@ -2222,13 +2222,13 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>94</height>
|
||||
<height>114</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>94</height>
|
||||
<height>114</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
@@ -2631,6 +2631,13 @@ p, li { white-space: pre-wrap; }
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="5">
|
||||
<widget class="QLabel" name="label_WinningCombination">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
#include "carddeckstylereader.h"
|
||||
#include <gamedata.h>
|
||||
#include <generic/serverguiwrapper.h>
|
||||
|
||||
#include <core/loghelper.h>
|
||||
#include <net/socket_msg.h>
|
||||
|
||||
#include <cmath>
|
||||
@@ -81,6 +81,8 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent)
|
||||
{
|
||||
int i;
|
||||
|
||||
LOG_MSG("starting gameTableImpl");
|
||||
|
||||
// this->setStyle(new QPlastiqueStyle);
|
||||
|
||||
//for statistic development
|
||||
@@ -870,6 +872,8 @@ void gameTableImpl::initGui(int speed)
|
||||
//kill running Singleshots!!!
|
||||
stopTimer();
|
||||
|
||||
LOG_MSG("starting gameTableImpl::initGui");
|
||||
|
||||
label_handNumber->setText(HandString+":");
|
||||
label_gameNumber->setText(GameString+":");
|
||||
|
||||
@@ -934,6 +938,7 @@ void gameTableImpl::initGui(int speed)
|
||||
|
||||
#endif
|
||||
|
||||
LOG_MSG("ending gameTableImpl::initGui");
|
||||
}
|
||||
|
||||
boost::shared_ptr<Session> gameTableImpl::getSession()
|
||||
@@ -2530,6 +2535,7 @@ void gameTableImpl::postRiverRunAnimation2()
|
||||
|
||||
if(nonfoldPlayersCounter!=1) {
|
||||
|
||||
label_WinningCombination->setText(CardsValue::determineHandName(currentGame->getCurrentHand()->getCurrentBeRo()->getHighestCardsValue(), activePlayerList).c_str());
|
||||
if(!flipHolecardsAllInAlreadyDone) {
|
||||
|
||||
for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) {
|
||||
@@ -3017,6 +3023,8 @@ void gameTableImpl::nextRoundCleanGui()
|
||||
resetMyButtonsCheckStateMemory();
|
||||
clearMyButtons();
|
||||
pushButton_showMyCards->hide();
|
||||
label_WinningCombination->clear();
|
||||
update();
|
||||
}
|
||||
|
||||
void gameTableImpl::stopTimer()
|
||||
@@ -4117,6 +4125,7 @@ void gameTableImpl::refreshGameTableStyle()
|
||||
myGameTableStyle->setBigFontBoardStyle(textLabel_handLabel);
|
||||
myGameTableStyle->setBigFontBoardStyle(label_Pot);
|
||||
#endif
|
||||
myGameTableStyle->setBigFontBoardStyle(label_WinningCombination);
|
||||
myGameTableStyle->setCardHolderStyle(label_CardHolder0,0);
|
||||
myGameTableStyle->setCardHolderStyle(label_CardHolder1,0);
|
||||
myGameTableStyle->setCardHolderStyle(label_CardHolder2,0);
|
||||
|
||||
@@ -2745,13 +2745,13 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>390</width>
|
||||
<height>82</height>
|
||||
<height>102</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>390</width>
|
||||
<height>82</height>
|
||||
<height>102</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
@@ -3039,6 +3039,13 @@ p, li { white-space: pre-wrap; }
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_WinningCombination">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "configfile.h"
|
||||
#include "soundevents.h"
|
||||
#include <net/socket_msg.h>
|
||||
#include <core/loghelper.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -46,6 +47,7 @@ using namespace std;
|
||||
GuiWrapper::GuiWrapper(ConfigFile *c, startWindowImpl *s) : myGuiLog(NULL), myW(NULL), myConfig(c), myStartWindow(s)
|
||||
{
|
||||
|
||||
LOG_MSG("starting GuiWrapper");
|
||||
|
||||
myW = new gameTableImpl(myConfig);
|
||||
myGuiLog = new guiLog(myW, myConfig);
|
||||
@@ -63,6 +65,7 @@ GuiWrapper::~GuiWrapper()
|
||||
|
||||
void GuiWrapper::initGui(int speed)
|
||||
{
|
||||
LOG_MSG("starting GuiWrapper::initGui");
|
||||
myW->signalInitGui(speed);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <gamedata.h>
|
||||
#include <generic/serverguiwrapper.h>
|
||||
#include <net/socket_msg.h>
|
||||
#include <core/loghelper.h>
|
||||
#include "tools.h"
|
||||
#include "session.h"
|
||||
#include "game.h"
|
||||
@@ -72,6 +73,8 @@ startWindowImpl::startWindowImpl(ConfigFile *c, Log *l)
|
||||
: myConfig(c), myLog(l), msgBoxOutdatedVersionActive(false)
|
||||
{
|
||||
|
||||
LOG_MSG("starting startWindowImpl");
|
||||
|
||||
myGuiInterface.reset(new GuiWrapper(myConfig, this));
|
||||
{
|
||||
mySession.reset(new Session(myGuiInterface.get(), myConfig, myLog));
|
||||
|
||||
@@ -105,7 +105,7 @@ AsioReceiveBuffer::ScanPackets(boost::shared_ptr<SessionData> session)
|
||||
size_t packetSize = ntohl(nativeVal);
|
||||
if (packetSize > MAX_PACKET_SIZE) {
|
||||
recvBufUsed = 0;
|
||||
LOG_ERROR("Session " << session->GetId() << " - Invalid packet size: " << packetSize);
|
||||
LOG_ERROR(session->GetClientAddr() << "Session " << session->GetId() << " - Invalid packet size: " << packetSize);
|
||||
} else if (recvBufUsed >= packetSize + NET_HEADER_SIZE) {
|
||||
try {
|
||||
tmpPacket = NetPacket::Create(&recvBuf[NET_HEADER_SIZE], packetSize);
|
||||
@@ -118,7 +118,7 @@ AsioReceiveBuffer::ScanPackets(boost::shared_ptr<SessionData> session)
|
||||
} catch (const exception &e) {
|
||||
// Reset buffer on error.
|
||||
recvBufUsed = 0;
|
||||
LOG_ERROR("Session " << session->GetId() << " - " << e.what());
|
||||
LOG_ERROR(session->GetClientAddr() << "Session " << session->GetId() << " - " << e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ AsioReceiveBuffer::ScanPackets(boost::shared_ptr<SessionData> session)
|
||||
if (validator.IsValidPacket(*tmpPacket)) {
|
||||
receivedPackets.push_back(tmpPacket);
|
||||
} else {
|
||||
LOG_ERROR("Session " << session->GetId() << " - Invalid packet: " << tmpPacket->GetMsg()->messagetype());
|
||||
LOG_ERROR(session->GetClientAddr() << "Session " << session->GetId() << " - Invalid packet: " << tmpPacket->GetMsg()->messagetype());
|
||||
}
|
||||
} else {
|
||||
dataAvailable = false;
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
#include <core/crypthelper.h>
|
||||
#include <qttoolsinterface.h>
|
||||
|
||||
#include <core/loghelper.h>
|
||||
|
||||
#include <game.h>
|
||||
#include <playerinterface.h>
|
||||
|
||||
@@ -1518,6 +1520,14 @@ ClientStateWaitStart::InternalHandlePacket(boost::shared_ptr<ClientThread> clien
|
||||
if (!tmpPlayer)
|
||||
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||
tmpPlayer->SetNumber(i);
|
||||
|
||||
LOG_MSG("PlayerData: {playerId, name, GUID, seat, number} -> {" <<
|
||||
playerId << "," <<
|
||||
tmpPlayer->GetName() << "," <<
|
||||
tmpPlayer->GetGuid() << "," <<
|
||||
i << "," <<
|
||||
tmpPlayer->GetNumber()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw ClientException(__FILE__, __LINE__, ERR_NET_INVALID_PLAYER_COUNT, 0);
|
||||
@@ -1552,6 +1562,54 @@ ClientStateWaitStart::InternalHandlePacket(boost::shared_ptr<ClientThread> clien
|
||||
throw ClientException(__FILE__, __LINE__, ERR_NET_INVALID_PLAYER_COUNT, 0);
|
||||
}
|
||||
client->InitGame();
|
||||
|
||||
|
||||
LOG_MSG("Game created. Let's LOG:");
|
||||
// LOG seats
|
||||
{
|
||||
boost::shared_ptr<Game> tmpGame = client->GetGame();
|
||||
PlayerListConstIterator it_c;
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer;
|
||||
PlayerList seatsList = tmpGame->getSeatsList();
|
||||
PlayerList activePlayerList = tmpGame->getActivePlayerList();
|
||||
PlayerList runningPlayerList = tmpGame->getRunningPlayerList();
|
||||
|
||||
LOG_MSG("\t === Player seats === ");
|
||||
for (it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c) {
|
||||
tmpPlayer = *it_c;
|
||||
|
||||
LOG_MSG("\t\t {ID, name, GUID; UID} => " <<
|
||||
tmpPlayer->getMyID() << ", " <<
|
||||
tmpPlayer->getMyName() << ", " <<
|
||||
tmpPlayer->getMyUniqueID() << ", " <<
|
||||
tmpPlayer->getMyGuid());
|
||||
}
|
||||
|
||||
|
||||
LOG_MSG("\t === Player active List === ");
|
||||
for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) {
|
||||
tmpPlayer = *it_c;
|
||||
|
||||
LOG_MSG("\t\t {ID, name, GUID; UID} => " <<
|
||||
tmpPlayer->getMyID() << ", " <<
|
||||
tmpPlayer->getMyName() << ", " <<
|
||||
tmpPlayer->getMyUniqueID() << ", " <<
|
||||
tmpPlayer->getMyGuid());
|
||||
}
|
||||
|
||||
LOG_MSG("\t === Player running List === ");
|
||||
for (it_c=runningPlayerList->begin(); it_c!=runningPlayerList->end(); ++it_c) {
|
||||
tmpPlayer = *it_c;
|
||||
|
||||
LOG_MSG("\t\t {ID, name, GUID; UID} => " <<
|
||||
tmpPlayer->getMyID() << ", " <<
|
||||
tmpPlayer->getMyName() << ", " <<
|
||||
tmpPlayer->getMyUniqueID() << ", " <<
|
||||
tmpPlayer->getMyGuid());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
client->GetGame()->setCurrentHandID(tmpHandId);
|
||||
// We need to remove the temporary player data objects after creating the game.
|
||||
BOOST_FOREACH(unsigned tmpPlayerId, tmpPlayerList) {
|
||||
@@ -1705,6 +1763,8 @@ ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client
|
||||
client->GetCallback().SignalNetClientPostRiverShowCards(r.playerid());
|
||||
client->GetClientLog()->logHoleCardsHandName(client->GetGame()->getActivePlayerList(), tmpPlayer, true);
|
||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_PlayerIdChangedMessage) {
|
||||
|
||||
LOG_MSG("performing rejoin");
|
||||
boost::shared_ptr<Game> curGame = client->GetGame();
|
||||
if (curGame) {
|
||||
// Perform Id change.
|
||||
@@ -1712,6 +1772,9 @@ ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(idChanged.oldplayerid());
|
||||
if (!tmpPlayer)
|
||||
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||
|
||||
LOG_MSG("Player rejoins with " << tmpPlayer->getMyCash());
|
||||
|
||||
tmpPlayer->setMyUniqueID(idChanged.newplayerid());
|
||||
// This player is now active again.
|
||||
tmpPlayer->setMyStayOnTableStatus(true);
|
||||
|
||||
@@ -113,6 +113,10 @@ NetPacket::SetGameData(const GameData &inData, NetGameInfo &outData)
|
||||
outData.set_endraisesmallblindvalue(inData.afterMBAlwaysRaiseValue);
|
||||
outData.set_firstsmallblind(inData.firstSmallBlind);
|
||||
outData.set_startmoney(inData.startMoney);
|
||||
outData.set_allowlatereg(inData.allowLateReg);
|
||||
outData.set_allowreentries(inData.allowReentries);
|
||||
outData.set_maxtimelatereg(inData.maxTimeLateReg);
|
||||
outData.set_numreentries(inData.numReentries);
|
||||
|
||||
BOOST_FOREACH(int manualBlind, inData.manualBlindsList) {
|
||||
outData.add_manualblinds(manualBlind);
|
||||
@@ -141,6 +145,10 @@ NetPacket::GetGameData(const NetGameInfo &inData, GameData &outData)
|
||||
outData.firstSmallBlind = inData.firstsmallblind();
|
||||
outData.afterMBAlwaysRaiseValue = inData.endraisesmallblindvalue();
|
||||
outData.startMoney = inData.startmoney();
|
||||
outData.allowLateReg = inData.allowlatereg();
|
||||
outData.allowReentries = inData.allowreentries();
|
||||
outData.numReentries = inData.numreentries();
|
||||
outData.maxTimeLateReg = inData.maxtimelatereg();
|
||||
|
||||
for (int i = 0; i < numManualBlinds; i++) {
|
||||
outData.manualBlindsList.push_back(static_cast<int>(inData.manualblinds(i)));
|
||||
|
||||
@@ -94,6 +94,7 @@ NetPacketValidator::NetPacketValidator()
|
||||
m_validationMap.insert(make_pair(PokerTHMessage_PokerTHMessageType_Type_StartEventAckMessage, ValidateStartEventAckMessage));
|
||||
m_validationMap.insert(make_pair(PokerTHMessage_PokerTHMessageType_Type_GameStartInitialMessage, ValidateGameStartInitialMessage));
|
||||
m_validationMap.insert(make_pair(PokerTHMessage_PokerTHMessageType_Type_GameStartRejoinMessage, ValidateGameStartRejoinMessage));
|
||||
m_validationMap.insert(make_pair(PokerTHMessage_PokerTHMessageType_Type_GameStartReentryMessage, ValidateGameStartReentryMessage));
|
||||
m_validationMap.insert(make_pair(PokerTHMessage_PokerTHMessageType_Type_HandStartMessage, ValidateHandStartMessage));
|
||||
m_validationMap.insert(make_pair(PokerTHMessage_PokerTHMessageType_Type_PlayersTurnMessage, ValidatePlayersTurnMessage));
|
||||
m_validationMap.insert(make_pair(PokerTHMessage_PokerTHMessageType_Type_MyActionRequestMessage, ValidateMyActionRequestMessage));
|
||||
@@ -695,6 +696,22 @@ NetPacketValidator::ValidateGameStartRejoinMessage(const NetPacket &packet)
|
||||
return retVal;
|
||||
}
|
||||
|
||||
bool
|
||||
NetPacketValidator::ValidateGameStartReentryMessage(const NetPacket &packet)
|
||||
{
|
||||
bool retVal = false;
|
||||
if (packet.GetMsg()->has_gamestartreentrymessage()) {
|
||||
const GameStartReentryMessage &msg = packet.GetMsg()->gamestartreentrymessage();
|
||||
if (msg.gameid() != 0
|
||||
&& msg.startdealerplayerid() != 0
|
||||
&& msg.handnum() != 0
|
||||
&& VALIDATE_LIST_SIZE(msg.reentryplayerdata(), 2, 10)) {
|
||||
|
||||
retVal = true;
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
bool
|
||||
NetPacketValidator::ValidateHandStartMessage(const NetPacket &packet)
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <net/serveracceptwebhelper.h>
|
||||
#include <net/sessiondata.h>
|
||||
#include <net/webreceivebuffer.h>
|
||||
@@ -58,10 +59,10 @@ ServerAcceptWebHelper::Listen(unsigned serverPort, bool /*ipv6*/, const std::str
|
||||
|
||||
m_webSocketServer->init_asio(m_ioService.get());
|
||||
|
||||
m_webSocketServer->set_validate_handler(boost::bind(boost::mem_fn(&ServerAcceptWebHelper::validate), this, _1));
|
||||
m_webSocketServer->set_open_handler(boost::bind(boost::mem_fn(&ServerAcceptWebHelper::on_open), this, _1));
|
||||
m_webSocketServer->set_close_handler(boost::bind(boost::mem_fn(&ServerAcceptWebHelper::on_close), this, _1));
|
||||
m_webSocketServer->set_message_handler(boost::bind(boost::mem_fn(&ServerAcceptWebHelper::on_message), this, _1, _2));
|
||||
m_webSocketServer->set_validate_handler(boost::bind(boost::mem_fn(&ServerAcceptWebHelper::validate), this, boost::placeholders::_1));
|
||||
m_webSocketServer->set_open_handler(boost::bind(boost::mem_fn(&ServerAcceptWebHelper::on_open), this, boost::placeholders::_1));
|
||||
m_webSocketServer->set_close_handler(boost::bind(boost::mem_fn(&ServerAcceptWebHelper::on_close), this, boost::placeholders::_1));
|
||||
m_webSocketServer->set_message_handler(boost::bind(boost::mem_fn(&ServerAcceptWebHelper::on_message), this, boost::placeholders::_1,boost::placeholders:: _2));
|
||||
|
||||
m_webSocketServer->listen(serverPort);
|
||||
m_webSocketServer->start_accept();
|
||||
|
||||
@@ -66,15 +66,28 @@ 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)
|
||||
: 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_stateTimer1(lobbyThread->GetIOService()), m_stateTimer2(lobbyThread->GetIOService()), m_allowEntryTimer(lobbyThread->GetIOService()),
|
||||
m_isNameReported(false), m_isLateRegAllowed(false)
|
||||
{
|
||||
LOG_VERBOSE("Game object " << GetId() << " created.");
|
||||
|
||||
// TODO (albmed): Next is wrong!!
|
||||
// If game is restarted without being created, m_isLateRegAllowed probably will be always false because its timer would already be cancelled in previous game and object is not created again.
|
||||
// So, constructor is not called again.
|
||||
// m_isLateRegAllowed should probably be set on Init() function or in ServerGameStateInit::Enter. To be checked!!
|
||||
|
||||
|
||||
// set late reg allowed
|
||||
if ((m_gameData.gameType == GAME_TYPE_NORMAL || m_gameData.gameType == GAME_TYPE_REGISTERED_ONLY) &&
|
||||
(m_gameData.allowLateReg || m_gameData.allowReentries) &&
|
||||
m_gameData.maxTimeLateReg > 0) m_isLateRegAllowed = true;
|
||||
|
||||
LOG_MSG("m_isLateRegAllowed: " << std::boolalpha << m_isLateRegAllowed);
|
||||
}
|
||||
|
||||
ServerGame::~ServerGame()
|
||||
@@ -92,6 +105,7 @@ void
|
||||
ServerGame::Exit()
|
||||
{
|
||||
m_voteKickTimer.cancel();
|
||||
m_allowEntryTimer.cancel();
|
||||
SetState(ServerGameStateFinal::Instance());
|
||||
}
|
||||
|
||||
@@ -293,11 +307,13 @@ ServerGame::TimerVoteKick(const boost::system::error_code &ec)
|
||||
PlayerDataList
|
||||
ServerGame::InternalStartGame()
|
||||
{
|
||||
LOG_ERROR("InternalStartGame() entered.");
|
||||
// Initialize the game.
|
||||
PlayerDataList playerData(GetFullPlayerDataList());
|
||||
|
||||
if (playerData.size() >= 2) {
|
||||
// Set DB Backend.
|
||||
// @TODO: check for wec or bbc game with bbcbot as creator
|
||||
if (GetGameData().gameType == GAME_TYPE_RANKING)
|
||||
m_database = GetLobbyThread().GetDatabase();
|
||||
else
|
||||
@@ -346,6 +362,14 @@ ServerGame::InternalStartGame()
|
||||
|
||||
GetDatabase().AsyncCreateGame(GetId(), GetName());
|
||||
InitRankingMap(playerData);
|
||||
|
||||
// @TODO: here to save last_games with mysql per player
|
||||
|
||||
if (GetGameData().gameType == GAME_TYPE_RANKING)
|
||||
StoreLastGames(playerData);
|
||||
|
||||
setEntries(playerData);
|
||||
|
||||
}
|
||||
return playerData;
|
||||
}
|
||||
@@ -442,6 +466,26 @@ ServerGame::StoreAndResetRanking()
|
||||
m_rankingMap.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ServerGame::StoreLastGames(const PlayerDataList &playerDataList)
|
||||
{
|
||||
// Store players lastgames in database.
|
||||
PlayerDataList::const_iterator i = playerDataList.begin();
|
||||
PlayerDataList::const_iterator end = playerDataList.end();
|
||||
while (i != end) {
|
||||
boost::shared_ptr<PlayerData> tmpPlayer(*i);
|
||||
// tmpPlayer->GetUniqueId()
|
||||
tmpPlayer->AddPlayerLastGame((long)time(NULL));
|
||||
LOG_ERROR("TimeStamp stored: " << tmpPlayer->GetPlayerLastGames().back());
|
||||
std::vector<long> last_games = tmpPlayer->GetPlayerLastGames();
|
||||
LOG_ERROR("Ready for storing vector for player " << tmpPlayer->GetDBId() << " - lastGameTs " << last_games.back());
|
||||
if(tmpPlayer->GetDBId() != DB_ID_INVALID){
|
||||
GetDatabase().SetPlayerLastGames(GetId(), tmpPlayer->GetDBId(), last_games, GetSessionManager().GetSessionByUniquePlayerId(tmpPlayer->GetUniqueId())->GetClientAddr());
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerGame::RemoveAutoLeavePlayers()
|
||||
{
|
||||
@@ -464,6 +508,7 @@ ServerGame::InternalEndGame()
|
||||
StoreAndResetRanking();
|
||||
m_game.reset();
|
||||
m_numJoinsPerPlayer.clear();
|
||||
m_numEntriesPlayer.clear();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -750,6 +795,13 @@ ServerGame::AddRejoinPlayer(unsigned playerId)
|
||||
m_rejoinPlayerList.push_back(playerId);
|
||||
}
|
||||
|
||||
void
|
||||
ServerGame::AddReentryPlayer(unsigned playerId)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_reentryPlayerListMutex);
|
||||
m_reentryPlayerList.push_back(playerId);
|
||||
}
|
||||
|
||||
PlayerIdList
|
||||
ServerGame::GetAndResetRejoinPlayers()
|
||||
{
|
||||
@@ -759,6 +811,22 @@ ServerGame::GetAndResetRejoinPlayers()
|
||||
return tmpList;
|
||||
}
|
||||
|
||||
unsigned
|
||||
ServerGame::GetNumberPlayersReentry()
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_rejoinPlayerListMutex);
|
||||
return static_cast<unsigned>(m_rejoinPlayerList.size());
|
||||
}
|
||||
|
||||
PlayerIdList
|
||||
ServerGame::GetAndResetReentryPlayers()
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_reentryPlayerListMutex);
|
||||
PlayerIdList tmpList(m_reentryPlayerList);
|
||||
m_reentryPlayerList.clear();
|
||||
return tmpList;
|
||||
}
|
||||
|
||||
void
|
||||
ServerGame::AddReactivatePlayer(unsigned playerId)
|
||||
{
|
||||
@@ -1091,6 +1159,12 @@ ServerGame::GetStateTimer2()
|
||||
return m_stateTimer2;
|
||||
}
|
||||
|
||||
boost::asio::steady_timer &
|
||||
ServerGame::GetAllowEntryTimer()
|
||||
{
|
||||
return m_allowEntryTimer;
|
||||
}
|
||||
|
||||
Game &
|
||||
ServerGame::GetGame()
|
||||
{
|
||||
@@ -1156,6 +1230,17 @@ ServerGame::CheckSettings(const GameData &data, const string &password, ServerMo
|
||||
retVal = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (data.gameType == GAME_TYPE_NORMAL || data.gameType == GAME_TYPE_REGISTERED_ONLY) { // allow late reg and reentries
|
||||
if (data.allowLateReg || data.allowReentries) {
|
||||
if (data.maxTimeLateReg < 1 || data.maxTimeLateReg > 60) retVal = false;
|
||||
if (data.allowReentries && (data.numReentries < 0 || data.numReentries > 10)) retVal = false;
|
||||
}
|
||||
}
|
||||
else { // does not allow
|
||||
if (data.allowLateReg || data.allowReentries) retVal = false;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -1192,3 +1277,88 @@ ServerGame::GetNumJoinsPerPlayer(const std::string &playerName)
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
void
|
||||
ServerGame::setEntries(const PlayerDataList &playerDataList) {
|
||||
|
||||
PlayerDataList::const_iterator i = playerDataList.begin();
|
||||
PlayerDataList::const_iterator end = playerDataList.end();
|
||||
|
||||
while (i != end) {
|
||||
boost::shared_ptr<PlayerData> tmpPlayer(*i);
|
||||
m_numEntriesPlayer[tmpPlayer->GetName()] = 0;
|
||||
++i;
|
||||
}
|
||||
|
||||
{
|
||||
LOG_MSG("Printting set entries:");
|
||||
|
||||
NumJoinsPerPlayerMap::const_iterator i = m_numEntriesPlayer.begin();
|
||||
NumJoinsPerPlayerMap::const_iterator end = m_numEntriesPlayer.end();
|
||||
|
||||
while (i != end) {
|
||||
LOG_MSG("\t{player, entries}: {" << (*i).first << ", " << (*i).second << "}");
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ServerGame::admitReentries(boost::shared_ptr<PlayerData> player) { // FIXME: maybe set a reason, to return appropiate message. eg: uint32 &reason
|
||||
|
||||
bool retVal = false;
|
||||
const GameData &tmpGameData = GetGameData();
|
||||
|
||||
// uncomment to remove logs
|
||||
/*if (!m_isLateRegAllowed) return retVal;
|
||||
NumJoinsPerPlayerMap::iterator pos = m_numEntriesPlayer.find(player->GetName());
|
||||
if (pos != m_numEntriesPlayer.end()) { // is reentry
|
||||
if (!tmpGameData.allowReentries || pos->second++ >= tmpGameData.numReentries ) return retVal; // number of entries exceeded
|
||||
}
|
||||
else { // is late reg
|
||||
if (!tmpGameData.allowLateReg) return false; // does not allow late reg
|
||||
m_numEntriesPlayer[player->GetName()] = 0; // add player as new entry. Perhaps this should be set otherplace
|
||||
}*/
|
||||
|
||||
// comment or delete to remove logs -- begin
|
||||
if (!m_isLateRegAllowed) {
|
||||
LOG_MSG("Late reg was not allowed or is no longer available");
|
||||
return retVal;
|
||||
}
|
||||
NumJoinsPerPlayerMap::iterator pos = m_numEntriesPlayer.find(player->GetName());
|
||||
if (pos != m_numEntriesPlayer.end()) { // is reentry
|
||||
LOG_MSG("Player " << player->GetName() << " is trying to re-entry. Previous entries: " << pos->second);
|
||||
if (!tmpGameData.allowReentries || pos->second++ >= tmpGameData.numReentries ) {
|
||||
LOG_MSG("Number of reentries exceeded");
|
||||
return retVal; // number of entries exceeded
|
||||
}
|
||||
else {
|
||||
LOG_MSG("Allowed to re-entry");
|
||||
}
|
||||
}
|
||||
else { // is late reg
|
||||
LOG_MSG("Player " << player->GetName() << " is trying a late reg");
|
||||
if (!tmpGameData.allowLateReg) {
|
||||
LOG_MSG("Game does not allow late reg");
|
||||
return false; // does not allow late reg
|
||||
}
|
||||
m_numEntriesPlayer[player->GetName()] = 0; // add player as new entry. Perhaps this should be set otherplace
|
||||
}
|
||||
|
||||
LOG_MSG("Late reg allowed!! ");
|
||||
// comment or delete to remove logs -- end
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ServerGame::CancelLateReg() {
|
||||
m_isLateRegAllowed = false;
|
||||
|
||||
LOG_MSG("Called CancelLateReg");
|
||||
}
|
||||
|
||||
bool
|
||||
ServerGame::IsLateReg() {
|
||||
return m_isLateRegAllowed;
|
||||
}
|
||||
@@ -92,6 +92,8 @@ using namespace boost::chrono;
|
||||
|
||||
#define GAME_MAX_NUM_JOINS_PER_PLAYER 6
|
||||
|
||||
#define TESTS_LATE_REG // (albmed) To develop set this define, to compile comment until reentry is implemented
|
||||
|
||||
// Helper functions
|
||||
|
||||
static void SendPlayerAction(ServerGame &server, boost::shared_ptr<PlayerInterface> player)
|
||||
@@ -155,7 +157,7 @@ static void SendNewRoundCards(ServerGame &server, Game &curGame, int state)
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
//
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -227,6 +229,35 @@ SetPlayerResult(PlayerResult &playerResult, boost::shared_ptr<PlayerInterface> t
|
||||
playerResult.set_playermoney(tmpPlayer->getMyCash());
|
||||
}
|
||||
|
||||
static int
|
||||
GetRandomFreeSeat(PlayerList playerList) {
|
||||
|
||||
// seek for a free seat
|
||||
PlayerListConstIterator player_i = playerList->begin();
|
||||
PlayerListConstIterator player_end = playerList->end();
|
||||
|
||||
std::vector<int> v(10, 0);
|
||||
while (player_i != player_end) {
|
||||
v[(*player_i)->getMyID()] = 1; // mark seats with player
|
||||
++player_i;
|
||||
}
|
||||
|
||||
// random seats
|
||||
random_shuffle(v.begin(), v.end());
|
||||
|
||||
int seat = -1;
|
||||
// seeks first free seat
|
||||
for (int i = 0; i < v.size(); i++) {
|
||||
if (v[i] == 0) {
|
||||
seat = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return seat;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ServerGameState::~ServerGameState()
|
||||
@@ -825,6 +856,14 @@ ServerGameStateStartGame::TimerTimeout(const boost::system::error_code &ec, boos
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerGameStateStartGame::TimerAllowLateRegTimeout(const boost::system::error_code &ec, boost::shared_ptr<ServerGame> server)
|
||||
{
|
||||
if (!ec && &server->GetState() != &ServerGameStateFinal::Instance()) {
|
||||
server->CancelLateReg();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerGameStateStartGame::DoStart(boost::shared_ptr<ServerGame> server)
|
||||
{
|
||||
@@ -852,8 +891,39 @@ ServerGameStateStartGame::DoStart(boost::shared_ptr<ServerGame> server)
|
||||
++player_i;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
LOG_MSG(" === SENDING DO START ====");
|
||||
LOG_MSG("\tPlayers: ");
|
||||
player_i = tmpPlayerList.begin();
|
||||
player_end = tmpPlayerList.end();
|
||||
|
||||
while (player_i != player_end) {
|
||||
boost::shared_ptr<PlayerData> tmpPlayer = (*player_i);
|
||||
LOG_MSG("\t\t {UID, name, GUID, seat}: -> {" <<
|
||||
tmpPlayer->GetUniqueId() << ", " <<
|
||||
tmpPlayer->GetName() << ", " <<
|
||||
tmpPlayer->GetGuid() << ", " <<
|
||||
tmpPlayer->GetNumber() << "}"
|
||||
);
|
||||
++player_i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
server->SendToAllPlayers(packet, SessionData::Game | SessionData::Spectating);
|
||||
|
||||
LOG_MSG("Starting timer for LateReg");
|
||||
|
||||
// set late reg timer (if allowed)
|
||||
if (server->IsLateReg()) {
|
||||
server->GetAllowEntryTimer().expires_from_now(
|
||||
minutes(server->GetGameData().maxTimeLateReg));
|
||||
server->GetAllowEntryTimer().async_wait(
|
||||
boost::bind(
|
||||
&ServerGameStateStartGame::TimerAllowLateRegTimeout, this, boost::asio::placeholders::error, server));
|
||||
}
|
||||
|
||||
// Start the first hand.
|
||||
ServerGameStateHand::StartNewHand(server);
|
||||
server->SetState(ServerGameStateHand::Instance());
|
||||
@@ -888,7 +958,55 @@ AbstractServerGameStateRunning::HandleNewPlayer(boost::shared_ptr<ServerGame> se
|
||||
|
||||
// Wait for rejoining player to confirm start of game.
|
||||
server->GetLobbyThread().GetSender().Send(session, packet);
|
||||
} else {
|
||||
}
|
||||
else if (session && session->GetPlayerData() && server->admitReentries(session->GetPlayerData())) {
|
||||
const GameData tmpGameData = server->GetGameData();
|
||||
|
||||
if (server->GetCurNumberOfPlayers() + static_cast<int>(server->GetNumberPlayersReentry()) < tmpGameData.maxNumberOfPlayers) { // there is a seat available
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef TESTS_LATE_REG
|
||||
server->MoveSessionToLobby(session, NTF_NET_REMOVED_GAME_FULL);
|
||||
#else
|
||||
// Uncomment next line when implemented
|
||||
AcceptNewSession(server, session, false); // player wants to join
|
||||
server->AddReentryPlayer(session->GetPlayerData()->GetUniqueId()); // add to list of players to reentry
|
||||
|
||||
LOG_MSG("Late reg is allowed and there is a seat available... unfortunatelly not implemented, yet ;)");
|
||||
|
||||
// Send start event right away.
|
||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_StartEventMessage);
|
||||
StartEventMessage *netStartEvent = packet->GetMsg()->mutable_starteventmessage();
|
||||
netStartEvent->set_starteventtype(StartEventMessage::reentryEvent); // <-- set reentry event!! TODO (albmed): Fist we have to check proto NET versions. Both NET_VERSION_MAJOR & NET_VERSION_MINOR
|
||||
netStartEvent->set_gameid(server->GetId());
|
||||
|
||||
// Wait for rejoining player to confirm start of game.
|
||||
server->GetLobbyThread().GetSender().Send(session, packet);
|
||||
|
||||
|
||||
// TODO (albmed):
|
||||
// - locate seat ---> this should be done in ServerGameStateHand::StartNewHand
|
||||
// - notify players and users
|
||||
// - move session to server
|
||||
// - set cash
|
||||
// - wait for button to pass (if necessary)
|
||||
// - let player play
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
server->MoveSessionToLobby(session, NTF_NET_REMOVED_GAME_FULL);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
// Do not accept "new" sessions in this state, only rejoin is allowed.
|
||||
server->MoveSessionToLobby(session, NTF_NET_REMOVED_ALREADY_RUNNING);
|
||||
}
|
||||
@@ -1251,8 +1369,81 @@ ServerGameStateHand::StartNewHand(boost::shared_ptr<ServerGame> server)
|
||||
curGame.getCurrentHand()->getRiver()->skipFirstRunGui();
|
||||
|
||||
// Consider all players, even inactive.
|
||||
PlayerListIterator i = curGame.getSeatsList()->begin();
|
||||
PlayerListIterator end = curGame.getSeatsList()->end();
|
||||
PlayerListIterator i;
|
||||
PlayerListIterator end;
|
||||
|
||||
{
|
||||
LOG_MSG("Starting new hand. Lets LOG: ");
|
||||
LOG_MSG("\tPlayer seats");
|
||||
|
||||
i = curGame.getSeatsList()->begin();
|
||||
end = curGame.getSeatsList()->end();
|
||||
while (i != end) {
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = (*i);
|
||||
|
||||
LOG_MSG("\t\t {ID, name, UID} -> {" <<
|
||||
tmpPlayer->getMyID() << ", " <<
|
||||
tmpPlayer->getMyName() << ", " <<
|
||||
tmpPlayer->getMyUniqueID() << "}"
|
||||
);
|
||||
++i;
|
||||
}
|
||||
|
||||
i = curGame.getActivePlayerList()->begin();
|
||||
end = curGame.getActivePlayerList()->end();
|
||||
|
||||
LOG_MSG("\tActive players");
|
||||
while (i != end) {
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = (*i);
|
||||
|
||||
LOG_MSG("\t\t {ID, name, UID} -> {" <<
|
||||
tmpPlayer->getMyID() << ", " <<
|
||||
tmpPlayer->getMyName() << ", " <<
|
||||
tmpPlayer->getMyUniqueID() << "}"
|
||||
);
|
||||
++i;
|
||||
}
|
||||
|
||||
i = curGame.getRunningPlayerList()->begin();
|
||||
end = curGame.getRunningPlayerList()->end();
|
||||
|
||||
LOG_MSG("\tRunning players");
|
||||
while (i != end) {
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = (*i);
|
||||
|
||||
LOG_MSG("\t\t {ID, name, UID} -> {" <<
|
||||
tmpPlayer->getMyID() << ", " <<
|
||||
tmpPlayer->getMyName() << ", " <<
|
||||
tmpPlayer->getMyUniqueID() << "}"
|
||||
);
|
||||
++i;
|
||||
}
|
||||
|
||||
PlayerDataList tmpPlayerList(server->GetFullPlayerDataList());
|
||||
|
||||
LOG_MSG("\tAll Data players");
|
||||
|
||||
PlayerDataList::iterator player_i = tmpPlayerList.begin();
|
||||
PlayerDataList::iterator player_end = tmpPlayerList.end();
|
||||
while (player_i != player_end) {
|
||||
boost::shared_ptr<PlayerData> tmpPlayer = (*player_i);
|
||||
|
||||
LOG_MSG("\t\tPlayerData: {playerId, name, number} -> {" <<
|
||||
tmpPlayer->GetUniqueId() << "," <<
|
||||
tmpPlayer->GetName() << "," <<
|
||||
//tmpPlayer->GetGuid() << "," <<
|
||||
tmpPlayer->GetNumber() << "}"
|
||||
);
|
||||
|
||||
++player_i;
|
||||
}
|
||||
}
|
||||
|
||||
// Consider all players, even inactive.
|
||||
i = curGame.getSeatsList()->begin();
|
||||
end = curGame.getSeatsList()->end();
|
||||
|
||||
|
||||
|
||||
// Send cards to all players.
|
||||
while (i != end) {
|
||||
@@ -1417,6 +1608,21 @@ ServerGameStateHand::InitRejoiningPlayers(boost::shared_ptr<ServerGame> server)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerGameStateHand::InitReetryPlayers(boost::shared_ptr<ServerGame> server)
|
||||
{
|
||||
PlayerIdList reentryIdList(server->GetAndResetReentryPlayers());
|
||||
PlayerIdList::iterator i = reentryIdList.begin();
|
||||
PlayerIdList::iterator end = reentryIdList.end();
|
||||
while (i != end) {
|
||||
boost::shared_ptr<SessionData> session(server->GetSessionManager().GetSessionByUniquePlayerId(*i));
|
||||
if (session && session->GetPlayerData()) {
|
||||
PerformReentry(server, session);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerGameStateHand::InitNewSpectators(boost::shared_ptr<ServerGame> server)
|
||||
{
|
||||
@@ -1463,6 +1669,102 @@ ServerGameStateHand::PerformRejoin(boost::shared_ptr<ServerGame> server, boost::
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerGameStateHand::PerformReentry(boost::shared_ptr<ServerGame> server, boost::shared_ptr<SessionData> session)
|
||||
{
|
||||
Game &curGame = server->GetGame();
|
||||
|
||||
// TODO (albmed):
|
||||
// Create player interface
|
||||
if (session) {
|
||||
// check if player already played this game
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame.getPlayerByName(session->GetPlayerData()->GetName());
|
||||
if (!tmpPlayer) {
|
||||
|
||||
// TODO: Late registration implementation is postponed
|
||||
|
||||
throw ServerException(__FILE__, __LINE__, ERR_NET_INTERNAL_GAME_ERROR, 0);
|
||||
// tmpPlayer = curGame.addNewPlayer(session->GetPlayerData()); // TODO (albmed): Create addNewPlayer method
|
||||
}
|
||||
else {
|
||||
// This means this is a reentry, because player already played this game
|
||||
|
||||
// check for id change
|
||||
if (session->GetPlayerData()->GetUniqueId() != tmpPlayer->getMyUniqueID()) {
|
||||
// Notify other clients about id change.
|
||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_PlayerIdChangedMessage);
|
||||
PlayerIdChangedMessage *netIdChanged = packet->GetMsg()->mutable_playeridchangedmessage();
|
||||
netIdChanged->set_oldplayerid(tmpPlayer->getMyUniqueID());
|
||||
netIdChanged->set_newplayerid(session->GetPlayerData()->GetUniqueId());
|
||||
server->SendToAllButOnePlayers(packet, session->GetId(), SessionData::Game | SessionData::Spectating | SessionData::SpectatorWaiting);
|
||||
|
||||
// Update the dealer, if necessary.
|
||||
curGame.replaceDealer(tmpPlayer->getMyUniqueID(), session->GetPlayerData()->GetUniqueId());
|
||||
|
||||
// Update the ranking map.
|
||||
server->ReplaceRankingPlayer(tmpPlayer->getMyUniqueID(), session->GetPlayerData()->GetUniqueId());
|
||||
// Change the Id in the poker engine.
|
||||
tmpPlayer->setMyUniqueID(session->GetPlayerData()->GetUniqueId());
|
||||
tmpPlayer->setMyGuid(session->GetPlayerData()->GetGuid());
|
||||
}
|
||||
|
||||
tmpPlayer->markRemoteAction();
|
||||
tmpPlayer->setIsSessionActive(true);
|
||||
SendGameDataReentry(server, session); // TODO (albmed): This method should be duplicated
|
||||
// - to send starting game cash: server->GetGameData().startMoney
|
||||
// - to make a new reentry message
|
||||
|
||||
}
|
||||
|
||||
/* int seat = GetRandomFreeSeat(curGame.getActivePlayerList()); // (albmed): if reentry, assign same seat or find a new one?
|
||||
if (seat >= 0) { // ok
|
||||
// seat found....
|
||||
|
||||
// is between dealer? TODO (albmed)
|
||||
unsigned dealerPosition = curGame.getDealerPosition();
|
||||
|
||||
|
||||
}
|
||||
else throw ServerException(__FILE__, __LINE__, ERR_NET_INTERNAL_GAME_ERROR, 0); */
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
ServerGameStateHand::GetRandomFreeSeat(const PlayerList playerList) {
|
||||
|
||||
// seek for a free seat
|
||||
PlayerListConstIterator player_i = playerList->begin();
|
||||
PlayerListConstIterator player_end = playerList->end();
|
||||
|
||||
std::vector<int> v(10, 0);
|
||||
while (player_i != player_end) {
|
||||
v[(*player_i)->getMyID()] = 1; // mark seats with player
|
||||
++player_i;
|
||||
}
|
||||
|
||||
// random seats
|
||||
random_shuffle(v.begin(), v.end());
|
||||
|
||||
int seat = -1;
|
||||
// seeks first free seat
|
||||
for(std::vector<int>::size_type i = 0; i != v.size(); i++) {
|
||||
if (v[i] == 0) {
|
||||
seat = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return seat;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ServerGameStateHand::SendGameData(boost::shared_ptr<ServerGame> server, boost::shared_ptr<SessionData> session)
|
||||
{
|
||||
@@ -1489,6 +1791,33 @@ ServerGameStateHand::SendGameData(boost::shared_ptr<ServerGame> server, boost::s
|
||||
server->GetLobbyThread().GetSender().Send(session, packet);
|
||||
}
|
||||
|
||||
void
|
||||
ServerGameStateHand::SendGameDataReentry(boost::shared_ptr<ServerGame> server, boost::shared_ptr<SessionData> session)
|
||||
{
|
||||
Game &curGame = server->GetGame();
|
||||
// Send game start notification to reentry client.
|
||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_GameStartReentryMessage);
|
||||
GameStartReentryMessage *netGameStart = packet->GetMsg()->mutable_gamestartreentrymessage();
|
||||
netGameStart->set_gameid(server->GetId());
|
||||
netGameStart->set_startdealerplayerid(curGame.getDealerPosition());
|
||||
netGameStart->set_handnum(curGame.getCurrentHandID());
|
||||
PlayerListIterator player_i = curGame.getSeatsList()->begin();
|
||||
PlayerListIterator player_end = curGame.getSeatsList()->end();
|
||||
int player_count = 0;
|
||||
while (player_i != player_end && player_count < server->GetStartData().numberOfPlayers) {
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = *player_i;
|
||||
GameStartReentryMessage::ReentryPlayerData *playerSlot = netGameStart->add_reentryplayerdata();
|
||||
playerSlot->set_playerid(tmpPlayer->getMyUniqueID());
|
||||
playerSlot->set_playermoney(server->GetGameData().startMoney);
|
||||
++player_i;
|
||||
++player_count;
|
||||
}
|
||||
|
||||
server->GetLobbyThread().GetSender().Send(session, packet);
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@@ -62,8 +62,10 @@
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <gsasl.h>
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
|
||||
#define SERVER_MAX_NUM_LOBBY_SESSIONS 512 // Maximum number of idle users in lobby.
|
||||
#define SERVER_MAX_NUM_LOBBY_SESSIONS 1536 // Maximum number of idle users in lobby.
|
||||
#define SERVER_MAX_NUM_TOTAL_SESSIONS 2000 // Total maximum of sessions, fitting a 2048 handle limit
|
||||
|
||||
#define SERVER_SAVE_STATISTICS_INTERVAL_SEC 60
|
||||
@@ -303,7 +305,8 @@ ServerLobbyThread::AddConnection(boost::shared_ptr<SessionData> sessionData)
|
||||
// Create a new session.
|
||||
m_sessionManager.AddSession(sessionData);
|
||||
|
||||
LOG_VERBOSE("Accepted connection - session #" << sessionData->GetId() << ".");
|
||||
LOG_VERBOSE(sessionData->GetRemoteIPAddressFromSocket() << " Accepted connection - session #" << sessionData->GetId() << ".");
|
||||
LOG_ERROR(sessionData->GetRemoteIPAddressFromSocket() << " Accepted connection - session #" << sessionData->GetId() << ".");
|
||||
|
||||
sessionData->StartTimerInitTimeout(SERVER_INIT_SESSION_TIMEOUT_SEC);
|
||||
sessionData->StartTimerGlobalTimeout(SERVER_SESSION_FORCED_TIMEOUT_SEC);
|
||||
@@ -1347,7 +1350,7 @@ ServerLobbyThread::HandleNetPacketRetrieveAvatar(boost::shared_ptr<SessionData>
|
||||
void
|
||||
ServerLobbyThread::HandleNetPacketCreateGame(boost::shared_ptr<SessionData> session, const JoinNewGameMessage &newGame)
|
||||
{
|
||||
LOG_VERBOSE("Creating new game, initiated by session #" << session->GetId() << ".");
|
||||
LOG_ERROR("Creating new game, initiated by session #" << session->GetId() << ".");
|
||||
|
||||
string password;
|
||||
if (newGame.has_password())
|
||||
@@ -1366,6 +1369,13 @@ ServerLobbyThread::HandleNetPacketCreateGame(boost::shared_ptr<SessionData> sess
|
||||
boost::replace_all(gameName, "\f", " ");
|
||||
unsigned gameId = GetNextGameId();
|
||||
|
||||
LOG_MSG ("Creating game with new params: {allowLate, allowReentries, numReentries, maxTimeLateReg} -> {" <<
|
||||
std::boolalpha <<
|
||||
tmpData.allowLateReg << ", " <<
|
||||
tmpData.allowReentries << ", " <<
|
||||
tmpData.numReentries << ", " <<
|
||||
tmpData.maxTimeLateReg << "}");
|
||||
|
||||
if (gameName.empty() || !isprint(gameName[0])) {
|
||||
SendJoinGameFailed(session, gameId, NTF_NET_JOIN_GAME_BAD_NAME);
|
||||
} else if (IsGameNameInUse(gameName)) {
|
||||
@@ -1377,6 +1387,10 @@ ServerLobbyThread::HandleNetPacketCreateGame(boost::shared_ptr<SessionData> sess
|
||||
SendJoinGameFailed(session, gameId, NTF_NET_JOIN_GUEST_FORBIDDEN);
|
||||
} else if (!ServerGame::CheckSettings(tmpData, password, GetServerMode())) {
|
||||
SendJoinGameFailed(session, gameId, NTF_NET_JOIN_INVALID_SETTINGS);
|
||||
} else if (!session->GetPlayerData()->IsPlayerAllowedToJoinCreateLimitRank(m_serverConfig.readConfigString("ServerLimitRankNum"), m_serverConfig.readConfigString("ServerLimitRankPeriod"))
|
||||
&& tmpData.gameType == GAME_TYPE_RANKING ) {
|
||||
LOG_ERROR("not allowed due to ranklimit");
|
||||
SendJoinGameFailed(session, gameId, NTF_NET_JOIN_IP_BLOCKED);
|
||||
} else {
|
||||
boost::shared_ptr<ServerGame> game(
|
||||
new ServerGame(
|
||||
@@ -1418,6 +1432,7 @@ ServerLobbyThread::HandleNetPacketJoinGame(boost::shared_ptr<SessionData> sessio
|
||||
MoveSessionToGame(game, session, joinGame.autoleave(), true);
|
||||
}
|
||||
} else {
|
||||
LOG_ERROR("JoinGame pre validation");
|
||||
// As guest, you are only allowed to join normal games.
|
||||
if (session->GetPlayerData()->GetRights() == PLAYER_RIGHTS_GUEST
|
||||
&& tmpData.gameType != GAME_TYPE_NORMAL) {
|
||||
@@ -1427,14 +1442,14 @@ ServerLobbyThread::HandleNetPacketJoinGame(boost::shared_ptr<SessionData> sessio
|
||||
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_NOT_INVITED);
|
||||
} else if (!game->CheckPassword(password)) {
|
||||
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_INVALID_PASSWORD);
|
||||
} else if (tmpData.gameType == GAME_TYPE_RANKING
|
||||
&& !joinGame.spectateonly()
|
||||
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR
|
||||
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4V6
|
||||
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4
|
||||
&& game->IsClientAddressConnected(session->GetClientAddr())) {
|
||||
} else if (tmpData.gameType == GAME_TYPE_RANKING && !session->GetPlayerData()->IsPlayerAllowedToJoinCreateLimitRank(m_serverConfig.readConfigString("ServerLimitRankNum"), m_serverConfig.readConfigString("ServerLimitRankPeriod"))) {
|
||||
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED);
|
||||
} else if (tmpData.gameType == GAME_TYPE_RANKING && !joinGame.spectateonly()
|
||||
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR
|
||||
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4V6
|
||||
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4
|
||||
&& game->IsClientAddressConnected(session->GetClientAddr())) {
|
||||
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED);
|
||||
|
||||
} else {
|
||||
MoveSessionToGame(game, session, joinGame.autoleave(), false);
|
||||
}
|
||||
@@ -1803,6 +1818,18 @@ ServerLobbyThread::UserValid(unsigned playerId, const DBPlayerData &dbPlayerData
|
||||
if (tmpSession && tmpSession->GetPlayerData()) {
|
||||
tmpSession->GetPlayerData()->SetDBId(dbPlayerData.id);
|
||||
tmpSession->GetPlayerData()->SetCountry(dbPlayerData.country);
|
||||
if(dbPlayerData.last_games.length() > 0){
|
||||
LOG_ERROR("last_games from db = " << dbPlayerData.last_games);
|
||||
vector<string> last_games;
|
||||
boost::split(last_games, dbPlayerData.last_games, boost::is_any_of(","));
|
||||
for (unsigned int i = 0; i < last_games.size(); i++){
|
||||
if(last_games[i].length() > 0)
|
||||
tmpSession->GetPlayerData()->AddPlayerLastGame(stol(last_games[i]));
|
||||
}
|
||||
LOG_ERROR("last_games last from vector after db = " << tmpSession->GetPlayerData()->GetPlayerLastGames().back());
|
||||
}else{
|
||||
LOG_ERROR("no lastGames from db");
|
||||
}
|
||||
this->AuthChallenge(tmpSession, dbPlayerData.secret);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include <net/serverexception.h>
|
||||
#include <net/socket_msg.h>
|
||||
|
||||
#include <ctime>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define SERVER_MAX_GUEST_USERS_LOBBY 50 // LG: Maximum number of guests users in lobby allowed
|
||||
|
||||
@@ -85,6 +85,7 @@ protected:
|
||||
static bool ValidateStartEventAckMessage(const NetPacket &packet);
|
||||
static bool ValidateGameStartInitialMessage(const NetPacket &packet);
|
||||
static bool ValidateGameStartRejoinMessage(const NetPacket &packet);
|
||||
static bool ValidateGameStartReentryMessage(const NetPacket &packet);
|
||||
static bool ValidateHandStartMessage(const NetPacket &packet);
|
||||
static bool ValidatePlayersTurnMessage(const NetPacket &packet);
|
||||
static bool ValidateMyActionRequestMessage(const NetPacket &packet);
|
||||
|
||||
@@ -111,6 +111,10 @@ public:
|
||||
void AddRejoinPlayer(unsigned playerId);
|
||||
PlayerIdList GetAndResetRejoinPlayers();
|
||||
|
||||
void AddReentryPlayer(unsigned playerId);
|
||||
PlayerIdList GetAndResetReentryPlayers();
|
||||
unsigned GetNumberPlayersReentry();
|
||||
|
||||
void AddReactivatePlayer(unsigned playerId);
|
||||
PlayerIdList GetAndResetReactivatePlayers();
|
||||
|
||||
@@ -128,6 +132,10 @@ public:
|
||||
|
||||
void AddPlayerToNumJoinsPerPlayer(const std::string &playerName);
|
||||
int GetNumJoinsPerPlayer(const std::string &playerName);
|
||||
bool admitReentries(boost::shared_ptr<PlayerData> player);
|
||||
|
||||
void CancelLateReg();
|
||||
bool IsLateReg();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -148,6 +156,7 @@ protected:
|
||||
void SetPlayerPlace(unsigned playerId, int place);
|
||||
void ReplaceRankingPlayer(unsigned oldPlayerId, unsigned newPlayerId);
|
||||
void StoreAndResetRanking();
|
||||
void StoreLastGames(const PlayerDataList &playerDataList);
|
||||
void RemoveAutoLeavePlayers();
|
||||
void InternalEndGame();
|
||||
|
||||
@@ -183,6 +192,7 @@ protected:
|
||||
|
||||
boost::asio::steady_timer &GetStateTimer1();
|
||||
boost::asio::steady_timer &GetStateTimer2();
|
||||
boost::asio::steady_timer &GetAllowEntryTimer();
|
||||
|
||||
const StartData &GetStartData() const;
|
||||
void SetStartData(const StartData &startData);
|
||||
@@ -195,6 +205,8 @@ protected:
|
||||
SessionManager &GetSessionManager();
|
||||
ServerDBInterface &GetDatabase();
|
||||
|
||||
void setEntries(const PlayerDataList &playerData);
|
||||
|
||||
typedef std::map<std::string, int> NumJoinsPerPlayerMap;
|
||||
|
||||
private:
|
||||
@@ -213,6 +225,9 @@ private:
|
||||
PlayerIdList m_rejoinPlayerList;
|
||||
mutable boost::mutex m_rejoinPlayerListMutex;
|
||||
|
||||
PlayerIdList m_reentryPlayerList;
|
||||
mutable boost::mutex m_reentryPlayerListMutex;
|
||||
|
||||
PlayerIdList m_reactivatePlayerList;
|
||||
mutable boost::mutex m_reactivatePlayerListMutex;
|
||||
|
||||
@@ -246,7 +261,9 @@ private:
|
||||
boost::asio::steady_timer m_voteKickTimer;
|
||||
boost::asio::steady_timer m_stateTimer1;
|
||||
boost::asio::steady_timer m_stateTimer2;
|
||||
boost::asio::steady_timer m_allowEntryTimer;
|
||||
bool m_isNameReported;
|
||||
bool m_isLateRegAllowed;
|
||||
|
||||
friend class ServerLobbyThread;
|
||||
friend class AbstractServerGameStateReceiving;
|
||||
@@ -259,6 +276,7 @@ private:
|
||||
friend class ServerGameStateWaitNextHand;
|
||||
|
||||
NumJoinsPerPlayerMap m_numJoinsPerPlayer;
|
||||
NumJoinsPerPlayerMap m_numEntriesPlayer;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <boost/asio.hpp>
|
||||
#include <playerdata.h>
|
||||
#include <net/sessionmanager.h>
|
||||
#include <engine/engine_defs.h>
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
@@ -145,6 +146,7 @@ protected:
|
||||
|
||||
virtual void InternalProcessPacket(boost::shared_ptr<ServerGame> server, boost::shared_ptr<SessionData> session, boost::shared_ptr<NetPacket> packet);
|
||||
void TimerTimeout(const boost::system::error_code &ec, boost::shared_ptr<ServerGame> server);
|
||||
void TimerAllowLateRegTimeout(const boost::system::error_code &ec, boost::shared_ptr<ServerGame> server);
|
||||
void DoStart(boost::shared_ptr<ServerGame> server);
|
||||
|
||||
private:
|
||||
@@ -191,9 +193,13 @@ protected:
|
||||
static void CheckPlayerTimeouts(boost::shared_ptr<ServerGame> server);
|
||||
static void ReactivatePlayers(boost::shared_ptr<ServerGame> server);
|
||||
static void InitRejoiningPlayers(boost::shared_ptr<ServerGame> server);
|
||||
static void InitReetryPlayers(boost::shared_ptr<ServerGame> server);
|
||||
static void InitNewSpectators(boost::shared_ptr<ServerGame> server);
|
||||
static void PerformRejoin(boost::shared_ptr<ServerGame> server, boost::shared_ptr<SessionData> session);
|
||||
static void PerformReentry(boost::shared_ptr<ServerGame> server, boost::shared_ptr<SessionData> session);
|
||||
static void SendGameData(boost::shared_ptr<ServerGame> server, boost::shared_ptr<SessionData> session);
|
||||
static void SendGameDataReentry(boost::shared_ptr<ServerGame> server, boost::shared_ptr<SessionData> session);
|
||||
static int GetRandomFreeSeat(const PlayerList playerList);
|
||||
|
||||
private:
|
||||
static ServerGameStateHand s_state;
|
||||
|
||||
@@ -40,6 +40,7 @@ typedef unsigned SessionId;
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <net/socket_helper.h>
|
||||
#include <net/sessiondatacallback.h>
|
||||
|
||||
@@ -65,6 +65,8 @@ public:
|
||||
bool IsPlayerConnected(unsigned uniqueId) const;
|
||||
bool IsClientAddressConnected(const std::string &clientAddress) const;
|
||||
bool IsGuestAllowedToConnect(const std::string &clientAddress) const;
|
||||
bool IsPlayerAllowedToJoinCreateLimitRank(const std::string &playerName) const;
|
||||
bool IsPlayerAllowedToJoinCreateLimitRank(unsigned uniqueId) const;
|
||||
|
||||
void ForEach(boost::function<void (boost::shared_ptr<SessionData>)> func);
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
#include <playerdata.h>
|
||||
#include <ctime>
|
||||
#include <core/loghelper.h> // @TODO: remove in productive
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -242,3 +244,59 @@ PlayerData::operator<(const PlayerData &other) const
|
||||
return m_number < other.GetNumber();
|
||||
}
|
||||
|
||||
void
|
||||
PlayerData::SetPlayerLastGames(std::vector<long> last_games)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||
m_last_games.clear();
|
||||
m_last_games = last_games;
|
||||
}
|
||||
|
||||
void
|
||||
PlayerData::AddPlayerLastGame(long lastGame)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||
|
||||
m_last_games.push_back(lastGame);
|
||||
}
|
||||
|
||||
std::vector<long>
|
||||
PlayerData::GetPlayerLastGames()
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||
return m_last_games;
|
||||
}
|
||||
|
||||
bool
|
||||
PlayerData::IsPlayerAllowedToJoinCreateLimitRank(std::string num, std::string period)
|
||||
{
|
||||
bool retVal = false;
|
||||
LOG_ERROR("checking IsPlayerAllowedToJoinCreateLimitRank() ");
|
||||
LOG_ERROR("num = " << num << " period " << period);
|
||||
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||
|
||||
long then = (long)time(NULL) - (long)(stoi(period) * 60);
|
||||
|
||||
int count = 0;
|
||||
int i=0;
|
||||
for(std::vector<long>::iterator timeStamp = m_last_games.begin(); timeStamp != m_last_games.end(); ++timeStamp) {
|
||||
LOG_ERROR("timeStamp " << *timeStamp);
|
||||
time_t ts = (time_t)*timeStamp;
|
||||
LOG_ERROR("comparing ts " << (long)ts << " with " << then);
|
||||
if((long)ts > then){
|
||||
LOG_ERROR("counting timeStamp in time " << ctime(&ts));
|
||||
count++;
|
||||
}else{
|
||||
LOG_ERROR("erasing overdued timestamp " << ctime(&ts));
|
||||
timeStamp = m_last_games.erase(timeStamp); // erase overdued entries
|
||||
if( timeStamp == m_last_games.end())
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if(count < stoi(num))
|
||||
retVal = true;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
@@ -116,6 +116,12 @@ public:
|
||||
int GetStartCash() const;
|
||||
void SetStartCash(int cash);
|
||||
|
||||
// @TODO: last_games here
|
||||
void AddPlayerLastGame(long last_games);
|
||||
void SetPlayerLastGames(std::vector<long> last_games);
|
||||
std::vector<long> GetPlayerLastGames();
|
||||
bool IsPlayerAllowedToJoinCreateLimitRank(std::string num, std::string period);
|
||||
|
||||
bool operator<(const PlayerData &other) const;
|
||||
|
||||
private:
|
||||
@@ -135,6 +141,8 @@ private:
|
||||
bool m_isGameAdmin;
|
||||
boost::shared_ptr<AvatarFile> m_netAvatarFile;
|
||||
|
||||
std::vector<long> m_last_games;
|
||||
|
||||
mutable boost::mutex m_dataMutex;
|
||||
};
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <net/clientthread.h>
|
||||
#include <core/avatarmanager.h>
|
||||
#include <net/servermanagerfactory.h>
|
||||
#include <core/loghelper.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
@@ -281,6 +282,14 @@ void Session::clientCreateGame(const GameData &gameData, const string &name, con
|
||||
{
|
||||
if (!myNetClient)
|
||||
return; // only act if client is running.
|
||||
|
||||
std::cout << "Creating game with new params: {allowLate, allowReentries, numReentries, maxTimeLateReg} -> {" <<
|
||||
std::boolalpha <<
|
||||
gameData.allowLateReg << ", " <<
|
||||
gameData.allowReentries << "," <<
|
||||
gameData.numReentries << ", " <<
|
||||
gameData.maxTimeLateReg << "}" << std::endl;
|
||||
|
||||
myNetClient->SendCreateGame(
|
||||
gameData,
|
||||
name,
|
||||
|
||||
+1565
-1256
File diff suppressed because it is too large.
Load diff
+1702
-1026
File diff suppressed because it is too large.
Load diff
+32467
-27628
File diff suppressed because it is too large.
Load diff
+27460
-14075
File diff suppressed because it is too large.
Load diff
@@ -311,9 +311,10 @@ public:
|
||||
* needed.
|
||||
*/
|
||||
timer_ptr set_timer(long duration, timer_handler callback) {
|
||||
timer_ptr new_timer = lib::make_shared<lib::asio::steady_timer>(
|
||||
lib::ref(*m_io_service),
|
||||
lib::asio::milliseconds(duration)
|
||||
timer_ptr new_timer(
|
||||
new lib::asio::steady_timer(
|
||||
*m_io_service,
|
||||
lib::asio::milliseconds(duration))
|
||||
);
|
||||
|
||||
if (config::enable_multithreading) {
|
||||
@@ -461,8 +462,7 @@ protected:
|
||||
m_io_service = io_service;
|
||||
|
||||
if (config::enable_multithreading) {
|
||||
m_strand = lib::make_shared<lib::asio::io_service::strand>(
|
||||
lib::ref(*io_service));
|
||||
m_strand.reset(new lib::asio::io_service::strand(*io_service));
|
||||
}
|
||||
|
||||
lib::error_code ec = socket_con_type::init_asio(io_service, m_strand,
|
||||
|
||||
@@ -191,8 +191,7 @@ public:
|
||||
|
||||
m_io_service = ptr;
|
||||
m_external_io_service = true;
|
||||
m_acceptor = lib::make_shared<lib::asio::ip::tcp::acceptor>(
|
||||
lib::ref(*m_io_service));
|
||||
m_acceptor.reset(new lib::asio::ip::tcp::acceptor(*m_io_service));
|
||||
|
||||
m_state = READY;
|
||||
ec = lib::error_code();
|
||||
@@ -660,9 +659,7 @@ public:
|
||||
* @since 0.3.0
|
||||
*/
|
||||
void start_perpetual() {
|
||||
m_work = lib::make_shared<lib::asio::io_service::work>(
|
||||
lib::ref(*m_io_service)
|
||||
);
|
||||
m_work.reset(new lib::asio::io_service::work(*m_io_service));
|
||||
}
|
||||
|
||||
/// Clears the endpoint's perpetual flag, allowing it to exit when empty
|
||||
@@ -826,8 +823,7 @@ protected:
|
||||
|
||||
// Create a resolver
|
||||
if (!m_resolver) {
|
||||
m_resolver = lib::make_shared<lib::asio::ip::tcp::resolver>(
|
||||
lib::ref(*m_io_service));
|
||||
m_resolver.reset(new lib::asio::ip::tcp::resolver(*m_io_service));
|
||||
}
|
||||
|
||||
tcon->set_uri(u);
|
||||
|
||||
@@ -168,8 +168,7 @@ protected:
|
||||
return socket::make_error_code(socket::error::invalid_state);
|
||||
}
|
||||
|
||||
m_socket = lib::make_shared<lib::asio::ip::tcp::socket>(
|
||||
lib::ref(*service));
|
||||
m_socket.reset(new lib::asio::ip::tcp::socket(*service));
|
||||
|
||||
m_state = READY;
|
||||
|
||||
|
||||
@@ -193,8 +193,7 @@ protected:
|
||||
if (!m_context) {
|
||||
return socket::make_error_code(socket::error::invalid_tls_context);
|
||||
}
|
||||
m_socket = lib::make_shared<socket_type>(
|
||||
_WEBSOCKETPP_REF(*service),lib::ref(*m_context));
|
||||
m_socket.reset(new socket_type(*service, *m_context));
|
||||
|
||||
m_io_service = service;
|
||||
m_strand = strand;
|
||||
|
||||
+46753
-13836
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user