Skip to content

Commit

Permalink
Merge pull request vmangos#2743 from 0blu/native-remove-ace-finally
Browse files Browse the repository at this point in the history
Native Branch: Remove last references of ACE in code and CMake
  • Loading branch information
ratkosrb authored Aug 30, 2024
2 parents a0b378f + f8f08c1 commit 21ca640
Show file tree
Hide file tree
Showing 26 changed files with 94 additions and 140 deletions.
14 changes: 0 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ endif()

if(USE_LIBCURL)
find_package(CURL REQUIRED)
#add_definitions(-D_HAS_AUTO_PTR_ETC) # for VS2017 ACE support, won't do any harm to other compilers
#set(CMAKE_CXX_STANDARD 17)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
endif()
Expand Down Expand Up @@ -161,19 +160,6 @@ set(CMAKE_INSTALL_RPATH ${LIBS_DIR})
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)

# Find needed packages and if necessery abort if something important is missing
unset(ACE_INCLUDE_DIR CACHE)
unset(ACE_LIBRARIES CACHE)
unset(ACE_LIBRARIES_DIR CACHE)
unset(ACE_INCLUDE_DIR)
unset(ACE_LIBRARIES)
unset(ACE_LIBRARIES_DIR)

find_package(ACE)
if(NOT ACE_FOUND)
message(FATAL_ERROR
"This project requires ACE installed. Please download the ACE Micro Release Kit from http://download.dre.vanderbilt.edu/ and install it. If this script didn't find ACE and it was correctly installed please set ACE_ROOT to the correct path."
)
endif()

if(NOT USE_STD_MALLOC)
unset(TBB_INCLUDE_DIRS CACHE)
Expand Down
81 changes: 0 additions & 81 deletions cmake/FindACE.cmake

This file was deleted.

5 changes: 0 additions & 5 deletions contrib/mmap/src/MMapCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
#ifndef _MMAP_COMMON_H
#define _MMAP_COMMON_H

// stop warning spam from ACE includes
#ifdef _WIN32
# pragma warning( disable : 4996 )
#endif

#include <string>
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions contrib/mmap/src/MapBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "Maps/GridMapDefines.h"
#include "DetourNavMeshBuilder.h"
#include "DetourCommon.h"
#include <climits>

using namespace VMAP;

Expand Down
1 change: 0 additions & 1 deletion contrib/mmap/src/MapBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "json.hpp"

using namespace VMAP;
// G3D namespace typedefs conflicts with ACE typedefs

using json = nlohmann::json;

Expand Down
29 changes: 20 additions & 9 deletions src/framework/Platform/Define.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,28 @@
#ifndef MANGOS_DEFINE_H
#define MANGOS_DEFINE_H

#include <sys/types.h>

#include <ace/Basic_Types.h>
#include <ace/Default_Constants.h>
#include <ace/OS_NS_dlfcn.h>
#include <ace/ACE_export.h>
#include "Platform/CompilerDefs.h"
#include <cstdint>

#include "Platform/CompilerDefs.h"
#if PLATFORM == PLATFORM_WINDOWS
// Unfortunately, every library (e.g. MySQL, G3D) includes <Windows.h> in their **HEADER**
// and will break parts of the code, since Windows adds so many marcos and stuff.
// So if we can't beat them, join them!
// We include Windows.h first and remove all the conflicting definitions after.

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <WinSock2.h>
// Now we need to remove all the stuff that comes included with Windows headers and will most probably cause errors...
#undef WIN32_LEAN_AND_MEAN
#undef NOMINMAX
#undef ERROR
#undef IGNORE
#endif // WINDOWS

#define MANGOS_LITTLEENDIAN 0
#define MANGOS_BIGENDIAN 1
Expand All @@ -43,8 +56,6 @@
# endif //ACE_BYTE_ORDER
#endif //MANGOS_ENDIAN

#define MANGOS_PATH_MAX PATH_MAX // ace/os_include/os_limits.h -> ace/Basic_Types.h

#if PLATFORM == PLATFORM_WINDOWS
# ifndef DECLSPEC_NORETURN
# define DECLSPEC_NORETURN __declspec(noreturn)
Expand Down
2 changes: 1 addition & 1 deletion src/game/CreatureGroups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ void CreatureGroupsManager::Load()
int32 maxCount = fields[3].GetInt32();

