Commit Graph

25959 Commits

Author SHA1 Message Date
Fabio Pedretti e4e50d7711 MapReader: Reject maps with out-of-range terrain tile texture index
m_Tex1Index is unvalidated (raw .pmp bytes / RMS script) and was used
to index m_TerrainTextures with no bounds check.
2026-08-29 16:19:08 +02:00
phosit d37db2ba07 Remove CStr::ReverseFind
It was only used once. In this case a normal `std::string::find` can be
used.
2026-08-28 09:50:01 +02:00
phosit 89c7aa47ce Remove CStr functions related to std::u16string
It wasn't used. The conversion to `std::u16string` wasn't even defined.
2026-08-28 09:50:01 +02:00
phosit 73d043fde5 Remove CStr::Pad
It was only used once. It can be replaced by fmt.
2026-08-28 09:50:01 +02:00
ShadowOfHassen aa86258751 Added ruins 2026-08-27 11:07:53 +02:00
ShadowOfHassen 14f9c9aaff Add treasure history entries 2026-08-27 11:07:53 +02:00
ShadowOfHassen a6b1318164 Add generic text attribute to credit json parser 2026-08-27 11:07:53 +02:00
Lancelot de Ferrière 2cc0cf457a Fix the callers of GetEffectiveAttackRange's out-of-reach range
Follows db23584fc3 - the caller of GetEffectiveAttackRange's didn't
really use the NEVER_IN_RANGE result properly.
The C++ engine does not handle Infinity (treated as 0).
This also changes MoveToTargetAttackRange to explicitly try to get
closer if the parabolic range is not in range, but it seems like a flat
range could - on the assumption that once we get closer, the terrain
height difference is lower.
2026-08-26 10:55:27 +02:00
Lancelot de Ferrière 56f94a6d4d Prevent div by zero in GetMaxReachableParabolicHeight
Introduced by fc3c0d7876.
2026-08-26 10:55:27 +02:00
Lancelot de Ferrière 2c699c29cc Fix integer overflow in GetMaxReachableParabolicHeight
range.GetInternalValue() is an i32; multiplying it by 2 before the cast
to i64 could overflow instead of widening, corrupting the divisor. Cast
to i64 first.
2026-08-26 10:55:27 +02:00
Lancelot de Ferrière ce119cd461 Fix towers firing at targets they cannot reach
Since 38b33b0484, the range check happened in CanAttack, however the
check there is too permissive.
This meant it was possible for towers to attack certain targets outside
their actual range, depending on the query results and unit AI focus
fire.
2026-08-26 10:55:27 +02:00
Lancelot de Ferrière d60e36c74a Remove unused BuildingAI.CheckTargetVisible
FireArrows now checks range/visibility via CanAttack directly (see next
commit), leaving this method unused.
2026-08-26 10:55:27 +02:00
Lancelot de Ferrière 63b0f05b43 UnitAI: keep chasing on forced orders.
Following 38b33b0484, units on aggressive stance no longer chase beyond
their own vision, including on player-forced orders. This fixes that
regression.
(Note that approaching and chasing are a bit inconsistent).
2026-08-26 10:55:27 +02:00
Lancelot de Ferrière cb6f46db71 UnitAI: Simplify GetQueryRange and fix issues
38b33b0484 partly rewrote GetQueryRange but ended up with two
bugs/regressions:
- in standGround, melee units used an effective max-range of 0 instead
  of their melee attack max range
- units that have a min-range did not see units within their min-range
  (even though they can move).

