Fixed error when transfering avatars. Additional logging.
This commit is contained in:
@@ -511,7 +511,7 @@ AvatarManager::InternalReadDirectory(const std::string &dir, AvatarMap &avatars)
|
|||||||
}
|
}
|
||||||
} catch (...)
|
} catch (...)
|
||||||
{
|
{
|
||||||
LOG_ERROR("Exception caught when trying to scan cache directory.");
|
LOG_ERROR("Exception caught when trying to scan avatar directory.");
|
||||||
retVal = false;
|
retVal = false;
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
|
|||||||
@@ -34,6 +34,14 @@
|
|||||||
syslog(LOG_ERR, "%s", outStream.str()); \
|
syslog(LOG_ERR, "%s", outStream.str()); \
|
||||||
} \
|
} \
|
||||||
while(false)
|
while(false)
|
||||||
|
#define LOG_MSG(e) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
std::ostringstream outStream; \
|
||||||
|
outStream << e << std::endl; \
|
||||||
|
syslog(LOG_INFO, "%s", outStream.str()); \
|
||||||
|
} \
|
||||||
|
while(false)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -41,6 +49,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#define LOG_ERROR(e) \
|
#define LOG_ERROR(e) \
|
||||||
std::cout << e << std::endl
|
std::cout << e << std::endl
|
||||||
|
#define LOG_MSG(e) \
|
||||||
|
std::cout << e << std::endl
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -986,7 +986,6 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
|||||||
// Next player's turn.
|
// Next player's turn.
|
||||||
curGame->getCurrentHand()->getCurrentBeRo()->setCurrentPlayersTurnId(tmpPlayer->getMyID());
|
curGame->getCurrentHand()->getCurrentBeRo()->setCurrentPlayersTurnId(tmpPlayer->getMyID());
|
||||||
curGame->getCurrentHand()->getCurrentBeRo()->setMinimumRaise(turnData.minimumRaise);
|
curGame->getCurrentHand()->getCurrentBeRo()->setMinimumRaise(turnData.minimumRaise);
|
||||||
// TODO: remove this
|
|
||||||
curGame->getCurrentHand()->getCurrentBeRo()->setPlayersTurn(tmpPlayer->getMyID());
|
curGame->getCurrentHand()->getCurrentBeRo()->setPlayersTurn(tmpPlayer->getMyID());
|
||||||
|
|
||||||
// Mark current player in GUI.
|
// Mark current player in GUI.
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <net/clientexception.h>
|
#include <net/clientexception.h>
|
||||||
#include <net/socket_msg.h>
|
#include <net/socket_msg.h>
|
||||||
#include <core/avatarmanager.h>
|
#include <core/avatarmanager.h>
|
||||||
|
#include <core/loghelper.h>
|
||||||
#include <clientenginefactory.h>
|
#include <clientenginefactory.h>
|
||||||
#include <game.h>
|
#include <game.h>
|
||||||
|
|
||||||
@@ -122,8 +123,9 @@ ClientThread::SendStartEvent(bool fillUpWithCpuPlayers)
|
|||||||
static_cast<NetPacketStartEvent *>(start.get())->SetData(startData);
|
static_cast<NetPacketStartEvent *>(start.get())->SetData(startData);
|
||||||
boost::mutex::scoped_lock lock(m_outPacketListMutex);
|
boost::mutex::scoped_lock lock(m_outPacketListMutex);
|
||||||
m_outPacketList.push_back(start);
|
m_outPacketList.push_back(start);
|
||||||
} catch (const NetException &)
|
} catch (const NetException &e)
|
||||||
{
|
{
|
||||||
|
LOG_ERROR("ClientThread::SendStartEvent: " << e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,8 +150,9 @@ ClientThread::SendPlayerAction()
|
|||||||
// Just dump the packet.
|
// Just dump the packet.
|
||||||
boost::mutex::scoped_lock lock(m_outPacketListMutex);
|
boost::mutex::scoped_lock lock(m_outPacketListMutex);
|
||||||
m_outPacketList.push_back(action);
|
m_outPacketList.push_back(action);
|
||||||
} catch (const NetException &)
|
} catch (const NetException &e)
|
||||||
{
|
{
|
||||||
|
LOG_ERROR("ClientThread::SendPlayerAction: " << e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,8 +170,9 @@ ClientThread::SendChatMessage(const std::string &msg)
|
|||||||
// Just dump the packet.
|
// Just dump the packet.
|
||||||
boost::mutex::scoped_lock lock(m_outPacketListMutex);
|
boost::mutex::scoped_lock lock(m_outPacketListMutex);
|
||||||
m_outPacketList.push_back(chat);
|
m_outPacketList.push_back(chat);
|
||||||
} catch (const NetException &)
|
} catch (const NetException &e)
|
||||||
{
|
{
|
||||||
|
LOG_ERROR("ClientThread::SendChatMessage: " << e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,9 +190,9 @@ ClientThread::SendJoinFirstGame(const std::string &password)
|
|||||||
static_cast<NetPacketJoinGame *>(join.get())->SetData(joinData);
|
static_cast<NetPacketJoinGame *>(join.get())->SetData(joinData);
|
||||||
boost::mutex::scoped_lock lock(m_outPacketListMutex);
|
boost::mutex::scoped_lock lock(m_outPacketListMutex);
|
||||||
m_outPacketList.push_back(join);
|
m_outPacketList.push_back(join);
|
||||||
} catch (const NetException &)
|
} catch (const NetException &e)
|
||||||
{
|
{
|
||||||
// TODO
|
LOG_ERROR("ClientThread::SendJoinFirstGame: " << e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,9 +210,9 @@ ClientThread::SendJoinGame(unsigned gameId, const std::string &password)
|
|||||||
static_cast<NetPacketJoinGame *>(join.get())->SetData(joinData);
|
static_cast<NetPacketJoinGame *>(join.get())->SetData(joinData);
|
||||||
boost::mutex::scoped_lock lock(m_outPacketListMutex);
|
boost::mutex::scoped_lock lock(m_outPacketListMutex);
|
||||||
m_outPacketList.push_back(join);
|
m_outPacketList.push_back(join);
|
||||||
} catch (const NetException &)
|
} catch (const NetException &e)
|
||||||
{
|
{
|
||||||
// TODO
|
LOG_ERROR("ClientThread::SendJoinGame: " << e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,9 +231,9 @@ ClientThread::SendCreateGame(const GameData &gameData, const std::string &name,
|
|||||||
static_cast<NetPacketCreateGame *>(create.get())->SetData(createData);
|
static_cast<NetPacketCreateGame *>(create.get())->SetData(createData);
|
||||||
boost::mutex::scoped_lock lock(m_outPacketListMutex);
|
boost::mutex::scoped_lock lock(m_outPacketListMutex);
|
||||||
m_outPacketList.push_back(create);
|
m_outPacketList.push_back(create);
|
||||||
} catch (const NetException &)
|
} catch (const NetException &e)
|
||||||
{
|
{
|
||||||
// TODO
|
LOG_ERROR("ClientThread::SendCreateGame: " << e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,7 +435,7 @@ ClientThread::SetUnknownPlayer(unsigned id)
|
|||||||
{
|
{
|
||||||
// Just remove it from the request list.
|
// Just remove it from the request list.
|
||||||
m_playerInfoRequestList.remove(id);
|
m_playerInfoRequestList.remove(id);
|
||||||
// TODO log error
|
LOG_ERROR("Server reported unknown player id: " << id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -483,8 +487,9 @@ ClientThread::CompleteTempAvatarData(unsigned playerId)
|
|||||||
if (!GetCachedPlayerInfo(playerId, tmpPlayerInfo))
|
if (!GetCachedPlayerInfo(playerId, tmpPlayerInfo))
|
||||||
throw ClientException(__FILE__, __LINE__, 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);
|
if (!GetAvatarManager().StoreAvatarInCache(tmpPlayerInfo.avatar, tmpAvatar->fileType, &tmpAvatar->fileData[0], avatarSize))
|
||||||
// TODO log error
|
LOG_ERROR("Failed to store avatar in cache directory.");
|
||||||
|
|
||||||
// Free memory.
|
// Free memory.
|
||||||
m_tempAvatarMap.erase(pos);
|
m_tempAvatarMap.erase(pos);
|
||||||
|
|
||||||
@@ -496,7 +501,7 @@ void
|
|||||||
ClientThread::SetUnknownAvatar(unsigned playerId)
|
ClientThread::SetUnknownAvatar(unsigned playerId)
|
||||||
{
|
{
|
||||||
m_tempAvatarMap.erase(playerId);
|
m_tempAvatarMap.erase(playerId);
|
||||||
// TODO log error
|
LOG_ERROR("Server reported unknown avatar for player: " << playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ClientContext &
|
const ClientContext &
|
||||||
|
|||||||
@@ -47,7 +47,10 @@ void
|
|||||||
ServerAcceptThread::Init(unsigned serverPort, bool ipv6, bool sctp, const std::string &pwd)
|
ServerAcceptThread::Init(unsigned serverPort, bool ipv6, bool sctp, const std::string &pwd)
|
||||||
{
|
{
|
||||||
if (IsRunning())
|
if (IsRunning())
|
||||||
return; // TODO: throw exception
|
{
|
||||||
|
assert(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ServerContext &context = GetContext();
|
ServerContext &context = GetContext();
|
||||||
|
|
||||||
|
|||||||
@@ -484,8 +484,9 @@ ServerLobbyThread::HandleNetPacketAvatarEnd(SessionWrapper session, const NetPac
|
|||||||
unsigned avatarSize = (unsigned)tmpAvatar->fileData.size();
|
unsigned avatarSize = (unsigned)tmpAvatar->fileData.size();
|
||||||
if (avatarSize == tmpAvatar->reportedSize)
|
if (avatarSize == tmpAvatar->reportedSize)
|
||||||
{
|
{
|
||||||
GetAvatarManager().StoreAvatarInCache(avatarMD5, tmpAvatar->fileType, &tmpAvatar->fileData[0], avatarSize);
|
if (!GetAvatarManager().StoreAvatarInCache(avatarMD5, tmpAvatar->fileType, &tmpAvatar->fileData[0], avatarSize))
|
||||||
// TODO log error
|
LOG_ERROR("Failed to store avatar in cache directory.");
|
||||||
|
|
||||||
// Free memory.
|
// Free memory.
|
||||||
session.playerData->SetNetAvatarData(boost::shared_ptr<AvatarData>());
|
session.playerData->SetNetAvatarData(boost::shared_ptr<AvatarData>());
|
||||||
// Init finished - start session.
|
// Init finished - start session.
|
||||||
@@ -551,12 +552,13 @@ ServerLobbyThread::HandleNetPacketRetrieveAvatar(SessionWrapper session, const N
|
|||||||
if (GetAvatarManager().GetAvatarFileName(request.avatar, tmpFile))
|
if (GetAvatarManager().GetAvatarFileName(request.avatar, tmpFile))
|
||||||
{
|
{
|
||||||
NetPacketList tmpPackets;
|
NetPacketList tmpPackets;
|
||||||
if (GetAvatarManager().AvatarFileToNetPackets(tmpFile, request.requestId, tmpPackets))
|
if (GetAvatarManager().AvatarFileToNetPackets(tmpFile, request.requestId, tmpPackets) == 0)
|
||||||
{
|
{
|
||||||
avatarFound = true;
|
avatarFound = true;
|
||||||
GetSender().SendLowPrio(session.sessionData->GetSocket(), tmpPackets);
|
GetSender().SendLowPrio(session.sessionData->GetSocket(), tmpPackets);
|
||||||
}
|
}
|
||||||
// TODO Log error
|
else
|
||||||
|
LOG_ERROR("Failed to read avatar file for network transmission.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!avatarFound)
|
if (!avatarFound)
|
||||||
@@ -865,9 +867,10 @@ ServerLobbyThread::BroadcastStatisticsUpdate()
|
|||||||
|
|
||||||
m_sessionManager.SendToAllSessions(GetSender(), packet, SessionData::Established);
|
m_sessionManager.SendToAllSessions(GetSender(), packet, SessionData::Established);
|
||||||
m_gameSessionManager.SendToAllSessions(GetSender(), packet, SessionData::Game);
|
m_gameSessionManager.SendToAllSessions(GetSender(), packet, SessionData::Game);
|
||||||
} catch (const NetException &)
|
} catch (const NetException &e)
|
||||||
{
|
{
|
||||||
// TODO log error.
|
// Ignore errors for now.
|
||||||
|
//LOG_ERROR("ServerLobbyThread::BroadcastStatisticsUpdate: " << e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-6
@@ -23,6 +23,7 @@
|
|||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
#include <gui/generic/serverguiwrapper.h>
|
#include <gui/generic/serverguiwrapper.h>
|
||||||
#include <net/socket_startup.h>
|
#include <net/socket_startup.h>
|
||||||
|
#include <core/loghelper.h>
|
||||||
|
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
|
|
||||||
@@ -67,7 +68,7 @@ main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
ENABLE_LEAK_CHECK();
|
ENABLE_LEAK_CHECK();
|
||||||
|
|
||||||
//_CrtSetBreakAlloc(164);
|
// _CrtSetBreakAlloc(4772);
|
||||||
|
|
||||||
//create defaultconfig
|
//create defaultconfig
|
||||||
ConfigFile *myConfig = new ConfigFile(argc, argv);
|
ConfigFile *myConfig = new ConfigFile(argc, argv);
|
||||||
@@ -82,13 +83,15 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
socket_startup();
|
socket_startup();
|
||||||
|
|
||||||
|
LOG_MSG("Starting PokerTH dedicated server. Availability: IPv6 "
|
||||||
|
<< socket_has_ipv6() << ", SCTP " << socket_has_sctp() << ", Dual Stack " << socket_has_dual_stack() << ".");
|
||||||
|
|
||||||
// Create pseudo Gui Wrapper for the server.
|
// Create pseudo Gui Wrapper for the server.
|
||||||
boost::shared_ptr<GuiInterface> myServerGuiInterface(new ServerGuiWrapper(myConfig, NULL, NULL, NULL));
|
boost::shared_ptr<GuiInterface> myServerGuiInterface(new ServerGuiWrapper(myConfig, NULL, NULL, NULL));
|
||||||
{
|
boost::shared_ptr<Session> session(new Session(myServerGuiInterface.get(), myConfig));
|
||||||
boost::shared_ptr<Session> session(new Session(myServerGuiInterface.get(), myConfig));
|
if (!session->init())
|
||||||
session->init(); // TODO handle error
|
LOG_ERROR("Missing files - please check your directory settings!");
|
||||||
myServerGuiInterface->setSession(session);
|
myServerGuiInterface->setSession(session);
|
||||||
}
|
|
||||||
|
|
||||||
myServerGuiInterface->getSession().startNetworkServer();
|
myServerGuiInterface->getSession().startNetworkServer();
|
||||||
while (!g_pokerthTerminate)
|
while (!g_pokerthTerminate)
|
||||||
@@ -98,6 +101,7 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
myServerGuiInterface->getSession().terminateNetworkServer();
|
myServerGuiInterface->getSession().terminateNetworkServer();
|
||||||
|
|
||||||
|
LOG_MSG("Terminating PokerTH dedicated server.");
|
||||||
socket_cleanup();
|
socket_cleanup();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user