if (maxCount <= 0)
maxCount = INT_MAX;
maxCount = std::numeric_limits<int32>::max();
else if (minCount > maxCount)
{
sLog.Out(LOG_DBERROR, LOG_LVL_MINIMAL, "CREATURE GROUPS: Min count %u is bigger than Max count %u for id %u in group with leader guid %u", minCount, maxCount, creatureId, fields[0].GetUInt32());
Expand Down
2 changes: 1 addition & 1 deletion src/game/WorldSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
\ingroup u2w
*/

#include "WorldSocket.h" // must be first to make ACE happy with ACE includes in it
#include "WorldSocket.h"
#include "Common.h"
#include "Database/DatabaseEnv.h"
#include "Log.h"
Expand Down
4 changes: 2 additions & 2 deletions src/game/pchdef.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//add here most rarely modified headers to speed up debug build compilation
#include "WorldSocket.h" // must be first to make ACE happy with ACE includes in it
#include "WorldSocket.h"
#include "Common.h"

#include "MapManager.h"
Expand All @@ -11,4 +11,4 @@
#include "SharedDefines.h"
#include "GuildMgr.h"
#include "ObjectMgr.h"
#include "ScriptMgr.h"
#include "ScriptMgr.h"
4 changes: 4 additions & 0 deletions src/mangosd/CliRunnable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include "CliRunnable.h"
#include "Database/DatabaseEnv.h"

#if PLATFORM == PLATFORM_APPLE
#include <sys/select.h>
#endif

void utf8print(void* /*arg*/, const char* str)
{
#if PLATFORM == PLATFORM_WINDOWS
Expand Down
1 change: 0 additions & 1 deletion src/mangosd/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ uint32 realmID; // Id of the realm
char const* g_mainLogFileName = "Server.log";

// Launch the mangos server
#undef main // TODO Remove me when ACE is removed
extern int main(int argc, char **argv)
{
ServerStartupArguments args;
Expand Down
1 change: 0 additions & 1 deletion src/realmd/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ volatile bool stopEvent = false; // Setting it to true stops the
DatabaseType LoginDatabase; // Accessor to the realm server database

// Launch the realm server
#undef main // TODO Remove me when ACE is removed
extern int main(int argc, char** argv)
{
ServerStartupArguments args;
Expand Down
6 changes: 4 additions & 2 deletions src/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ set (shared_SRCS
Multithreading/Messager.cpp
SRP6/SRP6.cpp
IO/Context/IoContext.h
IO/Utils.h
IO/Utils.cpp
IO/Utils_Unix.h
IO/Context/IoContext_macos.cpp
IO/Context/IoContext_unix.cpp
Expand Down Expand Up @@ -253,8 +255,8 @@ if(UNIX)
target_link_libraries(shared ${ACE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
endif(UNIX)

if(MINGW)
target_link_libraries(shared ${ACE_LIBRARIES} -lws2_32)
if(WIN32)
target_link_libraries(shared ws2_32 mswsock)
endif()

target_link_libraries(shared cpptrace::cpptrace)
Expand Down
5 changes: 3 additions & 2 deletions src/shared/Database/DBCFileLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include <cstdio>

#include "DBCFileLoader.h"

#include <cstdio>
#include <cstring>

DBCFileLoader::DBCFileLoader()
{
data = nullptr;
Expand Down
3 changes: 2 additions & 1 deletion src/shared/IO/Filesystem/impl/unix/FileHandle.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "IO/Filesystem/FileHandle.h"
#include "Log.h"
#include "IO/SystemErrorToString.h"
#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>

IO::Filesystem::FileHandle::~FileHandle()
{
Expand Down
3 changes: 2 additions & 1 deletion src/shared/IO/Filesystem/impl/unix/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#include "IO/Filesystem/FileHandle.h"
#include "Log.h"
#include "IO/SystemErrorToString.h"
#include <climits>
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>

/// This function will open a file in read shared and binary mode
/// You have to check the resulting pointer for nullptr!
Expand Down
2 changes: 2 additions & 0 deletions src/shared/IO/Networking/AsyncSocket_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#include <sys/epoll.h>
#elif defined(__APPLE__)
#include <sys/event.h>
#include <unistd.h>
#endif
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <thread>

Expand Down
1 change: 1 addition & 0 deletions src/shared/IO/Networking/DNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <ws2tcpip.h>
#elif defined(__linux__) || defined(__APPLE__)
#include <netdb.h>
#include <unistd.h>
#endif

std::string IO::Networking::DNS::GetOwnHostname()
Expand Down
4 changes: 2 additions & 2 deletions src/shared/IO/Networking/Internal.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "Errors.h"
#include "./Internal.h"

#if defined(__linux__)
#if defined(__linux__) || defined(__APPLE__)
#include <arpa/inet.h>
#endif

Expand All @@ -12,7 +12,7 @@ IO::Networking::IpAddress IO::Networking::Internal::inet_ntop(in_addr const* nat
// We cant use ::inet_ntoa(...) because it's not thread safe. We cant use ::inet_ntop(...) because it's not WinXP compatible, so we have to do it ourselves.
int constexpr MAX_IPV4_LENGTH = 16; // "255.255.255.255" = length 15 + 1 for null-terminator
char ipv4AddressString[MAX_IPV4_LENGTH];
{ // impl was taken from ACE, should be universal
{ // This implementation was taken from ACE, should be universal
uint8_t const* p = reinterpret_cast<uint8_t const*>(nativeAddress);
snprintf(ipv4AddressString, MAX_IPV4_LENGTH, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
}
Expand Down
7 changes: 7 additions & 0 deletions src/shared/IO/Networking/impl/unix/AsyncServerListener_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@
#include "IO/Networking/Internal.h"
#include "IO/SystemErrorToString.h"

#if defined(__linux__) || defined(__APPLE__)
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif

#if defined(__linux__)
#include <sys/epoll.h>
#elif defined(__APPLE__)
#include <sys/event.h>
#include <unistd.h>
#endif

template<typename TClientSocket>
Expand Down
16 changes: 16 additions & 0 deletions src/shared/IO/Utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "Utils.h"

#if defined(WIN32)
#include <Windows.h>
#else
#include <unistd.h>
#endif

uint64_t IO::Utils::GetCurrentProcessId()
{
#ifdef WIN32
return ::GetCurrentProcessId();
#else
return ::getpid();
#endif
}
10 changes: 10 additions & 0 deletions src/shared/IO/Utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef MANGOS_IO_UTILS_H
#define MANGOS_IO_UTILS_H

#include <cstdint>

namespace IO { namespace Utils {
uint64_t GetCurrentProcessId();
}} // namespace IO::Utils

#endif // MANGOS_IO_UTILS_H
Loading

0 comments on commit 21ca640

Please sign in to comment.