Added support for CppCheck static analysis and utility script to run clang-tidy.

This commit is contained in:
cbnolok 2025-05-24 14:07:58 +02:00
parent f7bca29326
commit af895d5fb6
10 changed files with 432 additions and 263 deletions

View file

@ -1,4 +1,4 @@
ExcludeHeaderFilterRegex: ^.*(lib\/).*
#ExcludeHeaderFilterRegex: ^.*(lib\/).*
Checks: >
#-*,
@ -16,26 +16,36 @@ Checks: >
-clang-analyzer-security.insecureAPI.strcpy,
-clang-diagnostic-format-security,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-no-malloc,
-cppcoreguidelines-init-variables, # false positives
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-prefer-member-initializer,
-cppcoreguidelines-pro-bounds-array-pointer-decay,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
#-cppcoreguidelines-pro-bounds-array-pointer-decay,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-type-const-cast, # we have some instances, and we should remove them...
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-special-member-functions, # explicit move, copy contructors...
##-hicpp-use-auto, #duplicate
##-hicpp-braces-around-statements,
##-hicpp-vararg, #duplicate
-misc-const-correctness, # temporary
-misc-include-cleaner,
-misc-non-private-member-variables-in-classes,
-modernize-avoid-c-arrays,
-modernize-use-auto,
-modernize-use-trailing-return-type,
-modernize-loop-convert,
-modernize-macro-to-enum,
-modernize-use-designated-initializers,
-modernize-use-nodiscard,
-modernize-use-using,
-readability-braces-around-statements,
-readability-delete-null-pointer,
-readability-else-after-return,
@ -43,6 +53,7 @@ Checks: >
-readability-identifier-length,
-readability-identifier-naming,
-readability-implicit-bool-conversion,
-readability-inconsistent-declaration-parameter-name,
-readability-magic-numbers,
-readability-misleading-indentation, # to be enabled after the source is properly formatted
-readability-simplify-boolean-expr,
@ -58,8 +69,8 @@ Checks: >
#WarningsAsErrors: "*"
CheckOptions:
- key: 'clang-analyzer-core.NonNullParamChecker:assert_like_macro'
value: 'DEBUG_ASSERT,ASSERT,ASSERT_ALWAYS'
# - key: 'clang-analyzer-core.NonNullParamChecker:assert_like_macro'
# value: 'DEBUG_ASSERT,ASSERT,ASSERT_ALWAYS'
- key: 'clang-analyzer-config:noreturn_function'
value: 'RaiseImmediateAbort,RaiseRecoverableAbort'
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }

View file

