2324 Commits

Author SHA1 Message Date
MihailRis
7bc96affbb add one-time warnings to deprecated blocks-related functions 2024-08-04 00:00:42 +03:00
MihailRis
0f527c196c
Merge pull request #281 from Pugemon/pvs-fix
reformat, conversion, and PVS studio fixes
2024-08-03 23:41:15 +03:00
Vyacheslav Ivanov
815ba45747
Merge remote-tracking branch 'origin/pvs-fix' into pvs-fix 2024-08-03 23:15:15 +03:00
Vyacheslav Ivanov
e4f8625e2a
fix: fix narrowing conversion double to float by using std math funcs
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 23:13:35 +03:00
Vyacheslav Ivanov
4211275c11
fix: PVS-Studio V523
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 23:05:28 +03:00
Vyacheslav Ivanov
faa1635014
fix: PVS-Studio V688
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 23:00:11 +03:00
Vyacheslav Ivanov
5369507938
fix: PVS-Studio V1048
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 23:00:10 +03:00
Vyacheslav Ivanov
ba2fe68ec6
fix: PVS-Studio V560
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 23:00:10 +03:00
Vyacheslav Ivanov
ab28b4df70
fix: PVS-Studio V550
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 23:00:10 +03:00
Vyacheslav Ivanov
3621e7ce1b
fix: PVS-Studio V522 mark false
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 23:00:10 +03:00
MihailRis
e014931e1e fix: selection update latency 2024-08-03 22:36:18 +03:00
Vyacheslav Ivanov
4efa574eec
fix: PVS-Studio V508 mark false
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 21:05:19 +03:00
Vyacheslav Ivanov
7c8f04aa75
fix: Do not use NULL in arithmetic
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 21:03:52 +03:00
Vyacheslav Ivanov
2cd6837da9
fix: optimization: PVS-Studio warning V836
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 20:03:34 +03:00
Vyacheslav Ivanov
bbf33e8e4d
format: reformat project
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 19:53:48 +03:00
Vyacheslav Ivanov
736cd175d5
format: fix: set AllowShortFunctionsOnASingleLine to 'None'
This parameter for disabling requires None, not 'false'

Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 19:39:58 +03:00
Vyacheslav Ivanov
2e7c0a109d fix: optimization: PVS-Studio warning V810
Cached the result of 'glm::vec3(size * 0.63f)' in a temporary variable to avoid multiple identical function calls and improve performance.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 17:52:15 +03:00
Vyacheslav Ivanov
5e70837d3f fix: optimization: PVS-Studio warning V815
The 'empty()' method is more efficient for checking if a string is empty compared to comparing it with an empty string literal.

The default constructor 'std::wstring()' is more efficient for creating an empty string compared to using a string literal.

The 'clear()' method is more efficient for clearing a std::wstring compared to assigning it an empty string literal.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 17:50:58 +03:00
Vyacheslav Ivanov
74a2dd7f6d fix: optimization: PVS-Studio warning V820
Replaced copying of the 'sources' variable with move semantics to improve performance.

By moving instead of copying, we avoid unnecessary copying of data and enhance efficiency.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 17:50:43 +03:00
Vyacheslav Ivanov
26ff0f133a fix: optimization: PVS-Studio warning V821
Creating variables in a more localized scope can enhance performance and make the code easier to understand.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 17:50:04 +03:00
Vyacheslav Ivanov
3fa7fac4df fix: optimization: PVS-Studio warning V830
Replaced 'std::optional::value()' with '*' operator to improve performance.

Using 'std::optional::value()' involves additional overhead compared to using the '*' or '->' operators. This change ensures more efficient access to the underlying value of the optional when you are certain that it contains a value.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 17:47:15 +03:00
Vyacheslav Ivanov
8c5e5559ec fix: optimization: PVS-Studio warning V831
Replaced 'at()' method with 'operator[]' to improve performance.

