mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
(cherry picked from commit 12701cb0c6)
Conflicts:
src/server/game/Achievements/AchievementMgr.cpp
src/server/game/AuctionHouse/AuctionHouseMgr.cpp
src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp
src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp
src/server/game/Battlefield/Battlefield.cpp
src/server/game/Battlefield/Zones/BattlefieldWG.cpp
src/server/game/Battlegrounds/BattlegroundMgr.cpp
src/server/game/Calendar/CalendarMgr.h
src/server/game/DungeonFinding/LFGQueue.cpp
src/server/game/Entities/Corpse/Corpse.cpp
src/server/game/Entities/Creature/Creature.cpp
src/server/game/Entities/Item/Item.cpp
src/server/game/Entities/Pet/Pet.cpp
src/server/game/Entities/Player/Player.cpp
src/server/game/Entities/Unit/Unit.cpp
src/server/game/Globals/ObjectMgr.cpp
src/server/game/Grids/ObjectGridLoader.cpp
src/server/game/Guilds/Guild.cpp
src/server/game/Handlers/AuctionHouseHandler.cpp
src/server/game/Handlers/BattlefieldHandler.cpp
src/server/game/Handlers/CalendarHandler.cpp
src/server/game/Handlers/CharacterHandler.cpp
src/server/game/Handlers/ChatHandler.cpp
src/server/game/Handlers/LFGHandler.cpp
src/server/game/Handlers/MailHandler.cpp
src/server/game/Handlers/MiscHandler.cpp
src/server/game/Handlers/MovementHandler.cpp
src/server/game/Handlers/PetHandler.cpp
src/server/game/Handlers/QueryHandler.cpp
src/server/game/Handlers/TicketHandler.cpp
src/server/game/Instances/InstanceSaveMgr.cpp
src/server/game/Server/WorldSession.cpp
src/server/game/Server/WorldSocket.cpp
src/server/game/Spells/Auras/SpellAuras.cpp
src/server/game/Tickets/TicketMgr.cpp
src/server/game/Tickets/TicketMgr.h
src/server/game/World/World.cpp
src/server/scripts/Commands/cs_gobject.cpp
src/server/scripts/Commands/cs_instance.cpp
src/server/scripts/Commands/cs_list.cpp
src/server/scripts/Northrend/zone_wintergrasp.cpp
src/server/scripts/Spells/spell_item.cpp
113 lines
5.1 KiB
C++
113 lines
5.1 KiB
C++
/*
|
|
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
|
*
|
|
* 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 "WorldSession.h"
|
|
#include "Containers.h"
|
|
#include "DB2Stores.h"
|
|
#include "GameTime.h"
|
|
#include "HotfixPackets.h"
|
|
#include "Log.h"
|
|
#include "ObjectDefines.h"
|
|
#include "Realm.h"
|
|
#include "World.h"
|
|
|
|
void WorldSession::HandleDBQueryBulk(WorldPackets::Hotfix::DBQueryBulk& dbQuery)
|
|
{
|
|
DB2StorageBase const* store = sDB2Manager.GetStorage(dbQuery.TableHash);
|
|
for (WorldPackets::Hotfix::DBQueryBulk::DBQueryRecord const& record : dbQuery.Queries)
|
|
{
|
|
WorldPackets::Hotfix::DBReply dbReply;
|
|
dbReply.TableHash = dbQuery.TableHash;
|
|
dbReply.RecordID = record.RecordID;
|
|
|
|
if (store && store->HasRecord(record.RecordID))
|
|
{
|
|
dbReply.Status = DB2Manager::HotfixRecord::Status::Valid;
|
|
dbReply.Timestamp = GameTime::GetGameTime();
|
|
store->WriteRecord(record.RecordID, GetSessionDbcLocale(), dbReply.Data);
|
|
|
|
if (std::vector<DB2Manager::HotfixOptionalData> const* optionalDataEntries = sDB2Manager.GetHotfixOptionalData(dbQuery.TableHash, record.RecordID, GetSessionDbcLocale()))
|
|
{
|
|
for (DB2Manager::HotfixOptionalData const& optionalData : *optionalDataEntries)
|
|
{
|
|
dbReply.Data << uint32(optionalData.Key);
|
|
dbReply.Data.append(optionalData.Data.data(), optionalData.Data.size());
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TC_LOG_TRACE("network", "CMSG_DB_QUERY_BULK: %s requested non-existing entry %u in datastore: %u", GetPlayerInfo().c_str(), record.RecordID, dbQuery.TableHash);
|
|
dbReply.Timestamp = GameTime::GetGameTime();
|
|
}
|
|
|
|
SendPacket(dbReply.Write());
|
|
}
|
|
}
|
|
|
|
void WorldSession::SendAvailableHotfixes()
|
|
{
|
|
SendPacket(WorldPackets::Hotfix::AvailableHotfixes(realm.Id.GetAddress(), sDB2Manager.GetHotfixData()).Write());
|
|
}
|
|
|
|
void WorldSession::HandleHotfixRequest(WorldPackets::Hotfix::HotfixRequest& hotfixQuery)
|
|
{
|
|
DB2Manager::HotfixContainer const& hotfixes = sDB2Manager.GetHotfixData();
|
|
WorldPackets::Hotfix::HotfixConnect hotfixQueryResponse;
|
|
hotfixQueryResponse.Hotfixes.reserve(hotfixQuery.Hotfixes.size());
|
|
for (int32 hotfixId : hotfixQuery.Hotfixes)
|
|
{
|
|
if (std::vector<DB2Manager::HotfixRecord> const* hotfixRecords = Trinity::Containers::MapGetValuePtr(hotfixes, hotfixId))
|
|
{
|
|
for (DB2Manager::HotfixRecord const& hotfixRecord : *hotfixRecords)
|
|
{
|
|
hotfixQueryResponse.Hotfixes.emplace_back();
|
|
|
|
WorldPackets::Hotfix::HotfixConnect::HotfixData& hotfixData = hotfixQueryResponse.Hotfixes.back();
|
|
hotfixData.Record = hotfixRecord;
|
|
if (hotfixRecord.HotfixStatus == DB2Manager::HotfixRecord::Status::Valid)
|
|
{
|
|
DB2StorageBase const* storage = sDB2Manager.GetStorage(hotfixRecord.TableHash);
|
|
if (storage && storage->HasRecord(uint32(hotfixRecord.RecordID)))
|
|
{
|
|
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()))
|
|
{
|
|
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());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
SendPacket(hotfixQueryResponse.Write());
|
|
}
|