Commit Graph

116 Commits

Author SHA1 Message Date
Paul Chote
b29b685058 Rename Fluent-related code to be more precise. 2024-10-04 15:11:27 +03:00
RoosterDragon
0649f3dc32 RCS0056 - roslynator_max_line_length = 160 2024-07-29 21:56:36 +02:00
RoosterDragon
9d5d2ab493 RCS0056 - roslynator_max_line_length = 180 2024-07-29 21:56:36 +02:00
RoosterDragon
bd809e5af7 Prevent community mods from warning on unused translations in the common assets
Currently when linting translations, we check for any unused translation keys. This works fine for the default mods, which own the entire sets of translation files. For community mods, they often import the translation files from the common mod assets, but they may only use some of the translations provided. Currently, they would get warnings about not using translations from the common files they have imported.

Since the community mods don't own those translations, getting warnings about it is annoying. To solve this issue, introduce a AllowUnusedTranslationsInExternalPackages in the mod.yaml which defaults to true. This will prevent reporting of unused translation keys from external assets. Keys that are used for external assets will still be validated, and keys from the mod assets will be both validated and unused keys will be reported.

We default the new flag to true and don't provide an update rule. This means community mods will get the new behaviour. For the default mods, we do want to check the "external" assets, since we control those assets. So the default mods have their mod.yaml updated to disable the flag and retain the existing behaviour of checking everything.
2024-07-28 22:43:14 +03:00
chacha
e5a7b6e795 Do not keep map pakages loaded on Game start to reduce memory impact 2024-04-30 11:06:17 +03:00
RoosterDragon
b58c1ea5bc Provide names and pools when creating MiniYaml.
- Rename the filename parameter to name and make it mandatory. Review all callers and ensure a useful string is provided as input, to ensure sufficient context is included for logging and debugging. This can be a filename, url, or any arbitrary text so include whatever context seems reasonable.
- When several MiniYamls are created that have similar content, provide a shared string pool. This allows strings that are common between all the yaml to be shared, reducing long term memory usage. We also change the pool from a dictionary to a set. Originally a Dictionary had to be used so we could call TryGetValue to get a reference to the pooled string. Now that more recent versions of dotnet provide a TryGetValue on HashSet, we can use a set directly without the memory wasted by having to store both keys and values in a dictionary.
2024-01-21 12:39:10 +02:00
Paul Chote
b3ee3551ca Prevent incompatible maps from being displayed in the map chooser. 2023-11-05 15:42:35 +02:00
RoosterDragon
949ba589c0 MiniYaml becomes an immutable data structure.
This changeset is motivated by a simple concept - get rid of the MiniYaml.Clone and MiniYamlNode.Clone methods to avoid deep copying yaml trees during merging. MiniYaml becoming immutable allows the merge function to reuse existing yaml trees rather than cloning them, saving on memory and improving merge performance. On initial loading the YAML for all maps is processed, so this provides a small reduction in initial loading time.

The rest of the changeset is dealing with the change in the exposed API surface. Some With* helper methods are introduced to allow creating new YAML from existing YAML. Areas of code that generated small amounts of YAML are able to transition directly to the immutable model without too much ceremony. Some use cases are far less ergonomic even with these helper methods and so a MiniYamlBuilder is introduced to retain mutable creation functionality. This allows those areas to continue to use the old mutable structures. The main users are the update rules and linting capabilities.
2023-08-07 21:57:10 +03:00
RoosterDragon
f752e04b03 Fix CA1816 2023-06-20 17:57:40 +02:00
RoosterDragon
f4af5c1764 Fix CA1852 2023-06-06 11:51:47 +03:00
RoosterDragon
300281695a Deserialize mod rules only once when loading all maps.
This avoids loading, parsing and merging YAML rules for the mod during loading of each individual map. This saves significant time resolving custom rules on each map loaded.
2023-06-01 12:59:53 +02:00
Matthias Mailänder
55ff0ac1f4 Inline variables. 2023-04-25 21:33:02 +03:00
Matthias Mailänder
68eec52cef Add TranslationProvider 2023-04-22 19:23:41 +02:00
Gustas
a065e6a47c Fix map level lobby options not being translated 2023-04-22 19:23:41 +02:00
Gustas
efe135e38b Add Translations to MapPreview 2023-04-22 19:23:41 +02:00
RoosterDragon
164abfdae1 Fix IDE0083 2023-04-08 16:51:51 +03:00
Gustas
e4ba9733fe Add sequences linting to ingame lobby 2023-04-07 16:23:30 +01:00
RoosterDragon
bcfa0c9ae9 Review StyleCop rules.
- Enforce SA1604 ElementDocumentationShouldHaveSummary.
- Enforce SA1629 DocumentationTextShouldEndWithAPeriod.
- Turn off some rules covered by IDExxxx rules.
- Remaining rules are treated as part of OpenRA style.
2023-03-18 12:46:10 +02:00
Paul Chote
c35ab081ff Rewrite sequence loading logic.
Multiple layers of Lazy<T>ness are replaced with
an explicit two-part loading scheme.

