Commit Graph

7575 Commits

Author SHA1 Message Date
Paul Chote
b40b67242f Fix FlashPostProcessEffect channel order. 2025-03-18 14:09:30 +02:00
Ashley Newson
37e5b0d74c Fix CnC generated map oceans becoming debris-filled
Water is not playable in CnC, so, the map generator may fill it in if
it's not attributed to the largest playable region. This would often
happen for circular-in-water maps when DenyWalledAreas is enabled.

This change adds a step to adopt any neighboring partially playable
space (such as beaches and water) into the largest region, which is
exempt from debris filling.

The change is almost purely cosmetic, though the previous debris filling
could slightly reduce playable space (due to filling playable beach
tiles), possibly causing generation to fail. As such, map generation is
now a very tiny bit more reliable.
2025-03-18 13:58:04 +02:00
RoosterDragon
cf3e213e7d Harvesters prefer ore near to the refinery.
When searching for ore, harvesters will prefer ore close to their refinery, the dockPos. However this only works when this is set, and is was not being set when expected. Fixing this prevents harvesters moving in straight lines, particularly when the ore is to the left of the refinery, which is the default path search direction.

Fixes a regression from d0974cfdd2.
2025-03-16 10:39:15 +00:00
Gustas
f679bb1e2e Fix a potential crash when cancelling capture 2025-03-16 10:29:34 +00:00
Paul Chote
9913ecb42f Remove save dialog when creating a new map. 2025-03-05 09:31:11 +02:00
Paul Chote
e186dc428e Rework MapCache API.
This clarifies the ownership of the underlying
IReadOnlyPackage objects, and avoids passing
around some unnecessary state.
2025-03-05 09:31:11 +02:00
Paul Chote
e06d74b417 Simplify map generator naming. 2025-03-04 09:05:59 +02:00
Paul Chote
ab3b6a0e43 Cache Fluent queries. 2025-03-04 09:05:59 +02:00
Paul Chote
e022744b0a Remove Map requirement from IMapGeneratorInfo.GetSettings. 2025-03-04 09:05:59 +02:00
Paul Chote
23b7b56c28 Combine IMapGenerator interfaces.
This removes the need to instantiate a dummy
trait instance and is more idiomatic.
2025-03-04 09:05:59 +02:00
RoosterDragon
db90cfb259 Show current pan behaviour & zoom modifier in input settings.
Fixes regression from 0338258b45.
2025-03-02 11:04:05 +02:00
Paul Chote
541cf3b720 Sanitize saved skirmish factions. 2025-02-22 15:31:51 +02:00
RoosterDragon
0338258b45 Fix IDE0200 2025-02-22 14:56:25 +02:00
RoosterDragon
ce3ad6fbb3 Some improvements for SpatiallyPartitioned.
- Tweak the Update and Remove methods to reduce the number of dictionary lookups required.
- Change the Update method to an indexer, this allows simplifying callers who wanted to AddOrUpdate a value.
- Implement IDictionary<T, Rectangle>, since the class already implements these semantics by providing a backing store of the bounds for each item.
- Clean up some naming to use the generic `item` instead of `actor`.
- Make the MutateBins action methods static.
2025-02-22 14:50:15 +02:00
RoosterDragon
1b2c119b58 Fix RCS1257, RCS1258, RCS1261, RCS1262, RCS1265, RCS1266, RCS1267 2025-02-22 14:35:57 +02:00
RoosterDragon
715d882456 Update LangVersion to C# 12.
Now that we have moved to net 8 from net 6, and with us no longer supporting the mono runtime, we can raise the C# version to match that supported by the net 8 runtime.

This unlocks C# 10, C# 11 and C# 12 features previously unavailable to us.
- https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history#c-version-10
- https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history#c-version-11
- https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history#c-version-12

A newer version of StyleCop is required to avoid rules tripping up on the new syntax.

Enable a handful of style rules that don't have many violations.
2025-02-20 12:54:12 +02:00
Ashley Newson
39a7e477c6 Add tooltips to some map generator settings
Adds tooltip descriptions for a few map generator settings. The tooltips
are limited to dropdown choices. No tooltips are added for the options
containing the choices or any non-dropdown settings.

- Terrain type
- Bounds shape
- Buildings

The "Square" bounds shape is rephrased as "Rectangle" for consistency
with the added description.

This is UI-only change.
2025-02-20 12:49:16 +02:00
Gustas
6ac33befe5 Adjust to a 4 space standard 2025-02-19 20:50:36 +00:00
RoosterDragon
cfde11556f Enable Net 7 and Net 8 style rules. 2025-02-16 20:01:50 +02:00
RoosterDragon
96de59f75a Run spell check over solution. 2025-02-16 12:45:19 +01:00
Gustas
ebf90970b2 Re-add a mini lobby options menu to missionbrowser 2025-02-16 12:39:23 +01:00
RoosterDragon
639dc7c288 Fix a bad comparison against Target.Invalid.
Target.Invalid acts like a NaN, and will not compare equal with itself. Compare against the TargetType instead, which performs the intended comparison.
2025-02-15 13:22:23 +00:00
Gustas
bcbf88719f Upgrade NuGet packages 2025-02-15 08:56:24 +00:00
michaeldgg2
81aa068b15 Upgrade to .NET 8.0 and remove/migrate obsolete stuff 2025-02-15 08:56:24 +00:00
michaeldgg2
2a3ef8f910 Drop win-x86 build 2025-02-15 08:56:24 +00:00
Ashley Newson
98fe3c98ab Refine civilian building placement and multibrushes 2025-02-11 12:57:04 +02:00
Ashley Newson
cc632660eb Add decorative civilian buildings to random maps
Allows the random map generator to optionally place civilian buildings
around the map for extra decoration. Buildings are placed last with
lowest priority to avoid competing for play area and resources.

Depends on #21738
2025-02-11 12:57:04 +02:00
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