TrinityCore
Loading...
Searching...
No Matches
Common.h File Reference
#include "Define.h"
#include <array>
#include <string>
#include <cstdlib>
+ Include dependency graph for Common.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  LocalizedString
 

Macros

#define atoll   _atoi64
 
#define llabs   _abs64
 
#define STRINGIZE(a)   #a
 
#define DEFAULT_LOCALE   LOCALE_enUS
 
#define M_PI   3.14159265358979323846
 
#define M_PI_4   0.785398163397448309616
 
#define MAX_QUERY_LEN   32*1024
 

Enumerations

enum  TimeConstants {
  MINUTE = 60 , HOUR = MINUTE*60 , DAY = HOUR*24 , WEEK = DAY*7 ,
  MONTH = DAY*30 , YEAR = MONTH*12 , IN_MILLISECONDS = 1000
}
 
enum  AccountTypes {
  SEC_PLAYER = 0 , SEC_MODERATOR = 1 , SEC_GAMEMASTER = 2 , SEC_ADMINISTRATOR = 3 ,
  SEC_CONSOLE = 4
}
 
enum  LocaleConstant : uint8 {
  LOCALE_enUS = 0 , LOCALE_koKR = 1 , LOCALE_frFR = 2 , LOCALE_deDE = 3 ,
  LOCALE_zhCN = 4 , LOCALE_zhTW = 5 , LOCALE_esES = 6 , LOCALE_esMX = 7 ,
  LOCALE_ruRU = 8 , LOCALE_none = 9 , LOCALE_ptBR = 10 , LOCALE_itIT = 11 ,
  TOTAL_LOCALES
}
 
enum class  CascLocaleBit : uint8 {
  None = 0 , enUS = 1 , koKR = 2 , Reserved = 3 ,
  frFR = 4 , deDE = 5 , zhCN = 6 , esES = 7 ,
  zhTW = 8 , enGB = 9 , enCN = 10 , enTW = 11 ,
  esMX = 12 , ruRU = 13 , ptBR = 14 , itIT = 15 ,
  ptPT = 16
}
 

Functions

unsigned long atoul (char const *str)
 
unsigned long long atoull (char const *str)
 
TC_COMMON_API LocaleConstant GetLocaleByName (std::string_view name)
 
constexpr bool IsValidLocale (LocaleConstant locale)
 

Variables

const uint8 OLD_TOTAL_LOCALES = 9
 
TC_COMMON_API char const * localeNames [TOTAL_LOCALES]
 
TC_COMMON_API CascLocaleBit WowLocaleToCascLocaleBit [TOTAL_LOCALES]
 

Macro Definition Documentation

◆ atoll

#define atoll   _atoi64

Definition at line 28 of file Common.h.

◆ DEFAULT_LOCALE

#define DEFAULT_LOCALE   LOCALE_enUS
Todo:
convert in simple system

Definition at line 82 of file Common.h.

◆ llabs

#define llabs   _abs64

Definition at line 29 of file Common.h.

◆ M_PI

#define M_PI   3.14159265358979323846

Definition at line 140 of file Common.h.

◆ M_PI_4

#define M_PI_4   0.785398163397448309616

Definition at line 144 of file Common.h.

◆ MAX_QUERY_LEN

#define MAX_QUERY_LEN   32*1024

Definition at line 147 of file Common.h.

◆ STRINGIZE

#define STRINGIZE (   a)    #a

Definition at line 41 of file Common.h.

Enumeration Type Documentation

◆ AccountTypes

Enumerator
SEC_PLAYER 
SEC_MODERATOR 
SEC_GAMEMASTER 
SEC_ADMINISTRATOR 
SEC_CONSOLE 

Definition at line 54 of file Common.h.

55{
56 SEC_PLAYER = 0,
57 SEC_MODERATOR = 1,
60 SEC_CONSOLE = 4 // must be always last in list, accounts must have less security level always also
61};
@ SEC_PLAYER
Definition: Common.h:56
@ SEC_ADMINISTRATOR
Definition: Common.h:59
@ SEC_GAMEMASTER
Definition: Common.h:58
@ SEC_MODERATOR
Definition: Common.h:57
@ SEC_CONSOLE
Definition: Common.h:60

◆ CascLocaleBit

enum class CascLocaleBit : uint8
strong
Enumerator
None 
enUS 
koKR 
Reserved 
frFR 
deDE 
zhCN 
esES 
zhTW 
enGB 
enCN 
enTW 
esMX 
ruRU 
ptBR 
itIT 
ptPT 

Definition at line 84 of file Common.h.

