TrinityCore
Loading...
Searching...
No Matches
Trinity Namespace Reference

Namespaces

namespace  Asio
 
namespace  Banner
 
namespace  ChatCommands
 
namespace  Containers
 
namespace  Crypto
 
namespace  Currency
 
namespace  Encoding
 
namespace  Honor
 
 
namespace  Impl
 
namespace  Legacy
 
namespace  Net
 
namespace  Predicates
 
namespace  SpellScripts
 
namespace  XP
 

Classes

class  AbsorbAuraOrderPred
 
struct  AIRelocationNotifier
 
class  AllCreaturesOfEntryInRange
 
class  AllFriendlyCreaturesInGrid
 
class  AllGameObjectsWithEntryInRange
 
class  AllWorldObjectsInRange
 
class  AnyAoETargetUnitInObjectRangeCheck
 
class  AnyAssistCreatureInRangeCheck
 
struct  AnyDeadUnitCheck
 
class  AnyDeadUnitObjectInRangeCheck
 
class  AnyDeadUnitSpellTargetInRangeCheck
 
class  AnyFriendlyUnitInObjectRangeCheck
 
class  AnyGroupedUnitInObjectRangeCheck
 
class  AnyPlayerInObjectRangeCheck
 
class  AnyPlayerInPositionRangeCheck
 
class  AnyUnfriendlyUnitInObjectRangeCheck
 
class  AnyUnitInObjectRangeCheck
 
class  AsyncProcessResult
 
class  AsyncProcessResultImplementation
 
class  BroadcastTextBuilder
 
class  CallOfHelpCreatureInRangeDo
 
class  ChatPacketSender
 
class  CheckedBufferOutputIterator
 
class  ContainerInserter
 
struct  CreatureLastSearcher
 
struct  CreatureListSearcher
 
struct  CreatureRelocationNotifier
 
struct  CreatureSearcher
 
class  CreatureTextTextBuilder
 
class  CreatureWithOptionsInObjectRangeCheck
 
struct  CreatureWorker
 
class  CustomChatTextBuilder
 
struct  DelayedUnitRelocation
 
struct  dependant_false
 
struct  find_type_if
 
struct  find_type_if< Check >
 
struct  find_type_if< Check, T1, Ts... >
 
class  FriendlyBelowHpPctEntryInRange
 
class  FriendlyCCedInRange
 
class  FriendlyMissingBuffInRange
 
class  GameObjectFocusCheck
 
class  GameObjectInRangeCheck
 
struct  GameObjectLastSearcher
 
struct  GameObjectListSearcher
 
struct  GameObjectSearcher
 
struct  GameObjectWorker
 
struct  GridUpdater
 
struct  has_type
 
struct  has_type< T, std::tuple< Us... > >
 
class  HealthPctOrderPred
 
class  HeightDifferenceCheck
 
struct  is_tuple
 
struct  is_tuple< std::tuple< Ts... > >
 
class  IteratorPair
 Utility class to enable range for loop syntax for multimap.equal_range uses. More...
 
class  LocalizedDo
 
struct  MessageDistDeliverer
 
struct  MessageDistDelivererToHostile
 
class  MostHPMissingInRange
 
class  MostHPPercentMissingInRange
 
class  NearestAssistCreatureInCreatureRangeCheck
 
class  NearestAttackableNoTotemUnitInObjectRangeCheck
 
class  NearestAttackableUnitInObjectRangeCheck
 
class  NearestCheckCustomizer
 
class  NearestCreatureEntryWithLiveStateInObjectRangeCheck
 
class  NearestGameObjectCheck
 
class  NearestGameObjectEntryInObjectRangeCheck
 
class  NearestGameObjectFishingHole
 
class  NearestGameObjectTypeInObjectRangeCheck
 
class  NearestHostileUnitCheck
 
class  NearestHostileUnitInAggroRangeCheck
 
class  NearestHostileUnitInAttackDistanceCheck
 
class  NearestPlayerInObjectRangeCheck
 
class  NearestUnspawnedGameObjectEntryInObjectRangeCheck
 
class  NoopCheckCustomizer
 
class  ObjectDistanceOrderPred
 
class  ObjectEntryAndPrivateOwnerIfExistsCheck
 
class  ObjectGUIDCheck
 
class  ObjectTypeIdCheck
 
struct  ObjectUpdater
 
struct  PacketSenderOwning
 
struct  PacketSenderRef
 
class  PlayerAtMinimumRangeAway
 
struct  PlayerDistWorker
 
struct  PlayerLastSearcher
 
struct  PlayerListSearcher
 
struct  PlayerRelocationNotifier
 
struct  PlayerSearcher
 
struct  PlayerWorker
 
class  PowerPctOrderPred
 
struct  RaceMask
 
class  RespawnDo
 
class  TCLogSink
 
class  ThreadPool
 
class  TrinityStringChatBuilder
 
class  UnitAuraCheck
 
struct  UnitLastSearcher
 
struct  UnitListSearcher
 
struct  UnitSearcher
 
struct  VisibleChangesNotifier
 
struct  VisibleNotifier
 
struct  WorldObjectLastSearcher
 
struct  WorldObjectListSearcher
 
struct  WorldObjectSearcher
 
struct  WorldObjectSpellAreaTargetCheck
 
