Commit graph

235 commits

Author SHA1 Message Date
Ralph Sennhauser
0c0552a428
Replace M_PI with C++ numbers
C++20 added π (pi) to the standard, replace the C macro globally.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2026-06-04 20:29:48 +02:00
Daniel Richard G.
4050c645ac Avoid SIGBUS error in the MD5 implementation on ARMv7 (armhf)
Encountered in the test-suite run. This is just a workaround; the
implementation needs to be reworked/replaced to accommodate
alignment-sensitive architectures.
2026-03-23 08:20:10 +01:00
Vladislav Belov
bedb6129f2
Reduces string allocations in GUI and maths. 2025-10-11 19:44:22 +02:00
Ralph Sennhauser
77e05ca26d
Convert span with dynamic extent to static extent
In some places we know the size at compile time, so use that knowlage.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-08-24 11:09:57 +02:00
Ralph Sennhauser
2cedb48de2
Remove custom span and use std::span
With C++20 the custom container PS:span, which was a backport of
std::span is no longer needed.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-08-24 11:09:57 +02:00
Ralph Sennhauser
7dece41990
Fix includes in source/lib
Make include-what-you-use happy with some files in source/lib and fix
what needs to be fixed.

Ref: #8086
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-08-03 10:15:37 +02:00
Ralph Sennhauser
6f2f8c13bf
Replace boost::mt19937 with std::mt19937
Available since C++11 and already used in the codebase.

Ref: #8210
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-07-19 10:46:02 +02:00
Ralph Sennhauser
ed4e2587c2
Fix includes in source/maths
Make include-what-you-use happy with files in source/maths and fix what
needs to be fixed.

Ref: #8086
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-07-06 18:24:31 +02:00
phosit
891908b801 Remove UNUSED
The `UNUSED` macro is used to mark a variable as unused but with a name.
Those usages are replaced with comments so that `UNUSED` can be removed.

https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-unused
2025-06-26 17:25:05 +02:00
Ralph Sennhauser
58219b974c
Fix trailing whitespace and add pre-commit hook
Some have their editor configured to remove trailing whitespace and
editing such a file would "fix" it, adding an unrelated change.

Fix whitespace violations excluding third party libs and generated files
like glad or patches.

Enable pre-commit hook trailing-whitespace to enforce it in the future.

Fixes: #8016
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-15 20:08:48 +02:00
phosit
4be8e0bcfb Tell GCC the maximum value of m_BufLen
GCC thinks `m_Buf + m_BufLen` can be outside the bound of `m_Buf`.
That is because `m_BufLen + len < CHUNK_SIZE` can evaluate to `true`
even if `m_BufLen` is bigger than `CHUNK_SIZE` due to wrapping. Tell GCC
that it's not possible.
2025-01-13 20:05:43 +01:00
Ralph Sennhauser
ead62bba78
Update trac links with gitea links
This replaces all links pointing to trac with their corresponding links
to gitea. Also replace http with https while at it.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2024-12-10 11:29:48 +01:00
trompetin17
8c250568e7
Add scrollpanel widget
This PR introduces a new ScrollPanel component with the following
capabilities:
- Scroll Orientation Support: Allows scrolling in horizontal, vertical,
  or both directions, providing flexibility for different use cases.
- Partial Object Rendering: Supports partial rendering of objects that
  are only partially visible within the scroll boundaries, improving
  visual accuracy and performance.
- Boundary-Constrained Mouse Interaction: Handles mouse events strictly
  within the panel's visible boundaries, preventing interaction with
  objects outside the scrollable area.
- Minimum Internal Size (min_width, min_height): Introduces support for
  virtual space management, allowing the panel to maintain a minimum
  internal size independent of its actual on-screen dimensions. Even
  when the panel is resized, this ensures that the content respects a
  defined virtual space (with min_width and min_height), effectively
  simulating a larger internal canvas. This is particularly useful for
  large content or scenarios where a more extensive scrollable area is
  required than the current visible panel.
