[4363] Applied MaNGOS coding style to src/shared.
[mangos-git.git] / src / shared / Common.h
blob7ae37012cfe5c40bc9830f70f9b28af6f9383172
1 /*
2 * Copyright (C) 2005,2006,2007 MaNGOS <http://www.mangosproject.org/>
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 #include "Platform/Define.h"
24 #if COMPILER == COMPILER_MICROSOFT
26 #pragma warning(disable:4996)
28 #ifndef __SHOW_STUPID_WARNINGS__
30 #pragma warning(disable:4244)
32 #pragma warning(disable:4267)
34 #pragma warning(disable:4800)
36 #pragma warning(disable:4018)
38 #pragma warning(disable:4311)
40 #pragma warning(disable:4305)
42 #pragma warning(disable:4005)
43 #endif // __SHOW_STUPID_WARNINGS__
44 #endif // __GNUC__
46 // we need to stick to 1 version or half of the stuff will work for someone
47 // others will not and opposite
48 // will only support WoW and WoW:TBC 2.1.3 client build 6898...
50 #define EXPECTED_MANGOS_CLIENT_BUILD {6898, 0}
52 // must be the first thing to include for it to work
53 #include "MemoryLeaks.h"
55 #ifdef HAVE_CONFIG_H
56 # include <config.h>
57 #endif
59 #include "Utilities/HashMap.h"
60 #include <stdio.h>
61 #include <stdlib.h>
62 #include <string.h>
63 #include <time.h>
64 #include <math.h>
65 #include <errno.h>
66 #include <signal.h>
68 #if PLATFORM == PLATFORM_WIN32
69 #define STRCASECMP stricmp
70 #else
71 #define STRCASECMP strcasecmp
72 #endif
74 #include <set>
75 #include <list>
76 #include <string>
77 #include <map>
78 #include <queue>
79 #include <sstream>
80 #include <algorithm>
82 #include <zthread/FastMutex.h>
83 #include <zthread/LockedQueue.h>
84 #include <zthread/Runnable.h>
85 #include <zthread/Thread.h>
87 #if PLATFORM == PLATFORM_WIN32
88 # define FD_SETSIZE 1024
89 # include <winsock2.h>
90 // XP winver - needed to compile with standard leak check in MemoryLeaks.h
91 // uncomment later if needed
92 //#define _WIN32_WINNT 0x0501
93 # include <ws2tcpip.h>
94 //#undef WIN32_WINNT
95 #else
96 # include <sys/types.h>
97 # include <sys/ioctl.h>
98 # include <sys/socket.h>
99 # include <netinet/in.h>
100 # include <unistd.h>
101 # include <netdb.h>
102 #endif
104 #if COMPILER == COMPILER_MICROSOFT
106 #include <float.h>
108 #define I64FMT "%016I64X"
109 #define I64FMTD "%I64u"
110 #define SI64FMTD "%I64d"
111 #define snprintf _snprintf
112 #define atoll __atoi64
113 #define vsnprintf _vsnprintf
114 #define strdup _strdup
115 #define finite(X) _finite(X)
117 #else
119 #define stricmp strcasecmp
120 #define strnicmp strncasecmp
121 #define I64FMT "%016llX"
122 #define I64FMTD "%llu"
123 #define SI64FMTD "%lld"
124 #endif
126 #define GUID_HIPART(x) (uint32)((x) >> 32)
127 #define GUID_LOPART(x) (uint32)((x) & 0xFFFFFFFFULL)
128 #define MAKE_GUID(l, h) uint64( uint32(l) | ( uint64(h) << 32 ) )
130 #define atol(a) strtoul( a, NULL, 10)
132 #define STRINGIZE(a) #a
134 #define for if(true) for
136 enum TimeConstants
138 MINUTE = 60,
139 HOUR = MINUTE*60,
140 DAY = HOUR*24,
141 MONTH = DAY*30
144 #if PLATFORM == PLATFORM_WIN32
145 # define MANGOS_DLL_SPEC __declspec(dllexport)
146 #else
147 # define MANGOS_DLL_SPEC
148 #endif
150 // we always use stdlibc++ std::max/std::min, undefine some not C++ standart defines (Win API and some pother platforms)
151 #ifdef max
152 #undef max
153 #endif
155 #ifdef min
156 #undef min
157 #endif
158 #endif