mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Battle.net: Implemented cache stream items
This commit is contained in:
@@ -241,7 +241,7 @@ CREATE TABLE `battlenet_modules` (
|
||||
`Type` varchar(8) NOT NULL,
|
||||
`System` varchar(8) NOT NULL,
|
||||
`Data` text,
|
||||
PRIMARY KEY (`Hash`),
|
||||
PRIMARY KEY (`Name`,`System`),
|
||||
UNIQUE KEY `uk_name_type_system` (`Name`,`Type`,`System`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
@@ -276,7 +276,26 @@ INSERT INTO `battlenet_modules` VALUES
|
||||
('bfe4ceb47700aa872e815e007e27df955d4cd4bc1fe731039ee6498ce209f368','Resume','auth','Win',NULL),
|
||||
('00ffd88a437afbb88d7d4b74be2e3b43601605ee229151aa9f4bebb29ef66280','Resume','auth','Mac',NULL),
|
||||
('898166926805f897804bdbbf40662c9d768590a51a0b26c40dbcdf332ba11974','Resume','auth','Wn64',NULL),
|
||||
('304627d437c38500c0b5ca0c6220eeade91390e52a2b005ff3f7754afa1f93cd','Resume','auth','Mc64',NULL);
|
||||
('304627d437c38500c0b5ca0c6220eeade91390e52a2b005ff3f7754afa1f93cd','Resume','auth','Mc64',NULL),
|
||||
('cc654428261322763f4cada5b7f4b3b67660e85639bea916986b3f366fe8adc2','ERRS','xml','enGB','AA6C50D3'),
|
||||
('2753d31092f1978bdd78ebd4fae2d189364ad7108ceb22fbf1413be1f43bef04','PFTY','pfty','zhCN','DF6C50D3'),
|
||||
('5813f318f7e40a07a7cdfeeec9827942e6fdc5ccee0d4171148443e429ad0ead','PFTY','pfty','ruRU','DF6C50D3'),
|
||||
('83663d54444eadad40d43725e59bde8eda10276e76fc3c4e6f2ca56332ee8f03','PFTY','pfty','enSG','DF6C50D3'),
|
||||
('870f53d10b4e1b09d6b622cd5671ba4ff1ad69512dfa2c676072c52e45c7f0f9','PFTY','pfty','esES','DF6C50D3'),
|
||||
('305bbdab1953e65974a249e276867e13ad2c3cabca3668983cb5ed406251bb7b','PFTY','pfty','frFR','DF6C50D3'),
|
||||
('83663d54444eadad40d43725e59bde8eda10276e76fc3c4e6f2ca56332ee8f03','PFTY','pfty','enGB','DF6C50D3'),
|
||||
('a2ec4b41148214037a2e89a2e557af716d085241b81f5244494bdc77a891ca38','PFTY','pfty','csCZ','DF6C50D3'),
|
||||
('a8c77051991b1a6c5dfe412e9f46d8f584349996fbde37c4f2a527c192163502','PFTY','pfty','plPL','DF6C50D3'),
|
||||
('83663d54444eadad40d43725e59bde8eda10276e76fc3c4e6f2ca56332ee8f03','PFTY','pfty','enUS','DF6C50D3'),
|
||||
('7466b2db3f03768aa2527535d4b3c6c9ef9e8fb07c6db88b1019f3d25a2942e8','PFTY','pfty','koKR','DF6C50D3'),
|
||||
('a2ec4b41148214037a2e89a2e557af716d085241b81f5244494bdc77a891ca38','PFTY','pfty','jaJP','DF6C50D3'),
|
||||
('3e381d4f83201f4e3c482eb74da12e5ff9dd924da2413d8fb33f5eea9a02c2c2','PFTY','pfty','zhTW','DF6C50D3'),
|
||||
('83663d54444eadad40d43725e59bde8eda10276e76fc3c4e6f2ca56332ee8f03','PFTY','pfty','enTH','DF6C50D3'),
|
||||
('b72e65b6b34d8f859e79b5f28952e26553a796d5e1d75c2b5930bc0daeaa728c','PFTY','pfty','itIT','DF6C50D3'),
|
||||
('e8b82becbe0a0a1bbb5561df69320edbd770897a8deaab23caa6736255e0dc33','PFTY','pfty','esMX','DF6C50D3'),
|
||||
('83663d54444eadad40d43725e59bde8eda10276e76fc3c4e6f2ca56332ee8f03','PFTY','pfty','enAU','DF6C50D3'),
|
||||
('0a3f6f3f0535ea21dbe620085192afc796203047e270e0e1b76f15a739fe1797','PFTY','pfty','ptBR','DF6C50D3'),
|
||||
('047329d08d433da2622e9fc2ee96c8dd8f35e7770699d07cf74855b9c8ea9125','PFTY','pfty','deDE','DF6C50D3');
|
||||
/*!40000 ALTER TABLE `battlenet_modules` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
|
||||
24
sql/updates/auth/2014_10_13_00_auth_434.sql
Normal file
24
sql/updates/auth/2014_10_13_00_auth_434.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
ALTER TABLE `battlenet_modules`
|
||||
DROP PRIMARY KEY,
|
||||
ADD PRIMARY KEY (`Name`, `System`);
|
||||
DELETE FROM `battlenet_modules` WHERE `Name` IN ('ERRS','PFTY');
|
||||
INSERT INTO `battlenet_modules` (`Hash`,`Name`,`Type`,`System`,`Data`) VALUES
|
||||
('cc654428261322763f4cada5b7f4b3b67660e85639bea916986b3f366fe8adc2', 'ERRS', 'xml', 'enGB', 'AA6C50D3'),
|
||||
('2753d31092f1978bdd78ebd4fae2d189364ad7108ceb22fbf1413be1f43bef04', 'PFTY', 'pfty', 'zhCN', 'DF6C50D3'),
|
||||
('5813f318f7e40a07a7cdfeeec9827942e6fdc5ccee0d4171148443e429ad0ead', 'PFTY', 'pfty', 'ruRU', 'DF6C50D3'),
|
||||
('83663d54444eadad40d43725e59bde8eda10276e76fc3c4e6f2ca56332ee8f03', 'PFTY', 'pfty', 'enSG', 'DF6C50D3'),
|
||||
('870f53d10b4e1b09d6b622cd5671ba4ff1ad69512dfa2c676072c52e45c7f0f9', 'PFTY', 'pfty', 'esES', 'DF6C50D3'),
|
||||
('305bbdab1953e65974a249e276867e13ad2c3cabca3668983cb5ed406251bb7b', 'PFTY', 'pfty', 'frFR', 'DF6C50D3'),
|
||||
('83663d54444eadad40d43725e59bde8eda10276e76fc3c4e6f2ca56332ee8f03', 'PFTY', 'pfty', 'enGB', 'DF6C50D3'),
|
||||
('a2ec4b41148214037a2e89a2e557af716d085241b81f5244494bdc77a891ca38', 'PFTY', 'pfty', 'csCZ', 'DF6C50D3'),
|
||||
('a8c77051991b1a6c5dfe412e9f46d8f584349996fbde37c4f2a527c192163502', 'PFTY', 'pfty', 'plPL', 'DF6C50D3'),
|
||||
('83663d54444eadad40d43725e59bde8eda10276e76fc3c4e6f2ca56332ee8f03', 'PFTY', 'pfty', 'enUS', 'DF6C50D3'),
|
||||
('7466b2db3f03768aa2527535d4b3c6c9ef9e8fb07c6db88b1019f3d25a2942e8', 'PFTY', 'pfty', 'koKR', 'DF6C50D3'),
|
||||
('a2ec4b41148214037a2e89a2e557af716d085241b81f5244494bdc77a891ca38', 'PFTY', 'pfty', 'jaJP', 'DF6C50D3'),
|
||||
('3e381d4f83201f4e3c482eb74da12e5ff9dd924da2413d8fb33f5eea9a02c2c2', 'PFTY', 'pfty', 'zhTW', 'DF6C50D3'),
|
||||
('83663d54444eadad40d43725e59bde8eda10276e76fc3c4e6f2ca56332ee8f03', 'PFTY', 'pfty', 'enTH', 'DF6C50D3'),
|
||||
('b72e65b6b34d8f859e79b5f28952e26553a796d5e1d75c2b5930bc0daeaa728c', 'PFTY', 'pfty', 'itIT', 'DF6C50D3'),
|
||||
('e8b82becbe0a0a1bbb5561df69320edbd770897a8deaab23caa6736255e0dc33', 'PFTY', 'pfty', 'esMX', 'DF6C50D3'),
|
||||
('83663d54444eadad40d43725e59bde8eda10276e76fc3c4e6f2ca56332ee8f03', 'PFTY', 'pfty', 'enAU', 'DF6C50D3'),
|
||||
('0a3f6f3f0535ea21dbe620085192afc796203047e270e0e1b76f15a739fe1797', 'PFTY', 'pfty', 'ptBR', 'DF6C50D3'),
|
||||
('047329d08d433da2622e9fc2ee96c8dd8f35e7770699d07cf74855b9c8ea9125', 'PFTY', 'pfty', 'deDE', 'DF6C50D3');
|
||||
83
src/server/bnetserver/Packets/CachePackets.cpp
Normal file
83
src/server/bnetserver/Packets/CachePackets.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "CachePackets.h"
|
||||
|
||||
void Battlenet::Cache::GetStreamItemsRequest::Read()
|
||||
{
|
||||
if (_stream.Read<bool>(1))
|
||||
{
|
||||
_stream.Read<uint16>(11); // padding
|
||||
ItemName = _stream.ReadFourCC();
|
||||
Channel = _stream.ReadFourCC();
|
||||
}
|
||||
else
|
||||
_stream.Read<uint16>(16);
|
||||
|
||||
_stream.Read<bool>(1); // StreamDirection
|
||||
ReferenceTime = _stream.Read<int32>(32) - std::numeric_limits<int32>::min();
|
||||
Locale = _stream.ReadFourCC();
|
||||
Index = _stream.Read<uint32>(32);
|
||||
_stream.Read<uint8>(6); // Module count, always 0
|
||||
}
|
||||
|
||||
std::string Battlenet::Cache::GetStreamItemsRequest::ToString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "Battlenet::Cache::GetStreamItemsRequest Channel: " << Channel << ", ItemName: " << ItemName
|
||||
<< ", Locale: " << Locale << ", Index: " << Index;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
void Battlenet::Cache::GetStreamItemsRequest::CallHandler(Session* session)
|
||||
{
|
||||
session->HandleGetStreamItemsRequest(*this);
|
||||
}
|
||||
|
||||
Battlenet::Cache::GetStreamItemsResponse::~GetStreamItemsResponse()
|
||||
{
|
||||
for (size_t i = 0; i < Modules.size(); ++i)
|
||||
delete Modules[i];
|
||||
}
|
||||
|
||||
void Battlenet::Cache::GetStreamItemsResponse::Write()
|
||||
{
|
||||
_stream.Write(0, 16);
|
||||
_stream.Write(Modules.size(), 6);
|
||||
for (ModuleInfo const* info : Modules)
|
||||
{
|
||||
_stream.WriteBytes(info->Type.c_str(), 4);
|
||||
_stream.WriteFourCC(info->Region);
|
||||
_stream.WriteBytes(info->ModuleId, 32);
|
||||
_stream.WriteBytes(info->Data, 4);
|
||||
}
|
||||
|
||||
_stream.Write(Index, 32);
|
||||
_stream.Write(0, 17); // padding
|
||||
_stream.Write(1, 16);
|
||||
_stream.Write(0, 2);
|
||||
}
|
||||
|
||||
std::string Battlenet::Cache::GetStreamItemsResponse::ToString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "Battlenet::Cache::GetStreamItemsResponse modules " << Modules.size();
|
||||
for (ModuleInfo const* module : Modules)
|
||||
stream << std::endl << "Battlenet::ModuleInfo Locale " << module->Region.c_str() << ", ModuleId " << ByteArrayToHexStr(module->ModuleId, 32) << ", Data " << ByteArrayToHexStr(module->Data, module->DataSize);
|
||||
|
||||
return stream.str();
|
||||
}
|
||||
@@ -29,7 +29,7 @@ namespace Battlenet
|
||||
CMSG_GATEWAY_LOOKUP_REQUEST = 0x2, // Not implemented
|
||||
CMSG_CONNECT_REQUEST = 0x4, // Not implemented
|
||||
CMSG_DATA_CHUNK = 0x7, // Not implemented
|
||||
SMSG_GET_STREAM_ITEMS_REQUEST = 0x9, // Not implemented
|
||||
CMSG_GET_STREAM_ITEMS_REQUEST = 0x9, // Not implemented
|
||||
|
||||
SMSG_GATEWAY_LOOKUP_RESPONSE = 0x3, // Not implemented
|
||||
SMSG_CONNECT_RESPONSE = 0x4, // Not implemented
|
||||
@@ -37,6 +37,41 @@ namespace Battlenet
|
||||
SMSG_RESULT = 0x8, // Not implemented
|
||||
SMSG_GET_STREAM_ITEMS_RESPONSE = 0x9 // Not implemented
|
||||
};
|
||||
|
||||
class GetStreamItemsRequest final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
GetStreamItemsRequest(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream)
|
||||
{
|
||||
ASSERT(header == PacketHeader(CMSG_GET_STREAM_ITEMS_REQUEST, CACHE) && "Invalid packet header for GetStreamItemsRequest");
|
||||
}
|
||||
|
||||
void Read() override;
|
||||
std::string ToString() const override;
|
||||
void CallHandler(Session* session);
|
||||
|
||||
std::string Channel;
|
||||
std::string ItemName;
|
||||
std::string Locale;
|
||||
uint32 Index;
|
||||
int32 ReferenceTime;
|
||||
};
|
||||
|
||||
class GetStreamItemsResponse final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
GetStreamItemsResponse() : ServerPacket(PacketHeader(SMSG_GET_STREAM_ITEMS_RESPONSE, CACHE))
|
||||
{
|
||||
}
|
||||
|
||||
~GetStreamItemsResponse();
|
||||
|
||||
void Write() override;
|
||||
std::string ToString() const override;
|
||||
|
||||
uint32 Index;
|
||||
std::vector<ModuleInfo*> Modules;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -217,13 +217,13 @@ void Battlenet::PacketManager::RegisterCachePackets()
|
||||
REGISTER_CLIENT_PACKET_NAME(PacketHeader(Cache::CMSG_GATEWAY_LOOKUP_REQUEST, CACHE), "Cache::GatewayLookupRequest");
|
||||
REGISTER_CLIENT_PACKET_NAME(PacketHeader(Cache::CMSG_CONNECT_REQUEST, CACHE), "Cache::ConnectRequest");
|
||||
REGISTER_CLIENT_PACKET_NAME(PacketHeader(Cache::CMSG_DATA_CHUNK, CACHE), "Cache::DataChunk");
|
||||
REGISTER_CLIENT_PACKET_NAME(PacketHeader(Cache::SMSG_GET_STREAM_ITEMS_REQUEST, CACHE), "Cache::GetStreamItemsRequest");
|
||||
REGISTER_CLIENT_PACKET(PacketHeader(Cache::CMSG_GET_STREAM_ITEMS_REQUEST, CACHE), Cache::GetStreamItemsRequest);
|
||||
|
||||
REGISTER_SERVER_PACKET_NAME(PacketHeader(Cache::SMSG_GATEWAY_LOOKUP_RESPONSE, CACHE), "Cache::GatewayLookupResponse");
|
||||
REGISTER_SERVER_PACKET_NAME(PacketHeader(Cache::SMSG_CONNECT_RESPONSE, CACHE), "Cache::ConnectResponse");
|
||||
REGISTER_SERVER_PACKET_NAME(PacketHeader(Cache::SMSG_PUBLISH_LIST_RESPONSE, CACHE), "Cache::PublishListResponse");
|
||||
REGISTER_SERVER_PACKET_NAME(PacketHeader(Cache::SMSG_RESULT, CACHE), "Cache::Result");
|
||||
REGISTER_SERVER_PACKET_NAME(PacketHeader(Cache::SMSG_GET_STREAM_ITEMS_RESPONSE, CACHE), "Cache::GetStreamItemsResponse");
|
||||
REGISTER_SERVER_PACKET(PacketHeader(Cache::SMSG_GET_STREAM_ITEMS_RESPONSE, CACHE), Cache::GetStreamItemsResponse);
|
||||
}
|
||||
|
||||
void Battlenet::PacketManager::RegisterProfilePackets()
|
||||
|
||||
@@ -51,7 +51,8 @@ void Battlenet::ModuleManager::Load()
|
||||
Battlenet::ModuleInfo* Battlenet::ModuleManager::CreateModule(std::string const& os, std::string const& name) const
|
||||
{
|
||||
ModuleKey key { os, name };
|
||||
ASSERT(_modules.count(key));
|
||||
if (!_modules.count(key))
|
||||
return nullptr;
|
||||
|
||||
return new ModuleInfo(*_modules.at(key));
|
||||
}
|
||||
|
||||
@@ -477,6 +477,17 @@ void Battlenet::Session::HandleSocialNetworkCheckConnected(Friends::SocialNetwor
|
||||
AsyncWrite(socialNetworkCheckConnectedResult);
|
||||
}
|
||||
|
||||
void Battlenet::Session::HandleGetStreamItemsRequest(Cache::GetStreamItemsRequest const& getStreamItemsRequest)
|
||||
{
|
||||
if (ModuleInfo* module = sModuleMgr->CreateModule(getStreamItemsRequest.Locale, getStreamItemsRequest.ItemName))
|
||||
{
|
||||
Cache::GetStreamItemsResponse* getStreamItemsResponse = new Cache::GetStreamItemsResponse();
|
||||
getStreamItemsResponse->Index = getStreamItemsRequest.Index;
|
||||
getStreamItemsResponse->Modules.push_back(module);
|
||||
AsyncWrite(getStreamItemsResponse);
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string PacketToStringHelper(Battlenet::ClientPacket const* packet)
|
||||
{
|
||||
if (sLog->ShouldLog("session.packets", LOG_LEVEL_TRACE))
|
||||
|
||||
@@ -81,6 +81,9 @@ namespace Battlenet
|
||||
// Friends
|
||||
void HandleSocialNetworkCheckConnected(Friends::SocialNetworkCheckConnected const& socialNetworkCheckConnected);
|
||||
|
||||
// Cache
|
||||
void HandleGetStreamItemsRequest(Cache::GetStreamItemsRequest const& getStreamItemsRequest);
|
||||
|
||||
void Start() override;
|
||||
|
||||
void UpdateRealms(std::vector<Realm const*>& realms, std::vector<RealmId>& deletedRealms);
|
||||
|
||||
@@ -40,10 +40,12 @@ void Battlenet::SessionManager::AddSession(Session* session)
|
||||
{
|
||||
std::unique_lock<boost::shared_mutex> lock(_sessionMutex);
|
||||
_sessions[{ session->GetAccountId(), session->GetGameAccountId() }] = session;
|
||||
_sessionsByAccountId[session->GetAccountId()].push_back(session);
|
||||
}
|
||||
|
||||
void Battlenet::SessionManager::RemoveSession(Session* session)
|
||||
{
|
||||
std::unique_lock<boost::shared_mutex> lock(_sessionMutex);
|
||||
_sessions.erase({ session->GetAccountId(), session->GetGameAccountId() });
|
||||
_sessionsByAccountId[session->GetAccountId()].remove(session);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace Battlenet
|
||||
{
|
||||
typedef SocketMgr<Session> BaseSocketMgr;
|
||||
typedef std::map<SessionInfo, Session*> SessionMap;
|
||||
typedef std::map<uint32, std::list<Session*>> SessionByAccountMap;
|
||||
|
||||
public:
|
||||
static SessionManager& Instance()
|
||||
@@ -74,6 +75,7 @@ namespace Battlenet
|
||||
static void OnSocketAccept(tcp::socket&& sock);
|
||||
|
||||
SessionMap _sessions;
|
||||
SessionByAccountMap _sessionsByAccountId;
|
||||
boost::shared_mutex _sessionMutex;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user