This fixes these issues and rewrite the function in a simpler fashion
for readability.
2026-08-26 10:55:27 +02:00
Lancelot de Ferrière 3cbcb69e7f Fix Gaia units never finding anything to attack
38b33b0484 added a visibility filter to TestEntityQuery, active whenever
a query sets preferMirages - which UnitAI's attack range query does.
However, those filters do not work for Gaia, and so the query never
returned anything.
2026-08-26 10:55:27 +02:00
Fabio Pedretti 4d721fdab2 RangeManager: Fix off-by-one bounds check in GetLosRevealWholeMap() 2026-08-25 17:47:49 +02:00
Fabio Pedretti 3836f4ea8e Lobby: Fix XmppClient.h include guard typo 2026-08-24 21:36:09 +02:00
Fabio Pedretti d5af8a97c1 Lobby: Remove dead if(true)/else in GuiPollNewMessages()
This is dead since 6fbf036ae4
2026-08-24 21:36:09 +02:00
phosit 058cdf78d9 Remove CStr::Right
It was only a wrapper around `std::string::substr`. The interface
matches the usecase more. In some places it's better to use
`std::string::ends_with`.
2026-08-24 14:05:00 +02:00
phosit 60824e77b9 Remove CStr::Left
It was only a wrapper around `std::string::substr`. In some places it's
better to use `std::string::starts_with`.
2026-08-24 13:34:37 +02:00
phosit d8bb617962 Remove CStr::Find(int, char)
It was only a wrapper around `std::string::find`. It is unused.
2026-08-23 17:47:02 +02:00
phosit 5071b27bb1 Remove CStr::Find(char)
It was only a wrapper around `std::string::find`. It is only used once.
2026-08-23 17:47:02 +02:00
phosit 982ede2a55 Remove CStr::Find(CStr)
It was only a wrapper around `std::string::find`. In some places it's
now better to use `std::string::starts_with`.
2026-08-23 17:46:52 +02:00
phosit 45ea0432a2 Remove CStr::FromDouble
In most places `fmt::format` is used because it's locale indidendant.
For the user reporter the locale dependant form of `fmt::format` is used
because it's shown to the user.
2026-08-23 12:01:33 +02:00
obelix e4b72711e6 Add proper SpecificNames to germ heroes
Proposed by @Vantha, elaborated by @Genava55:
https://wildfiregames.com/forum/topic/140675-more-ai-names-for-the-germans/?do=findComment&comment=618302

Refs: #8755
2026-08-23 02:22:15 +02:00
obelix 95ca5cebb6 Fix grammar for GenericName of germ Catafalque
Reported by @Vantha

Refs: #8755
2026-08-23 02:22:15 +02:00
joeybadz 74e1f088a0 Reduce serialization footprint in ResourceGatherer
Avoids serializing fields that can be derived at deserialization time to save serialization space

Fixes: #7263
2026-08-22 18:18:38 +02:00
phosit 7892a4f40f Fix "I will return" button
When temporarly leaving a multiplayer game the "I will return" button
didn't work. This was because there was no valid `closeSession`.
Since it requires accessing `this` the function can't be an arrow
function anymore.

Introduced in 2520c45220

Fixes: #9086
2026-08-20 21:35:18 +02:00
joeybadz 478acbdf5c Reconcile Teutobod's speed bonus and tooltip values
Updates the tooltip to match the actual speed bonus

Fixes #8864
2026-08-19 19:49:42 -04:00
Lancelot de Ferrière 4e04ccca4d UnitAI: properly follow queued return resources orders
GATHER.FINDINGNEWTARGET inserts a ReturnResource order ahead of the
next queued order when the unit is still carrying resources, but
skips doing so if the next order already returns those resources.
Unfortunately, the check was incorrectly written, missing a `.type`.
This meant we always added a fresh order.

Units could then sometimes return resources to the closest dropsites,
then move to the actually queued dropsite, which could lead to
unexpected pathing.

Introduced in 0dda3b579c where the feature was added.
2026-08-19 11:15:27 +02:00
joeybadz 2add365a4f Add camera view config options
Adds a variety of settings for the camera: scroll speed, zoom speed, smoothness, etc.

Fixes #4638
2026-08-19 04:19:45 +02:00
Lancelot de Ferrière 8acec374be Fix a ModifiersManager bug when changing player entities
The cache invalidation was incorrectly using forEach, which failed to invalidate the cache.
This never actually caused a bug because the game currently does not silently swap active player entities.
2026-08-16 17:37:51 +02:00
Fabio Pedretti 811ef65126 Fix: Correct control group iteration in ResolveFoundationCollisions
In `CCmpObstruction::ResolveFoundationCollisions`, the nested loop
intended to assign a persistent control group to colliding normal
entities was incorrectly iterating over `normalEnts` instead of
`persistentEnts`.

