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: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 // must be the first thing to include for it to work
66 #include "MemoryLeaks.h"
68 #include "Utilities/UnorderedMap.h"
79 #include <ieeefp.h> // finite() on Solaris
90 #include "LockedQueue.h"
91 #include "Threading.h"
93 #include <ace/Basic_Types.h>
94 #include <ace/Guard_T.h>
95 #include <ace/RW_Thread_Mutex.h>
96 #include <ace/Thread_Mutex.h>
98 #if PLATFORM == PLATFORM_WINDOWS
99 # define FD_SETSIZE 4096
100 # include <ace/config-all.h>
101 // XP winver - needed to compile with standard leak check in MemoryLeaks.h
102 // uncomment later if needed
103 //#define _WIN32_WINNT 0x0501
104 # include <ws2tcpip.h>
107 # include <sys/types.h>
108 # include <sys/ioctl.h>
109 # include <sys/socket.h>
110 # include <netinet/in.h>
115 #if COMPILER == COMPILER_MICROSOFT
119 # define I32FMT "%08I32X"
120 # define I64FMT "%016I64X"
121 # define snprintf _snprintf
122 # define vsnprintf _vsnprintf
123 # define finite(X) _finite(X)
127 # define stricmp strcasecmp
128 # define strnicmp strncasecmp
130 # define I32FMT "%08X"
131 # if ACE_SIZEOF_LONG == 8
132 # define I64FMT "%016lX"
134 # define I64FMT "%016llX"
135 # endif /* ACE_SIZEOF_LONG == 8 */
139 #define UI64FMTD ACE_UINT64_FORMAT_SPECIFIER
140 #define UI64LIT(N) ACE_UINT64_LITERAL(N)
142 #define SI64FMTD ACE_INT64_FORMAT_SPECIFIER
143 #define SI64LIT(N) ACE_INT64_LITERAL(N)
145 #define SIZEFMTD ACE_SIZE_T_FORMAT_SPECIFIER
147 inline float finiteAlways(float f
) { return finite(f
) ? f
: 0.0f
; }
149 #define atol(a) strtoul( a, NULL, 10)
151 #define STRINGIZE(a) #a
153 // used for creating values for respawn for example
154 #define MAKE_PAIR64(l, h) uint64( uint32(l) | ( uint64(h) << 32 ) )
155 #define PAIR64_HIPART(x) (uint32)((uint64(x) >> 32) & UI64LIT(0x00000000FFFFFFFF))
156 #define PAIR64_LOPART(x) (uint32)(uint64(x) & UI64LIT(0x00000000FFFFFFFF))
158 #define MAKE_PAIR32(l, h) uint32( uint16(l) | ( uint32(h) << 16 ) )
159 #define PAIR32_HIPART(x) (uint16)((uint32(x) >> 16) & 0x0000FFFF)
160 #define PAIR32_LOPART(x) (uint16)(uint32(x) & 0x0000FFFF)
169 IN_MILISECONDS
= 1000
177 SEC_ADMINISTRATOR
= 3,
178 SEC_CONSOLE
= 4 // must be always last in list, accounts must have less security level always also
183 LOCALE_enUS
= 0, // also enGB
196 LocaleConstant
GetLocaleByName(const std::string
& name
);
198 extern char const* localeNames
[MAX_LOCALE
];
203 LocaleConstant locale
;
206 // used for iterate all names including alternative
207 extern LocaleNameStr fullLocaleNameList
[];
209 //operator new[] based version of strdup() function! Release memory by using operator delete[] !
210 inline char * mangos_strdup(const char * source
)
212 char * dest
= new char[strlen(source
) + 1];
213 strcpy(dest
, source
);
217 // we always use stdlibc++ std::max/std::min, undefine some not C++ standard defines (Win API and some pother platforms)
227 # define M_PI 3.14159265358979323846
231 # define M_PI_F float(M_PI)