Commit Graph

7548 Commits

Author SHA1 Message Date
Ashley Newson
1f65fd234b Use long in CellLayerUtils.CalibrateQuantileInPlace index calculation
This is similar to #21727, but in CellLayerUtils instead of MatrixUtils.
Note that the lack of long does not result in any overflows/crashes in
existing code, but can cause crashes for new features requiring larger
calculations.
2025-02-08 14:11:05 +02:00
JovialFeline
052c74e2d7 Add Lua documentation details 2025-02-08 14:02:12 +02:00
Ashley Newson
611ac8ce54 Add fuzzer for map generator testing
Adds a fuzzer that iterates through map generation settings combinations
to either discover crashes or measure the frequency of rejected maps.

All generated maps are in-memory only and discarded immediately after
generation.

Running the fuzzer on anything other than a small combination of
settings is time expensive. It is added only as a utility for manual
invocation and is not integrated into the regular set of tests.
2025-02-06 14:23:01 +02:00
Ashley Newson
c6d5a1a182 Yield focus for map generator text settings
Makes any selected text-based map generator settings (currently just the
seed input) yield keyboard focus when the user presses escape or enter.
2025-02-06 14:06:04 +02:00
Gustas
09259be796 Match the check inside .CenterPosition 2025-02-01 20:31:07 +00:00
Gustas
409efe7f4a Allow tileset to be entered in lower case 2025-02-01 20:22:43 +00:00
Gustas
56109b0ca1 Fix bot harvesters crashing 2025-02-01 17:39:40 +02:00
Ashley Newson
1fda679b9f Refine map generator spawn placement rules
Spawn generation generally tries to place spawns:

- In spacious areas
- Away from the center (true center or mirror lines)
- Away from a symmetry-projected spawn
- Away from previously placed spawns

This commit introduces the following adjustments:

- The spacing between sequentially placed spawns is relaxed.
- Fix spawn mines contributing too much to the space reservation.
- Factor rotations into anti-center biasing calculation.
- Preserve spacing information in center space fallback decisions.
- Use a linear (instead of binary) falloff for anti-center biasing.
- Enforce that spawns have a minimum buildable area around them.
- Enforce that symmetry-projected spawns have as much separation as
  sequentially placed spawns would.
- Allow spawns on or near roads.
2025-01-31 13:58:20 +02:00
Ashley Newson
cdbcfb9e20 Fix illegal ore rings popping up around spawns in generated maps
Reorders and groups selective clearing of the resource placement plan to
-int.MaxValue to avoid subsequent code from inappropriately trying to
use it in arithmetic, which may just underflow to some completely wrong
value and lead to resources in illegal places.
2025-01-29 13:34:49 +02:00
Ashley Newson
19585ec7ac Fix overflow when calculating array quantile index
Fixes a crash which happens when trying to generate very large maps,
such as 256x256.

```
Exception of type `System.IndexOutOfRangeException`: Index was outside the bounds of the array.
   at OpenRA.Mods.Common.MapGenerator.MatrixUtils.CalibrateQuantileInPlace(Matrix`1 matrix, Int32 target, Int32 count, Int32 outOf) in /home/ashley/devel/OpenRA/OpenRA.Mods.Common/MapGenerator/MatrixUtils.cs:line 719
   at OpenRA.Mods.Common.Traits.RaMapGenerator.Generate(Map map, MiniYaml settings) in /home/ashley/devel/OpenRA/OpenRA.Mods.Common/Traits/World/RaMapGenerator.cs:line 755
