[6870] Not output error message at loading empty `db_script_string` table.
[getmangos.git] / src / shared / Common.h
blob5c938ea67a4e632b1396c673ed4e1e94254cca10
1 /*
2 * Copyright (C) 2005-2008 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
23 #ifdef HAVE_CONFIG_H
24 #ifdef PACKAGE
25 #undef PACKAGE
26 #endif //PACKAGE
27 #ifdef PACKAGE_BUGREPORT
28 #undef PACKAGE_BUGREPORT
29 #endif //PACKAGE_BUGREPORT
30 #ifdef PACKAGE_NAME
31 #undef PACKAGE_NAME
32 #endif //PACKAGE_NAME
33 #ifdef PACKAGE_STRING
34 #undef PACKAGE_STRING
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
42 #ifdef VERSION
43 #undef VERSION
44 #endif //VERSION
45 # include "config.h"
46 #undef PACKAGE
47 #undef PACKAGE_BUGREPORT
48 #undef PACKAGE_NAME
49 #undef PACKAGE_STRING
50 #undef PACKAGE_TARNAME
51 #undef PACKAGE_VERSION
52 #undef VERSION
53 #endif //HAVE_CONFIG_H
55 #include "Platform/Define.h"
57 #if COMPILER == COMPILER_MICROSOFT
59 #pragma warning(disable:4996)
61 #ifndef __SHOW_STUPID_WARNINGS__
63 #pragma warning(disable:4244)
65 #pragma warning(disable:4267)
67 #pragma warning(disable:4800)
69 #pragma warning(disable:4018)
71 #pragma warning(disable:4311)
73 #pragma warning(disable:4305)
75 #pragma warning(disable:4005)
76 #endif // __SHOW_STUPID_WARNINGS__
77 #endif // __GNUC__
79 // must be the first thing to include for it to work
80 #include "MemoryLeaks.h"
82 #include "Utilities/UnorderedMap.h"
83 #include <stdio.h>
84 #include <stdlib.h>
85 #include <string.h>
86 #include <time.h>
87 #include <math.h>
88 #include <errno.h>
89 #include <signal.h>
91 #if PLATFORM == PLATFORM_WINDOWS
92 #define STRCASECMP stricmp
93 #else
94 #define STRCASECMP strcasecmp
95 #endif
97 #include <set>
98 #include <list>
99 #include <string>
100 #include <map>
101 #include <queue>
102 #include <sstream>
103 #include <algorithm>
105 #include <zthread/FastMutex.h>
106 #include <zthread/LockedQueue.h>
107 #include <zthread/Runnable.h>
108 #include <zthread/Thread.h>
110 #if PLATFORM == PLATFORM_WINDOWS
111 # define FD_SETSIZE 4096
112 # include <ace/config-all.h>
113 // XP winver - needed to compile with standard leak check in MemoryLeaks.h
114 // uncomment later if needed
115 //#define _WIN32_WINNT 0x0501
116 # include <ws2tcpip.h>
117 //#undef WIN32_WINNT
118 #else
119 # include <sys/types.h>
120 # include <sys/ioctl.h>
121 # include <sys/socket.h>
122 # include <netinet/in.h>
123 # include <unistd.h>
124 # include <netdb.h>
125 #endif
127 #if COMPILER == COMPILER_MICROSOFT
129 #include <float.h>
131 #define I64FMT "%016I64X"
132 #define I64FMTD "%I64u"
133 #define SI64FMTD "%I64d"
134 #define snprintf _snprintf
135 #define atoll __atoi64
136 #define vsnprintf _vsnprintf
137 #define strdup _strdup
138 #define finite(X) _finite(X)
140 #else
142 #define stricmp strcasecmp
143 #define strnicmp strncasecmp
144 #define I64FMT "%016llX"
145 #define I64FMTD "%llu"
146 #define SI64FMTD "%lld"
147 #endif
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
155 enum TimeConstants
157 MINUTE = 60,
158 HOUR = MINUTE*60,
159 DAY = HOUR*24,
160 MONTH = DAY*30
163 enum AccountTypes
165 SEC_PLAYER = 0,
166 SEC_MODERATOR = 1,
167 SEC_GAMEMASTER = 2,
168 SEC_ADMINISTRATOR = 3,
169 SEC_CONSOLE = 4 // must be always last in list, accounts must have less security level always also
172 enum LocaleConstant
174 LOCALE_enUS = 0,
175 LOCALE_koKR = 1,
176 LOCALE_frFR = 2,
177 LOCALE_deDE = 3,
178 LOCALE_zhCN = 4,
179 LOCALE_zhTW = 5,
180 LOCALE_esES = 6,
181 LOCALE_esMX = 7,
182 LOCALE_ruRU = 8
185 #define MAX_LOCALE 9
187 extern char const* localeNames[MAX_LOCALE];
189 LocaleConstant GetLocaleByName(std::string name);
191 // we always use stdlibc++ std::max/std::min, undefine some not C++ standard defines (Win API and some pother platforms)
192 #ifdef max
193 #undef max
194 #endif
196 #ifdef min
197 #undef min
198 #endif
200 #ifndef M_PI
201 #define M_PI 3.14159265358979323846
202 #endif
204 #endif