The 'at()' method performs bounds checking, which can introduce overhead. Using 'operator[]' bypasses this check and can improve performance when you are certain that the index is within bounds.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 17:46:29 +03:00
Vyacheslav Ivanov
97a0bb5776 fix: optimization: PVS-Studio warning V835
Passing cheap-to-copy arguments by reference can sometimes lead to decreased performance. This change ensures that the argument is passed by value, which is more efficient in cases where the argument is inexpensive to copy.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 17:46:13 +03:00
Vyacheslav Ivanov
63ede5e27d fix: optimization: PVS-Studio warning V837
Replaced 'emplace' with 'try_emplace' to avoid unnecessary copies or moves when insertion fails.

The 'emplace' function does not guarantee that arguments will not be copied or moved if insertion is not successful. Using 'try_emplace' ensures that arguments are only copied or moved if the insertion actually takes place, thus improving performance.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 17:45:26 +03:00
Vyacheslav Ivanov
a20ffee7cb fix: optimization: PVS-Studio warning V823
Replaced 'push_back' with 'emplace_back' for better performance in containers.

Reported by: PVS-Studio

Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 17:44:51 +03:00
Vyacheslav Ivanov
35ef339b0c fix: optimization: PVS-Studio warning V825
The 'current.reset(lang.release())' expression is equivalent to 'current = std::move(lang)'.
Changed 'current.reset(lang.release())' to 'current = std::move(lang)' to improve code clarity and performance.

Reported by: PVS-Studio

Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 17:44:37 +03:00
Vyacheslav Ivanov
aecd0f5db9 fix: optimization: PVS-Studio warning V832
It's better to use '= default;' syntax instead of empty constructor and destructor body.
Using '= default;' can help the compiler generate more optimal code.

Reported by: PVS-Studio

Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 17:44:10 +03:00
Vyacheslav Ivanov
c858913a2f fix: optimization: PVS-Studio warning V807
Created references to avoid using repeated expressions, improving performance across multiple instances.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 17:43:12 +03:00
Vyacheslav Ivanov
52905ff27b fix: optimization: PVS-Studio warning V802
Rearranged structure fields in decreasing order of size to reduce structure size from 32 to 24 and 12 to 8 bytes on 64-bit platforms.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-03 17:42:06 +03:00
MihailRis
78e274dec4 fix frustum culling for entities 2024-08-03 17:41:03 +03:00
Vyacheslav Ivanov
e399e95930 fix: render: Fix WorldRenderer::renderBlockSelection
Block selection clears before new selection be drawn
Added a call to LineBatch::flush() to ensure that all buffered data is correctly uploaded to the GPU and rendered. The missing flush() was causing rendering artifacts, such as flickering of block outlines, which has now been resolved by ensuring that all accumulated data is processed and rendered properly.
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-02 15:13:22 +03:00
MihailRis
6da85af19b
Merge pull request #278 from MihailRis/revert-277-pvs-fix
Revert "fix: optimization: Various PVS-Studio warnings"
2024-08-02 14:59:59 +03:00
MihailRis
ba046a52c0
Revert "fix: optimization: Various PVS-Studio warnings" 2024-08-02 14:51:44 +03:00
MihailRis
a7ef7bb365
Merge pull request #277 from Pugemon/pvs-fix
fix: optimization: Various PVS-Studio warnings
2024-08-02 13:25:11 +03:00
Vyacheslav Ivanov
3a78746185
fix: render: Fix WorldRenderer::renderBlockSelection
Block selection clears before new selection be drawn
Added a call to LineBatch::flush() to ensure that all buffered data is correctly uploaded to the GPU and rendered. The missing flush() was causing rendering artifacts, such as flickering of block outlines, which has now been resolved by ensuring that all accumulated data is processed and rendered properly.
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-02 07:46:13 +03:00
Vyacheslav Ivanov
35d26a771f
fix: optimization: PVS-Studio warning V801
Redefined the second function argument as a const reference instead of by value to improve performance.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-02 06:18:05 +03:00
Vyacheslav Ivanov
c3e4341a04
fix: optimization: PVS-Studio warning V802
Rearranged structure fields in decreasing order of size to reduce structure size from 32 to 24 and 12 to 8 bytes on 64-bit platforms.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-02 06:12:30 +03:00
Vyacheslav Ivanov
c4cc71623d
fix: optimization: PVS-Studio warning V807
Created references to avoid using repeated expressions, improving performance across multiple instances.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-02 06:07:50 +03:00
Vyacheslav Ivanov
3d21b7ba6a
fix: optimization: PVS-Studio warning V810
Cached the result of 'glm::vec3(size * 0.63f)' in a temporary variable to avoid multiple identical function calls and improve performance.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-02 05:41:47 +03:00
Vyacheslav Ivanov
2c1103307f
fix: optimization: PVS-Studio warning V813
Passing large objects by const reference avoids unnecessary copying and enhances efficiency.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-02 05:35:55 +03:00
Vyacheslav Ivanov
5b325ac2bc
fix: optimization: PVS-Studio warning V815
The 'empty()' method is more efficient for checking if a string is empty compared to comparing it with an empty string literal.