2024-11-12 15:01:42 -05:00
Stan
bd5f8392be
Make CMatrix3D::operator*= behave as expected. 2024-10-08 16:04:22 +02:00
vladislavbelov
ffc4a56b9f Revert non-ASCII characters from source and configuration files introduced in 157c6af18e.
Fixes #6846

Differential Revision: https://code.wildfiregames.com/D5185
This was SVN commit r27965.
2023-12-03 00:30:12 +00:00
bb
157c6af18e Make the space in 0 A.D. non-breaking throughout the codebase.
Avoid cases of filenames
Update years in terms and other legal(ish) documents
Don't update years in license headers, since change is not meaningful

Will add linter rule in seperate commit

Happy recompiling everyone!

Original Patch By: Nescio
Comment By: Gallaecio
Differential Revision: D2620
This was SVN commit r27786.
2023-07-27 20:54:46 +00:00
vladislavbelov
dffde00e5f Reduces uniforms sizes for the Canvas2D shader.
Differential Revision: https://code.wildfiregames.com/D4796
This was SVN commit r27136.
2022-10-09 10:44:51 +00:00
vladislavbelov
04bd96cee0 Moves uniform and texture binding to CDeviceCommandContext.
Tested By: Langbart
Differential Revision: https://code.wildfiregames.com/D4631
This was SVN commit r26848.
2022-05-02 20:57:22 +00:00
vladislavbelov
d8b8128abb Adds AsFloatArray to CMatrix3D.
This was SVN commit r26834.
2022-04-27 19:53:42 +00:00
vladislavbelov
9b6365f9f2 Removes unused Noise generator added in 18eb72a25a without any actual usage.
60befbd1cf added the exact same implementation to the rmgen tool,
469d0fe5c5 removed the rmgen tool along with the original implementation
of noise.

Patch By: smiley
Differential Revision: https://code.wildfiregames.com/D4611
This was SVN commit r26810.
2022-04-20 20:22:01 +00:00
vladislavbelov
02c96903c5 Renames sgn function to Sign to fit the naming of other MathUtil functions.
This was SVN commit r26276.
2022-01-30 20:51:01 +00:00
wraitii
0779c64052 Add tests for fixed::FromFraction
Differential Revision: https://code.wildfiregames.com/D4458
This was SVN commit r26273.
2022-01-30 12:57:08 +00:00
wraitii
158cf8ea8d UnitMotion pushing improvements
The main change is the introduction of a 'pushing pressure' counter on
units. This counter increases when units get pushed around, and
decreases over time. In essence, units under high pressure move slower &
are harder to push around.
The major effect is that units can now get bogged down when very dense
groups start colliding. This makes movement more realistic, makes unit
movement more 'chokepointy', and generally improves the mathematical
soundness of the system (lower values are easier to handle for our 200ms
turns).

Other changes:
- The logic to detect units crossing each other's path has been
reworked. Units that run towards each other should not more obviously
avoid each other.
- New parameters: 'Spread' is a measure of how strong the pushing effect
is based on distance. With the current settings, static-pushing is
rather 'on/off', whereas moving-pushing is more gradual (and thus the
max influence distance was increased when moving).
- Default values have been tweaked for lower overlap.
- Units only looked at other units within their grid region. This led to
overlap near grid-borders. Units now look at neighboring grid elements,
which largely removes this issue. While this may be slower, the
performance of pushing was largely negligible before, so it is unlikely
to become a main cause of lag (and overlap was generally disliked by
players).
- Units no longer orient in the direction of pushing, but instead keep
facing their target. This can look slightly odd under very heavy pushing
forces, but vastly improves behaviour of very slow units such as rams
(since they spend much less time turning around). As a side-effect,
clean up angle code following acc780bcbb .

Engine changes:
- Add a debug rendering mode at compile-time to help understand what is
happening.
- Make it possible to constexpr initialise fractional fixed numbers by
using FromFraction

The 'pressure' change was inspired by alre's suggestion at
https://wildfiregames.com/forum/topic/56436-for-a-better-unit-movement/#comment-461987

Refs #6127