Sequences are parsed immediately, without the need
for the sprite assets, and tell the SpriteCache
which frames they need. Use-cases that want the
actual sprites can then tell the SpriteCache to
load the frames and the sequences to resolve the
sprites.
2023-03-10 20:11:33 +02:00
RoosterDragon
ad122c8e32 When running a server, don't load minimap previews into memory. 2023-03-02 00:13:46 +02:00
abcdefg30
5bf7fe852c Remove the copyright year numbers 2023-01-11 11:58:54 +02:00
Matthias Mailänder
19ecddcd86 Enforce use of 'var' instead of explicit type. 2022-12-28 23:02:04 +01:00
ThomasChr
a3f8b41e25 Add dropdown for sorting maps in map chooser dialog 2022-11-01 12:08:01 +02:00
Gustas
c40675cfba Include map.png into uid generation 2022-08-30 20:03:40 +02:00
abcdefg30
6a31b1f9f3 Update the copyright header year 2022-05-28 00:35:10 -05:00
Eduardo Cáceres
cae43808d9 Optimize string comparison 2022-05-18 11:42:36 -05:00
Eduardo Cáceres
79f321cb44 .Any(), .Count() -> .Count or .Length 2022-05-18 11:42:36 -05:00
Matthias Mailänder
af3362c62f Use string.Contains(char) instead of string.Contains(string)
with single characters
2022-04-13 20:09:57 +02:00
RoosterDragon
9cd55df584 Ensure editorconfig naming styles align with StyleCop SA13XX style rules.
Aligns the naming conventions defined in editorconfig (dotnet_naming_style, dotnet_naming_symbols, dotnet_naming_rule) which are reported under the IDE1006 rule with the existing StyleCop rules from the SA13XX range.

This ensures the two rulesets agree when rejecting and accepting naming conventions within the IDE, with a few edges cases where only one ruleset can enforce the convention. IDE1006 allows use to specify a naming convention for type parameters, const locals and protected readonly fields which SA13XX cannot enforce. Some StyleCop SA13XX rules such as SA1309 'Field names should not begin with underscore' are not possible to enforce with the naming rules of IDE1006.

Therefore we enable the IDE1006 as a build time warning to enforce conventions and extend them. We disable SA13XX rules that can now be covered by IDE1006 to avoid double-reporting but leave the remaining SA13XX rules that cover additional cases enabled.

We also re-enable the SA1311 rule convention but enforce it via IDE1006, requiring some violations to be fixed or duplication of existing suppressions. Most violations fixes are trivial renames with the following exception. In ActorInitializer.cs, we prefer to make the fields private instead. ValueActorInit provides a publicly accessible property for access and OwnerInit provides a publicly accessible method. Health.cs is adjusted to access the property base instead when overriding. The reflection calls must be adjusted to target the base class specifically, as searching for a private field from the derived class will fail to locate it on the base class.

Unused suppressions were removed.
2022-02-07 19:14:45 +01:00
penev92
0d24ccc47a Fixed unnecessary zero-length array allocations
Changed all currently present zero-length array allocations in the codebase to use `Array.Empty` instead.
2022-01-20 22:10:28 +01:00
Matthias Mailänder
07815143f1 Fix CA1825 warnings on empty array initialisation. 2021-12-06 13:19:28 +01:00
Andre Mohren
6810469634 Updated copyright years. 2021-06-29 18:33:21 -05:00
teinarss
10676be377 Replace F extension with string interpolation 2021-05-08 22:20:59 +02:00
Paul Chote
bb8a634ba8 Fix map installation. 2021-04-21 18:57:44 +02:00
Paul Chote
f9294f0e9e Enable dedicated server lint checks. 2021-04-21 18:57:44 +02:00
Paul Chote
9770967b04 Optimize MapPreview rule loading. 2021-04-21 18:57:44 +02:00
Paul Chote
0bbb32e8ac Rework MapPreview custom rule handling.
The previous asynchronous approach did not work particularly well,
leading to large janks when switching to custom maps or opening the
mission browser.

This commit introduces two key changes:

 * Rule loading for WorldActorInfo and PlayerActorInfo is made
   synchronous, in preparation for the next commit which will
   significantly optimize this path.
 * The full ruleset loading, which is required for map validation,
   is moved to the server-side and managed by a new ServerMapStatusCache.
   The previous syntax check is expanded to include the ability to run
   lint tests.
2021-04-21 18:57:44 +02:00
Paul Chote
abee274f88 Remove direct access to MapPreview.Rules. 2021-04-21 18:57:44 +02:00
Paul Chote
d52ba83f96 Replace terniary null checks with coalescing. 2021-03-08 18:11:25 +01:00
teinarss
7073279ab8 Replace WebClient with HttpClient 2021-03-07 16:04:57 +00:00
teinarss
4a1e4f3e16 Use expression body syntax 2021-03-07 13:00:52 +00:00
RoosterDragon
8fb65fd9bf Use string pooling in MiniYaml to de-duplicate strings in memory.
These config files often contain many repeated strings which result in different string references in memory. By using a pool, we can detect when the strings are equal and reuse an existing reference as strings are immutable.

The FromLines will now use a pool to de-duplicate strings for a single call. By allowing a pool to be provided as a parameter, we can reuse even more strings. The MapCache defines such a pool so that strings are reused across all maps in the cache for even more savings.
2020-10-12 21:57:08 +02:00
teinarss
9c4fd0e3d3 Use Null-Propagation Operator 2020-08-19 18:11:07 +01:00
teinarss
27f1a7ab27 Use out var syntax 2020-08-19 18:11:07 +01:00
teinarss
19b02875c7 Use Tuple syntax 2020-08-15 10:37:10 +01:00
Paul Chote
c6c3a8c60d Make ActorPreview and EditorActorPreview wrap ActorReference. 2020-06-19 17:57:56 +02:00
Paul Chote
7c6ec577dc Rewrite ActorInit queries. 2020-05-28 19:04:53 +02:00
abcdefg30
23b3c237b7 Update the year numbers in all license headers to 2020 2020-01-05 17:00:34 +00:00
Paul Chote
ab4a7e3558 Replace System.Drawing primitives with our own. 2019-03-04 18:26:42 +00:00
abcdefg30
cadbd0d9ab Change the year number in all cs headers from 2018 to 2019 2019-01-26 23:15:21 +01:00