The default constructor 'std::wstring()' is more efficient for creating an empty string compared to using a string literal.

The 'clear()' method is more efficient for clearing a std::wstring compared to assigning it an empty string literal.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-02 05:35:55 +03:00
Vyacheslav Ivanov
1068c3f4f4
fix: optimization: PVS-Studio warning V820
Replaced copying of the 'sources' variable with move semantics to improve performance.

By moving instead of copying, we avoid unnecessary copying of data and enhance efficiency.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-02 05:35:55 +03:00
Vyacheslav Ivanov
6b3146f98a
fix: optimization: PVS-Studio warning V821
Creating variables in a more localized scope can enhance performance and make the code easier to understand.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-02 05:35:53 +03:00
MihailRis
cba06c18ad fix doc/**/user-input.md 2024-08-02 03:02:33 +03:00
Vyacheslav Ivanov
e9a5f18bc3
fix: optimization: PVS-Studio warning V830
Replaced 'std::optional::value()' with '*' operator to improve performance.

Using 'std::optional::value()' involves additional overhead compared to using the '*' or '->' operators. This change ensures more efficient access to the underlying value of the optional when you are certain that it contains a value.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-02 02:38:54 +03:00
Vyacheslav Ivanov
f3f872c7a3
fix: optimization: PVS-Studio warning V831
Replaced 'at()' method with 'operator[]' to improve performance.

The 'at()' method performs bounds checking, which can introduce overhead. Using 'operator[]' bypasses this check and can improve performance when you are certain that the index is within bounds.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-02 02:38:54 +03:00
Vyacheslav Ivanov
1bdc9cf759
fix: optimization: PVS-Studio warning V835
Passing cheap-to-copy arguments by reference can sometimes lead to decreased performance. This change ensures that the argument is passed by value, which is more efficient in cases where the argument is inexpensive to copy.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-02 02:38:54 +03:00
Vyacheslav Ivanov
307ffc3c8f
fix: optimization: PVS-Studio warning V837
Replaced 'emplace' with 'try_emplace' to avoid unnecessary copies or moves when insertion fails.

The 'emplace' function does not guarantee that arguments will not be copied or moved if insertion is not successful. Using 'try_emplace' ensures that arguments are only copied or moved if the insertion actually takes place, thus improving performance.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-02 02:38:54 +03:00
Vyacheslav Ivanov
7fbd32b8df
fix: optimization: PVS-Studio warning V823
Replaced 'push_back' with 'emplace_back' for better performance in containers.

Reported by: PVS-Studio

Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-02 02:38:53 +03:00
Vyacheslav Ivanov
818fd716cc
fix: optimization: PVS-Studio warning V825
The 'current.reset(lang.release())' expression is equivalent to 'current = std::move(lang)'.
Changed 'current.reset(lang.release())' to 'current = std::move(lang)' to improve code clarity and performance.

Reported by: PVS-Studio

Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
2024-08-02 01:57:43 +03:00