85{
86 None = 0,
87 enUS = 1,
88 koKR = 2,
89 Reserved = 3,
90 frFR = 4,
91 deDE = 5,
92 zhCN = 6,
93 esES = 7,
94 zhTW = 8,
95 enGB = 9,
96 enCN = 10,
97 enTW = 11,
98 esMX = 12,
99 ruRU = 13,
100 ptBR = 14,
101 itIT = 15,
102 ptPT = 16
103};

◆ LocaleConstant

Enumerator
LOCALE_enUS 
LOCALE_koKR 
LOCALE_frFR 
LOCALE_deDE 
LOCALE_zhCN 
LOCALE_zhTW 
LOCALE_esES 
LOCALE_esMX 
LOCALE_ruRU 
LOCALE_none 
LOCALE_ptBR 
LOCALE_itIT 
TOTAL_LOCALES 

Definition at line 63 of file Common.h.

64{
65 LOCALE_enUS = 0,
66 LOCALE_koKR = 1,
67 LOCALE_frFR = 2,
68 LOCALE_deDE = 3,
69 LOCALE_zhCN = 4,
70 LOCALE_zhTW = 5,
71 LOCALE_esES = 6,
72 LOCALE_esMX = 7,
73 LOCALE_ruRU = 8,
74 LOCALE_none = 9,
75 LOCALE_ptBR = 10,
76 LOCALE_itIT = 11,
77
79};
@ LOCALE_zhCN
Definition: Common.h:69
@ LOCALE_deDE
Definition: Common.h:68
@ LOCALE_zhTW
Definition: Common.h:70
@ LOCALE_ptBR
Definition: Common.h:75
@ LOCALE_itIT
Definition: Common.h:76
@ LOCALE_none
Definition: Common.h:74
@ LOCALE_esES
Definition: Common.h:71
@ TOTAL_LOCALES
Definition: Common.h:78
@ LOCALE_ruRU
Definition: Common.h:73
@ LOCALE_frFR
Definition: Common.h:67
@ LOCALE_enUS
Definition: Common.h:65
@ LOCALE_koKR
Definition: Common.h:66
@ LOCALE_esMX
Definition: Common.h:72

◆ TimeConstants

Enumerator
MINUTE 
HOUR 
DAY 
WEEK 
MONTH 
YEAR 
IN_MILLISECONDS 

Definition at line 43 of file Common.h.

44{
45 MINUTE = 60,
46 HOUR = MINUTE*60,
47 DAY = HOUR*24,
48 WEEK = DAY*7,
49 MONTH = DAY*30,
50 YEAR = MONTH*12,
51 IN_MILLISECONDS = 1000
52};
@ IN_MILLISECONDS
Definition: Common.h:51
@ MINUTE
Definition: Common.h:45
@ HOUR
Definition: Common.h:46
@ DAY
Definition: Common.h:47
@ MONTH
Definition: Common.h:49
@ WEEK
Definition: Common.h:48
@ YEAR
Definition: Common.h:50

Function Documentation

◆ atoul()

unsigned long atoul ( char const *  str)
inline

Definition at line 38 of file Common.h.

38{ return strtoul(str, nullptr, 10); }
+ Here is the caller graph for this function:

◆ atoull()

unsigned long long atoull ( char const *  str)
inline

Definition at line 39 of file Common.h.

39{ return strtoull(str, nullptr, 10); }
+ Here is the caller graph for this function:

◆ GetLocaleByName()

TC_COMMON_API LocaleConstant GetLocaleByName ( std::string_view  name)

Definition at line 36 of file Common.cpp.

37{
38 for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
39 if (name == localeNames[i])
40 return LocaleConstant(i);
41
42 return TOTAL_LOCALES;
43}
char const * localeNames[TOTAL_LOCALES]
Definition: Common.cpp:20
LocaleConstant
Definition: Common.h:64
uint32_t uint32
Definition: Define.h:143
+ Here is the caller graph for this function:

◆ IsValidLocale()

constexpr bool IsValidLocale ( LocaleConstant  locale)
inlineconstexpr

Definition at line 111 of file Common.h.

112{
113 return locale < TOTAL_LOCALES && locale != LOCALE_none;
114}
+ Here is the caller graph for this function:

Variable Documentation

◆ localeNames

TC_COMMON_API char const* localeNames[TOTAL_LOCALES]
extern

Definition at line 20 of file Common.cpp.

◆ OLD_TOTAL_LOCALES

const uint8 OLD_TOTAL_LOCALES = 9

Definition at line 81 of file Common.h.

◆ WowLocaleToCascLocaleBit

TC_COMMON_API CascLocaleBit WowLocaleToCascLocaleBit[TOTAL_LOCALES]
extern

Definition at line 45 of file Common.cpp.