Fixed error when transfering avatars. Additional logging.

This commit is contained in:
lotodore
2007-10-24 23:17:12 +00:00
parent 2152b90e20
commit 9e180d01f3
7 changed files with 52 additions and 28 deletions
+1 -1
View File
@@ -511,7 +511,7 @@ AvatarManager::InternalReadDirectory(const std::string &dir, AvatarMap &avatars)
}
} catch (...)
{
LOG_ERROR("Exception caught when trying to scan cache directory.");
LOG_ERROR("Exception caught when trying to scan avatar directory.");
retVal = false;
}
return retVal;
+10
View File
@@ -34,6 +34,14 @@
syslog(LOG_ERR, "%s", outStream.str()); \
} \
while(false)
#define LOG_MSG(e) \
do \
{ \
std::ostringstream outStream; \
outStream << e << std::endl; \
syslog(LOG_INFO, "%s", outStream.str()); \
} \
while(false)
#endif
#endif
@@ -41,6 +49,8 @@
#include <iostream>
#define LOG_ERROR(e) \
std::cout << e << std::endl
#define LOG_MSG(e) \
std::cout << e << std::endl
#endif
#endif
-1
View File
@@ -986,7 +986,6 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
// Next player's turn.
curGame->getCurrentHand()->getCurrentBeRo()->setCurrentPlayersTurnId(tmpPlayer->getMyID());
curGame->getCurrentHand()->getCurrentBeRo()->setMinimumRaise(turnData.minimumRaise);
// TODO: remove this
curGame->getCurrentHand()->getCurrentBeRo()->setPlayersTurn(tmpPlayer->getMyID());
// Mark current player in GUI.
+18 -13
View File
@@ -25,6 +25,7 @@
#include <net/clientexception.h>
#include <net/socket_msg.h>
#include <core/avatarmanager.h>
#include <core/loghelper.h>
#include <clientenginefactory.h>
#include <game.h>
@@ -122,8 +123,9 @@ ClientThread::SendStartEvent(bool fillUpWithCpuPlayers)
static_cast<NetPacketStartEvent *>(start.get())->SetData(startData);
boost::mutex::scoped_lock lock(m_outPacketListMutex);
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.
boost::mutex::scoped_lock lock(m_outPacketListMutex);
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.
boost::mutex::scoped_lock lock(m_outPacketListMutex);
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);
boost::mutex::scoped_lock lock(m_outPacketListMutex);
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);
boost::mutex::scoped_lock lock(m_outPacketListMutex);
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);
boost::mutex::scoped_lock lock(m_outPacketListMutex);
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.
m_playerInfoRequestList.remove(id);
// TODO log error
LOG_ERROR("Server reported unknown player id: " << id);
}
void
@@ -483,8 +487,9 @@ ClientThread::CompleteTempAvatarData(unsigned playerId)
if (!GetCachedPlayerInfo(playerId, tmpPlayerInfo))
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
GetAvatarManager().StoreAvatarInCache(tmpPlayerInfo.avatar, tmpAvatar->fileType, &tmpAvatar->fileData[0], avatarSize);
// TODO log error
if (!GetAvatarManager().StoreAvatarInCache(tmpPlayerInfo.avatar, tmpAvatar->fileType, &tmpAvatar->fileData[0], avatarSize))
LOG_ERROR("Failed to store avatar in cache directory.");
// Free memory.
m_tempAvatarMap.erase(pos);
@@ -496,7 +501,7 @@ void
ClientThread::SetUnknownAvatar(unsigned playerId)
{
m_tempAvatarMap.erase(playerId);
// TODO log error
LOG_ERROR("Server reported unknown avatar for player: " << playerId);
}
const ClientContext &
+4 -1
View File
@@ -47,7 +47,10 @@ void
ServerAcceptThread::Init(unsigned serverPort, bool ipv6, bool sctp, const std::string &pwd)
{
if (IsRunning())
return; // TODO: throw exception
{
assert(false);
return;
}
ServerContext &context = GetContext();
+9 -6
View File
@@ -484,8 +484,9 @@ ServerLobbyThread::HandleNetPacketAvatarEnd(SessionWrapper session, const NetPac
unsigned avatarSize = (unsigned)tmpAvatar->fileData.size();
if (avatarSize == tmpAvatar->reportedSize)
{
GetAvatarManager().StoreAvatarInCache(avatarMD5, tmpAvatar->fileType, &tmpAvatar->fileData[0], avatarSize);
// TODO log error
if (!GetAvatarManager().StoreAvatarInCache(avatarMD5, tmpAvatar->fileType, &tmpAvatar->fileData[0], avatarSize))
LOG_ERROR("Failed to store avatar in cache directory.");
// Free memory.
session.playerData->SetNetAvatarData(boost::shared_ptr<AvatarData>());
// Init finished - start session.
@@ -551,12 +552,13 @@ ServerLobbyThread::HandleNetPacketRetrieveAvatar(SessionWrapper session, const N
if (GetAvatarManager().GetAvatarFileName(request.avatar, tmpFile))
{
NetPacketList tmpPackets;
if (GetAvatarManager().AvatarFileToNetPackets(tmpFile, request.requestId, tmpPackets))
if (GetAvatarManager().AvatarFileToNetPackets(tmpFile, request.requestId, tmpPackets) == 0)
{
avatarFound = true;
GetSender().SendLowPrio(session.sessionData->GetSocket(), tmpPackets);
}
// TODO Log error
else
LOG_ERROR("Failed to read avatar file for network transmission.");
}
if (!avatarFound)
@@ -865,9 +867,10 @@ ServerLobbyThread::BroadcastStatisticsUpdate()
m_sessionManager.SendToAllSessions(GetSender(), packet, SessionData::Established);
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
View File
@@ -23,6 +23,7 @@
#include "configfile.h"
#include <gui/generic/serverguiwrapper.h>
#include <net/socket_startup.h>
#include <core/loghelper.h>
#include <csignal>
@@ -67,7 +68,7 @@ main(int argc, char *argv[])
{
ENABLE_LEAK_CHECK();
//_CrtSetBreakAlloc(164);
// _CrtSetBreakAlloc(4772);
//create defaultconfig
ConfigFile *myConfig = new ConfigFile(argc, argv);
@@ -82,13 +83,15 @@ main(int argc, char *argv[])
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.
boost::shared_ptr<GuiInterface> myServerGuiInterface(new ServerGuiWrapper(myConfig, NULL, NULL, NULL));
{
boost::shared_ptr<Session> session(new Session(myServerGuiInterface.get(), myConfig));
session->init(); // TODO handle error
myServerGuiInterface->setSession(session);
}
boost::shared_ptr<Session> session(new Session(myServerGuiInterface.get(), myConfig));
if (!session->init())
LOG_ERROR("Missing files - please check your directory settings!");
myServerGuiInterface->setSession(session);
myServerGuiInterface->getSession().startNetworkServer();
while (!g_pokerthTerminate)
@@ -98,6 +101,7 @@ main(int argc, char *argv[])
}
myServerGuiInterface->getSession().terminateNetworkServer();
LOG_MSG("Terminating PokerTH dedicated server.");
socket_cleanup();
return 0;
}