Commit graph

53 commits

Author SHA1 Message Date
cbnolok
86373c9233 Add unit testing via DocTest
Moved CppCheck cmake code in a separate file.
2025-05-25 23:38:49 +02:00
cbnolok
6cdf242da1 CMake: external libs are now compiled as obj files, without an intermediate link-in-a-library stage.
This speeds up overall compilation, since only one link pass is done,
instead of one per target.
2025-05-09 20:08:22 +02:00
cbnolok
f542b8b6f2 CompilerFlagsBase: misspelled dead_strip flag 2025-04-27 18:18:28 +02:00
cbnolok
3e71a71fc6 Linking: moved --icf flag to CompilerFlagsChecker 2025-04-27 16:05:26 +02:00
cbnolok
dfb338e7bc Fized zlib compilation error con macos 2025-04-27 16:04:46 +02:00
cbnolok
dc55ffa6f1 Fix cmake/CompilerFlags*: actually use the base/common compiler flags, fix --gc-sections for OSX/AppleClang, temporarily comment some warnings. 2025-04-26 17:38:13 +02:00
cbnolok
205549abc2 CMake toolchains: moved some flags from CompilerFlagsChecker to CompilerFlagsBase.
The one moved are supported since a long time/older compiler versions
and from both Clang and GCC, so they can be safely moved.
Also, not having to check them, CMake configuration is a bit faster.
2025-04-26 17:34:59 +02:00
cbnolok
fb16b3dfda lib/zlib: updated CMakeLists to autoconfigure zconf.h from .cmakein file 2025-04-26 10:16:53 +02:00
cbnolok
8b0e5eca26 Update SQLite version from 3.33.0 to 3.49.1
Other than being a security update, it fixes a GCC 14 warning.
2025-04-26 09:24:00 +02:00
cbnolok
0b19f79b99 Moved fixed GCC/Clang compilation flags to separate cmake files. Fixed a
CMake parsing error causing optimizations not being applied correctly to
Nightly and Release build.
2025-02-14 07:27:23 +01:00
cbnolok
a043502947 Fixed compilation errors. Made more (easily) cross-platform the AbstractThread code (looking also at BSD). 2024-10-13 18:30:12 +02:00
cbnolok
28586ef1d2 Fixed MinGW compilation with both Clang and MSVC runtime libs.
Added different macros, instead of using _MSC_VER. This one is added
even when Clang with MSVC runtime, so it's not viable to check if we're
compiling with MSVC.
2024-10-13 18:30:12 +02:00
cbnolok
b75a9c949e Refactoring and small additions to CompilerFlagsChecker.cmake. 2024-10-13 18:30:12 +02:00
cbnolok
335c946156 Added CMake script to autodetect supported compiler flags, among those of interest. 2024-09-21 12:01:28 +02:00
cbnolok
aafb23444d Added precompiled headers. This speeds up dramatically the compilation speed. 2024-09-21 12:01:28 +02:00
cbnolok
af5f7d375a Update .clang-tidy, fixed a couple of linter warnings. 2024-09-09 18:51:32 +02:00
cbnolok
2981b76da9 Add .clang-tidy stub. 2024-09-08 21:20:42 +02:00
cbnolok
8dece16d96 CMake files (cmake_format_gersemi.sh): added tab conversion to 4 spaces also for commented lines. 2024-09-08 14:48:12 +02:00
cbnolok
eae1a45276 Formatted cmake files with gersemi. 2024-09-08 14:33:56 +02:00
cbnolok
405db0bb11 Restored PR #1255: Spellflags fix reorganization 2024-08-07 11:27:32 +02:00
cbnolok
4ea4325320 Fixed script parsing regression with empty strings, fixed undefined behaviors 2024-08-06 09:56:32 +02:00
cbnolok
75a07b4498 Several stability fixes
- Fixed: ini CommandPrefix being overwritten by data from other ini settings.
- Fixed: function call stack sometimes being subject to a race condition between two writing threads, corrupting it.
- Fixed: lots of memory corruption errors leaving the server unstable when loading a broken save file and recovering by loading a backup save.
- Fixed: CCacheableScriptFile sometimes not reading the last character.
- Fixed: .clang_format.
- Changed: RES_GET_INDEX macro to ResGetIndex function, allowing more integer type safety. Same for RES_GET_TYPE.
- Changed: Renamed THREAD_* macros to MT_*. Split them in always active macros (MT_*) and macros active only when MT_ENGINE is set to 1 (MT_ENGINE_*). There are some situations where we still need a mutex
even if not working with multithreaded script/networking engines (which are NOT complete).
- Changed: Disable signal handlers under Linux if running with ASAN or a debugger.
- Added: NOEXCEPT_DEBUG, it's simply the noexcept specifier, but it's ignored if running in a debug build (useful if we're using DEBUG_ASSERT inside a function which wouldn't otherwise throw an exception).
- Fixed: some undefined behaviors, like signed to unsigned conversion and vice versa.
- Added: additional checks for GCC and Clang ASAN builds.
2024-08-06 09:56:32 +02:00
cbnolok
5c9ea6bff6 Fixed: LASTUSED, LASTDISCONNECTED, TIMESTAMP being interpreted as a number with a different base (seconds or tenths of seconds or milliseconds) in different contexts. Now they expect in scripts only values in seconds.
Fixed: crash when moving a char in an area full of teleporters, or whichever items made the char move multiple times in the same tick.
Fixed: buffer read past the end in CCacheableScriptFile first reading.
Fixed: if a char had the COMM_CRYSTAL flag enabled, it called ::OnHear on every item in range, without checking if the item is actually capable of hearing.
Further optimized distance checks.
Separated the Github workflows into different files, in order to get a different badge for each build platform/type.
Dismissed AppVeyor build.
Added sphere_library/sfastmath.h.
2024-08-06 09:56:32 +02:00
cbnolok
fa3df00951 More speed optimizations.
CWorldSearchHolder now uses CSReferenceCount instead of rc_ptr, which is more complex and slightly slower.
Modified some ADDTOCALLSTACK calls for frequently called functions.
Changed some rand val generations in CCharFight to use the fast algorithm.
Inlined some small functions.
2024-08-06 09:56:32 +02:00
cbnolok
4d9a446fb7 Optimized CWorldSearch. Since it's used very, very often, instead of dynamically allocating memory for it each time, pre-allocate and request cached CWorldSearch instances. Use CWorldSearch::GetInstance().
Added cdrc external library (reference counted smart pointers, std::shared_ptr is too slow) and new CSReferenceCount sphere library. Cdrc has been slightly modified in order to be used and compiled in a multi-file project. See custom folder.
Added HAS_FLAGS_STRICT and HAS_FLAGS_ANY macros.
Fixed macOS compilation error.
2024-08-06 09:56:32 +02:00
cbnolok
743dda9900 Started rework of timed object ticking system (trying to change the default container from map of vectors to a multimap, also trying to delete elements as little as possible, to avoid cpu usage, reallocations and tree rebalancing).
Added #define MT_ENGINES: it doesn't make sense to keep unneeded mutex locks, at least until (if ever) we'll have a fully multithreaded engine.
Some advancement in making ASAN work on Windows with Clang.
Added .cmake-format
2024-08-06 09:56:32 +02:00
cbnolok
c7f4eb52f1 - Added: client commands ADDITEM and ADDCHAR, to be used in place of .ADD when there's the need to force the argument to be an item or a char.
This can be useful when using raw IDs (like 01, 0bd1, etc) instead of defnames.
- Improvement: changed the logic behind script files reading and caching, now it will be faster and require less memory.
- Fixed: correct thread name not being shown in the stack trace.
- Renamed ResourceGetID_Advance to ResourceGetID_EatStr, added fCanFail argument.
- Added some string functions, starting from POSIX C getline and getdelim (got the source from NetBSD and renamed to fReadUntilDelimiter), then added some more custom functions to help read from file or string buffers.
2024-06-04 13:56:45 +02:00
cbnolok
5b0ed57e19 Reverted to the old, garbled but working code for the twofish en/decryption... 2024-06-03 17:50:20 +02:00
cbnolok
cc8d5d2593 Added ini settings for network security: MaxConnectRequestsPerIP, TimeoutIncompleteConn.
Added serv_trigger functions: f_onserver_connectreq_ex, f_onserver_connection_acquired.
Fixed version string with git versioning disabled.
Updated .editorconfig.
Added more AddressSanitizer compiler/linker flags.
2024-06-03 17:42:05 +02:00
cbnolok
08bf180f05 Fixed sign/str format warnings, MinGW compilation, ASan Nightly MSVC builds 2024-05-29 19:14:11 +02:00
cbnolok
d04dc35bd3 Updated phmap lib, fixed osx-arm64 executable name, removed _32/64BITS macro references, added llvm symbolizer path to windows clang util bat. 2024-05-27 19:12:00 +02:00
cbnolok
66ef50b3c6 Some more optimizations, changed rand algorithm to the fast one for trivial tasks, fixed MSVC, typo for OSX toolchains and rigid cast making the Linux build fail. 2024-05-23 19:10:16 +02:00
cbnolok
d2330418fa Added pseudorandom number generation with xorshift algorithm, slightly changed rand function call syntax. 2024-05-20 11:18:01 +02:00
cbnolok
d66675e40a Added separated linker options for each C 3rd party lib.
Fixed twofish compilation error on Windows. That library wasn't really meant to be used as-is...
Made _GITVERSION define macro available only when enabling git versioning from CMake.
Modernized and fixed MSVC CMake toolchain.
Removed mariadb_version.h from git index.
2024-05-20 11:16:23 +02:00
cbnolok
d93a122352 Fixed warning for invalid debug checks in twofish.c
Fixed another warning for unchecked/unused return value.
2024-05-19 15:18:21 +02:00
cbnolok
84888279c9 Updated toolchains to set options per target, instead of globally.
Windows and OS X not yet tested.
Moved toolchains .inc files to include/ folder.
Renamed folder lib/bin into _bin.
Moved bcrypt and twofish library into lib folder and into new cmake projects. Restored twofish library to the original version.


