2 * Copyright (C) 2005-2010 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
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:4005) // 'identifier' : macro redefinition
61 # pragma warning(disable:4018) // 'expression' : signed/unsigned mismatch
62 # pragma warning(disable:4244) // 'argument' : conversion from 'type1' to 'type2', possible loss of data
63 # pragma warning(disable:4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data
64 # pragma warning(disable:4305) // 'identifier' : truncation from 'type1' to 'type2'
65 # pragma warning(disable:4311) // 'variable' : pointer truncation from 'type' to 'type'
66 # pragma warning(disable:4355) // 'this' : used in base member initializer list
67 # pragma warning(disable:4800) // 'type' : forcing value to bool 'true' or 'false' (performance warning)
68 #endif // __SHOW_STUPID_WARNINGS__
71 // must be the first thing to include for it to work
72 #include "MemoryLeaks.h"
74 #include "Utilities/UnorderedMap.h"
92 #include "LockedQueue.h"
93 #include "Threading.h"
95 #include <ace/Basic_Types.h>
96 #include <ace/Guard_T.h>
97 #include <ace/RW_Thread_Mutex.h>
98 #include <ace/Thread_Mutex.h>
100 #if PLATFORM == PLATFORM_WINDOWS
101 # define FD_SETSIZE 4096
102 # include <ace/config-all.h>
103 // XP winver - needed to compile with standard leak check in MemoryLeaks.h
104 // uncomment later if needed
105 //#define _WIN32_WINNT 0x0501
106 # include <ws2tcpip.h>
109 # include <sys/types.h>
110 # include <sys/ioctl.h>
111 # include <sys/socket.h>
112 # include <netinet/in.h>
117 #if COMPILER == COMPILER_MICROSOFT
121 # define I32FMT "%08I32X"
122 # define I64FMT "%016I64X"
123 # define snprintf _snprintf
124 # define vsnprintf _vsnprintf
125 # define finite(X) _finite(X)
129 # define stricmp strcasecmp
130 # define strnicmp strncasecmp
132 # define I32FMT "%08X"
133 # if ACE_SIZEOF_LONG == 8
134 # define I64FMT "%016lX"
136 # define I64FMT "%016llX"
137 # endif /* ACE_SIZEOF_LONG == 8 */
141 #define UI64FMTD ACE_UINT64_FORMAT_SPECIFIER
142 #define UI64LIT(N) ACE_UINT64_LITERAL(N)
144 #define SI64FMTD ACE_INT64_FORMAT_SPECIFIER
145 #define SI64LIT(N) ACE_INT64_LITERAL(N)
147 #define SIZEFMTD ACE_SIZE_T_FORMAT_SPECIFIER
149 inline float finiteAlways(float f
) { return finite(f
) ? f
: 0.0f
; }
151 #define atol(a) strtoul( a, NULL, 10)
153 #define STRINGIZE(a) #a
162 IN_MILISECONDS
= 1000
170 SEC_ADMINISTRATOR
= 3,
171 SEC_CONSOLE
= 4 // must be always last in list, accounts must have less security level always also
176 LOCALE_enUS
= 0, // also enGB
189 LocaleConstant
GetLocaleByName(const std::string
& name
);
191 extern char const* localeNames
[MAX_LOCALE
];
196 LocaleConstant locale
;
199 // used for iterate all names including alternative
200 extern LocaleNameStr fullLocaleNameList
[];
202 //operator new[] based version of strdup() function! Release memory by using operator delete[] !
203 inline char * mangos_strdup(const char * source
)
205 char * dest
= new char[strlen(source
) + 1];
206 strcpy(dest
, source
);
210 // we always use stdlibc++ std::max/std::min, undefine some not C++ standard defines (Win API and some pother platforms)
220 # define M_PI 3.14159265358979323846