Fixed g++ warnings. Additional client displaying.

This commit is contained in:
lotodore
2007-05-21 19:52:26 +00:00
parent 2ce67297ee
commit 4dd26a3c3a
6 changed files with 82 additions and 28 deletions
+56
View File
@@ -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)
: 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
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
+1 -1
View File
@@ -31,7 +31,7 @@ using namespace std;
Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
const PlayerDataList &playerDataList, const GameData &gameData,
const StartData &startData, int gameId)
: myGui(gui), myFactory(factory), actualHand(0), actualBoard(0),
: myFactory(factory), myGui(gui), actualHand(0), actualBoard(0),
startQuantityPlayers(gameData.numberOfPlayers),
startCash(gameData.startCash), startSmallBlind(gameData.smallBlind),
startHandsBeforeRaiseSmallBlind(gameData.handsBeforeRaise),
+1 -1
View File
@@ -514,7 +514,7 @@ ClientStateWaitHand::Process(ClientThread &client)
myCards[0] = (int)tmpData.yourCards[0];
myCards[1] = (int)tmpData.yourCards[1];
client.GetGame()->getPlayerArray()[0]->setMyCards(myCards);
client.GetGame()->initHand();
client.GetGame()->initHand();
client.GetGame()->startHand();
client.GetGui().dealHoleCards();
}
+16 -16
View File
@@ -52,18 +52,20 @@ using namespace std;
#define NET_ERR_OTHER 0xFFFF
#ifdef _MSC_VER
#pragma pack(push, 2)
#pragma pack(push, 1)
#define GCC_PACKED
#else
#pragma align 2
#define GCC_PACKED __attribute__ ((__packed__))
#endif
struct NetPacketHeader
struct GCC_PACKED NetPacketHeader
{
u_int16_t type;
u_int16_t length;
};
struct NetPacketJoinGameData
struct GCC_PACKED NetPacketJoinGameData
{
NetPacketHeader head;
u_int16_t requestedVersionMajor;
@@ -75,7 +77,7 @@ struct NetPacketJoinGameData
char password[1];
};
struct NetPacketJoinGameAckData
struct GCC_PACKED NetPacketJoinGameAckData
{
NetPacketHeader head;
u_int32_t sessionId;
@@ -88,14 +90,14 @@ struct NetPacketJoinGameAckData
u_int32_t startCash;
};
struct NetPacketJoinGameErrorData
struct GCC_PACKED NetPacketJoinGameErrorData
{
NetPacketHeader head;
u_int16_t errorReason;
u_int16_t reserved;
};
struct NetPacketPlayerJoinedData
struct GCC_PACKED NetPacketPlayerJoinedData
{
NetPacketHeader head;
u_int16_t playerId;
@@ -105,34 +107,34 @@ struct NetPacketPlayerJoinedData
char playerName[1];
};
struct NetPacketPlayerLeftData
struct GCC_PACKED NetPacketPlayerLeftData
{
NetPacketHeader head;
u_int16_t playerId;
u_int16_t reserved;
};
struct NetPacketGameStartData
struct GCC_PACKED NetPacketGameStartData
{
NetPacketHeader head;
u_int16_t startDealerPlayerId;
u_int16_t reserved;
};
struct NetPacketHandStartData
struct GCC_PACKED NetPacketHandStartData
{
NetPacketHeader head;
u_int16_t yourCards[2];
};
struct NetPacketPlayersTurnData
struct GCC_PACKED NetPacketPlayersTurnData
{
NetPacketHeader head;
u_int16_t gameState;
u_int16_t playerId;
};
struct NetPacketPlayersActionData
struct GCC_PACKED NetPacketPlayersActionData
{
NetPacketHeader head;
u_int16_t gameState;
@@ -140,7 +142,7 @@ struct NetPacketPlayersActionData
u_int32_t cashValue;
};
struct NetPacketPlayersActionRejectedData
struct GCC_PACKED NetPacketPlayersActionRejectedData
{
NetPacketHeader head;
u_int16_t gameState;
@@ -150,7 +152,7 @@ struct NetPacketPlayersActionRejectedData
u_int16_t reserved;
};
struct NetPacketErrorData
struct GCC_PACKED NetPacketErrorData
{
NetPacketHeader head;
u_int16_t reason;
@@ -159,8 +161,6 @@ struct NetPacketErrorData
#ifdef _MSC_VER
#pragma pack(pop)
#else
#pragma align 0
#endif
-10
View File
@@ -27,7 +27,6 @@
#include <core/rand.h>
#include <gamedata.h>
#include <game.h>
#include <tools.h>
#include <playerinterface.h>
#include <handinterface.h>
@@ -224,15 +223,6 @@ ServerRecvStateStartGame::HandleNewConnection(ServerRecvThread &server, boost::s
int
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);
NetPacketGameStart::Data gameStartData;
+8
View File
@@ -25,6 +25,7 @@
#include <net/receiverhelper.h>
#include <net/socket_msg.h>
#include <game.h>
#include <tools.h>
#include <localenginefactory.h>
#include <boost/lambda/lambda.hpp>
@@ -251,6 +252,13 @@ ServerRecvThread::InternalStartGame()
// EngineFactory 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++));
SetState(SERVER_START_GAME_STATE::Instance());
}