Skip to content

Commit

Permalink
Merge branch 'cvet:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
djempuiw authored Jun 18, 2024
2 parents 8c49914 + 4331ca7 commit ba6a77d
Show file tree
Hide file tree
Showing 17 changed files with 336 additions and 113 deletions.
7 changes: 3 additions & 4 deletions BuildTools/FinalizeGeneration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if(WIN32 OR LINUX OR APPLE OR ANDROID)
include_directories("${FO_RPMALLOC_DIR}/rpmalloc")
add_library(rpmalloc ${FO_RPMALLOC_SOURCE})
add_compile_definitions(FO_HAVE_RPMALLOC=1)
add_compile_definitions(ENABLE_PRELOAD=1)
add_compile_definitions(ENABLE_PRELOAD=${expr_StandaloneRpmallocEnabled})
target_compile_definitions(rpmalloc PRIVATE "$<$<PLATFORM_ID:Linux>:_GNU_SOURCE>")
list(APPEND FO_COMMON_LIBS "rpmalloc")
DisableLibWarnings(rpmalloc)
Expand Down Expand Up @@ -128,10 +128,9 @@ DisableLibWarnings(SDL2main SDL2-static)
# Tracy profiler
StatusMessage("+ Tracy")
set(FO_TRACY_DIR "${FO_ENGINE_ROOT}/ThirdParty/tracy")
set(expr_TracyEnabled $<OR:$<CONFIG:Profiling>,$<CONFIG:Debug_Profiling>,$<CONFIG:Profiling_OnDemand>>)
add_compile_definitions($<${expr_TracyEnabled}:TRACY_ENABLE>)
add_compile_definitions($<$<CONFIG:Profiling_OnDemand>:TRACY_ON_DEMAND>)
add_compile_definitions(FO_TRACY=$<BOOL:${expr_TracyEnabled}>)
add_compile_definitions($<${expr_TracyOnDemand}:TRACY_ON_DEMAND>)
add_compile_definitions(FO_TRACY=${expr_TracyEnabled})
set(TRACY_STATIC ON CACHE BOOL "Forced by FOnline" FORCE)
add_subdirectory("${FO_TRACY_DIR}")
include_directories("${FO_TRACY_DIR}/public")
Expand Down
8 changes: 6 additions & 2 deletions BuildTools/StartGeneration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ if(FO_MULTICONFIG)
set(CMAKE_CONFIGURATION_TYPES ${FO_CONFIGURATION_TYPES} CACHE STRING "Forced by FOnline" FORCE)
endif()

