mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Use boost::optional and boost::none instead of smelly pointer (#24134)
* Remove bad pointer usage from CharacterCache
Use TrinityCore Option type instead which is intended for this purpose. (Wrapper around boost::option until C++17 bump is finalised)
* Unify codestyle regarding TC optional type
Based upon advice from @Shauren
(cherry picked from commit 76831f1f46)
This commit is contained in:
@@ -117,7 +117,7 @@ void CharacterCache::DeleteCharacterCacheEntry(ObjectGuid const& guid, std::stri
|
||||
_characterCacheByNameStore.erase(name);
|
||||
}
|
||||
|
||||
void CharacterCache::UpdateCharacterData(ObjectGuid const& guid, std::string const& name, uint8* gender /*= nullptr*/, uint8* race /*= nullptr*/)
|
||||
void CharacterCache::UpdateCharacterData(ObjectGuid const& guid, std::string const& name, Optional<uint8> gender /*= {}*/, Optional<uint8> race /*= {}*/)
|
||||
{
|
||||
auto itr = _characterCacheStore.find(guid);
|
||||
if (itr == _characterCacheStore.end())
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "Define.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "Optional.h"
|
||||
#include <string>
|
||||
|
||||
struct CharacterCacheEntry
|
||||
@@ -47,7 +48,7 @@ class TC_GAME_API CharacterCache
|
||||
void AddCharacterCacheEntry(ObjectGuid const& guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level, bool isDeleted);
|
||||
void DeleteCharacterCacheEntry(ObjectGuid const& guid, std::string const& name);
|
||||
|
||||
void UpdateCharacterData(ObjectGuid const& guid, std::string const& name, uint8* gender = nullptr, uint8* race = nullptr);
|
||||
void UpdateCharacterData(ObjectGuid const& guid, std::string const& name, Optional<uint8> gender = {}, Optional<uint8> race = {});
|
||||
void UpdateCharacterGender(ObjectGuid const& guid, uint8 gender);
|
||||
void UpdateCharacterLevel(ObjectGuid const& guid, uint8 level);
|
||||
void UpdateCharacterAccountId(ObjectGuid const& guid, uint32 accountId);
|
||||
|
||||
@@ -815,7 +815,7 @@ void Garrison::Plot::ClearBuildingInfo(GarrisonType garrisonType, Player* owner)
|
||||
plotPlaced.PlotInfo = &PacketInfo;
|
||||
owner->SendDirectMessage(plotPlaced.Write());
|
||||
|
||||
BuildingInfo.PacketInfo = boost::none;
|
||||
BuildingInfo.PacketInfo.reset();
|
||||
}
|
||||
|
||||
void Garrison::Plot::SetBuildingInfo(WorldPackets::Garrison::GarrisonBuildingInfo const& buildingInfo, Player* owner)
|
||||
|
||||
@@ -1842,7 +1842,7 @@ void WorldSession::HandleCharCustomizeCallback(std::shared_ptr<WorldPackets::Cha
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
sCharacterCache->UpdateCharacterData(customizeInfo->CharGUID, customizeInfo->CharName, &customizeInfo->SexID);
|
||||
sCharacterCache->UpdateCharacterData(customizeInfo->CharGUID, customizeInfo->CharName, customizeInfo->SexID);
|
||||
|
||||
SendCharCustomize(RESPONSE_SUCCESS, customizeInfo.get());
|
||||
|
||||
@@ -2167,7 +2167,7 @@ void WorldSession::HandleCharRaceOrFactionChangeCallback(std::shared_ptr<WorldPa
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
sCharacterCache->UpdateCharacterData(factionChangeInfo->Guid, factionChangeInfo->Name, &factionChangeInfo->SexID, &factionChangeInfo->RaceID);
|
||||
sCharacterCache->UpdateCharacterData(factionChangeInfo->Guid, factionChangeInfo->Name, factionChangeInfo->SexID, factionChangeInfo->RaceID);
|
||||
|
||||
if (oldRace != factionChangeInfo->RaceID)
|
||||
{
|
||||
|
||||
@@ -278,7 +278,7 @@ Optional<std::shared_ptr<ScriptModule>>
|
||||
path.generic_string().c_str());
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
return {};
|
||||
}
|
||||
|
||||
// Use RAII to release the library on failure.
|
||||
@@ -305,7 +305,7 @@ Optional<std::shared_ptr<ScriptModule>>
|
||||
TC_LOG_ERROR("scripts.hotswap", "Could not extract all required functions from the shared library \"%s\"!",
|
||||
path.generic_string().c_str());
|
||||
|
||||
return boost::none;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2148,8 +2148,6 @@ void Spell::EffectDispel()
|
||||
WorldPackets::CombatLog::SpellDispellData dispellData;
|
||||
dispellData.SpellID = dispelableAura.GetAura()->GetId();
|
||||
dispellData.Harmful = false; // TODO: use me
|
||||
dispellData.Rolled = boost::none; // TODO: use me
|
||||
dispellData.Needed = boost::none; // TODO: use me
|
||||
|
||||
unitTarget->RemoveAurasDueToSpellByDispel(dispelableAura.GetAura()->GetId(), m_spellInfo->Id, dispelableAura.GetAura()->GetCasterGUID(), m_caster, dispelableAura.GetDispelCharges());
|
||||
|
||||
@@ -4568,8 +4566,6 @@ void Spell::EffectStealBeneficialBuff()
|
||||
WorldPackets::CombatLog::SpellDispellData dispellData;
|
||||
dispellData.SpellID = dispell.first;
|
||||
dispellData.Harmful = false; // TODO: use me
|
||||
dispellData.Rolled = boost::none; // TODO: use me
|
||||
dispellData.Needed = boost::none; // TODO: use me
|
||||
|
||||
unitTarget->RemoveAurasDueToSpellBySteal(dispell.first, dispell.second, m_caster);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user