Core/Datastores: corrected db structure for item.db hotfix table and removed timestamp field from hotfix_data as the timestamp is being generated by the server

This commit is contained in:
Ovahlord
2020-02-22 22:29:35 +01:00
parent d805730e96
commit f2b26c68a7
5 changed files with 11 additions and 19 deletions

View File

@@ -0,0 +1,6 @@
ALTER TABLE `hotfix_data`
DROP COLUMN `Timestamp`,
DROP PRIMARY KEY,
ADD PRIMARY KEY (`TableHash`, `RecordID`);
ALTER TABLE `hotfixes`.`item` ADD COLUMN `DisplayInfoID` INT(10) UNSIGNED DEFAULT 0 NOT NULL AFTER `Material`;

View File

@@ -35,7 +35,7 @@ void HotfixDatabaseConnection::DoPrepareStatements()
"Key17, Key18, Key19, Key20, Key21, Key22, Key23, Key24, Key25, Key26, Key27, Key28, Key29, Key30, Key31, Key32 FROM key_chain ORDER BY ID DESC", CONNECTION_SYNCH);
// Item.db2
PrepareStatement(HOTFIX_SEL_ITEM, "SELECT ID, Class, SubClass, SoundOverrideSubclass, Material, InventoryType, Sheath FROM item ORDER BY ID DESC", CONNECTION_SYNCH);
PrepareStatement(HOTFIX_SEL_ITEM, "SELECT ID, Class, SubClass, SoundOverrideSubclass, Material, DisplayInfoID, InventoryType, Sheath FROM item ORDER BY ID DESC", CONNECTION_SYNCH);
// ItemCurrencyCost.db2
PrepareStatement(HOTFIX_SEL_ITEM_CURRENCY_COST, "SELECT ID, ItemID FROM item_currency_cost ORDER BY ItemID DESC", CONNECTION_SYNCH);

View File

@@ -133,7 +133,7 @@ void DB2Manager::LoadHotfixData()
{
uint32 oldMSTime = getMSTime();
QueryResult result = HotfixDatabase.Query("SELECT TableHash, RecordID, `Timestamp`, Deleted FROM hotfix_data");
QueryResult result = HotfixDatabase.Query("SELECT TableHash, RecordID, Deleted FROM hotfix_data");
if (!result)
{
@@ -152,10 +152,9 @@ void DB2Manager::LoadHotfixData()
HotfixNotify info;
info.TableHash = fields[0].GetUInt32();
info.Entry = fields[1].GetUInt32();
info.Timestamp = fields[2].GetUInt32();
_hotfixData.push_back(info);
if (fields[3].GetBool())
if (fields[2].GetBool())
{
auto itr = _stores.find(info.TableHash);
if (itr != _stores.end())
@@ -167,14 +166,3 @@ void DB2Manager::LoadHotfixData()
TC_LOG_INFO("misc", ">> Loaded %u hotfix info entries in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
time_t DB2Manager::GetHotfixDate(uint32 entry, uint32 type) const
{
time_t ret = 0;
for (HotfixNotify const& hotfix : _hotfixData)
if (hotfix.Entry == entry && hotfix.TableHash == type)
if (time_t(hotfix.Timestamp) > ret)
ret = time_t(hotfix.Timestamp);
return ret ? ret : time(nullptr);
}

View File

@@ -53,7 +53,6 @@ public:
void LoadHotfixData();
HotfixData const* GetHotfixData() const { return &_hotfixData; }
time_t GetHotfixDate(uint32 entry, uint32 type) const;
private:
StorageMap _stores;

View File

@@ -557,18 +557,17 @@ void WorldSession::HandleDBQueryBulk(WorldPackets::Query::DBQueryBulk& packet)
{
WorldPackets::Query::DBReply response;
response.TableHash = packet.TableHash;
response.Timestamp = GameTime::GetGameTime() + (5 * IN_MILLISECONDS); // according to sniffs the server sends its local time + 5 seconds
if (store->HasRecord(rec.RecordID))
{
response.RecordID = rec.RecordID;
response.Timestamp = sDB2Manager.GetHotfixDate(rec.RecordID, packet.TableHash);
store->WriteRecord(rec.RecordID, GetSessionDbcLocale(), response.Data);
}
else
{
TC_LOG_ERROR("network", "CMSG_DB_QUERY_BULK: Entry %u does not exist in datastore: %u", rec.RecordID, packet.TableHash);
TC_LOG_TRACE("network", "CMSG_DB_QUERY_BULK: %s requested non-existing entry %u in datastore: %u", GetPlayerInfo().c_str(), rec.RecordID, packet.TableHash);
response.RecordID = -int32(rec.RecordID);
response.Timestamp = GameTime::GetGameTime();
}
SendPacket(response.Write());