Commit graph

8916 commits

Author SHA1 Message Date
Dunedan
e6c479e956
Show report statistics for single reports as well 2025-06-27 10:04:11 +02:00
Dunedan
7e531ec6fe
Add minimum, sum and percentile columns to reports 2025-06-27 10:03:38 +02:00
trompetin17
e845da025a
Add deprecation warning to GetTextSize API
Adds a runtime warning to `Engine.GetTextSize` indicating that the API
is deprecated and will be removed in a future version.

This API does not simulate GUI rendering accurately, as it treats markup
tags like [color], [font], or [icon] as visible characters. This leads
to incorrect size measurements in modern GUI layouts.

New recommended alternatives:
- Use `Engine.GetGUITextSize(...)` for accurate measurement of raw text
  blocks, fully simulating GUI rendering.
- Use `guiObject.getTextSize()` when working within a specific GUI
  object, as it accounts for maxWidth, padding (bufferZone), and object
  constraints.

A warning is now emitted at runtime to guide developers toward these
updated APIs.
2025-06-26 17:11:24 -05:00
trompetin17
19e82ebceb
Add getPreferredTextSize to calculate unconstrained text width
Introduces (CButton|CText).getPreferredTextSize, a new method for estimating
the natural width of a caption if the object had no width constraints.

Unlike .getTextSize, which reports the size after applying current
layout constraints (e.g., fixed width or anchors), getPreferredTextSize
answers the question: "How wide would this object need to be to display
the caption on a single line?"

This is particularly useful for modders and layout logic that wants to
dynamically size elements *before* assigning a fixed width or anchoring.
2025-06-26 16:58:32 -05:00
Ralph Sennhauser
7eaea3d181
Update headers in collada
Make include-what-you-use happy with files in source/collada and
fix what needs to be fixed after. Also switch quote with bracket include
where appropriate.

Ref: #8086
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-26 20:05:53 +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
phosit
dd26f3a802 Restrict param type of FSM events
Previously the param type was `void*` now the type has to be specified
as template parameter of the `CFsm`.
With this commit some casts can be removed.
2025-06-26 16:42:04 +02:00
Ralph Sennhauser
7f67bab7c8
Fix -Wrange-loop-construct in ModIo.cpp
Gcc 15 generates the following warning:

../../../source/ps/ModIo.cpp: In static member function ‘static bool ModIo::ParseModsResponse(const ScriptInterface&, const std::string&, std::vector<ModIoModData>&, const PKStruct&, std::string&)’:
../../../source/ps/ModIo.cpp:738:41: warning: loop variable ‘prop’ of type ‘const std::string&’ {aka ‘const std::__cxx11::basic_string<char>&’} binds to a temporary constructed from type ‘const char* const’ [-Wrange-loop-construct]
  738 |                 COPY_STRINGS_ELSE_CONTINUE("", el, "name", "name_id", "summary")
      |                                         ^~~~
../../../source/ps/ModIo.cpp:738:41: note: use non-reference type ‘const std::string’ {aka ‘const std::__cxx11::basic_string<char>’} to make the copy explicit or ‘const char* const&’ to prevent copying
../../../source/ps/ModIo.cpp:749:41: warning: loop variable ‘prop’ of type ‘const std::string&’ {aka ‘const std::__cxx11::basic_string<char>&’} binds to a temporary constructed from type ‘const char* const’ [-Wrange-loop-construct]
  749 |                 COPY_STRINGS_ELSE_CONTINUE("", modFile, "version", "filesize");
      |                                         ^~~~
../../../source/ps/ModIo.cpp:749:41: note: use non-reference type ‘const std::string’ {aka ‘const std::__cxx11::basic_string<char>’} to make the copy explicit or ‘const char* const&’ to prevent copying
../../../source/ps/ModIo.cpp:756:41: warning: loop variable ‘prop’ of type ‘const std::string&’ {aka ‘const std::__cxx11::basic_string<char>&’} binds to a temporary constructed from type ‘const char* const’ [-Wrange-loop-construct]
  756 |                 COPY_STRINGS_ELSE_CONTINUE("filehash_", filehash, "md5");
      |                                         ^~~~
