TrinityCore
Loading...
Searching...
No Matches
ObjectGuidSequenceGenerator.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
19#include "Log.h"
20#include "World.h"
21
22namespace
23{
24void HandleCounterOverflow(HighGuid high)
25{
26 TC_LOG_ERROR("misc", "{} guid overflow!! Can't continue, shutting down server. ", ObjectGuid::GetTypeName(high));
28}
29
30void CheckGuidTrigger(ObjectGuid::LowType newCounter)
31{
32 World* world = sWorld;
33 if (!world->IsGuidAlert() && newCounter > world->getIntConfig(CONFIG_RESPAWN_GUIDALERTLEVEL))
34 world->TriggerGuidAlert();
35 else if (!world->IsGuidWarning() && newCounter > world->getIntConfig(CONFIG_RESPAWN_GUIDWARNLEVEL))
36 world->TriggerGuidWarning();
37}
38
39ObjectGuid::LowType CheckGeneratedGuidValue(HighGuid high, ObjectGuid::LowType newCounter)
40{
41 if (newCounter >= ObjectGuid::GetMaxCounter(high) - 1)
42 HandleCounterOverflow(high);
43
44 if (high == HighGuid::Creature || high == HighGuid::Vehicle || high == HighGuid::GameObject || high == HighGuid::Transport)
45 CheckGuidTrigger(newCounter);
46
47 return newCounter;
48}
49}
50
52{
53 return CheckGeneratedGuidValue(_high, _nextGuid++);
54}
#define TC_LOG_ERROR(filterType__, message__,...)
Definition Log.h:190
HighGuid
Definition ObjectGuid.h:109
std::atomic< ObjectGuid::LowType > _nextGuid
std::string_view GetTypeName() const
Definition ObjectGuid.h:396
LowType GetMaxCounter() const
Definition ObjectGuid.h:360
uint64 LowType
Definition ObjectGuid.h:321
The World.
Definition World.h:555
uint32 getIntConfig(WorldIntConfigs index) const
Get a server configuration element (see #WorldConfigs)
Definition World.h:712
void TriggerGuidAlert()
Definition World.cpp:289
void TriggerGuidWarning()
Definition World.cpp:270
bool IsGuidAlert()
Definition World.h:777
static void StopNow(uint8 exitcode)
Definition World.h:667
bool IsGuidWarning()
Definition World.h:776
#define sWorld
Definition World.h:916
@ CONFIG_RESPAWN_GUIDALERTLEVEL
Definition World.h:421
@ CONFIG_RESPAWN_GUIDWARNLEVEL
Definition World.h:420
@ ERROR_EXIT_CODE
Definition World.h:76