Preparing client use of external avatar servers.

This commit is contained in:
lotodore
2009-03-18 15:01:43 +00:00
parent 64ec42aaa3
commit b1bad8d144
5 changed files with 24 additions and 1 deletions
+5
View File
@@ -63,6 +63,10 @@ public:
{return m_serverPort;}
void SetServerPort(unsigned serverPort)
{m_serverPort = serverPort;}
const std::string &GetAvatarServerAddr() const
{return m_avatarServerAddr;}
void SetAvatarServerAddr(const std::string &avatarServerAddr)
{m_avatarServerAddr = avatarServerAddr;}
const std::string &GetPassword() const
{return m_password;}
void SetPassword(const std::string &password)
@@ -102,6 +106,7 @@ private:
std::string m_serverListUrl;
bool m_useServerList;
unsigned m_serverPort;
std::string m_avatarServerAddr;
std::string m_password;
sockaddr_storage m_clientSockaddr;
std::string m_playerName;
+1
View File
@@ -54,6 +54,7 @@ public:
unsigned serverPort,
bool ipv6,
bool sctp,
const std::string &avatarServerAddress,
const std::string &pwd,
const std::string &playerName,
const std::string &avatarFile,
+9
View File
@@ -459,6 +459,9 @@ ClientStateReadingServerList::Process(ClientThread &client)
addrNode = firstServer->FirstChild("IPv4Address");
const TiXmlNode *portNode = firstServer->FirstChild("Port");
// Currently, only IPv4 is supported for avatar servers.
const TiXmlNode *avatarNode = firstServer->FirstChild("AvatarServerIPv4Address");
if (!addrNode || !addrNode->ToElement() || !portNode || !portNode->ToElement())
throw ClientException(__FILE__, __LINE__, ERR_SOCK_INVALID_SERVERLIST_XML, 0);
@@ -467,6 +470,12 @@ ClientStateReadingServerList::Process(ClientThread &client)
int tmpPort = 0;
portNode->ToElement()->QueryIntAttribute("value", &tmpPort);
context.SetServerPort((unsigned)tmpPort);
if (avatarNode && avatarNode->ToElement()) // optional
{
context.SetAvatarServerAddr(addrNode->ToElement()->Attribute("value"));
}
retVal = MSG_SOCK_SERVER_LIST_DONE;
}
else
+5 -1
View File
@@ -56,7 +56,8 @@ void
ClientThread::Init(
const string &serverAddress, const string &serverListUrl,
bool useServerList, unsigned serverPort, bool ipv6, bool sctp,
const string &pwd, const string &playerName, const string &avatarFile,
const string &avatarServerAddress, const string &pwd,
const string &playerName, const string &avatarFile,
const string &cacheDir)
{
if (IsRunning())
@@ -73,6 +74,7 @@ ClientThread::Init(
context.SetServerListUrl(serverListUrl);
context.SetUseServerList(useServerList);
context.SetServerPort(serverPort);
context.SetAvatarServerAddr(avatarServerAddress);
context.SetPassword(pwd);
context.SetPlayerName(playerName);
context.SetAvatarFile(avatarFile);
@@ -517,6 +519,8 @@ ClientThread::RetrieveAvatarIfNeeded(unsigned id, const PlayerInfo &info)
if (info.hasAvatar && !info.avatar.IsZero() && !GetAvatarManager().HasAvatar(info.avatar))
{
m_avatarHasRequestedList.push_back(id); // Never remove from this list. Only request once.
// TODO: download from avatar server if applicable.
boost::shared_ptr<NetPacket> retrieveAvatar(new NetPacketRetrieveAvatar);
NetPacketRetrieveAvatar::Data retrieveAvatarData;
retrieveAvatarData.requestId = id;