../../../source/ps/ModIo.cpp:756:41: note: use non-reference type ‘const std::string’ {aka ‘const std::__cxx11::basic_string<char>’} to make the copy explicit or ‘const char* const&’ to prevent copying
../../../source/ps/ModIo.cpp:762:41: warning: loop variable ‘prop’ of type ‘const std::string&’ {aka ‘const std::__cxx11::basic_string<char>&’} binds to a temporary constructed from type ‘const char* const’ [-Wrange-loop-construct]
  762 |                 COPY_STRINGS_ELSE_CONTINUE("", download, "binary_url");
      |                                         ^~~~
../../../source/ps/ModIo.cpp:762:41: note: use non-reference type ‘const std::string’ {aka ‘const std::__cxx11::basic_string<char>’} to make the copy explicit or ‘const char* const&’ to prevent copying

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-26 12:39:48 +02:00
phosit
77b1addb45 Enable modules in the GUI
Doesn't actually change a GUI-page to use modules. Adopting a GUI-page
now only requires JS and XML changes.

Ref: #8081
2025-06-26 10:50:21 +02:00
phosit
b8348bec55 Store the ScriptInterface& in ModuleLoader::Result
During hotloading the `ScriptRequest` was constructed from a
`JSContext*`. That requires that already an other `ScriptRequest` is
active. Which isn't always the case.
Now The `ScriptRequest` is constructed from a `ScriptInterface&`.

Storing a `ScriptInterface&` in the `ModuleLoader::Result` allows to
remove the `m_Result` as it is retrieved from the `ScriptInterface`.
2025-06-26 10:50:21 +02:00
Ralph Sennhauser
25c53cb0ac
Enable eslint style rule 'keyword-spacing'
After Stan suggesting change in a review comment just enable the rule
'keyword-spacing' [1] and fix violations so this is no longer a topic in
spirit of #7812.

[1] https://eslint.style/rules/keyword-spacing

Ref: #7245
Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-25 14:34:12 +02:00
Ralph Sennhauser
b6e66a5d43
Update headers in lobby
Some gloox headers need workarounds to be included, so mark the header
"lib/external_libraries/gloox.h" as source for all gloox symbols and
collect all headers we use under it.

Further make include-what-you-use happy with files in source/lobby and
fix what needs to be fixed after.

Ref: #8086
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-25 14:00:44 +02:00
Ralph Sennhauser
f2b2222284
Fix msvc truncation warning
The CI warns but doesn't fail, explicitly cast to float and while at it
use constant for PI/2.

```
source\graphics\cameracontroller.cpp(303): warning C4305: 'argument': truncation from 'double' to 'float'
```

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-21 08:27:45 +02:00
trompetin17
0ebcc45237
Refactor GetNextChunk for clarity and safety
Replaces the for(;;) loop in GetNextChunk with a clearer while
(bytesRead < size) loop for better readability and intent.

Other improvements:
- Uses constexpr for constant audio format parameters
- Replaces C-style cast with reinterpret_cast
- Ensures consistent use of static_cast for type conversions
- Improves comment formatting

This refactor maintains the original logic while aligning with modern
C++ best practices.
2025-06-20 10:49:23 -05:00
trompetin17
0396d67d26
Apply consistent naming to member variables in ogg.cpp
Renames local variables in the class to follow the member naming
convention using the m_ prefix (e.g., m_Adapter, m_VF, m_FileEOF).
2025-06-20 10:49:16 -05:00
trompetin17
6b9652050c
Use std::copy_n in VorbisBufferAdapter::Read
Replaces a raw memcpy call with std::copy_n in VorbisBufferAdapter::Read
for improved type safety and readability. This ensures cleaner buffer
copying using standard C++ algorithms, avoiding manual pointer
arithmetic on void*.

