Use client game id when kicking players during game.

This commit is contained in:
lotodore
2007-10-28 19:38:49 +00:00
parent ffc8bb4485
commit 3ea61381ef
7 changed files with 46 additions and 20 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ void Chat::sendMessage() {
QString playerToKick = myW->lineEdit_ChatInput->text().section(" ",1,1);
myW->lineEdit_ChatInput->setText("");
if(myW->getSession().getClientGameInfo(myW->getSession().getCurrentGame()->getMyGameID()).adminPlayerId == myW->getSession().getCurrentGame()->getSeatsList()->front()->getMyUniqueID()) {
if(myW->getSession().getClientGameInfo(myW->getSession().getClientCurrentGameId()).adminPlayerId == myW->getSession().getCurrentGame()->getSeatsList()->front()->getMyUniqueID()) {
if(playerToKick.toUtf8().constData() == myW->getSession().getCurrentGame()->getSeatsList()->front()->getMyName()) {
myW->textBrowser_Chat->append("<span style=\"color:#ff0000;\">"+tr("You cannot kick yourself!")+"</span>");
+1 -1
View File
@@ -3547,7 +3547,7 @@ void mainWindowImpl::networkGameModification() {
void mainWindowImpl::mouseOverFlipCards(bool front) {
if(mySession->getCurrentGameID()) {
if(mySession->getCurrentGame()) {
if(myConfig->readConfigInt("AntiPeekMode") && mySession->getCurrentGame()->getCurrentHand()->getSeatsList()->front()->getMyActiveStatus() && mySession->getCurrentGame()->getSeatsList()->front()->getMyAction() != PLAYER_ACTION_FOLD) {
holeCardsArray[0][0]->signalFastFlipCards(front);
holeCardsArray[0][1]->signalFastFlipCards(front);
+7 -2
View File
@@ -65,10 +65,11 @@ public:
void SendJoinGame(unsigned gameId, const std::string &password);
void SendCreateGame(const GameData &gameData, const std::string &name, const std::string &password);
GameInfo GetGameInfo(unsigned playerId) const;
GameInfo GetGameInfo(unsigned gameId) const;
PlayerInfo GetPlayerInfo(unsigned playerId) const;
bool GetPlayerIdFromName(const std::string &playerName, unsigned &playerId) const;
ServerStats GetStatData() const;
unsigned GetGameId() const;
ClientCallback &GetCallback();
GuiInterface &GetGui();
@@ -106,6 +107,7 @@ protected:
SenderThread &GetSender();
ReceiverHelper &GetReceiver();
void SetGameId(unsigned id);
const GameData &GetGameData() const;
void SetGameData(const GameData &gameData);
const StartData &GetStartData() const;
@@ -170,9 +172,12 @@ private:
mutable boost::mutex m_playerInfoMapMutex;
PlayerIdList m_playerInfoRequestList;
unsigned m_curGameId;
mutable boost::mutex m_curGameIdMutex;
AvatarDataMap m_tempAvatarMap;
unsigned m_curGameId;
unsigned m_curGameNum;
unsigned m_guiPlayerId;
bool m_sessionEstablished;
+1
View File
@@ -628,6 +628,7 @@ ClientStateWaitJoin::InternalProcess(ClientThread &client, boost::shared_ptr<Net
// Successfully joined a game.
NetPacketJoinGameAck::Data joinGameAckData;
packet->ToNetPacketJoinGameAck()->GetData(joinGameAckData);
client.SetGameId(joinGameAckData.gameId);
client.SetGameData(joinGameAckData.gameData);
// Player number is 0 on init. Will be set when the game starts.
+16 -2
View File
@@ -56,7 +56,7 @@ private:
ClientThread::ClientThread(GuiInterface &gui, AvatarManager &avatarManager)
: m_curState(NULL), m_gui(gui), m_avatarManager(avatarManager),
m_curGameId(1), m_guiPlayerId(0), m_sessionEstablished(false)
m_curGameId(0), m_curGameNum(1), m_guiPlayerId(0), m_sessionEstablished(false)
{
m_context.reset(new ClientContext);
m_senderCallback.reset(new ClientSenderCallback(*this));
@@ -331,7 +331,7 @@ ClientThread::Main()
MapPlayerDataList();
if (GetPlayerDataList().size() != (unsigned)GetStartData().numberOfPlayers)
throw ClientException(__FILE__, __LINE__, ERR_NET_INVALID_PLAYER_COUNT, 0);
m_game.reset(new Game(&m_gui, factory, GetPlayerDataList(), GetGameData(), GetStartData(), m_curGameId++));
m_game.reset(new Game(&m_gui, factory, GetPlayerDataList(), GetGameData(), GetStartData(), m_curGameNum++));
// Initialize GUI speed.
GetGui().initGui(GetGameData().guiSpeed);
// Signal start of game to GUI.
@@ -566,6 +566,20 @@ ClientThread::GetReceiver()
return *m_receiver;
}
unsigned
ClientThread::GetGameId() const
{
boost::mutex::scoped_lock lock(m_curGameIdMutex);
return m_curGameId;
}
void
ClientThread::SetGameId(unsigned id)
{
boost::mutex::scoped_lock lock(m_curGameIdMutex);
m_curGameId = id;
}
const GameData &
ClientThread::GetGameData() const
{
+15 -7
View File
@@ -39,7 +39,7 @@
using namespace std;
Session::Session(GuiInterface *g, ConfigFile *c)
: currentGameID(0), myNetClient(NULL), myNetServer(NULL), myIrcThread(NULL),
: currentGameNum(0), myNetClient(NULL), myNetServer(NULL), myIrcThread(NULL),
myGui(g), myConfig(c), myGameType(GAME_TYPE_NONE)
{
}
@@ -71,7 +71,7 @@ void Session::startLocalGame(const GameData &gameData, const StartData &startDat
myGameType = GAME_TYPE_LOCAL;
currentGame.reset();
currentGameID++;
currentGameNum++;
myGui->initGui(gameData.guiSpeed);
@@ -99,7 +99,7 @@ void Session::startLocalGame(const GameData &gameData, const StartData &startDat
// EngineFactory erstellen
boost::shared_ptr<EngineFactory> factory(new LocalEngineFactory(myConfig)); // LocalEngine erstellen
currentGame.reset(new Game(myGui, factory, playerDataList, gameData, startData, currentGameID));
currentGame.reset(new Game(myGui, factory, playerDataList, gameData, startData, currentGameNum));
//// SPIEL-SCHLEIFE
currentGame->initHand();
@@ -109,7 +109,7 @@ void Session::startLocalGame(const GameData &gameData, const StartData &startDat
void Session::startClientGame(boost::shared_ptr<Game> game)
{
currentGameID++;
currentGameNum++;
currentGame = game;
}
@@ -358,7 +358,7 @@ bool Session::isNetworkServerRunning() const
return myNetServer != NULL;
}
GameInfo Session::getClientGameInfo(unsigned playerId)
GameInfo Session::getClientGameInfo(unsigned playerId) const
{
GameInfo info;
if (myNetClient)
@@ -366,7 +366,7 @@ GameInfo Session::getClientGameInfo(unsigned playerId)
return info;
}
PlayerInfo Session::getClientPlayerInfo(unsigned playerId)
PlayerInfo Session::getClientPlayerInfo(unsigned playerId) const
{
PlayerInfo info;
if (myNetClient)
@@ -374,7 +374,7 @@ PlayerInfo Session::getClientPlayerInfo(unsigned playerId)
return info;
}
ServerStats Session::getClientStats()
ServerStats Session::getClientStats() const
{
ServerStats stats;
if (myNetClient)
@@ -382,3 +382,11 @@ ServerStats Session::getClientStats()
return stats;
}
unsigned Session::getClientCurrentGameId() const
{
unsigned id = 0;
if (myNetClient)
id = myNetClient->GetGameId();
return id;
}
+5 -7
View File
@@ -72,9 +72,6 @@ public:
void sendClientPlayerAction();
void setCurrentGameID(int theValue) { currentGameID = theValue; }
int getCurrentGameID() const { return currentGameID; }
void sendChatMessage(const std::string &message);
void kickPlayer(unsigned playerId);
void kickPlayer(const std::string &playerName);
@@ -82,13 +79,14 @@ public:
bool isNetworkClientRunning() const; // TODO hack
bool isNetworkServerRunning() const; // TODO hack
GameInfo getClientGameInfo(unsigned gameId);
PlayerInfo getClientPlayerInfo(unsigned playerId);
ServerStats getClientStats();
GameInfo getClientGameInfo(unsigned gameId) const;
PlayerInfo getClientPlayerInfo(unsigned playerId) const;
ServerStats getClientStats() const;
unsigned getClientCurrentGameId() const;
private:
int currentGameID;
int currentGameNum;
ClientThread *myNetClient;
ServerAcceptThread *myNetServer;