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
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());
}
}
}