...
```
2025-01-28 22:10:52 +02:00
Ashley Newson
037326024b Remove floating points from map generation
Removes all use of floating point from the RaMapGenerator map generator
and its dependencies.

Floating point behavior is potentially non-portable across client
hardware. Removing them should make the map generation logic
consistent even across clients with different floating point hardware
or compiler behavior. This may be useful for sync-safe multiplayer map
generation where clients independently generate the map from settings.

Most previously fractional public-facing settings are now represented
as numbers out of 1000, with some exceptions using 1000000. Most
internal logic which relies on fixed-point concepts now uses 1024ths,
though some floating point mechanisms have been replaced with
alternative discrete approximations (e.g. gaussian to binomial).
2025-01-27 20:42:38 +02:00
Ashley Newson
04e9cef38e Fix bounding of circle drawing in CellLayerUtils
Previously, only the RectangularIsometric case was handled, despite
this currently only being used in Rectangular mode. Additionally,
the calculation was slightly off.
2025-01-27 14:17:47 +02:00
Ashley Newson
2126f3c5a2 Add CnC map generator support
Adds map generator support for CnC (all tilesets), largely on par with
RA.

Most tilesets do not have a complete set of beach templates and
therefore do not support terrain settings involving water. DESERT is the
only tileset supporting water. Unlike in RA, water is not playable space
in CnC (no naval units), so only terrain settings with small bodies of
water are available.

Most changes are configuration (tileset and map generator config), with
just a small number of code changes.
2025-01-20 12:55:36 +02:00
Ashley Newson
9d77ca2bf8 Generate more elaborate roads
Updates the random map generator to produce more elaborate roads:

- Roads extend beyond map bounds.
- Shorter, unviable roads are pruned and merged to create longer roads.
- Roads can loop.
2025-01-18 13:32:56 +02:00
Pavel Penev
dfa922de91 Pulled out shared code from documentation commands 2025-01-17 18:09:02 +02:00
Pavel Penev
c66f63805a Added types for Utility documentation output 2025-01-17 18:09:02 +02:00
Pavel Penev
f2e582ce83 Moved documentation utility commands to a folder 2025-01-17 18:09:02 +02:00
Dan Stoian
e903baf680 Implement auto-save 2025-01-17 18:01:20 +02:00
Ashley Newson
dc4c596fa0 Fix an out-of-bounds CellLayer access in RaMapGenerator
Adds a bounds check for the water obstruction code, where a rotation
projection can be outside of the map area (on rotations other than
1, 2, or 4.)
2025-01-16 12:56:44 +02:00
Paul Chote
b9adbf8089 Only expose Facing for actors that define a facing. 2025-01-15 18:07:10 +02:00
Paul Chote
427e56d718 Only expose Location and CenterPosition for actors that occupy space. 2025-01-15 18:07:10 +02:00
RoosterDragon
aa121dcb2f Use covariant return types.
Use the covariant return type feature of C# 9 to allow method overrides to be more specific about their return type. By exposing this information, e.g. for Widget.Clone(), callers will have more information. This allows various casts to be removed as the information is now available within the type system.
2025-01-15 17:29:02 +02:00
Ashley Newson
9c568aba33 Fix map generator failures due to broken TilingPath edge extension
Coastlines and cliffs at the edge of a map should have been getting
extended beyond the map edge help them tile reliably. This was not
happening due to a conditional that accidentally got inverted during a
refactor.

Fixing the conditional makes beach and cliff tiling significantly more
reliable. (Note that there is no effect on road tiling.)
2025-01-15 17:23:41 +02:00
Ashley Newson
417f787294 Add experimental RA procedural map generator
Add an experimental procedural map generator for the Red Alert mod,
along with supporting code that may assist in the development of map
generators for other mods.

Map generation may be accessed as a tool in the Map Editor. This change
does not presently introduce direct lobby options for generated maps.

Features:

- Terrain with land, water, beaches, cliffs, roads, debris, and trees.
- Placement of mpspawns, neutral buildings, and resources.
- Rotational and mirror symmetry options.
- Various configurable parameters with presets.
- Deterministic with configurable seed.
- Performant.
2025-01-09 16:47:10 +02:00
louxia
0536c58b78 Avoid units continuing to follow the unattackable targets 2025-01-08 21:45:44 +02:00
Paul Chote
711055a3bc Add filenames to Trait/Weapon/SpriteSequence docs metadata. 2025-01-07 19:21:29 +02:00
michaeldgg2
c7cc9a68fd Eradicate ☠ Mono ☠
Co-Authored-By: Gustas <37534529+punkpun@users.noreply.github.com>
2025-01-07 18:07:13 +02:00
Paul Chote
5450572e0a Allow maps to override the player viewport size. 2025-01-06 23:57:08 +02:00
Gustas
8b4478260e Raname GrantConditionOnDeployWithCharge to GrantChargedConditionOnToggle
Also allow deploying without cancelling current activity, and make saboteurs use it
2024-12-27 16:37:49 +02:00
Gustas
d9cfb2c278 Cancel movement in invalid states 2024-12-27 16:30:38 +02:00
Gustas
1904012604 Fix harvesters refusing to queue dock orders whenn empty 2024-12-27 16:30:38 +02:00
Pavel Penev
955bf96a84 Added descriptions to ContentInstallerFileSystemLoader 2024-12-21 16:01:21 +02:00
Gustas
f820adab51 Add delete button to the map editor 2024-12-20 23:56:56 +02:00
Gustas
48d5b3c8d9 Update extractors to preserve indentation 2024-12-20 22:00:21 +02:00
RoosterDragon
0051d6fd63 Fix BaseBuilderBotModule.LocomotorsForProducibles.
Account for per-actor production (e.g. ProductionQueue) and per-player production (e.g. ClassicProductionQueue). This requires resolving the Production and ProductionQueue traits on both the producing actor, and the owning player actor.

When setting rally points, check the actor didn't die first.
2024-12-19 19:36:28 +02:00
Gustas
2a1eeae7ca Reduce the size of battlefield news when messages are short 2024-12-19 18:16:07 +02:00
Gustas
43325fdee7 Fix Package 'NuGet.CommandLine' 4.4.1 has a known moderate severity vulnerability 2024-12-12 16:00:19 +02:00
Mustafa Alperen Seki
087aebe058 Fix broken condition support for InstantlyRepairable. 2024-12-12 00:30:01 +02:00
RoosterDragon
bf7f81b7fe Improve some String.Split calls. 2024-11-15 22:28:18 +02:00
RoosterDragon
e2296ad2d1 Fix CA2263 2024-11-15 22:28:18 +02:00
RoosterDragon
332ab244a7 Fix CA1862 2024-11-15 22:28:18 +02:00
RoosterDragon
ed90322a0b Fix IDE0032 2024-11-15 22:28:18 +02:00
RoosterDragon
9809f6ed08 Add new .NET 9 rules to editorconfig.
Don't enforce all the rules yet, since we are still targeting .NET 6.

Adjust cast to nullable in UnloadCargo.ChooseExitSubCell. Avoid this cast tripping up CA2021 on older NET SDK versions.
2024-11-15 22:28:18 +02:00
Ashley Newson
7401182a1b Refactor editor clipboard logic as blitting logic
- Refactors internal editor clipboard logic into reusable map contents
  "Blitting" functionality.
- Fix actor processing being unnecessarily (cell) looped within
  CopySelectionContents (now CopyRegionContents).
- Deduplicates largely repeated code.
- Minor code simplifications and renames.
2024-11-15 19:18:38 +02:00
Paul Chote
feef5be143 Allow mods to override Encyclopedia preview owners. 2024-11-03 17:19:30 +02:00
Paul Chote
f805d67741 Allow mods to display Encyclopedia production info. 2024-11-03 17:19:30 +02:00
Paul Chote
497251c0eb Allow mods to display Encyclopedia portraits. 2024-11-03 17:19:30 +02:00
Paul Chote
c111cea7fc Allow mods to display Encyclopedia titles in description panel. 2024-11-03 17:19:30 +02:00
Paul Chote
eff4c66410 Allow Encyclopedia entries to scale the actor preview. 2024-11-03 17:19:30 +02:00
abcdefg30
78e47ea70a Support using player palettes as effect palette for SpawnActorPower 2024-11-03 17:02:00 +02:00