Fixed g++ warnings. Additional client displaying.
This commit is contained in:
@@ -24,6 +24,26 @@ using namespace std;
|
|||||||
ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC)
|
ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC)
|
||||||
: myFactory(f), myGui(g), myBoard(b), playerArray(p), myPreflop(0), myFlop(0), myTurn(0), myRiver(0), myID(id), actualQuantityPlayers(aP), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), allInCondition(0), bettingRoundsPlayed(0)
|
: myFactory(f), myGui(g), myBoard(b), playerArray(p), myPreflop(0), myFlop(0), myTurn(0), myRiver(0), myID(id), actualQuantityPlayers(aP), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), allInCondition(0), bettingRoundsPlayed(0)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
lastPlayersTurn = 0;
|
||||||
|
|
||||||
|
myBoard->setHand(this);
|
||||||
|
|
||||||
|
|
||||||
|
for(i=0; i<startQuantityPlayers; i++) {
|
||||||
|
if(playerArray[i]->getMyActiveStatus() != 0) {
|
||||||
|
playerArray[i]->setHand(this);
|
||||||
|
}
|
||||||
|
playerArray[i]->setMyCardsFlip(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// roundStartCashArray fllen
|
||||||
|
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||||
|
playerArray[i]->setMyRoundStartCash(playerArray[i]->getMyCash());
|
||||||
|
}
|
||||||
|
|
||||||
|
assignButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -40,6 +60,42 @@ ClientHand::start()
|
|||||||
void
|
void
|
||||||
ClientHand::assignButtons()
|
ClientHand::assignButtons()
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
//Aktive Spieler zählen
|
||||||
|
int activePlayersCounter = 0;
|
||||||
|
for (i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||||
|
if (playerArray[i]->getMyActiveStatus() == 1) activePlayersCounter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// alle Buttons loeschen
|
||||||
|
for (i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { playerArray[i]->setMyButton(0); }
|
||||||
|
|
||||||
|
// DealerButton zuweisen
|
||||||
|
playerArray[dealerPosition]->setMyButton(1);
|
||||||
|
|
||||||
|
// assign Small Blind next to dealer. ATTENTION: in heads up it is big blind
|
||||||
|
i = dealerPosition;
|
||||||
|
do {
|
||||||
|
i = (i+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||||
|
if(playerArray[i]->getMyActiveStatus()) {
|
||||||
|
if(activePlayersCounter > 2) playerArray[i]->setMyButton(2); //small blind normal
|
||||||
|
else playerArray[i]->setMyButton(3); //big blind in heads up
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} while(!(playerArray[i]->getMyActiveStatus()));
|
||||||
|
|
||||||
|
// assign big blind next to small blind. ATTENTION: in heads up it is small blind
|
||||||
|
do {
|
||||||
|
i = (i+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||||
|
if(playerArray[i]->getMyActiveStatus()) {
|
||||||
|
if(activePlayersCounter > 2) playerArray[i]->setMyButton(3); //big blind normal
|
||||||
|
else playerArray[i]->setMyButton(2); //small blind in heads up
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} while(!(playerArray[i]->getMyActiveStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ using namespace std;
|
|||||||
Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||||
const PlayerDataList &playerDataList, const GameData &gameData,
|
const PlayerDataList &playerDataList, const GameData &gameData,
|
||||||
const StartData &startData, int gameId)
|
const StartData &startData, int gameId)
|
||||||
: myGui(gui), myFactory(factory), actualHand(0), actualBoard(0),
|
: myFactory(factory), myGui(gui), actualHand(0), actualBoard(0),
|
||||||
startQuantityPlayers(gameData.numberOfPlayers),
|
startQuantityPlayers(gameData.numberOfPlayers),
|
||||||
startCash(gameData.startCash), startSmallBlind(gameData.smallBlind),
|
startCash(gameData.startCash), startSmallBlind(gameData.smallBlind),
|
||||||
startHandsBeforeRaiseSmallBlind(gameData.handsBeforeRaise),
|
startHandsBeforeRaiseSmallBlind(gameData.handsBeforeRaise),
|
||||||
|
|||||||
@@ -514,7 +514,7 @@ ClientStateWaitHand::Process(ClientThread &client)
|
|||||||
myCards[0] = (int)tmpData.yourCards[0];
|
myCards[0] = (int)tmpData.yourCards[0];
|
||||||
myCards[1] = (int)tmpData.yourCards[1];
|
myCards[1] = (int)tmpData.yourCards[1];
|
||||||
client.GetGame()->getPlayerArray()[0]->setMyCards(myCards);
|
client.GetGame()->getPlayerArray()[0]->setMyCards(myCards);
|
||||||
client.GetGame()->initHand();
|
client.GetGame()->initHand();
|
||||||
client.GetGame()->startHand();
|
client.GetGame()->startHand();
|
||||||
client.GetGui().dealHoleCards();
|
client.GetGui().dealHoleCards();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,18 +52,20 @@ using namespace std;
|
|||||||
#define NET_ERR_OTHER 0xFFFF
|
#define NET_ERR_OTHER 0xFFFF
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma pack(push, 2)
|
#pragma pack(push, 1)
|
||||||
|
#define GCC_PACKED
|
||||||
#else
|
#else
|
||||||
#pragma align 2
|
#define GCC_PACKED __attribute__ ((__packed__))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct NetPacketHeader
|
|
||||||
|
struct GCC_PACKED NetPacketHeader
|
||||||
{
|
{
|
||||||
u_int16_t type;
|
u_int16_t type;
|
||||||
u_int16_t length;
|
u_int16_t length;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NetPacketJoinGameData
|
struct GCC_PACKED NetPacketJoinGameData
|
||||||
{
|
{
|
||||||
NetPacketHeader head;
|
NetPacketHeader head;
|
||||||
u_int16_t requestedVersionMajor;
|
u_int16_t requestedVersionMajor;
|
||||||
@@ -75,7 +77,7 @@ struct NetPacketJoinGameData
|
|||||||
char password[1];
|
char password[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NetPacketJoinGameAckData
|
struct GCC_PACKED NetPacketJoinGameAckData
|
||||||
{
|
{
|
||||||
NetPacketHeader head;
|
NetPacketHeader head;
|
||||||
u_int32_t sessionId;
|
u_int32_t sessionId;
|
||||||
@@ -88,14 +90,14 @@ struct NetPacketJoinGameAckData
|
|||||||
u_int32_t startCash;
|
u_int32_t startCash;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NetPacketJoinGameErrorData
|
struct GCC_PACKED NetPacketJoinGameErrorData
|
||||||
{
|
{
|
||||||
NetPacketHeader head;
|
NetPacketHeader head;
|
||||||
u_int16_t errorReason;
|
u_int16_t errorReason;
|
||||||
u_int16_t reserved;
|
u_int16_t reserved;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NetPacketPlayerJoinedData
|
struct GCC_PACKED NetPacketPlayerJoinedData
|
||||||
{
|
{
|
||||||
NetPacketHeader head;
|
NetPacketHeader head;
|
||||||
u_int16_t playerId;
|
u_int16_t playerId;
|
||||||
@@ -105,34 +107,34 @@ struct NetPacketPlayerJoinedData
|
|||||||
char playerName[1];
|
char playerName[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NetPacketPlayerLeftData
|
struct GCC_PACKED NetPacketPlayerLeftData
|
||||||
{
|
{
|
||||||
NetPacketHeader head;
|
NetPacketHeader head;
|
||||||
u_int16_t playerId;
|
u_int16_t playerId;
|
||||||
u_int16_t reserved;
|
u_int16_t reserved;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NetPacketGameStartData
|
struct GCC_PACKED NetPacketGameStartData
|
||||||
{
|
{
|
||||||
NetPacketHeader head;
|
NetPacketHeader head;
|
||||||
u_int16_t startDealerPlayerId;
|
u_int16_t startDealerPlayerId;
|
||||||
u_int16_t reserved;
|
u_int16_t reserved;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NetPacketHandStartData
|
struct GCC_PACKED NetPacketHandStartData
|
||||||
{
|
{
|
||||||
NetPacketHeader head;
|
NetPacketHeader head;
|
||||||
u_int16_t yourCards[2];
|
u_int16_t yourCards[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NetPacketPlayersTurnData
|
struct GCC_PACKED NetPacketPlayersTurnData
|
||||||
{
|
{
|
||||||
NetPacketHeader head;
|
NetPacketHeader head;
|
||||||
u_int16_t gameState;
|
u_int16_t gameState;
|
||||||
u_int16_t playerId;
|
u_int16_t playerId;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NetPacketPlayersActionData
|
struct GCC_PACKED NetPacketPlayersActionData
|
||||||
{
|
{
|
||||||
NetPacketHeader head;
|
NetPacketHeader head;
|
||||||
u_int16_t gameState;
|
u_int16_t gameState;
|
||||||
@@ -140,7 +142,7 @@ struct NetPacketPlayersActionData
|
|||||||
u_int32_t cashValue;
|
u_int32_t cashValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NetPacketPlayersActionRejectedData
|
struct GCC_PACKED NetPacketPlayersActionRejectedData
|
||||||
{
|
{
|
||||||
NetPacketHeader head;
|
NetPacketHeader head;
|
||||||
u_int16_t gameState;
|
u_int16_t gameState;
|
||||||
@@ -150,7 +152,7 @@ struct NetPacketPlayersActionRejectedData
|
|||||||
u_int16_t reserved;
|
u_int16_t reserved;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NetPacketErrorData
|
struct GCC_PACKED NetPacketErrorData
|
||||||
{
|
{
|
||||||
NetPacketHeader head;
|
NetPacketHeader head;
|
||||||
u_int16_t reason;
|
u_int16_t reason;
|
||||||
@@ -159,8 +161,6 @@ struct NetPacketErrorData
|
|||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
#else
|
|
||||||
#pragma align 0
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
#include <core/rand.h>
|
#include <core/rand.h>
|
||||||
#include <gamedata.h>
|
#include <gamedata.h>
|
||||||
#include <game.h>
|
#include <game.h>
|
||||||
#include <tools.h>
|
|
||||||
#include <playerinterface.h>
|
#include <playerinterface.h>
|
||||||
#include <handinterface.h>
|
#include <handinterface.h>
|
||||||
|
|
||||||
@@ -224,15 +223,6 @@ ServerRecvStateStartGame::HandleNewConnection(ServerRecvThread &server, boost::s
|
|||||||
int
|
int
|
||||||
ServerRecvStateStartGame::Process(ServerRecvThread &server)
|
ServerRecvStateStartGame::Process(ServerRecvThread &server)
|
||||||
{
|
{
|
||||||
{
|
|
||||||
// Set dealer pos.
|
|
||||||
StartData startData;
|
|
||||||
int tmpDealerPos = 0;
|
|
||||||
Tools::getRandNumber(0, server.GetGameData().numberOfPlayers-1, 1, &tmpDealerPos, 0);
|
|
||||||
startData.startDealerPlayerId = static_cast<unsigned>(tmpDealerPos);
|
|
||||||
server.SetStartData(startData);
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::shared_ptr<NetPacket> answer(new NetPacketGameStart);
|
boost::shared_ptr<NetPacket> answer(new NetPacketGameStart);
|
||||||
|
|
||||||
NetPacketGameStart::Data gameStartData;
|
NetPacketGameStart::Data gameStartData;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <net/receiverhelper.h>
|
#include <net/receiverhelper.h>
|
||||||
#include <net/socket_msg.h>
|
#include <net/socket_msg.h>
|
||||||
#include <game.h>
|
#include <game.h>
|
||||||
|
#include <tools.h>
|
||||||
#include <localenginefactory.h>
|
#include <localenginefactory.h>
|
||||||
|
|
||||||
#include <boost/lambda/lambda.hpp>
|
#include <boost/lambda/lambda.hpp>
|
||||||
@@ -251,6 +252,13 @@ ServerRecvThread::InternalStartGame()
|
|||||||
// EngineFactory erstellen
|
// EngineFactory erstellen
|
||||||
boost::shared_ptr<EngineFactory> factory(new LocalEngineFactory(m_playerConfig)); // LocalEngine erstellen
|
boost::shared_ptr<EngineFactory> factory(new LocalEngineFactory(m_playerConfig)); // LocalEngine erstellen
|
||||||
|
|
||||||
|
// Set dealer pos.
|
||||||
|
StartData startData;
|
||||||
|
int tmpDealerPos = 0;
|
||||||
|
Tools::getRandNumber(0, GetGameData().numberOfPlayers-1, 1, &tmpDealerPos, 0);
|
||||||
|
startData.startDealerPlayerId = static_cast<unsigned>(tmpDealerPos);
|
||||||
|
SetStartData(startData);
|
||||||
|
|
||||||
m_game.reset(new Game(&gui, factory, playerData, GetGameData(), GetStartData(), m_curGameId++));
|
m_game.reset(new Game(&gui, factory, playerData, GetGameData(), GetStartData(), m_curGameId++));
|
||||||
SetState(SERVER_START_GAME_STATE::Instance());
|
SetState(SERVER_START_GAME_STATE::Instance());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user