mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/DataStores: Support all new hotfix status values
This commit is contained in:
6
sql/updates/hotfixes/master/2021_02_28_00_hotfixes.sql
Normal file
6
sql/updates/hotfixes/master/2021_02_28_00_hotfixes.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
ALTER TABLE `hotfix_data` ADD `Status` tinyint(3) unsigned NOT NULL DEFAULT '3' AFTER `Deleted`;
|
||||
|
||||
UPDATE `hotfix_data` SET `Status`=1 WHERE `Deleted`=0;
|
||||
UPDATE `hotfix_data` SET `Status`=2 WHERE `Deleted`=1;
|
||||
|
||||
ALTER TABLE `hotfix_data` DROP `Deleted`;
|
||||
@@ -1465,7 +1465,7 @@ void DB2Manager::LoadHotfixData()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
QueryResult result = HotfixDatabase.Query("SELECT Id, TableHash, RecordId, Deleted FROM hotfix_data ORDER BY Id");
|
||||
QueryResult result = HotfixDatabase.Query("SELECT Id, TableHash, RecordId, Status FROM hotfix_data ORDER BY Id");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
@@ -1484,8 +1484,8 @@ void DB2Manager::LoadHotfixData()
|
||||
int32 id = fields[0].GetInt32();
|
||||
uint32 tableHash = fields[1].GetUInt32();
|
||||
int32 recordId = fields[2].GetInt32();
|
||||
bool deleted = fields[3].GetBool();
|
||||
if (!deleted && _stores.find(tableHash) == _stores.end())
|
||||
HotfixRecord::Status status = static_cast<HotfixRecord::Status>(fields[3].GetUInt8());
|
||||
if (status == HotfixRecord::Status::Valid && _stores.find(tableHash) == _stores.end())
|
||||
{
|
||||
HotfixBlobKey key = std::make_pair(tableHash, recordId);
|
||||
if (std::none_of(_hotfixBlob.begin(), _hotfixBlob.end(), [key](HotfixBlobMap const& blob) { return blob.find(key) != blob.end(); }))
|
||||
@@ -1500,8 +1500,9 @@ void DB2Manager::LoadHotfixData()
|
||||
hotfixRecord.TableHash = tableHash;
|
||||
hotfixRecord.RecordID = recordId;
|
||||
hotfixRecord.HotfixID = id;
|
||||
hotfixRecord.HotfixStatus = status;
|
||||
_hotfixData.insert(hotfixRecord);
|
||||
deletedRecords[std::make_pair(tableHash, recordId)] = deleted;
|
||||
deletedRecords[std::make_pair(tableHash, recordId)] = status == HotfixRecord::Status::RecordRemoved;
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
|
||||
@@ -277,9 +277,17 @@ public:
|
||||
|
||||
struct HotfixRecord
|
||||
{
|
||||
enum class Status : uint8
|
||||
{
|
||||
Valid = 1,
|
||||
RecordRemoved = 2,
|
||||
Invalid = 3
|
||||
};
|
||||
|
||||
uint32 TableHash = 0;
|
||||
int32 RecordID = 0;
|
||||
int32 HotfixID = 0;
|
||||
Status HotfixStatus = Status::Invalid;
|
||||
|
||||
friend bool operator<(HotfixRecord const& left, HotfixRecord const& right)
|
||||
{
|
||||
|
||||
@@ -71,35 +71,38 @@ void WorldSession::HandleHotfixRequest(WorldPackets::Hotfix::HotfixRequest& hotf
|
||||
hotfixQueryResponse.Hotfixes.reserve(hotfixQuery.Hotfixes.size());
|
||||
for (DB2Manager::HotfixRecord const& hotfixRecord : hotfixQuery.Hotfixes)
|
||||
{
|
||||
if (hotfixes.find(hotfixRecord) != hotfixes.end())
|
||||
auto serverHotfixInfo = hotfixes.find(hotfixRecord);
|
||||
if (serverHotfixInfo != hotfixes.end())
|
||||
{
|
||||
DB2StorageBase const* storage = sDB2Manager.GetStorage(hotfixRecord.TableHash);
|
||||
hotfixQueryResponse.Hotfixes.emplace_back();
|
||||
|
||||
WorldPackets::Hotfix::HotfixConnect::HotfixData hotfixData;
|
||||
hotfixData.Record = hotfixRecord;
|
||||
if (storage && storage->HasRecord(uint32(hotfixRecord.RecordID)))
|
||||
WorldPackets::Hotfix::HotfixConnect::HotfixData& hotfixData = hotfixQueryResponse.Hotfixes.back();
|
||||
hotfixData.Record = *serverHotfixInfo;
|
||||
if (serverHotfixInfo->HotfixStatus == DB2Manager::HotfixRecord::Status::Valid)
|
||||
{
|
||||
std::size_t pos = hotfixQueryResponse.HotfixContent.size();
|
||||
storage->WriteRecord(uint32(hotfixRecord.RecordID), GetSessionDbcLocale(), hotfixQueryResponse.HotfixContent);
|
||||
|
||||
if (std::vector<DB2Manager::HotfixOptionalData> const* optionalDataEntries = sDB2Manager.GetHotfixOptionalData(hotfixRecord.TableHash, hotfixRecord.RecordID, GetSessionDbcLocale()))
|
||||
DB2StorageBase const* storage = sDB2Manager.GetStorage(hotfixRecord.TableHash);
|
||||
if (storage && storage->HasRecord(uint32(hotfixRecord.RecordID)))
|
||||
{
|
||||
for (DB2Manager::HotfixOptionalData const& optionalData : *optionalDataEntries)
|
||||
std::size_t pos = hotfixQueryResponse.HotfixContent.size();
|
||||
storage->WriteRecord(uint32(hotfixRecord.RecordID), GetSessionDbcLocale(), hotfixQueryResponse.HotfixContent);
|
||||
|
||||
if (std::vector<DB2Manager::HotfixOptionalData> const* optionalDataEntries = sDB2Manager.GetHotfixOptionalData(hotfixRecord.TableHash, hotfixRecord.RecordID, GetSessionDbcLocale()))
|
||||
{
|
||||
hotfixQueryResponse.HotfixContent << uint32(optionalData.Key);
|
||||
hotfixQueryResponse.HotfixContent.append(optionalData.Data.data(), optionalData.Data.size());
|
||||
for (DB2Manager::HotfixOptionalData const& optionalData : *optionalDataEntries)
|
||||
{
|
||||
hotfixQueryResponse.HotfixContent << uint32(optionalData.Key);
|
||||
hotfixQueryResponse.HotfixContent.append(optionalData.Data.data(), optionalData.Data.size());
|
||||
}
|
||||
}
|
||||
|
||||
hotfixData.Size = hotfixQueryResponse.HotfixContent.size() - pos;
|
||||
}
|
||||
else if (std::vector<uint8> const* blobData = sDB2Manager.GetHotfixBlobData(hotfixRecord.TableHash, hotfixRecord.RecordID, GetSessionDbcLocale()))
|
||||
{
|
||||
hotfixData.Size = blobData->size();
|
||||
hotfixQueryResponse.HotfixContent.append(blobData->data(), blobData->size());
|
||||
}
|
||||
|
||||
hotfixData.Size = hotfixQueryResponse.HotfixContent.size() - pos;
|
||||
}
|
||||
else if (std::vector<uint8> const* blobData = sDB2Manager.GetHotfixBlobData(hotfixRecord.TableHash, hotfixRecord.RecordID, GetSessionDbcLocale()))
|
||||
{
|
||||
hotfixData.Size = blobData->size();
|
||||
hotfixQueryResponse.HotfixContent.append(blobData->data(), blobData->size());
|
||||
}
|
||||
|
||||
hotfixQueryResponse.Hotfixes.emplace_back(std::move(hotfixData));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "HotfixPackets.h"
|
||||
#include "PacketUtilities.h"
|
||||
#include "Util.h"
|
||||
|
||||
namespace WorldPackets
|
||||
{
|
||||
@@ -88,16 +89,8 @@ void HotfixRequest::Read()
|
||||
ByteBuffer& operator<<(ByteBuffer& data, HotfixConnect::HotfixData const& hotfixData)
|
||||
{
|
||||
data << hotfixData.Record;
|
||||
if (hotfixData.Size)
|
||||
{
|
||||
data << uint32(*hotfixData.Size);
|
||||
data.WriteBits(1, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
data << uint32(0);
|
||||
data.WriteBits(3, 2);
|
||||
}
|
||||
data << uint32(hotfixData.Size);
|
||||
data.WriteBits(AsUnderlyingType(hotfixData.Record.HotfixStatus), 2);
|
||||
data.FlushBits();
|
||||
|
||||
return data;
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace WorldPackets
|
||||
struct HotfixData
|
||||
{
|
||||
DB2Manager::HotfixRecord Record;
|
||||
Optional<uint32> Size;
|
||||
uint32 Size = 0;
|
||||
};
|
||||
|
||||
HotfixConnect() : ServerPacket(SMSG_HOTFIX_CONNECT) { }
|
||||
|
||||
Reference in New Issue
Block a user