2007-01-13 02:40:33 +00:00
|
|
|
/***************************************************************************
|
|
|
|
|
* Copyright (C) 2006 by FThauer FHammer *
|
|
|
|
|
* f.thauer@web.de *
|
|
|
|
|
* *
|
|
|
|
|
* 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. *
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
#include "session.h"
|
|
|
|
|
#include "game.h"
|
|
|
|
|
#include "guiinterface.h"
|
2007-01-21 14:20:15 +00:00
|
|
|
#include "configfile.h"
|
2007-05-18 17:13:27 +00:00
|
|
|
#include <localenginefactory.h>
|
|
|
|
|
#include <clientenginefactory.h>
|
2007-02-18 13:45:56 +00:00
|
|
|
#include <net/clientthread.h>
|
2007-08-19 20:58:57 +00:00
|
|
|
#include <net/serveracceptthread.h>
|
2007-09-26 11:48:33 +00:00
|
|
|
#include <net/ircthread.h>
|
2007-09-08 20:40:46 +00:00
|
|
|
#include <core/avatarmanager.h>
|
2007-01-21 14:20:15 +00:00
|
|
|
|
2007-05-22 23:27:21 +00:00
|
|
|
#include <sstream>
|
|
|
|
|
|
2007-02-18 13:45:56 +00:00
|
|
|
#define NET_CLIENT_TERMINATE_TIMEOUT_MSEC 1000
|
2007-10-29 11:57:17 +00:00
|
|
|
#define NET_SERVER_TERMINATE_TIMEOUT_MSEC 10000
|
2007-09-30 13:15:52 +00:00
|
|
|
#define NET_IRC_TERMINATE_TIMEOUT_MSEC 2000
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2007-08-26 12:15:10 +00:00
|
|
|
#define NET_DEFAULT_GAME "default"
|
|
|
|
|
|
2007-01-13 02:40:33 +00:00
|
|
|
using namespace std;
|
|
|
|
|
|
2007-05-13 12:35:27 +00:00
|
|
|
Session::Session(GuiInterface *g, ConfigFile *c)
|
2007-10-28 19:38:49 +00:00
|
|
|
: currentGameNum(0), myNetClient(NULL), myNetServer(NULL), myIrcThread(NULL),
|
2007-10-08 20:14:44 +00:00
|
|
|
myGui(g), myConfig(c), myGameType(GAME_TYPE_NONE)
|
2007-08-19 20:58:57 +00:00
|
|
|
{
|
2007-01-13 02:40:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Session::~Session()
|
|
|
|
|
{
|
2007-02-18 13:45:56 +00:00
|
|
|
terminateNetworkClient();
|
2007-03-20 14:05:16 +00:00
|
|
|
terminateNetworkServer();
|
2007-02-18 13:45:56 +00:00
|
|
|
delete myConfig;
|
2007-04-21 20:42:50 +00:00
|
|
|
myConfig = 0;
|
2007-01-13 02:40:33 +00:00
|
|
|
}
|
|
|
|
|
|
2007-09-08 21:43:15 +00:00
|
|
|
bool Session::init()
|
|
|
|
|
{
|
2007-10-15 08:37:32 +00:00
|
|
|
myAvatarManager.reset(new AvatarManager);
|
2007-10-24 22:20:35 +00:00
|
|
|
bool retVal = myAvatarManager->Init(myConfig->readConfigString("AppDataDir"), myConfig->readConfigString("CacheDir"));
|
|
|
|
|
myAvatarManager->RemoveOldAvatarCacheEntries();
|
|
|
|
|
return retVal;
|
2007-09-08 21:43:15 +00:00
|
|
|
}
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2007-10-15 08:37:32 +00:00
|
|
|
void Session::init(boost::shared_ptr<AvatarManager> manager)
|
|
|
|
|
{
|
|
|
|
|
myAvatarManager = manager;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-20 00:16:29 +00:00
|
|
|
void Session::startLocalGame(const GameData &gameData, const StartData &startData) {
|
2007-05-02 21:20:54 +00:00
|
|
|
|
2007-10-08 20:14:44 +00:00
|
|
|
myGameType = GAME_TYPE_LOCAL;
|
|
|
|
|
|
2007-05-20 00:16:29 +00:00
|
|
|
currentGame.reset();
|
2007-10-28 19:38:49 +00:00
|
|
|
currentGameNum++;
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2007-05-20 00:16:29 +00:00
|
|
|
myGui->initGui(gameData.guiSpeed);
|
|
|
|
|
|
2007-04-26 21:11:13 +00:00
|
|
|
PlayerDataList playerDataList;
|
2007-06-11 19:46:18 +00:00
|
|
|
for(int i = 0; i < startData.numberOfPlayers; i++) {
|
2007-04-26 21:11:13 +00:00
|
|
|
|
|
|
|
|
//Namen und Avatarpfad abfragen
|
|
|
|
|
ostringstream myName;
|
|
|
|
|
if (i==0) { myName << "MyName"; }
|
|
|
|
|
else { myName << "Opponent" << i << "Name"; }
|
|
|
|
|
ostringstream myAvatar;
|
|
|
|
|
if (i==0) { myAvatar << "MyAvatar"; }
|
|
|
|
|
else { myAvatar << "Opponent" << i << "Avatar"; }
|
|
|
|
|
|
|
|
|
|
//PlayerData erzeugen
|
2007-04-26 23:07:08 +00:00
|
|
|
// UniqueId = PlayerNumber for local games.
|
2007-08-02 20:52:13 +00:00
|
|
|
boost::shared_ptr<PlayerData> playerData(new PlayerData(i, i,
|
|
|
|
|
i == 0 ? PLAYER_TYPE_HUMAN : PLAYER_TYPE_COMPUTER,
|
|
|
|
|
i == 0 ? PLAYER_RIGHTS_ADMIN : PLAYER_RIGHTS_NORMAL));
|
2007-04-26 21:11:13 +00:00
|
|
|
playerData->SetName(myConfig->readConfigString(myName.str()));
|
|
|
|
|
playerData->SetAvatarFile(myConfig->readConfigString(myAvatar.str()));
|
|
|
|
|
|
|
|
|
|
playerDataList.push_back(playerData);
|
|
|
|
|
}
|
2007-05-18 17:13:27 +00:00
|
|
|
// EngineFactory erstellen
|
|
|
|
|
boost::shared_ptr<EngineFactory> factory(new LocalEngineFactory(myConfig)); // LocalEngine erstellen
|
|
|
|
|
|
2007-10-28 19:38:49 +00:00
|
|
|
currentGame.reset(new Game(myGui, factory, playerDataList, gameData, startData, currentGameNum));
|
2007-05-18 17:13:27 +00:00
|
|
|
|
|
|
|
|
//// SPIEL-SCHLEIFE
|
|
|
|
|
currentGame->initHand();
|
|
|
|
|
currentGame->startHand();
|
|
|
|
|
// SPIEL-SCHLEIFE
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-20 00:16:29 +00:00
|
|
|
void Session::startClientGame(boost::shared_ptr<Game> game)
|
2007-05-18 17:13:27 +00:00
|
|
|
{
|
2007-10-28 19:38:49 +00:00
|
|
|
currentGameNum++;
|
2007-05-18 17:13:27 +00:00
|
|
|
|
2007-05-20 00:16:29 +00:00
|
|
|
currentGame = game;
|
2007-01-13 02:40:33 +00:00
|
|
|
}
|
2007-02-18 13:45:56 +00:00
|
|
|
|
2007-05-11 12:01:13 +00:00
|
|
|
Game *Session::getCurrentGame()
|
|
|
|
|
{
|
2007-05-20 00:16:29 +00:00
|
|
|
return currentGame.get();
|
2007-05-11 12:01:13 +00:00
|
|
|
}
|
|
|
|
|
|
2007-05-14 12:40:42 +00:00
|
|
|
GuiInterface *Session::getGui()
|
|
|
|
|
{
|
|
|
|
|
return myGui;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-15 08:37:32 +00:00
|
|
|
Session::GameType Session::getGameType()
|
2007-10-08 20:14:44 +00:00
|
|
|
{
|
|
|
|
|
return myGameType;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-15 08:37:32 +00:00
|
|
|
boost::shared_ptr<AvatarManager> Session::getAvatarManager()
|
|
|
|
|
{
|
|
|
|
|
return myAvatarManager;
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-26 12:15:10 +00:00
|
|
|
void Session::startInternetClient()
|
|
|
|
|
{
|
2007-10-08 20:14:44 +00:00
|
|
|
if (myNetClient || myIrcThread || !myGui)
|
2007-08-26 12:15:10 +00:00
|
|
|
{
|
|
|
|
|
assert(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2007-10-08 20:14:44 +00:00
|
|
|
myGameType = GAME_TYPE_INTERNET;
|
|
|
|
|
|
2007-10-10 11:56:09 +00:00
|
|
|
if (myConfig->readConfigInt("UseIRCLobbyChat"))
|
|
|
|
|
{
|
|
|
|
|
myIrcThread = new IrcThread(*myGui);
|
|
|
|
|
myIrcThread->Init(
|
|
|
|
|
myConfig->readConfigString("IRCServerAddress"),
|
|
|
|
|
myConfig->readConfigInt("IRCServerPort"),
|
|
|
|
|
myConfig->readConfigInt("IRCServerUseIpv6") == 1,
|
|
|
|
|
myConfig->readConfigString("MyName"),
|
|
|
|
|
myConfig->readConfigString("IRCChannel"));
|
|
|
|
|
myIrcThread->Run();
|
|
|
|
|
}
|
2007-10-08 20:14:44 +00:00
|
|
|
|
2007-09-09 00:00:19 +00:00
|
|
|
myNetClient = new ClientThread(*myGui, *myAvatarManager);
|
2007-08-26 12:15:10 +00:00
|
|
|
myNetClient->Init(
|
|
|
|
|
myConfig->readConfigString("InternetServerAddress"),
|
|
|
|
|
myConfig->readConfigInt("InternetServerPort"),
|
|
|
|
|
myConfig->readConfigInt("InternetServerUseIpv6") == 1,
|
|
|
|
|
myConfig->readConfigInt("InternetServerUseSctp") == 1,
|
|
|
|
|
myConfig->readConfigString("InternetServerPassword"),
|
2007-09-09 00:00:19 +00:00
|
|
|
myConfig->readConfigString("MyName"),
|
|
|
|
|
myConfig->readConfigString("MyAvatar"));
|
2007-08-26 12:15:10 +00:00
|
|
|
myNetClient->Run();
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-04 16:49:19 +00:00
|
|
|
void Session::startNetworkClient(const string &serverAddress, unsigned serverPort, bool ipv6, bool sctp, const string &pwd)
|
2007-02-18 13:45:56 +00:00
|
|
|
{
|
|
|
|
|
if (myNetClient || !myGui)
|
2007-06-02 21:19:19 +00:00
|
|
|
{
|
|
|
|
|
assert(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2007-10-08 20:14:44 +00:00
|
|
|
myGameType = GAME_TYPE_NETWORK;
|
|
|
|
|
|
2007-09-09 00:00:19 +00:00
|
|
|
myNetClient = new ClientThread(*myGui, *myAvatarManager);
|
2007-04-08 16:18:20 +00:00
|
|
|
myNetClient->Init(
|
|
|
|
|
serverAddress,
|
|
|
|
|
serverPort,
|
|
|
|
|
ipv6,
|
2007-06-04 16:49:19 +00:00
|
|
|
sctp,
|
2007-04-08 16:18:20 +00:00
|
|
|
pwd,
|
2007-09-09 00:00:19 +00:00
|
|
|
myConfig->readConfigString("MyName"),
|
|
|
|
|
myConfig->readConfigString("MyAvatar"));
|
2007-02-18 13:45:56 +00:00
|
|
|
myNetClient->Run();
|
2007-08-26 12:15:10 +00:00
|
|
|
myNetClient->SendJoinFirstGame("");
|
2007-02-18 13:45:56 +00:00
|
|
|
}
|
|
|
|
|
|
2007-08-26 12:15:10 +00:00
|
|
|
void Session::startNetworkClientForLocalServer(const GameData &gameData)
|
2007-03-20 14:05:16 +00:00
|
|
|
{
|
|
|
|
|
if (myNetClient || !myGui)
|
2007-06-02 21:19:19 +00:00
|
|
|
{
|
|
|
|
|
assert(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2007-10-08 20:14:44 +00:00
|
|
|
myGameType = GAME_TYPE_NETWORK;
|
|
|
|
|
|
2007-09-09 00:00:19 +00:00
|
|
|
myNetClient = new ClientThread(*myGui, *myAvatarManager);
|
2007-06-04 16:57:01 +00:00
|
|
|
bool useIpv6 = myConfig->readConfigInt("ServerUseIpv6") == 1;
|
|
|
|
|
const char *loopbackAddr = useIpv6 ? "::1" : "127.0.0.1";
|
2007-03-20 14:05:16 +00:00
|
|
|
myNetClient->Init(
|
2007-06-04 16:57:01 +00:00
|
|
|
loopbackAddr,
|
2007-03-20 14:05:16 +00:00
|
|
|
myConfig->readConfigInt("ServerPort"),
|
2007-06-04 16:57:01 +00:00
|
|
|
useIpv6,
|
2007-06-04 16:49:19 +00:00
|
|
|
myConfig->readConfigInt("ServerUseSctp") == 1,
|
2007-04-08 16:18:20 +00:00
|
|
|
myConfig->readConfigString("ServerPassword"),
|
2007-09-09 00:00:19 +00:00
|
|
|
myConfig->readConfigString("MyName"),
|
|
|
|
|
myConfig->readConfigString("MyAvatar"));
|
2007-03-20 14:05:16 +00:00
|
|
|
myNetClient->Run();
|
2007-08-26 12:15:10 +00:00
|
|
|
myNetClient->SendCreateGame(gameData, NET_DEFAULT_GAME, "");
|
2007-03-20 14:05:16 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-18 13:45:56 +00:00
|
|
|
void Session::terminateNetworkClient()
|
|
|
|
|
{
|
|
|
|
|
if (!myNetClient)
|
|
|
|
|
return; // already terminated
|
|
|
|
|
myNetClient->SignalTermination();
|
2007-10-08 20:14:44 +00:00
|
|
|
if (myIrcThread)
|
|
|
|
|
myIrcThread->SignalTermination();
|
|
|
|
|
// Give the threads some time to terminate.
|
2007-02-18 13:45:56 +00:00
|
|
|
if (myNetClient->Join(NET_CLIENT_TERMINATE_TIMEOUT_MSEC))
|
|
|
|
|
delete myNetClient;
|
2007-10-08 20:14:44 +00:00
|
|
|
if (myIrcThread && myIrcThread->Join(NET_IRC_TERMINATE_TIMEOUT_MSEC))
|
|
|
|
|
delete myIrcThread;
|
|
|
|
|
|
2007-02-18 13:45:56 +00:00
|
|
|
// If termination fails, leave a memory leak to prevent a crash.
|
|
|
|
|
myNetClient = 0;
|
2007-10-08 20:14:44 +00:00
|
|
|
myIrcThread = 0;
|
|
|
|
|
myGameType = GAME_TYPE_NONE;
|
2007-02-18 13:45:56 +00:00
|
|
|
}
|
2007-02-25 23:16:26 +00:00
|
|
|
|
2007-08-21 12:34:33 +00:00
|
|
|
void Session::clientCreateGame(const GameData &gameData, const string &name, const string &password)
|
|
|
|
|
{
|
|
|
|
|
if (!myNetClient)
|
|
|
|
|
return; // only act if client is running.
|
|
|
|
|
myNetClient->SendCreateGame(gameData, name, password);
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-05 19:14:34 +00:00
|
|
|
void Session::clientJoinGame(unsigned gameId, const std::string &password)
|
2007-08-21 12:34:33 +00:00
|
|
|
{
|
|
|
|
|
if (!myNetClient)
|
|
|
|
|
return; // only act if client is running.
|
2007-09-05 19:14:34 +00:00
|
|
|
myNetClient->SendJoinGame(gameId, password);
|
2007-08-21 12:34:33 +00:00
|
|
|
}
|
|
|
|
|
|
2007-08-26 12:15:10 +00:00
|
|
|
void Session::startNetworkServer()
|
2007-02-25 23:16:26 +00:00
|
|
|
{
|
|
|
|
|
if (myNetServer)
|
2007-06-02 21:19:19 +00:00
|
|
|
{
|
|
|
|
|
assert(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2007-10-07 15:52:12 +00:00
|
|
|
myNetServer = new ServerAcceptThread(*myGui, myConfig, *myAvatarManager);
|
2007-03-13 23:27:17 +00:00
|
|
|
myNetServer->Init(
|
|
|
|
|
myConfig->readConfigInt("ServerPort"),
|
|
|
|
|
myConfig->readConfigInt("ServerUseIpv6") == 1,
|
2007-06-04 17:42:20 +00:00
|
|
|
myConfig->readConfigInt("ServerUseSctp") == 1,
|
2007-08-20 15:30:22 +00:00
|
|
|
myConfig->readConfigString("ServerPassword"));
|
2007-02-25 23:16:26 +00:00
|
|
|
myNetServer->Run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Session::terminateNetworkServer()
|
|
|
|
|
{
|
|
|
|
|
if (!myNetServer)
|
|
|
|
|
return; // already terminated
|
|
|
|
|
myNetServer->SignalTermination();
|
|
|
|
|
// Give the thread some time to terminate.
|
|
|
|
|
if (myNetServer->Join(NET_SERVER_TERMINATE_TIMEOUT_MSEC))
|
|
|
|
|
{
|
|
|
|
|
delete myNetServer;
|
|
|
|
|
}
|
|
|
|
|
// If termination fails, leave a memory leak to prevent a crash.
|
|
|
|
|
myNetServer = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-02 18:58:54 +00:00
|
|
|
bool Session::waitForNetworkServer(unsigned timeoutMsec)
|
2007-07-30 23:22:58 +00:00
|
|
|
{
|
2007-10-02 18:58:54 +00:00
|
|
|
bool retVal = false;
|
2007-07-30 23:22:58 +00:00
|
|
|
if (!myNetServer)
|
2007-10-02 18:58:54 +00:00
|
|
|
retVal = true; // already terminated
|
|
|
|
|
else
|
2007-07-30 23:22:58 +00:00
|
|
|
{
|
2007-10-02 18:58:54 +00:00
|
|
|
if (myNetServer->Join(timeoutMsec))
|
|
|
|
|
{
|
|
|
|
|
delete myNetServer;
|
|
|
|
|
myNetServer = 0;
|
|
|
|
|
retVal = true;
|
|
|
|
|
}
|
2007-07-30 23:22:58 +00:00
|
|
|
}
|
2007-10-02 18:58:54 +00:00
|
|
|
return retVal;
|
2007-07-30 23:22:58 +00:00
|
|
|
}
|
|
|
|
|
|
2007-09-26 11:48:33 +00:00
|
|
|
void Session::sendIrcChatMessage(const std::string &message)
|
|
|
|
|
{
|
|
|
|
|
if (!myIrcThread)
|
|
|
|
|
return;
|
|
|
|
|
myIrcThread->SendChatMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-06 19:09:05 +00:00
|
|
|
void Session::sendLeaveCurrentGame()
|
|
|
|
|
{
|
|
|
|
|
if (!myNetClient)
|
|
|
|
|
return; // only act if client is running.
|
|
|
|
|
myNetClient->SendLeaveCurrentGame();
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-05 19:14:34 +00:00
|
|
|
void Session::sendStartEvent(bool fillUpWithCpuPlayers)
|
2007-08-02 20:52:13 +00:00
|
|
|
{
|
|
|
|
|
if (!myNetClient)
|
|
|
|
|
return; // only act if client is running.
|
2007-09-05 19:14:34 +00:00
|
|
|
myNetClient->SendStartEvent(fillUpWithCpuPlayers);
|
2007-08-02 20:52:13 +00:00
|
|
|
}
|
|
|
|
|
|
2007-05-23 22:31:56 +00:00
|
|
|
void Session::sendClientPlayerAction()
|
|
|
|
|
{
|
|
|
|
|
if (!myNetClient)
|
2007-05-25 16:03:12 +00:00
|
|
|
return; // only act if client is running.
|
2007-05-23 22:31:56 +00:00
|
|
|
myNetClient->SendPlayerAction();
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-07 21:19:06 +00:00
|
|
|
void Session::sendChatMessage(const std::string &message)
|
|
|
|
|
{
|
2007-05-25 16:03:12 +00:00
|
|
|
if (!myNetClient)
|
|
|
|
|
return; // only act if client is running.
|
|
|
|
|
myNetClient->SendChatMessage(message);
|
2007-05-25 00:09:51 +00:00
|
|
|
}
|
2007-05-26 17:06:03 +00:00
|
|
|
|
2007-09-05 19:14:34 +00:00
|
|
|
void Session::kickPlayer(unsigned playerId)
|
2007-06-07 21:19:06 +00:00
|
|
|
{
|
2007-08-02 20:52:13 +00:00
|
|
|
if (!myNetClient)
|
|
|
|
|
return; // only act if client is running.
|
2007-09-05 19:14:34 +00:00
|
|
|
myNetClient->SendKickPlayer(playerId);
|
2007-06-07 21:19:06 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-27 18:51:53 +00:00
|
|
|
void Session::kickPlayer(const string &playerName)
|
|
|
|
|
{
|
|
|
|
|
if (!myNetClient)
|
|
|
|
|
return; // only act if client is running.
|
|
|
|
|
unsigned playerId;
|
|
|
|
|
if (myNetClient->GetPlayerIdFromName(playerName, playerId))
|
|
|
|
|
kickPlayer(playerId);
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-26 17:06:03 +00:00
|
|
|
bool Session::isNetworkClientRunning() const
|
|
|
|
|
{
|
|
|
|
|
// This, and every place which calls this, is a HACK.
|
|
|
|
|
// TODO
|
|
|
|
|
return myNetClient != NULL;
|
|
|
|
|
}
|
2007-06-04 16:19:11 +00:00
|
|
|
|
2007-06-10 23:28:25 +00:00
|
|
|
bool Session::isNetworkServerRunning() const
|
|
|
|
|
{
|
|
|
|
|
// This, and every place which calls this, is a HACK.
|
|
|
|
|
// TODO
|
|
|
|
|
return myNetServer != NULL;
|
|
|
|
|
}
|
2007-08-27 09:57:51 +00:00
|
|
|
|
2007-10-28 19:38:49 +00:00
|
|
|
GameInfo Session::getClientGameInfo(unsigned playerId) const
|
2007-08-27 09:57:51 +00:00
|
|
|
{
|
2007-09-27 20:59:00 +00:00
|
|
|
GameInfo info;
|
|
|
|
|
if (myNetClient)
|
|
|
|
|
info = myNetClient->GetGameInfo(playerId);
|
|
|
|
|
return info;
|
2007-09-02 16:36:52 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-28 19:38:49 +00:00
|
|
|
PlayerInfo Session::getClientPlayerInfo(unsigned playerId) const
|
2007-09-02 16:36:52 +00:00
|
|
|
{
|
2007-09-27 20:59:00 +00:00
|
|
|
PlayerInfo info;
|
|
|
|
|
if (myNetClient)
|
|
|
|
|
info = myNetClient->GetPlayerInfo(playerId);
|
|
|
|
|
return info;
|
2007-08-27 09:57:51 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-28 19:38:49 +00:00
|
|
|
ServerStats Session::getClientStats() const
|
2007-10-20 22:22:11 +00:00
|
|
|
{
|
|
|
|
|
ServerStats stats;
|
|
|
|
|
if (myNetClient)
|
|
|
|
|
stats = myNetClient->GetStatData();
|
|
|
|
|
return stats;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-28 19:38:49 +00:00
|
|
|
unsigned Session::getClientCurrentGameId() const
|
|
|
|
|
{
|
|
|
|
|
unsigned id = 0;
|
|
|
|
|
if (myNetClient)
|
|
|
|
|
id = myNetClient->GetGameId();
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|