TrinityCore
Common.h
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
18#ifndef TRINITYCORE_COMMON_H
19#define TRINITYCORE_COMMON_H
20
21#include "Define.h"
22#include <array>
23#include <string>
24
25#define STRINGIZE(a) #a
26
28{
29 MINUTE = 60,
31 DAY = HOUR*24,
32 WEEK = DAY*7,
33 MONTH = DAY*30,
34 YEAR = MONTH*12,
35 IN_MILLISECONDS = 1000
36};
37
39{
44 SEC_CONSOLE = 4 // must be always last in list, accounts must have less security level always also
45};
46
48{
61
63};
64
66#define DEFAULT_LOCALE LOCALE_enUS
67
68enum class CascLocaleBit : uint8
69{
70 None = 0,
71 enUS = 1,
72 koKR = 2,
73 Reserved = 3,
74 frFR = 4,
75 deDE = 5,
76 zhCN = 6,
77 esES = 7,
78 zhTW = 8,
79 enGB = 9,
80 enCN = 10,
81 enTW = 11,
82 esMX = 12,
83 ruRU = 13,
84 ptBR = 14,
85 itIT = 15,
86 ptPT = 16
87};
88
89TC_COMMON_API extern char const* localeNames[TOTAL_LOCALES];
90
91TC_COMMON_API LocaleConstant GetLocaleByName(std::string_view name);
92
94
95constexpr inline bool IsValidLocale(LocaleConstant locale)
96{
97 return locale < TOTAL_LOCALES && locale != LOCALE_none;
98}
99
100#pragma pack(push, 1)
101
103{
104 constexpr char const* operator[](LocaleConstant locale) const
105 {
106 return Str[locale];
107 }
108
109 std::array<char const*, TOTAL_LOCALES> Str;
110};
111
112#pragma pack(pop)
113
114#ifndef M_PI
115#define M_PI 3.14159265358979323846
116#endif
117
118#ifndef M_PI_4
119#define M_PI_4 0.785398163397448309616
120#endif
121
122#define MAX_QUERY_LEN 32*1024
123
124#endif
LocaleConstant
Definition: Common.h:48
@ LOCALE_zhCN
Definition: Common.h:53
@ LOCALE_deDE
Definition: Common.h:52
@ LOCALE_zhTW
Definition: Common.h:54
@ LOCALE_ptBR
Definition: Common.h:59
@ LOCALE_itIT
Definition: Common.h:60
@ LOCALE_none
Definition: Common.h:58
@ LOCALE_esES
Definition: Common.h:55
@ TOTAL_LOCALES
Definition: Common.h:62
@ LOCALE_ruRU
Definition: Common.h:57
@ LOCALE_frFR
Definition: Common.h:51
@ LOCALE_enUS
Definition: Common.h:49
@ LOCALE_koKR
Definition: Common.h:50
@ LOCALE_esMX
Definition: Common.h:56
constexpr bool IsValidLocale(LocaleConstant locale)
Definition: Common.h:95
CascLocaleBit
Definition: Common.h:69
TC_COMMON_API char const * localeNames[TOTAL_LOCALES]
Definition: Common.cpp:20
const uint8 OLD_TOTAL_LOCALES
Definition: Common.h:65
TC_COMMON_API LocaleConstant GetLocaleByName(std::string_view name)
Definition: Common.cpp:36
TimeConstants
Definition: Common.h:28
@ IN_MILLISECONDS
Definition: Common.h:35
@ MINUTE
Definition: Common.h:29
@ HOUR
Definition: Common.h:30
@ DAY
Definition: Common.h:31
@ MONTH
Definition: Common.h:33
@ WEEK
Definition: Common.h:32
@ YEAR
Definition: Common.h:34
AccountTypes
Definition: Common.h:39
@ SEC_PLAYER
Definition: Common.h:40
@ SEC_ADMINISTRATOR
Definition: Common.h:43
@ SEC_GAMEMASTER
Definition: Common.h:42
@ SEC_MODERATOR
Definition: Common.h:41
@ SEC_CONSOLE
Definition: Common.h:44
TC_COMMON_API CascLocaleBit WowLocaleToCascLocaleBit[TOTAL_LOCALES]
Definition: Common.cpp:45
uint8_t uint8
Definition: Define.h:144
#define TC_COMMON_API
Definition: Define.h:99
std::array< char const *, TOTAL_LOCALES > Str
Definition: Common.h:109
constexpr char const * operator[](LocaleConstant locale) const
Definition: Common.h:104