58 Commits
Author SHA1 Message Date
Anders Jenbo 1c76897f2c Apply simple const rules using clang-tidy 2025-08-16 01:21:36 +02:00
Gleb Mazovetskiy c43aead8d1 Cleanup Diablo-SHA and codec.cpp
1. Switches to 32-bit based calculation throughout. This is faster and
   less error-prone as we only byte-swap once when reading and writing.
2. Removes global state from Diablo-SHA implementation.
2022-01-07 01:34:26 +00:00
Gleb Mazovetskiy 868289dc17 Add missing <cstring> includes 2021-11-28 15:32:36 +00:00
Gleb MazovetskiyandAnders Jenbo 7e1fea6f76 clang-format all files in {Source,test}/
Also includes a few manual tweaks to comments and newlines for better results.

Co-authored-by: Anders Jenbo <[email protected]>
2021-11-24 23:44:12 +01:00
Andrew James 0aea0782c7 Refactor Diablo-SHA to attempt to document behaviour through code (#2524)
* Hardcode the key and ensure buffers are appropriately sized.

If you do want to build the key at runtime the following initial state gets the right sequence:
```cpp
std::linear_congruential_engine<uint32_t, 214013, 2531011, 0> engine(3193970784);
for (auto &notch: key)
	notch = static_cast<byte>(engine() >> 16);
```

* Move public defines into sha.h, move private struct into .cpp

* Remove unused count member, clarify loop in SHA1Input

* Update circular shift to indicate desired behaviour, remove unnecessary negation.

The parameters are also reordered to match C++20 rotl/rotr and the usual order for shift operators.
2021-08-08 13:22:22 +02:00
Anders Jenbo 8df8b940c4 Handle some clang-tidy issues 2021-08-07 16:30:14 +02:00
Anders Jenbo de0b3a38b8 Apply code style 2021-07-20 02:51:39 +02:00
Anders Jenbo e5fc7fd17c Move remaning symbols in to anonymous namespaces 2021-07-20 02:51:39 +02:00
Anders Jenbo 903d4bd2e1 Scope all for loops
This caused 7 of the loops to be rewriteen using range by clang-tidy
2021-07-08 08:14:03 -07:00
Anders Jenbo a7c7fa0030 Fully apply clang-tidy/format to all files 2021-07-03 16:41:43 -07:00
Anders Jenbo ecea12fc15 Clang-tidy: ParameterCase 2021-07-03 15:46:39 -07:00
Anders Jenbo 0f2ad469ea ♻️Clean up variable initialization 2021-06-27 14:58:51 -07:00
Anders Jenbo bf780be1ed ♻️Cleanup all implicit bool conversions 2021-06-26 16:32:44 -07:00
Anders Jenbo 22b632f04a ♻️Clean up implicit bool conversions 2021-06-26 08:57:59 -07:00
Gleb Mazovetskiy 4d10642b3d 🧹 Add and use a DVL_ALWAYS_INLINE macro
Also moves attribute macros out of miniwin into a new header.
2021-05-13 01:54:27 +02:00
Anders Jenbo a32ac83090 🎨 cleanup trivial trype comparisons 2021-04-23 02:48:25 +02:00
Anders Jenbo 1e3ed903be 🎨 strip redundant else 2021-04-22 00:39:48 +02:00
Anders Jenbo 373f28736f 🎨 Acceptable parts of modernize-* 2021-04-19 22:42:19 +02:00
Anders Jenbo b978d80119 🎨 llvm-include-order 2021-04-19 20:11:20 +02:00
Anders Jenbo 997c1dba55 🚚 Split up all.h in to proper header relations 2021-04-16 01:04:54 +02:00
Anders Jenbo f450d6a125 🚚 Move defines to there proper files 2021-04-16 01:04:54 +02:00
Anders Jenbo bfb3c11c2b 🎨 Change namespace to devilution 2021-04-06 15:21:25 +02:00
Anders Jenbo 630e507f63 🚚 Apply namespace 2021-04-06 15:21:25 +02:00
pionere d5a0fa8e85 get rid of a few warnings 2021-02-19 22:04:11 +01:00
Anders Jenbo 61b2d0de95 Merge branch 'master' of github.com:diasurgical/devilution 2020-12-16 02:24:39 +01:00
Anders Jenbo 38dbcf7641 Format source 2020-12-02 00:52:38 +01:00
qndel 8c9a45863c fix saves in x64-release 2020-11-20 08:36:33 +01:00
Anders Jenbo 4794c8357c Merge branch 'master' of github.com:diasurgical/devilution 2020-11-02 03:59:47 +01:00
Anders Jenbo 4e8df866bc Fix function order [sha.cpp] 2020-10-26 01:15:51 +01:00
Anders Jenbo 893efd51ea Merge branch 'master' of github.com:diasurgical/devilution 2020-09-27 03:34:42 +02:00
Anders Jenbo 1ba96a6777 Add doxygen description to remaining engine files 2020-07-06 05:43:25 +02:00
Anders Jenbo a3505ab904 Remove the std namespace from uint32_t
Again to help older compileres that aren't C++11 aware.
2020-05-14 11:44:15 +02:00
Anders Jenbo 25993b4043 Merge branch 'master' of github.com:diasurgical/devilution 2020-02-14 23:03:31 +01:00
Anders Jenbo 20621a0642 add all.h and use in place of diablo.h (#2005)
Now diablo.h is treated in the same way as all other header files of
Source, as it only contains the declarations of global variables and
functions of diablo.cpp.

Besides consistency, this also enables mods to include diablo.h just
like any other header file without having to include every header file
(and without having to include C++ specific aspects of the now all.h).
2020-02-14 13:12:54 +01:00
Samuel-DEVULDER 9c516819c1 Make save game code big-endian compatible 2020-01-27 00:03:02 +01:00
Xadhoom 19992af2ad avoids implementation-defined behaviour 2019-11-07 00:41:24 +01:00
Gleb Mazovetskiy fb37bbf675 Disable some signed shift UBSAN warnings
On Clang we can do this globally via a sanitizer blacklist, but that's not supported on GCC (yet):
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61978

We disable these warnings because all compilers implement them in the
same way according to the N2218 proposal to standardize the behaviour:
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2218.htm
2019-10-10 13:51:19 +02:00
Gleb Mazovetskiy c2056c6cbf SHA: Fix some implementation-defined behaviour (#343)
* SHA: Fix negative base shift UB

* SHA: Avoid signed integer overflow

We do cast from uint32_t to int32_t but that should be OK everywhere.

* SHA: Always use portable arithmetic right shift
2019-10-10 09:10:57 +02:00
Anders Jenbo 23e7737c75 Merge branch 'master' of github.com:diasurgical/devilution
Fixes #92
2019-05-05 00:27:08 +02:00
Anders Jenbo ac102d3bfa Clean up sha.cpp 2019-05-02 00:16:46 +01:00
Xadhoom 6856fb74e2 Merge upstream beanch 'devilution/master' 2019-04-25 20:44:01 +00:00
Anders Jenbo 65b9fb87a8 Merge branch 'TownDead' 2019-04-24 14:08:25 +02:00
galaxyhaxz 540892ff9d Preliminary support for fixed header files 2019-04-21 17:20:38 +02:00
galaxyhaxz 4e01e03711 Cleanup default calling conventions 2019-04-09 12:04:00 +02:00
Xadhoom 5283a9ffd1 Put everything into namespace dvl 2019-03-11 20:10:23 +00:00
Anders Jenbo 1e4e826a36 Remove delta to devilution 2019-01-23 17:11:52 +01:00
Xadhoom cadef0d942 Merge upstream branch 'devilution/master' 2019-01-21 09:44:54 +00:00
Anders Jenbo 024d99fc9e C compatability from s (#521) 2018-12-29 21:15:33 +01:00
Anders Jenbo b1f6d3698f Update style to use tabs 2018-10-25 22:53:04 +02:00
Anders Jenbo 9c85b3f0eb clean up codec_init_key 2018-10-21 14:31:20 +02:00