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