Differential Revision: https://code.wildfiregames.com/D4439
This was SVN commit r26245.
2022-01-24 15:36:13 +00:00
vladislavbelov
809e3ed0bd Removes rand function usage from tests to avoid non-uniform distributions.
This was SVN commit r26012.
2021-11-25 17:57:59 +00:00
vladislavbelov
9b3dcd2610 Slightly improves minimap flares, makes animation more smooth via alpha fade in/out.
Tested By: Langbart
Differential Revision: https://code.wildfiregames.com/D4351
This was SVN commit r26001.
2021-11-16 16:58:32 +00:00
vladislavbelov
31a6ffdd3a Removes mentions of legacy and unused GL calls, unifies AsFloatArray.
This was SVN commit r25961.
2021-10-11 12:39:01 +00:00
Stan
d599a86b3e Disable the false positive "mod by 0" warning on Windows.
Differential Revision: https://code.wildfiregames.com/D4259
This was SVN commit r25906.
2021-09-09 17:49:07 +00:00
vladislavbelov
96708cc6a5 Adds header for forward declarations of CStr.
This was SVN commit r25905.
2021-09-09 17:39:08 +00:00
vladislavbelov
44f8d2c6f5 Fixes a bounding box projection to an incorrect camera causes the red water bug.
Tested By: Langbart
Differential Revision: https://code.wildfiregames.com/D3905
This was SVN commit r25440.
2021-05-15 13:33:36 +00:00
wraitii
bb49fbe793 Further reduce usage of TERRAIN_TILE_SIZE in non-terrain components
TERRAIN_TILE_SIZE is now only used in relevant places in the simulation.
This also makes it mostly possible to use CFixed in constexpr contexts.

Refs #5566

Differential Revision: https://code.wildfiregames.com/D3078
This was SVN commit r25360.
2021-05-02 17:40:00 +00:00
wraitii
924c6ce34e Rework 7ee94f23df
Following comments by @vladislavbelov.

Differential Revision: https://code.wildfiregames.com/D3860
This was SVN commit r25278.
2021-04-16 16:01:30 +00:00
vladislavbelov
389a5a4379 Removes low-level GL calls from graphics and geometrics primitives and adds DebugRenderer.
Tested By: Freagarach
Differential Revision: https://code.wildfiregames.com/D3857
This was SVN commit r25269.
2021-04-15 18:07:01 +00:00
wraitii
7ee94f23df Use type_identity to simplify Clamp usage.
Differential Revision: https://code.wildfiregames.com/D3859
This was SVN commit r25266.
2021-04-15 13:01:24 +00:00
vladislavbelov
742b636f70 Moves CRect from ps to maths to related geometric primitives.
This was SVN commit r25165.
2021-03-30 21:14:36 +00:00
vladislavbelov
c56c856ed5 Moves Frustum from graphics to maths to more related geometric primitives like bounding ones.
This was SVN commit r25159.
2021-03-29 17:28:13 +00:00
vladislavbelov
4f83f1a0e9 Cleanups Frustum and removes access to members.
This was SVN commit r25158.
2021-03-29 17:15:29 +00:00
vladislavbelov
969112b9c8 Replaces CPos by more a consistent CVector2D, reduces geometry code duplication.
Tested By: Freagarach, Langbart
Differential Revision: https://code.wildfiregames.com/D3759
This was SVN commit r25152.
2021-03-28 21:55:13 +00:00
vladislavbelov
d533084d7c Removes unused code from Size2D and changes eol-style to native.
This was SVN commit r25144.
2021-03-27 21:11:36 +00:00
vladislavbelov
db84c2a9b2 Moves CSize into a separate file and renames it to CSize2D according to other geometric entities.
This was SVN commit r25143.
2021-03-27 16:08:06 +00:00
vladislavbelov
bc66700e11 Adds more detailed test for perspective camera projection and its corners in world space.
Cleanups CVector3D a little bit.

This was SVN commit r25066.
2021-03-16 22:42:29 +00:00
wraitii
369c2e8801 Further header & precompiled cleanup, fix no-PCH builds.
GUIObjectBase is made a IGUIObject* to avoid including those headers
un-necessarily. Subsequent diffs ought to clean up the various of
pointers for that with a similar type with reference semantics.

