From 942e0ef347372492c2f5f1f29cd357a055e06252 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Fri, 16 Dec 2016 21:26:36 +0000 Subject: [PATCH 1/3] this proxy list sometimes went out of scope before copied, fix it so we don't bug any more toons! --- .../src/shared/ScriptMethodsObjectInfo.cpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/engine/server/library/serverScript/src/shared/ScriptMethodsObjectInfo.cpp b/engine/server/library/serverScript/src/shared/ScriptMethodsObjectInfo.cpp index 3a78cfce..453e5e7f 100755 --- a/engine/server/library/serverScript/src/shared/ScriptMethodsObjectInfo.cpp +++ b/engine/server/library/serverScript/src/shared/ScriptMethodsObjectInfo.cpp @@ -3367,38 +3367,38 @@ void JNICALL ScriptMethodsObjectInfoNamespace::sendScriptVarsToProxies(JNIEnv * { PROFILER_AUTO_BLOCK_DEFINE("JNI::sendScriptVarsToProxies"); - ServerObject * object = 0; if (obj != 0 && buffer != 0) { - if (JavaLibrary::getObject(obj, object)) + ServerObject *object = nullptr; + if (JavaLibrary::getObject(obj, object) && object != nullptr) { - ProxyList const &proxyList = object->getExposedProxyList(); + ProxyList proxyList(object->getExposedProxyList()); if (!proxyList.empty()) { - std::vector data; - if (ScriptConversion::convert(buffer, data)) - { - if(data.size() > 0) + std::vector data; + if (ScriptConversion::convert(buffer, data)) { - WARNING(data.size() > 60000, ("JavaLibrary::sendScriptVarsToProxies: " - "Packing scriptvars for object %s, packed data size = %d", + if(data.size() > 0) + { + WARNING(data.size() > 60000, ("JavaLibrary::sendScriptVarsToProxies: " + "Packing scriptvars for object %s, packed data size = %d", + object->getNetworkId().getValueString().c_str(), static_cast(data.size()))); uint32 const myProcessId = GameServer::getInstance().getProcessId(); uint32 const authProcessId = object->getAuthServerProcessId(); - ProxyList syncServers(proxyList); + if (myProcessId != authProcessId) { - syncServers.erase(myProcessId); - syncServers.insert(authProcessId); + proxyList.erase(myProcessId); + proxyList.insert(authProcessId); } - - ServerMessageForwarding::begin(std::vector(syncServers.begin(), syncServers.end())); - + + ServerMessageForwarding::begin(std::vector(proxyList.begin(), proxyList.end())); SynchronizeScriptVarDeltasMessage const deltasMessage(object->getNetworkId(), data); + ServerMessageForwarding::send(deltasMessage); - ServerMessageForwarding::end(); } } From 2b28fea68e82eb2105ddb5594c1bb5e971c807c1 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Fri, 16 Dec 2016 21:31:39 +0000 Subject: [PATCH 2/3] adopt our changes to the TC/live build branches, but remove link time optimization so we don't have to wait as long on the build --- CMakeLists.txt | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f3e3b2b..1df3cb7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,12 +70,7 @@ elseif(UNIX) find_package(Curses REQUIRED) # linker flags - set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-O1,--sort-common,--as-needed,-z,relro") - - if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -s") - endif() - + set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,--relax,-z,combreloc,-z,global,--no-omagic,-x,-s") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") # don't put anything too crazy in debug...and any common flags go into CMAKE_CXX_FLAGS @@ -86,11 +81,17 @@ elseif(UNIX) # Ofast doesn't work with gcc builds if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast \ + -fno-signed-zeros -freciprocal-math -ffp-contract=fast \ + -fno-threadsafe-statics -fslp-vectorize-aggressive -fslp-vectorize \ + -fno-stack-protector -fstrict-enums -fstrict-vtable-pointers \ + -fno-coverage-mapping -fno-spell-checking -fshort-enums -finline-functions \ + -finline-hint-functions -fno-unroll-loops") + + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") # O3 and Ofast include one or more flags that cause java to crash when using gcc6 - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -fno-signed-zeros \ - -freciprocal-math -ffp-contract=fast") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -fno-signed-zeros -freciprocal-math -fno-unroll-loops -fno-tree-loop-optimize") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") endif() @@ -102,9 +103,7 @@ elseif(UNIX) -Wno-write-strings -Wno-unknown-pragmas \ -Wno-uninitialized -Wno-reorder") - # set definitions - # note that STELLA_INTERNAL should never be used on the clang-profile or clang-profile-build branch - add_definitions(-DLINUX -D_REENTRANT -Dlinux -DSTELLA_INTERNAL -D_GNU_SOURCE -D_XOPEN_SOURCE=500) + add_definitions(-DLINUX -D_REENTRANT -Dlinux -D_USING_STL -D_GNU_SOURCE -D_XOPEN_SOURCE=500 -U_FORTIFY_SOURCE) endif() add_subdirectory(external) From 8fdc317105d86220b9a40df39d81681fb8470102 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sat, 17 Dec 2016 02:55:38 +0000 Subject: [PATCH 3/3] fix a couple warnings - because the objects in DataResourceList are static, we now need to have them predefined in each function as the class is static too - c++14 demands it --- .../src/shared/DataResourceList.h | 37 ++++++++++--------- external/3rd/library/libLeff/libLeff.h | 2 +- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/engine/shared/library/sharedFoundation/src/shared/DataResourceList.h b/engine/shared/library/sharedFoundation/src/shared/DataResourceList.h index a86629e5..f2476eeb 100755 --- a/engine/shared/library/sharedFoundation/src/shared/DataResourceList.h +++ b/engine/shared/library/sharedFoundation/src/shared/DataResourceList.h @@ -82,13 +82,10 @@ private: template inline void DataResourceList::install() { - if (ms_bindings == nullptr) - { - ms_bindings = new CreateDataResourceMap(); - ms_loaded = new LoadedDataResourceMap(); + auto static *ms_bindings = new CreateDataResourceMap(); + auto static *ms_loaded = new LoadedDataResourceMap(); - ExitChain::add (remove, "DataResourceList::remove"); - } + ExitChain::add (remove, "DataResourceList::remove"); } // DataResourceList::install //---------------------------------------------------------------------- @@ -100,6 +97,9 @@ inline void DataResourceList::install() template inline void DataResourceList::remove(void) { + auto static *ms_bindings = new CreateDataResourceMap(); + auto static *ms_loaded = new LoadedDataResourceMap(); + if (ms_loaded != nullptr) { #ifdef _DEBUG @@ -122,13 +122,11 @@ inline void DataResourceList::remove(void) #endif // _DEBUG delete ms_loaded; - ms_loaded = nullptr; } if (ms_bindings != nullptr) { delete ms_bindings; - ms_bindings = nullptr; } } // DataResourceList::remove @@ -144,6 +142,9 @@ template inline void DataResourceList::registerTemplate(Tag id, CreateDataResourceFunc createFunc) { + auto static *ms_bindings = new CreateDataResourceMap(); + auto static *ms_loaded = new LoadedDataResourceMap(); + if (ms_bindings == nullptr) install(); @@ -197,8 +198,6 @@ template inline typename DataResourceList::CreateDataResourceFunc DataResourceList::removeBinding( Tag id) { - NOT_NULL(ms_bindings); - CreateDataResourceFunc oldFunc = (*ms_bindings)[id]; ms_bindings->erase(id); return oldFunc; @@ -233,7 +232,8 @@ inline const T * DataResourceList::fetch(const char * filename) template inline T * DataResourceList::fetch(Tag id) { - NOT_NULL(ms_bindings); + auto static *ms_bindings = new CreateDataResourceMap(); + auto static *ms_loaded = new LoadedDataResourceMap(); typename CreateDataResourceMap::iterator iter = ms_bindings->find(id); if (iter == ms_bindings->end()) @@ -254,7 +254,8 @@ inline T * DataResourceList::fetch(Tag id) template inline const T * DataResourceList::fetch(Iff &source) { - NOT_NULL(ms_bindings); + auto static *ms_bindings = new CreateDataResourceMap(); + auto static *ms_loaded = new LoadedDataResourceMap(); #ifdef _DEBUG DataLint::pushAsset(source.getFileName()); @@ -297,7 +298,8 @@ inline const T * DataResourceList::fetch(Iff &source) template inline const T * DataResourceList::fetch(const CrcString &filename) { - NOT_NULL(ms_loaded); + auto static *ms_bindings = new CreateDataResourceMap(); + auto static *ms_loaded = new LoadedDataResourceMap(); // see if we already have loaded the template typename LoadedDataResourceMap::iterator iter = ms_loaded->find(&filename); @@ -335,17 +337,18 @@ inline const T * DataResourceList::fetch(const CrcString &filename) template inline void DataResourceList::release(const T & dataResource) { - NOT_NULL(ms_loaded); + auto static *ms_bindings = new CreateDataResourceMap(); + auto static *ms_loaded = new LoadedDataResourceMap(); if (ms_loaded != nullptr && dataResource.getReferenceCount() == 0) { typename LoadedDataResourceMap::iterator iter = ms_loaded->find(&dataResource.getCrcName()); if (iter != ms_loaded->end()) { - const T * const temp = (*iter).second; + delete (*iter).second; (*iter).second = nullptr; - ms_loaded->erase(iter); - delete temp; + + iter = ms_loaded->erase(iter); } } } // DataResourceList::release diff --git a/external/3rd/library/libLeff/libLeff.h b/external/3rd/library/libLeff/libLeff.h index 455774e1..f74b9282 100644 --- a/external/3rd/library/libLeff/libLeff.h +++ b/external/3rd/library/libLeff/libLeff.h @@ -59,7 +59,7 @@ template template<> struct vxCplIndexes<0> { typedef vxCplIndexList<> Result; }; // Compile-time string encryption of a single character -const char vxCplEncryptCharKey = vxRANDOM(0, 0xFF); +const int vxCplEncryptCharKey = vxRANDOM(0, 0xFF); constexpr char vxCplEncryptChar(const char Ch, uint32_t Idx) { return Ch ^ (vxCplEncryptCharKey + Idx); }