This caused the function to attempt to clobber default control groups
with other non-persistent groups, completely bypassing the intended
`ControlPersist` logic.

This patch fixes the inner loop to correctly iterate over
`persistentEnts`, ensuring foundations properly inherit persistent
control groups.

Fixes: 9ae084519f
2026-08-16 13:30:42 +02:00
phosit 6ffc251114 Make timedconfirmation.js a module
Refs: #8081
2026-08-14 12:41:45 +02:00
phosit 0f939b8abf Make termsdialog.js a module
Refs: #8081
2026-08-14 12:41:45 +02:00
phosit bf0c3af75a Make mod/gui/pregame/mainmenu.js a module
Refs: #8081
2026-08-14 12:41:45 +02:00
phosit 497efe5a99 Make msgbox.js a module
Refs: #8081
2026-08-14 12:41:45 +02:00
phosit 609efa7e32 Make modmod/help/help.js a module
Refs: #8081
2026-08-14 12:41:44 +02:00
phosit 9adb3e7889 Make modmod.js a module
Actions in xml files only has access to the global scope, not the module
scope. So define them in the js file.

Refs: #8081
2026-08-14 12:41:44 +02:00
phosit 2c4f7d85b6 Make modio.js a module
Actions in xml files only has access to the global scope, not the module
scope. So define them in the js file.

Refs: #8081
2026-08-14 12:41:44 +02:00
phosit 8918cfb0a7 Make incompatible_mods.js a module
Refs: #8081
2026-08-14 12:41:44 +02:00
Atrik 1b07b799ec Add test for queries with visibility checks 2026-08-12 22:40:59 +02:00
Atrik 38b33b0484 Enable attacks on foes visible through shared LOS
Adds baseRange parameter to parabolic queries for combined
2D + parabolic detection. StandGround and Chase stances now
use attack range (parabolic) with vision as baseRange, allowing
units to attack enemies visible through friendly vision.
Buildings benefit as well via BuildingAI.
2026-08-12 22:40:59 +02:00
Atrik ceca608848 Filter out hidden targets in CanAttack
Units should not be able to attack entities with "hidden" visibility.
Visible and fogged (mirage/retainInFog) targets remain attackable.
2026-08-12 22:40:59 +02:00
Atrik f84b51212a Add tests for CanEverReachTarget and its helpers 2026-08-12 22:40:59 +02:00
Atrik fc3c0d7876 Prevent targeting unreachable turreted entities
Introduce CanEverReachTarget in the Attack component to check whether
a target is geometrically reachable at all, accounting for height
offsets and turreted units inside buildings.

For non-parabolic attacks (e.g. melee), a simple 3D distance check
from the closest approach point is used.

For parabolic attacks (e.g. ranged), the parabolic range formula
is used to determine if the height difference is surmountable
from the closest horizontal distance to the target.

Add GetClosestApproachDistanceToTurretPoint to TurretHolder
to estimate the minimum horizontal distance to a turret point,
using its local offset and the holder's obstruction size.
Passable buildings are not considered obstacles.

Fixes units on the ground trying to attack unreachable units on walls
or towers when the projectile's arc cannot reach the required height.
2026-08-12 22:40:59 +02:00
Atrik db23584fc3 Add GetEffectiveAttackRange wrapper
Wraps RangeManager.GetEffectiveParabolicRange for unified range
resolution. Maintains symmetry with GetRange(), improves readability,
and consistently translates NEVER_IN_RANGE.

Simplifies callers in UnitAI and Attack.
2026-08-12 22:40:59 +02:00
Atrik f12975e9b9 Fix range target detection for StandGround stance
StandGround units now use parabolic range queries to detect enemies,
accounting for terrain elevation and height offsets. This ensures
units on hills or when 'turreted', can detect enemies
that are in parabolic range but outside flat range.

Previously, StandGround detection used flat circular queries,
causing units to miss enemies in their elevation-buffed range.
Other stances are unaffected since they chase targets anyway.
2026-08-12 22:40:59 +02:00
Atrik 2bc895bf0d Rename cmp to rangeManager for clarity 2026-08-12 22:40:59 +02:00
Atrik 3c215aff47 Add some tests for GetEffectiveParabolicRange 2026-08-12 22:40:59 +02:00