### Example Build and Install Commands Source: https://github.com/slash-design/destinycore/blob/master/doc/UnixInstall.txt This sequence of commands demonstrates how to create a build directory, configure the build with specific installation paths and options, compile the project, and install it. ```bash cmake ../ -DCMAKE_INSTALL_PREFIX=/home/trinity/server -DTOOLS=1 -DWITH_WARNINGS=1 make make install ``` -------------------------------- ### Manual Installation Setup for Other Generators Source: https://github.com/slash-design/destinycore/blob/master/dep/cotire/MANUAL.md Manual setup for installing unity targets for generators other than Makefiles. It involves setting up install rules for unity targets and a global `install_unity` target. ```cmake install(TARGETS example_unity RUNTIME DESTINATION "bin" OPTIONAL COMPONENT "unity") add_custom_target(install_unity COMMAND ${CMAKE_COMMAND} -DCOMPONENT=unity -P cmake_install.cmake COMMENT "Install the unity-built project..." WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_dependencies(unity_install example_unity) ``` -------------------------------- ### Start the servers Source: https://github.com/slash-design/destinycore/blob/master/README.md Starts the worldserver and bnetserver. ```bash ./bin/worldserver ./bin/bnetserver ``` -------------------------------- ### Example efsw File Watcher Implementation Source: https://github.com/slash-design/destinycore/blob/master/dep/efsw/README.md This example demonstrates how to implement a file listener, create a file watcher instance, add directories to watch (recursively and non-recursively), start watching, and remove a watch. ```c++ // Inherits from the abstract listener class, and implements the the file action handler class UpdateListener : public efsw::FileWatchListener { public: UpdateListener() {} void handleFileAction( efsw::WatchID watchid, const std::string& dir, const std::string& filename, efsw::Action action, std::string oldFilename = "" ) { switch( action ) { case efsw::Actions::Add: std::cout << "DIR (" << dir << ") FILE (" << filename << ") has event Added" << std::endl; break; case efsw::Actions::Delete: std::cout << "DIR (" << dir << ") FILE (" << filename << ") has event Delete" << std::endl; break; case efsw::Actions::Modified: std::cout << "DIR (" << dir << ") FILE (" << filename << ") has event Modified" << std::endl; break; case efsw::Actions::Moved: std::cout << "DIR (" << dir << ") FILE (" << filename << ") has event Moved from (" << oldFilename << ")" << std::endl; break; default: std::cout << "Should never happen!" << std::endl; } } }; // Create the file system watcher instance // efsw::FileWatcher allow a first boolean parameter that indicates if it should start with the generic file watcher instead of the platform specific backend efsw::FileWatcher * fileWatcher = new efsw::FileWatcher(); // Create the instance of your efsw::FileWatcherListener implementation UpdateListener * listener = new UpdateListener(); // Add a folder to watch, and get the efsw::WatchID // It will watch the /tmp folder recursively ( the third parameter indicates that is recursive ) // Reporting the files and directories changes to the instance of the listener efsw::WatchID watchID = fileWatcher->addWatch( "/tmp", listener, true ); // Adds another directory to watch. This time as non-recursive. efsw::WatchID watchID2 = fileWatcher->addWatch( "/usr", listener, false ); // Start watching asynchronously the directories fileWatcher->watch(); // Remove the second watcher added // You can also call removeWatch by passing the watch path ( it must end with an slash or backslash in windows, since that's how internally it's saved ) fileWatcher->removeWatch( watchID2 ); ``` -------------------------------- ### Install Node.JS packages Source: https://github.com/slash-design/destinycore/blob/master/contrib/ServerRelay/README.md Installs all necessary packages from package.json. ```javascript npm install ``` -------------------------------- ### Installation Rules Source: https://github.com/slash-design/destinycore/blob/master/dep/cpr/opt/curl/lib/CMakeLists.txt Defines the installation destinations for the library artifacts. ```cmake install(TARGETS ${LIB_NAME} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) ``` -------------------------------- ### Manual setup of linked libraries for unity target Source: https://github.com/slash-design/destinycore/blob/master/dep/cotire/MANUAL.md Example of manually setting up linked libraries for a unity target when COTIRE_UNITY_LINK_LIBRARIES_INIT is set to NONE. ```cmake set_target_properties(example PROPERTIES COTIRE_UNITY_LINK_LIBRARIES_INIT "NONE") ... cotire(example) target_link_libraries(MyExecutable_unity ${MyExecutableLibraries}) ``` -------------------------------- ### printf example Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/README.rst A printf example for comparison with iostreams. ```c++ printf("%.2f\n", 1.23456); ``` -------------------------------- ### Prefix Header Configuration Example Source: https://github.com/slash-design/destinycore/blob/master/dep/cotire/MANUAL.md Example demonstrating how to configure COTIRE_PREFIX_HEADER_IGNORE_PATH and COTIRE_PREFIX_HEADER_INCLUDE_PATH to manage header file inclusion. ```cmake set_target_properties(example PROPERTIES COTIRE_PREFIX_HEADER_IGNORE_PATH "${CMAKE_SOURCE_DIR}" COTIRE_PREFIX_HEADER_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/Libs") ``` -------------------------------- ### Send command example Source: https://github.com/slash-design/destinycore/blob/master/contrib/ServerRelay/README.md Example of using the 'send' command with a prefix to access worldserver console commands. ```javascript .send help // will return all commands available ``` -------------------------------- ### Installation commands Source: https://github.com/slash-design/destinycore/blob/master/src/server/bnetserver/CMakeLists.txt Defines installation rules for bnetserver and related files based on the operating system. ```cmake if (UNIX) install(TARGETS bnetserver DESTINATION bin) install(FILES bnetserver.conf.dist DESTINATION ${CONF_DIR}) install(FILES bnetserver.cert.pem bnetserver.key.pem DESTINATION bin) elseif (WIN32) install(TARGETS bnetserver DESTINATION "${CMAKE_INSTALL_PREFIX}") install(FILES bnetserver.conf.dist DESTINATION "${CMAKE_INSTALL_PREFIX}") install(FILES bnetserver.cert.pem bnetserver.key.pem DESTINATION "${CMAKE_INSTALL_PREFIX}") endif() # Generate precompiled header if (USE_COREPCH) add_cxx_pch(bnetserver ${PRIVATE_PCH_HEADER}) endif() ``` -------------------------------- ### Configuration file example (config.json) Source: https://github.com/slash-design/destinycore/blob/master/contrib/ServerRelay/README.md Example structure for the config.json file, detailing Discord bot token, channel IDs, server message URLs, and command prefixes. ```json { "token": "BOT-TOKEN", "channel_id": "RELAY-CHAT-ID", "staff_channel_ID" : "STAFF-CHANNEL-ID", "post_url_server_message_world": "http://127.0.0.1:8082/sendChannelMessage/", "post_url_server_message_alliance" : "http://127.0.0.1:8082/sendChannelMessage/0", "post_url_server_message_horde" : "http://127.0.0.1:8082/sendChannelMessage/1", "post_url_server_command": "http://127.0.0.1:8082/command", "post_port": "8082", "post_token": "TOKEN FROM WORLDSERVER.CONF ON WorldREST.AuthToken, THIS ONE NEED TO MATCH HERE", "channel_horde" : "world_h", // I RECOMMEND TO NOT CHANGE IT "channel_alliance": "world_a", // I RECOMMEND TO NOT CHANGE IT "allow_interactions" : "0", // IF YOU SET TO 1, YOU NEED TO ENABLE IN WORLDSERVER.CONF THIS ONE : AllowTwoSide.Interaction.Channel. "channel_world" : "world", // I RECOMMEND TO NOT CHANGE IT "command_prefix" : "." // IS USED ON staff channel for purge command(delete the message on channels) and send command for ingame commands(is same one from console) } ``` -------------------------------- ### iostreams example Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/README.rst An example demonstrating the verbosity of iostreams for formatting. ```c++ std::cout << std::setprecision(2) << std::fixed << 1.23456 << "\n"; ``` -------------------------------- ### Named arguments example Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/ChangeLog.rst Example demonstrating the use of named arguments in fmtlib. ```c++ fmt::print("The answer is {answer}.", fmt::arg("answer", 42)); ``` -------------------------------- ### Install Shared Library Source: https://github.com/slash-design/destinycore/blob/master/src/server/shared/CMakeLists.txt Installs the shared library based on the operating system. ```cmake if( BUILD_SHARED_LIBS ) if( UNIX ) install(TARGETS shared LIBRARY DESTINATION lib) elseif( WIN32 ) install(TARGETS shared RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}") endif() endif() ``` -------------------------------- ### Quick GET Request Source: https://github.com/slash-design/destinycore/blob/master/dep/cpr/README.md An example demonstrating a simple GET request using C++ Requests, including URL, authentication, and parameters. ```c++ #include int main(int argc, char** argv) { auto r = cpr::Get(cpr::Url{"https://api.github.com/repos/whoshuu/cpr/contributors"}, cpr::Authentication{"user", "pass"}, cpr::Parameters{{"anon", "true"}, {"key", "value"}}); r.status_code; // 200 r.header["content-type"]; // application/json; charset=utf-8 r.text; // JSON text string } ``` -------------------------------- ### Installation Configuration Source: https://github.com/slash-design/destinycore/blob/master/src/server/proto/CMakeLists.txt Configures installation rules for the 'proto' library based on build type (shared libraries). ```cmake if( BUILD_SHARED_LIBS ) if( UNIX ) install(TARGETS proto LIBRARY DESTINATION lib) elseif( WIN32 ) install(TARGETS proto RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}") endif() endif() ``` -------------------------------- ### Unity Source Example (OS X) Source: https://github.com/slash-design/destinycore/blob/master/dep/cotire/MANUAL.md An example of a unity source file generated for a project on OS X, showing preprocessor include directives for source files. ```cpp #ifdef __cplusplus #include "/Users/sakra/Documents/cotire/src/main.cpp" #include "/Users/sakra/Documents/cotire/src/example.cpp" #include "/Users/sakra/Documents/cotire/src/log.cpp" #endif ``` -------------------------------- ### Purge command example Source: https://github.com/slash-design/destinycore/blob/master/contrib/ServerRelay/README.md Example of using the 'purge' command to delete a specified number of messages from a channel. ```javascript .purge 10 // delete 10 messages from channel ``` -------------------------------- ### Makefile Generator Workaround for Installation Source: https://github.com/slash-design/destinycore/blob/master/dep/cotire/MANUAL.md This workaround uses `make all_unity` followed by `make install/fast` to install binaries built by unity targets when using a Makefile generator. ```bash make all_unity make install/fast ``` -------------------------------- ### Global initialization fix example Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/ChangeLog.rst Example demonstrating a fix for global initialization issues with constexpr support. ```c++ #include #include // This works on compilers with constexpr support. static const std::string answer = fmt::format("{}", 42); ``` -------------------------------- ### Install clang-format on Ubuntu Source: https://github.com/slash-design/destinycore/blob/master/dep/cpr/CONTRIBUTING.md Command to install clang-format version 3.8 on Ubuntu systems. ```bash apt-get install clang-format-3.8 ``` -------------------------------- ### Named arguments example Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/ChangeLog.rst Example demonstrating the use of named arguments with fmt::print, which leads to more compact and efficient compiled code. ```c++ #include int main() { fmt::print("The answer is {answer}\n", fmt::arg("answer", 42)); } ``` -------------------------------- ### Logger Configuration Example Source: https://github.com/slash-design/destinycore/blob/master/doc/LoggingHOWTO.txt Example of configuring a console appender to log messages with DEBUG level or higher, prefixing log type and level. ```config Appender.Console1=1,2,6 ``` -------------------------------- ### Install {fmt} with Conda Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/ChangeLog.rst Instructions for installing the {fmt} library on Linux, macOS, and Windows using Conda and conda-forge. ```bash conda install -c conda-forge fmt ``` -------------------------------- ### Installation Rules Source: https://github.com/slash-design/destinycore/blob/master/src/common/CMakeLists.txt Defines installation rules for the 'common' library based on whether shared libraries are being built and the operating system. ```cmake if( BUILD_SHARED_LIBS ) if( UNIX ) install(TARGETS common LIBRARY DESTINATION lib) elseif( WIN32 ) install(TARGETS common RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}") endif() endif() ``` -------------------------------- ### Example 2 Log Tracing - Info Source: https://github.com/slash-design/destinycore/blob/master/doc/LoggingHOWTO.txt Traces how an info message is logged to the file appender in Example 2. ```text TC_LOG_INFO(LOG_FILTER_CHARACTER, "Player Name Logged in"); System will try to find logger of type CHARACTER, as no logger is configured for CHARACTER it will use Root logger. As message Log Level is equal or higher than the Log level of logger the message is sent to the Appenders configured in the Logger. "Console" and "Server". Console will discard msg as Log Level is not higher or equal to this appender Server will write to file "2012-08-15 INFO [CHARACTER ] Player Name Logged in" ``` -------------------------------- ### File Appender Example Source: https://github.com/slash-design/destinycore/blob/master/doc/LoggingHOWTO.txt Example of configuring a file appender to log messages with DEBUG level or higher to 'Auth.log', prefixing timestamp, type, and level. ```config Appender.File=2,2,7,Auth.log,w ``` -------------------------------- ### Colored Console Appender Example Source: https://github.com/slash-design/destinycore/blob/master/doc/LoggingHOWTO.txt Example of configuring a console appender to log messages with ERROR level or higher, prefixing timestamp and using colored text. ```config Appender.Console2=1,5,1,13 11 9 5 3 1 ``` -------------------------------- ### Example 1 Log Tracing - Info Source: https://github.com/slash-design/destinycore/blob/master/doc/LoggingHOWTO.txt Traces how an info message is logged and then discarded. ```text TC_LOG_INFO(LOG_FILTER_CHARACTER, "Player Name Logged in"); System will try to find logger of type CHARACTER, as no logger is configured for CHARACTER it will use Root logger. As message Log Level is not equal or higher than the Log level of logger the message its discarted. ``` -------------------------------- ### Core API example Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/ChangeLog.rst Basic usage of the fmt::print function from the core API. ```c++ #include fmt::print("The answer is {}.", 42); ``` -------------------------------- ### Package Meta-data Setup Source: https://github.com/slash-design/destinycore/blob/master/dep/cpr/opt/curl/CMakeLists.txt Sets up package meta-data and prints the curl version. ```cmake # SET(PACKAGE "curl") message(STATUS "curl version=[${CURL_VERSION}]") # SET(PACKAGE_TARNAME "curl") # SET(PACKAGE_NAME "curl") # SET(PACKAGE_VERSION "-") # SET(PACKAGE_STRING "curl-") ``` -------------------------------- ### Example 1 Log Tracing - Error Source: https://github.com/slash-design/destinycore/blob/master/doc/LoggingHOWTO.txt Traces how an error message is logged. ```text TC_LOG_ERROR(LOG_FILTER_GUILD, "Guild 1 created"); System will try to find logger of type GUILD, as no logger is configured for GUILD it will use Root logger. As message Log Level is equal or higher than the Log level of logger the message is sent to the Appenders configured in the Logger. "Console" and "Server". Console will write: "ERROR [GUILD ] Guild 1 created" Server will write to file "2012-08-15 ERROR [GUILD ] Guild 1 created" ``` -------------------------------- ### Print to stdout Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/README.rst A basic example demonstrating how to print "Hello, world!" to the standard output using fmt::print. ```c++ #include int main() { fmt::print("Hello, world!\n"); } ``` -------------------------------- ### Example 2 Configuration Source: https://github.com/slash-design/destinycore/blob/master/doc/LoggingHOWTO.txt Configures console and file appenders, and sets the root logger to log info and above. ```config Appender.Console=1,5,6 Appender.Server=2,4,15,Server.log Logger.root=4,Console Server ``` -------------------------------- ### Example 1 Configuration Source: https://github.com/slash-design/destinycore/blob/master/doc/LoggingHOWTO.txt Configures console and file appenders, and sets the root logger to log errors. ```config Appender.Console=1,5,6 Appender.Server=2,5,7,Server.log,w Logger.root=5,Console Server ``` -------------------------------- ### Interactive Program Notice Source: https://github.com/slash-design/destinycore/blob/master/doc/GPL-2.0.txt An example of a short notice to be displayed by an interactive program when it starts. ```text Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. ``` -------------------------------- ### Install Headers Source: https://github.com/slash-design/destinycore/blob/master/dep/cpr/opt/curl/CMakeLists.txt Installs the curl header files to the include directory. ```cmake # install headers install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/curl" DESTINATION include FILES_MATCHING PATTERN "*.h") ``` -------------------------------- ### Running the server on Linux Source: https://github.com/slash-design/destinycore/blob/master/contrib/ServerRelay/README.md Commands to make the run.sh script executable and run it in the background on Linux. Also includes notes on setting up a crontab. ```bash chmod +x run.sh ./linux.sh & // OPTIONALY CAND SET A CRONTAB WITH run.sh. THE SERVER IF IS WILL CRASH, THE NODEMON WILL TAKE OF SERVER.JS. IF YOU WANT TO SETUP CRONTAB ON THE END NOT SPECIFY `` BECAUSE IS ALREADY SPECIFIED ON linux.sh ``` -------------------------------- ### Generate and Install curl-config Source: https://github.com/slash-design/destinycore/blob/master/dep/cpr/opt/curl/CMakeLists.txt Generates the 'curl-config' script from a template and installs it to the bin directory. ```cmake # Finally generate a "curl-config" matching this config configure_file("${CURL_SOURCE_DIR}/curl-config.in" "${CURL_BINARY_DIR}/curl-config" @ONLY) install(FILES "${CURL_BINARY_DIR}/curl-config" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) ``` -------------------------------- ### Clone and build benchmarks Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/README.rst Instructions for cloning the benchmarks repository and generating Makefiles with CMake. ```bash $ git clone --recursive https://github.com/fmtlib/format-benchmark.git $ cd format-benchmark $ cmake . ``` -------------------------------- ### Example 2 Log Tracing - Error Source: https://github.com/slash-design/destinycore/blob/master/doc/LoggingHOWTO.txt Traces how an error message is logged in Example 2. ```text TC_LOG_ERROR(LOG_FILTER_GUILD, "Guild 1 created"); Performs exactly as example 1. ``` -------------------------------- ### Example 3 Configuration Source: https://github.com/slash-design/destinycore/blob/master/doc/LoggingHOWTO.txt Configures console and file appenders for specific loggers (guild, character, sql.dev) and a default disabled root logger. ```config Appender.Console=1,1 Appender.SQLDev=2,2,0,SQLDev.log Logger.guild=1,Console Logger.entities.player.character=3,Console Logger.sql.dev=3,SQLDev ``` -------------------------------- ### Install clang-format on OS X Source: https://github.com/slash-design/destinycore/blob/master/dep/cpr/CONTRIBUTING.md Command to install clang-format on OS X using Homebrew. ```bash brew install clang-format ``` -------------------------------- ### Assembly output for FMT_COMPILE example Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/ChangeLog.rst Assembly code generated for the FMT_COMPILE example with single code units. ```asm _Z1fPc: movb $120, (%rdi) xorl %edx, %edx ``` -------------------------------- ### Movement Extractor Examples Source: https://github.com/slash-design/destinycore/blob/master/src/tools/mmaps_generator/Info/readme.txt Examples of how to run the movement_extractor tool with different arguments. ```bash movement_extractor builds maps using the default settings (see above for defaults) ``` ```bash movement_extractor --skipContinents true builds the default maps, except continents ``` ```bash movement_extractor 0 builds all tiles of map 0 ``` ```bash movement_extractor 0 --tile 34,46 builds only tile 34,46 of map 0 (this is the southern face of blackrock mountain) ``` -------------------------------- ### Run benchmark tests Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/README.rst Commands to run the speed test and bloat test for the benchmarks. ```bash $ make speed-test ``` ```bash $ make bloat-test ``` -------------------------------- ### Print with colors and text styles Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/README.rst Example of printing text with various colors and text styles using fmt::print. ```c++ #include int main() { fmt::print(fg(fmt::color::crimson) | fmt::emphasis::bold, "Hello, {}!\n", "world"); fmt::print(fg(fmt::color::floral_white) | bg(fmt::color::slate_gray) | fmt::emphasis::underline, "Hello, {}!\n", "мир"); fmt::print(fg(fmt::color::steel_blue) | fmt::emphasis::italic, "Hello, {}!\n", "世界"); } ``` -------------------------------- ### Running the server on Windows Source: https://github.com/slash-design/destinycore/blob/master/contrib/ServerRelay/README.md Command to run the server on Windows. Note: Will run without a CMD prompt visible. ```batch Run the file windows.vbs ``` -------------------------------- ### Example of setting COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES for optimization Source: https://github.com/slash-design/destinycore/blob/master/dep/cotire/MANUAL.md Demonstrates setting the cache variable to control the maximum number of includes per unity source file, useful for large projects or multi-core builds. ```bash $ cmake -D COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES=-j4 $ make -j 4 ``` -------------------------------- ### Generate and Install pkg-config file Source: https://github.com/slash-design/destinycore/blob/master/dep/cpr/opt/curl/CMakeLists.txt Generates the 'libcurl.pc' file for pkg-config from a template and installs it to the lib/pkgconfig directory. ```cmake # Finally generate a pkg-config file matching this config configure_file("${CURL_SOURCE_DIR}/libcurl.pc.in" "${CURL_BINARY_DIR}/libcurl.pc" @ONLY) install(FILES "${CURL_BINARY_DIR}/libcurl.pc" DESTINATION lib/pkgconfig) ``` -------------------------------- ### Example of conditionally loading cotire Source: https://github.com/slash-design/destinycore/blob/master/dep/cotire/MANUAL.md Shows a robust way to include and use the cotire module in CMakeLists.txt, handling cases where cotire might not be available. ```cmake include(cotire OPTIONAL) ... add_executable(example main.cpp example.cpp log.cpp log.h example.h) ... if (COMMAND cotire) cotire(example) endif() ``` -------------------------------- ### UTF-8 handling example Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/ChangeLog.rst Example demonstrating improved UTF-8 handling, printing a Unicode string with box-drawing characters. ```c++ fmt::print("┌{0:─^{2}}┐\n" "│{1: ^{2}}│\n" "└{0:─^{2}}┘\n", "", "Привет, мир!", 20); ``` -------------------------------- ### Prefix Header Example (Visual Studio 2013, Windows 7) Source: https://github.com/slash-design/destinycore/blob/master/dep/cotire/MANUAL.md A prefix header generated for a project using Visual Studio 2013 on Windows 7, including standard library headers. ```cpp #pragma warning(push, 0) #ifdef __cplusplus #include "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\string" #include "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\algorithm" #include "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\iostream" #endif #pragma warning(pop) ``` -------------------------------- ### Building RecastDemo on Windows Source: https://github.com/slash-design/destinycore/blob/master/dep/recastnavigation/README.md Instructions for building the RecastDemo project on Windows using premake5 and Visual Studio. ```bash "premake5" vs2015 # Open the solution, build, and run. ``` -------------------------------- ### Prefix Header Example (Xcode 5.1, OS X 10.9) Source: https://github.com/slash-design/destinycore/blob/master/dep/cotire/MANUAL.md A prefix header generated for a project using Xcode 5.1 on OS X 10.9, including standard library headers. ```cpp #pragma clang system_header #ifdef __cplusplus #include "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/string" #include "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/iostream" #endif ``` -------------------------------- ### Feature Detection Examples Source: https://github.com/slash-design/destinycore/blob/master/dep/cpr/opt/curl/CMakeLists.txt Examples of using CMake's check_symbol_exists to detect various C functions and macros. ```cmake if(HAVE_SIZEOF_LONG_LONG) set(HAVE_LONGLONG 1) set(HAVE_LL 1) endif(HAVE_SIZEOF_LONG_LONG) find_file(RANDOM_FILE urandom /dev) mark_as_advanced(RANDOM_FILE) # Check for some functions that are used if(HAVE_LIBWS2_32) set(CMAKE_REQUIRED_LIBRARIES ws2_32) elseif(HAVE_LIBSOCKET) set(CMAKE_REQUIRED_LIBRARIES socket) endif() check_symbol_exists(basename "${CURL_INCLUDES}" HAVE_BASENAME) check_symbol_exists(socket "${CURL_INCLUDES}" HAVE_SOCKET) # poll on macOS is unreliable, it first did not exist, then was broken until # fixed in 10.9 only to break again in 10.12. if(NOT APPLE) check_symbol_exists(poll "${CURL_INCLUDES}" HAVE_POLL) endif() check_symbol_exists(select "${CURL_INCLUDES}" HAVE_SELECT) check_symbol_exists(strdup "${CURL_INCLUDES}" HAVE_STRDUP) check_symbol_exists(strstr "${CURL_INCLUDES}" HAVE_STRSTR) check_symbol_exists(strtok_r "${CURL_INCLUDES}" HAVE_STRTOK_R) check_symbol_exists(strftime "${CURL_INCLUDES}" HAVE_STRFTIME) check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME) check_symbol_exists(strcasecmp "${CURL_INCLUDES}" HAVE_STRCASECMP) check_symbol_exists(stricmp "${CURL_INCLUDES}" HAVE_STRICMP) check_symbol_exists(strcmpi "${CURL_INCLUDES}" HAVE_STRCMPI) check_symbol_exists(strncmpi "${CURL_INCLUDES}" HAVE_STRNCMPI) check_symbol_exists(alarm "${CURL_INCLUDES}" HAVE_ALARM) if(NOT HAVE_STRNCMPI) set(HAVE_STRCMPI) endif(NOT HAVE_STRNCMPI) check_symbol_exists(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR) check_symbol_exists(gethostbyaddr_r "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR_R) check_symbol_exists(gettimeofday "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY) check_symbol_exists(inet_addr "${CURL_INCLUDES}" HAVE_INET_ADDR) check_symbol_exists(inet_ntoa "${CURL_INCLUDES}" HAVE_INET_NTOA) check_symbol_exists(inet_ntoa_r "${CURL_INCLUDES}" HAVE_INET_NTOA_R) check_symbol_exists(tcsetattr "${CURL_INCLUDES}" HAVE_TCSETATTR) check_symbol_exists(tcgetattr "${CURL_INCLUDES}" HAVE_TCGETATTR) check_symbol_exists(perror "${CURL_INCLUDES}" HAVE_PERROR) check_symbol_exists(closesocket "${CURL_INCLUDES}" HAVE_CLOSESOCKET) check_symbol_exists(setvbuf "${CURL_INCLUDES}" HAVE_SETVBUF) check_symbol_exists(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP) check_symbol_exists(getpass_r "${CURL_INCLUDES}" HAVE_GETPASS_R) check_symbol_exists(strlcat "${CURL_INCLUDES}" HAVE_STRLCAT) check_symbol_exists(getpwuid "${CURL_INCLUDES}" HAVE_GETPWUID) check_symbol_exists(geteuid "${CURL_INCLUDES}" HAVE_GETEUID) check_symbol_exists(utime "${CURL_INCLUDES}" HAVE_UTIME) check_symbol_exists(gmtime_r "${CURL_INCLUDES}" HAVE_GMTIME_R) check_symbol_exists(localtime_r "${CURL_INCLUDES}" HAVE_LOCALTIME_R) check_symbol_exists(gethostbyname "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME) check_symbol_exists(gethostbyname_r "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME_R) check_symbol_exists(signal "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC) check_symbol_exists(SIGALRM "${CURL_INCLUDES}" HAVE_SIGNAL_MACRO) if(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO) set(HAVE_SIGNAL 1) endif(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO) check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME) check_symbol_exists(strtoll "${CURL_INCLUDES}" HAVE_STRTOLL) check_symbol_exists(_strtoi64 "${CURL_INCLUDES}" HAVE__STRTOI64) check_symbol_exists(strerror_r "${CURL_INCLUDES}" HAVE_STRERROR_R) check_symbol_exists(siginterrupt "${CURL_INCLUDES}" HAVE_SIGINTERRUPT) check_symbol_exists(perror "${CURL_INCLUDES}" HAVE_PERROR) check_symbol_exists(fork "${CURL_INCLUDES}" HAVE_FORK) check_symbol_exists(getaddrinfo "${CURL_INCLUDES}" HAVE_GETADDRINFO) check_symbol_exists(freeaddrinfo "${CURL_INCLUDES}" HAVE_FREEADDRINFO) check_symbol_exists(freeifaddrs "${CURL_INCLUDES}" HAVE_FREEIFADDRS) check_symbol_exists(pipe "${CURL_INCLUDES}" HAVE_PIPE) check_symbol_exists(ftruncate "${CURL_INCLUDES}" HAVE_FTRUNCATE) check_symbol_exists(getprotobyname "${CURL_INCLUDES}" HAVE_GETPROTOBYNAME) check_symbol_exists(getrlimit "${CURL_INCLUDES}" HAVE_GETRLIMIT) check_symbol_exists(setlocale "${CURL_INCLUDES}" HAVE_SETLOCALE) check_symbol_exists(setrlimit "${CURL_INCLUDES}" HAVE_SETRLIMIT) check_symbol_exists(fcntl "${CURL_INCLUDES}" HAVE_FCNTL) check_symbol_exists(ioctl "${CURL_INCLUDES}" HAVE_IOCTL) check_symbol_exists(setsockopt "${CURL_INCLUDES}" HAVE_SETSOCKOPT) ``` -------------------------------- ### Format a string Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/README.rst Example of formatting an integer into a string using fmt::format. ```c++ std::string s = fmt::format("The answer is {}. ", 42); // s == "The answer is 42." ``` -------------------------------- ### Applying Cotire to Multiple Targets Source: https://github.com/slash-design/destinycore/blob/master/dep/cotire/MANUAL.md Demonstrates how to apply the `cotire` function to multiple targets simultaneously. ```cmake add_library(libA STATIC ...) add_library(libB SHARED ...) add_executable(example ...) ... cotire(example libA libB) ``` -------------------------------- ### Database Update Example Source: https://github.com/slash-design/destinycore/blob/master/doc/CharacterDBCleanup.txt Example of how to update the worldstates table to trigger character database cleanup for skills, spells, and talents. ```sql UPDATE worldstates SET value=14 WHERE entry=20004; ``` -------------------------------- ### Building RecastDemo on Linux Source: https://github.com/slash-design/destinycore/blob/master/dep/recastnavigation/README.md Instructions for building the RecastDemo project on Linux using premake5 and make. ```bash premake5 gmake cd Build/gmake make Run RecastDemo\Bin\RecastDemo ``` -------------------------------- ### Install Game Library Source: https://github.com/slash-design/destinycore/blob/master/src/server/game/CMakeLists.txt Configures installation rules for the game library based on the build type (shared libraries) and operating system. ```cmake if( BUILD_SHARED_LIBS ) if( UNIX ) install(TARGETS game LIBRARY DESTINATION lib) elseif( WIN32 ) install(TARGETS game RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}") endif() endif() ``` -------------------------------- ### Dependency Tracking for Prefix Header Source: https://github.com/slash-design/destinycore/blob/master/dep/cotire/MANUAL.md Example showing how to set the COTIRE_DEPENDENCY property on a source file to make prefix header creation dependent on its changes. ```cmake set_property (SOURCE "example.cpp" PROPERTY COTIRE_DEPENDENCY "TRUE") ``` -------------------------------- ### CMake Minimum Requirement and Module Path Setup Source: https://github.com/slash-design/destinycore/blob/master/dep/cpr/opt/curl/CMakeLists.txt Sets the minimum required CMake version and adds custom module paths. ```cmake cmake_minimum_required(VERSION 2.8 FATAL_ERROR) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}") ``` -------------------------------- ### Customized Inclusion of System Headers with `add_definitions` Source: https://github.com/slash-design/destinycore/blob/master/dep/cotire/MANUAL.md Example of how to use `add_definitions` to ensure preprocessor defines are applied when system headers are included in a precompiled header, preventing macro conflicts. ```cmake if (WIN32) # prevent definition of min and max macros through inclusion of Windows.h add_definitions("-DNOMINMAX") endif() ``` -------------------------------- ### Prefix Header Example (GCC 4.6, Ubuntu 12.04) Source: https://github.com/slash-design/destinycore/blob/master/dep/cotire/MANUAL.md A prefix header generated for a project using GCC 4.6 on Ubuntu 12.04, including standard library headers. ```cpp #pragma GCC system_header #ifdef __cplusplus #include "/usr/include/c++/4.6/string" #include "/usr/include/c++/4.6/algorithm" #include "/usr/include/c++/4.6/iterator" #include "/usr/include/c++/4.6/iostream" #endif ``` -------------------------------- ### Use Generated Prefix Header for Multiple Targets Source: https://github.com/slash-design/destinycore/blob/master/dep/cotire/MANUAL.md Example demonstrating how to apply a generated prefix header from one target to another. ```cmake cotire(example) get_target_property(_prefixHeader example COTIRE_CXX_PREFIX_HEADER) ... set_target_properties(other_target PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "${_prefixHeader}") cotire(other_target) ``` -------------------------------- ### RPATH Handling Source: https://github.com/slash-design/destinycore/blob/master/CMakeLists.txt Configures RPATH handling for the build and installation. ```cmake set(CMAKE_SKIP_BUILD_RPATH 0) set(CMAKE_BUILD_WITH_INSTALL_RPATH 0) list(APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") set(CMAKE_INSTALL_RPATH_USE_LINK_PATH 1) ``` -------------------------------- ### Write a file from a single thread Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/README.rst Example of writing to a file using fmt::output_file. ```c++ #include int main() { auto out = fmt::output_file("guide.txt"); out.print("Don't {}", "Panic"); } ``` -------------------------------- ### Boolean formatting (numeric) Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/ChangeLog.rst Example of formatting booleans as numbers. ```c++ fmt::print("{:d}\\n", true); ``` -------------------------------- ### Literals Source: https://github.com/slash-design/destinycore/blob/master/dep/fmt/ChangeLog.rst Example of using fmt::literals for named arguments. ```c++ using namespace fmt::literals; fmt::print("The answer is {answer}.\n", "answer"_a=42); ```