Fixed some format warnings.
2024-05-19 14:04:53 +02:00
cbnolok
4533f80f4c Moved each third-party library to a separate CMake project
This will allow setting per-project (build) settings and to build/link
Sphere using system-provided library source/headers/precompiled lib
(like the ones provided with -devel packages on Linux) instead of the
ones shipped with the projects.
This is also a necessary step to use git submodules.
2024-05-17 11:10:17 +02:00
cbnolok
3b2c4d9c6d Updated zlib to v1.3.1
Added Apple Silicon ARM build for Mac OS
Fixed Clang 15 compilation on newer MacOS images
2024-05-06 10:59:10 +02:00
cbnolok
07082fc518 Fixed: House customization sending wrong component data, breaking it.
Updated AppVeyor image, it looks like the default one has some problems setting up its PostgreSQL installation?
2023-11-18 16:43:22 +01:00
cbnolok
ba14b024a2 Preparations for master/dev branches development model.
Added git branch info into sphere; branch and revision number are not displayed to players/clients (by default).
Fixed some MSVC warnings for WinMain definition and a Clang warning for wrapper_ev.c.
2023-11-16 21:25:56 +01:00
cbnolok
7750d98e71 Fixed temporary strings allocation bugs and thread data retrieval upon server start.
Immediately after server start, the global objects are initialized in spheresvr.cpp. This happens before calling main().
Global objects initialization sometimes requires the allocation of temporary strings and the retrieval of the current thread state data (ThreadHolder class stuff).
Both of those things aren't yet created, so we can write to invalid memory instead of using the expected buffer.
When thread state data is not available, so we can't get a temporary string buffer in a thread-safe way, now it will be used the string buffer allocated for thread-unsafe access (for a minimum example, check Str_GetTemp code).
Also, when the server closes, also the temporary string pool and the thread state data are deleted, but there might be some code still requiring thread state data.
So it was added some code accounting of this special application state, avoiding reading or writing to the thread state data location, which doesn't hold anymore valid data.
2023-11-01 21:18:01 +01:00
cbnolok
ef2d63c48b Revert "Fixed temporary strings allocation bugs and thread data retrieval upon server start."
This reverts commit 14a4651e20.
2023-11-01 21:14:08 +01:00
cbnolok
14a4651e20 Fixed temporary strings allocation bugs and thread data retrieval upon server start.
Immediately after server start, the global objects are initialized in spheresvr.cpp. This happens before calling main().
Global objects initialization sometimes requires the allocation of temporary strings and the retrieval of the current thread state data (ThreadHolder class stuff).
Both of those things aren't yet created, so we can write to invalid memory instead of using the expected buffer.
When thread state data is not available, so we can't get a temporary string buffer in a thread-safe way, now it will be used the string buffer allocated for thread-unsafe access (for a minimum example, check Str_GetTemp code).
Also, when the server closes, also the temporary string pool and the thread state data are deleted, but there might be some code still requiring thread state data.
So it was added some code accounting of this special application state, avoiding reading or writing to the thread state data location, which doesn't hold anymore valid data.
2023-10-31 15:25:15 +01:00
cbnolok
a97663f354 Changed some containers type, using the new smart pointers and smart pointer vectors.
Added more useful methods to sl::smart_ptr_view and fixed raw_ptr_view.
2023-10-23 22:35:20 +02:00
cbnolok
24308e45d4 - Created new namespace "sl" to hold sphere_library classes and functions (it will be slowly populated).
- Added new "smart" pointer sl::smart_ptr_view, a customized version of the proposed std::observer_ptr. Use this to make clear that you aren't managing the lifetime of the pointer you are using, since it's owned by a unique_ptr or shared_ptr.
- Added new "smart" sl::raw_ptr_view. Same concept of sl::smart_ptr_view, but it wraps a raw/bare pointer (most often it will be used in conjunction with legacy code, which doesn't use smart pointers).

- Renamed CSSortedVector to sl::sorted_vector.
2023-10-23 22:35:20 +02:00
cbnolok
d99b6a792a Updated ZLib to version 1.3.0.1. 2023-10-07 20:27:37 +02:00
cbnolok
ff3b170c99 Updated flat_containers library. 2023-10-07 20:08:47 +02:00
cbnolok
4105d3b45e Updated parallel_hashmap external library, improved compiler flags for builds using sanitizers. 2023-10-07 19:58:49 +02:00
cbnolok
b7e2497c50 Moved to GCC 12, fixes for github workflow and if parsing.
Fixed IF parsing of arguments without curved brackets and inside angular brackets.
Fixed Github Linux workflow.
Fixed Libev config.h generation.
2023-05-03 18:35:08 +02:00
cbnolok
fe4f07d262 Fixed: Assertion failure and segmentation fault/invalid memory access caused by early use of Sphere methods requiring some data to be initialized first. Compilation and execution should now work with latest GCC versions.
Added: functions to explicitly promote or narrow numeric types.
Changed: Target architecture is precisely reported, instead of giving the number of "bits".
2023-04-30 19:32:00 +02:00