Information about the game is now shown in lobby, when selecting a game.
Some GUI modifications, GUI update is working properly now if the dialog is shown the second time (after clearing items). List of players for the game is still missing. With the new on-demand model for player id/player name, this is kind of hard to implement.
This commit is contained in:
@@ -21,6 +21,8 @@
|
|||||||
#ifndef _GAMEDATA_H_
|
#ifndef _GAMEDATA_H_
|
||||||
#define _GAMEDATA_H_
|
#define _GAMEDATA_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
enum GameMode
|
enum GameMode
|
||||||
{
|
{
|
||||||
GAME_MODE_CREATED = 1,
|
GAME_MODE_CREATED = 1,
|
||||||
@@ -41,6 +43,15 @@ struct GameData
|
|||||||
int playerActionTimeoutSec;
|
int playerActionTimeoutSec;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct GameInfo
|
||||||
|
{
|
||||||
|
GameInfo() : mode(GAME_MODE_CREATED), isPasswordProtected(false) {}
|
||||||
|
std::string name;
|
||||||
|
GameData data;
|
||||||
|
GameMode mode;
|
||||||
|
bool isPasswordProtected;
|
||||||
|
};
|
||||||
|
|
||||||
struct StartData
|
struct StartData
|
||||||
{
|
{
|
||||||
StartData() : startDealerPlayerId(0), numberOfPlayers(0) {}
|
StartData() : startDealerPlayerId(0), numberOfPlayers(0) {}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
|
|||||||
connect( pushButton_CreateGame, SIGNAL( clicked() ), this, SLOT( createGame() ) );
|
connect( pushButton_CreateGame, SIGNAL( clicked() ), this, SLOT( createGame() ) );
|
||||||
connect( pushButton_JoinGame, SIGNAL( clicked() ), this, SLOT( joinGame() ) );
|
connect( pushButton_JoinGame, SIGNAL( clicked() ), this, SLOT( joinGame() ) );
|
||||||
connect( treeWidget_GameList, SIGNAL( itemClicked ( QTreeWidgetItem*, int) ), this, SLOT( gameSelected(QTreeWidgetItem*, int) ) );
|
connect( treeWidget_GameList, SIGNAL( itemClicked ( QTreeWidgetItem*, int) ), this, SLOT( gameSelected(QTreeWidgetItem*, int) ) );
|
||||||
|
connect( treeWidget_GameList, SIGNAL( clear () ), this, SLOT( clearGames() ) );
|
||||||
|
|
||||||
pushButton_JoinGame->setEnabled(false);
|
pushButton_JoinGame->setEnabled(false);
|
||||||
|
|
||||||
@@ -98,8 +99,16 @@ void gameLobbyDialogImpl::gameSelected(QTreeWidgetItem* item, int)
|
|||||||
|
|
||||||
currentGameName = item->text(0);
|
currentGameName = item->text(0);
|
||||||
|
|
||||||
groupBox_GameInfo->setEnabled(TRUE);
|
groupBox_GameInfo->setEnabled(true);
|
||||||
groupBox_GameInfo->setTitle("Game Info - " + item->text(0));
|
groupBox_GameInfo->setTitle(tr("Game Info") + " - " + currentGameName);
|
||||||
|
|
||||||
|
assert(mySession);
|
||||||
|
GameInfo info = mySession->getClientGameInfo(currentGameName.toUtf8().constData());
|
||||||
|
label_SmallBlind->setText(QString::number(info.data.smallBlind));
|
||||||
|
label_StartCash->setText(QString::number(info.data.startMoney));
|
||||||
|
label_MaximumNumberOfPlayers->setText(QString::number(info.data.maxNumberOfPlayers));
|
||||||
|
label_HandsToRaiseSmallBlind->setText(QString::number(info.data.handsBeforeRaise));
|
||||||
|
label_TimeoutForPlayerAction->setText(QString::number(info.data.playerActionTimeoutSec));
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameLobbyDialogImpl::addGame(QString gameName)
|
void gameLobbyDialogImpl::addGame(QString gameName)
|
||||||
@@ -116,3 +125,17 @@ void gameLobbyDialogImpl::removeGame(QString gameName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gameLobbyDialogImpl::clearGames()
|
||||||
|
{
|
||||||
|
pushButton_JoinGame->setEnabled(false);
|
||||||
|
groupBox_GameInfo->setTitle(tr("Game Info"));
|
||||||
|
groupBox_GameInfo->setEnabled(false);
|
||||||
|
currentGameName = "";
|
||||||
|
|
||||||
|
label_SmallBlind->setText("");
|
||||||
|
label_StartCash->setText("");
|
||||||
|
label_MaximumNumberOfPlayers->setText("");
|
||||||
|
label_HandsToRaiseSmallBlind->setText("");
|
||||||
|
label_TimeoutForPlayerAction->setText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ public slots:
|
|||||||
void setCurrentGameName ( const QString& theValue ) { currentGameName = theValue; }
|
void setCurrentGameName ( const QString& theValue ) { currentGameName = theValue; }
|
||||||
QString getCurrentGameName() const { return currentGameName; }
|
QString getCurrentGameName() const { return currentGameName; }
|
||||||
|
|
||||||
|
void clearGames();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ConfigFile *myConfig;
|
ConfigFile *myConfig;
|
||||||
|
|||||||
@@ -121,7 +121,8 @@ void GuiWrapper::SignalNetClientPlayerLeft(const string &playerName)
|
|||||||
{
|
{
|
||||||
QString tmpName(QString::fromUtf8(playerName.c_str()));
|
QString tmpName(QString::fromUtf8(playerName.c_str()));
|
||||||
myW->signalNetClientPlayerLeft(tmpName);
|
myW->signalNetClientPlayerLeft(tmpName);
|
||||||
myLog->signalLogPlayerLeftMsg(tmpName);
|
if (!playerName.empty() && playerName[0] != '#')
|
||||||
|
myLog->signalLogPlayerLeftMsg(tmpName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiWrapper::SignalNetClientGameListNew(const string &gameName) { myW->signalNetClientGameListNew(QString::fromUtf8(gameName.c_str())); }
|
void GuiWrapper::SignalNetClientGameListNew(const string &gameName) { myW->signalNetClientGameListNew(QString::fromUtf8(gameName.c_str())); }
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ startNetworkGameDialogImpl::startNetworkGameDialogImpl(QWidget *parent, ConfigFi
|
|||||||
connect( pushButton_startGame, SIGNAL( clicked() ), this, SLOT( startGame() ) );
|
connect( pushButton_startGame, SIGNAL( clicked() ), this, SLOT( startGame() ) );
|
||||||
connect( pushButton_Kick, SIGNAL( clicked() ), this, SLOT( kickPlayer() ) );
|
connect( pushButton_Kick, SIGNAL( clicked() ), this, SLOT( kickPlayer() ) );
|
||||||
connect( treeWidget, SIGNAL( itemClicked ( QTreeWidgetItem*, int) ), this, SLOT( playerSelected(QTreeWidgetItem*, int) ) );
|
connect( treeWidget, SIGNAL( itemClicked ( QTreeWidgetItem*, int) ), this, SLOT( playerSelected(QTreeWidgetItem*, int) ) );
|
||||||
|
connect( treeWidget, SIGNAL( clear () ), this, SLOT( clearPlayers() ) );
|
||||||
|
|
||||||
pushButton_Kick->setEnabled(false);
|
pushButton_Kick->setEnabled(false);
|
||||||
pushButton_startGame->setEnabled(false);
|
pushButton_startGame->setEnabled(false);
|
||||||
@@ -114,20 +115,25 @@ void startNetworkGameDialogImpl::kickPlayer() {
|
|||||||
mySession->kickPlayer(playerName.toUtf8().constData());
|
mySession->kickPlayer(playerName.toUtf8().constData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pushButton_Kick->setEnabled(FALSE);
|
pushButton_Kick->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void startNetworkGameDialogImpl::checkPlayerQuantity() {
|
void startNetworkGameDialogImpl::checkPlayerQuantity() {
|
||||||
|
|
||||||
if (treeWidget->topLevelItemCount() >= 2 && isAdmin) {
|
if (treeWidget->topLevelItemCount() >= 2 && isAdmin) {
|
||||||
pushButton_startGame->setEnabled(TRUE);
|
pushButton_startGame->setEnabled(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pushButton_startGame->setEnabled(FALSE);
|
pushButton_startGame->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void startNetworkGameDialogImpl::clearPlayers()
|
||||||
|
{
|
||||||
|
pushButton_Kick->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
void startNetworkGameDialogImpl::setSession(Session *session)
|
void startNetworkGameDialogImpl::setSession(Session *session)
|
||||||
{
|
{
|
||||||
mySession = session;
|
mySession = session;
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public slots:
|
|||||||
void playerSelected(QTreeWidgetItem*, int);
|
void playerSelected(QTreeWidgetItem*, int);
|
||||||
void kickPlayer();
|
void kickPlayer();
|
||||||
void checkPlayerQuantity();
|
void checkPlayerQuantity();
|
||||||
|
void clearPlayers();
|
||||||
|
|
||||||
void keyPressEvent ( QKeyEvent*);
|
void keyPressEvent ( QKeyEvent*);
|
||||||
|
|
||||||
|
|||||||
@@ -62,11 +62,13 @@ public:
|
|||||||
void SendJoinGame(const std::string &name, const std::string &password);
|
void SendJoinGame(const std::string &name, const std::string &password);
|
||||||
void SendCreateGame(const GameData &gameData, const std::string &name, const std::string &password);
|
void SendCreateGame(const GameData &gameData, const std::string &name, const std::string &password);
|
||||||
|
|
||||||
|
GameInfo GetGameInfo(const std::string &game) const;
|
||||||
|
|
||||||
ClientCallback &GetCallback();
|
ClientCallback &GetCallback();
|
||||||
GuiInterface &GetGui();
|
GuiInterface &GetGui();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef std::map<unsigned, std::string> GameMap;
|
typedef std::map<unsigned, GameInfo> GameInfoMap;
|
||||||
typedef std::list<boost::shared_ptr<NetPacket> > NetPacketList;
|
typedef std::list<boost::shared_ptr<NetPacket> > NetPacketList;
|
||||||
typedef std::map<unsigned, PlayerInfo> PlayerInfoMap;
|
typedef std::map<unsigned, PlayerInfo> PlayerInfoMap;
|
||||||
|
|
||||||
@@ -110,8 +112,8 @@ protected:
|
|||||||
void RemoveDisconnectedPlayers();
|
void RemoveDisconnectedPlayers();
|
||||||
|
|
||||||
unsigned GetGameIdByName(const std::string &name) const;
|
unsigned GetGameIdByName(const std::string &name) const;
|
||||||
void AddGameInformation(unsigned id, const std::string &name);
|
void AddGameInfo(unsigned id, const GameInfo &info);
|
||||||
void RemoveGameInformation(unsigned id);
|
void RemoveGameInfo(unsigned id);
|
||||||
|
|
||||||
bool IsSessionEstablished() const;
|
bool IsSessionEstablished() const;
|
||||||
void SetSessionEstablished(bool flag);
|
void SetSessionEstablished(bool flag);
|
||||||
@@ -133,8 +135,8 @@ private:
|
|||||||
StartData m_startData;
|
StartData m_startData;
|
||||||
PlayerDataList m_playerDataList;
|
PlayerDataList m_playerDataList;
|
||||||
|
|
||||||
GameMap m_gameMap;
|
GameInfoMap m_gameInfoMap;
|
||||||
mutable boost::mutex m_gameMapMutex;
|
mutable boost::mutex m_gameInfoMapMutex;
|
||||||
|
|
||||||
boost::shared_ptr<Game> m_game;
|
boost::shared_ptr<Game> m_game;
|
||||||
PlayerInfoMap m_playerInfoMap;
|
PlayerInfoMap m_playerInfoMap;
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ ClientStateWaitJoin::InternalProcess(ClientThread &client, boost::shared_ptr<Net
|
|||||||
// A new game was created on the server.
|
// A new game was created on the server.
|
||||||
NetPacketGameListNew::Data gameListNewData;
|
NetPacketGameListNew::Data gameListNewData;
|
||||||
packet->ToNetPacketGameListNew()->GetData(gameListNewData);
|
packet->ToNetPacketGameListNew()->GetData(gameListNewData);
|
||||||
client.AddGameInformation(gameListNewData.gameId, gameListNewData.gameName);
|
client.AddGameInfo(gameListNewData.gameId, gameListNewData.gameInfo);
|
||||||
}
|
}
|
||||||
else if (packet->ToNetPacketGameListUpdate())
|
else if (packet->ToNetPacketGameListUpdate())
|
||||||
{
|
{
|
||||||
@@ -493,7 +493,7 @@ ClientStateWaitJoin::InternalProcess(ClientThread &client, boost::shared_ptr<Net
|
|||||||
NetPacketGameListUpdate::Data gameListUpdateData;
|
NetPacketGameListUpdate::Data gameListUpdateData;
|
||||||
packet->ToNetPacketGameListUpdate()->GetData(gameListUpdateData);
|
packet->ToNetPacketGameListUpdate()->GetData(gameListUpdateData);
|
||||||
if (gameListUpdateData.gameMode == GAME_MODE_CLOSED)
|
if (gameListUpdateData.gameMode == GAME_MODE_CLOSED)
|
||||||
client.RemoveGameInformation(gameListUpdateData.gameId);
|
client.RemoveGameInfo(gameListUpdateData.gameId);
|
||||||
}
|
}
|
||||||
else if (packet->ToNetPacketJoinGameAck())
|
else if (packet->ToNetPacketJoinGameAck())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -216,6 +216,26 @@ ClientThread::SendCreateGame(const GameData &gameData, const std::string &name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameInfo
|
||||||
|
ClientThread::GetGameInfo(const string &game) const
|
||||||
|
{
|
||||||
|
GameInfo tmpInfo;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
unsigned id = GetGameIdByName(game);
|
||||||
|
|
||||||
|
boost::mutex::scoped_lock lock(m_gameInfoMapMutex);
|
||||||
|
GameInfoMap::const_iterator pos = m_gameInfoMap.find(id);
|
||||||
|
if (pos != m_gameInfoMap.end())
|
||||||
|
{
|
||||||
|
tmpInfo = pos->second;
|
||||||
|
}
|
||||||
|
} catch (const NetException &)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return tmpInfo;
|
||||||
|
}
|
||||||
|
|
||||||
ClientCallback &
|
ClientCallback &
|
||||||
ClientThread::GetCallback()
|
ClientThread::GetCallback()
|
||||||
{
|
{
|
||||||
@@ -469,7 +489,13 @@ ClientThread::RemovePlayerData(unsigned playerId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!playerName.empty())
|
if (!playerName.empty())
|
||||||
|
{
|
||||||
|
// Remove name and id string.
|
||||||
GetCallback().SignalNetClientPlayerLeft(playerName);
|
GetCallback().SignalNetClientPlayerLeft(playerName);
|
||||||
|
ostringstream name;
|
||||||
|
name << "#" << playerId;
|
||||||
|
GetCallback().SignalNetClientPlayerLeft(name.str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -581,12 +607,12 @@ unsigned
|
|||||||
ClientThread::GetGameIdByName(const std::string &name) const
|
ClientThread::GetGameIdByName(const std::string &name) const
|
||||||
{
|
{
|
||||||
// Find the game.
|
// Find the game.
|
||||||
boost::mutex::scoped_lock lock(m_gameMapMutex);
|
boost::mutex::scoped_lock lock(m_gameInfoMapMutex);
|
||||||
GameMap::const_iterator i = m_gameMap.begin();
|
GameInfoMap::const_iterator i = m_gameInfoMap.begin();
|
||||||
GameMap::const_iterator end = m_gameMap.end();
|
GameInfoMap::const_iterator end = m_gameInfoMap.end();
|
||||||
while (i != end)
|
while (i != end)
|
||||||
{
|
{
|
||||||
if (i->second == name)
|
if (i->second.name == name)
|
||||||
break;
|
break;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@@ -597,29 +623,26 @@ ClientThread::GetGameIdByName(const std::string &name) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientThread::AddGameInformation(unsigned id, const std::string &name)
|
ClientThread::AddGameInfo(unsigned id, const GameInfo &info)
|
||||||
{
|
{
|
||||||
if (!name.empty())
|
|
||||||
{
|
{
|
||||||
{
|
boost::mutex::scoped_lock lock(m_gameInfoMapMutex);
|
||||||
boost::mutex::scoped_lock lock(m_gameMapMutex);
|
m_gameInfoMap.insert(GameInfoMap::value_type(id, info));
|
||||||
m_gameMap.insert(GameMap::value_type(id, name));
|
|
||||||
}
|
|
||||||
GetCallback().SignalNetClientGameListNew(name);
|
|
||||||
}
|
}
|
||||||
|
GetCallback().SignalNetClientGameListNew(info.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientThread::RemoveGameInformation(unsigned id)
|
ClientThread::RemoveGameInfo(unsigned id)
|
||||||
{
|
{
|
||||||
string name;
|
string name;
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_gameMapMutex);
|
boost::mutex::scoped_lock lock(m_gameInfoMapMutex);
|
||||||
GameMap::iterator pos = m_gameMap.find(id);
|
GameInfoMap::iterator pos = m_gameInfoMap.find(id);
|
||||||
if (pos != m_gameMap.end())
|
if (pos != m_gameInfoMap.end())
|
||||||
{
|
{
|
||||||
name = pos->second;
|
name = pos->second.name;
|
||||||
m_gameMap.erase(pos);
|
m_gameInfoMap.erase(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!name.empty())
|
if (!name.empty())
|
||||||
|
|||||||
@@ -1010,7 +1010,7 @@ NetPacketGameListNew::Clone() const
|
|||||||
void
|
void
|
||||||
NetPacketGameListNew::SetData(const NetPacketGameListNew::Data &inData)
|
NetPacketGameListNew::SetData(const NetPacketGameListNew::Data &inData)
|
||||||
{
|
{
|
||||||
u_int16_t gameNameLen = (u_int16_t)inData.gameName.length();
|
u_int16_t gameNameLen = (u_int16_t)inData.gameInfo.name.length();
|
||||||
|
|
||||||
// Some basic checks, so we don't use up too much memory.
|
// Some basic checks, so we don't use up too much memory.
|
||||||
// The constructed packet will also be checked.
|
// The constructed packet will also be checked.
|
||||||
@@ -1025,17 +1025,17 @@ NetPacketGameListNew::SetData(const NetPacketGameListNew::Data &inData)
|
|||||||
|
|
||||||
// Set the data.
|
// Set the data.
|
||||||
tmpData->gameId = htonl(inData.gameId);
|
tmpData->gameId = htonl(inData.gameId);
|
||||||
tmpData->gameMode = htons(inData.gameMode);
|
tmpData->gameMode = htons(inData.gameInfo.mode);
|
||||||
tmpData->gameNameLength = htons(gameNameLen);
|
tmpData->gameNameLength = htons(gameNameLen);
|
||||||
tmpData->maxNumberOfPlayers = htons(inData.gameData.maxNumberOfPlayers);
|
tmpData->maxNumberOfPlayers = htons(inData.gameInfo.data.maxNumberOfPlayers);
|
||||||
tmpData->smallBlind = htons(inData.gameData.smallBlind);
|
tmpData->smallBlind = htons(inData.gameInfo.data.smallBlind);
|
||||||
tmpData->handsBeforeRaise = htons(inData.gameData.handsBeforeRaise);
|
tmpData->handsBeforeRaise = htons(inData.gameInfo.data.handsBeforeRaise);
|
||||||
tmpData->proposedGuiSpeed = htons(inData.gameData.guiSpeed);
|
tmpData->proposedGuiSpeed = htons(inData.gameInfo.data.guiSpeed);
|
||||||
tmpData->playerActionTimeout = htons(inData.gameData.playerActionTimeoutSec);
|
tmpData->playerActionTimeout = htons(inData.gameInfo.data.playerActionTimeoutSec);
|
||||||
tmpData->startMoney = htonl(inData.gameData.startMoney);
|
tmpData->startMoney = htonl(inData.gameInfo.data.startMoney);
|
||||||
|
|
||||||
char *gameNamePtr = (char *)tmpData + sizeof(NetPacketGameListNewData);
|
char *gameNamePtr = (char *)tmpData + sizeof(NetPacketGameListNewData);
|
||||||
memcpy(gameNamePtr, inData.gameName.c_str(), gameNameLen);
|
memcpy(gameNamePtr, inData.gameInfo.name.c_str(), gameNameLen);
|
||||||
|
|
||||||
// Check the packet - just in case.
|
// Check the packet - just in case.
|
||||||
Check(GetRawData());
|
Check(GetRawData());
|
||||||
@@ -1047,18 +1047,18 @@ NetPacketGameListNew::GetData(NetPacketGameListNew::Data &outData) const
|
|||||||
// We assume that the data is valid. Validity has already been checked.
|
// We assume that the data is valid. Validity has already been checked.
|
||||||
NetPacketGameListNewData *tmpData = (NetPacketGameListNewData *)GetRawData();
|
NetPacketGameListNewData *tmpData = (NetPacketGameListNewData *)GetRawData();
|
||||||
|
|
||||||
outData.gameId = ntohl(tmpData->gameId);
|
outData.gameId = ntohl(tmpData->gameId);
|
||||||
outData.gameMode = static_cast<GameMode>(ntohs(tmpData->gameMode));
|
outData.gameInfo.mode = static_cast<GameMode>(ntohs(tmpData->gameMode));
|
||||||
u_int16_t gameNameLen = ntohs(tmpData->gameNameLength);
|
u_int16_t gameNameLen = ntohs(tmpData->gameNameLength);
|
||||||
outData.gameData.maxNumberOfPlayers = ntohs(tmpData->maxNumberOfPlayers);
|
outData.gameInfo.data.maxNumberOfPlayers = ntohs(tmpData->maxNumberOfPlayers);
|
||||||
outData.gameData.smallBlind = ntohs(tmpData->smallBlind);
|
outData.gameInfo.data.smallBlind = ntohs(tmpData->smallBlind);
|
||||||
outData.gameData.handsBeforeRaise = ntohs(tmpData->handsBeforeRaise);
|
outData.gameInfo.data.handsBeforeRaise = ntohs(tmpData->handsBeforeRaise);
|
||||||
outData.gameData.guiSpeed = ntohs(tmpData->proposedGuiSpeed);
|
outData.gameInfo.data.guiSpeed = ntohs(tmpData->proposedGuiSpeed);
|
||||||
outData.gameData.playerActionTimeoutSec = ntohs(tmpData->playerActionTimeout);
|
outData.gameInfo.data.playerActionTimeoutSec= ntohs(tmpData->playerActionTimeout);
|
||||||
outData.gameData.startMoney = ntohl(tmpData->startMoney);
|
outData.gameInfo.data.startMoney = ntohl(tmpData->startMoney);
|
||||||
|
|
||||||
char *gameNamePtr = (char *)tmpData + sizeof(NetPacketGameListNewData);
|
char *gameNamePtr = (char *)tmpData + sizeof(NetPacketGameListNewData);
|
||||||
outData.gameName = string(gameNamePtr, gameNameLen);
|
outData.gameInfo.name = string(gameNamePtr, gameNameLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
const NetPacketGameListNew *
|
const NetPacketGameListNew *
|
||||||
|
|||||||
@@ -225,6 +225,7 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const NetPacketIn
|
|||||||
// Partly, this is also done in netpacket.
|
// Partly, this is also done in netpacket.
|
||||||
// However, some disallowed names are checked only here.
|
// However, some disallowed names are checked only here.
|
||||||
if (initData.playerName.empty() || initData.playerName.size() > MAX_NAME_SIZE
|
if (initData.playerName.empty() || initData.playerName.size() > MAX_NAME_SIZE
|
||||||
|
|| initData.playerName[0] == '#'
|
||||||
|| initData.playerName.substr(0, sizeof(SERVER_COMPUTER_PLAYER_NAME) - 1) == SERVER_COMPUTER_PLAYER_NAME)
|
|| initData.playerName.substr(0, sizeof(SERVER_COMPUTER_PLAYER_NAME) - 1) == SERVER_COMPUTER_PLAYER_NAME)
|
||||||
{
|
{
|
||||||
SessionError(session, ERR_NET_INVALID_PLAYER_NAME);
|
SessionError(session, ERR_NET_INVALID_PLAYER_NAME);
|
||||||
@@ -552,9 +553,9 @@ ServerLobbyThread::CreateNetPacketGameListNew(const ServerGameThread &game)
|
|||||||
boost::shared_ptr<NetPacket> packet(new NetPacketGameListNew);
|
boost::shared_ptr<NetPacket> packet(new NetPacketGameListNew);
|
||||||
NetPacketGameListNew::Data packetData;
|
NetPacketGameListNew::Data packetData;
|
||||||
packetData.gameId = game.GetId();
|
packetData.gameId = game.GetId();
|
||||||
packetData.gameMode = GAME_MODE_CREATED;
|
packetData.gameInfo.mode = GAME_MODE_CREATED;
|
||||||
packetData.gameName = game.GetName();
|
packetData.gameInfo.name = game.GetName();
|
||||||
packetData.gameData = game.GetGameData();
|
packetData.gameInfo.data = game.GetGameData();
|
||||||
static_cast<NetPacketGameListNew *>(packet.get())->SetData(packetData);
|
static_cast<NetPacketGameListNew *>(packet.get())->SetData(packetData);
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -191,9 +191,7 @@ public:
|
|||||||
struct Data
|
struct Data
|
||||||
{
|
{
|
||||||
u_int32_t gameId;
|
u_int32_t gameId;
|
||||||
GameMode gameMode;
|
GameInfo gameInfo;
|
||||||
std::string gameName;
|
|
||||||
GameData gameData;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
NetPacketGameListNew();
|
NetPacketGameListNew();
|
||||||
|
|||||||
@@ -275,3 +275,10 @@ bool Session::isNetworkServerRunning() const
|
|||||||
// TODO
|
// TODO
|
||||||
return myNetServer != NULL;
|
return myNetServer != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameInfo Session::getClientGameInfo(const string &game)
|
||||||
|
{
|
||||||
|
assert(myNetClient);
|
||||||
|
return myNetClient->GetGameInfo(game);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ public:
|
|||||||
bool isNetworkClientRunning() const; // TODO hack
|
bool isNetworkClientRunning() const; // TODO hack
|
||||||
bool isNetworkServerRunning() const; // TODO hack
|
bool isNetworkServerRunning() const; // TODO hack
|
||||||
|
|
||||||
|
GameInfo getClientGameInfo(const std::string &game);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int currentGameID;
|
int currentGameID;
|
||||||
|
|||||||
Reference in New Issue
Block a user