2 * Copyright (C) 2005-2013 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef MANGOSSERVER_COMMON_H
20 #define MANGOSSERVER_COMMON_H
22 // config.h needs to be included 1st
27 #ifdef PACKAGE_BUGREPORT
28 #undef PACKAGE_BUGREPORT
29 #endif // PACKAGE_BUGREPORT
32 #endif // PACKAGE_NAME
35 #endif // PACKAGE_STRING
36 #ifdef PACKAGE_TARNAME
37 #undef PACKAGE_TARNAME
38 #endif // PACKAGE_TARNAME
39 #ifdef PACKAGE_VERSION
40 #undef PACKAGE_VERSION
41 #endif // PACKAGE_VERSION
47 #undef PACKAGE_BUGREPORT
50 #undef PACKAGE_TARNAME
51 #undef PACKAGE_VERSION
53 #endif // HAVE_CONFIG_H
55 #include "Platform/Define.h"
57 #if COMPILER == COMPILER_MICROSOFT
58 # pragma warning(disable:4996) // 'function': was declared deprecated
59 #ifndef __SHOW_STUPID_WARNINGS__
60 # pragma warning(disable:4244) // 'argument' : conversion from 'type1' to 'type2', possible loss of data
61 # pragma warning(disable:4355) // 'this' : used in base member initializer list
62 #endif // __SHOW_STUPID_WARNINGS__
65 #include "Utilities/UnorderedMapSet.h"
76 #include <ieeefp.h> // finite() on Solaris
88 #include "LockedQueue.h"
89 #include "Threading.h"
91 #include <ace/Basic_Types.h>
92 #include <ace/Guard_T.h>
93 #include <ace/RW_Thread_Mutex.h>
94 #include <ace/Thread_Mutex.h>
95 #include <ace/OS_NS_arpa_inet.h>
97 // Old ACE versions (pre-ACE-5.5.4) not have this type (add for allow use at Unix side external old ACE versions)
98 #if PLATFORM != PLATFORM_WINDOWS
100 typedef off_t ACE_OFF_T
;
104 #if PLATFORM == PLATFORM_WINDOWS
105 # if !defined (FD_SETSIZE)
106 # define FD_SETSIZE 4096
108 # include <ace/config-all.h>
109 # include <ws2tcpip.h>
111 # include <sys/types.h>
112 # include <sys/ioctl.h>
113 # include <sys/socket.h>
114 # include <netinet/in.h>
119 #if COMPILER == COMPILER_MICROSOFT
123 # define I32FMT "%08I32X"
124 # define I64FMT "%016I64X"
125 # define snprintf _snprintf
126 # define vsnprintf _vsnprintf
127 # define finite(X) _finite(X)
131 # define stricmp strcasecmp
132 # define strnicmp strncasecmp
134 # define I32FMT "%08X"
135 # if ACE_SIZEOF_LONG == 8
136 # define I64FMT "%016lX"
138 # define I64FMT "%016llX"
139 # endif /* ACE_SIZEOF_LONG == 8 */
143 #define UI64FMTD ACE_UINT64_FORMAT_SPECIFIER
144 #define UI64LIT(N) ACE_UINT64_LITERAL(N)
146 #define SI64FMTD ACE_INT64_FORMAT_SPECIFIER
147 #define SI64LIT(N) ACE_INT64_LITERAL(N)
149 #define SIZEFMTD ACE_SIZE_T_FORMAT_SPECIFIER
151 inline float finiteAlways(float f
) { return finite(f
) ? f
: 0.0f
; }
153 #define atol(a) strtoul( a, NULL, 10)
155 #define STRINGIZE(a) #a
157 // used for creating values for respawn for example
158 #define MAKE_PAIR64(l, h) uint64( uint32(l) | ( uint64(h) << 32 ) )
159 #define PAIR64_HIPART(x) (uint32)((uint64(x) >> 32) & UI64LIT(0x00000000FFFFFFFF))
160 #define PAIR64_LOPART(x) (uint32)(uint64(x) & UI64LIT(0x00000000FFFFFFFF))
162 #define MAKE_PAIR32(l, h) uint32( uint16(l) | ( uint32(h) << 16 ) )
163 #define PAIR32_HIPART(x) (uint16)((uint32(x) >> 16) & 0x0000FFFF)
164 #define PAIR32_LOPART(x) (uint16)(uint32(x) & 0x0000FFFF)
174 IN_MILLISECONDS
= 1000
182 SEC_ADMINISTRATOR
= 3,
183 SEC_CONSOLE
= 4 // must be always last in list, accounts must have less security level always also
186 // Used in mangosd/realmd
189 REALM_FLAG_NONE
= 0x00,
190 REALM_FLAG_INVALID
= 0x01,
191 REALM_FLAG_OFFLINE
= 0x02,
192 REALM_FLAG_SPECIFYBUILD
= 0x04, // client will show realm version in RealmList screen in form "RealmName (major.minor.revision.build)"
193 REALM_FLAG_UNK1
= 0x08,
194 REALM_FLAG_UNK2
= 0x10,
195 REALM_FLAG_NEW_PLAYERS
= 0x20,
196 REALM_FLAG_RECOMMENDED
= 0x40,
197 REALM_FLAG_FULL
= 0x80
202 LOCALE_enUS
= 0, // also enGB
215 LocaleConstant
GetLocaleByName(const std::string
& name
);
217 extern char const* localeNames
[MAX_LOCALE
];
222 LocaleConstant locale
;
225 // used for iterate all names including alternative
226 extern LocaleNameStr
const fullLocaleNameList
[];
228 // operator new[] based version of strdup() function! Release memory by using operator delete[] !
229 inline char* mangos_strdup(const char* source
)
231 char* dest
= new char[strlen(source
) + 1];
232 strcpy(dest
, source
);
236 // we always use stdlibc++ std::max/std::min, undefine some not C++ standard defines (Win API and some pother platforms)
246 # define M_PI 3.14159265358979323846
250 # define M_PI_F float(M_PI)
254 #define countof(array) (sizeof(array) / sizeof((array)[0]))