98{
99 uint32 graveyardOverride = 0;
100 sScriptMgr->OnPlayerBeforeChooseGraveyard(player, teamId, nearCorpse, graveyardOverride);
101 if (graveyardOverride)
102 {
103 return sGraveyard->GetGraveyard(graveyardOverride);
104 }
105
107
108 if (nearCorpse)
109 {
111 }
112
117
121
122 if (!zoneId && !areaId)
123 {
124 if (z > -500)
125 {
126 LOG_ERROR(
"sql.sql",
"GetClosestGraveyard: unable to find zoneId and areaId for map {} coords ({}, {}, {})", mapId, x, y, z);
128 }
129 }
130
131
132
133
134
135
136
137
138
139
141
142
143 if (range.first == range.second)
144 {
146 }
147 else
148 {
150
152 {
153
155 }
156 }
157
159
160
162 {
163 LOG_ERROR(
"sql.sql",
"Table `graveyard_zone` incomplete: Zone {} Team {} does not have a linked graveyard.", zoneId, teamId);
165 }
166
167
168 bool foundNear = false;
169 float distNear = 10000;
171
172
173 bool foundEntr = false;
174 float distEntr = 10000;
176
177
179
181
182 for (; range.first != range.second; ++range.first)
183 {
186 if (!entry)
187 {
188 LOG_ERROR(
"sql.sql",
"Table `graveyard_zone` has record for not existing `game_graveyard` table {}, skipped.", graveyardLink.
safeLocId);
189 continue;
190 }
191
192
194 {
195 continue;
196 }
197
198
199 enum DeathKnightGraveyards
200 {
201 GRAVEYARD_EBON_HOLD = 1369,
202 GRAVEYARD_ARCHERUS = 1405
203 };
204
206 {
207 continue;
208 }
209
210
211 if (mapId != entry->
Map)
212 {
213
214 if (!mapEntry
218 {
219
220 entryFar = entry;
221 continue;
222 }
223
224
227 if (foundEntr)
228 {
229 if (dist2 < distEntr)
230 {
231 distEntr = dist2;
232 entryEntr = entry;
233 }
234 }
235 else
236 {
237 foundEntr = true;
238 distEntr = dist2;
239 entryEntr = entry;
240 }
241 }
242
243 else
244 {
245 float dist2 = (entry->
x - x) * (entry->
x - x) + (entry->
y - y) * (entry->
y - y) + (entry->
z - z) * (entry->
z - z);
246 if (foundNear)
247 {
248 if (dist2 < distNear)
249 {
250 distNear = dist2;
251 entryNear = entry;
252 }
253 }
254 else
255 {
256 foundNear = true;
257 distNear = dist2;
258 entryNear = entry;
259 }
260 }
261 }
262
263 if (entryNear)
264 return entryNear;
265
266 if (entryEntr)
267 return entryEntr;
268
269 return entryFar;
270}
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
std::uint32_t uint32
Definition Define.h:107
#define sGraveyard
Definition GameGraveyard.h:74
#define LOG_ERROR(filterType__,...)
Definition Log.h:157
#define sScriptMgr
Definition ScriptMgr.h:727
@ CLASS_DEATH_KNIGHT
Definition SharedDefines.h:146
@ CLASS_CONTEXT_GRAVEYARD
Definition UnitDefines.h:242
GraveyardStruct const * GetDefaultGraveyard(TeamId teamId)
Definition GameGraveyard.cpp:86
WorldLocation GetCorpseLocation() const
Definition Player.h:2046
bool IsClass(Classes playerClass, ClassContext context=CLASS_CONTEXT_NONE) const override
Definition Player.cpp:1288
Definition Position.h:255
uint32 GetMapId() const
Definition Position.h:280
void GetWorldLocation(uint32 &mapId, float &x, float &y) const
Definition Position.h:285
void GetZoneAndAreaId(uint32 &zoneid, uint32 &areaid) const
Definition Object.cpp:3164
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:1324
float entrance_y
Definition DBCStructure.h:1341
int32 entrance_map
Definition DBCStructure.h:1339
bool IsBattlegroundOrArena() const
Definition DBCStructure.h:1356
float entrance_x
Definition DBCStructure.h:1340
float GetPositionZ() const
Definition Position.h:123
float GetPositionX() const
Definition Position.h:121
float GetPositionY() const
Definition Position.h:122