The change is functionally equivalent but aligns better with modern
C++17 practices.
2025-06-20 09:04:09 -05:00
trompetin17
1d20adc3b9
Ensure brace initialization for member variables in Ogg classes
This commit updates the Ogg-related classes to use uniform brace
initialization ({}) for member variables where applicable. Brace
initialization improves clarity and prevents potential narrowing
conversions or unintended behavior caused by default constructor
ambiguity.

This change improves consistency and aligns with modern C++ best
practices, especially in C++11 and later where brace initialization is
recommended for safer initialization semantics.
2025-06-20 09:04:01 -05:00
trompetin17
2ae95d3c49
Refactor OggStreamImpl to use exceptions for error handling
Introduce a new `Open` method in `OggStreamImpl` that encapsulates the
logic for opening Ogg Vorbis files. This method replaces the previous
`Open` method and utilizes `std::runtime_error` for error reporting
instead of returning error codes. The constructor has been updated to
call this new method, ensuring files are opened upon instantiation. The
changes streamline the code and improve error handling.
2025-06-20 08:51:39 -05:00
trompetin17
336ff333ed
Remove unused OpenOggStream method
OpenOggStream was previously used to stream Ogg files directly from the
file system. It operated on raw file paths (OsPath) and assumed
uncompressed, unarchived files, which made it unsuitable for working
with files inside archives or VFS layers.

However, its usage has been fully replaced by OpenOggNonstream, which:
- Reads the entire file into memory (non-streaming),
- Works with virtual file systems (VFS),
- Supports both archived and compressed assets,

Is already used consistently across debug and release builds.

There are no remaining references to OpenOggStream in the codebase, so
this commit removes the unused function and its associated logic.
2025-06-20 08:41:39 -05:00
Ralph Sennhauser
4c165dd208
Update some includes for iwyu part 1
First batch of fixes to please include-what-you-use.

Ref: #8086
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-20 09:01:19 +02:00
phosit
1652e82021 Use std::unique_ptr for CSimulation2Impl
Using a `std::unique_ptr` it's explicit that the data is owned by the
`CSimulation2`.
2025-06-19 22:12:52 +02:00
phosit
93666d8628 Remove ignore_result
`std::ignore` serves the same purpose and is C++ standard.
2025-06-19 19:05:56 +02:00
trompetin17
5b8cb7f34b
Support std::optional in FromJSVal
This commit introduces support for std::optional<T> in
Script::FromJSVal. When a JavaScript value is undefined or null, the
resulting optional is set to std::nullopt; otherwise, the value is
converted and wrapped.

This change allows components to cleanly handle optional script values
without needing manual null checks or exception handling in C++.

As a direct application of this feature, the Identity component now uses
std::optional<std::wstring> for the return value of GetCiv(). This
resolves a bug where formation templates (e.g., those inheriting from
template_formation.xml) do not explicitly define a civ. After commit
03f7903fec, the code assumed GetCiv() would always return a valid
string, leading to undefined behavior when it was missing.

With this update:
- GetCiv() returning undefined results in an empty optional.
- The Identity component defaults to an empty civilization string ("")
  when the civ is not defined.
- This avoids crashes or actor parsing errors for civ-less templates and
  improves robustness in script-C++ interaction.

Closes: #8107
Fixes: #8091
2025-06-19 08:52:24 -05:00
trompetin17
007b4f5db7
Improve error logging for failed JS-to-C++ script conversions
Previously, if a JavaScript function returned a value that failed to
convert to the requested C++ type (e.g., from JS undefined to
std::wstring), the ScriptInterface would fail silently, making debugging
difficult.

This commit improves the error reporting in the script system by logging
the name of the JavaScript function being called when a type conversion
failure occurs. This makes it easier to trace and fix issues arising
from script-side inconsistencies or missing return values.

The improved logging is particularly useful for debugging errors such as
undefined civ values from GetCiv() when used via m_Script.Call<T>().
2025-06-19 08:52:23 -05:00
Ralph Sennhauser
ddb738b17d
Remove empty cpp file vfs_path.cpp
Once upon time there was content but no more, so remove it.

