diff options
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/database/Database/QueryResultStructured.h | 14 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 38 | ||||
-rw-r--r-- | src/server/game/Movement/Waypoints/WaypointManager.cpp | 12 | ||||
-rw-r--r-- | src/server/game/Quests/QuestDef.cpp | 4 |
4 files changed, 35 insertions, 33 deletions
diff --git a/src/server/database/Database/QueryResultStructured.h b/src/server/database/Database/QueryResultStructured.h index 7995e879821..afd17edf5d6 100644 --- a/src/server/database/Database/QueryResultStructured.h +++ b/src/server/database/Database/QueryResultStructured.h @@ -20,6 +20,7 @@ #include <boost/preprocessor/cat.hpp> #include <boost/preprocessor/comma_if.hpp> +#include <boost/preprocessor/facilities/empty.hpp> #include <boost/preprocessor/seq/enum.hpp> #include <boost/preprocessor/seq/for_each.hpp> #include <boost/preprocessor/seq/for_each_i.hpp> @@ -29,11 +30,11 @@ #define DEFINE_FIELD_ACCESSOR_CACHE_FIELD(r, data, field) Field const& field() const\ {\ - return Result.Fetch()[indexes.field];\ + return Fields[indexes.field];\ } -#define DEFINE_FIELD_ACCESSOR_CACHE(struct_name, result_type, fields_list) \ - struct struct_name \ +#define DEFINE_FIELD_ACCESSOR_CACHE(namespace_name, struct_name, result_type, fields_list) \ + struct namespace_name struct_name \ { \ struct Indexes\ {\ @@ -42,11 +43,12 @@ std::size_t BOOST_PP_SEQ_ENUM(fields_list);\ };\ BOOST_PP_SEQ_FOR_EACH(DEFINE_FIELD_ACCESSOR_CACHE_FIELD, ~, fields_list) \ - result_type const& Result; \ + struct_name(result_type const& result) : Fields(result.Fetch()), indexes(indexes_impl(result)) { }\ + Field* Fields; \ static Indexes const& indexes_impl(result_type const& result) { static Indexes const instance(result); return instance; }\ - Indexes const& indexes = indexes_impl(Result);\ + Indexes const& indexes;\ } -#define DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(result_type, fields_list) DEFINE_FIELD_ACCESSOR_CACHE(BOOST_PP_CAT(FieldAccessors, __LINE__), result_type, fields_list) +#define DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(result_type, fields_list) DEFINE_FIELD_ACCESSOR_CACHE(BOOST_PP_EMPTY(), BOOST_PP_CAT(FieldAccessors, __LINE__), result_type, fields_list) #endif // TRINITYCORE_QUERY_RESULT_STRUCTURED_H diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 69c119e67db..d47d494a313 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -11128,11 +11128,11 @@ void ObjectMgr::LoadPlayerChoices() uint32 mawPowersCount = 0; { - DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(ResultSet, (ChoiceId)(UiTextureKitId)(SoundKitId)(CloseSoundKitId)(Duration)(Question)(PendingChoiceText) - (InfiniteRange)(HideWarboardHeader)(KeepOpenAfterChoice)(ShowChoicesAsList)(ForceDontShowChoicesAsList)(MaxResponses)(ScriptName)) fields { .Result = *choices }; - do { + DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(ResultSet, (ChoiceId)(UiTextureKitId)(SoundKitId)(CloseSoundKitId)(Duration)(Question)(PendingChoiceText) + (InfiniteRange)(HideWarboardHeader)(KeepOpenAfterChoice)(ShowChoicesAsList)(ForceDontShowChoicesAsList)(MaxResponses)(ScriptName)) fields { *choices }; + int32 choiceId = fields.ChoiceId().GetInt32(); PlayerChoice& choice = _playerChoices[choiceId]; @@ -11159,11 +11159,11 @@ void ObjectMgr::LoadPlayerChoices() "UiTextureAtlasElementID, SoundKitID, GroupID, UiTextureKitID, Answer, Header, SubHeader, ButtonTooltip, Description, Confirmation, RewardQuestID " "FROM playerchoice_response ORDER BY `Index` ASC")) { - DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(ResultSet, (ChoiceId)(ResponseId)(ChoiceArtFileId)(Flags)(WidgetSetID)(UiTextureAtlasElementID)(SoundKitID) - (GroupID)(UiTextureKitID)(Answer)(Header)(SubHeader)(ButtonTooltip)(Description)(Confirmation)(RewardQuestID)) fields{ .Result = *responses }; - do { + DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(ResultSet, (ChoiceId)(ResponseId)(ChoiceArtFileId)(Flags)(WidgetSetID)(UiTextureAtlasElementID)(SoundKitID) + (GroupID)(UiTextureKitID)(Answer)(Header)(SubHeader)(ButtonTooltip)(Description)(Confirmation)(RewardQuestID)) fields{ *responses }; + int32 choiceId = fields.ChoiceId().GetInt32(); int32 responseId = fields.ResponseId().GetInt32(); @@ -11200,11 +11200,11 @@ void ObjectMgr::LoadPlayerChoices() if (QueryResult rewards = WorldDatabase.Query("SELECT ChoiceId, ResponseId, TitleId, PackageId, SkillLineId, SkillPointCount, ArenaPointCount, HonorPointCount, Money, Xp FROM playerchoice_response_reward")) { - DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(ResultSet, (ChoiceId)(ResponseId)(TitleId)(PackageId)(SkillLineId) - (SkillPointCount)(ArenaPointCount)(HonorPointCount)(Money)(Xp)) fields{ .Result = *rewards }; - do { + DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(ResultSet, (ChoiceId)(ResponseId)(TitleId)(PackageId)(SkillLineId) + (SkillPointCount)(ArenaPointCount)(HonorPointCount)(Money)(Xp)) fields{ *rewards }; + int32 choiceId = fields.ChoiceId().GetInt32(); int32 responseId = fields.ResponseId().GetInt32(); @@ -11260,10 +11260,10 @@ void ObjectMgr::LoadPlayerChoices() if (QueryResult rewards = WorldDatabase.Query("SELECT ChoiceId, ResponseId, ItemId, BonusListIDs, Quantity FROM playerchoice_response_reward_item ORDER BY `Index` ASC")) { - DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(ResultSet, (ChoiceId)(ResponseId)(ItemId)(BonusListIDs)(Quantity)) fields { .Result = *rewards }; - do { + DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(ResultSet, (ChoiceId)(ResponseId)(ItemId)(BonusListIDs)(Quantity)) fields { *rewards }; + int32 choiceId = fields.ChoiceId().GetInt32(); int32 responseId = fields.ResponseId().GetInt32(); uint32 itemId = fields.ItemId().GetUInt32(); @@ -11309,10 +11309,10 @@ void ObjectMgr::LoadPlayerChoices() if (QueryResult rewards = WorldDatabase.Query("SELECT ChoiceId, ResponseId, CurrencyId, Quantity FROM playerchoice_response_reward_currency ORDER BY `Index` ASC")) { - DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(ResultSet, (ChoiceId)(ResponseId)(CurrencyId)(Quantity)) fields { .Result = *rewards }; - do { + DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(ResultSet, (ChoiceId)(ResponseId)(CurrencyId)(Quantity)) fields { *rewards }; + int32 choiceId = fields.ChoiceId().GetInt32(); int32 responseId = fields.ResponseId().GetInt32(); uint32 currencyId = fields.CurrencyId().GetUInt32(); @@ -11354,10 +11354,10 @@ void ObjectMgr::LoadPlayerChoices() if (QueryResult rewards = WorldDatabase.Query("SELECT ChoiceId, ResponseId, FactionId, Quantity FROM playerchoice_response_reward_faction ORDER BY `Index` ASC")) { - DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(ResultSet, (ChoiceId)(ResponseId)(FactionId)(Quantity)) fields { .Result = *rewards }; - do { + DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(ResultSet, (ChoiceId)(ResponseId)(FactionId)(Quantity)) fields { *rewards }; + int32 choiceId = fields.ChoiceId().GetInt32(); int32 responseId = fields.ResponseId().GetInt32(); uint32 factionId = fields.FactionId().GetUInt32(); @@ -11399,10 +11399,10 @@ void ObjectMgr::LoadPlayerChoices() if (QueryResult rewards = WorldDatabase.Query("SELECT ChoiceId, ResponseId, ItemId, BonusListIDs, Quantity FROM playerchoice_response_reward_item_choice ORDER BY `Index` ASC")) { - DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(ResultSet, (ChoiceId)(ResponseId)(ItemId)(BonusListIDs)(Quantity)) fields { .Result = *rewards }; - do { + DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(ResultSet, (ChoiceId)(ResponseId)(ItemId)(BonusListIDs)(Quantity)) fields { *rewards }; + int32 choiceId = fields.ChoiceId().GetInt32(); int32 responseId = fields.ResponseId().GetInt32(); uint32 itemId = fields.ItemId().GetUInt32(); @@ -11448,10 +11448,10 @@ void ObjectMgr::LoadPlayerChoices() if (QueryResult mawPowersResult = WorldDatabase.Query("SELECT ChoiceId, ResponseId, TypeArtFileID, Rarity, SpellID, MaxStacks FROM playerchoice_response_maw_power")) { - DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(ResultSet, (ChoiceId)(ResponseId)(TypeArtFileID)(Rarity)(SpellID)(MaxStacks)) fields { .Result = *mawPowersResult }; - do { + DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(ResultSet, (ChoiceId)(ResponseId)(TypeArtFileID)(Rarity)(SpellID)(MaxStacks)) fields { *mawPowersResult }; + int32 choiceId = fields.ChoiceId().GetInt32(); int32 responseId = fields.ResponseId().GetInt32(); diff --git a/src/server/game/Movement/Waypoints/WaypointManager.cpp b/src/server/game/Movement/Waypoints/WaypointManager.cpp index c1e8d4dde36..481fdc1a43d 100644 --- a/src/server/game/Movement/Waypoints/WaypointManager.cpp +++ b/src/server/game/Movement/Waypoints/WaypointManager.cpp @@ -26,8 +26,8 @@ #include "TemporarySummon.h" #include "Unit.h" -DEFINE_FIELD_ACCESSOR_CACHE(WaypointMgr::PathQueryResult, PreparedResultSet, (PathId)(MoveType)(Flags)(Velocity)); -DEFINE_FIELD_ACCESSOR_CACHE(WaypointMgr::PathNodeQueryResult, PreparedResultSet, (PathId)(NodeId)(PositionX)(PositionY)(PositionZ)(Orientation)(Delay)); +DEFINE_FIELD_ACCESSOR_CACHE(WaypointMgr::, PathQueryResult, PreparedResultSet, (PathId)(MoveType)(Flags)(Velocity)); +DEFINE_FIELD_ACCESSOR_CACHE(WaypointMgr::, PathNodeQueryResult, PreparedResultSet, (PathId)(NodeId)(PositionX)(PositionY)(PositionZ)(Orientation)(Delay)); WaypointMgr::WaypointMgr() = default; WaypointMgr::~WaypointMgr() = default; @@ -61,7 +61,7 @@ void WaypointMgr::_LoadPaths() do { - LoadPathFromDB({ .Result = *result }); + LoadPathFromDB(*result); ++count; } while (result->NextRow()); @@ -88,7 +88,7 @@ void WaypointMgr::_LoadPathNodes() do { - LoadPathNodesFromDB({ .Result = *result }); + LoadPathNodesFromDB(*result); ++count; } while (result->NextRow()); @@ -186,7 +186,7 @@ void WaypointMgr::ReloadPath(uint32 pathId) do { - LoadPathFromDB({ .Result = *result }); + LoadPathFromDB(*result); } while (result->NextRow()); } @@ -206,7 +206,7 @@ void WaypointMgr::ReloadPath(uint32 pathId) do { - LoadPathNodesFromDB({ .Result = *result }); + LoadPathNodesFromDB(*result); } while (result->NextRow()); if (WaypointPath* path = Trinity::Containers::MapGetValuePtr(_pathStore, pathId)) diff --git a/src/server/game/Quests/QuestDef.cpp b/src/server/game/Quests/QuestDef.cpp index 0b7b7a2e668..610212d40a6 100644 --- a/src/server/game/Quests/QuestDef.cpp +++ b/src/server/game/Quests/QuestDef.cpp @@ -48,9 +48,9 @@ (ManagedWorldStateID)(QuestSessionBonus)(LogTitle)(LogDescription)(QuestDescription)(AreaDescription)(PortraitGiverText)(PortraitGiverName)\ (PortraitTurnInText)(PortraitTurnInName)(QuestCompletionLog) -DEFINE_FIELD_ACCESSOR_CACHE(Quest::QuestTemplateQueryResult, ResultSet, QUEST_TEMPLATE_FIELDS); +DEFINE_FIELD_ACCESSOR_CACHE(Quest::, QuestTemplateQueryResult, ResultSet, QUEST_TEMPLATE_FIELDS); -Quest::Quest(QueryResult const& questRecord) : Quest(QuestTemplateQueryResult{ .Result = *questRecord }) +Quest::Quest(QueryResult const& questRecord) : Quest(*questRecord) { } |