Game configuration now placed in a struct. Prepared to send/receive game configuration over tcp.
This commit is contained in:
@@ -147,3 +147,5 @@ Server Notification: Player's Turn
|
|||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
2007 by Lothar May
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ INCLUDEPATH += . \
|
|||||||
HEADERS += src/game.h \
|
HEADERS += src/game.h \
|
||||||
src/session.h \
|
src/session.h \
|
||||||
src/playerdata.h \
|
src/playerdata.h \
|
||||||
|
src/gamedata.h \
|
||||||
src/config/configfile.h \
|
src/config/configfile.h \
|
||||||
src/core/rand.h \
|
src/core/rand.h \
|
||||||
src/core/thread.h \
|
src/core/thread.h \
|
||||||
|
|||||||
+9
-9
@@ -18,6 +18,7 @@
|
|||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
#include "gamedata.h"
|
||||||
|
|
||||||
#include "enginefactory.h"
|
#include "enginefactory.h"
|
||||||
#include "localenginefactory.h"
|
#include "localenginefactory.h"
|
||||||
@@ -29,14 +30,15 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Game::Game(GuiInterface* gui, const PlayerDataList &playerData, int sC, int sB, int hbrsB, int gameId)
|
Game::Game(GuiInterface* gui, const PlayerDataList &playerDataList, const GameData &gameData, int gameId)
|
||||||
: myGui(gui), actualHand(0), actualBoard(0), startCash(sC),
|
: myGui(gui), actualHand(0), actualBoard(0), startQuantityPlayers(gameData.numberOfPlayers),
|
||||||
startSmallBlind(sB), startHandsBeforeRaiseSmallBlind(hbrsB),myGameID(gameId),
|
startCash(gameData.startCash), startSmallBlind(gameData.smallBlind),
|
||||||
actualSmallBlind(sB), actualHandID(0), dealerPosition(0)
|
startHandsBeforeRaiseSmallBlind(gameData.handsBeforeRaise),
|
||||||
|
myGameID(gameId), actualQuantityPlayers(gameData.numberOfPlayers),
|
||||||
|
actualSmallBlind(gameData.smallBlind), actualHandID(0), dealerPosition(0)
|
||||||
{
|
{
|
||||||
// cout << "Create Game Object" << "\n";
|
// cout << "Create Game Object" << "\n";
|
||||||
int i;
|
int i;
|
||||||
startQuantityPlayers = actualQuantityPlayers = playerData.size();
|
|
||||||
|
|
||||||
actualHandID = 0;
|
actualHandID = 0;
|
||||||
|
|
||||||
@@ -59,8 +61,8 @@ Game::Game(GuiInterface* gui, const PlayerDataList &playerData, int sC, int sB,
|
|||||||
myTool.getRandNumber(0, startQuantityPlayers-1, 1, &dealerPosition, 0);
|
myTool.getRandNumber(0, startQuantityPlayers-1, 1, &dealerPosition, 0);
|
||||||
|
|
||||||
// Player erstellen
|
// Player erstellen
|
||||||
PlayerDataList::const_iterator player_i = playerData.begin();
|
PlayerDataList::const_iterator player_i = playerDataList.begin();
|
||||||
PlayerDataList::const_iterator player_end = playerData.end();
|
PlayerDataList::const_iterator player_end = playerDataList.end();
|
||||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||||
|
|
||||||
string myName;
|
string myName;
|
||||||
@@ -84,8 +86,6 @@ Game::Game(GuiInterface* gui, const PlayerDataList &playerData, int sC, int sB,
|
|||||||
startHand();
|
startHand();
|
||||||
|
|
||||||
// SPIEL-SCHLEIFE
|
// SPIEL-SCHLEIFE
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -32,12 +32,12 @@ class HandInterface;
|
|||||||
class PlayerInterface;
|
class PlayerInterface;
|
||||||
class BoardInterface;
|
class BoardInterface;
|
||||||
class EngineFactory;
|
class EngineFactory;
|
||||||
|
struct GameData;
|
||||||
|
|
||||||
class Game {
|
class Game {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Game(GuiInterface *gui, const PlayerDataList &playerData, int sC, int sB, int hbrsB, int gameId);
|
Game(GuiInterface *gui, const PlayerDataList &playerDataList, const GameData &gameData, int gameId);
|
||||||
|
|
||||||
~Game();
|
~Game();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2007 by Lothar May *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 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 General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
|
***************************************************************************/
|
||||||
|
/* Game data. */
|
||||||
|
|
||||||
|
#ifndef _GAMEDATA_H_
|
||||||
|
#define _GAMEDATA_H_
|
||||||
|
|
||||||
|
// For the sake of simplicity, this is a struct.
|
||||||
|
|
||||||
|
struct GameData
|
||||||
|
{
|
||||||
|
GameData() : numberOfPlayers(0), startCash(0), smallBlind(0), handsBeforeRaise(1) {}
|
||||||
|
unsigned numberOfPlayers;
|
||||||
|
unsigned startCash;
|
||||||
|
unsigned smallBlind;
|
||||||
|
unsigned handsBeforeRaise;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -601,14 +601,18 @@ void mainWindowImpl::startNewLocalGame(newGameDialogImpl *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//get values from local game dialog
|
//get values from local game dialog
|
||||||
|
GameData gameData;
|
||||||
if(v) {
|
if(v) {
|
||||||
//Speeds
|
//Speeds
|
||||||
guiGameSpeed = v->spinBox_gameSpeed->value();
|
guiGameSpeed = v->spinBox_gameSpeed->value();
|
||||||
setSpeeds();
|
setSpeeds();
|
||||||
//positioning Slider
|
//positioning Slider
|
||||||
horizontalSlider_speed->setValue(guiGameSpeed);
|
horizontalSlider_speed->setValue(guiGameSpeed);
|
||||||
//Start Game!!!
|
// Set Game Data
|
||||||
mySession->startGame(v->spinBox_quantityPlayers->value(), v->spinBox_startCash->value(), v->spinBox_smallBlind->value(), v->spinBox_handsBeforeRaiseSmallBlind->value());
|
gameData.numberOfPlayers = v->spinBox_quantityPlayers->value();
|
||||||
|
gameData.startCash = v->spinBox_startCash->value();
|
||||||
|
gameData.smallBlind = v->spinBox_smallBlind->value();
|
||||||
|
gameData.handsBeforeRaise = v->spinBox_handsBeforeRaiseSmallBlind->value();
|
||||||
}
|
}
|
||||||
// start with default values
|
// start with default values
|
||||||
else {
|
else {
|
||||||
@@ -617,9 +621,14 @@ void mainWindowImpl::startNewLocalGame(newGameDialogImpl *v) {
|
|||||||
setSpeeds();
|
setSpeeds();
|
||||||
//positioning Slider
|
//positioning Slider
|
||||||
horizontalSlider_speed->setValue(guiGameSpeed);
|
horizontalSlider_speed->setValue(guiGameSpeed);
|
||||||
//Start Game!!!
|
// Set Game Data
|
||||||
mySession->startGame(myConfig->readConfigInt("NumberOfPlayers"), myConfig->readConfigInt("StartCash"), myConfig->readConfigInt("SmallBlind"), myConfig->readConfigInt("HandsBeforeRaiseSmallBlind"));
|
gameData.numberOfPlayers = myConfig->readConfigInt("NumberOfPlayers");
|
||||||
|
gameData.startCash = myConfig->readConfigInt("StartCash");
|
||||||
|
gameData.smallBlind = myConfig->readConfigInt("SmallBlind");
|
||||||
|
gameData.handsBeforeRaise = myConfig->readConfigInt("HandsBeforeRaiseSmallBlind");
|
||||||
}
|
}
|
||||||
|
//Start Game!!!
|
||||||
|
mySession->startGame(gameData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -638,7 +647,13 @@ void mainWindowImpl::callCreateNetworkGameDialog() {
|
|||||||
mySession->terminateNetworkClient();
|
mySession->terminateNetworkClient();
|
||||||
mySession->terminateNetworkServer();
|
mySession->terminateNetworkServer();
|
||||||
|
|
||||||
mySession->startNetworkServer();
|
GameData gameData;
|
||||||
|
gameData.numberOfPlayers = myCreateNetworkGameDialog->spinBox_quantityPlayers->value();
|
||||||
|
gameData.startCash = myCreateNetworkGameDialog->spinBox_startCash->value();
|
||||||
|
gameData.smallBlind = myCreateNetworkGameDialog->spinBox_smallBlind->value();
|
||||||
|
gameData.handsBeforeRaise = myCreateNetworkGameDialog->spinBox_handsBeforeRaiseSmallBlind->value();
|
||||||
|
|
||||||
|
mySession->startNetworkServer(gameData);
|
||||||
mySession->startNetworkClientForLocalServer();
|
mySession->startNetworkClientForLocalServer();
|
||||||
|
|
||||||
myStartNetworkGameDialog->exec();
|
myStartNetworkGameDialog->exec();
|
||||||
|
|||||||
@@ -81,6 +81,9 @@ ServerRecvStateInit::Process(ServerRecvThread &server)
|
|||||||
tmpPacket->GetData(playerData);
|
tmpPacket->GetData(playerData);
|
||||||
server.GetCallback().SignalNetServerPlayerJoined(playerData.playerName);
|
server.GetCallback().SignalNetServerPlayerJoined(playerData.playerName);
|
||||||
boost::shared_ptr<NetPacket> answer(new NetPacketJoinGameAck);
|
boost::shared_ptr<NetPacket> answer(new NetPacketJoinGameAck);
|
||||||
|
NetPacketJoinGameAck::Data joinGameAckData;
|
||||||
|
// TODO: set data.
|
||||||
|
static_cast<NetPacketJoinGameAck *>(answer.get())->SetData(joinGameAckData);
|
||||||
server.GetSender().Send(answer, recvSock);
|
server.GetSender().Send(answer, recvSock);
|
||||||
session->SetState(SessionData::Established);
|
session->SetState(SessionData::Established);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,9 @@
|
|||||||
#include <net/sendercallback.h>
|
#include <net/sendercallback.h>
|
||||||
#include <net/receiverhelper.h>
|
#include <net/receiverhelper.h>
|
||||||
#include <net/socket_msg.h>
|
#include <net/socket_msg.h>
|
||||||
|
#include <gamedata.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class ServerSenderCallback : public SenderCallback
|
class ServerSenderCallback : public SenderCallback
|
||||||
{
|
{
|
||||||
@@ -47,6 +50,7 @@ ServerRecvThread::ServerRecvThread(ServerCallback &cb)
|
|||||||
m_senderCallback.reset(new ServerSenderCallback(*this));
|
m_senderCallback.reset(new ServerSenderCallback(*this));
|
||||||
m_sender.reset(new SenderThread(GetSenderCallback()));
|
m_sender.reset(new SenderThread(GetSenderCallback()));
|
||||||
m_receiver.reset(new ReceiverHelper);
|
m_receiver.reset(new ReceiverHelper);
|
||||||
|
m_gameData.reset(new GameData);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerRecvThread::~ServerRecvThread()
|
ServerRecvThread::~ServerRecvThread()
|
||||||
@@ -55,6 +59,13 @@ ServerRecvThread::~ServerRecvThread()
|
|||||||
CleanupSessionMap();
|
CleanupSessionMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ServerRecvThread::Init(const string &pwd, const GameData &gameData)
|
||||||
|
{
|
||||||
|
m_password = pwd;
|
||||||
|
*m_gameData = gameData;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerRecvThread::SendToAllPlayers(boost::shared_ptr<NetPacket> packet)
|
ServerRecvThread::SendToAllPlayers(boost::shared_ptr<NetPacket> packet)
|
||||||
{
|
{
|
||||||
@@ -297,6 +308,19 @@ ServerRecvThread::GetReceiver()
|
|||||||
return *m_receiver;
|
return *m_receiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const GameData &
|
||||||
|
ServerRecvThread::GetGameData()
|
||||||
|
{
|
||||||
|
assert(m_gameData.get());
|
||||||
|
return *m_gameData;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ServerRecvThread::CheckPassword(const std::string &password)
|
||||||
|
{
|
||||||
|
return (password == m_password);
|
||||||
|
}
|
||||||
|
|
||||||
ServerSenderCallback &
|
ServerSenderCallback &
|
||||||
ServerRecvThread::GetSenderCallback()
|
ServerRecvThread::GetSenderCallback()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ ServerThread::~ServerThread()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerThread::Init(unsigned serverPort, bool ipv6, const std::string &pwd)
|
ServerThread::Init(unsigned serverPort, bool ipv6, const std::string &pwd,
|
||||||
|
const GameData &gameData)
|
||||||
{
|
{
|
||||||
if (IsRunning())
|
if (IsRunning())
|
||||||
return; // TODO: throw exception
|
return; // TODO: throw exception
|
||||||
@@ -50,7 +51,8 @@ ServerThread::Init(unsigned serverPort, bool ipv6, const std::string &pwd)
|
|||||||
|
|
||||||
context.SetAddrFamily(ipv6 ? AF_INET6 : AF_INET);
|
context.SetAddrFamily(ipv6 ? AF_INET6 : AF_INET);
|
||||||
context.SetServerPort(serverPort);
|
context.SetServerPort(serverPort);
|
||||||
context.SetPassword(pwd);
|
|
||||||
|
GetRecvThread().Init(pwd, gameData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -43,10 +43,6 @@ public:
|
|||||||
{return m_serverPort;}
|
{return m_serverPort;}
|
||||||
void SetServerPort(unsigned serverPort)
|
void SetServerPort(unsigned serverPort)
|
||||||
{m_serverPort = serverPort;}
|
{m_serverPort = serverPort;}
|
||||||
const std::string &GetPassword() const
|
|
||||||
{return m_password;}
|
|
||||||
void SetPassword(const std::string &password)
|
|
||||||
{m_password = password;}
|
|
||||||
const sockaddr_storage *GetServerSockaddr() const
|
const sockaddr_storage *GetServerSockaddr() const
|
||||||
{return &m_serverSockaddr;}
|
{return &m_serverSockaddr;}
|
||||||
sockaddr_storage *GetServerSockaddr()
|
sockaddr_storage *GetServerSockaddr()
|
||||||
@@ -59,7 +55,6 @@ private:
|
|||||||
SOCKET m_sockfd;
|
SOCKET m_sockfd;
|
||||||
int m_addrFamily;
|
int m_addrFamily;
|
||||||
unsigned m_serverPort;
|
unsigned m_serverPort;
|
||||||
std::string m_password;
|
|
||||||
sockaddr_storage m_serverSockaddr;
|
sockaddr_storage m_serverSockaddr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <core/thread.h>
|
#include <core/thread.h>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <string>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include <net/connectdata.h>
|
#include <net/connectdata.h>
|
||||||
@@ -40,6 +41,7 @@ class SenderThread;
|
|||||||
class ReceiverHelper;
|
class ReceiverHelper;
|
||||||
class ServerSenderCallback;
|
class ServerSenderCallback;
|
||||||
class NetPacket;
|
class NetPacket;
|
||||||
|
struct GameData;
|
||||||
|
|
||||||
class ServerRecvThread : public Thread
|
class ServerRecvThread : public Thread
|
||||||
{
|
{
|
||||||
@@ -47,6 +49,8 @@ public:
|
|||||||
ServerRecvThread(ServerCallback &gui);
|
ServerRecvThread(ServerCallback &gui);
|
||||||
virtual ~ServerRecvThread();
|
virtual ~ServerRecvThread();
|
||||||
|
|
||||||
|
void Init(const std::string &pwd, const GameData &gameData);
|
||||||
|
|
||||||
void SendToAllPlayers(boost::shared_ptr<NetPacket> packet);
|
void SendToAllPlayers(boost::shared_ptr<NetPacket> packet);
|
||||||
void AddConnection(boost::shared_ptr<ConnectData> data);
|
void AddConnection(boost::shared_ptr<ConnectData> data);
|
||||||
void AddNotification(unsigned notification);
|
void AddNotification(unsigned notification);
|
||||||
@@ -78,6 +82,9 @@ protected:
|
|||||||
SenderThread &GetSender();
|
SenderThread &GetSender();
|
||||||
ReceiverHelper &GetReceiver();
|
ReceiverHelper &GetReceiver();
|
||||||
|
|
||||||
|
const GameData &GetGameData();
|
||||||
|
bool CheckPassword(const std::string &password);
|
||||||
|
|
||||||
ServerSenderCallback &GetSenderCallback();
|
ServerSenderCallback &GetSenderCallback();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -96,6 +103,9 @@ private:
|
|||||||
std::auto_ptr<SenderThread> m_sender;
|
std::auto_ptr<SenderThread> m_sender;
|
||||||
|
|
||||||
std::auto_ptr<ServerSenderCallback> m_senderCallback;
|
std::auto_ptr<ServerSenderCallback> m_senderCallback;
|
||||||
|
std::auto_ptr<GameData> m_gameData;
|
||||||
|
|
||||||
|
std::string m_password;
|
||||||
|
|
||||||
ServerCallback &m_callback;
|
ServerCallback &m_callback;
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class ServerContext;
|
|||||||
class ServerRecvThread;
|
class ServerRecvThread;
|
||||||
class ServerSenderCallback;
|
class ServerSenderCallback;
|
||||||
class SenderThread;
|
class SenderThread;
|
||||||
|
struct GameData;
|
||||||
|
|
||||||
class ServerThread : public Thread
|
class ServerThread : public Thread
|
||||||
{
|
{
|
||||||
@@ -38,7 +39,8 @@ public:
|
|||||||
virtual ~ServerThread();
|
virtual ~ServerThread();
|
||||||
|
|
||||||
// Set the parameters.
|
// Set the parameters.
|
||||||
void Init(unsigned serverPort, bool ipv6, const std::string &pwd);
|
void Init(unsigned serverPort, bool ipv6, const std::string &pwd,
|
||||||
|
const GameData &gameData);
|
||||||
void StartGame();
|
void StartGame();
|
||||||
|
|
||||||
ServerCallback &GetCallback();
|
ServerCallback &GetCallback();
|
||||||
|
|||||||
+2
-2
@@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
#include <playerdata.h>
|
#include <playerdata.h>
|
||||||
|
|
||||||
PlayerData::PlayerData()
|
PlayerData::PlayerData(unsigned uniqueId)
|
||||||
: m_type(PLAYER_TYPE_COMPUTER)
|
: m_uniqueId(uniqueId), m_type(PLAYER_TYPE_COMPUTER)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -34,7 +34,7 @@ enum PlayerType
|
|||||||
class PlayerData
|
class PlayerData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PlayerData();
|
PlayerData(unsigned uniqueId);
|
||||||
~PlayerData();
|
~PlayerData();
|
||||||
|
|
||||||
const std::string &GetName() const
|
const std::string &GetName() const
|
||||||
@@ -49,8 +49,11 @@ public:
|
|||||||
{return m_type;}
|
{return m_type;}
|
||||||
void SetPlayerType(PlayerType type)
|
void SetPlayerType(PlayerType type)
|
||||||
{m_type = type;}
|
{m_type = type;}
|
||||||
|
unsigned GetUniqueId() const
|
||||||
|
{return m_uniqueId;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
unsigned m_uniqueId;
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
std::string m_avatarFile;
|
std::string m_avatarFile;
|
||||||
PlayerType m_type;
|
PlayerType m_type;
|
||||||
|
|||||||
+8
-6
@@ -46,12 +46,12 @@ Session::~Session()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Session::startGame(int qP, int sC, int sB, int hbrsB) {
|
void Session::startGame(const GameData &gameData) {
|
||||||
|
|
||||||
currentGameID++;
|
currentGameID++;
|
||||||
|
|
||||||
PlayerDataList playerDataList;
|
PlayerDataList playerDataList;
|
||||||
for(int i=0; i<qP; i++) {
|
for(unsigned i=0; i<gameData.numberOfPlayers; i++) {
|
||||||
|
|
||||||
//Namen und Avatarpfad abfragen
|
//Namen und Avatarpfad abfragen
|
||||||
ostringstream myName;
|
ostringstream myName;
|
||||||
@@ -63,7 +63,8 @@ void Session::startGame(int qP, int sC, int sB, int hbrsB) {
|
|||||||
|
|
||||||
//PlayerData erzeugen
|
//PlayerData erzeugen
|
||||||
// TODO: PlayerType setzen
|
// TODO: PlayerType setzen
|
||||||
boost::shared_ptr<PlayerData> playerData(new PlayerData);
|
// UniqueId = PlayerNumber for local games.
|
||||||
|
boost::shared_ptr<PlayerData> playerData(new PlayerData(i));
|
||||||
playerData->SetName(myConfig->readConfigString(myName.str()));
|
playerData->SetName(myConfig->readConfigString(myName.str()));
|
||||||
playerData->SetAvatarFile(myConfig->readConfigString(myAvatar.str()));
|
playerData->SetAvatarFile(myConfig->readConfigString(myAvatar.str()));
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ void Session::startGame(int qP, int sC, int sB, int hbrsB) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
actualGame = new Game(myGui, playerDataList, sC, sB, hbrsB, currentGameID);
|
actualGame = new Game(myGui, playerDataList, gameData, currentGameID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::deleteGame() {
|
void Session::deleteGame() {
|
||||||
@@ -123,7 +124,7 @@ void Session::terminateNetworkClient()
|
|||||||
myNetClient = 0;
|
myNetClient = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::startNetworkServer()
|
void Session::startNetworkServer(const GameData &gameData)
|
||||||
{
|
{
|
||||||
if (myNetServer)
|
if (myNetServer)
|
||||||
return; // TODO: throw exception
|
return; // TODO: throw exception
|
||||||
@@ -131,7 +132,8 @@ void Session::startNetworkServer()
|
|||||||
myNetServer->Init(
|
myNetServer->Init(
|
||||||
myConfig->readConfigInt("ServerPort"),
|
myConfig->readConfigInt("ServerPort"),
|
||||||
myConfig->readConfigInt("ServerUseIpv6") == 1,
|
myConfig->readConfigInt("ServerUseIpv6") == 1,
|
||||||
myConfig->readConfigString("ServerPassword"));
|
myConfig->readConfigString("ServerPassword"),
|
||||||
|
gameData);
|
||||||
myNetServer->Run();
|
myNetServer->Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -19,6 +19,7 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#ifndef STDSESSION_H
|
#ifndef STDSESSION_H
|
||||||
#define STDSESSION_H
|
#define STDSESSION_H
|
||||||
|
#include "gamedata.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class GuiInterface;
|
class GuiInterface;
|
||||||
@@ -34,14 +35,14 @@ public:
|
|||||||
|
|
||||||
~Session();
|
~Session();
|
||||||
|
|
||||||
void startGame(int qP, int sC, int sB, int hbrsB);
|
void startGame(const GameData &gameData);
|
||||||
void deleteGame();
|
void deleteGame();
|
||||||
|
|
||||||
void startNetworkClient(const std::string &serverAddress, unsigned serverPort, bool ipv6, const std::string &pwd);
|
void startNetworkClient(const std::string &serverAddress, unsigned serverPort, bool ipv6, const std::string &pwd);
|
||||||
void startNetworkClientForLocalServer();
|
void startNetworkClientForLocalServer();
|
||||||
void terminateNetworkClient();
|
void terminateNetworkClient();
|
||||||
|
|
||||||
void startNetworkServer();
|
void startNetworkServer(const GameData &gameData);
|
||||||
void initiateNetworkServerGame();
|
void initiateNetworkServerGame();
|
||||||
void terminateNetworkServer();
|
void terminateNetworkServer();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user