struct  WorldObjectSpellConeTargetCheck
 
struct  WorldObjectSpellLineTargetCheck
 
struct  WorldObjectSpellNearbyTargetCheck
 
struct  WorldObjectSpellTargetCheck
 
struct  WorldObjectSpellTrajTargetCheck
 
struct  WorldObjectWorker
 
class  WorldWorldTextBuilder
 

Typedefs

using regex = TC_REGEX_NAMESPACE ::regex
 
using wregex = TC_REGEX_NAMESPACE ::wregex
 
template<typename... Args>
using FormatString = fmt::format_string< Args... >
 
template<template< typename... > typename Check, typename... Ts>
using find_type_if_t = typename find_type_if< Check, Ts... >::type
 

Functions

void Assert (char const *file, int line, char const *function, std::string debugInfo, char const *message)
 
void Assert (char const *file, int line, char const *function, std::string debugInfo, char const *message, char const *format,...)
 
void Fatal (char const *file, int line, char const *function, char const *message,...)
 
void Error (char const *file, int line, char const *function, char const *message)
 
void Warning (char const *file, int line, char const *function, char const *message)
 
void Abort (char const *file, int line, char const *function)
 
void Abort (char const *file, int line, char const *function, char const *message,...)
 
void AbortHandler (int sigval)
 
template<typename T >
void hash_combine (std::size_t &seed, T const &val)
 
template<typename T , typename Del >
auto make_unique_ptr_with_deleter (T ptr, Del &&deleter)
 
template<typename T >
auto MakeTCLogSink (T &&callback) -> TCLogSink< typename std::decay< T >::type >
 
template<typename T >
static int CreateChildProcess (T waiter, std::string const &executable, std::vector< std::string > const &argsVector, std::string const &logger, std::string const &input, bool secure)
 
int StartProcess (std::string const &executable, std::vector< std::string > const &args, std::string const &logger, std::string input_file, bool secure)
 
std::shared_ptr< AsyncProcessResultStartAsyncProcess (std::string executable, std::vector< std::string > args, std::string logger, std::string input_file, bool secure)
 
std::string SearchExecutableInPath (std::string const &filename)
 
template<typename Result , typename... Params>
Optional< Result > StringTo (std::string_view str, Params &&... params)
 
template<typename Type , typename... Params>
std::string ToString (Type &&val, Params &&... params)
 
template<typename... Args>
std::string StringFormat (FormatString< Args... > fmt, Args &&... args)
 Default TC string format function. More...
 
bool IsFormatEmptyOrNull (char const *fmt)
 Returns true if the given char pointer is null. More...
 
bool IsFormatEmptyOrNull (std::string const &fmt)
 Returns true if the given std::string is empty. More...
 
constexpr bool IsFormatEmptyOrNull (std::string_view fmt)
 Returns true if the given std::string_view is empty. More...
 
constexpr bool IsFormatEmptyOrNull (fmt::string_view fmt)
 
template<class T , class Tuple >
T * new_from_tuple (Tuple &&args)
 
TC_COMMON_API std::vector< std::string_view > Tokenize (std::string_view str, char sep, bool keepEmpty)
 
std::vector< std::string_view > Tokenize (std::string &&, char, bool)=delete
 
std::vector< std::string_view > Tokenize (std::string const &&, char, bool)=delete
 
std::vector< std::string_view > Tokenize (char const *str, char sep, bool keepEmpty)
 
template<typename T >
std::string GetTypeName ()
 
template<typename T >
std::string GetTypeName (T &&v)
 
template<class SPECIFIC_TYPE , class KEY_TYPE , class H , class T >
bool Insert (ContainerUnorderedMap< TypeList< H, T >, KEY_TYPE > &elements, KEY_TYPE const &handle, SPECIFIC_TYPE *obj)
 
template<class SPECIFIC_TYPE , class KEY_TYPE , class H , class T >
SPECIFIC_TYPE * Find (ContainerUnorderedMap< TypeList< H, T >, KEY_TYPE > const &elements, KEY_TYPE const &handle, SPECIFIC_TYPE *obj)
 
template<class SPECIFIC_TYPE , class KEY_TYPE , class H , class T >
bool Remove (ContainerUnorderedMap< TypeList< H, T >, KEY_TYPE > &elements, KEY_TYPE const &handle, SPECIFIC_TYPE *obj)
 
template<class SPECIFIC_TYPE , class KEY_TYPE , class H , class T >
bool Size (ContainerUnorderedMap< TypeList< H, T >, KEY_TYPE > const &elements, std::size_t *size, SPECIFIC_TYPE *obj)
 
template<class SPECIFIC_TYPE , class H , class T >
size_t Count (ContainerMapList< TypeList< H, T > > const &elements, SPECIFIC_TYPE *fake)
 
template<class SPECIFIC_TYPE , class H , class T >
SPECIFIC_TYPE * Insert (ContainerMapList< TypeList< H, T > > &elements, SPECIFIC_TYPE *obj)
 
template<class RET_TYPE , int CENTER_VAL>
RET_TYPE Compute (float x, float y, float center_offset, float size)
 
GridCoord ComputeGridCoord (float x, float y)
 
GridCoord ComputeGridCoordSimple (float x, float y)
 
CellCoord ComputeCellCoord (float x, float y)
 
