Core/Misc: Replace boost::optional with std::optional (#25047)

C++17 is already mandatory, so it's a safe thing to do
This commit is contained in:
Peter Keresztes Schmidt
2020-07-15 10:22:29 +02:00
committed by GitHub
parent ce1e2c0f9b
commit 202fd41389
16 changed files with 44 additions and 77 deletions

View File

@@ -256,7 +256,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);
@@ -265,7 +265,7 @@ public:
TC_LOG_INFO("entities.player.character", "Account: %d (IP: %s) Character:[%s] %s) created Account %s (Email: '%s')",
handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().ToString().c_str(),
accountName.c_str(), email.get_value_or("").c_str());
accountName.c_str(), email.value_or("").c_str());
}
break;
case AccountOpResult::AOR_NAME_TOO_LONG:
@@ -527,7 +527,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());
@@ -535,7 +535,7 @@ public:
TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] %s 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().ToString().c_str(),
confirmEmail.get_value_or("").c_str());
confirmEmail.value_or("").c_str());
return false;
}

View File

@@ -1917,7 +1917,7 @@ public:
auto mapId = args->TryConsume<uint32>();
if (mapId)
{
sMapMgr->DoForAllMapsWithMapId(mapId.get(),
sMapMgr->DoForAllMapsWithMapId(mapId.value(),
[handler](Map* map) -> void
{
HandleDebugGuidLimitsMap(handler, map);
@@ -1950,7 +1950,7 @@ public:
auto mapId = args->TryConsume<uint32>();
if (mapId)
{
sMapMgr->DoForAllMapsWithMapId(mapId.get(),
sMapMgr->DoForAllMapsWithMapId(mapId.value(),
[handler](Map* map) -> void
{
HandleDebugObjectCountMap(handler, map);

View File

@@ -214,7 +214,7 @@ public:
static bool HandleGoGridCommand(ChatHandler* handler, float gridX, float gridY, Optional<uint32> oMapId)
{
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;
@@ -337,7 +337,7 @@ public:
static bool HandleGoXYZCommand(ChatHandler* handler, float x, float y, Optional<float> z, Optional<uint32> id, Optional<float> o)
{
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))
@@ -359,7 +359,7 @@ public:
z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(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)
@@ -386,7 +386,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);
}