Exceptions are now derived from std::exception and tell source code file and line.
This commit is contained in:
@@ -18,8 +18,27 @@
|
|||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include "pokerthexception.h"
|
#include "pokerthexception.h"
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
PokerTHException::PokerTHException(const char *sourcefile, int sourceline, int errorId, int osErrorCode)
|
||||||
|
: m_errorId(errorId), m_osErrorCode(osErrorCode)
|
||||||
|
{
|
||||||
|
ostringstream msgStream;
|
||||||
|
msgStream << sourcefile << " (" << sourceline << "): Error " << errorId;
|
||||||
|
if (osErrorCode)
|
||||||
|
msgStream << " (system error " << osErrorCode << ")";
|
||||||
|
m_msg = msgStream.str();
|
||||||
|
}
|
||||||
|
|
||||||
PokerTHException::~PokerTHException()
|
PokerTHException::~PokerTHException()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
PokerTHException::what() const
|
||||||
|
{
|
||||||
|
return m_msg.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,21 +21,26 @@
|
|||||||
#ifndef _POKERTHEXCEPTION_H_
|
#ifndef _POKERTHEXCEPTION_H_
|
||||||
#define _POKERTHEXCEPTION_H_
|
#define _POKERTHEXCEPTION_H_
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class PokerTHException
|
class PokerTHException : public std::exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PokerTHException(int errorId, int osErrorCode)
|
PokerTHException(const char *sourcefile, int sourceline, int errorId, int osErrorCode);
|
||||||
: m_errorId(errorId), m_osErrorCode(osErrorCode) {}
|
|
||||||
virtual ~PokerTHException();
|
virtual ~PokerTHException();
|
||||||
|
|
||||||
int GetErrorId() const {return m_errorId;}
|
int GetErrorId() const {return m_errorId;}
|
||||||
int GetOsErrorCode() const {return m_osErrorCode;}
|
int GetOsErrorCode() const {return m_osErrorCode;}
|
||||||
|
|
||||||
|
virtual const char *what() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_errorId;
|
int m_errorId;
|
||||||
int m_osErrorCode;
|
int m_osErrorCode;
|
||||||
|
|
||||||
|
std::string m_msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ LocalBeRo::LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState g
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(it_c == myHand->getActivePlayerList()->end()) {
|
if(it_c == myHand->getActivePlayerList()->end()) {
|
||||||
throw LocalException(ERR_ACTIVE_PLAYER_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_ACTIVE_PLAYER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine smallBlindPosition
|
// determine smallBlindPosition
|
||||||
@@ -51,7 +51,7 @@ LocalBeRo::LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState g
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(it_c == myHand->getActivePlayerList()->end()) {
|
if(it_c == myHand->getActivePlayerList()->end()) {
|
||||||
throw LocalException(ERR_ACTIVE_PLAYER_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_ACTIVE_PLAYER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ void LocalBeRo::nextPlayer() {
|
|||||||
|
|
||||||
PlayerListConstIterator currentPlayersTurnConstIt = myHand->getRunningPlayerIt(currentPlayersTurnId);
|
PlayerListConstIterator currentPlayersTurnConstIt = myHand->getRunningPlayerIt(currentPlayersTurnId);
|
||||||
if(currentPlayersTurnConstIt == myHand->getRunningPlayerList()->end()) {
|
if(currentPlayersTurnConstIt == myHand->getRunningPlayerList()->end()) {
|
||||||
throw LocalException(ERR_RUNNING_PLAYER_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_RUNNING_PLAYER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
(*currentPlayersTurnConstIt)->action();
|
(*currentPlayersTurnConstIt)->action();
|
||||||
@@ -178,7 +178,7 @@ void LocalBeRo::run() {
|
|||||||
|
|
||||||
it_1 = myHand->getActivePlayerIt(smallBlindPositionId);
|
it_1 = myHand->getActivePlayerIt(smallBlindPositionId);
|
||||||
if(it_1 == myHand->getActivePlayerList()->end()) {
|
if(it_1 == myHand->getActivePlayerList()->end()) {
|
||||||
throw LocalException(ERR_ACTIVE_PLAYER_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_ACTIVE_PLAYER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0; i<myHand->getActivePlayerList()->size(); i++) {
|
for(i=0; i<myHand->getActivePlayerList()->size(); i++) {
|
||||||
@@ -195,7 +195,7 @@ void LocalBeRo::run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!formerRunningPlayerFound) {
|
if(!formerRunningPlayerFound) {
|
||||||
throw LocalException(ERR_FORMER_RUNNING_PLAYER_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_FORMER_RUNNING_PLAYER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// heads up: bigBlind begins -> dealer/smallBlind is running player before bigBlind
|
// heads up: bigBlind begins -> dealer/smallBlind is running player before bigBlind
|
||||||
@@ -343,7 +343,7 @@ void LocalBeRo::run() {
|
|||||||
// determine next running player
|
// determine next running player
|
||||||
PlayerListConstIterator currentPlayersTurnIt = myHand->getRunningPlayerIt( currentPlayersTurnId );
|
PlayerListConstIterator currentPlayersTurnIt = myHand->getRunningPlayerIt( currentPlayersTurnId );
|
||||||
if(currentPlayersTurnIt == myHand->getRunningPlayerList()->end()) {
|
if(currentPlayersTurnIt == myHand->getRunningPlayerList()->end()) {
|
||||||
throw LocalException(ERR_RUNNING_PLAYER_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_RUNNING_PLAYER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentPlayersTurnIt++;
|
currentPlayersTurnIt++;
|
||||||
@@ -386,7 +386,7 @@ void LocalBeRo::run() {
|
|||||||
|
|
||||||
currentPlayersTurnIt = myHand->getRunningPlayerIt( currentPlayersTurnId );
|
currentPlayersTurnIt = myHand->getRunningPlayerIt( currentPlayersTurnId );
|
||||||
if(currentPlayersTurnIt == myHand->getRunningPlayerList()->end()) {
|
if(currentPlayersTurnIt == myHand->getRunningPlayerList()->end()) {
|
||||||
throw LocalException(ERR_RUNNING_PLAYER_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_RUNNING_PLAYER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
(*currentPlayersTurnIt)->setMyTurn(true);
|
(*currentPlayersTurnIt)->setMyTurn(true);
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ void LocalBeRoPreflop::run() {
|
|||||||
|
|
||||||
it = getMyHand()->getActivePlayerIt(getSmallBlindPositionId());
|
it = getMyHand()->getActivePlayerIt(getSmallBlindPositionId());
|
||||||
if(it == getMyHand()->getActivePlayerList()->end()) {
|
if(it == getMyHand()->getActivePlayerList()->end()) {
|
||||||
throw LocalException(ERR_ACTIVE_PLAYER_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_ACTIVE_PLAYER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(it == getMyHand()->getActivePlayerList()->begin()) it = getMyHand()->getActivePlayerList()->end();
|
if(it == getMyHand()->getActivePlayerList()->begin()) it = getMyHand()->getActivePlayerList()->end();
|
||||||
@@ -227,7 +227,7 @@ void LocalBeRoPreflop::run() {
|
|||||||
|
|
||||||
PlayerListConstIterator currentPlayersTurnIt = getMyHand()->getRunningPlayerIt( getCurrentPlayersTurnId() );
|
PlayerListConstIterator currentPlayersTurnIt = getMyHand()->getRunningPlayerIt( getCurrentPlayersTurnId() );
|
||||||
if(currentPlayersTurnIt == getMyHand()->getRunningPlayerList()->end()) {
|
if(currentPlayersTurnIt == getMyHand()->getRunningPlayerList()->end()) {
|
||||||
throw LocalException(ERR_RUNNING_PLAYER_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_RUNNING_PLAYER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentPlayersTurnIt++;
|
currentPlayersTurnIt++;
|
||||||
@@ -353,7 +353,7 @@ void LocalBeRoPreflop::run() {
|
|||||||
|
|
||||||
currentPlayersTurnIt = getMyHand()->getRunningPlayerIt( getCurrentPlayersTurnId() );
|
currentPlayersTurnIt = getMyHand()->getRunningPlayerIt( getCurrentPlayersTurnId() );
|
||||||
if(currentPlayersTurnIt == getMyHand()->getRunningPlayerList()->end()) {
|
if(currentPlayersTurnIt == getMyHand()->getRunningPlayerList()->end()) {
|
||||||
throw LocalException(ERR_RUNNING_PLAYER_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_RUNNING_PLAYER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
(*currentPlayersTurnIt)->setMyTurn(true);
|
(*currentPlayersTurnIt)->setMyTurn(true);
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ void LocalBoard::distributePot() {
|
|||||||
// determine the number of level winners
|
// determine the number of level winners
|
||||||
winnerCount = potLevel.size()-2;
|
winnerCount = potLevel.size()-2;
|
||||||
if (!winnerCount) {
|
if (!winnerCount) {
|
||||||
throw LocalException(ERR_NO_WINNER);
|
throw LocalException(__FILE__, __LINE__, ERR_NO_WINNER);
|
||||||
}
|
}
|
||||||
|
|
||||||
// distribute the pot level sum to level winners
|
// distribute the pot level sum to level winners
|
||||||
@@ -176,7 +176,7 @@ void LocalBoard::distributePot() {
|
|||||||
for(j=2; j<potLevel.size(); j++) {
|
for(j=2; j<potLevel.size(); j++) {
|
||||||
it = currentHand->getSeatIt(potLevel[j]);
|
it = currentHand->getSeatIt(potLevel[j]);
|
||||||
if(it == seatsList->end()) {
|
if(it == seatsList->end()) {
|
||||||
throw LocalException(ERR_SEAT_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
(*it)->setMyCash( (*it)->getMyCash() + ((potLevel[1])/winnerCount));
|
(*it)->setMyCash( (*it)->getMyCash() + ((potLevel[1])/winnerCount));
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ void LocalBoard::distributePot() {
|
|||||||
|
|
||||||
it = currentHand->getSeatIt(winnerPointer);
|
it = currentHand->getSeatIt(winnerPointer);
|
||||||
if(it == seatsList->end()) {
|
if(it == seatsList->end()) {
|
||||||
throw LocalException(ERR_SEAT_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
if(j<mod) {
|
if(j<mod) {
|
||||||
(*it)->setMyCash( (*it)->getMyCash() + (int)((potLevel[1])/winnerCount) + 1);
|
(*it)->setMyCash( (*it)->getMyCash() + (int)((potLevel[1])/winnerCount) + 1);
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ class LocalException : public PokerTHException
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LocalException(int errorId)
|
LocalException(const char *sourcefile, int sourceline, int errorId)
|
||||||
: PokerTHException(errorId, 0) {}
|
: PokerTHException(sourcefile, sourceline, errorId, 0) {}
|
||||||
virtual ~LocalException();
|
virtual ~LocalException();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ void LocalHand::assignButtons() {
|
|||||||
// DealerButton zuweisen
|
// DealerButton zuweisen
|
||||||
it = getSeatIt(dealerPosition);
|
it = getSeatIt(dealerPosition);
|
||||||
if(it == seatsList->end()) {
|
if(it == seatsList->end()) {
|
||||||
throw LocalException(ERR_SEAT_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
(*it)->setMyButton(BUTTON_DEALER);
|
(*it)->setMyButton(BUTTON_DEALER);
|
||||||
|
|
||||||
@@ -417,7 +417,7 @@ void LocalHand::assignButtons() {
|
|||||||
bool nextActivePlayerFound = false;
|
bool nextActivePlayerFound = false;
|
||||||
PlayerListIterator dealerPositionIt = getSeatIt(dealerPosition);
|
PlayerListIterator dealerPositionIt = getSeatIt(dealerPosition);
|
||||||
if(dealerPositionIt == seatsList->end()) {
|
if(dealerPositionIt == seatsList->end()) {
|
||||||
throw LocalException(ERR_SEAT_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0; i<seatsList->size(); i++) {
|
for(i=0; i<seatsList->size(); i++) {
|
||||||
@@ -442,7 +442,7 @@ void LocalHand::assignButtons() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
if(!nextActivePlayerFound) {
|
if(!nextActivePlayerFound) {
|
||||||
throw LocalException(ERR_NEXT_ACTIVE_PLAYER_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_NEXT_ACTIVE_PLAYER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-5
@@ -26,7 +26,6 @@
|
|||||||
#include "engine_msg.h"
|
#include "engine_msg.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -67,7 +66,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
|||||||
++player_i;
|
++player_i;
|
||||||
}
|
}
|
||||||
if (player_i == player_end)
|
if (player_i == player_end)
|
||||||
throw LocalException(ERR_DEALER_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_DEALER_NOT_FOUND);
|
||||||
dealerPosition = startData.startDealerPlayerId;
|
dealerPosition = startData.startDealerPlayerId;
|
||||||
|
|
||||||
// Board erstellen
|
// Board erstellen
|
||||||
@@ -204,7 +203,7 @@ void Game::initHand()
|
|||||||
bool nextDealerFound = false;
|
bool nextDealerFound = false;
|
||||||
PlayerListConstIterator dealerPositionIt = currentHand->getSeatIt(dealerPosition);
|
PlayerListConstIterator dealerPositionIt = currentHand->getSeatIt(dealerPosition);
|
||||||
if(dealerPositionIt == seatsList->end()) {
|
if(dealerPositionIt == seatsList->end()) {
|
||||||
throw LocalException(ERR_SEAT_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0; i<seatsList->size(); i++) {
|
for(i=0; i<seatsList->size(); i++) {
|
||||||
@@ -221,7 +220,7 @@ void Game::initHand()
|
|||||||
|
|
||||||
}
|
}
|
||||||
if(!nextDealerFound) {
|
if(!nextDealerFound) {
|
||||||
throw LocalException(ERR_NEXT_DEALER_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_NEXT_DEALER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -260,7 +259,7 @@ boost::shared_ptr<PlayerInterface> Game::getCurrentPlayer()
|
|||||||
{
|
{
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer = getPlayerByUniqueId(getCurrentHand()->getCurrentBeRo()->getCurrentPlayersTurnId());
|
boost::shared_ptr<PlayerInterface> tmpPlayer = getPlayerByUniqueId(getCurrentHand()->getCurrentBeRo()->getCurrentPlayersTurnId());
|
||||||
if (!tmpPlayer.get())
|
if (!tmpPlayer.get())
|
||||||
throw LocalException(ERR_CURRENT_PLAYER_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_CURRENT_PLAYER_NOT_FOUND);
|
||||||
return tmpPlayer;
|
return tmpPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ class ClientException : public NetException
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ClientException(int errorId, int osErrorCode)
|
ClientException(const char *sourcefile, int sourceline, int errorId, int osErrorCode)
|
||||||
: NetException(errorId, osErrorCode) {}
|
: NetException(sourcefile, sourceline, errorId, osErrorCode) {}
|
||||||
|
|
||||||
virtual ~ClientException();
|
virtual ~ClientException();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -69,18 +69,18 @@ ClientStateInit::Process(ClientThread &client)
|
|||||||
ClientContext &context = client.GetContext();
|
ClientContext &context = client.GetContext();
|
||||||
|
|
||||||
if (context.GetServerAddr().empty())
|
if (context.GetServerAddr().empty())
|
||||||
throw ClientException(ERR_SOCK_SERVERADDR_NOT_SET, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_SOCK_SERVERADDR_NOT_SET, 0);
|
||||||
|
|
||||||
if (context.GetServerPort() < 1024)
|
if (context.GetServerPort() < 1024)
|
||||||
throw ClientException(ERR_SOCK_INVALID_PORT, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_SOCK_INVALID_PORT, 0);
|
||||||
|
|
||||||
context.SetSocket(socket(context.GetAddrFamily(), SOCK_STREAM, context.GetProtocol()));
|
context.SetSocket(socket(context.GetAddrFamily(), SOCK_STREAM, context.GetProtocol()));
|
||||||
if (!IS_VALID_SOCKET(context.GetSocket()))
|
if (!IS_VALID_SOCKET(context.GetSocket()))
|
||||||
throw ClientException(ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
|
throw ClientException(__FILE__, __LINE__, ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
|
||||||
|
|
||||||
unsigned long mode = 1;
|
unsigned long mode = 1;
|
||||||
if (IOCTLSOCKET(context.GetSocket(), FIONBIO, &mode) == SOCKET_ERROR)
|
if (IOCTLSOCKET(context.GetSocket(), FIONBIO, &mode) == SOCKET_ERROR)
|
||||||
throw ClientException(ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
|
throw ClientException(__FILE__, __LINE__, ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
|
||||||
|
|
||||||
// The following call is optional - the return value is not checked.
|
// The following call is optional - the return value is not checked.
|
||||||
int nodelay = 1;
|
int nodelay = 1;
|
||||||
@@ -126,7 +126,7 @@ ClientStateStartResolve::Process(ClientThread &client)
|
|||||||
{
|
{
|
||||||
// Success - but we still need to set the port.
|
// Success - but we still need to set the port.
|
||||||
if (!socket_set_port(context.GetServerPort(), context.GetAddrFamily(), (struct sockaddr *)context.GetClientSockaddr(), context.GetClientSockaddrSize()))
|
if (!socket_set_port(context.GetServerPort(), context.GetAddrFamily(), (struct sockaddr *)context.GetClientSockaddr(), context.GetClientSockaddrSize()))
|
||||||
throw ClientException(ERR_SOCK_SET_PORT_FAILED, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_SOCK_SET_PORT_FAILED, 0);
|
||||||
|
|
||||||
// No need to resolve - start connecting.
|
// No need to resolve - start connecting.
|
||||||
client.SetState(ClientStateStartConnect::Instance());
|
client.SetState(ClientStateStartConnect::Instance());
|
||||||
@@ -181,7 +181,7 @@ ClientStateResolving::Process(ClientThread &client)
|
|||||||
int retVal;
|
int retVal;
|
||||||
|
|
||||||
if (!m_resolver)
|
if (!m_resolver)
|
||||||
throw ClientException(ERR_SOCK_RESOLVE_FAILED, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_SOCK_RESOLVE_FAILED, 0);
|
||||||
|
|
||||||
if (m_resolver->Join(CLIENT_WAIT_TIMEOUT_MSEC))
|
if (m_resolver->Join(CLIENT_WAIT_TIMEOUT_MSEC))
|
||||||
{
|
{
|
||||||
@@ -190,7 +190,7 @@ ClientStateResolving::Process(ClientThread &client)
|
|||||||
Cleanup(); // Not required, but better keep things clean.
|
Cleanup(); // Not required, but better keep things clean.
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
throw ClientException(ERR_SOCK_RESOLVE_FAILED, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_SOCK_RESOLVE_FAILED, 0);
|
||||||
|
|
||||||
client.SetState(ClientStateStartConnect::Instance());
|
client.SetState(ClientStateStartConnect::Instance());
|
||||||
retVal = MSG_SOCK_RESOLVE_DONE;
|
retVal = MSG_SOCK_RESOLVE_DONE;
|
||||||
@@ -256,7 +256,7 @@ ClientStateStartConnect::Process(ClientThread &client)
|
|||||||
retVal = MSG_SOCK_INTERNAL_PENDING;
|
retVal = MSG_SOCK_INTERNAL_PENDING;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw ClientException(ERR_SOCK_CONNECT_FAILED, SOCKET_ERRNO());
|
throw ClientException(__FILE__, __LINE__, ERR_SOCK_CONNECT_FAILED, SOCKET_ERRNO());
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
@@ -308,19 +308,19 @@ ClientStateConnecting::Process(ClientThread &client)
|
|||||||
socklen_t tmpSize = sizeof(connectResult);
|
socklen_t tmpSize = sizeof(connectResult);
|
||||||
getsockopt(context.GetSocket(), SOL_SOCKET, SO_ERROR, (char *)&connectResult, &tmpSize);
|
getsockopt(context.GetSocket(), SOL_SOCKET, SO_ERROR, (char *)&connectResult, &tmpSize);
|
||||||
if (connectResult != 0)
|
if (connectResult != 0)
|
||||||
throw ClientException(ERR_SOCK_CONNECT_FAILED, connectResult);
|
throw ClientException(__FILE__, __LINE__, ERR_SOCK_CONNECT_FAILED, connectResult);
|
||||||
client.SetState(ClientStateStartSession::Instance());
|
client.SetState(ClientStateStartSession::Instance());
|
||||||
retVal = MSG_SOCK_CONNECT_DONE;
|
retVal = MSG_SOCK_CONNECT_DONE;
|
||||||
}
|
}
|
||||||
else if (selectResult == 0) // timeout
|
else if (selectResult == 0) // timeout
|
||||||
{
|
{
|
||||||
if (m_connectTimer.elapsed().total_seconds() >= CLIENT_CONNECT_TIMEOUT_SEC)
|
if (m_connectTimer.elapsed().total_seconds() >= CLIENT_CONNECT_TIMEOUT_SEC)
|
||||||
throw ClientException(ERR_SOCK_CONNECT_TIMEOUT, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_SOCK_CONNECT_TIMEOUT, 0);
|
||||||
else
|
else
|
||||||
retVal = MSG_SOCK_INTERNAL_PENDING;
|
retVal = MSG_SOCK_INTERNAL_PENDING;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw ClientException(ERR_SOCK_SELECT_FAILED, SOCKET_ERRNO());
|
throw ClientException(__FILE__, __LINE__, ERR_SOCK_SELECT_FAILED, SOCKET_ERRNO());
|
||||||
|
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
@@ -524,7 +524,7 @@ AbstractClientStateReceiving::Process(ClientThread &client)
|
|||||||
NetPacketError::Data errorData;
|
NetPacketError::Data errorData;
|
||||||
tmpPacket->ToNetPacketError()->GetData(errorData);
|
tmpPacket->ToNetPacketError()->GetData(errorData);
|
||||||
// Show the error.
|
// Show the error.
|
||||||
throw ClientException(errorData.errorCode, 0);
|
throw ClientException(__FILE__, __LINE__, errorData.errorCode, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
retVal = InternalProcess(client, tmpPacket);
|
retVal = InternalProcess(client, tmpPacket);
|
||||||
@@ -587,7 +587,7 @@ ClientStateWaitSession::InternalProcess(ClientThread &client, boost::shared_ptr<
|
|||||||
if (!avatarError)
|
if (!avatarError)
|
||||||
client.GetSender().SendLowPrio(client.GetContext().GetSocket(), tmpList);
|
client.GetSender().SendLowPrio(client.GetContext().GetSocket(), tmpList);
|
||||||
else
|
else
|
||||||
throw NetException(avatarError, 0);
|
throw ClientException(__FILE__, __LINE__, avatarError, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
@@ -746,7 +746,7 @@ ClientStateSynchronizeStart::InternalProcess(ClientThread &/*client*/, boost::sh
|
|||||||
int retVal = MSG_SOCK_INTERNAL_PENDING;
|
int retVal = MSG_SOCK_INTERNAL_PENDING;
|
||||||
|
|
||||||
if (packet->ToNetPacketGameStart())
|
if (packet->ToNetPacketGameStart())
|
||||||
throw ClientException(ERR_NET_START_TIMEOUT, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_NET_START_TIMEOUT, 0);
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
@@ -791,7 +791,7 @@ ClientStateWaitStart::InternalProcess(ClientThread &client, boost::shared_ptr<Ne
|
|||||||
unsigned playerId = (*slot_i).playerId;
|
unsigned playerId = (*slot_i).playerId;
|
||||||
boost::shared_ptr<PlayerData> tmpPlayer = client.GetPlayerDataByUniqueId(playerId);
|
boost::shared_ptr<PlayerData> tmpPlayer = client.GetPlayerDataByUniqueId(playerId);
|
||||||
if (!tmpPlayer.get())
|
if (!tmpPlayer.get())
|
||||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
tmpPlayer->SetNumber(num);
|
tmpPlayer->SetNumber(num);
|
||||||
|
|
||||||
++num;
|
++num;
|
||||||
@@ -860,7 +860,7 @@ ClientStateWaitHand::InternalProcess(ClientThread &client, boost::shared_ptr<Net
|
|||||||
packet->ToNetPacketEndOfGame()->GetData(endData);
|
packet->ToNetPacketEndOfGame()->GetData(endData);
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(endData.winnerPlayerId);
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(endData.winnerPlayerId);
|
||||||
if (!tmpPlayer)
|
if (!tmpPlayer)
|
||||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
client.GetGui().logPlayerWinGame(tmpPlayer->getMyName(), curGame->getMyGameID());
|
client.GetGui().logPlayerWinGame(tmpPlayer->getMyName(), curGame->getMyGameID());
|
||||||
client.GetCallback().SignalNetClientWaitDialog();
|
client.GetCallback().SignalNetClientWaitDialog();
|
||||||
client.SetState(ClientStateWaitGame::Instance());
|
client.SetState(ClientStateWaitGame::Instance());
|
||||||
@@ -902,7 +902,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
|||||||
packet->ToNetPacketPlayersActionDone()->GetData(actionDoneData);
|
packet->ToNetPacketPlayersActionDone()->GetData(actionDoneData);
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(actionDoneData.playerId);
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(actionDoneData.playerId);
|
||||||
if (!tmpPlayer)
|
if (!tmpPlayer)
|
||||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
|
|
||||||
bool isBigBlind = false;
|
bool isBigBlind = false;
|
||||||
|
|
||||||
@@ -964,7 +964,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
|||||||
packet->ToNetPacketPlayersTurn()->GetData(turnData);
|
packet->ToNetPacketPlayersTurn()->GetData(turnData);
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(turnData.playerId);
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(turnData.playerId);
|
||||||
if (!tmpPlayer)
|
if (!tmpPlayer)
|
||||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
|
|
||||||
// Set round.
|
// Set round.
|
||||||
if (curGame->getCurrentHand()->getCurrentRound() != turnData.gameState)
|
if (curGame->getCurrentHand()->getCurrentRound() != turnData.gameState)
|
||||||
@@ -1059,7 +1059,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
|||||||
{
|
{
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId((*i).playerId);
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId((*i).playerId);
|
||||||
if (!tmpPlayer)
|
if (!tmpPlayer)
|
||||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
|
|
||||||
int tmpCards[2];
|
int tmpCards[2];
|
||||||
tmpCards[0] = static_cast<int>((*i).cards[0]);
|
tmpCards[0] = static_cast<int>((*i).cards[0]);
|
||||||
@@ -1085,7 +1085,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
|||||||
|
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(endHandData.playerId);
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(endHandData.playerId);
|
||||||
if (!tmpPlayer)
|
if (!tmpPlayer)
|
||||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
|
|
||||||
tmpPlayer->setMyCash(endHandData.playerMoney);
|
tmpPlayer->setMyCash(endHandData.playerMoney);
|
||||||
// TODO use moneyWon
|
// TODO use moneyWon
|
||||||
@@ -1121,7 +1121,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
|||||||
{
|
{
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId((*i).playerId);
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId((*i).playerId);
|
||||||
if (!tmpPlayer)
|
if (!tmpPlayer)
|
||||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
|
|
||||||
int tmpCards[2];
|
int tmpCards[2];
|
||||||
int bestHandPos[5];
|
int bestHandPos[5];
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ ClientThread::Main()
|
|||||||
|
|
||||||
MapPlayerDataList();
|
MapPlayerDataList();
|
||||||
if (GetPlayerDataList().size() != (unsigned)GetStartData().numberOfPlayers)
|
if (GetPlayerDataList().size() != (unsigned)GetStartData().numberOfPlayers)
|
||||||
throw NetException(ERR_NET_INVALID_PLAYER_COUNT, 0);
|
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_curGameId++));
|
||||||
// Initialize GUI speed.
|
// Initialize GUI speed.
|
||||||
GetGui().initGui(GetGameData().guiSpeed);
|
GetGui().initGui(GetGameData().guiSpeed);
|
||||||
@@ -316,7 +316,7 @@ ClientThread::Main()
|
|||||||
if (IsSessionEstablished())
|
if (IsSessionEstablished())
|
||||||
SendPacketLoop();
|
SendPacketLoop();
|
||||||
}
|
}
|
||||||
} catch (const NetException &e)
|
} catch (const PokerTHException &e)
|
||||||
{
|
{
|
||||||
GetCallback().SignalNetClientError(e.GetErrorId(), e.GetOsErrorCode());
|
GetCallback().SignalNetClientError(e.GetErrorId(), e.GetOsErrorCode());
|
||||||
}
|
}
|
||||||
@@ -462,7 +462,7 @@ ClientThread::StoreInTempAvatarData(unsigned playerId, const vector<unsigned cha
|
|||||||
{
|
{
|
||||||
AvatarDataMap::iterator pos = m_tempAvatarMap.find(playerId);
|
AvatarDataMap::iterator pos = m_tempAvatarMap.find(playerId);
|
||||||
if (pos == m_tempAvatarMap.end())
|
if (pos == m_tempAvatarMap.end())
|
||||||
throw NetException(ERR_NET_INVALID_REQUEST_ID, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_NET_INVALID_REQUEST_ID, 0);
|
||||||
// We trust the server (concerning size of the data).
|
// We trust the server (concerning size of the data).
|
||||||
std::copy(data.begin(), data.end(), back_inserter(pos->second->fileData));
|
std::copy(data.begin(), data.end(), back_inserter(pos->second->fileData));
|
||||||
}
|
}
|
||||||
@@ -472,16 +472,16 @@ ClientThread::CompleteTempAvatarData(unsigned playerId)
|
|||||||
{
|
{
|
||||||
AvatarDataMap::iterator pos = m_tempAvatarMap.find(playerId);
|
AvatarDataMap::iterator pos = m_tempAvatarMap.find(playerId);
|
||||||
if (pos == m_tempAvatarMap.end())
|
if (pos == m_tempAvatarMap.end())
|
||||||
throw NetException(ERR_NET_INVALID_REQUEST_ID, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_NET_INVALID_REQUEST_ID, 0);
|
||||||
|
|
||||||
boost::shared_ptr<AvatarData> tmpAvatar = pos->second;
|
boost::shared_ptr<AvatarData> tmpAvatar = pos->second;
|
||||||
unsigned avatarSize = (unsigned)tmpAvatar->fileData.size();
|
unsigned avatarSize = (unsigned)tmpAvatar->fileData.size();
|
||||||
if (avatarSize != tmpAvatar->reportedSize)
|
if (avatarSize != tmpAvatar->reportedSize)
|
||||||
throw NetException(ERR_NET_WRONG_AVATAR_SIZE, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_NET_WRONG_AVATAR_SIZE, 0);
|
||||||
|
|
||||||
PlayerInfo tmpPlayerInfo;
|
PlayerInfo tmpPlayerInfo;
|
||||||
if (!GetCachedPlayerInfo(playerId, tmpPlayerInfo))
|
if (!GetCachedPlayerInfo(playerId, tmpPlayerInfo))
|
||||||
throw NetException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
|
|
||||||
GetAvatarManager().StoreAvatarInCache(tmpPlayerInfo.avatar, tmpAvatar->fileType, &tmpAvatar->fileData[0], avatarSize);
|
GetAvatarManager().StoreAvatarInCache(tmpPlayerInfo.avatar, tmpAvatar->fileType, &tmpAvatar->fileData[0], avatarSize);
|
||||||
// TODO log error
|
// TODO log error
|
||||||
@@ -772,7 +772,7 @@ ClientThread::GetGameIdByName(const std::string &name) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (i == end)
|
if (i == end)
|
||||||
throw NetException(ERR_NET_UNKNOWN_GAME, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_GAME, 0);
|
||||||
return i->first;
|
return i->first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -586,7 +586,7 @@ CheckGameInfoData(const GameInfoData *tmpData)
|
|||||||
|| !ntohl(tmpData->firstSmallBlind)
|
|| !ntohl(tmpData->firstSmallBlind)
|
||||||
|| !ntohl(tmpData->startMoney))
|
|| !ntohl(tmpData->startMoney))
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -598,7 +598,7 @@ NetPacket::Create(char *data, unsigned &dataSize)
|
|||||||
// Check minimum requirements.
|
// Check minimum requirements.
|
||||||
if (!data || dataSize < sizeof(NetPacketHeader))
|
if (!data || dataSize < sizeof(NetPacketHeader))
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetPacketHeader *tmpHeader = (NetPacketHeader *)data;
|
NetPacketHeader *tmpHeader = (NetPacketHeader *)data;
|
||||||
@@ -608,7 +608,7 @@ NetPacket::Create(char *data, unsigned &dataSize)
|
|||||||
if (tmpLen < sizeof(NetPacketHeader)
|
if (tmpLen < sizeof(NetPacketHeader)
|
||||||
|| tmpLen > MAX_PACKET_SIZE)
|
|| tmpLen > MAX_PACKET_SIZE)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
else if (dataSize >= tmpLen)
|
else if (dataSize >= tmpLen)
|
||||||
{
|
{
|
||||||
@@ -748,7 +748,7 @@ NetPacket::Create(char *data, unsigned &dataSize)
|
|||||||
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketError);
|
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketError);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw NetException(ERR_SOCK_INVALID_TYPE, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_TYPE, 0);
|
||||||
}
|
}
|
||||||
if (tmpPacket.get())
|
if (tmpPacket.get())
|
||||||
tmpPacket->SetRawData(tmpHeader);
|
tmpPacket->SetRawData(tmpHeader);
|
||||||
@@ -810,7 +810,7 @@ NetPacket::SetRawData(const NetPacketHeader *p)
|
|||||||
u_int16_t tmpLen = ntohs(p->length);
|
u_int16_t tmpLen = ntohs(p->length);
|
||||||
if (ntohs(p->type) != GetType())
|
if (ntohs(p->type) != GetType())
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check whether the data is valid.
|
// Check whether the data is valid.
|
||||||
Check(p);
|
Check(p);
|
||||||
@@ -1097,12 +1097,12 @@ NetPacket::Resize(u_int16_t newLen)
|
|||||||
if (newLen != oldLen)
|
if (newLen != oldLen)
|
||||||
{
|
{
|
||||||
if (newLen < sizeof(NetPacketHeader))
|
if (newLen < sizeof(NetPacketHeader))
|
||||||
throw NetException(ERR_SOCK_INTERNAL, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INTERNAL, 0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NetPacketHeader *newData = (NetPacketHeader *)malloc(newLen);
|
NetPacketHeader *newData = (NetPacketHeader *)malloc(newLen);
|
||||||
if (!newData)
|
if (!newData)
|
||||||
throw NetException(ERR_SOCK_INTERNAL, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INTERNAL, 0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Copy as much data as possible.
|
// Copy as much data as possible.
|
||||||
@@ -1130,7 +1130,7 @@ NetPacket::Check(const NetPacketHeader *data) const
|
|||||||
u_int16_t dataLen = ntohs(data->length);
|
u_int16_t dataLen = ntohs(data->length);
|
||||||
if (dataLen < m_initialSize || dataLen > m_maxSize)
|
if (dataLen < m_initialSize || dataLen > m_maxSize)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
InternalCheck(data);
|
InternalCheck(data);
|
||||||
@@ -1173,9 +1173,9 @@ NetPacketInit::SetData(const NetPacketInit::Data &inData)
|
|||||||
// Some basic checks, so we don't use up too much memory.
|
// Some basic checks, so we don't use up too much memory.
|
||||||
// The constructed packet will also be checked.
|
// The constructed packet will also be checked.
|
||||||
if (!playerNameLen || playerNameLen > MAX_NAME_SIZE)
|
if (!playerNameLen || playerNameLen > MAX_NAME_SIZE)
|
||||||
throw NetException(ERR_NET_INVALID_PLAYER_NAME, 0);
|
throw NetException(__FILE__, __LINE__, ERR_NET_INVALID_PLAYER_NAME, 0);
|
||||||
if (passwordLen > MAX_PASSWORD_SIZE)
|
if (passwordLen > MAX_PASSWORD_SIZE)
|
||||||
throw NetException(ERR_NET_INVALID_PASSWORD_STR, 0);
|
throw NetException(__FILE__, __LINE__, ERR_NET_INVALID_PASSWORD_STR, 0);
|
||||||
|
|
||||||
int avatarSize = inData.showAvatar ? MD5_DATA_SIZE : 0;
|
int avatarSize = inData.showAvatar ? MD5_DATA_SIZE : 0;
|
||||||
// Resize the packet so that the data fits in.
|
// Resize the packet so that the data fits in.
|
||||||
@@ -1255,20 +1255,20 @@ NetPacketInit::InternalCheck(const NetPacketHeader* data) const
|
|||||||
+ ADD_PADDING(passwordLength)
|
+ ADD_PADDING(passwordLength)
|
||||||
+ ADD_PADDING(playerNameLength))
|
+ ADD_PADDING(playerNameLength))
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check string sizes.
|
// Check string sizes.
|
||||||
if (passwordLength > MAX_PASSWORD_SIZE
|
if (passwordLength > MAX_PASSWORD_SIZE
|
||||||
|| !playerNameLength
|
|| !playerNameLength
|
||||||
|| playerNameLength > MAX_NAME_SIZE)
|
|| playerNameLength > MAX_NAME_SIZE)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check name string.
|
// Check name string.
|
||||||
char *namePtr = (char *)tmpData + sizeof(NetPacketInitData) + avatarSize + ADD_PADDING(passwordLength);
|
char *namePtr = (char *)tmpData + sizeof(NetPacketInitData) + avatarSize + ADD_PADDING(passwordLength);
|
||||||
if (namePtr[0] == 0)
|
if (namePtr[0] == 0)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1483,7 +1483,7 @@ NetPacketAvatarFile::SetData(const NetPacketAvatarFile::Data &inData)
|
|||||||
int fileDataSize = static_cast<int>(inData.fileData.size());
|
int fileDataSize = static_cast<int>(inData.fileData.size());
|
||||||
|
|
||||||
if (fileDataSize > MAX_FILE_DATA_SIZE)
|
if (fileDataSize > MAX_FILE_DATA_SIZE)
|
||||||
throw NetException(ERR_NET_BUF_INVALID_SIZE, 0);
|
throw NetException(__FILE__, __LINE__, ERR_NET_BUF_INVALID_SIZE, 0);
|
||||||
|
|
||||||
Resize((u_int16_t)
|
Resize((u_int16_t)
|
||||||
(sizeof(NetPacketAvatarFileData)
|
(sizeof(NetPacketAvatarFileData)
|
||||||
@@ -1532,11 +1532,11 @@ NetPacketAvatarFile::InternalCheck(const NetPacketHeader *data) const
|
|||||||
sizeof(NetPacketAvatarFileData)
|
sizeof(NetPacketAvatarFileData)
|
||||||
+ ADD_PADDING(fileDataSize))
|
+ ADD_PADDING(fileDataSize))
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
if (!fileDataSize || fileDataSize > MAX_FILE_DATA_SIZE)
|
if (!fileDataSize || fileDataSize > MAX_FILE_DATA_SIZE)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1689,9 +1689,9 @@ NetPacketGameListNew::SetData(const NetPacketGameListNew::Data &inData)
|
|||||||
// Some basic checks, so we don't use up too much memory.
|
// Some basic checks, so we don't use up too much memory.
|
||||||
// The constructed packet will also be checked.
|
// The constructed packet will also be checked.
|
||||||
if (!gameNameLen || gameNameLen > MAX_NAME_SIZE)
|
if (!gameNameLen || gameNameLen > MAX_NAME_SIZE)
|
||||||
throw NetException(ERR_NET_INVALID_GAME_NAME, 0);
|
throw NetException(__FILE__, __LINE__, ERR_NET_INVALID_GAME_NAME, 0);
|
||||||
if (numManualBlinds > MAX_NUM_MANUAL_BLINDS)
|
if (numManualBlinds > MAX_NUM_MANUAL_BLINDS)
|
||||||
throw NetException(ERR_NET_TOO_MANY_MANUAL_BLINDS, 0);
|
throw NetException(__FILE__, __LINE__, ERR_NET_TOO_MANY_MANUAL_BLINDS, 0);
|
||||||
|
|
||||||
// Resize the packet so that the data fits in.
|
// Resize the packet so that the data fits in.
|
||||||
Resize((u_int16_t)
|
Resize((u_int16_t)
|
||||||
@@ -1786,24 +1786,24 @@ NetPacketGameListNew::InternalCheck(const NetPacketHeader* data) const
|
|||||||
+ ADD_PADDING(gameNameLength)
|
+ ADD_PADDING(gameNameLength)
|
||||||
+ curNumPlayers * sizeof(unsigned))
|
+ curNumPlayers * sizeof(unsigned))
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check manual blind list size
|
// Check manual blind list size
|
||||||
if (numManualBlinds > MAX_NUM_MANUAL_BLINDS)
|
if (numManualBlinds > MAX_NUM_MANUAL_BLINDS)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check string size.
|
// Check string size.
|
||||||
if (!gameNameLength
|
if (!gameNameLength
|
||||||
|| gameNameLength > MAX_NAME_SIZE)
|
|| gameNameLength > MAX_NAME_SIZE)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check name string.
|
// Check name string.
|
||||||
char *namePtr = (char *)tmpData + sizeof(NetPacketGameListNewData) + manualBlindsLength;
|
char *namePtr = (char *)tmpData + sizeof(NetPacketGameListNewData) + manualBlindsLength;
|
||||||
if (namePtr[0] == 0)
|
if (namePtr[0] == 0)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2135,7 +2135,7 @@ NetPacketPlayerInfo::SetData(const NetPacketPlayerInfo::Data &inData)
|
|||||||
u_int16_t playerNameLen = (u_int16_t)inData.playerInfo.playerName.length();
|
u_int16_t playerNameLen = (u_int16_t)inData.playerInfo.playerName.length();
|
||||||
|
|
||||||
if (!playerNameLen || playerNameLen > MAX_NAME_SIZE)
|
if (!playerNameLen || playerNameLen > MAX_NAME_SIZE)
|
||||||
throw NetException(ERR_NET_INVALID_PLAYER_NAME, 0);
|
throw NetException(__FILE__, __LINE__, ERR_NET_INVALID_PLAYER_NAME, 0);
|
||||||
|
|
||||||
int avatarSize = inData.playerInfo.hasAvatar ? MD5_DATA_SIZE : 0;
|
int avatarSize = inData.playerInfo.hasAvatar ? MD5_DATA_SIZE : 0;
|
||||||
// Resize the packet so that the data fits in.
|
// Resize the packet so that the data fits in.
|
||||||
@@ -2206,13 +2206,13 @@ NetPacketPlayerInfo::InternalCheck(const NetPacketHeader* data) const
|
|||||||
+ avatarSize
|
+ avatarSize
|
||||||
+ ADD_PADDING(playerNameLength))
|
+ ADD_PADDING(playerNameLength))
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check string sizes.
|
// Check string sizes.
|
||||||
if (!playerNameLength
|
if (!playerNameLength
|
||||||
|| playerNameLength > MAX_NAME_SIZE)
|
|| playerNameLength > MAX_NAME_SIZE)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2308,11 +2308,11 @@ NetPacketCreateGame::SetData(const NetPacketCreateGame::Data &inData)
|
|||||||
// Some basic checks, so we don't use up too much memory.
|
// Some basic checks, so we don't use up too much memory.
|
||||||
// The constructed packet will also be checked.
|
// The constructed packet will also be checked.
|
||||||
if (!gameNameLen || gameNameLen > MAX_NAME_SIZE)
|
if (!gameNameLen || gameNameLen > MAX_NAME_SIZE)
|
||||||
throw NetException(ERR_NET_INVALID_PLAYER_NAME, 0);
|
throw NetException(__FILE__, __LINE__, ERR_NET_INVALID_PLAYER_NAME, 0);
|
||||||
if (passwordLen > MAX_PASSWORD_SIZE)
|
if (passwordLen > MAX_PASSWORD_SIZE)
|
||||||
throw NetException(ERR_NET_INVALID_PASSWORD_STR, 0);
|
throw NetException(__FILE__, __LINE__, ERR_NET_INVALID_PASSWORD_STR, 0);
|
||||||
if (numManualBlinds > MAX_NUM_MANUAL_BLINDS)
|
if (numManualBlinds > MAX_NUM_MANUAL_BLINDS)
|
||||||
throw NetException(ERR_NET_TOO_MANY_MANUAL_BLINDS, 0);
|
throw NetException(__FILE__, __LINE__, ERR_NET_TOO_MANY_MANUAL_BLINDS, 0);
|
||||||
|
|
||||||
int manualBlindsSize = numManualBlinds * sizeof(u_int32_t);
|
int manualBlindsSize = numManualBlinds * sizeof(u_int32_t);
|
||||||
// Resize the packet so that the data fits in.
|
// Resize the packet so that the data fits in.
|
||||||
@@ -2374,25 +2374,25 @@ NetPacketCreateGame::InternalCheck(const NetPacketHeader* data) const
|
|||||||
+ ADD_PADDING(passwordLength)
|
+ ADD_PADDING(passwordLength)
|
||||||
+ ADD_PADDING(gameNameLength))
|
+ ADD_PADDING(gameNameLength))
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check manual blind list size
|
// Check manual blind list size
|
||||||
if (numManualBlinds > MAX_NUM_MANUAL_BLINDS)
|
if (numManualBlinds > MAX_NUM_MANUAL_BLINDS)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check string sizes.
|
// Check string sizes.
|
||||||
if (passwordLength > MAX_PASSWORD_SIZE
|
if (passwordLength > MAX_PASSWORD_SIZE
|
||||||
|| !gameNameLength
|
|| !gameNameLength
|
||||||
|| gameNameLength > MAX_NAME_SIZE)
|
|| gameNameLength > MAX_NAME_SIZE)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check name string.
|
// Check name string.
|
||||||
char *namePtr = (char *)tmpData + sizeof(NetPacketCreateGameData) + manualBlindsLength + ADD_PADDING(passwordLength);
|
char *namePtr = (char *)tmpData + sizeof(NetPacketCreateGameData) + manualBlindsLength + ADD_PADDING(passwordLength);
|
||||||
if (namePtr[0] == 0)
|
if (namePtr[0] == 0)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
CheckGameInfoData(&tmpData->gameData);
|
CheckGameInfoData(&tmpData->gameData);
|
||||||
}
|
}
|
||||||
@@ -2430,7 +2430,7 @@ NetPacketJoinGame::SetData(const NetPacketJoinGame::Data &inData)
|
|||||||
// Some basic checks, so we don't use up too much memory.
|
// Some basic checks, so we don't use up too much memory.
|
||||||
// The constructed packet will also be checked.
|
// The constructed packet will also be checked.
|
||||||
if (passwordLen > MAX_PASSWORD_SIZE)
|
if (passwordLen > MAX_PASSWORD_SIZE)
|
||||||
throw NetException(ERR_NET_INVALID_PASSWORD_STR, 0);
|
throw NetException(__FILE__, __LINE__, ERR_NET_INVALID_PASSWORD_STR, 0);
|
||||||
|
|
||||||
// Resize the packet so that the data fits in.
|
// Resize the packet so that the data fits in.
|
||||||
Resize((u_int16_t)
|
Resize((u_int16_t)
|
||||||
@@ -2479,12 +2479,12 @@ NetPacketJoinGame::InternalCheck(const NetPacketHeader* data) const
|
|||||||
sizeof(NetPacketJoinGameData)
|
sizeof(NetPacketJoinGameData)
|
||||||
+ ADD_PADDING(passwordLength))
|
+ ADD_PADDING(passwordLength))
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check string size.
|
// Check string size.
|
||||||
if (passwordLength > MAX_PASSWORD_SIZE)
|
if (passwordLength > MAX_PASSWORD_SIZE)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2521,7 +2521,7 @@ NetPacketJoinGameAck::SetData(const NetPacketJoinGameAck::Data &inData)
|
|||||||
// Some basic checks, so we don't use up too much memory.
|
// Some basic checks, so we don't use up too much memory.
|
||||||
// The constructed packet will also be checked.
|
// The constructed packet will also be checked.
|
||||||
if (numManualBlinds > MAX_NUM_MANUAL_BLINDS)
|
if (numManualBlinds > MAX_NUM_MANUAL_BLINDS)
|
||||||
throw NetException(ERR_NET_TOO_MANY_MANUAL_BLINDS, 0);
|
throw NetException(__FILE__, __LINE__, ERR_NET_TOO_MANY_MANUAL_BLINDS, 0);
|
||||||
|
|
||||||
int manualBlindsSize = numManualBlinds * sizeof(u_int32_t);
|
int manualBlindsSize = numManualBlinds * sizeof(u_int32_t);
|
||||||
// Resize the packet so that the data fits in.
|
// Resize the packet so that the data fits in.
|
||||||
@@ -2570,13 +2570,13 @@ NetPacketJoinGameAck::InternalCheck(const NetPacketHeader* data) const
|
|||||||
sizeof(NetPacketJoinGameAckData)
|
sizeof(NetPacketJoinGameAckData)
|
||||||
+ manualBlindsLength)
|
+ manualBlindsLength)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check manual blind list size
|
// Check manual blind list size
|
||||||
if (numManualBlinds > MAX_NUM_MANUAL_BLINDS)
|
if (numManualBlinds > MAX_NUM_MANUAL_BLINDS)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Semantic checks
|
// Semantic checks
|
||||||
CheckGameInfoData(&tmpData->gameData);
|
CheckGameInfoData(&tmpData->gameData);
|
||||||
@@ -3067,7 +3067,7 @@ NetPacketGameStart::SetData(const NetPacketGameStart::Data &inData)
|
|||||||
|
|
||||||
// Basic checking.
|
// Basic checking.
|
||||||
if (numPlayers < MIN_NUMBER_OF_PLAYERS || numPlayers > MAX_NUMBER_OF_PLAYERS || numPlayers != inData.startData.numberOfPlayers)
|
if (numPlayers < MIN_NUMBER_OF_PLAYERS || numPlayers > MAX_NUMBER_OF_PLAYERS || numPlayers != inData.startData.numberOfPlayers)
|
||||||
throw NetException(ERR_NET_INVALID_PLAYER_COUNT, 0);
|
throw NetException(__FILE__, __LINE__, ERR_NET_INVALID_PLAYER_COUNT, 0);
|
||||||
|
|
||||||
// Resize the packet so that the data fits in.
|
// Resize the packet so that the data fits in.
|
||||||
Resize((u_int16_t)
|
Resize((u_int16_t)
|
||||||
@@ -3135,7 +3135,7 @@ NetPacketGameStart::InternalCheck(const NetPacketHeader* data) const
|
|||||||
sizeof(NetPacketGameStartData)
|
sizeof(NetPacketGameStartData)
|
||||||
+ numPlayers * sizeof(PlayerSlotData))
|
+ numPlayers * sizeof(PlayerSlotData))
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Semantic checks not needed.
|
// Semantic checks not needed.
|
||||||
}
|
}
|
||||||
@@ -3200,7 +3200,7 @@ NetPacketHandStart::InternalCheck(const NetPacketHeader* data) const
|
|||||||
NetPacketHandStartData *tmpData = (NetPacketHandStartData *)data;
|
NetPacketHandStartData *tmpData = (NetPacketHandStartData *)data;
|
||||||
if (ntohs(tmpData->yourCard1) > 51 || ntohs(tmpData->yourCard2) > 51)
|
if (ntohs(tmpData->yourCard1) > 51 || ntohs(tmpData->yourCard2) > 51)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3265,7 +3265,7 @@ NetPacketPlayersTurn::InternalCheck(const NetPacketHeader* data) const
|
|||||||
NetPacketPlayersTurnData *tmpData = (NetPacketPlayersTurnData *)data;
|
NetPacketPlayersTurnData *tmpData = (NetPacketPlayersTurnData *)data;
|
||||||
if (ntohs(tmpData->gameState) > GAME_STATE_RIVER)
|
if (ntohs(tmpData->gameState) > GAME_STATE_RIVER)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3330,12 +3330,12 @@ NetPacketPlayersAction::InternalCheck(const NetPacketHeader* data) const
|
|||||||
// Check whether the state is valid.
|
// Check whether the state is valid.
|
||||||
if (ntohs(tmpData->gameState) > GAME_STATE_RIVER)
|
if (ntohs(tmpData->gameState) > GAME_STATE_RIVER)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check whether the player action is valid.
|
// Check whether the player action is valid.
|
||||||
if (ntohs(tmpData->playerAction) > PLAYER_ACTION_ALLIN)
|
if (ntohs(tmpData->playerAction) > PLAYER_ACTION_ALLIN)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Semantic checks are done by the server process.
|
// Semantic checks are done by the server process.
|
||||||
}
|
}
|
||||||
@@ -3410,12 +3410,12 @@ NetPacketPlayersActionDone::InternalCheck(const NetPacketHeader* data) const
|
|||||||
&& gameState != GAME_STATE_PREFLOP_SMALL_BLIND
|
&& gameState != GAME_STATE_PREFLOP_SMALL_BLIND
|
||||||
&& gameState != GAME_STATE_PREFLOP_BIG_BLIND)
|
&& gameState != GAME_STATE_PREFLOP_BIG_BLIND)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check whether the player action is valid.
|
// Check whether the player action is valid.
|
||||||
if (ntohs(tmpData->playerAction) > PLAYER_ACTION_ALLIN)
|
if (ntohs(tmpData->playerAction) > PLAYER_ACTION_ALLIN)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3482,16 +3482,16 @@ NetPacketPlayersActionRejected::InternalCheck(const NetPacketHeader* data) const
|
|||||||
NetPacketPlayersActionRejectedData *tmpData = (NetPacketPlayersActionRejectedData *)data;
|
NetPacketPlayersActionRejectedData *tmpData = (NetPacketPlayersActionRejectedData *)data;
|
||||||
if (ntohs(tmpData->gameState) > GAME_STATE_RIVER)
|
if (ntohs(tmpData->gameState) > GAME_STATE_RIVER)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check whether the player action is valid.
|
// Check whether the player action is valid.
|
||||||
if (ntohs(tmpData->playerAction) > PLAYER_ACTION_ALLIN)
|
if (ntohs(tmpData->playerAction) > PLAYER_ACTION_ALLIN)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
if (!ntohs(tmpData->rejectionReason))
|
if (!ntohs(tmpData->rejectionReason))
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3555,7 +3555,7 @@ NetPacketDealFlopCards::InternalCheck(const NetPacketHeader* data) const
|
|||||||
NetPacketDealFlopCardsData *tmpData = (NetPacketDealFlopCardsData *)data;
|
NetPacketDealFlopCardsData *tmpData = (NetPacketDealFlopCardsData *)data;
|
||||||
if (ntohs(tmpData->flopCard1) > 51 || ntohs(tmpData->flopCard2) > 51 || ntohs(tmpData->flopCard3) > 51)
|
if (ntohs(tmpData->flopCard1) > 51 || ntohs(tmpData->flopCard2) > 51 || ntohs(tmpData->flopCard3) > 51)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3615,7 +3615,7 @@ NetPacketDealTurnCard::InternalCheck(const NetPacketHeader* data) const
|
|||||||
NetPacketDealTurnCardData *tmpData = (NetPacketDealTurnCardData *)data;
|
NetPacketDealTurnCardData *tmpData = (NetPacketDealTurnCardData *)data;
|
||||||
if (ntohs(tmpData->turnCard) > 51)
|
if (ntohs(tmpData->turnCard) > 51)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3675,7 +3675,7 @@ NetPacketDealRiverCard::InternalCheck(const NetPacketHeader* data) const
|
|||||||
NetPacketDealRiverCardData *tmpData = (NetPacketDealRiverCardData *)data;
|
NetPacketDealRiverCardData *tmpData = (NetPacketDealRiverCardData *)data;
|
||||||
if (ntohs(tmpData->riverCard) > 51)
|
if (ntohs(tmpData->riverCard) > 51)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3710,7 +3710,7 @@ NetPacketAllInShowCards::SetData(const NetPacketAllInShowCards::Data &inData)
|
|||||||
u_int16_t numPlayerCards = (u_int16_t)inData.playerCards.size();
|
u_int16_t numPlayerCards = (u_int16_t)inData.playerCards.size();
|
||||||
|
|
||||||
if (!numPlayerCards || numPlayerCards > MAX_NUM_PLAYER_CARDS)
|
if (!numPlayerCards || numPlayerCards > MAX_NUM_PLAYER_CARDS)
|
||||||
throw NetException(ERR_NET_INVALID_PLAYER_CARDS, 0);
|
throw NetException(__FILE__, __LINE__, ERR_NET_INVALID_PLAYER_CARDS, 0);
|
||||||
|
|
||||||
// Resize the packet so that the data fits in.
|
// Resize the packet so that the data fits in.
|
||||||
Resize((u_int16_t)
|
Resize((u_int16_t)
|
||||||
@@ -3780,11 +3780,11 @@ NetPacketAllInShowCards::InternalCheck(const NetPacketHeader* data) const
|
|||||||
sizeof(NetPacketAllInShowCardsData)
|
sizeof(NetPacketAllInShowCardsData)
|
||||||
+ numPlayerCards * sizeof(PlayerCardsData))
|
+ numPlayerCards * sizeof(PlayerCardsData))
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
if (ntohs(tmpData->numberOfPlayerCards) > MAX_NUMBER_OF_PLAYERS)
|
if (ntohs(tmpData->numberOfPlayerCards) > MAX_NUMBER_OF_PLAYERS)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Semantic checks not needed, this packet is sent by the server.
|
// Semantic checks not needed, this packet is sent by the server.
|
||||||
}
|
}
|
||||||
@@ -3820,7 +3820,7 @@ NetPacketEndOfHandShowCards::SetData(const NetPacketEndOfHandShowCards::Data &in
|
|||||||
u_int16_t numPlayerResults = (u_int16_t)inData.playerResults.size();
|
u_int16_t numPlayerResults = (u_int16_t)inData.playerResults.size();
|
||||||
|
|
||||||
if (!numPlayerResults || numPlayerResults > MAX_NUM_PLAYER_RESULTS)
|
if (!numPlayerResults || numPlayerResults > MAX_NUM_PLAYER_RESULTS)
|
||||||
throw NetException(ERR_NET_INVALID_PLAYER_RESULTS, 0);
|
throw NetException(__FILE__, __LINE__, ERR_NET_INVALID_PLAYER_RESULTS, 0);
|
||||||
|
|
||||||
// Resize the packet so that the data fits in.
|
// Resize the packet so that the data fits in.
|
||||||
Resize((u_int16_t)
|
Resize((u_int16_t)
|
||||||
@@ -3906,11 +3906,11 @@ NetPacketEndOfHandShowCards::InternalCheck(const NetPacketHeader* data) const
|
|||||||
sizeof(NetPacketEndOfHandShowCardsData)
|
sizeof(NetPacketEndOfHandShowCardsData)
|
||||||
+ numPlayerResults * sizeof(PlayerResultData))
|
+ numPlayerResults * sizeof(PlayerResultData))
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
if (ntohs(tmpData->numberOfPlayerResults) > MAX_NUMBER_OF_PLAYERS)
|
if (ntohs(tmpData->numberOfPlayerResults) > MAX_NUMBER_OF_PLAYERS)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Semantic checks not needed, this packet is sent by the server.
|
// Semantic checks not needed, this packet is sent by the server.
|
||||||
}
|
}
|
||||||
@@ -4153,7 +4153,7 @@ NetPacketSendChatText::SetData(const NetPacketSendChatText::Data &inData)
|
|||||||
u_int16_t textLen = (u_int16_t)inData.text.length();
|
u_int16_t textLen = (u_int16_t)inData.text.length();
|
||||||
|
|
||||||
if (!textLen || textLen > MAX_CHAT_TEXT_SIZE)
|
if (!textLen || textLen > MAX_CHAT_TEXT_SIZE)
|
||||||
throw NetException(ERR_NET_INVALID_CHAT_TEXT, 0);
|
throw NetException(__FILE__, __LINE__, ERR_NET_INVALID_CHAT_TEXT, 0);
|
||||||
|
|
||||||
// Resize the packet so that the data fits in.
|
// Resize the packet so that the data fits in.
|
||||||
Resize((u_int16_t)
|
Resize((u_int16_t)
|
||||||
@@ -4197,19 +4197,19 @@ NetPacketSendChatText::InternalCheck(const NetPacketHeader* data) const
|
|||||||
sizeof(NetPacketSendChatTextData)
|
sizeof(NetPacketSendChatTextData)
|
||||||
+ ADD_PADDING(textLength))
|
+ ADD_PADDING(textLength))
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check string size.
|
// Check string size.
|
||||||
if (!textLength
|
if (!textLength
|
||||||
|| textLength > MAX_CHAT_TEXT_SIZE)
|
|| textLength > MAX_CHAT_TEXT_SIZE)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check text string.
|
// Check text string.
|
||||||
char *textPtr = (char *)tmpData + sizeof(NetPacketSendChatTextData);
|
char *textPtr = (char *)tmpData + sizeof(NetPacketSendChatTextData);
|
||||||
if (textPtr[0] == 0)
|
if (textPtr[0] == 0)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4244,7 +4244,7 @@ NetPacketChatText::SetData(const NetPacketChatText::Data &inData)
|
|||||||
u_int16_t textLen = (u_int16_t)inData.text.length();
|
u_int16_t textLen = (u_int16_t)inData.text.length();
|
||||||
|
|
||||||
if (!textLen || textLen > MAX_CHAT_TEXT_SIZE)
|
if (!textLen || textLen > MAX_CHAT_TEXT_SIZE)
|
||||||
throw NetException(ERR_NET_INVALID_CHAT_TEXT, 0);
|
throw NetException(__FILE__, __LINE__, ERR_NET_INVALID_CHAT_TEXT, 0);
|
||||||
|
|
||||||
// Resize the packet so that the data fits in.
|
// Resize the packet so that the data fits in.
|
||||||
Resize((u_int16_t)
|
Resize((u_int16_t)
|
||||||
@@ -4290,13 +4290,13 @@ NetPacketChatText::InternalCheck(const NetPacketHeader* data) const
|
|||||||
sizeof(NetPacketChatTextData)
|
sizeof(NetPacketChatTextData)
|
||||||
+ ADD_PADDING(textLength))
|
+ ADD_PADDING(textLength))
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// Check string size.
|
// Check string size.
|
||||||
if (!textLength
|
if (!textLength
|
||||||
|| textLength > MAX_CHAT_TEXT_SIZE)
|
|| textLength > MAX_CHAT_TEXT_SIZE)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
}
|
}
|
||||||
// No more checks required - this packet is sent by the server.
|
// No more checks required - this packet is sent by the server.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ ReceiverHelper::Recv(SOCKET sock, ReceiveBuffer &buf)
|
|||||||
int selectResult = select(sock + 1, &readSet, NULL, NULL, &timeout);
|
int selectResult = select(sock + 1, &readSet, NULL, NULL, &timeout);
|
||||||
if (!IS_VALID_SELECT(selectResult))
|
if (!IS_VALID_SELECT(selectResult))
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_SELECT_FAILED, SOCKET_ERRNO());
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_SELECT_FAILED, SOCKET_ERRNO());
|
||||||
}
|
}
|
||||||
if (selectResult > 0) // recv is possible
|
if (selectResult > 0) // recv is possible
|
||||||
{
|
{
|
||||||
@@ -65,11 +65,11 @@ ReceiverHelper::Recv(SOCKET sock, ReceiveBuffer &buf)
|
|||||||
|
|
||||||
if (!IS_VALID_RECV(bytesRecvd))
|
if (!IS_VALID_RECV(bytesRecvd))
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_RECV_FAILED, SOCKET_ERRNO());
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_RECV_FAILED, SOCKET_ERRNO());
|
||||||
}
|
}
|
||||||
else if (bytesRecvd == 0)
|
else if (bytesRecvd == 0)
|
||||||
{
|
{
|
||||||
throw NetException(ERR_SOCK_CONN_RESET, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_CONN_RESET, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ ServerAcceptThread::Main()
|
|||||||
// The main server thread is simple. It only accepts connections.
|
// The main server thread is simple. It only accepts connections.
|
||||||
AcceptLoop();
|
AcceptLoop();
|
||||||
}
|
}
|
||||||
} catch (const NetException &e)
|
} catch (const PokerTHException &e)
|
||||||
{
|
{
|
||||||
GetCallback().SignalNetServerError(e.GetErrorId(), e.GetOsErrorCode());
|
GetCallback().SignalNetServerError(e.GetErrorId(), e.GetOsErrorCode());
|
||||||
}
|
}
|
||||||
@@ -98,15 +98,15 @@ ServerAcceptThread::Listen()
|
|||||||
ServerContext &context = GetContext();
|
ServerContext &context = GetContext();
|
||||||
|
|
||||||
if (context.GetServerPort() < 1024)
|
if (context.GetServerPort() < 1024)
|
||||||
throw ServerException(ERR_SOCK_INVALID_PORT, 0);
|
throw ServerException(__FILE__, __LINE__, ERR_SOCK_INVALID_PORT, 0);
|
||||||
|
|
||||||
context.SetSocket(socket(context.GetAddrFamily(), SOCK_STREAM, context.GetProtocol()));
|
context.SetSocket(socket(context.GetAddrFamily(), SOCK_STREAM, context.GetProtocol()));
|
||||||
if (!IS_VALID_SOCKET(context.GetSocket()))
|
if (!IS_VALID_SOCKET(context.GetSocket()))
|
||||||
throw ServerException(ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
|
throw ServerException(__FILE__, __LINE__, ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
|
||||||
|
|
||||||
unsigned long mode = 1;
|
unsigned long mode = 1;
|
||||||
if (IOCTLSOCKET(context.GetSocket(), FIONBIO, &mode) == SOCKET_ERROR)
|
if (IOCTLSOCKET(context.GetSocket(), FIONBIO, &mode) == SOCKET_ERROR)
|
||||||
throw ServerException(ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
|
throw ServerException(__FILE__, __LINE__, ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
|
||||||
|
|
||||||
// The following three calls are optional. If they fail, we don't care.
|
// The following three calls are optional. If they fail, we don't care.
|
||||||
int reuse = 1;
|
int reuse = 1;
|
||||||
@@ -126,7 +126,7 @@ ServerAcceptThread::Listen()
|
|||||||
(struct sockaddr *)context.GetServerSockaddr(),
|
(struct sockaddr *)context.GetServerSockaddr(),
|
||||||
context.GetServerSockaddrSize()))
|
context.GetServerSockaddrSize()))
|
||||||
{
|
{
|
||||||
throw ServerException(ERR_SOCK_SET_ADDR_FAILED, 0);
|
throw ServerException(__FILE__, __LINE__, ERR_SOCK_SET_ADDR_FAILED, 0);
|
||||||
}
|
}
|
||||||
if (!socket_set_port(
|
if (!socket_set_port(
|
||||||
context.GetServerPort(),
|
context.GetServerPort(),
|
||||||
@@ -134,7 +134,7 @@ ServerAcceptThread::Listen()
|
|||||||
(struct sockaddr *)context.GetServerSockaddr(),
|
(struct sockaddr *)context.GetServerSockaddr(),
|
||||||
context.GetServerSockaddrSize()))
|
context.GetServerSockaddrSize()))
|
||||||
{
|
{
|
||||||
throw ServerException(ERR_SOCK_SET_PORT_FAILED, 0);
|
throw ServerException(__FILE__, __LINE__, ERR_SOCK_SET_PORT_FAILED, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IS_VALID_BIND(bind(
|
if (!IS_VALID_BIND(bind(
|
||||||
@@ -142,12 +142,12 @@ ServerAcceptThread::Listen()
|
|||||||
(const struct sockaddr *)context.GetServerSockaddr(),
|
(const struct sockaddr *)context.GetServerSockaddr(),
|
||||||
context.GetServerSockaddrSize())))
|
context.GetServerSockaddrSize())))
|
||||||
{
|
{
|
||||||
throw ServerException(ERR_SOCK_BIND_FAILED, SOCKET_ERRNO());
|
throw ServerException(__FILE__, __LINE__, ERR_SOCK_BIND_FAILED, SOCKET_ERRNO());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IS_VALID_LISTEN(listen(context.GetSocket(), NET_SERVER_LISTEN_BACKLOG)))
|
if (!IS_VALID_LISTEN(listen(context.GetSocket(), NET_SERVER_LISTEN_BACKLOG)))
|
||||||
{
|
{
|
||||||
throw ServerException(ERR_SOCK_LISTEN_FAILED, SOCKET_ERRNO());
|
throw ServerException(__FILE__, __LINE__, ERR_SOCK_LISTEN_FAILED, SOCKET_ERRNO());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ ServerAcceptThread::AcceptLoop()
|
|||||||
int selectResult = select(context.GetSocket() + 1, &readSet, NULL, NULL, &timeout);
|
int selectResult = select(context.GetSocket() + 1, &readSet, NULL, NULL, &timeout);
|
||||||
if (!IS_VALID_SELECT(selectResult))
|
if (!IS_VALID_SELECT(selectResult))
|
||||||
{
|
{
|
||||||
throw ServerException(ERR_SOCK_SELECT_FAILED, SOCKET_ERRNO());
|
throw ServerException(__FILE__, __LINE__, ERR_SOCK_SELECT_FAILED, SOCKET_ERRNO());
|
||||||
}
|
}
|
||||||
if (selectResult > 0) // accept is possible
|
if (selectResult > 0) // accept is possible
|
||||||
{
|
{
|
||||||
@@ -176,7 +176,7 @@ ServerAcceptThread::AcceptLoop()
|
|||||||
|
|
||||||
if (!IS_VALID_SOCKET(tmpData->GetSocket()))
|
if (!IS_VALID_SOCKET(tmpData->GetSocket()))
|
||||||
{
|
{
|
||||||
throw ServerException(ERR_SOCK_ACCEPT_FAILED, SOCKET_ERRNO());
|
throw ServerException(__FILE__, __LINE__, ERR_SOCK_ACCEPT_FAILED, SOCKET_ERRNO());
|
||||||
}
|
}
|
||||||
|
|
||||||
GetLobbyThread().AddConnection(tmpData);
|
GetLobbyThread().AddConnection(tmpData);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include <net/senderthread.h>
|
#include <net/senderthread.h>
|
||||||
#include <net/netpacket.h>
|
#include <net/netpacket.h>
|
||||||
#include <net/socket_msg.h>
|
#include <net/socket_msg.h>
|
||||||
#include <net/netexception.h>
|
#include <net/serverexception.h>
|
||||||
#include <gamedata.h>
|
#include <gamedata.h>
|
||||||
#include <game.h>
|
#include <game.h>
|
||||||
#include <playerinterface.h>
|
#include <playerinterface.h>
|
||||||
@@ -684,9 +684,9 @@ ServerGameStateStartRound::Process(ServerGameThread &server)
|
|||||||
// Retrieve current player.
|
// Retrieve current player.
|
||||||
boost::shared_ptr<PlayerInterface> curPlayer = curGame.getCurrentPlayer();
|
boost::shared_ptr<PlayerInterface> curPlayer = curGame.getCurrentPlayer();
|
||||||
if (!curPlayer.get())
|
if (!curPlayer.get())
|
||||||
throw NetException(ERR_NET_NO_CURRENT_PLAYER, 0);
|
throw ServerException(__FILE__, __LINE__, ERR_NET_NO_CURRENT_PLAYER, 0);
|
||||||
if (!curPlayer->getMyActiveStatus())
|
if (!curPlayer->getMyActiveStatus())
|
||||||
throw NetException(ERR_NET_PLAYER_NOT_ACTIVE, 0);
|
throw ServerException(__FILE__, __LINE__, ERR_NET_PLAYER_NOT_ACTIVE, 0);
|
||||||
|
|
||||||
boost::shared_ptr<NetPacket> notification(new NetPacketPlayersTurn);
|
boost::shared_ptr<NetPacket> notification(new NetPacketPlayersTurn);
|
||||||
NetPacketPlayersTurn::Data playersTurnData;
|
NetPacketPlayersTurn::Data playersTurnData;
|
||||||
@@ -816,7 +816,7 @@ ServerGameStateWaitPlayerAction::Process(ServerGameThread &server)
|
|||||||
|
|
||||||
boost::shared_ptr<PlayerInterface> curPlayer = server.GetGame().getCurrentPlayer();
|
boost::shared_ptr<PlayerInterface> curPlayer = server.GetGame().getCurrentPlayer();
|
||||||
if (!curPlayer.get())
|
if (!curPlayer.get())
|
||||||
throw NetException(ERR_NET_NO_CURRENT_PLAYER, 0);
|
throw ServerException(__FILE__, __LINE__, ERR_NET_NO_CURRENT_PLAYER, 0);
|
||||||
|
|
||||||
// If the player is computer controlled, let the engine act.
|
// If the player is computer controlled, let the engine act.
|
||||||
if (curPlayer->getMyType() == PLAYER_TYPE_COMPUTER)
|
if (curPlayer->getMyType() == PLAYER_TYPE_COMPUTER)
|
||||||
@@ -862,7 +862,7 @@ ServerGameStateWaitPlayerAction::InternalProcess(ServerGameThread &server, Sessi
|
|||||||
Game &curGame = server.GetGame();
|
Game &curGame = server.GetGame();
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame.getPlayerByUniqueId(session.playerData->GetUniqueId());
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame.getPlayerByUniqueId(session.playerData->GetUniqueId());
|
||||||
if (!tmpPlayer.get())
|
if (!tmpPlayer.get())
|
||||||
throw NetException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
throw ServerException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
|
|
||||||
// Check whether this is the correct round.
|
// Check whether this is the correct round.
|
||||||
PlayerActionCode code = ACTION_CODE_VALID;
|
PlayerActionCode code = ACTION_CODE_VALID;
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ ServerGameThread::Main()
|
|||||||
// Process current state.
|
// Process current state.
|
||||||
GetState().Process(*this);
|
GetState().Process(*this);
|
||||||
} while (!ShouldTerminate() && GetSessionManager().HasSessions());
|
} while (!ShouldTerminate() && GetSessionManager().HasSessions());
|
||||||
} catch (const NetException &e)
|
} catch (const PokerTHException &e)
|
||||||
{
|
{
|
||||||
GetCallback().SignalNetServerError(e.GetErrorId(), e.GetOsErrorCode());
|
GetCallback().SignalNetServerError(e.GetErrorId(), e.GetOsErrorCode());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ ServerLobbyThread::Main()
|
|||||||
// Remove games.
|
// Remove games.
|
||||||
RemoveGameLoop();
|
RemoveGameLoop();
|
||||||
}
|
}
|
||||||
} catch (const NetException &e)
|
} catch (const PokerTHException &e)
|
||||||
{
|
{
|
||||||
GetCallback().SignalNetServerError(e.GetErrorId(), e.GetOsErrorCode());
|
GetCallback().SignalNetServerError(e.GetErrorId(), e.GetOsErrorCode());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ SessionManager::AddSession(SessionWrapper session)
|
|||||||
// already exists within the list.
|
// already exists within the list.
|
||||||
if (pos != m_sessionMap.end() && session.sessionData->GetSocket() == pos->first)
|
if (pos != m_sessionMap.end() && session.sessionData->GetSocket() == pos->first)
|
||||||
{
|
{
|
||||||
throw ServerException(ERR_SOCK_CONN_EXISTS, 0);
|
throw ServerException(__FILE__, __LINE__, ERR_SOCK_CONN_EXISTS, 0);
|
||||||
}
|
}
|
||||||
m_sessionMap.insert(pos, SessionMap::value_type(session.sessionData->GetSocket(), session));
|
m_sessionMap.insert(pos, SessionMap::value_type(session.sessionData->GetSocket(), session));
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ SessionManager::Select(unsigned timeoutMsec)
|
|||||||
int selectResult = select(maxSock + 1, &rdset, NULL, NULL, &timeout);
|
int selectResult = select(maxSock + 1, &rdset, NULL, NULL, &timeout);
|
||||||
if (!IS_VALID_SELECT(selectResult))
|
if (!IS_VALID_SELECT(selectResult))
|
||||||
{
|
{
|
||||||
throw ServerException(ERR_SOCK_SELECT_FAILED, SOCKET_ERRNO());
|
throw ServerException(__FILE__, __LINE__, ERR_SOCK_SELECT_FAILED, SOCKET_ERRNO());
|
||||||
}
|
}
|
||||||
if (selectResult > 0) // one (or more) of the sockets is readable
|
if (selectResult > 0) // one (or more) of the sockets is readable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ class NetException : public PokerTHException
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NetException(int errorId, int osErrorCode)
|
NetException(const char *sourcefile, int sourceline, int errorId, int osErrorCode)
|
||||||
: PokerTHException(errorId, osErrorCode) {}
|
: PokerTHException(sourcefile, sourceline, errorId, osErrorCode) {}
|
||||||
virtual ~NetException();
|
virtual ~NetException();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ class ServerException : public NetException
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ServerException(int errorId, int osErrorCode)
|
ServerException(const char *sourcefile, int sourceline, int errorId, int osErrorCode)
|
||||||
: NetException(errorId, osErrorCode) {}
|
: NetException(sourcefile, sourceline, errorId, osErrorCode) {}
|
||||||
|
|
||||||
virtual ~ServerException();
|
virtual ~ServerException();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user