Also:
- Add standard C and C++ headers (mostly cstring for memcpy, string and
vector) where needed.
- Swap out some includes for forward declarations
- Clean up un-necessary boost includes in precompiled and other headers.
- Clean up precompiled headers, including fewer things.
- Move ACPI to the windows-specific folder as it's included there only
and mostly specific to that platform.

Thanks Stan for the testing.

Differential Revision: https://code.wildfiregames.com/D3129
This was SVN commit r24352.
2020-12-09 14:39:14 +00:00
s0600204
d7d0f142d8 Update (and debundle) fmt dependancy
We now support the most recent released version of `fmt` available (at
the time
of committing).

As we no longer patch `fmt` to get it to work within `pyrogenesis`, this
commit
also mostly removes its source from our code-tree (some headers are
retained for
Windows builds).


If you are a user of...

Linux/BSD: You will now need to have `fmt` installed from your
distribution's
           package repository. The minimum supported version of `fmt` is
`4.0`.

      OSX: The source is acquired and compiled (in `build-osx-libs.sh`),
           then included and linked automatically.

  Windows: The relevant header files are retained and, along with a
pre-built
           library, are the only things still bundled.


Accepted by: wraitii
Tested by:
* Freagarach (Lubuntu 18.04, `fmt 4.0.0`)
* Krinkle (MacOS 10.14, `fmt 6.1.2`)
* nephele (Alpine Linux)
* wraitii (MacOS 10.14)
* Nescio (Fedora 33, `fmt 7.0.3`)

Windows library files built by: Stan
Fixes: #3190
Differential Revision: https://code.wildfiregames.com/D2689
This was SVN commit r24267.
2020-11-26 21:01:32 +00:00
wraitii
f6348b9617 Clean up header includes, add new forward declarations.
This cleans up many un-necessary header includes, either simply
providing nothing or forward declarations in their place.

No major compilation time change here, though this does reduce depencies
in some headers.

Also fix up old MacOS STL-include fixes that are no longer relevant.

Differential Revision: https://code.wildfiregames.com/D3128
This was SVN commit r24227.
2020-11-21 11:20:29 +00:00
wraitii
bb8456691b Avoid overflow in UnitMotion.
ComputeTargetPosition called Dot() with large enough vectors that it
overflowed. Avoid that by not actually doing the full dot product.

Reported by: Itms
Fixes #5852

Differential Revision: https://code.wildfiregames.com/D3061
This was SVN commit r24152.
2020-11-09 13:25:50 +00:00
Imarok
853e8c0f1e CVector2D: Fix members may not be initialized warnings
Differential Revision: https://code.wildfiregames.com/D2825
This was SVN commit r23784.
2020-06-21 18:21:31 +00:00
elexis
0dff6940f7 Implement a FixedVector2D::CompareLengthSquared function to provide a more performant alternative to CompareLength.
Avoids computing the square of the compared value every call.

Differential Revision: https://code.wildfiregames.com/D2058
Reviewed By: Vladislav
This was SVN commit r23489.
2020-02-09 21:00:43 +00:00
vladislavbelov
7790fd7d29 Removes duplication of Clamp function.
Reviewed By: wraitii
Commented By: Stan
Differential Revision: https://code.wildfiregames.com/D1763
This was SVN commit r23002.
2019-09-26 21:14:21 +00:00
vladislavbelov
d1fb66d2a7 Cleanups BoundingBoxAxisAligned and fixes coding styles a bit.
Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D1951
This was SVN commit r22372.
2019-06-12 20:23:14 +00:00
vladislavbelov
9f5494cb87 Fixes a misprint that was introduced in cb83d494e0.
This was SVN commit r22228.
2019-04-25 18:59:41 +00:00
Stan
fd719833ab Replace includes uniform_foo with uniform_foo_distribution as it's deprecated in newer versions of boost. It was added in the 1.47 version.
Reviewed by: @Angen, @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D1823
This was SVN commit r22211.
2019-04-22 21:45:23 +00:00