From f81e455e3a68012ce7e7e9c78100e7907fab8672 Mon Sep 17 00:00:00 2001 From: Rochet2 Date: Sun, 24 Jan 2016 19:25:25 +0200 Subject: [PATCH] Support C++11 and update Eluna Set compilation to use C++11 Updated Eluna version and applied all core modifications needed by the update --- .travis.yml | 27 +++++++++++++++++---------- cmake/SetDefinitions.cmake | 5 +++-- src/framework/Platform/Define.h | 2 ++ src/game/Object/Creature.cpp | 8 ++++++-- src/game/Object/GameObject.cpp | 8 ++++++-- src/game/WorldHandlers/Map.cpp | 25 +++++++++++++++++++------ src/modules/Eluna | 2 +- 7 files changed, 54 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7e3a2693..fe69b57e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: cpp -before_install: - - bash .travis.sh +# use docker in travis +sudo: false # reduce clone time by only getting the latest commit and not the whole history (default for travis is 100) git: @@ -10,23 +10,30 @@ git: # send notifications to stack as well as email notifications: slack: getmangos:yRgNBSgRQVh8WdfGEbT08Hit - -# only run travis on the master branch -branches: - only: - - release20 - - develop21 # build on both Linux and OSX (finally) os: - linux - - osx + - osx # build with both gcc and clang to ensure compatibility compiler: - gcc - clang - + +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-4.8 + - g++-4.8 + - clang + +before_install: + - bash .travis.sh + - if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$CC" = "gcc" ] ; then export CC=gcc-4.8 CXX=g++-4.8 ; fi + script: - test -d _build || mkdir _build - test -d _install || mkdir _install diff --git a/cmake/SetDefinitions.cmake b/cmake/SetDefinitions.cmake index a1602aa3..91b77666 100644 --- a/cmake/SetDefinitions.cmake +++ b/cmake/SetDefinitions.cmake @@ -119,11 +119,12 @@ elseif(UNIX) if(NOT DEBUG) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --no-warnings") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --no-warnings") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --no-warnings -std=c++11 -Wno-narrowing -Wno-deprecated-register") else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W -Wall -Wextra -Winit-self -Winvalid-pch -Wfatal-errors -g3") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -Wextra -Winit-self -Winvalid-pch -Wfatal-errors -Woverloaded-virtual -g3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -Wextra -Winit-self -Winvalid-pch -Wfatal-errors -Woverloaded-virtual -g3 -std=c++11 -Wno-narrowing -Wno-deprecated-register") endif() + elseif(CMAKE_C_COMPILER MATCHES "icc") if(PLATFORM EQUAL 32) add_definitions(-axSSE2) diff --git a/src/framework/Platform/Define.h b/src/framework/Platform/Define.h index 05766080..0b493302 100644 --- a/src/framework/Platform/Define.h +++ b/src/framework/Platform/Define.h @@ -173,6 +173,7 @@ typedef uint32 DWORD; #define CONCAT1(x, y) x##y #define STATIC_ASSERT_WORKAROUND(expr, msg) typedef char CONCAT(static_assert_failed_at_line_, __LINE__) [(expr) ? 1 : -1] +#ifndef COMPILER_HAS_CPP11_SUPPORT #if COMPILER == COMPILER_GNU # if !defined(__GXX_EXPERIMENTAL_CXX0X__) || (__GNUC__ < 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ < 7) # define override @@ -188,6 +189,7 @@ typedef uint32 DWORD; # define static_assert(a, b) STATIC_ASSERT_WORKAROUND(a, b) # endif #endif +#endif /** * @brief diff --git a/src/game/Object/Creature.cpp b/src/game/Object/Creature.cpp index 71306463..b659e1e0 100644 --- a/src/game/Object/Creature.cpp +++ b/src/game/Object/Creature.cpp @@ -183,8 +183,7 @@ Creature::~Creature() void Creature::AddToWorld() { #ifdef ENABLE_ELUNA - if (!IsInWorld()) - sEluna->OnAddToWorld(this); + bool inWorld = IsInWorld(); #endif /* ENABLE_ELUNA */ ///- Register the creature for guid lookup @@ -197,6 +196,11 @@ void Creature::AddToWorld() std::set const* mapList = sWorld.getConfigForceLoadMapIds(); if ((mapList && mapList->find(GetMapId()) != mapList->end()) || (GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_ACTIVE)) { SetActiveObjectState(true); } + +#ifdef ENABLE_ELUNA + if (!inWorld) + sEluna->OnAddToWorld(this); +#endif /* ENABLE_ELUNA */ } void Creature::RemoveFromWorld() diff --git a/src/game/Object/GameObject.cpp b/src/game/Object/GameObject.cpp index c7f75057..3f8725e7 100644 --- a/src/game/Object/GameObject.cpp +++ b/src/game/Object/GameObject.cpp @@ -85,8 +85,7 @@ GameObject::~GameObject() void GameObject::AddToWorld() { #ifdef ENABLE_ELUNA - if (!IsInWorld()) - sEluna->OnAddToWorld(this); + bool inWorld = IsInWorld(); #endif /* ENABLE_ELUNA */ ///- Register the gameobject for guid lookup @@ -100,6 +99,11 @@ void GameObject::AddToWorld() // After Object::AddToWorld so that for initial state the GO is added to the world (and hence handled correctly) UpdateCollisionState(); + +#ifdef ENABLE_ELUNA + if (!inWorld) + sEluna->OnAddToWorld(this); +#endif /* ENABLE_ELUNA */ } void GameObject::RemoveFromWorld() diff --git a/src/game/WorldHandlers/Map.cpp b/src/game/WorldHandlers/Map.cpp index 129ff6ac..d78aae3e 100644 --- a/src/game/WorldHandlers/Map.cpp +++ b/src/game/WorldHandlers/Map.cpp @@ -62,6 +62,11 @@ Map::~Map() if (m_persistentState) { m_persistentState->SetUsedByMapState(NULL); } // field pointer can be deleted after this +#ifdef ENABLE_ELUNA + if (Instanceable()) + sEluna->FreeInstanceId(GetInstanceId()); +#endif /* ENABLE_ELUNA */ + delete i_data; i_data = NULL; @@ -1192,14 +1197,22 @@ void Map::CreateInstanceData(bool load) if (i_data != NULL) { return; } - uint32 i_script_id = GetScriptId(); +#ifdef ENABLE_ELUNA + i_data = sEluna->GetInstanceData(this); +#endif /* ENABLE_ELUNA */ - if (!i_script_id) - { return; } - - i_data = sScriptMgr.CreateInstanceData(this); + uint32 i_script_id = 0; if (!i_data) - { return; } + { + i_script_id = GetScriptId(); + + if (!i_script_id) + { return; } + + i_data = sScriptMgr.CreateInstanceData(this); + if (!i_data) + { return; } + } if (load) { diff --git a/src/modules/Eluna b/src/modules/Eluna index 48e5d45d..33e3bf9d 160000 --- a/src/modules/Eluna +++ b/src/modules/Eluna @@ -1 +1 @@ -Subproject commit 48e5d45d9c504d0da83e015374b92bb36f97821b +Subproject commit 33e3bf9de270e916b5bacd5b329486e265eec609