83{
86
87
88 QueryResult result =
WorldDatabase.Query(
"SELECT leaderGUID, memberGUID, dist, angle, groupAI, point_1, point_2 FROM creature_formations ORDER BY leaderGUID");
89 if (!result)
90 {
91 LOG_WARN(
"server.loading",
">> Loaded 0 creatures in formations. DB table `creature_formations` is empty!");
93 return;
94 }
95
97 do
98 {
99 Field const* fields = result->Fetch();
100
101
105 float const follow_dist = fields[2].
Get<
float>();
106 float const follow_angle = fields[3].
Get<
float>() * (
static_cast<float>(M_PI) / 180);
110
111
113 {
114 if (!group_member.
HasGroupFlag(std::underlying_type_t<GroupAIFlags>(GroupAIFlags::GROUP_AI_FLAG_SUPPORTED)))
115 {
116 LOG_ERROR(
"sql.sql",
"creature_formations table leader guid {} and member guid {} has unsupported GroupAI flag value ({}). Skipped", group_member.
leaderGUID, memberGUID, group_member.
groupAI);
117 continue;
118 }
119
120 if (!group_member.
HasGroupFlag(std::underlying_type_t<GroupAIFlags>(GroupAIFlags::GROUP_AI_FLAG_FOLLOW_LEADER)) && (follow_dist > 0.0f || follow_angle > 0.0f))
121 {
122 LOG_ERROR(
"sql.sql",
"creature_formations table member guid {} and leader guid {} cannot have follow distance or follow angle because don't have GROUP_AI_FLAG_FOLLOW_LEADER flag. Values are not gonna be used", memberGUID, group_member.
leaderGUID);
125 }
126 else
127 {
130 }
131 }
132 else
133 {
134
135 if (group_member.
groupAI && !group_member.
HasGroupFlag(std::underlying_type_t<GroupAIFlags>(GroupAIFlags::GROUP_AI_FLAG_SUPPORTED)))
136 {
137 LOG_ERROR(
"sql.sql",
"creature_formations table leader guid {} and member guid {} has unsupported GroupAI flag value ({}). Skipped", group_member.
leaderGUID, memberGUID, group_member.
groupAI);
138 continue;
139 }
140
143 if (follow_dist > 0.0f || follow_angle > 0.0f)
144 {
145 LOG_ERROR(
"sql.sql",
"creature_formations table member guid {} and leader guid {} cannot have follow distance or follow angle. Values are not gonna be used", memberGUID, group_member.
leaderGUID);
146 }
147 }
148
150 {
151 LOG_ERROR(
"sql.sql",
"creature_formations table leader guid {} incorrect (does not exist). Skipped", group_member.
leaderGUID);
152 continue;
153 }
154
156 {
157 LOG_ERROR(
"sql.sql",
"creature_formations table member guid {} incorrect (does not exist). Skipped", memberGUID);
158 continue;
159 }
160
162 ++count;
163 } while (result->NextRow());
164
167}
#define LOG_INFO(filterType__,...)
Definition: Log.h:165
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
#define LOG_WARN(filterType__,...)
Definition: Log.h:161
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:131
uint32 getMSTime()
Definition: Timer.h:103
std::uint32_t uint32
Definition: Define.h:107
std::uint16_t uint16
Definition: Define.h:108
#define sObjectMgr
Definition: ObjectMgr.h:1635
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:27
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Class used to access individual fields of database query result.
Definition: Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:112
Definition: CreatureGroups.h:52
float follow_dist
Definition: CreatureGroups.h:64
uint32 point_1
Definition: CreatureGroups.h:67
float follow_angle
Definition: CreatureGroups.h:65
uint32 point_2
Definition: CreatureGroups.h:68
ObjectGuid::LowType leaderGUID
Definition: CreatureGroups.h:63
uint16 groupAI
Definition: CreatureGroups.h:66
bool HasGroupFlag(uint16 flag) const
Definition: CreatureGroups.h:70
CreatureGroupInfoType CreatureGroupMap
Definition: CreatureGroups.h:86
uint32 LowType
Definition: ObjectGuid.h:122