Core/Misc: replace boost::optional with std::optional

This commit is contained in:
Ovahlord committed 2021-02-19 14:07:43 +01:00
1 parent 44de269fca
commit 0299fa4fe1
38 files changed
+111 -143

No files matched your search

-3
View File
@@ -77,9 +77,6 @@ target_compile_definitions(boost
-DBOOST_DATE_TIME_NO_LIB
-DBOOST_REGEX_NO_LIB
-DBOOST_CHRONO_NO_LIB
# Due to MSVC linking error boost::none" already defined in scripts_...
# May be removed when the requirement is raised to boost 1.61 on windows.
-DBOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE
-DBOOST_SERIALIZATION_NO_LIB
-DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE
-DBOOST_ASIO_NO_DEPRECATED
@@ -314,7 +314,7 @@ namespace VMAP
int32 adtId, rootId, groupId;
uint32 flags;
if (getAreaInfo(mapId, x, y, data.floorZ, flags, adtId, rootId, groupId))
data.areaInfo = boost::in_place(adtId, rootId, groupId, flags);
data.areaInfo.emplace(adtId, rootId, groupId, flags);
return;
}
auto instanceTree = GetMapTree(mapId);
@@ -331,10 +331,10 @@ namespace VMAP
float liquidLevel;
if (!reqLiquidType || (GetLiquidFlagsPtr(liquidType) & reqLiquidType))
if (info.hitInstance->GetLiquidLevel(pos, info, liquidLevel))
data.liquidInfo = boost::in_place(liquidType, liquidLevel);
data.liquidInfo.emplace(liquidType, liquidLevel);
if (!IsVMAPDisabledForPtr(mapId, VMAP_DISABLE_AREAFLAG))
data.areaInfo = boost::in_place(info.hitInstance->adtId, info.rootId, info.hitModel->GetWmoID(), info.hitModel->GetMogpFlags());
data.areaInfo.emplace(info.hitInstance->adtId, info.rootId, info.hitModel->GetWmoID(), info.hitModel->GetMogpFlags());
}
}
}
+5 -3
View File
@@ -18,8 +18,10 @@
#ifndef TrinityCore_Optional_h__
#define TrinityCore_Optional_h__
#include "OptionalFwd.h"
#include <boost/optional.hpp>
#include <boost/utility/in_place_factory.hpp>
#include <optional>
//! Optional helper class to wrap optional values within.
template <class T>
using Optional = std::optional<T>;
#endif // TrinityCore_Optional_h__
-31
View File
@@ -1,31 +0,0 @@
/*
* 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/>.
*/
#ifndef OptionalFwd_h__
#define OptionalFwd_h__
namespace boost
{
template <class T>
class optional;
}
//! Optional helper class to wrap optional values within.
template <class T>
using Optional = boost::optional<T>;
#endif // OptionalFwd_h__
+1 -1
View File
@@ -188,7 +188,7 @@ TaskContext& TaskContext::SetGroup(TaskScheduler::group_t const group)
TaskContext& TaskContext::ClearGroup()
{
_task->_group = boost::none;
_task->_group = std::nullopt;
return *this;
}
+2 -1
View File
@@ -23,6 +23,7 @@
#include "Random.h"
#include <algorithm>
#include <chrono>
#include <functional>
#include <vector>
#include <queue>
#include <memory>
@@ -83,7 +84,7 @@ class TC_COMMON_API TaskScheduler
// Minimal Argument construct
Task(timepoint_t const& end, duration_t const& duration, task_handler_t const& task)
: _end(end), _duration(duration), _group(boost::none), _repeated(0), _task(task) { }
: _end(end), _duration(duration), _group(std::nullopt), _repeated(0), _task(task) { }
// Copy construct
Task(Task const&) = delete;
+1 -1
View File
@@ -51,7 +51,7 @@ class TC_GAME_API GameObjectAI
static int32 Permissible(GameObject const* go);
// Called when the dialog status between a player and the gameobject is requested.
virtual Optional<QuestGiverStatus> GetDialogStatus(Player* /*player*/) { return boost::none; }
virtual Optional<QuestGiverStatus> GetDialogStatus(Player* /*player*/) { return std::nullopt; }
// Called when a player opens a gossip dialog with the gameobject.
virtual bool GossipHello(Player* /*player*/) { return false; }
+1 -1
View File
@@ -196,7 +196,7 @@ class TC_GAME_API CreatureAI : public UnitAI
/// == Gossip system ================================
// Called when the dialog status between a player and the creature is requested.
virtual Optional<QuestGiverStatus> GetDialogStatus(Player* /*player*/) { return boost::none; }
virtual Optional<QuestGiverStatus> GetDialogStatus(Player* /*player*/) { return std::nullopt; }
// Called when a player opens a gossip dialog with the creature.
virtual bool GossipHello(Player* /*player*/) { return false; }
@@ -132,11 +132,11 @@ struct CommandArgsConsumerMulti<Tuple, Optional<NestedNextType>, offset>
// try with the argument
auto& myArg = std::get<offset>(tuple);
myArg.emplace();
if (char const* next = CommandArgsConsumerSingle<NestedNextType>::TryConsumeTo(*(myArg.get_ptr()), args))
if (char const* next = CommandArgsConsumerSingle<NestedNextType>::TryConsumeTo(myArg.value(), args))
if ((next = CommandArgsConsumerNext<Tuple, offset+1>::GoNext(tuple, next)))
return next;
// try again omitting the argument
myArg = boost::none;
myArg = std::nullopt;
if (char const* next = CommandArgsConsumerNext<Tuple, offset+1>::GoNext(tuple, args))
return next;
return nullptr;
@@ -171,8 +171,8 @@ class TC_GAME_API CommandArgs
{
Optional<std::tuple<advstd::remove_cvref_t<T1>, advstd::remove_cvref_t<T2>, advstd::remove_cvref_t<Ts>...>> rv;
rv.emplace();
if (!TryConsumeToTuple<0>(*(rv.get_ptr())))
rv = boost::none;
if (!TryConsumeToTuple<0>(rv.value()))
rv = std::nullopt;
return rv;
}
@@ -182,10 +182,10 @@ class TC_GAME_API CommandArgs
using T = advstd::remove_cvref_t<T1>;
Optional<T> rv;
rv.emplace();
if (char const* next = CommandArgsConsumerSingle<T>::TryConsumeTo(*(rv.get_ptr()), _args))
if (char const* next = CommandArgsConsumerSingle<T>::TryConsumeTo(rv.value(), _args))
_args = next;
else
rv = boost::none;
rv = std::nullopt;
return rv;
}
@@ -2174,7 +2174,7 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster, Option
if (!spellInfo->Effects[i].IsEffect())
continue;
if (effectMask && !(effectMask.get() & (1 << i)))
if (effectMask && !(effectMask.value() & (1 << i)))
continue;
if (!IsImmunedToSpellEffect(spellInfo, i, caster))
+1 -1
View File
@@ -128,7 +128,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
bool IsClassTrainerOf(Player const* player) const;
bool CanCreatureAttack(Unit const* victim, bool force = true) const;
void LoadTemplateImmunities();
bool IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster, Optional<uint8> effectMask = nullptr) const override;
bool IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster, Optional<uint8> effectMask = {}) const override;
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const override;
bool isElite() const;
bool isWorldBoss() const;
+1 -1
View File
@@ -1261,7 +1261,7 @@ void WorldObject::ProcessPositionDataChanged(PositionFullTerrainStatus const& da
m_outdoors = data.outdoors;
m_staticFloorZ = data.floorZ;
m_liquidStatus = data.liquidStatus;
m_wmoGroupID = data.areaInfo.is_initialized() ? data.areaInfo->groupId : 0;
m_wmoGroupID = data.areaInfo.has_value() ? data.areaInfo->groupId : 0;
}
void WorldObject::AddToWorld()
+1 -1
View File
@@ -444,7 +444,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
void setActive(bool isActiveObject);
bool IsFarVisible() const { return m_isFarVisible; }
void SetFarVisible(bool on);
bool IsVisibilityOverriden() const { return m_visibilityDistanceOverride.is_initialized(); }
bool IsVisibilityOverriden() const { return m_visibilityDistanceOverride.has_value(); }
void SetVisibilityDistanceOverride(VisibilityDistanceType type);
void SetWorldObject(bool apply);
bool IsPermanentWorldObject() const { return m_isWorldObject; }
+1 -1
View File
@@ -1618,7 +1618,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
transferPending.MapID = mapid;
if (Transport* transport = GetTransport())
{
transferPending.Ship = boost::in_place();
transferPending.Ship.emplace();
transferPending.Ship->ID = transport->GetEntry();
transferPending.Ship->OriginMapID = GetMapId();
}
+2 -2
View File
@@ -5173,7 +5173,7 @@ void Unit::SendAttackStateUpdate(CalcDamageInfo* damageInfo)
int32 overkill = damageInfo->damage - damageInfo->target->GetHealth();
packet.OverDamage = (overkill < 0 ? -1 : overkill);
packet.SubDmg = boost::in_place();
packet.SubDmg.emplace();
packet.SubDmg->SchoolMask = damageInfo->damageSchoolMask; // School of sub damage
packet.SubDmg->FDamage = damageInfo->damage; // sub damage
packet.SubDmg->Damage = damageInfo->damage; // Sub Damage
@@ -7688,7 +7688,7 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster, Optional<u
if (!spellInfo->Effects[i].IsEffect())
continue;
if (effectMask && !(effectMask.get() & (1 << i)))
if (effectMask && !(effectMask.value() & (1 << i)))
continue;
if (!IsImmunedToSpellEffect(spellInfo, i, caster))
+2 -3
View File
@@ -21,7 +21,6 @@
#include "Object.h"
#include "EventProcessor.h"
#include "CombatManager.h"
#include "OptionalFwd.h"
#include "SpellAuraDefines.h"
#include "SpellDefines.h"
#include "ThreatManager.h"
@@ -994,7 +993,7 @@ class TC_GAME_API Unit : public WorldObject
float MeleeSpellMissChance(Unit const* victim, WeaponAttackType attType, uint32 spellId) const;
SpellMissInfo MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo);
SpellMissInfo MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo);
SpellMissInfo SpellHitResult(Unit* victim, SpellInfo const* spellInfo, bool canReflect = false, Optional<uint8> effectMask = nullptr);
SpellMissInfo SpellHitResult(Unit* victim, SpellInfo const* spellInfo, bool canReflect = false, Optional<uint8> effectMask = {});
float GetUnitDodgeChance(WeaponAttackType attType, Unit const* victim) const;
float GetUnitParryChance(WeaponAttackType attType, Unit const* victim) const;
@@ -1548,7 +1547,7 @@ class TC_GAME_API Unit : public WorldObject
uint32 GetRemainingPeriodicAmount(ObjectGuid caster, uint32 spellId, AuraType auraType, uint8 effectIndex = 0) const;
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply);
virtual bool IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster, Optional<uint8> effectMask = nullptr) const; // redefined in Creature
virtual bool IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster, Optional<uint8> effectMask = {}) const; // redefined in Creature
uint32 GetSchoolImmunityMask() const;
uint32 GetMechanicImmunityMask() const;
+2 -2
View File
@@ -25,7 +25,7 @@ void WorldSession::SendAuthResponse(uint8 code, bool queued, uint32 queuePos)
if (code == AUTH_OK)
{
response.SuccessInfo = boost::in_place();
response.SuccessInfo.emplace();
response.SuccessInfo->AccountExpansionLevel = GetAccountExpansion();
response.SuccessInfo->ActiveExpansionLevel = GetExpansion();
@@ -33,7 +33,7 @@ void WorldSession::SendAuthResponse(uint8 code, bool queued, uint32 queuePos)
if (queued)
{
response.WaitInfo = boost::in_place();
response.WaitInfo.emplace();
response.WaitInfo->WaitCount = queuePos;
}
@@ -881,7 +881,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder const& holder)
bool europaTicketSystemEnabled = sWorld->getBoolConfig(CONFIG_ALLOW_BUG_REPORTS_AND_SUGGESTIONS);
if (europaTicketSystemEnabled)
{
features.EuropaTicketSystemStatus = boost::in_place();
features.EuropaTicketSystemStatus.emplace();
features.EuropaTicketSystemStatus->TryCount = 1;
features.EuropaTicketSystemStatus->LastResetTimeBeforeNow = 264134872; // Pulled from sniff data
features.EuropaTicketSystemStatus->PerMilliseconds = 10;
+2 -2
View File
@@ -2806,7 +2806,7 @@ void Map::GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, float x,
{
if (vmapData.areaInfo)
{
data.areaInfo = boost::in_place(vmapData.areaInfo->adtId, vmapData.areaInfo->rootId, vmapData.areaInfo->groupId, vmapData.areaInfo->mogpFlags);
data.areaInfo.emplace(vmapData.areaInfo->adtId, vmapData.areaInfo->rootId, vmapData.areaInfo->groupId, vmapData.areaInfo->mogpFlags);
// wmo found
WMOAreaTableEntry const* wmoEntry = sDBCManager.GetWMOAreaTableEntryByTripple(vmapData.areaInfo->rootId, vmapData.areaInfo->adtId, vmapData.areaInfo->groupId);
data.outdoors = (vmapData.areaInfo->mogpFlags & 0x8) != 0;
@@ -2867,7 +2867,7 @@ void Map::GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, float x,
}
}
data.liquidInfo = boost::in_place();
data.liquidInfo.emplace();
data.liquidInfo->level = vmapData.liquidInfo->level;
data.liquidInfo->depth_level = vmapData.floorZ;
data.liquidInfo->entry = liquidType;
+2 -2
View File
@@ -353,7 +353,7 @@ void MotionMaster::MoveLand(uint32 id, Position const& pos, Optional<float> velo
init.SetFly();
init.SetAnimation(AnimationTier::Ground);
if (velocity)
init.SetVelocity(velocity.get());
init.SetVelocity(velocity.value());
Mutate(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id), MOTION_SLOT_ACTIVE);
}
@@ -367,7 +367,7 @@ void MotionMaster::MoveTakeoff(uint32 id, Position const& pos, Optional<float> v
init.SetFly();
init.SetAnimation(AnimationTier::Hover);
if (velocity)
init.SetVelocity(velocity.get());
init.SetVelocity(velocity.value());
Mutate(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id), MOTION_SLOT_ACTIVE);
}
@@ -169,7 +169,7 @@ bool ChaseMovementGenerator::Update(Unit* owner, uint32 diff)
_nextMovementTimer.Reset(CHASE_MOVEMENT_INTERVAL);
// Target has moved since we last checked its position. Handle new cases
if (!_lastTargetPosition || target->GetPosition() != _lastTargetPosition.get())
if (!_lastTargetPosition || target->GetPosition() != _lastTargetPosition.value())
{
// Create new snapshot of our target's position
_lastTargetPosition = target->GetPosition();
@@ -34,13 +34,13 @@ inline bool CanMove(Creature const* creature)
CyclicMovementGenerator<Creature>::CyclicMovementGenerator(WaypointPath const* path, Optional<bool> enforceFlight, Optional<bool> enforceWalk, Optional<float> velocity) : _path(path), _stalled(false), _moveTimer(0)
{
if (enforceFlight.is_initialized())
if (enforceFlight.has_value())
_enforceFlight = *enforceFlight;
if (enforceWalk.is_initialized())
if (enforceWalk.has_value())
_enforceWalk = *enforceWalk;
if (velocity.is_initialized())
if (velocity.has_value())
_velocity = *velocity;
}
@@ -122,13 +122,13 @@ void CyclicMovementGenerator<Creature>::StartMovement(Creature* creature)
return G3D::Vector3(node.X, node.Y, node.Z);
});
if (flying || (_enforceFlight.is_initialized() && *_enforceFlight))
if (flying || (_enforceFlight.has_value() && *_enforceFlight))
{
init.SetFly();
init.SetUncompressed();
}
if (_velocity.is_initialized())
if (_velocity.has_value())
init.SetVelocity(*_velocity);
else
{
@@ -137,7 +137,7 @@ void CyclicMovementGenerator<Creature>::StartMovement(Creature* creature)
init.SetVelocity(velocity);
}
if (_enforceWalk.is_initialized())
if (_enforceWalk.has_value())
init.SetWalk(*_enforceWalk);
init.MovebyPath(path);
@@ -20,7 +20,7 @@
#include "MovementGenerator.h"
#include "Timer.h"
#include "OptionalFwd.h"
#include "Optional.h"
enum MovementGeneratorType : uint8;
@@ -158,8 +158,8 @@ static void GetFollowOffsets(uint8 followerIndex, float& distance, float& relati
FollowMovementGenerator::FollowMovementGenerator(Unit* target, Optional<float> distance, Optional<float> angle, bool joinFormation /*= true*/, bool catchUpToTarget /*= false*/, bool faceTarget /*= false*/) :
AbstractPursuer(PursuingType::Follow, ASSERT_NOTNULL(target)), _joinFormation(joinFormation), _catchUpToTarget(catchUpToTarget), _faceTarget(faceTarget)
{
_distance = distance ? distance.get() : 0.f;
_angle = angle ? angle.get() : 0.f;
_distance = distance ? distance.value() : 0.f;
_angle = angle ? angle.value() : 0.f;
}
FollowMovementGenerator::~FollowMovementGenerator() { }
@@ -215,7 +215,7 @@ void WaypointMovementGenerator<Creature>::StartMove(Creature* creature, bool rel
init.MoveTo(waypoint.X, waypoint.Y, waypoint.Z);
}
if (waypoint.Orientation.is_initialized() && waypoint.Delay > 0)
if (waypoint.Orientation.has_value() && waypoint.Delay > 0)
init.SetFacing(*waypoint.Orientation);
switch (waypoint.MoveType)
@@ -57,7 +57,7 @@ void WaypointMgr::Load()
waypoint.X = x;
waypoint.Y = y;
waypoint.Z = z;
if (o.is_initialized())
if (o.has_value())
waypoint.Orientation = o;
waypoint.Velocity = velocity;
waypoint.MoveType = fields[7].GetUInt32();
@@ -181,7 +181,7 @@ void WaypointMgr::ReloadPath(uint32 id)
waypoint.X = x;
waypoint.Y = y;
waypoint.Z = z;
if (o.is_initialized())
if (o.has_value())
waypoint.Orientation = o;
waypoint.Velocity = velocity;
waypoint.MoveType = fields[6].GetUInt32();
@@ -111,12 +111,12 @@ void WorldPackets::Auth::AuthSession::Read()
WorldPacket const* WorldPackets::Auth::AuthResponse::Write()
{
_worldPacket.WriteBit(WaitInfo.is_initialized());
_worldPacket.WriteBit(WaitInfo.has_value());
if (WaitInfo)
_worldPacket.WriteBit(WaitInfo->HasFCM);
_worldPacket.WriteBit(SuccessInfo.is_initialized());
_worldPacket.WriteBit(SuccessInfo.has_value());
_worldPacket.FlushBits();
if (SuccessInfo)
@@ -25,7 +25,7 @@ WorldPacket const* WorldPackets::CombatLog::AttackerStateUpdate::Write()
_worldPacket << VictimGUID.WriteAsPacked();
_worldPacket << int32(Damage);
_worldPacket << int32(OverDamage);
_worldPacket << uint8(SubDmg.is_initialized());
_worldPacket << uint8(SubDmg.has_value());
if (SubDmg)
{
@@ -24,10 +24,10 @@ WorldPacket const* WorldPackets::Misc::SetupCurrency::Write()
for (Record const& data : Data)
{
_worldPacket.WriteBit(data.WeeklyQuantity.is_initialized());
_worldPacket.WriteBit(data.WeeklyQuantity.has_value());
_worldPacket.WriteBits(data.Flags, 4);
_worldPacket.WriteBit(data.MaxWeeklyQuantity.is_initialized());
_worldPacket.WriteBit(data.TrackedQuantity.is_initialized());
_worldPacket.WriteBit(data.MaxWeeklyQuantity.has_value());
_worldPacket.WriteBit(data.TrackedQuantity.has_value());
}
_worldPacket.FlushBits();
@@ -36,14 +36,14 @@ WorldPacket const* WorldPackets::Misc::SetupCurrency::Write()
{
_worldPacket << uint32(data.Quantity);
if (data.MaxWeeklyQuantity.is_initialized())
if (data.MaxWeeklyQuantity.has_value())
_worldPacket << uint32(*data.MaxWeeklyQuantity);
if (data.TrackedQuantity.is_initialized())
if (data.TrackedQuantity.has_value())
_worldPacket << uint32(*data.TrackedQuantity);
_worldPacket << uint32(data.Type);
if (data.WeeklyQuantity.is_initialized())
if (data.WeeklyQuantity.has_value())
_worldPacket << uint32(*data.WeeklyQuantity);
}
@@ -351,9 +351,9 @@ WorldPacket const* WorldPackets::Misc::BindPointUpdate::Write()
WorldPacket const* WorldPackets::Misc::WorldServerInfo::Write()
{
_worldPacket.WriteBit(RestrictedAccountMaxLevel.is_initialized());
_worldPacket.WriteBit(RestrictedAccountMaxMoney.is_initialized());
_worldPacket.WriteBit(IneligibleForLootMask.is_initialized());
_worldPacket.WriteBit(RestrictedAccountMaxLevel.has_value());
_worldPacket.WriteBit(RestrictedAccountMaxMoney.has_value());
_worldPacket.WriteBit(IneligibleForLootMask.has_value());
_worldPacket.FlushBits();
if (IneligibleForLootMask)
@@ -24,8 +24,8 @@
WorldPacket const* WorldPackets::Movement::TransferPending::Write()
{
_worldPacket.WriteBit(TransferSpellID.is_initialized());
_worldPacket.WriteBit(Ship.is_initialized());
_worldPacket.WriteBit(TransferSpellID.has_value());
_worldPacket.WriteBit(Ship.has_value());
if (Ship)
{
_worldPacket << int32(Ship->OriginMapID);
@@ -137,19 +137,19 @@ WorldPacket const* WorldPackets::Movement::MoveTeleport::Write()
_worldPacket.WriteBit(MoverGUID[3]);
_worldPacket.WriteBit(MoverGUID[2]);
_worldPacket.WriteBit(Vehicle.is_initialized());
_worldPacket.WriteBit(Vehicle.has_value());
if (Vehicle)
{
_worldPacket.WriteBit(Vehicle->VehicleExitVoluntary);
_worldPacket.WriteBit(Vehicle->VehicleExitTeleport);
}
_worldPacket.WriteBit(TransportGUID.is_initialized());
_worldPacket.WriteBit(TransportGUID.has_value());
_worldPacket.WriteBit(MoverGUID[1]);
if (TransportGUID.is_initialized())
if (TransportGUID.has_value())
{
ObjectGuid transGUID = TransportGUID.get();
ObjectGuid transGUID = TransportGUID.value();
_worldPacket.WriteBit(transGUID[1]);
_worldPacket.WriteBit(transGUID[3]);
_worldPacket.WriteBit(transGUID[2]);
@@ -166,9 +166,9 @@ WorldPacket const* WorldPackets::Movement::MoveTeleport::Write()
_worldPacket.FlushBits();
if (TransportGUID.is_initialized())
if (TransportGUID.has_value())
{
ObjectGuid transGUID = TransportGUID.get();
ObjectGuid transGUID = TransportGUID.value();
_worldPacket.WriteByteSeq(transGUID[5]);
_worldPacket.WriteByteSeq(transGUID[6]);
_worldPacket.WriteByteSeq(transGUID[1]);
@@ -399,7 +399,7 @@ void WorldPackets::Movement::MonsterMove::InitializeSplineData(::Movement::MoveS
if (splineFlags.animation)
{
movementSpline.Animation = boost::in_place();
movementSpline.Animation.emplace();
movementSpline.Animation->AnimTier = splineFlags.animTier;
movementSpline.Animation->TierTransStartTime = moveSpline.effect_start_time;
}
@@ -408,7 +408,7 @@ void WorldPackets::Movement::MonsterMove::InitializeSplineData(::Movement::MoveS
if (splineFlags.parabolic)
{
movementSpline.JumpExtraData = boost::in_place();
movementSpline.JumpExtraData.emplace();
movementSpline.JumpExtraData->JumpGravity = moveSpline.vertical_acceleration;
movementSpline.JumpExtraData->StartTime = moveSpline.effect_start_time;
}
@@ -85,7 +85,7 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::NPC::VendorItem const& it
data << uint32(item.Price);
data << uint32(item.ItemDisplayInfoID);
if (item.PlayerConditionFailed.is_initialized())
if (item.PlayerConditionFailed.has_value())
data << int32(*item.PlayerConditionFailed);
data << int32(item.Quantity);
@@ -107,8 +107,8 @@ WorldPacket const* WorldPackets::NPC::VendorInventory::Write()
for (VendorItem const& item : Items)
{
_worldPacket.WriteBit(!item.ExtendedCostID.is_initialized());
_worldPacket.WriteBit(!item.PlayerConditionFailed.is_initialized());
_worldPacket.WriteBit(!item.ExtendedCostID.has_value());
_worldPacket.WriteBit(!item.PlayerConditionFailed.has_value());
}
_worldPacket.WriteBit(Vendor[4]);
@@ -145,7 +145,7 @@ void WorldPackets::Party::PartyMemberState::Initialize(Player const* player)
{
::Pet* pet = player->GetPet();
MemberStats.PetStats = boost::in_place();
MemberStats.PetStats.emplace();
MemberStats.PetStats->GUID = pet->GetGUID();
MemberStats.PetStats->Name = pet->GetName();
@@ -259,7 +259,7 @@ WorldPacket const* WorldPackets::Party::PartyMemberState::Write()
_worldPacket << aura;
}
if (MemberStats.PetStats.is_initialized())
if (MemberStats.PetStats.has_value())
{
if (ChangeMask & GROUP_UPDATE_FLAG_PET_GUID)
_worldPacket << MemberStats.PetStats->GUID;
@@ -290,10 +290,10 @@ WorldPacket const* WorldPackets::Party::PartyMemberState::Write()
if (ChangeMask & GROUP_UPDATE_FLAG_PET_AURAS)
{
_worldPacket << uint8(_worldPacket.GetOpcode() == SMSG_PARTY_MEMBER_FULL_STATE);
_worldPacket << uint64(MemberStats.PetStats.is_initialized() ? MemberStats.PetStats->AuraMask : 0);
_worldPacket << uint32(MemberStats.PetStats.is_initialized() ? MemberStats.PetStats->Auras.size() : 0);
_worldPacket << uint64(MemberStats.PetStats.has_value() ? MemberStats.PetStats->AuraMask : 0);
_worldPacket << uint32(MemberStats.PetStats.has_value() ? MemberStats.PetStats->Auras.size() : 0);
if (MemberStats.PetStats.is_initialized())
if (MemberStats.PetStats.has_value())
for (WorldPackets::Party::PartyMemberAuraStates const& aura : MemberStats.PetStats->Auras)
_worldPacket << aura;
}
+10 -10
View File
@@ -21,7 +21,7 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellHealPredicti
{
data << int32(predict.Points);
data << uint8(predict.Type);
if (predict.BeaconGUID.is_initialized())
if (predict.BeaconGUID.has_value())
data << predict.BeaconGUID->WriteAsPacked();
return data;
}
@@ -75,10 +75,10 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellTargetData c
{
data << uint32(spellTargetData.Flags);
if (spellTargetData.Unit.is_initialized())
if (spellTargetData.Unit.has_value())
data << spellTargetData.Unit->WriteAsPacked();
if (spellTargetData.Item.is_initialized())
if (spellTargetData.Item.has_value())
data << spellTargetData.Item->WriteAsPacked();
if (spellTargetData.SrcLocation)
@@ -87,7 +87,7 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellTargetData c
if (spellTargetData.DstLocation)
data << *spellTargetData.DstLocation;
if (spellTargetData.Name.is_initialized())
if (spellTargetData.Name.has_value())
data << *spellTargetData.Name;
return data;
@@ -125,7 +125,7 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellCastData con
data << spellCastData.Target;
if (spellCastData.RemainingPower.is_initialized())
if (spellCastData.RemainingPower.has_value())
data << uint32(*spellCastData.RemainingPower);
if (spellCastData.RemainingRunes)
@@ -140,7 +140,7 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellCastData con
if (spellCastData.ProjectileVisuals)
data << *spellCastData.ProjectileVisuals;
if (spellCastData.DestLocSpellCastIndex.is_initialized())
if (spellCastData.DestLocSpellCastIndex.has_value())
data << uint8(*spellCastData.DestLocSpellCastIndex);
// Todo: TARGET_FLAG_EXTRA_TARGETS (unused as it seems though)
@@ -188,11 +188,11 @@ WorldPacket const* WorldPackets::Spells::ChannelStart::Write()
_worldPacket << uint32(SpellID);
_worldPacket << int32(ChannelDuration);
_worldPacket << uint8(InterruptImmunities.is_initialized());
_worldPacket << uint8(InterruptImmunities.has_value());
if (InterruptImmunities)
_worldPacket << *InterruptImmunities;
_worldPacket << uint8(HealPrediction.is_initialized());
_worldPacket << uint8(HealPrediction.has_value());
if (HealPrediction)
_worldPacket << *HealPrediction;
@@ -217,7 +217,7 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::AuraDataInfo cons
data << uint8(auraData.Applications);
if (auraData.CastUnit)
data << auraData.CastUnit.get().WriteAsPacked();
data << auraData.CastUnit.value().WriteAsPacked();
if (auraData.Duration)
data << int32(*auraData.Duration);
@@ -226,7 +226,7 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::AuraDataInfo cons
data << int32(*auraData.Remaining);
for (uint8 i = 0; i < 3 /*MAX_SPELL_EFFECTS*/; ++i)
if (auraData.Points[i].is_initialized())
if (auraData.Points[i].has_value())
data << int32(*auraData.Points[i]);
return data;
@@ -28,8 +28,8 @@ WorldPacket const* WorldPackets::System::FeatureSystemStatus::Write()
_worldPacket.WriteBit(ItemRestorationButtonEnabled);
_worldPacket.WriteBit(TravelPassEnabled);
_worldPacket.WriteBit(ScrollOfResurrectionEnabled);
_worldPacket.WriteBit(EuropaTicketSystemStatus.is_initialized());
_worldPacket.WriteBit(SessionAlert.is_initialized());
_worldPacket.WriteBit(EuropaTicketSystemStatus.has_value());
_worldPacket.WriteBit(SessionAlert.has_value());
_worldPacket.WriteBit(VoiceEnabled);
_worldPacket.FlushBits();
+12 -12
View File
@@ -189,7 +189,7 @@ void SpellCastTargets::Write(WorldPackets::Spells::SpellTargetData& data)
if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION)
{
data.SrcLocation = boost::in_place();
data.SrcLocation.emplace();
data.SrcLocation->Transport = m_src._transportGUID; // relative position guid here - transport for example
if (!m_src._transportGUID.IsEmpty())
data.SrcLocation->Location = m_src._transportOffset;
@@ -199,7 +199,7 @@ void SpellCastTargets::Write(WorldPackets::Spells::SpellTargetData& data)
if (m_targetMask & TARGET_FLAG_DEST_LOCATION)
{
data.DstLocation = boost::in_place();
data.DstLocation.emplace();
data.DstLocation->Transport = m_dst._transportGUID; // relative position guid here - transport for example
if (!m_dst._transportGUID.IsEmpty())
data.DstLocation->Location = m_dst._transportOffset;
@@ -4325,7 +4325,7 @@ void Spell::SendSpellStart()
if (castFlags & CAST_FLAG_RUNE_LIST) // rune cooldowns list
{
castData.RemainingRunes = boost::in_place();
castData.RemainingRunes.emplace();
//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
@@ -4352,13 +4352,13 @@ void Spell::SendSpellStart()
if (castFlags & CAST_FLAG_PROJECTILE)
{
castData.Ammo = boost::in_place();
castData.Ammo.emplace();
UpdateSpellCastDataAmmo(*castData.Ammo);
}
if (castFlags & CAST_FLAG_IMMUNITY)
{
castData.Immunities = boost::in_place();
castData.Immunities.emplace();
castData.Immunities->School = schoolImmunityMask;
castData.Immunities->Value = mechanicImmunityMask;
}
@@ -4378,7 +4378,7 @@ void Spell::SendSpellStart()
}
}
castData.Predict = boost::in_place();
castData.Predict.emplace();
castData.Predict->Points = amount;
castData.Predict->Type = predictionType;
castData.Predict->BeaconGUID = m_caster->GetGUID();
@@ -4443,13 +4443,13 @@ void Spell::SendSpellGo()
castData.CastFlagsEx = m_castFlagsEx;
castData.CastTime = GameTime::GetGameTimeMS();
castData.HitInfo = boost::in_place();
castData.HitInfo.emplace();
UpdateSpellCastDataTargets(*castData.HitInfo);
m_targets.Write(castData.Target);
if (castFlags & CAST_FLAG_PROJECTILE)
{
castData.Ammo = boost::in_place();
castData.Ammo.emplace();
UpdateSpellCastDataAmmo(*castData.Ammo);
}
@@ -4458,7 +4458,7 @@ void Spell::SendSpellGo()
if (castFlags & CAST_FLAG_RUNE_LIST) // rune cooldowns list
{
castData.RemainingRunes = boost::in_place();
castData.RemainingRunes.emplace();
/// @todo There is a crash caused by a spell with CAST_FLAG_RUNE_LIST cast by a creature
//The creature is the mover of a player, so HandleCastSpellOpcode uses it as the caster
@@ -4484,14 +4484,14 @@ void Spell::SendSpellGo()
if (castFlags & CAST_FLAG_ADJUST_MISSILE)
{
castData.MissileTrajectory = boost::in_place();
castData.MissileTrajectory.emplace();
castData.MissileTrajectory->TravelTime = m_delayMoment;
castData.MissileTrajectory->Pitch = m_targets.GetElevation();
}
if (castFlags & CAST_FLAG_VISUAL_CHAIN)
{
castData.ProjectileVisuals = boost::in_place();
castData.ProjectileVisuals.emplace();
/*
castData.ProjectileVisuals->Id[0] = 0;
castData.ProjectileVisuals->Id[1] = 0;
@@ -4845,7 +4845,7 @@ void Spell::SendChannelStart(uint32 duration)
if (castFlags & CAST_FLAG_IMMUNITY)
{
packet.InterruptImmunities = boost::in_place();
packet.InterruptImmunities.emplace();
packet.InterruptImmunities->SchoolImmunities = schoolImmunityMask; // CastSchoolImmunities
packet.InterruptImmunities->SchoolImmunities = mechanicImmunityMask; // CastImmunities
}
+4 -4
View File
@@ -109,7 +109,7 @@ public:
return false;
}
switch (sAccountMgr->CreateAccount(accountName, password, email.get_value_or("")))
switch (sAccountMgr->CreateAccount(accountName, password, email.value_or("")))
{
case AccountOpResult::AOR_OK:
handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName);
@@ -118,7 +118,7 @@ public:
TC_LOG_INFO("entities.player.character", "Account: %d (IP: %s) Character:[%s] (GUID: %u) created Account %s (Email: '%s')",
handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().GetCounter(),
accountName.c_str(), email.get_value_or("").c_str());
accountName.c_str(), email.value_or("").c_str());
}
break;
case AccountOpResult::AOR_NAME_TOO_LONG:
@@ -385,7 +385,7 @@ public:
// This compares the old, current email to the entered email - however, only...
if ((pwConfig == PW_EMAIL || (pwConfig == PW_RBAC && handler->HasPermission(rbac::RBAC_PERM_EMAIL_CONFIRM_FOR_PASS_CHANGE))) // ...if either PW_EMAIL or PW_RBAC with the Permission is active...
&& !AccountMgr::CheckEmail(handler->GetSession()->GetAccountId(), confirmEmail.get_value_or(""))) // ... and returns false if the comparison fails.
&& !AccountMgr::CheckEmail(handler->GetSession()->GetAccountId(), confirmEmail.value_or(""))) // ... and returns false if the comparison fails.
{
handler->SendSysMessage(LANG_COMMAND_WRONGEMAIL);
sScriptMgr->OnFailedPasswordChange(handler->GetSession()->GetAccountId());
@@ -393,7 +393,7 @@ public:
TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change password, but the entered email [%s] is wrong.",
handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().GetCounter(),
confirmEmail.get_value_or("").c_str());
confirmEmail.value_or("").c_str());
return false;
}
+4 -4
View File
@@ -221,7 +221,7 @@ public:
{
Player* player = handler->GetSession()->GetPlayer();
uint32 mapId = oMapId.get_value_or(player->GetMapId());
uint32 mapId = oMapId.value_or(player->GetMapId());
// center of grid
float x = (gridX - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
@@ -355,7 +355,7 @@ public:
{
Player* player = handler->GetSession()->GetPlayer();
uint32 mapId = id.get_value_or(player->GetMapId());
uint32 mapId = id.value_or(player->GetMapId());
if (z)
{
if (!MapManager::IsValidMapCoord(mapId, x, y, *z))
@@ -377,7 +377,7 @@ public:
z = std::max(map->GetHeight(PhasingHandler::GetEmptyPhaseShift(), x, y, MAX_HEIGHT), map->GetWaterLevel(PhasingHandler::GetEmptyPhaseShift(), x, y));
}
return DoTeleport(handler, { x, y, *z, o.get_value_or(0.0f) }, mapId);
return DoTeleport(handler, { x, y, *z, o.value_or(0.0f) }, mapId);
}
static bool HandleGoTicketCommand(ChatHandler* handler, uint32 ticketId)
@@ -405,7 +405,7 @@ public:
static bool HandleGoOffsetCommand(ChatHandler* handler, float dX, Optional<float> dY, Optional<float> dZ, Optional<float> dO)
{
Position loc = handler->GetSession()->GetPlayer()->GetPosition();
loc.RelocateOffset({ dX, dY.get_value_or(0.0f), dZ.get_value_or(0.0f), dO.get_value_or(0.0f) });
loc.RelocateOffset({ dX, dY.value_or(0.0f), dZ.value_or(0.0f), dO.value_or(0.0f) });
return DoTeleport(handler, loc);
}
@@ -123,7 +123,7 @@ public:
void OnPlayerEnter(Player* player) override
{
if (!_teamInInstance.is_initialized())
if (!_teamInInstance.has_value())
{
_teamInInstance = player->GetTeam();