Project SkyFire Core
SkyFire 5.4.8 server core API documentation
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
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
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
113inline float finiteAlways(float f) { return finite(f) ? f : 0.0f; }
114
115#define STRINGIZE(a) #a
116
118{
119 MINUTE = 60,
120 HOUR = MINUTE * 60,
121 DAY = HOUR * 24,
122 WEEK = DAY * 7,
123 MONTH = DAY * 30,
124 YEAR = MONTH * 12,
126};
127
128enum class AccountTypes
129{
134 SEC_CONSOLE = 4 // must be always last in list, accounts must have less security level always also
135};
136
152
154#define DEFAULT_LOCALE LOCALE_enUS
155
156#define MAX_LOCALES 11
157#define MAX_ACCOUNT_TUTORIAL_VALUES 8
158
159extern char const* localeNames[TOTAL_LOCALES];
160
161LocaleConstant GetLocaleByName(const std::string& name);
162
163typedef std::vector<std::string> StringVector;
164
165#if defined(__GNUC__)
166#pragma pack(1)
167#else
168#pragma pack(push, 1)
169#endif
170
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
char const * localeNames[TOTAL_LOCALES]
Definition Common.cpp:8
const uint8 TOTAL_LOCALES
Definition Common.h:153
LocaleConstant
Definition Common.h:138
@ LOCALE_zhCN
Definition Common.h:143
@ LOCALE_deDE
Definition Common.h:142
@ LOCALE_zhTW
Definition Common.h:144
@ LOCALE_ptBR
Definition Common.h:149
@ LOCALE_itIT
Definition Common.h:148
@ LOCALE_esES
Definition Common.h:145
@ LOCALE_ruRU
Definition Common.h:147
@ LOCALE_frFR
Definition Common.h:141
@ LOCALE_ptPT
Definition Common.h:150
@ LOCALE_enUS
Definition Common.h:139
@ LOCALE_koKR
Definition Common.h:140
@ LOCALE_esMX
Definition Common.h:146
LocaleConstant GetLocaleByName(const std::string &name)
Definition Common.cpp:23
TimeConstants
Definition Common.h:118
@ IN_MILLISECONDS
Definition Common.h:125
@ MINUTE
Definition Common.h:119
@ HOUR
Definition Common.h:120
@ DAY
Definition Common.h:121
@ MONTH
Definition Common.h:123
@ WEEK
Definition Common.h:122
@ YEAR
Definition Common.h:124
std::vector< std::string > StringVector
Definition Common.h:163
#define finite(X)
Definition Common.h:101
AccountTypes
Definition Common.h:129
@ SEC_MODERATOR
Definition Common.h:131
@ SEC_ADMINISTRATOR
Definition Common.h:133
@ SEC_GAMEMASTER
Definition Common.h:132
float finiteAlways(float f)
Definition Common.h:113
std::uint8_t uint8
Definition Define.h:79
char const * Str[TOTAL_LOCALES]
Definition Common.h:173