@ -60,6 +60,8 @@ endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_SCAN_FOR_MODULES OFF) # disable C++ module scanning
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
set(CMAKE_VISIBILITY_INLINES_HIDDEN "YES")
# Need to clear shared library flags. If not, cmake sets -rdynamic and this
# add to the executable the full symbol table (included unused symbols).
@ -129,11 +131,36 @@ option(USE_UBSAN "Enable Undefined Behavior Sanitizer." FALSE)
option(USE_LSAN "Enable LeakSanitizer." FALSE)
option(USE_MSAN "Enable MemorySanitizer." FALSE)
option(USE_CPPCHECK "Perform static analysis with CppCheck." FALSE)
set(ENABLED_SANITIZER FALSE CACHE INTERNAL BOOL "Am i using a sanitizer?")
if(USE_ASAN OR USE_MSAN OR USE_LSAN OR USE_MSAN)
set(ENABLED_SANITIZER TRUE)
endif()
if(USE_CPPCHECK)
find_program(CMAKE_CXX_CPPCHECK NAMES cppcheck)
if(CMAKE_CXX_CPPCHECK)
include(CheckTypeSize)
check_type_size("void*" SIZEOF_VOID_P)
#message(STATUS "Pointer size = ${SIZEOF_VOID_P}")
list(
APPEND CMAKE_CXX_CPPCHECK
"-v"
"--enable=all"
"--inconclusive"
"--force"
"--inline-suppr"
"--suppress=missingIncludeSystem"
"--template='{file}({line}): {severity} ({id}): {message}'"
"--checkers-report=cppcheck_out.txt"
#"--suppressions-list=${CMAKE_SOURCE_DIR}/CppCheckSuppressions.txt"
"-D__SIZEOF_POINTER__=${SIZEOF_VOID_P}"
)
endif()
endif()
# -------------------- Stuff to set right away, after having parsed the checkboxes/CLI arguments.
@ -210,13 +237,13 @@ if(SINGLE_TARGET)
add_executable(
spheresvr_release
${is_win32_app_linker}
${SPHERE_SOURCES}
${SPHERE_SOURCES} ${SPHERE_HEADERS}
#${docs_TEXT}
)
set_target_properties(spheresvr_release PROPERTIES OUTPUT_NAME SphereSvrX${ARCH_BITS}_release)
#set_target_properties(spheresvr_release PROPERTIES CXX_EXTENSIONS OFF)
#target_compile_features(spheresvr_release PUBLIC cxx_std_20)
target_precompile_headers(spheresvr_release ${pch_options})
target_precompile_headers(spheresvr_release ${pch_list})
if(NOT ${FORCE_DEBUG_INFO})
add_custom_command(TARGET spheresvr_release POST_BUILD
@ -230,13 +257,13 @@ if(SINGLE_TARGET)
add_executable(
spheresvr_nightly
${is_win32_app_linker}
${SPHERE_SOURCES}
${SPHERE_SOURCES} ${SPHERE_HEADERS}
#${docs_TEXT}
)
set_target_properties(spheresvr_nightly PROPERTIES OUTPUT_NAME SphereSvrX${ARCH_BITS}_nightly)
#set_target_properties(spheresvr_nightly PROPERTIES CXX_EXTENSIONS OFF)
#target_compile_features(spheresvr_nightly PUBLIC cxx_std_20)
target_precompile_headers(spheresvr_nightly ${pch_options})
target_precompile_headers(spheresvr_nightly ${pch_list})
if(NOT ${FORCE_DEBUG_INFO})
add_custom_command(TARGET spheresvr_nightly POST_BUILD
@ -250,23 +277,27 @@ if(SINGLE_TARGET)
add_executable(
spheresvr_debug
${is_win32_app_linker}
${SPHERE_SOURCES}
${SPHERE_SOURCES} ${SPHERE_HEADERS}
#${docs_TEXT}
)
set_target_properties(spheresvr_debug PROPERTIES OUTPUT_NAME SphereSvrX${ARCH_BITS}_debug)
#set_target_properties(spheresvr_debug PROPERTIES CXX_EXTENSIONS OFF)
#target_compile_features(spheresvr_debug PUBLIC cxx_std_20)
target_precompile_headers(spheresvr_debug ${pch_options})
target_precompile_headers(spheresvr_debug ${pch_list})
endif()
else(SINGLE_TARGET)
set(TARGETS ${TARGETS} spheresvr)
add_executable(spheresvr ${is_win32_app_linker} ${SPHERE_SOURCES} ${docs_TEXT})
add_executable(spheresvr
${is_win32_app_linker}
${SPHERE_SOURCES} ${SPHERE_HEADERS}
${docs_TEXT}
)
set_target_properties(spheresvr PROPERTIES OUTPUT_NAME_RELEASE SphereSvrX${ARCH_BITS}_release)
set_target_properties(spheresvr PROPERTIES OUTPUT_NAME_NIGHTLY SphereSvrX${ARCH_BITS}_nightly)
set_target_properties(spheresvr PROPERTIES OUTPUT_NAME_DEBUG SphereSvrX${ARCH_BITS}_debug)
#set_target_properties(spheresvr PROPERTIES CXX_EXTENSIONS OFF)
#target_compile_features(spheresvr PUBLIC cxx_std_20)
target_precompile_headers(spheresvr ${pch_options})
target_precompile_headers(spheresvr ${pch_list})
# To be tested
#add_custom_command(TARGET spheresvr POST_BUILD

View file

@ -1,8 +1,18 @@
include("${CMAKE_CURRENT_LIST_DIR}/include/Linux-Clang_common.inc.cmake")
function(toolchain_force_compiler)
set(CMAKE_C_COMPILER "clang" CACHE STRING "C compiler" FORCE)
set(CMAKE_CXX_COMPILER "clang++" CACHE STRING "C++ compiler" FORCE)
#if(DEFINED ENV{CC})
# set(CMAKE_C_COMPILER $ENV{CC})
#else()
# set(CMAKE_C_COMPILER "clang" CACHE STRING "C compiler")
set(CMAKE_C_COMPILER "clang" CACHE STRING "C compiler" FORCE)
#endif()
#if(DEFINED ENV{CXX})
# set(CMAKE_CXX_COMPILER $ENV{CXX})
#elseif("${CMAKE_CXX_COMPILER}" STREQUAL "")
#set(CMAKE_CXX_COMPILER "clang++" CACHE STRING "C++ compiler")
set(CMAKE_CXX_COMPILER "clang++" CACHE STRING "C++ compiler" FORCE)
#endif()
if(CROSSCOMPILING_ARCH)
message(FATAL_ERROR "Incomplete/to be tested.") # are the names/paths correct?

View file

@ -1,6 +1,11 @@
##############################
# Precompiled Header Files
##############################
# Precompiled header: it's parsed only once and stored in memory as an intermediate form. This speeds up compilation drastically.
# Be wise in chosing those, since every time we change one of them, we'll have to recompile every one on the list.
set(pch_options
set(pch_list
PRIVATE src/common/common.h
#PRIVATE src/common/sphere_library/CSRand.h
PRIVATE src/common/sphere_library/CSString.h
@ -23,159 +28,172 @@ set(pch_options
#PRIVATE src/game/clients/CClient.h
#PRIVATE src/game/chars/CChar.h
#PRIVATE src/game/items/CItem.h
)
# Main program files: threads, console...
set(sphere_SRCS
##############################
# Sphere Main
##############################
set(sphere_S
src/sphere/asyncdb.cpp
src/sphere/ConsoleInterface.cpp
src/sphere/ProfileData.cpp
src/sphere/ProfileTask.cpp
src/sphere/threads.cpp
src/sphere/ntservice.cpp
src/sphere/ntwindow.cpp
src/sphere/UnixTerminal.cpp
)
set(sphere_H
src/sphere/asyncdb.h
src/sphere/containers.h
src/sphere/ConsoleInterface.cpp
src/sphere/ConsoleInterface.h
src/sphere/ProfileData.cpp
src/sphere/ProfileData.h
src/sphere/ProfileTask.cpp
src/sphere/ProfileTask.h
src/sphere/threads.cpp
src/sphere/threads.h
src/sphere/ntservice.cpp
src/sphere/ntservice.h
src/sphere/ntwindow.cpp
src/sphere/ntwindow.h
src/sphere/UnixTerminal.cpp
src/sphere/UnixTerminal.h
)
source_group(sphere FILES ${sphere_SRCS})
source_group(sphere FILES ${sphere_H} ${sphere_S})
# Network management files
set(network_SRCS
##############################
# Network Management
##############################
set(network_S
src/network/CClientIterator.cpp
src/network/CClientIterator.h
src/network/CIPHistoryManager.cpp
src/network/CIPHistoryManager.h
src/network/CNetState.cpp
src/network/CNetState.h
src/network/CNetworkInput.cpp
src/network/CNetworkInput.h
src/network/CNetworkManager.cpp
src/network/CNetworkManager.h
src/network/CNetworkOutput.cpp
src/network/CNetworkOutput.h
src/network/CNetworkThread.cpp
src/network/CNetworkThread.h
src/network/CPacketManager.cpp
src/network/CPacketManager.h
src/network/CSocket.cpp
src/network/CSocket.h
src/network/linuxev.cpp
src/network/linuxev.h
src/network/net_datatypes.h
src/network/net_datatypes.cpp
src/network/packet.cpp
src/network/packet.h
src/network/receive.cpp
src/network/receive.h
src/network/send.cpp
src/network/send.h
src/network/PingServer.cpp
)
set(network_H
src/network/CClientIterator.h
src/network/CIPHistoryManager.h
src/network/CNetState.h
src/network/CNetworkInput.h
src/network/CNetworkManager.h
src/network/CNetworkOutput.h
src/network/CNetworkThread.h
src/network/CPacketManager.h
src/network/CSocket.h
src/network/linuxev.h
src/network/net_datatypes.h
src/network/packet.h
src/network/receive.h
src/network/send.h
src/network/PingServer.h
)
source_group(network FILES ${network_SRCS})
source_group(network FILES ${network_H} ${network_S})
# Handle UO Client files
set(uofiles_SRCS
src/game/uo_files/CUOHuesRec.h
##############################
# UO Files
##############################
set(uofiles_S
src/game/uo_files/CUOHuesRec.cpp
src/game/uo_files/CUOIndexRec.h
src/game/uo_files/CUOIndexRec.cpp
src/game/uo_files/CUOItemInfo.h
src/game/uo_files/CUOItemInfo.cpp
src/game/uo_files/CUOMapList.cpp
src/game/uo_files/CUOMapMeter.cpp
src/game/uo_files/CUOMobtypes.cpp
src/game/uo_files/CUOMultiItemRec.cpp
src/game/uo_files/CUOStaticItemRec.cpp
src/game/uo_files/CUOTerrainInfo.cpp
src/game/uo_files/CUOTiledata.cpp
src/game/uo_files/CUOVersionBlock.cpp
)
set(uofiles_H
src/game/uo_files/CUOHuesRec.h
src/game/uo_files/CUOIndexRec.h
src/game/uo_files/CUOItemInfo.h
src/game/uo_files/CUOItemTypeRec.h
src/game/uo_files/CUOMapBlock.h
src/game/uo_files/CUOMapList.h
src/game/uo_files/CUOMapList.cpp
src/game/uo_files/CUOMapMeter.h
src/game/uo_files/CUOMapMeter.cpp
src/game/uo_files/CUOMobtypes.h
src/game/uo_files/CUOMobtypes.cpp
src/game/uo_files/CUOMultiItemRec.h
src/game/uo_files/CUOMultiItemRec.cpp
src/game/uo_files/CUOStaticItemRec.h
src/game/uo_files/CUOStaticItemRec.cpp
src/game/uo_files/CUOTerrainInfo.h
src/game/uo_files/CUOTerrainInfo.cpp
src/game/uo_files/CUOTerrainTypeRec.h
src/game/uo_files/CUOTiledata.h
src/game/uo_files/CUOTiledata.cpp
src/game/uo_files/CUOVersionBlock.h
src/game/uo_files/CUOVersionBlock.cpp
src/game/uo_files/uofiles_enums.h
src/game/uo_files/uofiles_enums_itemid.h
src/game/uo_files/uofiles_enums_creid.h
src/game/uo_files/uofiles_macros.h
src/game/uo_files/uofiles_types.h
)
source_group(game\\uo_files FILES ${uofiles_SRCS})
source_group(game\\uo_files FILES ${uofiles_H} ${uofiles_S})
# Files containing 'background work'
set(common_SRCS
##############################
# Common
##############################
set(common_S
src/common/sqlite/SQLite.cpp
src/common/CCacheableScriptFile.cpp
src/common/CDataBase.cpp
src/common/CException.cpp
src/common/CExpression.cpp
src/common/CFloatMath.cpp
src/common/CLanguageID.cpp
src/common/CLocalVarsExtra.cpp
src/common/CLog.cpp
src/common/CServerMap.cpp
src/common/CUID.cpp
src/common/CPointBase.cpp
src/common/CRect.cpp
src/common/CScript.cpp
src/common/CScriptContexts.cpp
src/common/CScriptObj.cpp
src/common/CScriptParserBufs.cpp
src/common/CScriptTriggerArgs.cpp
src/common/CSFileObj.cpp
src/common/CSFileObjContainer.cpp
src/common/CSVFile.cpp
src/common/CTextConsole.cpp
src/common/CUOClientVersion.cpp
src/common/CUOInstall.cpp
src/common/CVarDefMap.cpp
src/common/ListDefContMap.cpp
)
set(common_H
src/common/sqlite/SQLite.h
src/common/assertion.h
src/common/basic_threading.h
src/common/common.cpp
src/common/common.h
src/common/CCacheableScriptFile.cpp
src/common/CCacheableScriptFile.h
src/common/CDataBase.cpp
src/common/CDataBase.h
src/common/CException.cpp
src/common/CException.h
src/common/CExpression.cpp
src/common/CExpression.h
src/common/CFloatMath.cpp
src/common/CFloatMath.h
src/common/CLanguageID.cpp
src/common/CLanguageID.h
src/common/CLocalVarsExtra.cpp
src/common/CLocalVarsExtra.h
src/common/CLog.cpp
src/common/CLog.h
src/common/CServerMap.cpp
src/common/CServerMap.h
src/common/CUID.cpp
src/common/CUID.h
src/common/CPointBase.cpp
src/common/CPointBase.h
src/common/CRect.cpp
src/common/CRect.h
src/common/CScript.cpp
src/common/CScript.h
src/common/CScriptContexts.cpp
src/common/CScriptContexts.h
src/common/CScriptObj.cpp
src/common/CScriptObj.h
src/common/CScriptParserBufs.cpp
src/common/CScriptParserBufs.h
src/common/CScriptTriggerArgs.cpp
src/common/CScriptTriggerArgs.h
src/common/CSFileObj.cpp
src/common/CSFileObj.h
src/common/CSFileObjContainer.cpp
src/common/CSFileObjContainer.h
src/common/CSVFile.cpp
src/common/CSVFile.h
src/common/CTextConsole.cpp
src/common/CTextConsole.h
src/common/CUOClientVersion.cpp
src/common/CUOClientVersion.h
src/common/CUOInstall.cpp
src/common/CUOInstall.h
src/common/CVarDefMap.cpp
src/common/CVarDefMap.h
src/common/datatypes.h
src/common/ListDefContMap.cpp
src/common/ListDefContMap.h
src/common/os_unix.h
src/common/os_windows.h
@ -183,262 +201,300 @@ set(common_SRCS
src/common/sphereversion.h
src/common/target_info.h
)
source_group(common FILES ${common_SRCS})
source_group(common FILES ${common_H} ${common_S})
# Login encryption handling
set(crypto_SRCS
##############################
# Windows CrashDump
##############################
set(crashdump_S
src/common/crashdump/crashdump.cpp
)
set(crashdump_H
src/common/crashdump/crashdump.h
src/common/crashdump/mingwdbghelp.h
)
source_group(common\\crashdump FILES ${crashdump_H} ${crashdump_S})
##############################
# Login / Cryptography
##############################
set(crypto_S
src/common/crypto/CBCrypt.cpp
src/common/crypto/CBCrypt.h
src/common/crypto/CCrypto.cpp
src/common/crypto/CCrypto.h
src/common/crypto/CCryptoBlowFish.cpp
src/common/crypto/CCryptoLogin.cpp
src/common/crypto/CCryptoKeyCalc.cpp
src/common/crypto/CCryptoKeyCalc.h
src/common/crypto/CCryptoMD5Interface.cpp
src/common/crypto/CCryptoTwoFishInterface.cpp
src/common/crypto/CHuffman.cpp
src/common/crypto/CHuffman.h
src/common/crypto/CMD5.cpp
)
set(crypto_H
src/common/crypto/CBCrypt.h
src/common/crypto/CCrypto.h
src/common/crypto/CCryptoKeyCalc.h
src/common/crypto/CHuffman.h
src/common/crypto/CMD5.h
src/common/crypto/crypto_common.h
)
source_group(common\\crypto FILES ${crypto_SRCS})
source_group(common\\crypto FILES ${crypto_H} ${crypto_S})
set(resource_SRCS
##############################
# Sphere Resources
##############################
set(resource_S
src/common/resource/CResourceDef.cpp
src/common/resource/CResourceDef.h
src/common/resource/CResourceHolder.cpp
src/common/resource/CResourceHolder.h
src/common/resource/CResourceID.cpp
src/common/resource/CResourceID.h
src/common/resource/CResourceHash.cpp
src/common/resource/CResourceHash.h
src/common/resource/CResourceLink.cpp
src/common/resource/CResourceLink.h
src/common/resource/CResourceLock.cpp
src/common/resource/CResourceLock.h
src/common/resource/CResourceRef.cpp
src/common/resource/CResourceRef.h
src/common/resource/CResourceScript.cpp
src/common/resource/CResourceScript.h
src/common/resource/CResourceSortedArrays.cpp
src/common/resource/CResourceSortedArrays.h
src/common/resource/CResourceQty.cpp
src/common/resource/CResourceQty.h
src/common/resource/CValueDefs.cpp
)
set(resource_H
src/common/resource/CResourceDef.h
src/common/resource/CResourceHolder.h
src/common/resource/CResourceID.h
src/common/resource/CResourceHash.h
src/common/resource/CResourceLink.h
src/common/resource/CResourceLock.h
src/common/resource/CResourceRef.h
src/common/resource/CResourceScript.h
src/common/resource/CResourceSortedArrays.h
src/common/resource/CResourceQty.h
src/common/resource/CValueDefs.h
)
source_group(common\\resource FILES ${resource_SRCS})
source_group(common\\resource FILES ${resource_H} ${resource_S})
set(resourcesections_SRCS
##############################
# Scripted resource sections
##############################
set(resourcesections_S
src/common/resource/sections/CDialogDef.cpp
src/common/resource/sections/CDialogDef.h
src/common/resource/sections/CItemTypeDef.cpp
src/common/resource/sections/CItemTypeDef.h
src/common/resource/sections/CRandGroupDef.cpp
src/common/resource/sections/CRandGroupDef.h
src/common/resource/sections/CRegionResourceDef.cpp
src/common/resource/sections/CRegionResourceDef.h
src/common/resource/sections/CResourceNamedDef.cpp
src/common/resource/sections/CResourceNamedDef.h
src/common/resource/sections/CSkillClassDef.cpp
src/common/resource/sections/CSkillClassDef.h
src/common/resource/sections/CSkillDef.cpp
src/common/resource/sections/CSkillDef.h
src/common/resource/sections/CSpellDef.cpp
src/common/resource/sections/CSpellDef.h
src/common/resource/sections/CWebPageDef.cpp
)
set(resourcesections_H
src/common/resource/sections/CDialogDef.h
src/common/resource/sections/CItemTypeDef.h
src/common/resource/sections/CRandGroupDef.h
src/common/resource/sections/CRegionResourceDef.h
src/common/resource/sections/CResourceNamedDef.h
src/common/resource/sections/CSkillClassDef.h
src/common/resource/sections/CSkillDef.h
src/common/resource/sections/CSpellDef.h
src/common/resource/sections/CWebPageDef.h
)
source_group(common\\resource\\sections FILES ${resourcesections_SRCS})
source_group(common\\resource\\sections FILES ${resourcesections_H} ${resourcesections_S})
# Sphere library files
set(spherelibrary_SRCS
##############################
# Sphere Library files
##############################
set(spherelibrary_S
src/common/sphere_library/CSAssoc.cpp
src/common/sphere_library/CSAssoc.h
src/common/sphere_library/CSFile.cpp
src/common/sphere_library/CSFile.h
src/common/sphere_library/CSFileList.cpp
src/common/sphere_library/CSFileList.h
src/common/sphere_library/CSFileText.cpp
src/common/sphere_library/CSFileText.h
src/common/sphere_library/CSMemBlock.cpp
src/common/sphere_library/CSObjCont.cpp
src/common/sphere_library/CSObjList.cpp
src/common/sphere_library/CSQueue.cpp
src/common/sphere_library/CSRand.cpp
src/common/sphere_library/CSString.cpp
src/common/sphere_library/CSTime.cpp
src/common/sphere_library/CSWindow.cpp
src/common/sphere_library/smutex.cpp
src/common/sphere_library/sresetevents.cpp
src/common/sphere_library/sstring.cpp
src/common/sphere_library/sstringobjs.cpp
src/common/sphere_library/stypecast.cpp
)
set(spherelibrary_H
src/common/sphere_library/CSAssoc.h
src/common/sphere_library/CSFile.h
src/common/sphere_library/CSFileList.h
src/common/sphere_library/CSFileText.h
src/common/sphere_library/CSMemBlock.h
src/common/sphere_library/CSObjArray.h
src/common/sphere_library/CSObjCont.cpp
src/common/sphere_library/CSObjCont.h
src/common/sphere_library/CSObjContRec.h
src/common/sphere_library/CSObjList.cpp
src/common/sphere_library/CSObjList.h
src/common/sphere_library/CSObjListRec.h
src/common/sphere_library/CSObjSortArray.h
src/common/sphere_library/CSPtrTypeArray.h
src/common/sphere_library/CSReferenceCount.h
src/common/sphere_library/CSTypedArray.h
src/common/sphere_library/CSQueue.cpp
src/common/sphere_library/CSQueue.h
src/common/sphere_library/CSRand.cpp
src/common/sphere_library/CSRand.h
src/common/sphere_library/CSString.cpp
src/common/sphere_library/CSString.h
src/common/sphere_library/CSTime.cpp
src/common/sphere_library/CSTime.h
src/common/sphere_library/CSWindow.cpp
src/common/sphere_library/CSWindow.h
src/common/sphere_library/scontainer_ops.h
src/common/sphere_library/sfastmath.h
src/common/sphere_library/smap.h
src/common/sphere_library/smutex.h
src/common/sphere_library/smutex.cpp
src/common/sphere_library/sobjpool.h
src/common/sphere_library/squeues.h
src/common/sphere_library/sresetevents.cpp
src/common/sphere_library/sresetevents.h
src/common/sphere_library/ssorted_vector.h
src/common/sphere_library/sptr.h
src/common/sphere_library/sptr_containers.h
src/common/sphere_library/sstacks.h
src/common/sphere_library/sstring.cpp
src/common/sphere_library/sstring.h
src/common/sphere_library/sstringobjs.cpp
src/common/sphere_library/sstringobjs.h
src/common/sphere_library/stypecast.cpp
src/common/sphere_library/stypecast.h
)
source_group(common\\sphere_library FILES ${spherelibrary_SRCS})
source_group(common\\sphere_library FILES ${spherelibrary_H} ${spherelibrary_S})
# Main game files.
set(game_SRCS
##############################
# Main game-related classes
##############################
set(game_S
src/game/CBase.cpp
src/game/CBase.h
src/game/CContainer.cpp
src/game/CContainer.h
src/game/CComponent.cpp
src/game/CComponent.h
src/game/CComponentProps.cpp
src/game/CComponentProps.h
src/game/CEntity.cpp
src/game/CEntity.h
src/game/CEntityProps.cpp
src/game/CEntityProps.h
src/game/CObjBase.cpp
src/game/CObjBase.h
src/game/CObjBaseTemplate.cpp
src/game/CObjBaseTemplate.h
src/game/CPathFinder.cpp
src/game/CPathFinder.h
src/game/CRegion.cpp
src/game/CRegion.h
src/game/CRegionBase.cpp
src/game/CRegionBase.h
src/game/CResourceCalc.cpp
src/game/CScriptProfiler.h
src/game/CSector.cpp
src/game/CSector.h
src/game/CSectorEnviron.h
src/game/CSectorEnviron.cpp
src/game/CSectorTemplate.cpp
src/game/CSectorTemplate.h
src/game/CSectorList.cpp
src/game/CSectorList.h
src/game/CServer.cpp
src/game/CServer.h
src/game/CServerConfig.cpp
src/game/CServerConfig.h
src/game/CServerDef.cpp
src/game/CServerDef.h
src/game/CServerTime.cpp
src/game/CServerTime.h
src/game/CStartLoc.h
src/game/CTeleport.cpp
src/game/CTeleport.h
src/game/CTimedFunction.cpp
src/game/CTimedFunction.h
src/game/CTimedFunctionHandler.cpp
src/game/CTimedFunctionHandler.h
src/game/CTimedObject.cpp
src/game/CTimedObject.h
src/game/CWorld.cpp
src/game/CWorld.h
src/game/CWorldCache.cpp
src/game/CWorldCache.h
src/game/CWorldClock.cpp
src/game/CWorldClock.h
src/game/CWorldComm.cpp
src/game/CWorldComm.h
src/game/CWorldGameTime.cpp
src/game/CWorldGameTime.h
src/game/CWorldImport.cpp
src/game/CWorldMap.cpp
src/game/CWorldMap.h
src/game/CWorldSearch.cpp
src/game/CWorldSearch.h
src/game/CWorldTicker.cpp
src/game/CWorldTicker.h
src/game/CWorldTickingList.cpp
src/game/CWorldTickingList.h
src/game/CWorldTimedFunctions.cpp
src/game/spheresvr.cpp
src/game/triggers.cpp
src/game/CSectorEnviron.cpp
)
set(game_H
src/game/CBase.h
src/game/CContainer.h
src/game/CComponent.h
src/game/CComponentProps.h
src/game/CEntity.h
src/game/CEntityProps.h
src/game/CObjBase.h
src/game/CObjBaseTemplate.h
src/game/CPathFinder.h
src/game/CRegion.h
src/game/CRegionBase.h
src/game/CScriptProfiler.h
src/game/CSector.h
src/game/CSectorEnviron.h
src/game/CSectorTemplate.h
src/game/CSectorList.h
src/game/CServer.h
src/game/CServerConfig.h
src/game/CServerDef.h
src/game/CServerTime.h
src/game/CStartLoc.h
src/game/CTeleport.h
src/game/CTimedFunction.h
src/game/CTimedFunctionHandler.h
src/game/CTimedObject.h
src/game/CWorld.h
src/game/CWorldCache.h
src/game/CWorldClock.h
src/game/CWorldComm.h
src/game/CWorldGameTime.h
src/game/CWorldMap.h
src/game/CWorldSearch.h
src/game/CWorldTicker.h
src/game/CWorldTickingList.h
src/game/CWorldTimedFunctions.h
src/game/game_enums.h
src/game/game_macros.h
src/game/spheresvr.cpp
src/game/spheresvr.h
src/game/triggers.h
src/game/triggers.cpp
)
source_group(game FILES ${game_SRCS})
source_group(game FILES ${game_H} ${game_S})
set(items_SRCS
##############################
# Item entities
##############################
set(items_S
src/game/items/CItem.cpp
src/game/items/CItem.h
src/game/items/CItemBase.cpp
src/game/items/CItemBase.h
src/game/items/CItemCommCrystal.cpp
src/game/items/CItemCommCrystal.h
src/game/items/CItemContainer.cpp
src/game/items/CItemContainer.h
src/game/items/CItemCorpse.cpp
src/game/items/CItemCorpse.h
src/game/items/CItemMap.cpp
src/game/items/CItemMap.h
src/game/items/CItemMemory.cpp
src/game/items/CItemMemory.h
src/game/items/CItemMessage.cpp
src/game/items/CItemMessage.h
src/game/items/CItemMulti.cpp
src/game/items/CItemMulti.h
src/game/items/CItemMultiCustom.cpp
src/game/items/CItemMultiCustom.h
src/game/items/CItemPlant.cpp
src/game/items/CItemScript.cpp
src/game/items/CItemScript.h
src/game/items/CItemShip.cpp
src/game/items/CItemShip.h
src/game/items/CItemScript.cpp
src/game/items/CItemScript.h
src/game/items/CItemStone.cpp
src/game/items/CItemStone.h
src/game/items/CItemVendable.cpp
)
set(items_H
src/game/items/CItem.h
src/game/items/CItemBase.h
src/game/items/CItemCommCrystal.h
src/game/items/CItemContainer.h
src/game/items/CItemCorpse.h
src/game/items/CItemMap.h
src/game/items/CItemMemory.h
src/game/items/CItemMessage.h
src/game/items/CItemMulti.h
src/game/items/CItemMultiCustom.h
src/game/items/CItemScript.h
src/game/items/CItemShip.h
src/game/items/CItemStone.h
src/game/items/CItemVendable.h
src/game/items/item_types.h
)
source_group(game\\items FILES ${items_SRCS})
source_group(game\\items FILES ${items_H} ${items_S})
set(chars_SRCS
##############################
# Chars entities
##############################
set(chars_S
src/game/chars/CCharAct.cpp
src/game/chars/CCharBase.cpp
src/game/chars/CChar.cpp
src/game/chars/CChar.h
src/game/chars/CCharAttacker.cpp
src/game/chars/CCharBase.h
src/game/chars/CCharFight.cpp
src/game/chars/CCharLOS.cpp
src/game/chars/CCharMemory.cpp
src/game/chars/CCharNotoriety.cpp
src/game/chars/CCharNPC.cpp
src/game/chars/CCharNPC.h
src/game/chars/CCharNPCAct.cpp
src/game/chars/CCharNPCAct_Fight.cpp
src/game/chars/CCharNPCAct_Magic.cpp
@ -446,84 +502,93 @@ set(chars_SRCS
src/game/chars/CCharNPCPet.cpp
src/game/chars/CCharNPCStatus.cpp
src/game/chars/CCharPlayer.cpp
src/game/chars/CCharPlayer.h
src/game/chars/CCharRefArray.h
src/game/chars/CCharRefArray.cpp
src/game/chars/CCharSkill.cpp
src/game/chars/CCharSpell.cpp
src/game/chars/CCharStat.cpp
src/game/chars/CCharStatus.cpp
src/game/chars/CCharUse.cpp
src/game/chars/CStoneMember.h
src/game/chars/CStoneMember.cpp
)
source_group(game\\chars FILES ${chars_SRCS})
set(chars_H
src/game/chars/CChar.h
src/game/chars/CCharBase.h
src/game/chars/CCharNPC.h
src/game/chars/CCharPlayer.h
src/game/chars/CCharRefArray.h
src/game/chars/CStoneMember.h
)
source_group(game\\chars FILES ${chars_H} ${items_S})
set(clients_SRCS
##############################
# Clients
##############################
set(clients_S
src/game/clients/CAccount.cpp
src/game/clients/CAccount.h
src/game/clients/CChat.cpp
src/game/clients/CChat.h
src/game/clients/CChatChannel.cpp
src/game/clients/CChatChannel.h
src/game/clients/CChatChanMember.cpp
src/game/clients/CChatChanMember.h
src/game/clients/CClient.cpp
src/game/clients/CClientDialog.cpp
src/game/clients/CClientEvent.cpp
src/game/clients/CClient.h
src/game/clients/CClientLog.cpp
src/game/clients/CClientMsg.cpp
src/game/clients/CClientMsg_AOSTooltip.cpp
src/game/clients/CClientTarg.cpp
src/game/clients/CClientTooltip.h
src/game/clients/CClientTooltip.cpp
src/game/clients/CClientUse.cpp
src/game/clients/CGlobalChatChanMember.cpp
src/game/clients/CGlobalChatChanMember.h
src/game/clients/CGMPage.cpp
src/game/clients/CGMPage.h
src/game/clients/CParty.cpp
)
set(clients_H
src/game/clients/CAccount.h
src/game/clients/CChat.h
src/game/clients/CChatChannel.h
src/game/clients/CChatChanMember.h
src/game/clients/CClient.h
src/game/clients/CClientTooltip.h
src/game/clients/CGlobalChatChanMember.h
src/game/clients/CGMPage.h
src/game/clients/CParty.h
)
source_group(game\\clients FILES ${clients_SRCS})
source_group(game\\clients FILES ${clients_H} ${clients_S})
set(components_SRCS
##############################
# ECS: components
##############################
set(components_S
src/game/components/subcomponents/CFactionDef.cpp
src/game/components/subcomponents/CFactionDef.h
src/game/components/CCChampion.cpp
src/game/components/CCChampion.h
src/game/components/CCItemDamageable.cpp
src/game/components/CCItemDamageable.h
src/game/components/CCMultiMovable.cpp
src/game/components/CCMultiMovable.h
src/game/components/CCPropsChar.cpp
src/game/components/CCPropsChar.h
src/game/components/CCPropsItem.cpp
src/game/components/CCPropsItem.h
src/game/components/CCPropsItemChar.cpp
src/game/components/CCPropsItemChar.h
src/game/components/CCPropsItemEquippable.cpp
src/game/components/CCPropsItemEquippable.h
src/game/components/CCPropsItemWeapon.cpp
src/game/components/CCPropsItemWeapon.h
src/game/components/CCPropsItemWeaponRanged.cpp
src/game/components/CCPropsItemWeaponRanged.h
src/game/components/CCSpawn.cpp
)
set(components_H
src/game/components/subcomponents/CFactionDef.h
src/game/components/CCChampion.h
src/game/components/CCItemDamageable.h
src/game/components/CCMultiMovable.h
src/game/components/CCPropsChar.h
src/game/components/CCPropsItem.h
src/game/components/CCPropsItemChar.h
src/game/components/CCPropsItemEquippable.h
src/game/components/CCPropsItemWeapon.h
src/game/components/CCPropsItemWeaponRanged.h
src/game/components/CCSpawn.h
)
source_group(game\\components FILES ${components_SRCS})
source_group(game\\components FILES ${components_H} ${components_S})
# CrashDump files
set(crashdump_SRCS
src/common/crashdump/crashdump.cpp
src/common/crashdump/crashdump.h
src/common/crashdump/mingwdbghelp.h
)
source_group(common\\crashdump FILES ${crashdump_SRCS})
# Table definitions
set(tables_SRCS
##############################
# Table Definitions
##############################
set(tables_S
src/tables/CBaseBaseDef_props.tbl
src/tables/CChar_functions.tbl
src/tables/CChar_props.tbl
@ -560,28 +625,57 @@ set(tables_SRCS
src/tables/defmessages.tbl
src/tables/triggers.tbl
)
source_group(tables FILES ${tables_SRCS})
source_group(tables FILES ${tables_S})
set(app_resources_SRCS src/resources/SphereSvr.rc)
##############################
# App Resources (Windows .rc)
##############################
set(app_resources_S
src/resources/SphereSvr.rc
)
# Misc doc and *.ini files
set(docs_TEXT Changelog.txt src/sphere.ini src/sphereCrypt.ini)
##############################
# Docs and Configs
##############################
set(docs_TEXT
Changelog.txt
src/sphere.ini
src/sphereCrypt.ini
)
set(SPHERE_HEADERS
${game_H}
${items_H}
${chars_H}
${clients_H}
${components_H}
${uofiles_H}
${common_H}
${resource_H}
${resourcesections_H}
${network_H}
${crypto_H}
${sphere_H}
${crashdump_H}
${spherelibrary_H}
)
set(SPHERE_SOURCES
${game_SRCS}
${items_SRCS}
${chars_SRCS}
${clients_SRCS}
${components_SRCS}
${uofiles_SRCS}
${common_SRCS}
${resource_SRCS}
${resourcesections_SRCS}
${network_SRCS}
${crypto_SRCS}
${sphere_SRCS}
${crashdump_SRCS}
${spherelibrary_SRCS}
${tables_SRCS}
${app_resources_SRCS}
${game_S}
${items_S}
${chars_S}
${clients_S}
${components_S}
${uofiles_S}
${common_S}
${resource_S}
${resourcesections_S}
${network_S}
${crypto_S}
${sphere_S}
${crashdump_S}
${spherelibrary_S}
${tables_S}
${app_resources_S}
)

View file

@ -98,6 +98,9 @@ namespace sl
return 0;
*/
if (!dataptr)
return sl::scont_bad_index();
size_t _lo = 0;
while (_lo < _size)
{
@ -169,6 +172,8 @@ namespace sl
return sl::scont_bad_index();
}
const _Type* const _dataptr = base_type::data();
if (!_dataptr)
return sl::scont_bad_index();
size_t _idx = this->lower_element(_mySize, _dataptr, value);
if (_idx == _mySize)
return sl::scont_bad_index();

View file

@ -496,9 +496,9 @@ constexpr uint32 usize_narrow_u32(const size_t source_val) noexcept
else
return a;
*/
#if SIZE_MAX == UINT64_MAX
#if (__SIZEOF_POINTER__ == 8) //SIZE_MAX == UINT64_MAX
return n64_narrow_n32(source_val);
#elif SIZE_MAX == UINT32_MAX
#elif (__SIZEOF_POINTER__ == 4) //SIZE_MAX == UINT32_MAX
return source_val;
#else
# error "size_t is neither 8 nor 4 bytes?"
@ -696,9 +696,9 @@ template <typename T> int64 i64_from_u64_checked(T, bool) = delete; // disable i
[[nodiscard]] inline
int8 i8_from_usize_checked(const size_t source_val, bool should_assert) // not clamping/capping
{
#if SIZE_MAX == UINT64_MAX
#if (__SIZEOF_POINTER__ == 8) //SIZE_MAX == UINT64_MAX
return n64_narrow_n8_checked(source_val, should_assert);
#elif SIZE_MAX == UINT32_MAX
#elif (__SIZEOF_POINTER__ == 4) // SIZE_MAX == UINT32_MAX
return n32_narrow_n8_checked(source_val, should_assert);
#else
# error "size_t is neither 8 nor 4 bytes?"
@ -710,9 +710,9 @@ template <typename T> int8 i8_from_usize_checked(T, bool) = delete; // disable i
[[nodiscard]] inline
int16 i16_from_usize_checked(const size_t source_val, bool should_assert) // not clamping/capping
{
#if SIZE_MAX == UINT64_MAX
#if (__SIZEOF_POINTER__ == 8) //SIZE_MAX == UINT64_MAX
return n64_narrow_n16_checked(source_val, should_assert);
#elif SIZE_MAX == UINT32_MAX
#elif (__SIZEOF_POINTER__ == 4) // SIZE_MAX == UINT32_MAX
return n32_narrow_n16_checked(source_val, should_assert);
#else
# error "size_t is neither 8 nor 4 bytes?"
@ -723,9 +723,9 @@ template <typename T> int16 i16_from_usize_checked(T, bool) = delete; // disable
[[nodiscard]] inline
int32 i32_from_usize_checked(const size_t source_val, bool should_assert) // not clamping/capping
{
#if SIZE_MAX == UINT64_MAX
#if (__SIZEOF_POINTER__ == 8) //SIZE_MAX == UINT64_MAX
return i32_from_u32_clamping(n64_narrow_n32_checked(source_val, should_assert));
#elif SIZE_MAX == UINT32_MAX
#elif (__SIZEOF_POINTER__ == 4) // SIZE_MAX == UINT32_MAX
return i32_from_u32_checked(n_alias_cast<uint32>(source_val), should_assert);
#else
# error "size_t is neither 8 nor 4 bytes?"
@ -736,9 +736,9 @@ template <typename T> int32 i32_from_usize_checked(T, bool) = delete; // disable
[[nodiscard]] inline
int64 i64_from_usize_checked(const size_t source_val, bool should_assert) // not clamping/capping
{
#if SIZE_MAX == UINT64_MAX
#if (__SIZEOF_POINTER__ == 8) //SIZE_MAX == UINT64_MAX
return i64_from_u64_checked(n_alias_cast<uint64>(source_val), should_assert);
#elif SIZE_MAX == UINT32_MAX
#elif (__SIZEOF_POINTER__ == 4) // SIZE_MAX == UINT32_MAX
(void)should_assert;
return static_cast<int64>(source_val); // For sure it will fit
#else

View file

@ -1988,7 +1988,6 @@ bool CServer::r_Verb( CScript &s, CTextConsole * pSrc )
{
g_Log.Event(LOGL_EVENT, "Not allowed during world save and/or resync pause");
}
break;
}
else
{

View file

@ -0,0 +1,5 @@
// Avoid false-positive issues by giving an alternative definition of Assert_Fail, used by ASSERT and PERSISTANT_ASSERT.
void Assert_Fail(const char *, const char *, long long)
{
__coverity_panic__();
}

View file

@ -0,0 +1,12 @@
*:/lib/*
unreachableCode
unusedFunction
duplInheritedMember
missingOverride // suppress temporarily
virtualCallInConstructor // suppress temporarily
constParameterPointer // suppress temporarily
passedByValue // suppress temporarily
funcArgNamesDifferent // suppress temporarily
noExplicitConstructor // suppress temporarily
returnByReference // suppress temporarily
functionConst

View file

@ -0,0 +1,2 @@
#!/use/bin/sh
clang-tidy -p ../build/compile_commands.json -checks='-*,clang-analyzer*' ../src/**/*.cpp ../src/**/*.h