Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
Common.h
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
#ifndef SKYFIRESERVER_COMMON_H
7
#define SKYFIRESERVER_COMMON_H
8
9
// config.h needs to be included 1st
11
// make separate header however, because It makes mess here.
12
#ifdef HAVE_CONFIG_H
13
// Remove Some things that we will define
14
// This is in case including another config.h
15
// before skyfire config.h
16
#ifdef PACKAGE
17
#undef PACKAGE
18
#endif
//PACKAGE
19
#ifdef PACKAGE_BUGREPORT
20
#undef PACKAGE_BUGREPORT
21
#endif
//PACKAGE_BUGREPORT
22
#ifdef PACKAGE_NAME
23
#undef PACKAGE_NAME
24
#endif
//PACKAGE_NAME
25
#ifdef PACKAGE_STRING
26
#undef PACKAGE_STRING
27
#endif
//PACKAGE_STRING
28
#ifdef PACKAGE_TARNAME
29
#undef PACKAGE_TARNAME
30
#endif
//PACKAGE_TARNAME
31
#ifdef PACKAGE_VERSION
32
#undef PACKAGE_VERSION
33
#endif
//PACKAGE_VERSION
34
#ifdef VERSION
35
#undef VERSION
36
#endif
//VERSION
37
38
# include "
Config.h
"
39
40
#undef PACKAGE
41
#undef PACKAGE_BUGREPORT
42
#undef PACKAGE_NAME
43
#undef PACKAGE_STRING
44
#undef PACKAGE_TARNAME
45
#undef PACKAGE_VERSION
46
#undef VERSION
47
#endif
//HAVE_CONFIG_H
48
49
#include "
Define.h
"
50
51
#include "
Dynamic/UnorderedMap.h
"
52
#include <stdio.h>
53
#include <stdlib.h>
54
#include <string.h>
55
#include <time.h>
56
#include <math.h>
57
#include <errno.h>
58
#include <signal.h>
59
#include <assert.h>
60
61
#if PLATFORM == PLATFORM_WINDOWS
62
#define STRCASECMP stricmp
63
#else
64
#define STRCASECMP strcasecmp
65
#endif
66
67
#include <set>
68
#include <list>
69
#include <string>
70
#include <map>
71
#include <queue>
72
#include <sstream>
73
#include <algorithm>
74
75
#include "
Threading/LockedQueue.h
"
76
#include "
Threading/Threading.h
"
77
78
#if PLATFORM == PLATFORM_WINDOWS
79
// XP winver - needed to compile with standard leak check in MemoryLeaks.h
80
// uncomment later if needed
81
//#define _WIN32_WINNT 0x0501
82
# include <ws2tcpip.h>
83
//#undef WIN32_WINNT
84
#else
85
# include <sys/types.h>
86
# include <sys/ioctl.h>
87
# include <sys/socket.h>
88
# include <netinet/in.h>
89
# include <unistd.h>
90
# include <netdb.h>
91
#endif
92
93
#if COMPILER == COMPILER_MICROSOFT
94
95
#include <float.h>
96
97
#define I32FMT "%08I32X"
98
#define I64FMT "%016I64X"
99
#define atoll _atoi64
100
#define vsnprintf _vsnprintf
101
#define finite(X) _finite(X)
102
#define llabs _abs64
103
104
#else
105
106
#define stricmp strcasecmp
107
#define strnicmp strncasecmp
108
#define I32FMT "%08X"
109
#define I64FMT "%016llX"
110
111
#endif
112
113
inline
float
finiteAlways
(
float
f) {
return
finite
(f) ? f : 0.0f; }
114
115
#define STRINGIZE(a) #a
116
117
enum
TimeConstants
118
{
119
MINUTE
= 60,
120
HOUR
=
MINUTE
* 60,
121
DAY
=
HOUR
* 24,
122
WEEK
=
DAY
* 7,
123
MONTH
=
DAY
* 30,
124
YEAR
=
MONTH
* 12,
125
IN_MILLISECONDS
= 1000
126
};
127
128
enum class
AccountTypes
129
{
130
SEC_PLAYER
= 0,
131
SEC_MODERATOR
= 1,
132
SEC_GAMEMASTER
= 2,
133
SEC_ADMINISTRATOR
= 3,
134
SEC_CONSOLE
= 4
// must be always last in list, accounts must have less security level always also
135
};
136
137
enum
LocaleConstant
138
{
139
LOCALE_enUS
= 0,
140
LOCALE_koKR
= 1,
141
LOCALE_frFR
= 2,
142
LOCALE_deDE
= 3,
143
LOCALE_zhCN
= 4,
144
LOCALE_zhTW
= 5,
145
LOCALE_esES
= 6,
146
LOCALE_esMX
= 7,
147
LOCALE_ruRU
= 8,
148
LOCALE_itIT
= 9,
149
LOCALE_ptBR
= 10,
150
LOCALE_ptPT
= 11
151
};
152
153
const
uint8
TOTAL_LOCALES
= 12;
154
#define DEFAULT_LOCALE LOCALE_enUS
155
156
#define MAX_LOCALES 11
157
#define MAX_ACCOUNT_TUTORIAL_VALUES 8
158
159
extern
char
const
*
localeNames
[
TOTAL_LOCALES
];
160
161
LocaleConstant
GetLocaleByName
(
const
std::string& name);
162
163
typedef
std::vector<std::string>
StringVector
;
164
165
#if defined(__GNUC__)
166
#pragma pack(1)
167
#else
168
#pragma pack(push, 1)
169
#endif
170
171
struct
LocalizedString
172
{
173
char
const
*
Str
[
TOTAL_LOCALES
];
174
};
175
176
#if defined(__GNUC__)
177
#pragma pack()
178
#else
179
#pragma pack(pop)
180
#endif
181
182
// we always use stdlibc++ std::max/std::min, undefine some not C++ standard defines (Win API and some other platforms)
183
#ifdef max
184
#undef max
185
#endif
186
187
#ifdef min
188
#undef min
189
#endif
190
191
#ifndef M_PI
192
#define M_PI 3.14159265358979323846f
193
#endif
194
195
#define MAX_QUERY_LEN 32*1024
196
197
#endif
localeNames
char const * localeNames[TOTAL_LOCALES]
Definition
Common.cpp:8
TOTAL_LOCALES
const uint8 TOTAL_LOCALES
Definition
Common.h:153
LocaleConstant
LocaleConstant
Definition
Common.h:138
LOCALE_zhCN
@ LOCALE_zhCN
Definition
Common.h:143
LOCALE_deDE
@ LOCALE_deDE
Definition
Common.h:142
LOCALE_zhTW
@ LOCALE_zhTW
Definition
Common.h:144
LOCALE_ptBR
@ LOCALE_ptBR
Definition
Common.h:149
LOCALE_itIT
@ LOCALE_itIT
Definition
Common.h:148
LOCALE_esES
@ LOCALE_esES
Definition
Common.h:145
LOCALE_ruRU
@ LOCALE_ruRU
Definition
Common.h:147
LOCALE_frFR
@ LOCALE_frFR
Definition
Common.h:141
LOCALE_ptPT
@ LOCALE_ptPT
Definition
Common.h:150
LOCALE_enUS
@ LOCALE_enUS
Definition
Common.h:139
LOCALE_koKR
@ LOCALE_koKR
Definition
Common.h:140
LOCALE_esMX
@ LOCALE_esMX
Definition
Common.h:146
GetLocaleByName
LocaleConstant GetLocaleByName(const std::string &name)
Definition
Common.cpp:23
TimeConstants
TimeConstants
Definition
Common.h:118
IN_MILLISECONDS
@ IN_MILLISECONDS
Definition
Common.h:125
MINUTE
@ MINUTE
Definition
Common.h:119
HOUR
@ HOUR
Definition
Common.h:120
DAY
@ DAY
Definition
Common.h:121
MONTH
@ MONTH
Definition
Common.h:123
WEEK
@ WEEK
Definition
Common.h:122
YEAR
@ YEAR
Definition
Common.h:124
StringVector
std::vector< std::string > StringVector
Definition
Common.h:163
finite
#define finite(X)
Definition
Common.h:101
AccountTypes
AccountTypes
Definition
Common.h:129
AccountTypes::SEC_CONSOLE
@ SEC_CONSOLE
Definition
Common.h:134
AccountTypes::SEC_PLAYER
@ SEC_PLAYER
Definition
Common.h:130
AccountTypes::SEC_MODERATOR
@ SEC_MODERATOR
Definition
Common.h:131
AccountTypes::SEC_ADMINISTRATOR
@ SEC_ADMINISTRATOR
Definition
Common.h:133
AccountTypes::SEC_GAMEMASTER
@ SEC_GAMEMASTER
Definition
Common.h:132
finiteAlways
float finiteAlways(float f)
Definition
Common.h:113
Config.h
Define.h
uint8
std::uint8_t uint8
Definition
Define.h:79
LockedQueue.h
Threading.h
UnorderedMap.h
LocalizedString
Definition
Common.h:172
LocalizedString::Str
char const * Str[TOTAL_LOCALES]
Definition
Common.h:173
src
server
shared
Common.h
Generated on
for Project SkyFire Core by
1.17.0