aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNaios <naios-dev@live.de>2015-04-27 17:01:30 +0200
committerNaios <naios-dev@live.de>2015-04-27 17:01:30 +0200
commitd37ecf796ef24fe96e56ef5262bab1ae4390dc2f (patch)
tree41c3f6d6493175a595af3bf387403763c1345cd2 /src
parent5acc4b14aa81a5e9a946d11cfa9034d334ea7144 (diff)
Core/Misc: Use boost::in_place() to initialize optionals.
* Improves commit 800d5d893964a822655 * Thanks @Shauren for this great suggestion.
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Battlegrounds/Battleground.cpp4
-rw-r--r--src/server/game/Entities/Player/Player.cpp2
-rw-r--r--src/server/game/Guilds/Guild.cpp2
-rw-r--r--src/server/game/Handlers/AuthHandler.cpp6
-rw-r--r--src/server/game/Handlers/CharacterHandler.cpp4
-rw-r--r--src/server/game/Handlers/InspectHandler.cpp2
-rw-r--r--src/server/game/Handlers/TradeHandler.cpp2
-rw-r--r--src/server/game/Server/Packets/ItemPackets.cpp6
-rw-r--r--src/server/game/Server/Packets/MovementPackets.h2
-rw-r--r--src/server/game/Server/Packets/SpellPackets.cpp2
-rw-r--r--src/server/game/Server/Packets/TicketPackets.cpp10
-rw-r--r--src/server/game/Server/Packets/WhoPackets.cpp2
-rw-r--r--src/server/game/Spells/Spell.cpp8
-rw-r--r--src/server/game/Support/SupportMgr.cpp2
-rw-r--r--src/server/shared/Common.h1
15 files changed, 28 insertions, 27 deletions
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index 5a5356d0748..922bf4fed36 100644
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -1325,7 +1325,7 @@ void Battleground::BuildPvPLogDataPacket(WorldPackets::Battleground::PVPLogData&
playerData.Faction = score.second->TeamId;
if (score.second->HonorableKills || score.second->Deaths || score.second->BonusHonor)
{
- playerData.Honor = WorldPackets::Battleground::PVPLogData::HonorData();
+ playerData.Honor = boost::in_place();
playerData.Honor->HonorKills = score.second->HonorableKills;
playerData.Honor->Deaths = score.second->Deaths;
playerData.Honor->ContributionPoints = score.second->BonusHonor;
@@ -1354,7 +1354,7 @@ void Battleground::BuildPvPLogDataPacket(WorldPackets::Battleground::PVPLogData&
if (isRated())
{
- pvpLogData.Ratings = WorldPackets::Battleground::PVPLogData::RatingData();
+ pvpLogData.Ratings = boost::in_place();
for (uint8 i = 0; i < BG_TEAMS_COUNT; ++i)
{
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 39b468e729e..81e0cbd2e66 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -2155,7 +2155,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
transferPending.MapID = mapid;
if (Transport* transport = GetTransport())
{
- transferPending.Ship = WorldPackets::Movement::TransferPending::ShipTransferPending();
+ transferPending.Ship = boost::in_place();
transferPending.Ship->ID = transport->GetEntry();
transferPending.Ship->OriginMapID = GetMapId();
}
diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp
index 5c45a81f18c..c5812999490 100644
--- a/src/server/game/Guilds/Guild.cpp
+++ b/src/server/game/Guilds/Guild.cpp
@@ -1313,7 +1313,7 @@ void Guild::SendQueryResponse(WorldSession* session)
{
WorldPackets::Guild::QueryGuildInfoResponse response;
response.GuildGuid = GetGUID();
- response.Info = WorldPackets::Guild::QueryGuildInfoResponse::GuildInfo();
+ response.Info = boost::in_place();
response.Info->GuildGUID = GetGUID();
response.Info->VirtualRealmAddress = GetVirtualRealmAddress();
diff --git a/src/server/game/Handlers/AuthHandler.cpp b/src/server/game/Handlers/AuthHandler.cpp
index 233a0346c9c..66a31ce0bf2 100644
--- a/src/server/game/Handlers/AuthHandler.cpp
+++ b/src/server/game/Handlers/AuthHandler.cpp
@@ -28,13 +28,13 @@ void WorldSession::SendAuthResponse(uint8 code, bool queued, uint32 queuePos)
if (queued)
{
- response.WaitInfo = WorldPackets::Auth::AuthResponse::AuthWaitInfo();
+ response.WaitInfo = boost::in_place();
response.WaitInfo->WaitCount = queuePos;
}
if (code == AUTH_OK)
{
- response.SuccessInfo = WorldPackets::Auth::AuthResponse::AuthSuccessInfo();
+ response.SuccessInfo = boost::in_place();
response.SuccessInfo->AccountExpansionLevel = GetExpansion();
response.SuccessInfo->ActiveExpansionLevel = GetExpansion();
@@ -64,7 +64,7 @@ void WorldSession::SendAuthWaitQue(uint32 position)
response.Result = AUTH_OK;
else
{
- response.WaitInfo = WorldPackets::Auth::AuthResponse::AuthWaitInfo();
+ response.WaitInfo = boost::in_place();
response.WaitInfo->WaitCount = position;
response.Result = AUTH_WAIT_QUEUE;
}
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
index 39dae87cba9..ea859bc7b08 100644
--- a/src/server/game/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Handlers/CharacterHandler.cpp
@@ -1135,7 +1135,7 @@ void WorldSession::SendFeatureSystemStatus()
features.VoiceEnabled = false;
features.BrowserEnabled = false; // Has to be false, otherwise client will crash if "Customer Support" is opened
- features.EuropaTicketSystemStatus = WorldPackets::System::FeatureSystemStatus::EuropaTicketConfig();
+ features.EuropaTicketSystemStatus = boost::in_place();
features.EuropaTicketSystemStatus->ThrottleState.MaxTries = 10;
features.EuropaTicketSystemStatus->ThrottleState.PerMilliseconds = 60000;
features.EuropaTicketSystemStatus->ThrottleState.TryCount = 1;
@@ -2583,7 +2583,7 @@ void WorldSession::SendCharFactionChange(ResponseCodes result, WorldPackets::Cha
if (result == RESPONSE_SUCCESS)
{
- packet.Display = WorldPackets::Character::CharFactionChangeResult::CharFactionChangeDisplayInfo();
+ packet.Display = boost::in_place();
packet.Display->Name = factionChangeInfo->Name;
packet.Display->SexID = factionChangeInfo->SexID;
packet.Display->SkinID = *factionChangeInfo->SkinID;
diff --git a/src/server/game/Handlers/InspectHandler.cpp b/src/server/game/Handlers/InspectHandler.cpp
index 18a28938611..886234e720d 100644
--- a/src/server/game/Handlers/InspectHandler.cpp
+++ b/src/server/game/Handlers/InspectHandler.cpp
@@ -65,7 +65,7 @@ void WorldSession::HandleInspectOpcode(WorldPackets::Inspect::Inspect& inspect)
if (Guild* guild = sGuildMgr->GetGuildById(player->GetGuildId()))
{
- inspectResult.GuildData = WorldPackets::Inspect::InspectGuildData();
+ inspectResult.GuildData = boost::in_place();
inspectResult.GuildData->GuildGUID = guild->GetGUID();
inspectResult.GuildData->NumGuildMembers = guild->GetMembersCount();
inspectResult.GuildData->AchievementPoints = guild->GetAchievementMgr().GetAchievementPoints();
diff --git a/src/server/game/Handlers/TradeHandler.cpp b/src/server/game/Handlers/TradeHandler.cpp
index 9a5ed1a2667..159876fdebd 100644
--- a/src/server/game/Handlers/TradeHandler.cpp
+++ b/src/server/game/Handlers/TradeHandler.cpp
@@ -69,7 +69,7 @@ void WorldSession::SendUpdateTrade(bool trader_data /*= true*/)
tradeItem.GiftCreator = item->GetGuidValue(ITEM_FIELD_GIFTCREATOR);
if (!item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
{
- tradeItem.Unwrapped = WorldPackets::Trade::TradeUpdated::UnwrappedTradeItem();
+ tradeItem.Unwrapped = boost::in_place();
tradeItem.Unwrapped->Item.Initialize(item);
tradeItem.Unwrapped->EnchantID = item->GetEnchantmentId(PERM_ENCHANTMENT_SLOT);
diff --git a/src/server/game/Server/Packets/ItemPackets.cpp b/src/server/game/Server/Packets/ItemPackets.cpp
index 7e5550b971f..3feea2cdc98 100644
--- a/src/server/game/Server/Packets/ItemPackets.cpp
+++ b/src/server/game/Server/Packets/ItemPackets.cpp
@@ -104,7 +104,7 @@ ByteBuffer& operator>>(ByteBuffer& data, Optional<WorldPackets::Item::ItemBonusI
{
uint32 bonusListIdSize;
- itemBonusInstanceData = WorldPackets::Item::ItemBonusInstanceData();
+ itemBonusInstanceData = boost::in_place();
data >> itemBonusInstanceData->Context;
data >> bonusListIdSize;
@@ -180,7 +180,7 @@ void WorldPackets::Item::ItemInstance::Initialize(::Item const* item)
std::vector<uint32> const& bonusListIds = item->GetDynamicValues(ITEM_DYNAMIC_FIELD_BONUSLIST_IDS);
if (!bonusListIds.empty())
{
- ItemBonus = WorldPackets::Item::ItemBonusInstanceData();
+ ItemBonus = boost::in_place();
ItemBonus->BonusListIDs.insert(ItemBonus->BonusListIDs.end(), bonusListIds.begin(), bonusListIds.end());
ItemBonus->Context = item->GetUInt32Value(ITEM_FIELD_CONTEXT);
}
@@ -203,7 +203,7 @@ void WorldPackets::Item::ItemInstance::Initialize(::LootItem const& lootItem)
RandomPropertiesID = lootItem.randomPropertyId;
if (!lootItem.BonusListIDs.empty())
{
- ItemBonus = ItemBonusInstanceData();
+ ItemBonus = boost::in_place();
ItemBonus->BonusListIDs = lootItem.BonusListIDs;
ItemBonus->Context = 0; /// @todo
}
diff --git a/src/server/game/Server/Packets/MovementPackets.h b/src/server/game/Server/Packets/MovementPackets.h
index 4ab2fe39fae..6803bdf3b95 100644
--- a/src/server/game/Server/Packets/MovementPackets.h
+++ b/src/server/game/Server/Packets/MovementPackets.h
@@ -175,13 +175,13 @@ namespace WorldPackets
class TransferPending final : public ServerPacket
{
- public:
struct ShipTransferPending
{
uint32 ID = 0; ///< gameobject_template.entry of the transport the player is teleporting on
int32 OriginMapID = -1; ///< Map id the player is currently on (before teleport)
};
+ public:
TransferPending() : ServerPacket(SMSG_TRANSFER_PENDING, 16) { }
WorldPacket const* Write() override;
diff --git a/src/server/game/Server/Packets/SpellPackets.cpp b/src/server/game/Server/Packets/SpellPackets.cpp
index 341ca6c1128..421a2e9a46c 100644
--- a/src/server/game/Server/Packets/SpellPackets.cpp
+++ b/src/server/game/Server/Packets/SpellPackets.cpp
@@ -143,7 +143,7 @@ WorldPacket const* WorldPackets::Spells::AuraUpdate::Write()
ByteBuffer& operator>>(ByteBuffer& buffer, Optional<WorldPackets::Spells::TargetLocation>& location)
{
- location = WorldPackets::Spells::TargetLocation();
+ location = boost::in_place();
buffer >> location->Transport;
buffer >> location->Location.m_positionX;
buffer >> location->Location.m_positionY;
diff --git a/src/server/game/Server/Packets/TicketPackets.cpp b/src/server/game/Server/Packets/TicketPackets.cpp
index 4a73f9ea750..a91cdbec92a 100644
--- a/src/server/game/Server/Packets/TicketPackets.cpp
+++ b/src/server/game/Server/Packets/TicketPackets.cpp
@@ -236,7 +236,7 @@ ByteBuffer& operator>>(ByteBuffer& data, WorldPackets::Ticket::SupportTicketSubm
ByteBuffer& operator>>(ByteBuffer& data, Optional<WorldPackets::Ticket::SupportTicketSubmitComplaint::SupportTicketMailInfo>& mail)
{
- mail = WorldPackets::Ticket::SupportTicketSubmitComplaint::SupportTicketMailInfo();
+ mail = boost::in_place();
data >> mail->MailID;
uint16 bodyLength = data.ReadBits(13);
@@ -250,7 +250,7 @@ ByteBuffer& operator>>(ByteBuffer& data, Optional<WorldPackets::Ticket::SupportT
ByteBuffer& operator>>(ByteBuffer& data, Optional<WorldPackets::Ticket::SupportTicketSubmitComplaint::SupportTicketCalendarEventInfo>& event)
{
- event = WorldPackets::Ticket::SupportTicketSubmitComplaint::SupportTicketCalendarEventInfo();
+ event = boost::in_place();
data >> event->EventID;
data >> event->InviteID;
uint8 titleLength = data.ReadBits(8);
@@ -262,7 +262,7 @@ ByteBuffer& operator>>(ByteBuffer& data, Optional<WorldPackets::Ticket::SupportT
ByteBuffer& operator>>(ByteBuffer& data, Optional<WorldPackets::Ticket::SupportTicketSubmitComplaint::SupportTicketPetInfo>& pet)
{
- pet = WorldPackets::Ticket::SupportTicketSubmitComplaint::SupportTicketPetInfo();
+ pet = boost::in_place();
data >> pet->PetID;
uint8 nameLength = data.ReadBits(8);
@@ -273,7 +273,7 @@ ByteBuffer& operator>>(ByteBuffer& data, Optional<WorldPackets::Ticket::SupportT
ByteBuffer& operator>>(ByteBuffer& data, Optional<WorldPackets::Ticket::SupportTicketSubmitComplaint::SupportTicketGuildInfo>& guild)
{
- guild = WorldPackets::Ticket::SupportTicketSubmitComplaint::SupportTicketGuildInfo();
+ guild = boost::in_place();
data >> guild->GuildID;
uint8 nameLength = data.ReadBits(8);
@@ -284,7 +284,7 @@ ByteBuffer& operator>>(ByteBuffer& data, Optional<WorldPackets::Ticket::SupportT
ByteBuffer& operator>>(ByteBuffer& data, Optional<WorldPackets::Ticket::SupportTicketSubmitComplaint::Struct5E4383>& str)
{
- str = WorldPackets::Ticket::SupportTicketSubmitComplaint::Struct5E4383();
+ str = boost::in_place();
data >> str->RideTicket;
data >> str->_40;
data >> str->_56;
diff --git a/src/server/game/Server/Packets/WhoPackets.cpp b/src/server/game/Server/Packets/WhoPackets.cpp
index 47b5b4da5a7..99ce0805e8b 100644
--- a/src/server/game/Server/Packets/WhoPackets.cpp
+++ b/src/server/game/Server/Packets/WhoPackets.cpp
@@ -41,7 +41,7 @@ ByteBuffer& operator>>(ByteBuffer& data, WorldPackets::Who::WhoWord& word)
ByteBuffer& operator>>(ByteBuffer& data, Optional<WorldPackets::Who::WhoRequestServerInfo>& serverInfo)
{
- serverInfo = WorldPackets::Who::WhoRequestServerInfo();
+ serverInfo = boost::in_place();
data >> serverInfo->FactionGroup;
data >> serverInfo->Locale;
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 2fd118941b6..194467ccadf 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -222,7 +222,7 @@ void SpellCastTargets::Write(WorldPackets::Spells::SpellTargetData& data)
if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION)
{
- data.SrcLocation = WorldPackets::Spells::TargetLocation();
+ data.SrcLocation = boost::in_place();
data.SrcLocation->Transport = m_src._transportGUID; // relative position guid here - transport for example
if (!m_src._transportGUID.IsEmpty())
data.SrcLocation->Location = m_src._transportOffset;
@@ -232,7 +232,7 @@ void SpellCastTargets::Write(WorldPackets::Spells::SpellTargetData& data)
if (m_targetMask & TARGET_FLAG_DEST_LOCATION)
{
- data.DstLocation = WorldPackets::Spells::TargetLocation();
+ data.DstLocation = boost::in_place();
data.DstLocation->Transport = m_dst._transportGUID; // relative position guid here - transport for example
if (!m_dst._transportGUID.IsEmpty())
data.DstLocation->Location = m_dst._transportOffset;
@@ -3888,7 +3888,7 @@ void Spell::SendSpellStart()
if (castFlags & CAST_FLAG_RUNE_LIST) // rune cooldowns list
{
- castData.RemainingRunes = WorldPackets::Spells::RuneData();
+ castData.RemainingRunes = boost::in_place();
//TODO: There is a crash caused by a spell with CAST_FLAG_RUNE_LIST casted by a creature
//The creature is the mover of a player, so HandleCastSpellOpcode uses it as the caster
@@ -4006,7 +4006,7 @@ void Spell::SendSpellGo()
if (castFlags & CAST_FLAG_RUNE_LIST) // rune cooldowns list
{
- castData.RemainingRunes = WorldPackets::Spells::RuneData();
+ castData.RemainingRunes = boost::in_place();
//TODO: There is a crash caused by a spell with CAST_FLAG_RUNE_LIST casted by a creature
//The creature is the mover of a player, so HandleCastSpellOpcode uses it as the caster
diff --git a/src/server/game/Support/SupportMgr.cpp b/src/server/game/Support/SupportMgr.cpp
index 06d09615e59..90afcfd1511 100644
--- a/src/server/game/Support/SupportMgr.cpp
+++ b/src/server/game/Support/SupportMgr.cpp
@@ -1056,7 +1056,7 @@ void SupportMgr::SendGmTicket(WorldSession* session, GmTicket* ticket) const
if (ticket)
{
response.Result = GMTICKET_STATUS_HASTEXT;
- response.Info = WorldPackets::Ticket::GMTicketGetTicketResponse::GMTicketInfo();
+ response.Info = boost::in_place();
response.Info->TicketID = ticket->GetId();
response.Info->TicketDescription = ticket->GetDescription();
diff --git a/src/server/shared/Common.h b/src/server/shared/Common.h
index 4e1e24cce42..dc9e948966d 100644
--- a/src/server/shared/Common.h
+++ b/src/server/shared/Common.h
@@ -40,6 +40,7 @@
#include <algorithm>
#include <boost/optional.hpp>
+#include <boost/utility/in_place_factory.hpp>
#include "Debugging/Errors.h"