mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 01:37:37 +01:00
Core/Battle.net: Refactored FCC writing
This commit is contained in:
@@ -138,10 +138,15 @@ namespace Battlenet
|
||||
}
|
||||
|
||||
//WriteFloat
|
||||
void WriteFourCC(char const* fcc)
|
||||
void WriteFourCC(std::string const& fcc)
|
||||
{
|
||||
uint32 intVal = *(uint32*)fcc;
|
||||
uint32 intVal = *(uint32*)fcc.c_str();
|
||||
size_t len = fcc.length();
|
||||
EndianConvertReverse(intVal);
|
||||
// Add padding
|
||||
while (len++ < 4)
|
||||
intVal >>= 8;
|
||||
|
||||
Write(intVal, 32);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,6 @@ void BattlenetMgr::LoadModules()
|
||||
Field* fields = result->Fetch();
|
||||
Battlenet::ModuleInfo* module = new Battlenet::ModuleInfo();
|
||||
module->Type = fields[2].GetString();
|
||||
module->Region.assign("\0\0EU", 4);
|
||||
HexStrToByteArray(fields[0].GetString(), module->ModuleId);
|
||||
std::string data = fields[4].GetString();
|
||||
module->DataSize = data.length() / 2;
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Battlenet
|
||||
|
||||
struct ModuleInfo
|
||||
{
|
||||
ModuleInfo() : DataSize(0), Data(nullptr) { }
|
||||
ModuleInfo() : Region("EU"), DataSize(0), Data(nullptr) { }
|
||||
ModuleInfo(ModuleInfo const& right) : Type(right.Type), Region(right.Region), DataSize(right.DataSize), Data(nullptr)
|
||||
{
|
||||
memcpy(ModuleId, right.ModuleId, 32);
|
||||
|
||||
@@ -67,7 +67,7 @@ std::string Battlenet::AuthChallenge::ToString() const
|
||||
std::ostringstream stream;
|
||||
stream << "Battlenet::AuthChallenge Program: " << Program << ", Platform: " << Platform << ", Locale: " << Locale;
|
||||
for (Component const& component : Components)
|
||||
stream << std::endl << "Battlenet::AuthChallenge::Component Program: " << component.Program << ", Platform: " << component.Platform << ", Build: " << component.Build;
|
||||
stream << std::endl << "Battlenet::Component Program: " << component.Program << ", Platform: " << component.Platform << ", Build: " << component.Build;
|
||||
|
||||
if (!Login.empty())
|
||||
stream << std::endl << "Battlenet::AuthChallenge Login: " << Login;
|
||||
@@ -81,7 +81,7 @@ void Battlenet::ProofRequest::Write()
|
||||
for (ModuleInfo const* info : Modules)
|
||||
{
|
||||
_stream.WriteBytes(info->Type.c_str(), 4);
|
||||
_stream.WriteFourCC(info->Region.c_str());
|
||||
_stream.WriteFourCC(info->Region);
|
||||
_stream.WriteBytes(info->ModuleId, 32);
|
||||
_stream.Write(info->DataSize, 10);
|
||||
_stream.WriteBytes(info->Data, info->DataSize);
|
||||
@@ -93,7 +93,7 @@ std::string Battlenet::ProofRequest::ToString() const
|
||||
std::ostringstream stream;
|
||||
stream << "Battlenet::ProofRequest modules " << Modules.size();
|
||||
for (ModuleInfo const* module : Modules)
|
||||
stream << std::endl << "Locale " << module->Region << "ModuleId " << ByteArrayToHexStr(module->ModuleId, 32) << "BlobSize " << module->DataSize;
|
||||
stream << std::endl << "Battlenet::ModuleInfo Locale " << module->Region.c_str() << ", ModuleId " << ByteArrayToHexStr(module->ModuleId, 32) << ", BlobSize " << module->DataSize;
|
||||
|
||||
return stream.str();
|
||||
}
|
||||
@@ -138,7 +138,7 @@ void Battlenet::AuthComplete::Write()
|
||||
{
|
||||
ModuleInfo& info = Modules[i];
|
||||
_stream.WriteBytes(info.Type.c_str(), 4);
|
||||
_stream.WriteFourCC(info.Region.c_str());
|
||||
_stream.WriteFourCC(info.Region);
|
||||
_stream.WriteBytes(info.ModuleId, 32);
|
||||
_stream.Write(info.DataSize, 10);
|
||||
_stream.WriteBytes(info.Data, info.DataSize);
|
||||
@@ -165,7 +165,7 @@ void Battlenet::AuthComplete::Write()
|
||||
{
|
||||
ModuleInfo& info = Modules[0];
|
||||
_stream.WriteBytes(info.Type.c_str(), 4);
|
||||
_stream.WriteFourCC(info.Region.c_str());
|
||||
_stream.WriteFourCC(info.Region);
|
||||
_stream.WriteBytes(info.ModuleId, 32);
|
||||
_stream.Write(info.DataSize, 10);
|
||||
_stream.WriteBytes(info.Data, info.DataSize);
|
||||
|
||||
Reference in New Issue
Block a user