CellCoord ComputeCellCoord (float x, float y, float &x_off, float &y_off)
 
void NormalizeMapCoord (float &c)
 
bool IsValidMapCoord (float c)
 
bool IsValidMapCoord (float x, float y)
 
bool IsValidMapCoord (float x, float y, float z)
 
bool IsValidMapCoord (float x, float y, float z, float o)
 
uint32 GetExpansionForLevel (uint32 level)
 
void SelectRandomInjuredTargets (std::list< WorldObject * > &targets, size_t maxTargets, bool prioritizePlayers)
 

Variables

template<typename T , typename... Us>
constexpr bool has_type_v = has_type<T, Us...>::value
 
template<typename... Ts>
constexpr bool is_tuple_v = is_tuple<Ts...>::value
 
template<typename T >
constexpr bool dependant_false_v = dependant_false<T>::value
 

Typedef Documentation

◆ find_type_if_t

template<template< typename... > typename Check, typename... Ts>
using Trinity::find_type_if_t = typedef typename find_type_if<Check, Ts...>::type

Definition at line 65 of file Types.h.

◆ FormatString

template<typename... Args>
using Trinity::FormatString = typedef fmt::format_string<Args...>

Definition at line 26 of file StringFormat.h.

◆ regex

Definition at line 28 of file Regex.h.

◆ wregex

Definition at line 29 of file Regex.h.

Function Documentation

◆ Abort() [1/2]

TC_COMMON_API void Trinity::Abort ( char const *  file,
int  line,
char const *  function 
)

Definition at line 124 of file Errors.cpp.

125{
126 std::string formattedMessage = StringFormat("\n{}:{} in {} ABORTED.\n", file, line, function);
127 fprintf(stderr, "%s", formattedMessage.c_str());
128 fflush(stderr);
129 Crash(formattedMessage.c_str());
130}
#define Crash(message)
Definition: Errors.cpp:39
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default TC string format function.
Definition: StringFormat.h:30
+ Here is the call graph for this function:

◆ Abort() [2/2]

TC_COMMON_API void Trinity::Abort ( char const *  file,
int  line,
char const *  function,
char const *  message,
  ... 
)

Definition at line 132 of file Errors.cpp.

133{
134 va_list args;
135 va_start(args, message);
136
137 std::string formattedMessage = StringFormat("\n{}:{} in {} ABORTED:\n", file, line, function) + FormatAssertionMessage(message, args) + '\n';
138 va_end(args);
139
140 fprintf(stderr, "%s", formattedMessage.c_str());
141 fflush(stderr);
142
143 Crash(formattedMessage.c_str());
144}
+ Here is the call graph for this function:

◆ AbortHandler()

TC_COMMON_API void Trinity::AbortHandler ( int  sigval)

Definition at line 146 of file Errors.cpp.

147{
148 // nothing useful to log here, no way to pass args
149 std::string formattedMessage = StringFormat("Caught signal {}\n", sigval);
150 fprintf(stderr, "%s", formattedMessage.c_str());
151 fflush(stderr);
152 Crash(formattedMessage.c_str());
153}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Assert() [1/2]

TC_COMMON_API void Trinity::Assert ( char const *  file,
int  line,
char const *  function,
std::string  debugInfo,
char const *  message 
)

Definition at line 73 of file Errors.cpp.

74{
75 std::string formattedMessage = StringFormat("\n{}:{} in {} ASSERTION FAILED:\n {}\n", file, line, function, message) + debugInfo + '\n';
76 fprintf(stderr, "%s", formattedMessage.c_str());
77 fflush(stderr);
78 Crash(formattedMessage.c_str());
79}
+ Here is the call graph for this function:

◆ Assert() [2/2]

TC_COMMON_API void Trinity::Assert ( char const *  file,
int  line,
char const *  function,
std::string  debugInfo,
char const *  message,
char const *  format,
  ... 
)

Definition at line 81 of file Errors.cpp.

82{
83 va_list args;
84 va_start(args, format);
85
86 std::string formattedMessage = StringFormat("\n{}:{} in {} ASSERTION FAILED:\n {}\n", file, line, function, message) + FormatAssertionMessage(format, args) + '\n' + debugInfo + '\n';
87 va_end(args);
88
89 fprintf(stderr, "%s", formattedMessage.c_str());
90 fflush(stderr);
91
92 Crash(formattedMessage.c_str());
93}
+ Here is the call graph for this function:

◆ Compute()

template<class RET_TYPE , int CENTER_VAL>
RET_TYPE Trinity::Compute ( float  x,
float  y,
float  center_offset,
float  size 
)
inline

Definition at line 193 of file GridDefines.h.

