From f2b26c68a7cc4aee417dda5696ec631c040b47b6 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Sat, 22 Feb 2020 22:29:35 +0100 Subject: [PATCH] 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 --- .../hotfixes/4.3.4/2020_02_22_00_hotfixes.sql | 6 ++++++ .../Database/Implementation/HotfixDatabase.cpp | 2 +- src/server/game/DataStores/DB2Stores.cpp | 16 ++-------------- src/server/game/DataStores/DB2Stores.h | 1 - src/server/game/Handlers/QueryHandler.cpp | 5 ++--- 5 files changed, 11 insertions(+), 19 deletions(-) create mode 100644 sql/updates/hotfixes/4.3.4/2020_02_22_00_hotfixes.sql diff --git a/sql/updates/hotfixes/4.3.4/2020_02_22_00_hotfixes.sql b/sql/updates/hotfixes/4.3.4/2020_02_22_00_hotfixes.sql new file mode 100644 index 00000000000..7c39ce4a19e --- /dev/null +++ b/sql/updates/hotfixes/4.3.4/2020_02_22_00_hotfixes.sql @@ -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`; diff --git a/src/server/database/Database/Implementation/HotfixDatabase.cpp b/src/server/database/Database/Implementation/HotfixDatabase.cpp index 4a8ba7a8dac..24f034402d2 100644 --- a/src/server/database/Database/Implementation/HotfixDatabase.cpp +++ b/src/server/database/Database/Implementation/HotfixDatabase.cpp @@ -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); diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp index d71b0288b72..3c84af3028d 100644 --- a/src/server/game/DataStores/DB2Stores.cpp +++ b/src/server/game/DataStores/DB2Stores.cpp @@ -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); -} diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h index c70729faa0d..af5b14a4807 100644 --- a/src/server/game/DataStores/DB2Stores.h +++ b/src/server/game/DataStores/DB2Stores.h @@ -53,7 +53,6 @@ public: void LoadHotfixData(); HotfixData const* GetHotfixData() const { return &_hotfixData; } - time_t GetHotfixDate(uint32 entry, uint32 type) const; private: StorageMap _stores; diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp index fba437af355..767975a89ef 100644 --- a/src/server/game/Handlers/QueryHandler.cpp +++ b/src/server/game/Handlers/QueryHandler.cpp @@ -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());