Ref: #8086
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-19 09:03:38 +02:00
Ralph Sennhauser
0108ff51f4
Fix no-pch build after b34f4b79aa
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-18 21:12:33 +02:00
phosit
11b92f784f Decrease interval of hotload check on mac
There are 8 hotloads in the tests. When each takes 1 second that adds 8
seconds to the tests. Decrease the interval value to an acceptable
number.
2025-06-18 14:42:13 +02:00
Stan
85bb494c17 Catch more file changes on mac 2025-06-18 14:42:13 +02:00
Stan
6a0dfa6dc1 Test whether some files are reloaded more directly
Add a way to tell whether `ReloadChangedFiles` actually catched events
by returning `INFO::SKIPPED` when it didn't.
Unlike GUI apps, you have to explicitely tell macOS to punp events in
console apps thus add a loop in the tests.
2025-06-18 14:42:13 +02:00
Stan
2a47bbf096 Use a mutex to syncronize g_QueuedDirs
`g_QueuedDirs is accessed by multiple threads. It has to be syncronized.
2025-06-18 14:42:13 +02:00
Stan
8b58d8865c Don't use ".." to get the data-directory
`sys_ExecutablePathname().Parent()/".."/"data";` was causing realpath to
pail on macOS, because ".." doesn't match any directory.
2025-06-18 14:42:13 +02:00
phosit
0698243dd1 Don't skip tests on mac
The tests where accidetally skipped on mac because it's treated as BSD.
2025-06-18 14:42:13 +02:00
phosit
d9795d29fe Remove the name of some unused arguments
Remove some usage of the `UNUSED` macro. Remove only those cases where
the names can be deduced from their type.

https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-unused
2025-06-18 12:49:59 +02:00
Ralph Sennhauser
657be906fe
Cleanup use of boost::filesystem
Suppressing boost warnings is already covered by how we include
libraries if there are actually still any of them relevant.

Then the v2 vs v3 stuff is obsolete as boost ships with filesystem v4
this days.

Lastly injecting a namespace alias via pch header is questionable, so
just don't.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-17 21:56:04 +02:00
trompetin17
b34f4b79aa
Allow setting CGUISize properties directly
Previously, modifying individual CGUISize properties (left, top, right,
bottom) via JavaScript had no effect unless the entire size object was
copied, modified, and reassigned—resulting in verbose and error-prone
code.

This update introduces proper JavaScript property accessors, enabling
direct reading and writing of CGUISize members. The result is a more
intuitive and scriptable API.

Key Changes:
- Implemented JavaScript get/set accessors for each CGUISize property,
  directly interacting with the native object.
- Retained support for string assignments to CGUISize
- Maintained the GUISize JS object for backward compatibility, also
  marked as deprecated.
- Improved CGUISimpleSetting<CGUISize> to allow partial updates via
  direct property access.
- allow assigning size from object with pixel and percent values

You can now assign size using an object with properties like:
size = {
  left: number, right: number, top: number, bottom: number,
  rleft: number, rright: number, rtop: number, rbottom: number
}

- One or more properties can be specified, the missing properties with
  fill as zero.
- Assignment triggers an immediate update event.

Delayed Setting Notifications:
- Introduced a mechanism for delayed setting notifications, currently
  only used in CGUISimpleSetting<CGUISize>, to avoid redundant
  recalculations.
- Ensured that getComputedSize triggers any pending delayed
  notifications before returning the size.

This change significantly enhances the developer experience and brings
the behavior in line with typical expectations for direct property
manipulation in JavaScript.
2025-06-17 12:57:33 -05:00
trompetin17
8d957ec91d
Remove hardcoded library linking pragmas from vorbis.h 2025-06-17 11:26:05 -05:00
trompetin17
ba67208b22
Remove zlib library linking pragma 2025-06-17 11:26:04 -05:00
trompetin17
c1751cd8e8
Remove libpng library linking pragma 2025-06-17 11:26:04 -05:00
trompetin17
cd4aebbb90
Remove unnecessary pragma comment for OpenAL 2025-06-17 11:26:03 -05:00
trompetin17
c375d9ba67
Add SDL2 linking configuration to premake 2025-06-17 11:26:03 -05:00
trompetin17
59ff5d912f
Add oleaut32 library support and remove unnecessary pragma comment 2025-06-17 11:25:54 -05:00
Mentula 0 A.D.
cb2717faba Add support for bird's eye camera view
A new hotkey "hotkey.camera.togglebirdseyeview" allows to switch
between regular view and bird's eye (top-down) view.

When bird's eye view gets toggled on, the camera moves above the scene;
When bird's eye view gets toggled off, the camera moves back to the
default vertical rotation angle;
When bird's eye view is on, vertical rotation is disallowed.
2025-06-16 20:01:07 +02:00
trompetin17
8e255af185
Fix mods configuration stacking and mergin per mod
Previously, the engine only loaded the last mod’s `config/mod.cfg` file,
causing earlier mods' configuration settings to be ignored. This broke
the expectation of stackable mod behavior and affected features relying
on custom config, such as font overrides.

This commit updates the mod mounting and configuration process to:

- Mount each mod's files before attempting to load its config.
- Reload each mod's `config/modname.cfg` via `g_ConfigDB.Reload(CFG_MOD)`
  after mounting.
- Merge configuration keys into the CFG_MOD namespace:
  - If a key exists, its value is updated.
  - If not, the key is added.

This behavior now aligns with the VFS override system, where later mods
take precedence but earlier mods still contribute.

Also adds `_test.mods` for validation.

Fixes edge cases for mod authors who rely on consistent and layered
configuration overrides.

Related: #6383, #1810
Fixes: #8060
2025-06-16 11:03:09 -05:00
Dunedan
bd15b87be6
Remove the limit of the available graph colors
Previously the number of graph colors was limited, which resulted in the
reuse of colors if many different profiling regions or reports were
displayed. This commit changes so unique colors are generated for
each region/graph, by utilizing the beauty of the golden ratio.
2025-06-16 08:17:38 +02:00
Dunedan
1a65267b83
Remove unnecessary hslToRgb() utility function
We can use the `hsl()` function provided by CSS directly in the
profiler2 UI, instead of using a custom utility function.
2025-06-16 08:16:34 +02:00
Dunedan
256e3819df
Use other composition for multiple graphs
"lighten" would result in a disappearing graph when too many graphs
overlapped, "exclusion" looks much better in this situation.
2025-06-16 08:16:24 +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
Langbart
e6ad1141fd fix(atlas): Fix ship placement in Atlas
- Changed the obstruction check to use the unit's passability class.
Ref: https://code.wildfiregames.com/rP16149

Fix: #8053
2025-06-15 19:24:49 +02:00
trompetin17
c0a3f2d885
Preload common glyphs after font load to reduce rendering delay
To improve visual consistency during dynamic font rendering, especially
on lower-end machines or during low FPS moments, we now preload a set of
common Latin letters, digits, and punctuation glyphs immediately after a
font is loaded by the FontManager.

This reduces the likelihood of users seeing empty or missing characters
on the first frame after a font is used, minimizing visual glitches
during simulation.

The preloaded characters include:
- Uppercase and lowercase Latin letters (A–Z, a–z)
- Digits (0–9)
- Common punctuation and symbols (e.g., .,;:!?()[]{}<> etc.)

This change helps smooth the user experience and avoids blank spaces
during the initial rendering of text in performance-constrained
scenarios.
2025-06-15 08:05:12 -05:00
Stan
03f7903fec
Make rallypoints moddable.
Allow use of {civ} tags in templates to simplify mod dependencies and inheritance.

Reviewed-On: #8038
Reviewed-By: @phosit
2025-06-15 07:43:08 +02:00