Compare commits

...

2059 Commits

Author SHA1 Message Date
Matthias Mailänder
22a42b7dc9 Manually add game speeds to the linter. 2022-11-18 23:14:54 +01:00
Gustas
c01e4043e8 Introduce MinDistance to AreaBeam projectile 2022-11-17 20:51:28 +01:00
Thomas Christlieb
c8665c98a6 fix misclicks through sidebar 2022-11-16 23:22:39 +01:00
abcdefg30
e54b88a6cb Remove dead code inside SupportPower.cs 2022-11-16 20:45:33 +02:00
RoosterDragon
b8a71215eb Fix Locomotor IsMoving checks.
The Locomotor IsMoving check was allowing us to consider another actor that moving as not a blocker. However for some reason it also considered the actor trying to path being mobile as sufficient for this check to pass which did not make sense. We remove that extra check and inline the method.

This was a regression from 4a609bbee8 which changed the method from IsMovingInMyDirection (which required the lookup of the mobile trait) to just IsMoving. It should have removed the lookup as not required.

This fixes a crash in HPF which was considered the location as blocked when Locomotor considered it unblocked because the logic was not aligned. Removing this check aligns the logic and resolves the crash.
2022-11-15 15:42:02 +02:00
Vapre
7005da3592 SpriteRenderer, do not copy vertex array data each flush. 2022-11-14 23:33:24 +01:00
Gustas
243e2b2a2a Fix cloned widgets not having default cursor set 2022-11-13 15:05:48 -06:00
RoosterDragon
a85ac26367 Pathing considers reachability of source cells consistently.
Using the local pathfinder, you could not find a path to an unreachable destination cell, but it was possible to find a path from an unreachable source cell if there was a reachable cells adjacent to it.

The hierarchical pathfinder did not have this behaviour and considering an unreachable source cell to block attempts to find a path.

Now, we unify the pathfinders to use a consistent behaviour, allowing paths from unreachable source cells to be found.
2022-11-13 19:59:36 +01:00
abcdefg30
bedfa622d7 Update AUTHORS 2022-11-12 07:57:12 +01:00
Gustas
0b86936dcd Nerf player experience 2022-11-10 23:33:52 +01:00
ThomasChr
6c348620f3 Use Stop button on (production) buildings to reset rally point fixes #20414 2022-11-09 08:44:09 +02:00
Gustas
ad269555d9 Don't let the player interrupt takeoff after a succesful caryall pickup 2022-11-08 21:51:12 +01:00
Gustas
5db07097e8 Fix carryall not removing influence when cancelling land activity 2022-11-08 21:51:12 +01:00
Gustas
b401f601de Refresh ChatDisabledUntil when entering a new server 2022-11-06 22:28:52 +01:00
Gustas
33a1bb8e6b Don't disable chat in replays 2022-11-06 22:28:52 +01:00
Ivaylo Draganov
4ecf4f9f3f Add a .zsync suffix to appimagecheck URL to pass appimaged checks
Depends on changes in the master server that rewrite the appimagecheck URL.
2022-11-06 14:00:25 +01:00
Matthias Mailänder
81020e70fa Fix actors with immobile actors that don't occupy space
to be placed everywhere way outside the map boundaries.
2022-11-05 21:41:39 +01:00
Matthias Mailänder
74c35edbd9 Fix a crash when flood filling tiles outside of the map. 2022-11-04 00:10:46 +01:00
Gustas
64908c8e70 Fix RenameContrailProperties UpdateRule 2022-11-03 23:35:57 +01:00
Matthias Mailänder
889be47b23 Remove dubFinder style sheet. 2022-11-02 21:33:32 +01:00
Vapre
4fc232f2a6 Authors, anvilvapre. 2022-11-02 14:05:53 +02:00
ThomasChr
a3f8b41e25 Add dropdown for sorting maps in map chooser dialog 2022-11-01 12:08:01 +02:00
abcdefg30
c664af4fe2 Seal the Server.Connection class
Solves CA1816
2022-10-31 12:19:34 +01:00
abcdefg30
a00348dac1 Dispose all connections when shutting down a server 2022-10-31 12:19:34 +01:00
abcdefg30
111d9e4230 Fix replay player disconnect handling 2022-10-30 14:55:55 +01:00
Gustas
7cdc98c8fa FIx anti-ground missiles damaging air units and vice versa 2022-10-30 14:40:39 +01:00
dnqbob
583d85cc2e Allow weapons with no damage warheads to be fired 2022-10-30 14:38:16 +01:00
N.N
08de346e31 fix worm spawn in campaing 2022-10-30 14:32:25 +01:00
notsinned
5242716887 Fix for turret following invisible unit
Fixed turret tracking invisible units after being attacked

Fix for turret following invisible unit

Fix for turrent following invisible unit
2022-10-30 14:08:29 +01:00
Gustas
57143087d7 Fix Aircraft not updating influence when changing height
Occupied cells was defined by height yet we didn't update actor map on changing height. This in some scenarios could have caused the aircraft to forget to remove its influence from actor map
2022-10-30 14:01:32 +01:00
darkademic
f612d82797 Use MacOS 11 for release packaging. 2022-10-29 18:30:58 +02:00
Matthias Mailänder
c22b3f30bb Log OpenRA and Operating System language on crash. 2022-10-29 13:36:36 +03:00
Matthias Mailänder
147804ac30 Inline variables. 2022-10-29 13:36:36 +03:00
EoralMilk
949ef1662d Add mouse scroll to ProductionPaletteWidget 2022-10-28 19:33:57 +02:00
Matthias Mailänder
efe65701e4 Expose game speeds to localisation. 2022-10-27 23:30:19 +02:00
penev92
425c678cd9 Fix TD missions file not using package syntax 2022-10-24 11:45:36 +02:00
Matthias Mailänder
71956cb2a2 Documentation split release/playtest into different branches. 2022-10-21 18:54:58 +03:00
Matthias Mailänder
34ccaf6e9d Fix a crash in Fall of Greece 1: Personal War 2022-10-21 10:42:48 -05:00
Matthias Mailänder
5c8a537efd Fix a crash in Allies 06a. 2022-10-21 10:42:48 -05:00
abcdefg30
c100e64c8e Update Tiberium Forest 2022-10-21 10:35:52 -05:00
Matthias Mailänder
8f415bc7af Localize developer debug cheats. 2022-10-21 17:08:16 +02:00
Matthias Mailänder
44aaf4dd07 Localise text notifications. 2022-10-21 17:08:16 +02:00
Gustas
c041ea7d39 Crash on image/panel not found and add TryGet functions for searching 2022-10-20 19:28:02 +02:00
Gustas
e743e6dd61 Simplify boolean expressions in ProductionPaletteWidget 2022-10-20 19:20:45 +02:00
Gustas
af3d6792b8 Fix ProductionPalette ClockAnimation and NotBuildableAnimation being ignored. 2022-10-20 19:20:45 +02:00
Matthias Mailänder
bd138db9e2 Don't use header tags for non-headers. 2022-10-20 11:02:58 +03:00
Orb370
d9a8a0619c TD-Fall-2022-Balance-Commit 2022-10-19 20:23:19 +03:00
Gustas
686f158117 Refactor BindButtonIcon 2022-10-19 18:26:24 +02:00
abcdefg30
3de0b7982e Adjust the ZOffset of pyle to avoid clipping through the flagpole 2022-10-19 12:23:35 +02:00
abcdefg30
3f5e5e43b3 Make the exit cells of the GDI Barracks transient 2022-10-19 12:23:35 +02:00
Matthias Mailänder
5c3d4a7fe4 Return an error message for invalid cash amounts. 2022-10-18 23:16:20 +02:00
Gustas
347148e02f Allow cash ticking sound to overlap 2022-10-18 22:36:44 +02:00
abcdefg30
fde4f8d0e5 Throw an exception when map.yaml cannot be read 2022-10-18 22:27:51 +02:00
abcdefg30
95c0846ced Remove the filename from the undefined MapFormat exception 2022-10-18 22:27:51 +02:00
abcdefg30
40e207200a Fix a typo in the undefined MapFormat exception message 2022-10-18 22:27:51 +02:00
Matthias Mailänder
acc2c11e69 Fix SupportPowers ClockAnimation being ignored. 2022-10-17 14:20:11 +03:00
abcdefg30
df484633f7 Update the TD map pool 2022-10-14 21:22:42 -05:00
abcdefg30
9498f067bc Remove crate crushing from Visceroids 2022-10-14 20:56:47 -05:00
abcdefg30
625dca6435 Fix dinos not being able to crush crates 2022-10-14 20:56:47 -05:00
Gustas
3181102415 Fix default expressions in commit 75f642bd09 2022-10-14 14:15:57 +03:00
abcdefg30
6e6c828c85 Fix SquadManagerBotModule caching in RenderDebugState 2022-10-14 13:50:57 +03:00
abcdefg30
d8349a429a Remove unnecessary uses of Exts.IsTraitEnabled 2022-10-14 13:50:57 +03:00
abcdefg30
75f642bd09 Introduce FirstEnabledConditionalTraitOrDefault 2022-10-14 13:50:57 +03:00
Gustas
858d782af1 Simplify 'default' expression (IDE0034) 2022-10-11 17:40:05 +02:00
abcdefg30
02d9ba020d Add a workaround for unbinding script members on Mono 2022-10-10 20:27:07 +03:00
Unrud
a2a34dafde MacOS buildpackage: Fix deduplication
The variable `${MOD}` was not enclosed in quotes, but the value contained a space. This caused the argument to be split into two parts.
Using **find** isn't necessary due to globbing.
2022-10-09 00:39:28 +02:00
Gustas
ab26878033 Fix MapCache mapUpdates 2022-10-08 23:08:53 +02:00
Gustas
7f677f1842 Allow driving under crates and crushable units 2022-10-07 21:06:04 +02:00
Gustas
5abbdc37cb Revert "Fix crushables and crates causing HPF to crash."
This reverts commit 5765e51c56.
2022-10-07 21:06:04 +02:00
Gustas
625dc1dd35 Fix subterranean units teleporting to surface and jump jets to ground 2022-10-06 23:03:33 +02:00
Matthias Mailänder
ee0d37f2b1 Add back the man page install 2022-10-05 22:01:04 +02:00
Matthias Mailänder
38a22ebd55 These are not Linux exclusive. 2022-10-05 22:01:04 +02:00
Gustas
043e6f662f Make demolition conditional 2022-10-04 21:55:17 +02:00
Matthias Mailänder
eb897d755e Add observer vision stats. 2022-10-03 20:48:18 +02:00
Ivaylo Draganov
e7dcbb3c2d Improve translation of power/silo usage tooltip
- Fix an instance where "silo-usage" translation was used without
arguments
- Use the same translation reference for the "Power usage"
- Make the ResourceBarWidget accept a cached transform with the tooltip
text
so it won't have to build the string itself
- Display an infinity symbol when the infinite power cheat is used
- Removes a magic number that is no longer used (>1000000 to check for
unlimited power)
2022-10-03 12:00:42 +02:00
Gustas
ba763ac0f0 Add highlighted state to GetCachedStatefulImage 2022-10-01 16:52:04 +03:00
abcdefg30
a75818026a Use SDL.SDL_OpenURL instead of Process.Start to open FAQ and Logs 2022-10-01 14:19:30 +03:00
Matthias Mailänder
6bd631618c Remove unnecessary value assignment (IDE0059) 2022-10-01 14:15:33 +03:00
abcdefg30
757c4d84c7 Change the incompatible replay dialogue text from "Cancel" to "OK" 2022-09-29 23:34:59 +03:00
abcdefg30
b2498fec7d Fix a crash when version or mod of a replay are null 2022-09-29 23:34:59 +03:00
abcdefg30
0d6a7b3c52 Add line breaks to the incompatible replay translations 2022-09-29 23:34:59 +03:00
abcdefg30
a691112c54 Update Linguini to 0.3.1 2022-09-29 23:34:59 +03:00
RoosterDragon
3c66ca709a Fix some bugs in LongBitSet
- Use LongBitSetAllocator and not BitSetAllocator. Using the wrong allocator means all string based checks and displays would provide incorrect results.
- Remove LongBitSetAllocator.Mask which wasn't being calculated or Reset correctly. We can use world.AllPlayersMask to provide the same effect at use sites.
2022-09-29 21:58:17 +02:00
Matthias Mailänder
0080e98390 Fix No Players No Bots No Spectators label overlapping. 2022-09-26 22:47:33 +03:00
tomas
7b7ccf4128 Fix crash in OrderBuffer 2022-09-26 22:44:13 +03:00
Gustas
899298442a Rename the remaining properties in ScrollItemWidget
BaseName: to BackGround:
2022-09-26 13:33:21 +02:00
Matthias Mailänder
f6d13baf4b Use inline strings. 2022-09-26 11:05:15 +03:00
Matthias Mailänder
90a2b677f1 Exit with error code on invalid commands and arguments. 2022-09-26 11:05:15 +03:00
Gustas
fe72dd4140 Remove a ScrollItem header hack
with the merge of #20218 headers no longer need to be selected
2022-09-24 16:23:59 +02:00
Gustas
6b63114aaa Rename ScrollWidget BaseName to Background
To match button
2022-09-24 16:23:59 +02:00
Gustas
5e6f14c9ee Polish TD ScrollItemWidget 2022-09-24 16:23:59 +02:00
RoosterDragon
5765e51c56 Fix crushables and crates causing HPF to crash.
When crushables and crates change their Location/TopLeft, their crushability is cached, but when their CenterPosition is changed, their cached crushability is not refreshed. Since their CrushableBy functions depends on IsAtGroundLevel, which depends on the CenterPosition, this means that when the crushability is cached it will depend on the current height of the object. If the height of the object changes, the cache is not refreshed and now contains out of date information.

The Locomotor cache and the HPF both cache this same information, but at different times. HPF caches immediately, but Locomotor caches on demand which means there can be a delay. This means they can have inconsistent, differing views of the crushability information. This eventually surfaces in a "The abstract path should never be searched for an unreachable point." error from HPF when it detects the inconsistency.

The bug is that Locomotor was caching information without refreshing it when required. Fixing this to refresh the cache when the CenterPosition changes is likely to have negative performance impacts. As would removing crushability from the cache. These would both be fixes that address the underlying bug.

The high impacts of a proper fix lead us to a workaround instead. If we set the CenterPosition before setting the Location, then when the Location is set and the caches are refreshed, the new CenterPosition is available when caching the crushability information. This means logic depending on IsAtGroundLevel will get the new information and cache a more up-to-date view of things. This means when changing both the CenterPosition and Location together we now cache correct information. However calls that set only the CenterPosition and not the Location can still result in a bad cache state. Although this is imperfect it is an improvement over current affairs, and has less impact.
2022-09-24 15:15:53 +02:00
Gustas
1809817b3f Add ContrailEndColor and Contrail transparency control 2022-09-24 13:19:22 +02:00
Gustas
d8f45714a7 Add contrail property descriptions to Bullet and Missile 2022-09-24 13:19:22 +02:00
Gustas
56b665f243 Add TrailDelay to Contrail 2022-09-24 13:19:22 +02:00
Gustas
c781eb0cab Add pressed state to RA and TS ScrollItemWidget 2022-09-22 17:11:33 +02:00
abcdefg30
28adb915f5 Make CheckPalettes report duplicate palettes 2022-09-21 20:06:11 +02:00
abcdefg30
97c96c46f4 Only search for palette definitions on the world actor 2022-09-21 20:06:11 +02:00
abcdefg30
0bbcff973f Only query the palette attribute once in CheckPalettes 2022-09-21 20:06:11 +02:00
N.N
ae7fc11472 Minor adjustment into the D2k
Minor adjustment into the D2k

- Add rally point into the Palace
- removed harvester MustBeDestroyed in campaing
- Players can see they carryalls and ornothopers under the fog.
- Increased CameraRemoveDelay on Superweapons so player can see superweapon impact.
2022-09-21 18:06:18 +02:00
RoosterDragon
70c2ec15d3 Change spaces to tabs.
To follow code style.
2022-09-19 23:36:30 +02:00
Unrud
3f106bef72 Scripts: Check exit status of background process 2022-09-18 10:30:58 +02:00
Unrud
5b085b6c15 Scripts: Remove obsolete comment 2022-09-18 10:30:58 +02:00
Unrud
c29f1590c9 Scripts: Remove exit stmts covered by errexit 2022-09-18 10:30:58 +02:00
Unrud
e2fd7ce7ed Scripts: Remove some subshells that ignore errors 2022-09-18 10:30:58 +02:00
Unrud
1b9a86c0a0 Sciprts: Set pipefail or remove pipes
Errors in pipes are ignored otherwise
2022-09-18 10:30:58 +02:00
Unrud
946cd8f322 Scripts: Set errexit to catch errors 2022-09-18 10:30:58 +02:00
Unrud
7cd0d8c079 Scripts: Prevent paths interpreted as args 2022-09-18 10:30:58 +02:00
Unrud
ea02b90636 Scripts: Quote path variables 2022-09-18 10:30:58 +02:00
Gustas
bb2ee37cc0 Add pressed state to D2K ScrollItemWidget 2022-09-18 10:07:46 +02:00
Shrooblord
70771da45a don't notify players a Harvester is under attack when it's actually healing
Co-authored-by: Gustas <37534529+PunkPun@users.noreply.github.com>
2022-09-17 18:57:59 +02:00
penev92
49ac9079a2 Renamed SpriteSequence documentation command and output file 2022-09-17 15:15:42 +02:00
penev92
04afa4a72c Added some sorting to documentation output 2022-09-17 15:15:42 +02:00
penev92
6b98a75658 Added referencing types to enum definitions 2022-09-17 15:15:42 +02:00
penev92
07b9c941b4 Added documentation page title 2022-09-17 15:15:42 +02:00
penev92
eda3dfa50f Added enum export to documentation generation 2022-09-17 15:15:42 +02:00
Ivaylo Draganov
a985452907 Add myself to AUTHORS 2022-09-16 09:46:20 +01:00
Zachary Schirm
1339faa5f4 Disallowed Save Map without Title and Author Input 2022-09-13 18:48:21 +03:00
Gustas
d95c6e821c Use CachedTransform in ImageWidget 2022-09-13 16:11:18 +02:00
Matthias Mailänder
1536530f78 Add a fake .zsync suffix parameter to pass linting. 2022-09-13 13:20:05 +03:00
Matthias Mailänder
d3a8b07f05 Remove unread private member (IDE0052) 2022-09-13 10:36:57 +03:00
Gustas
43e0cca663 Prevent game from starting with unavailable map 2022-09-12 20:13:42 +02:00
Vapre
7f404f64a6 Selection, cache DeveloperMode trait. 2022-09-11 22:00:18 +03:00
Matthias Mailänder
3be0e9e8a5 Add an in-game encyclopedia to Dune 2000. 2022-09-11 20:19:58 +03:00
RoosterDragon
d2a3659078 Fix landed aircraft above ground level not removing influence on take off.
When the Land activity is run, the aircraft adds influence to the cell so it cannot be used by other actors. When the TakeOff activity runs, it removes the influence so the cell can be used by other actors.

However, when a Carryall picks up a unit, it is told to Land with a vertical offset - it never reaches ground level. When the TakeOff activity runs, it saw the aircraft was above ground level and bailed out. The means the influence is never removed. The cell is now unusable despite the fact the Carryall has left.

To fix this, TakeOff now checks if influence was applied instead of checking if the aircraft is above ground level. If so, we know the Land activity had decided that influence was required, even if the aircraft has not made it to ground level. When TakeOff runs, it will treat it as a proper take off event even though the aircraft is already above ground level. This means influence will be removed and the cell will become accessible as intended.

In ActorMap, we also fix a design flaw where disposed actors where excluded from queries. This caused cache inconsistencies with clients using ActorMap.CellUpdated event to rely on updates. This event will not get called when the actor was disposed, so the downsteam client may have cached the actors at that location, only for them to "change" when the actor is later disposed. This could cause the Locomotor and HierarchicalPathFInder to have inconsistent views of the actors on the map, causing crashes if the inconsistent state broken some internal invariants. The only reason to exclude disposed actors would be to cover up for the actors not being removed properly from the map, which is fixed now aircraft are handled correctly. If ever an actor isn't removed from the actor map, then the caller needs fixing rather than having the actor map exclude it.
2022-09-11 20:04:12 +03:00
Matthias Mailänder
b8e261ff2f Code cleanup in the Tiberian Dawn Lua scripts.
Uppercase global variables.
Declare local variables.
Remove unused variable.
2022-09-11 19:44:38 +03:00
Matthias Mailänder
ca45e02265 Fix untranslated strings in skirmish objectives. 2022-09-10 22:58:28 +03:00
Ivaylo Draganov
3453d13188 Adjust faction label width in lobby to fit better when truncated 2022-09-10 18:26:40 +02:00
Vapre
e3aa2dc6c0 HitShape, query trait via actor cached targetable positions. 2022-09-10 18:23:12 +02:00
abcdefg30
f88b6d78ff Move update rules from 20201213 to 20210321 2022-09-10 17:52:19 +02:00
Vapre
7754e486ee GpsDotEffect, ShouldRender, optimization. 2022-09-10 17:49:58 +02:00
RoosterDragon
7e67889294 Fix a crash when trying to pathfind from unusable custom movement layers.
If a path search is attempted from a location outside the map, then PathSearch will filter these out to prevent any crashes. The path search will result in no path. However if the location is within the map but on a custom movement layer that the locomotor cannot use, this currently crashes. To fix this we apply a similar filtering logic to ignore any source locations that cannot be used, and so the path search will result in no path for these as well.
2022-09-10 15:24:25 +02:00
penev92
c52913716c Added SpriteSequence documentation generation 2022-09-09 21:18:58 +02:00
penev92
dc8c0221e7 Fixed documentation Python script handling of null
The script would serialize null values as "None" in the Markdown files it produces, which is not great. It's better to leave empty strings.
2022-09-09 21:18:58 +02:00
penev92
99b27bbe7b Added missing file extensions to asset browser
These are all file extensions used by the respective mods ingame, so they should be visible in the asset browser as well.
2022-09-09 16:57:22 +03:00
penev92
60b85c933e Reorder asset browser UI's asset list and filters 2022-09-09 16:57:22 +03:00
penev92
8a38ac0d24 Added an asset type filter to AssetBrowserLogic 2022-09-09 16:57:22 +03:00
Gustas
4901de24b1 Select LastModifiedMap when entering ServerCreation 2022-09-09 14:31:25 +03:00
Gustas
81561778a2 Select LastModifiedMap when entering MissionBrowser
And add auto-updating to the play button
2022-09-09 14:31:25 +03:00
Gustas
63b76d1b53 Select LastModifiedMap when entering LobbyLogic 2022-09-09 14:31:25 +03:00
Gustas
02b6a260af Make IngameMenuLogic use ShowMenu 2022-09-09 14:31:25 +03:00
Zachary Schirm
9a5d352e41 Disallow saving the game with an empty name field 2022-09-09 11:39:31 +03:00
Zachary Schirm
125a7b8c88 Disallow Join button without IP address input
Disallow join button without IP address Input

Closes #20234

Trying to join a server with an empty address crashes the game. This fix disallows pressing join button without ip address field input.  Updated to reuse search for joinButton vs 2 separate calls to search.
2022-09-09 11:22:52 +03:00
Gustas
ee0d958cd1 Fixed incorect fluent name in MissionBrowserLogic 2022-09-08 23:45:11 +02:00
Gustas
9ae27b8e60 Fix team 0 being translated in SpawnSelectorTooltipLogic 2022-09-08 23:45:11 +02:00
Gustas
1b00cef30f Fix a few tooltip translations being called every frame
in WorldTooltipLogic and IngamePowerBarLogic
2022-09-08 23:45:11 +02:00
Ivaylo Draganov
56a9acd035 Extract a couple of untranslated strings 2022-09-08 23:45:11 +02:00
dnqbob
6ccd000257 Make building and bridge repair traits public 2022-09-07 14:04:23 +02:00
Matthias Mailänder
fb5624880b Fix sorting. 2022-09-06 20:52:04 +03:00
Matthias Mailänder
67aa0cdede Avoid Count() when Any() could be used (CA1827) 2022-09-06 20:52:04 +03:00
Matthias Mailänder
7ba6a49378 Avoid using LINQ on indexable collections (CA1826) 2022-09-06 18:02:39 +02:00
Matthias Mailänder
68ca09e896 Fixed "bots" not getting translated in Lobby dropdowns 2022-09-05 22:35:50 +02:00
reaperrr
145f6abc09 Add option to limit render fps to game tick rate
This helps slow systems that struggle to render 2 frames per game tick.
2022-09-04 17:00:37 +03:00
penev92
216029dc27 Fix a crash with BlockingCollection in Connection
The BlockingCollection would have `IsAddingCompleted` to true, but `IsComplete` to false, slipping through the cracks and causing an InvalidOperationException ("The collection has been marked as complete with regards to additions.") when trying to add to it.
We now add a check on `(Try)SendData` to only try to add if we can. The collection is still viable for reading until empty/`IsComplete`.
2022-09-04 13:04:17 +03:00
RoosterDragon
2a681d3791 Fix HierarchicalPathFinder considering some unreachable cells as reachable.
When using the internal AbstractCellForLocalCell method to check if a local cell is reachable, this should return null when the cell is unreachable. If multiple abstract cells were required for that grid, this worked as intended. Only reachable cells are stored in the localCellToAbstractCell mapping. For a grid that required only a single abstract cell, which is the common case, we optimize this to store only the single abstract cell rather than the whole mapping for potentially 100 cells in that grid. However this makes no distinction between the reachable and unreachable cells, so when we check later we get incorrect results. If a cell is unreachable but belongs to the same grid as a single group of reachable cells then we incorrectly report it as reachable. The easiest way to see this incorrect behaviour is when the PathExists is called and can sometimes indicate a path exists when it does not.

To fix this, we now ensure we perform a check to see if the cell is reachable in this single layer case, this allows us to retain the optimization where we don't need to store the whole mapping, but allows us to correctly indicate when cells are unreachable.
2022-09-03 19:28:47 +02:00
Vapre
63499c6334 ShroudRenderer, fix, no shroud or fog in editor. 2022-09-03 19:20:25 +02:00
Vapre
57ce88cc9a ShroudRenderer, fix, render Shroud if fog disabled. 2022-09-02 20:13:56 -05:00
Matthias Mailänder
e2284f660c Add documentation to TeslaZap. 2022-09-02 19:58:48 -05:00
Matthias Mailänder
3513d37702 Fix a line break. 2022-09-02 19:58:48 -05:00
penev92
737cdd7851 Reworked trait documentation generation
Switched the Utility's ExtractTraitDocsCommand output to JSON.
Updated documentation generation to use that and the new Python script to generate the Markdown file, same as the Weapon documentation.
2022-09-02 20:56:55 +02:00
penev92
a522457bb6 Reworked weapon documentation generation
Switched the Utility's ExtractWeaponDocsCommand output to JSON.
Added a Python script to generate documentation Markdown from JSON.
2022-09-02 20:56:55 +02:00
penev92
c21bf31ebc Fixed weapon docs not including WeaponInfo
Also made some code cleanups in the weapon docs export code.
2022-09-02 20:56:55 +02:00
penev92
a73d710bec Added Util.InternalTypeName() 2022-09-02 20:56:55 +02:00
penev92
9ed2e699c6 Fix tiny error in output string 2022-09-02 20:56:55 +02:00
penev92
2f0f5f4cda Fixed ScrollPanelWidget not resetting on Clear 2022-09-02 16:16:45 +02:00
Gustas
8402d7d476 Improved Widget.RemoveChildren performance
Modifying the list potentially several thousand times is really slow, so notify the child elements that they are being removed and then clear the list in one go.
2022-09-02 16:16:45 +02:00
penev92
378c447ded Misc fixes in AssetBrowserLogic and MapOverlaysLogic 2022-09-02 16:16:45 +02:00
penev92
df836620dc Added missing spacing to map editor dropdowns 2022-09-02 16:16:45 +02:00
Ivaylo Draganov
c1e1765c2f Move game speed lobby dropdown before time limit dropdown
Game speed is the more frequently changed option and with the current
layout it was buried below the fold.
2022-09-02 16:09:05 +02:00
Matthias Mailänder
0b67b5bfae Extract translation strings. 2022-09-02 14:41:24 +03:00
Gustas
dfd5a960ed Fix RepairableBuilding never stopping repair 2022-09-01 18:30:47 +03:00
RoosterDragon
2d45e67bca Teach HierarchicalPathFinder about Immovable actors.
By tracking updates on the ActorMap the HierarchicalPathFinder can be aware of actors moving around the map. We track a subset of immovable actors that always block. These actors can be treated as impassable obstacles just like terrain. When a path needs to be found the abstract path will guide the search around this subset of immovable actors just like it can guide the search around impassable terrain. For path searches that were previously imperformant because some immovable actors created a bottleneck that needed to be routed around, these will now be performant instead. Path searches with bottlenecks created by items such as trees, walls and buildings should see a performance improvement. Bottlenecks created by other units will not benefit.

We now maintain two sets of HPFs. One is aware of immovable actors and will be used for path searches that request BlockedByActor.Immovable, BlockedByActor.Stationary and BlockedByActor.All to guide that around the immovable obstacles. The other is aware of terrain only and will be used for searches that request BlockedByActor.None, or if an ignoreActor is provided. A new UI dropdown when using the `/hpf` command will allow switching between the visuals of the two sets.
2022-08-31 23:12:42 +02:00
RoosterDragon
7e7d94ca89 Fix Locomotor CellCache to not consider transit only cells as crushable.
When the UpdateCellBlocking encountered a transit-only cell (the bibs around a building) it would bail from the loop. This would leave the cellCrushablePlayers set to all players. It would update the cell cache and mark that cell as a crushable location.

When CanMoveFreelyInto would later evaluate a cell, it would consider it passable because the crushable check would pass (cellCache.Crushable.Overlaps(actor.Owner.PlayerMask)) rather than because the transit check (otherActor.OccupiesSpace is Building building && building.TransitOnlyCells().Contains(cell)) would pass.

Although this meant the cell was treated as passable in either scenario, it means the cache contained incorrect data. The cell does not contain any crushable actors but the cache would indicate it did. Correcting this means we can rely on the crushability information stored in the cache to be accurate.
2022-08-31 23:12:42 +02:00
RoosterDragon
77779023d5 Notify of shroud state changes when using DevVisibility cheat.
When this cheat is used by notifying of shroud changes we invoke the usual logic that would occur if the visibility had been granted by units. Without this change any cached information about the visibility is not refreshed. Without this refresh actors with different visibility may not act correctly.

One aspect this improves is frozen actors. Using the visibility cheat will show up all actors on the map. If the cheat is then disabled than frozen actors will appear in their place. Prior to this change a frozen actor would fail to appear if the cheat had caused it to be revealed. Healthbars and selection boxes are also made consistent for similar reasons.
2022-08-31 23:31:48 +03:00
RoosterDragon
1fc1bdc849 Fix frozen actors lacking tooltips if they have the cloak ability.
Since bbf5970bc1 we update frozen actors only when required.

In 8339c6843e a regression was fixed where actors created in line of sight would be invisible.

Here, we fix a related regression where cloaked units that are revealed, and then frozen when you move out of line of sight would lack tooltips.

The fix centers around the setting of the Hidden flag. In the old code this used CanBeViewedByPlayer which checks for visibility modifiers and then uses the default visibility. The bug with this code is that when a visibility modifier was not hiding the actor, then we would report the default visibility state instead. However the frozen visibility state applies here which means if the frozen actor is visible, then we consider the actor to be hidden and therefore tooltips will not appear. In the fixed version we only consider the modifiers. This means a visibility modifier such as Cloak can hide the frozen actor tooltips. But otherwise we do not consider the frozen actor to be hidden. This prevents a frozen actor from hiding its own tooltips in some unintended circular logic. Hidden now becomes just a flag to indicate if the visibility modifiers are overriding things, as intended.
2022-08-31 23:31:48 +03:00
Mustafa Alperen Seki
16babc1975 Fix Fog color on Radar. 2022-08-31 16:04:40 +03:00
Vapre
215898c7ec ScriptActorInterfaces, unbind on actor destroy. 2022-08-30 21:44:39 +02:00
Gustas
fc1d8d2355 Update RA maps to format 12 2022-08-30 20:03:40 +02:00
Gustas
f98a74f70d Update TD maps to format 12 2022-08-30 20:03:40 +02:00
Gustas
89bb800dbf Update D2K maps to format 12 2022-08-30 20:03:40 +02:00
Gustas
09cb38bc6e Update TS maps to format 12 2022-08-30 20:03:40 +02:00
Gustas
c40675cfba Include map.png into uid generation 2022-08-30 20:03:40 +02:00
RoosterDragon
bcf4ff3b7c Prevent radar crash when dealing with map height. 2022-08-30 19:58:48 +02:00
Gustas
539bb09d50 Fix shroud selector dropdown 2022-08-29 21:13:27 +03:00
Gustas
51c09ddae9 Fix Mission Group having all headers selected 2022-08-29 13:45:38 +03:00
Gustas
08dbfe0cbd Refactor ScrollItemWidget to use stateful image names 2022-08-29 13:45:38 +03:00
Gustas
11a2e6e19b Add more confirmation dialogue to the map editor
When saving on top of another map, or when saving on a map that has been edited outside the map editor
2022-08-29 12:31:01 +03:00
Gustas
d3589c051d Add descriptions to all projectiles and warheads 2022-08-29 12:26:33 +03:00
Vapre
6e547469d6 Shroud, combine IsVisible and IsExplored into a single function. 2022-08-28 18:50:51 +02:00
Ivaylo Draganov
cc1f10dd35 Truncate faction name in lobby dropdown button 2022-08-25 10:44:17 +03:00
dnqbob
29fc2b80d9 WithMuzzleOverlay is decoration 2022-08-21 23:59:15 +02:00
Gustas
ce254f8b46 Add per player mutes 2022-08-20 14:52:49 +02:00
Gustas
81da717f19 Add chat on/off icon to glyphs 2022-08-20 14:52:49 +02:00
Gustas
16198c121c Increase the size of ingame-info panel
And add an Actions section for Kick
2022-08-20 14:52:49 +02:00
Gustas
dde10249d5 Fixup faction and score info UI
And increase spectator name length to match regular players
2022-08-20 14:52:49 +02:00
Gustas
58fcffa429 Add anti-flood protection 2022-08-20 10:24:25 +02:00
tomas
ac623d784a Remove Do() and replace with foreach() 2022-08-19 22:38:38 +02:00
tomas
92478a219e Fix crash when selecting the same map 2022-08-18 00:03:50 +02:00
Gustas
3ab6d3f00a Remove map editor debug message 2022-08-17 23:29:11 +02:00
RoosterDragon
32aaac1dc2 HierarchicalPathFinder.PathExists checks the locations are in map bounds.
Without this, passing locations outside the map could cause a crash instead of reporting no path.
2022-08-17 10:13:27 +03:00
Gustas
ae3a1c2561 Add truncation to FactionLabel 2022-08-16 18:58:45 +03:00
Mustafa Alperen Seki
1b1868fca6 Render every available ProductionIconOverlay. 2022-08-16 15:08:51 +03:00
Mustafa Alperen Seki
54340591e3 Unhardcode VeteranProductionIconOverlay. 2022-08-16 15:08:51 +03:00
Gustas
d438508994 Added try/catch for TypeDictionary errors in Lint code
TypeDictionary errors are very hard for modders to debug as they don't mention which actor is causing the error
2022-08-15 23:19:18 +02:00
Matthias Mailänder
cc58fe1a0f Extract translation strings. 2022-08-14 16:11:51 +02:00
Matthias Mailänder
8201a57b10 Don't complain about re-usable terms not getting referenced. 2022-08-14 16:11:51 +02:00
Matthias Mailänder
2c8c6e50da Code cleanup 2022-08-14 16:11:51 +02:00
Gustas
10ac07bf9f Fix ChooseInitialMap 2022-08-13 17:14:21 +02:00
RoosterDragon
8339c6843e Fix actors not being visible when created within sight range of an enemy.
Since bbf5970bc1 we only update frozen actor state on demand rather than every tick. However when the actor was initially created we were failing to set the initial visibility state if the frozen actor was invisible.

With this fix, we now set the visibility states on creation correctly. This fixes an issue where enemy actors created within line of sight would not appear.
2022-08-13 12:05:03 +03:00
RoosterDragon
2599cb26d8 Allow custom cost to exclude source locations in path searches.
During the refactoring to introduce HierarchicalPathFinder, custom costs were no longer applied to source locations. The logic being that if we are already in the source location, then there should be no cost added to it to get there - we are already there!

Path searches support the ability to go from multiple sources to a single target, but the reverse is not supported. Some callers that require a search from a single source to one of multiple targets perform their search in reverse, swapping the source and targets so they can run the search, then reversing the path they are given so things are the correct way around again. For callers that also use a custom cost like the harvester code that do this in order to find free refineries, they might want the custom cost to be applied to the source location. The harvester code uses this to filter out overloaded refineries. It wants to search from a harvester to multiple refineries, and thus reverses this in order to perform the path search. Without the custom cost being applied to the "source" locations, this filtering logic never gets applied.

To fix this, we now apply the custom cost to source locations. If the custom cost provides an invalid path, then the source location is excluded entirely. Although this seems unintuitive on its own, this allows searches done "in reverse" to work again.
2022-08-13 11:58:45 +03:00
RoosterDragon
df858e06d6 Fix HierarchicalPathFinder failing to consider multiple source locations.
When asked to find a path from multiple source locations, the abstract search is used to determine which source locations are viable. Source locations that cannot be reached on the abstract graph are excluded from the local path search. As we know the locations are unreachable, this prevents the local path search from expanding over the entire search space in an attempt to find these unreachable locations, preventing wasted effort.

In order to determine these reachable locations, the abstract search is expanded successively trying to reach each source location each time. However, this failed to account for a property of the ExpandToTarget for which a comment is now added. If the location was found previously, then expanding to try and find it again will fail. If the source locations were close together, it was likely that the initial expansions of the search space would have included them, and thus they would not be found on a later expansion. This would mean these locations would incorrectly be thought unreachable.

To fix this, we check if the location has already been explored (has CellStatus.Closed in the graph). If so we can check the cost to determine if it is reachable.
2022-08-13 11:58:45 +03:00
abcdefg30
f49536ea12 Use Attribute.IsDefined over GetCustomAttributes 2022-08-12 20:14:54 +02:00
Matthias Mailänder
aa14c9c570 Add VTOL landing exhaust animation. 2022-08-12 00:54:44 +03:00
Matthias Mailänder
1073a7124f Remove an unused field from TakeOff.cs 2022-08-12 00:54:44 +03:00
Gustas
542c5dcfc3 Cleanup directional cursor yaml 2022-08-08 23:28:51 +02:00
Gustas
88e2314776 Add directional support powers to D2K ornithopters 2022-08-08 23:28:51 +02:00
Gustas
fd9758dcbf Make game timer only blink on pause 2022-08-08 10:47:05 +02:00
RoosterDragon
bbf5970bc1 Update frozen actors only when required.
Previously, actors that were visible would refresh their frozen actor state every tick in preparation for the actor becoming hidden, and the frozen actor appearing as a placeholder instead.

By using ICreatesFrozenActors.OnVisibilityChanged when can avoid refreshing the state constantly, and instead just refresh it the moment the frozen actor needs to appear. This provides a nice performance improvement on the cost on managing frozen actors.
2022-08-07 16:50:53 +02:00
darkademic
e827e9952e Additional performance graph colors so same color is not used multiple times. 2022-08-06 22:33:27 +02:00
abcdefg30
dc6be0fd77 Change the IRC link from Freenode to Libera in the issue template config 2022-08-06 16:12:25 +02:00
abcdefg30
47b6f564e3 Add a link to Discord to the PR template and change Freenode to Libera 2022-08-06 16:12:25 +02:00
abcdefg30
d830bca706 Fix force fire opportunity targets not being persisted properly 2022-08-06 15:38:46 +02:00
abcdefg30
5f86f56bed Reduce code duplication in AttackFollow 2022-08-06 15:38:46 +02:00
abcdefg30
0134f63f4d Fix actors with AttackFollow moving away from their targets on amove 2022-08-06 15:38:46 +02:00
Unrud
b88ebd8499 Make Red Alert SVG artwork square
Fix typo in height (128 instead of 138).
2022-08-04 20:02:44 +02:00
RoosterDragon
93998dc4a7 Add a PathFinderOverlay to visualize path searches.
Activated with the '/path-debug' chat command, this displays the explored search space and costs when searching for paths. It supports custom movement layers, bi-directional searches as well as visualizing searches over the abstract graph of the HierarchicalPathFinder. The most recent search among selected units is shown.
2022-08-03 23:12:42 +02:00
RoosterDragon
aef65d353d Replace DomainIndex internals with a lookup from HierarchicalPathFinder instead
Teach HierarchicalPathFinder to keep a cache of domain indices, refreshing them only on demand and when invalidated by terrain changes. This provides an accurate and quick determination for checking if paths exist between given locations.

By exposing PathExistsForLocomotor on the IPathFinder interface, we can remove the DomainIndex trait entirely.
2022-08-03 23:12:42 +02:00
RoosterDragon
5a8f91aa21 Add a hierarchical path finder to improve pathfinding performance.
Replaces the existing bi-directional search between points used by the pathfinder with a guided hierarchical search. The old search was a standard A* search with a heuristic of advancing in straight line towards the target. This heuristic performs well if a mostly direct path to the target exists, it performs poorly it the path has to navigate around blockages in the terrain. The hierarchical path finder maintains a simplified, abstract graph. When a path search is performed it uses this abstract graph to inform the heuristic. Instead of moving blindly towards the target, it will instead steer around major obstacles, almost as if it had been provided a map which ensures it can move in roughly the right direction. This allows it to explore less of the area overall, improving performance.

When a path needs to steer around terrain on the map, the hierarchical path finder is able to greatly improve on the previous performance. When a path is able to proceed in a straight line, no performance benefit will be seen. If the path needs to steer around actors on the map instead of terrain (e.g. trees, buildings, units) then the same poor pathfinding performance as before will be observed.
2022-08-03 23:12:42 +02:00
abcdefg30
cea9ceb72e Support multiple With(Turret)AimAnimation traits 2022-08-03 21:11:03 +02:00
abcdefg30
f2eb42a4b2 Make With(Turret)AimAnimation support multiple AttackBase traits 2022-08-03 21:11:03 +02:00
abcdefg30
ee3c54b572 Disallow starting a game without players 2022-08-03 21:03:46 +02:00
abcdefg30
ea72c50fb4 Fix GrantConditionOnPowerState not being usable on player actors 2022-08-03 20:58:21 +02:00
abcdefg30
1628ce64db Fix lobby error messages from the server being untranslated 2022-08-03 20:54:13 +02:00
dnqbob
8d3ff9d2fc UnhardcodeBaseBuilderBotModule rule update 2022-08-03 11:22:59 +02:00
dnqbob
013ec52108 Unhardcode defenses in BaseBuilderBotModule 2022-08-03 11:22:59 +02:00
Vapre
e8748200f7 Demolishable, trivial optimization. 2022-08-02 00:29:59 +03:00
Vapre
3f3687f71d Widget, avoid copying child list when reverse iterating. 2022-07-31 22:10:49 +02:00
N.N
a9d1b771a0 Align ORA d2k to original D2k
Align ORA D2k weapons to better match original d2k.
2022-07-28 23:42:00 +02:00
RoosterDragon
8dec998d8f Fix tab completion to work for all available commands.
Commands are registered in WorldLoaded event handlers, and IngameChatLogic takes all registered commands and provides tab completion. However IngameChatLogic is also created during WorldLoaded via LoadWidgetAtGameStart. No initialization order is enforced between commands and LoadWidgetAtGameStart, so they can appear in any order.

If a command gets registered before LoadWidgetAtGameStart runs, then it will get tab completion. If it gets registered after then no tab completion is available, even though the command can still be used and appears when using '/help'.

To fix this, we allow the tab completion to check for available commands lazily, meaning it will check for available commands every time the tab key is pressed. This means it will always have the full list of commands available regardless of the initialization order.
2022-07-26 16:42:18 +02:00
teinarss
999af0c05b Add OrderBuffer and time synchronisation. 2022-07-26 15:09:08 +03:00
abcdefg30
4435bdec3c Fix a crash when there is no briefing text 2022-07-25 20:19:36 -05:00
Gustas
e00887e4e1 Make support power fakes infiltratable 2022-07-25 20:07:02 -05:00
N.N
75554123f6 make ornithopter targetable
make ornithopter targetable by anti-air units

update to use just one Targetable type
2022-07-24 21:17:28 +02:00
Gustas
bf5bd63635 Refactor checkbox 2022-07-23 18:32:43 +02:00
Vapre
804bff1b0e TooltipWidgetContainer, load tooltip ui only when visible. 2022-07-18 17:54:57 +02:00
Andre Mohren
0e5f33ef93 PlayerColorPalette now using the full palette if no RemapIndex is set. 2022-07-18 12:23:39 +03:00
Andre Mohren
df72d303b8 Added PaletteFromGrayscale. 2022-07-18 12:23:39 +03:00
Gustas
b597c000d6 Update LobbyLogic to use the new MapCache map tracking 2022-07-17 22:23:13 +02:00
Gustas
6bcf194874 Add map update tracking to MapCache and fix crash when restarting a game 2022-07-17 22:23:13 +02:00
AspectInteractive2
a1a50d6c98 Added rotation logic to the renderer to enable the use of Interpolated Facings. 2022-07-17 17:03:53 +02:00
Sieds Aalberts
e060d6eb05 CellLayer TryGetValue. Return a value if within cell layer bounds. 2022-07-15 20:41:26 +03:00
Gustas
a5ea98ae35 Add RAGL S12 balance 2022-07-15 19:05:41 +02:00
penev92
4f34029556 Added a missing SequenceReferenceAttribute 2022-07-15 19:23:41 +03:00
tomas
5f4ed5f16b Update TextNotificationsManager to use Ui.Send 2022-07-15 19:19:09 +03:00
tomas
b0329aad35 Add Mediator for UI notifications 2022-07-15 19:19:09 +03:00
Matthias Mailänder
91fbd618ce Fix a crash when encountering 0 byte .vqa placeholders. 2022-07-12 23:23:28 +02:00
Leo512bit
9e34299085 Changed anypower tag name to A Power Plant
Updated wording and changed cnc

Capitlazied and added TS
2022-07-11 23:31:41 +02:00
Unrud
0a36d6f995 Use python3 for gtk-dialog.py
As mentioned in https://github.com/OpenRA/OpenRA/pull/20059#issuecomment-1166288560
2022-07-10 18:55:25 +02:00
Unrud
678f249c63 Scripts: Disable markup in error messages
Error messages are displayed using the following methods:

* **zenity** parses pango markup and replaces escaped characters
* **kdialog** replaces (some) escaped characters
* **gtk-dialog.py** replaces `\n`
* **printf** interprets format strings and replaces escaped characters
* **echo** just displays the text

The error messages themself contain escaped characters and paths from variables.

This PR unifies the behavior by:

* Use **printf** to format error messages and replace escaped characters
* Setting `--no-markup` for **zenity** to disable pango markup and escaped characters
* Remove `\n` replacement from **gtk-dialog.py**.
* Use plain **echo** instead of **printf**
2022-07-10 18:55:25 +02:00
Gustas
a03e794140 Add an option to disable chat in replays 2022-07-08 19:40:04 +02:00
abcdefg30
8a98ad51fd Fix sequences only being checked on actors with RenderSprites 2022-07-08 10:28:39 +03:00
abcdefg30
0ded8f8080 Allow null images for SmokeImage on SmudgeLayer 2022-07-08 10:28:39 +03:00
Gustas
36a86c2cd8 Nerf supply truck XP gain 2022-07-06 19:55:49 -05:00
abcdefg30
90ea611cee Rename the 20201213 update rules directory to 20210321 2022-07-05 16:44:17 +02:00
Unrud
bd6d69c5a1 Makefile: More robust check-scripts
Use **xargs** to pass results of **find** instead of word splitting. Word splitting fails when filenames contain white spaces (or if no files are found).
2022-07-05 16:07:01 +02:00
abcdefg30
8e1dce4bbe Add a lint check for maps without playable player 2022-07-05 16:01:22 +02:00
Gustas
7439f8b20a Update AUTHORS 2022-07-05 16:12:09 +03:00
Vapre
8c042a243e PathSearch, make TargetPredicate a readonly private field. 2022-07-04 20:34:23 +02:00
Matthias Mailänder
834de4efbe Port to Linguini 2022-07-02 22:32:37 +01:00
Matthias Mailänder
9d8c2bb4c4 Recommend .ftl syntax highlighting. 2022-07-02 22:32:37 +01:00
Sieds Aalberts
f5de8be3f0 Rectangle equals, trivial optimization. 2022-07-02 23:40:01 +03:00
Paul Chote
c8df1e864c Rework sequence docs plumbing. 2022-07-02 14:10:52 +03:00
Paul Chote
2037e37d4e Replace Sequence EmbeddedPalette with HasEmbeddedPalette. 2022-07-02 14:10:52 +03:00
abcdefg30
c1822d1cef Fix NREs in CheckUnknownWeaponFields 2022-06-26 23:46:51 +01:00
abcdefg30
82692b9d7f Fix crashes in WeaponInfo when warheads or projectiles cannot be created 2022-06-26 23:46:51 +01:00
abcdefg30
185bef39b0 Fix "Inherits" nodes being resolved as objects during linting 2022-06-26 23:46:51 +01:00
abcdefg30
5fe166dfd3 Fix an NRE in CheckUnknownTraitFields 2022-06-26 23:46:51 +01:00
penev92
07ec2d03fb Added an option to run utility.cmd programatically
And still pass arguments to Utility.exe without having to manually input them.
2022-06-26 16:14:22 +01:00
penev92
c3c5dbfa35 Unhardcoded SpriteSequence properties
To prepare them for documentation generation.
Also added descriptions to SpriteSequence implementations and their properties.
Also made a few code style fixes.
2022-06-26 15:41:19 +01:00
abcdefg30
d1f7fb8fb8 Serialize the actor generation for network orders 2022-06-25 18:18:49 +02:00
abcdefg30
13145557c8 Fix the switch-case formatting in Order.Deserialize 2022-06-25 18:18:49 +02:00
Mustafa Alperen Seki
c15af9f68a Ignore nonexistent actors in D2k importer code instead of crashing. 2022-06-24 22:26:15 +01:00
Mustafa Alperen Seki
6083eb4ac8 Remove D2k CheckImportActors 2022-06-24 22:26:15 +01:00
penev92
07db77fb8d Fix RemoveTurnToDock update rule 2022-06-24 21:16:26 +01:00
Ivaylo Draganov
5f42c7c8df Add support for readonly hotkeys and expose chat input hotkeys 2022-06-24 19:42:53 +01:00
Matthias Mailänder
1969ae361c Add missing ISync 2022-06-12 18:40:35 +02:00
Paul Chote
d050fe9f26 Move UnitOrderGenerator to Mods.Common. 2022-06-12 11:57:38 +02:00
Paul Chote
6eb8a4568b Allow mods to replace UnitOrderGenerator with their own default. 2022-06-12 11:57:38 +02:00
Paul Chote
bbe068f6cb Move IOrderGenerator to OpenRA.Orders namespace. 2022-06-12 11:57:38 +02:00
Ivaylo Draganov
320228f9d9 Add hotkeys for editor map overlays 2022-06-10 18:21:57 +02:00
Ivaylo Draganov
13ceda3259 Add hotkeys for map editor tabs 2022-06-10 18:21:57 +02:00
Ivaylo Draganov
b02a3d0f8f Remove unused yaml node in editor chrome 2022-06-10 18:21:57 +02:00
RoosterDragon
c9ee902510 Fix issues preventing suboptimal path searches.
Two different issues were causing a path search to not explore cells in order of the cheapest estimated route first. This meant the search could sometimes miss a cheaper route and return a suboptimal path.

- PriorityQueue had a bug which would cause it to not check some elements when restoring the heap property of its internal data structure. Failing to do this would invalidate the heap property, meaning it would not longer return the items in correct priority order. Additional tests ensure this is covered.
- When a path search encountered the same cell again with a lower cost, it would not update the priority queue with the new cost. This meant the cell was not explored early enough as it was in the queue with its original, higher cost. Exploring other paths might close off surrounding cells, preventing the cell with the lower cost from progressing. Instead we now add a duplicate with the lower cost to ensure it gets explored at the right time. We remove the duplicate with the higher cost in CanExpand by checking for already Closed cells.
2022-06-07 15:47:02 +02:00
penev92
c1cb9ea6be Removed an using, redundant when building on Mono 2022-06-03 21:43:43 +02:00
abcdefg30
6a31b1f9f3 Update the copyright header year 2022-05-28 00:35:10 -05:00
Matthias Mailänder
3f328a14be Hack removal 2022-05-24 21:07:54 -05:00
Matthias Mailänder
709512b166 Add Lua API export in EmmyLua syntax. 2022-05-24 21:07:54 -05:00
RoosterDragon
550db7e958 Ensure SpawnStartingUnits initializes after Locomotor.
Prior to ef44c31a72, Locomotor would be earlier in the trait initialization sequence than SpawnStartingUnits. After this commit, the initialization sequence was perturbed and SpawnStartingUnits would initialize first. When SpawnStartingUnits would query CanEnterCell this would generate a null reference as Locomotor had not yet initialized.

SpawnStartingUnitsInfo is made to initialize NotBefore LocomotorInfo to enforce the required trait ordering.
2022-05-24 12:45:03 -05:00
darkademic
1fc3785f79 Make range modifiers apply to AreaBeam projectile. 2022-05-22 19:42:23 -05:00
RoosterDragon
89042014bd Gracefully handle trying to find paths outside the map.
Rather than crashing, return no path instead.
2022-05-22 17:39:44 -05:00
abcdefg30
4ec19b3486 Remove deprecated airstrike and paratrooper methods for Lua 2022-05-22 10:57:30 -05:00
abcdefg30
7ec74749be Remove the deprecated WAngle.Range accessor for Lua 2022-05-22 10:57:30 -05:00
abcdefg30
c827d1a4ab Remove deprecated integer facing handling for Lua 2022-05-22 10:57:30 -05:00
abcdefg30
660130653c Use TryGetValue instead of ContainsKey and a lookup for cached sounds 2022-05-22 10:39:27 -05:00
abcdefg30
ea04a7fec5 Clear cached notifications when initializing a new map/mod 2022-05-22 10:39:27 -05:00
abcdefg30
9d481854f3 Make currentSounds readonly 2022-05-22 10:39:27 -05:00
atlimit8
85b9cf0a69 Fix fatal radar sound bug
The following error occurs on a map where the radar activation sound plays:
Exception has occurred: CLR/System.ArgumentException
An exception of type 'System.ArgumentException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'Property set method not found.'
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
   at OpenRA.FieldLoader.LoadField(Object target, String key, String value) in /home/jason/git/OpenRA/OpenRA.Game/FieldLoader.cs:line 609
   at OpenRA.WidgetLoader.LoadWidget(WidgetArgs args, Widget parent, MiniYamlNode node) in /home/jason/git/OpenRA/OpenRA.Game/Widgets/WidgetLoader.cs:line 60
   at OpenRA.WidgetLoader.LoadWidget(WidgetArgs args, Widget parent, MiniYamlNode node) in /home/jason/git/OpenRA/OpenRA.Game/Widgets/WidgetLoader.cs:line 67
   at OpenRA.WidgetLoader.LoadWidget(WidgetArgs args, Widget parent, MiniYamlNode node) in /home/jason/git/OpenRA/OpenRA.Game/Widgets/WidgetLoader.cs:line 67
   at OpenRA.WidgetLoader.LoadWidget(WidgetArgs args, Widget parent, MiniYamlNode node) in /home/jason/git/OpenRA/OpenRA.Game/Widgets/WidgetLoader.cs:line 67
   at OpenRA.WidgetLoader.LoadWidget(WidgetArgs args, Widget parent, String w) in /home/jason/git/OpenRA/OpenRA.Game/Widgets/WidgetLoader.cs:line 43
   at OpenRA.Game.LoadWidget(World world, String id, Widget parent, WidgetArgs args) in /home/jason/git/OpenRA/OpenRA.Game/Game.cs:line 160
   at OpenRA.Mods.Common.Widgets.Logic.LoadIngamePlayerOrObserverUILogic..ctor(Widget widget, World world) in /home/jason/git/OpenRA/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs:line 34
2022-05-21 16:10:08 +02:00
Eduardo Cáceres
a1811b4b04 Add fixed issues as warnings to .editorconfig 2022-05-18 11:42:36 -05:00
Eduardo Cáceres
c224bfdc0d Include name in authors 2022-05-18 11:42:36 -05:00
Eduardo Cáceres
8ced155ca3 Simplify 'always true' expressions
Co-authored-by: atlimit8 <atlimit8-vcs@gmx.com>
2022-05-18 11:42:36 -05:00
Eduardo Cáceres
aa998a46d9 Simplify collection initialization 2022-05-18 11:42:36 -05:00
Eduardo Cáceres
cae43808d9 Optimize string comparison 2022-05-18 11:42:36 -05:00
Eduardo Cáceres
c0d270b87d Abstract class with public constructor 2022-05-18 11:42:36 -05:00
Eduardo Cáceres
1b69ff017d Dictionary optimization 2022-05-18 11:42:36 -05:00
Eduardo Cáceres
b71402f64d Convert extension in real extension 2022-05-18 11:42:36 -05:00
Eduardo Cáceres
2677e9c013 Use pattern matching 2022-05-18 11:42:36 -05:00
Eduardo Cáceres
aed2b8afae Remove unnecessarily interpolated strings 2022-05-18 11:42:36 -05:00
Eduardo Cáceres
7eb64ea6fc Use read-only autoimplemented property when possible 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
penev92
6eb4fe8980 Added a VSCode task to run the utility 2022-05-15 23:06:25 -05:00
penev92
9a30d260a1 Added launch profiles for the Utility project 2022-05-15 23:06:25 -05:00
abcdefg30
581b5cfacf Resolve an IDE0017 warning in ImportLegacyMapCommand 2022-05-11 15:33:23 +02:00
Paul Chote
c6dc0b58be Change macOS control group defaults back to Cmd. 2022-05-09 14:58:01 +02:00
Ivaylo Draganov
6a1a6b6397 Add platform override support for hotkeys and unhardcode editor hotkeys 2022-05-07 20:55:49 +01:00
Ivaylo Draganov
1cf4838b08 Remove unneeded yaml nodes from hotkey settings 2022-05-03 22:22:55 +02:00
Ivaylo Draganov
f0e69c3f64 Add hotkey filtering functionality (by name and by context) 2022-05-03 22:22:55 +02:00
Paul Chote
56153aac9f Search x86_64 before other multiarch dirs. 2022-05-01 11:55:28 +02:00
Leo512bit
ddef76e833 Added more thief voice lines 2022-04-30 17:19:48 -05:00
Ivaylo Draganov
0522576f73 Allow scrolling of settings panels while hovering a section header 2022-04-30 21:46:55 +02:00
abcdefg30
512eaf2746 Use Building instead of D2kBuilding for the Sietch actor 2022-04-30 12:28:28 -05:00
RoosterDragon
714b38c97c Add CellCostChanged event to Locomotor.
This event allows subscribers to be made aware when the terrain costs for a cell change.
2022-04-30 15:56:04 +02:00
Ivaylo Draganov
bc676fbf78 Add text notifications to many in-game events 2022-04-30 12:39:29 +01:00
Ivaylo Draganov
ea0bcbd1cc Adjust position of transients panel in TS 2022-04-30 12:39:29 +01:00
Ivaylo Draganov
24b9482cc1 Add support for transient text notifications matching speech notifications 2022-04-30 12:39:29 +01:00
Ivaylo Draganov
9f723be65a Add checkbox to settings for toggling transient notifications 2022-04-30 12:39:29 +01:00
Ivaylo Draganov
a1e6ac85dc Add transient notifications pool 2022-04-30 12:39:29 +01:00
RoosterDragon
e22b6de4e8 Rename PathGraph to MapPathGraph.
Move PathCostForInvalidPath and MovementCostForUnreachableCell constants into a new static class, PathGraph.
2022-04-27 23:19:59 +02:00
RoosterDragon
a1a583ea0a Split out a base class for PathGraph.
Move the domain logic involved into a base class named DensePathGraph. The base class contains all the domain logic necessary to traverse a graph including concepts such as custom movement layer.

PathGraph becomes responsible for proving a backing array for the pathfinding information, and is where the pooling logic lives instead, helping split the two concepts out.
2022-04-27 23:19:59 +02:00
penev92
86515610a5 Made all projectile and warhead fields readonly
This came up while working on the new documentation generation and comparing the results to ORAIDE's own code parser.
2022-04-26 22:37:12 +02:00
penev92
2bac492a65 Made all traitInfo fields readonly
This came up while working on the new documentation generation and comparing the results to ORAIDE's own code parser.
2022-04-26 22:37:12 +02:00
Gustas
135823fced fix crash when non-host exits map chooser 2022-04-25 23:03:27 +02:00
Paul Chote
a152bf7324 Replace custom mono defines with toolchain-provided defines. 2022-04-24 20:31:47 +02:00
RoosterDragon
3e5666ca53 Return an empty path when a search with no locations is made.
The restores the previous behaviour before FindUnitPathToTargetCell was introduced. This prevents callers such as the harvester code crashing when a harvester tries to route home to a refinery, but there are no refineries.
2022-04-24 12:52:18 +02:00
RoosterDragon
7df39f3522 On Locomotor initialization, update blocked cells.
Prior to ef44c31a72, Locomotor would be earlier in the trait initialization sequence than SpawnMapActors. Locomotor would assume no actors on the map, and register to update blocked cells when new ones were added. When SpawnMapActors created actors, Locomotor was made aware and kept up-to-date.

After this commit, the initialization sequence was perturbed and SpawnMapActors would initialize first. Locomotor would assume no actors on the map and thus be unaware of these starting units, meaning those starting units would not cause blocking, allowing units to pass through them.

There are two possible fixes. SpawnMapActorsInfo can initialize NotBefore<LocomotorInfo>, enforcing that actors are spawned after locomotor is ready. Or we can remove the assumption in Locomotor that the map starts empty, and have it update blocked cells on startup. The latter seems cleaner, so any other traits that may want to spawn actors don't have to be aware sequencing their initialization with the Locomotor trait, instead things would "just work".
2022-04-24 12:48:52 +02:00
Matthias Mailänder
4c08e449e0 Fix master server respond not being localized. 2022-04-23 22:29:40 +01:00
Paul Chote
0dbd8264b8 Handle exceptions thrown by HttpClient.GetAsync. 2022-04-23 22:44:05 +02:00
Matthias Mailänder
6c81590b20 Extract translation strings. 2022-04-21 13:26:55 +03:00
Matthias Mailänder
99033ab016 Localize dedicated server messages. 2022-04-21 13:26:55 +03:00
Matthias Mailänder
fe15748cc0 Wrap console logging with time stamp. 2022-04-21 13:26:55 +03:00
Matthias Mailänder
aaa3b49496 Update Mono.NAT 2022-04-21 13:11:45 +03:00
RoosterDragon
ecb7c16751 Tweak handling of nullable types in LUA doc generation.
The types for Int32 and Boolean are currently replaced with friendly names of int and bool for the docs. Ensure we apply the same handling when these are nullable types, changing the output from Int32? and Boolean? to int? and bool?
2022-04-18 13:02:05 +02:00
RoosterDragon
d2935672ca Fix the shape of the IPathFinder interface, ensure all path searches use it.
Some path searches, using PathSearch, were created directly at the callsite rather than using the pathfinder trait. This means some searches did not not benefit from the performance checks done in the pathfinder trait. It also means the pathfinder trait was not responsible for all pathing done in the game. Fix this with the following changes:
- Create a sensible shape for the IPathFinder interface and promote it to a trait interface, allowing theoretical replacements of the implementation. Ensure none of the concrete classes in OpenRA.Mods.Common.Pathfinder are exposed in the interface to ensure this is possible.
- Update the PathFinder class to implement the interface, and update several callsites manually running pathfinding code to instead call the IPathFinder interface.
- Overall, this allows any implementation of the IPathFinder interface to intercept and control all path searching performed by the game. Previously some searches would not have used it, and no alternate implementations were possible as the existing implementation was hardcoded into the interface shape.

Additionally:
- Move the responsibility of finding paths on completed path searches from pathfinder to path search, which is a more sensible location.
- Clean up the pathfinder pre-search optimizations.
2022-04-18 11:18:43 +01:00
RoosterDragon
2583a7af31 After NotBefore<> support to control initialization order.
Requires<T> means that trait of type T will be initialized first, and asserts that at least one exists. The new NotBefore<T> means that trait of type T will be initialized first, but allows no traits.

This allows traits to control initialization order for optional dependencies. They want to be initialized second so they can rely on the dependencies having been initialized. But if the dependencies are optional then to not throw if none are present.

We apply this to Locomotor which was previously using AddFrameEndTask to work around trait order initialization. This improves the user experience as the initialization is applied whilst the loading screen is still visible, rather than the game starting and creating jank by performing initialization on the first tick.
2022-04-18 10:31:47 +01:00
Mustafa Alperen Seki
62e7c7a318 Make PortableChrono PausableConditional. 2022-04-17 12:14:50 +02:00
Mustafa Alperen Seki
9de8d8854d Pass PortableChrono instead of PortableChronoInfo to PortableChronoOrderGenerator. 2022-04-17 12:14:50 +02:00
Matthias Mailänder
648c56bca1 Don't crash when joining a game after asset installation. 2022-04-17 00:27:36 +03:00
Matthias Mailänder
0f90713aba Added addition error logging to graphics.log when SDL fails 2022-04-16 22:37:05 +02:00
Mustafa Alperen Seki
30f14dcc4c Fix Army Spectator tab not using FactionImages. 2022-04-15 18:17:49 +02:00
RoosterDragon
ac0969d688 Use nameof instead of hardcoded strings in reflection calls.
This helps improve the safety of code the uses reflection when methods may get renamed, and helps navigating code as the nameof will show up when searching for references to members.
2022-04-14 19:58:15 +02:00
Gustas
b254eb0f3d Add dynamic map refresh 2022-04-14 16:16:38 +02:00
Gustas
61df7974b0 Make the delete button not call MapCache every frame 2022-04-14 16:16:38 +02:00
tomas
515aba0ee7 Update SDL to 2.0.20 2022-04-13 20:13:01 +02: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
Matthias Mailänder
3bc28ba6e2 Use inline string replacement. 2022-04-13 20:09:57 +02:00
dnqbob
4f43b157a8 Add place variant building for BaseBuilderBotModule.
1. If it follow the refinery placing logic, then we can use Facings in PlaceBuildingVariants to help BaseBuilderBotModule "rotates" it to minefield.

2. If it is a normal building, BaseBuilderBotModule will place a random variant actor.
2022-04-12 22:28:03 +02:00
penev92
f74d1c3cf8 Adjusted D2k mission player colors
PlayerReference colors in D2k missions only affect chat text and minimap colors because actors use specific palette colors.
So using the colors from the original game's minimap.
2022-04-12 22:15:02 +02:00
penev92
2866342522 Add missing PlayerReferences in D2k map import 2022-04-12 22:15:02 +02:00
tomas
8e19463450 Fix desync handling 2022-04-12 21:56:46 +02:00
abcdefg30
dab8ee4f94 Load campaign and utils Lua scripts before map scripts 2022-04-12 21:54:11 +02:00
Mustafa Alperen Seki
c71af0e613 Make NukePower MissileImage optional. 2022-04-12 21:52:29 +02:00
Mustafa Alperen Seki
60b123c641 Split NukePower MissileImage from MissileWeapon. 2022-04-12 21:52:29 +02:00
Matthias Mailänder
0260884369 Added translation support for server orders. 2022-04-03 19:23:26 +02:00
Matthias Mailänder
ee95d2591f Code cleanup. 2022-04-03 19:23:26 +02:00
Matthias Mailänder
7735107deb Add a script trigger overlay. 2022-04-02 18:01:00 +02:00
Matthias Mailänder
058fb51f4c Reduce the menu button size to save space. 2022-04-02 18:01:00 +02:00
Matthias Mailänder
0e7ad43425 Remove unused parameters. 2022-04-01 23:30:26 +02:00
RoosterDragon
ea243b8558 Fix crash in TSEditorResourceLayer when adding resources.
Ensure cells are within map bounds when checking if adjacent cells should be cleared during resource placement.
2022-03-26 23:07:41 +01:00
abcdefg30
e685731b33 Add an update rule for the removal of AttackFrontal's FacingTolerance 2022-03-13 11:16:47 +01:00
abcdefg30
889425ab0f Remove AttackFrontal's FacingTolerance and define it explicitly in rules 2022-03-13 11:16:47 +01:00
dnqbob
9049ae6f20 Add a backawrd moving option for mobile 2022-03-13 10:46:04 +01:00
Vapre
83357af14c WorldRenderer, replace foreach ActorsWithTraits with ApplyToActorsWithTrait. #18798. 2022-03-13 10:45:01 +01:00
Matthias Mailänder
00356b8bbd Setup Tiberian Sun forest fires. 2022-03-12 17:16:43 +01:00
Mustafa Alperen Seki
b54a724aea Add ability to override CannotPlaceNotification per queue. 2022-03-12 12:55:41 +01:00
Matthias Mailänder
a6cb20a4ec Fix overlapping tracks when vehicle rotates.
Also optimize the function slightly.
2022-03-12 12:53:59 +01:00
Matthias Mailänder
5220da1bae This can never be null. 2022-03-12 12:53:59 +01:00
Mustafa Alperen Seki
2f1edd4516 Remove Replacable actors for LineBuild too. 2022-03-11 22:32:08 +01:00
Mustafa Alperen Seki
a7004b2db7 Check for placeablilty of LineBuild Segment instead of the Post. 2022-03-11 22:32:08 +01:00
Mustafa Alperen Seki
153bd14f9e Add Force-Move undeploy to D2k Thumper Infantry. 2022-03-11 22:29:45 +01:00
Leo512bit
d2611ebfb4 Added fsmap to music.ymal and set the lose music to it.
Signed-off-by: Leo512bit <leonardmatthewteyssier@gmail.com>
2022-03-11 21:36:43 +01:00
Ivaylo Draganov
eadc8ad689 Change color of labels that correspond to disabled inputs
- Add a new widget type for input and extend it from other input widgets
- Add a new label type that can be linked to an input widget
- Change the label color when the input's disabled state changes
2022-03-07 21:01:33 +01:00
Mustafa Alperen Seki
0203476da9 Update variables for Flash lua function. 2022-03-05 15:19:01 +01:00
Mustafa Alperen Seki
7e4c3acda3 Fix ZRamp only allowing integer values. 2022-03-02 19:41:49 +01:00
darkademic
e082497a1a Corrected StartBurstReport sound synchronisation when used with FireDelay. 2022-02-26 10:40:19 -06:00
Matthias Mailänder
9605e5ad9c Use the new MiniYAML GitHub syntax. 2022-02-26 17:04:50 +01:00
Matthias Mailänder
da4fb27fca Use modern string syntax. 2022-02-26 17:04:50 +01:00
penev92
57d3321d0f Make WithDockingAnimation optional
The `Refinery` trait has a hardcoded usage of `SpriteHarvesterDockSequence`, which requires the harvester to have `WithDockingAnimation`, making it inconvenient-at-best to NOT have a docking/unloading animation.
2022-02-23 22:06:07 +01:00
IceReaper
fa8bfc6ca0 Allow mods to implement new building placement conditions and cursors. 2022-02-22 01:20:38 +02:00
penev92
0f1ff3f2fc Recommend the MiniYAML language server extension
Recommends  https://marketplace.visualstudio.com/items?itemName=openra.oraide-vscode  as a VSCode extension for the OpenRA workspace.
2022-02-20 16:30:38 +01:00
Mustafa Alperen Seki
91f626c42a Make WithVoxelWalkerBody PausableConditional. 2022-02-18 12:24:23 +01:00
dnqbob
6c33d47ef3 Update rule on renaming 'CloakTypes' to 'DetectionTypes' 2022-02-12 19:30:21 +01:00
dnqbob
831bed2c4d Add enter-cloak & exit-cloak effect for Cloak 2022-02-12 19:30:21 +01:00
RoosterDragon
d67f696bd0 Move BlockedByActor, IPositionableInfo, IPositionable to Mods.Common.
Actor previously cached targetable locations for static actors as an optimization. As we can no longer reference the IPositionable interface, move this optimization to HitShape instead. Although we lose some of the efficiency of caching the final result on the actor, we gain some by allowing HitShape to cache the results as long as they have not changed. So instead of being limited to static actors, we can extend the caching to currently stationary actor.
2022-02-11 23:35:08 +01:00
RoosterDragon
d8a4d7fd1d Cache the global mix database in MixLoader
We can reuse this global database as it doesn't change, rather than loading a new copy each time a new mix file is parsed.
2022-02-11 14:05:55 +01:00
RoosterDragon
f5d1fe4bc4 Use more efficient search in MergeIntoResolved
Switch Enumerable.FirstOrDefault to List.Find. The latter can avoid some allocations because the concrete collection type is known.
2022-02-11 14:01:16 +01:00
RoosterDragon
ed72e61f8f Add detailed documentation for BlockedByActor enum. 2022-02-08 23:34:07 +01: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
Gustas
13ee62c181 Make overlay dropdown optional 2022-02-06 19:21:43 +01:00
Gustas
addfdf50fa Crash when EditorWorld does not have BuildableTerrainOverlay 2022-02-06 19:21:43 +01:00
reaperrr
a17af87a5e Fix aircraft with TakeOffOnCreation=false not freeing exit
...when another actor gets produced.
2022-02-06 19:20:29 +01:00
reaperrr
44fc4a1d0f Fix random placement of AssociateWithAirfieldActivity
It doesn't belong to IMove, so it doesn't belong into that region.
Put it near ICreationActivity where it belongs.
2022-02-06 19:20:29 +01:00
darkademic
257ef95963 Suffix projectile shadow palettes with player name if IsPlayerPalette = true. 2022-02-06 19:18:59 +01:00
Matthias Mailänder
9bb41630e7 Update documentation action to .NET 6 2022-02-06 18:06:44 +01:00
Ivaylo Draganov
f5ab9d95fe Make remove from control group hotkey available only to players 2022-02-06 09:09:33 -06:00
Mustafa Alperen Seki
c096934db8 Fix projectile shadow alpha calculation. 2022-02-04 23:35:44 +01:00
Ivaylo Draganov
1813edc74b Add contexts for hotkey validation 2022-02-04 18:49:05 +01:00
RoosterDragon
1bc95a290f Preallocate dictionary size in ToDictionaryWithConflictLog 2022-02-02 15:10:37 +01:00
Smittytron
74cced319c Change terrain type of clear straight bridge tiles 2022-01-31 14:19:47 +01:00
RoosterDragon
bd30c66f95 Reuse object arrays in FieldLoader Parse methods 2022-01-30 19:47:06 +01:00
RoosterDragon
2ab3917f29 Clean up usage of DomainIndex
- When a path search is being performed the path search will not attempt route to inaccessible cells, so domain index checks to avoid inaccessible cells in the search predicate are redundant and can be removed.
- DomainIndex is a required world trait, so we don't need to use TraitOrDefault and therefore can avoid dealing with the null case.
2022-01-30 16:22:26 +01:00
Matthias Mailänder
4b4b0125a2 Make UnitsInRange accessible to mod code. 2022-01-30 11:56:43 +01:00
Matthias Mailänder
240c96b781 Expose sprite sequence to linting and documentation. 2022-01-30 11:56:43 +01:00
RoosterDragon
6dc189b7d1 Rearrange various API surfaces related to pathfinding.
The existing APIs surfaces for pathfinding are in a wonky shape. We rearrange various responsibilities to better locations and simplify some abstractions that aren't providing value.

- IPathSearch, BasePathSearch and PathSearch are combined into only PathSearch. Its role is now to run a search space over a graph, maintaining the open queue and evaluating the provided heuristic function. The builder-like methods (WithHeuristic, Reverse, FromPoint, etc) are removed in favour of optional parameters in static creation methods. This removes confusion between the builder-aspect and the search function itself. It also becomes responsible for applying the heuristic weight to the heuristic. This fixes an issue where an externally provided heuristic ignored the weighting adjustment, as previously the weight was baked into the default heuristic only.
- Reduce the IGraph interface to the concepts of nodes and edges. Make it non-generic as it is specifically for pathfinding, and rename to IPathGraph accordingly. This is sufficient for a PathSearch to perform a search over any given IGraph. The various customization options are concrete properties of PathGraph only.
- PathFinder does not need to deal with disposal of the search/graph, that is the caller's responsibility.
- Remove CustomBlock from PathGraph as it was unused.
- Remove FindUnitPathToRange as it was unused.
- Use PathFinder.NoPath as the single helper to represent no/empty paths.
2022-01-30 11:47:52 +01:00
Matthias Mailänder
cd1fe2d23b Fix saving into writable system directories. 2022-01-30 11:46:42 +01:00
abcdefg30
2af8296f48 Add the possibility to always show detection circles 2022-01-30 11:41:02 +01:00
abcdefg30
7c085e49c7 Cache DetectCloaked traits in RenderDetectionCircle 2022-01-30 11:41:02 +01:00
xan2622
13fbc412d2 removal 2022-01-30 11:28:16 +01:00
abcdefg30
a9cd2d41c7 Fix ToAhsv using the wrong type for alpha 2022-01-29 13:44:02 +01:00
Ivaylo Draganov
7a93b9ea8c Make control group hotkeys configurable
- Split control groups management to its own interface
- Add hotkeys for selecting, creating, adding to and combining with control groups
- Add a ControlGroups widget to manage the player interaction
2022-01-28 18:38:18 +01:00
Gustas
04b456d6c2 Create overlays dropdown 2022-01-26 23:09:18 +01:00
Gustas
2f130b17ba Fix buildable overlay not updating and make ramps unbuildable 2022-01-23 22:37:02 +01:00
penev92
9cc631ca7e Added a rule about using object initializers 2022-01-23 13:14:57 +01:00
penev92
ab09ce21b4 Changed code to use object initializers everywhere 2022-01-23 13:14:57 +01:00
penev92
70e2769a85 Added a rule about the readonly modifier
Also added a rule to silence StyleCop complaining about StaticReadonlyFieldsMustBeginWithUpperCaseLetter to match what we already have configured for the IDE.
2022-01-22 18:47:06 +00:00
penev92
bf332b6619 Fixed fields missing the readonly modifier 2022-01-22 18:47:06 +00:00
Piotr Usewicz
f83e27d647 Point towards arm libraries
When compiling for macOS using `unix-generic` on Apple M1 processors, point sarchdirs towards the correct location in Homebrew for arm64.
2022-01-22 18:21:36 +00:00
penev92
a67cfabd1e Reordered code style rules
To order them by their number.
2022-01-20 22:10:28 +01:00
penev92
8dbaa0c49f Added more explanations to .editorconfig 2022-01-20 22:10:28 +01:00
penev92
92d1d64dce Changed one-liner braces rule to silent
Having this set to "none" disabled the IDE's option to add braces, whereas "silent" lets it do it on the user's request while still not suggesting it on its own.
2022-01-20 22:10:28 +01:00
penev92
31b3647c09 Added a rule about unordered modifiers 2022-01-20 22:10:28 +01:00
penev92
d37336456d Fixed inconsistent declaration modifier order 2022-01-20 22:10:28 +01:00
penev92
3bacd81b8b Added a rule about zero-length array allocations 2022-01-20 22:10:28 +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
Paul Chote
1312c1aa72 Rename macOS compat packages to mono. 2022-01-20 19:31:43 +01:00
penev92
19dd23e349 Beautified the .editorconfig file 2022-01-19 14:37:14 +01:00
dnqbob
242d589c45 Make AI airstrike aircraft spawns randomly 2022-01-17 15:43:20 +01:00
Mustafa Alperen Seki
d149624b84 Add Lua Scripting for Carryall. 2022-01-12 14:24:13 +01:00
penev92
860ec642b8 Addressed review comments
- Renamed `IVideo.CurrentFrameNumber` to `CurrentFrameIndex`
 - Improved logged error message in VideoPlayerWidget
 - Renumbered fields in ThreadedGraphicsContext
2022-01-11 18:16:31 +01:00
penev92
248b8d1102 Renamed IVideo implementations
To match the interface they are implementing.
2022-01-11 18:16:31 +01:00
penev92
6f0509d235 Removed now-unused ITexture.SetData() overload 2022-01-11 18:16:31 +01:00
penev92
cb8530fbae Reworked internal palettes in video reader classes
This removes the need to pack & unpack color bytes as uints for no gain.
2022-01-11 18:16:31 +01:00
penev92
c4ab7041b8 Updated VideoPlayerWidget to play new IVideo data
Added optional padding to video frames because that's what VideoPlayerWidget expects.
Keeping the option to not use padding for other use-cases like converting frames to PNG.
2022-01-11 18:16:31 +01:00
penev92
ee29d0f9c7 Changed IVideo.CurrentFrameData uint[,] -> byte[] 2022-01-11 18:16:31 +01:00
penev92
1b5f2f1b39 Removed caching properties from video readers
Those seem redundant since the frame number is guaranteed to match the loaded data inside CurrentFrameData.
2022-01-11 18:16:31 +01:00
penev92
0df3b34c52 Did a beautification pass on IVideo and family
Removed property backing fields where applicable, introduced C#7 syntax for properties.
Renamed a bunch of interface properties and class private members with more descriptive names.
Did some inconsequential reordering.
2022-01-11 18:16:31 +01:00
abcdefg30
556413c91d Add whitespace fixes from the automatic update rule run 2022-01-11 18:09:05 +01:00
abcdefg30
f3bc450e20 Fix an oversight in the update rule for AttackBomber's FacingTolerance 2022-01-11 18:09:05 +01:00
abcdefg30
6556b33cef Move update rules to the correct subfolders and paths 2022-01-11 18:09:05 +01:00
abcdefg30
15c2800601 Retire the release-20191117 UpdatePath 2022-01-11 18:09:05 +01:00
abcdefg30
d660ce9c47 Change the UpdatePath targets from playtest-20201213 to release-20210321 2022-01-11 18:09:05 +01:00
Matthias Mailänder
6770c08bf9 Fix scrollitem-nohover-hover not found. 2022-01-11 17:40:58 +01:00
Ivaylo Draganov
99ac128820 Add selected actors count to feedback notification text 2022-01-09 19:07:45 +01:00
Mustafa Alperen Seki
fe05382b24 Change "actor id" to "actor name" in some descs. 2022-01-09 19:02:05 +01:00
Mustafa Alperen Seki
3c60a515f7 Add CarryableConditions to Carryall. 2022-01-09 19:02:05 +01:00
penev92
b67954451a Removed obsolete file OpenRA.sln.DotSettings
- The DEFAULT_PRIVATE_MODIFIER behaviour is now handled by the .editorconfig file via `dotnet_style_require_accessibility_modifiers = omit_if_default:warning`.
 Also added `dotnet_diagnostic.IDE0040.severity = warning` there to raise compile-time errors in the CI.
 - The field naming conventions seem to already be covered by (some) analyzer rules (checked in both VS and VSCode) - IDE1006/SA1306 and SA1307.
2022-01-09 18:58:37 +01:00
penev92
2f6f214bac Removed a bunch of explicit access modifiers 2022-01-09 18:58:37 +01:00
penev92
413d564f1d Removed obsolete file stylecop.json
It currently has two functions, both of which are covered by our .editorconfig file.
2022-01-09 18:58:37 +01:00
penev92
1326bca65c Updated .gitignore file
Removed some obsolete entries now that there is a new build directory.
2022-01-09 18:58:37 +01:00
Mustafa Alperen Seki
721210eafe Fix RevealsMap's effect not being removed for non-owners. 2022-01-09 18:53:16 +01:00
penev92
c6dacb50e8 Added hiding of the palette picker in the AssetBrowser 2022-01-09 18:40:32 +01:00
penev92
495faea96b Updated scale sliders to accout for the new AssetBrowser layout 2022-01-09 18:40:32 +01:00
penev92
b6b417d42f Fixed AssetBrowserLogic disposing audio streams prematurely 2022-01-09 18:40:32 +01:00
penev92
6fb228ddd1 Fixed Mp3Loader and OggLoader not resetting stream position 2022-01-09 18:40:32 +01:00
penev92
87b92b53a4 Reworked ISoundFormat.LengthInSeconds implementations 2022-01-09 18:40:32 +01:00
penev92
631297417c Fixed background music playing momentarily in AssetBrowser when switching to a video asset 2022-01-09 18:40:32 +01:00
penev92
001efc9409 Added containing package name to asset tooltip 2022-01-09 18:40:32 +01:00
penev92
8d20487cb6 Added manual playing and stopping of audio in the AssetBrowserLogic
Also added visualisation of audio file length and progress and improved asset cleanup.
2022-01-09 18:40:32 +01:00
penev92
abea3a0f74 Fixed AudFormat and WavFormat implementations of ISoundFormat.LengthInSeconds
- Fixed a rounding issue in `WavReader.WaveLength()`.
- Fixed `AudReader.SoundLength()` not resetting the stream position.
- Fixed crashes caused by disposed streams because `LengthInSeconds` would try and calculate the length on the fly. It is now precalculated and cached (making it consistent across all 5 current `ISoundFormat` implementations).
- Fixed a crash in `AudReader.LoadSound()`'s `out Func<Stream> result` because that func would try and access the disposed stream's `Length` property. That works for `SegmentStream`, but not for `FileStream`.
- Fixed frameCount/soundLength label positioning in the AssetBrowser window to avoid text clipping .
2022-01-09 18:40:32 +01:00
penev92
8b944e9c82 Added audio playback to the AssetBrowser 2022-01-09 18:40:32 +01:00
penev92
7a9e0863d6 Added a scale slider for sprites in the AssetBrowser 2022-01-09 18:40:32 +01:00
penev92
40c728269c Added a scale slider for models in the AssetBrowser 2022-01-09 18:40:32 +01:00
penev92
6907081c2b Paused shellmap music when opening videos in the AssetBrowser 2022-01-09 18:40:32 +01:00
penev92
a058b1f5bd Split AssetBrowser supported formats
Splitting them from one array into separate allows us to then reliably pick how each asset should be presented. Also lets us unhardcode some checks like "if file is .vxl ... else is sprite".
2022-01-09 18:40:32 +01:00
abcdefg30
8ac2815c9e Fix the first Land ctor not passing targetLineColor on 2022-01-07 01:22:16 +01:00
abcdefg30
942a0c8712 Update an outdated comment in Land.cs 2022-01-07 01:22:16 +01:00
Matthias Mailänder
cdac14b92b Avoid duplicate field. 2022-01-06 16:10:49 +02:00
Matthias Mailänder
718bf88b9a Remove superflous null checks
and cache a dictionary lookup.
2022-01-06 01:54:27 +01:00
Ivaylo Draganov
eb4de47362 Add support for disabled click sound in scrollbar widget 2022-01-05 21:15:19 +01:00
Ivaylo Draganov
c3dfac7ade Remove redundant default hotkey UI notice 2022-01-04 18:35:41 +01:00
Ivaylo Draganov
5aeae694be Use disabled button state for slider thumb 2022-01-04 18:35:41 +01:00
Ivaylo Draganov
bdfe025059 Update introductory prompts to match settings layout 2022-01-04 18:35:41 +01:00
Ivaylo Draganov
8a2b63c944 Update lobby options tab layout to match settings layout 2022-01-04 18:35:41 +01:00
Ivaylo Draganov
9f96d4159a Update common game ingame info tabs to match settings layout 2022-01-04 18:35:41 +01:00
Ivaylo Draganov
955464ee1d Update TD game info panel to match the settings panel 2022-01-04 18:35:41 +01:00
Ivaylo Draganov
3ecaf76804 Overhaul settings panel layout
- make the panel larger
- place settings widgets in a scroll panel
- arrange settings widgets in two columns
- make tabs in TD vertical
2022-01-04 18:35:41 +01:00
Smittytron
a36eb585d3 Fix HiveGassed regression in Ant03 2022-01-04 12:50:00 +01:00
abcdefg30
bf7ec4aec1 Update nuget packages 2022-01-04 12:34:30 +01:00
abcdefg30
b448f2d324 Disable trimmed publishing 2022-01-04 12:34:30 +01:00
abcdefg30
b12c15ea9d Update to .NET 6 2022-01-04 12:34:30 +01:00
abcdefg30
eae6d33cd9 Fix highlighting of the credits tabs 2021-12-30 12:42:56 +00:00
Smittytron
3c24a3f9c7 Update Allies10a to work with Lua cleanup 2021-12-29 17:13:09 +01:00
Matthias Mailänder
bb27837149 Don't make support airplanes huntable. 2021-12-28 13:08:38 -06:00
Ivaylo Draganov
87534022b3 Make size and white-space of game save/load panel more consistent 2021-12-28 17:48:21 +01:00
Ivaylo Draganov
d2c08c72bd Adjust size, position and white-space of several panels 2021-12-28 17:48:21 +01:00
Ivaylo Draganov
0261dcaa7a Make size and white-space of "Mission Browser" panel consistent 2021-12-28 17:48:21 +01:00
Ivaylo Draganov
d14ba6b04d Make size and white-space of "Replay Browser" panel consistent 2021-12-28 17:48:21 +01:00
Ivaylo Draganov
a69d86c587 Make size and white-space of "Asset Browser" panel consistent 2021-12-28 17:48:21 +01:00
Ivaylo Draganov
8fb3bbe5f9 Make size and white-space of "Music" and "Credits" panels consistent 2021-12-28 17:48:21 +01:00
Matthias Mailänder
1c00a2fbec Bump NUnit slightly. 2021-12-27 22:33:06 +01:00
Matthias Mailänder
82ce4717aa Bump Pfim 2021-12-27 22:33:06 +01:00
Matthias Mailänder
2b23bde925 Bump NVorbis 2021-12-27 22:33:06 +01:00
Matthias Mailänder
bc52e8b6a9 Bump Mono.NAT 2021-12-27 22:33:06 +01:00
Matthias Mailänder
fb296d7dcb Bump Fluent.Net 2021-12-27 22:33:06 +01:00
Matthias Mailänder
6997b973ee Fix a null reference exception. 2021-12-17 14:11:19 +01:00
dnqbob
c968a2a902 Contrail smooth&color fix 2021-12-16 23:48:03 +01:00
Matthias Mailänder
5fcc049040 Fix a null reference exception. 2021-12-08 21:07:19 +01:00
Matthias Mailänder
ff20c1c59d Avoid unnecessary variable assignment. 2021-12-06 13:19:28 +01:00
Matthias Mailänder
2c5f1f343f Code style. 2021-12-06 13:19:28 +01:00
Matthias Mailänder
b147da388a Mark fields readonly. 2021-12-06 13:19:28 +01:00
Matthias Mailänder
4a60d56753 Add a lint tag and documentation. 2021-12-06 13:19:28 +01:00
Matthias Mailänder
9d905d8291 Remove unused parameters and variables. 2021-12-06 13:19:28 +01:00
Matthias Mailänder
07815143f1 Fix CA1825 warnings on empty array initialisation. 2021-12-06 13:19:28 +01:00
RoosterDragon
727084c5fc Run spell check over solution 2021-12-05 19:23:43 +01:00
Matthias Mailänder
b3d290edd9 Rename support power field for consistency. 2021-12-05 14:56:01 +01:00
Matthias Mailänder
9852bd08e4 Clean up existing rules. 2021-12-05 14:56:01 +01:00
RoosterDragon
3bde4ebbaf Fix Move.PathSearchOrder
Each successive value of BlockedByActor is a superset of the previous value. Having a mixed up order of values in PathSearchOrder is not useful.

In the previous ordering, if a search for Immovable failed to find a path, it would then attempt Stationary. However Stationary is *more* restrictive then Immovable. If Immovable failed, there is no way Stationary could succeed. This means the search for Stationary is wasted effort.

In the fixed ordering, we try Stationary first. In the fixed ordering there are no pointless searches. Every search might succeed where the previous one failed and is therefore useful to try.
2021-12-05 13:53:56 +01:00
Matthias Mailänder
f44a2ea9a3 Fix formatting problems. 2021-12-05 13:17:32 +01:00
Matthias Mailänder
5eaba4f893 Unhardcode AI defensive priorities. 2021-12-05 13:17:32 +01:00
Matthias Mailänder
e82aa9977e Unhardcode AI air units and exclude scripted aircraft. 2021-12-05 13:17:32 +01:00
Matthias Mailänder
00ece1ba55 Add configurable tooltips to the Discord integration. 2021-12-05 13:09:59 +01:00
Matthias Mailänder
c9022bcb73 Add support for superweapon detected sounds. 2021-12-05 13:02:15 +01:00
darkademic
c51327c4cc Make yaml check utility load each map separately to reduce memory usage. 2021-12-04 20:07:19 +01:00
Ivaylo Draganov
695b7865d3 fixup! Add support for non-overlapping sound notifications 2021-11-29 23:44:59 +01:00
Ivaylo Draganov
fa6ff32f65 Add support for non-overlapping sound notifications 2021-11-29 23:44:59 +01:00
RoosterDragon
137d384304 Remove path caching.
The path cache was originally a moderate benefit, but over time a couple of things have conspired against it:

- Only paths with BlockedByActor.None are cached. Originally all paths regardless of blocking were cached but this was deemed unacceptable due to potentially returning outdated paths as actors move about. Paths with BlockedByActor.None are only invalidated if terrain conditions change, which are rarer.
- Move will try and find a path 4 times, trying with a different BlockedByActor check each time. BlockedByActor.None is the last check and only reached if the other searches fail. This is a rare scenario.

Overall, this means the hit rate for the cache is almost non-existent. Given the constraints on path validity it seems unlikely that the hit rate could be improved significantly, therefore it seems reasonable to remove the cache entirely to remove the overhead of cache management.
2021-11-29 01:03:14 +01:00
Paul Chote
31bd32e7ef Allow launcher scripts to run from other working directories. 2021-11-28 23:09:32 +01:00
GeorgeD64
e00efbf53d Added map name support to Launch.Map command line parameter
Fixed code based on feedback

Replaced try/catch block with a null check and exception throw

Fixed code based on feedback

Fixed code based on feedback

Simplified Launch.Map parameter to use map name directly
2021-11-28 23:06:26 +01:00
Ivaylo Draganov
a537346580 Move selection hotkeys out of world interaction widget
- Split SelectionUtils for selecting actors in the world to a static class
- Split selection hotkeys into their own logic classes
2021-11-27 15:06:39 +01:00
Ivaylo Draganov
e9cc89a336 Yield keyboard focus upon leaving the ingame chat tab 2021-11-27 14:57:04 +01:00
Gustas
975da89400 RAGL balance changes 2021-11-27 13:33:55 +01:00
Matthias Mailänder
5ed3f55ed2 Use global idle hunt. 2021-11-26 23:39:41 +01:00
Matthias Mailänder
b9bfbfd5ac Use global objective initialisation. 2021-11-26 23:39:41 +01:00
Matthias Mailänder
d42edfc0b9 Use global difficulty. 2021-11-26 23:39:41 +01:00
Matthias Mailänder
58b105f0d4 Reorganize global .lua files. 2021-11-26 23:39:41 +01:00
Matthias Mailänder
a502e85e68 Fail gracefully when there is just one default difficulty. 2021-11-26 23:39:41 +01:00
RoosterDragon
a59f4b2c4a Add a helper for multiplying by sqrt(2) 2021-11-25 22:50:22 +01:00
RoosterDragon
f0e24f6d21 Make knowledge of height discontinuities live in Locomotor not PathGraph. 2021-11-21 17:52:12 +01:00
RoosterDragon
8c627aa185 Clean up PathSearch
- Remove functionality for tracking cells considered during the search, as nothing relies on this.
- Rename various parameters in the expand function to closer match naming of fields used in CellInfo, intended to improve clarity.
2021-11-21 12:03:16 +01:00
Orb370
e1ade59a32 TD Balance Fall 2021 Commit
TD-Balance-Fall-2021 Commit

TD-Balance-Fall-2021-Commit
2021-11-20 17:37:43 -06:00
RoosterDragon
290ed17c9d Adjust some naming and order of parameters in CellInfo
- Make Status the first field.
- Rename EstimatedTotal to EstimatedTotalCost to make it clearer it has the same unit as the CostSoFar field.
- Rename PreviousPos to PreviousNode as node terminology is a better match for usage.
2021-11-20 12:13:42 +01:00
Matthias Mailänder
98b25ddd5e Check for dead actors when searching for exits. 2021-11-18 20:52:05 +01:00
RoosterDragon
31267aa22d Fix some incorrect logic in PathGraph.GetConnections.PathGraph
Firstly, when dealing with maps with height discontinuities, the neighbouring cells we need to search are more that the set we need to search on flat maps. We ensure that as we traverse a map with varying height, we now consider cells "behind" us that may have become accessible due to a height change.

Secondly, when considering connections available via Custom Movement Layers, make sure the target cell on the new layer is actually enterable. Previously this cell would be reported as a valid connection, even if it wasn't actually possible to enter the cell as it was blocked. We also apply the same optimization of ignoring already closed cells.
2021-11-16 00:33:19 +01:00
RoosterDragon
1d23c23d06 Adjust span comparisons for clarity and add some test cases. 2021-11-15 13:20:34 +01:00
RoosterDragon
5416910249 Remove unused method in MiniYaml 2021-11-15 13:20:34 +01:00
RoosterDragon
73547c31ec Remove MiniYamlNodes alias in MiniYaml. 2021-11-15 13:20:34 +01:00
RoosterDragon
2db312a792 In MiniYaml, presize some collections and trim lists during parsing. 2021-11-15 13:20:34 +01:00
RoosterDragon
0f01df5474 Avoid string allocations in MiniYaml parsing.
- Stream lines in as memory rather than needing to realise a string for each line, via a new method in StreamExts.
- Use span to avoid string allocations during parsing until we want to realise the node itself, in MiniYaml.FromLines.
- Change several callsites to use the streaming extension method rather than string method where possible.
2021-11-15 13:20:34 +01:00
penev92
270c566570 Fixed the Windows make script building in Release
This is a follow-up to PR 19379, which aimed to "provide an easy debug option for VSCode developers", but only did so for non-Windows users. VSCode has been building in Release mode for ever and continued to do so on Windows after that PR.
2021-11-14 10:07:18 +00:00
RoosterDragon
225bcbbd22 Normalize all support dir paths to end with a directory separator.
Previously, some paths used a separator and some did not. This broke some de-duplication logic in ExternalMods which tried to enumerate distinct paths but would end up running logic on the same directory more than one as it was provided both with and without a trailing directory separator. By normalizing the path this logic now works.
2021-11-13 22:24:43 +01:00
Vapre
d53601daa6 World, SyncHash, cache per tick. 2021-11-13 21:46:40 +01:00
RoosterDragon
dd9d600ef9 Change GetCustomMovementLayers to expose an array, not a dictionary.
As there are few custom movement layers, using an array is good for improving lookup speed. Additionally, we can simplify some code by reserving index 0 of the array for the ground layer. Code that needs to maintain a state for the ground layer and every custom movement layer can now maintain a flat array of state using index 0 for the ground layer, and the the ICustomMovementLayer.Index for the custom movement layer. This removes a lot of ternary statements checking for the ground layer special case.
2021-11-13 12:15:48 +00:00
Ivaylo Draganov
3310f14dea Use mission notifications pool with appropriate chat line template 2021-11-12 22:30:07 +01:00
penev92
a71da0a25a Unhardcoded engine credits file
Moved the file name/path to ModCredits, read from mod.yaml
2021-11-12 22:24:44 +01:00
Matthias Mailänder
9b1cec7712 Add support for gapless looping music. 2021-11-11 23:49:54 +01:00
abcdefg30
9916e4c4ac Fix a crash in the TSEditorResourceLayer neighbour validation 2021-11-11 15:09:24 +01:00
abcdefg30
31cec0c17f Fix a crash in the TSResourceLayer neighbour validation 2021-11-11 15:09:24 +01:00
reaperrr
430c7a4d7d Fix TD voice crashes
The original PR used too much copy-paste.
2021-11-08 14:46:41 +01:00
Matthias Mailänder
7d83d4d47f Add OmniSharp settings. 2021-11-08 14:41:34 +01:00
Matthias Mailänder
2fa1c05ed0 Ignore workspace settings. 2021-11-08 14:41:34 +01:00
Matthias Mailänder
f7fd3dfff8 Remove workspace settings. 2021-11-08 14:41:34 +01:00
abcdefg30
93c45255f1 Move a using into the Mono specific code path 2021-11-07 00:26:15 +01:00
abcdefg30
280dd8e2a5 Update launch-game.cmd to specify Engine.LaunchPath and support restarting 2021-11-06 11:21:13 +01:00
Paul Chote
5d83706eae Require an explicit launch path for mod registrations.
This also removes a workaround that allowed the current mod to be
registered even if it defined a bogus path. Uses of Game.ExternalMods
should therefore always use TryGetValue and correctly handle it
returning false.
2021-11-06 11:21:13 +01:00
Paul Chote
4275e87c57 Show an error prompt if restart mod switch fails. 2021-11-06 11:21:13 +01:00
Gustas
c5a6577cee Fix production scalling 2021-11-05 00:01:21 +01:00
Matthias Mailänder
ade5d211e9 IRC moved to Libera 2021-10-31 17:02:00 +01:00
Matthias Mailänder
e05b86b935 Recommend the OpenRA Lua extension. 2021-10-30 13:11:14 +02:00
Matthias Mailänder
e8ee31cd6e The launch settings have been migrated to .NET Core already. 2021-10-30 13:11:14 +02:00
Matthias Mailänder
59bed108b1 Minor csharp warning fixes. 2021-10-30 13:11:14 +02:00
abcdefg30
05420ab5ce Fix the Windows packing script not working with wget only 2021-10-29 22:25:59 +02:00
abcdefg30
32bc561878 Add a check for wine64 to the Windows packaging 2021-10-29 22:25:59 +02:00
abc013
311b6fcd83 Don't count actors owned by noncombatant players to kills statistic 2021-10-29 21:07:06 +02:00
abc013
c0da9f1eab Fix walls counting to kills/deaths statistic 2021-10-29 21:07:06 +02:00
Ivaylo Draganov
98434ef96b Add audio feedback for selection hotkeys 2021-10-29 20:55:41 +02:00
Ivaylo Draganov
9b9c116097 Add text feedback for type selection hotkey when selection is empty 2021-10-29 20:55:41 +02:00
Ivaylo Draganov
3c77df276a Add full-stop to UI feedback text notifications 2021-10-29 20:55:41 +02:00
Ivaylo Draganov
a680cae00c Move audio muted/unmuted notifications to feedback pool 2021-10-29 20:55:41 +02:00
Ivaylo Draganov
01d47566cc Add a transients panel with corresponding chrome logic and a notification template 2021-10-29 20:55:41 +02:00
Ivaylo Draganov
9e92340ea7 Rework chat line templates and logic
- Extract chat line templates and logic so they can be reused across widgets
- Make text notification styling entirely template driven (by removing chat color configuration and making color optional for `TextNotification`)
- Add a new TextNotificationsDisplay widget (based on and replacing ChatDisplayWidget)
- Add timestamp support to text notifications
2021-10-29 20:55:41 +02:00
abc013
8416dc3f2d Fix wrong subcell offsets for TS 2021-10-27 21:53:39 +02:00
abc013
c33290c19b Display error message instead of stack trace in battlefield news when failing to fetch news 2021-10-27 18:40:52 +02:00
teinarss
1a56cee9a1 Add Tick scale plumbing 2021-10-26 22:40:15 +02:00
Oliver Brakmann
7f3130c7a6 Use TimeLimitManager in mission Allies10a 2021-10-26 16:40:47 +02:00
Oliver Brakmann
be4466115d Do not update countdown label unless there is a timelimit 2021-10-26 16:40:47 +02:00
Smittytron
0c42f59656 Add Allies10a 2021-10-26 16:40:47 +02:00
Orb370
3a56532f0b Fix Europe Map Commit
Fix Europe Map Commit

Fix Europe Map Commit

Fix Europe Map Commit
2021-10-26 16:18:18 +02:00
abc013
442752b6ba Fix owner of selected actor not always being selected owner in editor 2021-10-24 22:54:10 +02:00
abc013
0898655175 Fix radar preview not updating when editing actor owner 2021-10-24 22:54:10 +02:00
RoosterDragon
3bee524c6b Avoid allocation in PackageEntry.HashFilename
This is a very frequently called method during loading, and taking some care to avoid allocations improves performance noticeably.
2021-10-24 21:40:01 +02:00
RoosterDragon
2ed4cb8aff Ensure Clear(T) also have a safety check to ensure no listener is attached.
Move related methods next to each other.
Change Clear(T) to use Array.Fill.
2021-10-23 15:43:47 +02:00
RoosterDragon
19760b04bd Allow the default value of a CellInfo to be an Unvisited location.
In CellInfoLayerPool, instead of having to store a layer with the default values, we know we can just clear the pooled layer in order to reset it. This saves on memory, and also makes resetting marginally faster.

In PathSearch, we need to amend a check to ensure a cell info is not Unvisited before we check on its cost.
2021-10-23 15:43:47 +02:00
Matthias Mailänder
6edd5d7bfa Avoid an unnecessary assignment. 2021-10-22 22:02:15 +02:00
Matthias Mailänder
a3ccc81892 Remove unused fields and parameters. 2021-10-22 22:02:15 +02:00
Matthias Mailänder
3b5bfb4bf4 Avoid initialisation of empty arrays. 2021-10-22 22:02:15 +02:00
Matthias Mailänder
5ff9d9a1f1 Add missing flags attribute required for HasFlags. 2021-10-22 22:02:15 +02:00
penev92
f056cbba13 Added a bunch of TraitLocationAttributes
Also moved a few traits to their proper subfolders.
2021-10-16 20:52:50 +02:00
penev92
67598dd151 Moved some traits from ^BaseWorld to World in TS 2021-10-16 20:52:50 +02:00
Paul Chote
166583b1ec Fix disabled chat focus issues. 2021-10-16 13:34:39 -05:00
penev92
e1e76411f7 Added a rule for unused usings to OpenRA.ruleset
Unfortunately due to bugs in the analyzers or something else, the IDE0005 doesn't work as expected. The "officially suggested" workaround is to enable XML documentation generation to trigger IDE0005 during compiling. Then we need to add three more rules to silence the warnings that come from the XML documentation generation. We also need to enable code style enforcing on build for all of this to work.
Known issue is that all of this produces a bunch (tens to hundreds) of obscure analyzer warnings on older versions of Visual Studio, but those seem to not be causing issues.
2021-10-15 13:12:33 +02:00
penev92
8ba6d13b2f Removed unused using directives 2021-10-15 13:12:33 +02:00
Matthias Mailänder
3790a4a6a4 Fix actor has multiple AttackBase traits. 2021-10-15 12:11:35 +02:00
abcdefg30
e8e0e155e5 Explain the try-finally clause in Sync.cs in a comment 2021-10-14 19:45:29 +02:00
abcdefg30
b366db7175 Revert "Directly run unsynced functions if we don't check sync hashes"
This reverts commit 1dc0a603c7.
2021-10-14 19:45:29 +02:00
penev92
3ce32fe354 Added faction-specific units for colorpicker previews in TS 2021-10-13 23:59:11 +02:00
Matthias Mailänder
2b361ad41e Add a link to the web chat
as ircs:// isn't linked on GitHub
and not everyone is familiar with IRC clients
2021-10-12 10:57:35 +02:00
Matthias Mailänder
f9f540f47e Website repository has changed. 2021-10-12 10:57:35 +02:00
Matthias Mailänder
c9b0ddf772 Add a link to Discord with badge. 2021-10-12 10:57:35 +02:00
Matthias Mailänder
139af0c2bc Fix a crash when building placements are moved out of the map. 2021-10-12 10:47:34 +02:00
Orb370
d88198e61e Allow Targeting While Defenses are in the Construction Animation Commit 2021-10-11 17:49:44 -05:00
RoosterDragon
df9398a871 Use named pathfinding constants.
- Rename CostForInvalidCell to PathCostForInvalidPath
- Add MovementCostForUnreachableCell
- Update usages of int.MaxValue and short.Maxvalue to use named constants where relevant.
- Update costs on ICustomMovementLayer to return short, for consistency with costs from Locomotor.
- Rename some methods to distinguish between path/movement cost.
2021-10-10 17:09:38 +02:00
abcdefg30
884e6cdb51 Exempt D2k Harvesters from slowness modifiers applied when damaged 2021-10-09 14:55:27 -05:00
abcdefg30
4269fc67d5 Remove hacks around checking sync while disposing the shellmap 2021-10-09 21:13:35 +02:00
abcdefg30
69248132ad Don't desync while the world is disposing 2021-10-09 21:13:35 +02:00
abcdefg30
1dc0a603c7 Directly run unsynced functions if we don't check sync hashes 2021-10-09 21:13:35 +02:00
Ivaylo Draganov
091d756c14 Change lobby options description to make sense in both disabled and enabled state 2021-10-09 08:43:28 -05:00
RoosterDragon
9bcbbdd3fc Remove unused code in Move. 2021-10-09 00:02:00 +02:00
abcdefg30
a930c123ed Initialize the Discord rich presence with an empty presence 2021-10-08 00:47:10 +03:00
abcdefg30
62c083bb01 Remove a bogus and unneeded import 2021-10-08 00:47:10 +03:00
Raf Czlonka
5cc1405f3f Update links
- _http_ `->` _https_ where appropriate
- _wiki.openra.net_ `->` _https://github.com/OpenRA/OpenRA/wiki_
- _bugs.openra.net_ `->` _https://github.com/OpenRA/OpenRA/issues_
- the IRC channel is now on Libera.Chat + make it into a URI

This is in order to be consistent (one link to GitHub wiki already
exists), reflect reality, as well as avoid unnecessary redirects.
2021-10-07 12:38:36 -05:00
VonNah
0e33d08384 Fixed incorrect voice lines for Generic-, Vehicle-, Moebius- and CommandoVoice.
Signed-off-by: VonNah <vonnahora@gmail.com>
2021-10-03 19:39:28 -05:00
abcdefg30
dc11b82fc9 Fix a NRE in DeliverUnit.ReleaseUnit.OnFirstRun 2021-10-02 22:01:24 +01:00
RoosterDragon
6e0917169d Teach FieldLoader.ParseCPos about CPos.Layer. 2021-10-02 21:54:26 +01:00
RoosterDragon
4cc33b2871 Add some ToString overrides to improve debug experience. 2021-10-02 21:54:26 +01:00
RoosterDragon
3a020e96fe Update ICustomMovementLayer to not depend on actor for costs.
No implementations require the actor.
2021-10-02 21:47:24 +01:00
RoosterDragon
6f3b4ecae9 Speed up Map.Contains checks for non-flat maps.
We observe that most cells within a map lie within a region where no matter their height, their projection would still remain in map bounds. We can utilise this to perform a fast check for such cells and skipping the expensive checks on their actual height. We only need to check the actual height of a cell if this could cause the projection to go out of bounds.
2021-10-02 21:43:11 +01:00
abcdefg30
d370cb48c5 Remove unreachable code in TransformsIntoTransforms 2021-10-02 21:34:51 +01:00
KonH
9ed809943d Just use Dispose methods without arguments (disposing always passed as true) 2021-10-02 22:14:08 +02:00
KonH
8bce6eb3ac Remove GC.SuppressFinalize calls from classes without destructors 2021-10-02 22:14:08 +02:00
teinarss
279e7eb1c9 Disable Stylecop on debug config 2021-10-02 21:13:58 +02:00
Paul Chote
defaf92752 Send order queue length in ping responses. 2021-10-02 21:03:00 +02:00
Paul Chote
2d08f2bbfd Allow the server to ack no or multiple packets in the same frame. 2021-10-02 21:03:00 +02:00
Zimmermann Gyula
a13d046304 Add twinkle effects to the gems. 2021-10-02 20:17:03 +02:00
Matthias Mailänder
a2a668077c Refactor RandomDelay:
Allow different types of random
and reflect other use cases by renaming.
2021-10-02 20:17:03 +02:00
RoosterDragon
3a7aeb5324 Ensure TargetLineRenderable width and marker size don't get lost.
By making the constructor take non-optional parameters, this highlights some calls sites which were forgetting to set these values. These are now fixed.

Set the path debug to have a marker size of 2 for better visibility.
2021-10-02 12:14:54 +01:00
Vapre
9d4d4bb924 Locomotor, PathGraph, trivial optimizations. 2021-10-01 22:21:47 +02:00
tovl
a428aaa602 Make sure OpenAlSound.Source is never accessed after the source is freed for reuse 2021-10-01 21:15:52 +02:00
tovl
2bc03b4d84 Fix OpenAlSound.Complete being incorrect when OpenAl source is reused. 2021-10-01 21:15:52 +02:00
teinarss
289c4ef2b7 Remove Microsoft.DotNet.PlatformAbstractions 2021-09-29 20:52:44 +02:00
teinarss
80b6a5a27f Update nuget packages 2021-09-29 20:52:44 +02:00
Ivaylo Draganov
7f2ac477a2 Improve Game.Mod argument check in launch script 2021-09-28 21:44:53 +02:00
Ivaylo Draganov
69b375dc48 Replace zenity select dropdown with a list 2021-09-28 21:44:53 +02:00
Vapre
e8bae2e50a Crash on capture fix. #19482. 2021-09-27 21:19:12 +01:00
Matthias Mailänder
6b3eee8481 Don't just swallow the web exception. 2021-09-27 20:16:22 +02:00
Paul Chote
3d73d5ef29 Remove incorrect comment and merge nested conditionals. 2021-09-27 19:48:05 +02:00
Paul Chote
a0d49729f5 Ignore modifiers when applying terrain damage. 2021-09-27 19:31:25 +02:00
Ikko Ashimine
a573052f2e Fix typo in rules.yaml
recieved -> received
2021-09-27 18:08:05 +02:00
Ivaylo Draganov
994ba35507 Add description to difficulty lobby option for missions 2021-09-26 21:25:08 +01:00
Ivaylo Draganov
2d178f5033 Do not center lobby options vertically in the scroll panel 2021-09-26 21:25:08 +01:00
Ivaylo Draganov
f018fdecdd Remove special handling for cases when there's only one game info tab
The addition of the lobby options tab ensures that there will always
be at least two tabs ("Objectives" and "Options").
2021-09-26 21:25:08 +01:00
Ivaylo Draganov
fa0adb5a1b Hide various lobby options from missions and minigames 2021-09-26 21:25:08 +01:00
Ivaylo Draganov
3e0834b4ef Display lobby options in-game on a dedicated tab 2021-09-26 21:25:08 +01:00
RoosterDragon
fc5f8fcd31 Fix indent 2021-09-26 15:49:48 +02:00
RoosterDragon
2f955e01f5 Fix style errors 2021-09-26 15:49:48 +02:00
Paul Chote
c958bf9680 Restore threaded renderer. 2021-09-26 15:19:20 +02:00
Matthias Mailänder
98b87004cc Bump SharpZipLib. 2021-09-26 11:18:15 +01:00
Paul Chote
8588af1001 Disable chat for the first 5s (configurable) after joining a server. 2021-09-23 12:52:20 +02:00
teinarss
9eab92e90a Add Rich Presence button with link to website 2021-09-22 15:57:54 +02:00
Paul Chote
2424ddc79a Move NetTickScale (now NetFrameInterval) control to the server. 2021-09-21 15:12:36 +02:00
Paul Chote
df798fb620 Overhaul client latency calculations.
The ping/pong orders are replaced with a dedicated
(and much smaller) Ping packet that is handled
directly in the client and server Connection wrappers.

This allows clients to respond when the orders are
processed, instead of queuing the pong order to be
sent in the next frame (which added an extra 120ms
of unwanted latency).

The ping frequency has been raised to 1Hz, and pings
are now routed through the server events queue in
preparation for the future dynamic latency system.

The raw ping numbers are no longer sent to clients,
the server instead evaluates a single ConnectionQuality
value that in the future may be based on more than
just the ping times.
2021-09-21 15:12:36 +02:00
Paul Chote
67face8cf0 Rename connection packet handling. 2021-09-21 15:12:36 +02:00
Paul Chote
4eefa637a3 Remove obsolete threaded renderer workarounds. 2021-09-20 22:33:25 +02:00
Paul Chote
be8e2cf3a4 Move OpenGL context creation to the main thread. 2021-09-20 22:33:25 +02:00
Matthias Mailänder
f08a0b113e Allow mods to customize application title. 2021-09-19 22:29:50 +02:00
Matthias Mailänder
3a8957c6f3 Remove unused function parameter. 2021-09-19 22:29:50 +02:00
Smittytron
99006a02ed Add destroy triggers for prison actors in Allies03a 2021-09-18 21:26:10 +02:00
Smittytron
77e1e77387 Use FireClusterWarhead with barrels 2021-09-18 21:26:10 +02:00
Matthias Mailänder
0604a58581 Send a ping when the server is shut down
and stop the LAN beacon.
2021-09-18 17:38:52 +01:00
Matthias Mailänder
58e482c05a Fix hashset documentation. 2021-09-18 13:16:25 +01:00
Matthias Mailänder
eba266aecf Use MarkDown tables in trait documentation export. 2021-09-18 12:52:27 +01:00
Matthias Mailänder
5bf4daddec Set the default game name to the player name. 2021-09-15 18:39:24 +02:00
Paul Chote
54c08748e0 Overhaul player disconnect notifications. 2021-09-12 22:53:50 +02:00
abcdefg30
b8e343bee9 Fix Phase Transports not uncloaking while unloading 2021-09-12 10:47:33 +02:00
Vapre
5ae4662f08 RunUnsynced, do not recalculate sync hash on reentry. Cache debug settings. 2021-09-12 10:06:44 +02:00
Paul Chote
b3159d7515 Fix d2k map editor crash if spice is placed at the edge of map. 2021-09-09 10:19:17 +02:00
abcdefg30
a1e62158e2 Add a workaround for "Check around synced code" problems 2021-09-08 20:26:53 +02:00
abcdefg30
777d966958 Remove unnecessary server creation when creating a new map 2021-09-08 20:26:53 +02:00
abcdefg30
0b75991fbc Make the editor use an EchoConnection instead of a local server 2021-09-07 20:45:50 +02:00
Paul Chote
e0e219793f Fix shellmap OrderManager use after dispose. 2021-09-02 23:23:23 +02:00
Paul Chote
8f412f869d Move order latency control to the server. 2021-09-02 23:23:23 +02:00
Paul Chote
6421c17515 Rework IConnection implementations:
* EchoConnection is now a trivial buffer that stores
  and repeats orders directly without serialization.

* NetworkConnection no longer subclasses EchoConnection,
  and now also caches local orders without serialization.

* Replay recording was moved to NetworkConnection
  (it is never used on EchoConnection).
2021-09-02 23:23:23 +02:00
Paul Chote
408f30b5cd Extract OrderIO.SerializeOrders helper.
Note: This changes immediate orders to no longer be
individually framed in their own packets.
2021-09-02 23:23:23 +02:00
teinarss
db74f155bb Update DropClient to always drop Connection 2021-09-02 08:05:37 +02:00
Matthias Mailänder
978de64903 Don't count suicides into the game score. 2021-09-02 08:00:44 +02:00
Matthias Mailänder
e616cd1bcb Save the player color in the introduction panel. 2021-09-02 07:39:54 +02:00
Andre Mohren
2c84c43607 Fixed odd sprite size "frame hopping". 2021-09-02 07:34:13 +02:00
Paul Chote
442d91537e Don't display spectator info for scripted players. 2021-08-28 23:15:02 +02:00
Paul Chote
7f92d64d84 Disable replay player visibility dropdown in singleplayer missions. 2021-08-28 23:15:02 +02:00
Paul Chote
c7700a8a2b Fix DropDownButtonWidget ignoring yaml separator overrides. 2021-08-28 23:15:02 +02:00
Paul Chote
e389c00a11 Remove packet byte wrangling from OrderManager. 2021-08-26 22:00:59 +02:00
Paul Chote
52b597d5d2 Remove order latency checks from BaseBuilderQueueManager. 2021-08-26 22:00:59 +02:00
Paul Chote
8a587ddeab Disable depth-buffer command if EnableDepthBuffer is disabled. 2021-08-25 17:42:44 +02:00
Paul Chote
512dee0ac0 Fix rendering glitches with EnableDepthBuffer disabled. 2021-08-25 17:42:44 +02:00
Matthias Mailänder
024beacafb Don't smear the paste while moving the mouse. 2021-08-22 16:06:21 +02:00
teinarss
b4256df9c1 Cleanup in Connection 2021-08-22 09:43:25 +01:00
reaperrr
c860bf19ee Add GDI 05c
Well, 05eb really, but until we implement campaign progression,
calling it 'c' is the easiest way to differentiate it without breaking
our mission title length/alignment conventions.
2021-08-21 20:34:50 +02:00
Paul Chote
06ea7bf923 Regenerate TS map previews. 2021-08-21 14:16:02 +02:00
Paul Chote
3551eb3128 Fix map preview bounds calculation. 2021-08-21 14:16:02 +02:00
Paul Chote
7f94d67d39 Replace Map.CustomTerrain radar colors with IRadarTerrainLayer.
* TSVeinsRenderer now shows border cells on the radar
* BuildableTerrainLayer now uses the radar colors defined on the individual tiles
* CliffBackImpassabilityLayer no longer overrides the underlying terrain color.
2021-08-21 14:16:02 +02:00
Paul Chote
72c0c7e38b Remove rocks and trees from TS minimap previews. 2021-08-21 14:16:02 +02:00
Paul Chote
2a2785d8c9 Fix model debug sprite rectangle rendering. 2021-08-21 13:45:41 +02:00
Paul Chote
7a3dae428a Work around clipping on ramp type 7. 2021-08-21 13:45:41 +02:00
Paul Chote
dcd3e8d444 Ignore terrain slopes when calculating model shadows.
This is less realistic, but better matches the original
game and is the only practical way to reduce visual issues
caused by long shadows being cast over multiple cells.
2021-08-21 13:45:41 +02:00
Paul Chote
68710e48a6 Add terrain orientation support for Mobile. 2021-08-21 13:45:41 +02:00
Paul Chote
c88d1bbefa Add WRot SLerp and axis-angle ctor.
These allow more complex calculations to be made
using rotations.
2021-08-21 13:45:41 +02:00
Paul Chote
d509d3f5f9 Fix carryall InitialActor creation. 2021-08-20 21:04:18 +02:00
Smittytron
8a4945d20a Polish and standardize Allies01 2021-08-20 20:48:05 +02:00
Andre Mohren
0ea6a5626f Do not enforce mods to use stylecop. 2021-08-20 20:45:31 +02:00
Paul Chote
864cc4becc Fix weather particle physics.
The trait documentation specified that the speed
and offset values are px/tick, but they have actually
always been treated as px/render.

Fix the update logic and rescale the map definitions
to account for the fixed behaviour.
2021-08-20 20:38:37 +02:00
Paul Chote
d2257f9784 Fix macOS compat build dock icon, app name, dark mode support. 2021-08-20 20:34:23 +02:00
Paul Chote
f70457a66f Remove unused symbol lookups. 2021-08-20 20:34:23 +02:00
Paul Chote
278a4acf96 Fix Engine.LaunchPath for macOS compatibility builds. 2021-08-20 20:34:23 +02:00
Paul Chote
be3412ee74 Fix depth offsets for sprite with non-zero ZRamp.
Bibs and other effects that should be drawn at ground level
can now simply define ZRamp: 1, Offset: <X>,<Y>,1, avoiding the
need to account for the Y offset or internal sprite offsets.
2021-08-20 20:17:55 +02:00
Paul Chote
27f9f35efb Fix incorrect world height to screen depth conversion. 2021-08-20 20:17:55 +02:00
Paul Chote
ef1aee5e95 Fix and document the depth buffer calculations. 2021-08-20 20:17:55 +02:00
Paul Chote
962d6496bd Overhaul depth preview rendering:
* Replace Jet color map with grayscale
* Added Shift + \ hotkey to toggle preview
* Added Shift + [, Shift + ] hotkeys to change contrast
* Added Shift + ;, Shift + ' hotkeys to change offset
2021-08-20 20:17:55 +02:00
Paul Chote
91c5f2cabe Add Cityscape map. 2021-08-20 20:17:55 +02:00
Paul Chote
a9c6430924 Fix TS map importer:
- Fix infantry subcells and facing
- Import sandbags/walls.
2021-08-20 20:17:55 +02:00
Vapre
2ea2815529 CallFunc, avoid null check. 2021-08-20 12:31:04 +02:00
Paul Chote
5eb4c6a0bb Set _KDE_NET_WM_DESKTOP_FILE x11 window property.
This explicitly tells KDE to associate the OpenRA window with
the integrated appimage desktop file, allowing it to use the
correct resolution icon for the task switcher.
2021-08-16 20:18:00 +02:00
abcdefg30
4145723ef0 Remove Sdl2HardwareCursorException 2021-08-14 17:11:34 +01:00
abcdefg30
b8ba1b36fe Don't throw an exception when creating a hardware cursor fails 2021-08-14 17:11:34 +01:00
Matthias Mailänder
f63e15f5de Fix igloos being labeled as haystacks in-game. 2021-08-11 19:09:20 -05:00
MustaphaTR
2f44b016b0 Add a condition per tileset. 2021-08-11 19:09:20 -05:00
Matthias Mailänder
b7bba5d55a Restrict sonar pulse to unshrouded water. 2021-08-11 22:46:19 +02:00
teinarss
fba4c5049c Replace Thread.CurrentThread.ManagedThreadId with Environment.CurrentManagedThreadId 2021-08-10 23:02:18 +02:00
Vapre
573a6cf645 FindAndDeliverResources, trivial optimizations. 2021-08-10 23:59:43 +03:00
reaperrr
eff7e803bf Minor MoveOrderTargeter optimization
IsTraitPaused should be cheaper than Map.Contains,
so let's perform the cheaper check first.
2021-08-10 18:26:05 +02:00
reaperrr
58f55b808a Add comment in Mobile
This isn't obvious to people not entirely familiar
with the code.
2021-08-10 18:26:05 +02:00
reaperrr
777a927c04 Cache unchanging values for MoveWithinRange
In theory, CandidateMovementCells could be called
every tick, so let's avoid creating the vars
every time.
2021-08-10 18:26:05 +02:00
Matthias Mailänder
0249116206 Rename instant to fast charge to avoid tab complete clash. 2021-08-09 13:17:47 -05:00
Ivaylo Draganov
2d0e7040db Add separate chat panel for spectators and players
Forces the chat and performance panels to be re-initialized when a
player transitions to spectators. This ensures that spectators don't
get to see faction themed widgets.
2021-08-08 12:50:31 +01:00
Paul Chote
edd3a2eb75 Fix ingame menu tab display. 2021-08-07 13:12:56 -05:00
Paul Chote
29f4f5a0cd Remove redundant ts ingame-info.yaml. 2021-08-07 13:12:56 -05:00
abcdefg30
ba7e1319ac Remove DisableWindowsRenderThread and use threaded renderering for non windowed mode 2021-08-07 14:49:09 +01:00
Ivaylo Draganov
7a1169744e Add tooltips to map name and author in map chooser 2021-08-05 18:36:50 +02:00
abcdefg30
453d59ae16 Defer rollover checks while generating selection decorations 2021-08-05 01:43:35 +03:00
Vapre
35e9fade06 PathGraph, skip closed cells early. Fix #19579. 2021-08-04 20:02:12 +02:00
Paul Chote
8fc042fed1 Fix style nits in OrderEffects. 2021-08-02 21:50:32 +02:00
Paul Chote
2c5fce5e3c Add missing TraitLocation to OrderEffects. 2021-08-02 21:50:32 +02:00
Paul Chote
7a93ff3258 Add support for TS-style tinted target flashes. 2021-08-02 21:50:32 +02:00
Paul Chote
9291263609 Fix indentation in OrderEffects. 2021-08-02 21:50:32 +02:00
Matthias Mailänder
f4a5878a53 Fix veinholes on Sunstroke. 2021-08-01 14:56:53 -05:00
Paul Chote
1ecb3bf99a Don't add empty Translations nodes to maps. 2021-07-31 13:14:46 +02:00
reaperrr
c88994a0dd Fix unarmed civilians being selected as combat units 2021-07-30 09:03:29 -05:00
fruehstueck
29b0999da3 Add GDI 8b 2021-07-30 09:03:29 -05:00
Paul Chote
b08117dc93 Don't report "Primary Building Selected" when nothing changes. 2021-07-29 16:19:53 +02:00
Paul Chote
99322cee8f Set the closest production to Primary when force-targeting rallypoints. 2021-07-29 16:19:53 +02:00
Vapre
e201e410f4 PathGraph, skip closed cells early.
In path finding GetConnections considers connections to already closed cells and calculates the cost for them. The caller afterwards ignores them. These are 15% of all connections.
2021-07-27 14:49:22 +02:00
Paul Chote
24f64ae1a8 Fix an edge case where the wrong sheet may be mapped to a depth sprite. 2021-07-25 19:20:19 +02:00
Ivaylo Draganov
1f3f489328 Show map preview tooltip only if needed 2021-07-25 00:25:08 +01:00
Ivaylo Draganov
31056d4253 Add tooltip to overflowing map title in server browser 2021-07-25 00:25:08 +01:00
Paul Chote
70892a6661 Change DrawSprite calls to provide scales instead of sizes.
This allows us to remove a hacky workaround for calculating
depth offsets when sprites have size.Z == 0.
2021-07-25 00:32:17 +02:00
Paul Chote
8e94e1d5ec Rework WidgetUtil sprite rendering helpers. 2021-07-25 00:32:17 +02:00
Vapre
2e6f444285 Map.Contains check grid type once. 2021-07-24 15:34:56 +02:00
abcdefg30
dcaa658678 Remove an outdated reference to ConditionManager 2021-07-23 11:04:07 -05:00
Hang
249bc4abc8 Fix the hide-map sequence of the d2k crate-effects
Frame 4218 belongs to explosion/nuke sequence, which should not part of crate-effects/hide-map sequence
2021-07-22 23:13:16 +02:00
Hang
757ca0561f Update misc.yaml
Typo Lenght -> Length
2021-07-21 13:36:25 +02:00
Vapre
001134ce59 Do not start DiscordService client if disabled. 2021-07-21 12:13:21 +02:00
Paul Chote
f8ed768e39 Change makefile/packaging "RUNTIME=dotnet" to "RUNTIME=net5". 2021-07-18 20:57:22 +02:00
Chris Harris
1c6ca394c1 Fix duplicate ActorIDs 2021-07-17 23:27:25 +02:00
Vapre
627fd4e68b CellLayer.Index inline CPos.ToMPos. 2021-07-16 09:51:55 +02:00
Paul Chote
7bfe83cce7 Fix WithIdleOverlay PlayerPalette editor rendering. 2021-07-15 12:05:09 +02:00
Matthias Mailänder
d169210531 Display the production overlay only where the unit will exit. 2021-07-14 19:06:22 -05:00
Matthias Mailänder
902006bf53 Fix editor losing copy after each paste. 2021-07-13 21:01:33 -05:00
Mustafa Alperen Seki
dcb70d12e3 Make Harvester conditional. 2021-07-12 15:41:04 +02:00
Matthias Mailänder
cd90c70cdf Fix a null reference exception. 2021-07-12 15:20:34 +02:00
Matthias Mailänder
f1f5df3749 Fix .shp icons being misdetected as .wsa animations. 2021-07-12 11:49:06 +02:00
Matthias Mailänder
b2f18ad0ad Add support for .ogg files. 2021-07-12 00:35:16 +02:00
Matthias Mailänder
af0b7621d2 Minor fixes. 2021-07-12 00:35:16 +02:00
Matthias Mailänder
2bd7869059 Fix haystacks being selectable buildings. 2021-07-12 00:15:38 +02:00
Matthias Mailänder
e1816a6da0 Fix a crash when opening map Chernobyl with the editor. 2021-07-11 16:38:27 +01:00
teinarss
f3777a25e6 Refactor send and receive Orders loop 2021-07-10 23:35:47 +02:00
teinarss
5e1468facb Fix NRE with ConnectionStateChanged 2021-07-08 01:12:05 +02:00
Matthias Mailänder
3e6e5a83f3 I feel like I am back. 2021-07-07 15:20:47 +02:00
Paul Chote
25c095619a Parse Mp3 length from metadata tags. 2021-07-07 15:20:47 +02:00
Matthias Mailänder
407372268d Add support for .mp3 files. 2021-07-07 15:20:47 +02:00
Paul Chote
aa798c252b Remove "X has joined the game." notification when starting a Skirmish. 2021-07-06 13:12:51 +02:00
Ivaylo Draganov
9c658ad36b Increase the opacity of panel-gray-gdi 2021-07-06 10:13:43 +02:00
Ivaylo Draganov
2923077b3d Style TD in-game chat and performance graph with faction colors 2021-07-06 10:13:43 +02:00
Ivaylo Draganov
cbdf6c3747 Add faction suffix support to text fields and scroll panels 2021-07-06 10:13:43 +02:00
Ivaylo Draganov
9687988976 Use pattern matching syntax in AddFactionSuffixLogic 2021-07-06 10:13:43 +02:00
Ivaylo Draganov
64e76e1a90 Make text fields yield keyboard focus on "Esc" in a consistent way
- search fields clear the input and yield if empty
- chat field and actor edit field yield without clearing
2021-07-04 23:37:29 +02:00
reaperrr
df8295fa2c Make aircraft turn speed scale with speed modifiers 2021-07-04 21:26:45 +01:00
reaperrr
0ac277a88d Improve Aircraft TurnSpeed getters readability 2021-07-04 21:26:45 +01:00
reaperrr
5a548d6acc Introduce IdleMovementSpeed
That actually factors in speed modifiers and trait pause/disable.
2021-07-04 21:26:45 +01:00
reaperrr
1262a9c6c9 Minor FlyIdle perf optimization
None of these prerequisites change on the fly,
so cache the result in the activity ctor.
2021-07-04 21:26:45 +01:00
reaperrr
5ecb3eec16 Fix IdleTurnSpeed ignoring trait pause/disable 2021-07-04 21:26:45 +01:00
Ivaylo Draganov
2ea6bfba7b Allow the player to toggle the display of UI Feedback chat pool 2021-07-04 14:02:58 +01:00
Ivaylo Draganov
6af354ff99 Split chat lines into pools
- Add a common class for passing around chat lines
- Add wrapper methods for adding chat lines
- Combine repeated chat lines in the display widget
2021-07-04 14:02:58 +01:00
abc013
0a02bd524a Update DestroyResourceWarhead to support Resource type and amount options. 2021-07-04 11:13:05 +01:00
Paul Chote
f9b058d36b Add click sounds to color widgets. 2021-07-03 12:18:25 -05:00
Paul Chote
bc51461427 Make sure the hue returned by Color.RgbToHsv is positive. 2021-07-03 12:18:25 -05:00
Paul Chote
fca12fd707 Validate custom color picker colors. 2021-07-03 12:18:25 -05:00
teinarss
1f1373509e Refactor server orders 2021-07-03 14:55:03 +01:00
Abdurrahmaan Iqbal
a8900d9860 Rebind chat hotkeys to prevent Tab changing chat mode
Enter/Shift+Enter now toggle team/all chat respectively and Shift+Tab switches chat mode instead of Tab
2021-07-03 14:49:03 +01:00
Abdurrahmaan Iqbal
6967c1fff3 Pass KeyInput to OnKey functions 2021-07-03 14:49:03 +01:00
abc013
2742985520 Prevent saving and starting a map when max player count is exceeded. 2021-07-03 08:25:16 -05:00
Smittytron
347a09e6cf Switch remaining RA missions to Normal default difficulty 2021-07-03 00:25:53 +02:00
Smittytron
e1a28078bb Fix difficulty dropdown for RA mission Sarin Gas 2: Down Under 2021-07-03 00:25:53 +02:00
Smittytron
27562ab88f Fix and standardize TD mission difficulty dropdowns 2021-07-03 00:25:53 +02:00
reaperrr
9371cecc00 Render disabled targetable positions in gray
Instead of not rendering them at all.
Also moved their debug overlay to HitShape.
2021-07-02 10:58:29 +01:00
reaperrr
feba9f2b9f Make orientation caching in HitShape readonly
HitShape Requires<BodyOrientation> anyway.
2021-07-02 10:58:29 +01:00
reaperrr
6d55161043 Show disabled HitShapes in gray
Instead of disabling their debug overlay entirely.
2021-07-02 10:58:29 +01:00
Andre Mohren
7356f2506b Moved flashimage to world trait. 2021-07-01 16:38:51 +02:00
Ivaylo Draganov
ad4425d11e Use cached transforms for images in widgets 2021-07-01 14:21:22 +01:00
Matthias Mailänder
c8ab409d38 Allow mod code to access the buildable terrain overlay. 2021-07-01 12:41:06 +01:00
Smittytron
9a587d2aaa Standardize player naming in Ant01 2021-06-30 23:11:10 +02:00
Smittytron
bcbd2418b4 Adjust hard difficulty in Ant01 2021-06-30 23:11:10 +02:00
Andre Mohren
8a776c7138 32bpp bullets no longer crash without palette. 2021-06-30 22:58:03 +02:00
Andre Mohren
6810469634 Updated copyright years. 2021-06-29 18:33:21 -05:00
VonNah
5a7a09a6a7 Fixed the crumble-overlay of all the buildings. 2021-06-27 15:29:57 +02:00
Leo512bit
e60e7beeef Slower damaged units 2021-06-26 09:24:30 -05:00
Ivaylo Draganov
9313638997 Fix handicap dropdown disabled state 2021-06-25 09:25:17 -05:00
Ivaylo Draganov
1af2ab566e Fix player handicap erroneously set to player team 2021-06-25 09:25:17 -05:00
Andre Mohren
de6b8b6a74 32bpp terrain does not need a palette. 2021-06-25 10:38:53 +02:00
Andre Mohren
62207313a0 32bpp assets dont need a palette to be defined. 2021-06-25 10:33:54 +02:00
teinarss
b3b10729cd Remove ServerExternalMod from OrderManager 2021-06-12 12:50:51 +02:00
teinarss
91f99eeb4c Cleanup in Connect 2021-06-12 12:50:51 +02:00
teinarss
a1b3450b47 Remove Password and Endpoint from OrderManager 2021-06-12 12:50:51 +02:00
Matthias Mailänder
da4bf7f191 Document and test the building placement preview for Dune 2000. 2021-06-12 12:43:03 +02:00
tjk-ws
a893cf9cb6 Unhardcode weapon ammo consumption
fix gh actions
2021-06-11 10:21:24 -05:00
Ivaylo Draganov
9fa5dcc055 Remove unused method in WidgetUtils 2021-06-11 10:16:34 -05:00
abcdefg30
fe146cb77a Remove superfluous Buildable traits from dummy helper actors 2021-06-10 19:22:46 -05:00
Vapre
fc49d6943a OrderIO performance improvement
OrderIO, ToOrderList, skip if frame is empty,
which occurs often each client each frame.
2021-06-09 23:31:27 +02:00
Matthias Mailänder
44b2dda585 Add an editor overlay for unbuildable terrain. 2021-06-06 21:14:44 +02:00
Matthias Mailänder
3980e4fa90 Use consistent and easy to read debug command names.
Reorganize dev cheat command handling.
2021-06-06 18:40:48 +02:00
darkademic
ca2bef3cd1 Updated TD unit speeds to account for move jumpy-ness fix. 2021-06-04 23:20:13 +02:00
darkademic
cbd82c7204 Updated RA unit speeds to account for move jumpy-ness fix. 2021-06-04 23:17:41 +02:00
teinarss
82115c6bf7 Move Text handling to its own class 2021-06-04 21:47:39 +02:00
Paul Chote
2a26ddc622 Replace server Select loop with individual client threads.
This guarantees that any unexpected blocking calls due to network
issues cannot stall the main server thread.
2021-05-30 14:37:25 +02:00
Paul Chote
6535411744 Move SendData to Connection. 2021-05-30 14:37:25 +02:00
Paul Chote
7c02b4d264 Add Connection.EndPoint property. 2021-05-30 14:37:25 +02:00
Paul Chote
7e79e69eae Remove public mutable state from Connection. 2021-05-30 14:37:25 +02:00
Paul Chote
dacacdf130 Remove global fallback to software cursors on error.
We now only fall back for the specific cursors that failed.
2021-05-30 12:01:44 +02:00
abc013
8fede9d6ba Add ValidStances checks to BlocksProjectiles and Gate. 2021-05-27 21:37:37 +02:00
teinarss
d10c592987 Fix crash in OrderManager 2021-05-23 12:44:18 +01:00
reaperrr
acccb01c76 Fix Move regression
If progress == Distance, we must not move again on the same tick,
but still 'return true' to avoid losing a tick in the case
when this is the last Move tick followed by a different activity
(or a new queued Move, for example via waypoints).
2021-05-23 10:49:40 +02:00
Matthias Mailänder
6876fe45e1 Use nameof for additional robustness in trait documentation. 2021-05-22 23:22:31 +01:00
Matthias Mailänder
52a4b5acd7 Fix documentation about GeneratesShroud to CreatesShroud rename. 2021-05-22 23:22:31 +01:00
Smittytron
92b6401360 Remove Thief from Exodus 2021-05-22 23:29:42 +02:00
Smittytron
ea24a15011 Set mission default difficulties to normal 2021-05-22 23:29:42 +02:00
Smittytron
243dc965c0 Move IdleHunt function to campaign-global.lua 2021-05-22 23:29:42 +02:00
Smittytron
f1f9098109 Move TRUK prereq overrides to campaign-rules.yaml 2021-05-22 23:29:42 +02:00
Smittytron
79b3f9bf06 Use proper title case conventions in mission names 2021-05-22 23:29:42 +02:00
Smittytron
dff245a9ce Fix tile error in Soviet09 2021-05-22 23:29:42 +02:00
Smittytron
91f9fa0f1f Add Ant 03 2021-05-22 13:42:09 +02:00
Smittytron
6f919fc232 Change anthill to correct impassable tiles 2021-05-22 13:42:09 +02:00
Smittytron
ce277481c3 Add Aftermath mission In the Nick of Time 2021-05-22 13:31:40 +02:00
Smittytron
d2039a14e1 Add Counterstrike mission Fall of Greece 2: Evacuation 2021-05-22 13:27:46 +02:00
Paul Chote
a27ef16911 Add EngineRootPath csproj property to simplify SDK inheritance. 2021-05-22 11:22:26 +02:00
Paul Chote
dc3dc7df73 Fix map-player bots not working on dedicated servers.
The host is almost never going to be client index 0
on public dedicated servers. Set to the actual host
client ID instead.
2021-05-22 11:18:45 +02:00
abcdefg30
872adbec0a Remove crate crushing from visceroids in TD and TS 2021-05-17 09:57:43 +02:00
Paul Chote
c64cfea179 Allow mods to downscale framebuffer resolution for large world viewports. 2021-05-16 14:22:52 +02:00
Paul Chote
84dff779ac Work around rendering glitches with non-unity pixel scales. 2021-05-16 14:22:52 +02:00
Paul Chote
0d4b81fe6f Set world framebuffer size based on minimum zoom.
This avoids reallocating buffers each time the player changes zoom level.
2021-05-16 14:22:52 +02:00
Paul Chote
0735345674 Set world framebuffer size based on minimum zoom.
This avoids reallocating buffers each time the player changes zoom level.
2021-05-16 14:10:32 +02:00
Paul Chote
bb15bd20c0 Add support for 16 bit floating point textures. 2021-05-16 14:10:32 +02:00
Paul Chote
95f5d162ef Increase SheetCount back to 8.
This was previously decreased to support legacy GPUs
that only supported 8 texture image units and we need
to reserve one of these for the palette texture.

OpenGL 3.X mandates a minimum of 16 (and most most GL2
cards also supported it) so we can now safely increase
this limit.
2021-05-16 14:10:32 +02:00
Smittytron
7967a462a1 Add override to prevent Orca construction in Nod07c 2021-05-16 13:27:39 +02:00
Smittytron
e225785744 Remove Medium Tank overrides from Nod08a and Nod08b 2021-05-16 13:27:39 +02:00
Smittytron
46dcdfa58e Remove Light Tank override from GDI05a 2021-05-16 13:27:39 +02:00
Smittytron
f8debe340f Add building override for Chem Trooper in GDI05b 2021-05-16 13:27:39 +02:00
Smittytron
83f99727a7 Change E3 to Infantry.Nod in GDI03 2021-05-16 13:27:39 +02:00
Smittytron
cbf84f62d4 Use correct overrides in GDI02 2021-05-16 13:27:39 +02:00
VonNah
fa68954dda Fixed incorrect Harkonnen Devastator warhead impact sound. 2021-05-15 23:07:25 +02:00
Paul Chote
98caae106f Move Palette traits to their own directory.
Also adds missing TraitLocation definitions.
2021-05-15 15:29:46 +02:00
Paul Chote
3bc42543fa Decouple color picker palette definitions to their own trait. 2021-05-15 15:29:46 +02:00
Paul Chote
57d955ec72 Change Color.ToAhsv to tuple syntax. 2021-05-15 15:29:46 +02:00
Paul Chote
96e333a30e Fix TS colorpicker turret facing. 2021-05-15 15:29:46 +02:00
Paul Chote
560f1a6466 Restrict player color choices to the hue-saturation plane. 2021-05-15 15:29:46 +02:00
Paul Chote
4042d5b179 Preserve original brightness when remapping player colors. 2021-05-15 15:29:46 +02:00
Paul Chote
9d62ce214c Move color picker actor type from metrics to ColorPickerManager. 2021-05-15 15:29:46 +02:00
Paul Chote
f65de2dd43 Merge ColorPreviewManagerWidget into ColorPickerManager. 2021-05-15 15:29:46 +02:00
Paul Chote
7b58f03f1c Move ColorValidator logic into a new ColorPickerManager trait. 2021-05-15 15:29:46 +02:00
oldnaari
52577c1de9 Fix Atreides silo damaged sequence
Fix the Atreides silo rendering as full silo instead of damaged silo when damaged
2021-05-14 13:43:13 +02:00
reaperrr
fc3f200357 Replace F in OrderManager 2021-05-09 15:00:07 +01:00
Paul Chote
d89f14dcbc Limit resource center queries to 50 maps at a time. 2021-05-09 15:37:30 +02:00
teinarss
96b8273916 Remove FrameData and update OrderManager 2021-05-09 15:08:48 +02:00
Smittytron
eda79d8626 Add Soviet10 2021-05-08 23:57:07 +02:00
teinarss
0c50057220 Update KickSpectators clientCount to be passed as int 2021-05-08 22:20:59 +02:00
teinarss
10676be377 Replace F extension with string interpolation 2021-05-08 22:20:59 +02:00
teinarss
1385aca783 Move ConnectionTarget to its own file 2021-05-08 20:41:40 +02:00
abcdefg30
121959efe4 Update the Desc of AttackBase.FacingTolerance 2021-05-04 10:44:23 -05:00
Paul Chote
8d2ec78713 Replace TerrainType.CustomCursor with Mobile.TerrainCursors. 2021-05-04 11:56:23 +02:00
Paul Chote
01371f2c65 Expose TransformsIntoAircraft move cursor to yaml. 2021-05-04 11:56:23 +02:00
Paul Chote
b344bba59a Expose Aircraft move cursor to yaml. 2021-05-04 11:56:23 +02:00
Paul Chote
a6d393f19b Fix a crash when using legacy GL. 2021-05-04 09:46:31 +02:00
Matthias Mailänder
7e19d6a205 Fix Player and Actor Properties / Commands rendering. 2021-05-04 01:13:18 +02:00
reaperrr
92a9f1e234 Split expansion mission categories in Allied and Soviet
It's not always apparent from the title which faction a mission
belongs to, and players may want to know beforehand
instead of having to guess.
2021-05-03 19:22:37 +01:00
Greg Solo
c39f7e521a Use shell param instead of duplicating the flow 2021-05-03 19:17:03 +01:00
Greg Solo
c9b9efe745 Setup debug make to support vscode debug 2021-05-03 19:17:03 +01:00
Vapre
a5a371f1ff GameSettings, EnableDiscordService. 2021-05-03 11:42:57 +01:00
Matthias Mailänder
b491e892ff Lint check the harvest cursor. 2021-05-03 10:58:35 +01:00
reaperrr
771932354b Remove unused leftovers from GDI08a
Those became redundant due to using global MoveAndHunt
in SendWaves.
2021-05-01 20:48:28 +02:00
reaperrr
89f270b67c GDI08a typo fix 2021-05-01 20:48:28 +02:00
abcdefg30
3276373745 Pause rendering when the window is minimized 2021-04-26 21:56:20 +01:00
teinarss
5667081764 Fix log should be disposed correctly 2021-04-26 21:50:26 +01:00
teinarss
b23d533006 Update Log to wait for items in worker thread 2021-04-26 21:50:26 +01:00
Matthias Mailänder
1f01d0b6b1 Add a Fluent based translation system. 2021-04-24 16:49:17 +02:00
reaperrr
f1a9a5180d Use real (milli)seconds for notifications
Allows for more fine-grained control, while
adding independence from gamespeed and getting
rid of magic * 25 multiplications.
2021-04-21 19:34:16 +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
61d64287e1 Move LoadMaps after InitializeFonts.
This allows text to be displayed earlier in the loading screen.
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
reaperrr
53e6d974f0 Change Crate.Lifetime from 'seconds' to ticks
As far as I could tell, this was the last place that still
used 'seconds' instead of ticks, apart from
some sound notification intervals (which are better
converted to real [milli]seconds).

Also renamed ScaredyCat.PanicLength to PanicDuration for
consistency and easier finding.
2021-04-19 20:03:08 +02:00
reaperrr
e3fd54e147 Replace * 25 in internal tick defaults with actual total
While the idea behind it is understandable,
this was inconsistent with the bulk of other defaults.
2021-04-19 20:03:08 +02:00
Vapre
52d39db84a Fix possible endless loop in replay recorder while opening save file. 2021-04-15 18:10:45 +02:00
reaperrr
27ddae3df9 Fix Move jumpy-ness on MovePart transitions
There were 2 issues at work here, both when progress
would overshoot Distance (which is the usual case,
rather than the exception):
- the overshot progress was passed on by MoveFirstHalf, however
  OnComplete would make the next MovePart start ticking the
  same tick on which the old MovePart reached Distance,
  but move by carryoverProgress +(!!!) terrain speed instead of moving
  by just the left-over carryoverProgress.
- MoveSecondHalf would not pass any overshot progress to the
  next MoveFirstHalf queued by parent Move, leading to
  the next MoveFirstHalf performing a full-speed move the same tick
  MoveSecondHalf finished its last move.
2021-04-15 18:03:42 +02:00
reaperrr
4c7e3d8f3a Rename fraction to distance/progress in MovePart 2021-04-15 18:03:42 +02:00
reaperrr
646495fc5f Simplify MovePart code
InnerActivity and UpdateCenterLocation made this
overly complex and hard to read & debug.

This also fixes a bug that would make an outdated
facing being passed during OnComplete (because
InnerActivity was cached before UpdateCenterLocation
could set the correct final facing).
2021-04-15 18:03:42 +02:00
Mustafa Alperen Seki
a9661a233a Fix Lua error in Har8 when Merc HFac is captured after Palace is killed. 2021-04-13 21:39:24 +02:00
CrazyAlex25
2d05e10819 Modify build properties 2021-04-12 00:44:17 +02:00
Matthias Mailänder
5a0bcc01a6 Add a lint check for trait placement on hardcoded actor names. 2021-04-11 20:20:00 +02:00
Smittytron
0d3c624bbc Standardize usage of AddObjective in RA missions 2021-04-11 12:26:14 +02:00
Smittytron
26fbcf6076 Change fence owner in Soviet01 2021-04-11 12:26:14 +02:00
Smittytron
418fca3d9e Move OnAnyDamaged function to campaign-global.lua 2021-04-11 12:26:14 +02:00
Smittytron
dd366f8cf9 Rename top-o-the-world script file 2021-04-11 12:26:14 +02:00
Smittytron
6b63e88056 Move crate lifetime overrides to campaign-rules.yaml 2021-04-11 12:26:14 +02:00
Smittytron
a96e2fb588 Add Soviet11b 2021-04-10 23:00:31 +02:00
Smittytron
ca2f966c3b Add Soviet 11a 2021-04-10 22:26:40 +02:00
reaperrr
e161d9daa7 Misc TraitDictionary style fixes 2021-04-10 15:59:24 +02:00
reaperrr
aa834db1e3 Make perf.log output for ticking things opt-in
Both writing to perf.log frequently as well as GetTimestamp
aren't free and hurt performance particularly on slower systems
(which can have notably higher output to perf.log, further
amplifying the problem).
Therefore we make simulation perf logging opt-in.

Additionally, logging of the current tick and tick type
(local/net) is removed from debug.log, and some
remnant debug logging for kills and pips is removed
to keep performance-sensitive logging limited to
perf.log.
2021-04-10 15:59:24 +02:00
Paul Chote
a1df91b665 Allow BuildingInfluence to track overlapping buildings in the same cell. 2021-04-10 14:28:31 +02:00
Paul Chote
bc286b78bf Add AnyBuildingAt method to BuildingInfluence. 2021-04-10 14:28:31 +02:00
Paul Chote
19c7e14393 Simplify BuildingInfo.IsCloseEnoughToBase adjacency checks. 2021-04-10 14:28:31 +02:00
reaperrr
1a9dfc0893 Refactor GameSpeed setting
*Remove internal GameSpeed defaults
 Enforce setting values explicitly all the time
 Require definition of a DefaultSpeed

*Remove Global.Timestep default

*Remove the hacky Timestep/OrderLatency setting via LobbyInfo

*Fix shellmaps ignoring mod-defined gamespeeds

*Make DateTimeGlobal use the MapOptions gamespeed
2021-04-09 22:58:14 +01:00
Matthias Mailänder
fe129956bb Make the resource layer optional in the map editor. 2021-04-07 12:19:55 +01:00
reaperrr
eec7de4646 Fix RA infantry shadow being visible when parachuting 2021-04-04 17:06:03 -05:00
teinarss
605181efe4 Update Log to use worker thread 2021-04-03 22:53:30 +01:00
Paul Chote
fc0ed75a94 Fix Firestorm asset installation. 2021-04-03 15:12:18 -05:00
Smittytron
d95c4146e2 Rework objectives in Situation Critical 2021-04-03 17:58:00 +01:00
Vapre
38f0d50648 Minor optimization. Save a call to IsAlliedWith if not disguised. #18791. 2021-04-03 17:12:12 +01:00
reaperrr
808d8e63bc Add GiveUnitCrateActions for ships to RA 2021-04-03 16:22:27 +01:00
reaperrr
55967035d9 Update RA wcrate.shp
Now uses the original colors again.
Also added back a frame without shadow (for
parachuting).
2021-04-03 16:22:27 +01:00
reaperrr
13a101f11f Add a frame with shadow to both TD crate types
And remove the crate.shp in return
(which was just scrate.shp with shadow).

Also fixes WCRATE actor to actually use the correct .shp.
2021-04-03 16:22:27 +01:00
Paul Chote
35a0a3cf90 Remove rcedit after building windows packages. 2021-04-03 12:19:41 +02:00
Smittytron
08d8f5d8d9 Swap c1 and c7 out of CivilianEvacuees in Monster Tank Madness 2021-04-03 11:38:33 +02:00
Smittytron
f7c9eccf7a Add Selectable Class to technicians 2021-04-03 11:38:33 +02:00
teinarss
6ba9e64380 Rename modifiablePalettes to mutablePalettes in HardwarePalette 2021-04-03 11:33:31 +02:00
teinarss
8b0a3ea680 Remove our own impl of ReadOnlyList and update usages 2021-04-03 11:33:31 +02:00
teinarss
e12ff2c59d Remove our own ReadOnlyDictionary and update usages 2021-04-03 11:33:31 +02:00
Smittytron
afbdb395b2 Add SelectableSupportUnit to Thief 2021-04-03 11:24:00 +02:00
teinarss
3d381e6e32 Make SpriteFont.Measure take zero allocations 2021-04-03 11:22:45 +02:00
Matthias Mailänder
a02737107e Add a .wsa file reader. 2021-04-03 11:19:06 +02:00
Matthias Mailänder
590ab88c45 Don't prefer braces (for one liners). 2021-04-03 10:53:08 +02:00
Patrick
7a7c07e9c4 fix AreaBeam + GrantExternalConditionWarhead bug 2021-04-02 13:05:20 +02:00
reaperrr
40aafe586d Move Game.Timestep to Widget
Game.Timestep wasn't used for anything other than
UI anymore anyway, moving it makes this more clear.
2021-04-02 12:00:42 +01:00
abcdefg30
6b93f955a4 Fix a crash in LevelUpCrateAction 2021-04-02 11:57:44 +01:00
reaperrr
75a3bb4f0b CellIsEvaluating perf optimization
If an actor has Mobile, it implements IOccupySpace
so we can use OccupiesSpace to save a trait look-up.
2021-03-27 22:29:13 +00:00
reaperrr
441e18b898 Remove PathHash
This is 9(!) years old and we haven't had
pathfinding-related desyncs in quite a while.

We can still bring this back later if we ever
need it again.
2021-03-27 22:29:13 +00:00
reaperrr
b8e64df4b1 Remove SmokeTrailWhenDamaged
One of the most outdated and limited traits remaining,
which can do nothing LeavesTrails doesn't cover by now.
2021-03-27 18:42:57 +00:00
Matthias Mailänder
d15e7f76fc Port back to Mono.Nat and make discovery async. 2021-03-27 18:36:12 +00:00
Andre Mohren
3f510b6d93 Make ISpriteLoader aware of the source file name. 2021-03-27 17:36:59 +01:00
teinarss
d60c05eff3 Change to use pattern matching 2021-03-27 17:29:20 +01:00
Paul Chote
7c0e4b25ae Specify interaction bounds relative to the mod tile size. 2021-03-27 16:31:50 +01:00
Smittytron
852241d98e Add Allies05c 2021-03-27 14:46:11 +01:00
Smittytron
8deba81214 Add Allies05b 2021-03-27 13:55:27 +01:00
Smittytron
887a093f46 Add Counterstrike mission Siberian Conflict 3: Wasteland 2021-03-27 13:32:40 +01:00
Smittytron
4778dba36d Fix whitespace issues in RA mission browser 2021-03-27 13:25:22 +01:00
Smittytron
438b2240f4 Add AI infantry production to Soviet02a 2021-03-27 13:25:22 +01:00
Smittytron
58a6333834 Add AI infantry production to Soviet02b 2021-03-27 13:25:22 +01:00
Smittytron
f8feec685f Use correct sprite for Moneycrate 2021-03-27 13:25:22 +01:00
Smittytron
79404cd397 Link campaign-global.lua to remaining missions 2021-03-27 13:25:22 +01:00
Smittytron
6a6c5848c2 Remove fake building overrides from Survival01 2021-03-27 13:25:22 +01:00
Smittytron
420c8ebc4c Remove fake building overrides from Allies02 2021-03-27 13:25:22 +01:00
Matthias Mailänder
c0ea95ca46 Update itch user name. 2021-03-27 11:34:03 +00:00
Matthias Mailänder
1a8d971145 Fix a syntax error. 2021-03-27 11:07:35 +00:00
Paul Chote
7afcb9d757 Fix TS infantry player color. 2021-03-27 11:06:12 +01:00
Smittytron
8a5c0736f5 Remove CivilianKilled notification default from TD 2021-03-27 10:58:29 +01:00
Castle
12b6bb9448 Allow BlendMode of RgbaColorRenderer to be changed 2021-03-23 17:07:20 +01:00
reaperrr
e2a6b55d44 Move up Undamaged check in DamageState
A mere int comparison is obviously cheaper than
a comparison between two multiplications,
so pulling this above the checks of other damage states
allows us to bail early for undamaged actors.
2021-03-21 17:37:42 +01:00
reaperrr
c240c0a24b Only apply non-100 damage modifiers in InflictDamage
Profiling has shown that filtering them out early is cheaper
than applying those percentage modifiers anyway.

Additionally, profiling shows foreach loops to be cheaper
than LINQ here as well.
2021-03-21 17:37:42 +01:00
reaperrr
2528b79610 Fix D2k DamagesConcrete overrides 2021-03-21 11:09:41 +00:00
Matthias Mailänder
e13fd4816e Extract the directory if the registry value points to a filename. 2021-03-20 18:42:02 +01:00
Andre Mohren
1f6e0f582a Fixed aiming not propertly stopped. 2021-03-20 18:33:04 +01:00
Matthias Mailänder
bbbed49f82 Add a lint check for cursor definitions. 2021-03-20 17:37:16 +01:00
Matthias Mailänder
cefb2e7cc6 Remove unused trait lookup. 2021-03-20 17:37:16 +01:00
Paul Chote
470bc4e092 Polish deployed mobile sensor array:
- Force temperate palette to avoid glitches on snow maps
- Add missing active animation
2021-03-20 17:15:56 +01:00
Paul Chote
08c7c80bb7 Render building lights as their own tint-ignoring animations. 2021-03-20 17:15:56 +01:00
Paul Chote
5832ec76d4 Render integrated muzzle flashes as their own tint-ignoring animations. 2021-03-20 17:15:56 +01:00
Paul Chote
594e5b80d7 Add WithMakeOverlay trait. 2021-03-20 17:15:56 +01:00
Paul Chote
14a434975a Add facing support to WithAttackOverlay. 2021-03-20 17:15:56 +01:00
Paul Chote
6854b23bcc Add custom palette support to WithSpriteBody. 2021-03-20 17:15:56 +01:00
Paul Chote
0c52d275fa Add TransparentIndex to PaletteFromFile. 2021-03-20 17:15:56 +01:00
Paul Chote
e63b9b4986 Add condition support to ActorLostNotification. 2021-03-20 17:07:29 +01:00
Paul Chote
0e270bec56 Restrict Chronoshiftable trait to Mobile and Husk actors. 2021-03-20 17:04:42 +01:00
Andre Mohren
f5f06b86ad ExplosionOnDamageTransition now Conditional. 2021-03-20 17:02:47 +01:00
Paul Chote
fcc3008b00 Implement proper TS Tiberium and Vein logic. 2021-03-20 16:45:41 +01:00
Paul Chote
0bdd46451e Overhaul resource layer logic:
* ResourceType trait has been removed.
* Simulation-related data is now defined on the
  ResourceLayer (which mods can subclass/replace).
* Support non-money resources by moving the resource
  values to the PlayerResources trait.
* Allow mods to disable the neighbour density override
  and instead always use the map-defined densities.
* Allow mods to define their own resource placement
  logic (e.g. allow resources on slopes) by subclassing
  (Editor)ResourceLayer.
* Improve ability to subclass/override ResourceRenderer
  by exposing more virtual methods.
2021-03-20 16:45:41 +01:00
Paul Chote
c35e9fb016 Remove custom D2k spice variant logic and improve editor cursor sprite. 2021-03-20 16:45:41 +01:00
Paul Chote
80e92849da Replace ResourceType with strings in interfaces/public methods. 2021-03-20 16:45:41 +01:00
Paul Chote
dcd8eccee4 Replace ResourceLayer references with IResourceLayer in traits/warheads. 2021-03-20 16:45:41 +01:00
Paul Chote
5adcbe4c78 Use IResourceLayer for editor resources. 2021-03-20 16:45:41 +01:00
Paul Chote
0b93556c06 Add resource updating methods to IResourceLayer. 2021-03-20 16:45:41 +01:00
Paul Chote
7e9d291223 Add IResourceRenderer interface. 2021-03-20 16:45:41 +01:00
Paul Chote
1dc26a9b8e Pass resource type and count to IAcceptResources instead of the value. 2021-03-20 16:45:41 +01:00
Paul Chote
3dbc6400a6 Use IResourceLayer in BaseBuilderBotModule. 2021-03-20 16:45:41 +01:00
reaperrr
adf1aeb06a Add support for pool-specific ammo pips decoration 2021-03-20 15:31:41 +01:00
Vapre
be224934a5 FieldLoader, use dictionary for GetValue to make it twice as fast. 2021-03-17 18:18:53 +01:00
teinarss
6b74093c04 Add readonly to structs 2021-03-14 15:17:57 +01:00
reaperrr
65c796dec7 Use Mobile.Pathfinder to reduce trait look-ups 2021-03-14 12:28:54 +00:00
reaperrr
503e706d45 Check for IsReloading in HasAnyValidWeapons
For Attack*.CanAttack().

Allows us to drop the additional check for armaments with ammo.
2021-03-14 12:28:54 +00:00
reaperrr
a1f974bd40 Save Mobile trait look-up in AttackBase 2021-03-14 12:28:54 +00:00
Unrud
11171ff649 Makefile: Fail target version when not a git repository 2021-03-13 15:57:17 +00:00
Paul Chote
3ff1888d74 Fail Situation Critical if Volkov is killed before entering the world. 2021-03-13 15:55:24 +00:00
Paul Chote
cbea08e1fe Fix non-relative path handling in install logic. 2021-03-13 15:56:38 +01:00
Paul Chote
b622afd7fd Fix self-contained packaging. 2021-03-13 13:12:31 +01:00
Paul Chote
7694d0842b Fix two outdated comments. 2021-03-12 21:52:16 +01:00
Paul Chote
a90e6940ab Add sequence scale and alpha support to ShroudRenderer. 2021-03-12 21:52:16 +01:00
Paul Chote
96c3825b6a Add alpha support to TerrainSpriteLayer. 2021-03-12 21:52:16 +01:00
Paul Chote
a6467cb515 Fix Nullable type handling in Lua docs. 2021-03-10 17:46:44 +01:00
Paul Chote
d52ba83f96 Replace terniary null checks with coalescing. 2021-03-08 18:11:25 +01:00
reaperrr
2473b8763b Rename methods/activities with Visual in them
While they may be only 'visual' in terms of influence/cell grid,
they all do update CenterPosition, which is essentially the
actual world position of the actor.
'Visual' would imply that it only affects the position where the
actor is drawn, which is inaccurate.
Furthermore, using the term 'Visual' here would make
naming future methods/properties related to visual interpolation
unnecessarily complicated, because that's where we might
need a real 'Visual(Only)Position'.
2021-03-08 11:19:11 +01:00
teinarss
7073279ab8 Replace WebClient with HttpClient 2021-03-07 16:04:57 +00:00
teinarss
ed43071792 Compile engine and mod dlls as NET5 when not using mono 2021-03-07 16:04:57 +00:00
teinarss
4a1e4f3e16 Use expression body syntax 2021-03-07 13:00:52 +00:00
Paul Chote
555c43843b Fix lobby checkbox event rectangle overlapping with scrollbars. 2021-03-05 18:58:51 +01:00
Paul Chote
a0d75d1e63 Fix rendering artifacts with RA's dialog5 background. 2021-03-05 18:33:39 +01:00
reaperrr
1a7a47fa08 Randomize AI idle harvester scan intervals 2021-02-28 18:58:03 +01:00
teinarss
c2279d3071 Change GetField calls to use nameof 2021-02-28 18:43:51 +01:00
teinarss
ed295ae315 Change throw exceptions to use nameof in parameter 2021-02-28 18:43:51 +01:00
teinarss
53b781960c Change FieldLoader.LoadUsing to use nameof 2021-02-28 18:43:51 +01:00
penev92
6b794ba3e5 Added the "missing" song to the D2k TestFiles
Since it's music it's optional, so the players still won't know anything happened, but if they do open the content manager they will have a chance for an automatic installation.
2021-02-28 12:29:15 +00:00
penev92
2f95e56256 Fixed incorrect D2k song installation 2021-02-28 12:29:15 +00:00
pizzaoverhead
c8644adc85 Fix TLS error on Win7. 2021-02-28 10:15:29 +00:00
Paul Chote
8b81078929 Fix lighting effects in "The Pit" map. 2021-02-24 19:20:48 +01:00
Paul Chote
76a10283c4 Fix TS effect translucency/lighting effects. 2021-02-24 19:20:48 +01:00
Paul Chote
0975102e92 Add Alpha support to sequences.
Alpha can specify a single value for the sequence
or values for each frame in the sequence.

AlphaFade: True can be specified to linearly fade
to transparent over the length of the animation.
2021-02-24 19:20:48 +01:00
Paul Chote
445d943549 Remove obsolete shadow palette definitions. 2021-02-20 02:08:40 +01:00
Paul Chote
554486fb0b Replace projectile, WithShadow, WithParachute shadows with tint effects. 2021-02-20 02:08:40 +01:00
penev92
1c1af89bb9 Fixed D2k VQA videos crashing the game 2021-02-19 13:38:12 +01:00
Trevor Nichols
536c130a39 Add MSADPCM audio format decoding support 2021-02-19 01:56:57 +01:00
Matthias Mailänder
5aa67a42c1 Bump Eluant version to support Unicode strings. 2021-02-18 23:16:49 +01:00
Paul Chote
f661d1ba48 Remove OLDLST campaign overrides. 2021-02-14 18:13:21 +01:00
reaperrr
717b9ba1e6 Fix TS GDI temperate radar sprite
Unlike its snow counterpart, the transition between building
and its shadow was jarring, making it look as if there was a
1-pixel gap between them. Fixed that.

Also applied some very subtle polish by replacing some non-
remapable red pixels (nothing worth porting to snow variant, though).
2021-02-14 14:40:58 +00:00
reaperrr
c57cc96145 TS radars Z offset fixes
The lower borders of the sprites were cut off without this.
2021-02-14 14:40:58 +00:00
Smittytron
16fa1ef144 Change Z-offsets that overlap Repair Facility 2021-02-14 14:31:50 +00:00
Smittytron
788f0f3e24 Change Z-offsets that overlap Service Depot 2021-02-14 14:31:50 +00:00
Unrud
ccf9c8fb22 AppStream Metadata: Add violence-worship: moderate 2021-02-14 14:16:53 +00:00
Unrud
ee31146501 Update AppStream metadata for linux packaging
A few small improvements:
* The type `desktop` was renamed to `desktop-appliaction` (a long time ago)
* Add `launchable` to tell how the application can be launched
* Use `https` for homepage link
* Add link to the bugtracker
* Update `oars-1.0` to `oars-1.1`
* Remove all unnecessary `content_attribute` entries with value `none`
2021-02-14 14:16:53 +00:00
Vapre
f176a0ed83 Fix. Call EndGame in one place of server main loop. Ensure UPnP port forward is removed always. 18807. 2021-02-14 13:54:48 +00:00
Matthias Mailänder
e7cfd2765c Make UI cursors configurable. 2021-02-14 13:09:59 +00:00
abcdefg30
96c4554644 Remove GenericSelectTarget 2021-02-14 12:51:12 +00:00
Mustafa Alperen Seki
df94f0ec8b Add InitialActor to Carryall. 2021-02-14 12:47:08 +00:00
Adam Mitchell
9ee7294c81 Improve shroud performance 2021-02-12 20:58:56 +01:00
Smittytron
5cf622fb6e Improve AI response in Nod03b 2021-02-12 20:38:37 +01:00
Smittytron
8711d8799c Improve AI response in Nod03a 2021-02-12 20:38:37 +01:00
Smittytron
e9a6a3afc5 Add clarifying objective to Monster Tank Madness 2021-02-12 02:30:12 +01:00
abcdefg30
9c29264be7 Drop FlyAttackRun targets when we don't have valid armaments against them 2021-02-12 02:17:26 +01:00
abcdefg30
e6c9d5fc96 Don't check IsTraitDisabled twice when calculating IsTargetableBy 2021-02-12 02:17:26 +01:00
Paul Chote
d09476c603 Remove custom palettes from building placement previews. 2021-02-12 02:08:30 +01:00
Orb
5bda6852a4 APC Balance Tweak Commit 2021-02-09 23:07:44 +01:00
Ivaylo Draganov
641b05eb21 Split settings panels logic and add support for custom panels 2021-02-08 11:25:50 +01:00
reaperrr
62fd11d5c4 Fix deployed tick tank sprites
Several pixels used non-remapable red colors.
2021-02-06 22:46:52 +01:00
Smittytron
e807664437 Add TanyaRescued speech notification to Downunder 2021-02-06 01:18:48 +01:00
Smittytron
e46440b94f Correct the ownership of walls in Allies05a 2021-02-06 01:18:48 +01:00
Smittytron
30ea1e23b4 Delay SendReinforcements() to split notifications 2021-02-06 01:18:48 +01:00
Smittytron
4db2fd980a Kill pillboxes with barrels in Soviet01 2021-02-06 01:18:48 +01:00
Smittytron
9580d61fb0 Fix spaces in Monster Tank Madness 2021-02-06 01:18:48 +01:00
Smittytron
27aefcc0ce Fix tabs in Ant01 2021-02-06 01:18:48 +01:00
Smittytron
b8b1a4930c Change BarrelExplode CreateEffect to large_napalm 2021-02-05 23:41:03 +01:00
Smittytron
d7a40f3bdb Change BarrelExplode to use FireDeath 2021-02-05 23:41:03 +01:00
Paul Chote
fb0031d34a Rename remaining Stance references to PlayerRelationship. 2021-02-04 23:14:09 +01:00
Paul Chote
b3821e71dc Fix Tanya's prone firing animations. 2021-02-02 23:05:07 +01:00
Unrud
8a90413b87 Use version from VERSION file
The `VERSION` variable doesn't work with a release tarball, because it requires git to be set correctly.
Instead this reads the version from the `VERSION` file.
2021-02-01 23:13:48 +01:00
abcdefg30
115984054d Increase the reload delay of the prison colt to match the normal colt 2021-01-31 22:35:42 +00:00
abcdefg30
69addda86c Fix the gun sounds not playing in Allies05a 2021-01-31 22:35:42 +00:00
Smittytron
c2379f251d Fix crash in Allies 05a on SamBarrel kill 2021-01-31 18:52:47 +01:00
abcdefg30
3422bf1b59 Remove the 'docs' target from the windows make file 2021-01-30 21:08:25 +00:00
Paul Chote
e830d1e9c2 Fix Concrete placement on invalid terrain. 2021-01-30 14:48:04 +01:00
Smittytron
f767c24601 Remove SpawnActorOnDeath from civilian structures 2021-01-30 13:47:14 +01:00
Paul Chote
2c09b1414c Ignore invalid server entries instead of the entire list. 2021-01-30 13:44:51 +01:00
Paul Chote
df1191db5b Don't crash if a null uid is given to QueryRemoteMapDetails. 2021-01-30 13:44:51 +01:00
Paul Chote
62433ecb8b Prevent AttackPopupTurreted.TickIdle from running while disabled. 2021-01-30 13:16:58 +01:00
Paul Chote
09f680201f Restore missing versioned source code package. 2021-01-30 13:04:23 +01:00
reaperrr
5ba662cfae Fix RA inf death anims playing too fast 2021-01-30 01:23:39 +00:00
Paul Chote
d6d0fd597d Fix Tanya firing animation. 2021-01-29 15:04:42 +01:00
Paul Chote
fec1c813a5 Support burst-specific infantry attack animations. 2021-01-29 15:04:42 +01:00
Paul Chote
547b6d19dc Reduce Tanya firing rate. 2021-01-29 15:04:42 +01:00
Paul Chote
5e6dd50c3b Suppress error messages from make.ps1 clean.
Also removed obsolete ./*/bin removal.
2021-01-29 14:54:40 +01:00
Paul Chote
4251ed69bb Keep Discord join button active for spectators. 2021-01-29 14:38:13 +01:00
Paul Chote
b05ee80d5c Remove first-client check from LobbySettingsNotification.
ClientWithIndex may rarely be null, causing a crash.
In any case we do want to report these changes to the first client, as
somebody else may have changed the settings and left.
2021-01-29 14:35:32 +01:00
Paul Chote
84ced8704d Fix bot-controlled aircraft stalling above cloaked targets. 2021-01-29 14:30:27 +01:00
teinarss
58313520f0 Change renderables to class to avoid boxing 2021-01-29 00:24:27 +01:00
reaperrr
0d8ef1a1dd Make Contrail conditional and public
Also moved it to 'Render' subfolder while at it.
2021-01-28 23:30:45 +01:00
Matthias Mailänder
28ddab7cc2 Disallow building sell during construction. 2021-01-27 22:51:58 +01:00
Matthias Mailänder
8f06b0a836 Add a "structure sold" notification. 2021-01-27 22:51:58 +01:00
Paul Chote
3b768dacf5 Increase map chooser dialog size to match the lobby. 2021-01-25 20:43:53 +01:00
Smittytron
d67b3245e0 Change hospital owner in Nod07b 2021-01-24 10:47:05 +00:00
abcdefg30
a1dd1fc5d1 Fix an compiler error on bleed 2021-01-23 23:15:58 +00:00
Paul Chote
889153ce81 Add shadow rendering for resource sprites. 2021-01-23 20:59:53 +01:00
teinarss
30e5c807b0 Add Map and server name to discord details 2021-01-22 14:14:02 +01:00
Paul Chote
db2fded24d Fix AutoTarget.ChooseTarget ignoring AttackBase.TargetFrozenActors. 2021-01-21 19:25:07 +01:00
Paul Chote
82a9809192 Remove RenderSprites.Scale. 2021-01-21 18:22:11 +01:00
Paul Chote
f6b40b2bce Allow sequences to define a Scale factor. 2021-01-21 18:22:11 +01:00
abcdefg30
fd75e03d9c Use pattern matching in FieldSaver 2021-01-21 18:05:07 +01:00
Paul Chote
d6a05f2ea2 Fix Sardarkaur not attacking while attack-moving. 2021-01-17 19:42:49 +01:00
Paul Chote
f51603e440 Add ShpRemastered sprite loader. 2021-01-16 23:16:34 +01:00
Paul Chote
f341c9a8a6 Add TGA and DDS sprite loaders. 2021-01-16 23:16:34 +01:00
Paul Chote
765944cfa2 Switch macOS and Linux default toolchain to .NET 5. 2021-01-16 22:58:05 +01:00
Paul Chote
15c926b6b9 Move DefineConstants="MONO" into OpenRA.Game.csproj. 2021-01-16 22:58:05 +01:00
teinarss
b486112c98 Fix broken editorconfig 2021-01-16 22:28:17 +01:00
Paul Chote
223a0015a6 Allow terrain depth sprites to be loaded from a second file. 2021-01-16 22:09:08 +01:00
Paul Chote
632af7c7e6 Support mixed indexed/BGRA terrain tiles. 2021-01-16 22:09:08 +01:00
Paul Chote
142870d78a Support multiple sheets in TerrainSpriteLayer. 2021-01-16 22:09:08 +01:00
Paul Chote
b0aa32cd1b Support multiple palettes in TerrainSpriteLayer. 2021-01-16 22:09:08 +01:00
Matthias Mailänder
281229e8b4 Update path according to latest appstream specifications. 2021-01-16 20:02:19 +01:00
Matthias Mailänder
8f0d53ffd9 Document the target platform parameter during install
as it otherwise copies the system binaries.
2021-01-16 20:02:19 +01:00
Matthias Mailänder
ddfa5a4d35 Get rid of unnecessary Makefile variables. 2021-01-16 20:02:19 +01:00
Matthias Mailänder
cbf2e2e2ef Don't contain the build root in the wrappers. 2021-01-16 20:02:19 +01:00
Matthias Mailänder
62803aff88 Create BIN_PATH first on shortcut installation. 2021-01-16 20:02:19 +01:00
VonNah
bc9cd57fa0 Fix vehicle explosion and missile impact sounds in Tiberian Dawn 2021-01-16 01:32:20 +00:00
VonNah
93fa9bdfb8 Fixed an issue where RadarUp and DisablePower/EnablePower use the wrong sound effects.
Signed-off-by: VonNah <vonnahora@gmail.com>
2021-01-16 00:48:35 +00:00
reaperrr
808c5f0951 Remove ScriptTriggers from map deco actors
Removes it from destroyed fields, trees and rocks in RA and C&C.

This trait isn't free in terms of performance due to all the
INotify* calls, and the mentioned actors should rarely
- if ever - need it. Besides, if a mission ever really needs
this on those actors, the trait can be added back via
map rules.
2021-01-16 00:44:03 +00:00
Paul Chote
a70637f28f Fix missing System.Threading.Tasks.Parallel in packaged net5 builds. 2021-01-15 12:18:00 +01:00
Paul Chote
a12e4657ee Update apt metadata before installing dependencies. 2021-01-12 23:09:11 +01:00
Paul Chote
53db1230ab Move default tileset parsing to Mods.Common. 2021-01-11 21:57:55 +01:00
Paul Chote
207e09fea9 Add plumbing for mod-defined terrain loaders. 2021-01-11 21:57:55 +01:00
Paul Chote
b86b638700 Move editor template rendering to TerrainRenderer. 2021-01-11 21:57:55 +01:00
Paul Chote
995c33a942 Remove Ruleset.TileSet. 2021-01-11 21:57:55 +01:00
Paul Chote
6d6efd5fe8 Move tileset image validation to TerrainRendererInfo. 2021-01-11 21:57:55 +01:00
Paul Chote
2782620081 Add ITemplatedTerrainInfo interface. 2021-01-11 21:57:55 +01:00
Paul Chote
be2ca77acf Add ITerrainInfoNotifyMapCreated interface. 2021-01-11 21:57:55 +01:00
Paul Chote
87790069e9 Add ITerrainInfo interface. 2021-01-11 21:57:55 +01:00
Paul Chote
0a374e2264 Move ownership of tile sprites to the terrain renderer. 2021-01-11 21:57:55 +01:00
Paul Chote
2eee911c58 Fix infantry freezing death animations in Top o' the World mission. 2021-01-11 11:32:38 +01:00
Paul Chote
bb65646c4d Fix Grenadier death animation in Sarin Gas 3 mission. 2021-01-11 11:32:38 +01:00
Paul Chote
fea700fb72 Add death types support to the Lua Kill() API. 2021-01-11 11:32:38 +01:00
tovl
560c3230cd Let harvesters only search for refineries when needing to unload. 2021-01-10 23:43:48 +01:00
Paul Chote
e990a83b7a Cancel support power targeting if power cannot be activated. 2021-01-10 22:42:32 +01:00
Paul Chote
02a2624bcc Add a per-player handicap option to the lobby.
Handicaps reduce unit health, firepower, and build speed.
2021-01-10 22:23:52 +01:00
Paul Chote
c7c78eda80 Increase lobby and server list width. 2021-01-10 22:23:52 +01:00
Paul Chote
b1200b8078 Switch make.ps1 to downloading from our GeoIP data mirror. 2021-01-10 21:13:26 +01:00
Matthias Mailänder
0cb25f1044 Fix syntax errors. 2021-01-10 21:06:39 +01:00
Matthias Mailänder
8ee728891d Use the GitHub action variable for clickable links. 2021-01-10 21:06:39 +01:00
Matthias Mailänder
bbaa475287 Update SDL 2 nuget package to match the platform. 2021-01-10 21:04:44 +01:00
Matthias Mailänder
7bc17b59f5 Add a generic video player widget. 2021-01-10 10:21:17 +01:00
Smittytron
514652bb6a Add Aftermath mission Shock Therapy 2021-01-10 02:34:50 +01:00
Paul Chote
3e7665146a Avoid BuildUnit crash if the item is invalidated before the task runs. 2021-01-10 01:34:51 +01:00
Paul Chote
16d0f8a5a6 Add a setting to pause the shellmap. 2021-01-10 00:23:30 +01:00
Paul Chote
aeab9a8116 Group bot AttackMove orders. 2021-01-09 23:55:50 +01:00
Orb
f9a5669eb4 Playtest-Balance-Tweaks Commit 2021-01-09 23:22:49 +01:00
Paul Chote
868736fe1a Remove obsolete --check-runtime-assemblies utility command. 2021-01-09 19:53:22 +01:00
Paul Chote
0984de6bea Change install_assemblies_mono to install all bin contents. 2021-01-09 19:53:22 +01:00
Paul Chote
69ffd70d3f Switch Appimages to net 5. 2021-01-09 19:53:22 +01:00
Paul Chote
2fae69c0ba Run appimagetool directly. 2021-01-09 19:53:22 +01:00
Paul Chote
f1d66a4c70 Use ULFO format for non-compat disk images (requires macOS 10.11+). 2021-01-09 19:53:22 +01:00
Paul Chote
84ce33fe9c Trim unused assemblies to reduce packaged size further. 2021-01-09 19:53:22 +01:00
Paul Chote
e583165dff Replace duplicate runtime files with hardlinks to reduce dmg size. 2021-01-09 19:53:22 +01:00
Paul Chote
7bedba5837 Switch macOS packages to .NET 5. 2021-01-09 19:53:22 +01:00
Paul Chote
8c9b9df125 Change WithColoredOverlay to use a color instead of a palette. 2021-01-06 00:06:51 +01:00
Paul Chote
96641873ae Replace highlight palette with tint effects. 2021-01-06 00:06:51 +01:00
Paul Chote
8edd9de278 Replace ITintableRenderable with IModifyableRenderable. 2021-01-06 00:06:51 +01:00
Paul Chote
67754e8693 Add alpha support to SpriteRenderer. 2021-01-06 00:06:51 +01:00
Paul Chote
b88495c689 Remove palettes from base IRenderable. 2021-01-06 00:06:51 +01:00
Paul Chote
71b13c7b5d Disable AttackPopupTurreted state changes when paused. 2021-01-03 12:46:47 +01:00
nvrnight
b3f39bffce Issue #18936: The game no longer crashes when TextFieldWidget sends Enter key press and onSelect action is null. 2021-01-03 12:26:52 +01:00
Smittytron
b44a9ab5fc Fix palettes in Fall of Greece 1 2021-01-02 22:43:28 +01:00
Smittytron
e34255b0b2 Add campaign-palettes to missions lacking it 2021-01-02 22:43:28 +01:00
Paul Chote
2fee62af4d Fix exit priority ordering. 2021-01-02 15:43:03 +01:00
Paul Chote
fc1032cd9e Start rally point lines at the spawn position instead of the exit cell. 2021-01-02 15:29:18 +01:00
Paul Chote
60195e2842 Prevent Health: 100 from being added to actors. 2021-01-02 15:12:20 +01:00
Paul Chote
6fed31717c Fix map editor inverting preview color channels. 2021-01-02 11:43:55 +01:00
Paul Chote
aee3eb99c3 Fix --dump-sequence-sheets crash. 2021-01-02 11:43:55 +01:00
Paul Chote
3aa6fd3dc4 Add a friendly type name for Nullable<T>. 2021-01-02 11:38:24 +01:00
teinarss
5e74e58b22 Add support for dotnet core for Windows 2021-01-01 19:42:01 +01:00
abcdefg30
fef7a018f2 Add an update rule 2020-12-31 12:09:56 +01:00
abcdefg30
1d4891b017 Rename several MP traits 2020-12-31 12:09:56 +01:00
Ivaylo Draganov
e9a803e3c1 Update launch.json to work with the new launcher 2020-12-30 17:31:37 +01:00
Nah
4abe7d5895 Update defaults.yaml
Fix the Building's SoundOnDamageTransition DamagedSounds with the correct one and add a second sound file to DestroyedSounds for more variation like in the original Tiberian Dawn.
2020-12-30 14:06:56 +00:00
abcdefg30
cd68db5c11 Move myes1 and mrise1 from Select to Move Mechanic Voices 2020-12-30 02:01:00 +00:00
abcdefg30
ae9f437bb8 Enable mechanic voices from Aftermath 2020-12-30 02:01:00 +00:00
Smittytron
a047893049 Remove out of bounds actors from Exodus 2020-12-30 01:51:27 +00:00
Smittytron
5b2733decf Fix lag issue on Exodus by narrowing exit area 2020-12-30 01:51:27 +00:00
Ivaylo Draganov
ff60540fac Add player random faction info in the objectives panel 2020-12-30 01:44:50 +00:00
abcdefg30
a68a91bb39 Explicitly return on failure in make.ps1 2020-12-29 21:26:07 +01:00
abcdefg30
0bf8d2241f Correct Shock Trooper Move and Select voices 2020-12-29 21:15:53 +01:00
Orb
06850e6271 Fix-MT-Sound-Commit 2020-12-28 10:56:20 +01:00
Paul Chote
62fa3b7c9c Rename SpriteFrameType enums. 2020-12-25 18:51:25 +01:00
Paul Chote
ce09b402d0 Fix definition and use of non-indexed sprite color channels.
Our SpriteFrameType names refer to the byte channel order rather than
the bit order, meaning that SpriteFrameType.BGRA corresponds to the
standard Color.ToArgb() etc byte order when the (little-endian) integer
is read as 4 individual bytes.

The previous code did not account for the fact that non-indexed Png
uses big-endian storage for its RGBA colours, and that SheetBuilder
had the color channels incorrectly swapped to match and cancel this out.

New SpriteFrameType enums are introduced to distinguish between BGRA
(little-endian) and RGBA (big-endian) formats, and also for 24bit data
without alpha. The channel swizzling / alpha creation is now handled
when copying into the texture atlas, removing the need for non-png
ISpriteLoader implementations to allocate an additional temporary array
and reorder the channels during load.
2020-12-25 18:51:25 +01:00
Paul Chote
6e7ad9df25 Remove vestigial translation plumbing.
This was never completed to the level required to
be properly used ingame.
2020-12-25 16:18:28 +01:00
Matthias Mailänder
fb20479379 Add .vxl support to the asset browser. 2020-12-25 00:00:11 +00:00
Matthias Mailänder
9d181e88d2 Name the files that cause crashes. 2020-12-25 00:00:11 +00:00
Vapre
e90fc1ef39 As proposed by Leonardo-Ferreira. 2020-12-24 23:43:35 +00:00
Vapre
ce013f17d6 Server DispatchOrdersToClients create frame once for all clients.
Avoid creating frame data per client connection. Avoid
the allocation of a memory stream and setting frame header
and copying frame data.
2020-12-24 23:43:35 +00:00
Vapre
78253ce284 Activity, fixes.
Do not call SkipDoneActivities method recursively via the
NextActivity property. Rather use the nextActivity member.
Avoiding additional function calls and a recursively
growing stack.

Do not call ChildActivity and NextActivity properties
twice in a row. Once to test for null and after to access
it's value. It will cause the complete list of activities
to be traversed twice looking for non done activities.

Replace Queue method with a version that does not the
NextActivity property causing an extra call to
SkipDoneActivities. Avoid calling Queue recursively.

Similar replace QueueChild with a version that does
not call additional methods.

Note that ActivitiesImplementing returns only non
done activities. The method name does not suggest this.

Please consider making NextActivity a method to cleary indicate it
involves the logic of skipping Done activities. To let
the called know it is 'expensive'.

Please consider renaming the protected property ChildActivity to
FirstChildActivityNotDone to avoid it being used as childActivity.

Please consider maintaining a pointer to the first
non done activity. This avoids the need the each time find it.
2020-12-24 23:02:07 +00:00
Taryn Hill
2671e40c1d feat: ActorSpawnManager.SpawnInterval supports 1 or 2 values
Providing 2 values creates a range from which a value is randomly selected.
2020-12-24 22:15:15 +00:00
Matthias Mailänder
04cda69ef9 This compression is actually not yet supported. 2020-12-24 22:05:37 +00:00
Matthias Mailänder
b4c483ce1a Fix channels. 2020-12-24 22:05:37 +00:00
Matthias Mailänder
9a9f58d744 Support 8 bit .aud files. 2020-12-24 22:05:37 +00:00
Matthias Mailänder
d38fe542a2 Improve performance. 2020-12-24 15:56:18 +00:00
Matthias Mailänder
80503fbf36 Bump SharpZipLib. 2020-12-24 13:48:21 +00:00
Paul Chote
99a23b4056 Fix an incorrect comment in install_assemblies_mono 2020-12-24 12:08:56 +01:00
Matthias Mailänder
13a7de4b6b Allow a system chat label override. 2020-12-24 10:01:54 +00:00
teinarss
73bba97aaa Update MasterServerPinger to modern approach 2020-12-22 20:57:40 +01:00
abcdefg30
d6e9cdab5b Add the 9th Dark Tournament map as "Oil Spill" 2020-12-21 21:08:39 +01:00
Paul Chote
1a177bc2de Remove unused variables from Map.SavePreview. 2020-12-19 13:07:01 +01:00
Paul Chote
e0b3e631fe Remove obsolete null checks. 2020-12-19 13:07:01 +01:00
Paul Chote
2518a353af Add lint test for invalid map tiles. 2020-12-19 13:07:01 +01:00
Paul Chote
989800efff Fix missing tiles in upstream maps. 2020-12-19 13:07:01 +01:00
Paul Chote
c02846e2cb Replace invalid tiles on map load. 2020-12-19 13:07:01 +01:00
Matthias Mailänder
09db4a0e25 Enable debug mode by default. 2020-12-15 23:06:05 +01:00
Trevor Nichols
a85da9d86c Implement loader for MegV3 file format 2020-12-15 11:11:05 +01:00
Paul Chote
920d00bbae Use nearest-neighbour scaling in --debug-chrome-regions utility command. 2020-12-14 22:38:25 +01:00
Ivaylo Draganov
62475279ee Remove unneeded chrome yaml declarations 2020-12-14 20:52:38 +01:00
Matthias Mailänder
d8e979d283 Remove dead code. 2020-12-14 20:38:50 +01:00
Paul Chote
299b8880dd Fix api output directory. 2020-12-14 18:33:35 +01:00
Paul Chote
61027e4067 Fix docs.openra.net repository reference. 2020-12-14 18:33:35 +01:00
Paul Chote
a7249c10dc Fix docs.openra.net documentation workflow. 2020-12-13 15:35:31 +01:00
Paul Chote
611d12ac78 Migrate CI and packaging from Travis CI to GitHub Actions. 2020-12-12 20:17:29 +00:00
abcdefg30
ef9f26a60d Fix MissionObjectives not properly ending the game 2020-12-12 14:59:49 +01:00
abcdefg30
aeaffc0a8e Properly restrict the spectator view in mission maps 2020-12-12 14:59:49 +01:00
Paul Chote
e3084e230e Switch mirror for nsis3 package. 2020-12-12 14:54:50 +01:00
Paul Chote
4c01c772f8 Fix incorrect animation playing when moving infantry stop to attack. 2020-12-12 14:40:13 +01:00
Paul Chote
ed94f7680a Revert "Fix WithInfantryBody wrongly overwriting attack animations"
This reverts commit 1a63cc4a41.
2020-12-12 14:40:13 +01:00
yuantse
408d66cdaf Add Allies 09a 2020-12-12 13:18:08 +01:00
Smittytron
c4a0f2f169 Add Counterstrike mission Sarin Gas 3: Controlled Burn 2020-12-12 13:15:18 +01:00
Paul Chote
26b28d26da Prevent Civilians from wandering onto Tiberium. 2020-12-12 12:54:46 +01:00
Paul Chote
8ded6dafd4 Add AvoidTerrainTypes to ScaredyCat. 2020-12-12 12:54:46 +01:00
Paul Chote
57a94ad667 Add AvoidTerrainTypes to Wanders. 2020-12-12 12:54:46 +01:00
Paul Chote
53933a4d8f Fix restart black screen race condition. 2020-12-11 22:57:57 +01:00
Paul Chote
6606d7dd93 Add DisplayFaction details to the replay metadata. 2020-12-11 18:05:44 +01:00
Paul Chote
7a256dcafa Fix rally point target line exit display. 2020-12-11 17:25:30 +01:00
abcdefg30
7899c52b6d Add an update rule 2020-12-11 17:13:02 +01:00
abcdefg30
919c670502 Update the rules of the default mods 2020-12-11 17:13:02 +01:00
abcdefg30
aac3174efc Rename Stances to Relationships in the yaml api 2020-12-11 17:13:02 +01:00
Paul Chote
a8d3d5c79a Fix Neutral crushing checks. 2020-12-08 20:17:11 +01:00
Paul Chote
7c852d90fb Ignore aircraft when searching for enemy targets. 2020-12-07 23:39:22 +01:00
Paul Chote
269ce9c406 Exclude carryalls from AI squads. 2020-12-07 23:39:22 +01:00
Paul Chote
53d98ec255 Abort squad states that are not able to move. 2020-12-07 23:39:22 +01:00
Paul Chote
7a7cd21578 Fix TD SAM Site facings being reset when damaged while closed. 2020-12-07 01:44:04 +01:00
abcdefg30
2b363e4e1c Fix WithInfantryBody wrongly overwriting attack animations 2020-12-07 00:29:16 +01:00
Paul Chote
b1560ae69c Overhaul packaging scripts and helpers:
- Shared helpers extracted to functions.sh for use by upstream packaging,
  Mod SDK, and downstream packaging (via the Makefile targets).
- Assembly management separated from data and combined between engine
  and mods to prepare for pending .NET core requirements.
- Streamline Makefile targets.
- Clean up a lot of old technical debt.
2020-12-06 17:16:47 +01:00
Paul Chote
f3ebe07540 Fix WithDeliveryAnimation overriding sell animation. 2020-12-06 09:49:40 +01:00
Orb
6cac587753 ST Death Explosion Change Commit 2020-12-06 09:47:22 +01:00
Paul Chote
09e6cc4add Enable dark mode support on macOS. 2020-12-05 17:09:32 +00:00
Paul Chote
5a2f91be1c Fix building bibs not blocking placement. 2020-12-05 17:06:04 +00:00
Paul Chote
25071b813e Prevent concrete from spawning underneath already placed building bibs.
This is the equivalent to reverting 83b61ab.
2020-12-05 17:06:04 +00:00
Paul Chote
d61bd675c4 Revert "Remove BuildingInfluence from ResourceLayer."
This reverts commit 1634f3b70e.
2020-12-05 17:06:04 +00:00
Paul Chote
582e2774ac Revert "Remove BuildingInfluence from building adjacency check."
This reverts commit 33a1ca5965.
2020-12-05 17:06:04 +00:00
Paul Chote
5a52ce5330 Revert "Remove BuildingInfluence trait."
This reverts commit 34bf143328.
2020-12-05 17:06:04 +00:00
abcdefg30
31c9b4fc80 Revert renderable buffer sorting improvements 2020-12-05 17:03:03 +00:00
abcdefg30
4953ce314b Make Attack turn during its own tick 2020-12-05 16:41:30 +00:00
Paul Chote
86519bfda5 Expose Player.HomeLocation to the Lua API. 2020-12-05 14:14:56 +01:00
teinarss
2c9a36b9a3 Update float3 to readonly and use in modifier for parameters. 2020-12-02 20:37:50 +01:00
Paul Chote
d3847d49ed Fix windows package filenames. 2020-12-02 19:41:24 +01:00
Paul Chote
57f40a0b20 Remove obsolete variable definition. 2020-12-02 19:41:24 +01:00
Paul Chote
fa05f4e4b0 Generate Unicode-aware Windows installers. 2020-12-02 19:41:24 +01:00
Paul Chote
754f41ecd1 Remove redundant python check from Linux package creation. 2020-12-02 19:41:24 +01:00
Paul Chote
4b6e1c2198 Add a utility wrapper script for non-Windows. 2020-12-02 16:57:51 +01:00
teinarss
e6db2c98d0 Make WRot readonly and use in parameter modifier 2020-12-01 22:54:39 +00:00
Paul Chote
942f1e2d9e Fix infantry ignoring the default subcell when produced.
They were being created with the correct subcell, but was rejecting it
as invalid because it was already occupied (by the unit itself).
2020-12-01 22:39:11 +01:00
Paul Chote
da5c94858f Evaluate exit distance from the exit cell instead of the spawn position. 2020-12-01 22:35:43 +01:00
Paul Chote
77ffc20a5f Convert Attack*.FacingTolerance to WAngle. 2020-11-30 16:39:48 +01:00
abcdefg30
d75fed3a00 Replace chan with c10 in actors spawned from selling RA tech buildings 2020-11-30 01:07:36 +01:00
Matthias Mailänder
2aba054fe8 Move it to the right folder. 2020-11-29 18:27:59 +01:00
Paul Chote
3b1f4ba07f Fix production exit desync. 2020-11-28 17:49:36 +01:00
Paul Chote
d35768e0f9 Rework Windows launchers:
- Use SDL2 message boxes instead of Winforms.
- Use a proper project instead of compiling a single file.
- Use assembly attributes instead of modifying strings in the source code.
- Remove generic OpenRA.exe launcher.
- Replace MakeLAA.exe with a python script.
2020-11-27 20:32:02 +01:00
Paul Chote
07a10069db Introduce new OpenRA.exe entrypoint and change OpenRA.Game to a library. 2020-11-27 20:32:02 +01:00
Paul Chote
20fe59e844 Output compiled binaries to ./bin. 2020-11-24 17:53:48 +01:00
Paul Chote
6ad5b9ebc4 Allow the game root directory to be moved away from the binaries. 2020-11-24 17:53:48 +01:00
Paul Chote
dd0b08d54a Replace ^ and . in platform paths with ^SupportDir and ^EngineDir. 2020-11-24 17:53:48 +01:00
Paul Chote
1cc1f93fb0 Rename Platform.GameDir to Platform.EngineDir. 2020-11-24 17:53:48 +01:00
Paul Chote
72f1f06ebc Remove Platform.UnresolvePath. 2020-11-22 16:42:46 +01:00
Paul Chote
151cea96e9 Remove Platform.IsPathRelativeToSupportDirectory. 2020-11-22 16:42:46 +01:00
Paul Chote
888915b53b Use Platform.GameDir explicitly in hardcoded paths. 2020-11-22 16:42:46 +01:00
Paul Chote
de7a84e8ed Don't use Platform.ResolvePath when constructing hardcoded paths. 2020-11-22 16:42:46 +01:00
Paul Chote
1dd5b113c7 Fix asset browser and map editor paths for SDK-based mods. 2020-11-22 16:42:46 +01:00
Paul Chote
e9ad38667e Expose TransformsInto* targetline colors to yaml. 2020-11-21 14:52:54 +01:00
abcdefg30
05e8026713 Remove or use unused variables in TransformsIntoAircraft 2020-11-20 23:12:44 +01:00
abcdefg30
5b75649888 Fix TransformsIntoAircraft transforming on all orders 2020-11-20 23:12:44 +01:00
Matthias Mailänder
c22392eb1e Enable itch app auto updates on Windows. 2020-11-17 19:46:28 +01:00
dnqbob
7c2a51df38 Make OrderGenerator flexible on mouse input for modder 2020-11-17 19:18:04 +01:00
reaperrr
05cb9b1fbf Fix dock sequence dock/undock notifications
- move Refinery dock/undock notifications to OnStateDock/-Undock
and only call Undock if Dock was also called.
- Add INotifyHarvesterAction support to VoxelHarvesterDockSequence.
2020-11-15 16:56:28 +01:00
reaperrr
6bba35c330 Fix TS harvesters getting stuck in unload graphics
when refinery is destroyed while unloading.
2020-11-15 16:56:28 +01:00
reaperrr
90d9ee1f5c Fix harv dock sequence issuing drag despite cancellation 2020-11-15 16:56:28 +01:00
reaperrr
385f01247b Fix harvs dragging to refinery even if it died while turning 2020-11-15 16:56:28 +01:00
reaperrr
996029ee38 Fix undock anim playing even if docking was cancelled
...before dock anim could run.

The undock animation would play even if the dock anim
hadn't run (meaning the sequence cancelled before the docking
completed, for example due to refinery death).
2020-11-15 16:56:28 +01:00
reaperrr
87929b3d91 Fix dock animation continuing after refinery died
OnStateDock would always be triggered, even if the
refinery was killed before the harvester would finish
docking.
2020-11-15 16:56:28 +01:00
abcdefg30
e7e50cc101 Remove WorldUtils.AreMutualAllies 2020-11-15 16:37:51 +01:00
abcdefg30
d6c0926856 Remove LaysTerrain 2020-11-15 16:33:32 +01:00
abcdefg30
99ec119ffd Move LaysTerrain functionality to D2kBuilding 2020-11-15 16:33:32 +01:00
abcdefg30
6b2920cc91 Introduce D2kBuilding 2020-11-15 16:33:32 +01:00
abcdefg30
05f933f007 Add an update rule for the DamagedByTerrain refactor 2020-11-15 16:33:32 +01:00
abcdefg30
80aeb5ada6 Refactor DamagedByTerrain 2020-11-15 16:33:32 +01:00
abcdefg30
83ea65d4ff Require IOccupySpace for DamagedByTerrain 2020-11-15 16:33:32 +01:00
Paul Chote
46b3b01b89 Fix WithVoxelBarrel orientation calculations. 2020-11-15 13:51:12 +00:00
Orb
973f679939 TD Veterancy Adjustment Commit 2020-11-15 09:46:54 +01:00
abcdefg30
6de1b7b915 Always mark defeated/victorious players as spectating 2020-11-15 09:45:16 +01:00
Orb
e7ce739fec TD Fix Repair Times Commit 2020-11-15 09:42:21 +01:00
abcdefg30
bf14a4ce80 Remove an unused variable from LoadComplete 2020-11-15 09:38:02 +01:00
abcdefg30
8840a690c6 Fix maps without spawn points no longer working 2020-11-15 09:38:02 +01:00
abcdefg30
77e85e7c58 Change DisabledSpawnPoints from List to HashSet 2020-11-15 09:38:02 +01:00
Pavol Molnar
6943cf5ad5 fixed tooltip, issue 18301 2020-11-15 09:36:56 +01:00
Vapre
17996dfdfc Shroud, access ProjectedCellLayer by array index. Shroud.touchedCount to avoid Tick updates.
Shroud, access ProjectedCellLayer by array index over PPos index.

Performance improvement. Avoid the multiple PPos to array index
conversions in the same method call by calculating the cell
layer index once.

Background:

`Shroud.Tick` and `ProjectedCellLayer.Index(PPos puv)` shows up
in profile reports as one of the most expensive methods
(9% of CPU time).

In `Shroud.Tick` calls `ProjectedCellLayer.Index(PPos puv)` multiple
times for the same or different cell layers of the same dimension.

Improvement:

Benchmark results show an 0.5ms mean improvement in tick
time and 0.3 improvement in render time -
on a replay map of 1.12 min of play at max speed.

Render time:
       render222052(bleed)  render221934(this commit)
count   8144.000000   8144.000000
mean      11.410075     11.470100
std        5.004876      4.731463
min        3.450700      3.638400
25%        7.409100      7.015900
50%       12.410600     12.435900
75%       13.998100     14.242900
max      149.036200    149.656500

Tick time:
       tick_time222043(bleed)  tick_time221923(this commit)
count      2366.000000      2366.000000
mean          4.762923         4.275833
std           3.240976         3.206362
min           0.263900         1.653600
25%           4.145375         3.668600
50%           4.779350         4.240050
75%           5.232575         4.611775
max          85.751800        87.387100

Shroud.touchedCount to avoid Tick updates if no cells touched.

Avoids iterating over all map cells of the `touched` cell layer.

Tick time improvement of 40%+ - during at least the first two
minutes of gameplay.

During the first minutes of a game - out of every 1000 ticks
only 10-100 result in the Shroud - of any player - to be touched.

For certains player types (Neutral, Creep) less Shroud updates
are expected throughout a complete game.

Throughout a complete game human/AI players can also have no
Shroud touches during certain Ticks.
2020-11-14 18:33:49 +00:00
reaperrr
7f32776701 Fix some RA effect warheads ignoring water actors 2020-11-14 16:06:21 +01:00
reaperrr
fce109a46d Fix piff anims of Sniper and SilencedPPK weapons 2020-11-14 16:06:21 +01:00
reaperrr
748292324a Update RA/TD light guns cosmetic effects
Use single piff instead of piffs per impact on
M60s and M1, but in return add visual inaccuracy.

Gave minigunner MG two additional delayed effect warheads
to match sound and fire animation.
2020-11-14 16:06:21 +01:00
reaperrr
efe0de2ecb Move around TD Pistol yaml
Feels more organized if located below the inherited
^LightMG, like all other inheritors.
2020-11-14 16:06:21 +01:00
reaperrr
cac9940736 Support 'inaccuracy' on effect warhead
Purely cosmetic, allows to 'fake' slight inaccuracy without
affecting game balance on weapons like light machine guns.
2020-11-14 16:06:21 +01:00
abcdefg30
559b143265 Use FlyForward for strafing 2020-11-14 12:50:02 +00:00
abcdefg30
a66305e282 Fix the constructor order of FlyForward 2020-11-14 12:50:02 +00:00
abcdefg30
b3aa61ee8e Make fields readonly where possible 2020-11-14 12:50:02 +00:00
abcdefg30
80436a3195 Add a distance based constructor to FlyForward 2020-11-14 12:50:02 +00:00
abcdefg30
5127a6813d Rename FlyTimed to FlyForward 2020-11-14 12:50:02 +00:00
tovl
84eb3c54ef Expose targetline colors to yaml.
All targetlines can now be set to a custom color in yaml or set to be invisible.
All automated behaviours including scripted activities now have no visible target lines.
2020-11-14 12:04:19 +00:00
abcdefg30
ea3c7a3c34 Remove the Stances dictionary 2020-11-14 11:04:41 +00:00
abcdefg30
718cf37146 Misc code improvements 2020-11-14 11:04:41 +00:00
abcdefg30
10f645bf77 Replace usage of the Stances dict by a method call 2020-11-14 11:04:41 +00:00
abcdefg30
eda9966d27 Rename Stance to PlayerRelationship 2020-11-14 11:04:41 +00:00
abc013
672172d1f1 Add missing PlayNotification calls to SelectTarget. 2020-11-12 19:52:06 +00:00
abcdefg30
a366e37014 Fix angles in the Descriptions of TDGunboat 2020-11-10 20:32:08 +01:00
Trevor Nichols
d66e0bb22e Right click lobby spawns to disable or remove players. 2020-11-07 19:33:28 +01:00
teinarss
13581c030d Use in parameter for Target 2020-11-06 22:02:24 +01:00
teinarss
13a8b6bda2 Make Target readonly 2020-11-06 22:02:24 +01:00
Paul Chote
3aaaa95618 Apply range modifiers to Missile RangeLimit. 2020-11-05 19:15:13 +01:00
abcdefg30
e3929d7ded Fix reservable crashing when unreserving and attack moving 2020-11-05 13:22:22 +01:00
teinarss
2c62f747d9 Fix style in issue template config 2020-11-04 23:26:04 +01:00
teinarss
e08818cca1 Update issue template with links to FAQ 2020-11-04 23:26:04 +01:00
Matthias Mailänder
b4670345dd Don't crash when the bullet bounces outside of the map. 2020-11-04 10:59:55 +01:00
abcdefg30
0320dcdef9 Revise the RA map pool 2020-11-02 21:32:25 +00:00
Mustafa Alperen Seki
8b12cce250 Disable neutral Oil Derricks in TD and RA. 2020-11-02 21:27:37 +00:00
Mustafa Alperen Seki
6bb7ab0f97 Add GrantConditionOnCombatantOwner. 2020-11-02 21:27:37 +00:00
Matthias Mailänder
b32346d65f Add a range marker to the nuke targeter. 2020-11-02 10:13:29 +00:00
darkademic
8f9c212921 Make AI randomly select from map squares with above average attractiveness when using support powers. 2020-11-01 21:20:00 +00:00
Orb
df39d4fcc4 TD Map Pool 2020 Commit 2020-11-01 19:21:23 +00:00
RoosterDragon
4daa5193b6 Use tie breaks for sort order in WorldRenderer.GenerateRenderables 2020-11-01 19:00:20 +00:00
abc013
13596c1474 Add offset to Explodes. 2020-10-31 17:48:21 +01:00
abc013
bb71b59e18 Improve explosion determination. 2020-10-31 14:55:13 +01:00
abc013
f2797c711c Add InvalidBounceTerrain parameter to Projectile. 2020-10-31 14:55:13 +01:00
Paul Chote
6b6b1e56e6 Resolve random players and spawn points in server replays. 2020-10-31 14:31:44 +01:00
abcdefg30
7b75a78e38 Fix free-of-charge repairing still costing credits 2020-10-30 15:12:47 +01:00
Taryn Hill
2cea4b26e8 vscode debugging: build before launching 2020-10-30 13:58:05 +01:00
dnqbob
48f4a98c6a Fix AI air squad misbehaving in TS maps
Change Cpos to Mpos by Pchote
2020-10-30 09:20:01 +01:00
Paul Chote
9ddc9073c2 Revert "Determine stance for spectators based on shroud selection"
This reverts commit e459fde031.
2020-10-30 08:36:23 +01:00
abcdefg30
774f2e0852 Fix Production.cs not properly using INotifyCreated 2020-10-29 21:42:03 +00:00
abcdefg30
f5a963ac47 Production now uses nearest exit to rally point. 2020-10-29 21:42:03 +00:00
Vapre
38f1f1e5c2 Replace TraitContainer.AllEnumerator with ApplyToAll.
As proposed in the past in #13577.

Replace TraitContainer.All() that uses the custom AllEnumerator with
TraitContainer.ApplyToAllX() that takes an action as argument.

The AllEnumerator.Current function show up in profiling reports since it is
used each tick multiple times for multiple traits. The function is 'heavy'
because it creates TraitPair<T>'s temporary objects for each actor
trait combination.

In the past about 20k ITick trait pairs were present during an average
multi player game.

Using an Apply function that takes an action avoid the need to create
these temporary objects.

To be able to still use 'DoTimed' somewhat efficiently the measurement
was moved to inside the trait container method.

Results in a 25% performance improvement in accessing all traits of
a certain type.

Apply function could be used for other TraitContainer functions as well
for further improvements.

Test result for calling on a dummy trait on 20k actors a 1000 times:
  1315 ms traitcontainer.AllEnumerator (current)
   989 ms traitcontainer.Apply (this commit)
2020-10-29 21:21:12 +00:00
Mustafa Alperen Seki
4cdbf74256 Add Align: to SupportPowerTimerWidget. 2020-10-29 19:46:51 +01:00
Andrew Odintsov
bd0738c5c4 Determine stance for spectators based on shroud selection 2020-10-26 23:39:42 +00:00
Paul Chote
72c82cb080 Remove BuildingInfluence trait. 2020-10-26 16:51:12 +01:00
Paul Chote
b9dd59cd63 Remove BuildingInfluence from building adjacency check. 2020-10-26 16:51:12 +01:00
Paul Chote
79019b06ca Remove BuildingInfluence from Plug placement. 2020-10-26 16:51:12 +01:00
Paul Chote
90b25be1b6 Remove BuildingInfluence from ResourceLayer. 2020-10-26 16:51:12 +01:00
Paul Chote
e4faa6b0f0 Remove BuildingInfluence from Aircraft. 2020-10-26 16:51:12 +01:00
Paul Chote
1a3dfdc67f Remove BuildingInfluence from LaysTerrain. 2020-10-26 16:51:12 +01:00
Paul Chote
8d2156fb30 Remove BuildingInfluence from BuildableTerrainLayer. 2020-10-26 16:51:12 +01:00
Paul Chote
5e032edd28 Remove redundant BuildingInfluence checks.
Buildings are already excluded by the ActorMap checks.
2020-10-26 16:51:12 +01:00
Vapre
63d597e4ad ShroudRenderer UpdateShroud only when at least one cell is dirty.
UpdateShroud shows up in profile reports as one of the most
active methods (2.3% CPU time, main mono thread).

This commit introduces `anyCellDirty` to indicate that at lease one
of the cells was marked as dirty.

Avoiding the need to traverse all projected cells of the map
to find any dirty cell.

This reduces the number of shroud updates by at least 50% during a
test game. I assume this is related to renders occurring more
often than logic ticks(?).
2020-10-25 23:01:19 +01:00
Pavel Penev
4135045ca4 Added valid TerrainTypes to the Minelayer trait
Also added a configurable deploy cursor and fixed Minelayer target cell validation checks, which should make for a much better experiencing when dragging over an area with blocking terrain, shroud, fog, etc.
2020-10-24 12:20:15 +02:00
abcdefg30
538623c835 Add a lint check for player counts 2020-10-24 10:09:22 +02:00
abcdefg30
3674583053 Throw an exception at load when a map has more than 64 players 2020-10-24 10:09:22 +02:00
Paul Chote
daa8c74c37 Improve Replaceable logic:
- Remove BuildingInfluence checks
- Support multiple Replaceable/Replacement traits on the same actors
- Fix description typos
2020-10-22 22:15:43 +02:00
Mustafa Alperen Seki
8aeec24c9b Add DamageTypes to Demolition 2020-10-21 18:41:16 +02:00
RoosterDragon
54c4a05062 Classes derived from Stream override ReadByte.
The Stream.ReadByte method is implemented by allocating a 1 byte buffer and calling into Read(byte[], int, int). Override ReadByte in derived classes to avoid needing to allocate this small temp buffer.

Also, fix some bugs in the stream implementations. Remove Write capability from MergedStream that didn't make sense. Add guards into SegmentStream to ensure reads and writes belonged to the segment - otherwise a reader or writer could access regions of the base stream that were outside the intended segment.
2020-10-20 22:53:32 +02:00
RoosterDragon
466de89e17 PackageEntry.HashFilename avoids stream reads .
Operate directly on the array to avoid overhead of stream reads.
2020-10-20 22:53:32 +02:00
RoosterDragon
6eaf51d450 CursorManager avoids use of BitConverter.
Avoid allocating a small temp array via BitConverter.GetBytes, and instead use bitwise ops to isolate the components of the color.
2020-10-20 22:53:32 +02:00
RoosterDragon
7c8dc5d5f4 XccGlobalDatabase allocation improvements
- Use the count to size the capacity of the list.
- Use a char array as a buffer, so will can build each string directly rather than needing a ToArray call first.
2020-10-20 22:53:32 +02:00
RoosterDragon
4f34d3edb3 Improvements in MiniYaml allocation
- Clone method will use the node count to create the correct capacity.
- ResolveInherits will use the node count as the suggested initial capacity.
- FromStream will now stream lines, rather than reading the whole file into memory and then splitting into lines.
2020-10-20 22:53:32 +02:00
RoosterDragon
0efdbc762d Avoid ReadBytes calls in some StreamExts methods.
Read individual bytes to avoid allocating small temp arrays.
2020-10-20 22:53:32 +02:00
Matthias Mailänder
5e42c03afc Replace more \n characters with write lines. 2020-10-19 22:37:01 +01:00
Matthias Mailänder
58726160a9 Reduce the indention level to show the table of contents. 2020-10-19 22:37:01 +01:00
Matthias Mailänder
8cd9215756 Add an additional new line before the unordered list. 2020-10-19 22:37:01 +01:00
Orb
0e33640b14 Code Polish TD Commit 2020-10-19 13:33:25 +02:00
reaperrr
a1c8cbab0b Enable recoil anim on RA/TD Gun Turrets 2020-10-18 20:39:22 +02:00
reaperrr
50b484df56 Fix RA/TD defense turrets facing issues
By using WithSpriteTurret instead of
WithEmbeddedTurretSpriteBody.
2020-10-18 20:39:22 +02:00
reaperrr
99facd2797 Fix default facing of RA/TD Gun Turrets
Compare with make anim and original, 224 was
one facing too far.
2020-10-18 20:39:22 +02:00
Paul Chote
f79e1cacf0 Fix and document FMV scanline rendering. 2020-10-18 20:15:11 +02:00
Paul Chote
82069db724 Fix FMV aspect ratio. 2020-10-18 20:15:11 +02:00
Paul Chote
5a7dc385a3 Remove obsolete LocomotorInfo caching. 2020-10-18 18:19:56 +02:00
darkademic
49e7a33db0 Fixed WithRangeCircle when Visibility is set to Always. 2020-10-18 18:06:22 +02:00
Paul Chote
90b26681eb Remove trait queries from Actor ctor. 2020-10-18 18:00:17 +02:00
Matthias Mailänder
14fc0254c6 Make all range circles fully configurable. 2020-10-18 15:08:17 +01:00
Matthias Mailänder
214aa64ce3 Fix Analyzer warning: V3128 field is used before initialized 2020-10-18 14:53:35 +01:00
abcdefg30
a7bb217887 Make the calculation of DesiredLocalFacing more readable 2020-10-18 14:48:05 +01:00
abcdefg30
10cb8090ec Remove the second arrow on the preview of gdi08a 2020-10-18 14:33:52 +01:00
abcdefg30
1fdecb4e9d Fix briefing text and video of nod04a 2020-10-18 14:33:52 +01:00
abcdefg30
575596c9ad Fix map previews and order in TD 2020-10-18 14:33:52 +01:00
RoosterDragon
e11c8436bd Misc changes to reduce allocation:
- Avoid creating new strings in SpriteRenderer.Flush.
- ProductionQueue.CancelUnbuildableItems can exit early if the queue is empty. It can also use a set of names for quicker lookups.
- OpenGL.CheckGLError avoids a Enum.HasFlag call.
2020-10-17 23:48:48 +02:00
RoosterDragon
c23efea402 Comments to justify GC.Collect calls, compact LOH during load. 2020-10-17 23:48:48 +02:00
RoosterDragon
8d3cec5bea When a render method has nothing to render, eagerly return.
By eagerly returning an empty enumerable in these cases, this avoids allocating an enumerable for the whole render method if nothing will be drawn.
2020-10-17 23:48:48 +02:00
RoosterDragon
87389d3051 Reuse a list in FrozenActor.RefreshState 2020-10-17 23:48:48 +02:00
RoosterDragon
71e3ca4493 Sort renderables in-place in WorldRenderer.GenerateRenderables 2020-10-17 23:48:48 +02:00
RoosterDragon
2adee1e374 Use HasMovementType to avoid Enum.HasFlag allocations. 2020-10-17 23:48:48 +02:00
RoosterDragon
094ccf76b0 Prefer Min/MaxBy overloads to OrderBy().First() patterns 2020-10-17 23:48:48 +02:00
RoosterDragon
bb116034c7 Avoid or reduce LINQ allocations required in various areas. 2020-10-17 23:48:48 +02:00
Paul Chote
da53d5b776 Fix a divide by zero crash in Move. 2020-10-17 22:31:35 +02:00
abcdefg30
75fe0e524f Fix units not attack moving to waypoints after resupply/takeoff 2020-10-17 19:48:54 +01:00
Matthias Mailänder
0ded0355c1 Allow mod code to set rally point indicators. 2020-10-16 18:14:33 +01:00
Matthias Mailänder
4da14cee0a Disable UPnP on local games. 2020-10-16 18:14:33 +01:00
Orb
90c8e112e2 Stealth C17 Checkbox 2020-10-16 18:09:43 +01:00
Orb
d49bf81d95 TD Balance 2020 3 Commit 2020-10-16 17:52:41 +01:00
abcdefg30
abbe16b6ec Remove default parameters 2020-10-15 10:53:06 +02:00
abcdefg30
274bf06eae Fix evacuated civilians not staying at the GDI base 2020-10-15 10:53:06 +02:00
abcdefg30
dcf7b6b3f6 Add an alternative escape route to the south 2020-10-15 10:53:06 +02:00
abcdefg30
4173e40a9d Use actor names instead of searching for actors with a type 2020-10-15 10:53:06 +02:00
abcdefg30
1abd272862 Fix actor naming since those are not Nod soldiers 2020-10-15 10:53:06 +02:00
abcdefg30
946bf7b9fa Let civilians flee away from - not towards - the player in Nod04b 2020-10-15 10:53:06 +02:00
Matthias Mailänder
0d64fa549b Fix the command bar selecting dead units
and crashing while doing a trait lookup on them.
2020-10-14 19:58:24 +02:00
abcdefg30
8a7020b4ef Ignore the length requirement of sync orders we want to drop 2020-10-14 19:53:49 +02:00
abcdefg30
1bc19e788c Drop and log sync orders with mismatching length 2020-10-14 19:53:49 +02:00
abcdefg30
c17110dac5 Make OrderManager fields readonly where possible 2020-10-14 19:53:49 +02:00
abcdefg30
d07b34e67e Style fixups in ReplayConnection.cs 2020-10-14 19:53:49 +02:00
abcdefg30
accecee018 Fix savegames not saving sync packets correctly 2020-10-14 19:53:49 +02:00
abcdefg30
1861174d38 Add a Order.SyncHashOrderLength const 2020-10-14 19:53:49 +02:00
Curtis Shmyr
8d5ed65feb Remove effective owner check when choosing armament 2020-10-14 19:52:34 +02:00
Paul Chote
a375f0e58a Rewrite spawn point assignment logic. 2020-10-13 20:41:39 +02:00
RoosterDragon
b2b639434c ThreadedGraphicsContext improvements.
- VertexBuffer interface redefined to remove an IntPtr overload for SetData. This removes some unsafe code in TerrainSpriteLayer. This also allows the ThreadedVertexBuffer to use a buffer and post these calls, meaning the SetData call can now be non-blocking.
- ThreadedTexture SetData now checks the incoming array size. As the arrays sent here are usually large (megabytes) this allows us to avoid creating temp arrays in the LOH and skip Array.Copy calls on large arrays. This means the call is now blocking more often, but significantly reduces memory churn and GC Gen2 collections.
2020-10-13 15:54:53 +02:00
Curtis Shmyr
5eadd26f66 Set lobby bool display values to start uppercase 2020-10-12 22:05:35 +02:00
Curtis Shmyr
c0cbca26ea Use lobby option display values when clients join 2020-10-12 22:05:35 +02: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
RoosterDragon
9072d645fd Use TrimExcess to shrink lists used by MiniYaml after loading 2020-10-12 21:57:08 +02:00
Paul Chote
597b8b1caa Hide legacy GL support behind a feature flag. 2020-10-12 12:24:22 +02:00
Paul Chote
2c0d512727 Package and default to GLES via ANGLE on windows. 2020-10-12 12:24:22 +02:00
Paul Chote
87c5cc96ad Add an "Automatic" GL profile. 2020-10-12 12:24:22 +02:00
Paul Chote
fc844cfa6d Print the GL_RENDERER string to stdout on engine start. 2020-10-12 12:24:22 +02:00
Paul Chote
1ab1c30e39 Remove glGetTexImage/glBindFragDataLocation on GLES.
These functions are not available in GLES3.
2020-10-12 12:24:22 +02:00
reaperrr
f2a1a497c7 Fix Pillbox damage
These were overlooked during the RA target type
refactor.
2020-10-12 11:56:55 +02:00
Paul Chote
1ddbe50b3f Add inline node inclusion support to mod.yaml. 2020-10-11 01:42:59 +02:00
Paul Chote
dd7b8b24af Use tileset ID in sequences instead of the TileSet object. 2020-10-11 01:23:15 +02:00
abcdefg30
6dcb701d1d Fix a crash in AIUtils 2020-10-10 17:54:55 +02:00
reaperrr
f67b7ad837 Cache IResolveOrder traits on Actor
Avoids looking up all of them each time
an actor is given an order.
2020-10-10 13:59:40 +01:00
reaperrr
a4a409f39b Pass world directly to UnitOrders.ResolveOrder
Avoids order.Subject.World look-ups.

Also removes validOrders parameter,
we can get that directly from World now.
2020-10-10 13:59:40 +01:00
reaperrr
904a5f60d1 Cache IOrderValidator traits on World 2020-10-10 13:59:40 +01:00
dnqbob
ca8341d432 Avoid WaterCheck crash in base builder 2020-10-10 11:44:43 +02:00
Clément Bœsch
815bbc6ee8 Save disconnect frame in the GameInformation
This information is useful to infer a winner in case the winstate is
unknown.
2020-10-10 01:17:39 +02:00
Clément Bœsch
ca8870a5cf Server: handle wins/losses using Sync hash
Signed-off-by: Paul Chote <pchote@users.noreply.github.com>
2020-10-10 01:17:39 +02:00
Clément Bœsch
e5da58e2b4 Server: add basic replay recording
Signed-off-by: Paul Chote <pchote@users.noreply.github.com>
2020-10-10 01:17:39 +02:00
Paul Chote
dd18829def Traits: add ICreatePlayersInfo
Signed-off-by: Clément Bœsch <u@pkh.me>
2020-10-10 01:17:39 +02:00
Paul Chote
41814a881d Player: move player name resolve in a dedicated function
Signed-off-by: Paul Chote <pchote@users.noreply.github.com>
2020-10-10 01:17:39 +02:00
Clément Bœsch
d708f46d50 Orders: make SyncHash packet size check more accurate 2020-10-10 01:17:39 +02:00
Clément Bœsch
11f57b2b26 Protocol: add defeat state bitfields to Sync packets
Signed-off-by: Paul Chote <pchote@users.noreply.github.com>
2020-10-10 01:17:39 +02:00
Paul Chote
60df247416 Streamline SpawnOccupant management. 2020-10-09 12:19:19 +02:00
Trevor Nichols
6f32196f89 Support List<> for FieldSaver/FieldLoader 2020-10-07 22:04:10 +02:00
abcdefg30
d647aab7fe Fix d2k conyards granting an unconsumed "auto-concrete" condition 2020-10-06 23:25:12 +01:00
Mustafa Alperen Seki
be88c33399 Add a lobby option to disable Concrete in D2k. 2020-10-06 13:29:33 +02:00
Mustafa Alperen Seki
7372da150a Make LaysTerrain Conditional. 2020-10-06 13:29:33 +02:00
Mustafa Alperen Seki
3ec3eac160 Don't StartOnThreshold if the trait is disabled. 2020-10-06 13:29:33 +02:00
reaperrr
0990caefd7 Fix turreted defenses always realigning
This looks weird, doesn't match the originals
and makes map-defined custom facings useless.
2020-10-06 12:53:11 +02:00
Paul Chote
fc1786e243 Fix turrets immediately realigning on actor creation. 2020-10-05 15:13:48 +02:00
Matthias Mailänder
7e61199458 Fix a link in the Lua documentation. 2020-10-05 10:11:30 +02:00
Paul Chote
0672553a07 Lock Server.LobbyInfo to prevent races with callback threads. 2020-10-04 20:31:07 +02:00
reaperrr
8d1f72c104 Fix for SquadManagerBotModule
Aircraft and ships are immediately assigned a squad,
so adding them to `unitsHangingAroundTheBase` is bogus.
2020-10-04 00:31:35 +01:00
reaperrr
6337067032 Clean up property names + defaults of smudge smoke 2020-10-02 23:46:48 +02:00
reaperrr
7395a3ed2d Use cached world instead of query in SmudgeLayer 2020-10-02 23:46:48 +02:00
abcdefg30
e4e1878a4b Remove an used TerrainTemplateInfo constructor 2020-10-02 12:09:42 +02:00
abcdefg30
cc8908d7eb Make ProductionParadrop and ProductionAirdrop refund undelivered actors 2020-10-02 11:51:48 +02:00
abcdefg30
0dac4520ad Add a 'refundableValue' parameter to 'Produce' 2020-10-02 11:51:48 +02:00
Paul Chote
cc2e369475 Fix corrupted final frame in VQA playback. 2020-10-02 11:37:00 +02:00
tovl
92189e4b50 Let docking angle be determined by the host building. 2020-10-02 11:28:14 +02:00
abcdefg30
2e8c85ff0b Add support for querying the Passengers of an actor via Lua 2020-10-02 11:24:52 +02:00
abcdefg30
798aff1140 Fix ValidStances of RevealsMap not working 2020-10-02 11:17:03 +02:00
Niklas Holma
8596ce00cc Add a text field next to the map editor actor initializer sliders. 2020-09-28 15:46:19 +02:00
Matthias Mailänder
b5613acad8 Don't put absolute paths of developer machines in there. 2020-09-28 12:47:27 +02:00
Matthias Mailänder
7e992d44c8 Fix a crash when refineries share a cell. 2020-09-28 12:45:20 +02:00
Matthias Mailänder
7a7393b9f0 cachedWidth is never assigned. 2020-09-27 22:56:41 +01:00
Matthias Mailänder
f13e6fb76d Fix Analyzer warning V3008 variable is assigned values twice. 2020-09-27 22:56:41 +01:00
Mustafa Alperen Seki
3e83346915 Add DamageTypes to SoundOnDamageTransition. 2020-09-27 21:22:52 +01:00
Mustafa Alperen Seki
761d3583c4 Add DeathTypes to ShakeOnDeath. 2020-09-27 21:22:52 +01:00
abcdefg30
1a4b773fda Replace 'is' by 'as' and a null check in ScriptMemberWrapper 2020-09-27 22:17:20 +02:00
Matthias Mailänder
930f8ab207 Reset lobby ready state when options change server side. 2020-09-27 15:06:48 +02:00
Matthias Mailänder
2e438f1da9 Remove superfluous null checks. 2020-09-27 00:11:25 +01:00
abcdefg30
4627387ae3 Document the 'CancelActivity' field 2020-09-26 23:20:00 +01:00
abcdefg30
fd69bce609 Use CancelActivity instead of hackily using ResolveOrder 2020-09-26 23:20:00 +01:00
abcdefg30
391d9030cb Move update rules into their correct subfolder 2020-09-26 23:20:00 +01:00
abcdefg30
1ad9a4b65d Move shared color definitions to common metrics 2020-09-26 23:05:28 +01:00
abcdefg30
c6cc2405d3 Move shared sound definitions to common metrics 2020-09-26 23:05:28 +01:00
Matthias Mailänder
0e39cc7829 Tooltip is a conditional trait.
Fix Analyzer warning: V3146 Possible null dereference.
2020-09-26 22:59:39 +01:00
Matthias Mailänder
8d7e5f4663 Fix Analyzer warning: V3022 Expression is always true. 2020-09-26 22:59:39 +01:00
Paul Chote
e320bbfc87 Add disclaimer in readme. 2020-09-26 13:40:20 +02:00
Paul Chote
2e104046d4 Remove music downloads. 2020-09-26 13:40:20 +02:00
reaperrr
9cf38c1784 Increase Pillbox muzzle anim length
Length of muzzle anim now roughly matches the length
of the sound and impact animations.
2020-09-20 20:34:44 +02:00
Paul Chote
1aca6da1ea Hide "Furthest" battlefield camera option if the mod disables it. 2020-09-20 20:28:28 +02:00
abcdefg30
ce4d263b52 Fix AttackMove getting unarmed units stuck 2020-09-20 12:02:20 +02:00
abcdefg30
53c02eb2b9 Fix a crash in the Move activity 2020-09-18 20:12:42 +02:00
abcdefg30
82a2148300 Fix grouped orders not being validated correctly 2020-09-15 10:16:50 +02:00
Paul Chote
b72a58b917 Add missing ActorReferences to yaml dictionaries. 2020-09-15 09:27:50 +02:00
Paul Chote
7f7bce50dc Add dictionary support for ActorReference. 2020-09-15 09:27:50 +02:00
Paul Chote
290e214638 Remove unexpected RenderSprite.FactionImage fallback. 2020-09-12 17:52:46 +02:00
Paul Chote
ad4d6eaec9 Improve --check-missing-sprites error handling. 2020-09-12 17:52:46 +02:00
Paul Chote
cd9bf53e1a Use nameof() to reference image fields. 2020-09-12 17:52:46 +02:00
Paul Chote
ac8b312140 Generalize --check-sequence-sprites to --check-missing-sprites. 2020-09-12 17:52:46 +02:00
Paul Chote
3e849568ff Improve exception message for bogus tileset definitions. 2020-09-12 17:52:46 +02:00
Paul Chote
5d6961619d Fix WithIdleOverlayInfo Image override. 2020-09-12 17:52:46 +02:00
Paul Chote
94180f6a0a Add SequenceReference support for dictionaries. 2020-09-12 17:52:46 +02:00
Paul Chote
7803686aec Rewrite sequence linting / missing file handling.
- Distinguish between missing sequences and missing sprites
- Lint default sequences as well as maps
- Improved performance
- Correctly handle null images
2020-09-12 17:52:46 +02:00
Paul Chote
b8e60ca8ec Fix SequenceReference definitions. 2020-09-12 17:52:46 +02:00
Paul Chote
b985edbc29 Add ModData to ILintRulesPass.Run. 2020-09-12 17:52:46 +02:00
Paul Chote
ffdb3f86d7 Move mod-specific lint attributes to Mods.Common. 2020-09-12 17:52:46 +02:00
Paul Chote
c9b2a34561 Save SubCellInit as an integer. 2020-09-12 17:17:26 +02:00
Paul Chote
e5dc0309f1 Support OPENRA_DISPLAY_SCALE environment variable on Windows. 2020-09-12 00:37:20 +02:00
abcdefg30
57a3ad8ae2 Replace 'inner' with 'move' inside AttackMoveActivity 2020-09-12 00:30:33 +02:00
abcdefg30
ad3722e19f Add support for circumventing the target scan limit in AttackMove 2020-09-12 00:30:33 +02:00
abcdefg30
a12d127fd6 Rework the internals of AttackMoveActivity
Avoids creating and throwing away inner activities unnecessarily
2020-09-12 00:30:33 +02:00
abcdefg30
e80ebfae35 Use readonly where possible in AttackMoveActivity 2020-09-12 00:30:33 +02:00
abcdefg30
4669d6b378 Work around a sound issue when loading saves 2020-09-12 00:18:25 +02:00
abcdefg30
9f093da61e Unhardcode the leeway range of AttackFollow 2020-09-11 23:55:57 +02:00
abcdefg30
c0d31688c4 Exclude walls from the assets value 2020-09-11 23:44:30 +02:00
abcdefg30
86698e7822 Exclude C17, A10 and carryall.reinforce from the assets value 2020-09-11 23:44:30 +02:00
abcdefg30
3fc5859f08 Add 'AddToAssetsValue' to 'UpdatesPlayerStatistics' 2020-09-11 23:44:30 +02:00
tovl
f9bb663f6b Allow thieves to capture landed aircraft in RA mod. 2020-09-10 18:18:09 +02:00
tovl
5e8121bd0b Properly cancel EnterActor when target capturable trait is disabled. 2020-09-10 18:18:09 +02:00
Paul Chote
9cd6df2929 Replace DecorationPosition with mod-defined string ids. 2020-09-09 23:16:05 +02:00
Matthias Mailänder
b16cbeacb6 Sort contents before merging to unify UIDs across filesystems. 2020-09-07 17:25:24 +02:00
Matthias Mailänder
4d46464bc6 Fix an invalid target crash
target.CenterPosition is referenced in warhead orientation later
2020-09-06 12:21:15 +01:00
Matthias Mailänder
7746dc55f0 Remove the table of content
which is auto-generated by mkdocs.
2020-09-06 11:44:23 +01:00
Matthias Mailänder
5d9e8b56c5 Use fewer hard-coded HTML tags to improve mkdocs rendering. 2020-09-06 11:44:23 +01:00
Matthias Mailänder
d1c06365a8 Move automatic API documentation to docs.openra.net 2020-09-06 11:44:23 +01:00
Matthias Mailänder
b56ddc1a08 Check global scripts for Lua errors. 2020-09-05 21:13:47 +01:00
Orb
ae8c8e781f TD Balance Summer 2020 2 2020-09-05 21:02:59 +01:00
reaperrr
1344b1f2e3 Remove system order checks from PlayerStatistics
ResolveOrder for actors isn't even used
for these.
2020-09-05 17:22:04 +01:00
reaperrr
36df25dcb4 GivesExperience performance optimization
Move some look-ups to creation to reduce contribution
to actor death cost.
2020-09-05 17:16:00 +01:00
reaperrr
84246d287d Merge two ifs into one in SpawnActorOnDeath 2020-09-05 17:16:00 +01:00
reaperrr
6d0fbfa21f Explodes performance optimization
Cache armaments on creation, avoid LINQ.

Also merge and put first the DamageThreshold == 0
check in Damaged, because the common default IS 0,
so most of the time the IsTraitDisabled and
IsInWorld checks are redundant.
2020-09-05 17:16:00 +01:00
abcdefg30
034c6824de Fix MiG missiles damaging airborne actors 2020-09-05 18:06:30 +02:00
reaperrr
c8afa4a2a8 Remove defenderStats look-up from UpdatePlayerStatistics
playerStats is updated on owner change,
so it should always be identical to the removed defenderStats.
2020-09-05 11:12:38 +02:00
abcdefg30
1a77f7320b Fix a crash when updating the DiscordPresence party size 2020-09-05 10:36:35 +02:00
abcdefg30
183ece1360 Remove the unused SetPlayers method 2020-09-05 10:36:35 +02:00
abcdefg30
035cc3da99 Turn DiscordService's 'GetService' into property 2020-09-05 10:36:35 +02:00
ABrandau
c01c39954a Update Harpy Rotor 2020-09-01 18:57:43 +02:00
Matthias Mailänder
c48eb572e3 Remove MuzzleSplitFacings and expose MuzzleSequence to testing. 2020-09-01 18:53:43 +02:00
Paul Chote
b03ab1212f Remove install-core target. 2020-09-01 18:48:54 +02:00
Paul Chote
8a9b5e7e01 Split a separate "compat" macOS package that uses the system mono. 2020-09-01 18:48:54 +02:00
Paul Chote
9b90e4f25a Remove Coverity references. 2020-09-01 18:48:54 +02:00
Paul Chote
8a4401bdcb Fix Appveyor GeoIP download. 2020-09-01 18:48:54 +02:00
Paul Chote
d52e90cf23 Improve .travis.yml compatibility for non-OpenRA deploys. 2020-09-01 18:48:54 +02:00
Paul Chote
14ef0a7740 Remove markdown/html pages from windows install. 2020-09-01 18:48:54 +02:00
Paul Chote
c1f79b348a Generate platform-specific artwork from common source files. 2020-09-01 18:48:54 +02:00
Paul Chote
62166a50d9 Move itch upload script. 2020-09-01 18:48:54 +02:00
Brent Gardner
283b330403 Workaround for GLES 2.0 hardware 2020-09-01 18:00:51 +02:00
teinarss
2cf6b74295 Refactoring on GetEventBounds in Widget 2020-09-01 17:56:12 +02:00
abcdefg30
1a9f707d18 Remove the last reference to DedicatedLoop 2020-08-30 18:12:48 +02:00
Aigamo
06a1c88e86 Replace 0x7FFFFFFF with int.MaxValue 2020-08-29 12:37:20 +01:00
ycanardeau
f358b566b1 Replace NetFrameNumber >= 1 with GameStarted 2020-08-29 12:37:20 +01:00
reaperrr
15fc27d142 Use cached selected in SelectionDecorationsBase 2020-08-28 12:24:07 +02:00
reaperrr
ad20597d74 Cache hue picker sprite in HueSliderWidget 2020-08-27 21:17:37 +02:00
reaperrr
6d409a7c97 Cache indicator sprite in ResourceBarWidget at initialization 2020-08-27 21:17:37 +02:00
reaperrr
36d5ae5421 Cache SupportPowersWidget offsets at initialization
As well as overlay font.
2020-08-27 21:17:37 +02:00
tovl
db9744ea7f Let TS aircraft turn slower when circling. 2020-08-27 21:15:38 +02:00
tovl
5e62fe86fc Add IdleSpeed to aircraft trait. 2020-08-27 21:15:38 +02:00
Paul Chote
6cfa27c33b Replace per-color font caches with tinted rendering. 2020-08-24 18:38:08 +02:00
Taryn Hill
a405969199 docs: link to docs.openra.net instead of wiki.openra.net in readme for generated trait docs 2020-08-23 11:20:02 +02:00
Paul Praet
9a6f3b4c05 Reset Ready status of players in Lobby when options change
Addresses #11274
2020-08-23 00:05:55 +03:00
Matthias Mailänder
7be059a79b Download our cached version after they blocked Travis CI... 2020-08-22 13:06:08 +02:00
reaperrr
29b55de042 Cache rectangles and font in ProductionTabsWidget 2020-08-21 18:06:18 +02:00
reaperrr
235fb19aa8 Cache overlay traits in ProductionPaletteWidget
Instead of looking this up every Draw tick,
cache and update it only when a non-null new
CurrentQueue is set (as the overlays can only change
at that time).
2020-08-21 18:06:18 +02:00
reaperrr
c0f54fa4fc Cache offsets in ProductionPaletteWidget
At least those that never change.
2020-08-21 18:06:18 +02:00
reaperrr
cdc216aca0 Fix airborne husk target types
Doesn't really make a difference, since it only matters
for effect warheads and those already could target both
air and ground actors, but GroundActor was still wrong.
2020-08-20 20:46:58 +02:00
reaperrr
4505053618 Simplify CreateEffectWarhead code
Simplified and streamlined code,
based on past feedback and suggestions.

Note: The new methods will move to
Warhead later, once they're used by more
than one warhead.
2020-08-20 20:46:58 +02:00
abcdefg30
e0d53126d6 Remove the Light Tank husk 2020-08-20 19:17:39 +02:00
abcdefg30
12ff1dd14c Add RAGL balance changes 2020-08-20 19:17:39 +02:00
abcdefg30
50db3152f6 Fix the windows uninstaller name 2020-08-20 17:33:48 +02:00
teinarss
9c4fd0e3d3 Use Null-Propagation Operator 2020-08-19 18:11:07 +01:00
teinarss
8d27d22100 Use discard syntax 2020-08-19 18:11:07 +01:00
teinarss
27f1a7ab27 Use out var syntax 2020-08-19 18:11:07 +01:00
teinarss
d52e4793fe Refactor classes to structs 2020-08-19 11:54:29 +02:00
teinarss
544ac6cb33 Fix crash after entering manage content 2020-08-19 11:40:43 +02:00
Paul Chote
06fbc1a6cf Hide TraitInfo.InstanceName from FieldLoader. 2020-08-17 20:13:32 +02:00
abcdefg30
edab10e6a6 Make the Phase Transport uncloak during repair by mechanics 2020-08-16 21:01:16 +02:00
abcdefg30
dd99fc93e4 Uncloak during resupply when "UncloakOn: Dock" is defined 2020-08-16 21:01:16 +02:00
abcdefg30
dbe824d4e5 Correct "offseted" to "offset" 2020-08-16 15:02:56 +02:00
Paul Chote
6e73d7f5c2 Tidy MapEditorLogic ctor. 2020-08-16 14:17:45 +02:00
Paul Chote
960056d300 Fix mod switcher icon handling. 2020-08-16 14:17:45 +02:00
Paul Chote
3efac3287e Fix Session.Deserialize error handling. 2020-08-16 14:17:45 +02:00
Paul Chote
c4b4a8c8a5 Fix incorrect ramp fill in Map.Resize. 2020-08-16 14:17:45 +02:00
Paul Chote
b833f033bf Remove redundant check from LabelWithHighlightWidget. 2020-08-16 14:17:45 +02:00
Paul Chote
ad75e2be89 Remove redundant check from SupportPowerInstance. 2020-08-16 14:17:45 +02:00
Orb
7ee4fbeb0d New Money Settings 2020-08-15 21:02:01 +01:00
Paul Chote
9886f0ca9a Fix Harvester crash when multiple resource renderers are used. 2020-08-15 18:43:40 +02:00
Paul Chote
46cf56d6ff Remove editor-specific resource rendering.
Mods must manually move their *ResourceRenderer definitions from
World onto BaseWorld to restore resource rendering in the editor.
2020-08-15 18:43:40 +02:00
Matthias Mailänder
e7af295b5e Allow news per mod. 2020-08-15 16:21:21 +01:00
Matthias Mailänder
9d179d9a1a Initialize the font only once and make it configurable. 2020-08-15 16:13:21 +01:00
Matthias Mailänder
15010f9567 Fix production palette ignoring yaml font overrides. 2020-08-15 16:13:21 +01:00
Oliver Brakmann
a7f4f6c1cf Use LeaveMapAtClosestEdge for scripted MiGs on Intervention 2020-08-15 13:38:57 +01:00
Oliver Brakmann
3eeb677f14 Add LeaveMapAtClosestEdge idle behaviour for Aircraft 2020-08-15 13:38:57 +01:00
Paul Chote
ef69a3de66 Use nameof() in PaletteReference. 2020-08-15 13:41:45 +02:00
abcdefg30
0aa5e07252 Send the 'minefieldStart' along with a 'PlaceMinefield' order 2020-08-15 11:34:00 +01:00
abcdefg30
07d58337f1 Let order generators account for selection changes 2020-08-15 11:34:00 +01:00
abcdefg30
b5e3f25418 Fix CashTrickler crashing without IOccupiesSpace 2020-08-15 11:21:39 +01:00
teinarss
19b02875c7 Use Tuple syntax 2020-08-15 10:37:10 +01:00
Taryn Hill
8a74f6ea18 change whitespace-only lines to empty lines in Lua scripts 2020-08-14 15:08:14 +02:00
abcdefg30
a847f3eafa Fix actors not yet in the world improperly updating power state 2020-08-14 11:46:38 +02:00
Curtis Shmyr
a751f074e7 Added actor parameter to Lua UnloadPassenger 2020-08-10 10:38:35 +02:00
Paul Chote
75cb5c2166 Convert turret facings to WAngle relative to the body. 2020-08-09 19:43:53 +02:00
Paul Chote
70a86bed7a Optimize WRot negation.
The conjugate of a quaternion just negates the x/y/z components, so
there is no need to recalculate from scratch and throw away precision
by forcing a quat->euler->quat round trip.
2020-08-09 19:43:53 +02:00
dnqbob
f67f8ed05e WithLandingCraftAnimation can stop on all movement 2020-08-09 13:22:56 +02:00
Mustafa Alperen Seki
1ae53220d6 Add CurrentMuzzleFacing to FireClusterWarhead. 2020-08-09 13:18:39 +02:00
Matthias Mailänder
c546cb552e Make the fonts configurable. 2020-08-09 13:14:32 +02:00
Matthias Mailänder
10f8836d7b Fix a null reference exception. 2020-08-09 13:14:32 +02:00
dnqbob
7ecd4124ce Make "RepairableNear" public, helpful for modder 2020-08-08 13:20:39 +02:00
abcdefg30
54cd77be8e Add Tiberium near the transformable tree in cnc64gdi01 2020-08-05 11:45:11 +02:00
Mustafa Alperen Seki
43388cb7fc Don't check HasAdequateRefineryCount if no RefineryTypes defined. 2020-08-05 11:29:22 +02:00
Mustafa Alperen Seki
4cc5104fde Unhardcode AI's MinimumRefineryCount numbers. 2020-08-05 11:29:22 +02:00
Curtis Shmyr
d519cabae3 Add actor experience to the Lua API 2020-08-03 18:35:50 +02:00
abcdefg30
9852e29835 Fix subs targeting naval structures by default 2020-08-03 17:50:36 +02:00
Matthias Mailänder
3a427c3630 Add a sequence reference attribute to label fallbacks. 2020-08-02 22:15:13 +02:00
Matthias Mailänder
336656e8f7 Remove superflous warning as null is a valid value here. 2020-08-02 22:15:13 +02:00
Matthias Mailänder
06ad9666e8 Replace burns with more modular and testable trait combinations. 2020-08-02 22:15:13 +02:00
Matthias Mailänder
728e0c6600 If it defaults to the actor type, then it shouldn't be required. 2020-08-02 22:15:13 +02:00
Matthias Mailänder
657e690bdd Add an image override. 2020-08-02 22:15:13 +02:00
Matthias Mailänder
2d36d0a659 Reflect in naming that negative SelfHealing is a thing. 2020-08-02 22:15:13 +02:00
Matthias Mailänder
c42fd5d2e2 Add IsDecoration as a configurable option. 2020-08-02 22:15:13 +02:00
Trevor Nichols
10bf97eff6 Reduce severity of editorconfig and prefer multiline braces 2020-08-02 14:37:39 +02:00
Matthias Mailänder
ea9992247d Reorder string placeholders. 2020-08-02 12:00:53 +02:00
Matthias Mailänder
b90fecff76 Remove the prefixed method name. 2020-08-02 12:00:53 +02:00
Matthias Mailänder
a4fc9fea3b Unify AIUtils.BotDebug prefixes. 2020-08-02 12:00:53 +02:00
abcdefg30
b7c7eff2a2 Fix the position of the red cross in RA 2020-08-02 11:56:15 +02:00
Stuart McHattie
8c10dc406a Prevent Mac's Cmd+Q from exiting the game
This operation can be devastating if you were trying to assign a control group using Cmd + 1 but accidentally catch the Q key during gameplay.
2020-07-28 23:12:39 +01:00
Stuart McHattie
05c3861426 Add myself to the authors list 2020-07-28 23:12:39 +01:00
Matthias Mailänder
1ef5db8896 Document the built in hitshape types. 2020-07-28 23:42:26 +02:00
Andre Mohren
006a87692a Removed unused imports. 2020-07-28 18:22:51 +02:00
Oliver Brakmann
e019b70420 Fix actor previews for actors with types written in capital letters 2020-07-26 10:57:18 +02:00
Smittytron
70ec5b0344 Add flash to mission paranukes 2020-07-26 10:52:06 +02:00
abcdefg30
5401ace540 Add a death animation to Visceroids 2020-07-24 18:13:11 +02:00
abcdefg30
ab9081c852 Force enable Visceroids in the default rules 2020-07-24 18:13:11 +02:00
Matthias Mailänder
3a9b35980c Revert "Reduce order latency locally"
This reverts commit 20e5219cf4.
2020-07-21 21:58:31 +02:00
Matthias Mailänder
150439d215 Revert "Change where we send orders"
This reverts commit 616d9421d6.
2020-07-21 21:58:31 +02:00
Matthias Mailänder
b01a534a98 Revert "Refactor the OrderManager and world tick loop, improves input latency"
This reverts commit f642cead44.
2020-07-21 21:58:31 +02:00
Trevor Nichols
758b0b08d0 Add to .editorconfig additional naming rules to match this codebase's style 2020-07-21 16:15:30 +02:00
teinarss
f87ba1d8a4 Update SP maps with transformable trees 2020-07-20 14:05:52 +02:00
teinarss
67fa7bdcc9 Add TransformsNearResources 2020-07-20 14:05:52 +02:00
Matthias Mailänder
0b03aca104 Fix linter for player palettes. 2020-07-19 10:44:55 +02:00
Paul Chote
3bf61f1043 Fix incorrect rotation calculation in ThrowsShrapnel. 2020-07-19 10:41:05 +02:00
Paul Chote
ac975f4139 Convert yaml-exposed facings to WAngle. 2020-07-19 10:41:05 +02:00
abcdefg30
6d12301f88 Fix the aircraft facing slider in the editor 2020-07-18 01:45:00 +02:00
Andre Mohren
914950c4a5 When zooming using the mousewheel, zoom towards the pointer location. 2020-07-17 20:12:10 +02:00
Paul Chote
b417b267dd Store quaternion components directly.
This avoids precision loss when combining rotations.
The equivalent Euler angles are calculated for external use
but the quaternion components are preferred for any further
internal calculations.
2020-07-17 15:02:32 +02:00
Paul Chote
aae497eff1 Pass pre-combined rotations into the rendering code. 2020-07-17 15:02:32 +02:00
Paul Chote
3c9db4c2ac Add WRot.Rotate to allow rotations to be combined. 2020-07-17 15:02:32 +02:00
Paul Chote
8c3793e7ea Rename WRot.Zero to WRot.None. 2020-07-17 15:02:32 +02:00
Oliver Brakmann
60a7f53491 Fix target lines appearing not long enough on screen
Also changes the Delay attribute from ticks to milliseconds.
2020-07-16 00:28:05 +02:00
Mustafa Alperen Seki
04bfd62f2f Fix FireClusterWarhead playing wrong Report sound. 2020-07-15 23:55:01 +02:00
Paul Chote
117b8b3653 Change tiberium colors to match the original game. 2020-07-13 14:02:02 +02:00
Paul Chote
70cb0d2924 Improve TS map importer and reimport classic maps. 2020-07-13 14:02:02 +02:00
Paul Chote
c5ea496c45 Add terrain lighting definitions to TS. 2020-07-13 14:02:02 +02:00
Paul Chote
01e955ca37 Implement TS-style terrain lighting. 2020-07-13 14:02:02 +02:00
Paul Chote
fdb66c769c Change terrain layers to track sequences instead of sprites. 2020-07-13 14:02:02 +02:00
Paul Chote
38b3fbbdbe Fix [RequireExplicitImplementation] failures on event properties. 2020-07-13 14:02:02 +02:00
Paul Chote
3bc5d2d02c Add INotifyEditorPlacementInfo interface.
This allows TraitInfos to act when the actor preview is placed
in the editor, returning arbitrary data which the editor stores
and gives back if the preview is removed.
2020-07-13 14:02:02 +02:00
Paul Chote
ac7eda8ca2 Add support for rendering tinted artwork. 2020-07-13 14:02:02 +02:00
reaperrr
baf58f53b3 Adapt SpreadDamageWH to ImpactOrientation
The ImpactOrientation needs to be computed from
point of impact to target if the target wasn't hit directly.

Also adapted warhead code to use WarheadArgs consistently,
as well as pass HitShape instead of just HitShapeInfo
(both needed for future and/or downstream features).
2020-07-12 19:52:55 +02:00
reaperrr
8513a83331 Add ImpactOrientation to WarheadArgs
Allows to pass the horizontal facing/yaw
and vertical angle/pitch of the carrier
projectile to warheads for further use.

Add ImpactPosition to WarheadArgs

InflictDamage doesn't pass the impact pos
directly, and the very point of WarheadArgs
is to avoid adding more and more arguments
to the warhead methods.
2020-07-12 19:52:55 +02:00
Orb
bf7fecff10 TD Balance Summer 2020 2020-07-12 19:31:59 +02:00
Oliver Brakmann
6e1f2f636c Increase GameOverDelay for missions from 1.5 to 3 secs 2020-07-12 15:06:55 +02:00
Oliver Brakmann
8b3db6f3d6 Allow granting a condition to Carryalls currently carrying units 2020-07-12 14:36:01 +02:00
Matthias Mailänder
39d0abe982 Remove bit rot. 2020-07-12 14:32:32 +02:00
teinarss
c2026dc254 Add Discord Rich Presence 2020-07-12 14:27:59 +02:00
Matthias Mailänder
cae6c28754 Change the prefix in front of replays. 2020-07-12 13:43:05 +02:00
Sly
3b99924799 Corrected spelling error 2020-07-10 14:48:22 +02:00
Sly
b2b548b103 Corrected spelling error 2020-07-10 14:46:40 +02:00
Pavel Penev
c2e3806a77 Added a FlashPaletteEffect to RA nukes and removed from D2k 2020-07-10 13:22:54 +02:00
Pavel Penev
25500a7dda Updated a stale copyright header 2020-07-10 13:22:54 +02:00
Pavel Penev
8c394a4cb5 Created FlashPaletteEffectWarhead and removed the hardcoded flashing from NukeLaunch
Not actually hardcoded, but there was a hard dependency in NukeLaunch on FlashPaletteEffect and explicit flashing checks.
2020-07-10 13:22:54 +02:00
Pavel Penev
2e7bd4de4b Fixed a bug with the NukeLaunch's Player palette 2020-07-10 13:22:54 +02:00
Matthias Mailänder
7261322e41 Add support for Visual Studio Code. 2020-07-10 12:33:57 +03:00
abcdefg30
cada396733 Fix a crash when previewing an actor using WithCrateBody in the editor 2020-07-09 20:31:03 +02:00
Chris
9f9709f058 Add python3 support to launch-game.sh 2020-07-09 20:21:48 +02:00
abcdefg30
26fc65209d Fix the bogus Actors iterator 2020-07-09 18:11:53 +02:00
Adam Mitchell
f642cead44 Refactor the OrderManager and world tick loop, improves input latency 2020-07-09 13:48:55 +02:00
Adam Mitchell
616d9421d6 Change where we send orders 2020-07-09 13:48:55 +02:00
Adam Mitchell
20e5219cf4 Reduce order latency locally 2020-07-09 13:48:55 +02:00
Vapre
9edda21b06 Avoid three time array lookup in TraitContainer.Actors. 2020-07-09 12:16:04 +02:00
Paul Chote
6d6822ca15 Update map inits in RA/TD/D2k. 2020-07-08 20:38:30 +02:00
Paul Chote
a2269e7ee7 Convert (Dynamic)FacingInit, (Dynamic)TurretFacingInit to WAngle. 2020-07-08 20:38:30 +02:00
Paul Chote
e8f443f4a9 Remove TurretFacingsInit and PlugsInit. 2020-07-08 20:38:30 +02:00
Ivaylo Draganov
67f8452178 Add button to override duplicate hotkey bindings 2020-07-08 19:59:07 +02:00
Ivaylo Draganov
47f6e407d9 Cancel hotkey rebind on Esc key press 2020-07-08 19:59:07 +02:00
abcdefg30
889e2152a4 Cache ProjectedCellBounds during load time 2020-07-08 18:37:50 +02:00
abcdefg30
173aae1f81 Directly check the map bounds instead of converting to PPos 2020-07-08 18:37:50 +02:00
abcdefg30
baed80983b Fix the launch-game.sh newlines not displaying in the console 2020-07-07 22:30:55 +02:00
abcdefg30
b00423dc76 Correct the crash dialog title 2020-07-07 22:30:55 +02:00
abcdefg30
376ed15079 Correct the support folder location in the crash dialog 2020-07-07 22:30:55 +02:00
abcdefg30
a6d8d6cd8e Use tabs as indentation consistently 2020-07-07 22:30:55 +02:00
Paul Chote
b3ee8b447e Reduce duplication between Map and PlayerRadarTerrain. 2020-07-07 22:12:22 +02:00
Paul Chote
5f588561b6 Rewrite TS minimap rendering:
* Rename LeftColor and RightColor to MinColor and MaxColor
  These are mapped from LowRadarColor and HighRadarColor in
  the original inis, and appear to be used to set the bounding
  values for selecting a random colour, NOT for left/right
  pixels (which caused noticeably wrong banding).

* Adjust brightness based on terrain height.
  MinHeightColorBrightness and MaxHeightColorBrightness
  were chosen by trial/error to match the original
  map preview rendering.
2020-07-07 22:12:22 +02:00
Smittytron
83c53e17e0 Allow repairable tech buildings in campaign-rules 2020-07-07 19:47:10 +02:00
Smittytron
c028488894 Add Soviet 09 2020-07-07 19:47:10 +02:00
abcdefg30
b066005f7e Fix AttackBomber marking aircraft that are not in the world as in range 2020-07-06 22:30:41 +02:00
abcdefg30
87e33a75c6 Fix a crash when calling an airstrike at the map edge 2020-07-06 22:30:41 +02:00
Matthias Mailänder
4961b0943b Add a text base spy disguise decoration. 2020-07-05 21:43:12 +02:00
Smittytron
eda1e9c266 Add Counterstrike mission Siberian Conflict 1: Fresh Tracks 2020-07-05 21:33:56 +02:00
abcdefg30
bc7bf174d8 Don't tick the announcement timer when not in low power
When entering low power it will be reset to 0 again anyway
2020-07-05 20:37:17 +02:00
abcdefg30
2e06d5790b Update the PowerState only when power is added or removed 2020-07-05 20:37:17 +02:00
abcdefg30
ab8790e8f1 Style/Readability changes 2020-07-05 20:37:17 +02:00
abcdefg30
7d630e63e7 Let Railgun implement ISync 2020-07-05 18:10:14 +02:00
Smittytron
77899191f3 Add Aftermath mission Situation Critical 2020-07-05 17:21:43 +02:00
Smittytron
6871873e93 Add Counterstrike mission Fall of Greece 1: Personal War 2020-07-05 15:59:18 +02:00
Smittytron
fc4bd131cd Add Aftermath mission: Production Disruption 2020-07-05 15:58:10 +02:00
Pavel Penev
d866286f82 Added back the DescAttributes on projectiles' Inaccuracy fields 2020-07-05 13:04:18 +02:00
Pavel Penev
76dfda164e Moved projectile inaccuracy calculations to Common.Util
Also moved the InaccuracyType enum there. This also quietly adds the RangeModifiers to the calculations for all projectiles, while they were only used on Bullet so far, which seemed very wrong.
2020-07-05 13:04:18 +02:00
Pavel Penev
134d47e48c Added InaccuracyType.Absolute to projectiles 2020-07-05 13:04:18 +02:00
Pavel Penev
a2dbd5e013 Changed weapons in D2k to use the new PerCellIncrement inaccuracy
Also adjusted the inaccuracy values. This should bring inaccuracy in D2k pretty much in line with the original game, with the potential liberty of decreased inaccuracy for the Deviator tank.
2020-07-05 13:04:18 +02:00
Pavel Penev
c27412c83a Added InaccuracyType enum and updated projectiles accordingly
Also updated the inaccuracy calculations to account for the new inaccuracy type - either based on distance up to a max defined inaccuracy at max range (old style) or based on distance with each cell (1024 range) increasing the inaccuracy with a set step.
2020-07-05 13:04:18 +02:00
Pavel Penev
4143aba595 Added syncing to some Railgun projectile fields 2020-07-05 13:04:18 +02:00
Ivaylo Draganov
39ccac4022 Refactor command bar buttons to use unified widget state names 2020-07-05 11:50:45 +01:00
Ivaylo Draganov
7943f4deb6 Unify widget state image suffixes (disabled, pressed, hover, focus)
- Add a property for arrows image collection (in drop-downs, scrollbars
and production tabs)
- Add a property for separators image collection (in drop-downs)
- Add hover and disable states to the drop-down separator
- Unify button, textfield and checkbox state suffixes
2020-07-05 11:50:45 +01:00
Curtis Shmyr
2dda2d7689 Added lua IsCloaked actor property 2020-07-04 21:06:52 +02:00
Matthias Mailänder
b8f2a14ea0 Automatically upload release to itch.io using butler. 2020-07-04 20:59:10 +02:00
Oliver Brakmann
595809f090 Fix Carryalls waiting for actors on transit-only tiles 2020-07-04 16:47:17 +02:00
abcdefg30
477db9cd4a Fix travis builds not failing when errors occur during static checking 2020-07-03 21:29:25 +01:00
teinarss
67ff292d62 Refactor WorldRenderer to use less allocations 2020-07-03 17:41:41 +02:00
darkademic
ae882b85a9 Make AI randomly scan map for targets for its air squads. 2020-07-02 23:05:49 +02:00
abcdefg30
5e92915095 Fix the cargo unload regression with scripted transports
The activity is not interruptible, so we'd continue after the Move regardless
2020-07-02 21:14:35 +02:00
Smittytron
95809db03c Move Harvester overrides to campaign-rules.yaml 2020-07-02 19:29:37 +02:00
Smittytron
6d5a5121bc Remove worthless function from Allies08 2020-07-02 19:29:37 +02:00
Smittytron
86992751c7 Update Soviet-08a 2020-07-02 19:29:37 +02:00
Smittytron
2eba8b6c37 Add Soviet-08b 2020-07-02 19:29:37 +02:00
Smittytron
e1523e939d Utilize Panic function with added OnDamaged trigger 2020-06-28 17:30:24 +02:00
Smittytron
15a92f443d Replace paraprop power with scripted drops in Soviet01 2020-06-28 17:30:24 +02:00
KorGgenT
b57c68e392 Fix units walk over tunnels and under bridges. 2020-06-28 17:21:54 +02:00
Matthias Mailänder
e95fcb6bc0 Don't let blossom tree poof all at the same time. 2020-06-28 13:43:33 +02:00
Matthias Mailänder
6581fcb6a7 Add a random interval to idle animations. 2020-06-28 13:43:33 +02:00
tovl
6551337bd8 Make TS walkers AlwaysTurnInPlace. 2020-06-28 00:11:26 +02:00
tovl
137df52fdd Make infantry AlwaysTurnInPlace. 2020-06-28 00:11:26 +02:00
tovl
b79aa7eb6a Add AlwaysTurnInPlace option to Mobile. 2020-06-28 00:11:26 +02:00
Alfred Lang
1c8c49dc8e Fix do allow AI do place plugbuildings like RBG Tower on GDI Component Tower 2020-06-27 10:35:06 +02:00
Andrew Odintsov
f0c808d2fc Replace FloodFill with IEditorAction implementation 2020-06-24 19:08:54 +02:00
Curtis Shmyr
26d9ae88df Replace TargetAndAttack with a global aircraft attack function 2020-06-23 20:09:42 +02:00
Curtis Shmyr
3c7f119bb1 Add a damage parameter to Lua OnDamage callback 2020-06-23 19:58:31 +02:00
Ian T. Jacobsen
fea35923f0 Minefield now shows red when out of map bounds and Minelayer now does not get stuck at edge of map
Made it impossible to detect enemy units again

Fix whitespace
2020-06-21 20:16:57 +02:00
Paul Chote
9627776318 Add pitch and roll to TS aircraft. 2020-06-21 18:05:40 +02:00
Paul Chote
6dcde3af72 Allow voxel-based aircraft to pitch and roll. 2020-06-21 18:05:40 +02:00
Paul Chote
43717a89b5 Add Orientation getter to IFacing. 2020-06-21 18:05:40 +02:00
Matthias Mailänder
c7ba359688 Add drop pod reinforcements. 2020-06-21 17:28:24 +02:00
Matthias Mailänder
dc3dbf6d85 Remove uneccessary parentheses. 2020-06-21 17:28:24 +02:00
Smittytron
71664c85ff Fix TargetTypes regression in SnipeWeapon 2020-06-21 12:34:43 +02:00
Nikita Pozdeev
cb41be113a Fix map editor radar ignoring color from terrain 2020-06-20 14:37:23 +02:00
Matthias Mailänder
4fe7daa85e Fix juggernaut preview being disabled by default. 2020-06-19 21:30:34 +02:00
abcdefg30
f75afc6ee4 Fix a compilation error in WithInfantryBody.cs 2020-06-19 20:01:04 +02:00
abcdefg30
67fd71ab92 Add a ProjectedCellLayer and use it in Shroud.cs 2020-06-19 18:31:51 +02:00
abcdefg30
385e70552e Create CellLayerBase 2020-06-19 18:31:51 +02:00
Matthias Mailänder
1e2c67bfca Increase UPnP device discovery timeout. 2020-06-19 18:00:27 +02:00
Paul Chote
56739f87fb Allow plugs to be configured in the map editor. 2020-06-19 17:57:56 +02:00
Paul Chote
571eb7614f Support multiple turrets in the editor. 2020-06-19 17:57:56 +02:00
Paul Chote
c6c3a8c60d Make ActorPreview and EditorActorPreview wrap ActorReference. 2020-06-19 17:57:56 +02:00
Paul Chote
ae7cfa56b7 Restrict IActorPreviewInitInfo to ActorInit. 2020-06-19 17:57:56 +02:00
Paul Chote
b856613194 Add ISingleInstanceInit interface.
Inits that are logically singletons (e.g. actor
location or owner) should implement this interface
to avoid runtime inconsistencies.

Duplicate instances are rejected at init-time,
allowing simpler queries when they are used.
2020-06-19 17:57:56 +02:00
Paul Chote
86305879cb Parse Enum *ValueInit as string values, not integers. 2020-06-19 17:28:01 +02:00
Paul Chote
e5a1a8a706 Replace deprecated API usage. 2020-06-19 17:28:01 +02:00
Paul Chote
27602a4a97 Add WAngle-compatible airstrike/paratrooper APIs. 2020-06-19 17:28:01 +02:00
Paul Chote
a98e460257 Expose WAngle to Lua API and deprecate old Facing. 2020-06-19 17:28:01 +02:00
Paul Chote
0349435650 Remove deprecated Paratrooper API methods. 2020-06-19 17:28:01 +02:00
Paul Chote
c3fbdca18f Add yellow-shirt technician. 2020-06-19 17:09:13 +02:00
Paul Chote
acb5245a28 Restore correct palette and voices for RA civilians.
A new C11 infantry has been added to use the custom
c3 sprite that was originally added back when only
c1 and c2 were used in OpenRA.
2020-06-19 17:09:13 +02:00
Paul Chote
23561cd76b Add custom palette support to WithInfantryBody. 2020-06-19 17:09:13 +02:00
Paul Chote
d3ab3d7d78 Move IndexedPlayerPalette to Mods.Common and add a non-player version. 2020-06-19 17:09:13 +02:00
Matthias Mailänder
5b870be83f Let the 2nd civilian panic when his mate gets electrocuted. 2020-06-19 16:50:28 +02:00
Matthias Mailänder
6130d5622c Add a panic function to the Lua API. 2020-06-19 16:50:28 +02:00
abcdefg30
318c4e3456 Remove InitialStanceAI overrides from campaign missions 2020-06-19 16:46:34 +02:00
abcdefg30
ab701449e2 Change Subs to use the Defend stance by default 2020-06-19 16:46:34 +02:00
abcdefg30
9a3447d863 Fix airstrike and paratroopers power not removing cameras at the map edge 2020-06-19 16:04:54 +02:00
matjaeck
5280637adf Fix PickupUnit not validating cargo on first run. 2020-06-19 15:59:14 +02:00
Matthias Mailänder
3bce55ac44 Cancel the attack when no traits are active. 2020-06-19 13:43:03 +02:00
Curtis Shmyr
a3f79503ed Fix Lua DisplaySystemMessage writing twice 2020-06-16 13:11:02 +02:00
Curtis Shmyr
02d462a82c Fix copying public key to clipboard if already authed 2020-06-13 19:15:27 +02:00
Smittytron
3d17328d0d Fix regression and cleanup scu35ea 2020-06-12 23:50:44 +02:00
reaperrr
0e81abc21b Fix weapons not accounting for Air
If a weapon was aiming at a target position rather
than an actor target, it would always check target types
of the terrain below, ignoring altitude (and therefore ignoring
"InvalidTargets: Air").
2020-06-12 21:00:53 +02:00
Paul Chote
803b930405 Change IFacing.TurnSpeed to WAngle. 2020-06-12 18:35:41 +02:00
Paul Chote
6adf45bcb4 Convert IFacing.Facing and TurnSpeed to WAngle. 2020-06-12 18:35:41 +02:00
Matthias Mailänder
01417c88c5 Add missing actor reference for lint testing. 2020-06-10 19:07:14 +02:00
abcdefg30
60bbbe0d93 Fix the Death Hand launch notification playing for the player not enemy 2020-06-10 18:57:08 +02:00
Matthias Mailänder
888dfd3654 Stop the boat to remove it immediately. 2020-06-09 22:40:32 +02:00
Matthias Mailänder
12de56ff62 Fix crash notication "AlertBeep" not found. 2020-06-09 22:40:32 +02:00
Matthias Mailänder
b7cee41c54 Fix TD gunboat not updating actor map influence. 2020-06-09 22:40:32 +02:00
Paul Chote
10aac03f75 Add CompositeActorInit and simplify chronoshift inits. 2020-06-08 19:18:38 +02:00
Paul Chote
0eb0041f90 Allow ActorInits to target a specific trait by matching the @ suffix. 2020-06-08 19:18:38 +02:00
Paul Chote
b38018af9c Replace IActorInit with an abstract class.
A shared ValueActorInit<T> is introduced to reduce duplication
in the most common init cases, and an ActorInitActorReference
allow actors to be referenced by map.yaml name.
2020-06-08 19:18:38 +02:00
Unknown
4df5ac0385 Change default to ground-attack 2020-06-07 10:31:44 -05:00
Unknown
a7476bc303 Improve detail + double fire rate/half damage 2020-06-07 10:31:44 -05:00
Unknown
cc4b3cb361 Add APC ground attack sprite turret 2020-06-07 10:31:44 -05:00
Ivaylo Draganov
31a965b29a Add suffix to player name in shroud selector 2020-06-06 14:40:48 +01:00
Ivaylo Draganov
7a213338a2 Add helper method to add suffix to player name label 2020-06-06 14:40:48 +01:00
abcdefg30
fb27a25e52 Fix a crash with support powers and units without selection decorations 2020-06-06 13:46:27 +01:00
abcdefg30
534b09ae4a Fix bots not working after adminship was transferred 2020-06-03 18:30:18 +02:00
abcdefg30
341a9f370c Fix a crash in Evacuation 2020-06-02 22:53:40 +02:00
Matthias Mailänder
607d9b2d5c Fix index out of bounds exception for off world aircraft. 2020-06-02 19:25:53 +01:00
abcdefg30
507ce40ad2 Fix a crash in LegacyBridgeLayer 2020-06-02 19:22:19 +01:00
reaperrr
f58c3aed32 Use OccupiesSpace to save more trait look-ups
This time in Locomotor.IsBlockedBy.
2020-06-02 20:08:34 +02:00
reaperrr
55e85bd9ca Save Mobile look-up in BasePathSearch
By casting to OccupiesSpace and then
looking up Info.LocomotorInfo directly.
2020-06-02 20:08:34 +02:00
reaperrr
4bf614c5cd Use OccupiesSpace to avoid Mobile look-up in Move
While individual trait look-ups may be cheap,
if a large army that is currently standing still gets
its first move-including order, the look-ups of dozens
or even hundreds of actors may happen on the same tick.

Therefore this may help reducing that first-order lag spike,
at least a little bit.
2020-06-02 20:08:34 +02:00
abcdefg30
96b06c75d1 Make Resupply display target lines for all queued move activities 2020-06-02 18:23:54 +02:00
Matthias Mailänder
d261648ab0 Fix BeingCapturedCondition getting revoked from the wrong actor. 2020-06-02 10:45:49 +02:00
Paul Chote
7b81b9e806 Bullet Facing -> WAngle. 2020-06-01 21:34:32 +02:00
Paul Chote
a93aea3e4e AreaBeam Facing -> WAngle. 2020-06-01 21:34:32 +02:00
Paul Chote
2cfacc2c7d ProjectileArgs facing -> WAngle. 2020-06-01 21:34:32 +02:00
Paul Chote
6d6b21a0eb Convert Aircraft.Facing to WAngle. 2020-06-01 20:25:38 +02:00
Matthias Mailänder
7a78c37851 Add .NET Coding Conventions 2020-05-31 13:27:03 +01:00
Ivaylo Draganov
b8a9f41892 Add missing trait descriptions for cursors and unify the language 2020-05-31 00:12:04 +02:00
Ivaylo Draganov
227567dfe1 Formatting: wrap and indent long argument lists 2020-05-31 00:12:04 +02:00
Ivaylo Draganov
d5ff5c672b Add configurable cursors for entering allied actor targeters 2020-05-31 00:12:04 +02:00
Ivaylo Draganov
393f6eca3a Add configurable target cursors to various traits 2020-05-31 00:12:04 +02:00
Paul Chote
d193ef856e Fix harvest animation facing glitch. 2020-05-30 19:58:03 +02:00
abcdefg30
44d3691fa1 Assign Player.IsBot before calling INotifyCreated.Created 2020-05-30 19:47:29 +02:00
abcdefg30
27d0465891 Remove workarounds for querying the PlayerActor in Created 2020-05-30 19:47:29 +02:00
abcdefg30
52a9fcef3c Rename "Created" to "Initialize" and let it handle adding to the world 2020-05-30 19:47:29 +02:00
abcdefg30
7386816f52 Manually construct the PlayerActor to fix crashes during actor creation 2020-05-30 19:47:29 +02:00
abcdefg30
9c0075b233 Move hardcoded PlayerActorTypes to shared const variables 2020-05-30 19:47:29 +02:00
abcdefg30
e4c5700baf Remove an unused using 2020-05-30 19:47:29 +02:00
reaperrr
e1b7df8b6a Use OccupiesSpace to avoid Mobile look-ups
in PathFinder.FindUnitPath and FindUnitPathToRange.
2020-05-30 04:05:29 -05:00
Paul Chote
c999b2d778 Convert QuantizeFacing to WAngle facings. 2020-05-28 21:23:51 +02:00
Paul Chote
bfb6c671fb Change QuantizeFacing to return a facing instead of an index. 2020-05-28 21:23:51 +02:00
Paul Chote
7c6ec577dc Rewrite ActorInit queries. 2020-05-28 19:04:53 +02:00
Paul Chote
626b40f31b Account for ramps in terrain height calculations. 2020-05-28 09:41:55 -05:00
Paul Chote
5af12440ba Replace MapGrid.CellCorners with a new CellRamp struct. 2020-05-28 09:41:55 -05:00
Paul Chote
4614f6febe Cache cell ramps to avoid repeated tileset lookups. 2020-05-28 09:41:55 -05:00
Pavel Penev
1354ffc32e Added multiple production speedup to D2k
Based on the specification in issue 18051.
2020-05-27 10:32:35 +02:00
Pavel Penev
3723939c99 Adjusted D2k build times to match the original game
Removed custom production queue speedups and custom actor build time slowdowns and adjusted BuildDurations based on the specifications in issue 18051.
2020-05-27 10:32:35 +02:00
Pavel Penev
e099739e13 Reduced HitShape radius of D2k units to minimum
Since they are only used to hold the armor type anyway.
2020-05-27 10:28:25 +02:00
Pavel Penev
21a48cc41d Switched D2k to use the new DamageCalculationType
This brings D2k in line with the damage model of the original game.
2020-05-27 10:28:25 +02:00
Pavel Penev
4740266308 Added DamageCalculationType enum to SpreadDamageWarhead 2020-05-27 10:28:25 +02:00
Pavel Penev
78139413d7 Equalized the DoImpact methods in damage warheads 2020-05-27 10:28:25 +02:00
Pavel Penev
f0578a75f4 Cleaned up DamageWarhead
Reordered methods and fixed access modifiers. Also removed unused using statements from warheads.
2020-05-27 10:28:25 +02:00
abcdefg30
7a0e55a02a Restore trailing whitespaces to windows batch scripts 2020-05-26 22:57:11 +02:00
reaperrr
f132bac80d Add Tree armor type and remove tree-only warheads
This simplifies #12467.
Using a tree-exclusive amor type is far more efficient
than adding more warheads, which cost performance
due to their huge Spread

This also restores the 100% efficiency vs. trees for
some of the incendiary nuke warheads (which have
reduced efficiency vs. Wood since #13643).

Note: Atomic had two tree-only warheads with a Delay
of 15, I believe the first one to be a copy-paste error
and moved the damage to the regular SpreadDamage
with a Delay of 10.
2020-05-26 22:51:29 +02:00
reaperrr
109ea4fe5b Fix Barrel explosion damage 2020-05-26 22:46:26 +02:00
Matthias Mailänder
f33feafd0e Add TurnOnIdle. 2020-05-25 13:07:19 +02:00
reaperrr
9195356e3a Upgrade DepthCharge effect setup
- med_explosion instead of small_explosion on surface hit
- only play explosion on surfaced subs
- only play h2obomb2.aud when hitting a submerged sub
2020-05-24 13:26:40 +02:00
reaperrr
eff91108f4 Make RA ships show both explosion and splash
...when destroyed, to imply sinking.
2020-05-24 13:26:40 +02:00
reaperrr
e40c0516e6 Adapt RA warheads to new target types 2020-05-24 13:26:40 +02:00
reaperrr
c580a94ab7 Fix RA weapon ValidTargets 2020-05-24 13:26:40 +02:00
reaperrr
6a545bb942 Streamline RA target types
No more sharing of target types between terrain
and actors (except bridges), removed 'Ground(Actor)'
from WaterActors (was only used by weapons/warheads,
which can just list both ground- and water types.
2020-05-24 13:26:40 +02:00
Matthias Mailänder
672bd2d9fe Don't crash when putting the trait on the World actor. 2020-05-24 12:36:26 +02:00
Ivaylo Draganov
3ab4a584ab Remove trailing white-space from various files 2020-05-23 11:38:44 +02:00
Ivaylo Draganov
150d02ac0d Remove trailing white-space from lua files 2020-05-23 11:38:44 +02:00
Ivaylo Draganov
6d26f60904 Remove trailing white-space from yaml files 2020-05-23 11:38:44 +02:00
abcdefg30
b42276953f Fix a crash when a harvester is rebuilt in cnc64gdi01 2020-05-22 21:25:58 +02:00
abcdefg30
7c290b9f76 Fix not all harvesters in cnc64gdi01 being rebuilt 2020-05-22 21:25:58 +02:00
abcdefg30
51fe1d6629 Let AI autotargeting in D2k ignore sandworms 2020-05-22 20:40:36 +02:00
Matthias Mailänder
8f558d2b47 Add a bullet bounce sound. 2020-05-21 14:44:13 +02:00
abcdefg30
3f5fadf2e9 Move stray update rules into the correct subfolder 2020-05-21 14:08:14 +02:00
abcdefg30
07c16cee1d Add TargetTypes to HealActorsCrateAction 2020-05-21 14:08:14 +02:00
abcdefg30
24130dfcdc Add an update rule for the RenameHealCrateAction rename 2020-05-21 14:08:14 +02:00
abcdefg30
15a2341a91 Rename HealUnitsCrateAction to HealActorsCrateAction 2020-05-21 14:08:14 +02:00
Paul Chote
86f61298e6 Replace ITraitInfo interface with TraitInfo class. 2020-05-21 13:01:04 +02:00
abcdefg30
3cd7ec3878 Make the TS Test AI build aircraft 2020-05-21 10:05:05 +02:00
abcdefg30
8b13d3e4c7 Fix resupply not displaying target lines correctly 2020-05-19 22:11:20 +02:00
Ivaylo Draganov
327d451abc Add trim_trailing_whitespace to .editorconfig 2020-05-18 17:39:24 +02:00
atlimit8
2dac16ee02 add SquadManagerBotModuleInfo.IgnoredEnemyTargetTypes 2020-05-17 22:02:32 +01:00
abcdefg30
d4b92a19d7 Remove bogus weapon override defintions from TD campaign maps 2020-05-17 13:39:51 +01:00
tovl
e0357596f5 Correct aircraft repulsion direction when outside of the map. 2020-05-17 12:46:17 +02:00
atlimit8
1ef27d18c1 check name for Actor.GrantCondition() 2020-05-17 12:33:29 +02:00
Matthias Mailänder
1d2d8ed107 Don't hard-code the transparent background color. 2020-05-16 22:28:52 +01:00
reaperrr
1bf01bc214 Remove WaterStructure TargetType from RA SYRD/SPEN
- only used for auto-targeting
- inconsistent with their fakes (which didn't have this)
- unnecessary, since the 'Ship' target type covers all
  surface water actors we want to be auto-targetable by default,
  while 'Structure' is enough to add syard/spen in AttackAnything.
2020-05-15 08:22:02 +02:00
reaperrr
0015deca47 Fix TS Tiberium Fiend target types
Was missing Creep, preventing actors from
auto-targeting it (unlike all other critters).
2020-05-15 08:22:02 +02:00
reaperrr
ddfdc6e90f Clean up TD weapon ValidTargets
- Missiles can now force-fire on water like other weapons
- Superweapons can now target empty water
- made Chemspray null InvalidTargets to avoid yaml-merge issues
- Improved APCGun effect warhead perf by ignoring actors
- removed stale Tiberium weapon mission overrides
2020-05-15 08:22:02 +02:00
abcdefg30
5db2ad54f2 Fix a scripting error in nod04b 2020-05-14 22:40:44 +01:00
teinarss
b8a5750529 Add map.contains check to CanStayInCell 2020-05-14 20:06:21 +02:00
Andrew Odintsov
98d5b8c7cc Remove redundant call to OnTextEdited 2020-05-14 11:01:48 +02:00
Andrew Odintsov
3f34154a1e Add OnTextEdited call to RemoveSelectedText
This would allow expty text box to be processed and disable filtering
2020-05-14 11:01:48 +02:00
thisisjacob
3119f831b3 Added notice for entering vehicles in docs 2020-05-13 17:25:49 -05:00
thisisjacob
8a07b762a2 Changed documentation for OnEnterComplete 2020-05-13 17:25:49 -05:00
Matthias Mailänder
551ab2fc59 Cache the footprint LINQ for performance. 2020-05-12 20:53:05 -05:00
Zimmermann Gyula
99957e57b9 Update the default mods. 2020-05-12 20:53:05 -05:00
Matthias Mailänder
be2c59bc6e Add upgrade rule to convert ranges to footprints. 2020-05-12 20:53:05 -05:00
Zimmermann Gyula
57f9a49b66 Use footprints in ChronoshiftPower. 2020-05-12 20:53:05 -05:00
Zimmermann Gyula
54bd0eb99d Use footprints in GrantExternalConditionPower. 2020-05-12 20:53:05 -05:00
Zimmermann Gyula
485faac294 Implement SupportPower.CellsMatching. 2020-05-12 20:53:05 -05:00
Andrew Odintsov
d531d6f3ef Simplify groupActors condition 2020-05-12 15:06:50 +02:00
Andrew Odintsov
3a9fdb82f5 Add IsInWorld check for controlled groups 2020-05-12 15:06:50 +02:00
reaperrr
5024ae1156 TS ClusterMissile typo fix 2020-05-10 15:20:25 +02:00
abcdefg30
0135dd9ed3 Use inheritance to shorten the desert shellmap custom rules 2020-05-09 14:36:50 -05:00
abcdefg30
a6e9b86bbe Remove AnnounceOnKill Tanya overwrites from the desert shellmap 2020-05-09 14:36:50 -05:00
abcdefg30
237c4444b5 Remove DeathSounds overwrites from the desert shellmap 2020-05-09 14:36:50 -05:00
reaperrr
a68467292e Use TargetType.Invalid checks instead of IsValidFor 2020-05-09 17:59:23 +02:00
reaperrr
978c69d0c3 Make Warhead.IsValidTarget method protected
IsValidTarget is never called from outside warheads.
2020-05-09 17:59:23 +02:00
reaperrr
3eabc59921 Make resource warheads AirThreshold-aware 2020-05-09 17:59:23 +02:00
reaperrr
2b3d99fac2 Sanitize resource warheads
- Fix potential crash due to invalid target (no CenterPosition)
- Fix potential crash on multiple ResourceLayers
2020-05-09 17:59:23 +02:00
reaperrr
2bdefe0e9e Move AirThreshold to Warhead
To reduce duplication and for later use in more warheads.
2020-05-09 17:59:23 +02:00
reaperrr
de81fc2aca Minor CreateEffectWarhead optimization
Palette only matters if we actually display an explosion.
2020-05-09 17:59:23 +02:00
reaperrr
b514e0a6e7 D2k yaml comment removal
Naming the warhead for its purpose is cleaner
than comments, in my opinion.
2020-05-09 17:56:08 +02:00
reaperrr
715dfa4541 Use args in FireClusterWarhead methods
Instead of directly passing damage modifiers.
2020-05-09 17:56:08 +02:00
reaperrr
ac57a37224 DamageWarhead polish
Use BitSet.IsEmpty.
2020-05-09 17:56:08 +02:00
Paul Chote
afd620b092 Reimplement ClassicQuantizeFacing using a look-up-table. 2020-05-09 10:40:50 -05:00
Paul Chote
552bceb07c SpriteEffect facing -> WAngle. 2020-05-09 10:20:23 -05:00
Paul Chote
fe58ed1283 Animation facing -> WAngle. 2020-05-09 10:20:23 -05:00
Paul Chote
361e2d463c ISpriteSequence facing -> WAngle. 2020-05-09 10:20:23 -05:00
atlimit8
259c8d2c98 Merge ConditionManager trait directly into Actor 2020-05-09 15:46:11 +02:00
abcdefg30
e12c1dc9aa Retire the "release-20190314" path 2020-05-09 13:08:10 +01:00
abcdefg30
7fb49e383d Update and fix the latest update path and rules 2020-05-09 13:08:10 +01:00
Matthias Mailänder
1df3e28253 Initialize RangeModifiers. 2020-05-08 20:58:27 +02:00
Paul Chote
bacec2689d Remove error message duplication. 2020-05-08 15:17:44 +02:00
jrb0001
bf397591f9 Implement IPv6 support for server and direct connect 2020-05-08 15:17:44 +02:00
Matthias Mailänder
bd1a936c7a Add the armed technician. 2020-05-08 09:42:14 +02:00
Matthias Mailänder
0871d6e321 Setup the Firestorm civilian voices. 2020-05-08 09:42:14 +02:00
abcdefg30
265d296db6 Add infiltration sounds support to InfiltrateForSupportPowerReset 2020-05-05 15:16:09 -05:00
Matthias Mailänder
5ec136b57c Don't play the make animation on the wall sprite body. 2020-05-05 13:23:58 +02:00
atlimit8
f1e8f9c9d0 Fixed PNG frame count calculation
This fixes the order of operations and rounding issue, making it columns * rows.
2020-05-02 23:14:31 +02:00
Paul Chote
f03841c4e4 Hide selection decorations when spectators zoom too far out. 2020-05-02 14:30:04 -05:00
Pavel Penev
0ae58ff0ea Adjusted damage spread ranges on weapons in D2k to match the original game 2020-05-02 20:22:01 +01:00
Pavel Penev
390c1899ca Changed weapons in D2k to have a linear damage falloff to match the original game 2020-05-02 20:22:01 +01:00
Matthias Mailänder
89aa6d1e4e Don't attack during buildup. 2020-05-02 20:07:09 +01:00
Matthias Mailänder
24638b02a9 Fix turret build sounds. 2020-05-02 20:07:09 +01:00
Matthias Mailänder
4b0ab6ab37 Add the crumble overlay to the turrets. 2020-05-02 20:07:09 +01:00
Matthias Mailänder
1f02d9f141 Add the make animation for the turrets. 2020-05-02 20:07:09 +01:00
Matthias Mailänder
0103c38c13 Don't change the animation when it's not your turn. 2020-05-02 20:07:09 +01:00
Matthias Mailänder
3cc76f91b4 Fix the make animation for the silos. 2020-05-02 20:07:09 +01:00
abcdefg30
10dc248f07 Remove unused usings from BaseBuilderBotModule 2020-05-02 14:05:44 -05:00
abcdefg30
d1f89c6217 Update the Desc of GrantCondition 2020-05-02 14:05:44 -05:00
abcdefg30
76ba4fc32d Use a modular AI in soviet05 2020-05-02 14:05:44 -05:00
abcdefg30
37f90fff44 Throw LuaExceptions instead of InvalidDataExceptions in ConditionProperties 2020-05-02 14:05:44 -05:00
abcdefg30
9fa6da3bc7 Add PlayerConditionProperties 2020-05-02 14:05:44 -05:00
abcdefg30
aa8cf237ab Make Greece the owner of all starting actors in soviet05 2020-05-02 14:05:44 -05:00
Matthias Mailänder
c131728aa4 Give more context when crashing during .png sheet loading. 2020-05-02 13:26:06 -05:00
Paul Chote
2abd137494 Remove OpenRA.PostProcess.exe.
The LAA flag is now set when packaging
Windows release installers.
2020-05-02 17:26:54 +02:00
Paul Chote
90815ace59 Add a decoration glyph for friendly units in tunnels. 2020-05-02 16:16:16 +02:00
Matthias Mailänder
53d916d7f1 Add some basic error handling to png metadata writing. 2020-05-02 04:13:34 -05:00
reaperrr
2b4035979b Make all warheads use WarheadArgs
Instead of passing damageModifiers directly.
2020-05-02 03:09:18 +03:00
Matthias Mailänder
38cdc93010 Default the optional effect sequence to null 2020-05-01 19:43:36 +03:00
Matthias Mailänder
346dad3898 Remove trailing spaces. 2020-05-01 19:43:36 +03:00
Matthias Mailänder
42256bc262 Add an out of bounds check. 2020-05-01 19:41:06 +03:00
Matthias Mailänder
70babb4067 Validate the target before querying it's center position. 2020-05-01 16:53:29 +02:00
Matthias Mailänder
3603e6373d Check for invalid targets. 2020-04-30 01:42:19 -05:00
Matthias Mailänder
bd1760682f Rename WithNukeLaunch* traits to WithSupportPower*. 2020-04-30 01:37:05 -05:00
Matthias Mailänder
52d0490f95 Supersede INotifyNuke 2020-04-30 01:37:05 -05:00
Matthias Mailänder
b3b0aa75ae Add new interfaces for support powers. 2020-04-30 01:37:05 -05:00
Paul Chote
e42d177920 Include selection decorations when calculating ScreenMap bounds. 2020-04-30 00:09:57 +02:00
Paul Chote
c2156af7b0 Restore missing minelayer pips. 2020-04-29 22:59:48 +02:00
dnqbob
86394eb56c "FindEnemy" functions ignore hidden actors
(helped by reaperrr and abcdefg30)
2020-04-28 15:35:02 +02:00
dnqbob
2d7790f5e4 StateBase.cs modified:
1. Optimize & move "ammo" related function from "AirStates.cs" to StateBase.cs

2. Optimize & move "IsRearm" function from "AirStates.cs" to StateBase.cs, name changed to "IsRearming"

(optimized by reaperrr)
2020-04-28 15:35:02 +02:00
Matthias Mailänder
3df43529a6 Document BitSet<TargetableType> 2020-04-27 16:06:32 +02:00
Matthias Mailänder
a1c9b27057 Add InfiltrateForSupportPowerReset 2020-04-27 16:06:32 +02:00
abcdefg30
089dd233a5 Correct the support dir location in ExtractSettingsDocsCommand 2020-04-26 12:38:11 +01:00
Matthias Mailänder
86a7a0bd6c Move Render*Circle traits to their base traits. 2020-04-26 10:30:50 +02:00
Paul Chote
7ebca36a9c Disable debug callbacks on Intel HD 4000. 2020-04-25 21:03:43 +02:00
Paul Chote
d5aed5a88a Expose GL Profile in settings menu. 2020-04-25 21:03:43 +02:00
Paul Chote
dac1f270ce Restore legacy OpenGL 2.1 support. 2020-04-25 21:03:43 +02:00
Paul Chote
839be24053 Replace PreferGLES settings flag with GLProfile enum. 2020-04-25 21:03:43 +02:00
Paul Chote
91c4179f05 Split GLProfile from GLFeatures. 2020-04-25 21:03:43 +02:00
Matthias Mailänder
a4b427bfac Clarify AttackPanicChance and add PanicChance. 2020-04-24 18:38:54 +02:00
reaperrr
250f5bec18 Misc yaml style fixes 2020-04-24 18:22:35 +02:00
reaperrr
336e2a10e0 Fixed RA STNK turret not using fudged facings 2020-04-24 18:22:35 +02:00
reaperrr
b5e9b7635e MoveClassicFacingFudge update rule 2020-04-24 18:22:35 +02:00
reaperrr
0df7fa1596 Add sequence update rule support 2020-04-24 18:22:35 +02:00
reaperrr
c10487d635 Move ClassicFacingFudge support to Mods.Cnc
This moves the TD/RA-specific re-mapping of sprite facings
and coordinates to Mods.Cnc.
2020-04-24 18:22:35 +02:00
abcdefg30
bc9b3bef74 Fix a crash when completing objectives in Allies06 out of order 2020-04-23 21:56:46 +01:00
abcdefg30
e57462e7ca Make attack moving and guarding use a grouped order 2020-04-21 01:35:40 -05:00
abcdefg30
78bf27709f Add basic support for grouped orders 2020-04-21 01:35:40 -05:00
Matthias Mailänder
fc84cd9204 Add an is in world check to fix a crash. 2020-04-21 01:15:43 -05:00
Matthias Mailänder
e361f7b246 The category field has been pluralized. 2020-04-19 15:21:10 +02:00
Matthias Mailänder
b0497b7505 Fix double whitespace. 2020-04-19 15:21:10 +02:00
Zimmermann Gyula
a894e31fa5 Remove now obsolete tileset palette entry. 2020-04-19 15:21:10 +02:00
Matthias Mailänder
dd062adec2 Add descriptions as those are not obvious in this context. 2020-04-18 13:56:26 -05:00
Matthias Mailänder
d187575a2c Make support power icons configurable and testable. 2020-04-18 13:56:26 -05:00
teinarss
85096c4ba2 Update CoordinateTest to be compatible with new nunit version. 2020-04-18 11:36:25 -05:00
teinarss
e13fd693c3 Add Nuget packages for all dependencies 2020-04-18 11:36:25 -05:00
Mustafa Alperen Seki
cc35512472 Add a trait to reveal the whole map when conditions are met. 2020-04-18 10:49:25 -05:00
abcdefg30
4e548291ce Treat transit-only tiles as invalid locations for minelayers 2020-04-18 13:35:06 +01:00
abcdefg30
3ba86f329f Remove Game.HasInputFocus 2020-04-17 22:26:03 -05:00
Mustafa Alperen Seki
5b34af0f12 Change all instances of ToLower() to ToLowerInvariant() 2020-04-17 17:01:42 -05:00
Adam Mitchell
0a9eb1ff83 Fix units stuck on transit-only when resupplying 2020-04-17 11:13:46 +02:00
abcdefg30
942dd0e5f7 Adapt the utility commands to import crates as well 2020-04-17 10:52:59 +02:00
abcdefg30
400102f3d3 Remove a TODO about grey nod colors 2020-04-17 10:52:59 +02:00
abcdefg30
9ccdeb3d36 Set the wcrate and scrate sequences up 2020-04-17 10:52:59 +02:00
abcdefg30
7e0f0dd2d2 Add missing money crates to TD campaign missions 2020-04-17 10:52:59 +02:00
abcdefg30
d920cbb7f6 Move money crates to a default in the shared campaign rules 2020-04-17 10:52:59 +02:00
Paul Chote
417677e6f4 Work around and explain color picker conversion issue. 2020-04-17 10:41:08 +02:00
Paul Chote
33f3038316 Fix map-specific factions remaining selected when changing map. 2020-04-16 16:49:00 +02:00
Paul Chote
429dbe3e0c Block profiles with revoked keys from joining auth-only servers. 2020-04-16 16:43:10 +02:00
abcdefg30
471fc44751 Add more engineers to the wave in nod07
Otherwise buildings will only be damaged
2020-04-16 13:21:33 +02:00
abcdefg30
1b8e346307 Fix APC reinforcements in nod07a and b 2020-04-16 13:21:33 +02:00
abcdefg30
a456583a08 Fix a crash in nod07b 2020-04-16 13:21:33 +02:00
Paul Chote
a63c17baab Disable IP tooltip in skirmish games. 2020-04-15 23:16:24 +02:00
Paul Chote
9c4faddc0f Switch GeoIP database from MaxMind to IP2Location.
The IP2Location data is licensed under CC BY-SA, which
allows us to distribute the database with releases.
2020-04-15 23:16:24 +02:00
Paul Chote
6828c4c1e9 Fix long player locations overrunning the player tooltip. 2020-04-15 23:16:24 +02:00
Matthias Mailänder
80131e7ec0 Group readonly fields. 2020-04-15 21:42:50 +02:00
Matthias Mailänder
ac381a6f58 Allow multiple ResourceRenderer traits. 2020-04-15 21:42:50 +02:00
Matthias Mailänder
521b516bf9 Mark suggested fields as readonly. 2020-04-15 21:42:50 +02:00
netnazgul
6a825f8e60 Modify preset colors to not get flagged by color validator 2020-04-14 18:31:18 +02:00
Paul Chote
f0a243ca10 Fix mine layer desync.
World.FogObscures depends on the local RenderPlayer and should not
be used from simulation code!
2020-04-12 23:06:55 +02:00
Matthias Mailänder
e5457a3390 Allow wall renderers in mod code. 2020-04-11 16:29:00 +02:00
Matthias Mailänder
47e21f8bef Remove unused using. 2020-04-11 16:29:00 +02:00
Matthias Mailänder
331b854e4e Add a lint check for production bar types. 2020-04-10 21:00:26 +02:00
Matthias Mailänder
274bc9cbba Add missing sequence reference. 2020-04-10 20:56:54 +02:00
Matthias Mailänder
827f8d95b4 Remove unused using. 2020-04-10 20:56:54 +02:00
Matthias Mailänder
2946dd35d5 Spaces to tabs. 2020-04-10 20:14:39 +02:00
Matthias Mailänder
74d884787d Remove trailing tabs/spaces. 2020-04-09 22:32:05 +02:00
Matthias Mailänder
5516e16fb8 Make the default player color configurable in mod.yaml 2020-04-09 22:32:05 +02:00
reaperrr
cadf4eb322 Limit TS fona to temperate theater
Their art wasn't drawn with snow terrain in mind,
so no point in allowing to place them on snow maps.
2020-04-07 22:04:16 +02:00
Matthias Mailänder
269249e86e Fix the fona sequence definitions. 2020-04-07 22:04:16 +02:00
Matthias Mailänder
30f87d2308 Port some Translucent=yes from Art.ini 2020-04-07 22:00:31 +02:00
Zimmermann Gyula
8b7e72b95e Add three additional blending modes. 2020-04-07 22:00:31 +02:00
abcdefg30
1e64048956 Cache PlayerResources and unit cost in Resupply 2020-04-07 21:27:16 +02:00
abcdefg30
8512e696f5 Add Creeps as enemy in all D2k missions 2020-04-07 21:19:08 +02:00
abcdefg30
6a03a9ec5f Fix a yaml error in GDI08a 2020-04-07 20:59:17 +02:00
netnazgul
5e04c99d57 Fix tile errors on the map "Pie of Animosity" 2020-04-07 20:53:28 +02:00
Mustafa Alperen Seki
82f15491c0 Allow Engineers in RA to enter undamaged (Camo) PillBoxes. 2020-04-03 04:09:43 -05:00
Mustafa Alperen Seki
101843fbb7 Make EngineerRepairable conditional. 2020-04-03 04:09:43 -05:00
Zimmermann Gyula
9e534f3804 Add damagetypes to repairing. 2020-03-31 01:10:51 -05:00
Punsho
ca3cfc0184 RA Balance patch 2020-03-29 21:57:12 +02:00
Paul Chote
d62fb901e2 Fix actors with no footprint leaving stale data when deleted. 2020-03-29 21:10:45 +02:00
Matthias Mailänder
73a2b59c2c Add additional notification support to infiltration. 2020-03-29 12:00:16 -05:00
Paul Chote
2c7a56625c Move selectableActor check inside InputOverridesSelection. 2020-03-29 13:20:10 +02:00
Ivaylo Draganov
e2572b214f Adjust spacing and width in editor category dropdown 2020-03-28 20:41:03 +00:00
abcdefg30
d22cd3a74f Adjust the map visibility panel height 2020-03-28 20:41:03 +00:00
abcdefg30
0c8fcedfdf Start with randomized wind strength 2020-03-28 19:46:47 +01:00
Paul Chote
99009c37ce Fix and simplify WeatherOverlay:
- Fix rendering issues
- Track particles in world pixels instead of screen pixels
- Removed un/underused fade in/out support
- Update wind once per tick instead of once per particle
- Make Particle struct readonly
2020-03-28 19:46:47 +01:00
Paul Chote
d9f5771778 Make the right edge of the airfield transitable. 2020-03-28 19:13:14 +01:00
Paul Chote
d35b5070fb Fix minelayers leaking enemy mine positions through the fog. 2020-03-28 18:49:07 +01:00
Paul Chote
02f41f9afc Fix SpriteEffect updating twice in the first tick. 2020-03-28 17:12:25 +01:00
abcdefg30
c797aa1d5e Change syrf to syrd on the desert shellmap 2020-03-27 19:24:22 +01:00
Paul Chote
b2f7f67756 Fix and simplify ScrollPanelWidget thumb rect calculation. 2020-03-26 16:54:46 +01:00
dnqbob
09014ab6d5 transformation can pass exp to new actor 2020-03-26 02:04:44 -05:00
Matthias Mailänder
8f8747d65e Always show the building fake tags 2020-03-26 00:52:24 -05:00
Ivaylo Draganov
be19e137e2 Align lobby bits in the player tab in TD 2020-03-25 13:01:49 +01:00
Paul Chote
3155291064 Restore ability to configure RMB orders + RMB panning. 2020-03-25 12:36:21 +01:00
Paul Chote
a5b22e6a36 Remove text caching from CncLoadScreen.
We have repeatedly failed at invalidating these
cached values when things change, so the small perf
win is not worth the hassle.
2020-03-25 12:20:14 +01:00
Paul Chote
9c251e8b6a Fix detection circle line rendering. 2020-03-24 20:59:46 +01:00
Matthias Mailänder
6056568182 Remove unused terrain type. 2020-03-24 19:48:54 +01:00
Zimmermann Gyula
7b7c1da18d Add a shared parallel production queue. 2020-03-24 13:35:15 -05:00
Paul Chote
fb5b4b3547 Rename Defense button tooltip to Support. 2020-03-24 13:13:18 -05:00
Paul Chote
19918d485e Disable plugs when there are no sockets to place them. 2020-03-24 13:13:18 -05:00
Paul Chote
45c6c6ba10 Fix Waste Refinery bib. 2020-03-24 13:13:18 -05:00
Paul Chote
0e436bc686 Move plugs and superweapons to Building queue. 2020-03-24 13:13:18 -05:00
Ivaylo Draganov
b0dfea0a09 Adjust the stroke of the muted indicator glyph 2020-03-24 16:56:49 +01:00
Paul Chote
2c4e6c4188 Remove special-case rollover rendering. 2020-03-24 00:07:10 -05:00
Paul Chote
9f3254dbd1 Implement isometric selection boxes for TS structures. 2020-03-24 00:07:10 -05:00
Paul Chote
88cdad4189 Add support for polygon selection shapes. 2020-03-24 00:07:10 -05:00
Paul Chote
4ba50a4379 Remove IEquatable from ActorBoundsPair. 2020-03-24 00:07:10 -05:00
Paul Chote
2b6c104011 Update RA decorations. 2020-03-24 00:07:10 -05:00
Paul Chote
4b446d100e Update D2k decorations. 2020-03-24 00:07:10 -05:00
Paul Chote
f9ca2114a9 Update TS decorations. 2020-03-24 00:07:10 -05:00
Paul Chote
afc9c6ef85 Update TD decorations. 2020-03-24 00:07:10 -05:00
Paul Chote
ac200f6173 Rework decoration renderable traits:
- Removed implicit pip definitions and IPips interface.
  New decoration traits have been added to render them.
  Pip types are no longer hardcoded in OpenRA.Game.

- Decoration rendering is now managed by SelectionDecorations(Base),
  which allows us to remove assumptions about the selection box
  geometry from the decoration traits.

- RenderNameTag has been replaced by WithNameTagDecoration, which is
  an otherwise normal decoration trait.

- Unify the configuration and reduce duplication between traits.

- Removed hardcoded references to specific selection box renderables.

- Remove legacy cruft.
2020-03-24 00:07:10 -05:00
Paul Chote
73a78eadb1 Move Interactable and Selectable to Mods.Common. 2020-03-24 00:07:10 -05:00
Matthias Mailänder
c5139fb6c2 Remove the hard-coded ban of placing buildings on resources. 2020-03-23 23:48:33 -05:00
Paul Chote
9faf9aa1b9 Replace deprecated native OpenAL with OpenAL Soft on macOS. 2020-03-23 11:13:31 +01:00
unknown
3c2e9be248 Add gdi09ea 2020-03-21 21:09:52 +01:00
Matthias Mailänder
5b59f6612f Remove .lua scripts from the .NET solution file. 2020-03-21 17:30:26 +00:00
abcdefg30
3d69363f35 Add support for destroying enemy carryalls 2020-03-21 10:58:17 +01:00
abcdefg30
b580b4fd33 Add support for an announcement function for carryall reinforcements 2020-03-21 10:58:17 +01:00
abcdefg30
74f86d70f8 Add Ordos06a 2020-03-21 10:58:17 +01:00
abcdefg30
3959104f9b Let VS2019 remove a duplicate line from the solution 2020-03-21 10:58:17 +01:00
Paul Chote
1ff037a257 Remove invalid caching from GCOT. 2020-03-20 17:43:24 +01:00
abcdefg30
32700df117 Fix the settings tooltip container being overwritten ingame 2020-03-20 16:06:06 +01:00
Matthias Mailänder
b4edec215e Fix spy ignoring the target's faction. 2020-03-19 23:11:38 +01:00
Michael Silber
dffa1e45f4 Add gdi08a 2020-03-17 19:04:36 +01:00
Paul Chote
df3b6dde34 Update macOS launcher to fix "View Logs" button. 2020-03-16 20:15:58 +01:00
Matthias Mailänder
834bbf467e Make GlobalLightingPaletteEffect public 2020-03-16 11:10:30 +01:00
Paul Chote
4d4f94208e Cache CandidateMovementCells within the same tick. 2020-03-12 17:07:14 +01:00
Paul Chote
416713de0c Fix infantry switching subcells and blocking eachother while moving. 2020-03-11 15:40:12 +01:00
Paul Chote
c523ca8efe Fix FreeSubCell ignoring preferred subcell requests. 2020-03-11 15:40:12 +01:00
Paul Chote
9acea56108 Fix pathing across transit-only cells. 2020-03-11 15:40:12 +01:00
Paul Chote
44a7422375 Fix variable naming in Locomotor. 2020-03-11 15:40:12 +01:00
abcdefg30
0d0e7eb179 Fix aircraft not taking off properly 2020-03-08 17:20:39 +01:00
abcdefg30
ea6c840343 Fix the panic chance calculation in ScaredyCat 2020-03-08 16:33:23 +01:00
abcdefg30
d2db0913ac Fix the missle jamming chance calculation 2020-03-08 16:33:23 +01:00
Punsho
3721dae74d Making missiles properly go over terrrain and track air units 2020-03-07 13:00:28 +01:00
Matthias Mailänder
9050a2447b Add remappable support to production icons. 2020-03-04 22:02:30 +01:00
2779 changed files with 149636 additions and 81038 deletions

View File

@@ -6,13 +6,205 @@ charset=utf-8
[*]
end_of_line = LF
insert_final_newline = true
trim_trailing_whitespace = true
; 4-column tab indentation
; 4-column tab indentation and .NET coding conventions
[*.cs]
indent_style = tab
indent_size = 4
dotnet_separate_import_directive_groups = false
dotnet_sort_system_directives_first = true
csharp_style_var_elsewhere = true:suggestion
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_prefer_braces = when_multiline:suggestion
csharp_using_directive_placement = outside_namespace:suggestion
csharp_new_line_before_open_brace = all
csharp_space_around_binary_operators = before_and_after
## Naming styles:
dotnet_naming_style.camel_case.capitalization = camel_case
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_naming_style.i_prefix_pascal_case.capitalization = pascal_case
dotnet_naming_style.i_prefix_pascal_case.required_prefix = I
## Symbol specifications:
dotnet_naming_symbols.const_locals.applicable_kinds = local
dotnet_naming_symbols.const_locals.applicable_accessibilities = *
dotnet_naming_symbols.const_locals.required_modifiers = const
dotnet_naming_symbols.const_fields.applicable_kinds = field
dotnet_naming_symbols.const_fields.applicable_accessibilities = *
dotnet_naming_symbols.const_fields.required_modifiers = const
dotnet_naming_symbols.static_readonly_fields.applicable_kinds = field
dotnet_naming_symbols.static_readonly_fields.applicable_accessibilities = *
dotnet_naming_symbols.static_readonly_fields.required_modifiers = static, readonly
dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field
dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, internal, protected, protected_internal, private_protected
dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly
dotnet_naming_symbols.private_or_protected_fields.applicable_kinds = field
dotnet_naming_symbols.private_or_protected_fields.applicable_accessibilities = private, protected, private_protected
dotnet_naming_symbols.interfaces.applicable_kinds = interface
dotnet_naming_symbols.interfaces.applicable_accessibilities = *
dotnet_naming_symbols.parameters_and_locals.applicable_kinds = parameter, local
dotnet_naming_symbols.parameters_and_locals.applicable_accessibilities = *
dotnet_naming_symbols.most_symbols.applicable_kinds = namespace, class, struct, enum, field, property, method, local_function, event, delegate, type_parameter
dotnet_naming_symbols.most_symbols.applicable_accessibilities = *
## Naming rules:
dotnet_naming_rule.const_locals_should_be_pascal_case.symbols = const_locals
dotnet_naming_rule.const_locals_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.const_locals_should_be_pascal_case.severity = warning
dotnet_naming_rule.const_fields_should_be_pascal_case.symbols = const_fields
dotnet_naming_rule.const_fields_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.const_fields_should_be_pascal_case.severity = warning
dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.symbols = static_readonly_fields
dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.severity = warning
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = warning
dotnet_naming_rule.private_or_protected_fields_should_be_camel_case.symbols = private_or_protected_fields
dotnet_naming_rule.private_or_protected_fields_should_be_camel_case.style = camel_case
dotnet_naming_rule.private_or_protected_fields_should_be_camel_case.severity = warning
dotnet_naming_rule.interfaces_should_be_i_prefix_pascal_case.symbols = interfaces
dotnet_naming_rule.interfaces_should_be_i_prefix_pascal_case.style = i_prefix_pascal_case
dotnet_naming_rule.interfaces_should_be_i_prefix_pascal_case.severity = warning
dotnet_naming_rule.parameters_and_locals_should_be_camel_case.symbols = parameters_and_locals
dotnet_naming_rule.parameters_and_locals_should_be_camel_case.style = camel_case
dotnet_naming_rule.parameters_and_locals_should_be_camel_case.severity = warning
dotnet_naming_rule.most_symbols_should_be_pascal_case.symbols = most_symbols
dotnet_naming_rule.most_symbols_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.most_symbols_should_be_pascal_case.severity = warning
## Formatting:
# Also handled by StyleCopAnalyzers - SA1024: ColonsMustBeSpacedCorrectly.
csharp_space_after_colon_in_inheritance_clause = true
# Also handled by StyleCopAnalyzers - SA1024: ColonsMustBeSpacedCorrectly.
csharp_space_before_colon_in_inheritance_clause = true
# Also handled by StyleCopAnalyzers - SA1000: KeywordsMustBeSpacedCorrectly.
csharp_space_after_keywords_in_control_flow_statements = true
# Leave code block on single line.
csharp_preserve_single_line_blocks = true
# Leave statements and member declarations on the same line.
csharp_preserve_single_line_statements = true
# IDE0049, IDE-only counterpart of StyleCopAnalyzers - SA1121: UseBuiltInTypeAlias.
dotnet_style_predefined_type_for_member_access = true
# IDE0049, IDE-only counterpart of StyleCopAnalyzers - SA1121: UseBuiltInTypeAlias.
dotnet_style_predefined_type_for_locals_parameters_members = true
## Others:
# Show an IDE warning when default access modifiers are explicitly specified.
dotnet_style_require_accessibility_modifiers = omit_if_default:warning
# Don't prefer braces (for one liners).
dotnet_diagnostic.IDE0011.severity = silent
# Object initialization can be simplified / Use object initializer.
dotnet_diagnostic.IDE0017.severity = warning
# Collection initialization can be simplified
dotnet_diagnostic.IDE0028.severity = warning
# Simplify 'default' expression
dotnet_diagnostic.IDE0034.severity = warning
# Modifiers are not ordered.
dotnet_diagnostic.IDE0036.severity = warning
# Raise a warning on build when default access modifiers are explicitly specified.
dotnet_diagnostic.IDE0040.severity = warning
# Make field readonly.
dotnet_diagnostic.IDE0044.severity = warning
# Unused private member.
dotnet_diagnostic.IDE0052.severity = warning
# Unnecessary value assignment.
dotnet_diagnostic.IDE0059.severity = warning
# Unused parameter.
dotnet_diagnostic.IDE0060.severity = warning
# Naming rule violation.
dotnet_diagnostic.IDE1006.severity = warning
# Avoid unnecessary zero-length array allocations.
dotnet_diagnostic.CA1825.severity = warning
# Do not use Enumerable methods on indexable collections. Instead use the collection directly.
dotnet_diagnostic.CA1826.severity = warning
# Count() is used where Any() could be used instead to improve performance.
dotnet_diagnostic.CA1827.severity = warning
# Use Length/Count property instead of Enumerable.Count method.
dotnet_diagnostic.CA1829.severity = warning
# Use string.Contains(char) instead of string.Contains(string) with single characters.
dotnet_diagnostic.CA1847.severity = warning
; 4-column tab indentation
[*.yaml]
indent_style = tab
indent_size = 4
indent_size = 4
# Use 'Count' property instead of 'Any' method.
dotnet_diagnostic.RCS1080.severity = warning
# Use read-only auto-implemented property.
dotnet_diagnostic.RCS1170.severity = warning
# Unnecessary interpolated string.
dotnet_diagnostic.RCS1214.severity = warning
# Unnecessary usage of verbatim string literal.
dotnet_diagnostic.RCS1192.severity = warning
# Use pattern matching instead of combination of 'as' operator and null check.
dotnet_diagnostic.RCS1221.severity = warning
# Expression is always equal to 'true'.
dotnet_diagnostic.RCS1215.severity = warning
# Use StringComparison when comparing strings.
dotnet_diagnostic.RCS1155.severity = warning
# Abstract type should not have public constructors.
dotnet_diagnostic.RCS1160.severity = warning
# Optimize 'Dictionary<TKey, TValue>.ContainsKey' call.
dotnet_diagnostic.RCS1235.severity = warning
# Call extension method as instance method.
dotnet_diagnostic.RCS1196.severity = warning

View File

@@ -1,11 +1,14 @@
blank_issues_enabled: false
contact_links:
- name: Frequently Asked Questions
url: https://github.com/OpenRA/OpenRA/wiki/FAQ#frequently-asked-questions
about: Explanations for common problems and questions.
- name: OpenRA Forum
url: https://forum.openra.net/
about: "Please ask questions about modding here."
about: Please ask questions about modding here.
- name: OpenRA Discord server
url: https://discord.openra.net/
about: "Join the community Discord server for community discussion and support."
about: Join the community Discord server for community discussion and support.
- name: OpenRA IRC Channel
url: https://webchat.freenode.net/#openra
about: "Join our development IRC channel on freenode for discussion of development topics."
url: https://web.libera.chat/#openra
about: Join our development IRC channel on Libera for discussion of development topics.

View File

@@ -1,6 +1,6 @@
---
name: Crash report
about: Report a game crash.
about: Report a game crash. Check the FAQ first https://github.com/OpenRA/OpenRA/wiki/FAQ#common-issues
title: My game crashed
labels: Crash
assignees: ''

View File

@@ -13,4 +13,4 @@ You can help speed up the review process by following a few steps:
* Respond to review comments as soon as you reasonably can. Reviewers will usually prioritize Pull Requests that are still fresh in their minds. Make sure to leave a comment when you push new changes, otherwise GitHub does not automatically notify reviewers!
* Leave a polite comment asking for reviews if a week or more has passed without feedback.
If you need any help you can ask in the #openra IRC channel on freenode (most active during European evenings).
If you need any help you can ask on Discord (https://discord.openra.net) or in the #openra IRC channel on Libera (not as active as Discord).

77
.github/workflows/ci.yaml vendored Normal file
View File

@@ -0,0 +1,77 @@
name: Continuous Integration
on:
push:
pull_request:
branches: [ bleed ]
jobs:
linux:
name: Linux (.NET 6.0)
runs-on: ubuntu-20.04
steps:
- name: Clone Repository
uses: actions/checkout@v2
- name: Install .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Check Code
run: |
make check
- name: Check Mods
run: |
sudo apt-get install lua5.1
make check-scripts
make test
linux-mono:
name: Linux (mono)
runs-on: ubuntu-20.04
steps:
- name: Clone Repository
uses: actions/checkout@v2
- name: Check Code
run: |
mono --version
make RUNTIME=mono check
- name: Check Mods
run: |
# check-scripts does not depend on .net/mono, so is not needed here
make RUNTIME=mono test
windows:
name: Windows (.NET 6.0)
runs-on: windows-2019
steps:
- name: Clone Repository
uses: actions/checkout@v2
- name: Install .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Check Code
shell: powershell
run: |
# Work around runtime failures on the GH Actions runner
dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org
.\make.ps1 check
dotnet build OpenRA.Test\OpenRA.Test.csproj -c Debug --nologo -p:TargetPlatform=win-x64
dotnet test bin\OpenRA.Test.dll --test-adapter-path:.
- name: Check Mods
run: |
chocolatey install lua --version 5.1.5.52
$ENV:Path = $ENV:Path + ";C:\Program Files (x86)\Lua\5.1\"
.\make.ps1 check-scripts
.\make.ps1 test

129
.github/workflows/documentation.yml vendored Normal file
View File

@@ -0,0 +1,129 @@
name: Deploy Documentation
on:
workflow_dispatch:
inputs:
tag:
description: 'Git Tag'
required: true
default: 'release-xxxxxxxx'
jobs:
wiki:
name: Update Wiki
if: github.repository == 'openra/openra'
runs-on: ubuntu-20.04
steps:
- name: Clone Repository
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.tag }}
- name: Install .NET 6
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Prepare Environment
run: |
make all
- name: Clone Wiki
uses: actions/checkout@v2
with:
repository: openra/openra.wiki
token: ${{ secrets.DOCS_TOKEN }}
path: wiki
- name: Update Wiki (Playtest)
if: startsWith(github.event.inputs.tag, 'playtest-')
env:
GIT_TAG: ${{ github.event.inputs.tag }}
run: |
./utility.sh all --settings-docs "${GIT_TAG}" > "wiki/Settings (playtest).md"
- name: Update Wiki (Release)
if: startsWith(github.event.inputs.tag, 'release-')
env:
GIT_TAG: ${{ github.event.inputs.tag }}
run: |
./utility.sh all --settings-docs "${GIT_TAG}" > "wiki/Settings.md"
- name: Push Wiki
env:
GIT_TAG: ${{ github.event.inputs.tag }}
run: |
cd wiki
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
git add --all
git commit -m "Update auto-generated documentation for ${GIT_TAG}"
git push origin master
docs:
name: Update docs.openra.net
if: github.repository == 'openra/openra'
runs-on: ubuntu-20.04
steps:
- name: Clone Repository
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.tag }}
- name: Install .NET 6
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Prepare Environment
run: |
make all
- name: Clone docs.openra.net
uses: actions/checkout@v2
with:
repository: openra/docs
token: ${{ secrets.DOCS_TOKEN }}
path: docs
- name: Update docs.openra.net (Playtest)
if: startsWith(github.event.inputs.tag, 'playtest-')
env:
GIT_TAG: ${{ github.event.inputs.tag }}
run: |
git checkout playtest
./utility.sh all --docs "${GIT_TAG}" | python3 ./packaging/format-docs.py > "docs/api/traits.md"
./utility.sh all --weapon-docs "${GIT_TAG}" | python3 ./packaging/format-docs.py > "docs/api/weapons.md"
./utility.sh all --sprite-sequence-docs "${GIT_TAG}" | python3 ./packaging/format-docs.py > "docs/api/sprite-sequences.md"
./utility.sh all --lua-docs "${GIT_TAG}" > "docs/api/lua.md"
- name: Update docs.openra.net (Release)
if: startsWith(github.event.inputs.tag, 'release-')
env:
GIT_TAG: ${{ github.event.inputs.tag }}
run: |
git checkout release
./utility.sh all --docs "${GIT_TAG}" | python3 ./packaging/format-docs.py > "docs/api/traits.md"
./utility.sh all --weapon-docs "${GIT_TAG}" | python3 ./packaging/format-docs.py > "docs/api/weapons.md"
./utility.sh all --sprite-sequence-docs "${GIT_TAG}" | python3 ./packaging/format-docs.py > "docs/api/sprite-sequences.md"
./utility.sh all --lua-docs "${GIT_TAG}" > "docs/api/lua.md"
- name: Commit docs.openra.net
env:
GIT_TAG: ${{ github.event.inputs.tag }}
run: |
cd docs
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
git add *.md
git commit -m "Update auto-generated documentation for ${GIT_TAG}"
- name: Push docs.openra.net (Release)
if: startsWith(github.event.inputs.tag, 'release-')
run: |
git push origin release
- name: Push docs.openra.net (Playtest)
if: startsWith(github.event.inputs.tag, 'playtest-')
run: |
git push origin playtest

86
.github/workflows/itch.yml vendored Normal file
View File

@@ -0,0 +1,86 @@
name: Deploy itch.io Packages
on:
workflow_dispatch:
inputs:
tag:
description: 'Git Tag'
required: true
default: 'release-xxxxxxxx'
jobs:
itch:
name: Deploy to itch.io
runs-on: ubuntu-20.04
if: github.repository == 'openra/openra'
steps:
- name: Download Packages
run: |
wget -q "https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.tag }}/OpenRA-${{ github.event.inputs.tag }}-x64.exe"
wget -q "https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.tag }}/OpenRA-${{ github.event.inputs.tag }}-x64-winportable.zip" -O "OpenRA-${{ github.event.inputs.tag }}-x64-win-itch.zip"
wget -q "https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.tag }}/OpenRA-${{ github.event.inputs.tag }}.dmg"
wget -q "https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.tag }}/OpenRA-Dune-2000-x86_64.AppImage"
wget -q "https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.tag }}/OpenRA-Red-Alert-x86_64.AppImage"
wget -q "https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.tag }}/OpenRA-Tiberian-Dawn-x86_64.AppImage"
wget -q "https://raw.githubusercontent.com/${{ github.repository }}/${{ github.event.inputs.tag }}/packaging/.itch.toml"
zip -u "OpenRA-${{ github.event.inputs.tag }}-x64-win-itch.zip" .itch.toml
- name: Publish Windows Installer
uses: josephbmanley/butler-publish-itchio-action@master
env:
BUTLER_CREDENTIALS: ${{ secrets.BUTLER_CREDENTIALS }}
CHANNEL: win
ITCH_GAME: openra
ITCH_USER: openra
VERSION: ${{ github.event.inputs.tag }}
PACKAGE: OpenRA-${{ github.event.inputs.tag }}-x64.exe
- name: Publish Windows Itch Bundle
uses: josephbmanley/butler-publish-itchio-action@master
env:
BUTLER_CREDENTIALS: ${{ secrets.BUTLER_CREDENTIALS }}
CHANNEL: itch
ITCH_GAME: openra
ITCH_USER: openra
VERSION: ${{ github.event.inputs.tag }}
PACKAGE: OpenRA-${{ github.event.inputs.tag }}-x64-win-itch.zip
- name: Publish macOS Package
uses: josephbmanley/butler-publish-itchio-action@master
env:
BUTLER_CREDENTIALS: ${{ secrets.BUTLER_CREDENTIALS }}
CHANNEL: macos
ITCH_GAME: openra
ITCH_USER: openra
VERSION: ${{ github.event.inputs.tag }}
PACKAGE: OpenRA-${{ github.event.inputs.tag }}.dmg
- name: Publish RA AppImage
uses: josephbmanley/butler-publish-itchio-action@master
env:
BUTLER_CREDENTIALS: ${{ secrets.BUTLER_CREDENTIALS }}
CHANNEL: linux-ra
ITCH_GAME: openra
ITCH_USER: openra
VERSION: ${{ github.event.inputs.tag }}
PACKAGE: OpenRA-Red-Alert-x86_64.AppImage
- name: Publish TD AppImage
uses: josephbmanley/butler-publish-itchio-action@master
env:
BUTLER_CREDENTIALS: ${{ secrets.BUTLER_CREDENTIALS }}
CHANNEL: linux-cnc
ITCH_GAME: openra
ITCH_USER: openra
VERSION: ${{ github.event.inputs.tag }}
PACKAGE: OpenRA-Tiberian-Dawn-x86_64.AppImage
- name: Publish D2k AppImage
uses: josephbmanley/butler-publish-itchio-action@master
env:
BUTLER_CREDENTIALS: ${{ secrets.BUTLER_CREDENTIALS }}
CHANNEL: linux-d2k
ITCH_GAME: openra
ITCH_USER: openra
VERSION: ${{ github.event.inputs.tag }}
PACKAGE: OpenRA-Dune-2000-x86_64.AppImage

129
.github/workflows/packaging.yml vendored Normal file
View File

@@ -0,0 +1,129 @@
name: Release Packaging
on:
push:
tags:
- 'release-*'
- 'playtest-*'
- 'devtest-*'
jobs:
source:
name: Source Tarball
runs-on: ubuntu-20.04
steps:
- name: Clone Repository
uses: actions/checkout@v2
- name: Prepare Environment
run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> ${GITHUB_ENV}
- name: Package Source
run: |
mkdir -p build/source
./packaging/source/buildpackage.sh "${GIT_TAG}" "${PWD}/build/source"
- name: Upload Packages
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
overwrite: true
file_glob: true
file: build/source/*
linux:
name: Linux AppImages
runs-on: ubuntu-20.04
steps:
- name: Clone Repository
uses: actions/checkout@v2
- name: Install .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Prepare Environment
run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> ${GITHUB_ENV}
- name: Package AppImages
run: |
mkdir -p build/linux
./packaging/linux/buildpackage.sh "${GIT_TAG}" "${PWD}/build/linux"
- name: Upload Packages
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
overwrite: true
file_glob: true
file: build/linux/*
macos:
name: macOS Disk Images
runs-on: macos-11
steps:
- name: Clone Repository
uses: actions/checkout@v2
- name: Install .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Prepare Environment
run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> ${GITHUB_ENV}
- name: Package Disk Images
env:
MACOS_DEVELOPER_IDENTITY: ${{ secrets.MACOS_DEVELOPER_IDENTITY }}
MACOS_DEVELOPER_CERTIFICATE_BASE64: ${{ secrets.MACOS_DEVELOPER_CERTIFICATE_BASE64 }}
MACOS_DEVELOPER_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_DEVELOPER_CERTIFICATE_PASSWORD }}
MACOS_DEVELOPER_USERNAME: ${{ secrets.MACOS_DEVELOPER_USERNAME }}
MACOS_DEVELOPER_PASSWORD: ${{ secrets.MACOS_DEVELOPER_PASSWORD }}
run: |
mkdir -p build/macos
./packaging/macos/buildpackage.sh "${GIT_TAG}" "${PWD}/build/macos"
- name: Upload Packages
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
overwrite: true
file_glob: true
file: build/macos/*
windows:
name: Windows Installers
runs-on: ubuntu-20.04
steps:
- name: Clone Repository
uses: actions/checkout@v2
- name: Install .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Prepare Environment
run: |
echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> ${GITHUB_ENV}
sudo apt-get update
sudo apt-get install nsis wine64
- name: Package Installers
run: |
mkdir -p build/windows
./packaging/windows/buildpackage.sh "${GIT_TAG}" "${PWD}/build/windows"
- name: Upload Packages
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
overwrite: true
file_glob: true
file: build/windows/*

21
.gitignore vendored
View File

@@ -13,20 +13,11 @@ obj
_ReSharper.*/
/.vs
# Visual Studio Code
/.vscode/settings.json
# binaries
mods/*/*.dll
mods/*/*.mdb
mods/*/*.pdb
/*.dll
/*.dll.config
/*.so
/*.dylib
/*.pdb
/*.mdb
/*.exe
/*.exe.config
thirdparty/download/*
*.mmdb.gz
IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP
# backup files by various editors
*~
@@ -50,10 +41,6 @@ Settings.md
openra.6
update.log
# StyleCop
*.Cache
StyleCopViolations.xml
# SublimeText
*.sublime-project
*.sublime-workspace

View File

@@ -1,86 +0,0 @@
# Travis-CI Build for OpenRA
# see travis-ci.org for details
language: csharp
mono: 6.4.0
jobs:
include:
- os: linux
dist: xenial
- os: osx
if: tag IS present
osx_image: xcode10
cache:
directories:
- thirdparty/download
addons:
apt:
packages:
- lua5.1
- dpkg
- zsync
- markdown
# Environment variables
env:
secure: "C0+Hlfa0YGErxUuWV00Tj6p45otC/D3YwYFuLpi2mj1rDFn/4dgh5WRngjvdDBVbXJ3duaZ78jPHWm1jr7vn2jqj9yETsCIK9psWd38ep/FEBM0SDr6MUD89OuXk/YyvxJAE+UXF6bXg7giey09g/CwBigjMW7ynET3wNAWPHPs="
# Fetch dependencies
# Run the build script
# Check source code with StyleCop
# call OpenRA to check for YAML errors
# Run the NUnit tests
script:
- travis_retry make all-dependencies
- make all
- test "$TRAVIS_OS_NAME" == "linux" && make check || echo "Skipping check"
- test "$TRAVIS_OS_NAME" == "linux" && make check-scripts || echo "Skipping scripts check"
- test "$TRAVIS_OS_NAME" == "linux" && make test || echo "Skipping tests"
- test "$TRAVIS_OS_NAME" == "linux" && make nunit || echo "Skipping nunit tests"
# Only watch the development branch and tagged release.
branches:
only:
- /^release-.*$/
- /^playtest-.*$/
- /^pkgtest-.*$/
- /^prep-.*$/
- bleed
# Notify developers when build passed/failed.
notifications:
irc:
template:
- "%{repository}#%{build_number} %{commit} %{author}: %{message} %{build_url}"
channels:
- "irc.freenode.net#openra"
use_notice: true
skip_join: true
before_deploy:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
wget https://mirrors.edge.kernel.org/ubuntu/pool/universe/n/nsis/nsis-common_3.04-1_all.deb;
wget https://mirrors.edge.kernel.org/ubuntu/pool/universe/n/nsis/nsis_3.04-1_amd64.deb;
sudo dpkg -i nsis-common_3.04-1_all.deb;
sudo dpkg -i nsis_3.04-1_amd64.deb;
cd packaging && ./update-wiki.sh ${TRAVIS_TAG} && cd ..;
fi;
- export PATH=$PATH:$HOME/usr/bin
- DOTVERSION=`echo ${TRAVIS_TAG} | sed "s/-/\\./g"`
- cd packaging
- mkdir build
- ./package-all.sh ${TRAVIS_TAG} ${PWD}/build/
deploy:
provider: releases
api_key:
secure: "g/LU11f+mjqv+lj0sR1UliHwogXL4ofJUwoG5Dbqlvdf5UTLWytw/OWSCv8RGyuh10miyWeaoqHh1cn2C1IFhUEqN1sSeKKKOWOTvJ2FR5mzi9uH3d/MOBzG5icQ7Qh0fZ1YPz5RaJJhYu6bmfvA/1gD49GoaX2kxQL4J5cEBgg="
file_glob: true
file: build/*
skip_cleanup: true
on:
all_branches: true
tags: true
repo: OpenRA/OpenRA

9
.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,9 @@
{
"recommendations": [
"ms-dotnettools.csharp",
"openra.oraide-vscode",
"openra.vscode-openra-lua",
"EditorConfig.EditorConfig",
"macabeus.vscode-fluent",
]
}

63
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,63 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch (TD)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceRoot}/bin/OpenRA.dll",
"windows": {
"program": "${workspaceRoot}/bin/OpenRA.exe",
},
"args": ["Game.Mod=cnc", "Engine.EngineDir=.."],
"preLaunchTask": "build",
},
{
"name": "Launch (RA)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceRoot}/bin/OpenRA.dll",
"windows": {
"program": "${workspaceRoot}/bin/OpenRA.exe",
},
"args": ["Game.Mod=ra", "Engine.EngineDir=.."],
"preLaunchTask": "build",
},
{
"name": "Launch (D2k)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceRoot}/bin/OpenRA.dll",
"windows": {
"program": "${workspaceRoot}/bin/OpenRA.exe",
},
"args": ["Game.Mod=d2k", "Engine.EngineDir=.."],
"preLaunchTask": "build",
},
{
"name": "Launch (TS)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceRoot}/bin/OpenRA.dll",
"windows": {
"program": "${workspaceRoot}/bin/OpenRA.exe",
},
"args": ["Game.Mod=ts", "Engine.EngineDir=.."],
"preLaunchTask": "build",
},
{
"name": "Launch Utility",
"type": "coreclr",
"request": "launch",
"program": "${workspaceRoot}/bin/OpenRA.Utility.dll",
"windows": {
"program": "${workspaceRoot}/bin/OpenRA.Utility.exe",
},
"args": ["all", "--docs", "{DEV_VERSION}"],
"env": {
"ENGINE_DIR": ".."
},
"preLaunchTask": "build",
},
]
}

36
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,36 @@
{
"version": "2.0.0",
"options": {
"env": {
"ENGINE_DIR": ".."
}
},
"tasks": [
{
"label": "build",
"command": "make",
"args": ["all", "CONFIGURATION=Debug"],
"windows": {
"command": "make.cmd"
}
},
{
"label": "Run Utility",
"command": "dotnet ${workspaceRoot}/bin/OpenRA.Utility.dll ${input:modId} ${input:command}",
"type": "shell",
}
],
"inputs": [
{
"id": "modId",
"description": "ID of the mod to run",
"default": "all",
"type": "promptString"
}, {
"id": "command",
"description": "Name of the command + parameters",
"default": "",
"type": "promptString"
},
]
}

54
AUTHORS
View File

@@ -2,28 +2,30 @@ OpenRA wouldn't be where it is today without the
hard work of many contributors.
The OpenRA developers are:
* Chris Forbes (chrisf)
* Gustas Kažukauskas (PunkPun)
* Lukas Franke (abcdefg30)
* Paul Chote (pchote)
* Reaperrr
* Matthias Mailänder (Mailaender)
Previous developers included:
* Alli Witheford (alzeih)
* Caleb Anderson (RobotCaleb)
* Chris Forbes (chrisf)
* Curtis Shmyr (hamb)
* Daniel Hernandez (Mancano)
* Igor Popov (ihptru)
* Matthias Mailänder (Mailaender)
* Megan Bowra-Dean (beedee)
* Mike Bundy (kehaar)
* Oliver Brakmann (obrakmann)
* Paul Chote (pchote)
* Pavel Penev (penev92)
* Reaperrr
* Robert Pepperell (ytinasni)
* ScottNZ
* Tom Roostan (RoosterDragon)
Also thanks to:
* abmyii
* anvilvapre (anvilvapre)
* Adam Valy (Tschokky)
* Akseli Virtanen (RAGEQUIT)
* Alexander Fast (mizipzor)
@@ -37,14 +39,17 @@ Also thanks to:
* Arik Lirette (Angusm3)
* Barnaby Smith (mvi)
* Bellator
* Bernd Stellwag (burned42)
* Biofreak
* Braxton Williams (Buddytex)
* Brendan Gluth (Mechanical_Man)
* Brent Gardner (bggardner)
* Bryan Wilbur
* Bugra Cuhadaroglu (BugraC)
* Chris Cameron (Vesuvian)
* Chris Grant (Unit158)
* Christer Ulfsparre (Holloweye)
* Christoph Lahner (chlah)
* clem
* Cody Brittain (Generalcamo)
* Constantin Helmig (CH4Code)
@@ -57,6 +62,7 @@ Also thanks to:
* DeadlySurprise
* Dmitri Suvorov (suvjunmd)
* dtluna
* Eduardo Cáceres (eduherminio)
* Erasmus Schroder (rasco)
* Eric Bajumpaa (SteelPhase)
* Evgeniy Sergeev (evgeniysergeev)
@@ -74,6 +80,7 @@ Also thanks to:
* Imago
* Iran
* Ishan Bhargava (ishantheperson)
* Ivaylo Draganov (dragunoff)
* Jacob Dufault (jacobdufault)
* James Dunne (jsd)
* James Gilbert (DSUK)
@@ -134,19 +141,22 @@ Also thanks to:
* Rikhardur Bjarni Einarsson (WolfGaming)
* Sascha Biedermann (bidifx)
* Sean Hunt (coppro)
* Sebastien Kerguen (xanax)
* Shawn Collins (UberWaffe)
* Simon Verbeke (Saticmotion)
* Stuart McHattie (SDJMcHattie)
* Taryn Hill (Phrohdoh)
* Teemu Nieminen (Temeez)
* Thomas Christlieb (ThomasChr)
* Tim Mylemans (gecko)
* Tirili
* Tomas Einarsson (Mesacer)
* Tom van Leth (tovl)
* Trevor Nichols (ocdi)
* Tristan Keating (Kilkakon)
* Tristan Mühlbacher (MicroBit)
* UnknownProgrammer
* Vladimir Komarov (VrKomarov)
* Wojciech Walaszek (Voidwalker)
* Wuschel
Using GNU FreeFont distributed under the GNU GPL
@@ -160,9 +170,6 @@ FreeType License.
Using OpenAL Soft distributed under the GNU LGPL.
Using MaxMind GeoIP2 .NET API distributed under
the Apache 2.0 license.
Using SDL2-CS and OpenAL-CS created by Ethan
Lee and released under the zlib license.
@@ -172,9 +179,17 @@ under the MIT license.
Using FuzzyLogicLibrary (fuzzynet) by Dmitry
Kaluzhny and released under the GNU GPL terms.
Using Open.Nat by Lucas Ontivero, based on the work
of Alan McGovern and Ben Motmans and distributed
under the MIT license.
Using Mono.Nat by Alan McGovern, Ben Motmans,
Nicholas Terry distributed under the MIT license.
Using MP3Sharp by Robert Bruke and Zane Wagner
licensed under the GNU LGPL Version 3.
Using TagLib# by Stephen Shaw licensed under the
GNU LGPL Version 2.1.
Using NVorbis by Andrew Ward distributed under
the MIT license.
Using ICSharpCode.SharpZipLib initially by Mike
Krueger and distributed under the GNU GPL terms.
@@ -182,6 +197,23 @@ Krueger and distributed under the GNU GPL terms.
Using rix0rrr.BeaconLib developed by Rico Huijbers
distributed under MIT License.
Using DiscordRichPresence developed by Lachee
distributed under MIT License.
Using Json.NET developed by James Newton-King
distributed under MIT License.
Using ANGLE distributed under the BS3 3-Clause license.
Using Pfim developed by Nick Babcock
distributed under the MIT license.
Using Linguini by the Space Station 14 team
licensed under Apache and MIT terms.
This site or product includes IP2Location LITE data
available from http://www.ip2location.com.
Finally, special thanks goes to the original teams
at Westwood Studios and EA for creating the classic
games which OpenRA aims to reimagine.

View File

@@ -56,8 +56,8 @@ further defined and clarified by project maintainers.
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by private-messaging a project team member (users with a + in front
of their name) via our IRC channel (#openra on freenode
[webchat](http://webchat.freenode.net/?channels=openra)). All
of their name) via our IRC channel (#openra on Libera
[webchat](https://web.libera.chat/#openra)). All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.

File diff suppressed because one or more lines are too long

View File

@@ -1,40 +1,52 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
<OutputType>Library</OutputType>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<UseVSHostingProcess>false</UseVSHostingProcess>
<OutputPath>..</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<LangVersion>5</LangVersion>
<LangVersion>7.3</LangVersion>
<DebugSymbols>true</DebugSymbols>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<EngineRootPath Condition="'$(EngineRootPath)' == ''">..</EngineRootPath>
<OutputPath>$(EngineRootPath)/bin</OutputPath>
<PlatformTarget>AnyCPU</PlatformTarget>
<ExternalConsole>false</ExternalConsole>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
<Configurations>Debug;Release;Release-x86</Configurations>
<CodeAnalysisRuleSet>$(EngineRootPath)/OpenRA.ruleset</CodeAnalysisRuleSet>
<Nullable>disable</Nullable>
</PropertyGroup>
<PropertyGroup>
<TargetFramework Condition="'$(MSBuildRuntimeType)'!='Mono'">net6.0</TargetFramework>
<TargetFramework Condition="'$(MSBuildRuntimeType)'=='Mono'">netstandard2.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<TargetPlatform Condition="$([MSBuild]::IsOsPlatform('Windows'))">win-x64</TargetPlatform>
<TargetPlatform Condition="$([MSBuild]::IsOsPlatform('Linux'))">linux-x64</TargetPlatform>
<TargetPlatform Condition="$([MSBuild]::IsOsPlatform('OSX'))">osx-x64</TargetPlatform>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>false</Optimize>
</PropertyGroup>
<ItemGroup>
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
<Compile Include="**/*.cs" Exclude="$(DefaultItemExcludes)" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release-x86'">
<Prefer32bit>true</Prefer32bit>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<AdditionalFiles Include="../stylecop.json" />
</ItemGroup>
<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'">
<!-- Disable code style analysis on Release builds to improve compile-time performance -->
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Analyzer Remove="@(Analyzer)" />
</ItemGroup>
</Target>
<!-- StyleCop -->
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
</ItemGroup>
</Project>

View File

@@ -8,105 +8,76 @@ Windows
Compiling OpenRA requires the following dependencies:
* [Windows PowerShell >= 4.0](http://microsoft.com/powershell) (included by default in recent Windows 10 versions)
* [.NET Framework 4.6.1 (Developer Pack)](https://dotnet.microsoft.com/download/dotnet-framework/net461) (or via Visual Studio 2017)
* [.NET Core 2.2 SDK](https://dotnet.microsoft.com/download/dotnet-core/2.2) (or via Visual Studio 2017)
* [.NET 6 SDK](https://dotnet.microsoft.com/download/dotnet/6.0) (or via Visual Studio)
Type `make dependencies` in a command terminal to download pre-compiled native libraries for:
* [SDL 2](http://www.libsdl.org/download-2.0.php)
* [FreeType](http://gnuwin32.sourceforge.net/packages/freetype.htm)
* [zlib](http://gnuwin32.sourceforge.net/packages/zlib.htm)
* [OpenAL](http://kcat.strangesoft.net/openal.html)
* [liblua 5.1](http://luabinaries.sourceforge.net/download.html)
To compile OpenRA, open the `OpenRA.sln` solution in the main folder, build it from the command-line with MSBuild or use the Makefile analogue command `make all` scripted in PowerShell syntax.
To compile OpenRA, open the `OpenRA.sln` solution in the main folder, build it from the command-line with `dotnet` or use the Makefile analogue command `make all` scripted in PowerShell syntax.
Run the game with `launch-game.cmd`. It can be handed arguments that specify the exact mod one wishes to run, for example, run `launch-game.cmd Game.Mod=ra` to launch Red Alert, `launch-game.cmd Game.Mod=cnc` to start Tiberian dawn or `launch-game.cmd Game.Mod=d2k` to launch Dune 2000.
Linux
=====
Mono, version 5.4 or later, is required to compile OpenRA. You can add the [upstream mono repository](https://www.mono-project.com/download/stable/#download-lin) for your distro to obtain the latest version if your system packages are not sufficient.
.NET 6 or Mono (version 6.4 or later) is required to compile OpenRA. We recommend using .NET 6 when possible, as Mono is poorly packaged by most Linux distributions (e.g. missing the required `msbuild` toolchain), and has been deprecated as a standalone project.
Use `make dependencies` to map the native libraries to your system and fetch the remaining CLI dependencies to place them at the appropriate places.
The [.NET 6 download page](https://dotnet.microsoft.com/download/dotnet/6.0) provides repositories for various package managers and binary releases for several architectures. If you prefer to use Mono, we suggest adding the [upstream repository](https://www.mono-project.com/download/stable/#download-lin) for your distro to obtain the latest version and the `msbuild` toolchain.
To compile OpenRA, run `make all` from the command line. After this one can run the game with `./launch-game.sh`. It is also possible to specify the mod you wish to run from the command line, e.g. with `./launch-game.sh Game.Mod=ts` if you wish to try the experimental Tiberian Sun mod.
To compile OpenRA, run `make` from the command line (or `make RUNTIME=mono` if using Mono). After this one can run the game with `./launch-game.sh`. It is also possible to specify the mod you wish to run from the command line, e.g. with `./launch-game.sh Game.Mod=ts` if you wish to try the experimental Tiberian Sun mod.
Type `sudo make install` for system-wide installation. Run `sudo make install-linux-shortcuts` to get startup scripts, icons and desktop files. You can then run the Red Alert by executing the `openra-ra` command, the Dune 2000 mod by running the `openra-d2k` command and Tiberian Dawn by the `openra-cnc` command. Alternatively, you can also run these mods by clicking on their desktop shortcuts if you ran `sudo make install-linux-shortcuts`.
The default behaviour on the x86_64 architecture is to download several pre-compiled native libraries using the Nuget packaging manager. If you prefer to use system libraries, compile instead using `make TARGETPLATFORM=unix-generic`.
Arch Linux
----------
If you choose to use system libraries, or your system is not x86_64, you will need to install [SDL 2](https://www.libsdl.org/download-2.0.php), [FreeType](http://gnuwin32.sourceforge.net/packages/freetype.htm), [OpenAL](https://openal-soft.org/), and [liblua 5.1](http://luabinaries.sourceforge.net/download.html) before compiling OpenRA.
It is important to note there is an unofficial [`openra-git`](https://aur.archlinux.org/packages/openra-git) package in the Arch User Repository (AUR) of Arch Linux. If manually compiling is the way you wish to go the build and runtime dependencies can be installed with:
These can be installed using your package manager on various distros:
<details><summary>Arch Linux</summary>
```
sudo pacman -S mono openal libgl freetype2 sdl2 lua51 xdg-utils zenity
sudo pacman -S openal libgl freetype2 sdl2 lua51
```
Debian/Ubuntu
-------------
:warning: The `mono` packages in the Ubuntu < 19.04 and Debian < 10 repositories are too old to support OpenRA. :warning:
See the instructions under the *Linux* section above to upgrade `mono` using the upstream releases if needed.
</details>
<details><summary>Debian/Ubuntu</summary>
```
sudo apt install mono-devel libfreetype6 libopenal1 liblua5.1-0 libsdl2-2.0-0 xdg-utils zenity wget
sudo apt install libfreetype6 libopenal1 liblua5.1-0 libsdl2-2.0-0
```
Fedora
------
:warning: The `mono` packages in the Fedora repositories are too old to support OpenRA. :warning:
See the instructions under the *Linux* section above to upgrade `mono` using the upstream releases.
</details>
<details><summary>Fedora</summary>
```
sudo dnf install "pkgconfig(mono)" SDL2 freetype "lua = 5.1" openal-soft xdg-utils zenity
sudo dnf install SDL2 freetype "lua = 5.1" openal-soft
```
Gentoo
------
</details>
<details><summary>Gentoo</summary>
```
sudo emerge -av dev-lang/mono dev-dotnet/libgdiplus media-libs/freetype:2 media-libs/libsdl2 media-libs/openal virtual/jpeg virtual/opengl '=dev-lang/lua-5.1.5*' x11-misc/xdg-utils gnome-extra/zenity
sudo emerge -av media-libs/freetype:2 media-libs/libsdl2 media-libs/openal virtual/opengl '=dev-lang/lua-5.1.5*'
```
Mageia
------
</details>
<details><summary>Mageia</summary>
```
sudo dnf install "pkgconfig(mono)" SDL2 freetype "lib*lua5.1" "lib*freetype2" "lib*sdl2.0_0" openal-soft xdg-utils zenity
sudo dnf install SDL2 freetype "lib*lua5.1" "lib*freetype2" "lib*sdl2.0_0" openal-soft
```
openSUSE
--------
</details>
<details><summary>openSUSE</summary>
```
sudo zypper in mono-devel openal-soft freetype2 SDL2 lua51 xdg-utils zenity
sudo zypper in openal-soft freetype2 SDL2 lua51
```
Red Hat Enterprise Linux (and rebuilds, e.g. CentOS)
----------------------------------------------------
The EPEL repository is required in order for the following command to run properly.
</details>
<details><summary>Red Hat Enterprise Linux (and rebuilds, e.g. CentOS)</summary>
The EPEL repository is required in order for the following command to run properly.
```
sudo yum install "pkgconfig(mono)" SDL2 freetype "lua = 5.1" openal-soft xdg-utils zenity
sudo yum install SDL2 freetype "lua = 5.1" openal-soft
```
</details>
OSX
Type `sudo make install` for system-wide installation. Run `sudo make install-linux-shortcuts` to get startup scripts, icons and desktop files. You can then run the Red Alert by executing the `openra-ra` command, the Dune 2000 mod by running the `openra-d2k` command and Tiberian Dawn by the `openra-cnc` command. Alternatively, you can also run these mods by clicking on their desktop shortcuts if you ran `sudo make install-linux-shortcuts`.
macOS
=====
Before compiling OpenRA you must install the following dependencies:
* [Mono >= 5.4](https://www.mono-project.com/download/stable/#download-mac)
[.NET 6](https://dotnet.microsoft.com/download/dotnet/6.0) or [Mono](https://www.mono-project.com/download/stable/#download-mac) (version 6.4 or later) is required to compile OpenRA. We recommend using .NET 6 unless you are running a very old version of macOS (10.9 through 10.14).
Use `make dependencies` to download pre-compiled native libraries for:
* [SDL 2](http://www.libsdl.org/download-2.0.php)
* [FreeType](http://gnuwin32.sourceforge.net/packages/freetype.htm)
* [OpenAL](http://kcat.strangesoft.net/openal.html)
* [liblua 5.1](http://luabinaries.sourceforge.net/download.html)
To compile OpenRA, run `make` from the command line.
Run with `./launch-game.sh`.
To compile OpenRA, run `make` from the command line (or `make RUNTIME=mono` if using Mono). Run with `./launch-game.sh`.

438
Makefile
View File

@@ -1,57 +1,43 @@
############################# INSTRUCTIONS #############################
#
# to compile, run:
# make [DEBUG=true]
# make
#
# to compile using Mono (version 6.4 or greater) instead of .NET 6, run:
# make RUNTIME=mono
#
# to compile using system libraries for native dependencies, run:
# make [RUNTIME=net6] TARGETPLATFORM=unix-generic
#
# to check unit tests (requires NUnit version >= 2.6), run:
# make nunit [NUNIT_CONSOLE=<path-to/nunit[2]-console>] [NUNIT_LIBS_PATH=<path-to-libs-dir>] [NUNIT_LIBS=<nunit-libs>]
# Use NUNIT_CONSOLE if nunit[3|2]-console was not downloaded by `make dependencies` nor is it in bin search paths
# Use NUNIT_LIBS_PATH if NUnit libs are not in search paths. Include trailing /
# Use NUNIT_LIBS if NUnit libs have different names (such as including a prefix or suffix)
# to check the official mods for erroneous yaml files, run:
# make test
# make [RUNTIME=net6] test
#
# to check the official mod dlls for StyleCop violations, run:
# make check
# to check the engine and official mod dlls for code style violations, run:
# make [RUNTIME=net6] check
#
# to install, run:
# make [prefix=/foo] [bindir=/bar/bin] install
# to compile and install Red Alert, Tiberian Dawn, and Dune 2000, run:
# make [RUNTIME=net6] [prefix=/foo] [bindir=/bar/bin] install
#
# to install Linux startup scripts, desktop files and icons:
# make install-linux-shortcuts [DEBUG=false]
# to compile and install Red Alert, Tiberian Dawn, and Dune 2000
# using system libraries for native dependencies, run:
# make [prefix=/foo] [bindir=/bar/bin] TARGETPLATFORM=unix-generic install
#
# to install the engine and common mod files (omitting the default mods):
# make install-engine
# make install-common-mod-files
# to install FreeDesktop startup scripts, desktop files, icons, and MIME metadata
# make install-linux-shortcuts
#
# to uninstall, run:
# make uninstall
# to install FreeDesktop AppStream metadata
# make install-linux-appdata
#
# to install the Unix man page
# make install-man
#
# for help, run:
# make help
#
# to start the game, run:
# openra
############################## TOOLCHAIN ###############################
#
# List of .NET assemblies that we can guarantee exist
# OpenRA.Game.dll is a harmless false positive that we can ignore
WHITELISTED_OPENRA_ASSEMBLIES = OpenRA.Game.exe OpenRA.Utility.exe OpenRA.Platforms.Default.dll OpenRA.Mods.Common.dll OpenRA.Mods.Cnc.dll OpenRA.Mods.D2k.dll OpenRA.Game.dll
# These are explicitly shipped alongside our core files by the packaging script
WHITELISTED_THIRDPARTY_ASSEMBLIES = ICSharpCode.SharpZipLib.dll FuzzyLogicLibrary.dll MaxMind.Db.dll Eluant.dll rix0rrr.BeaconLib.dll Open.Nat.dll SDL2-CS.dll OpenAL-CS.dll
# These are shipped in our custom minimal mono runtime and also available in the full system-installed .NET/mono stack
# This list *must* be kept in sync with the files packaged by the AppImageSupport and OpenRALauncherOSX repositories
WHITELISTED_CORE_ASSEMBLIES = mscorlib.dll System.dll System.Configuration.dll System.Core.dll System.Numerics.dll System.Security.dll System.Xml.dll Mono.Security.dll
NUNIT_LIBS_PATH :=
NUNIT_LIBS := $(NUNIT_LIBS_PATH)nunit.framework.dll
######################### UTILITIES/SETTINGS ###########################
#
# install locations
# Install locations for local installs and downstream packaging
prefix ?= /usr/local
datarootdir ?= $(prefix)/share
datadir ?= $(datarootdir)
@@ -60,321 +46,151 @@ bindir ?= $(prefix)/bin
libdir ?= $(prefix)/lib
gameinstalldir ?= $(libdir)/openra
BIN_INSTALL_DIR = $(DESTDIR)$(bindir)
DATA_INSTALL_DIR = $(DESTDIR)$(gameinstalldir)
# install tools
# Toolchain
CWD = $(shell pwd)
MSBUILD = msbuild -verbosity:m -nologo
DOTNET = dotnet
MONO = mono
RM = rm
RM_R = $(RM) -r
RM_F = $(RM) -f
RM_RF = $(RM) -rf
CP = cp
CP_R = $(CP) -r
INSTALL = install
INSTALL_DIR = $(INSTALL) -d
INSTALL_PROGRAM = $(INSTALL) -m755
INSTALL_DATA = $(INSTALL) -m644
# Toolchain
MSBUILD = msbuild -verbosity:m -nologo
RUNTIME ?= net6
CONFIGURATION ?= Release
# Enable 32 bit builds while generating the windows installer
WIN32 = false
# Only for use in target version:
VERSION := $(shell git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || (c=$$(git rev-parse --short HEAD 2>/dev/null) && echo git-$$c))
# program targets
VERSION = $(shell git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || echo git-`git rev-parse --short HEAD`)
# dependencies
# Detect target platform for dependencies if not given by the user
ifndef TARGETPLATFORM
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_S),Darwin)
os-dependencies = osx-dependencies
TARGETPLATFORM = osx-x64
else
os-dependencies = linux-dependencies
ifeq ($(UNAME_M),x86_64)
TARGETPLATFORM = linux-x64
else
TARGETPLATFORM = unix-generic
endif
endif
endif
##################### DEVELOPMENT BUILDS AND TESTS #####################
#
all:
@echo "Compiling in ${CONFIGURATION} mode..."
ifeq ($(RUNTIME), mono)
@command -v $(firstword $(MSBUILD)) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 6.4."; exit 1)
@$(MSBUILD) -t:Build -restore -p:Configuration=${CONFIGURATION} -p:TargetPlatform=$(TARGETPLATFORM)
else
@$(DOTNET) build -c ${CONFIGURATION} -nologo -p:TargetPlatform=$(TARGETPLATFORM)
endif
ifeq ($(TARGETPLATFORM), unix-generic)
@./configure-system-libraries.sh
endif
@./fetch-geoip.sh
# dotnet clean and msbuild -t:Clean leave files that cause problems when switching between mono/dotnet
# Deleting the intermediate / output directories ensures the build directory is actually clean
clean:
@-$(RM_RF) ./bin ./*/obj
@-$(RM_F) IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP
check:
@echo
@echo "Compiling in Debug mode..."
ifeq ($(RUNTIME), mono)
# Enabling EnforceCodeStyleInBuild and GenerateDocumentationFile as a workaround for some code style rules (in particular IDE0005) being bugged and not reporting warnings/errors otherwise.
@$(MSBUILD) -t:build -restore -p:Configuration=Debug -warnaserror -p:TargetPlatform=$(TARGETPLATFORM) -p:EnforceCodeStyleInBuild=true -p:GenerateDocumentationFile=true
else
# Enabling EnforceCodeStyleInBuild and GenerateDocumentationFile as a workaround for some code style rules (in particular IDE0005) being bugged and not reporting warnings/errors otherwise.
@$(DOTNET) build -c Debug -nologo -warnaserror -p:TargetPlatform=$(TARGETPLATFORM) -p:EnforceCodeStyleInBuild=true -p:GenerateDocumentationFile=true
endif
ifeq ($(TARGETPLATFORM), unix-generic)
@./configure-system-libraries.sh
endif
@echo
@echo "Checking for explicit interface violations..."
@./utility.sh all --check-explicit-interfaces
@echo
@echo "Checking for incorrect conditional trait interface overrides..."
@./utility.sh all --check-conditional-trait-interface-overrides
check-scripts:
@echo
@echo "Checking for Lua syntax errors..."
@luac -p $(shell find mods/*/maps/* -iname '*.lua')
@luac -p $(shell find lua/* -iname '*.lua')
@find lua/ mods/*/{maps,scripts}/ -iname "*.lua" -print0 | xargs -0n1 luac -p
check: dependencies
@echo
@echo "Compiling in debug mode..."
@$(MSBUILD) -t:build -p:Configuration=Debug
@echo
@echo "Checking runtime assemblies..."
@mono --debug OpenRA.Utility.exe all --check-runtime-assemblies $(WHITELISTED_OPENRA_ASSEMBLIES) $(WHITELISTED_THIRDPARTY_ASSEMBLIES) $(WHITELISTED_CORE_ASSEMBLIES)
@echo
@echo "Checking for explicit interface violations..."
@mono --debug OpenRA.Utility.exe all --check-explicit-interfaces
@echo
@echo "Checking for incorrect conditional trait interface overrides..."
@mono --debug OpenRA.Utility.exe all --check-conditional-trait-interface-overrides
NUNIT_CONSOLE := $(shell test -f thirdparty/download/nunit3-console.exe && echo mono thirdparty/download/nunit3-console.exe || \
which nunit3-console 2>/dev/null || which nunit2-console 2>/dev/null || which nunit-console 2>/dev/null)
nunit: core
@echo
@echo "Checking unit tests..."
@if [ "$(NUNIT_CONSOLE)" = "" ] ; then \
echo 'nunit[3|2]-console not found!'; \
echo 'Was "make dependencies" called or is NUnit installed?'>&2; \
echo 'See "make help".'; \
exit 1; \
fi
@if $(NUNIT_CONSOLE) --help | head -n 1 | grep -E "NUnit version (1|2\.[0-5])";then \
echo 'NUnit version >= 2.6 required'>&2; \
echo 'Try "make dependencies" first to use NUnit from NuGet.'>&2; \
echo 'See "make help".'; \
exit 1; \
fi
@$(NUNIT_CONSOLE) --noresult OpenRA.Test.nunit
test: core
test: all
@echo
@echo "Testing Tiberian Sun mod MiniYAML..."
@mono --debug OpenRA.Utility.exe ts --check-yaml
@./utility.sh ts --check-yaml
@echo
@echo "Testing Dune 2000 mod MiniYAML..."
@mono --debug OpenRA.Utility.exe d2k --check-yaml
@./utility.sh d2k --check-yaml
@echo
@echo "Testing Tiberian Dawn mod MiniYAML..."
@mono --debug OpenRA.Utility.exe cnc --check-yaml
@./utility.sh cnc --check-yaml
@echo
@echo "Testing Red Alert mod MiniYAML..."
@mono --debug OpenRA.Utility.exe ra --check-yaml
@./utility.sh ra --check-yaml
########################## MAKE/INSTALL RULES ##########################
############# LOCAL INSTALLATION AND DOWNSTREAM PACKAGING ##############
#
all: dependencies core
core:
@command -v $(firstword $(MSBUILD)) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 5.4."; exit 1)
ifeq ($(WIN32), $(filter $(WIN32),true yes y on 1))
@$(MSBUILD) -t:build -p:Configuration="Release-x86"
else
@$(MSBUILD) -t:build -p:Configuration=Release
endif
clean:
@ $(MSBUILD) -t:clean
@-$(RM_F) *.config
@-$(RM_F) *.exe *.dll *.dylib ./OpenRA*/*.dll *.pdb mods/**/*.dll mods/**/*.pdb *.resources
@-$(RM_RF) ./*/bin ./*/obj
@-$(RM_RF) ./thirdparty/download
distclean: clean
cli-dependencies:
@./thirdparty/fetch-thirdparty-deps.sh
@ $(CP_R) thirdparty/download/*.dll .
@ $(CP_R) thirdparty/download/*.dll.config .
@ test -f OpenRA.Game/obj/project.assets.json || $(MSBUILD) -t:restore
linux-dependencies: cli-dependencies linux-native-dependencies
linux-native-dependencies:
@./thirdparty/configure-native-deps.sh
windows-dependencies: cli-dependencies
ifeq ($(WIN32), $(filter $(WIN32),true yes y on 1))
@./thirdparty/fetch-thirdparty-deps-windows.sh x86
else
@./thirdparty/fetch-thirdparty-deps-windows.sh x64
endif
osx-dependencies: cli-dependencies
@./thirdparty/fetch-thirdparty-deps-osx.sh
@ $(CP_R) thirdparty/download/osx/*.dylib .
@ $(CP_R) thirdparty/download/osx/*.dll.config .
dependencies: $(os-dependencies)
all-dependencies: cli-dependencies windows-dependencies osx-dependencies
version: VERSION mods/ra/mod.yaml mods/cnc/mod.yaml mods/d2k/mod.yaml mods/ts/mod.yaml mods/modcontent/mod.yaml mods/all/mod.yaml
@echo "$(VERSION)" > VERSION
@for i in $? ; do \
awk '{sub("Version:.*$$","Version: $(VERSION)"); print $0}' $${i} > $${i}.tmp && \
awk '{sub("/[^/]*: User$$", "/$(VERSION): User"); print $0}' $${i}.tmp > $${i} && \
rm $${i}.tmp; \
done
ifeq ($(VERSION),)
$(error Unable to determine new version (requires git or override of variable VERSION))
endif
@sh -c '. ./packaging/functions.sh; set_engine_version "$(VERSION)" .'
@sh -c '. ./packaging/functions.sh; set_mod_version "$(VERSION)" mods/ra/mod.yaml mods/cnc/mod.yaml mods/d2k/mod.yaml mods/ts/mod.yaml mods/modcontent/mod.yaml mods/all/mod.yaml'
install: dependencies core install-core
install:
@sh -c '. ./packaging/functions.sh; install_assemblies $(CWD) $(DESTDIR)$(gameinstalldir) $(TARGETPLATFORM) $(RUNTIME) True True True'
@sh -c '. ./packaging/functions.sh; install_data $(CWD) $(DESTDIR)$(gameinstalldir) cnc d2k ra'
install-linux-shortcuts: install-linux-scripts install-linux-icons install-linux-desktop
install-engine:
@-echo "Installing OpenRA engine to $(DATA_INSTALL_DIR)"
@$(INSTALL_DIR) "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) OpenRA.Game.exe "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) OpenRA.Server.exe "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) OpenRA.Utility.exe "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) OpenRA.Platforms.Default.dll "$(DATA_INSTALL_DIR)"
@$(INSTALL_DATA) OpenRA.Platforms.Default.dll.config "$(DATA_INSTALL_DIR)"
@$(INSTALL_DATA) VERSION "$(DATA_INSTALL_DIR)/VERSION"
@$(INSTALL_DATA) AUTHORS "$(DATA_INSTALL_DIR)/AUTHORS"
@$(INSTALL_DATA) COPYING "$(DATA_INSTALL_DIR)/COPYING"
@$(CP_R) glsl "$(DATA_INSTALL_DIR)"
@$(CP_R) lua "$(DATA_INSTALL_DIR)"
@$(CP) SDL2-CS* "$(DATA_INSTALL_DIR)"
@$(CP) OpenAL-CS* "$(DATA_INSTALL_DIR)"
@$(CP) Eluant* "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) ICSharpCode.SharpZipLib.dll "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) FuzzyLogicLibrary.dll "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) Open.Nat.dll "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) MaxMind.Db.dll "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) rix0rrr.BeaconLib.dll "$(DATA_INSTALL_DIR)"
install-common-mod-files:
@-echo "Installing OpenRA common mod files to $(DATA_INSTALL_DIR)"
@$(INSTALL_DIR) "$(DATA_INSTALL_DIR)/mods"
@$(CP_R) mods/common "$(DATA_INSTALL_DIR)/mods/"
@$(INSTALL_PROGRAM) mods/common/OpenRA.Mods.Common.dll "$(DATA_INSTALL_DIR)/mods/common"
@$(INSTALL_PROGRAM) mods/common/OpenRA.Mods.Cnc.dll "$(DATA_INSTALL_DIR)/mods/common"
@$(INSTALL_DATA) "global mix database.dat" "$(DATA_INSTALL_DIR)/global mix database.dat"
install-default-mods:
@-echo "Installing OpenRA default mods to $(DATA_INSTALL_DIR)"
@$(INSTALL_DIR) "$(DATA_INSTALL_DIR)/mods"
@$(CP_R) mods/cnc "$(DATA_INSTALL_DIR)/mods/"
@$(CP_R) mods/ra "$(DATA_INSTALL_DIR)/mods/"
@$(CP_R) mods/d2k "$(DATA_INSTALL_DIR)/mods/"
@$(INSTALL_PROGRAM) mods/d2k/OpenRA.Mods.D2k.dll "$(DATA_INSTALL_DIR)/mods/d2k"
@$(CP_R) mods/modcontent "$(DATA_INSTALL_DIR)/mods/"
install-core: install-engine install-common-mod-files install-default-mods
@$(CP) *.sh "$(DATA_INSTALL_DIR)"
install-linux-icons:
for SIZE in 16x16 32x32 48x48 64x64 128x128; do \
$(INSTALL_DIR) "$(DESTDIR)$(datadir)/icons/hicolor/$$SIZE/apps"; \
$(INSTALL_DATA) packaging/linux/icons/ra_$$SIZE.png "$(DESTDIR)$(datadir)/icons/hicolor/$$SIZE/apps/openra-ra.png"; \
$(INSTALL_DATA) packaging/linux/icons/cnc_$$SIZE.png "$(DESTDIR)$(datadir)/icons/hicolor/$$SIZE/apps/openra-cnc.png"; \
$(INSTALL_DATA) packaging/linux/icons/d2k_$$SIZE.png "$(DESTDIR)$(datadir)/icons/hicolor/$$SIZE/apps/openra-d2k.png"; \
done
$(INSTALL_DIR) "$(DESTDIR)$(datadir)/icons/hicolor/scalable/apps"
$(INSTALL_DATA) packaging/linux/icons/ra_scalable.svg "$(DESTDIR)$(datadir)/icons/hicolor/scalable/apps/openra-ra.svg"
$(INSTALL_DATA) packaging/linux/icons/cnc_scalable.svg "$(DESTDIR)$(datadir)/icons/hicolor/scalable/apps/openra-cnc.svg"
install-linux-desktop:
@$(INSTALL_DIR) "$(DESTDIR)$(datadir)/applications"
@sed 's/{MODID}/ra/g' packaging/linux/openra.desktop.in | sed 's/{MODNAME}/Red Alert/g' | sed 's/{TAG}/$(VERSION)/g' > packaging/linux/openra-ra.desktop
@$(INSTALL_DATA) packaging/linux/openra-ra.desktop "$(DESTDIR)$(datadir)/applications"
@sed 's/{MODID}/cnc/g' packaging/linux/openra.desktop.in | sed 's/{MODNAME}/Tiberian Dawn/g' | sed 's/{TAG}/$(VERSION)/g' > packaging/linux/openra-cnc.desktop
@$(INSTALL_DATA) packaging/linux/openra-cnc.desktop "$(DESTDIR)$(datadir)/applications"
@sed 's/{MODID}/d2k/g' packaging/linux/openra.desktop.in | sed 's/{MODNAME}/Dune 2000/g' | sed 's/{TAG}/$(VERSION)/g' > packaging/linux/openra-d2k.desktop
@$(INSTALL_DATA) packaging/linux/openra-d2k.desktop "$(DESTDIR)$(datadir)/applications"
@-$(RM) packaging/linux/openra-ra.desktop packaging/linux/openra-cnc.desktop packaging/linux/openra-d2k.desktop
install-linux-mime:
@$(INSTALL_DIR) "$(DESTDIR)$(datadir)/mime/packages/"
@sed 's/{MODID}/ra/g' packaging/linux/openra-mimeinfo.xml.in | sed 's/{TAG}/$(VERSION)/g' > packaging/linux/openra-mimeinfo.xml
@$(INSTALL_DATA) packaging/linux/openra-mimeinfo.xml "$(DESTDIR)$(datadir)/mime/packages/openra-ra.xml"
@sed 's/{MODID}/cnc/g' packaging/linux/openra-mimeinfo.xml.in | sed 's/{TAG}/$(VERSION)/g' > packaging/linux/openra-mimeinfo.xml
@$(INSTALL_DATA) packaging/linux/openra-mimeinfo.xml "$(DESTDIR)$(datadir)/mime/packages/openra-cnc.xml"
@sed 's/{MODID}/d2k/g' packaging/linux/openra-mimeinfo.xml.in | sed 's/{TAG}/$(VERSION)/g' > packaging/linux/openra-mimeinfo.xml
@$(INSTALL_DATA) packaging/linux/openra-mimeinfo.xml "$(DESTDIR)$(datadir)/mime/packages/openra-d2k.xml"
install-linux-shortcuts:
@sh -c '. ./packaging/functions.sh; install_linux_shortcuts $(CWD) "$(DESTDIR)" "$(gameinstalldir)" "$(bindir)" "$(datadir)" "$(shell head -n1 VERSION)" cnc d2k ra'
install-linux-appdata:
@$(INSTALL_DIR) "$(DESTDIR)$(datadir)/appdata/"
@sed 's/{MODID}/ra/g' packaging/linux/openra.appdata.xml.in | sed 's/{MOD_NAME}/Red Alert/g' | sed 's/{SCREENSHOT_RA}/ type="default"/g' | sed 's/{SCREENSHOT_CNC}//g' | sed 's/{SCREENSHOT_D2K}//g'> packaging/linux/openra-ra.appdata.xml
@$(INSTALL_DATA) packaging/linux/openra-ra.appdata.xml "$(DESTDIR)$(datadir)/appdata/"
@sed 's/{MODID}/cnc/g' packaging/linux/openra.appdata.xml.in | sed 's/{MOD_NAME}/Tiberian Dawn/g' | sed 's/{SCREENSHOT_RA}//g' | sed 's/{SCREENSHOT_CNC}/ type="default"/g' | sed 's/{SCREENSHOT_D2K}//g'> packaging/linux/openra-cnc.appdata.xml
@$(INSTALL_DATA) packaging/linux/openra-cnc.appdata.xml "$(DESTDIR)$(datadir)/appdata/"
@sed 's/{MODID}/d2k/g' packaging/linux/openra.appdata.xml.in | sed 's/{MOD_NAME}/Dune 2000/g' | sed 's/{SCREENSHOT_RA}//g' | sed 's/{SCREENSHOT_CNC}//g' | sed 's/{SCREENSHOT_D2K}/ type="default"/g'> packaging/linux/openra-d2k.appdata.xml
@$(INSTALL_DATA) packaging/linux/openra-d2k.appdata.xml "$(DESTDIR)$(datadir)/appdata/"
@-$(RM) packaging/linux/openra-ra.appdata.xml packaging/linux/openra-cnc.appdata.xml packaging/linux/openra-d2k.appdata.xml
@sh -c '. ./packaging/functions.sh; install_linux_appdata $(CWD) "$(DESTDIR)" "$(datadir)" cnc d2k ra'
install-man-page:
@$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man6/"
@mono --debug OpenRA.Utility.exe all --man-page > openra.6
@$(INSTALL_DATA) openra.6 "$(DESTDIR)$(mandir)/man6/"
@-$(RM) openra.6
install-linux-scripts:
ifeq ($(DEBUG), $(filter $(DEBUG),false no n off 0))
@sed 's/{DEBUG}//' packaging/linux/openra.in | sed 's|{GAME_INSTALL_DIR}|$(gameinstalldir)|' | sed 's|{BIN_DIR}|$(bindir)|' > packaging/linux/openra.debug.in
@sed 's/{DEBUG}//' packaging/linux/openra-server.in | sed 's|{GAME_INSTALL_DIR}|$(gameinstalldir)|' | sed 's|{BIN_DIR}|$(bindir)|' > packaging/linux/openra-server.debug.in
else
@sed 's/{DEBUG}/--debug/' packaging/linux/openra.in | sed 's|{GAME_INSTALL_DIR}|$(gameinstalldir)|' | sed 's|{BIN_DIR}|$(bindir)|' > packaging/linux/openra.debug.in
@sed 's/{DEBUG}/--debug/' packaging/linux/openra-server.in | sed 's|{GAME_INSTALL_DIR}|$(gameinstalldir)|' | sed 's|{BIN_DIR}|$(bindir)|' > packaging/linux/openra-server.debug.in
endif
@sed 's/{MODID}/ra/g' packaging/linux/openra.debug.in | sed 's/{TAG}/$(VERSION)/g' | sed 's/{MODNAME}/Red Alert/g' > packaging/linux/openra-ra
@sed 's/{MODID}/cnc/g' packaging/linux/openra.debug.in | sed 's/{TAG}/$(VERSION)/g' | sed 's/{MODNAME}/Tiberian Dawn/g' > packaging/linux/openra-cnc
@sed 's/{MODID}/d2k/g' packaging/linux/openra.debug.in | sed 's/{TAG}/$(VERSION)/g' | sed 's/{MODNAME}/Dune 2000/g' > packaging/linux/openra-d2k
@$(INSTALL_DIR) "$(BIN_INSTALL_DIR)"
@$(INSTALL_PROGRAM) -m +rx packaging/linux/openra-ra "$(BIN_INSTALL_DIR)"
@$(INSTALL_PROGRAM) -m +rx packaging/linux/openra-cnc "$(BIN_INSTALL_DIR)"
@$(INSTALL_PROGRAM) -m +rx packaging/linux/openra-d2k "$(BIN_INSTALL_DIR)"
@-$(RM) packaging/linux/openra-ra packaging/linux/openra-cnc packaging/linux/openra-d2k packaging/linux/openra.debug.in
@sed 's/{MODID}/ra/g' packaging/linux/openra-server.debug.in | sed 's/{MODNAME}/Red Alert/g' > packaging/linux/openra-ra-server
@sed 's/{MODID}/cnc/g' packaging/linux/openra-server.debug.in | sed 's/{MODNAME}/Tiberian Dawn/g' > packaging/linux/openra-cnc-server
@sed 's/{MODID}/d2k/g' packaging/linux/openra-server.debug.in | sed 's/{MODNAME}/Dune 2000/g' > packaging/linux/openra-d2k-server
@$(INSTALL_DIR) "$(BIN_INSTALL_DIR)"
@$(INSTALL_PROGRAM) -m +rx packaging/linux/openra-ra-server "$(BIN_INSTALL_DIR)"
@$(INSTALL_PROGRAM) -m +rx packaging/linux/openra-cnc-server "$(BIN_INSTALL_DIR)"
@$(INSTALL_PROGRAM) -m +rx packaging/linux/openra-d2k-server "$(BIN_INSTALL_DIR)"
@-$(RM) packaging/linux/openra-ra-server packaging/linux/openra-cnc-server packaging/linux/openra-d2k-server packaging/linux/openra-server.debug.in
uninstall:
@-$(RM_R) "$(DATA_INSTALL_DIR)"
@-$(RM_F) "$(BIN_INSTALL_DIR)/openra-ra"
@-$(RM_F) "$(BIN_INSTALL_DIR)/openra-ra-server"
@-$(RM_F) "$(BIN_INSTALL_DIR)/openra-cnc"
@-$(RM_F) "$(BIN_INSTALL_DIR)/openra-cnc-server"
@-$(RM_F) "$(BIN_INSTALL_DIR)/openra-d2k"
@-$(RM_F) "$(BIN_INSTALL_DIR)/openra-d2k-server"
@-$(RM_F) "$(DESTDIR)$(datadir)/applications/openra-ra.desktop"
@-$(RM_F) "$(DESTDIR)$(datadir)/applications/openra-cnc.desktop"
@-$(RM_F) "$(DESTDIR)$(datadir)/applications/openra-d2k.desktop"
@-for SIZE in 16x16 32x32 48x48 64x64 128x128; do \
$(RM_F) "$(DESTDIR)$(datadir)/icons/hicolor/$$SIZE/apps/openra-ra.png"; \
$(RM_F) "$(DESTDIR)$(datadir)/icons/hicolor/$$SIZE/apps/openra-cnc.png"; \
$(RM_F) "$(DESTDIR)$(datadir)/icons/hicolor/$$SIZE/apps/openra-d2k.png"; \
done
@-$(RM_F) "$(DESTDIR)$(datadir)/icons/hicolor/scalable/apps/openra-ra.svg"
@-$(RM_F) "$(DESTDIR)$(datadir)/icons/hicolor/scalable/apps/openra-cnc.svg"
@-$(RM_F) "$(DESTDIR)$(datadir)/mime/packages/openra-ra.xml"
@-$(RM_F) "$(DESTDIR)$(datadir)/mime/packages/openra-cnc.xml"
@-$(RM_F) "$(DESTDIR)$(datadir)/mime/packages/openra-d2k.xml"
@-$(RM_F) "$(DESTDIR)$(datadir)/appdata/openra-ra.appdata.xml"
@-$(RM_F) "$(DESTDIR)$(datadir)/appdata/openra-cnc.appdata.xml"
@-$(RM_F) "$(DESTDIR)$(datadir)/appdata/openra-d2k.appdata.xml"
@-$(RM_F) "$(DESTDIR)$(mandir)/man6/openra.6"
install-man: all
@mkdir -p $(DESTDIR)$(mandir)/man6/
@./utility.sh all --man-page > $(DESTDIR)$(mandir)/man6/openra.6
help:
@echo 'to compile, run:'
@echo ' make [DEBUG=false]'
@echo ' make'
@echo
@echo 'to check unit tests (requires NUnit version >= 2.6), run:'
@echo ' make nunit [NUNIT_CONSOLE=<path-to/nunit[3|2]-console>] [NUNIT_LIBS_PATH=<path-to-libs-dir>] [NUNIT_LIBS=<nunit-libs>]'
@echo ' Use NUNIT_CONSOLE if nunit[3|2]-console was not downloaded by `make dependencies` nor is it in bin search paths'
@echo ' Use NUNIT_LIBS_PATH if NUnit libs are not in search paths. Include trailing /'
@echo ' Use NUNIT_LIBS if NUnit libs have different names (such as including a prefix or suffix)'
@echo 'to compile using Mono (version 6.4 or greater) instead of .NET 6, run:'
@echo ' make RUNTIME=mono'
@echo
@echo 'to compile using system libraries for native dependencies, run:'
@echo ' make [RUNTIME=net6] TARGETPLATFORM=unix-generic'
@echo
@echo 'to check the official mods for erroneous yaml files, run:'
@echo ' make test'
@echo ' make [RUNTIME=net6] test'
@echo
@echo 'to install, run:'
@echo ' make [prefix=/foo] [bindir=/bar/bin] install'
@echo 'to check the engine and official mod dlls for code style violations, run:'
@echo ' make [RUNTIME=net6] check'
@echo
@echo 'to install Linux startup scripts, desktop files and icons'
@echo ' make install-linux-shortcuts [DEBUG=false]'
@echo 'to compile and install Red Alert, Tiberian Dawn, and Dune 2000 run:'
@echo ' make [RUNTIME=net6] [prefix=/foo] [TARGETPLATFORM=unix-generic] install'
@echo
@echo 'to uninstall, run:'
@echo ' make uninstall'
@echo 'to compile and install Red Alert, Tiberian Dawn, and Dune 2000'
@echo 'using system libraries for native dependencies, run:'
@echo ' make [RUNTIME=net6] [prefix=/foo] [bindir=/bar/bin] TARGETPLATFORM=unix-generic install'
@echo
@echo 'to start the game, run:'
@echo ' openra'
@echo 'to install FreeDesktop startup scripts, desktop files, icons, and MIME metadata'
@echo ' make install-linux-shortcuts'
@echo
@echo 'to install FreeDesktop AppStream metadata'
@echo ' make install-linux-appdata'
@echo
@echo 'to install a Unix man page'
@echo ' make install-man'
########################### MAKEFILE SETTINGS ##########################
#
@@ -382,4 +198,4 @@ help:
.SUFFIXES:
.PHONY: check-scripts check nunit test all core clean distclean cli-dependencies linux-dependencies linux-native-dependencies windows-dependencies osx-dependencies dependencies all-dependencies version install install-linux-shortcuts install-engine install-common-mod-files install-default-mods install-core install-linux-icons install-linux-desktop install-linux-mime install-linux-appdata install-man-page install-linux-scripts uninstall help
.PHONY: all clean check check-scripts test version install install-linux-shortcuts install-linux-appdata install-man help

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -26,7 +26,7 @@ namespace OpenRA.Activities
public readonly Color Color;
public readonly Sprite Tile;
public TargetLineNode(Target target, Color color, Sprite tile = null)
public TargetLineNode(in Target target, Color color, Sprite tile = null)
{
// Note: Not all activities are drawable. In that case, pass Target.Invalid as target,
// if "yield break" in TargetLineNode(Actor self) is not feasible.
@@ -53,15 +53,15 @@ namespace OpenRA.Activities
Activity childActivity;
protected Activity ChildActivity
{
get { return SkipDoneActivities(childActivity); }
private set { childActivity = value; }
get => SkipDoneActivities(childActivity);
private set => childActivity = value;
}
Activity nextActivity;
public Activity NextActivity
{
get { return SkipDoneActivities(nextActivity); }
private set { nextActivity = value; }
get => SkipDoneActivities(nextActivity);
private set => nextActivity = value;
}
internal static Activity SkipDoneActivities(Activity first)
@@ -74,14 +74,14 @@ namespace OpenRA.Activities
// drop valid activities queued after it. Walk the queue until we find a valid activity or
// (more likely) run out of activities.
while (first != null && first.State == ActivityState.Done)
first = first.NextActivity;
first = first.nextActivity;
return first;
}
public bool IsInterruptible { get; protected set; }
public bool ChildHasPriority { get; protected set; }
public bool IsCanceling { get { return State == ActivityState.Canceling; } }
public bool IsCanceling => State == ActivityState.Canceling;
bool finishing;
bool firstRunCompleted;
bool lastRun;
@@ -95,7 +95,7 @@ namespace OpenRA.Activities
public Activity TickOuter(Actor self)
{
if (State == ActivityState.Done)
throw new InvalidOperationException("Actor {0} attempted to tick activity {1} after it had already completed.".F(self, GetType()));
throw new InvalidOperationException($"Actor {self} attempted to tick activity {GetType()} after it had already completed.");
if (State == ActivityState.Queued)
{
@@ -105,7 +105,7 @@ namespace OpenRA.Activities
}
if (!firstRunCompleted)
throw new InvalidOperationException("Actor {0} attempted to tick activity {1} before running its OnFirstRun method.".F(self, GetType()));
throw new InvalidOperationException($"Actor {self} attempted to tick activity {GetType()} before running its OnFirstRun method.");
// Only run the parent tick when the child is done.
// We must always let the child finish on its own before continuing.
@@ -120,7 +120,8 @@ namespace OpenRA.Activities
lastRun = Tick(self);
// Avoid a single tick delay if the childactivity was just queued.
if (ChildActivity != null && ChildActivity.State == ActivityState.Queued)
var ca = ChildActivity;
if (ca != null && ca.State == ActivityState.Queued)
{
if (ChildHasPriority)
lastRun = TickChild(self) && finishing;
@@ -185,8 +186,7 @@ namespace OpenRA.Activities
/// </summary>
internal void OnActorDisposeOuter(Actor self)
{
if (ChildActivity != null)
ChildActivity.OnActorDisposeOuter(self);
ChildActivity?.OnActorDisposeOuter(self);
OnActorDispose(self);
}
@@ -199,8 +199,7 @@ namespace OpenRA.Activities
if (!IsInterruptible)
return;
if (ChildActivity != null)
ChildActivity.Cancel(self);
ChildActivity?.Cancel(self);
// Directly mark activities that are queued and therefore didn't run yet as done
State = State == ActivityState.Queued ? ActivityState.Done : ActivityState.Canceling;
@@ -208,18 +207,18 @@ namespace OpenRA.Activities
public void Queue(Activity activity)
{
if (NextActivity != null)
NextActivity.Queue(activity);
else
NextActivity = activity;
var it = this;
while (it.nextActivity != null)
it = it.nextActivity;
it.nextActivity = activity;
}
public void QueueChild(Activity activity)
{
if (ChildActivity != null)
ChildActivity.Queue(activity);
if (childActivity != null)
childActivity.Queue(activity);
else
ChildActivity = activity;
childActivity = activity;
}
/// <summary>
@@ -243,11 +242,9 @@ namespace OpenRA.Activities
Console.WriteLine(GetType().ToString().Split('.').Last());
if (ChildActivity != null)
ChildActivity.PrintActivityTree(self, origin, level + 1);
ChildActivity?.PrintActivityTree(self, origin, level + 1);
if (NextActivity != null)
NextActivity.PrintActivityTree(self, origin, level);
NextActivity?.PrintActivityTree(self, origin, level);
}
}
@@ -273,15 +270,21 @@ namespace OpenRA.Activities
public IEnumerable<T> ActivitiesImplementing<T>(bool includeChildren = true) where T : IActivityInterface
{
if (includeChildren && ChildActivity != null)
foreach (var a in ChildActivity.ActivitiesImplementing<T>())
yield return a;
// Skips Done child and next activities
if (includeChildren)
{
var ca = ChildActivity;
if (ca != null)
foreach (var a in ca.ActivitiesImplementing<T>())
yield return a;
}
if (this is T)
yield return (T)(object)this;
if (NextActivity != null)
foreach (var a in NextActivity.ActivitiesImplementing<T>())
var na = NextActivity;
if (na != null)
foreach (var a in na.ActivitiesImplementing<T>())
yield return a;
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -22,11 +22,11 @@ namespace OpenRA.Activities
IsInterruptible = interruptible;
}
Action a;
readonly Action a;
public override bool Tick(Actor self)
{
if (a != null) a();
a.Invoke();
return true;
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -11,6 +11,8 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using Eluant;
using Eluant.ObjectBinding;
@@ -22,9 +24,18 @@ using OpenRA.Traits;
namespace OpenRA
{
[Flags]
public enum SystemActors
{
Player = 0,
EditorPlayer = 1,
World = 2,
EditorWorld = 4
}
public sealed class Actor : IScriptBindable, IScriptNotifyBind, ILuaTableBinding, ILuaEqualityBinding, ILuaToStringBinding, IEquatable<Actor>, IDisposable
{
internal struct SyncHash
internal readonly struct SyncHash
{
public readonly ISync Trait;
readonly Func<object, int> hashFunction;
@@ -47,37 +58,56 @@ namespace OpenRA
Activity currentActivity;
public Activity CurrentActivity
{
get { return Activity.SkipDoneActivities(currentActivity); }
private set { currentActivity = value; }
get => Activity.SkipDoneActivities(currentActivity);
private set => currentActivity = value;
}
public int Generation;
public Actor ReplacedByActor;
public IEffectiveOwner EffectiveOwner { get; private set; }
public IOccupySpace OccupiesSpace { get; private set; }
public ITargetable[] Targetables { get; private set; }
public IEffectiveOwner EffectiveOwner { get; }
public IOccupySpace OccupiesSpace { get; }
public ITargetable[] Targetables { get; }
public IEnumerable<ITargetablePositions> EnabledTargetablePositions { get; private set; }
public bool IsIdle { get { return CurrentActivity == null; } }
public bool IsDead { get { return Disposed || (health != null && health.IsDead); } }
public bool IsIdle => CurrentActivity == null;
public bool IsDead => Disposed || (health != null && health.IsDead);
public CPos Location { get { return OccupiesSpace.TopLeft; } }
public WPos CenterPosition { get { return OccupiesSpace.CenterPosition; } }
public CPos Location => OccupiesSpace.TopLeft;
public WPos CenterPosition => OccupiesSpace.CenterPosition;
public WRot Orientation
public WRot Orientation => facing?.Orientation ?? WRot.None;
/// <summary>Value used to represent an invalid token.</summary>
public static readonly int InvalidConditionToken = -1;
class ConditionState
{
get
{
// TODO: Support non-zero pitch/roll in IFacing (IOrientation?)
var facingValue = facing != null ? facing.Facing : 0;
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facingValue));
}
/// <summary>Delegates that have registered to be notified when this condition changes.</summary>
public readonly List<VariableObserverNotifier> Notifiers = new List<VariableObserverNotifier>();
/// <summary>Unique integers identifying granted instances of the condition.</summary>
public readonly HashSet<int> Tokens = new HashSet<int>();
}
internal SyncHash[] SyncHashes { get; private set; }
readonly Dictionary<string, ConditionState> conditionStates = new Dictionary<string, ConditionState>();
/// <summary>Each granted condition receives a unique token that is used when revoking.</summary>
readonly Dictionary<int, string> conditionTokens = new Dictionary<int, string>();
int nextConditionToken = 1;
/// <summary>Cache of condition -> enabled state for quick evaluation of token counter conditions.</summary>
readonly Dictionary<string, int> conditionCache = new Dictionary<string, int>();
/// <summary>Read-only version of conditionCache that is passed to IConditionConsumers.</summary>
readonly IReadOnlyDictionary<string, int> readOnlyConditionCache;
internal SyncHash[] SyncHashes { get; }
readonly IFacing facing;
readonly IHealth health;
readonly IResolveOrder[] resolveOrders;
readonly IRenderModifier[] renderModifiers;
readonly IRender[] renders;
readonly IMouseBounds[] mouseBounds;
@@ -85,18 +115,26 @@ namespace OpenRA
readonly IDefaultVisibility defaultVisibility;
readonly INotifyBecomingIdle[] becomingIdles;
readonly INotifyIdle[] tickIdles;
readonly ITargetablePositions[] targetablePositions;
WPos[] staticTargetablePositions;
readonly IEnumerable<WPos> enabledTargetableWorldPositions;
bool created;
internal Actor(World world, string name, TypeDictionary initDict)
{
var duplicateInit = initDict.WithInterface<ISingleInstanceInit>().GroupBy(i => i.GetType())
.FirstOrDefault(i => i.Count() > 1);
if (duplicateInit != null)
throw new InvalidDataException($"Duplicate initializer '{duplicateInit.Key.Name}'");
var init = new ActorInitializer(this, initDict);
readOnlyConditionCache = new ReadOnlyDictionary<string, int>(conditionCache);
World = world;
ActorID = world.NextAID();
if (initDict.Contains<OwnerInit>())
Owner = init.Get<OwnerInit, Player>();
var ownerInit = init.GetOrDefault<OwnerInit>();
if (ownerInit != null)
Owner = ownerInit.Value(world);
if (name != null)
{
@@ -106,51 +144,94 @@ namespace OpenRA
throw new NotImplementedException("No rules definition for unit " + name);
Info = world.Map.Rules.Actors[name];
foreach (var trait in Info.TraitsInConstructOrder())
var resolveOrdersList = new List<IResolveOrder>();
var renderModifiersList = new List<IRenderModifier>();
var rendersList = new List<IRender>();
var mouseBoundsList = new List<IMouseBounds>();
var visibilityModifiersList = new List<IVisibilityModifier>();
var becomingIdlesList = new List<INotifyBecomingIdle>();
var tickIdlesList = new List<INotifyIdle>();
var targetablesList = new List<ITargetable>();
var targetablePositionsList = new List<ITargetablePositions>();
var syncHashesList = new List<SyncHash>();
foreach (var traitInfo in Info.TraitsInConstructOrder())
{
AddTrait(trait.Create(init));
var trait = traitInfo.Create(init);
AddTrait(trait);
// Some traits rely on properties provided by IOccupySpace in their initialization,
// so we must ready it now, we cannot wait until all traits have finished construction.
if (trait is IOccupySpaceInfo)
OccupiesSpace = Trait<IOccupySpace>();
// PERF: Cache all these traits as soon as the actor is created. This is a fairly cheap one-off cost per
// actor that allows us to provide some fast implementations of commonly used methods that are relied on by
// performance-sensitive parts of the core game engine, such as pathfinding, visibility and rendering.
// Note: The blocks are required to limit the scope of the t's, so we make an exception to our normal style
// rules for spacing in order to keep these assignments compact and readable.
{ if (trait is IOccupySpace t) OccupiesSpace = t; }
{ if (trait is IEffectiveOwner t) EffectiveOwner = t; }
{ if (trait is IFacing t) facing = t; }
{ if (trait is IHealth t) health = t; }
{ if (trait is IResolveOrder t) resolveOrdersList.Add(t); }
{ if (trait is IRenderModifier t) renderModifiersList.Add(t); }
{ if (trait is IRender t) rendersList.Add(t); }
{ if (trait is IMouseBounds t) mouseBoundsList.Add(t); }
{ if (trait is IVisibilityModifier t) visibilityModifiersList.Add(t); }
{ if (trait is IDefaultVisibility t) defaultVisibility = t; }
{ if (trait is INotifyBecomingIdle t) becomingIdlesList.Add(t); }
{ if (trait is INotifyIdle t) tickIdlesList.Add(t); }
{ if (trait is ITargetable t) targetablesList.Add(t); }
{ if (trait is ITargetablePositions t) targetablePositionsList.Add(t); }
{ if (trait is ISync t) syncHashesList.Add(new SyncHash(t)); }
}
resolveOrders = resolveOrdersList.ToArray();
renderModifiers = renderModifiersList.ToArray();
renders = rendersList.ToArray();
mouseBounds = mouseBoundsList.ToArray();
visibilityModifiers = visibilityModifiersList.ToArray();
becomingIdles = becomingIdlesList.ToArray();
tickIdles = tickIdlesList.ToArray();
Targetables = targetablesList.ToArray();
var targetablePositions = targetablePositionsList.ToArray();
EnabledTargetablePositions = targetablePositions.Where(Exts.IsTraitEnabled);
enabledTargetableWorldPositions = EnabledTargetablePositions.SelectMany(tp => tp.TargetablePositions(this));
SyncHashes = syncHashesList.ToArray();
}
// PERF: Cache all these traits as soon as the actor is created. This is a fairly cheap one-off cost per
// actor that allows us to provide some fast implementations of commonly used methods that are relied on by
// performance-sensitive parts of the core game engine, such as pathfinding, visibility and rendering.
EffectiveOwner = TraitOrDefault<IEffectiveOwner>();
facing = TraitOrDefault<IFacing>();
health = TraitOrDefault<IHealth>();
renderModifiers = TraitsImplementing<IRenderModifier>().ToArray();
renders = TraitsImplementing<IRender>().ToArray();
mouseBounds = TraitsImplementing<IMouseBounds>().ToArray();
visibilityModifiers = TraitsImplementing<IVisibilityModifier>().ToArray();
defaultVisibility = Trait<IDefaultVisibility>();
becomingIdles = TraitsImplementing<INotifyBecomingIdle>().ToArray();
tickIdles = TraitsImplementing<INotifyIdle>().ToArray();
Targetables = TraitsImplementing<ITargetable>().ToArray();
targetablePositions = TraitsImplementing<ITargetablePositions>().ToArray();
world.AddFrameEndTask(w =>
{
// Caching this in a AddFrameEndTask, because trait construction order might cause problems if done directly at creation time.
// All actors that can move or teleport should have IPositionable, if not it's pretty safe to assume the actor is completely immobile and
// all targetable positions can be cached if all ITargetablePositions have no conditional requirements.
if (!Info.HasTraitInfo<IPositionableInfo>() && targetablePositions.Any() && targetablePositions.All(tp => tp.AlwaysEnabled))
staticTargetablePositions = targetablePositions.SelectMany(tp => tp.TargetablePositions(this)).ToArray();
});
SyncHashes = TraitsImplementing<ISync>().Select(sync => new SyncHash(sync)).ToArray();
}
internal void Created()
internal void Initialize(bool addToWorld = true)
{
created = true;
// Make sure traits are usable for condition notifiers
foreach (var t in TraitsImplementing<INotifyCreated>())
t.Created(this);
var allObserverNotifiers = new HashSet<VariableObserverNotifier>();
foreach (var provider in TraitsImplementing<IObservesVariables>())
{
foreach (var variableUser in provider.GetVariableObservers())
{
allObserverNotifiers.Add(variableUser.Notifier);
foreach (var variable in variableUser.Variables)
{
var cs = conditionStates.GetOrAdd(variable);
cs.Notifiers.Add(variableUser.Notifier);
// Initialize conditions that have not yet been granted to 0
// NOTE: Some conditions may have already been granted by INotifyCreated calling GrantCondition,
// and we choose to assign the token count to safely cover both cases instead of adding an if branch.
conditionCache[variable] = cs.Tokens.Count;
}
}
}
// Update all traits with their initial condition state
foreach (var notify in allObserverNotifiers)
notify(this, readOnlyConditionCache);
// TODO: Other traits may need initialization after being notified of initial condition state.
// TODO: A post condition initialization notification phase may allow queueing activities instead.
// The initial activity should run before any activities queued by INotifyCreated.Created
// However, we need to know which traits are enabled (via conditions), so wait for after the calls and insert the activity as the first
ICreationActivity creationActivity = null;
@@ -160,7 +241,7 @@ namespace OpenRA
continue;
if (creationActivity != null)
throw new InvalidOperationException("More than one enabled ICreationActivity trait: {0} and {1}".F(creationActivity.GetType().Name, ica.GetType().Name));
throw new InvalidOperationException($"More than one enabled ICreationActivity trait: {creationActivity.GetType().Name} and {ica.GetType().Name}");
var activity = ica.GetCreationActivity();
if (activity == null)
@@ -171,6 +252,9 @@ namespace OpenRA
activity.Queue(CurrentActivity);
CurrentActivity = activity;
}
if (addToWorld)
World.Add(this);
}
public void Tick()
@@ -233,7 +317,7 @@ namespace OpenRA
yield return r;
}
public Rectangle MouseBounds(WorldRenderer wr)
public Polygon MouseBounds(WorldRenderer wr)
{
foreach (var mb in mouseBounds)
{
@@ -242,7 +326,7 @@ namespace OpenRA
return bounds;
}
return Rectangle.Empty;
return Polygon.Empty;
}
public void QueueActivity(bool queued, Activity nextActivity)
@@ -266,8 +350,7 @@ namespace OpenRA
public void CancelActivity()
{
if (CurrentActivity != null)
CurrentActivity.Cancel(this);
CurrentActivity?.Cancel(this);
}
public override int GetHashCode()
@@ -277,8 +360,7 @@ namespace OpenRA
public override bool Equals(object obj)
{
var o = obj as Actor;
return o != null && Equals(o);
return obj is Actor o && Equals(o);
}
public bool Equals(Actor other)
@@ -319,8 +401,7 @@ namespace OpenRA
{
// If CurrentActivity isn't null, run OnActorDisposeOuter in case some cleanups are needed.
// This should be done before the FrameEndTask to avoid dependency issues.
if (CurrentActivity != null)
CurrentActivity.OnActorDisposeOuter(this);
CurrentActivity?.OnActorDisposeOuter(this);
// Allow traits/activities to prevent a race condition when they depend on disposing the actor (e.g. Transforms)
WillDispose = true;
@@ -339,11 +420,16 @@ namespace OpenRA
World.TraitDict.RemoveActor(this);
Disposed = true;
if (luaInterface != null)
luaInterface.Value.OnActorDestroyed();
luaInterface?.Value.OnActorDestroyed();
});
}
public void ResolveOrder(Order order)
{
foreach (var r in resolveOrders)
r.ResolveOrder(this, order);
}
// TODO: move elsewhere.
public void ChangeOwner(Player newOwner)
{
@@ -395,7 +481,7 @@ namespace OpenRA
health.InflictDamage(this, attacker, damage, false);
}
public void Kill(Actor attacker, BitSet<DamageType> damageTypes = default(BitSet<DamageType>))
public void Kill(Actor attacker, BitSet<DamageType> damageTypes = default)
{
if (Disposed || health == null)
return;
@@ -436,7 +522,7 @@ namespace OpenRA
{
// PERF: Avoid LINQ.
foreach (var targetable in Targetables)
if (targetable.IsTraitEnabled() && targetable.TargetableBy(this, byActor))
if (targetable.TargetableBy(this, byActor))
return true;
return false;
@@ -444,16 +530,71 @@ namespace OpenRA
public IEnumerable<WPos> GetTargetablePositions()
{
if (staticTargetablePositions != null)
return staticTargetablePositions;
var enabledTargetablePositionTraits = targetablePositions.Where(Exts.IsTraitEnabled);
if (enabledTargetablePositionTraits.Any())
return enabledTargetablePositionTraits.SelectMany(tp => tp.TargetablePositions(this));
if (EnabledTargetablePositions.Any())
return enabledTargetableWorldPositions;
return new[] { CenterPosition };
}
#region Conditions
void UpdateConditionState(string condition, int token, bool isRevoke)
{
var conditionState = conditionStates.GetOrAdd(condition);
if (isRevoke)
conditionState.Tokens.Remove(token);
else
conditionState.Tokens.Add(token);
conditionCache[condition] = conditionState.Tokens.Count;
// Conditions may be granted or revoked before the state is initialized.
// These notifications will be processed after INotifyCreated.Created.
if (created)
foreach (var notify in conditionState.Notifiers)
notify(this, readOnlyConditionCache);
}
/// <summary>
/// Grants a specified condition if it is valid.
/// Otherwise, just returns InvalidConditionToken.
/// </summary>
/// <returns>The token that is used to revoke this condition.</returns>
public int GrantCondition(string condition)
{
if (string.IsNullOrEmpty(condition))
return InvalidConditionToken;
var token = nextConditionToken++;
conditionTokens.Add(token, condition);
UpdateConditionState(condition, token, false);
return token;
}
/// <summary>
/// Revokes a previously granted condition.
/// </summary>
/// <param name="token">The token ID returned by GrantCondition.</param>
/// <returns>The invalid token ID.</returns>
public int RevokeCondition(int token)
{
if (!conditionTokens.TryGetValue(token, out var condition))
throw new InvalidOperationException($"Attempting to revoke condition with invalid token {token} for {this}.");
conditionTokens.Remove(token);
UpdateConditionState(condition, token, true);
return InvalidConditionToken;
}
/// <summary>Returns whether the specified token is valid for RevokeCondition</summary>
public bool TokenValid(int token)
{
return conditionTokens.ContainsKey(token);
}
#endregion
#region Scripting interface
Lazy<ScriptActorInterface> luaInterface;
@@ -465,14 +606,13 @@ namespace OpenRA
public LuaValue this[LuaRuntime runtime, LuaValue keyValue]
{
get { return luaInterface.Value[runtime, keyValue]; }
set { luaInterface.Value[runtime, keyValue] = value; }
get => luaInterface.Value[runtime, keyValue];
set => luaInterface.Value[runtime, keyValue] = value;
}
public LuaValue Equals(LuaRuntime runtime, LuaValue left, LuaValue right)
{
Actor a, b;
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
if (!left.TryGetClrValue(out Actor a) || !right.TryGetClrValue(out Actor b))
return false;
return a == b;
@@ -480,7 +620,7 @@ namespace OpenRA
public LuaValue ToString(LuaRuntime runtime)
{
return "Actor ({0})".F(this);
return $"Actor ({this})";
}
public bool HasScriptProperty(string name)

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -16,7 +16,7 @@ using OpenRA.Scripting;
namespace OpenRA
{
public struct CPos : IScriptBindable, ILuaAdditionBinding, ILuaSubtractionBinding, ILuaEqualityBinding, ILuaTableBinding, IEquatable<CPos>
public readonly struct CPos : IScriptBindable, ILuaAdditionBinding, ILuaSubtractionBinding, ILuaEqualityBinding, ILuaTableBinding, IEquatable<CPos>
{
// Coordinates are packed in a 32 bit signed int
// X and Y are 12 bits (signed): -2048...2047
@@ -25,13 +25,13 @@ namespace OpenRA
public readonly int Bits;
// X is padded to MSB, so bit shift does the correct sign extension
public int X { get { return Bits >> 20; } }
public int X => Bits >> 20;
// Align Y with a short, cast, then shift the rest of the way
// The signed short bit shift does the correct sign extension
public int Y { get { return ((short)(Bits >> 4)) >> 4; } }
public int Y => ((short)(Bits >> 4)) >> 4;
public byte Layer { get { return (byte)Bits; } }
public byte Layer => (byte)Bits;
public CPos(int bits) { Bits = bits; }
public CPos(int x, int y)
@@ -58,7 +58,13 @@ namespace OpenRA
public bool Equals(CPos other) { return Bits == other.Bits; }
public override bool Equals(object obj) { return obj is CPos && Equals((CPos)obj); }
public override string ToString() { return X + "," + Y; }
public override string ToString()
{
if (Layer == 0)
return X + "," + Y;
return X + "," + Y + "," + Layer;
}
public MPos ToMPos(Map map)
{
@@ -89,41 +95,35 @@ namespace OpenRA
public LuaValue Add(LuaRuntime runtime, LuaValue left, LuaValue right)
{
CPos a;
CVec b;
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
throw new LuaException("Attempted to call CPos.Add(CPos, CVec) with invalid arguments ({0}, {1})".F(left.WrappedClrType().Name, right.WrappedClrType().Name));
if (!left.TryGetClrValue(out CPos a) || !right.TryGetClrValue(out CVec b))
throw new LuaException($"Attempted to call CPos.Add(CPos, CVec) with invalid arguments ({left.WrappedClrType().Name}, {right.WrappedClrType().Name})");
return new LuaCustomClrObject(a + b);
}
public LuaValue Subtract(LuaRuntime runtime, LuaValue left, LuaValue right)
{
CPos a;
var rightType = right.WrappedClrType();
if (!left.TryGetClrValue(out a))
throw new LuaException("Attempted to call CPos.Subtract(CPos, (CPos|CVec)) with invalid arguments ({0}, {1})".F(left.WrappedClrType().Name, rightType.Name));
if (!left.TryGetClrValue(out CPos a))
throw new LuaException($"Attempted to call CPos.Subtract(CPos, (CPos|CVec)) with invalid arguments ({left.WrappedClrType().Name}, {rightType.Name})");
if (rightType == typeof(CPos))
{
CPos b;
right.TryGetClrValue(out b);
right.TryGetClrValue(out CPos b);
return new LuaCustomClrObject(a - b);
}
else if (rightType == typeof(CVec))
{
CVec b;
right.TryGetClrValue(out b);
right.TryGetClrValue(out CVec b);
return new LuaCustomClrObject(a - b);
}
throw new LuaException("Attempted to call CPos.Subtract(CPos, (CPos|CVec)) with invalid arguments ({0}, {1})".F(left.WrappedClrType().Name, rightType.Name));
throw new LuaException($"Attempted to call CPos.Subtract(CPos, (CPos|CVec)) with invalid arguments ({left.WrappedClrType().Name}, {rightType.Name})");
}
public LuaValue Equals(LuaRuntime runtime, LuaValue left, LuaValue right)
{
CPos a, b;
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
if (!left.TryGetClrValue(out CPos a) || !right.TryGetClrValue(out CPos b))
return false;
return a == b;
@@ -138,14 +138,11 @@ namespace OpenRA
case "X": return X;
case "Y": return Y;
case "Layer": return Layer;
default: throw new LuaException("CPos does not define a member '{0}'".F(key));
default: throw new LuaException($"CPos does not define a member '{key}'");
}
}
set
{
throw new LuaException("CPos is read-only. Use CPos.New to create a new value");
}
set => throw new LuaException("CPos is read-only. Use CPos.New to create a new value");
}
#endregion

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -17,7 +17,7 @@ using OpenRA.Scripting;
namespace OpenRA
{
public struct CVec : IScriptBindable, ILuaAdditionBinding, ILuaSubtractionBinding, ILuaUnaryMinusBinding, ILuaEqualityBinding, ILuaTableBinding, IEquatable<CVec>
public readonly struct CVec : IScriptBindable, ILuaAdditionBinding, ILuaSubtractionBinding, ILuaUnaryMinusBinding, ILuaEqualityBinding, ILuaTableBinding, IEquatable<CVec>
{
public readonly int X, Y;
@@ -42,8 +42,8 @@ namespace OpenRA
public CVec Sign() { return new CVec(Math.Sign(X), Math.Sign(Y)); }
public CVec Abs() { return new CVec(Math.Abs(X), Math.Abs(Y)); }
public int LengthSquared { get { return X * X + Y * Y; } }
public int Length { get { return Exts.ISqrt(LengthSquared); } }
public int LengthSquared => X * X + Y * Y;
public int Length => Exts.ISqrt(LengthSquared);
public CVec Clamp(Rectangle r)
{
@@ -75,18 +75,16 @@ namespace OpenRA
public LuaValue Add(LuaRuntime runtime, LuaValue left, LuaValue right)
{
CVec a, b;
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
throw new LuaException("Attempted to call CVec.Add(CVec, CVec) with invalid arguments ({0}, {1})".F(left.WrappedClrType().Name, right.WrappedClrType().Name));
if (!left.TryGetClrValue(out CVec a) || !right.TryGetClrValue(out CVec b))
throw new LuaException($"Attempted to call CVec.Add(CVec, CVec) with invalid arguments ({left.WrappedClrType().Name}, {right.WrappedClrType().Name})");
return new LuaCustomClrObject(a + b);
}
public LuaValue Subtract(LuaRuntime runtime, LuaValue left, LuaValue right)
{
CVec a, b;
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
throw new LuaException("Attempted to call CVec.Subtract(CVec, CVec) with invalid arguments ({0}, {1})".F(left.WrappedClrType().Name, right.WrappedClrType().Name));
if (!left.TryGetClrValue(out CVec a) || !right.TryGetClrValue(out CVec b))
throw new LuaException($"Attempted to call CVec.Subtract(CVec, CVec) with invalid arguments ({left.WrappedClrType().Name}, {right.WrappedClrType().Name})");
return new LuaCustomClrObject(a - b);
}
@@ -98,8 +96,7 @@ namespace OpenRA
public LuaValue Equals(LuaRuntime runtime, LuaValue left, LuaValue right)
{
CVec a, b;
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
if (!left.TryGetClrValue(out CVec a) || !right.TryGetClrValue(out CVec b))
return false;
return a == b;
@@ -113,14 +110,11 @@ namespace OpenRA
{
case "X": return X;
case "Y": return Y;
default: throw new LuaException("CVec does not define a member '{0}'".F(key));
default: throw new LuaException($"CVec does not define a member '{key}'");
}
}
set
{
throw new LuaException("CVec is read-only. Use CVec.New to create a new value");
}
set => throw new LuaException("CVec is read-only. Use CVec.New to create a new value");
}
#endregion

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -9,12 +9,12 @@
*/
#endregion
using OpenRA.Primitives;
namespace OpenRA
{
public interface ICacheStorage<T>
public class DefaultPlayer : IGlobalModData
{
void Remove(string key);
void Store(string key, T data);
T Retrieve(string key);
public readonly Color Color = Color.FromArgb(0xEE, 0xEE, 0xEE);
}
}

View File

@@ -1,97 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System;
using System.ComponentModel;
using System.Net;
namespace OpenRA
{
public class Download
{
readonly object syncObject = new object();
WebClient wc;
public static string FormatErrorMessage(Exception e)
{
var ex = e as WebException;
if (ex == null)
return e.Message;
switch (ex.Status)
{
case WebExceptionStatus.RequestCanceled:
return "Cancelled";
case WebExceptionStatus.NameResolutionFailure:
return "DNS lookup failed";
case WebExceptionStatus.Timeout:
return "Connection timeout";
case WebExceptionStatus.ConnectFailure:
return "Cannot connect to remote server";
case WebExceptionStatus.ProtocolError:
return "File not found on remote server";
default:
return ex.Message;
}
}
void EnableTLS12OnWindows()
{
// Enable TLS 1.2 on Windows: .NET 4.7 on Windows 10 only supports obsolete protocols by default
// SecurityProtocolType.Tls12 is not defined in the .NET 4.5 reference dlls used by mono,
// so we must use the enum's constant value directly
if (Platform.CurrentPlatform == PlatformType.Windows)
ServicePointManager.SecurityProtocol |= (SecurityProtocolType)3072;
}
public Download(string url, string path, Action<DownloadProgressChangedEventArgs> onProgress, Action<AsyncCompletedEventArgs> onComplete)
{
EnableTLS12OnWindows();
lock (syncObject)
{
wc = new WebClient { Proxy = null };
wc.DownloadProgressChanged += (_, a) => onProgress(a);
wc.DownloadFileCompleted += (_, a) => { DisposeWebClient(); onComplete(a); };
wc.DownloadFileAsync(new Uri(url), path);
}
}
public Download(string url, Action<DownloadProgressChangedEventArgs> onProgress, Action<DownloadDataCompletedEventArgs> onComplete)
{
EnableTLS12OnWindows();
lock (syncObject)
{
wc = new WebClient { Proxy = null };
wc.DownloadProgressChanged += (_, a) => onProgress(a);
wc.DownloadDataCompleted += (_, a) => { DisposeWebClient(); onComplete(a); };
wc.DownloadDataAsync(new Uri(url));
}
}
void DisposeWebClient()
{
lock (syncObject)
{
wc.Dispose();
wc = null;
}
}
public void CancelAsync()
{
lock (syncObject)
if (wc != null)
wc.CancelAsync();
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -17,8 +17,8 @@ namespace OpenRA.Effects
{
public class AsyncAction : IEffect
{
Action a;
IAsyncResult ar;
readonly Action a;
readonly IAsyncResult ar;
public AsyncAction(IAsyncResult ar, Action a)
{

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -17,7 +17,7 @@ namespace OpenRA.Effects
{
public class DelayedAction : IEffect
{
Action a;
readonly Action a;
int delay;
public DelayedAction(int delay, Action a)

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -66,12 +66,7 @@ namespace OpenRA
// Several types of support directory types are available, depending on
// how the player has installed and launched the game.
// Read registration metadata from all of them
var sources = Enum.GetValues(typeof(SupportDirType))
.Cast<SupportDirType>()
.Select(t => Platform.GetSupportDir(t))
.Distinct();
foreach (var source in sources)
foreach (var source in GetSupportDirs(ModRegistration.User | ModRegistration.System))
{
var metadataPath = Path.Combine(source, "ModMetadata");
if (!Directory.Exists(metadataPath))
@@ -121,7 +116,7 @@ namespace OpenRA
mods[key] = mod;
}
internal void Register(Manifest mod, string launchPath, ModRegistration registration)
internal void Register(Manifest mod, string launchPath, IEnumerable<string> launchArgs, ModRegistration registration)
{
if (mod.Metadata.Hidden)
return;
@@ -133,7 +128,7 @@ namespace OpenRA
new MiniYamlNode("Version", mod.Metadata.Version),
new MiniYamlNode("Title", mod.Metadata.Title),
new MiniYamlNode("LaunchPath", launchPath),
new MiniYamlNode("LaunchArgs", "Game.Mod=" + mod.Id)
new MiniYamlNode("LaunchArgs", new[] { "Game.Mod=" + mod.Id }.Concat(launchArgs).JoinWith(", "))
}));
using (var stream = mod.Package.GetStream("icon.png"))
@@ -148,7 +143,7 @@ namespace OpenRA
if (stream != null)
yaml.Value.Nodes.Add(new MiniYamlNode("Icon3x", Convert.ToBase64String(stream.ReadAllBytes())));
var sources = new List<string>();
var sources = new HashSet<string>();
if (registration.HasFlag(ModRegistration.System))
sources.Add(Platform.GetSupportDir(SupportDirType.System));
@@ -167,7 +162,7 @@ namespace OpenRA
LoadMod(yaml.Value, forceRegistration: true);
var lines = new List<MiniYamlNode> { yaml }.ToLines().ToArray();
foreach (var source in sources.Distinct())
foreach (var source in sources)
{
var metadataPath = Path.Combine(source, "ModMetadata");
@@ -191,23 +186,9 @@ namespace OpenRA
/// * Filename doesn't match internal key
/// * Fails to parse as a mod registration
/// </summary>
internal void ClearInvalidRegistrations(ExternalMod activeMod, ModRegistration registration)
internal void ClearInvalidRegistrations(ModRegistration registration)
{
var sources = new List<string>();
if (registration.HasFlag(ModRegistration.System))
sources.Add(Platform.GetSupportDir(SupportDirType.System));
if (registration.HasFlag(ModRegistration.User))
{
// User support dir may be using the modern or legacy value, or overridden by the user
// Add all the possibilities and let the .Distinct() below ignore the duplicates
sources.Add(Platform.GetSupportDir(SupportDirType.User));
sources.Add(Platform.GetSupportDir(SupportDirType.ModernUser));
sources.Add(Platform.GetSupportDir(SupportDirType.LegacyUser));
}
var activeModKey = ExternalMod.MakeKey(activeMod);
foreach (var source in sources.Distinct())
foreach (var source in GetSupportDirs(registration))
{
var metadataPath = Path.Combine(source, "ModMetadata");
if (!Directory.Exists(metadataPath))
@@ -222,13 +203,10 @@ namespace OpenRA
var m = FieldLoader.Load<ExternalMod>(yaml);
modKey = ExternalMod.MakeKey(m);
// Continue to the next entry if it is the active mod (even if the LaunchPath is bogus)
if (modKey == activeModKey)
continue;
// Continue to the next entry if this one is valid
if (File.Exists(m.LaunchPath) && Path.GetFileNameWithoutExtension(path) == modKey &&
!(activeMod != null && m.LaunchPath == activeMod.LaunchPath && m.Id == activeMod.Id && m.Version != activeMod.Version))
// HACK: Explicitly invalidate paths to OpenRA.dll to clean up bogus metadata files
// that were created after the initial migration from .NET Framework to Core/5.
if (File.Exists(m.LaunchPath) && Path.GetFileNameWithoutExtension(path) == modKey && Path.GetExtension(m.LaunchPath) != ".dll")
continue;
}
catch (Exception e)
@@ -258,23 +236,10 @@ namespace OpenRA
internal void Unregister(Manifest mod, ModRegistration registration)
{
var sources = new List<string>();
if (registration.HasFlag(ModRegistration.System))
sources.Add(Platform.GetSupportDir(SupportDirType.System));
if (registration.HasFlag(ModRegistration.User))
{
// User support dir may be using the modern or legacy value, or overridden by the user
// Add all the possibilities and let the .Distinct() below ignore the duplicates
sources.Add(Platform.GetSupportDir(SupportDirType.User));
sources.Add(Platform.GetSupportDir(SupportDirType.ModernUser));
sources.Add(Platform.GetSupportDir(SupportDirType.LegacyUser));
}
var key = ExternalMod.MakeKey(mod);
mods.Remove(key);
foreach (var source in sources.Distinct())
foreach (var source in GetSupportDirs(registration))
{
var path = Path.Combine(source, "ModMetadata", key + ".yaml");
try
@@ -290,10 +255,33 @@ namespace OpenRA
}
}
public ExternalMod this[string key] { get { return mods[key]; } }
public int Count { get { return mods.Count; } }
public ICollection<string> Keys { get { return mods.Keys; } }
public ICollection<ExternalMod> Values { get { return mods.Values; } }
IEnumerable<string> GetSupportDirs(ModRegistration registration)
{
var sources = new HashSet<string>(4);
if (registration.HasFlag(ModRegistration.System))
sources.Add(Platform.GetSupportDir(SupportDirType.System));
if (registration.HasFlag(ModRegistration.User))
{
// User support dir may be using the modern or legacy value, or overridden by the user
// Add all the possibilities and let the HashSet ignore the duplicates
sources.Add(Platform.GetSupportDir(SupportDirType.User));
sources.Add(Platform.GetSupportDir(SupportDirType.ModernUser));
sources.Add(Platform.GetSupportDir(SupportDirType.LegacyUser));
}
return sources;
}
public ExternalMod this[string key] => mods[key];
public int Count => mods.Count;
public ICollection<string> Keys => mods.Keys;
public ICollection<ExternalMod> Values => mods.Values;
IEnumerable<string> IReadOnlyDictionary<string, ExternalMod>.Keys => ((IReadOnlyDictionary<string, ExternalMod>)mods).Keys;
IEnumerable<ExternalMod> IReadOnlyDictionary<string, ExternalMod>.Values => ((IReadOnlyDictionary<string, ExternalMod>)mods).Values;
public bool ContainsKey(string key) { return mods.ContainsKey(key); }
public IEnumerator<KeyValuePair<string, ExternalMod>> GetEnumerator() { return mods.GetEnumerator(); }
public bool TryGetValue(string key, out ExternalMod value) { return mods.TryGetValue(key, out value); }

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -38,12 +38,6 @@ namespace OpenRA
catch { return def; }
}
public static void Do<T>(this IEnumerable<T> e, Action<T> fn)
{
foreach (var ee in e)
fn(ee);
}
public static Lazy<T> Lazy<T>(Func<T> p) { return new Lazy<T>(p); }
public static IEnumerable<string> GetNamespaces(this Assembly a)
@@ -53,7 +47,7 @@ namespace OpenRA
public static bool HasAttribute<T>(this MemberInfo mi)
{
return mi.GetCustomAttributes(typeof(T), true).Length != 0;
return Attribute.IsDefined(mi, typeof(T));
}
public static T[] GetCustomAttributes<T>(this MemberInfo mi, bool inherit)
@@ -80,7 +74,7 @@ namespace OpenRA
static int WindingDirectionTest(int2 v0, int2 v1, int2 p)
{
return (v1.X - v0.X) * (p.Y - v0.Y) - (p.X - v0.X) * (v1.Y - v0.Y);
return Math.Sign((v1.X - v0.X) * (p.Y - v0.Y) - (p.X - v0.X) * (v1.Y - v0.Y));
}
public static bool PolygonContains(this int2[] polygon, int2 p)
@@ -101,6 +95,16 @@ namespace OpenRA
return windingNumber != 0;
}
public static bool LinesIntersect(int2 a, int2 b, int2 c, int2 d)
{
// If line segments AB and CD intersect:
// - the triangles ACD and BCD must have opposite sense (clockwise or anticlockwise)
// - the triangles CAB and DAB must have opposite sense
// Segments intersect if the orientation (clockwise or anticlockwise) of the two points in each line segment are opposite with respect to the other
// Assumes that lines are not collinear
return WindingDirectionTest(c, d, a) != WindingDirectionTest(c, d, b) && WindingDirectionTest(a, b, c) != WindingDirectionTest(a, b, d);
}
public static bool HasModifier(this Modifiers k, Modifiers mod)
{
// PERF: Enum.HasFlag is slower and requires allocations.
@@ -110,13 +114,19 @@ namespace OpenRA
public static V GetOrAdd<K, V>(this Dictionary<K, V> d, K k)
where V : new()
{
return d.GetOrAdd(k, _ => new V());
return d.GetOrAdd(k, new V());
}
public static V GetOrAdd<K, V>(this Dictionary<K, V> d, K k, V v)
{
if (!d.TryGetValue(k, out var ret))
d.Add(k, ret = v);
return ret;
}
public static V GetOrAdd<K, V>(this Dictionary<K, V> d, K k, Func<K, V> createFn)
{
V ret;
if (!d.TryGetValue(k, out ret))
if (!d.TryGetValue(k, out var ret))
d.Add(k, ret = createFn(k));
return ret;
}
@@ -143,9 +153,9 @@ namespace OpenRA
if (xs.Count == 0)
{
if (throws)
throw new ArgumentException("Collection must not be empty.", "ts");
throw new ArgumentException("Collection must not be empty.", nameof(ts));
else
return default(T);
return default;
}
else
return xs.ElementAt(r.Next(xs.Count));
@@ -220,9 +230,9 @@ namespace OpenRA
{
if (!e.MoveNext())
if (throws)
throw new ArgumentException("Collection must not be empty.", "ts");
throw new ArgumentException("Collection must not be empty.", nameof(ts));
else
return default(T);
return default;
t = e.Current;
u = selector(t);
while (e.MoveNext())
@@ -262,7 +272,7 @@ namespace OpenRA
public static int ISqrt(int number, ISqrtRoundMode round = ISqrtRoundMode.Floor)
{
if (number < 0)
throw new InvalidOperationException("Attempted to calculate the square root of a negative integer: {0}".F(number));
throw new InvalidOperationException($"Attempted to calculate the square root of a negative integer: {number}");
return (int)ISqrt((uint)number, round);
}
@@ -303,7 +313,7 @@ namespace OpenRA
public static long ISqrt(long number, ISqrtRoundMode round = ISqrtRoundMode.Floor)
{
if (number < 0)
throw new InvalidOperationException("Attempted to calculate the square root of a negative integer: {0}".F(number));
throw new InvalidOperationException($"Attempted to calculate the square root of a negative integer: {number}");
return (long)ISqrt((ulong)number, round);
}
@@ -341,10 +351,14 @@ namespace OpenRA
return root;
}
public static int MultiplyBySqrtTwo(short number)
{
return number * 46341 / 32768;
}
public static int IntegerDivisionRoundingAwayFromZero(int dividend, int divisor)
{
int remainder;
var quotient = Math.DivRem(dividend, divisor, out remainder);
var quotient = Math.DivRem(dividend, divisor, out var remainder);
if (remainder == 0)
return quotient;
return quotient + (Math.Sign(dividend) == Math.Sign(divisor) ? 1 : -1);
@@ -360,6 +374,11 @@ namespace OpenRA
return ts.Concat(moreTs);
}
public static IEnumerable<T> Exclude<T>(this IEnumerable<T> ts, params T[] exclusions)
{
return ts.Except(exclusions);
}
public static HashSet<T> ToHashSet<T>(this IEnumerable<T> source)
{
return new HashSet<T>(source);
@@ -382,7 +401,8 @@ namespace OpenRA
// Try to build a dictionary and log all duplicates found (if any):
var dupKeys = new Dictionary<TKey, List<string>>();
var d = new Dictionary<TKey, TElement>();
var capacity = source is ICollection<TSource> collection ? collection.Count : 0;
var d = new Dictionary<TKey, TElement>(capacity);
foreach (var item in source)
{
var key = keySelector(item);
@@ -393,30 +413,28 @@ namespace OpenRA
continue;
// Check for a key conflict:
if (d.ContainsKey(key))
if (!d.TryAdd(key, element))
{
List<string> dupKeyMessages;
if (!dupKeys.TryGetValue(key, out dupKeyMessages))
if (!dupKeys.TryGetValue(key, out var dupKeyMessages))
{
// Log the initial conflicting value already inserted:
dupKeyMessages = new List<string>();
dupKeyMessages.Add(logValue(d[key]));
dupKeyMessages = new List<string>
{
logValue(d[key])
};
dupKeys.Add(key, dupKeyMessages);
}
// Log this conflicting value:
dupKeyMessages.Add(logValue(element));
continue;
}
d.Add(key, element);
}
// If any duplicates were found, throw a descriptive error
if (dupKeys.Count > 0)
{
var badKeysFormatted = string.Join(", ", dupKeys.Select(p => "{0}: [{1}]".F(logKey(p.Key), string.Join(",", p.Value))));
var msg = "{0}, duplicate values found for the following keys: {1}".F(debugName, badKeysFormatted);
var badKeysFormatted = string.Join(", ", dupKeys.Select(p => $"{logKey(p.Key)}: [{string.Join(",", p.Value)}]"));
var msg = $"{debugName}, duplicate values found for the following keys: {badKeysFormatted}";
throw new ArgumentException(msg);
}
@@ -497,8 +515,7 @@ namespace OpenRA
public static bool IsTraitEnabled<T>(this T trait)
{
var disabledTrait = trait as IDisabledTrait;
return disabledTrait == null || !disabledTrait.IsTraitDisabled;
return !(trait is IDisabledTrait disabledTrait) || !disabledTrait.IsTraitDisabled;
}
public static T FirstEnabledTraitOrDefault<T>(this IEnumerable<T> ts)
@@ -508,7 +525,7 @@ namespace OpenRA
if (t.IsTraitEnabled())
return t;
return default(T);
return default;
}
public static T FirstEnabledTraitOrDefault<T>(this T[] ts)
@@ -518,8 +535,72 @@ namespace OpenRA
if (t.IsTraitEnabled())
return t;
return default(T);
return default;
}
public static T FirstEnabledConditionalTraitOrDefault<T>(this IEnumerable<T> ts) where T : IDisabledTrait
{
// PERF: Avoid LINQ.
foreach (var t in ts)
if (!t.IsTraitDisabled)
return t;
return default;
}
public static T FirstEnabledConditionalTraitOrDefault<T>(this T[] ts) where T : IDisabledTrait
{
// PERF: Avoid LINQ.
foreach (var t in ts)
if (!t.IsTraitDisabled)
return t;
return default;
}
public static LineSplitEnumerator SplitLines(this string str, char separator)
{
return new LineSplitEnumerator(str.AsSpan(), separator);
}
}
public ref struct LineSplitEnumerator
{
ReadOnlySpan<char> str;
readonly char separator;
public LineSplitEnumerator(ReadOnlySpan<char> str, char separator)
{
this.str = str;
this.separator = separator;
Current = default;
}
public LineSplitEnumerator GetEnumerator() => this;
public bool MoveNext()
{
var span = str;
// Reach the end of the string
if (span.Length == 0)
return false;
var index = span.IndexOf(separator);
if (index == -1)
{
// The remaining string is an empty string
str = ReadOnlySpan<char>.Empty;
Current = span;
return true;
}
Current = span.Slice(0, index);
str = span.Slice(index + 1);
return true;
}
public ReadOnlySpan<char> Current { get; private set; }
}
public static class Enum<T>
@@ -535,7 +616,7 @@ namespace OpenRA
if (values.Any(x => !names.Contains(x)))
{
value = default(T);
value = default;
return false;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -15,7 +15,6 @@ using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Reflection;
using OpenRA.Graphics;
using OpenRA.Primitives;
namespace OpenRA
@@ -73,32 +72,14 @@ namespace OpenRA
return "";
var t = v.GetType();
if (t == typeof(Color))
{
return ((Color)v).ToString();
}
if (t == typeof(Rectangle))
{
var r = (Rectangle)v;
return "{0},{1},{2},{3}".F(r.X, r.Y, r.Width, r.Height);
}
if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(BitSet<>))
{
return ((IEnumerable<string>)v).Select(FormatValue).JoinWith(", ");
}
if (t.IsArray && t.GetArrayRank() == 1)
{
return ((Array)v).Cast<object>().Select(FormatValue).JoinWith(", ");
}
if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(HashSet<>))
{
if (t.IsGenericType && (t.GetGenericTypeDefinition() == typeof(HashSet<>) || t.GetGenericTypeDefinition() == typeof(List<>)))
return ((System.Collections.IEnumerable)v).Cast<object>().Select(FormatValue).JoinWith(", ");
}
// This is only for documentation generation
if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Dictionary<,>))
@@ -113,17 +94,14 @@ namespace OpenRA
var formattedKey = FormatValue(key);
var formattedValue = FormatValue(value);
result += "{0}: {1}{2}".F(formattedKey, formattedValue, Environment.NewLine);
result += $"{formattedKey}: {formattedValue}{Environment.NewLine}";
}
return result;
}
if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Primitives.Cache<,>))
return ""; // TODO
if (t == typeof(DateTime))
return ((DateTime)v).ToString("yyyy-MM-dd HH-mm-ss", CultureInfo.InvariantCulture);
if (v is DateTime d)
return d.ToString("yyyy-MM-dd HH-mm-ss", CultureInfo.InvariantCulture);
// Try the TypeConverter
var conv = TypeDescriptor.GetConverter(t);

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -17,6 +17,7 @@ using System.Net;
using System.Text;
using ICSharpCode.SharpZipLib.Checksum;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
using OpenRA.Graphics;
using OpenRA.Primitives;
namespace OpenRA.FileFormats
@@ -25,12 +26,15 @@ namespace OpenRA.FileFormats
{
static readonly byte[] Signature = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a };
public int Width { get; set; }
public int Height { get; set; }
public Color[] Palette { get; set; }
public byte[] Data { get; set; }
public int Width { get; }
public int Height { get; }
public Color[] Palette { get; }
public byte[] Data { get; }
public SpriteFrameType Type { get; }
public Dictionary<string, string> EmbeddedData = new Dictionary<string, string>();
public int PixelStride => Type == SpriteFrameType.Indexed8 ? 1 : Type == SpriteFrameType.Rgb24 ? 3 : 4;
public Png(Stream s)
{
if (!Verify(s))
@@ -38,9 +42,8 @@ namespace OpenRA.FileFormats
s.Position += 8;
var headerParsed = false;
var isPaletted = false;
var is24Bit = false;
var data = new List<byte>();
Type = SpriteFrameType.Rgba32;
while (true)
{
@@ -65,14 +68,12 @@ namespace OpenRA.FileFormats
var bitDepth = ms.ReadUInt8();
var colorType = (PngColorType)ms.ReadByte();
isPaletted = IsPaletted(bitDepth, colorType);
is24Bit = colorType == PngColorType.Color;
if (IsPaletted(bitDepth, colorType))
Type = SpriteFrameType.Indexed8;
else if (colorType == PngColorType.Color)
Type = SpriteFrameType.Rgb24;
var dataLength = Width * Height;
if (!isPaletted)
dataLength *= 4;
Data = new byte[dataLength];
Data = new byte[Width * Height * PixelStride];
var compression = ms.ReadByte();
/*var filter = */ms.ReadByte();
@@ -133,39 +134,28 @@ namespace OpenRA.FileFormats
{
using (var ds = new InflaterInputStream(ns))
{
var pxStride = isPaletted ? 1 : is24Bit ? 3 : 4;
var srcStride = Width * pxStride;
var destStride = Width * (isPaletted ? 1 : 4);
var pxStride = PixelStride;
var rowStride = Width * pxStride;
var prevLine = new byte[srcStride];
var prevLine = new byte[rowStride];
for (var y = 0; y < Height; y++)
{
var filter = (PngFilter)ds.ReadByte();
var line = ds.ReadBytes(srcStride);
var line = ds.ReadBytes(rowStride);
for (var i = 0; i < srcStride; i++)
for (var i = 0; i < rowStride; i++)
line[i] = i < pxStride
? UnapplyFilter(filter, line[i], 0, prevLine[i], 0)
: UnapplyFilter(filter, line[i], line[i - pxStride], prevLine[i], prevLine[i - pxStride]);
if (is24Bit)
{
// Fold alpha channel into RGB data
for (var i = 0; i < line.Length / 3; i++)
{
Array.Copy(line, 3 * i, Data, y * destStride + 4 * i, 3);
Data[y * destStride + 4 * i + 3] = 255;
}
}
else
Array.Copy(line, 0, Data, y * destStride, line.Length);
Array.Copy(line, 0, Data, y * rowStride, rowStride);
prevLine = line;
}
}
}
if (isPaletted && Palette == null)
if (Type == SpriteFrameType.Indexed8 && Palette == null)
throw new InvalidDataException("Non-Palette indexed PNG are not supported.");
return;
@@ -175,7 +165,7 @@ namespace OpenRA.FileFormats
}
}
public Png(byte[] data, int width, int height, Color[] palette = null,
public Png(byte[] data, SpriteFrameType type, int width, int height, Color[] palette = null,
Dictionary<string, string> embeddedData = null)
{
var expectLength = width * height;
@@ -185,11 +175,46 @@ namespace OpenRA.FileFormats
if (data.Length != expectLength)
throw new InvalidDataException("Input data does not match expected length");
Type = type;
Width = width;
Height = height;
Palette = palette;
Data = data;
switch (type)
{
case SpriteFrameType.Indexed8:
case SpriteFrameType.Rgba32:
case SpriteFrameType.Rgb24:
{
// Data is already in a compatible format
Data = data;
if (type == SpriteFrameType.Indexed8)
Palette = palette;
break;
}
case SpriteFrameType.Bgra32:
case SpriteFrameType.Bgr24:
{
// Convert to big endian
Data = new byte[data.Length];
var stride = PixelStride;
for (var i = 0; i < width * height; i++)
{
Data[stride * i] = data[stride * i + 2];
Data[stride * i + 1] = data[stride * i + 1];
Data[stride * i + 2] = data[stride * i + 0];
if (type == SpriteFrameType.Bgra32)
Data[stride * i + 3] = data[stride * i + 3];
}
break;
}
default:
throw new InvalidDataException($"Unhandled SpriteFrameType {type}");
}
if (embeddedData != null)
EmbeddedData = embeddedData;
@@ -274,9 +299,8 @@ namespace OpenRA.FileFormats
header.Write(IPAddress.HostToNetworkOrder(Height));
header.WriteByte(8); // Bit depth
var colorType = Palette != null
? PngColorType.Indexed | PngColorType.Color
: PngColorType.Color | PngColorType.Alpha;
var colorType = Type == SpriteFrameType.Indexed8 ? PngColorType.Indexed | PngColorType.Color :
Type == SpriteFrameType.Rgb24 ? PngColorType.Color : PngColorType.Color | PngColorType.Alpha;
header.WriteByte((byte)colorType);
header.WriteByte(0); // Compression
@@ -286,7 +310,7 @@ namespace OpenRA.FileFormats
WritePngChunk(output, "IHDR", header);
}
bool alphaPalette = false;
var alphaPalette = false;
if (Palette != null)
{
using (var palette = new MemoryStream())
@@ -318,12 +342,12 @@ namespace OpenRA.FileFormats
{
using (var compressed = new DeflaterOutputStream(data))
{
var stride = Width * (Palette != null ? 1 : 4);
var rowStride = Width * PixelStride;
for (var y = 0; y < Height; y++)
{
// Write uncompressed scanlines for simplicity
compressed.WriteByte(0);
compressed.Write(Data, y * stride, stride);
compressed.Write(Data, y * rowStride, rowStride);
}
compressed.Flush();

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -28,7 +28,7 @@ namespace OpenRA.FileFormats
public ReplayMetadata(GameInformation info)
{
if (info == null)
throw new ArgumentNullException("info");
throw new ArgumentNullException(nameof(info));
GameInfo = info;
}
@@ -44,7 +44,7 @@ namespace OpenRA.FileFormats
// Read version
var version = fs.ReadInt32();
if (version != MetaVersion)
throw new NotSupportedException("Metadata version {0} is not supported".F(version));
throw new NotSupportedException($"Metadata version {version} is not supported");
// Read game info (max 100K limit as a safeguard against corrupted files)
var data = fs.ReadString(Encoding.UTF8, 1024 * 100);

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -28,7 +28,7 @@ namespace OpenRA.FileSystem
public class FileSystem : IReadOnlyFileSystem
{
public IEnumerable<IReadOnlyPackage> MountedPackages { get { return mountedPackages.Keys; } }
public IEnumerable<IReadOnlyPackage> MountedPackages => mountedPackages.Keys;
readonly Dictionary<IReadOnlyPackage, int> mountedPackages = new Dictionary<IReadOnlyPackage, int>();
readonly Dictionary<string, IReadOnlyPackage> explicitMounts = new Dictionary<string, IReadOnlyPackage>();
readonly string modID;
@@ -63,19 +63,16 @@ namespace OpenRA.FileSystem
{
// Raw directories are the easiest and one of the most common cases, so try these first
var resolvedPath = Platform.ResolvePath(filename);
if (!filename.Contains("|") && Directory.Exists(resolvedPath))
if (!resolvedPath.Contains('|') && Directory.Exists(resolvedPath))
return new Folder(resolvedPath);
// Children of another package require special handling
IReadOnlyPackage parent;
string subPath = null;
if (TryGetPackageContaining(filename, out parent, out subPath))
if (TryGetPackageContaining(filename, out var parent, out var subPath))
return parent.OpenPackage(subPath, this);
// Try and open it normally
IReadOnlyPackage package;
var stream = Open(filename);
if (TryParsePackage(stream, filename, out package))
if (TryParsePackage(stream, filename, out var package))
return package;
// No package loaders took ownership of the stream, so clean it up
@@ -97,9 +94,8 @@ namespace OpenRA.FileSystem
{
name = name.Substring(1);
Manifest mod;
if (!installedMods.TryGetValue(name, out mod))
throw new InvalidOperationException("Could not load mod '{0}'. Available mods: {1}".F(name, installedMods.Keys.JoinWith(", ")));
if (!installedMods.TryGetValue(name, out var mod))
throw new InvalidOperationException($"Could not load mod '{name}'. Available mods: {installedMods.Keys.JoinWith(", ")}");
package = mod.Package;
modPackages.Add(package);
@@ -108,7 +104,7 @@ namespace OpenRA.FileSystem
{
package = OpenPackage(name);
if (package == null)
throw new InvalidOperationException("Could not open package '{0}', file not found or its format is not supported.".F(name));
throw new InvalidOperationException($"Could not open package '{name}', file not found or its format is not supported.");
}
Mount(package, explicitName);
@@ -122,8 +118,7 @@ namespace OpenRA.FileSystem
public void Mount(IReadOnlyPackage package, string explicitName = null)
{
var mountCount = 0;
if (mountedPackages.TryGetValue(package, out mountCount))
if (mountedPackages.TryGetValue(package, out var mountCount))
{
// Package is already mounted
// Increment the mount count and bump up the file loading priority
@@ -149,8 +144,7 @@ namespace OpenRA.FileSystem
public bool Unmount(IReadOnlyPackage package)
{
var mountCount = 0;
if (!mountedPackages.TryGetValue(package, out mountCount))
if (!mountedPackages.TryGetValue(package, out var mountCount))
return false;
if (--mountCount <= 0)
@@ -203,17 +197,13 @@ namespace OpenRA.FileSystem
var package = fileIndex[filename]
.LastOrDefault(x => x.Contains(filename));
if (package != null)
return package.GetStream(filename);
return null;
return package?.GetStream(filename);
}
public Stream Open(string filename)
{
Stream s;
if (!TryOpen(filename, out s))
throw new FileNotFoundException("File not found: {0}".F(filename), filename);
if (!TryOpen(filename, out var s))
throw new FileNotFoundException($"File not found: {filename}", filename);
return s;
}
@@ -238,8 +228,7 @@ namespace OpenRA.FileSystem
var explicitSplit = filename.IndexOf('|');
if (explicitSplit > 0)
{
IReadOnlyPackage explicitPackage;
if (explicitMounts.TryGetValue(filename.Substring(0, explicitSplit), out explicitPackage))
if (explicitMounts.TryGetValue(filename.Substring(0, explicitSplit), out var explicitPackage))
{
s = explicitPackage.GetStream(filename.Substring(explicitSplit + 1));
if (s != null)
@@ -274,12 +263,9 @@ namespace OpenRA.FileSystem
{
var explicitSplit = filename.IndexOf('|');
if (explicitSplit > 0)
{
IReadOnlyPackage explicitPackage;
if (explicitMounts.TryGetValue(filename.Substring(0, explicitSplit), out explicitPackage))
if (explicitMounts.TryGetValue(filename.Substring(0, explicitSplit), out var explicitPackage))
if (explicitPackage.Contains(filename.Substring(explicitSplit + 1)))
return true;
}
return fileIndex.ContainsKey(filename);
}
@@ -293,8 +279,7 @@ namespace OpenRA.FileSystem
if (explicitSplit < 0)
return false;
IReadOnlyPackage explicitPackage;
if (!explicitMounts.TryGetValue(filename.Substring(0, explicitSplit), out explicitPackage))
if (!explicitMounts.TryGetValue(filename.Substring(0, explicitSplit), out var explicitPackage))
return false;
if (installedMods[modID].Package == explicitPackage)
@@ -310,7 +295,7 @@ namespace OpenRA.FileSystem
public static string ResolveAssemblyPath(string path, Manifest manifest, InstalledMods installedMods)
{
var explicitSplit = path.IndexOf('|');
if (explicitSplit > 0)
if (explicitSplit > 0 && !path.StartsWith("^"))
{
var parent = path.Substring(0, explicitSplit);
var filename = path.Substring(explicitSplit + 1);
@@ -321,8 +306,7 @@ namespace OpenRA.FileSystem
if (parentPath.StartsWith("$", StringComparison.Ordinal))
{
Manifest mod;
if (!installedMods.TryGetValue(parentPath.Substring(1), out mod))
if (!installedMods.TryGetValue(parentPath.Substring(1), out var mod))
return null;
if (!(mod.Package is Folder))

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -12,6 +12,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace OpenRA.FileSystem
{
@@ -26,16 +27,17 @@ namespace OpenRA.FileSystem
Directory.CreateDirectory(path);
}
public string Name { get { return path; } }
public string Name => path;
public IEnumerable<string> Contents
{
get
{
foreach (var filename in Directory.GetFiles(path, "*", SearchOption.TopDirectoryOnly))
yield return Path.GetFileName(filename);
foreach (var filename in Directory.GetDirectories(path))
yield return Path.GetFileName(filename);
// Order may vary on different file systems and it matters for hashing.
return Directory.GetFiles(path, "*", SearchOption.TopDirectoryOnly)
.Concat(Directory.GetDirectories(path))
.Select(Path.GetFileName)
.OrderBy(f => f);
}
}
@@ -58,17 +60,15 @@ namespace OpenRA.FileSystem
return new Folder(resolvedPath);
// Zip files loaded from Folders (and *only* from Folders) can be read-write
IReadWritePackage readWritePackage;
if (ZipFileLoader.TryParseReadWritePackage(resolvedPath, out readWritePackage))
if (ZipFileLoader.TryParseReadWritePackage(resolvedPath, out var readWritePackage))
return readWritePackage;
// Other package types can be loaded normally
IReadOnlyPackage package;
var s = GetStream(filename);
if (s == null)
return null;
if (context.TryParsePackage(s, filename, out package))
if (context.TryParsePackage(s, filename, out var package))
return package;
s.Dispose();

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -14,7 +14,6 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using ICSharpCode.SharpZipLib.Zip;
using OpenRA.Primitives;
namespace OpenRA.FileSystem
{
@@ -67,8 +66,7 @@ namespace OpenRA.FileSystem
public void Dispose()
{
if (pkg != null)
pkg.Close();
pkg?.Close();
}
public IReadOnlyPackage OpenPackage(string filename, FileSystem context)
@@ -82,12 +80,11 @@ namespace OpenRA.FileSystem
return new ZipFolder(this, filename);
// Other package types can be loaded normally
IReadOnlyPackage package;
var s = GetStream(filename);
if (s == null)
return null;
if (context.TryParsePackage(s, filename, out package))
if (context.TryParsePackage(s, filename, out var package))
return package;
s.Dispose();
@@ -144,8 +141,8 @@ namespace OpenRA.FileSystem
sealed class ZipFolder : IReadOnlyPackage
{
public string Name { get { return path; } }
public ReadOnlyZipFile Parent { get; private set; }
public string Name => path;
public ReadOnlyZipFile Parent { get; }
readonly string path;
public ZipFolder(ReadOnlyZipFile parent, string path)

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -22,7 +22,7 @@ namespace OpenRA
public class Fonts : IGlobalModData
{
[FieldLoader.LoadUsing("LoadFonts")]
[FieldLoader.LoadUsing(nameof(LoadFonts))]
public readonly Dictionary<string, FontData> FontList;
static object LoadFonts(MiniYaml y)

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -16,9 +16,8 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime;
using System.Threading;
using System.Threading.Tasks;
using OpenRA.Graphics;
using OpenRA.Network;
using OpenRA.Primitives;
@@ -30,8 +29,6 @@ namespace OpenRA
{
public static class Game
{
public const int NetTickScale = 3; // 120 ms net tick for 40 ms local tick
public const int Timestep = 40;
public const int TimestepJankThreshold = 250; // Don't catch up for delays larger than 250ms
public static InstalledMods Mods { get; private set; }
@@ -41,6 +38,7 @@ namespace OpenRA
public static Settings Settings;
public static CursorManager Cursor;
public static bool HideCursor;
static WorldRenderer worldRenderer;
static string modLaunchWrapper;
@@ -51,68 +49,94 @@ namespace OpenRA
public static Renderer Renderer;
public static Sound Sound;
public static bool HasInputFocus = false;
public static string EngineVersion { get; private set; }
public static LocalPlayerProfile LocalPlayerProfile;
static Task discoverNat;
static bool takeScreenshot = false;
static Benchmark benchmark = null;
public static event Action OnShellmapLoaded = () => { };
public static OrderManager JoinServer(string host, int port, string password, bool recordReplay = true)
public static OrderManager JoinServer(ConnectionTarget endpoint, string password, bool recordReplay = true)
{
var connection = new NetworkConnection(host, port);
var newConnection = new NetworkConnection(endpoint);
if (recordReplay)
connection.StartRecording(() => { return TimestampedFilename(); });
newConnection.StartRecording(() => { return TimestampedFilename(); });
var om = new OrderManager(host, port, password, connection);
var om = new OrderManager(newConnection);
JoinInner(om);
CurrentServerSettings.Password = password;
CurrentServerSettings.Target = endpoint;
lastConnectionState = ConnectionState.PreConnecting;
ConnectionStateChanged(OrderManager, password, newConnection);
return om;
}
static string TimestampedFilename(bool includemilliseconds = false)
public static string TimestampedFilename(bool includemilliseconds = false, string extra = "")
{
var format = includemilliseconds ? "yyyy-MM-ddTHHmmssfffZ" : "yyyy-MM-ddTHHmmssZ";
return "OpenRA-" + DateTime.UtcNow.ToString(format, CultureInfo.InvariantCulture);
return ModData.Manifest.Id + extra + "-" + DateTime.UtcNow.ToString(format, CultureInfo.InvariantCulture);
}
static void JoinInner(OrderManager om)
{
if (OrderManager != null) OrderManager.Dispose();
// Refresh TextNotificationsManager before the game starts.
TextNotificationsManager.Clear();
// HACK: The shellmap World and OrderManager are owned by the main menu's WorldRenderer instead of Game.
// This allows us to switch Game.OrderManager from the shellmap to the new network connection when joining
// a lobby, while keeping the OrderManager that runs the shellmap intact.
// A matching check in World.Dispose (which is called by WorldRenderer.Dispose) makes sure that we dispose
// the shellmap's OM when a lobby game actually starts.
if (OrderManager?.World == null || OrderManager.World.Type != WorldType.Shellmap)
OrderManager?.Dispose();
OrderManager = om;
lastConnectionState = ConnectionState.PreConnecting;
ConnectionStateChanged(OrderManager);
}
public static void JoinReplay(string replayFile)
{
JoinInner(new OrderManager("<no server>", -1, "", new ReplayConnection(replayFile)));
JoinInner(new OrderManager(new ReplayConnection(replayFile)));
}
static void JoinLocal()
{
JoinInner(new OrderManager("<no server>", -1, "", new EchoConnection()));
JoinInner(new OrderManager(new EchoConnection()));
// Add a spectator client for the local player
// On the shellmap this player is controlling the map via scripted orders
OrderManager.LobbyInfo.Clients.Add(new Session.Client
{
Index = OrderManager.Connection.LocalClientId,
Name = Settings.Player.Name,
PreferredColor = Settings.Player.Color,
Color = Settings.Player.Color,
Faction = "Random",
SpawnPoint = 0,
Team = 0,
State = Session.ClientState.Ready
});
}
// More accurate replacement for Environment.TickCount
static Stopwatch stopwatch = Stopwatch.StartNew();
public static long RunTime { get { return stopwatch.ElapsedMilliseconds; } }
static readonly Stopwatch Stopwatch = Stopwatch.StartNew();
public static long RunTime => Stopwatch.ElapsedMilliseconds;
public static int RenderFrame = 0;
public static int NetFrameNumber { get { return OrderManager.NetFrameNumber; } }
public static int LocalTick { get { return OrderManager.LocalFrameNumber; } }
public static int NetFrameNumber => OrderManager.NetFrameNumber;
public static int LocalTick => OrderManager.LocalFrameNumber;
public static event Action<string, int> OnRemoteDirectConnect = (a, b) => { };
public static event Action<OrderManager> ConnectionStateChanged = _ => { };
public static event Action<ConnectionTarget> OnRemoteDirectConnect = _ => { };
public static event Action<OrderManager, string, NetworkConnection> ConnectionStateChanged = (om, pass, conn) => { };
static ConnectionState lastConnectionState = ConnectionState.PreConnecting;
public static int LocalClientId { get { return OrderManager.Connection.LocalClientId; } }
public static int LocalClientId => OrderManager.Connection.LocalClientId;
public static void RemoteDirectConnect(string host, int port)
public static void RemoteDirectConnect(ConnectionTarget endpoint)
{
OnRemoteDirectConnect(host, port);
OnRemoteDirectConnect(endpoint);
}
// Hacky workaround for orderManager visibility
@@ -155,8 +179,7 @@ namespace OpenRA
internal static void StartGame(string mapUID, WorldType type)
{
// Dispose of the old world before creating a new one.
if (worldRenderer != null)
worldRenderer.Dispose();
worldRenderer?.Dispose();
Cursor.SetCursor(null);
BeforeGameStart();
@@ -165,6 +188,7 @@ namespace OpenRA
using (new PerfTimer("PrepareMap"))
map = ModData.PrepareMap(mapUID);
using (new PerfTimer("NewWorld"))
OrderManager.World = new World(ModData, map, OrderManager, type);
@@ -172,11 +196,13 @@ namespace OpenRA
worldRenderer = new WorldRenderer(ModData, OrderManager.World);
// Proactively collect memory during loading to reduce peak memory.
GC.Collect();
using (new PerfTimer("LoadComplete"))
OrderManager.World.LoadComplete(worldRenderer);
// Proactively collect memory during loading to reduce peak memory.
GC.Collect();
if (OrderManager.GameStarted)
@@ -185,27 +211,44 @@ namespace OpenRA
Ui.MouseFocusWidget = null;
Ui.KeyboardFocusWidget = null;
OrderManager.LocalFrameNumber = 0;
OrderManager.LastTickTime = RunTime;
OrderManager.StartGame();
worldRenderer.RefreshPalette();
Cursor.SetCursor("default");
Cursor.SetCursor(ChromeMetrics.Get<string>("DefaultCursor"));
// Now loading is completed, now is the ideal time to run a GC and compact the LOH.
// - All the temporary garbage created during loading can be collected.
// - Live objects are likely to live for the length of the game or longer,
// thus promoting them into a higher generation is not an issue.
// - We can remove any fragmentation in the LOH caused by temporary loading garbage.
// - A loading screen is visible, so a delay won't matter to the user.
// Much better to clean up now then to drop frames during gameplay for GC pauses.
GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
GC.Collect();
}
public static void RestartGame()
{
var replay = OrderManager.Connection as ReplayConnection;
var replayName = replay != null ? replay.Filename : null;
var replayName = replay?.Filename;
var lobbyInfo = OrderManager.LobbyInfo;
// Reseed the RNG so this isn't an exact repeat of the last game
lobbyInfo.GlobalSettings.RandomSeed = CosmeticRandom.Next();
// Note: the map may have been changed on disk outside the game, changing its UID.
// Use the updated UID if we have tracked the update instead of failing.
lobbyInfo.GlobalSettings.Map = ModData.MapCache.GetUpdatedMap(lobbyInfo.GlobalSettings.Map);
if (lobbyInfo.GlobalSettings.Map == null)
{
Disconnect();
Ui.ResetAll();
LoadShellMap();
return;
}
var orders = new[]
{
Order.Command("sync_lobby {0}".F(lobbyInfo.Serialize())),
Order.Command($"sync_lobby {lobbyInfo.Serialize()}"),
Order.Command("startgame")
};
@@ -234,7 +277,7 @@ namespace OpenRA
LobbyInfoChanged += lobbyReady;
om = JoinServer(IPAddress.Loopback.ToString(), CreateLocalServer(mapUID), "");
om = JoinServer(CreateLocalServer(mapUID), "");
}
public static bool IsHost
@@ -253,40 +296,47 @@ namespace OpenRA
public static void InitializeSettings(Arguments args)
{
Settings = new Settings(Platform.ResolvePath(Path.Combine(Platform.SupportDirPrefix, "settings.yaml")), args);
Settings = new Settings(Path.Combine(Platform.SupportDir, "settings.yaml"), args);
}
public static RunStatus InitializeAndRun(string[] args)
{
Initialize(new Arguments(args));
// Proactively collect memory during loading to reduce peak memory.
GC.Collect();
return Run();
}
static void Initialize(Arguments args)
{
var engineDirArg = args.GetValue("Engine.EngineDir", null);
if (!string.IsNullOrEmpty(engineDirArg))
Platform.OverrideEngineDir(engineDirArg);
var supportDirArg = args.GetValue("Engine.SupportDir", null);
if (!string.IsNullOrEmpty(supportDirArg))
Platform.OverrideSupportDir(supportDirArg);
Console.WriteLine("Platform is {0}", Platform.CurrentPlatform);
Console.WriteLine($"Platform is {Platform.CurrentPlatform}");
// Load the engine version as early as possible so it can be written to exception logs
try
{
EngineVersion = File.ReadAllText(Platform.ResolvePath(Path.Combine(".", "VERSION"))).Trim();
EngineVersion = File.ReadAllText(Path.Combine(Platform.EngineDir, "VERSION")).Trim();
}
catch { }
if (string.IsNullOrEmpty(EngineVersion))
EngineVersion = "Unknown";
Console.WriteLine("Engine version is {0}", EngineVersion);
Console.WriteLine($"Engine version is {EngineVersion}");
Console.WriteLine($"Runtime: {Platform.RuntimeVersion}");
// Special case handling of Game.Mod argument: if it matches a real filesystem path
// then we use this to override the mod search path, and replace it with the mod id
var modID = args.GetValue("Game.Mod", null);
var explicitModPaths = new string[0];
var explicitModPaths = Array.Empty<string>();
if (modID != null && (File.Exists(modID) || Directory.Exists(modID)))
{
explicitModPaths = new[] { modID };
@@ -302,6 +352,7 @@ namespace OpenRA
Log.AddChannel("graphics", "graphics.log");
Log.AddChannel("geoip", "geoip.log");
Log.AddChannel("nat", "nat.log");
Log.AddChannel("client", "client.log");
var platforms = new[] { Settings.Game.Platform, "Default", null };
foreach (var p in platforms)
@@ -312,10 +363,18 @@ namespace OpenRA
Settings.Game.Platform = p;
try
{
var rendererPath = Platform.ResolvePath(Path.Combine(".", "OpenRA.Platforms." + p + ".dll"));
var assembly = Assembly.LoadFile(rendererPath);
var rendererPath = Path.Combine(Platform.BinDir, "OpenRA.Platforms." + p + ".dll");
#if NET5_0_OR_GREATER
var loader = new AssemblyLoader(rendererPath);
var platformType = loader.LoadDefaultAssembly().GetTypes().SingleOrDefault(t => typeof(IPlatform).IsAssignableFrom(t));
#else
// NOTE: This is currently the only use of System.Reflection in this file, so would give an unused using error if we import it above
var assembly = System.Reflection.Assembly.LoadFile(rendererPath);
var platformType = assembly.GetTypes().SingleOrDefault(t => typeof(IPlatform).IsAssignableFrom(t));
#endif
if (platformType == null)
throw new InvalidOperationException("Platform dll must include exactly one IPlatform implementation.");
@@ -327,54 +386,51 @@ namespace OpenRA
}
catch (Exception e)
{
Log.Write("graphics", "{0}", e);
Log.Write("graphics", $"{e}");
Console.WriteLine("Renderer initialization failed. Check graphics.log for details.");
if (Renderer != null)
Renderer.Dispose();
Renderer?.Dispose();
if (Sound != null)
Sound.Dispose();
Sound?.Dispose();
}
}
if (Settings.Server.DiscoverNatDevices)
discoverNat = UPnP.DiscoverNatDevices(Settings.Server.NatDiscoveryTimeout);
Nat.Initialize();
var modSearchArg = args.GetValue("Engine.ModSearchPaths", null);
var modSearchPaths = modSearchArg != null ?
FieldLoader.GetValue<string[]>("Engine.ModsPath", modSearchArg) :
new[] { Path.Combine(".", "mods") };
new[] { Path.Combine(Platform.EngineDir, "mods") };
Mods = new InstalledMods(modSearchPaths, explicitModPaths);
Console.WriteLine("Internal mods:");
foreach (var mod in Mods)
Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Metadata.Title, mod.Value.Metadata.Version);
Console.WriteLine($"\t{mod.Key}: {mod.Value.Metadata.Title} ({mod.Value.Metadata.Version})");
modLaunchWrapper = args.GetValue("Engine.LaunchWrapper", null);
ExternalMods = new ExternalMods();
Manifest currentMod;
if (modID != null && Mods.TryGetValue(modID, out currentMod))
if (modID != null && Mods.TryGetValue(modID, out _))
{
var launchPath = args.GetValue("Engine.LaunchPath", Assembly.GetEntryAssembly().Location);
var launchPath = args.GetValue("Engine.LaunchPath", null);
var launchArgs = new List<string>();
// Sanitize input from platform-specific launchers
// Process.Start requires paths to not be quoted, even if they contain spaces
if (launchPath.First() == '"' && launchPath.Last() == '"')
if (launchPath != null && launchPath.First() == '"' && launchPath.Last() == '"')
launchPath = launchPath.Substring(1, launchPath.Length - 2);
ExternalMods.Register(Mods[modID], launchPath, ModRegistration.User);
// Metadata registration requires an explicit launch path
if (launchPath != null)
ExternalMods.Register(Mods[modID], launchPath, launchArgs, ModRegistration.User);
ExternalMod activeMod;
if (ExternalMods.TryGetValue(ExternalMod.MakeKey(Mods[modID]), out activeMod))
ExternalMods.ClearInvalidRegistrations(activeMod, ModRegistration.User);
ExternalMods.ClearInvalidRegistrations(ModRegistration.User);
}
Console.WriteLine("External mods:");
foreach (var mod in ExternalMods)
Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Title, mod.Value.Version);
Console.WriteLine($"\t{mod.Key}: {mod.Value.Title} ({mod.Value.Version})");
InitializeMod(modID, args);
}
@@ -383,20 +439,17 @@ namespace OpenRA
{
// Clear static state if we have switched mods
LobbyInfoChanged = () => { };
ConnectionStateChanged = om => { };
ConnectionStateChanged = (om, p, conn) => { };
BeforeGameStart = () => { };
OnRemoteDirectConnect = (a, b) => { };
OnRemoteDirectConnect = endpoint => { };
delayedActions = new ActionQueue();
Ui.ResetAll();
if (worldRenderer != null)
worldRenderer.Dispose();
worldRenderer?.Dispose();
worldRenderer = null;
if (server != null)
server.Shutdown();
if (OrderManager != null)
OrderManager.Dispose();
server?.Shutdown();
OrderManager?.Dispose();
if (ModData != null)
{
@@ -410,67 +463,56 @@ namespace OpenRA
throw new InvalidOperationException("Game.Mod argument missing.");
if (!Mods.ContainsKey(mod))
throw new InvalidOperationException("Unknown or invalid mod '{0}'.".F(mod));
throw new InvalidOperationException($"Unknown or invalid mod '{mod}'.");
Console.WriteLine("Loading mod: {0}", mod);
Console.WriteLine($"Loading mod: {mod}");
Sound.StopVideo();
ModData = new ModData(Mods[mod], Mods, true);
LocalPlayerProfile = new LocalPlayerProfile(Platform.ResolvePath(Path.Combine("^", Settings.Game.AuthProfile)), ModData.Manifest.Get<PlayerDatabase>());
LocalPlayerProfile = new LocalPlayerProfile(Path.Combine(Platform.SupportDir, Settings.Game.AuthProfile), ModData.Manifest.Get<PlayerDatabase>());
if (!ModData.LoadScreen.BeforeLoad())
return;
using (new PerfTimer("LoadMaps"))
ModData.MapCache.LoadMaps();
ModData.InitializeLoaders(ModData.DefaultFileSystem);
Renderer.InitializeFonts(ModData);
using (new PerfTimer("LoadMaps"))
ModData.MapCache.LoadMaps();
var grid = ModData.Manifest.Contains<MapGrid>() ? ModData.Manifest.Get<MapGrid>() : null;
Renderer.InitializeDepthBuffer(grid);
if (Cursor != null)
Cursor.Dispose();
Cursor?.Dispose();
Cursor = new CursorManager(ModData.CursorProvider);
var metadata = ModData.Manifest.Metadata;
if (!string.IsNullOrEmpty(metadata.WindowTitle))
Renderer.Window.SetWindowTitle(metadata.WindowTitle);
PerfHistory.Items["render"].HasNormalTick = false;
PerfHistory.Items["batches"].HasNormalTick = false;
PerfHistory.Items["render_world"].HasNormalTick = false;
PerfHistory.Items["render_widgets"].HasNormalTick = false;
PerfHistory.Items["render_flip"].HasNormalTick = false;
PerfHistory.Items["terrain_lighting"].HasNormalTick = false;
JoinLocal();
try
{
if (discoverNat != null)
discoverNat.Wait();
}
catch (Exception e)
{
Console.WriteLine("NAT discovery failed: {0}", e.Message);
Log.Write("nat", e.ToString());
}
ChromeMetrics.TryGet("ChatMessageColor", out chatMessageColor);
ChromeMetrics.TryGet("SystemMessageColor", out systemMessageColor);
ModData.LoadScreen.StartGame(args);
}
public static void LoadEditor(string mapUid)
{
JoinLocal();
StartGame(mapUid, WorldType.Editor);
}
public static void LoadShellMap()
{
var shellmap = ChooseShellmap();
using (new PerfTimer("StartGame"))
{
StartGame(shellmap, WorldType.Shellmap);
@@ -525,17 +567,19 @@ namespace OpenRA
// Note: These delayed actions should only be used by widgets or disposing objects
// - things that depend on a particular world should be queuing them on the world actor.
static volatile ActionQueue delayedActions = new ActionQueue();
static Color systemMessageColor = Color.White;
static Color chatMessageColor = Color.White;
public static void RunAfterTick(Action a) { delayedActions.Add(a, RunTime); }
public static void RunAfterDelay(int delayMilliseconds, Action a) { delayedActions.Add(a, RunTime + delayMilliseconds); }
[TranslationReference("filename")]
static readonly string SavedScreenshot = "saved-screenshot";
static void TakeScreenshotInner()
{
using (new PerfTimer("Renderer.SaveScreenshot"))
{
var mod = ModData.Manifest.Metadata;
var directory = Platform.ResolvePath(Platform.SupportDirPrefix, "Screenshots", ModData.Manifest.Id, mod.Version);
var directory = Path.Combine(Platform.SupportDir, "Screenshots", ModData.Manifest.Id, mod.Version);
Directory.CreateDirectory(directory);
var filename = TimestampedFilename(true);
@@ -543,7 +587,7 @@ namespace OpenRA
Log.Write("debug", "Taking screenshot " + path);
Renderer.SaveScreenshot(path);
Debug("Saved screenshot " + filename);
TextNotificationsManager.Debug(ModData.Translation.GetString(SavedScreenshot, Translation.Arguments("filename", filename)));
}
}
@@ -553,48 +597,29 @@ namespace OpenRA
var world = orderManager.World;
var uiTickDelta = tick - Ui.LastTickTime;
if (uiTickDelta >= Timestep)
if (Ui.LastTickTime.ShouldAdvance(tick))
{
// Explained below for the world tick calculation
var integralTickTimestep = (uiTickDelta / Timestep) * Timestep;
Ui.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : Timestep;
Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, Ui.Tick);
Ui.LastTickTime.AdvanceTickTime(tick);
Sync.RunUnsynced(world, Ui.Tick);
Cursor.Tick();
}
var worldTimestep = world == null ? Timestep : world.IsLoadingGameSave ? 1 : world.Timestep;
var worldTickDelta = tick - orderManager.LastTickTime;
if (worldTimestep != 0 && worldTickDelta >= worldTimestep)
if (orderManager.LastTickTime.ShouldAdvance(tick))
{
using (new PerfSample("tick_time"))
{
// Tick the world to advance the world time to match real time:
// If dt < TickJankThreshold then we should try and catch up by repeatedly ticking
// If dt >= TickJankThreshold then we should accept the jank and progress at the normal rate
// dt is rounded down to an integer tick count in order to preserve fractional tick components.
var integralTickTimestep = (worldTickDelta / worldTimestep) * worldTimestep;
orderManager.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : worldTimestep;
orderManager.LastTickTime.AdvanceTickTime(tick);
Sound.Tick();
Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, orderManager.TickImmediate);
Sync.RunUnsynced(world, orderManager.TickImmediate);
if (world == null)
return;
var isNetTick = LocalTick % NetTickScale == 0;
if (!isNetTick || orderManager.IsReadyForNextFrame)
if (orderManager.TryTick())
{
++orderManager.LocalFrameNumber;
Log.Write("debug", "--Tick: {0} ({1})", LocalTick, isNetTick ? "net" : "local");
if (isNetTick)
orderManager.Tick();
Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, () =>
Sync.RunUnsynced(world, () =>
{
world.OrderGenerator.Tick(world);
});
@@ -603,16 +628,13 @@ namespace OpenRA
PerfHistory.Tick();
}
else if (orderManager.NetFrameNumber == 0)
orderManager.LastTickTime = RunTime;
// Wait until we have done our first world Tick before TickRendering
if (orderManager.LocalFrameNumber > 0)
Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, () => world.TickRender(worldRenderer));
Sync.RunUnsynced(world, () => world.TickRender(worldRenderer));
}
if (benchmark != null)
benchmark.Tick(LocalTick);
benchmark?.Tick(LocalTick);
}
}
@@ -620,10 +642,10 @@ namespace OpenRA
{
PerformDelayedActions();
if (OrderManager.Connection.ConnectionState != lastConnectionState)
if (OrderManager.Connection is NetworkConnection nc && nc.ConnectionState != lastConnectionState)
{
lastConnectionState = OrderManager.Connection.ConnectionState;
ConnectionStateChanged(OrderManager);
lastConnectionState = nc.ConnectionState;
ConnectionStateChanged(OrderManager, null, nc);
}
InnerLogicTick(OrderManager);
@@ -710,6 +732,7 @@ namespace OpenRA
PerfHistory.Items["render_world"].Tick();
PerfHistory.Items["render_widgets"].Tick();
PerfHistory.Items["render_flip"].Tick();
PerfHistory.Items["terrain_lighting"].Tick();
}
static void Loop()
@@ -759,13 +782,20 @@ namespace OpenRA
while (state == RunStatus.Running)
{
// Ideal time between logic updates. Timestep = 0 means the game is paused
// but we still call LogicTick() because it handles pausing internally.
var logicInterval = worldRenderer != null && worldRenderer.World.Timestep != 0 ? worldRenderer.World.Timestep : Timestep;
var logicInterval = Ui.Timestep;
var logicWorld = worldRenderer?.World;
// ReplayTimestep = 0 means the replay is paused: we need to keep logicInterval as UI.Timestep to avoid breakage
if (logicWorld != null && !(logicWorld.IsReplay && logicWorld.ReplayTimestep == 0))
logicInterval = logicWorld == OrderManager.World ? OrderManager.SuggestedTimestep : logicWorld.Timestep;
// Ideal time between screen updates
var maxFramerate = Settings.Graphics.CapFramerate ? Settings.Graphics.MaxFramerate.Clamp(1, 1000) : 1000;
var renderInterval = 1000 / maxFramerate;
var renderInterval = logicInterval;
if (!Settings.Graphics.CapFramerateToGameFps)
{
var maxFramerate = Settings.Graphics.CapFramerate ? Settings.Graphics.MaxFramerate.Clamp(1, 1000) : 1000;
renderInterval = 1000 / maxFramerate;
}
// Tick as fast as possible while restoring game saves, capping rendering at 5 FPS
if (OrderManager.World != null && OrderManager.World.IsLoadingGameSave)
@@ -799,8 +829,7 @@ namespace OpenRA
var haveSomeTimeUntilNextLogic = now < nextLogic;
var isTimeToRender = now >= nextRender;
if ((isTimeToRender && haveSomeTimeUntilNextLogic) || forceRender)
if (!Renderer.WindowIsSuspended && ((isTimeToRender && haveSomeTimeUntilNextLogic) || forceRender))
{
nextRender = now + renderInterval;
@@ -815,6 +844,19 @@ namespace OpenRA
RenderTick();
renderBeforeNextTick = false;
}
// Simulate a render tick if it was time to render but we skip actually rendering
if (Renderer.WindowIsSuspended && isTimeToRender)
{
// Make sure that nextUpdate is set to a proper minimum interval
nextRender = now + renderInterval;
// Still process SDL events to allow a restore to come through
Renderer.Window.PumpInput(new NullInputHandler());
// Ensure that we still logic tick despite not rendering
renderBeforeNextTick = false;
}
}
else
Thread.Sleep((int)(nextUpdate - now));
@@ -836,12 +878,10 @@ namespace OpenRA
finally
{
// Ensure that the active replay is properly saved
if (OrderManager != null)
OrderManager.Dispose();
OrderManager?.Dispose();
}
if (worldRenderer != null)
worldRenderer.Dispose();
worldRenderer?.Dispose();
ModData.Dispose();
ChromeProvider.Deinitialize();
@@ -858,30 +898,9 @@ namespace OpenRA
state = RunStatus.Success;
}
public static void AddSystemLine(string text)
{
AddSystemLine("Battlefield Control", text);
}
public static void AddSystemLine(string name, string text)
{
OrderManager.AddChatLine(name, systemMessageColor, text, systemMessageColor);
}
public static void AddChatLine(string name, Color nameColor, string text)
{
OrderManager.AddChatLine(name, nameColor, text, chatMessageColor);
}
public static void Debug(string s, params object[] args)
{
AddSystemLine("Debug", string.Format(s, args));
}
public static void Disconnect()
{
if (OrderManager.World != null)
OrderManager.World.TraitDict.PrintReport();
OrderManager.World?.TraitDict.PrintReport();
OrderManager.Dispose();
CloseServer();
@@ -890,8 +909,7 @@ namespace OpenRA
public static void CloseServer()
{
if (server != null)
server.Shutdown();
server?.Shutdown();
}
public static T CreateObject<T>(string name)
@@ -899,12 +917,19 @@ namespace OpenRA
return ModData.ObjectCreator.CreateObject<T>(name);
}
public static void CreateServer(ServerSettings settings)
public static ConnectionTarget CreateServer(ServerSettings settings)
{
server = new Server.Server(new IPEndPoint(IPAddress.Any, settings.ListenPort), settings, ModData, ServerType.Multiplayer);
var endpoints = new List<IPEndPoint>
{
new IPEndPoint(IPAddress.IPv6Any, settings.ListenPort),
new IPEndPoint(IPAddress.Any, settings.ListenPort)
};
server = new Server.Server(endpoints, settings, ModData, ServerType.Multiplayer);
return server.GetEndpointForLocalConnection();
}
public static int CreateLocalServer(string map)
public static ConnectionTarget CreateLocalServer(string map)
{
var settings = new ServerSettings()
{
@@ -913,9 +938,16 @@ namespace OpenRA
AdvertiseOnline = false
};
server = new Server.Server(new IPEndPoint(IPAddress.Loopback, 0), settings, ModData, ServerType.Local);
// Always connect to local games using the same loopback connection
// Exposing multiple endpoints introduces a race condition on the client's PlayerIndex (sometimes 0, sometimes 1)
// This would break the Restart button, which relies on the PlayerIndex always being the same for local servers
var endpoints = new List<IPEndPoint>
{
new IPEndPoint(IPAddress.Loopback, 0)
};
server = new Server.Server(endpoints, settings, ModData, ServerType.Local);
return server.Port;
return server.GetEndpointForLocalConnection();
}
public static bool IsCurrentWorld(World world)
@@ -937,16 +969,13 @@ namespace OpenRA
{
var orders = new List<Order>
{
Order.Command("option gamespeed {0}".F("default")),
Order.Command("state {0}".F(Session.ClientState.Ready))
Order.Command("option gamespeed default"),
Order.Command($"state {Session.ClientState.Ready}")
};
var path = Platform.ResolvePath(launchMap);
var map = ModData.MapCache.SingleOrDefault(m => m.Uid == launchMap) ??
ModData.MapCache.SingleOrDefault(m => m.Package.Name == path);
var map = ModData.MapCache.SingleOrDefault(m => m.Uid == launchMap || Path.GetFileName(m.Package.Name) == launchMap);
if (map == null)
throw new InvalidOperationException("Could not find map '{0}'.".F(launchMap));
throw new ArgumentException($"Could not find map '{launchMap}'.");
CreateAndStartLocalServer(map.Uid, orders);
}
@@ -960,4 +989,11 @@ namespace OpenRA
}
}
}
public static class CurrentServerSettings
{
public static string Password;
public static ConnectionTarget Target;
public static ExternalMod ServerExternalMod;
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -33,11 +33,13 @@ namespace OpenRA
public DateTime EndTimeUtc;
/// <summary>Gets the game's duration, from the time the game started until the replay recording stopped.</summary>
public TimeSpan Duration { get { return EndTimeUtc > StartTimeUtc ? EndTimeUtc - StartTimeUtc : TimeSpan.Zero; } }
public IList<Player> Players { get; private set; }
public MapPreview MapPreview { get { return Game.ModData.MapCache[MapUid]; } }
public TimeSpan Duration => EndTimeUtc > StartTimeUtc ? EndTimeUtc - StartTimeUtc : TimeSpan.Zero;
public IList<Player> Players { get; }
public HashSet<int> DisabledSpawnPoints = new HashSet<int>();
public MapPreview MapPreview => Game.ModData.MapCache[MapUid];
public IEnumerable<Player> HumanPlayers { get { return Players.Where(p => p.IsHuman); } }
public bool IsSinglePlayer { get { return HumanPlayers.Count() == 1; } }
public bool IsSinglePlayer => HumanPlayers.Count() == 1;
readonly Dictionary<OpenRA.Player, Player> playersByRuntime;
@@ -74,7 +76,7 @@ namespace OpenRA
}
catch (YamlException)
{
Log.Write("debug", "GameInformation deserialized invalid MiniYaml:\n{0}".F(data));
Log.Write("debug", $"GameInformation deserialized invalid MiniYaml:\n{data}");
throw;
}
}
@@ -87,7 +89,7 @@ namespace OpenRA
};
for (var i = 0; i < Players.Count; i++)
nodes.Add(new MiniYamlNode("Player@{0}".F(i), FieldSaver.Save(Players[i])));
nodes.Add(new MiniYamlNode($"Player@{i}", FieldSaver.Save(Players[i])));
return nodes.WriteToString();
}
@@ -96,10 +98,10 @@ namespace OpenRA
public void AddPlayer(OpenRA.Player runtimePlayer, Session lobbyInfo)
{
if (runtimePlayer == null)
throw new ArgumentNullException("runtimePlayer");
throw new ArgumentNullException(nameof(runtimePlayer));
if (lobbyInfo == null)
throw new ArgumentNullException("lobbyInfo");
throw new ArgumentNullException(nameof(lobbyInfo));
// We don't care about spectators and map players
if (runtimePlayer.NonCombatant || !runtimePlayer.Playable)
@@ -118,11 +120,14 @@ namespace OpenRA
IsBot = runtimePlayer.IsBot,
FactionName = runtimePlayer.Faction.Name,
FactionId = runtimePlayer.Faction.InternalName,
DisplayFactionName = runtimePlayer.DisplayFaction.Name,
DisplayFactionId = runtimePlayer.DisplayFaction.InternalName,
Color = runtimePlayer.Color,
Team = client.Team,
Handicap = client.Handicap,
SpawnPoint = runtimePlayer.SpawnPoint,
IsRandomFaction = runtimePlayer.Faction.InternalName != client.Faction,
IsRandomSpawnPoint = runtimePlayer.SpawnPoint != client.SpawnPoint,
IsRandomSpawnPoint = runtimePlayer.DisplaySpawnPoint == 0,
Fingerprint = client.Fingerprint
};
@@ -133,9 +138,7 @@ namespace OpenRA
/// <summary>Gets the player information for the specified runtime player instance.</summary>
public Player GetPlayer(OpenRA.Player runtimePlayer)
{
Player player;
playersByRuntime.TryGetValue(runtimePlayer, out player);
playersByRuntime.TryGetValue(runtimePlayer, out var player);
return player;
}
@@ -158,9 +161,14 @@ namespace OpenRA
public string FactionId;
public Color Color;
/// <summary>The faction (including Random, etc.) that was selected in the lobby.</summary>
public string DisplayFactionName;
public string DisplayFactionId;
/// <summary>The team ID on start-up, or 0 if the player is not part of a team.</summary>
public int Team;
public int SpawnPoint;
public int Handicap;
/// <summary>True if the faction was chosen at random; otherwise, false.</summary>
public bool IsRandomFaction;
@@ -181,6 +189,9 @@ namespace OpenRA
/// <summary>The time when this player won or lost the game.</summary>
public DateTime OutcomeTimestampUtc;
/// <summary>The frame at which this player disconnected.</summary>
public int DisconnectFrame;
#endregion
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -23,6 +23,7 @@ namespace OpenRA
public class ActorInfo
{
public const string AbstractActorPrefix = "^";
public const char TraitInstanceSeparator = '@';
/// <summary>
/// The actor name can be anything, but the sprites used in the Render*: traits default to this one.
@@ -32,7 +33,7 @@ namespace OpenRA
/// </summary>
public readonly string Name;
readonly TypeDictionary traits = new TypeDictionary();
List<ITraitInfo> constructOrderCache = null;
List<TraitInfo> constructOrderCache = null;
public ActorInfo(ObjectCreator creator, string name, MiniYaml node)
{
@@ -46,7 +47,7 @@ namespace OpenRA
{
// HACK: The linter does not want to crash when a trait doesn't exist but only print an error instead
// LoadTraitInfo will only return null to signal us to abort here if the linter is running
var trait = LoadTraitInfo(creator, t.Key.Split('@')[0], t.Value);
var trait = LoadTraitInfo(creator, t.Key, t.Value);
if (trait != null)
traits.Add(trait);
}
@@ -60,11 +61,11 @@ namespace OpenRA
}
catch (YamlException e)
{
throw new YamlException("Actor type {0}: {1}".F(name, e.Message));
throw new YamlException($"Actor type {name}: {e.Message}");
}
}
public ActorInfo(string name, params ITraitInfo[] traitInfos)
public ActorInfo(string name, params TraitInfo[] traitInfos)
{
Name = name;
foreach (var t in traitInfos)
@@ -72,20 +73,23 @@ namespace OpenRA
traits.TrimExcess();
}
static ITraitInfo LoadTraitInfo(ObjectCreator creator, string traitName, MiniYaml my)
static TraitInfo LoadTraitInfo(ObjectCreator creator, string traitName, MiniYaml my)
{
if (!string.IsNullOrEmpty(my.Value))
throw new YamlException("Junk value `{0}` on trait node {1}"
.F(my.Value, traitName));
throw new YamlException($"Junk value `{my.Value}` on trait node {traitName}");
// HACK: The linter does not want to crash when a trait doesn't exist but only print an error instead
// ObjectCreator will only return null to signal us to abort here if the linter is running
var info = creator.CreateObject<ITraitInfo>(traitName + "Info");
var traitInstance = traitName.Split(TraitInstanceSeparator);
var info = creator.CreateObject<TraitInfo>(traitInstance[0] + "Info");
if (info == null)
return null;
try
{
if (traitInstance.Length > 1)
info.GetType().GetField(nameof(info.InstanceName)).SetValue(info, traitInstance[1]);
FieldLoader.Load(info, my);
}
catch (FieldLoader.MissingFieldsException e)
@@ -97,19 +101,20 @@ namespace OpenRA
return info;
}
public IEnumerable<ITraitInfo> TraitsInConstructOrder()
public IEnumerable<TraitInfo> TraitsInConstructOrder()
{
if (constructOrderCache != null)
return constructOrderCache;
var source = traits.WithInterface<ITraitInfo>().Select(i => new
var source = traits.WithInterface<TraitInfo>().Select(i => new
{
Trait = i,
Type = i.GetType(),
Dependencies = PrerequisitesOf(i).ToList()
Dependencies = PrerequisitesOf(i).ToList(),
OptionalDependencies = OptionalPrerequisitesOf(i).ToList()
}).ToList();
var resolved = source.Where(s => !s.Dependencies.Any()).ToList();
var resolved = source.Where(s => s.Dependencies.Count == 0 && s.OptionalDependencies.Count == 0).ToList();
var unresolved = source.Except(resolved);
var testResolve = new Func<Type, Type, bool>((a, b) => a == b || a.IsAssignableFrom(b));
@@ -118,7 +123,9 @@ namespace OpenRA
var more = unresolved.Where(u =>
u.Dependencies.All(d => // To be resolvable, all dependencies must be satisfied according to the following conditions:
resolved.Exists(r => testResolve(d, r.Type)) && // There must exist a resolved trait that meets the dependency.
!unresolved.Any(u1 => testResolve(d, u1.Type)))); // All matching traits that meet this dependency must be resolved first.
!unresolved.Any(u1 => testResolve(d, u1.Type))) && // All matching traits that meet this dependency must be resolved first.
u.OptionalDependencies.All(d => // To be resolvable, all optional dependencies must be satisfied according to the following condition:
!unresolved.Any(u1 => testResolve(d, u1.Type)))); // All matching traits that meet this optional dependencies must be resolved first.
// Continue resolving traits as long as possible.
// Each time we resolve some traits, this means dependencies for other traits may then be possible to satisfy in the next pass.
@@ -138,7 +145,9 @@ namespace OpenRA
foreach (var u in unresolved)
{
var deps = u.Dependencies.Where(d => !resolved.Exists(r => r.Type == d));
exceptionString += u.Type + ": { " + string.Join(", ", deps) + " }\r\n";
var optDeps = u.OptionalDependencies.Where(d => !resolved.Exists(r => r.Type == d));
var allDeps = string.Join(", ", deps.Select(o => o.ToString()).Concat(optDeps.Select(o => $"[{o}]")));
exceptionString += $"{u.Type}: {{ {allDeps} }}\r\n";
}
throw new YamlException(exceptionString);
@@ -148,7 +157,7 @@ namespace OpenRA
return constructOrderCache;
}
public static IEnumerable<Type> PrerequisitesOf(ITraitInfo info)
public static IEnumerable<Type> PrerequisitesOf(TraitInfo info)
{
return info
.GetType()
@@ -157,6 +166,15 @@ namespace OpenRA
.Select(t => t.GetGenericArguments()[0]);
}
public static IEnumerable<Type> OptionalPrerequisitesOf(TraitInfo info)
{
return info
.GetType()
.GetInterfaces()
.Where(t => t.IsGenericType && t.GetGenericTypeDefinition() == typeof(NotBefore<>))
.Select(t => t.GetGenericArguments()[0]);
}
public bool HasTraitInfo<T>() where T : ITraitInfoInterface { return traits.Contains<T>(); }
public T TraitInfo<T>() where T : ITraitInfoInterface { return traits.Get<T>(); }
public T TraitInfoOrDefault<T>() where T : ITraitInfoInterface { return traits.GetOrDefault<T>(); }

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -9,7 +9,6 @@
*/
#endregion
using System.IO;
using OpenRA.FileSystem;
namespace OpenRA.GameRules
@@ -41,8 +40,7 @@ namespace OpenRA.GameRules
public void Load(IReadOnlyFileSystem fileSystem)
{
Stream stream;
if (!fileSystem.TryOpen(Filename, out stream))
if (!fileSystem.TryOpen(Filename, out var stream))
return;
try
@@ -50,8 +48,7 @@ namespace OpenRA.GameRules
Exists = true;
foreach (var loader in Game.ModData.SoundLoaders)
{
ISoundFormat soundFormat;
if (loader.TryParseSound(stream, out soundFormat))
if (loader.TryParseSound(stream, out var soundFormat))
{
Length = (int)soundFormat.LengthInSeconds;
soundFormat.Dispose();

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -22,12 +22,12 @@ namespace OpenRA
{
public class Ruleset
{
public readonly IReadOnlyDictionary<string, ActorInfo> Actors;
public readonly ActorInfoDictionary Actors;
public readonly IReadOnlyDictionary<string, WeaponInfo> Weapons;
public readonly IReadOnlyDictionary<string, SoundInfo> Voices;
public readonly IReadOnlyDictionary<string, SoundInfo> Notifications;
public readonly IReadOnlyDictionary<string, MusicInfo> Music;
public readonly TileSet TileSet;
public readonly ITerrainInfo TerrainInfo;
public readonly SequenceProvider Sequences;
public readonly IReadOnlyDictionary<string, MiniYamlNode> ModelSequences;
@@ -37,16 +37,16 @@ namespace OpenRA
IReadOnlyDictionary<string, SoundInfo> voices,
IReadOnlyDictionary<string, SoundInfo> notifications,
IReadOnlyDictionary<string, MusicInfo> music,
TileSet tileSet,
ITerrainInfo terrainInfo,
SequenceProvider sequences,
IReadOnlyDictionary<string, MiniYamlNode> modelSequences)
{
Actors = actors;
Actors = new ActorInfoDictionary(actors);
Weapons = weapons;
Voices = voices;
Notifications = notifications;
Music = music;
TileSet = tileSet;
TerrainInfo = terrainInfo;
Sequences = sequences;
ModelSequences = modelSequences;
@@ -60,15 +60,14 @@ namespace OpenRA
}
catch (YamlException e)
{
throw new YamlException("Actor type {0}: {1}".F(a.Name, e.Message));
throw new YamlException($"Actor type {a.Name}: {e.Message}");
}
}
}
foreach (var weapon in Weapons)
{
var projectileLoaded = weapon.Value.Projectile as IRulesetLoaded<WeaponInfo>;
if (projectileLoaded != null)
if (weapon.Value.Projectile is IRulesetLoaded<WeaponInfo> projectileLoaded)
{
try
{
@@ -76,14 +75,13 @@ namespace OpenRA
}
catch (YamlException e)
{
throw new YamlException("Projectile type {0}: {1}".F(weapon.Key, e.Message));
throw new YamlException($"Projectile type {weapon.Key}: {e.Message}");
}
}
foreach (var warhead in weapon.Value.Warheads)
{
var cacher = warhead as IRulesetLoaded<WeaponInfo>;
if (cacher != null)
if (warhead is IRulesetLoaded<WeaponInfo> cacher)
{
try
{
@@ -91,7 +89,7 @@ namespace OpenRA
}
catch (YamlException e)
{
throw new YamlException("Weapon type {0}: {1}".F(weapon.Key, e.Message));
throw new YamlException($"Weapon type {weapon.Key}: {e.Message}");
}
}
}
@@ -117,7 +115,7 @@ namespace OpenRA
if (filterNode != null)
yamlNodes = yamlNodes.Where(k => !filterNode(k));
return new ReadOnlyDictionary<string, T>(yamlNodes.ToDictionaryWithConflictLog(k => k.Key.ToLowerInvariant(), makeObject, "LoadFromManifest<" + name + ">"));
return yamlNodes.ToDictionaryWithConflictLog(k => k.Key.ToLowerInvariant(), makeObject, "LoadFromManifest<" + name + ">");
}
public static Ruleset LoadDefaults(ModData modData)
@@ -133,7 +131,7 @@ namespace OpenRA
filterNode: n => n.Key.StartsWith(ActorInfo.AbstractActorPrefix, StringComparison.Ordinal));
var weapons = MergeOrDefault("Manifest,Weapons", fs, m.Weapons, null, null,
k => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value));
k => new WeaponInfo(k.Value));
var voices = MergeOrDefault("Manifest,Voices", fs, m.Voices, null, null,
k => new SoundInfo(k.Value));
@@ -171,10 +169,10 @@ namespace OpenRA
public static Ruleset LoadDefaultsForTileSet(ModData modData, string tileSet)
{
var dr = modData.DefaultRules;
var ts = modData.DefaultTileSets[tileSet];
var terrainInfo = modData.DefaultTerrainInfo[tileSet];
var sequences = modData.DefaultSequences[tileSet];
return new Ruleset(dr.Actors, dr.Weapons, dr.Voices, dr.Notifications, dr.Music, ts, sequences, dr.ModelSequences);
return new Ruleset(dr.Actors, dr.Weapons, dr.Voices, dr.Notifications, dr.Music, terrainInfo, sequences, dr.ModelSequences);
}
public static Ruleset Load(ModData modData, IReadOnlyFileSystem fileSystem, string tileSet,
@@ -192,7 +190,7 @@ namespace OpenRA
filterNode: n => n.Key.StartsWith(ActorInfo.AbstractActorPrefix, StringComparison.Ordinal));
var weapons = MergeOrDefault("Weapons", fileSystem, m.Weapons, mapWeapons, dr.Weapons,
k => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value));
k => new WeaponInfo(k.Value));
var voices = MergeOrDefault("Voices", fileSystem, m.Voices, mapVoices, dr.Voices,
k => new SoundInfo(k.Value));
@@ -203,19 +201,19 @@ namespace OpenRA
var music = MergeOrDefault("Music", fileSystem, m.Music, mapMusic, dr.Music,
k => new MusicInfo(k.Key, k.Value));
// TODO: Add support for merging custom tileset modifications
var ts = modData.DefaultTileSets[tileSet];
// TODO: Add support for merging custom terrain modifications
var terrainInfo = modData.DefaultTerrainInfo[tileSet];
// TODO: Top-level dictionary should be moved into the Ruleset instead of in its own object
var sequences = mapSequences == null ? modData.DefaultSequences[tileSet] :
new SequenceProvider(fileSystem, modData, ts, mapSequences);
new SequenceProvider(fileSystem, modData, tileSet, mapSequences);
var modelSequences = dr.ModelSequences;
if (mapModelSequences != null)
modelSequences = MergeOrDefault("ModelSequences", fileSystem, m.ModelSequences, mapModelSequences, dr.ModelSequences,
k => k);
ruleset = new Ruleset(actors, weapons, voices, notifications, music, ts, sequences, modelSequences);
ruleset = new Ruleset(actors, weapons, voices, notifications, music, terrainInfo, sequences, modelSequences);
};
if (modData.IsOnMainThread)
@@ -237,7 +235,7 @@ namespace OpenRA
static bool AnyCustomYaml(MiniYaml yaml)
{
return yaml != null && (yaml.Value != null || yaml.Nodes.Any());
return yaml != null && (yaml.Value != null || yaml.Nodes.Count > 0);
}
static bool AnyFlaggedTraits(ModData modData, List<MiniYamlNode> actors)
@@ -250,7 +248,7 @@ namespace OpenRA
{
var traitName = traitNode.Key.Split('@')[0];
var traitType = modData.ObjectCreator.FindType(traitName + "Info");
if (traitType != null && traitType.GetInterface("ILobbyCustomRulesIgnore") == null)
if (traitType != null && traitType.GetInterface(nameof(ILobbyCustomRulesIgnore)) == null)
return true;
}
catch (Exception ex)

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -33,23 +33,28 @@ namespace OpenRA.GameRules
{
FieldLoader.Load(this, y);
VoicePools = Exts.Lazy(() => Voices.ToDictionary(a => a.Key, a => new SoundPool(1f, a.Value)));
VoicePools = Exts.Lazy(() => Voices.ToDictionary(a => a.Key, a => new SoundPool(1f, SoundPool.DefaultInterruptType, a.Value)));
NotificationsPools = Exts.Lazy(() => ParseSoundPool(y, "Notifications"));
}
Dictionary<string, SoundPool> ParseSoundPool(MiniYaml y, string key)
static Dictionary<string, SoundPool> ParseSoundPool(MiniYaml y, string key)
{
var ret = new Dictionary<string, SoundPool>();
var classifiction = y.Nodes.First(x => x.Key == key);
foreach (var t in classifiction.Value.Nodes)
{
var volumeModifier = 1f;
var volumeModifierNode = t.Value.Nodes.FirstOrDefault(x => x.Key == "VolumeModifier");
var volumeModifierNode = t.Value.Nodes.FirstOrDefault(x => x.Key == nameof(SoundPool.VolumeModifier));
if (volumeModifierNode != null)
volumeModifier = FieldLoader.GetValue<float>(volumeModifierNode.Key, volumeModifierNode.Value.Value);
var interruptType = SoundPool.DefaultInterruptType;
var interruptTypeNode = t.Value.Nodes.FirstOrDefault(x => x.Key == nameof(SoundPool.InterruptType));
if (interruptTypeNode != null)
interruptType = FieldLoader.GetValue<SoundPool.InterruptType>(interruptTypeNode.Key, interruptTypeNode.Value.Value);
var names = FieldLoader.GetValue<string[]>(t.Key, t.Value.Value);
var sp = new SoundPool(volumeModifier, names);
var sp = new SoundPool(volumeModifier, interruptType, names);
ret.Add(t.Key, sp);
}
@@ -59,13 +64,17 @@ namespace OpenRA.GameRules
public class SoundPool
{
public enum InterruptType { DoNotPlay, Interrupt, Overlap }
public const InterruptType DefaultInterruptType = InterruptType.DoNotPlay;
public readonly float VolumeModifier;
public readonly InterruptType Type;
readonly string[] clips;
readonly List<string> liveclips = new List<string>();
public SoundPool(float volumeModifier, params string[] clips)
public SoundPool(float volumeModifier, InterruptType interruptType, params string[] clips)
{
VolumeModifier = volumeModifier;
Type = interruptType;
this.clips = clips;
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -24,8 +24,8 @@ namespace OpenRA.GameRules
public int[] DamageModifiers;
public int[] InaccuracyModifiers;
public int[] RangeModifiers;
public int Facing;
public Func<int> CurrentMuzzleFacing;
public WAngle Facing;
public Func<WAngle> CurrentMuzzleFacing;
public WPos Source;
public Func<WPos> CurrentSource;
public Actor SourceActor;
@@ -36,8 +36,10 @@ namespace OpenRA.GameRules
public class WarheadArgs
{
public WeaponInfo Weapon;
public int[] DamageModifiers = { };
public int[] DamageModifiers = Array.Empty<int>();
public WPos? Source;
public WRot ImpactOrientation;
public WPos ImpactPosition;
public Actor SourceActor;
public Target WeaponTarget;
@@ -45,11 +47,22 @@ namespace OpenRA.GameRules
{
Weapon = args.Weapon;
DamageModifiers = args.DamageModifiers;
ImpactPosition = args.PassiveTarget;
Source = args.Source;
SourceActor = args.SourceActor;
WeaponTarget = args.GuidedTarget;
}
// For places that only want to update some of the fields (usually DamageModifiers)
public WarheadArgs(WarheadArgs args)
{
Weapon = args.Weapon;
DamageModifiers = args.DamageModifiers;
Source = args.Source;
SourceActor = args.SourceActor;
WeaponTarget = args.WeaponTarget;
}
// Default empty constructor for callers that want to initialize fields themselves
public WarheadArgs() { }
}
@@ -92,6 +105,12 @@ namespace OpenRA.GameRules
[Desc("What types of targets are unaffected.", "Overrules ValidTargets.")]
public readonly BitSet<TargetableType> InvalidTargets;
static readonly BitSet<TargetableType> TargetTypeAir = new BitSet<TargetableType>("Air");
[Desc("If weapon is not directly targeting an actor and targeted position is above this altitude,",
"the weapon will ignore terrain target types and only check TargetTypeAir for validity.")]
public readonly WDist AirThreshold = new WDist(128);
[Desc("Delay in ticks between firing shots from the same ammo magazine. If one entry, it will be used for all bursts.",
"If multiple entries, their number needs to match Burst - 1.")]
public readonly int[] BurstDelays = { 5 };
@@ -102,13 +121,18 @@ namespace OpenRA.GameRules
[Desc("Does this weapon aim at the target's center regardless of other targetable offsets?")]
public readonly bool TargetActorCenter = false;
[FieldLoader.LoadUsing("LoadProjectile")]
[FieldLoader.LoadUsing(nameof(LoadProjectile))]
public readonly IProjectileInfo Projectile;
[FieldLoader.LoadUsing("LoadWarheads")]
[FieldLoader.LoadUsing(nameof(LoadWarheads))]
public readonly List<IWarhead> Warheads = new List<IWarhead>();
public WeaponInfo(string name, MiniYaml content)
/// <summary>
/// This constructor is used solely for documentation generation!
/// </summary>
public WeaponInfo() { }
public WeaponInfo(MiniYaml content)
{
// Resolve any weapon-level yaml inheritance or removals
// HACK: The "Defaults" sequence syntax prevents us from doing this generally during yaml parsing
@@ -118,10 +142,13 @@ namespace OpenRA.GameRules
static object LoadProjectile(MiniYaml yaml)
{
MiniYaml proj;
if (!yaml.ToDictionary().TryGetValue("Projectile", out proj))
if (!yaml.ToDictionary().TryGetValue("Projectile", out var proj))
return null;
var ret = Game.CreateObject<IProjectileInfo>(proj.Value + "Info");
if (ret == null)
return null;
FieldLoader.Load(ret, proj);
return ret;
}
@@ -132,6 +159,9 @@ namespace OpenRA.GameRules
foreach (var node in yaml.Nodes.Where(n => n.Key.StartsWith("Warhead")))
{
var ret = Game.CreateObject<IWarhead>(node.Value.Value + "Warhead");
if (ret == null)
continue;
FieldLoader.Load(ret, node.Value);
retList.Add(ret);
}
@@ -145,7 +175,7 @@ namespace OpenRA.GameRules
}
/// <summary>Checks if the weapon is valid against (can target) the target.</summary>
public bool IsValidAgainst(Target target, World world, Actor firedBy)
public bool IsValidAgainst(in Target target, World world, Actor firedBy)
{
if (target.Type == TargetType.Actor)
return IsValidAgainst(target.Actor, firedBy);
@@ -155,6 +185,10 @@ namespace OpenRA.GameRules
if (target.Type == TargetType.Terrain)
{
var dat = world.Map.DistanceAboveTerrain(target.CenterPosition);
if (dat > AirThreshold)
return IsValidTarget(TargetTypeAir);
var cell = world.Map.CellContaining(target.CenterPosition);
if (!world.Map.Contains(cell))
return false;
@@ -198,20 +232,24 @@ namespace OpenRA.GameRules
}
/// <summary>Applies all the weapon's warheads to the target.</summary>
public void Impact(Target target, WarheadArgs args)
public void Impact(in Target target, WarheadArgs args)
{
var world = args.SourceActor.World;
foreach (var warhead in Warheads)
{
if (warhead.Delay > 0)
world.AddFrameEndTask(w => w.Add(new DelayedImpact(warhead.Delay, warhead, target, args)));
{
// Lambdas can't use 'in' variables, so capture a copy for later
var delayedTarget = target;
world.AddFrameEndTask(w => w.Add(new DelayedImpact(warhead.Delay, warhead, delayedTarget, args)));
}
else
warhead.DoImpact(target, args);
}
}
/// <summary>Applies all the weapon's warheads to the target. Only use for projectile-less, special-case impacts.</summary>
public void Impact(Target target, Actor firedBy)
public void Impact(in Target target, Actor firedBy)
{
// The impact will happen immediately at target.CenterPosition.
var args = new WarheadArgs

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -10,27 +10,49 @@
#endregion
using System.Collections.Generic;
using System.Linq;
namespace OpenRA
{
public class GameSpeed
{
[Translate]
public readonly string Name = "Default";
public readonly int Timestep = 40;
public readonly int OrderLatency = 3;
[FieldLoader.Require]
public readonly string Name;
[FieldLoader.Require]
public readonly int Timestep;
[FieldLoader.Require]
public readonly int OrderLatency;
}
public class GameSpeeds : IGlobalModData
{
[FieldLoader.LoadUsing("LoadSpeeds")]
[FieldLoader.Require]
public readonly string DefaultSpeed;
[FieldLoader.LoadUsing(nameof(LoadSpeeds))]
public readonly Dictionary<string, GameSpeed> Speeds;
static object LoadSpeeds(MiniYaml y)
{
var ret = new Dictionary<string, GameSpeed>();
foreach (var node in y.Nodes)
ret.Add(node.Key, FieldLoader.Load<GameSpeed>(node.Value));
var speedsNode = y.Nodes.FirstOrDefault(n => n.Key == "Speeds");
if (speedsNode == null)
throw new YamlException("Error parsing GameSpeeds: Missing Speeds node!");
foreach (var node in speedsNode.Value.Nodes)
{
try
{
ret.Add(node.Key, FieldLoader.Load<GameSpeed>(node.Value));
}
catch (FieldLoader.MissingFieldsException e)
{
var label = e.Missing.Length > 1 ? "Required properties missing" : "Required property missing";
throw new YamlException($"Error parsing GameSpeed {node.Key}: {label}: {e.Missing.JoinWith(", ")}");
}
}
return ret;
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -23,7 +23,7 @@ namespace OpenRA.Graphics
public bool IsDecoration { get; set; }
readonly SequenceProvider sequenceProvider;
readonly Func<int> facingFunc;
readonly Func<WAngle> facingFunc;
readonly Func<bool> paused;
int frame;
@@ -33,15 +33,15 @@ namespace OpenRA.Graphics
Action tickFunc = () => { };
public Animation(World world, string name)
: this(world, name, () => 0) { }
: this(world, name, () => WAngle.Zero) { }
public Animation(World world, string name, Func<int> facingFunc)
public Animation(World world, string name, Func<WAngle> facingFunc)
: this(world, name, facingFunc, null) { }
public Animation(World world, string name, Func<bool> paused)
: this(world, name, () => 0, paused) { }
: this(world, name, () => WAngle.Zero, paused) { }
public Animation(World world, string name, Func<int> facingFunc, Func<bool> paused)
public Animation(World world, string name, Func<WAngle> facingFunc, Func<bool> paused)
{
sequenceProvider = world.Map.Rules.Sequences;
Name = name.ToLowerInvariant();
@@ -49,42 +49,51 @@ namespace OpenRA.Graphics
this.paused = paused;
}
public int CurrentFrame { get { return backwards ? CurrentSequence.Length - frame - 1 : frame; } }
public Sprite Image { get { return CurrentSequence.GetSprite(CurrentFrame, facingFunc()); } }
public int CurrentFrame => backwards ? CurrentSequence.Length - frame - 1 : frame;
public IRenderable[] Render(WPos pos, WVec offset, int zOffset, PaletteReference palette, float scale)
public Sprite Image => CurrentSequence.GetSprite(CurrentFrame, facingFunc());
public IRenderable[] Render(WPos pos, in WVec offset, int zOffset, PaletteReference palette)
{
var imageRenderable = new SpriteRenderable(Image, pos, offset, CurrentSequence.ZOffset + zOffset, palette, scale, IsDecoration);
var tintModifiers = CurrentSequence.IgnoreWorldTint ? TintModifiers.IgnoreWorldTint : TintModifiers.None;
var alpha = CurrentSequence.GetAlpha(CurrentFrame);
var (image, rotation) = CurrentSequence.GetSpriteWithRotation(CurrentFrame, facingFunc());
var imageRenderable = new SpriteRenderable(image, pos, offset, CurrentSequence.ZOffset + zOffset, palette, CurrentSequence.Scale, alpha, float3.Ones, tintModifiers, IsDecoration,
rotation);
if (CurrentSequence.ShadowStart >= 0)
{
var shadow = CurrentSequence.GetShadow(CurrentFrame, facingFunc());
var shadowRenderable = new SpriteRenderable(shadow, pos, offset, CurrentSequence.ShadowZOffset + zOffset, palette, scale, true);
var shadowRenderable = new SpriteRenderable(shadow, pos, offset, CurrentSequence.ShadowZOffset + zOffset, palette, CurrentSequence.Scale, 1f, float3.Ones, tintModifiers,
true, rotation);
return new IRenderable[] { shadowRenderable, imageRenderable };
}
return new IRenderable[] { imageRenderable };
}
public IRenderable[] RenderUI(WorldRenderer wr, int2 pos, WVec offset, int zOffset, PaletteReference palette, float scale)
public IRenderable[] RenderUI(WorldRenderer wr, int2 pos, in WVec offset, int zOffset, PaletteReference palette, float scale = 1f, float rotation = 0f)
{
scale *= CurrentSequence.Scale;
var screenOffset = (scale * wr.ScreenVectorComponents(offset)).XY.ToInt2();
var imagePos = pos + screenOffset - new int2((int)(scale * Image.Size.X / 2), (int)(scale * Image.Size.Y / 2));
var imageRenderable = new UISpriteRenderable(Image, WPos.Zero + offset, imagePos, CurrentSequence.ZOffset + zOffset, palette, scale);
var alpha = CurrentSequence.GetAlpha(CurrentFrame);
var imageRenderable = new UISpriteRenderable(Image, WPos.Zero + offset, imagePos, CurrentSequence.ZOffset + zOffset, palette, scale, alpha, rotation);
if (CurrentSequence.ShadowStart >= 0)
{
var shadow = CurrentSequence.GetShadow(CurrentFrame, facingFunc());
var shadowPos = pos - new int2((int)(scale * shadow.Size.X / 2), (int)(scale * shadow.Size.Y / 2));
var shadowRenderable = new UISpriteRenderable(shadow, WPos.Zero + offset, shadowPos, CurrentSequence.ShadowZOffset + zOffset, palette, scale);
var shadowRenderable = new UISpriteRenderable(shadow, WPos.Zero + offset, shadowPos, CurrentSequence.ShadowZOffset + zOffset, palette, scale, 1f, rotation);
return new IRenderable[] { shadowRenderable, imageRenderable };
}
return new IRenderable[] { imageRenderable };
}
public Rectangle ScreenBounds(WorldRenderer wr, WPos pos, WVec offset, float scale)
public Rectangle ScreenBounds(WorldRenderer wr, WPos pos, in WVec offset)
{
var scale = CurrentSequence.Scale;
var xy = wr.ScreenPxPosition(pos) + wr.ScreenPxOffset(offset);
var cb = CurrentSequence.Bounds;
return Rectangle.FromLTRB(
@@ -96,7 +105,7 @@ namespace OpenRA.Graphics
public IRenderable[] Render(WPos pos, PaletteReference palette)
{
return Render(pos, WVec.Zero, 0, palette, 1f);
return Render(pos, WVec.Zero, 0, palette);
}
public void Play(string sequenceName)
@@ -107,7 +116,7 @@ namespace OpenRA.Graphics
int CurrentSequenceTickOrDefault()
{
const int DefaultTick = 40; // 25 fps == 40 ms
return CurrentSequence != null ? CurrentSequence.Tick : DefaultTick;
return CurrentSequence?.Tick ?? DefaultTick;
}
void PlaySequence(string sequenceName)
@@ -156,7 +165,7 @@ namespace OpenRA.Graphics
{
frame = CurrentSequence.Length - 1;
tickFunc = () => { };
if (after != null) after();
after?.Invoke();
}
};
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -35,21 +35,21 @@ namespace OpenRA.Graphics
ZOffset = zOffset;
}
public IRenderable[] Render(Actor self, WorldRenderer wr, PaletteReference pal, float scale)
public IRenderable[] Render(Actor self, PaletteReference pal)
{
var center = self.CenterPosition;
var offset = OffsetFunc != null ? OffsetFunc() : WVec.Zero;
var offset = OffsetFunc?.Invoke() ?? WVec.Zero;
var z = (ZOffset != null) ? ZOffset(center + offset) : 0;
return Animation.Render(center, offset, z, pal, scale);
var z = ZOffset?.Invoke(center + offset) ?? 0;
return Animation.Render(center, offset, z, pal);
}
public Rectangle ScreenBounds(Actor self, WorldRenderer wr, float scale)
public Rectangle ScreenBounds(Actor self, WorldRenderer wr)
{
var center = self.CenterPosition;
var offset = OffsetFunc != null ? OffsetFunc() : WVec.Zero;
var offset = OffsetFunc?.Invoke() ?? WVec.Zero;
return Animation.ScreenBounds(wr, center, offset, scale);
return Animation.ScreenBounds(wr, center, offset);
}
public static implicit operator AnimationWithOffset(Animation a)

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -52,12 +52,12 @@ namespace OpenRA.Graphics
public readonly Dictionary<string, Rectangle> Regions = new Dictionary<string, Rectangle>();
}
public static IReadOnlyDictionary<string, Collection> Collections { get; private set; }
public static IReadOnlyDictionary<string, Collection> Collections => collections;
static Dictionary<string, Collection> collections;
static Dictionary<string, Pair<Sheet, int>> cachedSheets;
static Dictionary<string, (Sheet Sheet, int Density)> cachedSheets;
static Dictionary<string, Dictionary<string, Sprite>> cachedSprites;
static Dictionary<string, Sprite[]> cachedPanelSprites;
static Dictionary<Collection, Pair<Sheet, int>> cachedCollectionSheets;
static Dictionary<Collection, (Sheet Sheet, int)> cachedCollectionSheets;
static IReadOnlyFileSystem fileSystem;
static float dpiScale = 1;
@@ -72,12 +72,10 @@ namespace OpenRA.Graphics
fileSystem = modData.DefaultFileSystem;
collections = new Dictionary<string, Collection>();
cachedSheets = new Dictionary<string, Pair<Sheet, int>>();
cachedSheets = new Dictionary<string, (Sheet, int)>();
cachedSprites = new Dictionary<string, Dictionary<string, Sprite>>();
cachedPanelSprites = new Dictionary<string, Sprite[]>();
cachedCollectionSheets = new Dictionary<Collection, Pair<Sheet, int>>();
Collections = new ReadOnlyDictionary<string, Collection>(collections);
cachedCollectionSheets = new Dictionary<Collection, (Sheet, int)>();
var chrome = MiniYaml.Merge(modData.Manifest.Chrome
.Select(s => MiniYaml.FromStream(fileSystem.Open(s), s)));
@@ -91,7 +89,7 @@ namespace OpenRA.Graphics
{
if (cachedSheets != null)
foreach (var sheet in cachedSheets.Values)
sheet.First.Dispose();
sheet.Sheet.Dispose();
collections = null;
cachedSheets = null;
@@ -108,12 +106,10 @@ namespace OpenRA.Graphics
collections.Add(name, FieldLoader.Load<Collection>(yaml));
}
static Pair<Sheet, int> SheetForCollection(Collection c)
static (Sheet Sheet, int Density) SheetForCollection(Collection c)
{
Pair<Sheet, int> sheetDensity;
// Outer cache avoids recalculating image names
if (!cachedCollectionSheets.TryGetValue(c, out sheetDensity))
if (!cachedCollectionSheets.TryGetValue(c, out (Sheet, int) sheetDensity))
{
var image = c.Image;
var density = 1;
@@ -137,7 +133,7 @@ namespace OpenRA.Graphics
sheet.GetTexture().ScaleFilter = TextureScaleFilter.Linear;
sheetDensity = Pair.New(sheet, density);
sheetDensity = (sheet, density);
cachedSheets.Add(image, sheetDensity);
}
@@ -148,25 +144,27 @@ namespace OpenRA.Graphics
}
public static Sprite GetImage(string collectionName, string imageName)
{
var image = TryGetImage(collectionName, imageName);
if (image == null)
throw new ArgumentException($"Sprite `{collectionName}/{imageName}` was not found.");
return image;
}
public static Sprite TryGetImage(string collectionName, string imageName)
{
if (string.IsNullOrEmpty(collectionName))
return null;
// Cached sprite
Dictionary<string, Sprite> cachedCollection;
Sprite sprite;
if (cachedSprites.TryGetValue(collectionName, out cachedCollection) && cachedCollection.TryGetValue(imageName, out sprite))
if (cachedSprites.TryGetValue(collectionName, out var cachedCollection) && cachedCollection.TryGetValue(imageName, out var sprite))
return sprite;
Collection collection;
if (!collections.TryGetValue(collectionName, out collection))
{
Log.Write("debug", "Could not find collection '{0}'", collectionName);
if (!collections.TryGetValue(collectionName, out var collection))
return null;
}
Rectangle mi;
if (!collection.Regions.TryGetValue(imageName, out mi))
if (!collection.Regions.TryGetValue(imageName, out var mi))
return null;
// Cache the sprite
@@ -177,35 +175,39 @@ namespace OpenRA.Graphics
cachedSprites.Add(collectionName, cachedCollection);
}
var image = new Sprite(sheetDensity.First, sheetDensity.Second * mi, TextureChannel.RGBA, 1f / sheetDensity.Second);
var image = new Sprite(sheetDensity.Sheet, sheetDensity.Density * mi, TextureChannel.RGBA, 1f / sheetDensity.Density);
cachedCollection.Add(imageName, image);
return image;
}
public static Sprite[] GetPanelImages(string collectionName)
{
var panel = TryGetPanelImages(collectionName);
if (panel == null)
throw new ArgumentException($"Panel `{collectionName}` was not found.");
return panel;
}
public static Sprite[] TryGetPanelImages(string collectionName)
{
if (string.IsNullOrEmpty(collectionName))
return null;
// Cached sprite
Sprite[] cachedSprites;
if (cachedPanelSprites.TryGetValue(collectionName, out cachedSprites))
if (cachedPanelSprites.TryGetValue(collectionName, out var cachedSprites))
return cachedSprites;
Collection collection;
if (!collections.TryGetValue(collectionName, out collection))
{
Log.Write("debug", "Could not find collection '{0}'", collectionName);
if (!collections.TryGetValue(collectionName, out var collection))
return null;
}
Sprite[] sprites;
if (collection.PanelRegion != null)
{
if (collection.PanelRegion.Length != 8)
{
Log.Write("debug", "Collection '{0}' does not define a valid PanelRegion", collectionName);
Log.Write("debug", $"Collection '{collectionName}' does not define a valid PanelRegion");
return null;
}
@@ -214,36 +216,41 @@ namespace OpenRA.Graphics
var pr = collection.PanelRegion;
var ps = collection.PanelSides;
var sides = new[]
var sides = new (PanelSides PanelSides, Rectangle Bounds)[]
{
Pair.New(PanelSides.Top | PanelSides.Left, new Rectangle(pr[0], pr[1], pr[2], pr[3])),
Pair.New(PanelSides.Top, new Rectangle(pr[0] + pr[2], pr[1], pr[4], pr[3])),
Pair.New(PanelSides.Top | PanelSides.Right, new Rectangle(pr[0] + pr[2] + pr[4], pr[1], pr[6], pr[3])),
Pair.New(PanelSides.Left, new Rectangle(pr[0], pr[1] + pr[3], pr[2], pr[5])),
Pair.New(PanelSides.Center, new Rectangle(pr[0] + pr[2], pr[1] + pr[3], pr[4], pr[5])),
Pair.New(PanelSides.Right, new Rectangle(pr[0] + pr[2] + pr[4], pr[1] + pr[3], pr[6], pr[5])),
Pair.New(PanelSides.Bottom | PanelSides.Left, new Rectangle(pr[0], pr[1] + pr[3] + pr[5], pr[2], pr[7])),
Pair.New(PanelSides.Bottom, new Rectangle(pr[0] + pr[2], pr[1] + pr[3] + pr[5], pr[4], pr[7])),
Pair.New(PanelSides.Bottom | PanelSides.Right, new Rectangle(pr[0] + pr[2] + pr[4], pr[1] + pr[3] + pr[5], pr[6], pr[7]))
(PanelSides.Top | PanelSides.Left, new Rectangle(pr[0], pr[1], pr[2], pr[3])),
(PanelSides.Top, new Rectangle(pr[0] + pr[2], pr[1], pr[4], pr[3])),
(PanelSides.Top | PanelSides.Right, new Rectangle(pr[0] + pr[2] + pr[4], pr[1], pr[6], pr[3])),
(PanelSides.Left, new Rectangle(pr[0], pr[1] + pr[3], pr[2], pr[5])),
(PanelSides.Center, new Rectangle(pr[0] + pr[2], pr[1] + pr[3], pr[4], pr[5])),
(PanelSides.Right, new Rectangle(pr[0] + pr[2] + pr[4], pr[1] + pr[3], pr[6], pr[5])),
(PanelSides.Bottom | PanelSides.Left, new Rectangle(pr[0], pr[1] + pr[3] + pr[5], pr[2], pr[7])),
(PanelSides.Bottom, new Rectangle(pr[0] + pr[2], pr[1] + pr[3] + pr[5], pr[4], pr[7])),
(PanelSides.Bottom | PanelSides.Right, new Rectangle(pr[0] + pr[2] + pr[4], pr[1] + pr[3] + pr[5], pr[6], pr[7]))
};
sprites = sides.Select(x => ps.HasSide(x.First) ? new Sprite(sheetDensity.First, sheetDensity.Second * x.Second, TextureChannel.RGBA, 1f / sheetDensity.Second) : null)
sprites = sides.Select(x => ps.HasSide(x.PanelSides) ? new Sprite(sheetDensity.Sheet, sheetDensity.Density * x.Bounds, TextureChannel.RGBA, 1f / sheetDensity.Density) : null)
.ToArray();
}
else
{
// PERF: We don't need to search for images if there are no definitions.
// PERF: It's more efficient to send an empty array rather than an array of 9 nulls.
if (!collection.Regions.Any())
return Array.Empty<Sprite>();
// Support manual definitions for unusual dialog layouts
sprites = new[]
{
GetImage(collectionName, "corner-tl"),
GetImage(collectionName, "border-t"),
GetImage(collectionName, "corner-tr"),
GetImage(collectionName, "border-l"),
GetImage(collectionName, "background"),
GetImage(collectionName, "border-r"),
GetImage(collectionName, "corner-bl"),
GetImage(collectionName, "border-b"),
GetImage(collectionName, "corner-br")
TryGetImage(collectionName, "corner-tl"),
TryGetImage(collectionName, "border-t"),
TryGetImage(collectionName, "corner-tr"),
TryGetImage(collectionName, "border-l"),
TryGetImage(collectionName, "background"),
TryGetImage(collectionName, "border-r"),
TryGetImage(collectionName, "corner-bl"),
TryGetImage(collectionName, "border-b"),
TryGetImage(collectionName, "corner-br")
};
}
@@ -256,8 +263,7 @@ namespace OpenRA.Graphics
if (string.IsNullOrEmpty(collectionName))
return new Size(0, 0);
Collection collection;
if (!collections.TryGetValue(collectionName, out collection))
if (!collections.TryGetValue(collectionName, out var collection))
{
Log.Write("debug", "Could not find collection '{0}'", collectionName);
return new Size(0, 0);

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -35,7 +35,7 @@ namespace OpenRA.Graphics
Cursor cursor;
bool isLocked = false;
int2 lockedPosition;
bool hardwareCursorsDisabled = false;
readonly bool hardwareCursorsDisabled = false;
bool hardwareCursorsDoubled = false;
public CursorManager(CursorProvider cursorProvider)
@@ -69,9 +69,16 @@ namespace OpenRA.Graphics
// Hotspot is specified relative to the center of the frame
var hotspot = f.Offset.ToInt2() - kv.Value.Hotspot - new int2(f.Size) / 2;
// SheetBuilder expects data in BGRA
var data = FrameToBGRA(kv.Key, f, palette);
c.Sprites[c.Length++] = sheetBuilder.Add(data, f.Size, 0, hotspot);
// Resolve indexed data to real colours
var data = f.Data;
var type = f.Type;
if (type == SpriteFrameType.Indexed8)
{
data = ConvertIndexedToBgra(kv.Key, f, palette);
type = SpriteFrameType.Bgra32;
}
c.Sprites[c.Length++] = sheetBuilder.Add(data, type, f.Size, 0, hotspot);
// Bounds relative to the hotspot
c.Bounds = Rectangle.Union(c.Bounds, new Rectangle(hotspot, f.Size));
@@ -99,34 +106,28 @@ namespace OpenRA.Graphics
// Dispose any existing cursors to avoid leaking native resources
ClearHardwareCursors();
try
foreach (var kv in cursors)
{
foreach (var kv in cursors)
var template = kv.Value;
for (var i = 0; i < template.Sprites.Length; i++)
{
var template = kv.Value;
for (var i = 0; i < template.Sprites.Length; i++)
if (template.Cursors[i] != null)
template.Cursors[i].Dispose();
// Calculate the padding to position the frame within sequenceBounds
var paddingTL = -(template.Bounds.Location - template.Sprites[i].Offset.XY.ToInt2());
var paddingBR = template.PaddedSize - new int2(template.Sprites[i].Bounds.Size) - paddingTL;
var hardwareCursor = CreateHardwareCursor(kv.Key, template.Sprites[i], paddingTL, paddingBR, -template.Bounds.Location);
if (hardwareCursor != null)
template.Cursors[i] = hardwareCursor;
else
{
if (template.Cursors[i] != null)
template.Cursors[i].Dispose();
// Calculate the padding to position the frame within sequenceBounds
var paddingTL = -(template.Bounds.Location - template.Sprites[i].Offset.XY.ToInt2());
var paddingBR = template.PaddedSize - new int2(template.Sprites[i].Bounds.Size) - paddingTL;
template.Cursors[i] = CreateHardwareCursor(kv.Key, template.Sprites[i], paddingTL, paddingBR, -template.Bounds.Location);
Log.Write("debug", $"Failed to initialize hardware cursor for {template.Name}.");
Console.WriteLine($"Failed to initialize hardware cursor for {template.Name}.");
}
}
}
catch (Exception e)
{
Log.Write("debug", "Failed to initialize hardware cursors. Falling back to software cursors.");
Log.Write("debug", "Error was: " + e.Message);
Console.WriteLine("Failed to initialize hardware cursors. Falling back to software cursors.");
Console.WriteLine("Error was: " + e.Message);
ClearHardwareCursors();
}
hardwareCursorsDoubled = graphicSettings.CursorDouble;
}
@@ -170,10 +171,11 @@ namespace OpenRA.Graphics
if (cursor != null && frame >= cursor.Cursors.Length)
frame %= cursor.Cursors.Length;
if (cursor == null || isLocked)
var hardwareCursor = cursor?.Cursors[frame];
if (hardwareCursor == null || isLocked)
Game.Renderer.Window.SetHardwareCursor(null);
else
Game.Renderer.Window.SetHardwareCursor(cursor.Cursors[frame]);
Game.Renderer.Window.SetHardwareCursor(hardwareCursor);
}
public void Render(Renderer renderer)
@@ -189,17 +191,17 @@ namespace OpenRA.Graphics
// Render cursor in software
var doubleCursor = graphicSettings.CursorDouble;
var cursorSprite = cursor.Sprites[frame % cursor.Length];
var cursorSize = doubleCursor ? 2.0f * cursorSprite.Size : cursorSprite.Size;
var cursorScale = doubleCursor ? 2 : 1;
// Cursor is rendered in native window coordinates
// Apply same scaling rules as hardware cursors
if (Game.Renderer.NativeWindowScale > 1.5f)
cursorSize = 2 * cursorSize;
cursorScale *= 2;
var mousePos = isLocked ? lockedPosition : Viewport.LastMousePos;
renderer.RgbaSpriteRenderer.DrawSprite(cursorSprite,
mousePos,
cursorSize / Game.Renderer.WindowScale);
cursorScale / Game.Renderer.WindowScale);
}
public void Lock()
@@ -217,34 +219,27 @@ namespace OpenRA.Graphics
Update();
}
public static byte[] FrameToBGRA(string name, ISpriteFrame frame, ImmutablePalette palette)
public static byte[] ConvertIndexedToBgra(string name, ISpriteFrame frame, ImmutablePalette palette)
{
// Data is already in BGRA format
if (frame.Type == SpriteFrameType.BGRA)
return frame.Data;
if (frame.Type != SpriteFrameType.Indexed8)
throw new ArgumentException("ConvertIndexedToBgra requires input frames to be indexed.", nameof(frame));
// Cursors may be either native BGRA or Indexed.
// Indexed sprites are converted to BGRA using the referenced palette.
// All palettes must be explicitly referenced, even if they are embedded in the sprite.
if (frame.Type == SpriteFrameType.Indexed && palette == null)
throw new InvalidOperationException("Cursor sequence `{0}` attempted to load an indexed sprite but does not define Palette".F(name));
if (palette == null)
throw new InvalidOperationException($"Cursor sequence `{name}` attempted to load an indexed sprite but does not define Palette");
var width = frame.Size.Width;
var height = frame.Size.Height;
var data = new byte[4 * width * height];
for (var j = 0; j < height; j++)
unsafe
{
for (var i = 0; i < width; i++)
// Cast the data to an int array so we can copy the src data directly
fixed (byte* bd = &data[0])
{
var bytes = BitConverter.GetBytes(palette[frame.Data[j * width + i]]);
var c = palette[frame.Data[j * width + i]];
var k = 4 * (j * width + i);
// Convert RGBA to BGRA
data[k] = bytes[2];
data[k + 1] = bytes[1];
data[k + 2] = bytes[0];
data[k + 3] = bytes[3];
var rgba = (uint*)bd;
for (var j = 0; j < height; j++)
for (var i = 0; i < width; i++)
rgba[j * width + i] = palette[frame.Data[j * width + i]];
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -31,15 +31,14 @@ namespace OpenRA.Graphics
// Overwrite previous definitions if there are duplicates
var pals = new Dictionary<string, IProvidesCursorPaletteInfo>();
foreach (var p in modData.DefaultRules.Actors["world"].TraitInfos<IProvidesCursorPaletteInfo>())
foreach (var p in modData.DefaultRules.Actors[SystemActors.World].TraitInfos<IProvidesCursorPaletteInfo>())
if (p.Palette != null)
pals[p.Palette] = p;
Palettes = nodesDict["Cursors"].Nodes.Select(n => n.Value.Value)
.Where(p => p != null)
.Distinct()
.ToDictionary(p => p, p => pals[p].ReadPalette(modData.DefaultFileSystem))
.AsReadOnly();
.ToDictionary(p => p, p => pals[p].ReadPalette(modData.DefaultFileSystem));
var frameCache = new FrameCache(fileSystem, modData.SpriteLoaders);
var cursors = new Dictionary<string, CursorSequence>();
@@ -47,7 +46,7 @@ namespace OpenRA.Graphics
foreach (var sequence in s.Value.Nodes)
cursors.Add(sequence.Key, new CursorSequence(frameCache, sequence.Key, s.Key, s.Value.Value, sequence.Value));
Cursors = cursors.AsReadOnly();
Cursors = cursors;
}
public bool HasCursorSequence(string cursor)
@@ -60,7 +59,7 @@ namespace OpenRA.Graphics
try { return Cursors[cursor]; }
catch (KeyNotFoundException)
{
throw new InvalidOperationException("Cursor does not have a sequence `{0}`".F(cursor));
throw new InvalidOperationException($"Cursor does not have a sequence `{cursor}`");
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -31,8 +31,10 @@ namespace OpenRA.Graphics
Palette = palette;
Name = name;
Frames = cache[cursorSrc].Skip(Start).ToArray();
if ((d.ContainsKey("Length") && d["Length"].Value == "*") || (d.ContainsKey("End") && d["End"].Value == "*"))
Length = Frames.Length - Start;
Length = Frames.Length;
else if (d.ContainsKey("Length"))
Length = Exts.ParseIntegerInvariant(d["Length"].Value);
else if (d.ContainsKey("End"))
@@ -40,22 +42,17 @@ namespace OpenRA.Graphics
else
Length = 1;
Frames = cache[cursorSrc]
.Skip(Start)
.Take(Length)
.ToArray();
Frames = Frames.Take(Length).ToArray();
if (d.ContainsKey("X"))
{
int x;
Exts.TryParseIntegerInvariant(d["X"].Value, out x);
Exts.TryParseIntegerInvariant(d["X"].Value, out var x);
Hotspot = Hotspot.WithX(x);
}
if (d.ContainsKey("Y"))
{
int y;
Exts.TryParseIntegerInvariant(d["Y"].Value, out y);
Exts.TryParseIntegerInvariant(d["Y"].Value, out var y);
Hotspot = Hotspot.WithY(y);
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -17,76 +17,94 @@ namespace OpenRA.Graphics
{
public sealed class HardwarePalette : IDisposable
{
public ITexture Texture { get; private set; }
public ITexture Texture { get; }
public ITexture ColorShifts { get; }
public int Height { get; private set; }
readonly Dictionary<string, ImmutablePalette> palettes = new Dictionary<string, ImmutablePalette>();
readonly Dictionary<string, MutablePalette> modifiablePalettes = new Dictionary<string, MutablePalette>();
readonly IReadOnlyDictionary<string, MutablePalette> readOnlyModifiablePalettes;
readonly Dictionary<string, MutablePalette> mutablePalettes = new Dictionary<string, MutablePalette>();
readonly Dictionary<string, int> indices = new Dictionary<string, int>();
byte[] buffer = new byte[0];
byte[] buffer = Array.Empty<byte>();
float[] colorShiftBuffer = Array.Empty<float>();
public HardwarePalette()
{
Texture = Game.Renderer.Context.CreateTexture();
readOnlyModifiablePalettes = modifiablePalettes.AsReadOnly();
ColorShifts = Game.Renderer.Context.CreateTexture();
}
public bool Contains(string name)
{
return modifiablePalettes.ContainsKey(name) || palettes.ContainsKey(name);
return mutablePalettes.ContainsKey(name) || palettes.ContainsKey(name);
}
public IPalette GetPalette(string name)
{
MutablePalette mutable;
if (modifiablePalettes.TryGetValue(name, out mutable))
if (mutablePalettes.TryGetValue(name, out var mutable))
return mutable.AsReadOnly();
ImmutablePalette immutable;
if (palettes.TryGetValue(name, out immutable))
if (palettes.TryGetValue(name, out var immutable))
return immutable;
throw new InvalidOperationException("Palette `{0}` does not exist".F(name));
throw new InvalidOperationException($"Palette `{name}` does not exist");
}
public int GetPaletteIndex(string name)
{
int ret;
if (!indices.TryGetValue(name, out ret))
throw new InvalidOperationException("Palette `{0}` does not exist".F(name));
if (!indices.TryGetValue(name, out var ret))
throw new InvalidOperationException($"Palette `{name}` does not exist");
return ret;
}
public void AddPalette(string name, ImmutablePalette p, bool allowModifiers)
{
if (palettes.ContainsKey(name))
throw new InvalidOperationException("Palette {0} has already been defined".F(name));
throw new InvalidOperationException($"Palette {name} has already been defined");
int index = palettes.Count;
// PERF: the first row in the palette textures is reserved as a placeholder for non-indexed sprites
// that do not have a color-shift applied. This provides a quick shortcut to avoid querying the
// color-shift texture for every pixel only to find that most are not shifted.
var index = palettes.Count + 1;
indices.Add(name, index);
palettes.Add(name, p);
if (palettes.Count > Height)
if (index >= Height)
{
Height = Exts.NextPowerOf2(palettes.Count);
Height = Exts.NextPowerOf2(index + 1);
Array.Resize(ref buffer, Height * Palette.Size * 4);
Array.Resize(ref colorShiftBuffer, Height * 4);
}
if (allowModifiers)
modifiablePalettes.Add(name, new MutablePalette(p));
mutablePalettes.Add(name, new MutablePalette(p));
else
CopyPaletteToBuffer(index, p);
}
public void ReplacePalette(string name, IPalette p)
{
if (modifiablePalettes.ContainsKey(name))
CopyPaletteToBuffer(indices[name], modifiablePalettes[name] = new MutablePalette(p));
if (mutablePalettes.ContainsKey(name))
CopyPaletteToBuffer(indices[name], mutablePalettes[name] = new MutablePalette(p));
else if (palettes.ContainsKey(name))
CopyPaletteToBuffer(indices[name], palettes[name] = new ImmutablePalette(p));
else
throw new InvalidOperationException("Palette `{0}` does not exist".F(name));
throw new InvalidOperationException($"Palette `{name}` does not exist");
CopyBufferToTexture();
}
public void SetColorShift(string name, float hueOffset, float satOffset, float minHue, float maxHue)
{
var index = GetPaletteIndex(name);
colorShiftBuffer[4 * index + 0] = hueOffset;
colorShiftBuffer[4 * index + 1] = satOffset;
colorShiftBuffer[4 * index + 2] = minHue;
colorShiftBuffer[4 * index + 3] = maxHue;
}
public bool HasColorShift(string name)
{
var index = GetPaletteIndex(name);
return colorShiftBuffer[4 * index + 2] != 0 || colorShiftBuffer[4 * index + 3] != 0;
}
public void Initialize()
{
CopyModifiablePalettesToBuffer();
@@ -100,26 +118,27 @@ namespace OpenRA.Graphics
void CopyModifiablePalettesToBuffer()
{
foreach (var kvp in modifiablePalettes)
foreach (var kvp in mutablePalettes)
CopyPaletteToBuffer(indices[kvp.Key], kvp.Value);
}
void CopyBufferToTexture()
{
Texture.SetData(buffer, Palette.Size, Height);
ColorShifts.SetFloatData(colorShiftBuffer, 1, Height);
}
public void ApplyModifiers(IEnumerable<IPaletteModifier> paletteMods)
{
foreach (var mod in paletteMods)
mod.AdjustPalette(readOnlyModifiablePalettes);
mod.AdjustPalette(mutablePalettes);
// Update our texture with the changes.
CopyModifiablePalettesToBuffer();
CopyBufferToTexture();
// Reset modified palettes back to their original colors, ready for next time.
foreach (var kvp in modifiablePalettes)
foreach (var kvp in mutablePalettes)
{
var originalPalette = palettes[kvp.Key];
var modifiedPalette = kvp.Value;
@@ -130,6 +149,7 @@ namespace OpenRA.Graphics
public void Dispose()
{
Texture.Dispose();
ColorShifts.Dispose();
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -10,6 +10,7 @@
#endregion
using System;
using System.Collections.Generic;
using OpenRA.FileSystem;
using OpenRA.Primitives;
@@ -29,7 +30,7 @@ namespace OpenRA.Graphics
Rectangle AggregateBounds { get; }
}
public struct ModelRenderData
public readonly struct ModelRenderData
{
public readonly int Start;
public readonly int Count;
@@ -45,6 +46,7 @@ namespace OpenRA.Graphics
public interface IModelCache : IDisposable
{
IModel GetModel(string model);
IModel GetModelSequence(string model, string sequence);
bool HasModelSequence(string model, string sequence);
IVertexBuffer<Vertex> VertexBuffer { get; }
@@ -62,10 +64,15 @@ namespace OpenRA.Graphics
class PlaceholderModelCache : IModelCache
{
public IVertexBuffer<Vertex> VertexBuffer { get { throw new NotImplementedException(); } }
public IVertexBuffer<Vertex> VertexBuffer => throw new NotImplementedException();
public void Dispose() { }
public IModel GetModel(string model)
{
throw new NotImplementedException();
}
public IModel GetModelSequence(string model, string sequence)
{
throw new NotImplementedException();
@@ -77,6 +84,7 @@ namespace OpenRA.Graphics
}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "IDE0060:Remove unused parameter", Justification = "Load game API")]
public PlaceholderModelSequenceLoader(ModData modData) { }
public IModelCache CacheModels(IReadOnlyFileSystem fileSystem, ModData modData, IReadOnlyDictionary<string, MiniYamlNode> modelDefinitions)

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -10,21 +10,20 @@
#endregion
using System;
using System.Collections.Generic;
using OpenRA.Primitives;
namespace OpenRA.Graphics
{
public struct ModelAnimation
public readonly struct ModelAnimation
{
public readonly IModel Model;
public readonly Func<WVec> OffsetFunc;
public readonly Func<IEnumerable<WRot>> RotationFunc;
public readonly Func<WRot> RotationFunc;
public readonly Func<bool> DisableFunc;
public readonly Func<uint> FrameFunc;
public readonly bool ShowShadow;
public ModelAnimation(IModel model, Func<WVec> offset, Func<IEnumerable<WRot>> rotation, Func<bool> disable, Func<uint> frame, bool showshadow)
public ModelAnimation(IModel model, Func<WVec> offset, Func<WRot> rotation, Func<bool> disable, Func<uint> frame, bool showshadow)
{
Model = model;
OffsetFunc = offset;
@@ -47,12 +46,6 @@ namespace OpenRA.Graphics
xy.Y + (int)(r.Bottom * scale));
}
public bool IsVisible
{
get
{
return DisableFunc == null || !DisableFunc();
}
}
public bool IsVisible => DisableFunc == null || !DisableFunc();
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -42,13 +42,14 @@ namespace OpenRA.Graphics
static readonly float[] ZVector = new float[] { 0, 0, 1, 1 };
static readonly float[] FlipMtx = Util.ScaleMatrix(1, -1, 1);
static readonly float[] ShadowScaleFlipMtx = Util.ScaleMatrix(2, -2, 2);
static readonly float[] GroundNormal = { 0, 0, 1, 1 };
readonly Renderer renderer;
readonly IShader shader;
readonly Dictionary<Sheet, IFrameBuffer> mappedBuffers = new Dictionary<Sheet, IFrameBuffer>();
readonly Stack<KeyValuePair<Sheet, IFrameBuffer>> unmappedBuffers = new Stack<KeyValuePair<Sheet, IFrameBuffer>>();
readonly List<Pair<Sheet, Action>> doRender = new List<Pair<Sheet, Action>>();
readonly List<(Sheet Sheet, Action Func)> doRender = new List<(Sheet, Action)>();
SheetBuilder sheetBuilderForFrame;
bool isInFrame;
@@ -64,7 +65,7 @@ namespace OpenRA.Graphics
shader.SetTexture("Palette", palette);
}
public void SetViewportParams(Size screen, int2 scroll)
public void SetViewportParams()
{
var a = 2f / renderer.SheetSize;
var view = new[]
@@ -79,8 +80,8 @@ namespace OpenRA.Graphics
}
public ModelRenderProxy RenderAsync(
WorldRenderer wr, IEnumerable<ModelAnimation> models, WRot camera, float scale,
float[] groundNormal, WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
WorldRenderer wr, IEnumerable<ModelAnimation> models, in WRot camera, float scale,
in WRot groundOrientation, in WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
PaletteReference color, PaletteReference normals, PaletteReference shadowPalette)
{
if (!isInFrame)
@@ -92,7 +93,10 @@ namespace OpenRA.Graphics
// Correct for bogus light source definition
var lightYaw = Util.MakeFloatMatrix(new WRot(WAngle.Zero, WAngle.Zero, -lightSource.Yaw).AsMatrix());
var lightPitch = Util.MakeFloatMatrix(new WRot(WAngle.Zero, -lightSource.Pitch, WAngle.Zero).AsMatrix());
var shadowTransform = Util.MatrixMultiply(lightPitch, lightYaw);
var ground = Util.MakeFloatMatrix(groundOrientation.AsMatrix());
var shadowTransform = Util.MatrixMultiply(Util.MatrixMultiply(lightPitch, lightYaw), Util.MatrixInverse(ground));
var groundNormal = Util.MatrixVectorMultiply(ground, GroundNormal);
var invShadowTransform = Util.MatrixInverse(shadowTransform);
var cameraTransform = Util.MakeFloatMatrix(camera.AsMatrix());
@@ -114,8 +118,7 @@ namespace OpenRA.Graphics
var offsetVec = Util.MatrixVectorMultiply(invCameraTransform, wr.ScreenVector(m.OffsetFunc()));
var offsetTransform = Util.TranslationMatrix(offsetVec[0], offsetVec[1], offsetVec[2]);
var worldTransform = m.RotationFunc().Aggregate(Util.IdentityMatrix(),
(x, y) => Util.MatrixMultiply(Util.MakeFloatMatrix(y.AsMatrix()), x));
var worldTransform = Util.MakeFloatMatrix(m.RotationFunc().AsMatrix());
worldTransform = Util.MatrixMultiply(scaleTransform, worldTransform);
worldTransform = Util.MatrixMultiply(offsetTransform, worldTransform);
@@ -161,10 +164,8 @@ namespace OpenRA.Graphics
}
// Shadows are rendered at twice the resolution to reduce artifacts
Size spriteSize, shadowSpriteSize;
int2 spriteOffset, shadowSpriteOffset;
CalculateSpriteGeometry(tl, br, 1, out spriteSize, out spriteOffset);
CalculateSpriteGeometry(stl, sbr, 2, out shadowSpriteSize, out shadowSpriteOffset);
CalculateSpriteGeometry(tl, br, 1, out var spriteSize, out var spriteOffset);
CalculateSpriteGeometry(stl, sbr, 2, out var shadowSpriteSize, out var shadowSpriteOffset);
if (sheetBuilderForFrame == null)
sheetBuilderForFrame = new SheetBuilder(SheetType.BGRA, AllocateSheet);
@@ -181,7 +182,7 @@ namespace OpenRA.Graphics
var correctionTransform = Util.MatrixMultiply(translateMtx, FlipMtx);
var shadowCorrectionTransform = Util.MatrixMultiply(shadowTranslateMtx, ShadowScaleFlipMtx);
doRender.Add(Pair.New<Sheet, Action>(sprite.Sheet, () =>
doRender.Add((sprite.Sheet, () =>
{
foreach (var m in models)
{
@@ -189,8 +190,7 @@ namespace OpenRA.Graphics
var offsetVec = Util.MatrixVectorMultiply(invCameraTransform, wr.ScreenVector(m.OffsetFunc()));
var offsetTransform = Util.TranslationMatrix(offsetVec[0], offsetVec[1], offsetVec[2]);
var rotations = m.RotationFunc().Aggregate(Util.IdentityMatrix(),
(x, y) => Util.MatrixMultiply(Util.MakeFloatMatrix(y.AsMatrix()), x));
var rotations = Util.MakeFloatMatrix(m.RotationFunc().AsMatrix());
var worldTransform = Util.MatrixMultiply(scaleTransform, rotations);
worldTransform = Util.MatrixMultiply(offsetTransform, worldTransform);
@@ -209,7 +209,7 @@ namespace OpenRA.Graphics
var t = m.Model.TransformationMatrix(i, frame);
var it = Util.MatrixInverse(t);
if (it == null)
throw new InvalidOperationException("Failed to invert the transformed matrix of frame {0} during RenderAsync.".F(i));
throw new InvalidOperationException($"Failed to invert the transformed matrix of frame {i} during RenderAsync.");
// Transform light vector from shadow -> world -> limb coords
var lightDirection = ExtractRotationVector(Util.MatrixMultiply(it, lightTransform));
@@ -326,16 +326,16 @@ namespace OpenRA.Graphics
foreach (var v in doRender)
{
// Change sheet
if (v.First != currentSheet)
if (v.Sheet != currentSheet)
{
if (fbo != null)
DisableFrameBuffer(fbo);
currentSheet = v.First;
currentSheet = v.Sheet;
fbo = EnableFrameBuffer(currentSheet);
}
v.Second();
v.Func();
}
if (fbo != null)

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -42,9 +42,10 @@ namespace OpenRA.Graphics
class ReadOnlyPalette : IPalette
{
IPalette palette;
readonly IPalette palette;
public ReadOnlyPalette(IPalette palette) { this.palette = palette; }
public uint this[int index] { get { return palette[index]; } }
public uint this[int index] => palette[index];
public void CopyToArray(Array destination, int destinationOffset)
{
palette.CopyToArray(destination, destinationOffset);
@@ -56,28 +57,25 @@ namespace OpenRA.Graphics
{
readonly uint[] colors = new uint[Palette.Size];
public uint this[int index]
{
get { return colors[index]; }
}
public uint this[int index] => colors[index];
public void CopyToArray(Array destination, int destinationOffset)
{
Buffer.BlockCopy(colors, 0, destination, destinationOffset * 4, Palette.Size * 4);
}
public ImmutablePalette(string filename, int[] remap)
public ImmutablePalette(string filename, int[] remapTransparent, int[] remap)
{
using (var s = File.OpenRead(filename))
LoadFromStream(s, remap);
LoadFromStream(s, remapTransparent, remap);
}
public ImmutablePalette(Stream s, int[] remapShadow)
public ImmutablePalette(Stream s, int[] remapTransparent, int[] remapShadow)
{
LoadFromStream(s, remapShadow);
LoadFromStream(s, remapTransparent, remapShadow);
}
void LoadFromStream(Stream s, int[] remapShadow)
void LoadFromStream(Stream s, int[] remapTransparent, int[] remapShadow)
{
using (var reader = new BinaryReader(s))
for (var i = 0; i < Palette.Size; i++)
@@ -94,7 +92,9 @@ namespace OpenRA.Graphics
colors[i] = (uint)((255 << 24) | (r << 16) | (g << 8) | b);
}
colors[0] = 0; // Convert black background to transparency.
foreach (var i in remapTransparent)
colors[i] = 0;
foreach (var i in remapShadow)
colors[i] = 140u << 24;
}
@@ -126,8 +126,8 @@ namespace OpenRA.Graphics
public uint this[int index]
{
get { return colors[index]; }
set { colors[index] = value; }
get => colors[index];
set => colors[index] = value;
}
public void CopyToArray(Array destination, int destinationOffset)

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -18,8 +18,8 @@ namespace OpenRA.Graphics
public readonly string Name;
public IPalette Palette { get; internal set; }
public float TextureIndex { get { return index / hardwarePalette.Height; } }
public float TextureMidIndex { get { return (index + 0.5f) / hardwarePalette.Height; } }
public float TextureIndex => index / hardwarePalette.Height;
public float TextureMidIndex => (index + 0.5f) / hardwarePalette.Height;
public PaletteReference(string name, int index, IPalette palette, HardwarePalette hardwarePalette)
{
@@ -28,5 +28,7 @@ namespace OpenRA.Graphics
this.index = index;
this.hardwarePalette = hardwarePalette;
}
public bool HasColorShift => hardwarePalette.HasColorShift(Name);
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -15,9 +15,18 @@ using OpenRA.Primitives;
namespace OpenRA
{
public enum GLProfile
{
Automatic,
ANGLE,
Modern,
Embedded,
Legacy
}
public interface IPlatform
{
IPlatformWindow CreateWindow(Size size, WindowMode windowMode, float scaleModifier, int batchSize, int videoDisplay);
IPlatformWindow CreateWindow(Size size, WindowMode windowMode, float scaleModifier, int batchSize, int videoDisplay, GLProfile profile, bool enableLegacyGL);
ISoundEngine CreateSound(string device);
IFont CreateFont(byte[] data);
}
@@ -32,7 +41,10 @@ namespace OpenRA
Subtractive,
Multiply,
Multiplicative,
DoubleMultiplicative
DoubleMultiplicative,
LowAdditive,
Screen,
Translucent
}
public interface IPlatformWindow : IDisposable
@@ -46,6 +58,8 @@ namespace OpenRA
Size SurfaceSize { get; }
int DisplayCount { get; }
int CurrentDisplay { get; }
bool HasInputFocus { get; }
bool IsSuspended { get; }
event Action<float, float, float, float> OnWindowScaleChanged;
@@ -58,13 +72,19 @@ namespace OpenRA
IHardwareCursor CreateHardwareCursor(string name, Size size, byte[] data, int2 hotspot, bool pixelDouble);
void SetHardwareCursor(IHardwareCursor cursor);
void SetWindowTitle(string title);
void SetRelativeMouseMode(bool mode);
void SetScaleModifier(float scale);
GLProfile GLProfile { get; }
GLProfile[] SupportedGLProfiles { get; }
}
public interface IGraphicsContext : IDisposable
{
IVertexBuffer<Vertex> CreateVertexBuffer(int size);
Vertex[] CreateVertices(int size);
ITexture CreateTexture();
IFrameBuffer CreateFrameBuffer(Size s);
IFrameBuffer CreateFrameBuffer(Size s, Color clearColor);
@@ -86,8 +106,12 @@ namespace OpenRA
{
void Bind();
void SetData(T[] vertices, int length);
void SetData(T[] vertices, int start, int length);
void SetData(IntPtr data, int start, int length);
/// <summary>
/// Upon return `vertices` may reference another array object of at least the same size - containing random values.
/// </summary>
void SetData(ref T[] vertices, int length);
void SetData(T[] vertices, int offset, int start, int length);
}
public interface IShader
@@ -106,8 +130,8 @@ namespace OpenRA
public interface ITexture : IDisposable
{
void SetData(uint[,] colors);
void SetData(byte[] colors, int width, int height);
void SetFloatData(float[] data, int width, int height);
byte[] GetData();
Size Size { get; }
TextureScaleFilter ScaleFilter { get; set; }
@@ -129,7 +153,7 @@ namespace OpenRA
TriangleList,
}
public struct Range<T>
public readonly struct Range<T>
{
public readonly T Start, End;
public Range(T start, T end) { Start = start; End = end; }

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -10,7 +10,6 @@
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Primitives;
@@ -18,44 +17,35 @@ namespace OpenRA.Graphics
{
public class PlayerColorRemap : IPaletteRemap
{
Dictionary<int, Color> remapColors;
readonly int[] remapIndices;
readonly float hue;
readonly float saturation;
public static int GetRemapIndex(int[] ramp, int i)
public PlayerColorRemap(int[] remapIndices, float hue, float saturation)
{
return ramp[i];
}
public PlayerColorRemap(int[] ramp, Color c, float rampFraction)
{
var h = c.GetHue() / 360.0f;
var s = c.GetSaturation();
var l = c.GetBrightness();
// Increase luminosity if required to represent the full ramp
var rampRange = (byte)((1 - rampFraction) * l);
var c1 = Color.FromAhsl(h, s, Math.Max(rampRange, l));
var c2 = Color.FromAhsl(h, s, (byte)Math.Max(0, l - rampRange));
var baseIndex = ramp[0];
var remapRamp = ramp.Select(r => r - ramp[0]);
var rampMaxIndex = ramp.Length - 1;
// reversed remapping
if (ramp[0] > ramp[rampMaxIndex])
{
baseIndex = ramp[rampMaxIndex];
for (var i = rampMaxIndex; i > 0; i--)
remapRamp = ramp.Select(r => r - ramp[rampMaxIndex]);
}
remapColors = remapRamp.Select((x, i) => Pair.New(baseIndex + i, Exts.ColorLerp(x / (float)ramp.Length, c1, c2)))
.ToDictionary(u => u.First, u => u.Second);
this.remapIndices = remapIndices;
this.hue = hue;
this.saturation = saturation;
}
public Color GetRemappedColor(Color original, int index)
{
Color c;
return remapColors.TryGetValue(index, out c)
? c : original;
if (!remapIndices.Contains(index))
return original;
// Color remapping is applied in a linear color space, so start
// by undoing the pre-multiplied alpha and gamma corrections
var (r, g, b) = original.ToLinear();
// Calculate the brightness (i.e HSV value) of the original colour
// This inlines the single line of Color.RgbToHsv() that we need
var value = Math.Max(Math.Max(r, g), b);
// Construct the new RGB color
(r, g, b) = Color.HsvToRgb(hue, saturation, value);
// Convert linear back to SRGB and pre-multiply by the alpha
return Color.FromLinear(original.A, r, g, b);
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -9,6 +9,7 @@
*/
#endregion
using System;
using OpenRA.Primitives;
namespace OpenRA.Graphics
@@ -16,18 +17,40 @@ namespace OpenRA.Graphics
public interface IRenderable
{
WPos Pos { get; }
PaletteReference Palette { get; }
int ZOffset { get; }
bool IsDecoration { get; }
IRenderable WithPalette(PaletteReference newPalette);
IRenderable WithZOffset(int newOffset);
IRenderable OffsetBy(WVec offset);
IRenderable OffsetBy(in WVec offset);
IRenderable AsDecoration();
IFinalizedRenderable PrepareRender(WorldRenderer wr);
}
public interface IPalettedRenderable : IRenderable
{
PaletteReference Palette { get; }
IPalettedRenderable WithPalette(PaletteReference newPalette);
}
[Flags]
public enum TintModifiers
{
None = 0,
IgnoreWorldTint = 1,
ReplaceColor = 2
}
public interface IModifyableRenderable : IRenderable
{
float Alpha { get; }
float3 Tint { get; }
TintModifiers TintModifiers { get; }
IModifyableRenderable WithAlpha(float newAlpha);
IModifyableRenderable WithTint(in float3 newTint, TintModifiers newTintModifiers);
}
public interface IFinalizedRenderable
{
void Render(WorldRenderer wr);

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -28,7 +28,7 @@ namespace OpenRA.Graphics
this.parent = parent;
}
public void DrawLine(float3 start, float3 end, float width, Color startColor, Color endColor)
public void DrawLine(in float3 start, in float3 end, float width, Color startColor, Color endColor, BlendMode blendMode = BlendMode.Alpha)
{
var delta = (end - start) / (end - start).XY.Length;
var corner = width / 2 * new float3(-delta.Y, delta.X, delta.Z);
@@ -52,10 +52,10 @@ namespace OpenRA.Graphics
vertices[4] = new Vertex(end - corner + Offset, er, eg, eb, ea, 0, 0);
vertices[5] = new Vertex(start - corner + Offset, sr, sg, sb, sa, 0, 0);
parent.DrawRGBAVertices(vertices);
parent.DrawRGBAVertices(vertices, blendMode);
}
public void DrawLine(float3 start, float3 end, float width, Color color)
public void DrawLine(in float3 start, in float3 end, float width, Color color, BlendMode blendMode = BlendMode.Alpha)
{
var delta = (end - start) / (end - start).XY.Length;
var corner = width / 2 * new float2(-delta.Y, delta.X);
@@ -72,7 +72,7 @@ namespace OpenRA.Graphics
vertices[3] = new Vertex(end + corner + Offset, r, g, b, a, 0, 0);
vertices[4] = new Vertex(end - corner + Offset, r, g, b, a, 0, 0);
vertices[5] = new Vertex(start - corner + Offset, r, g, b, a, 0, 0);
parent.DrawRGBAVertices(vertices);
parent.DrawRGBAVertices(vertices, blendMode);
}
/// <summary>
@@ -80,7 +80,7 @@ namespace OpenRA.Graphics
/// Will behave badly if the lines are parallel.
/// Z position is the average of a and b (ignores actual intersection point if it exists)
/// </summary>
float3 IntersectionOf(float3 a, float3 da, float3 b, float3 db)
float3 IntersectionOf(in float3 a, in float3 da, in float3 b, in float3 db)
{
var crossA = a.X * (a.Y + da.Y) - a.Y * (a.X + da.X);
var crossB = b.X * (b.Y + db.Y) - b.Y * (b.X + db.X);
@@ -90,7 +90,7 @@ namespace OpenRA.Graphics
return new float3(x / d, y / d, 0.5f * (a.Z + b.Z));
}
void DrawDisconnectedLine(IEnumerable<float3> points, float width, Color color)
void DrawDisconnectedLine(IEnumerable<float3> points, float width, Color color, BlendMode blendMode)
{
using (var e = points.GetEnumerator())
{
@@ -101,13 +101,13 @@ namespace OpenRA.Graphics
while (e.MoveNext())
{
var point = e.Current;
DrawLine(lastPoint, point, width, color);
DrawLine(lastPoint, point, width, color, blendMode);
lastPoint = point;
}
}
}
void DrawConnectedLine(float3[] points, float width, Color color, bool closed)
void DrawConnectedLine(float3[] points, float width, Color color, bool closed, BlendMode blendMode)
{
// Not a line
if (points.Length < 2)
@@ -116,7 +116,7 @@ namespace OpenRA.Graphics
// Single segment
if (points.Length == 2)
{
DrawLine(points[0], points[1], width, color);
DrawLine(points[0], points[1], width, color, blendMode);
return;
}
@@ -163,7 +163,7 @@ namespace OpenRA.Graphics
vertices[3] = new Vertex(cc + Offset, r, g, b, a, 0, 0);
vertices[4] = new Vertex(cd + Offset, r, g, b, a, 0, 0);
vertices[5] = new Vertex(ca + Offset, r, g, b, a, 0, 0);
parent.DrawRGBAVertices(vertices);
parent.DrawRGBAVertices(vertices, blendMode);
// Advance line segment
end = next;
@@ -175,32 +175,32 @@ namespace OpenRA.Graphics
}
}
public void DrawLine(IEnumerable<float3> points, float width, Color color, bool connectSegments = false)
public void DrawLine(IEnumerable<float3> points, float width, Color color, bool connectSegments = false, BlendMode blendMode = BlendMode.Alpha)
{
if (!connectSegments)
DrawDisconnectedLine(points, width, color);
DrawDisconnectedLine(points, width, color, blendMode);
else
DrawConnectedLine(points as float3[] ?? points.ToArray(), width, color, false);
DrawConnectedLine(points as float3[] ?? points.ToArray(), width, color, false, blendMode);
}
public void DrawPolygon(float3[] vertices, float width, Color color)
public void DrawPolygon(float3[] vertices, float width, Color color, BlendMode blendMode = BlendMode.Alpha)
{
DrawConnectedLine(vertices, width, color, true);
DrawConnectedLine(vertices, width, color, true, blendMode);
}
public void DrawPolygon(float2[] vertices, float width, Color color)
public void DrawPolygon(float2[] vertices, float width, Color color, BlendMode blendMode = BlendMode.Alpha)
{
DrawConnectedLine(vertices.Select(v => new float3(v, 0)).ToArray(), width, color, true);
DrawConnectedLine(vertices.Select(v => new float3(v, 0)).ToArray(), width, color, true, blendMode);
}
public void DrawRect(float3 tl, float3 br, float width, Color color)
public void DrawRect(in float3 tl, in float3 br, float width, Color color, BlendMode blendMode = BlendMode.Alpha)
{
var tr = new float3(br.X, tl.Y, tl.Z);
var bl = new float3(tl.X, br.Y, br.Z);
DrawPolygon(new[] { tl, tr, br, bl }, width, color);
DrawPolygon(new[] { tl, tr, br, bl }, width, color, blendMode);
}
public void FillTriangle(float3 a, float3 b, float3 c, Color color)
public void FillTriangle(in float3 a, in float3 b, in float3 c, Color color, BlendMode blendMode = BlendMode.Alpha)
{
color = Util.PremultiplyAlpha(color);
var cr = color.R / 255.0f;
@@ -211,17 +211,17 @@ namespace OpenRA.Graphics
vertices[0] = new Vertex(a + Offset, cr, cg, cb, ca, 0, 0);
vertices[1] = new Vertex(b + Offset, cr, cg, cb, ca, 0, 0);
vertices[2] = new Vertex(c + Offset, cr, cg, cb, ca, 0, 0);
parent.DrawRGBAVertices(vertices);
parent.DrawRGBAVertices(vertices, blendMode);
}
public void FillRect(float3 tl, float3 br, Color color)
public void FillRect(in float3 tl, in float3 br, Color color, BlendMode blendMode = BlendMode.Alpha)
{
var tr = new float3(br.X, tl.Y, tl.Z);
var bl = new float3(tl.X, br.Y, br.Z);
FillRect(tl, tr, br, bl, color);
FillRect(tl, tr, br, bl, color, blendMode);
}
public void FillRect(float3 a, float3 b, float3 c, float3 d, Color color)
public void FillRect(in float3 a, in float3 b, in float3 c, in float3 d, Color color, BlendMode blendMode = BlendMode.Alpha)
{
color = Util.PremultiplyAlpha(color);
var cr = color.R / 255.0f;
@@ -235,10 +235,10 @@ namespace OpenRA.Graphics
vertices[3] = new Vertex(c + Offset, cr, cg, cb, ca, 0, 0);
vertices[4] = new Vertex(d + Offset, cr, cg, cb, ca, 0, 0);
vertices[5] = new Vertex(a + Offset, cr, cg, cb, ca, 0, 0);
parent.DrawRGBAVertices(vertices);
parent.DrawRGBAVertices(vertices, blendMode);
}
public void FillRect(float3 a, float3 b, float3 c, float3 d, Color topLeftColor, Color topRightColor, Color bottomRightColor, Color bottomLeftColor)
public void FillRect(in float3 a, in float3 b, in float3 c, in float3 d, Color topLeftColor, Color topRightColor, Color bottomRightColor, Color bottomLeftColor, BlendMode blendMode = BlendMode.Alpha)
{
vertices[0] = VertexWithColor(a + Offset, topLeftColor);
vertices[1] = VertexWithColor(b + Offset, topRightColor);
@@ -247,10 +247,10 @@ namespace OpenRA.Graphics
vertices[4] = VertexWithColor(d + Offset, bottomLeftColor);
vertices[5] = VertexWithColor(a + Offset, topLeftColor);
parent.DrawRGBAVertices(vertices);
parent.DrawRGBAVertices(vertices, blendMode);
}
static Vertex VertexWithColor(float3 xyz, Color color)
static Vertex VertexWithColor(in float3 xyz, Color color)
{
color = Util.PremultiplyAlpha(color);
var cr = color.R / 255.0f;
@@ -261,7 +261,7 @@ namespace OpenRA.Graphics
return new Vertex(xyz, cr, cg, cb, ca, 0, 0);
}
public void FillEllipse(float3 tl, float3 br, Color color, int vertices = 32)
public void FillEllipse(in float3 tl, in float3 br, Color color, BlendMode blendMode = BlendMode.Alpha)
{
// TODO: Create an ellipse polygon instead
var a = (br.X - tl.X) / 2;
@@ -272,7 +272,7 @@ namespace OpenRA.Graphics
{
var z = float2.Lerp(tl.Z, br.Z, (y - tl.Y) / (br.Y - tl.Y));
var dx = a * (float)Math.Sqrt(1 - (y - yc) * (y - yc) / b / b);
DrawLine(new float3(xc - dx, y, z), new float3(xc + dx, y, z), 1, color);
DrawLine(new float3(xc - dx, y, z), new float3(xc + dx, y, z), 1, color, blendMode);
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -22,28 +22,36 @@ namespace OpenRA.Graphics
this.parent = parent;
}
public void DrawSprite(Sprite s, float3 location, float3 size)
public void DrawSprite(Sprite s, in float3 location, in float3 scale, float rotation = 0f)
{
if (s.Channel != TextureChannel.RGBA)
throw new InvalidOperationException("DrawRGBASprite requires a RGBA sprite.");
parent.DrawSprite(s, location, 0, size);
parent.DrawSprite(s, 0, location, scale, rotation);
}
public void DrawSprite(Sprite s, float3 location)
public void DrawSprite(Sprite s, in float3 location, float scale = 1f, float rotation = 0f)
{
if (s.Channel != TextureChannel.RGBA)
throw new InvalidOperationException("DrawRGBASprite requires a RGBA sprite.");
parent.DrawSprite(s, location, 0, s.Size);
parent.DrawSprite(s, 0, location, scale, rotation);
}
public void DrawSprite(Sprite s, float3 a, float3 b, float3 c, float3 d)
public void DrawSprite(Sprite s, in float3 location, float scale, in float3 tint, float alpha, float rotation = 0f)
{
if (s.Channel != TextureChannel.RGBA)
throw new InvalidOperationException("DrawRGBASprite requires a RGBA sprite.");
parent.DrawSprite(s, a, b, c, d);
parent.DrawSprite(s, 0, location, scale, tint, alpha, rotation);
}
public void DrawSprite(Sprite s, in float3 a, in float3 b, in float3 c, in float3 d, in float3 tint, float alpha)
{
if (s.Channel != TextureChannel.RGBA)
throw new InvalidOperationException("DrawRGBASprite requires a RGBA sprite.");
parent.DrawSprite(s, 0, a, b, c, d, tint, alpha);
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -26,35 +26,39 @@ namespace OpenRA.Graphics
int Length { get; }
int Stride { get; }
int Facings { get; }
int InterpolatedFacings { get; }
int Tick { get; }
int ZOffset { get; }
int ShadowStart { get; }
int ShadowZOffset { get; }
int[] Frames { get; }
Rectangle Bounds { get; }
bool IgnoreWorldTint { get; }
float Scale { get; }
Sprite GetSprite(int frame);
Sprite GetSprite(int frame, int facing);
Sprite GetShadow(int frame, int facing);
Sprite GetSprite(int frame, WAngle facing);
(Sprite, WAngle) GetSpriteWithRotation(int frame, WAngle facing);
Sprite GetShadow(int frame, WAngle facing);
float GetAlpha(int frame);
}
public interface ISpriteSequenceLoader
{
Action<string> OnMissingSpriteError { get; set; }
IReadOnlyDictionary<string, ISpriteSequence> ParseSequences(ModData modData, TileSet tileSet, SpriteCache cache, MiniYamlNode node);
IReadOnlyDictionary<string, ISpriteSequence> ParseSequences(ModData modData, string tileSet, SpriteCache cache, MiniYamlNode node);
}
public class SequenceProvider : IDisposable
{
readonly ModData modData;
readonly TileSet tileSet;
readonly string tileSet;
readonly Lazy<Sequences> sequences;
readonly Lazy<SpriteCache> spriteCache;
public SpriteCache SpriteCache { get { return spriteCache.Value; } }
public SpriteCache SpriteCache => spriteCache.Value;
readonly Dictionary<string, UnitSequences> sequenceCache = new Dictionary<string, UnitSequences>();
public SequenceProvider(IReadOnlyFileSystem fileSystem, ModData modData, TileSet tileSet, MiniYaml additionalSequences)
public SequenceProvider(IReadOnlyFileSystem fileSystem, ModData modData, string tileSet, MiniYaml additionalSequences)
{
this.modData = modData;
this.tileSet = tileSet;
@@ -69,17 +73,17 @@ namespace OpenRA.Graphics
public ISpriteSequence GetSequence(string unitName, string sequenceName)
{
UnitSequences unitSeq;
if (!sequences.Value.TryGetValue(unitName, out unitSeq))
throw new InvalidOperationException("Unit `{0}` does not have any sequences defined.".F(unitName));
if (!sequences.Value.TryGetValue(unitName, out var unitSeq))
throw new InvalidOperationException($"Unit `{unitName}` does not have any sequences defined.");
ISpriteSequence seq;
if (!unitSeq.Value.TryGetValue(sequenceName, out seq))
throw new InvalidOperationException("Unit `{0}` does not have a sequence named `{1}`".F(unitName, sequenceName));
if (!unitSeq.Value.TryGetValue(sequenceName, out var seq))
throw new InvalidOperationException($"Unit `{unitName}` does not have a sequence named `{sequenceName}`");
return seq;
}
public IEnumerable<string> Images => sequences.Value.Keys;
public bool HasSequence(string unitName)
{
return sequences.Value.ContainsKey(unitName);
@@ -87,18 +91,16 @@ namespace OpenRA.Graphics
public bool HasSequence(string unitName, string sequenceName)
{
UnitSequences unitSeq;
if (!sequences.Value.TryGetValue(unitName, out unitSeq))
throw new InvalidOperationException("Unit `{0}` does not have any sequences defined.".F(unitName));
if (!sequences.Value.TryGetValue(unitName, out var unitSeq))
throw new InvalidOperationException($"Unit `{unitName}` does not have any sequences defined.");
return unitSeq.Value.ContainsKey(sequenceName);
}
public IEnumerable<string> Sequences(string unitName)
{
UnitSequences unitSeq;
if (!sequences.Value.TryGetValue(unitName, out unitSeq))
throw new InvalidOperationException("Unit `{0}` does not have any sequences defined.".F(unitName));
if (!sequences.Value.TryGetValue(unitName, out var unitSeq))
throw new InvalidOperationException($"Unit `{unitName}` does not have any sequences defined.");
return unitSeq.Value.Keys;
}
@@ -107,15 +109,15 @@ namespace OpenRA.Graphics
{
var nodes = MiniYaml.Load(fileSystem, modData.Manifest.Sequences, additionalSequences);
var items = new Dictionary<string, UnitSequences>();
foreach (var n in nodes)
foreach (var node in nodes)
{
// Work around the loop closure issue in older versions of C#
var node = n;
// Nodes starting with ^ are inheritable but never loaded directly
if (node.Key.StartsWith(ActorInfo.AbstractActorPrefix, StringComparison.Ordinal))
continue;
var key = node.Value.ToLines(node.Key).JoinWith("|");
UnitSequences t;
if (sequenceCache.TryGetValue(key, out t))
if (sequenceCache.TryGetValue(key, out var t))
items.Add(node.Key, t);
else
{
@@ -125,7 +127,7 @@ namespace OpenRA.Graphics
}
}
return new ReadOnlyDictionary<string, UnitSequences>(items);
return items;
}
public void Preload()

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -32,7 +32,7 @@ namespace OpenRA.Graphics
return data;
}
public bool Buffered { get { return data != null || texture == null; } }
public bool Buffered => data != null || texture == null;
public Sheet(SheetType type, Size size)
{
@@ -79,21 +79,17 @@ namespace OpenRA.Graphics
public Png AsPng()
{
var data = GetData();
if (Type == SheetType.Indexed)
throw new InvalidOperationException("AsPng() cannot be called on Indexed sheets.");
// Convert BGRA to RGBA
for (var i = 0; i < Size.Width * Size.Height; i++)
{
var temp = data[i * 4];
data[i * 4] = data[i * 4 + 2];
data[i * 4 + 2] = temp;
}
return new Png(data, Size.Width, Size.Height);
return new Png(GetData(), SpriteFrameType.Bgra32, Size.Width, Size.Height);
}
public Png AsPng(TextureChannel channel, IPalette pal)
{
if (Type != SheetType.Indexed)
throw new InvalidOperationException("AsPng(TextureChannel, IPalette) can only be called on Indexed sheets.");
var d = GetData();
var plane = new byte[Size.Width * Size.Height];
var dataStride = 4 * Size.Width;
@@ -107,7 +103,7 @@ namespace OpenRA.Graphics
for (var i = 0; i < Palette.Size; i++)
palColors[i] = pal.GetColor(i);
return new Png(plane, Size.Width, Size.Height, palColors);
return new Png(plane, SpriteFrameType.Indexed8, Size.Width, Size.Height, palColors);
}
public void CreateBuffer()
@@ -146,8 +142,7 @@ namespace OpenRA.Graphics
public void Dispose()
{
if (texture != null)
texture.Dispose();
texture?.Dispose();
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -52,9 +52,16 @@ namespace OpenRA.Graphics
{
switch (t)
{
case SpriteFrameType.Indexed: return SheetType.Indexed;
case SpriteFrameType.BGRA: return SheetType.BGRA;
default: throw new NotImplementedException("Unknown SpriteFrameType {0}".F(t));
case SpriteFrameType.Indexed8:
return SheetType.Indexed;
// Util.FastCopyIntoChannel will automatically convert these to BGRA
case SpriteFrameType.Bgra32:
case SpriteFrameType.Bgr24:
case SpriteFrameType.Rgba32:
case SpriteFrameType.Rgb24:
return SheetType.BGRA;
default: throw new NotImplementedException($"Unknown SpriteFrameType {t}");
}
}
@@ -74,16 +81,16 @@ namespace OpenRA.Graphics
this.margin = margin;
}
public Sprite Add(ISpriteFrame frame) { return Add(frame.Data, frame.Size, 0, frame.Offset); }
public Sprite Add(byte[] src, Size size) { return Add(src, size, 0, float3.Zero); }
public Sprite Add(byte[] src, Size size, float zRamp, float3 spriteOffset)
public Sprite Add(ISpriteFrame frame) { return Add(frame.Data, frame.Type, frame.Size, 0, frame.Offset); }
public Sprite Add(byte[] src, SpriteFrameType type, Size size) { return Add(src, type, size, 0, float3.Zero); }
public Sprite Add(byte[] src, SpriteFrameType type, Size size, float zRamp, in float3 spriteOffset)
{
// Don't bother allocating empty sprites
if (size.Width == 0 || size.Height == 0)
return new Sprite(current, Rectangle.Empty, 0, spriteOffset, channel, BlendMode.Alpha);
var rect = Allocate(size, zRamp, spriteOffset);
Util.FastCopyIntoChannel(rect, src);
Util.FastCopyIntoChannel(rect, src, type);
current.CommitBufferedData();
return rect;
}
@@ -96,15 +103,6 @@ namespace OpenRA.Graphics
return rect;
}
public Sprite Add(Size size, byte paletteIndex)
{
var data = new byte[size.Width * size.Height];
for (var i = 0; i < data.Length; i++)
data[i] = paletteIndex;
return Add(data, size);
}
TextureChannel? NextChannel(TextureChannel t)
{
var nextChannel = (int)t + (int)Type;
@@ -115,7 +113,7 @@ namespace OpenRA.Graphics
}
public Sprite Allocate(Size imageSize, float scale = 1f) { return Allocate(imageSize, 0, float3.Zero, scale); }
public Sprite Allocate(Size imageSize, float zRamp, float3 spriteOffset, float scale = 1f)
public Sprite Allocate(Size imageSize, float zRamp, in float3 spriteOffset, float scale = 1f)
{
if (imageSize.Width + p.X + margin > current.Size.Width)
{
@@ -149,9 +147,9 @@ namespace OpenRA.Graphics
return rect;
}
public Sheet Current { get { return current; } }
public TextureChannel CurrentChannel { get { return channel; } }
public IEnumerable<Sheet> AllSheets { get { return sheets; } }
public Sheet Current => current;
public TextureChannel CurrentChannel => channel;
public IEnumerable<Sheet> AllSheets => sheets;
public void Dispose()
{

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -23,13 +23,12 @@ namespace OpenRA.Graphics
public readonly float ZRamp;
public readonly float3 Size;
public readonly float3 Offset;
public readonly float3 FractionalOffset;
public readonly float Top, Left, Bottom, Right;
public Sprite(Sheet sheet, Rectangle bounds, TextureChannel channel, float scale = 1)
: this(sheet, bounds, 0, float2.Zero, channel, BlendMode.Alpha, scale) { }
public Sprite(Sheet sheet, Rectangle bounds, float zRamp, float3 offset, TextureChannel channel, BlendMode blendMode = BlendMode.Alpha, float scale = 1f)
public Sprite(Sheet sheet, Rectangle bounds, float zRamp, in float3 offset, TextureChannel channel, BlendMode blendMode = BlendMode.Alpha, float scale = 1f)
{
Sheet = sheet;
Bounds = bounds;
@@ -38,13 +37,16 @@ namespace OpenRA.Graphics
Channel = channel;
Size = scale * new float3(bounds.Size.Width, bounds.Size.Height, bounds.Size.Height * zRamp);
BlendMode = blendMode;
FractionalOffset = Size.Z != 0 ? offset / Size :
new float3(offset.X / Size.X, offset.Y / Size.Y, 0);
Left = (float)Math.Min(bounds.Left, bounds.Right) / sheet.Size.Width;
Top = (float)Math.Min(bounds.Top, bounds.Bottom) / sheet.Size.Height;
Right = (float)Math.Max(bounds.Left, bounds.Right) / sheet.Size.Width;
Bottom = (float)Math.Max(bounds.Top, bounds.Bottom) / sheet.Size.Height;
// Some GPUs suffer from precision issues when rendering into non 1:1 framebuffers that result
// in rendering a line of texels that sample outside the sprite rectangle.
// Insetting the texture coordinates by a small fraction of a pixel avoids this
// with negligible impact on the 1:1 rendering case.
var inset = 1 / 128f;
Left = (Math.Min(bounds.Left, bounds.Right) + inset) / sheet.Size.Width;
Top = (Math.Min(bounds.Top, bounds.Bottom) + inset) / sheet.Size.Height;
Right = (Math.Max(bounds.Left, bounds.Right) - inset) / sheet.Size.Width;
Bottom = (Math.Max(bounds.Top, bounds.Bottom) - inset) / sheet.Size.Height;
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -10,7 +10,6 @@
#endregion
using System;
using System.Linq;
using OpenRA.Primitives;
using OpenRA.Support;
@@ -18,13 +17,12 @@ namespace OpenRA.Graphics
{
public sealed class SpriteFont : IDisposable
{
public int TopOffset { get; private set; }
public int TopOffset { get; }
readonly int size;
readonly SheetBuilder builder;
readonly Func<string, float> lineWidth;
readonly IFont font;
readonly Cache<Pair<char, Color>, GlyphInfo> glyphs;
readonly Cache<Tuple<char, Color, int>, Sprite> contrastGlyphs;
readonly Cache<char, GlyphInfo> glyphs;
readonly Cache<(char C, int Radius), Sprite> contrastGlyphs;
readonly Cache<int, float[]> dilationElements;
float deviceScale;
@@ -32,24 +30,23 @@ namespace OpenRA.Graphics
public SpriteFont(string name, byte[] data, int size, int ascender, float scale, SheetBuilder builder)
{
if (builder.Type != SheetType.BGRA)
throw new ArgumentException("The sheet builder must create BGRA sheets.", "builder");
throw new ArgumentException("The sheet builder must create BGRA sheets.", nameof(builder));
deviceScale = scale;
this.size = size;
this.builder = builder;
font = Game.Renderer.CreateFont(data);
glyphs = new Cache<Pair<char, Color>, GlyphInfo>(CreateGlyph, Pair<char, Color>.EqualityComparer);
contrastGlyphs = new Cache<Tuple<char, Color, int>, Sprite>(CreateContrastGlyph);
glyphs = new Cache<char, GlyphInfo>(CreateGlyph);
contrastGlyphs = new Cache<(char, int), Sprite>(CreateContrastGlyph);
dilationElements = new Cache<int, float[]>(CreateCircularWeightMap);
// PERF: Cache these delegates for Measure calls.
Func<char, float> characterWidth = character => glyphs[Pair.New(character, Color.White)].Advance;
lineWidth = line => line.Sum(characterWidth) / deviceScale;
// Pre-cache small font sizes so glyphs are immediately available when we need them
if (size <= 24)
PrecacheColor(Color.White, name);
using (new PerfTimer($"Precache {name} {size}px"))
for (var n = (char)0x20; n < (char)0x7f; n++)
if (glyphs[n] == null)
throw new InvalidOperationException();
TopOffset = size - ascender;
}
@@ -61,14 +58,6 @@ namespace OpenRA.Graphics
contrastGlyphs.Clear();
}
void PrecacheColor(Color c, string name)
{
using (new PerfTimer("PrecacheColor {0} {1}px {2}".F(name, size, c)))
for (var n = (char)0x20; n < (char)0x7f; n++)
if (glyphs[Pair.New(n, c)] == null)
throw new InvalidOperationException();
}
void DrawTextContrast(string text, float2 location, Color contrastColor, int contrastOffset)
{
// Offset from the baseline position to the top-left of the glyph for rendering
@@ -78,6 +67,7 @@ namespace OpenRA.Graphics
var screenContrast = (int)(contrastOffset * deviceScale);
var screen = new int2((int)(location.X * deviceScale + 0.5f), (int)(location.Y * deviceScale + 0.5f));
var contrastVector = new float2(screenContrast, screenContrast);
var tint = new float3(contrastColor.R / 255f, contrastColor.G / 255f, contrastColor.B / 255f);
foreach (var s in text)
{
if (s == '\n')
@@ -87,15 +77,16 @@ namespace OpenRA.Graphics
continue;
}
var g = glyphs[Pair.New(s, Color.Black)];
var g = glyphs[s];
// Convert screen coordinates back to UI coordinates for drawing
if (g.Sprite != null)
{
var contrastSprite = contrastGlyphs[Tuple.Create(s, contrastColor, screenContrast)];
var contrastSprite = contrastGlyphs[(s, screenContrast)];
Game.Renderer.RgbaSpriteRenderer.DrawSprite(contrastSprite,
(screen + g.Offset - contrastVector) / deviceScale,
contrastSprite.Size / deviceScale);
1f / deviceScale,
tint, 1f);
}
screen += new int2((int)(g.Advance + 0.5f), 0);
@@ -109,6 +100,7 @@ namespace OpenRA.Graphics
// Calculate positions in screen pixel coordinates
var screen = new int2((int)(location.X * deviceScale + 0.5f), (int)(location.Y * deviceScale + 0.5f));
var tint = new float3(c.R / 255f, c.G / 255f, c.B / 255f);
foreach (var s in text)
{
if (s == '\n')
@@ -118,13 +110,14 @@ namespace OpenRA.Graphics
continue;
}
var g = glyphs[Pair.New(s, c)];
var g = glyphs[s];
// Convert screen coordinates back to UI coordinates for drawing
if (g.Sprite != null)
Game.Renderer.RgbaSpriteRenderer.DrawSprite(g.Sprite,
(screen + g.Offset).ToFloat2() / deviceScale,
g.Sprite.Size / deviceScale);
1f / deviceScale,
tint, 1f);
screen += new int2((int)(g.Advance + 0.5f), 0);
}
@@ -144,6 +137,7 @@ namespace OpenRA.Graphics
var offset = new float2(0, size);
var cosa = (float)Math.Cos(-angle);
var sina = (float)Math.Sin(-angle);
var tint = new float3(c.R / 255f, c.G / 255f, c.B / 255f);
var p = offset;
foreach (var s in text)
@@ -155,7 +149,7 @@ namespace OpenRA.Graphics
continue;
}
var g = glyphs[Pair.New(s, c)];
var g = glyphs[s];
if (g.Sprite != null)
{
var tl = new float2(
@@ -176,7 +170,8 @@ namespace OpenRA.Graphics
ra + screenOffset,
rb + screenOffset,
rc + screenOffset,
rd + screenOffset);
rd + screenOffset,
tint, 1f);
}
p += new float2(g.Advance / deviceScale, 0);
@@ -237,14 +232,31 @@ namespace OpenRA.Graphics
if (string.IsNullOrEmpty(text))
return new int2(0, size);
var lines = text.Split('\n');
return new int2((int)Math.Ceiling(lines.Max(lineWidth)), lines.Length * size);
var lines = text.SplitLines('\n');
var maxWidth = 0f;
var rows = 0;
foreach (var line in lines)
{
rows++;
maxWidth = Math.Max(maxWidth, LineWidth(line));
}
return new int2((int)Math.Ceiling(maxWidth), rows * size);
}
GlyphInfo CreateGlyph(Pair<char, Color> c)
float LineWidth(ReadOnlySpan<char> line)
{
var glyph = font.CreateGlyph(c.First, size, deviceScale);
var result = 0f;
foreach (var c in line)
result += glyphs[c].Advance;
return result / deviceScale;
}
GlyphInfo CreateGlyph(char c)
{
var glyph = font.CreateGlyph(c, size, deviceScale);
if (glyph.Data == null)
{
return new GlyphInfo
@@ -274,12 +286,10 @@ namespace OpenRA.Graphics
if (p != 0)
{
var q = destStride * (j + s.Bounds.Top) + 4 * (i + s.Bounds.Left);
var pmc = Util.PremultiplyAlpha(Color.FromArgb(p, c.Second));
dest[q] = pmc.B;
dest[q + 1] = pmc.G;
dest[q + 2] = pmc.R;
dest[q + 3] = pmc.A;
dest[q] = p;
dest[q + 1] = p;
dest[q + 2] = p;
dest[q + 3] = p;
}
}
}
@@ -347,16 +357,12 @@ namespace OpenRA.Graphics
return elem;
}
Sprite CreateContrastGlyph(Tuple<char, Color, int> c)
Sprite CreateContrastGlyph((char C, int Radius) c)
{
// Source glyph color doesn't matter, so use black
var glyph = glyphs[Pair.New(c.Item1, Color.Black)];
var color = c.Item2;
var r = c.Item3;
var glyph = glyphs[c.C];
var r = c.Radius;
var size = new Size(glyph.Sprite.Bounds.Width + 2 * r, glyph.Sprite.Bounds.Height + 2 * r);
var s = builder.Allocate(size);
var s = builder.Allocate(new Size(glyph.Sprite.Bounds.Width + 2 * r, glyph.Sprite.Bounds.Height + 2 * r));
var dest = s.Sheet.GetData();
var destStride = s.Sheet.Size.Width * 4;
@@ -398,11 +404,10 @@ namespace OpenRA.Graphics
if (alpha > 0)
{
var q = destStride * (j + s.Bounds.Top) + 4 * (i + s.Bounds.Left);
var pmc = Util.PremultiplyAlpha(Color.FromArgb(alpha, color));
dest[q] = pmc.B;
dest[q + 1] = pmc.G;
dest[q + 2] = pmc.R;
dest[q + 3] = pmc.A;
dest[q] = alpha;
dest[q + 1] = alpha;
dest[q + 2] = alpha;
dest[q + 3] = alpha;
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -18,11 +18,33 @@ using OpenRA.Primitives;
namespace OpenRA.Graphics
{
public enum SpriteFrameType { Indexed, BGRA }
/// <summary>
/// Describes the format of the pixel data in a ISpriteFrame.
/// Note that the channel order is defined for little-endian bytes, so BGRA corresponds
/// to a 32bit ARGB value, such as that returned by Color.ToArgb()!
/// </summary>
public enum SpriteFrameType
{
// 8 bit index into an external palette
Indexed8,
// 32 bit color such as returned by Color.ToArgb() or the bmp file format
// (remember that little-endian systems place the little bits in the first byte!)
Bgra32,
// Like BGRA, but without an alpha channel
Bgr24,
// 32 bit color in big-endian format, like png
Rgba32,
// Like RGBA, but without an alpha channel
Rgb24
}
public interface ISpriteLoader
{
bool TryParseSprite(Stream s, out ISpriteFrame[] frames, out TypeDictionary metadata);
bool TryParseSprite(Stream s, string filename, out ISpriteFrame[] frames, out TypeDictionary metadata);
}
public interface ISpriteFrame
@@ -47,7 +69,7 @@ namespace OpenRA.Graphics
public class SpriteCache
{
public readonly Cache<SpriteFrameType, SheetBuilder> SheetBuilders;
public readonly Cache<SheetType, SheetBuilder> SheetBuilders;
readonly ISpriteLoader[] loaders;
readonly IReadOnlyFileSystem fileSystem;
@@ -57,7 +79,7 @@ namespace OpenRA.Graphics
public SpriteCache(IReadOnlyFileSystem fileSystem, ISpriteLoader[] loaders)
{
SheetBuilders = new Cache<SpriteFrameType, SheetBuilder>(t => new SheetBuilder(SheetBuilder.FrameTypeToSheetType(t)));
SheetBuilders = new Cache<SheetType, SheetBuilder>(t => new SheetBuilder(t));
this.fileSystem = fileSystem;
this.loaders = loaders;
@@ -76,8 +98,7 @@ namespace OpenRA.Graphics
var allSprites = sprites.GetOrAdd(filename);
var sprite = allSprites.FirstOrDefault();
ISpriteFrame[] unloaded;
if (!unloadedFrames.TryGetValue(filename, out unloaded))
if (!unloadedFrames.TryGetValue(filename, out var unloaded))
unloaded = null;
// This is the first time that the file has been requested
@@ -85,8 +106,7 @@ namespace OpenRA.Graphics
// the loaded cache (initially empty)
if (sprite == null)
{
TypeDictionary fileMetadata = null;
unloaded = FrameLoader.GetFrames(fileSystem, filename, loaders, out fileMetadata);
unloaded = FrameLoader.GetFrames(fileSystem, filename, loaders, out var fileMetadata);
unloadedFrames[filename] = unloaded;
metadata[filename] = fileMetadata;
@@ -105,7 +125,7 @@ namespace OpenRA.Graphics
{
if (unloaded[i] != null)
{
sprite[i] = SheetBuilders[unloaded[i].Type].Add(unloaded[i]);
sprite[i] = SheetBuilders[SheetBuilder.FrameTypeToSheetType(unloaded[i].Type)].Add(unloaded[i]);
unloaded[i] = null;
}
}
@@ -125,8 +145,7 @@ namespace OpenRA.Graphics
/// </summary>
public TypeDictionary FrameMetadata(string filename)
{
TypeDictionary fileMetadata;
if (!metadata.TryGetValue(filename, out fileMetadata))
if (!metadata.TryGetValue(filename, out var fileMetadata))
{
FrameLoader.GetFrames(fileSystem, filename, loaders, out fileMetadata);
metadata[filename] = fileMetadata;
@@ -142,11 +161,10 @@ namespace OpenRA.Graphics
public FrameCache(IReadOnlyFileSystem fileSystem, ISpriteLoader[] loaders)
{
TypeDictionary metadata;
frames = new Cache<string, ISpriteFrame[]>(filename => FrameLoader.GetFrames(fileSystem, filename, loaders, out metadata));
frames = new Cache<string, ISpriteFrame[]>(filename => FrameLoader.GetFrames(fileSystem, filename, loaders, out _));
}
public ISpriteFrame[] this[string filename] { get { return frames[filename]; } }
public ISpriteFrame[] this[string filename] => frames[filename];
}
public static class FrameLoader
@@ -155,7 +173,7 @@ namespace OpenRA.Graphics
{
using (var stream = fileSystem.Open(filename))
{
var spriteFrames = GetFrames(stream, loaders, out metadata);
var spriteFrames = GetFrames(stream, loaders, filename, out metadata);
if (spriteFrames == null)
throw new InvalidDataException(filename + " is not a valid sprite file!");
@@ -163,13 +181,12 @@ namespace OpenRA.Graphics
}
}
public static ISpriteFrame[] GetFrames(Stream stream, ISpriteLoader[] loaders, out TypeDictionary metadata)
public static ISpriteFrame[] GetFrames(Stream stream, ISpriteLoader[] loaders, string filename, out TypeDictionary metadata)
{
ISpriteFrame[] frames;
metadata = null;
foreach (var loader in loaders)
if (loader.TryParseSprite(stream, out frames, out metadata))
if (loader.TryParseSprite(stream, filename, out var frames, out metadata))
return frames;
return null;

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -9,14 +9,15 @@
*/
#endregion
using System;
using System.Collections.Generic;
using OpenRA.Primitives;
namespace OpenRA.Graphics
{
public struct SpriteRenderable : IRenderable, IFinalizedRenderable
public class SpriteRenderable : IPalettedRenderable, IModifyableRenderable, IFinalizedRenderable
{
public static readonly IEnumerable<IRenderable> None = new IRenderable[0];
public static readonly IEnumerable<IRenderable> None = Array.Empty<IRenderable>();
readonly Sprite sprite;
readonly WPos pos;
@@ -24,9 +25,14 @@ namespace OpenRA.Graphics
readonly int zOffset;
readonly PaletteReference palette;
readonly float scale;
readonly WAngle rotation = WAngle.Zero;
readonly float3 tint;
readonly TintModifiers tintModifiers;
readonly float alpha;
readonly bool isDecoration;
public SpriteRenderable(Sprite sprite, WPos pos, WVec offset, int zOffset, PaletteReference palette, float scale, bool isDecoration)
public SpriteRenderable(Sprite sprite, WPos pos, WVec offset, int zOffset, PaletteReference palette, float scale, float alpha,
float3 tint, TintModifiers tintModifiers, bool isDecoration, WAngle rotation)
{
this.sprite = sprite;
this.pos = pos;
@@ -34,32 +40,83 @@ namespace OpenRA.Graphics
this.zOffset = zOffset;
this.palette = palette;
this.scale = scale;
this.rotation = rotation;
this.tint = tint;
this.isDecoration = isDecoration;
this.tintModifiers = tintModifiers;
this.alpha = alpha;
// PERF: Remove useless palette assignments for RGBA sprites
// HACK: This is working around the fact that palettes are defined on traits rather than sequences
// and can be removed once this has been fixed
if (sprite.Channel == TextureChannel.RGBA && !(palette?.HasColorShift ?? false))
this.palette = null;
}
public WPos Pos { get { return pos + offset; } }
public WVec Offset { get { return offset; } }
public PaletteReference Palette { get { return palette; } }
public int ZOffset { get { return zOffset; } }
public bool IsDecoration { get { return isDecoration; } }
public SpriteRenderable(Sprite sprite, WPos pos, WVec offset, int zOffset, PaletteReference palette, float scale, float alpha,
float3 tint, TintModifiers tintModifiers, bool isDecoration)
: this(sprite, pos, offset, zOffset, palette, scale, alpha, tint, tintModifiers, isDecoration, WAngle.Zero) { }
public IRenderable WithPalette(PaletteReference newPalette) { return new SpriteRenderable(sprite, pos, offset, zOffset, newPalette, scale, isDecoration); }
public IRenderable WithZOffset(int newOffset) { return new SpriteRenderable(sprite, pos, offset, newOffset, palette, scale, isDecoration); }
public IRenderable OffsetBy(WVec vec) { return new SpriteRenderable(sprite, pos + vec, offset, zOffset, palette, scale, isDecoration); }
public IRenderable AsDecoration() { return new SpriteRenderable(sprite, pos, offset, zOffset, palette, scale, true); }
public WPos Pos => pos + offset;
public WVec Offset => offset;
public PaletteReference Palette => palette;
public int ZOffset => zOffset;
public bool IsDecoration => isDecoration;
public float Alpha => alpha;
public float3 Tint => tint;
public TintModifiers TintModifiers => tintModifiers;
public IPalettedRenderable WithPalette(PaletteReference newPalette)
{
return new SpriteRenderable(sprite, pos, offset, zOffset, newPalette, scale, alpha, tint, tintModifiers, isDecoration, rotation);
}
public IRenderable WithZOffset(int newOffset)
{
return new SpriteRenderable(sprite, pos, offset, newOffset, palette, scale, alpha, tint, tintModifiers, isDecoration, rotation);
}
public IRenderable OffsetBy(in WVec vec)
{
return new SpriteRenderable(sprite, pos + vec, offset, zOffset, palette, scale, alpha, tint, tintModifiers, isDecoration, rotation);
}
public IRenderable AsDecoration()
{
return new SpriteRenderable(sprite, pos, offset, zOffset, palette, scale, alpha, tint, tintModifiers, true, rotation);
}
public IModifyableRenderable WithAlpha(float newAlpha)
{
return new SpriteRenderable(sprite, pos, offset, zOffset, palette, scale, newAlpha, tint, tintModifiers, isDecoration, rotation);
}
public IModifyableRenderable WithTint(in float3 newTint, TintModifiers newTintModifiers)
{
return new SpriteRenderable(sprite, pos, offset, zOffset, palette, scale, alpha, newTint, newTintModifiers, isDecoration, rotation);
}
float3 ScreenPosition(WorldRenderer wr)
{
var xy = wr.ScreenPxPosition(pos) + wr.ScreenPxOffset(offset) - (0.5f * scale * sprite.Size.XY).ToInt2();
// HACK: The z offset needs to be applied somewhere, but this probably is the wrong place.
return new float3(xy, sprite.Offset.Z + wr.ScreenZPosition(pos, 0) - 0.5f * scale * sprite.Size.Z);
var s = 0.5f * scale * sprite.Size;
return wr.Screen3DPxPosition(pos) + wr.ScreenPxOffset(offset) - new float3((int)s.X, (int)s.Y, s.Z);
}
public IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; }
public void Render(WorldRenderer wr)
{
Game.Renderer.WorldSpriteRenderer.DrawSprite(sprite, ScreenPosition(wr), palette, scale * sprite.Size);
var wsr = Game.Renderer.WorldSpriteRenderer;
var t = alpha * tint;
if (wr.TerrainLighting != null && (tintModifiers & TintModifiers.IgnoreWorldTint) == 0)
t *= wr.TerrainLighting.TintAt(pos);
// Shader interprets negative alpha as a flag to use the tint colour directly instead of multiplying the sprite colour
var a = alpha;
if ((tintModifiers & TintModifiers.ReplaceColor) != 0)
a *= -1;
wsr.DrawSprite(sprite, palette, ScreenPosition(wr), scale, t, a, rotation.RendererRadians());
}
public void RenderDebugGeometry(WorldRenderer wr)
@@ -67,13 +124,16 @@ namespace OpenRA.Graphics
var pos = ScreenPosition(wr) + sprite.Offset;
var tl = wr.Viewport.WorldToViewPx(pos);
var br = wr.Viewport.WorldToViewPx(pos + sprite.Size);
Game.Renderer.RgbaColorRenderer.DrawRect(tl, br, 1, Color.Red);
if (rotation == WAngle.Zero)
Game.Renderer.RgbaColorRenderer.DrawRect(tl, br, 1, Color.Red);
else
Game.Renderer.RgbaColorRenderer.DrawPolygon(Util.RotateQuad(tl, br - tl, rotation.RendererRadians()), 1, Color.Red);
}
public Rectangle ScreenBounds(WorldRenderer wr)
{
var screenOffset = ScreenPosition(wr) + sprite.Offset;
return new Rectangle((int)screenOffset.X, (int)screenOffset.Y, (int)sprite.Size.X, (int)sprite.Size.Y);
return Util.BoundingRectangle(screenOffset, sprite.Size, rotation.RendererRadians());
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -10,17 +10,21 @@
#endregion
using System;
using System.Collections.Generic;
using OpenRA.Primitives;
namespace OpenRA.Graphics
{
public class SpriteRenderer : Renderer.IBatchRenderer
{
public const int SheetCount = 8;
static readonly string[] SheetIndexToTextureName = Exts.MakeArray(SheetCount, i => $"Texture{i}");
readonly Renderer renderer;
readonly IShader shader;
readonly Vertex[] vertices;
readonly Sheet[] sheets = new Sheet[7];
Vertex[] vertices;
readonly Sheet[] sheets = new Sheet[SheetCount];
BlendMode currentBlend = BlendMode.Alpha;
int nv = 0;
@@ -30,7 +34,7 @@ namespace OpenRA.Graphics
{
this.renderer = renderer;
this.shader = shader;
vertices = new Vertex[renderer.TempBufferSize];
vertices = renderer.Context.CreateVertices(renderer.TempBufferSize);
}
public void Flush()
@@ -39,13 +43,15 @@ namespace OpenRA.Graphics
{
for (var i = 0; i < ns; i++)
{
shader.SetTexture("Texture{0}".F(i), sheets[i].GetTexture());
shader.SetTexture(SheetIndexToTextureName[i], sheets[i].GetTexture());
sheets[i] = null;
}
renderer.Context.SetBlendMode(currentBlend);
shader.PrepareRender();
renderer.DrawBatch(vertices, nv, PrimitiveType.TriangleList);
// PERF: The renderer may choose to replace vertices with a different temporary buffer.
renderer.DrawBatch(ref vertices, nv, PrimitiveType.TriangleList);
renderer.Context.SetBlendMode(BlendMode.None);
nv = 0;
@@ -77,100 +83,170 @@ namespace OpenRA.Graphics
for (; secondarySheetIndex < ns; secondarySheetIndex++)
if (sheets[secondarySheetIndex] == secondarySheet)
break;
// If neither sheet has been mapped both index values will be set to ns.
// This is fine if they both reference the same texture, but if they don't
// we must increment the secondary sheet index to the next free sampler.
if (secondarySheetIndex == sheetIndex && secondarySheet != sheet)
secondarySheetIndex++;
}
// Make sure that we have enough free samplers to map both if needed, otherwise flush
var needSamplers = (sheetIndex == ns ? 1 : 0) + (secondarySheetIndex == ns ? 1 : 0);
if (ns + needSamplers >= sheets.Length)
if (Math.Max(sheetIndex, secondarySheetIndex) >= sheets.Length)
{
Flush();
sheetIndex = 0;
if (ss != null)
secondarySheetIndex = 1;
secondarySheetIndex = ss != null && ss.SecondarySheet != sheet ? 1 : 0;
}
if (sheetIndex >= ns)
{
sheets[sheetIndex] = sheet;
ns += 1;
ns++;
}
if (secondarySheetIndex >= ns && ss != null)
{
sheets[secondarySheetIndex] = ss.SecondarySheet;
ns += 1;
ns++;
}
return new int2(sheetIndex, secondarySheetIndex);
}
internal void DrawSprite(Sprite s, float3 location, float paletteTextureIndex, float3 size)
float ResolveTextureIndex(Sprite s, PaletteReference pal)
{
if (pal == null)
return 0;
// PERF: Remove useless palette assignments for RGBA sprites
// HACK: This is working around the limitation that palettes are defined on traits rather than on sequences,
// and can be removed once this has been fixed
if (s.Channel == TextureChannel.RGBA && !pal.HasColorShift)
return 0;
return pal.TextureIndex;
}
internal void DrawSprite(Sprite s, float paletteTextureIndex, in float3 location, in float3 scale, float rotation = 0f)
{
var samplers = SetRenderStateForSprite(s);
Util.FastCreateQuad(vertices, location + s.FractionalOffset * size, s, samplers, paletteTextureIndex, nv, size);
Util.FastCreateQuad(vertices, location + scale * s.Offset, s, samplers, paletteTextureIndex, nv, scale * s.Size, float3.Ones,
1f, rotation);
nv += 6;
}
public void DrawSprite(Sprite s, float3 location, PaletteReference pal)
{
DrawSprite(s, location, pal.TextureIndex, s.Size);
}
public void DrawSprite(Sprite s, float3 location, PaletteReference pal, float3 size)
{
DrawSprite(s, location, pal.TextureIndex, size);
}
public void DrawSprite(Sprite s, float3 a, float3 b, float3 c, float3 d)
internal void DrawSprite(Sprite s, float paletteTextureIndex, in float3 location, float scale, float rotation = 0f)
{
var samplers = SetRenderStateForSprite(s);
Util.FastCreateQuad(vertices, a, b, c, d, s, samplers, 0, nv);
Util.FastCreateQuad(vertices, location + scale * s.Offset, s, samplers, paletteTextureIndex, nv, scale * s.Size, float3.Ones,
1f, rotation);
nv += 6;
}
public void DrawVertexBuffer(IVertexBuffer<Vertex> buffer, int start, int length, PrimitiveType type, Sheet sheet, BlendMode blendMode)
public void DrawSprite(Sprite s, PaletteReference pal, in float3 location, float scale = 1f, float rotation = 0f)
{
shader.SetTexture("Texture0", sheet.GetTexture());
DrawSprite(s, ResolveTextureIndex(s, pal), location, scale, rotation);
}
internal void DrawSprite(Sprite s, float paletteTextureIndex, in float3 location, float scale, in float3 tint, float alpha,
float rotation = 0f)
{
var samplers = SetRenderStateForSprite(s);
Util.FastCreateQuad(vertices, location + scale * s.Offset, s, samplers, paletteTextureIndex, nv, scale * s.Size, tint, alpha,
rotation);
nv += 6;
}
public void DrawSprite(Sprite s, PaletteReference pal, in float3 location, float scale, in float3 tint, float alpha,
float rotation = 0f)
{
DrawSprite(s, ResolveTextureIndex(s, pal), location, scale, tint, alpha, rotation);
}
internal void DrawSprite(Sprite s, float paletteTextureIndex, in float3 a, in float3 b, in float3 c, in float3 d, in float3 tint, float alpha)
{
var samplers = SetRenderStateForSprite(s);
Util.FastCreateQuad(vertices, a, b, c, d, s, samplers, paletteTextureIndex, tint, alpha, nv);
nv += 6;
}
public void DrawVertexBuffer(IVertexBuffer<Vertex> buffer, int start, int length, PrimitiveType type, IEnumerable<Sheet> sheets, BlendMode blendMode)
{
var i = 0;
foreach (var s in sheets)
{
if (i >= SheetCount)
ThrowSheetOverflow(nameof(sheets));
if (s != null)
shader.SetTexture(SheetIndexToTextureName[i++], s.GetTexture());
}
renderer.Context.SetBlendMode(blendMode);
shader.PrepareRender();
renderer.DrawBatch(buffer, start, length, type);
renderer.Context.SetBlendMode(BlendMode.None);
}
// PERF: methods that throw won't be inlined by the JIT, so extract a static helper for use on hot paths
static void ThrowSheetOverflow(string paramName)
{
throw new ArgumentException($"SpriteRenderer only supports {SheetCount} simultaneous textures", paramName);
}
// For RGBAColorRenderer
internal void DrawRGBAVertices(Vertex[] v)
internal void DrawRGBAVertices(Vertex[] v, BlendMode blendMode)
{
renderer.CurrentBatchRenderer = this;
if (currentBlend != BlendMode.Alpha || nv + v.Length > renderer.TempBufferSize)
if (currentBlend != blendMode || nv + v.Length > renderer.TempBufferSize)
Flush();
currentBlend = BlendMode.Alpha;
currentBlend = blendMode;
Array.Copy(v, 0, vertices, nv, v.Length);
nv += v.Length;
}
public void SetPalette(ITexture palette)
public void SetPalette(ITexture palette, ITexture colorShifts)
{
shader.SetTexture("Palette", palette);
shader.SetTexture("ColorShifts", colorShifts);
}
public void SetViewportParams(Size screen, float depthScale, float depthOffset, int2 scroll)
public void SetViewportParams(Size sheetSize, int downscale, float depthMargin, int2 scroll)
{
shader.SetVec("Scroll", scroll.X, scroll.Y, scroll.Y);
shader.SetVec("r1",
2f / screen.Width,
2f / screen.Height,
-depthScale / screen.Height);
shader.SetVec("r2", -1, -1, 1 - depthOffset);
// Calculate the scale (r1) and offset (r2) that convert from OpenRA viewport pixels
// to OpenGL normalized device coordinates (NDC). OpenGL expects coordinates to vary from [-1, 1],
// so we rescale viewport pixels to the range [0, 2] using r1 then subtract 1 using r2.
var width = 2f / (downscale * sheetSize.Width);
var height = 2f / (downscale * sheetSize.Height);
// Texture index is sampled as a float, so convert to pixels then scale
shader.SetVec("DepthTextureScale", 128 * depthScale / screen.Height);
// Depth is more complicated:
// * The OpenGL z axis is inverted (negative is closer) relative to OpenRA (positive is closer).
// * We want to avoid clipping pixels that are behind the nominal z == y plane at the
// top of the map, or above the nominal z == y plane at the bottom of the map.
// We therefore expand the depth range by an extra margin that is calculated based on
// the maximum expected world height (see Renderer.InitializeDepthBuffer).
// * Sprites can specify an additional per-pixel depth offset map, which is applied in the
// fragment shader. The fragment shader operates in OpenGL window coordinates, not NDC,
// with a depth range [0, 1] corresponding to the NDC [-1, 1]. We must therefore multiply the
// sprite channel value [0, 1] by 255 to find the pixel depth offset, then by our depth scale
// to find the equivalent NDC offset, then divide by 2 to find the window coordinate offset.
// * If depthMargin == 0 (which indicates per-pixel depth testing is disabled) sprites that
// extend beyond the top of bottom edges of the screen may be pushed outside [-1, 1] and
// culled by the GPU. We avoid this by forcing everything into the z = 0 plane.
var depth = depthMargin != 0f ? 2f / (downscale * (sheetSize.Height + depthMargin)) : 0;
shader.SetVec("DepthTextureScale", 128 * depth);
shader.SetVec("Scroll", scroll.X, scroll.Y, depthMargin != 0f ? scroll.Y : 0);
shader.SetVec("r1", width, height, -depth);
shader.SetVec("r2", -1, -1, depthMargin != 0f ? 1 : 0);
}
public void SetDepthPreviewEnabled(bool enabled)
public void SetDepthPreview(bool enabled, float contrast, float offset)
{
shader.SetBool("EnableDepthPreview", enabled);
shader.SetVec("DepthPreviewParams", contrast, offset);
}
public void SetAntialiasingPixelsPerTexel(float pxPerTx)

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -15,14 +15,14 @@ using OpenRA.Primitives;
namespace OpenRA.Graphics
{
public struct TargetLineRenderable : IRenderable, IFinalizedRenderable
public class TargetLineRenderable : IRenderable, IFinalizedRenderable
{
readonly IEnumerable<WPos> waypoints;
readonly Color color;
readonly int width;
readonly int markerSize;
public TargetLineRenderable(IEnumerable<WPos> waypoints, Color color, int width = 1, int markerSize = 1)
public TargetLineRenderable(IEnumerable<WPos> waypoints, Color color, int width, int markerSize)
{
this.waypoints = waypoints;
this.color = color;
@@ -30,14 +30,19 @@ namespace OpenRA.Graphics
this.markerSize = markerSize;
}
public WPos Pos { get { return waypoints.First(); } }
public PaletteReference Palette { get { return null; } }
public int ZOffset { get { return 0; } }
public bool IsDecoration { get { return true; } }
public WPos Pos => waypoints.First();
public int ZOffset => 0;
public bool IsDecoration => true;
public IRenderable WithZOffset(int newOffset) { return this; }
public IRenderable OffsetBy(in WVec vec)
{
// Lambdas can't use 'in' variables, so capture a copy for later
var offset = vec;
return new TargetLineRenderable(waypoints.Select(w => w + offset), color, width, markerSize);
}
public IRenderable WithPalette(PaletteReference newPalette) { return new TargetLineRenderable(waypoints, color); }
public IRenderable WithZOffset(int newOffset) { return new TargetLineRenderable(waypoints, color); }
public IRenderable OffsetBy(WVec vec) { return new TargetLineRenderable(waypoints.Select(w => w + vec), color); }
public IRenderable AsDecoration() { return this; }
public IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; }
@@ -51,14 +56,14 @@ namespace OpenRA.Graphics
foreach (var b in waypoints.Skip(1).Select(pos => wr.Viewport.WorldToViewPx(wr.Screen3DPosition(pos))))
{
Game.Renderer.RgbaColorRenderer.DrawLine(a, b, width, color);
DrawTargetMarker(wr, color, b, markerSize);
DrawTargetMarker(color, b, markerSize);
a = b;
}
DrawTargetMarker(wr, color, first);
DrawTargetMarker(color, first);
}
public static void DrawTargetMarker(WorldRenderer wr, Color color, int2 screenPos, int size = 1)
public static void DrawTargetMarker(Color color, int2 screenPos, int size = 1)
{
var offset = new int2(size, size);
var tl = screenPos - offset;

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -12,19 +12,21 @@
using System;
using System.Collections.Generic;
using System.IO;
using OpenRA.Primitives;
namespace OpenRA.Graphics
{
public sealed class TerrainSpriteLayer : IDisposable
{
public readonly Sheet Sheet;
static readonly int[] CornerVertexMap = { 0, 1, 2, 2, 3, 0 };
public readonly BlendMode BlendMode;
readonly Sheet[] sheets;
readonly Sprite emptySprite;
readonly IVertexBuffer<Vertex> vertexBuffer;
readonly Vertex[] vertices;
readonly bool[] ignoreTint;
readonly HashSet<int> dirtyRows = new HashSet<int>();
readonly int rowStride;
readonly bool restrictToBounds;
@@ -32,67 +34,161 @@ namespace OpenRA.Graphics
readonly WorldRenderer worldRenderer;
readonly Map map;
readonly PaletteReference palette;
readonly PaletteReference[] palettes;
public TerrainSpriteLayer(World world, WorldRenderer wr, Sheet sheet, BlendMode blendMode, PaletteReference palette, bool restrictToBounds)
public TerrainSpriteLayer(World world, WorldRenderer wr, Sprite emptySprite, BlendMode blendMode, bool restrictToBounds)
{
worldRenderer = wr;
this.restrictToBounds = restrictToBounds;
Sheet = sheet;
this.emptySprite = emptySprite;
sheets = new Sheet[SpriteRenderer.SheetCount];
BlendMode = blendMode;
this.palette = palette;
map = world.Map;
rowStride = 6 * map.MapSize.X;
vertices = new Vertex[rowStride * map.MapSize.Y];
palettes = new PaletteReference[map.MapSize.X * map.MapSize.Y];
vertexBuffer = Game.Renderer.Context.CreateVertexBuffer(vertices.Length);
emptySprite = new Sprite(sheet, Rectangle.Empty, TextureChannel.Alpha);
wr.PaletteInvalidated += UpdatePaletteIndices;
if (wr.TerrainLighting != null)
{
ignoreTint = new bool[rowStride * map.MapSize.Y];
wr.TerrainLighting.CellChanged += UpdateTint;
}
}
void UpdatePaletteIndices()
{
// Everything in the layer uses the same palette,
// so we can fix the indices in one pass
for (var i = 0; i < vertices.Length; i++)
{
var v = vertices[i];
vertices[i] = new Vertex(v.X, v.Y, v.Z, v.S, v.T, v.U, v.V, palette.TextureIndex, v.C);
var p = palettes[i / 6]?.TextureIndex ?? 0;
vertices[i] = new Vertex(v.X, v.Y, v.Z, v.S, v.T, v.U, v.V, p, v.C, v.R, v.G, v.B, v.A);
}
for (var row = 0; row < map.MapSize.Y; row++)
dirtyRows.Add(row);
}
public void Update(CPos cell, Sprite sprite)
public void Clear(CPos cell)
{
var xyz = sprite == null ? float3.Zero :
worldRenderer.Screen3DPosition(map.CenterOfCell(cell)) + sprite.Offset - 0.5f * sprite.Size;
Update(cell.ToMPos(map.Grid.Type), sprite, xyz);
Update(cell, null, null, 1f, 1f, true);
}
public void Update(MPos uv, Sprite sprite, float3 pos)
public void Update(CPos cell, ISpriteSequence sequence, PaletteReference palette, int frame)
{
Update(cell, sequence.GetSprite(frame), palette, sequence.Scale, sequence.GetAlpha(frame), sequence.IgnoreWorldTint);
}
public void Update(CPos cell, Sprite sprite, PaletteReference palette, float scale = 1f, float alpha = 1f, bool ignoreTint = false)
{
var xyz = float3.Zero;
if (sprite != null)
{
if (sprite.Sheet != Sheet)
throw new InvalidDataException("Attempted to add sprite from a different sheet");
var cellOrigin = map.CenterOfCell(cell) - new WVec(0, 0, map.Grid.Ramps[map.Ramp[cell]].CenterHeightOffset);
xyz = worldRenderer.Screen3DPosition(cellOrigin) + scale * (sprite.Offset - 0.5f * sprite.Size);
}
Update(cell.ToMPos(map.Grid.Type), sprite, palette, xyz, scale, alpha, ignoreTint);
}
void UpdateTint(MPos uv)
{
var offset = rowStride * uv.V + 6 * uv.U;
if (ignoreTint[offset])
{
for (var i = 0; i < 6; i++)
{
var v = vertices[offset + i];
vertices[offset + i] = new Vertex(v.X, v.Y, v.Z, v.S, v.T, v.U, v.V, v.P, v.C, v.A * float3.Ones, v.A);
}
return;
}
// Allow the terrain tint to vary linearly across the cell to smooth out the staircase effect
// This is done by sampling the lighting the corners of the sprite, even though those pixels are
// transparent for isometric tiles
var tl = worldRenderer.TerrainLighting;
var pos = map.CenterOfCell(uv.ToCPos(map));
var step = map.Grid.Type == MapGridType.RectangularIsometric ? 724 : 512;
var weights = new[]
{
tl.TintAt(pos + new WVec(-step, -step, 0)),
tl.TintAt(pos + new WVec(step, -step, 0)),
tl.TintAt(pos + new WVec(step, step, 0)),
tl.TintAt(pos + new WVec(-step, step, 0))
};
// Apply tint directly to the underlying vertices
// This saves us from having to re-query the sprite information, which has not changed
for (var i = 0; i < 6; i++)
{
var v = vertices[offset + i];
vertices[offset + i] = new Vertex(v.X, v.Y, v.Z, v.S, v.T, v.U, v.V, v.P, v.C, v.A * weights[CornerVertexMap[i]], v.A);
}
dirtyRows.Add(uv.V);
}
int GetOrAddSheetIndex(Sheet sheet)
{
if (sheet == null)
return 0;
for (var i = 0; i < sheets.Length; i++)
{
if (sheets[i] == sheet)
return i;
if (sheets[i] == null)
{
sheets[i] = sheet;
return i;
}
}
throw new InvalidDataException("Sheet overflow");
}
public void Update(MPos uv, Sprite sprite, PaletteReference palette, in float3 pos, float scale, float alpha, bool ignoreTint)
{
int2 samplers;
if (sprite != null)
{
if (sprite.BlendMode != BlendMode)
throw new InvalidDataException("Attempted to add sprite with a different blend mode");
samplers = new int2(GetOrAddSheetIndex(sprite.Sheet), GetOrAddSheetIndex((sprite as SpriteWithSecondaryData)?.SecondarySheet));
// PERF: Remove useless palette assignments for RGBA sprites
// HACK: This is working around the limitation that palettes are defined on traits rather than on sequences,
// and can be removed once this has been fixed
if (sprite.Channel == TextureChannel.RGBA && !(palette?.HasColorShift ?? false))
palette = null;
}
else
{
sprite = emptySprite;
samplers = int2.Zero;
}
// The vertex buffer does not have geometry for cells outside the map
if (!map.Tiles.Contains(uv))
return;
var offset = rowStride * uv.V + 6 * uv.U;
Util.FastCreateQuad(vertices, pos, sprite, int2.Zero, palette.TextureIndex, offset, sprite.Size);
Util.FastCreateQuad(vertices, pos, sprite, samplers, palette?.TextureIndex ?? 0, offset, scale * sprite.Size, alpha * float3.Ones, alpha);
palettes[uv.V * map.MapSize.X + uv.U] = palette;
if (worldRenderer.TerrainLighting != null)
{
this.ignoreTint[offset] = ignoreTint;
UpdateTint(uv);
}
dirtyRows.Add(uv.V);
}
@@ -114,20 +210,12 @@ namespace OpenRA.Graphics
continue;
var rowOffset = rowStride * row;
unsafe
{
// The compiler / language spec won't let us calculate a pointer to
// an offset inside a generic array T[], and so we are forced to
// calculate the start-of-row pointer here to pass in to SetData.
fixed (Vertex* vPtr = &vertices[0])
vertexBuffer.SetData((IntPtr)(vPtr + rowOffset), rowOffset, rowStride);
}
vertexBuffer.SetData(vertices, rowOffset, rowOffset, rowStride);
}
Game.Renderer.WorldSpriteRenderer.DrawVertexBuffer(
vertexBuffer, rowStride * firstRow, rowStride * (lastRow - firstRow),
PrimitiveType.TriangleList, Sheet, BlendMode);
PrimitiveType.TriangleList, sheets, BlendMode);
Game.Renderer.Flush();
}
@@ -135,6 +223,9 @@ namespace OpenRA.Graphics
public void Dispose()
{
worldRenderer.PaletteInvalidated -= UpdatePaletteIndices;
if (worldRenderer.TerrainLighting != null)
worldRenderer.TerrainLighting.CellChanged -= UpdateTint;
vertexBuffer.Dispose();
}
}

View File

@@ -1,168 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using OpenRA.Primitives;
using OpenRA.Support;
namespace OpenRA.Graphics
{
class TheaterTemplate
{
public readonly Sprite[] Sprites;
public readonly int Stride;
public readonly int Variants;
public TheaterTemplate(Sprite[] sprites, int stride, int variants)
{
Sprites = sprites;
Stride = stride;
Variants = variants;
}
}
public sealed class Theater : IDisposable
{
readonly Dictionary<ushort, TheaterTemplate> templates = new Dictionary<ushort, TheaterTemplate>();
SheetBuilder sheetBuilder;
readonly Sprite missingTile;
readonly MersenneTwister random;
TileSet tileset;
public Theater(TileSet tileset)
{
this.tileset = tileset;
var allocated = false;
Func<Sheet> allocate = () =>
{
if (allocated)
throw new SheetOverflowException("Terrain sheet overflow. Try increasing the tileset SheetSize parameter.");
allocated = true;
return new Sheet(SheetType.Indexed, new Size(tileset.SheetSize, tileset.SheetSize));
};
random = new MersenneTwister();
var frameCache = new FrameCache(Game.ModData.DefaultFileSystem, Game.ModData.SpriteLoaders);
foreach (var t in tileset.Templates)
{
var variants = new List<Sprite[]>();
foreach (var i in t.Value.Images)
{
var allFrames = frameCache[i];
var frameCount = tileset.EnableDepth ? allFrames.Length / 2 : allFrames.Length;
var indices = t.Value.Frames != null ? t.Value.Frames : Enumerable.Range(0, frameCount);
variants.Add(indices.Select(j =>
{
var f = allFrames[j];
var tile = t.Value.Contains(j) ? t.Value[j] : null;
// The internal z axis is inverted from expectation (negative is closer)
var zOffset = tile != null ? -tile.ZOffset : 0;
var zRamp = tile != null ? tile.ZRamp : 1f;
var offset = new float3(f.Offset, zOffset);
var type = SheetBuilder.FrameTypeToSheetType(f.Type);
// Defer SheetBuilder creation until we know what type of frames we are loading!
// TODO: Support mixed indexed and BGRA frames
if (sheetBuilder == null)
sheetBuilder = new SheetBuilder(SheetBuilder.FrameTypeToSheetType(f.Type), allocate);
else if (type != sheetBuilder.Type)
throw new InvalidDataException("Sprite type mismatch. Terrain sprites must all be either Indexed or RGBA.");
var s = sheetBuilder.Allocate(f.Size, zRamp, offset);
Util.FastCopyIntoChannel(s, f.Data);
if (tileset.EnableDepth)
{
var ss = sheetBuilder.Allocate(f.Size, zRamp, offset);
Util.FastCopyIntoChannel(ss, allFrames[j + frameCount].Data);
// s and ss are guaranteed to use the same sheet
// because of the custom terrain sheet allocation
s = new SpriteWithSecondaryData(s, s.Sheet, ss.Bounds, ss.Channel);
}
return s;
}).ToArray());
}
var allSprites = variants.SelectMany(s => s);
// Ignore the offsets baked into R8 sprites
if (tileset.IgnoreTileSpriteOffsets)
allSprites = allSprites.Select(s => new Sprite(s.Sheet, s.Bounds, s.ZRamp, new float3(float2.Zero, s.Offset.Z), s.Channel, s.BlendMode));
templates.Add(t.Value.Id, new TheaterTemplate(allSprites.ToArray(), variants.First().Count(), t.Value.Images.Length));
}
// 1x1px transparent tile
missingTile = sheetBuilder.Add(new byte[sheetBuilder.Type == SheetType.BGRA ? 4 : 1], new Size(1, 1));
Sheet.ReleaseBuffer();
}
public Sprite TileSprite(TerrainTile r, int? variant = null)
{
TheaterTemplate template;
if (!templates.TryGetValue(r.Type, out template))
return missingTile;
if (r.Index >= template.Stride)
return missingTile;
var start = template.Variants > 1 ? variant.HasValue ? variant.Value : random.Next(template.Variants) : 0;
return template.Sprites[start * template.Stride + r.Index];
}
public Rectangle TemplateBounds(TerrainTemplateInfo template, Size tileSize, MapGridType mapGrid)
{
Rectangle? templateRect = null;
var i = 0;
for (var y = 0; y < template.Size.Y; y++)
{
for (var x = 0; x < template.Size.X; x++)
{
var tile = new TerrainTile(template.Id, (byte)(i++));
var tileInfo = tileset.GetTileInfo(tile);
// Empty tile
if (tileInfo == null)
continue;
var sprite = TileSprite(tile);
var u = mapGrid == MapGridType.Rectangular ? x : (x - y) / 2f;
var v = mapGrid == MapGridType.Rectangular ? y : (x + y) / 2f;
var tl = new float2(u * tileSize.Width, (v - 0.5f * tileInfo.Height) * tileSize.Height) - 0.5f * sprite.Size;
var rect = new Rectangle((int)(tl.X + sprite.Offset.X), (int)(tl.Y + sprite.Offset.Y), (int)sprite.Size.X, (int)sprite.Size.Y);
templateRect = templateRect.HasValue ? Rectangle.Union(templateRect.Value, rect) : rect;
}
}
return templateRect.HasValue ? templateRect.Value : Rectangle.Empty;
}
public Sheet Sheet { get { return sheetBuilder.Current; } }
public void Dispose()
{
sheetBuilder.Dispose();
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -13,7 +13,7 @@ using OpenRA.Primitives;
namespace OpenRA.Graphics
{
public struct UISpriteRenderable : IRenderable, IFinalizedRenderable
public class UISpriteRenderable : IRenderable, IPalettedRenderable, IFinalizedRenderable
{
readonly Sprite sprite;
readonly WPos effectiveWorldPos;
@@ -21,8 +21,10 @@ namespace OpenRA.Graphics
readonly int zOffset;
readonly PaletteReference palette;
readonly float scale;
readonly float alpha;
readonly float rotation = 0f;
public UISpriteRenderable(Sprite sprite, WPos effectiveWorldPos, int2 screenPos, int zOffset, PaletteReference palette, float scale)
public UISpriteRenderable(Sprite sprite, WPos effectiveWorldPos, int2 screenPos, int zOffset, PaletteReference palette, float scale = 1f, float alpha = 1f, float rotation = 0f)
{
this.sprite = sprite;
this.effectiveWorldPos = effectiveWorldPos;
@@ -30,37 +32,48 @@ namespace OpenRA.Graphics
this.zOffset = zOffset;
this.palette = palette;
this.scale = scale;
this.alpha = alpha;
this.rotation = rotation;
// PERF: Remove useless palette assignments for RGBA sprites
// HACK: This is working around the fact that palettes are defined on traits rather than sequences
// and can be removed once this has been fixed
if (sprite.Channel == TextureChannel.RGBA && !(palette?.HasColorShift ?? false))
this.palette = null;
}
// Does not exist in the world, so a world positions don't make sense
public WPos Pos { get { return effectiveWorldPos; } }
public WVec Offset { get { return WVec.Zero; } }
public bool IsDecoration { get { return true; } }
public WPos Pos => effectiveWorldPos;
public WVec Offset => WVec.Zero;
public bool IsDecoration => true;
public PaletteReference Palette { get { return palette; } }
public int ZOffset { get { return zOffset; } }
public PaletteReference Palette => palette;
public int ZOffset => zOffset;
public IRenderable WithPalette(PaletteReference newPalette) { return new UISpriteRenderable(sprite, effectiveWorldPos, screenPos, zOffset, newPalette, scale); }
public IPalettedRenderable WithPalette(PaletteReference newPalette) { return new UISpriteRenderable(sprite, effectiveWorldPos, screenPos, zOffset, newPalette, scale, alpha, rotation); }
public IRenderable WithZOffset(int newOffset) { return this; }
public IRenderable OffsetBy(WVec vec) { return this; }
public IRenderable OffsetBy(in WVec vec) { return this; }
public IRenderable AsDecoration() { return this; }
public IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; }
public void Render(WorldRenderer wr)
{
Game.Renderer.SpriteRenderer.DrawSprite(sprite, screenPos, palette, scale * sprite.Size);
Game.Renderer.SpriteRenderer.DrawSprite(sprite, palette, screenPos, scale, float3.Ones, alpha, rotation);
}
public void RenderDebugGeometry(WorldRenderer wr)
{
var offset = screenPos + sprite.Offset.XY;
Game.Renderer.RgbaColorRenderer.DrawRect(offset, offset + sprite.Size.XY, 1, Color.Red);
if (rotation == 0f)
Game.Renderer.RgbaColorRenderer.DrawRect(offset, offset + sprite.Size.XY, 1, Color.Red);
else
Game.Renderer.RgbaColorRenderer.DrawPolygon(Util.RotateQuad(offset, sprite.Size, rotation), 1, Color.Red);
}
public Rectangle ScreenBounds(WorldRenderer wr)
{
var offset = screenPos + sprite.Offset;
return new Rectangle((int)offset.X, (int)offset.Y, (int)sprite.Size.X, (int)sprite.Size.Y);
return Util.BoundingRectangle(offset, sprite.Size, rotation);
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -20,26 +20,60 @@ namespace OpenRA.Graphics
// yes, our channel order is nuts.
static readonly int[] ChannelMasks = { 2, 1, 0, 3 };
public static void FastCreateQuad(Vertex[] vertices, float3 o, Sprite r, int2 samplers, float paletteTextureIndex, int nv, float3 size)
public static void FastCreateQuad(Vertex[] vertices, in float3 o, Sprite r, int2 samplers, float paletteTextureIndex, int nv,
in float3 size, in float3 tint, float alpha, float rotation = 0f)
{
var b = new float3(o.X + size.X, o.Y, o.Z);
var c = new float3(o.X + size.X, o.Y + size.Y, o.Z + size.Z);
var d = new float3(o.X, o.Y + size.Y, o.Z + size.Z);
FastCreateQuad(vertices, o, b, c, d, r, samplers, paletteTextureIndex, nv);
float3 a, b, c, d;
// Rotate sprite if rotation angle is not equal to 0
if (rotation != 0f)
{
var center = o + 0.5f * size;
var angleSin = (float)Math.Sin(-rotation);
var angleCos = (float)Math.Cos(-rotation);
// Rotated offset for +/- x with +/- y
var ra = 0.5f * new float3(
size.X * angleCos - size.Y * angleSin,
size.X * angleSin + size.Y * angleCos,
(size.X * angleSin + size.Y * angleCos) * size.Z / size.Y);
// Rotated offset for +/- x with -/+ y
var rb = 0.5f * new float3(
size.X * angleCos + size.Y * angleSin,
size.X * angleSin - size.Y * angleCos,
(size.X * angleSin - size.Y * angleCos) * size.Z / size.Y);
a = center - ra;
b = center + rb;
c = center + ra;
d = center - rb;
}
else
{
a = o;
b = new float3(o.X + size.X, o.Y, o.Z);
c = new float3(o.X + size.X, o.Y + size.Y, o.Z + size.Z);
d = new float3(o.X, o.Y + size.Y, o.Z + size.Z);
}
FastCreateQuad(vertices, a, b, c, d, r, samplers, paletteTextureIndex, tint, alpha, nv);
}
public static void FastCreateQuad(Vertex[] vertices, float3 a, float3 b, float3 c, float3 d, Sprite r, int2 samplers, float paletteTextureIndex, int nv)
public static void FastCreateQuad(Vertex[] vertices,
in float3 a, in float3 b, in float3 c, in float3 d,
Sprite r, int2 samplers, float paletteTextureIndex,
in float3 tint, float alpha, int nv)
{
float sl = 0;
float st = 0;
float sr = 0;
float sb = 0;
// See shp.vert for documentation on the channel attribute format
// See combined.vert for documentation on the channel attribute format
var attribC = r.Channel == TextureChannel.RGBA ? 0x02 : ((byte)r.Channel) << 1 | 0x01;
attribC |= samplers.X << 6;
var ss = r as SpriteWithSecondaryData;
if (ss != null)
if (r is SpriteWithSecondaryData ss)
{
sl = ss.SecondaryLeft;
st = ss.SecondaryTop;
@@ -51,15 +85,15 @@ namespace OpenRA.Graphics
}
var fAttribC = (float)attribC;
vertices[nv] = new Vertex(a, r.Left, r.Top, sl, st, paletteTextureIndex, fAttribC);
vertices[nv + 1] = new Vertex(b, r.Right, r.Top, sr, st, paletteTextureIndex, fAttribC);
vertices[nv + 2] = new Vertex(c, r.Right, r.Bottom, sr, sb, paletteTextureIndex, fAttribC);
vertices[nv + 3] = new Vertex(c, r.Right, r.Bottom, sr, sb, paletteTextureIndex, fAttribC);
vertices[nv + 4] = new Vertex(d, r.Left, r.Bottom, sl, sb, paletteTextureIndex, fAttribC);
vertices[nv + 5] = new Vertex(a, r.Left, r.Top, sl, st, paletteTextureIndex, fAttribC);
vertices[nv] = new Vertex(a, r.Left, r.Top, sl, st, paletteTextureIndex, fAttribC, tint, alpha);
vertices[nv + 1] = new Vertex(b, r.Right, r.Top, sr, st, paletteTextureIndex, fAttribC, tint, alpha);
vertices[nv + 2] = new Vertex(c, r.Right, r.Bottom, sr, sb, paletteTextureIndex, fAttribC, tint, alpha);
vertices[nv + 3] = new Vertex(c, r.Right, r.Bottom, sr, sb, paletteTextureIndex, fAttribC, tint, alpha);
vertices[nv + 4] = new Vertex(d, r.Left, r.Bottom, sl, sb, paletteTextureIndex, fAttribC, tint, alpha);
vertices[nv + 5] = new Vertex(a, r.Left, r.Top, sl, st, paletteTextureIndex, fAttribC, tint, alpha);
}
public static void FastCopyIntoChannel(Sprite dest, byte[] src)
public static void FastCopyIntoChannel(Sprite dest, byte[] src, SpriteFrameType srcType)
{
var destData = dest.Sheet.GetData();
var width = dest.Bounds.Width;
@@ -82,12 +116,34 @@ namespace OpenRA.Graphics
{
for (var i = 0; i < width; i++)
{
var r = src[k++];
var g = src[k++];
var b = src[k++];
var a = src[k++];
var cc = Color.FromArgb(a, r, g, b);
byte r, g, b, a;
switch (srcType)
{
case SpriteFrameType.Bgra32:
case SpriteFrameType.Bgr24:
{
b = src[k++];
g = src[k++];
r = src[k++];
a = srcType == SpriteFrameType.Bgra32 ? src[k++] : (byte)255;
break;
}
case SpriteFrameType.Rgba32:
case SpriteFrameType.Rgb24:
{
r = src[k++];
g = src[k++];
b = src[k++];
a = srcType == SpriteFrameType.Rgba32 ? src[k++] : (byte)255;
break;
}
default:
throw new InvalidOperationException($"Unknown SpriteFrameType {srcType}");
}
var cc = Color.FromArgb(a, r, g, b);
data[(y + j) * destStride + x + i] = PremultiplyAlpha(cc).ToArgb();
}
}
@@ -136,16 +192,29 @@ namespace OpenRA.Graphics
for (var i = 0; i < width; i++)
{
Color cc;
if (src.Palette == null)
switch (src.Type)
{
var r = src.Data[k++];
var g = src.Data[k++];
var b = src.Data[k++];
var a = src.Data[k++];
cc = Color.FromArgb(a, r, g, b);
case SpriteFrameType.Indexed8:
{
cc = src.Palette[src.Data[k++]];
break;
}
case SpriteFrameType.Rgba32:
case SpriteFrameType.Rgb24:
{
var r = src.Data[k++];
var g = src.Data[k++];
var b = src.Data[k++];
var a = src.Type == SpriteFrameType.Rgba32 ? src.Data[k++] : (byte)255;
cc = Color.FromArgb(a, r, g, b);
break;
}
// Pngs don't support BGR[A], so no need to include them here
default:
throw new InvalidOperationException($"Unknown SpriteFrameType {src.Type}");
}
else
cc = src.Palette[src.Data[k++]];
data[(y + j) * destStride + x + i] = PremultiplyAlpha(cc).ToArgb();
}
@@ -154,6 +223,69 @@ namespace OpenRA.Graphics
}
}
/// <summary>Rotates a quad about its center in the x-y plane.</summary>
/// <param name="tl">The top left vertex of the quad</param>
/// <param name="size">A float3 containing the X, Y, and Z lengths of the quad</param>
/// <param name="rotation">The number of radians to rotate by</param>
/// <returns>An array of four vertices representing the rotated quad (top-left, top-right, bottom-right, bottom-left)</returns>
public static float3[] RotateQuad(float3 tl, float3 size, float rotation)
{
var center = tl + 0.5f * size;
var angleSin = (float)Math.Sin(-rotation);
var angleCos = (float)Math.Cos(-rotation);
// Rotated offset for +/- x with +/- y
var ra = 0.5f * new float3(
size.X * angleCos - size.Y * angleSin,
size.X * angleSin + size.Y * angleCos,
(size.X * angleSin + size.Y * angleCos) * size.Z / size.Y);
// Rotated offset for +/- x with -/+ y
var rb = 0.5f * new float3(
size.X * angleCos + size.Y * angleSin,
size.X * angleSin - size.Y * angleCos,
(size.X * angleSin - size.Y * angleCos) * size.Z / size.Y);
return new float3[]
{
center - ra,
center + rb,
center + ra,
center - rb
};
}
/// <summary>
/// Returns the bounds of an object. Used for determining which objects need to be rendered on screen, and which do not.
/// </summary>
/// <param name="offset">The top left vertex of the object</param>
/// <param name="size">A float 3 containing the X, Y, and Z lengths of the object</param>
/// <param name="rotation">The angle to rotate the object by (use 0f if there is no rotation)</param>
public static Rectangle BoundingRectangle(float3 offset, float3 size, float rotation)
{
if (rotation == 0f)
return new Rectangle((int)offset.X, (int)offset.Y, (int)size.X, (int)size.Y);
var rotatedQuad = Util.RotateQuad(offset, size, rotation);
var minX = rotatedQuad[0].X;
var maxX = rotatedQuad[0].X;
var minY = rotatedQuad[0].Y;
var maxY = rotatedQuad[0].Y;
for (var i = 1; i < rotatedQuad.Length; i++)
{
minX = Math.Min(rotatedQuad[i].X, minX);
maxX = Math.Max(rotatedQuad[i].X, maxX);
minY = Math.Min(rotatedQuad[i].Y, minY);
maxY = Math.Max(rotatedQuad[i].Y, maxY);
}
return new Rectangle(
(int)minX,
(int)minY,
(int)Math.Ceiling(maxX) - (int)minX,
(int)Math.Ceiling(maxY) - (int)minY);
}
public static Color PremultiplyAlpha(Color c)
{
if (c.A == byte.MaxValue)

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -14,19 +14,36 @@ using System.Runtime.InteropServices;
namespace OpenRA.Graphics
{
[StructLayout(LayoutKind.Sequential)]
public struct Vertex
public readonly struct Vertex
{
public readonly float X, Y, Z, S, T, U, V, P, C;
// 3d position
public readonly float X, Y, Z;
public Vertex(float3 xyz, float s, float t, float u, float v, float p, float c)
: this(xyz.X, xyz.Y, xyz.Z, s, t, u, v, p, c) { }
// Primary and secondary texture coordinates or RGBA color
public readonly float S, T, U, V;
public Vertex(float x, float y, float z, float s, float t, float u, float v, float p, float c)
// Palette and channel flags
public readonly float P, C;
// Color tint
public readonly float R, G, B, A;
public Vertex(in float3 xyz, float s, float t, float u, float v, float p, float c)
: this(xyz.X, xyz.Y, xyz.Z, s, t, u, v, p, c, float3.Ones, 1f) { }
public Vertex(in float3 xyz, float s, float t, float u, float v, float p, float c, in float3 tint, float a)
: this(xyz.X, xyz.Y, xyz.Z, s, t, u, v, p, c, tint.X, tint.Y, tint.Z, a) { }
public Vertex(float x, float y, float z, float s, float t, float u, float v, float p, float c, in float3 tint, float a)
: this(x, y, z, s, t, u, v, p, c, tint.X, tint.Y, tint.Z, a) { }
public Vertex(float x, float y, float z, float s, float t, float u, float v, float p, float c, float r, float g, float b, float a)
{
X = x; Y = y; Z = z;
S = s; T = t;
U = u; V = v;
P = p; C = c;
R = r; G = g; B = b; A = a;
}
}
}

View File

@@ -0,0 +1,36 @@
#region Copyright & License Information
/*
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
namespace OpenRA.Video
{
public interface IVideo
{
ushort FrameCount { get; }
byte Framerate { get; }
ushort Width { get; }
ushort Height { get; }
/// <summary>
/// Current frame color data in 32-bit BGRA.
/// </summary>
byte[] CurrentFrameData { get; }
int CurrentFrameIndex { get; }
void AdvanceFrame();
bool HasAudio { get; }
byte[] AudioData { get; }
int AudioChannels { get; }
int SampleBits { get; }
int SampleRate { get; }
void Reset();
}
}

View File

@@ -0,0 +1,32 @@
#region Copyright & License Information
/*
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.IO;
namespace OpenRA.Video
{
public interface IVideoLoader
{
bool TryParseVideo(Stream s, bool useFramePadding, out IVideo video);
}
public static class VideoLoader
{
public static IVideo GetVideo(Stream stream, bool useFramePadding, IVideoLoader[] loaders)
{
foreach (var loader in loaders)
if (loader.TryParseVideo(stream, useFramePadding, out var video))
return video;
return null;
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -19,6 +19,11 @@ namespace OpenRA.Graphics
[Flags]
public enum ScrollDirection { None = 0, Up = 1, Left = 2, Down = 4, Right = 8 }
public interface INotifyViewportZoomExtentsChanged
{
void ViewportZoomExtentsChanged(float minZoom, float maxZoom);
}
public static class ViewportExts
{
public static bool Includes(this ScrollDirection d, ScrollDirection s)
@@ -46,11 +51,11 @@ namespace OpenRA.Graphics
// Viewport geometry (world-px)
public int2 CenterLocation { get; private set; }
public WPos CenterPosition { get { return worldRenderer.ProjectedPosition(CenterLocation); } }
public WPos CenterPosition => worldRenderer.ProjectedPosition(CenterLocation);
public Rectangle Rectangle { get { return new Rectangle(TopLeft, new Size(viewportSize.X, viewportSize.Y)); } }
public int2 TopLeft { get { return CenterLocation - viewportSize / 2; } }
public int2 BottomRight { get { return CenterLocation + viewportSize / 2; } }
public Rectangle Rectangle => new Rectangle(TopLeft, new Size(viewportSize.X, viewportSize.Y));
public int2 TopLeft => CenterLocation - viewportSize / 2;
public int2 BottomRight => CenterLocation + viewportSize / 2;
int2 viewportSize;
ProjectedCellRegion cells;
bool cellsDirty = true;
@@ -70,10 +75,7 @@ namespace OpenRA.Graphics
public float Zoom
{
get
{
return zoom;
}
get => zoom;
private set
{
@@ -84,12 +86,22 @@ namespace OpenRA.Graphics
}
}
public float MinZoom => minZoom;
public void AdjustZoom(float dz)
{
// Exponential ensures that equal positive and negative steps have the same effect
Zoom = (zoom * (float)Math.Exp(dz)).Clamp(unlockMinZoom ? unlockedMinZoom : minZoom, maxZoom);
}
public void AdjustZoom(float dz, int2 center)
{
var oldCenter = worldRenderer.Viewport.ViewToWorldPx(center);
AdjustZoom(dz);
var newCenter = worldRenderer.Viewport.ViewToWorldPx(center);
CenterLocation += oldCenter - newCenter;
}
public void ToggleZoom()
{
// Unlocked zooms always reset to the default zoom
@@ -226,7 +238,7 @@ namespace OpenRA.Graphics
if (unlockMinZoom)
{
// Specators and the map editor support zooming out by an extra factor of two.
// Spectators and the map editor support zooming out by an extra factor of two.
// TODO: Allow zooming out until the full map is visible
// We need to improve our viewport scroll handling to center the map as we zoom out
// before this will work well enough to enable
@@ -237,6 +249,12 @@ namespace OpenRA.Graphics
Zoom = minZoom;
else
Zoom = Zoom.Clamp(minZoom, maxZoom);
var maxSize = (1f / (unlockMinZoom ? unlockedMinZoom : minZoom) * new float2(Game.Renderer.NativeResolution));
Game.Renderer.SetMaximumViewportSize(new Size((int)maxSize.X, (int)maxSize.Y));
foreach (var t in worldRenderer.World.WorldActor.TraitsImplementing<INotifyViewportZoomExtentsChanged>())
t.ViewportZoomExtentsChanged(minZoom, maxZoom);
}
public CPos ViewToWorld(int2 view)
@@ -244,7 +262,6 @@ namespace OpenRA.Graphics
var world = worldRenderer.Viewport.ViewToWorldPx(view);
var map = worldRenderer.World.Map;
var candidates = CandidateMouseoverCells(world).ToList();
var tileSet = worldRenderer.World.Map.Rules.TileSet;
foreach (var uv in candidates)
{
@@ -253,18 +270,9 @@ namespace OpenRA.Graphics
var s = worldRenderer.ScreenPxPosition(p);
if (Math.Abs(s.X - world.X) <= tileSize.Width && Math.Abs(s.Y - world.Y) <= tileSize.Height)
{
var ramp = 0;
if (map.Contains(uv))
{
var ti = tileSet.GetTileInfo(map.Tiles[uv]);
if (ti != null)
ramp = ti.RampType;
}
var corners = map.Grid.CellCorners[ramp];
var pos = map.CenterOfCell(uv.ToCPos(map));
var screen = corners.Select(c => worldRenderer.ScreenPxPosition(pos + c)).ToArray();
var ramp = map.Grid.Ramps[map.Ramp.Contains(uv) ? map.Ramp[uv] : 0];
var pos = map.CenterOfCell(uv.ToCPos(map)) - new WVec(0, 0, ramp.CenterHeightOffset);
var screen = ramp.Corners.Select(c => worldRenderer.ScreenPxPosition(pos + c)).ToArray();
if (screen.PolygonContains(world))
return uv.ToCPos(map);
}
@@ -274,7 +282,7 @@ namespace OpenRA.Graphics
// Try and find the closest cell
if (candidates.Count > 0)
{
return candidates.OrderBy(uv =>
return candidates.MinBy(uv =>
{
var p = map.CenterOfCell(uv.ToCPos(map.Grid.Type));
var s = worldRenderer.ScreenPxPosition(p);
@@ -282,7 +290,7 @@ namespace OpenRA.Graphics
var dy = Math.Abs(s.Y - world.Y);
return dx * dx + dy * dy;
}).First().ToCPos(map);
}).ToCPos(map);
}
// Something is very wrong, but lets return something that isn't completely bogus and hope the caller can recover
@@ -306,7 +314,7 @@ namespace OpenRA.Graphics
public int2 ViewToWorldPx(int2 view) { return (graphicSettings.UIScale / Zoom * view.ToFloat2()).ToInt2() + TopLeft; }
public int2 WorldToViewPx(int2 world) { return ((Zoom / graphicSettings.UIScale) * (world - TopLeft).ToFloat2()).ToInt2(); }
public int2 WorldToViewPx(float3 world) { return ((Zoom / graphicSettings.UIScale) * (world - TopLeft).XY).ToInt2(); }
public int2 WorldToViewPx(in float3 world) { return ((Zoom / graphicSettings.UIScale) * (world - TopLeft).XY).ToInt2(); }
public void Center(IEnumerable<Actor> actors)
{

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -20,14 +20,14 @@ namespace OpenRA.Graphics
{
public sealed class WorldRenderer : IDisposable
{
public static readonly Func<IRenderable, int> RenderableScreenZPositionComparisonKey =
r => ZPosition(r.Pos, r.ZOffset);
public static readonly Func<IRenderable, int> RenderableZPositionComparisonKey =
r => r.Pos.Y + r.Pos.Z + r.ZOffset;
public readonly Size TileSize;
public readonly int TileScale;
public readonly World World;
public readonly Theater Theater;
public Viewport Viewport { get; private set; }
public Viewport Viewport { get; }
public readonly ITerrainLighting TerrainLighting;
public event Action PaletteInvalidated = null;
@@ -43,7 +43,7 @@ namespace OpenRA.Graphics
readonly List<IFinalizedRenderable> preparedOverlayRenderables = new List<IFinalizedRenderable>();
readonly List<IFinalizedRenderable> preparedAnnotationRenderables = new List<IFinalizedRenderable>();
bool lastDepthPreviewEnabled;
readonly List<IRenderable> renderablesBuffer = new List<IRenderable>();
internal WorldRenderer(ModData modData, World world)
{
@@ -65,7 +65,7 @@ namespace OpenRA.Graphics
palette.Initialize();
Theater = new Theater(world.Map.Rules.TileSet);
TerrainLighting = world.WorldActor.TraitOrDefault<ITerrainLighting>();
terrainRenderer = world.WorldActor.TraitOrDefault<IRenderTerrain>();
debugVis = Exts.Lazy(() => world.WorldActor.TraitOrDefault<DebugVisualizations>());
@@ -83,7 +83,13 @@ namespace OpenRA.Graphics
return new PaletteReference(name, palette.GetPaletteIndex(name), pal, palette);
}
public PaletteReference Palette(string name) { return palettes.GetOrAdd(name, createPaletteReference); }
public PaletteReference Palette(string name)
{
// HACK: This is working around the fact that palettes are defined on traits rather than sequences
// and can be removed once this has been fixed.
return name == null ? null : palettes.GetOrAdd(name, createPaletteReference);
}
public void AddPalette(string name, ImmutablePalette pal, bool allowModifiers = false, bool allowOverwrite = false)
{
if (allowOverwrite && palette.Contains(name))
@@ -93,8 +99,8 @@ namespace OpenRA.Graphics
var oldHeight = palette.Height;
palette.AddPalette(name, pal, allowModifiers);
if (oldHeight != palette.Height && PaletteInvalidated != null)
PaletteInvalidated();
if (oldHeight != palette.Height)
PaletteInvalidated?.Invoke();
}
}
@@ -107,78 +113,121 @@ namespace OpenRA.Graphics
palettes[name].Palette = pal;
}
IEnumerable<IFinalizedRenderable> GenerateRenderables()
public void SetPaletteColorShift(string name, float hueOffset, float satOffset, float minHue, float maxHue)
{
var actors = onScreenActors.Append(World.WorldActor);
if (World.RenderPlayer != null)
actors = actors.Append(World.RenderPlayer.PlayerActor);
palette.SetColorShift(name, hueOffset, satOffset, minHue, maxHue);
}
// PERF: Avoid LINQ.
void GenerateRenderables()
{
foreach (var actor in onScreenActors)
renderablesBuffer.AddRange(actor.Render(this));
renderablesBuffer.AddRange(World.WorldActor.Render(this));
if (World.RenderPlayer != null)
renderablesBuffer.AddRange(World.RenderPlayer.PlayerActor.Render(this));
var worldRenderables = actors.SelectMany(a => a.Render(this));
if (World.OrderGenerator != null)
worldRenderables = worldRenderables.Concat(World.OrderGenerator.Render(this, World));
renderablesBuffer.AddRange(World.OrderGenerator.Render(this, World));
// Unpartitioned effects
worldRenderables = worldRenderables.Concat(World.UnpartitionedEffects.SelectMany(e => e.Render(this)));
foreach (var e in World.UnpartitionedEffects)
renderablesBuffer.AddRange(e.Render(this));
// Partitioned, currently on-screen effects
var effectRenderables = World.ScreenMap.RenderableEffectsInBox(Viewport.TopLeft, Viewport.BottomRight);
worldRenderables = worldRenderables.Concat(effectRenderables.SelectMany(e => e.Render(this)));
foreach (var e in World.ScreenMap.RenderableEffectsInBox(Viewport.TopLeft, Viewport.BottomRight))
renderablesBuffer.AddRange(e.Render(this));
worldRenderables = worldRenderables.OrderBy(RenderableScreenZPositionComparisonKey);
// Renderables must be ordered using a stable sorting algorithm to avoid flickering artefacts
foreach (var renderable in renderablesBuffer.OrderBy(RenderableZPositionComparisonKey))
preparedRenderables.Add(renderable.PrepareRender(this));
return worldRenderables.Select(r => r.PrepareRender(this));
// PERF: Reuse collection to avoid allocations.
renderablesBuffer.Clear();
}
IEnumerable<IFinalizedRenderable> GenerateOverlayRenderables()
// PERF: Avoid LINQ.
void GenerateOverlayRenderables()
{
var actors = World.ActorsWithTrait<IRenderAboveShroud>()
.Where(a => a.Actor.IsInWorld && !a.Actor.Disposed && (!a.Trait.SpatiallyPartitionable || onScreenActors.Contains(a.Actor)))
.SelectMany(a => a.Trait.RenderAboveShroud(a.Actor, this));
World.ApplyToActorsWithTrait<IRenderAboveShroud>((actor, trait) =>
{
if (!actor.IsInWorld || actor.Disposed || (trait.SpatiallyPartitionable && !onScreenActors.Contains(actor)))
return;
var selected = World.Selection.Actors.Where(a => a.IsInWorld && !a.Disposed)
.SelectMany(a => a.TraitsImplementing<IRenderAboveShroudWhenSelected>()
.Where(t => !t.SpatiallyPartitionable || onScreenActors.Contains(a))
.SelectMany(t => t.RenderAboveShroud(a, this)));
foreach (var renderable in trait.RenderAboveShroud(actor, this))
preparedOverlayRenderables.Add(renderable.PrepareRender(this));
});
var effects = World.Effects.Select(e => e as IEffectAboveShroud)
.Where(e => e != null)
.SelectMany(e => e.RenderAboveShroud(this));
foreach (var a in World.Selection.Actors)
{
if (!a.IsInWorld || a.Disposed)
continue;
foreach (var t in a.TraitsImplementing<IRenderAboveShroudWhenSelected>())
{
if (t.SpatiallyPartitionable && !onScreenActors.Contains(a))
continue;
foreach (var renderable in t.RenderAboveShroud(a, this))
preparedOverlayRenderables.Add(renderable.PrepareRender(this));
}
}
foreach (var e in World.Effects)
{
if (!(e is IEffectAboveShroud ea))
continue;
foreach (var renderable in ea.RenderAboveShroud(this))
preparedOverlayRenderables.Add(renderable.PrepareRender(this));
}
var orderGenerator = SpriteRenderable.None;
if (World.OrderGenerator != null)
orderGenerator = World.OrderGenerator.RenderAboveShroud(this, World);
return actors
.Concat(selected)
.Concat(effects)
.Concat(orderGenerator)
.Select(r => r.PrepareRender(this));
foreach (var renderable in World.OrderGenerator.RenderAboveShroud(this, World))
preparedOverlayRenderables.Add(renderable.PrepareRender(this));
}
IEnumerable<IFinalizedRenderable> GenerateAnnotationRenderables()
// PERF: Avoid LINQ.
void GenerateAnnotationRenderables()
{
var actors = World.ActorsWithTrait<IRenderAnnotations>()
.Where(a => a.Actor.IsInWorld && !a.Actor.Disposed && (!a.Trait.SpatiallyPartitionable || onScreenActors.Contains(a.Actor)))
.SelectMany(a => a.Trait.RenderAnnotations(a.Actor, this));
World.ApplyToActorsWithTrait<IRenderAnnotations>((actor, trait) =>
{
if (!actor.IsInWorld || actor.Disposed || (trait.SpatiallyPartitionable && !onScreenActors.Contains(actor)))
return;
var selected = World.Selection.Actors.Where(a => a.IsInWorld && !a.Disposed)
.SelectMany(a => a.TraitsImplementing<IRenderAnnotationsWhenSelected>()
.Where(t => !t.SpatiallyPartitionable || onScreenActors.Contains(a))
.SelectMany(t => t.RenderAnnotations(a, this)));
foreach (var renderAnnotation in trait.RenderAnnotations(actor, this))
preparedAnnotationRenderables.Add(renderAnnotation.PrepareRender(this));
});
var effects = World.Effects.Select(e => e as IEffectAnnotation)
.Where(e => e != null)
.SelectMany(e => e.RenderAnnotation(this));
foreach (var a in World.Selection.Actors)
{
if (!a.IsInWorld || a.Disposed)
continue;
foreach (var t in a.TraitsImplementing<IRenderAnnotationsWhenSelected>())
{
if (t.SpatiallyPartitionable && !onScreenActors.Contains(a))
continue;
foreach (var renderAnnotation in t.RenderAnnotations(a, this))
preparedAnnotationRenderables.Add(renderAnnotation.PrepareRender(this));
}
}
foreach (var e in World.Effects)
{
if (!(e is IEffectAnnotation ea))
continue;
foreach (var renderAnnotation in ea.RenderAnnotation(this))
preparedAnnotationRenderables.Add(renderAnnotation.PrepareRender(this));
}
var orderGenerator = SpriteRenderable.None;
if (World.OrderGenerator != null)
orderGenerator = World.OrderGenerator.RenderAnnotations(this, World);
return actors
.Concat(selected)
.Concat(effects)
.Concat(orderGenerator)
.Select(r => r.PrepareRender(this));
foreach (var renderAnnotation in World.OrderGenerator.RenderAnnotations(this, World))
preparedAnnotationRenderables.Add(renderAnnotation.PrepareRender(this));
}
public void PrepareRenderables()
@@ -190,9 +239,11 @@ namespace OpenRA.Graphics
// PERF: Reuse collection to avoid allocations.
onScreenActors.UnionWith(World.ScreenMap.RenderableActorsInBox(Viewport.TopLeft, Viewport.BottomRight));
preparedRenderables.AddRange(GenerateRenderables());
preparedOverlayRenderables.AddRange(GenerateOverlayRenderables());
preparedAnnotationRenderables.AddRange(GenerateAnnotationRenderables());
GenerateRenderables();
GenerateOverlayRenderables();
GenerateAnnotationRenderables();
onScreenActors.Clear();
}
@@ -201,11 +252,7 @@ namespace OpenRA.Graphics
if (World.WorldActor.Disposed)
return;
if (debugVis.Value != null && lastDepthPreviewEnabled != debugVis.Value.DepthBuffer)
{
lastDepthPreviewEnabled = debugVis.Value.DepthBuffer;
Game.Renderer.WorldSpriteRenderer.SetDepthPreviewEnabled(lastDepthPreviewEnabled);
}
debugVis.Value?.UpdateDepthBuffer();
var bounds = Viewport.GetScissorBounds(World.Type != WorldType.Editor);
Game.Renderer.EnableScissor(bounds);
@@ -213,8 +260,7 @@ namespace OpenRA.Graphics
if (enableDepthBuffer)
Game.Renderer.Context.EnableDepthBuffer();
if (terrainRenderer != null)
terrainRenderer.RenderTerrain(this, Viewport);
terrainRenderer?.RenderTerrain(this, Viewport);
Game.Renderer.Flush();
@@ -224,15 +270,16 @@ namespace OpenRA.Graphics
if (enableDepthBuffer)
Game.Renderer.ClearDepthBuffer();
foreach (var a in World.ActorsWithTrait<IRenderAboveWorld>())
if (a.Actor.IsInWorld && !a.Actor.Disposed)
a.Trait.RenderAboveWorld(a.Actor, this);
World.ApplyToActorsWithTrait<IRenderAboveWorld>((actor, trait) =>
{
if (actor.IsInWorld && !actor.Disposed)
trait.RenderAboveWorld(actor, this);
});
if (enableDepthBuffer)
Game.Renderer.ClearDepthBuffer();
foreach (var a in World.ActorsWithTrait<IRenderShroud>())
a.Trait.RenderShroud(this);
World.ApplyToActorsWithTrait<IRenderShroud>((actor, trait) => trait.RenderShroud(this));
if (enableDepthBuffer)
Game.Renderer.Context.DisableDepthBuffer();
@@ -277,11 +324,16 @@ namespace OpenRA.Graphics
Game.Renderer.RgbaColorRenderer.DrawRect(tl, br, 1, Color.MediumSpringGreen);
}
foreach (var r in World.ScreenMap.MouseBounds(World.RenderPlayer))
foreach (var b in World.ScreenMap.MouseBounds(World.RenderPlayer))
{
var tl = Viewport.WorldToViewPx(new float2(r.Left, r.Top));
var br = Viewport.WorldToViewPx(new float2(r.Right, r.Bottom));
Game.Renderer.RgbaColorRenderer.DrawRect(tl, br, 1, Color.OrangeRed);
var points = new float2[b.Vertices.Length];
for (var index = 0; index < b.Vertices.Length; index++)
{
var vertex = b.Vertices[index];
points[index] = Viewport.WorldToViewPx(vertex).ToFloat2();
}
Game.Renderer.RgbaColorRenderer.DrawPolygon(points, 1, Color.OrangeRed);
}
}
@@ -306,7 +358,13 @@ namespace OpenRA.Graphics
public float3 Screen3DPosition(WPos pos)
{
var z = ZPosition(pos, 0) * (float)TileSize.Height / TileScale;
// The projection from world coordinates to screen coordinates has
// a non-obvious relationship between the y and z coordinates:
// * A flat surface with constant y (e.g. a vertical wall) in world coordinates
// transforms into a flat surface with constant z (depth) in screen coordinates.
// * Increasing the world y coordinate increases screen y and z coordinates equally.
// * Increases the world z coordinate decreases screen y but doesn't change screen z.
var z = pos.Y * (float)TileSize.Height / TileScale;
return new float3((float)TileSize.Width * pos.X / TileScale, (float)TileSize.Height * (pos.Y - pos.Z) / TileScale, z);
}
@@ -325,7 +383,7 @@ namespace OpenRA.Graphics
}
// For scaling vectors to pixel sizes in the model renderer
public float3 ScreenVectorComponents(WVec vec)
public float3 ScreenVectorComponents(in WVec vec)
{
return new float3(
(float)TileSize.Width * vec.X / TileScale,
@@ -334,29 +392,19 @@ namespace OpenRA.Graphics
}
// For scaling vectors to pixel sizes in the model renderer
public float[] ScreenVector(WVec vec)
public float[] ScreenVector(in WVec vec)
{
var xyz = ScreenVectorComponents(vec);
return new[] { xyz.X, xyz.Y, xyz.Z, 1f };
}
public int2 ScreenPxOffset(WVec vec)
public int2 ScreenPxOffset(in WVec vec)
{
// Round to nearest pixel
var xyz = ScreenVectorComponents(vec);
return new int2((int)Math.Round(xyz.X), (int)Math.Round(xyz.Y));
}
public float ScreenZPosition(WPos pos, int offset)
{
return ZPosition(pos, offset) * (float)TileSize.Height / TileScale;
}
static int ZPosition(WPos pos, int offset)
{
return pos.Y + pos.Z + offset;
}
/// <summary>
/// Returns a position in the world that is projected to the given screen position.
/// There are many possible world positions, and the returned value chooses the value with no elevation.
@@ -375,7 +423,6 @@ namespace OpenRA.Graphics
World.Dispose();
palette.Dispose();
Theater.Dispose();
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -20,6 +20,8 @@ namespace OpenRA
public readonly Hotkey Default = Hotkey.Invalid;
public readonly string Description = "";
public readonly HashSet<string> Types = new HashSet<string>();
public readonly HashSet<string> Contexts = new HashSet<string>();
public readonly bool Readonly = false;
public bool HasDuplicates { get; internal set; }
public HotkeyDefinition(string name, MiniYaml node)
@@ -36,6 +38,22 @@ namespace OpenRA
var typesNode = node.Nodes.FirstOrDefault(n => n.Key == "Types");
if (typesNode != null)
Types = FieldLoader.GetValue<HashSet<string>>("Types", typesNode.Value.Value);
var contextsNode = node.Nodes.FirstOrDefault(n => n.Key == "Contexts");
if (contextsNode != null)
Contexts = FieldLoader.GetValue<HashSet<string>>("Contexts", contextsNode.Value.Value);
var platformNode = node.Nodes.FirstOrDefault(n => n.Key == "Platform");
if (platformNode != null)
{
var platformOverride = platformNode.Value.Nodes.FirstOrDefault(n => n.Key == Platform.CurrentPlatform.ToString());
if (platformOverride != null)
Default = FieldLoader.GetValue<Hotkey>("value", platformOverride.Value.Value);
}
var readonlyNode = node.Nodes.FirstOrDefault(n => n.Key == "Readonly");
if (readonlyNode != null)
Readonly = FieldLoader.GetValue<bool>("Readonly", readonlyNode.Value.Value);
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -35,12 +35,12 @@ namespace OpenRA
foreach (var kv in settings)
{
if (definitions.ContainsKey(kv.Key))
if (definitions.ContainsKey(kv.Key) && !definitions[kv.Key].Readonly)
keys[kv.Key] = kv.Value;
}
foreach (var hd in definitions)
hd.Value.HasDuplicates = GetFirstDuplicate(hd.Value.Name, this[hd.Value.Name].GetValue(), hd.Value) != null;
hd.Value.HasDuplicates = GetFirstDuplicate(hd.Value, this[hd.Value.Name].GetValue()) != null;
}
internal Func<Hotkey> GetHotkeyReference(string name)
@@ -50,8 +50,7 @@ namespace OpenRA
return () => keys[name];
// Try and parse as a hardcoded definition
Hotkey key;
if (!Hotkey.TryParse(name, out key))
if (!Hotkey.TryParse(name, out var key))
key = Hotkey.Invalid;
return () => key;
@@ -59,8 +58,10 @@ namespace OpenRA
public void Set(string name, Hotkey value)
{
HotkeyDefinition definition;
if (!definitions.TryGetValue(name, out definition))
if (!definitions.TryGetValue(name, out var definition))
return;
if (definition.Readonly)
return;
keys[name] = value;
@@ -70,7 +71,7 @@ namespace OpenRA
settings.Remove(name);
var hadDuplicates = definition.HasDuplicates;
definition.HasDuplicates = GetFirstDuplicate(definition.Name, this[definition.Name].GetValue(), definition) != null;
definition.HasDuplicates = GetFirstDuplicate(definition, this[definition.Name].GetValue()) != null;
if (hadDuplicates || definition.HasDuplicates)
{
@@ -79,33 +80,30 @@ namespace OpenRA
if (hd.Value == definition)
continue;
hd.Value.HasDuplicates = GetFirstDuplicate(hd.Value.Name, this[hd.Value.Name].GetValue(), hd.Value) != null;
hd.Value.HasDuplicates = GetFirstDuplicate(hd.Value, this[hd.Value.Name].GetValue()) != null;
}
}
}
public HotkeyDefinition GetFirstDuplicate(string name, Hotkey value, HotkeyDefinition definition)
public HotkeyDefinition GetFirstDuplicate(HotkeyDefinition definition, Hotkey value)
{
if (definition == null)
return null;
foreach (var kv in keys)
{
if (kv.Key == name)
if (kv.Key == definition.Name)
continue;
if (kv.Value == value && definitions[kv.Key].Types.Overlaps(definition.Types))
if (kv.Value == value && definitions[kv.Key].Contexts.Overlaps(definition.Contexts))
return definitions[kv.Key];
}
return null;
}
public HotkeyReference this[string name]
{
get
{
return new HotkeyReference(GetHotkeyReference(name));
}
}
public HotkeyReference this[string name] => new HotkeyReference(GetHotkeyReference(name));
public IEnumerable<HotkeyDefinition> Definitions { get { return definitions.Values; } }
public IEnumerable<HotkeyDefinition> Definitions => definitions.Values;
}
}

View File

@@ -0,0 +1,63 @@
#region Copyright & License Information
/*
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System;
using System.IO;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace OpenRA
{
public delegate void OnProgress(long total, long totalRead, int progressPercentage);
public static class HttpExtension
{
public static async Task ReadAsStreamWithProgress(this HttpResponseMessage response, Stream outputStream, OnProgress onProgress, CancellationToken token)
{
var total = response.Content.Headers.ContentLength ?? -1;
var canReportProgress = total > 0;
#if NET5_0_OR_GREATER
using (var contentStream = await response.Content.ReadAsStreamAsync(token))
#else
using (var contentStream = await response.Content.ReadAsStreamAsync())
#endif
{
var totalRead = 0L;
var buffer = new byte[8192];
var hasMoreToRead = true;
do
{
var read = await contentStream.ReadAsync(buffer.AsMemory(0, buffer.Length), token);
if (read == 0)
hasMoreToRead = false;
else
{
await outputStream.WriteAsync(buffer.AsMemory(0, read), token);
totalRead += read;
if (canReportProgress)
{
var progressPercentage = (int)((double)totalRead / total * 100);
onProgress?.Invoke(total, totalRead, progressPercentage);
}
}
}
while (hasMoreToRead && !token.IsCancellationRequested);
onProgress?.Invoke(total, totalRead, 100);
}
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -13,7 +13,7 @@ using System;
namespace OpenRA
{
public struct Hotkey : IEquatable<Hotkey>
public readonly struct Hotkey : IEquatable<Hotkey>
{
public static Hotkey Invalid = new Hotkey(Keycode.UNKNOWN, Modifiers.None);
public bool IsValid()
@@ -32,11 +32,9 @@ namespace OpenRA
var parts = s.Split(' ');
Keycode key;
if (!Enum<Keycode>.TryParse(parts[0], true, out key))
if (!Enum<Keycode>.TryParse(parts[0], true, out var key))
{
int c;
if (!int.TryParse(parts[0], out c))
if (!int.TryParse(parts[0], out var c))
return false;
key = (Keycode)c;
}
@@ -83,11 +81,10 @@ namespace OpenRA
public override bool Equals(object obj)
{
var o = obj as Hotkey?;
return o != null && o == this;
return obj is Hotkey o && (Hotkey?)o == this;
}
public override string ToString() { return "{0} {1}".F(Key, Modifiers.ToString("F")); }
public override string ToString() { return $"{Key} {Modifiers.ToString("F")}"; }
public string DisplayString()
{

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -37,36 +37,24 @@ namespace OpenRA
public void OnKeyInput(KeyInput input)
{
Sync.RunUnsynced(Game.Settings.Debug.SyncCheckUnsyncedCode, world, () => Ui.HandleKeyPress(input));
Sync.RunUnsynced(world, () => Ui.HandleKeyPress(input));
}
public void OnTextInput(string text)
{
Sync.RunUnsynced(Game.Settings.Debug.SyncCheckUnsyncedCode, world, () => Ui.HandleTextInput(text));
Sync.RunUnsynced(world, () => Ui.HandleTextInput(text));
}
public void OnMouseInput(MouseInput input)
{
Sync.RunUnsynced(Game.Settings.Debug.SyncCheckUnsyncedCode, world, () => Ui.HandleInput(input));
Sync.RunUnsynced(world, () => Ui.HandleInput(input));
}
}
public class MouseButtonPreference
{
public MouseButton Action
{
get
{
return Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Left : MouseButton.Right;
}
}
public MouseButton Action => Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Left : MouseButton.Right;
public MouseButton Cancel
{
get
{
return Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Right : MouseButton.Left;
}
}
public MouseButton Cancel => Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Right : MouseButton.Left;
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -498,8 +498,7 @@ namespace OpenRA
public static string DisplayString(Keycode k)
{
string ret;
if (!KeyNames.TryGetValue(k, out ret))
if (!KeyNames.TryGetValue(k, out var ret))
return k.ToString();
return ret;

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -14,30 +14,25 @@ using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.FileSystem;
using OpenRA.Graphics;
using OpenRA.Primitives;
namespace OpenRA
{
public class InstalledMods : IReadOnlyDictionary<string, Manifest>
{
readonly Dictionary<string, Manifest> mods;
readonly SheetBuilder sheetBuilder;
/// <summary>Initializes the collection of locally installed mods.</summary>
/// <param name="searchPaths">Filesystem paths to search for mod packages.</param>
/// <param name="explicitPaths">Filesystem paths to additional mod packages.</param>
public InstalledMods(IEnumerable<string> searchPaths, IEnumerable<string> explicitPaths)
{
sheetBuilder = new SheetBuilder(SheetType.BGRA, 256);
mods = GetInstalledMods(searchPaths, explicitPaths);
}
static IEnumerable<Pair<string, string>> GetCandidateMods(IEnumerable<string> searchPaths)
static IEnumerable<(string Id, string Path)> GetCandidateMods(IEnumerable<string> searchPaths)
{
var mods = new List<Pair<string, string>>();
var mods = new List<(string, string)>();
foreach (var path in searchPaths)
{
try
@@ -48,7 +43,7 @@ namespace OpenRA
var directory = new DirectoryInfo(resolved);
foreach (var subdir in directory.EnumerateDirectories())
mods.Add(Pair.New(subdir.Name, subdir.FullName));
mods.Add((subdir.Name, subdir.FullName));
}
catch (Exception e)
{
@@ -76,11 +71,10 @@ namespace OpenRA
}
catch (Exception e)
{
Log.Write("debug", "Load mod '{0}': {1}".F(path, e));
Log.Write("debug", $"Load mod '{path}': {e}");
}
if (package != null)
package.Dispose();
package?.Dispose();
return null;
}
@@ -89,22 +83,22 @@ namespace OpenRA
{
var ret = new Dictionary<string, Manifest>();
var candidates = GetCandidateMods(searchPaths)
.Concat(explicitPaths.Select(p => Pair.New(Path.GetFileNameWithoutExtension(p), p)));
.Concat(explicitPaths.Select(p => (Id: Path.GetFileNameWithoutExtension(p), Path: p)));
foreach (var pair in candidates)
{
var mod = LoadMod(pair.First, pair.Second);
var mod = LoadMod(pair.Id, pair.Path);
if (mod != null)
ret[pair.First] = mod;
ret[pair.Id] = mod;
}
return ret;
}
public Manifest this[string key] { get { return mods[key]; } }
public int Count { get { return mods.Count; } }
public ICollection<string> Keys { get { return mods.Keys; } }
public ICollection<Manifest> Values { get { return mods.Values; } }
public Manifest this[string key] => mods[key];
public IEnumerable<string> Keys => mods.Keys;
public IEnumerable<Manifest> Values => mods.Values;
public int Count => mods.Count;
public bool ContainsKey(string key) { return mods.ContainsKey(key); }
public IEnumerator<KeyValuePair<string, Manifest>> GetEnumerator() { return mods.GetEnumerator(); }
public bool TryGetValue(string key, out Manifest value) { return mods.TryGetValue(key, out value); }

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -12,10 +12,10 @@
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using OpenRA.Support;
namespace OpenRA
{
@@ -24,11 +24,11 @@ namespace OpenRA
const int AuthKeySize = 2048;
public enum LinkState { Uninitialized, GeneratingKeys, Unlinked, CheckingLink, ConnectionFailed, Linked }
public LinkState State { get { return innerState; } }
public string Fingerprint { get { return innerFingerprint; } }
public string PublicKey { get { return innerPublicKey; } }
public LinkState State => innerState;
public string Fingerprint => innerFingerprint;
public string PublicKey => innerPublicKey;
public PlayerProfile ProfileData { get { return innerData; } }
public PlayerProfile ProfileData => innerData;
volatile LinkState innerState;
volatile PlayerProfile innerData;
@@ -76,19 +76,16 @@ namespace OpenRA
if (State != LinkState.Unlinked && State != LinkState.Linked && State != LinkState.ConnectionFailed)
return;
Action<DownloadDataCompletedEventArgs> onQueryComplete = i =>
Task.Run(async () =>
{
try
{
innerState = LinkState.Unlinked;
var client = HttpClientFactory.Create();
if (i.Error != null)
{
innerState = LinkState.ConnectionFailed;
return;
}
var httpResponseMessage = await client.GetAsync(playerDatabase.Profile + Fingerprint);
var result = await httpResponseMessage.Content.ReadAsStreamAsync();
var yaml = MiniYaml.FromString(Encoding.UTF8.GetString(i.Result)).First();
var yaml = MiniYaml.FromStream(result).First();
if (yaml.Key == "Player")
{
innerData = FieldLoader.Load<PlayerProfile>(yaml.Value);
@@ -100,6 +97,8 @@ namespace OpenRA
else
innerState = LinkState.Linked;
}
else
innerState = LinkState.Unlinked;
}
catch (Exception e)
{
@@ -108,13 +107,11 @@ namespace OpenRA
}
finally
{
if (onComplete != null)
onComplete();
onComplete?.Invoke();
}
};
});
innerState = LinkState.CheckingLink;
new Download(playerDatabase.Profile + Fingerprint, _ => { }, onQueryComplete);
}
public void GenerateKeypair()
@@ -160,7 +157,7 @@ namespace OpenRA
}
innerState = LinkState.Uninitialized;
parameters = default(RSAParameters);
parameters = default;
innerFingerprint = null;
innerData = null;
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -14,7 +14,7 @@ using OpenRA.Primitives;
namespace OpenRA
{
public struct MPos : IEquatable<MPos>
public readonly struct MPos : IEquatable<MPos>
{
public readonly int U, V;
@@ -66,7 +66,7 @@ namespace OpenRA
/// <summary>
/// Projected map position
/// </summary>
public struct PPos : IEquatable<PPos>
public readonly struct PPos : IEquatable<PPos>
{
public readonly int U, V;

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -11,6 +11,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using OpenRA.FileSystem;
@@ -20,6 +21,17 @@ namespace OpenRA
{
public interface IGlobalModData { }
public sealed class TerrainFormat : IGlobalModData
{
public readonly string Type;
public readonly IReadOnlyDictionary<string, MiniYaml> Metadata;
public TerrainFormat(MiniYaml yaml)
{
Type = yaml.Value;
Metadata = new ReadOnlyDictionary<string, MiniYaml>(yaml.ToDictionary());
}
}
public sealed class SpriteSequenceFormat : IGlobalModData
{
public readonly string Type;
@@ -48,11 +60,12 @@ namespace OpenRA
public string Version;
public string Website;
public string WebIcon32;
public string WindowTitle;
public bool Hidden;
}
/// <summary> Describes what is to be loaded in order to run a mod. </summary>
public class Manifest
public class Manifest : IDisposable
{
public readonly string Id;
public readonly IReadOnlyPackage Package;
@@ -66,17 +79,19 @@ namespace OpenRA
public readonly IReadOnlyDictionary<string, string> Packages;
public readonly IReadOnlyDictionary<string, string> MapFolders;
public readonly MiniYaml LoadScreen;
public readonly string DefaultOrderGenerator;
public readonly string[] SoundFormats = { };
public readonly string[] SpriteFormats = { };
public readonly string[] PackageFormats = { };
public readonly string[] SoundFormats = Array.Empty<string>();
public readonly string[] SpriteFormats = Array.Empty<string>();
public readonly string[] PackageFormats = Array.Empty<string>();
public readonly string[] VideoFormats = Array.Empty<string>();
readonly string[] reservedModuleNames =
{
"Metadata", "Folders", "MapFolders", "Packages", "Rules",
"Include", "Metadata", "Folders", "MapFolders", "Packages", "Rules",
"Sequences", "ModelSequences", "Cursors", "Chrome", "Assemblies", "ChromeLayout", "Weapons",
"Voices", "Notifications", "Music", "Translations", "TileSets", "ChromeMetrics", "Missions", "Hotkeys",
"ServerTraits", "LoadScreen", "SupportsMapsFrom", "SoundFormats", "SpriteFormats",
"ServerTraits", "LoadScreen", "DefaultOrderGenerator", "SupportsMapsFrom", "SoundFormats", "SpriteFormats", "VideoFormats",
"RequiresMods", "PackageFormats"
};
@@ -89,16 +104,33 @@ namespace OpenRA
{
Id = modId;
Package = package;
yaml = new MiniYaml(null, MiniYaml.FromStream(package.GetStream("mod.yaml"), "mod.yaml")).ToDictionary();
var nodes = MiniYaml.FromStream(package.GetStream("mod.yaml"), "mod.yaml");
for (var i = nodes.Count - 1; i >= 0; i--)
{
if (nodes[i].Key != "Include")
continue;
// Replace `Includes: filename.yaml` with the contents of filename.yaml
var filename = nodes[i].Value.Value;
var contents = package.GetStream(filename);
if (contents == null)
throw new YamlException($"{nodes[i].Location}: File `{filename}` not found.");
nodes.RemoveAt(i);
nodes.InsertRange(i, MiniYaml.FromStream(contents, filename));
}
// Merge inherited overrides
yaml = new MiniYaml(null, MiniYaml.Merge(new[] { nodes })).ToDictionary();
Metadata = FieldLoader.Load<ModMetadata>(yaml["Metadata"]);
// TODO: Use fieldloader
MapFolders = YamlDictionary(yaml, "MapFolders");
MiniYaml packages;
if (yaml.TryGetValue("Packages", out packages))
Packages = packages.ToDictionary(x => x.Value).AsReadOnly();
if (yaml.TryGetValue("Packages", out var packages))
Packages = packages.ToDictionary(x => x.Value);
Rules = YamlList(yaml, "Rules");
Sequences = YamlList(yaml, "Sequences");
@@ -130,6 +162,9 @@ namespace OpenRA
MapCompatibility = compat.ToArray();
if (yaml.ContainsKey("DefaultOrderGenerator"))
DefaultOrderGenerator = yaml["DefaultOrderGenerator"].Value;
if (yaml.ContainsKey("PackageFormats"))
PackageFormats = FieldLoader.GetValue<string[]>("PackageFormats", yaml["PackageFormats"].Value);
@@ -138,6 +173,9 @@ namespace OpenRA
if (yaml.ContainsKey("SpriteFormats"))
SpriteFormats = FieldLoader.GetValue<string[]>("SpriteFormats", yaml["SpriteFormats"].Value);
if (yaml.ContainsKey("VideoFormats"))
VideoFormats = FieldLoader.GetValue<string[]>("VideoFormats", yaml["VideoFormats"].Value);
}
public void LoadCustomData(ObjectCreator oc)
@@ -149,7 +187,7 @@ namespace OpenRA
var t = oc.FindType(kv.Key);
if (t == null || !typeof(IGlobalModData).IsAssignableFrom(t))
throw new InvalidDataException("`{0}` is not a valid mod manifest entry.".F(kv.Key));
throw new InvalidDataException($"`{kv.Key}` is not a valid mod manifest entry.");
IGlobalModData module;
var ctor = t.GetConstructor(new[] { typeof(MiniYaml) });
@@ -171,10 +209,10 @@ namespace OpenRA
customDataLoaded = true;
}
static string[] YamlList(Dictionary<string, MiniYaml> yaml, string key, bool parsePaths = false)
static string[] YamlList(Dictionary<string, MiniYaml> yaml, string key)
{
if (!yaml.ContainsKey(key))
return new string[] { };
return Array.Empty<string>();
return yaml[key].ToDictionary().Keys.ToArray();
}
@@ -182,10 +220,9 @@ namespace OpenRA
static IReadOnlyDictionary<string, string> YamlDictionary(Dictionary<string, MiniYaml> yaml, string key)
{
if (!yaml.ContainsKey(key))
return new ReadOnlyDictionary<string, string>();
return new Dictionary<string, string>();
var inner = yaml[key].ToDictionary(my => my.Value);
return new ReadOnlyDictionary<string, string>(inner);
return yaml[key].ToDictionary(my => my.Value);
}
public bool Contains<T>() where T : IGlobalModData
@@ -217,9 +254,8 @@ namespace OpenRA
/// </summary>
public T Get<T>(ObjectCreator oc) where T : IGlobalModData
{
MiniYaml data;
var t = typeof(T);
if (!yaml.TryGetValue(t.Name, out data))
if (!yaml.TryGetValue(t.Name, out var data))
{
// Lazily create the default values if not explicitly defined.
return (T)oc.CreateBasic(t);
@@ -241,5 +277,14 @@ namespace OpenRA
return (T)module;
}
public void Dispose()
{
foreach (var module in modules)
{
var disposableModule = module as IDisposable;
disposableModule?.Dispose();
}
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
@@ -9,23 +9,35 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA
{
public interface IActorInitializer
{
World World { get; }
T Get<T>() where T : IActorInit;
U Get<T, U>() where T : IActorInit<U>;
bool Contains<T>() where T : IActorInit;
T GetOrDefault<T>(TraitInfo info) where T : ActorInit;
T Get<T>(TraitInfo info) where T : ActorInit;
U GetValue<T, U>(TraitInfo info) where T : ValueActorInit<U>;
U GetValue<T, U>(TraitInfo info, U fallback) where T : ValueActorInit<U>;
bool Contains<T>(TraitInfo info) where T : ActorInit;
T GetOrDefault<T>() where T : ActorInit, ISingleInstanceInit;
T Get<T>() where T : ActorInit, ISingleInstanceInit;
U GetValue<T, U>() where T : ValueActorInit<U>, ISingleInstanceInit;
U GetValue<T, U>(U fallback) where T : ValueActorInit<U>, ISingleInstanceInit;
bool Contains<T>() where T : ActorInit, ISingleInstanceInit;
}
public class ActorInitializer : IActorInitializer
{
public readonly Actor Self;
public World World { get { return Self.World; } }
public World World => Self.World;
internal TypeDictionary Dict;
@@ -35,50 +47,228 @@ namespace OpenRA
Dict = dict;
}
public T Get<T>() where T : IActorInit { return Dict.Get<T>(); }
public U Get<T, U>() where T : IActorInit<U> { return Dict.Get<T>().Value(World); }
public bool Contains<T>() where T : IActorInit { return Dict.Contains<T>(); }
}
public interface IActorInit { }
public interface IActorInit<T> : IActorInit
{
T Value(World world);
}
public class LocationInit : IActorInit<CPos>
{
[FieldFromYamlKey]
readonly CPos value = CPos.Zero;
public LocationInit() { }
public LocationInit(CPos init) { value = init; }
public CPos Value(World world) { return value; }
}
public class OwnerInit : IActorInit<Player>
{
[FieldFromYamlKey]
public readonly string PlayerName = "Neutral";
Player player;
public OwnerInit() { }
public OwnerInit(string playerName) { PlayerName = playerName; }
public OwnerInit(Player player)
public T GetOrDefault<T>(TraitInfo info) where T : ActorInit
{
this.player = player;
PlayerName = player.InternalName;
var inits = Dict.WithInterface<T>();
// Traits tagged with an instance name prefer inits with the same name.
// If a more specific init is not available, fall back to an unnamed init.
// If duplicate inits are defined, take the last to match standard yaml override expectations
if (info != null && !string.IsNullOrEmpty(info.InstanceName))
return inits.LastOrDefault(i => i.InstanceName == info.InstanceName) ??
inits.LastOrDefault(i => string.IsNullOrEmpty(i.InstanceName));
// Untagged traits will only use untagged inits
return inits.LastOrDefault(i => string.IsNullOrEmpty(i.InstanceName));
}
public T Get<T>(TraitInfo info) where T : ActorInit
{
var init = GetOrDefault<T>(info);
if (init == null)
throw new InvalidOperationException($"TypeDictionary does not contain instance of type `{typeof(T)}`");
return init;
}
public U GetValue<T, U>(TraitInfo info) where T : ValueActorInit<U>
{
return Get<T>(info).Value;
}
public U GetValue<T, U>(TraitInfo info, U fallback) where T : ValueActorInit<U>
{
var init = GetOrDefault<T>(info);
return init != null ? init.Value : fallback;
}
public bool Contains<T>(TraitInfo info) where T : ActorInit { return GetOrDefault<T>(info) != null; }
public T GetOrDefault<T>() where T : ActorInit, ISingleInstanceInit
{
return Dict.GetOrDefault<T>();
}
public T Get<T>() where T : ActorInit, ISingleInstanceInit
{
return Dict.Get<T>();
}
public U GetValue<T, U>() where T : ValueActorInit<U>, ISingleInstanceInit
{
return Get<T>().Value;
}
public U GetValue<T, U>(U fallback) where T : ValueActorInit<U>, ISingleInstanceInit
{
var init = GetOrDefault<T>();
return init != null ? init.Value : fallback;
}
public bool Contains<T>() where T : ActorInit, ISingleInstanceInit { return GetOrDefault<T>() != null; }
}
/*
* Things to be aware of when writing ActorInits:
*
* - ActorReference and ActorGlobal can dynamically create objects without calling a constructor.
* The object will be allocated directly then the best matching Initialize() method will be called to set valid state.
* - ActorReference will always attempt to call Initialize(MiniYaml). ActorGlobal will use whichever one it first
* finds with an argument type that matches the given LuaValue.
* - Most ActorInits will want to inherit either ValueActorInit<T> or CompositeActorInit which hide the low-level plumbing.
* - Inits that reference actors should use ActorInitActorReference which allows actors to be referenced by name in map.yaml
* - Inits that should only have a single instance defined on an actor should implement ISingleInstanceInit to allow
* direct queries and runtime enforcement.
* - Inits that aren't ISingleInstanceInit should expose a ctor that accepts a TraitInfo to allow per-trait targeting.
*/
public abstract class ActorInit
{
[FieldLoader.Ignore]
public readonly string InstanceName;
protected ActorInit(string instanceName)
{
InstanceName = instanceName;
}
protected ActorInit() { }
public abstract MiniYaml Save();
}
public interface ISingleInstanceInit { }
public abstract class ValueActorInit<T> : ActorInit
{
readonly T value;
protected ValueActorInit(TraitInfo info, T value)
: base(info.InstanceName) { this.value = value; }
protected ValueActorInit(string instanceName, T value)
: base(instanceName) { this.value = value; }
protected ValueActorInit(T value) { this.value = value; }
public virtual T Value => value;
public virtual void Initialize(MiniYaml yaml)
{
Initialize((T)FieldLoader.GetValue(nameof(value), typeof(T), yaml.Value));
}
public virtual void Initialize(T value)
{
var field = typeof(ValueActorInit<T>).GetField(nameof(value), BindingFlags.NonPublic | BindingFlags.Instance);
if (field != null)
field.SetValue(this, value);
}
public override MiniYaml Save()
{
return new MiniYaml(FieldSaver.FormatValue(value));
}
}
public abstract class CompositeActorInit : ActorInit
{
protected CompositeActorInit(TraitInfo info)
: base(info.InstanceName) { }
protected CompositeActorInit()
: base() { }
public virtual void Initialize(MiniYaml yaml)
{
FieldLoader.Load(this, yaml);
}
public virtual void Initialize(Dictionary<string, object> values)
{
foreach (var field in GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
{
var sa = field.GetCustomAttributes<FieldLoader.SerializeAttribute>(false).DefaultIfEmpty(FieldLoader.SerializeAttribute.Default).First();
if (!sa.Serialize)
continue;
if (values.TryGetValue(field.Name, out var value))
field.SetValue(this, value);
}
}
public virtual Dictionary<string, Type> InitializeArgs()
{
var dict = new Dictionary<string, Type>();
foreach (var field in GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
{
var sa = field.GetCustomAttributes<FieldLoader.SerializeAttribute>(false).DefaultIfEmpty(FieldLoader.SerializeAttribute.Default).First();
if (!sa.Serialize)
continue;
dict[field.Name] = field.FieldType;
}
return dict;
}
public override MiniYaml Save()
{
return FieldSaver.Save(this);
}
}
public class LocationInit : ValueActorInit<CPos>, ISingleInstanceInit
{
public LocationInit(CPos value)
: base(value) { }
}
public class OwnerInit : ActorInit, ISingleInstanceInit
{
public readonly string InternalName;
readonly Player value;
public OwnerInit(Player value)
{
this.value = value;
InternalName = value.InternalName;
}
public OwnerInit(string value)
{
InternalName = value;
}
public Player Value(World world)
{
if (player != null)
return player;
return value ?? world.Players.First(x => x.InternalName == InternalName);
}
return world.Players.First(x => x.InternalName == PlayerName);
public void Initialize(MiniYaml yaml)
{
var field = typeof(OwnerInit).GetField(nameof(InternalName), BindingFlags.Public | BindingFlags.Instance);
if (field != null)
field.SetValue(this, yaml.Value);
}
public void Initialize(Player player)
{
var field = typeof(OwnerInit).GetField(nameof(value), BindingFlags.NonPublic | BindingFlags.Instance);
if (field != null)
field.SetValue(this, player);
}
public override MiniYaml Save()
{
return new MiniYaml(InternalName);
}
}
public abstract class RuntimeFlagInit : ActorInit, ISuppressInitExport
{
public override MiniYaml Save()
{
throw new NotImplementedException("RuntimeFlagInit cannot be saved");
}
}
}

Some files were not shown because too many files have changed in this diff Show More