194 {
195 // calculate and store temporary values in double format for having same result as same mySQL calculations
196 double x_offset = (double(x) - center_offset)/size;
197 double y_offset = (double(y) - center_offset)/size;
198
199 int x_val = int(x_offset + CENTER_VAL + 0.5);
200 int y_val = int(y_offset + CENTER_VAL + 0.5);
201 return RET_TYPE(x_val, y_val);
202 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ComputeCellCoord() [1/2]

CellCoord Trinity::ComputeCellCoord ( float  x,
float  y 
)
inline

Definition at line 216 of file GridDefines.h.

217 {
218 return Compute<CellCoord, CENTER_GRID_CELL_ID>(x, y, CENTER_GRID_CELL_OFFSET, SIZE_OF_GRID_CELL);
219 }
#define CENTER_GRID_CELL_OFFSET
Definition: GridDefines.h:51
#define SIZE_OF_GRID_CELL
Definition: GridDefines.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ComputeCellCoord() [2/2]

CellCoord Trinity::ComputeCellCoord ( float  x,
float  y,
float &  x_off,
float &  y_off 
)
inline

Definition at line 221 of file GridDefines.h.

222 {
223 double x_offset = (double(x) - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL;
224 double y_offset = (double(y) - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL;
225
226 int x_val = int(x_offset + CENTER_GRID_CELL_ID + 0.5f);
227 int y_val = int(y_offset + CENTER_GRID_CELL_ID + 0.5f);
228 x_off = (float(x_offset) - float(x_val) + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL;
229 y_off = (float(y_offset) - float(y_val) + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL;
230 return CellCoord(x_val, y_val);
231 }
#define CENTER_GRID_CELL_ID
Definition: GridDefines.h:50
CoordPair< TOTAL_NUMBER_OF_CELLS_PER_MAP > CellCoord
Definition: GridDefines.h:188
+ Here is the call graph for this function:

◆ ComputeGridCoord()

GridCoord Trinity::ComputeGridCoord ( float  x,
float  y 
)
inline

Definition at line 204 of file GridDefines.h.

205 {
206 return Compute<GridCoord, CENTER_GRID_ID>(x, y, CENTER_GRID_OFFSET, SIZE_OF_GRIDS);
207 }
#define SIZE_OF_GRIDS
Definition: GridDefines.h:40
#define CENTER_GRID_OFFSET
Definition: GridDefines.h:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ComputeGridCoordSimple()

GridCoord Trinity::ComputeGridCoordSimple ( float  x,
float  y 
)
inline

Definition at line 209 of file GridDefines.h.

210 {
211 int gx = (int)(CENTER_GRID_ID - x / SIZE_OF_GRIDS);
212 int gy = (int)(CENTER_GRID_ID - y / SIZE_OF_GRIDS);
213 return GridCoord((MAX_NUMBER_OF_GRIDS - 1) - gx, (MAX_NUMBER_OF_GRIDS - 1) - gy);
214 }
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:187
#define MAX_NUMBER_OF_GRIDS
Definition: GridDefines.h:38
#define CENTER_GRID_ID
Definition: GridDefines.h:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Count()

template<class SPECIFIC_TYPE , class H , class T >
size_t Trinity::Count ( ContainerMapList< TypeList< H, T > > const &  elements,
SPECIFIC_TYPE *  fake 
)
inline

Definition at line 112 of file TypeContainerFunctions.h.

113 {
114 if constexpr (std::is_same_v<H, SPECIFIC_TYPE>)
115 {
116 return elements._elements._element.getSize();
117 }
118
119 if constexpr (std::is_same_v<T, TypeNull>)
120 return 0;
121 else
122 return Count(elements._TailElements, fake);
123 }
GridRefManager< OBJECT > _element
Definition: TypeContainer.h:39
+ Here is the caller graph for this function:

◆ CreateChildProcess()

template<typename T >
static int Trinity::CreateChildProcess ( waiter,
std::string const &  executable,
std::vector< std::string > const &  argsVector,
std::string const &  logger,
std::string const &  input,
bool  secure 
)
static

Definition at line 80 of file StartProcess.cpp.

84{
85 ipstream outStream;
86 ipstream errStream;
87
88 if (!secure)
89 {
90 TC_LOG_TRACE(logger, "Starting process \"{}\" with arguments: \"{}\".",
91 executable, boost::algorithm::join(argsVector, " "));
92 }
93
94 // prepare file with only read permission (boost process opens with read_write)
95 std::shared_ptr<FILE> inputFile(!input.empty() ? fopen(input.c_str(), "rb") : nullptr, [](FILE* ptr)
96 {
97 if (ptr != nullptr)
98 fclose(ptr);
99 });
100
101 // Start the child process
102 child c = [&]()
103 {
104 if (inputFile)
105 {
106 // With binding stdin
107 return child{
108 exe = boost::filesystem::absolute(executable).string(),
109 args = argsVector,
110 env = environment(boost::this_process::environment()),
111 std_in = inputFile.get(),
112 std_out = outStream,
113 std_err = errStream
114 };
115 }
116 else
117 {
118 // Without binding stdin
119 return child{
120 exe = boost::filesystem::absolute(executable).string(),
121 args = argsVector,
122 env = environment(boost::this_process::environment()),
123 std_in = boost::process::close,
124 std_out = outStream,
125 std_err = errStream
126 };
127 }
128 }();
129
130 auto outInfo = MakeTCLogSink([&](std::string_view msg)
131 {
132 TC_LOG_INFO(logger, "{}", msg);
133 });
134
135 auto outError = MakeTCLogSink([&](std::string_view msg)
136 {
137 TC_LOG_ERROR(logger, "{}", msg);
138 });
139
140 copy(outStream, outInfo);
141 copy(errStream, outError);
142
143 // Call the waiter in the current scope to prevent
144 // the streams from closing too early on leaving the scope.
145 int const result = waiter(c);
146
147 if (!secure)
148 {
149 TC_LOG_TRACE(logger, ">> Process \"{}\" finished with return value {}.",
150 executable, result);
151 }
152
153 return result;
154}
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:153
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:165
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:159
auto MakeTCLogSink(T &&callback) -> TCLogSink< typename std::decay< T >::type >
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Error()

TC_COMMON_API void TC_COMMON_API void TC_COMMON_API void Trinity::Error ( char const *  file,
int  line,
char const *  function,
char const *  message 
)

Definition at line 110 of file Errors.cpp.

111{
112 std::string formattedMessage = StringFormat("\n{}:{} in {} ERROR:\n {}\n", file, line, function, message);
113 fprintf(stderr, "%s", formattedMessage.c_str());
114 fflush(stderr);
115 Crash(formattedMessage.c_str());
116}
+ Here is the call graph for this function:

◆ Fatal()

TC_COMMON_API void TC_COMMON_API void Trinity::Fatal ( char const *  file,
int  line,
char const *  function,
char const *  message,
  ... 
)

Definition at line 95 of file Errors.cpp.

96{
97 va_list args;
98 va_start(args, message);
99
100 std::string formattedMessage = StringFormat("\n{}:{} in {} FATAL ERROR:\n", file, line, function) + FormatAssertionMessage(message, args) + '\n';
101 va_end(args);
102
103 fprintf(stderr, "%s", formattedMessage.c_str());
104 fflush(stderr);
105
106 std::this_thread::sleep_for(std::chrono::seconds(10));
107 Crash(formattedMessage.c_str());
108}
+ Here is the call graph for this function:

◆ Find()

template<class SPECIFIC_TYPE , class KEY_TYPE , class H , class T >
SPECIFIC_TYPE * Trinity::Find ( ContainerUnorderedMap< TypeList< H, T >, KEY_TYPE > const &  elements,
KEY_TYPE const &  handle,
SPECIFIC_TYPE *  obj 
)
inline

Definition at line 60 of file TypeContainerFunctions.h.

61 {
62 if constexpr (std::is_same_v<H, SPECIFIC_TYPE>)
63 {
64 auto i = elements._elements._element.find(handle);
65 if (i == elements._elements._element.end())
66 return nullptr;
67 else
68 return i->second;
69 }
70
71 if constexpr (std::is_same_v<T, TypeNull>)
72 return nullptr;
73 else
74 return Find(elements._TailElements, handle, obj);
75 }
std::unordered_map< KEY_TYPE, OBJECT * > _element
Definition: TypeContainer.h:57
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetExpansionForLevel()

uint32 Trinity::GetExpansionForLevel ( uint32  level)
inline

Definition at line 31 of file Formulas.h.

32 {
33 if (level < 60)
34 return EXPANSION_CLASSIC;
35 else if (level < 70)
37 else if (level < 80)
39 else if (level < 85)
41 else if (level < 90)
43 else if (level < 100)
45 else
46 return CURRENT_EXPANSION;
47 }
#define CURRENT_EXPANSION
Definition: SharedDefines.h:98
@ EXPANSION_WARLORDS_OF_DRAENOR
Definition: SharedDefines.h:88
@ EXPANSION_CLASSIC
Definition: SharedDefines.h:83
@ EXPANSION_THE_BURNING_CRUSADE
Definition: SharedDefines.h:84
@ EXPANSION_MISTS_OF_PANDARIA
Definition: SharedDefines.h:87
@ EXPANSION_CATACLYSM
Definition: SharedDefines.h:86
@ EXPANSION_WRATH_OF_THE_LICH_KING
Definition: SharedDefines.h:85
+ Here is the caller graph for this function:

◆ GetTypeName() [1/2]

template<typename T >
std::string Trinity::GetTypeName ( )

Definition at line 498 of file Util.h.

498{ return Impl::GetTypeName(typeid(T)); }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetTypeName() [2/2]

template<typename T >
std::string Trinity::GetTypeName ( T &&  v)

Definition at line 500 of file Util.h.

501{
502 if constexpr (std::is_same_v<std::remove_cv_t<T>, std::type_info>)
503 return Impl::GetTypeName(v);
504 else
505 return Impl::GetTypeName(typeid(v));
506}
+ Here is the call graph for this function:

◆ hash_combine()

template<typename T >
void Trinity::hash_combine ( std::size_t &  seed,
T const &  val 
)
inline

Definition at line 27 of file Hash.h.

28 {
29 seed ^= std::hash<T>()(val) + 0x9E3779B9 + (seed << 6) + (seed >> 2);
30 }
+ Here is the caller graph for this function:

◆ Insert() [1/2]

template<class SPECIFIC_TYPE , class H , class T >
SPECIFIC_TYPE * Trinity::Insert ( ContainerMapList< TypeList< H, T > > &  elements,
SPECIFIC_TYPE *  obj 
)
inline

Definition at line 127 of file TypeContainerFunctions.h.

128 {
129 if constexpr (std::is_same_v<H, SPECIFIC_TYPE>)
130 {
131 obj->AddToGrid(elements._elements._element);
132 return obj;
133 }
134
135 if constexpr (std::is_same_v<T, TypeNull>)
136 return nullptr;
137 else
138 return Insert(elements._TailElements, obj);
139 }
ContainerMapList< T > _TailElements
Definition: TypeContainer.h:51
+ Here is the call graph for this function:

◆ Insert() [2/2]

template<class SPECIFIC_TYPE , class KEY_TYPE , class H , class T >
bool Trinity::Insert ( ContainerUnorderedMap< TypeList< H, T >, KEY_TYPE > &  elements,
KEY_TYPE const &  handle,
SPECIFIC_TYPE *  obj 
)
inline

Definition at line 35 of file TypeContainerFunctions.h.

36 {
37 if constexpr (std::is_same_v<H, SPECIFIC_TYPE>)
38 {
39 auto i = elements._elements._element.find(handle);
40 if (i == elements._elements._element.end())
41 {
42 elements._elements._element[handle] = obj;
43 return true;
44 }
45 else
46 {
47 ASSERT(i->second == obj, "Object with certain key already in but objects are different!");
48 return false;
49 }
50 }
51
52 if constexpr (std::is_same_v<T, TypeNull>)
53 return false;
54 else
55 return Insert(elements._TailElements, handle, obj);
56 }
#define ASSERT
Definition: Errors.h:68
void Insert(Player *p)
ContainerUnorderedMap< T, KEY_TYPE > _TailElements
Definition: TypeContainer.h:69
ContainerUnorderedMap< H, KEY_TYPE > _elements
Definition: TypeContainer.h:68
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsFormatEmptyOrNull() [1/4]

bool Trinity::IsFormatEmptyOrNull ( char const *  fmt)
inline

Returns true if the given char pointer is null.

Definition at line 43 of file StringFormat.h.

44 {
45 return fmt == nullptr;
46 }
+ Here is the caller graph for this function:

◆ IsFormatEmptyOrNull() [2/4]

constexpr bool Trinity::IsFormatEmptyOrNull ( fmt::string_view  fmt)
inlineconstexpr

Definition at line 60 of file StringFormat.h.

61 {
62 return fmt.size() == 0;
63 }

◆ IsFormatEmptyOrNull() [3/4]

bool Trinity::IsFormatEmptyOrNull ( std::string const &  fmt)
inline

Returns true if the given std::string is empty.

Definition at line 49 of file StringFormat.h.

50 {
51 return fmt.empty();
52 }

◆ IsFormatEmptyOrNull() [4/4]

constexpr bool Trinity::IsFormatEmptyOrNull ( std::string_view  fmt)
inlineconstexpr

Returns true if the given std::string_view is empty.

Definition at line 55 of file StringFormat.h.

56 {
57 return fmt.empty();
58 }

◆ IsValidMapCoord() [1/4]

bool Trinity::IsValidMapCoord ( float  c)
inline

Definition at line 241 of file GridDefines.h.

242 {
243 return std::isfinite(c) && (std::fabs(c) <= MAP_HALFSIZE - 0.5f);
244 }
#define MAP_HALFSIZE
Definition: GridDefines.h:58
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsValidMapCoord() [2/4]

bool Trinity::IsValidMapCoord ( float  x,
float  y 
)
inline

Definition at line 246 of file GridDefines.h.

247 {
248 return IsValidMapCoord(x) && IsValidMapCoord(y);
249 }
bool IsValidMapCoord(float c)
Definition: GridDefines.h:241
+ Here is the call graph for this function:

◆ IsValidMapCoord() [3/4]

bool Trinity::IsValidMapCoord ( float  x,
float  y,
float  z 
)
inline

Definition at line 251 of file GridDefines.h.

252 {
253 return IsValidMapCoord(x, y) && IsValidMapCoord(z);
254 }
+ Here is the call graph for this function:

◆ IsValidMapCoord() [4/4]

bool Trinity::IsValidMapCoord ( float  x,
float  y,
float  z,
float  o 
)
inline

Definition at line 256 of file GridDefines.h.

257 {
258 return IsValidMapCoord(x, y, z) && std::isfinite(o);
259 }
+ Here is the call graph for this function:

◆ make_unique_ptr_with_deleter()

template<typename T , typename Del >
auto Trinity::make_unique_ptr_with_deleter ( ptr,
Del &&  deleter 
)

Definition at line 41 of file Memory.h.

42{
43 using Deleter_t = Impl::unique_ptr_deleter<T, Del>;
44
45 return std::unique_ptr<T, Deleter_t>(ptr, Deleter_t(std::forward<Del>(deleter)));
46}
+ Here is the caller graph for this function:

◆ MakeTCLogSink()

template<typename T >
auto Trinity::MakeTCLogSink ( T &&  callback) -> TCLogSink<typename std::decay<T>::type>

Definition at line 73 of file StartProcess.cpp.

75{
76 return { std::forward<T>(callback) };
77}
+ Here is the caller graph for this function:

◆ new_from_tuple()

template<class T , class Tuple >
T * Trinity::new_from_tuple ( Tuple &&  args)

Definition at line 59 of file Tuples.h.

60 {
61 return Impl::new_from_tuple<T>(std::forward<Tuple>(args), std::make_index_sequence<std::tuple_size_v<std::remove_reference_t<Tuple>>>{});
62 }

◆ NormalizeMapCoord()

void Trinity::NormalizeMapCoord ( float &  c)
inline

Definition at line 233 of file GridDefines.h.

234 {
235 if (c > MAP_HALFSIZE - 0.5f)
236 c = MAP_HALFSIZE - 0.5f;
237 else if (c < -(MAP_HALFSIZE - 0.5f))
238 c = -(MAP_HALFSIZE - 0.5f);
239 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Remove()

template<class SPECIFIC_TYPE , class KEY_TYPE , class H , class T >
bool Trinity::Remove ( ContainerUnorderedMap< TypeList< H, T >, KEY_TYPE > &  elements,
KEY_TYPE const &  handle,
SPECIFIC_TYPE *  obj 
)
inline

Definition at line 79 of file TypeContainerFunctions.h.

80 {
81 if constexpr (std::is_same_v<H, SPECIFIC_TYPE>)
82 {
83 elements._elements._element.erase(handle);
84 return true;
85 }
86
87 if constexpr (std::is_same_v<T, TypeNull>)
88 return false;
89 else
90 return Remove(elements._TailElements, handle, obj);
91 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SearchExecutableInPath()

TC_COMMON_API std::string Trinity::SearchExecutableInPath ( std::string const &  filename)

Searches for the given executable in the PATH variable and returns a non-empty string when it was found.

Definition at line 268 of file StartProcess.cpp.

269{
270 try
271 {
272 return search_path(filename).string();
273 }
274 catch (...)
275 {
276 return "";
277 }
278}
+ Here is the caller graph for this function:

◆ SelectRandomInjuredTargets()

TC_GAME_API void Trinity::SelectRandomInjuredTargets ( std::list< WorldObject * > &  targets,
size_t  maxTargets,
bool  prioritizePlayers 
)

Definition at line 9049 of file Spell.cpp.

9050{
9051 if (targets.size() <= maxTargets)
9052 return;
9053
9054 std::vector<WorldObject*> tempTargets(targets.begin(), targets.end());
9055
9056 auto begin = tempTargets.begin();
9057 auto end = tempTargets.end();
9058
9059 if (prioritizePlayers)
9060 {
9061 auto playersEnd = std::stable_partition(begin, end, [](WorldObject const* target)
9062 {
9063 return target->IsPlayer();
9064 });
9065
9066 size_t playerCount = std::distance(begin, playersEnd);
9067 if (playerCount < maxTargets)
9068 {
9069 // not enough players, add nonplayer targets
9070 // prioritize injured nonplayers over full health nonplayers
9071 auto injuredNonPlayersEnd = std::stable_partition(playersEnd, end, [](WorldObject const* target)
9072 {
9073 return target->IsUnit() && !target->ToUnit()->IsFullHealth();
9074 });
9075
9076 size_t injuredNonPlayersCount = std::distance(playersEnd, injuredNonPlayersEnd);
9077 if (playerCount + injuredNonPlayersCount < maxTargets)
9078 {
9079 // not enough players + injured nonplayers
9080 // fill remainder with random full health nonplayers
9081 Containers::RandomShuffle(injuredNonPlayersEnd, end);
9082 }
9083 else if (playerCount + injuredNonPlayersCount > maxTargets)
9084 {
9085 // randomize injured nonplayers order
9086 // final list will contain all players + random injured nonplayers
9087 Containers::RandomShuffle(playersEnd, injuredNonPlayersEnd);
9088 }
9089
9090 targets.assign(tempTargets.begin(), tempTargets.begin() + maxTargets);
9091 return;
9092 }
9093
9094 // We have more players than we requested, proceed checking injured targets
9095 end = playersEnd;
9096 }
9097
9098 auto injuredUnitsEnd = std::stable_partition(begin, end, [](WorldObject const* target)
9099 {
9100 return target->IsUnit() && !target->ToUnit()->IsFullHealth();
9101 });
9102
9103 size_t injuredUnitsCount = std::distance(begin, injuredUnitsEnd);
9104 if (injuredUnitsCount < maxTargets)
9105 {
9106 // not enough injured units
9107 // fill remainder with full health units
9108 Containers::RandomShuffle(injuredUnitsEnd, end);
9109 }
9110 else if (injuredUnitsCount > maxTargets)
9111 {
9112 // select random injured units
9113 Containers::RandomShuffle(begin, injuredUnitsEnd);
9114 }
9115
9116 targets.assign(tempTargets.begin(), tempTargets.begin() + maxTargets);
9117}
bool IsPlayer() const
Definition: Object.h:198
static Unit * ToUnit(Object *o)
Definition: Object.h:211
bool IsUnit() const
Definition: Object.h:210
bool IsFullHealth() const
Definition: Unit.h:895
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Size()

template<class SPECIFIC_TYPE , class KEY_TYPE , class H , class T >
bool Trinity::Size ( ContainerUnorderedMap< TypeList< H, T >, KEY_TYPE > const &  elements,
std::size_t *  size,
SPECIFIC_TYPE *  obj 
)
inline

Definition at line 95 of file TypeContainerFunctions.h.

96 {
97 if constexpr (std::is_same_v<H, SPECIFIC_TYPE>)
98 {
99 *size = elements._elements._element.size();
100 return true;
101 }
102
103 if constexpr (std::is_same_v<T, TypeNull>)
104 return false;
105 else
106 return Size(elements._TailElements, size, obj);
107 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StartAsyncProcess()

TC_COMMON_API std::shared_ptr< AsyncProcessResult > Trinity::StartAsyncProcess ( std::string  executable,
std::vector< std::string >  args,
std::string  logger,
std::string  input_file = "",
bool  secure = false 
)

Starts a process asynchronously with the given arguments and parameters and returns an AsyncProcessResult immediately which is set, when the process exits. When an input path is given, the file will be routed to the processes stdin. When the process is marked as secure no arguments are leaked to logs. Note that most executables expect it's name as the first argument.

Definition at line 258 of file StartProcess.cpp.

260{
261 auto handle = std::make_shared<AsyncProcessResultImplementation>(
262 std::move(executable), std::move(args), std::move(logger), std::move(input_file), secure);
263
264 handle->SetFuture(std::async(std::launch::async, [handle] { return handle->StartProcess(); }));
265 return handle;
266}

◆ StartProcess()

TC_COMMON_API int Trinity::StartProcess ( std::string const &  executable,
std::vector< std::string > const &  args,
std::string const &  logger,
std::string  input_file = "",
bool  secure = false 
)

Starts a process with the given arguments and parameters and will block until the process is finished. When an input path is given, the file will be routed to the processes stdin. When the process is marked as secure no arguments are leaked to logs. Note that most executables expect it's name as the first argument.

Definition at line 156 of file StartProcess.cpp.

158{
159 return CreateChildProcess([](child& c) -> int
160 {
161 try
162 {
163 c.wait();
164 return c.exit_code();
165 }
166 catch (...)
167 {
168 return EXIT_FAILURE;
169 }
170 }, executable, args, logger, input_file, secure);
171}
static int CreateChildProcess(T waiter, std::string const &executable, std::vector< std::string > const &argsVector, std::string const &logger, std::string const &input, bool secure)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StringFormat()

template<typename... Args>
std::string Trinity::StringFormat ( FormatString< Args... >  fmt,
Args &&...  args 
)
inline

Default TC string format function.

Definition at line 30 of file StringFormat.h.

31 {
32 try
33 {
34 return fmt::format(fmt, std::forward<Args>(args)...);
35 }
36 catch (std::exception const& formatError)
37 {
38 return fmt::format("An error occurred formatting string \"{}\" : {}", fmt, formatError.what());
39 }
40 }
+ Here is the caller graph for this function:

◆ StringTo()

template<typename Result , typename... Params>
Optional< Result > Trinity::StringTo ( std::string_view  str,
Params &&...  params 
)

Definition at line 263 of file StringConvert.h.

264 {
265 return Trinity::Impl::StringConvertImpl::For<Result>::FromString(str, std::forward<Params>(params)...);
266 }
std::unordered_set< uint32 > params[2]
Definition: DisableMgr.cpp:50
+ Here is the caller graph for this function:

◆ Tokenize() [1/4]

std::vector< std::string_view > Trinity::Tokenize ( char const *  str,
char  sep,
bool  keepEmpty 
)
inline

Definition at line 50 of file Util.h.

50{ return Tokenize(std::string_view(str ? str : ""), sep, keepEmpty); }
TC_COMMON_API std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
Definition: Util.cpp:40
+ Here is the call graph for this function:

◆ Tokenize() [2/4]

std::vector< std::string_view > Trinity::Tokenize ( std::string &&  ,
char  ,
bool   
)
delete

◆ Tokenize() [3/4]

std::vector< std::string_view > Trinity::Tokenize ( std::string const &&  ,
char  ,
bool   
)
delete

◆ Tokenize() [4/4]

std::vector< std::string_view > Trinity::Tokenize ( std::string_view  str,
char  sep,
bool  keepEmpty 
)

Definition at line 40 of file Util.cpp.

41{
42 std::vector<std::string_view> tokens;
43
44 size_t start = 0;
45 for (size_t end = str.find(sep); end != std::string_view::npos; end = str.find(sep, start))
46 {
47 if (keepEmpty || (start < end))
48 tokens.push_back(str.substr(start, end - start));
49 start = end+1;
50 }
51
52 if (keepEmpty || (start < str.length()))
53 tokens.push_back(str.substr(start));
54
55 return tokens;
56}
+ Here is the caller graph for this function:

◆ ToString()

template<typename Type , typename... Params>
std::string Trinity::ToString ( Type &&  val,
Params &&...  params 
)

Definition at line 269 of file StringConvert.h.

270 {
271 return Trinity::Impl::StringConvertImpl::For<std::decay_t<Type>>::ToString(std::forward<Type>(val), std::forward<Params>(params)...);
272 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Warning()

TC_COMMON_API void Trinity::Warning ( char const *  file,
int  line,
char const *  function,
char const *  message 
)

Definition at line 118 of file Errors.cpp.

119{
120 fprintf(stderr, "\n%s:%i in %s WARNING:\n %s\n",
121 file, line, function, message);
122}

Variable Documentation

◆ dependant_false_v

template<typename T >
constexpr bool Trinity::dependant_false_v = dependant_false<T>::value
constexpr

Definition at line 71 of file Types.h.

◆ has_type_v

template<typename T , typename... Us>
constexpr bool Trinity::has_type_v = has_type<T, Us...>::value
constexpr

Definition at line 34 of file Tuples.h.

◆ is_tuple_v

template<typename... Ts>
constexpr bool Trinity::is_tuple_v = is_tuple<Ts...>::value
constexpr

Definition at line 47 of file Tuples.h.