AddConfiguration(Profiling RelWithDebInfo)
AddConfiguration(Profiling_Total RelWithDebInfo)
AddConfiguration(Profiling_OnDemand RelWithDebInfo)
AddConfiguration(Debug_Profiling Debug)
AddConfiguration(Debug_Profiling_Total Debug)
AddConfiguration(Debug_Profiling_OnDemand Debug)
AddConfiguration(Release_Ext Release)

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
Expand Down Expand Up @@ -162,6 +163,9 @@ add_compile_definitions($<$<CONFIG:San_Address_Undefined>:LLVM_USE_SANITIZER=Add
set(expr_FullOptimization $<OR:$<CONFIG:Release>,$<CONFIG:Release_Ext>,$<CONFIG:MinSizeRel>>)
set(expr_DebugInfo $<NOT:$<OR:$<CONFIG:Release>,$<CONFIG:Release_Ext>,$<CONFIG:MinSizeRel>>>)
set(expr_PrefixConfig $<NOT:$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>,$<CONFIG:MinSizeRel>>>)
set(expr_TracyEnabled $<OR:$<CONFIG:Profiling_Total>,$<CONFIG:Profiling_OnDemand>,$<CONFIG:Debug_Profiling_Total>,$<CONFIG:Debug_Profiling_OnDemand>>)
set(expr_TracyOnDemand $<OR:$<CONFIG:Profiling_OnDemand>,$<CONFIG:Debug_Profiling_OnDemand>>)
set(expr_StandaloneRpmallocEnabled $<NOT:${expr_TracyEnabled}>)

# Headless configuration (without video/audio/input)
if(FO_BUILD_CLIENT OR FO_BUILD_SERVER OR FO_BUILD_SINGLE OR FO_BUILD_EDITOR OR FO_BUILD_MAPPER)
Expand Down
12 changes: 6 additions & 6 deletions BuildTools/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,16 @@ def patchConfig(filePath, additionalConfigData=None):
for binType in [''] + \
(['Headless'] if 'Headless' in packArgs else []) + \
(['Service'] if 'Service' in packArgs else []) + \
(['Profiling'] if 'Profiling' in packArgs else []) + \
(['TotalProfiling'] if 'TotalProfiling' in packArgs else []) + \
(['OnDemandProfiling'] if 'OnDemandProfiling' in packArgs else []) + \
(['OGL'] if 'OGL' in packArgs else []):
binName = args.devname + '_' + args.target + (binType if binType in ['Headless', 'Service'] else '')
binOutName = (binName if args.target != 'Client' else args.nicename) + \
('_Profiling' if binType in ['Profiling', 'OnDemandProfiling'] else '') + \
('_Profiling' if binType in ['TotalProfiling', 'OnDemandProfiling'] else '') + \
('_OpenGL' if binType == 'OGL' else '')
log('Setup', arch, binName, binType)
binEntry = args.target + '-' + args.platform + '-' + arch + \
('-Profiling' if binType == 'Profiling' else '') + \
('-Profiling_Total' if binType == 'TotalProfiling' else '') + \
('-Profiling_OnDemand' if binType == 'OnDemandProfiling' else '') + \
('-Debug' if 'Debug' in packArgs else '')
binPath = getInput(os.path.join('Binaries', binEntry), binName)
Expand Down Expand Up @@ -336,14 +336,14 @@ def patchConfig(filePath, additionalConfigData=None):
for binType in [''] + \
(['Headless'] if 'Headless' in packArgs else []) + \
(['Daemon'] if 'Daemon' in packArgs else []) + \
(['Profiling'] if 'Profiling' in packArgs else []) + \
(['TotalProfiling'] if 'TotalProfiling' in packArgs else []) + \
(['OnDemandProfiling'] if 'OnDemandProfiling' in packArgs else []):
binName = args.devname + '_' + args.target + (binType if binType in ['Headless', 'Daemon'] else '')
binOutName = (binName if args.target != 'Client' else args.nicename) + \
('_Profiling' if binType in ['Profiling', 'OnDemandProfiling'] else '')
('_Profiling' if binType in ['TotalProfiling', 'OnDemandProfiling'] else '')
log('Setup', arch, binName, binType)
binEntry = args.target + '-' + args.platform + '-' + arch + \
('-Profiling' if binType == 'Profiling' else '') + \
('-Profiling_Total' if binType == 'TotalProfiling' else '') + \
('-Profiling_OnDemand' if binType == 'OnDemandProfiling' else '') + \
('-Debug' if 'Debug' in packArgs else '')
binPath = getInput(os.path.join('Binaries', binEntry), binName)
Expand Down
78 changes: 61 additions & 17 deletions Source/Common/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ auto IsRunInDebugger() noexcept -> bool

auto BreakIntoDebugger([[maybe_unused]] string_view error_message) noexcept -> bool
{
STACK_TRACE_ENTRY();
NO_STACK_TRACE_ENTRY();

if (IsRunInDebugger()) {
#if FO_WINDOWS
Expand Down Expand Up @@ -748,7 +748,11 @@ void emscripten_sleep(unsigned int ms)
// Replace memory allocator
#if FO_HAVE_RPMALLOC

#if FO_TRACY
#include "client/tracy_rpmalloc.hpp"
#else
#include "rpmalloc.h"
#endif

#include <new>

Expand All @@ -762,52 +766,68 @@ extern void CRTDECL operator delete(void* p) noexcept
{
#if FO_TRACY
TracyFree(p);
#endif
tracy::rpfree(p);
#else
rpfree(p);
#endif
}

extern void CRTDECL operator delete[](void* p) noexcept
{
#if FO_TRACY
TracyFree(p);
#endif
tracy::rpfree(p);
#else
rpfree(p);
#endif
}

extern void* CRTDECL operator new(std::size_t size) noexcept(false)
{
auto* p = rpmalloc(size);
#if FO_TRACY
tracy::InitRpmalloc();
auto* p = tracy::rpmalloc(size);
TracyAlloc(p, size);
#else
auto* p = rpmalloc(size);
#endif
return p;
}

extern void* CRTDECL operator new[](std::size_t size) noexcept(false)
{
auto* p = rpmalloc(size);
#if FO_TRACY
tracy::InitRpmalloc();
auto* p = tracy::rpmalloc(size);
TracyAlloc(p, size);
#else
auto* p = rpmalloc(size);
#endif
return p;
}

extern void* CRTDECL operator new(std::size_t size, const std::nothrow_t& tag) noexcept
{
UNUSED_VARIABLE(tag);
auto* p = rpmalloc(size);
#if FO_TRACY
tracy::InitRpmalloc();
auto* p = tracy::rpmalloc(size);
TracyAlloc(p, size);
#else
auto* p = rpmalloc(size);
#endif
return p;
}

extern void* CRTDECL operator new[](std::size_t size, const std::nothrow_t& tag) noexcept
{
UNUSED_VARIABLE(tag);
auto* p = rpmalloc(size);
#if FO_TRACY
tracy::InitRpmalloc();
auto* p = tracy::rpmalloc(size);
TracyAlloc(p, size);
#else
auto* p = rpmalloc(size);
#endif
return p;
}
Expand All @@ -818,17 +838,21 @@ extern void CRTDECL operator delete(void* p, std::size_t size) noexcept
UNUSED_VARIABLE(size);
#if FO_TRACY
TracyFree(p);
#endif
tracy::rpfree(p);
#else
rpfree(p);
#endif
}

extern void CRTDECL operator delete[](void* p, std::size_t size) noexcept
{
UNUSED_VARIABLE(size);
#if FO_TRACY
TracyFree(p);
#endif
tracy::rpfree(p);
#else
rpfree(p);
#endif
}
#endif

Expand All @@ -838,17 +862,21 @@ extern void CRTDECL operator delete(void* p, std::align_val_t align) noexcept
UNUSED_VARIABLE(align);
#if FO_TRACY
TracyFree(p);
#endif
tracy::rpfree(p);
#else
rpfree(p);
#endif
}

extern void CRTDECL operator delete[](void* p, std::align_val_t align) noexcept
{
UNUSED_VARIABLE(align);
#if FO_TRACY
TracyFree(p);
#endif
tracy::rpfree(p);
#else
rpfree(p);
#endif
}

extern void CRTDECL operator delete(void* p, std::size_t size, std::align_val_t align) noexcept
Expand All @@ -857,8 +885,10 @@ extern void CRTDECL operator delete(void* p, std::size_t size, std::align_val_t
UNUSED_VARIABLE(align);
#if FO_TRACY
TracyFree(p);
#endif
tracy::rpfree(p);
#else
rpfree(p);
#endif
}

extern void CRTDECL operator delete[](void* p, std::size_t size, std::align_val_t align) noexcept
Expand All @@ -867,44 +897,58 @@ extern void CRTDECL operator delete[](void* p, std::size_t size, std::align_val_
UNUSED_VARIABLE(align);
#if FO_TRACY
TracyFree(p);
#endif
tracy::rpfree(p);
#else
rpfree(p);
#endif
}

extern void* CRTDECL operator new(std::size_t size, std::align_val_t align) noexcept(false)
{
auto* p = rpaligned_alloc(static_cast<size_t>(align), size);
#if FO_TRACY
tracy::InitRpmalloc();
auto* p = tracy::rpaligned_alloc(static_cast<size_t>(align), size);
TracyAlloc(p, size);
#else
auto* p = rpaligned_alloc(static_cast<size_t>(align), size);
#endif
return p;
}

extern void* CRTDECL operator new[](std::size_t size, std::align_val_t align) noexcept(false)
{
auto* p = rpaligned_alloc(static_cast<size_t>(align), size);
#if FO_TRACY
tracy::InitRpmalloc();
auto* p = tracy::rpaligned_alloc(static_cast<size_t>(align), size);
TracyAlloc(p, size);
#else
auto* p = rpaligned_alloc(static_cast<size_t>(align), size);
#endif
return p;
}

extern void* CRTDECL operator new(std::size_t size, std::align_val_t align, const std::nothrow_t& tag) noexcept
{
UNUSED_VARIABLE(tag);
auto* p = rpaligned_alloc(static_cast<size_t>(align), size);
#if FO_TRACY
tracy::InitRpmalloc();
auto* p = tracy::rpaligned_alloc(static_cast<size_t>(align), size);
TracyAlloc(p, size);
#else
auto* p = rpaligned_alloc(static_cast<size_t>(align), size);
#endif
return p;
}

extern void* CRTDECL operator new[](std::size_t size, std::align_val_t align, const std::nothrow_t& tag) noexcept
{
UNUSED_VARIABLE(tag);
auto* p = rpaligned_alloc(static_cast<size_t>(align), size);
#if FO_TRACY
tracy::InitRpmalloc();
auto* p = tracy::rpaligned_alloc(static_cast<size_t>(align), size);
TracyAlloc(p, size);
#else
auto* p = rpaligned_alloc(static_cast<size_t>(align), size);
#endif
return p;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Common/EntityProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ class CritterProperties : public EntityProperties
///@ ExportProperty ReadOnly
ENTITY_PROPERTY(PrivateServer, vector<uint8>, GlobalMapFog);
///@ ExportProperty
ENTITY_PROPERTY(VirtualPrivateServer, uint, SneakCoefficient);
ENTITY_PROPERTY(PrivateServer, uint, SneakCoefficient);
///@ ExportProperty
ENTITY_PROPERTY(VirtualProtected, uint, LookDistance);
ENTITY_PROPERTY(Protected, uint, LookDistance);
///@ ExportProperty
ENTITY_PROPERTY(Protected, int, ReplicationTime);
///@ ExportProperty
Expand Down
2 changes: 2 additions & 0 deletions Source/Common/Settings-Include.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ FIXED_SETTING(uint, DataBaseCommitPeriod, 10);
FIXED_SETTING(uint, DataBaseMaxCommitJobs, 100);
FIXED_SETTING(uint, LoopAverageTimeInterval, 1000);
FIXED_SETTING(bool, WriteHealthFile, false);
FIXED_SETTING(bool, ProtoMapStaticGrid, false);
FIXED_SETTING(bool, MapInstanceStaticGrid, false);
SETTING_GROUP_END();

#undef FIXED_SETTING
Expand Down
Loading

0 comments on commit ba6a77d

Please sign in to comment.