128{
129 if (!zoneId && !areaId)
130 {
131 if (z > -500)
132 {
133 LOG_ERROR(
"sql.sql",
"GetClosestGraveyard: unable to find zoneId and areaId for map {} coords ({}, {}, {})", mapId, x, y, z);
135 }
136 }
137
138
139
140
141
142
143
144
145
146
148
149
150 if (range.first == range.second)
151 {
153 }
154 else
155 {
157
159 {
160
162 }
163 }
164
166
167
169 {
170 LOG_ERROR(
"sql.sql",
"Table `graveyard_zone` incomplete: Zone {} Team {} does not have a linked graveyard.", zoneId, teamId);
172 }
173
174
175 bool foundNear = false;
176 float distNear = 10000;
178
179
180 bool foundEntr = false;
181 float distEntr = 10000;
183
184
186
188
189 for (; range.first != range.second; ++range.first)
190 {
193 if (!entry)
194 {
195 LOG_ERROR(
"sql.sql",
"Table `graveyard_zone` has record for not existing `game_graveyard` table {}, skipped.", graveyardLink.
safeLocId);
196 continue;
197 }
198
199
201 {
202 continue;
203 }
204
205
206 enum DeathKnightGraveyards
207 {
208 GRAVEYARD_EBON_HOLD = 1369,
209 GRAVEYARD_ARCHERUS = 1405
210 };
211
212 if (!isDeathKnight && (graveyardLink.
safeLocId == GRAVEYARD_EBON_HOLD || graveyardLink.
safeLocId == GRAVEYARD_ARCHERUS))
213 {
214 continue;
215 }
216
217
218 if (mapId != entry->
Map)
219 {
220
221 if (!mapEntry
225 {
226
227 entryFar = entry;
228 continue;
229 }
230
231
234 if (foundEntr)
235 {
236 if (dist2 < distEntr)
237 {
238 distEntr = dist2;
239 entryEntr = entry;
240 }
241 }
242 else
243 {
244 foundEntr = true;
245 distEntr = dist2;
246 entryEntr = entry;
247 }
248 }
249
250 else
251 {
252 float dist2 = (entry->
x - x) * (entry->
x - x) + (entry->
y - y) * (entry->
y - y) + (entry->
z - z) * (entry->
z - z);
253 if (foundNear)
254 {
255 if (dist2 < distNear)
256 {
257 distNear = dist2;
258 entryNear = entry;
259 }
260 }
261 else
262 {
263 foundNear = true;
264 distNear = dist2;
265 entryNear = entry;
266 }
267 }
268 }
269
270 if (entryNear)
271 return entryNear;
272
273 if (entryEntr)
274 return entryEntr;
275
276 return entryFar;
277}
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
GraveyardStruct const * GetDefaultGraveyard(TeamId teamId)
Definition GameGraveyard.cpp:86
bool IsNeutralOrFriendlyToTeam(TeamId playerTeamId) const
Definition GameGraveyard.h:42
Definition GameGraveyard.h:27
float z
Definition GameGraveyard.h:32
float x
Definition GameGraveyard.h:30
float y
Definition GameGraveyard.h:31
uint32 Map
Definition GameGraveyard.h:29
Definition DBCStructure.h:1361
float entrance_y
Definition DBCStructure.h:1378
int32 entrance_map
Definition DBCStructure.h:1376
bool IsBattlegroundOrArena() const
Definition DBCStructure.h:1393
float entrance_x
Definition DBCStructure.h:1377