diff --git a/.gitignore b/.gitignore
index 8227eacb..211b039b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,6 +33,7 @@ bld/
[Ll]og/
[Ll]ogs/
/[Gg]ame/
+build_intermediate/
# Visual Studio 2015/2017 cache/options directory
.vs/
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 00000000..263b21c3
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,18 @@
+cmake_minimum_required( VERSION 3.16 )
+project( r5sdk )
+
+include( "r5dev/cmake/Configure.cmake" )
+include( "r5dev/cmake/Macros.cmake" )
+include( "r5dev/cmake/Options.cmake" )
+
+initial_setup()
+setup_build_configurations()
+define_compiler_variables()
+apply_project_settings()
+
+include_directories( "${ENGINE_SOURCE_DIR}" )
+include_directories( "${ENGINE_SOURCE_DIR}/public" )
+include_directories( "${ENGINE_SOURCE_DIR}/thirdparty" )
+
+# Include the subdirectories that contain the individual projects
+add_subdirectory( "${ENGINE_SOURCE_DIR}" )
diff --git a/CreateSolution.bat b/CreateSolution.bat
new file mode 100644
index 00000000..ab3a3f56
--- /dev/null
+++ b/CreateSolution.bat
@@ -0,0 +1,38 @@
+@echo off
+setlocal
+
+set BUILDDIR=build_intermediate
+set BINDIR=game
+
+REM Check for Visual Studio versions in order
+for %%V in (15 16 17) do (
+ reg query "HKEY_CLASSES_ROOT\VisualStudio.DTE.%%V.0" >> nul 2>&1
+ if NOT ERRORLEVEL 1 (
+ if "%%V"=="15" (
+ set "CMAKE_GENERATOR=Visual Studio 15 2017"
+ ) else if "%%V"=="16" (
+ set "CMAKE_GENERATOR=Visual Studio 16 2019"
+ ) else if "%%V"=="17" (
+ set "CMAKE_GENERATOR=Visual Studio 17 2022"
+ )
+ echo Using Visual Studio %%V as generator.
+ goto :build
+ )
+)
+
+echo Could not find a supported version of Visual Studio; exiting...
+exit /b 1
+
+:build
+if not exist "%BUILDDIR%" (
+ mkdir "%BUILDDIR%"
+)
+if not exist "%BINDIR%" (
+ mkdir "%BINDIR%"
+)
+
+cd "%BUILDDIR%"
+cmake .. -G"%CMAKE_GENERATOR%" -A"x64"
+cd ..
+
+echo Finished generating solution files.
diff --git a/README.md b/README.md
index 91960958..ed1493c0 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,7 @@
* This repository houses the source code for the development package targeting the game **Apex Legends**.
## Building
+R5sdk uses the CMake project generation and build tools. For more information, visit [CMake](https://cmake.org/).
In order to compile the SDK, you will need to install Visual Studio 2017, 2019 or 2022 with:
* Desktop Development with C++ Package.
* Windows SDK 10.0.10240.0 or higher.
@@ -9,13 +10,12 @@ In order to compile the SDK, you will need to install Visual Studio 2017, 2019 o
* [Optional] C++ Clang/LLVM compiler.
Steps:
-1. Download or clone the solution to anywhere on your disk.
- 1. In the folder `r5sdk.sln` resides, create a new folder called `game`.
+1. Download or clone the project to anywhere on your disk.
+ 1. Run `CreateSolution.bat` in the root folder, this will generate the files in `build_intermediate`.
2. Move all the game files in the `game` folder so that the path `game/r5apex(_ds).exe` is valid.
2. Open `r5sdk.sln` in Visual Studio and compile the solution.
- 1. Depending on your version of Visual Studio and the selected compiler, you might need to re-target the solution.
- 2. All binaries and symbols are compiled in the `game` folder.
- 3. Run `launcher.exe`, toggle and set the desired options and hit the `Launch Game` button.
+ 1. All binaries and symbols are compiled in the `game` folder.
+ 2. Run `launcher.exe`, toggle and set the desired options and hit the `Launch Game` button.
## Debugging
The tools and libraries offered by the SDK could be debugged right after they are compiled.
@@ -35,11 +35,11 @@ Steps:
- The `-nosmap` parameter instructs the SDK to always compute the RVA's of each function signature on launch (!! slow !!).
- The `-noworkerdll` parameter prevents the GameSDK DLL from initializing (workaround as the DLL is imported by the game executable).
-Launch parameters can be added to the `startup_*.cfg` files,
+Launch parameters can be added to the `startup_*.cfg` files,
which are located in `\platform\cfg\startup_*.cfg`.
## Note [IMPORTANT]
-This is not a cheat or hack; attempting to use the SDK on the live version of the game could result in a permanent account ban.
+This is not a cheat or hack; attempting to use the SDK on the live version of the game could result in a permanent account ban.
The supported game versions are:
* S0 `R5pc_r5launch_J1557_CL387233_2019_01_28_07_43_PM`.
diff --git a/r5dev/CMakeLists.txt b/r5dev/CMakeLists.txt
new file mode 100644
index 00000000..cfc2ccd5
--- /dev/null
+++ b/r5dev/CMakeLists.txt
@@ -0,0 +1,66 @@
+cmake_minimum_required( VERSION 3.16 )
+
+set( FOLDER_CONTEXT "Foundation" )
+add_subdirectory( vpc ) # VPC and Tier0 must be the first as this creates the shared PCH!
+add_subdirectory( tier0 )
+add_subdirectory( tier1 )
+add_subdirectory( tier2 )
+add_subdirectory( launcher )
+add_subdirectory( protoc )
+add_subdirectory( appframework )
+
+set( FOLDER_CONTEXT "Libraries" )
+add_subdirectory( mathlib )
+add_subdirectory( vpklib )
+add_subdirectory( vstdlib )
+add_subdirectory( vphysics )
+add_subdirectory( ebisusdk )
+add_subdirectory( codecs )
+
+set( FOLDER_CONTEXT "UI" )
+add_subdirectory( vguimatsurface )
+add_subdirectory( vgui )
+
+set( FOLDER_CONTEXT "Respawn" )
+add_subdirectory( rtech )
+
+set( FOLDER_CONTEXT "Thirdparty" )
+add_subdirectory( thirdparty/cppnet )
+add_subdirectory( thirdparty/curl )
+add_subdirectory( thirdparty/sdl )
+add_subdirectory( thirdparty/imgui )
+add_subdirectory( thirdparty/spdlog )
+add_subdirectory( thirdparty/lzham )
+add_subdirectory( thirdparty/fastlz )
+
+set( FOLDER_CONTEXT "Thirdparty/Recast" )
+add_subdirectory( thirdparty/recast )
+
+set( FOLDER_CONTEXT "Thirdparty/Microsoft" )
+add_subdirectory( thirdparty/detours )
+
+set( FOLDER_CONTEXT "Thirdparty/Google" )
+add_subdirectory( thirdparty/protobuf )
+
+set( FOLDER_CONTEXT "Tools" )
+add_subdirectory( sdklauncher )
+add_subdirectory( netconsole )
+add_subdirectory( naveditor )
+
+set( FOLDER_CONTEXT "System" )
+add_subdirectory( networksystem )
+add_subdirectory( pluginsystem )
+add_subdirectory( materialsystem )
+add_subdirectory( inputsystem )
+add_subdirectory( filesystem )
+add_subdirectory( datacache )
+add_subdirectory( localize )
+add_subdirectory( engine )
+
+set( FOLDER_CONTEXT "Plugins" )
+add_subdirectory( pluginsdk )
+
+set( FOLDER_CONTEXT "Game" )
+add_subdirectory( vscript )
+add_subdirectory( game )
+add_subdirectory( core )
diff --git a/r5dev/appframework/CMakeLists.txt b/r5dev/appframework/CMakeLists.txt
new file mode 100644
index 00000000..f70fb886
--- /dev/null
+++ b/r5dev/appframework/CMakeLists.txt
@@ -0,0 +1,15 @@
+cmake_minimum_required( VERSION 3.16 )
+add_module( "lib" "appframework" "vpc" ${FOLDER_CONTEXT} )
+
+start_sources()
+
+add_sources( SOURCE_GROUP "Private"
+ "IAppSystemGroup.cpp"
+)
+
+add_sources( SOURCE_GROUP "Public"
+ "${ENGINE_SOURCE_DIR}/public/appframework/IAppSystem.h"
+ "${ENGINE_SOURCE_DIR}/public/appframework/IAppSystemGroup.h"
+)
+
+end_sources()
diff --git a/r5dev/public/appframework/IAppSystemGroup.cpp b/r5dev/appframework/IAppSystemGroup.cpp
similarity index 90%
rename from r5dev/public/appframework/IAppSystemGroup.cpp
rename to r5dev/appframework/IAppSystemGroup.cpp
index 6699985f..d5b3e1df 100644
--- a/r5dev/public/appframework/IAppSystemGroup.cpp
+++ b/r5dev/appframework/IAppSystemGroup.cpp
@@ -1,4 +1,4 @@
-//===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
+//===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose: Defines a group of app systems that all have the same lifetime
// that need to be connected/initialized, etc. in a well-defined order
@@ -7,7 +7,7 @@
// $NoKeywords: $
//===========================================================================//
#include "core/stdafx.h"
-#include "IAppSystemGroup.h"
+#include "appframework/IAppSystemGroup.h"
//-----------------------------------------------------------------------------
// Purpose: Initialize plugin system
diff --git a/r5dev/bonesetup/bone_utils.cpp b/r5dev/bonesetup/bone_utils.cpp
deleted file mode 100644
index 6154b971..00000000
--- a/r5dev/bonesetup/bone_utils.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-//===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//
-//===========================================================================//
-
-#include "core/stdafx.h"
-#include "mathlib/mathlib.h"
-
-//-----------------------------------------------------------------------------
-// Purpose: qt = ( s * p ) * q
-//-----------------------------------------------------------------------------
-void QuaternionSM(float s, const Quaternion& p, const Quaternion& q, Quaternion& qt)
-{
- Quaternion p1, q1;
-
- QuaternionScale(p, s, p1);
- QuaternionMult(p1, q, q1);
- QuaternionNormalize(q1);
- qt[0] = q1[0];
- qt[1] = q1[1];
- qt[2] = q1[2];
- qt[3] = q1[3];
-}
-
-#if ALLOW_SIMD_QUATERNION_MATH
-FORCEINLINE fltx4 QuaternionSMSIMD(const fltx4& s, const fltx4& p, const fltx4& q)
-{
- fltx4 p1, q1, result;
- p1 = QuaternionScaleSIMD(p, s);
- q1 = QuaternionMultSIMD(p1, q);
- result = QuaternionNormalizeSIMD(q1);
- return result;
-}
-
-FORCEINLINE fltx4 QuaternionSMSIMD(float s, const fltx4& p, const fltx4& q)
-{
- return QuaternionSMSIMD(ReplicateX4(s), p, q);
-}
-#endif
-
-//-----------------------------------------------------------------------------
-// Purpose: qt = p * ( s * q )
-//-----------------------------------------------------------------------------
-void QuaternionMA(const Quaternion& p, float s, const Quaternion& q, Quaternion& qt)
-{
- Quaternion p1, q1;
-
- QuaternionScale(q, s, q1);
- QuaternionMult(p, q1, p1);
- QuaternionNormalize(p1);
- qt[0] = p1[0];
- qt[1] = p1[1];
- qt[2] = p1[2];
- qt[3] = p1[3];
-}
-
-#if ALLOW_SIMD_QUATERNION_MATH
-
-FORCEINLINE fltx4 QuaternionMASIMD(const fltx4& p, const fltx4& s, const fltx4& q)
-{
- fltx4 p1, q1, result;
- q1 = QuaternionScaleSIMD(q, s);
- p1 = QuaternionMultSIMD(p, q1);
- result = QuaternionNormalizeSIMD(p1);
- return result;
-}
-
-FORCEINLINE fltx4 QuaternionMASIMD(const fltx4& p, float s, const fltx4& q)
-{
- return QuaternionMASIMD(p, ReplicateX4(s), q);
-}
-#endif
-
-
-//-----------------------------------------------------------------------------
-// Purpose: qt = p + s * q
-//-----------------------------------------------------------------------------
-void QuaternionAccumulate(const Quaternion& p, float s, const Quaternion& q, Quaternion& qt)
-{
- Quaternion q2;
- QuaternionAlign(p, q, q2);
-
- qt[0] = p[0] + s * q2[0];
- qt[1] = p[1] + s * q2[1];
- qt[2] = p[2] + s * q2[2];
- qt[3] = p[3] + s * q2[3];
-}
-
-#if ALLOW_SIMD_QUATERNION_MATH
-FORCEINLINE fltx4 QuaternionAccumulateSIMD(const fltx4& p, float s, const fltx4& q)
-{
- fltx4 q2, s4, result;
- q2 = QuaternionAlignSIMD(p, q);
- s4 = ReplicateX4(s);
- result = MaddSIMD(s4, q2, p);
- return result;
-}
-#endif
diff --git a/r5dev/cmake/Configure.cmake b/r5dev/cmake/Configure.cmake
new file mode 100644
index 00000000..c1f81670
--- /dev/null
+++ b/r5dev/cmake/Configure.cmake
@@ -0,0 +1,22 @@
+# -----------------------------------------------------------------------------
+# Initial setup for build system
+# -----------------------------------------------------------------------------
+macro( initial_setup )
+ set( CMAKE_CXX_STANDARD 17 )
+ set( CMAKE_CXX_STANDARD_REQUIRED True )
+
+ set(ENGINE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/r5dev" CACHE PATH "Engine source directory")
+
+ set( GLOBAL_PCH
+ "${ENGINE_SOURCE_DIR}/core/stdafx.h"
+ ) # Global precompiled header shared among all libraries
+
+ set_property( GLOBAL PROPERTY USE_FOLDERS ON ) # Use filters
+endmacro()
+
+# -----------------------------------------------------------------------------
+# Set global configuration types
+# -----------------------------------------------------------------------------
+macro( setup_build_configurations )
+ set( CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE )
+endmacro()
diff --git a/r5dev/cmake/Macros.cmake b/r5dev/cmake/Macros.cmake
new file mode 100644
index 00000000..004c924a
--- /dev/null
+++ b/r5dev/cmake/Macros.cmake
@@ -0,0 +1,95 @@
+# -----------------------------------------------------------------------------
+# Start the source file list
+# -----------------------------------------------------------------------------
+macro( start_sources )
+ add_sources( SOURCE_GROUP ""
+ # Add the CMakeLists file to the project filter root
+ "CMakeLists.txt"
+)
+endmacro()
+
+# -----------------------------------------------------------------------------
+# Add source files to target within a project filter
+# -----------------------------------------------------------------------------
+macro( add_sources )
+ set( options )
+ set( oneValueArgs SOURCE_GROUP )
+ set( multiValueArgs )
+
+ cmake_parse_arguments( ADD_SOURCES
+ "${options}"
+ "${oneValueArgs}"
+ "${multiValueArgs}" ${ARGN}
+ )
+
+ if( NOT ADD_SOURCES_SOURCE_GROUP )
+ message( FATAL_ERROR "SOURCE_GROUP must be provided" )
+ endif()
+
+ source_group( "${ADD_SOURCES_SOURCE_GROUP}" FILES ${ADD_SOURCES_UNPARSED_ARGUMENTS} )
+ target_sources( ${PROJECT_NAME} PRIVATE ${ADD_SOURCES_UNPARSED_ARGUMENTS} )
+endmacro()
+
+# -----------------------------------------------------------------------------
+# End the source file list ( optional parameter sets the runtime output dir )
+# -----------------------------------------------------------------------------
+macro( end_sources )
+ if( NOT "${ARGN}" STREQUAL "" ) # Check if an output directory is passed
+ set_target_output_dirs( ${PROJECT_NAME} ${ARGN} )
+ else()
+ set_target_output_dirs( ${PROJECT_NAME} "game/" )
+ endif()
+endmacro()
+
+# -----------------------------------------------------------------------------
+# Add modules to the project
+# -----------------------------------------------------------------------------
+macro( add_module MODULE_TYPE MODULE_NAME REUSE_PCH FOLDER_NAME )
+ project( ${MODULE_NAME} )
+
+ if( ${MODULE_TYPE} STREQUAL "lib" )
+ add_library( ${PROJECT_NAME} )
+ elseif( ${MODULE_TYPE} STREQUAL "shared_lib" )
+ add_library( ${PROJECT_NAME} SHARED )
+ target_link_options( ${PROJECT_NAME} PRIVATE
+ "$<$:/LTCG>"
+ )
+ elseif(${MODULE_TYPE} STREQUAL "exe")
+ add_executable( ${PROJECT_NAME} )
+ target_link_options( ${PROJECT_NAME} PRIVATE
+ "$<$:/LTCG>"
+ )
+ else()
+ message( FATAL_ERROR "Invalid module type: ${MODULE_TYPE}; expected 'lib', 'shared_lib', or 'exe'." )
+ endif()
+
+ if ( NOT "${REUSE_PCH}" STREQUAL "" )
+ target_precompile_headers( ${PROJECT_NAME} REUSE_FROM ${REUSE_PCH} )
+ endif()
+
+ set_target_properties( ${MODULE_NAME} PROPERTIES FOLDER ${FOLDER_NAME} )
+endmacro()
+
+# -----------------------------------------------------------------------------
+# Initialize global compiler defines
+# -----------------------------------------------------------------------------
+macro( define_compiler_variables )
+ if( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
+ add_definitions( -DCOMPILER_MSVC )
+ elseif( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
+ add_definitions( -DCOMPILER_CLANG )
+ elseif( CMAKE_CXX_COMPILER_ID MATCHES "GNU" )
+ add_definitions( -DCOMPILER_GCC )
+ else()
+ message( FATAL_ERROR "Unsupported compiler: ${CMAKE_CXX_COMPILER_ID}" )
+ endif()
+endmacro()
+
+# -----------------------------------------------------------------------------
+# Apply whole program optimization for this target in release ( !slow! )
+# -----------------------------------------------------------------------------
+macro( whole_program_optimization )
+ target_compile_options( ${PROJECT_NAME} PRIVATE
+ $<$:/GL>
+ )
+endmacro()
diff --git a/r5dev/cmake/Options.cmake b/r5dev/cmake/Options.cmake
new file mode 100644
index 00000000..38b2e31c
--- /dev/null
+++ b/r5dev/cmake/Options.cmake
@@ -0,0 +1,107 @@
+# -----------------------------------------------------------------------------
+# Setup each build configuration
+# -----------------------------------------------------------------------------
+macro( apply_project_settings )
+ # Set common settings for all configurations
+ add_compile_options(
+ $<$:/permissive->
+ $<$:/MP>
+ $<$:/W4>
+ $<$:/GR>
+ $<$:/D_UNICODE>
+ $<$:/DUNICODE>
+ )
+
+ set( GAMEDLL_OPTION "GAMEDLL_S3" CACHE STRING "Game DLL version" )
+ set_property( CACHE GAMEDLL_OPTION PROPERTY STRINGS
+ "GAMEDLL_S0"
+ "GAMEDLL_S1"
+ "GAMEDLL_S2"
+ "GAMEDLL_S3"
+ )
+
+ # Set common defines
+ add_compile_definitions(
+ "_CRT_SECURE_NO_WARNINGS"
+ "SPDLOG_COMPILED_LIB"
+ "SPDLOG_NO_EXCEPTIONS"
+ "CURL_STATICLIB"
+ "${GAMEDLL_OPTION}"
+ )
+
+ # Set settings for Debug configuration
+ add_compile_options(
+ $<$,$>:/MTd>
+ )
+
+ # Set settings for Profile configuration
+ add_compile_options(
+ $<$,$>:/Ox>
+ $<$,$>:/GF>
+ $<$,$>:/MT>
+ )
+ set( CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_PROFILE} /PROFILE" )
+
+ # Set settings for Release configuration
+ add_compile_options(
+ $<$,$>:/Ob2>
+ $<$,$>:/Oi>
+ $<$,$>:/Ot>
+ $<$,$>:/GF>
+ $<$,$>:/MT>
+ $<$,$>:/GS->
+ $<$,$>:/Gy>
+ $<$,$>:/fp:fast>
+ )
+
+ set( CMAKE_EXE_LINKER_FLAGS_RELEASE
+ "${CMAKE_EXE_LINKER_FLAGS_RELEASE}
+ /OPT:REF
+ /OPT:ICF
+ /RELEASE
+ /SAFESEH:NO
+ /DEBUG"
+ )
+
+ # Commonly used directories accross libraries.
+ include_directories(
+ "${ENGINE_SOURCE_DIR}/"
+ "${ENGINE_SOURCE_DIR}/public/"
+ "${ENGINE_SOURCE_DIR}/thirdparty/"
+ "${ENGINE_SOURCE_DIR}/thirdparty/imgui/"
+ "${ENGINE_SOURCE_DIR}/thirdparty/recast/"
+ )
+endmacro()
+
+# -----------------------------------------------------------------------------
+# Setup build output directories for target
+# -----------------------------------------------------------------------------
+macro( set_target_output_dirs TARGET RUNTIME_DIR )
+ # Set output directories
+ set_target_properties( ${TARGET} PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/${RUNTIME_DIR}"
+ RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/${RUNTIME_DIR}"
+ RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/${RUNTIME_DIR}"
+ RUNTIME_OUTPUT_DIRECTORY_PROFILE "${CMAKE_SOURCE_DIR}/${RUNTIME_DIR}"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib/${TARGET}"
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib/${TARGET}"
+ )
+
+ # Set output directories for each configuration
+ foreach( CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES} )
+ set_target_properties( ${TARGET} PROPERTIES
+ "RUNTIME_OUTPUT_DIRECTORY_${CONFIG_TYPE}" "${CMAKE_SOURCE_DIR}/${RUNTIME_DIR}"
+ "ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_TYPE}" "${CMAKE_SOURCE_DIR}/lib/${TARGET}/${CONFIG_TYPE}"
+ "LIBRARY_OUTPUT_DIRECTORY_${CONFIG_TYPE}" "${CMAKE_SOURCE_DIR}/lib/${TARGET}/${CONFIG_TYPE}"
+ "LINK_FLAGS_${CONFIG_TYPE}" "/PDB:${PDB_FULL_PATH}"
+ )
+ endforeach()
+
+ # Set PDB properties for release builds ( should be created )
+ set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi" )
+ set( PDB_OUTPUT_DIRECTORY "RUNTIME_OUTPUT_DIRECTORY_${CONFIG_TYPE}" )
+
+ # Set linker properties
+ set( CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF" )
+ set( CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_PROFILE} /DEBUG /PROFILE" )
+endmacro()
diff --git a/r5dev/cmake/PostBuild.cmake b/r5dev/cmake/PostBuild.cmake
new file mode 100644
index 00000000..bb12b675
--- /dev/null
+++ b/r5dev/cmake/PostBuild.cmake
@@ -0,0 +1,49 @@
+# -----------------------------------------------------------------------------
+# Creates and writes the build string after building a project
+# -----------------------------------------------------------------------------
+function( WriteBuildString OUTPUT_DIR )
+ # Get the current date and time
+ string( TIMESTAMP CURRENT_DATE "%Y_%m_%d_%I_%M" ) # Use %I for 12-hour clock
+
+ # Compute AM/PM
+ string( TIMESTAMP CURRENT_HOUR "%H" )
+ if( CURRENT_HOUR LESS 12 )
+ set( TIME_DESIGNATOR "AM" )
+ else()
+ set( TIME_DESIGNATOR "PM" )
+ endif()
+
+ # Get the current git commit hash
+ execute_process( COMMAND
+ git rev-parse --short HEAD
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ OUTPUT_VARIABLE GIT_COMMIT_HASH
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+
+ # Convert the hash to uppercase
+ string( TOUPPER
+ "${GIT_COMMIT_HASH}" GIT_COMMIT_HASH
+ )
+
+ # Get the current git branch name
+ execute_process( COMMAND
+ git rev-parse --abbrev-ref HEAD
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ OUTPUT_VARIABLE GIT_BRANCH_NAME
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+
+ # Construct the build string
+ set( BUILD_STRING
+ "R5pc_${GIT_BRANCH_NAME}_N1094_${GIT_COMMIT_HASH}_${CURRENT_DATE}_${TIME_DESIGNATOR}\n"
+ )
+
+ # Write the build string to a file
+ file( WRITE
+ "${CMAKE_SOURCE_DIR}/${OUTPUT_DIR}/build.txt" "${BUILD_STRING}"
+ )
+endfunction()
+
+# Initiate the creation command
+WriteBuildString( "../../../game" )
diff --git a/r5dev/codecs/CMakeLists.txt b/r5dev/codecs/CMakeLists.txt
new file mode 100644
index 00000000..6be341c2
--- /dev/null
+++ b/r5dev/codecs/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required( VERSION 3.16 )
+add_module( "lib" "codecs" "vpc" ${FOLDER_CONTEXT} )
+
+start_sources()
+
+add_sources( SOURCE_GROUP "Bink"
+ "bink/bink_impl.cpp"
+ "bink/bink_impl.h"
+)
+
+add_sources( SOURCE_GROUP "Miles"
+ "miles/miles_impl.cpp"
+ "miles/miles_impl.h"
+ "miles/miles_types.h" # TODO[ AMOS ]: move to public!
+ "miles/radshal_wasapi.h"
+)
+
+end_sources()
+
+target_include_directories( ${PROJECT_NAME} PRIVATE "${ENGINE_SOURCE_DIR}/tier0/" "${ENGINE_SOURCE_DIR}/tier1/" )
diff --git a/r5dev/vstdlib/callback.cpp b/r5dev/common/callback.cpp
similarity index 99%
rename from r5dev/vstdlib/callback.cpp
rename to r5dev/common/callback.cpp
index 8e2476b9..2cf30be9 100644
--- a/r5dev/vstdlib/callback.cpp
+++ b/r5dev/common/callback.cpp
@@ -14,6 +14,7 @@
#endif // !CLIENT_DLL
#ifndef DEDICATED
#include "engine/client/cl_rcon.h"
+#include "engine/client/cdll_engine_int.h"
#endif // !DEDICATED
#include "engine/client/client.h"
#include "engine/net.h"
@@ -23,9 +24,6 @@
#ifndef CLIENT_DLL
#include "engine/server/server.h"
#endif // !CLIENT_DLL
-#ifndef DEDICATED
-#include "client/cdll_engine_int.h"
-#endif // !DEDICATED
#include "rtech/rtech_game.h"
#include "rtech/rtech_utils.h"
#include "filesystem/basefilesystem.h"
@@ -44,8 +42,8 @@
#include "public/worldsize.h"
#include "mathlib/crc32.h"
#include "mathlib/mathlib.h"
-#include "vstdlib/completion.h"
-#include "vstdlib/callback.h"
+#include "common/completion.h"
+#include "common/callback.h"
#ifndef DEDICATED
#include "materialsystem/cmaterialglue.h"
#endif // !DEDICATED
diff --git a/r5dev/vstdlib/callback.h b/r5dev/common/callback.h
similarity index 100%
rename from r5dev/vstdlib/callback.h
rename to r5dev/common/callback.h
diff --git a/r5dev/vstdlib/completion.cpp b/r5dev/common/completion.cpp
similarity index 99%
rename from r5dev/vstdlib/completion.cpp
rename to r5dev/common/completion.cpp
index 623b8c66..a94918b9 100644
--- a/r5dev/vstdlib/completion.cpp
+++ b/r5dev/common/completion.cpp
@@ -8,7 +8,7 @@
#include "engine/cmodel_bsp.h"
#include "tier1/strtools.h"
#include "completion.h"
-#include "autocompletefilelist.h"
+#include "vstdlib/autocompletefilelist.h"
//-----------------------------------------------------------------------------
// Purpose:
diff --git a/r5dev/vstdlib/completion.h b/r5dev/common/completion.h
similarity index 98%
rename from r5dev/vstdlib/completion.h
rename to r5dev/common/completion.h
index 2bc886d2..a762f81a 100644
--- a/r5dev/vstdlib/completion.h
+++ b/r5dev/common/completion.h
@@ -1,6 +1,6 @@
#pragma once
#include "public/iconvar.h"
-#include "autocompletefilelist.h"
+#include "vstdlib/autocompletefilelist.h"
int Host_SSMap_f_CompletionFunc(char const* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH]);
int Host_Map_f_CompletionFunc(char const* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH]);
diff --git a/r5dev/appframework/engine_launcher_api.h b/r5dev/common/engine_launcher_api.h
similarity index 100%
rename from r5dev/appframework/engine_launcher_api.h
rename to r5dev/common/engine_launcher_api.h
diff --git a/r5dev/common/global.cpp b/r5dev/common/global.cpp
new file mode 100644
index 00000000..70394de1
--- /dev/null
+++ b/r5dev/common/global.cpp
@@ -0,0 +1,786 @@
+
+#include "core/stdafx.h"
+#include "const.h"
+#include "tier0/commandline.h"
+#include "tier1/cvar.h"
+#include "tier1/cmd.h"
+#include "tier1/NetAdr.h"
+#include "tier2/curlutils.h" // For initializing the curl cvars.
+#include "completion.h"
+#include "callback.h"
+#include "global.h"
+
+//-----------------------------------------------------------------------------
+// ENGINE |
+ConVar* sdk_fixedframe_tickinterval = nullptr;
+ConVar* single_frame_shutdown_for_reload = nullptr;
+ConVar* old_gather_props = nullptr;
+
+ConVar* enable_debug_overlays = nullptr;
+ConVar* debug_draw_box_depth_test = nullptr;
+
+ConVar* developer = nullptr;
+ConVar* fps_max = nullptr;
+
+ConVar* staticProp_defaultBuildFrustum = nullptr;
+ConVar* staticProp_no_fade_scalar = nullptr;
+ConVar* staticProp_gather_size_weight = nullptr;
+
+ConVar* model_defaultFadeDistScale = nullptr;
+ConVar* model_defaultFadeDistMin = nullptr;
+
+ConVar* ip_cvar = nullptr;
+ConVar* hostname = nullptr;
+ConVar* hostdesc = nullptr;
+ConVar* hostip = nullptr;
+ConVar* hostport = nullptr;
+ConVar* host_hasIrreversibleShutdown = nullptr;
+ConVar* mp_gamemode = nullptr;
+
+ConVar* rcon_address = nullptr;
+ConVar* rcon_password = nullptr;
+
+ConVar* r_debug_overlay_nodecay = nullptr;
+ConVar* r_debug_overlay_invisible = nullptr;
+ConVar* r_debug_overlay_wireframe = nullptr;
+ConVar* r_debug_draw_depth_test = nullptr;
+ConVar* r_drawWorldMeshes = nullptr;
+ConVar* r_drawWorldMeshesDepthOnly = nullptr;
+ConVar* r_drawWorldMeshesDepthAtTheEnd = nullptr;
+
+#ifndef DEDICATED
+ConVar* r_visualizetraces = nullptr;
+ConVar* r_visualizetraces_duration = nullptr;
+#endif // !DEDICATED
+
+ConVar* stream_overlay = nullptr;
+ConVar* stream_overlay_mode = nullptr;
+//-----------------------------------------------------------------------------
+// SERVER |
+#ifndef CLIENT_DLL
+ConVar* ai_ainDumpOnLoad = nullptr;
+ConVar* ai_ainDebugConnect = nullptr;
+ConVar* ai_script_nodes_draw = nullptr;
+ConVar* ai_script_nodes_draw_range = nullptr;
+ConVar* ai_script_nodes_draw_nearest = nullptr;
+
+ConVar* navmesh_always_reachable = nullptr;
+ConVar* navmesh_debug_type = nullptr;
+ConVar* navmesh_debug_tile_range = nullptr;
+ConVar* navmesh_debug_camera_range = nullptr;
+#ifndef DEDICATED
+ConVar* navmesh_draw_bvtree = nullptr;
+ConVar* navmesh_draw_portal = nullptr;
+ConVar* navmesh_draw_polys = nullptr;
+ConVar* navmesh_draw_poly_bounds = nullptr;
+ConVar* navmesh_draw_poly_bounds_inner = nullptr;
+#endif // !DEDICATED
+
+ConVar* sv_showconnecting = nullptr;
+ConVar* sv_globalBanlist = nullptr;
+ConVar* sv_pylonVisibility = nullptr;
+ConVar* sv_pylonRefreshRate = nullptr;
+ConVar* sv_banlistRefreshRate = nullptr;
+ConVar* sv_statusRefreshRate = nullptr;
+ConVar* sv_forceChatToTeamOnly = nullptr;
+
+ConVar* sv_updaterate_mp = nullptr;
+ConVar* sv_updaterate_sp = nullptr;
+ConVar* sv_autoReloadRate = nullptr;
+
+ConVar* sv_simulateBots = nullptr;
+ConVar* sv_showhitboxes = nullptr;
+ConVar* sv_stats = nullptr;
+
+ConVar* sv_quota_stringCmdsPerSecond = nullptr;
+
+ConVar* sv_validatePersonaName = nullptr;
+ConVar* sv_minPersonaNameLength = nullptr;
+ConVar* sv_maxPersonaNameLength = nullptr;
+
+ConVar* sv_voiceEcho = nullptr;
+ConVar* sv_voiceenable = nullptr;
+ConVar* sv_alltalk = nullptr;
+
+//#ifdef DEDICATED
+ConVar* sv_rcon_debug = nullptr;
+ConVar* sv_rcon_sendlogs = nullptr;
+ConVar* sv_rcon_banpenalty = nullptr; // TODO
+ConVar* sv_rcon_maxfailures = nullptr;
+ConVar* sv_rcon_maxignores = nullptr;
+ConVar* sv_rcon_maxsockets = nullptr;
+ConVar* sv_rcon_maxconnections = nullptr;
+ConVar* sv_rcon_maxpacketsize = nullptr;
+ConVar* sv_rcon_whitelist_address = nullptr;
+//#endif // DEDICATED
+#endif // !CLIENT_DLL
+ConVar* sv_cheats = nullptr;
+ConVar* sv_visualizetraces = nullptr;
+ConVar* sv_visualizetraces_duration = nullptr;
+#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1)
+ConVar* bhit_enable = nullptr;
+ConVar* bhit_depth_test = nullptr;
+ConVar* bhit_abs_origin = nullptr;
+#endif // !GAMEDLL_S0 && !GAMEDLL_S1
+//-----------------------------------------------------------------------------
+// CLIENT |
+#ifndef DEDICATED
+ConVar* cl_rcon_request_sendlogs = nullptr;
+ConVar* cl_quota_stringCmdsPerSecond = nullptr;
+
+ConVar* cl_notify_invert_x = nullptr;
+ConVar* cl_notify_invert_y = nullptr;
+ConVar* cl_notify_offset_x = nullptr;
+ConVar* cl_notify_offset_y = nullptr;
+
+ConVar* cl_showsimstats = nullptr;
+ConVar* cl_simstats_invert_x = nullptr;
+ConVar* cl_simstats_invert_y = nullptr;
+ConVar* cl_simstats_offset_x = nullptr;
+ConVar* cl_simstats_offset_y = nullptr;
+
+ConVar* cl_showgpustats = nullptr;
+ConVar* cl_gpustats_invert_x = nullptr;
+ConVar* cl_gpustats_invert_y = nullptr;
+ConVar* cl_gpustats_offset_x = nullptr;
+ConVar* cl_gpustats_offset_y = nullptr;
+
+ConVar* cl_showmaterialinfo = nullptr;
+ConVar* cl_materialinfo_offset_x = nullptr;
+ConVar* cl_materialinfo_offset_y = nullptr;
+
+ConVar* cl_threaded_bone_setup = nullptr;
+
+ConVar* con_drawnotify = nullptr;
+ConVar* con_notifylines = nullptr;
+ConVar* con_notifytime = nullptr;
+
+ConVar* con_notify_invert_x = nullptr;
+ConVar* con_notify_invert_y = nullptr;
+ConVar* con_notify_offset_x = nullptr;
+ConVar* con_notify_offset_y = nullptr;
+
+ConVar* con_notify_script_server_clr = nullptr;
+ConVar* con_notify_script_client_clr = nullptr;
+ConVar* con_notify_script_ui_clr = nullptr;
+ConVar* con_notify_native_server_clr = nullptr;
+ConVar* con_notify_native_client_clr = nullptr;
+ConVar* con_notify_native_ui_clr = nullptr;
+ConVar* con_notify_native_engine_clr = nullptr;
+ConVar* con_notify_native_fs_clr = nullptr;
+ConVar* con_notify_native_rtech_clr = nullptr;
+ConVar* con_notify_native_ms_clr = nullptr;
+ConVar* con_notify_native_audio_clr = nullptr;
+ConVar* con_notify_native_video_clr = nullptr;
+ConVar* con_notify_netcon_clr = nullptr;
+ConVar* con_notify_common_clr = nullptr;
+ConVar* con_notify_warning_clr = nullptr;
+ConVar* con_notify_error_clr = nullptr;
+
+ConVar* con_max_lines = nullptr;
+ConVar* con_max_history = nullptr;
+ConVar* con_suggestion_limit = nullptr;
+ConVar* con_suggestion_showhelptext = nullptr;
+ConVar* con_suggestion_showflags = nullptr;
+ConVar* con_suggestion_flags_realtime = nullptr;
+
+ConVar* origin_disconnectWhenOffline = nullptr;
+
+ConVar* serverbrowser_hideEmptyServers = nullptr;
+ConVar* serverbrowser_mapFilter = nullptr;
+ConVar* serverbrowser_gamemodeFilter = nullptr;
+#endif // !DEDICATED
+//-----------------------------------------------------------------------------
+// FILESYSTEM |
+ConVar* fs_showWarnings = nullptr;
+ConVar* fs_showAllReads = nullptr;
+ConVar* fs_packedstore_entryblock_stats = nullptr;
+ConVar* fs_packedstore_workspace = nullptr;
+ConVar* fs_packedstore_compression_level = nullptr;
+ConVar* fs_packedstore_max_helper_threads = nullptr;
+//-----------------------------------------------------------------------------
+// MATERIALSYSTEM |
+#ifndef DEDICATED
+ConVar* mat_alwaysComplain = nullptr;
+#endif // !DEDICATED
+//-----------------------------------------------------------------------------
+// SQUIRREL |
+ConVar* script_show_output = nullptr;
+ConVar* script_show_warning = nullptr;
+//-----------------------------------------------------------------------------
+// NETCHANNEL |
+ConVar* net_tracePayload = nullptr;
+ConVar* net_encryptionEnable = nullptr;
+ConVar* net_useRandomKey = nullptr;
+ConVar* net_usesocketsforloopback = nullptr;
+ConVar* net_processTimeBudget = nullptr;
+
+ConVar* pylon_matchmaking_hostname = nullptr;
+ConVar* pylon_host_update_interval = nullptr;
+ConVar* pylon_showdebuginfo = nullptr;
+//-----------------------------------------------------------------------------
+// RTECH API |
+ConVar* rtech_debug = nullptr;
+//-----------------------------------------------------------------------------
+// RUI |
+#ifndef DEDICATED
+ConVar* rui_drawEnable = nullptr;
+ConVar* rui_defaultDebugFontFace = nullptr;
+#endif // !DEDICATED
+//-----------------------------------------------------------------------------
+// MILES |
+#ifndef DEDICATED
+ConVar* miles_debug = nullptr;
+ConVar* miles_language = nullptr;
+#endif
+
+//-----------------------------------------------------------------------------
+// Purpose: initialize ConVar's
+//-----------------------------------------------------------------------------
+void ConVar_StaticInit(void)
+{
+ //-------------------------------------------------------------------------
+ // ENGINE |
+ hostdesc = ConVar::StaticCreate("hostdesc", "", FCVAR_RELEASE, "Host game server description.", false, 0.f, false, 0.f, nullptr, nullptr);
+ sdk_fixedframe_tickinterval = ConVar::StaticCreate("sdk_fixedframe_tickinterval", "0.01", FCVAR_RELEASE, "The tick interval used by the SDK fixed frame.", false, 0.f, false, 0.f, nullptr, nullptr);
+ staticProp_defaultBuildFrustum = ConVar::StaticCreate("staticProp_defaultBuildFrustum", "0", FCVAR_DEVELOPMENTONLY, "Use the old solution for building static prop frustum culling.", false, 0.f, false, 0.f, nullptr, nullptr);
+
+ curl_debug = ConVar::StaticCreate("curl_debug" , "0" , FCVAR_DEVELOPMENTONLY, "Determines whether or not to enable curl debug logging.", false, 0.f, false, 0.f, nullptr, "1 = curl logs; 0 (zero) = no logs.");
+ curl_timeout = ConVar::StaticCreate("curl_timeout" , "15", FCVAR_DEVELOPMENTONLY, "Maximum time in seconds a curl transfer operation could take.", false, 0.f, false, 0.f, nullptr, nullptr);
+ ssl_verify_peer = ConVar::StaticCreate("ssl_verify_peer", "1" , FCVAR_DEVELOPMENTONLY, "Verify the authenticity of the peer's SSL certificate.", false, 0.f, false, 0.f, nullptr, "1 = curl verifies; 0 (zero) = no verification.");
+
+ rcon_address = ConVar::StaticCreate("rcon_address", "[loopback]:37015", FCVAR_SERVER_CANNOT_QUERY | FCVAR_DONTRECORD | FCVAR_RELEASE, "Remote server access address.", false, 0.f, false, 0.f, nullptr, nullptr);
+ rcon_password = ConVar::StaticCreate("rcon_password", "" , FCVAR_SERVER_CANNOT_QUERY | FCVAR_DONTRECORD | FCVAR_RELEASE, "Remote server access password (rcon is disabled if empty).", false, 0.f, false, 0.f, &RCON_PasswordChanged_f, nullptr);
+
+ r_debug_overlay_nodecay = ConVar::StaticCreate("r_debug_overlay_nodecay" , "0", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Keeps all debug overlays alive regardless of their lifetime. Use command 'clear_debug_overlays' to clear everything.", false, 0.f, false, 0.f, nullptr, nullptr);
+ r_debug_overlay_invisible = ConVar::StaticCreate("r_debug_overlay_invisible" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Show invisible debug overlays (alpha < 1 = 255).", false, 0.f, false, 0.f, nullptr, nullptr);
+ r_debug_overlay_wireframe = ConVar::StaticCreate("r_debug_overlay_wireframe" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Use wireframe in debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ r_debug_draw_depth_test = ConVar::StaticCreate("r_debug_draw_depth_test" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Toggle depth test for other debug draw functionality.", false, 0.f, false, 0.f, nullptr, nullptr);
+ r_drawWorldMeshes = ConVar::StaticCreate("r_drawWorldMeshes" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Render world meshes.", false, 0.f, false, 0.f, nullptr, nullptr);
+ r_drawWorldMeshesDepthOnly = ConVar::StaticCreate("r_drawWorldMeshesDepthOnly" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Render world meshes (depth only).", false, 0.f, false, 0.f, nullptr, nullptr);
+ r_drawWorldMeshesDepthAtTheEnd = ConVar::StaticCreate("r_drawWorldMeshesDepthAtTheEnd", "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Render world meshes (depth at the end).", false, 0.f, false, 0.f, nullptr, nullptr);
+ //-------------------------------------------------------------------------
+ // SERVER |
+#ifndef CLIENT_DLL
+ ai_ainDumpOnLoad = ConVar::StaticCreate("ai_ainDumpOnLoad" , "0", FCVAR_DEVELOPMENTONLY, "Dumps AIN data from node graphs loaded from the disk on load.", false, 0.f, false, 0.f, nullptr, nullptr);
+ ai_ainDebugConnect = ConVar::StaticCreate("ai_ainDebugConnect" , "0", FCVAR_DEVELOPMENTONLY, "Debug AIN node connections.", false, 0.f, false, 0.f, nullptr, nullptr);
+ ai_script_nodes_draw_range = ConVar::StaticCreate("ai_script_nodes_draw_range" , "0", FCVAR_DEVELOPMENTONLY, "Debug draw AIN script nodes ranging from shift index to this cvar.", false, 0.f, false, 0.f, nullptr, nullptr);
+ ai_script_nodes_draw_nearest = ConVar::StaticCreate("ai_script_nodes_draw_nearest", "1", FCVAR_DEVELOPMENTONLY, "Debug draw AIN script node links to nearest node (build order is used if null).", false, 0.f, false, 0.f, nullptr, nullptr);
+
+ navmesh_always_reachable = ConVar::StaticCreate("navmesh_always_reachable" , "0" , FCVAR_DEVELOPMENTONLY, "Marks goal poly from agent poly as reachable regardless of table data ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr);
+ navmesh_debug_type = ConVar::StaticCreate("navmesh_debug_type" , "0" , FCVAR_DEVELOPMENTONLY, "NavMesh debug draw hull index.", true, 0.f, true, 4.f, nullptr, "0 = small, 1 = med_short, 2 = medium, 3 = large, 4 = extra large");
+ navmesh_debug_tile_range = ConVar::StaticCreate("navmesh_debug_tile_range" , "0" , FCVAR_DEVELOPMENTONLY, "NavMesh debug draw tiles ranging from shift index to this cvar.", true, 0.f, false, 0.f, nullptr, nullptr);
+ navmesh_debug_camera_range = ConVar::StaticCreate("navmesh_debug_camera_range" , "2000" , FCVAR_DEVELOPMENTONLY, "Only debug draw tiles within this distance from camera origin.", true, 0.f, false, 0.f, nullptr, nullptr);
+#ifndef DEDICATED
+ navmesh_draw_bvtree = ConVar::StaticCreate("navmesh_draw_bvtree" , "-1", FCVAR_DEVELOPMENTONLY, "Draws the BVTree of the NavMesh tiles.", false, 0.f, false, 0.f, nullptr, "Index: > 0 && < mesh->m_tileCount");
+ navmesh_draw_portal = ConVar::StaticCreate("navmesh_draw_portal" , "-1", FCVAR_DEVELOPMENTONLY, "Draws the portal of the NavMesh tiles.", false, 0.f, false, 0.f, nullptr, "Index: > 0 && < mesh->m_tileCount");
+ navmesh_draw_polys = ConVar::StaticCreate("navmesh_draw_polys" , "-1", FCVAR_DEVELOPMENTONLY, "Draws the polys of the NavMesh tiles.", false, 0.f, false, 0.f, nullptr, "Index: > 0 && < mesh->m_tileCount");
+ navmesh_draw_poly_bounds = ConVar::StaticCreate("navmesh_draw_poly_bounds" , "-1", FCVAR_DEVELOPMENTONLY, "Draws the bounds of the NavMesh polys.", false, 0.f, false, 0.f, nullptr, "Index: > 0 && < mesh->m_tileCount");
+ navmesh_draw_poly_bounds_inner = ConVar::StaticCreate("navmesh_draw_poly_bounds_inner" , "0" , FCVAR_DEVELOPMENTONLY, "Draws the inner bounds of the NavMesh polys (requires navmesh_draw_poly_bounds).", false, 0.f, false, 0.f, nullptr, "Index: > 0 && < mesh->m_tileCount");
+#endif // !DEDICATED
+ sv_showconnecting = ConVar::StaticCreate("sv_showconnecting" , "1", FCVAR_RELEASE, "Logs information about the connecting client to the console.", false, 0.f, false, 0.f, nullptr, nullptr);
+ sv_globalBanlist = ConVar::StaticCreate("sv_globalBanlist" , "1", FCVAR_RELEASE, "Determines whether or not to use the global banned list.", false, 0.f, false, 0.f, nullptr, "0 = Disable, 1 = Enable.");
+ sv_pylonVisibility = ConVar::StaticCreate("sv_pylonVisibility", "0", FCVAR_RELEASE, "Determines the visibility to the Pylon master server.", false, 0.f, false, 0.f, nullptr, "0 = Offline, 1 = Hidden, 2 = Public.");
+ sv_pylonRefreshRate = ConVar::StaticCreate("sv_pylonRefreshRate" , "5.0" , FCVAR_DEVELOPMENTONLY, "Pylon host refresh rate (seconds).", true, 2.f, true, 8.f, nullptr, nullptr);
+ sv_banlistRefreshRate = ConVar::StaticCreate("sv_banlistRefreshRate", "30.0", FCVAR_DEVELOPMENTONLY, "Banned list refresh rate (seconds).", true, 1.f, false, 0.f, nullptr, nullptr);
+ sv_statusRefreshRate = ConVar::StaticCreate("sv_statusRefreshRate" , "0.5", FCVAR_RELEASE, "Server status refresh rate (seconds).", true, 0.f, false, 0.f, nullptr, nullptr);
+ sv_autoReloadRate = ConVar::StaticCreate("sv_autoReloadRate" , "0" , FCVAR_RELEASE, "Time in seconds between each server auto-reload (disabled if null).", true, 0.f, false, 0.f, nullptr, nullptr);
+ sv_simulateBots = ConVar::StaticCreate("sv_simulateBots", "1", FCVAR_RELEASE, "Simulate user commands for bots on the server.", true, 0.f, false, 0.f, nullptr, nullptr);
+
+ sv_rcon_debug = ConVar::StaticCreate("sv_rcon_debug" , "0" , FCVAR_RELEASE, "Show rcon debug information ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr);
+ sv_rcon_sendlogs = ConVar::StaticCreate("sv_rcon_sendlogs" , "0" , FCVAR_RELEASE, "Network console logs to connected and authenticated sockets.", false, 0.f, false, 0.f, nullptr, nullptr);
+ sv_rcon_banpenalty = ConVar::StaticCreate("sv_rcon_banpenalty" , "10", FCVAR_RELEASE, "Number of minutes to ban users who fail rcon authentication.", false, 0.f, false, 0.f, nullptr, nullptr);
+ sv_rcon_maxfailures = ConVar::StaticCreate("sv_rcon_maxfailures", "10", FCVAR_RELEASE, "Max number of times a user can fail rcon authentication before being banned.", true, 1.f, false, 0.f, nullptr, nullptr);
+ sv_rcon_maxignores = ConVar::StaticCreate("sv_rcon_maxignores" , "15", FCVAR_RELEASE, "Max number of times a user can ignore the instruction message before being banned.", true, 1.f, false, 0.f, nullptr, nullptr);
+ sv_rcon_maxsockets = ConVar::StaticCreate("sv_rcon_maxsockets" , "32", FCVAR_RELEASE, "Max number of accepted sockets before the server starts closing redundant sockets.", true, 1.f, true, MAX_PLAYERS, nullptr, nullptr);
+ sv_rcon_maxconnections = ConVar::StaticCreate("sv_rcon_maxconnections" , "1" , FCVAR_RELEASE, "Max number of authenticated connections before the server closes the listen socket.", true, 1.f, true, MAX_PLAYERS, &RCON_ConnectionCountChanged_f, nullptr);
+ sv_rcon_maxpacketsize = ConVar::StaticCreate("sv_rcon_maxpacketsize" , "1024", FCVAR_RELEASE, "Max number of bytes allowed in a command packet from a non-authenticated net console.", true, 0.f, false, 0.f, nullptr, nullptr);
+ sv_rcon_whitelist_address = ConVar::StaticCreate("sv_rcon_whitelist_address", "" , FCVAR_RELEASE, "This address is not considered a 'redundant' socket and will never be banned for failed authentication attempts.", false, 0.f, false, 0.f, &RCON_WhiteListAddresChanged_f, "Format: '::ffff:127.0.0.1'");
+
+ sv_quota_stringCmdsPerSecond = ConVar::StaticCreate("sv_quota_stringCmdsPerSecond", "16", FCVAR_RELEASE, "How many string commands per second clients are allowed to submit, 0 to disallow all string commands.", true, 0.f, false, 0.f, nullptr, nullptr);
+ sv_validatePersonaName = ConVar::StaticCreate("sv_validatePersonaName" , "1" , FCVAR_RELEASE, "Validate the client's textual persona name on connect.", true, 0.f, false, 0.f, nullptr, nullptr);
+ sv_minPersonaNameLength = ConVar::StaticCreate("sv_minPersonaNameLength", "4" , FCVAR_RELEASE, "The minimum length of the client's textual persona name.", true, 0.f, false, 0.f, nullptr, nullptr);
+ sv_maxPersonaNameLength = ConVar::StaticCreate("sv_maxPersonaNameLength", "16", FCVAR_RELEASE, "The maximum length of the client's textual persona name.", true, 0.f, false, 0.f, nullptr, nullptr);
+#endif // !CLIENT_DLL
+#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1)
+ bhit_depth_test = ConVar::StaticCreate("bhit_depth_test", "0", FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED, "Use depth test for bullet ray trace overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ bhit_abs_origin = ConVar::StaticCreate("bhit_abs_origin", "1", FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED, "Draw entity's predicted abs origin upon bullet impact for trajectory debugging (requires 'r_visualizetraces' to be set!).", false, 0.f, false, 0.f, nullptr, nullptr);
+#endif // !GAMEDLL_S0 && !GAMEDLL_S1
+ //-------------------------------------------------------------------------
+ // CLIENT |
+#ifndef DEDICATED
+ cl_rcon_request_sendlogs = ConVar::StaticCreate("cl_rcon_request_sendlogs", "1" , FCVAR_RELEASE, "Request the rcon server to send console logs on connect.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_quota_stringCmdsPerSecond = ConVar::StaticCreate("cl_quota_stringCmdsPerSecond", "16" , FCVAR_RELEASE, "How many string commands per second user is allowed to submit, 0 to allow all submissions.", true, 0.f, false, 0.f, nullptr, nullptr);
+
+ cl_notify_invert_x = ConVar::StaticCreate("cl_notify_invert_x", "0", FCVAR_DEVELOPMENTONLY, "Inverts the X offset for console notify debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_notify_invert_y = ConVar::StaticCreate("cl_notify_invert_y", "0", FCVAR_DEVELOPMENTONLY, "Inverts the Y offset for console notify debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_notify_offset_x = ConVar::StaticCreate("cl_notify_offset_x", "10", FCVAR_DEVELOPMENTONLY, "X offset for console notify debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_notify_offset_y = ConVar::StaticCreate("cl_notify_offset_y", "10", FCVAR_DEVELOPMENTONLY, "Y offset for console notify debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+
+ cl_showsimstats = ConVar::StaticCreate("cl_showsimstats" , "0" , FCVAR_DEVELOPMENTONLY, "Shows the tick counter for the server/client simulation and the render frame.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_simstats_invert_x = ConVar::StaticCreate("cl_simstats_invert_x", "1" , FCVAR_DEVELOPMENTONLY, "Inverts the X offset for simulation debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_simstats_invert_y = ConVar::StaticCreate("cl_simstats_invert_y", "1" , FCVAR_DEVELOPMENTONLY, "Inverts the Y offset for simulation debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_simstats_offset_x = ConVar::StaticCreate("cl_simstats_offset_x", "650", FCVAR_DEVELOPMENTONLY, "X offset for simulation debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_simstats_offset_y = ConVar::StaticCreate("cl_simstats_offset_y", "120", FCVAR_DEVELOPMENTONLY, "Y offset for simulation debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+
+ cl_showgpustats = ConVar::StaticCreate("cl_showgpustats" , "0", FCVAR_DEVELOPMENTONLY, "Texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_gpustats_invert_x = ConVar::StaticCreate("cl_gpustats_invert_x", "1", FCVAR_DEVELOPMENTONLY, "Inverts the X offset for texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_gpustats_invert_y = ConVar::StaticCreate("cl_gpustats_invert_y", "1", FCVAR_DEVELOPMENTONLY, "Inverts the Y offset for texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_gpustats_offset_x = ConVar::StaticCreate("cl_gpustats_offset_x", "650", FCVAR_DEVELOPMENTONLY, "X offset for texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_gpustats_offset_y = ConVar::StaticCreate("cl_gpustats_offset_y", "105", FCVAR_DEVELOPMENTONLY, "Y offset for texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+
+ cl_showmaterialinfo = ConVar::StaticCreate("cl_showmaterialinfo" , "0" , FCVAR_DEVELOPMENTONLY, "Draw info for the material under the crosshair on screen.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_materialinfo_offset_x = ConVar::StaticCreate("cl_materialinfo_offset_x", "0" , FCVAR_DEVELOPMENTONLY, "X offset for material debug info overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_materialinfo_offset_y = ConVar::StaticCreate("cl_materialinfo_offset_y", "420", FCVAR_DEVELOPMENTONLY, "Y offset for material debug info overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+
+ con_drawnotify = ConVar::StaticCreate("con_drawnotify", "0", FCVAR_RELEASE, "Draws the RUI console to the hud.", false, 0.f, false, 0.f, nullptr, nullptr);
+ con_notifylines = ConVar::StaticCreate("con_notifylines" , "3" , FCVAR_MATERIAL_SYSTEM_THREAD, "Number of console lines to overlay for debugging.", true, 1.f, false, 0.f, nullptr, nullptr);
+ con_notifytime = ConVar::StaticCreate("con_notifytime" , "6" , FCVAR_MATERIAL_SYSTEM_THREAD, "How long to display recent console text to the upper part of the game window.", false, 1.f, false, 50.f, nullptr, nullptr);
+
+ con_notify_invert_x = ConVar::StaticCreate("con_notify_invert_x", "0" , FCVAR_MATERIAL_SYSTEM_THREAD, "Inverts the X offset for RUI console overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ con_notify_invert_y = ConVar::StaticCreate("con_notify_invert_y", "0" , FCVAR_MATERIAL_SYSTEM_THREAD, "Inverts the Y offset for RUI console overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ con_notify_offset_x = ConVar::StaticCreate("con_notify_offset_x", "10", FCVAR_MATERIAL_SYSTEM_THREAD, "X offset for RUI console overlay.", false, 1.f, false, 50.f, nullptr, nullptr);
+ con_notify_offset_y = ConVar::StaticCreate("con_notify_offset_y", "10", FCVAR_MATERIAL_SYSTEM_THREAD, "Y offset for RUI console overlay.", false, 1.f, false, 50.f, nullptr, nullptr);
+
+ con_notify_script_server_clr = ConVar::StaticCreate("con_notify_script_server_clr", "130 120 245 255", FCVAR_MATERIAL_SYSTEM_THREAD, "Script SERVER VM RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
+ con_notify_script_client_clr = ConVar::StaticCreate("con_notify_script_client_clr", "117 116 139 255", FCVAR_MATERIAL_SYSTEM_THREAD, "Script CLIENT VM RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
+ con_notify_script_ui_clr = ConVar::StaticCreate("con_notify_script_ui_clr" , "200 110 110 255", FCVAR_MATERIAL_SYSTEM_THREAD, "Script UI VM RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
+
+ con_notify_native_server_clr = ConVar::StaticCreate("con_notify_native_server_clr", "20 50 248 255" , FCVAR_MATERIAL_SYSTEM_THREAD, "Native SERVER RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
+ con_notify_native_client_clr = ConVar::StaticCreate("con_notify_native_client_clr", "70 70 70 255" , FCVAR_MATERIAL_SYSTEM_THREAD, "Native CLIENT RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
+ con_notify_native_ui_clr = ConVar::StaticCreate("con_notify_native_ui_clr" , "200 60 60 255" , FCVAR_MATERIAL_SYSTEM_THREAD, "Native UI RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
+ con_notify_native_engine_clr = ConVar::StaticCreate("con_notify_native_engine_clr", "255 255 255 255", FCVAR_MATERIAL_SYSTEM_THREAD, "Native engine RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
+ con_notify_native_fs_clr = ConVar::StaticCreate("con_notify_native_fs_clr" , "0 100 225 255" , FCVAR_MATERIAL_SYSTEM_THREAD, "Native FileSystem RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
+ con_notify_native_rtech_clr = ConVar::StaticCreate("con_notify_native_rtech_clr" , "25 120 20 255" , FCVAR_MATERIAL_SYSTEM_THREAD, "Native RTech RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
+ con_notify_native_ms_clr = ConVar::StaticCreate("con_notify_native_ms_clr" , "200 20 180 255" , FCVAR_MATERIAL_SYSTEM_THREAD, "Native MaterialSystem RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
+ con_notify_native_audio_clr = ConVar::StaticCreate("con_notify_native_audio_clr" , "238 43 10 255" , FCVAR_MATERIAL_SYSTEM_THREAD, "Native AudioSystem RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
+ con_notify_native_video_clr = ConVar::StaticCreate("con_notify_native_video_clr" , "115 0 235 255" , FCVAR_MATERIAL_SYSTEM_THREAD, "Native VideoSystem RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
+
+ con_notify_netcon_clr = ConVar::StaticCreate("con_notify_netcon_clr" , "255 255 255 255", FCVAR_MATERIAL_SYSTEM_THREAD, "Net console RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
+ con_notify_common_clr = ConVar::StaticCreate("con_notify_common_clr" , "255 140 80 255" , FCVAR_MATERIAL_SYSTEM_THREAD, "Common RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
+
+ con_notify_warning_clr = ConVar::StaticCreate("con_notify_warning_clr", "180 180 20 255", FCVAR_MATERIAL_SYSTEM_THREAD, "Warning RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
+ con_notify_error_clr = ConVar::StaticCreate("con_notify_error_clr" , "225 20 20 255" , FCVAR_MATERIAL_SYSTEM_THREAD, "Error RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr);
+
+ con_max_lines = ConVar::StaticCreate("con_max_lines" , "1024", FCVAR_DEVELOPMENTONLY, "Maximum number of lines in the console before cleanup starts.", true, 1.f, false, 0.f, nullptr, nullptr);
+ con_max_history = ConVar::StaticCreate("con_max_history" , "512" , FCVAR_DEVELOPMENTONLY, "Maximum number of command submission items before history cleanup starts.", true, 0.f, false, 0.f, nullptr, nullptr);
+ con_suggestion_limit = ConVar::StaticCreate("con_suggestion_limit" , "128" , FCVAR_DEVELOPMENTONLY, "Maximum number of suggestions the autocomplete window will show for the console.", true, 0.f, false, 0.f, nullptr, nullptr);
+ con_suggestion_showhelptext = ConVar::StaticCreate("con_suggestion_showhelptext" , "1" , FCVAR_DEVELOPMENTONLY, "Show CommandBase help text in autocomplete window.", false, 0.f, false, 0.f, nullptr, nullptr);
+ con_suggestion_showflags = ConVar::StaticCreate("con_suggestion_showflags" , "1" , FCVAR_DEVELOPMENTONLY, "Show CommandBase flags in autocomplete window.", false, 0.f, false, 0.f, nullptr, nullptr);
+ con_suggestion_flags_realtime = ConVar::StaticCreate("con_suggestion_flags_realtime", "1" , FCVAR_DEVELOPMENTONLY, "Whether to show compile-time or run-time CommandBase flags.", false, 0.f, false, 0.f, nullptr, nullptr);
+
+ serverbrowser_hideEmptyServers = ConVar::StaticCreate("serverbrowser_hideEmptyServers", "0", FCVAR_RELEASE, "Hide empty servers in the server browser", false, 0.f, false, 0.f, nullptr, nullptr);
+ serverbrowser_mapFilter = ConVar::StaticCreate("serverbrowser_mapFilter", "0", FCVAR_RELEASE, "Filter servers by map in the server browser", false, 0.f, false, 0.f, nullptr, nullptr);
+ serverbrowser_gamemodeFilter = ConVar::StaticCreate("serverbrowser_gamemodeFilter", "0", FCVAR_RELEASE, "Filter servers by gamemode in the server browser", false, 0.f, false, 0.f, nullptr, nullptr);
+#endif // !DEDICATED
+ //-------------------------------------------------------------------------
+ // FILESYSTEM |
+ fs_showWarnings = ConVar::StaticCreate("fs_showWarnings" , "0", FCVAR_DEVELOPMENTONLY, "Logs the FileSystem warnings to the console, filtered by 'fs_warning_level' ( !slower! ).", true, 0.f, true, 2.f, nullptr, "0 = log to file. 1 = 0 + log to console. 2 = 1 + log to notify.");
+ fs_packedstore_entryblock_stats = ConVar::StaticCreate("fs_packedstore_entryblock_stats" , "0", FCVAR_DEVELOPMENTONLY, "Logs the stats of each file entry in the VPK during decompression ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr);
+ fs_packedstore_workspace = ConVar::StaticCreate("fs_packedstore_workspace" , "platform/ship/", FCVAR_DEVELOPMENTONLY, "Determines the current VPK workspace.", false, 0.f, false, 0.f, nullptr, nullptr);
+ fs_packedstore_compression_level = ConVar::StaticCreate("fs_packedstore_compression_level", "default", FCVAR_DEVELOPMENTONLY, "Determines the VPK compression level.", false, 0.f, false, 0.f, nullptr, "fastest faster default better uber");
+ fs_packedstore_max_helper_threads = ConVar::StaticCreate("fs_packedstore_max_helper_threads" , "-1", FCVAR_DEVELOPMENTONLY, "Max # of additional \"helper\" threads to create during compression.", true, -1, true, LZHAM_MAX_HELPER_THREADS, nullptr, "Must range between [-1,LZHAM_MAX_HELPER_THREADS], where -1=max practical.");
+ //-------------------------------------------------------------------------
+ // MATERIALSYSTEM |
+#ifndef DEDICATED
+ mat_alwaysComplain = ConVar::StaticCreate("mat_alwaysComplain", "0", FCVAR_RELEASE | FCVAR_MATERIAL_SYSTEM_THREAD, "Always complain when a material is missing.", false, 0.f, false, 0.f, nullptr, nullptr);
+#endif // !DEDICATED
+ //-------------------------------------------------------------------------
+ // SQUIRREL |
+ script_show_output = ConVar::StaticCreate("script_show_output" , "0", FCVAR_RELEASE, "Prints the VM output to the console ( !slower! ).", true, 0.f, true, 2.f, nullptr, "0 = log to file. 1 = 0 + log to console. 2 = 1 + log to notify.");
+ script_show_warning = ConVar::StaticCreate("script_show_warning", "0", FCVAR_RELEASE, "Prints the VM warning output to the console ( !slower! ).", true, 0.f, true, 2.f, nullptr, "0 = log to file. 1 = 0 + log to console. 2 = 1 + log to notify.");
+ //-------------------------------------------------------------------------
+ // NETCHANNEL |
+ net_tracePayload = ConVar::StaticCreate("net_tracePayload" , "0", FCVAR_DEVELOPMENTONLY , "Log the payload of the send/recv datagram to a file on the disk.", false, 0.f, false, 0.f, nullptr, nullptr);
+ net_encryptionEnable = ConVar::StaticCreate("net_encryptionEnable" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED , "Use AES encryption on game packets.", false, 0.f, false, 0.f, nullptr, nullptr);
+ net_useRandomKey = ConVar::StaticCreate("net_useRandomKey" , "1" , FCVAR_RELEASE , "Use random AES encryption key for game packets.", false, 0.f, false, 0.f, &NET_UseRandomKeyChanged_f, nullptr);
+ net_processTimeBudget = ConVar::StaticCreate("net_processTimeBudget" ,"200" , FCVAR_RELEASE , "Net message process time budget in milliseconds (removing netchannel if exceeded).", true, 0.f, false, 0.f, nullptr, "0 = disabled.");
+ //-------------------------------------------------------------------------
+ // NETWORKSYSTEM |
+ pylon_matchmaking_hostname = ConVar::StaticCreate("pylon_matchmaking_hostname", "ms.r5reloaded.com", FCVAR_RELEASE, "Holds the pylon matchmaking hostname.", false, 0.f, false, 0.f, &MP_HostName_Changed_f, nullptr);
+ pylon_host_update_interval = ConVar::StaticCreate("pylon_host_update_interval", "5" , FCVAR_RELEASE, "Length of time in seconds between each status update interval to master server.", true, 5.f, false, 0.f, nullptr, nullptr);
+ pylon_showdebuginfo = ConVar::StaticCreate("pylon_showdebuginfo" , "0" , FCVAR_RELEASE, "Shows debug output for pylon.", false, 0.f, false, 0.f, nullptr, nullptr);
+ //-------------------------------------------------------------------------
+ // RTECH API |
+ rtech_debug = ConVar::StaticCreate("rtech_debug", "0", FCVAR_DEVELOPMENTONLY, "Shows debug output for the RTech system.", false, 0.f, false, 0.f, nullptr, nullptr);
+ //-------------------------------------------------------------------------
+ // RUI |
+#ifndef DEDICATED
+ rui_drawEnable = ConVar::StaticCreate("rui_drawEnable", "1", FCVAR_RELEASE, "Draws the RUI if set.", false, 0.f, false, 0.f, nullptr, "1 = Draw, 0 = No Draw.");
+#endif // !DEDICATED
+ //-------------------------------------------------------------------------
+ // MILES |
+#ifndef DEDICATED
+ miles_debug = ConVar::StaticCreate("miles_debug", "0", FCVAR_RELEASE, "Enables debug prints for the Miles Sound System.", false, 0.f, false, 0.f, nullptr, "1 = Print, 0 = No Print");
+#endif // !DEDICATED
+ //-------------------------------------------------------------------------
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: initialize shipped ConVar's
+//-----------------------------------------------------------------------------
+void ConVar_InitShipped(void)
+{
+#ifndef CLIENT_DLL
+ ai_script_nodes_draw = g_pCVar->FindVar("ai_script_nodes_draw");
+#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1)
+ bhit_enable = g_pCVar->FindVar("bhit_enable");
+#endif // !GAMEDLL_S0 && !GAMEDLL_S1
+#endif // !CLIENT_DLL
+ developer = g_pCVar->FindVar("developer");
+ fps_max = g_pCVar->FindVar("fps_max");
+ fs_showAllReads = g_pCVar->FindVar("fs_showAllReads");
+#ifndef DEDICATED
+ cl_threaded_bone_setup = g_pCVar->FindVar("cl_threaded_bone_setup");
+#endif // !DEDICATED
+ single_frame_shutdown_for_reload = g_pCVar->FindVar("single_frame_shutdown_for_reload");
+ enable_debug_overlays = g_pCVar->FindVar("enable_debug_overlays");
+ debug_draw_box_depth_test = g_pCVar->FindVar("debug_draw_box_depth_test");
+ model_defaultFadeDistScale = g_pCVar->FindVar("model_defaultFadeDistScale");
+ model_defaultFadeDistMin = g_pCVar->FindVar("model_defaultFadeDistMin");
+#ifndef DEDICATED
+ miles_language = g_pCVar->FindVar("miles_language");
+ rui_defaultDebugFontFace = g_pCVar->FindVar("rui_defaultDebugFontFace");
+ r_visualizetraces = g_pCVar->FindVar("r_visualizetraces");
+ r_visualizetraces_duration = g_pCVar->FindVar("r_visualizetraces_duration");
+#endif // !DEDICATED
+ staticProp_no_fade_scalar = g_pCVar->FindVar("staticProp_no_fade_scalar");
+ staticProp_gather_size_weight = g_pCVar->FindVar("staticProp_gather_size_weight");
+ stream_overlay = g_pCVar->FindVar("stream_overlay");
+ stream_overlay_mode = g_pCVar->FindVar("stream_overlay_mode");
+ sv_cheats = g_pCVar->FindVar("sv_cheats");
+ sv_visualizetraces = g_pCVar->FindVar("sv_visualizetraces");
+ sv_visualizetraces_duration = g_pCVar->FindVar("sv_visualizetraces_duration");
+ old_gather_props = g_pCVar->FindVar("old_gather_props");
+#ifndef DEDICATED
+ origin_disconnectWhenOffline = g_pCVar->FindVar("origin_disconnectWhenOffline");
+#endif // !DEDICATED
+ mp_gamemode = g_pCVar->FindVar("mp_gamemode");
+ ip_cvar = g_pCVar->FindVar("ip");
+ hostname = g_pCVar->FindVar("hostname");
+ hostip = g_pCVar->FindVar("hostip");
+ hostport = g_pCVar->FindVar("hostport");
+ host_hasIrreversibleShutdown = g_pCVar->FindVar("host_hasIrreversibleShutdown");
+ net_usesocketsforloopback = g_pCVar->FindVar("net_usesocketsforloopback");
+#ifndef CLIENT_DLL
+ sv_stats = g_pCVar->FindVar("sv_stats");
+
+ sv_updaterate_mp = g_pCVar->FindVar("sv_updaterate_mp");
+ sv_updaterate_sp = g_pCVar->FindVar("sv_updaterate_sp");
+
+ sv_showhitboxes = g_pCVar->FindVar("sv_showhitboxes");
+ sv_forceChatToTeamOnly = g_pCVar->FindVar("sv_forceChatToTeamOnly");
+
+ sv_voiceenable = g_pCVar->FindVar("sv_voiceenable");
+ sv_voiceEcho = g_pCVar->FindVar("sv_voiceEcho");
+ sv_alltalk = g_pCVar->FindVar("sv_alltalk");
+
+ sv_showhitboxes->SetMin(-1); // Allow user to go over each entity manually without going out of bounds.
+ sv_showhitboxes->SetMax(NUM_ENT_ENTRIES - 1);
+
+ sv_forceChatToTeamOnly->RemoveFlags(FCVAR_DEVELOPMENTONLY);
+ sv_forceChatToTeamOnly->AddFlags(FCVAR_REPLICATED);
+
+ ai_script_nodes_draw->SetValue(-1);
+#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2)
+ bhit_enable->SetValue(0);
+#endif // !(GAMEDLL_S0) || !(GAMEDLL_S1) || !(GAMEDLL_S2)
+#endif // !CLIENT_DLL
+#ifndef DEDICATED
+ cl_threaded_bone_setup->RemoveFlags(FCVAR_DEVELOPMENTONLY);
+ rui_defaultDebugFontFace->RemoveFlags(FCVAR_DEVELOPMENTONLY);
+ origin_disconnectWhenOffline->RemoveFlags(FCVAR_DEVELOPMENTONLY);
+#endif // !DEDICATED
+ mp_gamemode->RemoveFlags(FCVAR_DEVELOPMENTONLY);
+ mp_gamemode->RemoveChangeCallback(mp_gamemode->m_fnChangeCallbacks[0]);
+ mp_gamemode->InstallChangeCallback(MP_GameMode_Changed_f, false);
+ net_usesocketsforloopback->RemoveFlags(FCVAR_DEVELOPMENTONLY);
+ net_usesocketsforloopback->InstallChangeCallback(NET_UseSocketsForLoopbackChanged_f, false);
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: unregister/disable extraneous ConVar's.
+//-----------------------------------------------------------------------------
+void ConVar_PurgeShipped(void)
+{
+#ifdef DEDICATED
+ const char* pszToPurge[] =
+ {
+ "bink_materials_enabled",
+ "communities_enabled",
+ "community_frame_run",
+ "ime_enabled",
+ "origin_igo_mutes_sound_enabled",
+ "twitch_shouldQuery",
+ "voice_enabled",
+ };
+
+ for (size_t i = 0; i < SDK_ARRAYSIZE(pszToPurge); i++)
+ {
+ if (ConVar* pCVar = g_pCVar->FindVar(pszToPurge[i]))
+ {
+ pCVar->SetValue(0);
+ }
+ }
+#endif // DEDICATED
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: clear all hostname ConVar's.
+//-----------------------------------------------------------------------------
+void ConVar_PurgeHostNames(void)
+{
+ const char* pszHostNames[] =
+ {
+ "assetdownloads_hostname",
+ "communities_hostname",
+ "matchmaking_hostname",
+ "party_hostname",
+ "persistence_hostname",
+ "persistenceDef_hostname",
+ "pin_telemetry_hostname",
+ "publication_hostname",
+ "serverReports_hostname",
+ "skill_hostname",
+ "speechtotext_hostname",
+ "staticfile_hostname",
+ "stats_hostname",
+ "steamlink_hostname",
+ "subscription_hostname",
+ "users_hostname"
+ };
+
+ for (size_t i = 0; i < SDK_ARRAYSIZE(pszHostNames); i++)
+ {
+ if (ConVar* pCVar = g_pCVar->FindVar(pszHostNames[i]))
+ {
+ pCVar->SetValue(NET_IPV4_UNSPEC);
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: ConCommand registration
+//-----------------------------------------------------------------------------
+void ConCommand_StaticInit(void)
+{
+ //-------------------------------------------------------------------------
+ // ENGINE DLL |
+#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1)
+ ConCommand::StaticCreate("bhit", "Bullet-hit trajectory debug.", nullptr, FCVAR_DEVELOPMENTONLY | FCVAR_GAMEDLL, BHit_f, nullptr);
+#endif // !GAMEDLL_S0 && !GAMEDLL_S1
+#ifndef DEDICATED
+ ConCommand::StaticCreate("line", "Draw a debug line.", nullptr, FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, Line_f, nullptr);
+ ConCommand::StaticCreate("sphere", "Draw a debug sphere.", nullptr, FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, Sphere_f, nullptr);
+ ConCommand::StaticCreate("capsule", "Draw a debug capsule.", nullptr, FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, Capsule_f, nullptr);
+#endif //!DEDICATED
+ ConCommand::StaticCreate("con_help", "Shows the colors and description of each context.", nullptr, FCVAR_RELEASE, CON_Help_f, nullptr);
+#ifndef CLIENT_DLL
+ ConCommand::StaticCreate("reload_playlists", "Reloads the playlists file.", nullptr, FCVAR_RELEASE, Host_ReloadPlaylists_f, nullptr);
+#endif // !CLIENT_DLL
+ //-------------------------------------------------------------------------
+ // SERVER DLL |
+#ifndef CLIENT_DLL
+ ConCommand::StaticCreate("script", "Run input code as SERVER script on the VM.", nullptr, FCVAR_GAMEDLL | FCVAR_CHEAT, SQVM_ServerScript_f, nullptr);
+ ConCommand::StaticCreate("sv_kick", "Kick a client from the server by user name.", "sv_kick \"\"", FCVAR_RELEASE, Host_Kick_f, nullptr);
+ ConCommand::StaticCreate("sv_kickid", "Kick a client from the server by handle, nucleus id or ip address.", "sv_kickid \"\"/\"/\"", FCVAR_RELEASE, Host_KickID_f, nullptr);
+ ConCommand::StaticCreate("sv_ban", "Bans a client from the server by user name.", "sv_ban ", FCVAR_RELEASE, Host_Ban_f, nullptr);
+ ConCommand::StaticCreate("sv_banid", "Bans a client from the server by handle, nucleus id or ip address.", "sv_banid \"\"/\"/\"", FCVAR_RELEASE, Host_BanID_f, nullptr);
+ ConCommand::StaticCreate("sv_unban", "Unbans a client from the server by nucleus id or ip address.", "sv_unban \"\"/\"\"", FCVAR_RELEASE, Host_Unban_f, nullptr);
+ ConCommand::StaticCreate("sv_reloadbanlist", "Reloads the banned list.", nullptr, FCVAR_RELEASE, Host_ReloadBanList_f, nullptr);
+ ConCommand::StaticCreate("sv_addbot", "Creates a bot on the server.", nullptr, FCVAR_RELEASE, CC_CreateFakePlayer_f, nullptr);
+ ConCommand::StaticCreate("navmesh_hotswap", "Hot swap the NavMesh for all hulls.", nullptr, FCVAR_DEVELOPMENTONLY, Detour_HotSwap_f, nullptr);
+#endif // !CLIENT_DLL
+#ifndef DEDICATED
+ //-------------------------------------------------------------------------
+ // CLIENT DLL |
+ ConCommand::StaticCreate("script_client", "Run input code as CLIENT script on the VM.", nullptr, FCVAR_CLIENTDLL | FCVAR_CHEAT, SQVM_ClientScript_f, nullptr);
+ ConCommand::StaticCreate("rcon", "Forward RCON query to remote server.", "rcon \"\"", FCVAR_CLIENTDLL | FCVAR_RELEASE, RCON_CmdQuery_f, nullptr);
+ ConCommand::StaticCreate("rcon_disconnect", "Disconnect from RCON server.", nullptr, FCVAR_CLIENTDLL | FCVAR_RELEASE, RCON_Disconnect_f, nullptr);
+
+ ConCommand::StaticCreate("con_history", "Shows the developer console submission history.", nullptr, FCVAR_CLIENTDLL | FCVAR_RELEASE, CON_LogHistory_f, nullptr);
+ ConCommand::StaticCreate("con_removeline", "Removes a range of lines from the developer console.", nullptr, FCVAR_CLIENTDLL | FCVAR_RELEASE, CON_RemoveLine_f, nullptr);
+ ConCommand::StaticCreate("con_clearlines", "Clears all lines from the developer console.", nullptr, FCVAR_CLIENTDLL | FCVAR_RELEASE, CON_ClearLines_f, nullptr);
+ ConCommand::StaticCreate("con_clearhistory", "Clears all submissions from the developer console history.", nullptr, FCVAR_CLIENTDLL | FCVAR_RELEASE, CON_ClearHistory_f, nullptr);
+
+ ConCommand::StaticCreate("toggleconsole", "Show/hide the developer console.", nullptr, FCVAR_CLIENTDLL | FCVAR_RELEASE, ToggleConsole_f, nullptr);
+ ConCommand::StaticCreate("togglebrowser", "Show/hide the server browser.", nullptr, FCVAR_CLIENTDLL | FCVAR_RELEASE, ToggleBrowser_f, nullptr);
+ //-------------------------------------------------------------------------
+ // UI DLL |
+ ConCommand::StaticCreate("script_ui", "Run input code as UI script on the VM.", nullptr, FCVAR_CLIENTDLL | FCVAR_CHEAT, SQVM_UIScript_f, nullptr);
+#endif // !DEDICATED
+ //-------------------------------------------------------------------------
+ // FILESYSTEM API |
+ ConCommand::StaticCreate("fs_vpk_mount", "Mount a VPK file for FileSystem usage.", nullptr, FCVAR_DEVELOPMENTONLY, VPK_Mount_f, nullptr);
+ ConCommand::StaticCreate("fs_vpk_unmount", "Unmount a VPK file and clear its cache.", nullptr, FCVAR_DEVELOPMENTONLY, VPK_Unmount_f, nullptr);
+ ConCommand::StaticCreate("fs_vpk_build", "Build a VPK file from current workspace.", nullptr, FCVAR_DEVELOPMENTONLY, VPK_Pack_f, nullptr);
+ ConCommand::StaticCreate("fs_vpk_unpack", "Unpack all files from a VPK file.", nullptr, FCVAR_DEVELOPMENTONLY, VPK_Unpack_f, nullptr);
+ //-------------------------------------------------------------------------
+ // RTECH API |
+ ConCommand::StaticCreate("rtech_strtoguid", "Calculates the GUID from input data.", nullptr, FCVAR_DEVELOPMENTONLY, RTech_StringToGUID_f, nullptr);
+ ConCommand::StaticCreate("pak_decompress", "Decompresses specified RPAK file.", nullptr, FCVAR_DEVELOPMENTONLY, RTech_Decompress_f, RTech_PakDecompress_f_CompletionFunc);
+ ConCommand::StaticCreate("pak_requestload", "Requests asynchronous load for specified RPAK file.", nullptr, FCVAR_DEVELOPMENTONLY, Pak_RequestLoad_f, RTech_PakLoad_f_CompletionFunc);
+ ConCommand::StaticCreate("pak_requestunload", "Requests unload for specified RPAK file or ID.", nullptr, FCVAR_DEVELOPMENTONLY, Pak_RequestUnload_f, RTech_PakUnload_f_CompletionFunc);
+ ConCommand::StaticCreate("pak_swap", "Requests swap for specified RPAK file or ID", nullptr, FCVAR_DEVELOPMENTONLY, Pak_Swap_f, nullptr);
+ ConCommand::StaticCreate("pak_listpaks", "Display a list of the loaded Pak files.", nullptr, FCVAR_RELEASE, Pak_ListPaks_f, nullptr);
+ ConCommand::StaticCreate("pak_listtypes", "Display a list of the registered asset types.", nullptr, FCVAR_RELEASE, Pak_ListTypes_f, nullptr);
+ //-------------------------------------------------------------------------
+ // NETCHANNEL |
+ ConCommand::StaticCreate("net_setkey", "Sets user specified base64 net key.", nullptr, FCVAR_RELEASE, NET_SetKey_f, nullptr);
+ ConCommand::StaticCreate("net_generatekey", "Generates and sets a random base64 net key.", nullptr, FCVAR_RELEASE, NET_GenerateKey_f, nullptr);
+ //-------------------------------------------------------------------------
+ // TIER0 |
+ ConCommand::StaticCreate("sig_getadr", "Logs the sigscan results to the console.", nullptr, FCVAR_DEVELOPMENTONLY | FCVAR_HIDDEN, SIG_GetAdr_f, nullptr);
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: shipped ConCommand initialization
+//-----------------------------------------------------------------------------
+void ConCommand_InitShipped(void)
+{
+ ///------------------------------------------------------ [ CALLBACK SWAP ]
+ //-------------------------------------------------------------------------
+ // ENGINE DLL |
+ ConCommand* changelevel = g_pCVar->FindCommand("changelevel");
+ ConCommand* map = g_pCVar->FindCommand("map");
+ ConCommand* map_background = g_pCVar->FindCommand("map_background");
+ ConCommand* ss_map = g_pCVar->FindCommand("ss_map");
+ ConCommand* migrateme = g_pCVar->FindCommand("migrateme");
+ ConCommand* help = g_pCVar->FindCommand("help");
+ ConCommand* convar_list = g_pCVar->FindCommand("convar_list");
+ ConCommand* convar_differences = g_pCVar->FindCommand("convar_differences");
+ ConCommand* convar_findByFlags = g_pCVar->FindCommand("convar_findByFlags");
+#ifndef DEDICATED
+ //-------------------------------------------------------------------------
+ // MATERIAL SYSTEM
+ ConCommand* mat_crosshair = g_pCVar->FindCommand("mat_crosshair"); // Patch callback function to working callback.
+ //-------------------------------------------------------------------------
+ // CLIENT DLL |
+ ConCommand* give = g_pCVar->FindCommand("give");
+#endif // !DEDICATED
+
+ help->m_fnCommandCallback = CVHelp_f;
+ convar_list->m_fnCommandCallback = CVList_f;
+ convar_differences->m_fnCommandCallback = CVDiff_f;
+ convar_findByFlags->m_fnCommandCallback = CVFlag_f;
+#ifndef CLIENT_DLL
+ changelevel->m_fnCommandCallback = Host_Changelevel_f;
+#endif // !CLIENT_DLL
+ changelevel->m_fnCompletionCallback = Host_Changelevel_f_CompletionFunc;
+
+ map->m_fnCompletionCallback = Host_Map_f_CompletionFunc;
+ map_background->m_fnCompletionCallback = Host_Background_f_CompletionFunc;
+ ss_map->m_fnCompletionCallback = Host_SSMap_f_CompletionFunc;
+
+#ifndef DEDICATED
+ mat_crosshair->m_fnCommandCallback = Mat_CrossHair_f;
+ give->m_fnCompletionCallback = Game_Give_f_CompletionFunc;
+#endif // !DEDICATED
+
+ /// ------------------------------------------------------ [ FLAG REMOVAL ]
+ //-------------------------------------------------------------------------
+ if (!CommandLine()->CheckParm("-devsdk"))
+ {
+ const char* pszMaskedBases[] =
+ {
+#ifndef DEDICATED
+ "connect",
+ "connectAsSpectator",
+ "connectWithKey",
+ "silentconnect",
+ "set",
+ "ping",
+#endif // !DEDICATED
+ "launchplaylist",
+ "quit",
+ "exit",
+ "reload",
+ "restart",
+ "status",
+ "version",
+ };
+
+ for (size_t i = 0; i < SDK_ARRAYSIZE(pszMaskedBases); i++)
+ {
+ if (ConCommandBase* pCommandBase = g_pCVar->FindCommandBase(pszMaskedBases[i]))
+ {
+ pCommandBase->RemoveFlags(FCVAR_DEVELOPMENTONLY);
+ }
+ }
+
+ convar_list->RemoveFlags(FCVAR_DEVELOPMENTONLY);
+ convar_differences->RemoveFlags(FCVAR_DEVELOPMENTONLY);
+ convar_findByFlags->RemoveFlags(FCVAR_DEVELOPMENTONLY);
+ help->RemoveFlags(FCVAR_DEVELOPMENTONLY);
+ migrateme->RemoveFlags(FCVAR_SERVER_CAN_EXECUTE);
+ changelevel->RemoveFlags(FCVAR_DEVELOPMENTONLY);
+ map->RemoveFlags(FCVAR_DEVELOPMENTONLY | FCVAR_SERVER_CAN_EXECUTE);
+ map_background->RemoveFlags(FCVAR_DEVELOPMENTONLY | FCVAR_SERVER_CAN_EXECUTE);
+ ss_map->RemoveFlags(FCVAR_DEVELOPMENTONLY | FCVAR_SERVER_CAN_EXECUTE);
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: unregister extraneous ConCommand's.
+//-----------------------------------------------------------------------------
+void ConCommand_PurgeShipped(void)
+{
+#ifdef DEDICATED
+ const char* pszCommandToRemove[] =
+ {
+ "bind",
+ "bind_held",
+ "bind_list",
+ "bind_list_abilities",
+ "bind_US_standard",
+ "bind_held_US_standard",
+ "unbind",
+ "unbind_US_standard",
+ "unbindall",
+ "unbind_all_gamepad",
+ "unbindall_ignoreGamepad",
+ "unbind_batch",
+ "unbind_held",
+ "unbind_held_US_standard",
+ "uiscript_reset",
+ "getpos_bind",
+ "connect",
+ "silent_connect",
+ "ping",
+ "gameui_activate",
+ "gameui_hide",
+ "weaponSelectOrdnance",
+ "weaponSelectPrimary0",
+ "weaponSelectPrimary1",
+ "weaponSelectPrimary2",
+ "+scriptCommand1",
+ "-scriptCommand1",
+ "+scriptCommand2",
+ "-scriptCommand2",
+ "+scriptCommand3",
+ "-scriptCommand3",
+ "+scriptCommand4",
+ "-scriptCommand4",
+ "+scriptCommand5",
+ "-scriptCommand5",
+ "+scriptCommand6",
+ "-scriptCommand6",
+ "+scriptCommand7",
+ "-scriptCommand7",
+ "+scriptCommand8",
+ "-scriptCommand8",
+ "+scriptCommand9",
+ "-scriptCommand9",
+ };
+
+ for (size_t i = 0; i < SDK_ARRAYSIZE(pszCommandToRemove); i++)
+ {
+ ConCommandBase* pCommandBase = g_pCVar->FindCommandBase(pszCommandToRemove[i]);
+
+ if (pCommandBase)
+ {
+ g_pCVar->UnregisterConCommand(pCommandBase);
+ }
+ }
+#endif // DEDICATED
+}
\ No newline at end of file
diff --git a/r5dev/common/global.h b/r5dev/common/global.h
new file mode 100644
index 00000000..be74da5d
--- /dev/null
+++ b/r5dev/common/global.h
@@ -0,0 +1,232 @@
+#ifndef GLOBAL_H
+#define GLOBAL_H
+
+//-------------------------------------------------------------------------
+// ENGINE |
+extern ConVar* sdk_fixedframe_tickinterval;
+extern ConVar* single_frame_shutdown_for_reload;
+extern ConVar* old_gather_props;
+
+extern ConVar* enable_debug_overlays;
+extern ConVar* debug_draw_box_depth_test;
+
+extern ConVar* developer;
+extern ConVar* fps_max;
+
+extern ConVar* staticProp_defaultBuildFrustum;
+extern ConVar* staticProp_no_fade_scalar;
+extern ConVar* staticProp_gather_size_weight;
+
+extern ConVar* model_defaultFadeDistScale;
+extern ConVar* model_defaultFadeDistMin;
+
+extern ConVar* ip_cvar;
+extern ConVar* hostname;
+extern ConVar* hostdesc;
+extern ConVar* hostip;
+extern ConVar* hostport;
+extern ConVar* host_hasIrreversibleShutdown;
+
+extern ConVar* mp_gamemode;
+
+extern ConVar* rcon_address;
+extern ConVar* rcon_password;
+
+extern ConVar* r_debug_overlay_nodecay;
+extern ConVar* r_debug_overlay_invisible;
+extern ConVar* r_debug_overlay_wireframe;
+extern ConVar* r_debug_draw_depth_test;
+extern ConVar* r_drawWorldMeshes;
+extern ConVar* r_drawWorldMeshesDepthOnly;
+extern ConVar* r_drawWorldMeshesDepthAtTheEnd;
+
+#ifndef DEDICATED
+extern ConVar* r_visualizetraces;
+extern ConVar* r_visualizetraces_duration;
+#endif // !DEDICATED
+
+extern ConVar* stream_overlay;
+extern ConVar* stream_overlay_mode;
+//-------------------------------------------------------------------------
+// SERVER |
+#ifndef CLIENT_DLL
+extern ConVar* ai_ainDumpOnLoad;
+extern ConVar* ai_ainDebugConnect;
+extern ConVar* ai_script_nodes_draw;
+extern ConVar* ai_script_nodes_draw_range;
+extern ConVar* ai_script_nodes_draw_nearest;
+
+extern ConVar* navmesh_always_reachable;
+extern ConVar* navmesh_debug_type;
+extern ConVar* navmesh_debug_tile_range;
+extern ConVar* navmesh_debug_camera_range;
+#ifndef DEDICATED
+extern ConVar* navmesh_draw_bvtree;
+extern ConVar* navmesh_draw_portal;
+extern ConVar* navmesh_draw_polys;
+extern ConVar* navmesh_draw_poly_bounds;
+extern ConVar* navmesh_draw_poly_bounds_inner;
+#endif // DEDICATED
+extern ConVar* sv_showconnecting;
+extern ConVar* sv_globalBanlist;
+extern ConVar* sv_pylonVisibility;
+extern ConVar* sv_pylonRefreshRate;
+extern ConVar* sv_banlistRefreshRate;
+extern ConVar* sv_statusRefreshRate;
+extern ConVar* sv_forceChatToTeamOnly;
+
+extern ConVar* sv_updaterate_mp;
+extern ConVar* sv_updaterate_sp;
+extern ConVar* sv_autoReloadRate;
+
+extern ConVar* sv_simulateBots;
+extern ConVar* sv_showhitboxes;
+extern ConVar* sv_stats;
+
+extern ConVar* sv_quota_stringCmdsPerSecond;
+
+extern ConVar* sv_validatePersonaName;
+extern ConVar* sv_minPersonaNameLength;
+extern ConVar* sv_maxPersonaNameLength;
+
+extern ConVar* sv_voiceEcho;
+extern ConVar* sv_voiceenable;
+extern ConVar* sv_alltalk;
+
+//#ifdef DEDICATED
+extern ConVar* sv_rcon_debug;
+extern ConVar* sv_rcon_sendlogs;
+extern ConVar* sv_rcon_banpenalty;
+extern ConVar* sv_rcon_maxfailures;
+extern ConVar* sv_rcon_maxignores;
+extern ConVar* sv_rcon_maxsockets;
+extern ConVar* sv_rcon_maxconnections;
+extern ConVar* sv_rcon_maxpacketsize;
+extern ConVar* sv_rcon_whitelist_address;
+//#endif // DEDICATED
+#endif // CLIENT_DLL
+extern ConVar* sv_cheats;
+extern ConVar* sv_visualizetraces;
+extern ConVar* sv_visualizetraces_duration;
+#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1)
+extern ConVar* bhit_enable;
+extern ConVar* bhit_depth_test;
+extern ConVar* bhit_abs_origin;
+#endif // !GAMEDLL_S0 && !GAMEDLL_S1
+//-------------------------------------------------------------------------
+// CLIENT |
+#ifndef DEDICATED
+extern ConVar* cl_rcon_request_sendlogs;
+extern ConVar* cl_quota_stringCmdsPerSecond;
+
+extern ConVar* cl_notify_invert_x;
+extern ConVar* cl_notify_invert_y;
+extern ConVar* cl_notify_offset_x;
+extern ConVar* cl_notify_offset_y;
+
+extern ConVar* cl_showsimstats;
+extern ConVar* cl_simstats_invert_x;
+extern ConVar* cl_simstats_invert_y;
+extern ConVar* cl_simstats_offset_x;
+extern ConVar* cl_simstats_offset_y;
+
+extern ConVar* cl_showgpustats;
+extern ConVar* cl_gpustats_invert_x;
+extern ConVar* cl_gpustats_invert_y;
+extern ConVar* cl_gpustats_offset_x;
+extern ConVar* cl_gpustats_offset_y;
+
+extern ConVar* cl_showmaterialinfo;
+extern ConVar* cl_materialinfo_offset_x;
+extern ConVar* cl_materialinfo_offset_y;
+
+extern ConVar* cl_threaded_bone_setup;
+
+extern ConVar* con_drawnotify;
+extern ConVar* con_notifylines;
+extern ConVar* con_notifytime;
+
+extern ConVar* con_notify_invert_x;
+extern ConVar* con_notify_invert_y;
+extern ConVar* con_notify_offset_x;
+extern ConVar* con_notify_offset_y;
+
+extern ConVar* con_notify_script_server_clr;
+extern ConVar* con_notify_script_client_clr;
+extern ConVar* con_notify_script_ui_clr;
+extern ConVar* con_notify_native_server_clr;
+extern ConVar* con_notify_native_client_clr;
+extern ConVar* con_notify_native_ui_clr;
+extern ConVar* con_notify_native_engine_clr;
+extern ConVar* con_notify_native_fs_clr;
+extern ConVar* con_notify_native_rtech_clr;
+extern ConVar* con_notify_native_ms_clr;
+extern ConVar* con_notify_native_audio_clr;
+extern ConVar* con_notify_native_video_clr;
+extern ConVar* con_notify_netcon_clr;
+extern ConVar* con_notify_common_clr;
+extern ConVar* con_notify_warning_clr;
+extern ConVar* con_notify_error_clr;
+
+extern ConVar* con_max_lines;
+extern ConVar* con_max_history;
+extern ConVar* con_suggestion_limit;
+extern ConVar* con_suggestion_showhelptext;
+extern ConVar* con_suggestion_showflags;
+extern ConVar* con_suggestion_flags_realtime;
+
+extern ConVar* origin_disconnectWhenOffline;
+#endif // !DEDICATED
+//-------------------------------------------------------------------------
+// FILESYSTEM |
+extern ConVar* fs_showWarnings;
+extern ConVar* fs_showAllReads;
+extern ConVar* fs_packedstore_entryblock_stats;
+extern ConVar* fs_packedstore_workspace;
+extern ConVar* fs_packedstore_compression_level;
+extern ConVar* fs_packedstore_max_helper_threads;
+//-------------------------------------------------------------------------
+// MATERIALSYSTEM |
+#ifndef DEDICATED
+extern ConVar* mat_alwaysComplain;
+#endif // !DEDICATED
+//-------------------------------------------------------------------------
+// SQUIRREL |
+extern ConVar* script_show_output;
+extern ConVar* script_show_warning;
+//-------------------------------------------------------------------------
+// NETCHANNEL |
+extern ConVar* net_tracePayload;
+extern ConVar* net_encryptionEnable;
+extern ConVar* net_useRandomKey;
+extern ConVar* net_usesocketsforloopback;
+extern ConVar* net_processTimeBudget;
+
+extern ConVar* pylon_matchmaking_hostname;
+extern ConVar* pylon_host_update_interval;
+extern ConVar* pylon_showdebuginfo;
+//-------------------------------------------------------------------------
+// RTECH API |
+extern ConVar* rtech_debug;
+//-------------------------------------------------------------------------
+// RUI |
+#ifndef DEDICATED
+extern ConVar* rui_drawEnable;
+extern ConVar* rui_defaultDebugFontFace;
+#endif // !DEDICATED
+//-------------------------------------------------------------------------
+// MILES |
+#ifndef DEDICATED
+extern ConVar* miles_debug;
+extern ConVar* miles_language;
+#endif
+
+void ConVar_StaticInit(void);
+void ConVar_InitShipped(void);
+void ConVar_PurgeShipped(void);
+void ConVar_PurgeHostNames(void);
+void ConCommand_StaticInit(void);
+void ConCommand_InitShipped(void);
+void ConCommand_PurgeShipped(void);
+
+#endif // GLOBAL_H
diff --git a/r5dev/common/netmessages.h b/r5dev/common/netmessages.h
index e418f36d..f6969270 100644
--- a/r5dev/common/netmessages.h
+++ b/r5dev/common/netmessages.h
@@ -27,7 +27,7 @@ class Base_CmdKeyValues;
//-------------------------------------------------------------------------
// MM_HEARTBEAT
//-------------------------------------------------------------------------
-inline CMemory MM_Heartbeat__ToString; // server HeartBeat? (baseserver.cpp).
+//inline CMemory MM_Heartbeat__ToString; // server HeartBeat? (baseserver.cpp).
//-------------------------------------------------------------------------
// SVC_Print
@@ -315,11 +315,11 @@ class V_NetMessages : public IDetour
LogConAdr("SVC_ServerTick::`vftable'", reinterpret_cast(g_pSVC_ServerTick_VFTable));
LogConAdr("SVC_VoiceData::`vftable'", reinterpret_cast(g_pSVC_VoiceData_VFTable));
LogConAdr("Base_CmdKeyValues::`vftable'", reinterpret_cast(g_pBase_CmdKeyValues_VFTable));
- LogFunAdr("MM_Heartbeat::ToString", MM_Heartbeat__ToString.GetPtr());
+ //LogFunAdr("MM_Heartbeat::ToString", MM_Heartbeat__ToString.GetPtr());
}
virtual void GetFun(void) const
{
- MM_Heartbeat__ToString = g_GameDll.FindPatternSIMD("48 83 EC 38 E8 ?? ?? ?? ?? 3B 05 ?? ?? ?? ??");
+ //MM_Heartbeat__ToString = g_GameDll.FindPatternSIMD("48 83 EC 38 E8 ?? ?? ?? ?? 3B 05 ?? ?? ?? ??");
// 48 83 EC 38 E8 ? ? ? ? 3B 05 ? ? ? ?
}
virtual void GetVar(void) const { }
diff --git a/r5dev/common/opcodes.cpp b/r5dev/common/opcodes.cpp
index c03a34a9..fc822a50 100644
--- a/r5dev/common/opcodes.cpp
+++ b/r5dev/common/opcodes.cpp
@@ -3,7 +3,6 @@
*-----------------------------------------------------------------------------*/
#include "core/stdafx.h"
-#include "launcher/IApplication.h"
#include "common/opcodes.h"
//#include "common/netmessages.h"
//#include "engine/cmodel_bsp.h"
@@ -17,7 +16,9 @@
//#include "engine/client/cl_main.h"
//#include "engine/client/client.h"
//#include "engine/client/clientstate.h"
+//#include "engine/client/cdll_engine_int.h"
//#include "engine/sys_getmodes.h"
+//#include "engine/sys_dll.h"
#ifndef CLIENT_DLL
#include "game/server/ai_networkmanager.h"
#include "game/server/fairfight_impl.h"
@@ -25,11 +26,9 @@
#endif // !CLIENT_DLL
#include "rtech/rtech_game.h"
//#include "rtech/rui/rui.h"
-//#include "client/cdll_engine_int.h"
//#include "materialsystem/cmaterialsystem.h"
//#include "studiorender/studiorendercontext.h"
#include "vscript/languages/squirrel_re/include/sqvm.h"
-//#include "bsplib/bsplib.h"
//#include "ebisusdk/EbisuSDK.h"
#ifndef DEDICATED
#include "codecs/miles/radshal_wasapi.h"
diff --git a/r5dev/core/CMakeLists.txt b/r5dev/core/CMakeLists.txt
new file mode 100644
index 00000000..baa7b3b0
--- /dev/null
+++ b/r5dev/core/CMakeLists.txt
@@ -0,0 +1,131 @@
+cmake_minimum_required( VERSION 3.16 )
+macro( add_sdk_project PROJECT_NAME )
+add_module( "shared_lib" ${PROJECT_NAME} "vpc" ${FOLDER_CONTEXT} )
+
+start_sources()
+
+if( NOT ${PROJECT_NAME} STREQUAL "dedicated" )
+file( GLOB PNG_SOURCES
+ "${ENGINE_SOURCE_DIR}/resource/png/*.png"
+)
+add_sources( SOURCE_GROUP "Resource"
+ "${ENGINE_SOURCE_DIR}/resource/r5dev.rc"
+ "${PNG_SOURCES}"
+)
+endif()
+
+add_sources( SOURCE_GROUP "Core"
+ "assert.h"
+ "dllmain.cpp"
+ "init.cpp"
+ "init.h"
+ "logdef.cpp"
+ "logdef.h"
+ "logger.cpp"
+ "logger.h"
+ "r5dev.h"
+ "resource.h"
+ "shared_pch.h"
+ "stdafx.cpp"
+ "stdafx.h"
+ "termutil.cpp"
+ "termutil.h"
+)
+
+target_link_libraries( ${PROJECT_NAME} PRIVATE
+ "advapi32.lib"
+ "bcrypt.lib"
+ "crypt32.lib"
+ "dbghelp.lib"
+ "wldap32.lib"
+ "ws2_32.lib"
+ "Rpcrt4.lib"
+
+ "vpc"
+ "tier0"
+ "tier1"
+ "tier2"
+ "launcher"
+ "appframework"
+
+ "vstdlib"
+ "vpklib"
+ "mathlib"
+ "protocol_pb"
+ "vphysics"
+
+ "rtech_tools"
+ "rtech_game"
+ "stryder"
+
+ "libdetours"
+ "liblzham"
+ "libcurl"
+ "libprotobuf"
+ "libspdlog"
+ "libdetour"
+ "navdebugutils"
+
+ "networksystem"
+ "pluginsystem"
+ "filesystem"
+ "datacache"
+ "EbisuSDK"
+
+ "localize"
+
+ "vscript"
+ "game"
+)
+
+if( NOT ${PROJECT_NAME} STREQUAL "dedicated" )
+target_link_libraries( ${PROJECT_NAME} PRIVATE
+ "libimgui"
+ "codecs"
+
+ "inputsystem"
+ "materialsystem"
+
+ "vguimatsurface"
+ "vgui"
+ "rui"
+
+ "engine"
+ "d3d11.lib"
+)
+else()
+target_link_libraries( ${PROJECT_NAME} PRIVATE
+ "engine_ds"
+)
+endif()
+
+if( ${PROJECT_NAME} STREQUAL "gamesdk" )
+end_sources()
+target_compile_definitions( ${PROJECT_NAME} PRIVATE
+ "GAMESDK"
+)
+elseif( ${PROJECT_NAME} STREQUAL "dedicated" )
+end_sources()
+target_compile_definitions( ${PROJECT_NAME} PRIVATE
+ "DEDICATED"
+)
+elseif( ${PROJECT_NAME} STREQUAL "client" )
+end_sources( "game/bin/x64_retail/" )
+target_compile_definitions( ${PROJECT_NAME} PRIVATE
+ "CLIENT_DLL"
+)
+endif()
+
+target_link_options( ${PROJECT_NAME} PRIVATE
+ "/STACK:8000000" # Match game executable stack reserve size
+)
+
+add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -P ${ENGINE_SOURCE_DIR}/cmake/PostBuild.cmake
+)
+
+endmacro()
+
+add_sdk_project( "gamesdk" )
+add_sdk_project( "dedicated" )
+add_sdk_project( "client" )
diff --git a/r5dev/core/dllmain.cpp b/r5dev/core/dllmain.cpp
index dd8c595c..44e542ab 100644
--- a/r5dev/core/dllmain.cpp
+++ b/r5dev/core/dllmain.cpp
@@ -2,6 +2,7 @@
#include "core/r5dev.h"
#include "core/init.h"
#include "core/logdef.h"
+#include "core/logger.h"
#include "tier0/crashhandler.h"
/*****************************************************************************/
#ifndef DEDICATED
@@ -17,6 +18,38 @@
// INITIALIZATION
//#############################################################################
+void Crash_Callback()
+{
+ // Shutdown SpdLog to flush all buffers.
+ SpdLog_Shutdown();
+
+ // TODO[ AMOS ]: This is where we want to call backtrace from.
+}
+
+void Tier0_Init()
+{
+#if !defined (DEDICATED)
+ g_GameDll = CModule("r5apex.exe");
+ g_RadVideoToolsDll = CModule("bink2w64.dll");
+ g_RadAudioDecoderDll = CModule("binkawin64.dll");
+ g_RadAudioSystemDll = CModule("mileswin64.dll");
+#if !defined (CLIENT_DLL)
+ g_SDKDll = CModule("gamesdk.dll");
+#else // This dll is loaded from 'bin/x64_retail//'
+ g_SDKDll = CModule("client.dll");
+#endif // !CLIENT_DLL
+#else // No DirectX and Miles imports.
+ g_GameDll = CModule("r5apex_ds.exe");
+ g_SDKDll = CModule("dedicated.dll");
+#endif // !DEDICATED
+
+ // Setup logger callback sink.
+ g_CoreMsgVCallback = &EngineLoggerSink;
+
+ // Setup crash callback.
+ g_CrashHandler->SetCrashCallback(&Crash_Callback);
+}
+
void SDK_Init()
{
if (strstr(GetCommandLineA(), "-launcher"))
@@ -113,6 +146,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
if (!s_bNoWorkerDll)
{
+ Tier0_Init();
SDK_Init();
}
else // Destroy crash handler.
diff --git a/r5dev/core/init.cpp b/r5dev/core/init.cpp
index 31487ab1..6c134d1a 100644
--- a/r5dev/core/init.cpp
+++ b/r5dev/core/init.cpp
@@ -18,19 +18,17 @@
#include "tier0/sigcache.h"
#include "tier1/cmd.h"
#include "tier1/cvar.h"
-#include "tier1/binstream.h"
#include "vpc/IAppSystem.h"
#include "vpc/keyvalues.h"
#include "vpc/rson.h"
#include "vpc/interfaces.h"
-#include "vstdlib/callback.h"
-#include "vstdlib/completion.h"
+#include "common/callback.h"
+#include "common/completion.h"
#include "vstdlib/keyvaluessystem.h"
#include "common/opcodes.h"
#include "common/netmessages.h"
#include "launcher/prx.h"
#include "launcher/launcher.h"
-#include "launcher/IApplication.h"
#include "filesystem/basefilesystem.h"
#include "filesystem/filesystem.h"
#include "datacache/mdlcache.h"
@@ -49,13 +47,13 @@
#include "vgui/vgui_debugpanel.h"
#include "vgui/vgui_fpspanel.h"
#include "vguimatsurface/MatSystemSurface.h"
-#include "client/vengineclient_impl.h"
-#include "client/cdll_engine_int.h"
+#include "engine/client/vengineclient_impl.h"
+#include "engine/client/cdll_engine_int.h"
#endif // !DEDICATED
#ifndef CLIENT_DLL
#include "engine/server/server.h"
-#include "server/persistence.h"
-#include "server/vengineserver_impl.h"
+#include "engine/server/persistence.h"
+#include "engine/server/vengineserver_impl.h"
#endif // !CLIENT_DLL
#include "studiorender/studiorendercontext.h"
#include "rtech/rtech_game.h"
@@ -80,6 +78,7 @@
#include "engine/host_cmd.h"
#include "engine/host_state.h"
#include "engine/modelloader.h"
+#include "engine/cmd.h"
#include "engine/net.h"
#include "engine/net_chan.h"
#include "engine/networkstringtable.h"
@@ -186,7 +185,7 @@ void Systems_Init()
spdlog::info("{:16s} '{:10.6f}' seconds ('{:12d}' clocks)\n", "Detour->Attach()", initTimer.GetDuration().GetSeconds(), initTimer.GetDuration().GetCycles());
spdlog::info("+-------------------------------------------------------------+\n");
- ConVar::StaticInit();
+ ConVar_StaticInit();
}
//////////////////////////////////////////////////////////////////////////
@@ -408,7 +407,6 @@ void DetourRegister() // Register detour classes to be searched and hooked.
REGISTER(VLauncher);
REGISTER(VAppSystemGroup);
- REGISTER(VApplication);
// FileSystem
REGISTER(VBaseFileSystem);
@@ -435,10 +433,9 @@ void DetourRegister() // Register detour classes to be searched and hooked.
// StaticPropMgr
REGISTER(VStaticPropMgr);
+#ifndef DEDICATED
// MaterialSystem
REGISTER(VMaterialSystem);
-
-#ifndef DEDICATED
REGISTER(VMaterialGlue);
REGISTER(VShaderGlue);
@@ -482,16 +479,7 @@ void DetourRegister() // Register detour classes to be searched and hooked.
#endif // !DEDICATED
// Engine
- REGISTER(VTraceInit);
REGISTER(VCommon);
- REGISTER(VModel_BSP);
- REGISTER(VHost);
- REGISTER(VHostCmd);
- REGISTER(VHostState);
- REGISTER(VModelLoader);
- REGISTER(VNet);
- REGISTER(VNetChan);
- REGISTER(VNetworkStringTableContainer);
REGISTER(VSys_Dll);
REGISTER(VSys_Dll2);
@@ -500,6 +488,17 @@ void DetourRegister() // Register detour classes to be searched and hooked.
REGISTER(VEngineTrace);
REGISTER(VModelInfo);
+ REGISTER(VTraceInit);
+ REGISTER(VModel_BSP);
+ REGISTER(VHost);
+ REGISTER(VHostCmd);
+ REGISTER(VHostState);
+ REGISTER(VModelLoader);
+ REGISTER(VCmd);
+ REGISTER(VNet);
+ REGISTER(VNetChan);
+ REGISTER(VNetworkStringTableContainer);
+
REGISTER(VLocalize);
#ifndef DEDICATED
diff --git a/r5dev/core/logdef.cpp b/r5dev/core/logdef.cpp
index 90894482..f6f08e8b 100644
--- a/r5dev/core/logdef.cpp
+++ b/r5dev/core/logdef.cpp
@@ -18,7 +18,8 @@ void SpdLog_Init(void)
}
#ifndef NETCONSOLE
- g_LogSessionDirectory = fmt::format("platform\\logs\\{:s}", g_ProcessTimestamp);
+ g_LogSessionUUID = CreateUUID();
+ g_LogSessionDirectory = fmt::format("platform\\logs\\{:s}", g_LogSessionUUID);
/************************
* IMGUI LOGGER SETUP *
************************/
diff --git a/r5dev/core/logdef.h b/r5dev/core/logdef.h
index a499007f..e77ac593 100644
--- a/r5dev/core/logdef.h
+++ b/r5dev/core/logdef.h
@@ -1,13 +1,21 @@
#pragma once
+#include
+#include "thirdparty/spdlog/spdlog.h"
+#include "thirdparty/spdlog/async.h"
+#include "thirdparty/spdlog/sinks/ostream_sink.h"
+#include "thirdparty/spdlog/sinks/basic_file_sink.h"
+#include "thirdparty/spdlog/sinks/stdout_sinks.h"
+#include "thirdparty/spdlog/sinks/stdout_color_sinks.h"
+#include "thirdparty/spdlog/sinks/ansicolor_sink.h"
+#include "thirdparty/spdlog/sinks/rotating_file_sink.h"
+
constexpr int SPDLOG_MAX_SIZE = 10 * 1024 * 1024; // Sets number of bytes before rotating logger.
constexpr int SPDLOG_NUM_FILE = 512; // Sets number of files to rotate to.
inline bool g_bSpdLog_UseAnsiClr = false;
inline bool g_bSpdLog_PostInit = false;
-inline string g_LogSessionDirectory;
-
extern std::shared_ptr g_TermLogger;
extern std::shared_ptr g_ImGuiLogger;
diff --git a/r5dev/core/logger.cpp b/r5dev/core/logger.cpp
new file mode 100644
index 00000000..d0bd2e6c
--- /dev/null
+++ b/r5dev/core/logger.cpp
@@ -0,0 +1,318 @@
+#include "core/stdafx.h"
+#include "tier0/utility.h"
+#include "logdef.h"
+#include "logger.h"
+#ifndef DEDICATED
+#include "vgui/vgui_debugpanel.h"
+#include "gameui/IConsole.h"
+#endif // !DEDICATED
+#ifndef CLIENT_DLL
+#include "engine/server/sv_rcon.h"
+#endif // !CLIENT_DLL
+#ifndef NETCONSOLE
+#include "vscript/languages/squirrel_re/include/sqstdaux.h"
+#endif // !NETCONSOLE
+std::mutex g_LogMutex;
+
+#if !defined (DEDICATED) && !defined (NETCONSOLE)
+ImVec4 CheckForWarnings(LogType_t type, eDLL_T context, const ImVec4& defaultCol)
+{
+ ImVec4 color = defaultCol;
+ if (type == LogType_t::LOG_WARNING || context == eDLL_T::SYSTEM_WARNING)
+ {
+ color = ImVec4(1.00f, 1.00f, 0.00f, 0.80f);
+ }
+ else if (type == LogType_t::LOG_ERROR || context == eDLL_T::SYSTEM_ERROR)
+ {
+ color = ImVec4(1.00f, 0.00f, 0.00f, 0.80f);
+ }
+
+ return color;
+}
+
+ImVec4 GetColorForContext(LogType_t type, eDLL_T context)
+{
+ switch (context)
+ {
+ case eDLL_T::SCRIPT_SERVER:
+ return CheckForWarnings(type, context, ImVec4(0.59f, 0.58f, 0.73f, 1.00f));
+ case eDLL_T::SCRIPT_CLIENT:
+ return CheckForWarnings(type, context, ImVec4(0.59f, 0.58f, 0.63f, 1.00f));
+ case eDLL_T::SCRIPT_UI:
+ return CheckForWarnings(type, context, ImVec4(0.59f, 0.48f, 0.53f, 1.00f));
+ case eDLL_T::SERVER:
+ return CheckForWarnings(type, context, ImVec4(0.23f, 0.47f, 0.85f, 1.00f));
+ case eDLL_T::CLIENT:
+ return CheckForWarnings(type, context, ImVec4(0.46f, 0.46f, 0.46f, 1.00f));
+ case eDLL_T::UI:
+ return CheckForWarnings(type, context, ImVec4(0.59f, 0.35f, 0.46f, 1.00f));
+ case eDLL_T::ENGINE:
+ return CheckForWarnings(type, context, ImVec4(0.70f, 0.70f, 0.70f, 1.00f));
+ case eDLL_T::FS:
+ return CheckForWarnings(type, context, ImVec4(0.32f, 0.64f, 0.72f, 1.00f));
+ case eDLL_T::RTECH:
+ return CheckForWarnings(type, context, ImVec4(0.36f, 0.70f, 0.35f, 1.00f));
+ case eDLL_T::MS:
+ return CheckForWarnings(type, context, ImVec4(0.75f, 0.30f, 0.68f, 1.00f));
+ case eDLL_T::AUDIO:
+ return CheckForWarnings(type, context, ImVec4(0.93f, 0.42f, 0.12f, 1.00f));
+ case eDLL_T::VIDEO:
+ return CheckForWarnings(type, context, ImVec4(0.73f, 0.00f, 0.92f, 1.00f));
+ case eDLL_T::NETCON:
+ return CheckForWarnings(type, context, ImVec4(0.81f, 0.81f, 0.81f, 1.00f));
+ case eDLL_T::COMMON:
+ return CheckForWarnings(type, context, ImVec4(1.00f, 0.80f, 0.60f, 1.00f));
+ default:
+ return CheckForWarnings(type, context, ImVec4(0.81f, 0.81f, 0.81f, 1.00f));
+ }
+}
+#endif // !DEDICATED && !NETCONSOLE
+
+const char* GetContextNameByIndex(eDLL_T context, const bool ansiColor = false)
+{
+ int index = static_cast(context);
+ const char* contextName = s_DefaultAnsiColor;
+
+ switch (context)
+ {
+ case eDLL_T::SCRIPT_SERVER:
+ contextName = s_ScriptAnsiColor[0];
+ break;
+ case eDLL_T::SCRIPT_CLIENT:
+ contextName = s_ScriptAnsiColor[1];
+ break;
+ case eDLL_T::SCRIPT_UI:
+ contextName = s_ScriptAnsiColor[2];
+ break;
+ case eDLL_T::SERVER:
+ case eDLL_T::CLIENT:
+ case eDLL_T::UI:
+ case eDLL_T::ENGINE:
+ case eDLL_T::FS:
+ case eDLL_T::RTECH:
+ case eDLL_T::MS:
+ case eDLL_T::AUDIO:
+ case eDLL_T::VIDEO:
+ case eDLL_T::NETCON:
+ case eDLL_T::COMMON:
+ contextName = s_DllAnsiColor[index];
+ break;
+ case eDLL_T::SYSTEM_WARNING:
+ case eDLL_T::SYSTEM_ERROR:
+ case eDLL_T::NONE:
+ default:
+ break;
+ }
+
+ if (!ansiColor)
+ {
+ // Shift # chars to skip ANSI row.
+ contextName += sizeof(s_DefaultAnsiColor) - 1;
+ }
+
+ return contextName;
+}
+
+bool LoggedFromClient(eDLL_T context)
+{
+#ifndef DEDICATED
+ return (context == eDLL_T::CLIENT || context == eDLL_T::SCRIPT_CLIENT
+ || context == eDLL_T::UI || context == eDLL_T::SCRIPT_UI
+ || context == eDLL_T::NETCON);
+#else
+ NOTE_UNUSED(context);
+ return false;
+#endif // !DEDICATED
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Show logs to all console interfaces (va_list version)
+// Input : logType -
+// logLevel -
+// context -
+// *pszLogger -
+// *pszFormat -
+// args -
+// exitCode -
+// *pszUptimeOverride -
+//-----------------------------------------------------------------------------
+void EngineLoggerSink(LogType_t logType, LogLevel_t logLevel, eDLL_T context,
+ const char* pszLogger, const char* pszFormat, va_list args,
+ const UINT exitCode /*= NO_ERROR*/, const char* pszUptimeOverride /*= nullptr*/)
+{
+ const char* pszUpTime = pszUptimeOverride ? pszUptimeOverride : Plat_GetProcessUpTime();
+ string message = g_bSpdLog_PostInit ? pszUpTime : "";
+
+ const bool bToConsole = (logLevel >= LogLevel_t::LEVEL_CONSOLE);
+ const bool bUseColor = (bToConsole && g_bSpdLog_UseAnsiClr);
+
+ const char* pszContext = GetContextNameByIndex(context, bUseColor);
+ message.append(pszContext);
+
+#if !defined (DEDICATED) && !defined (NETCONSOLE)
+ ImVec4 overlayColor = GetColorForContext(logType, context);
+ eDLL_T overlayContext = context;
+#endif // !DEDICATED && !NETCONSOLE
+
+#if !defined (NETCONSOLE)
+ bool bSquirrel = false;
+ bool bWarning = false;
+ bool bError = false;
+#else
+ NOTE_UNUSED(pszLogger);
+#endif // !NETCONSOLE
+
+ //-------------------------------------------------------------------------
+ // Setup logger and context
+ //-------------------------------------------------------------------------
+ switch (logType)
+ {
+ case LogType_t::LOG_WARNING:
+#if !defined (DEDICATED) && !defined (NETCONSOLE)
+ overlayContext = eDLL_T::SYSTEM_WARNING;
+#endif // !DEDICATED && !NETCONSOLE
+ if (bUseColor)
+ {
+ message.append(g_svYellowF);
+ }
+ break;
+ case LogType_t::LOG_ERROR:
+#if !defined (DEDICATED) && !defined (NETCONSOLE)
+ overlayContext = eDLL_T::SYSTEM_ERROR;
+#endif // !DEDICATED && !NETCONSOLE
+ if (bUseColor)
+ {
+ message.append(g_svRedF);
+ }
+ break;
+#ifndef NETCONSOLE
+ case LogType_t::SQ_INFO:
+ bSquirrel = true;
+ break;
+ case LogType_t::SQ_WARNING:
+#ifndef DEDICATED
+ overlayContext = eDLL_T::SYSTEM_WARNING;
+ overlayColor = ImVec4(1.00f, 1.00f, 0.00f, 0.80f);
+#endif // !DEDICATED
+ bSquirrel = true;
+ bWarning = true;
+ break;
+#endif // !NETCONSOLE
+ default:
+ break;
+ }
+
+ //-------------------------------------------------------------------------
+ // Format actual input
+ //-------------------------------------------------------------------------
+ va_list argsCopy;
+ va_copy(argsCopy, args);
+ const string formatted = FormatV(pszFormat, argsCopy);
+ va_end(argsCopy);
+
+#ifndef NETCONSOLE
+ //-------------------------------------------------------------------------
+ // Colorize script warnings and errors
+ //-------------------------------------------------------------------------
+ if (bToConsole && bSquirrel)
+ {
+ if (bWarning && g_bSQAuxError)
+ {
+ if (formatted.find("SCRIPT ERROR:") != string::npos ||
+ formatted.find(" -> ") != string::npos)
+ {
+ bError = true;
+ }
+ }
+ else if (g_bSQAuxBadLogic)
+ {
+ if (formatted.find("There was a problem processing game logic.") != string::npos)
+ {
+ bError = true;
+ g_bSQAuxBadLogic = false;
+ }
+ }
+
+ // Append warning/error color before appending the formatted text,
+ // so that this gets marked as such while preserving context colors.
+ if (bError)
+ {
+#ifndef DEDICATED
+ overlayContext = eDLL_T::SYSTEM_ERROR;
+ overlayColor = ImVec4(1.00f, 0.00f, 0.00f, 0.80f);
+#endif // !DEDICATED
+
+ if (bUseColor)
+ {
+ message.append(g_svRedF);
+ }
+ }
+ else if (bUseColor && bWarning)
+ {
+ message.append(g_svYellowF);
+ }
+ }
+#endif // !NETCONSOLE
+ message.append(formatted);
+
+ //-------------------------------------------------------------------------
+ // Emit to all interfaces
+ //-------------------------------------------------------------------------
+ std::lock_guard lock(g_LogMutex);
+ if (bToConsole)
+ {
+ g_TermLogger->debug(message);
+
+ if (bUseColor)
+ {
+ // Remove ANSI rows before emitting to file or over wire.
+ message = std::regex_replace(message, s_AnsiRowRegex, "");
+ }
+ }
+
+#ifndef NETCONSOLE
+ // Output is always logged to the file.
+ std::shared_ptr ntlogger = spdlog::get(pszLogger); // <-- Obtain by 'pszLogger'.
+ assert(ntlogger.get() != nullptr);
+ ntlogger->debug(message);
+
+ if (bToConsole)
+ {
+#ifndef CLIENT_DLL
+ if (!LoggedFromClient(context) && RCONServer()->ShouldSend(sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG))
+ {
+ RCONServer()->SendEncode(formatted.c_str(), pszUpTime, sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG,
+ int(context), int(logType));
+ }
+#endif // !CLIENT_DLL
+#ifndef DEDICATED
+ g_ImGuiLogger->debug(message);
+
+ if (g_bSpdLog_PostInit)
+ {
+ g_pConsole->AddLog(ConLog_t(g_LogStream.str(), overlayColor));
+
+ if (logLevel >= LogLevel_t::LEVEL_NOTIFY) // Draw to mini console.
+ {
+ g_pOverlay->AddLog(overlayContext, g_LogStream.str());
+ }
+ }
+#endif // !DEDICATED
+ }
+
+#ifndef DEDICATED
+ g_LogStream.str(string());
+ g_LogStream.clear();
+#endif // !DEDICATED
+
+#endif // !NETCONSOLE
+
+ if (exitCode) // Terminate the process if an exit code was passed.
+ {
+ if (MessageBoxA(NULL, Format("%s- %s", pszUpTime, message.c_str()).c_str(),
+ "SDK Error", MB_ICONERROR | MB_OK))
+ {
+ TerminateProcess(GetCurrentProcess(), exitCode);
+ }
+ }
+}
diff --git a/r5dev/core/logger.h b/r5dev/core/logger.h
new file mode 100644
index 00000000..45983939
--- /dev/null
+++ b/r5dev/core/logger.h
@@ -0,0 +1,8 @@
+#ifndef LOGGER_H
+#define LOGGER_H
+
+void EngineLoggerSink(LogType_t logType, LogLevel_t logLevel, eDLL_T context,
+ const char* pszLogger, const char* pszFormat, va_list args,
+ const UINT exitCode /*= NO_ERROR*/, const char* pszUptimeOverride /*= nullptr*/);
+
+#endif // LOGGER_H
diff --git a/r5dev/core/shared_pch.h b/r5dev/core/shared_pch.h
new file mode 100644
index 00000000..f46a2834
--- /dev/null
+++ b/r5dev/core/shared_pch.h
@@ -0,0 +1,72 @@
+//===========================================================================//
+//
+// Purpose: Shared precompiled header file.
+//
+//===========================================================================//
+#ifndef SHARED_PCH_H
+#define SHARED_PCH_H
+
+#if defined(_DEBUG) || defined(_PROFILE)
+#pragma message ("Profiling is turned on; do not release this binary!\n")
+#endif // _DEBUG || _PROFILE
+
+// System includes.
+#define WIN32_LEAN_AND_MEAN // Prevent winsock2 redefinition.
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include