Compare commits

...

943 Commits

Author SHA1 Message Date
DrSmugleaf
42b414d3b7 Change state manager methods to return the new state 2022-08-15 00:51:41 +02:00
ElectroJr
25212cbb4d Version: 0.40.3.0 2022-08-14 17:20:31 -04:00
Leon Friedrich
c56cc24804 Update RGA validator (#3134) 2022-08-15 07:17:36 +10:00
Paul
cf9250f25d Version: 0.40.2.0 2022-08-14 11:19:59 +02:00
Paul
a105e02131 fixes mapfile schema 2022-08-14 11:18:43 +02:00
Paul
cebdca87df Version: 0.40.1.0 2022-08-14 01:35:56 +02:00
Paul Ritter
bbabee3949 fixes struct instantiation (#3129) 2022-08-14 01:34:51 +02:00
Paul
f16d41704b Version: 0.40.0.0 2022-08-13 23:13:17 +02:00
Paul Ritter
6f557ac821 cleans up copy and removes ipopulatedefaultvalues (#3085)
Co-authored-by: Paul <ritter.paul1@gmail.com>
2022-08-13 23:12:04 +02:00
wrexbe
ba70a7c95e Fix ResourcePath serialize copy (#3127) 2022-08-13 22:19:56 +02:00
Leon Friedrich
f3796ee69d Fix nested container insert bug (#3062) 2022-08-13 10:30:07 +10:00
metalgearsloth
b2a71e5ef8 Version: 0.39.1.0 2022-08-11 09:47:26 +10:00
metalgearsloth
c253130c4a Add private ctor for ResourcePath (#3118) 2022-08-11 09:46:21 +10:00
Paul Ritter
f03826b5ec defines yaml schemas for robust generic attribution files and mapfiles (#3089)
Co-authored-by: ike709 <ike709@users.noreply.github.com>
Co-authored-by: Paul <ritter.paul1@gmail.com>
2022-08-10 12:48:24 +02:00
metalgearsloth
69cf93a425 Version: 0.39.0.0 2022-08-10 17:04:56 +10:00
metalgearsloth
a4ea7fed6a Make tiledefinitions use spritespecifier (#3113) 2022-08-10 17:04:12 +10:00
metalgearsloth
7046152ec8 Version: 0.38.1.0 2022-08-10 13:06:28 +10:00
Leon Friedrich
f6f1f76980 Fix nullable yaml validation (#3106) 2022-08-10 01:00:47 +02:00
Rinkashikachi
a98a214fa3 Fix issue with Fluents ??? for empty suffix. (#3114) 2022-08-10 01:00:21 +02:00
metalgearsloth
faadb70de7 Overlay shader cleanup (#3112) 2022-08-10 00:52:32 +02:00
Pieter-Jan Briers
7a6d6c83b1 CVar.CONFIDENTIAL flag.
Hides CVar values from completion results.
2022-08-10 00:40:30 +02:00
Julian Giebel
9e32eb46e5 Update ImageSharp and fix incompatibilities (#3092) 2022-08-09 13:15:55 +02:00
Leon Friedrich
bea91d119e Fix CustomHashSetSerializer bug (#3087)
* Fix CustomHashSetSerializer bug

* Create a copy of source if target is null

* null !
2022-08-08 18:05:23 +02:00
metalgearsloth
9ec725d848 Version: 0.38.0.0 2022-08-08 11:43:52 +10:00
Leon Friedrich
790d523ebd Remove string keys from appearance component (#3086) 2022-08-08 11:43:17 +10:00
metalgearsloth
147ca286ea Version: 0.37.0.0 2022-08-07 13:56:27 +10:00
Leon Friedrich
bc25f5d727 Allow entities to be spawned directly in null-space (#3107) 2022-08-07 13:54:06 +10:00
Pieter-Jan Briers
c65740eba6 Version: 0.36.0.0 2022-08-07 00:31:55 +02:00
Pieter-Jan Briers
59e6a797f1 Revert "Move BUI logic to the UI system (#3102)"
This reverts commit 53c496fe27.
2022-08-07 00:25:20 +02:00
Pieter-Jan Briers
663d901e6b Version: 0.35.0.0 2022-08-07 00:18:03 +02:00
Pieter-Jan Briers
585126bf52 Fix race conditions with handshake messages.
MsgMapStrServerHandshake was being sent as unordered, meaning that it  could actually arrive on the client before the handshake-finished messages. Whoops.
2022-08-07 00:14:55 +02:00
metalgearsloth
e27ed228ad Revert "More BUI changes (#3104)" (#3109) 2022-08-06 16:58:45 +10:00
metalgearsloth
ef35187624 Version: 0.34.0.0 2022-08-06 14:58:38 +10:00
metalgearsloth
1cf31fbea6 Non-generic GetEntityQuery (#3103) 2022-08-06 14:52:32 +10:00
Leon Friedrich
c7a3c43a4f More BUI changes (#3104) 2022-08-06 14:51:23 +10:00
ElectroJr
01b55494e8 Version: 0.33.0.1 2022-08-04 18:31:43 -04:00
ElectroJr
be9ab89b29 Fix serializer copy-ref error 2022-08-04 18:30:44 -04:00
ElectroJr
d4c8631587 Version: 0.33.0.0 2022-08-04 18:18:50 -04:00
Paul Ritter
3d43fc510e refactors copy api to use ref (#3093) 2022-08-05 08:17:02 +10:00
wrexbe
931c38a97d Allow ignore missing to specify postfix (#3035) 2022-08-05 07:37:14 +10:00
Leon Friedrich
53c496fe27 Move BUI logic to the UI system (#3102) 2022-08-05 07:18:22 +10:00
metalgearsloth
c696ac1c73 Version: 0.32.1.0 2022-08-04 12:48:27 +10:00
Leon Friedrich
57e5ceef1a BUI range check changes (#3099) 2022-08-04 09:00:38 +10:00
Leon Friedrich
b5279f3f89 Fix awake-physics map change bug (#3088) 2022-08-04 08:58:50 +10:00
metalgearsloth
fc424309c1 Don't IoC resolve in appearancevisualizerserializer (#3100) 2022-08-03 09:24:37 +02:00
Leon Friedrich
19aac6c461 Wake physics on container removal (#3098) 2022-08-02 01:34:13 +10:00
Paul
2decf31a78 Version: 0.32.0.0 2022-08-01 14:29:28 +02:00
Paul
f33ba17148 Version: 0.34.0.0 2022-08-01 14:24:45 +02:00
Paul Ritter
752d4dfe8b prototype composition (#3070)
* prototype composition

* oops

* better

* fixes build

* should fix

* misc fixes & circle test

* moar circle checks

* adds tests

Co-authored-by: Paul <ritter.paul1@gmail.com>
2022-08-01 14:22:46 +02:00
Júlio César Ueti
92d40cded3 Adds a check to HandleContainerRemoved to handle different canCollide states. (#3072)
* Checks the canCollide of the entity and passes it to SetCanCollide, defaults to true

* Remove added new line

* Requested changes
2022-08-01 01:45:02 +10:00
Leon Friedrich
11f8bf794a More joint fixes (#3091)
* More joint fixes

* Punctuation
2022-08-01 00:09:31 +10:00
Vera Aguilera Puerto
0604464dcc Bandaid MIDI crash involving malicious/malformed MIDI events.
Temporary fix until I have enough time to fix this proper.
2022-07-31 01:13:36 +02:00
ElectroJr
9f25c14707 Version: 0.31.1.0 2022-07-29 12:19:01 -04:00
Leon Friedrich
2c50e4f219 Pitch scale variation fix (#3090) 2022-07-30 02:16:39 +10:00
metalgearsloth
e97d8b9b14 Use scale with placementmanager (#3058)
Bandaid until it gets refactored.
2022-07-29 13:30:41 +10:00
metalgearsloth
f129bd45c5 Fix linear velocity cap rounding (#3051)
Here we use it as a hard cap.
2022-07-29 13:30:05 +10:00
Jacob Tong
f812b307b5 Toggle button updates (#3018)
* Change toggle button to only trigger on UIClick

* Add tests for toggle buttons
2022-07-29 13:28:59 +10:00
ElectroJr
436cb98d53 Version: 0.31.0.0 2022-07-28 22:16:31 -04:00
Leon Friedrich
1c1ced0f8a Joint changes (#3068) 2022-07-29 12:14:21 +10:00
Leon Friedrich
97015569f6 AudioSystem Rejig (#3038) 2022-07-29 12:14:05 +10:00
Leon Friedrich
ee2d266d6b Validate sprite specifier states (#3075) 2022-07-28 09:17:40 +10:00
Leon Friedrich
786ecdb8b1 More window open overrides (#3073) 2022-07-26 06:56:28 -07:00
Pieter-Jan Briers
488260cc64 Windows 11 immersive dark mode.
Dark window titles
2022-07-25 23:53:06 +02:00
metalgearsloth
6ee96873a4 Version: 0.30.0.1 2022-07-25 20:15:16 +10:00
metalgearsloth
2220f3e346 Fix broadphase desync (#3078) 2022-07-25 20:09:07 +10:00
metalgearsloth
137723357c Version: 0.30.0.0 2022-07-25 15:30:50 +10:00
metalgearsloth
db3f3e5b32 Allow maps to be saved (#3055)
* Allow maps to be saved

* I hate myself

* fix?

* Fix maybe?
2022-07-25 15:30:20 +10:00
Leon Friedrich
fc10adfb03 Fix a WorldSpaceEntities overlay bug (#3074) 2022-07-24 19:10:07 -07:00
Pieter-Jan Briers
812809bbfd Fix ILocValue.Format getting invalid LocContext 2022-07-24 02:28:58 +02:00
Pieter-Jan Briers
ec70abe928 Analyzer to make Task`1.Result scary. (#3069) 2022-07-23 12:33:55 +02:00
Vera Aguilera Puerto
0ec6995542 MIDI refactor part 1: MidiRendererState (#3015) 2022-07-23 11:56:33 +02:00
Pieter-Jan Briers
1c28782d5d Fix some grid-related warnings 2022-07-21 17:35:09 +02:00
Leon Friedrich
45472fa342 Make unknown component errors more helpful (#3063) 2022-07-21 16:54:04 +02:00
20kdc
18a5335373 Provide a generic way to expose tags on the status endpoint (#2769)
* Provide a generic way to expose tags on the status endpoint for Launcher to presumably later consume.

* Switch to a JSON array for server tags
2022-07-21 16:28:56 +02:00
metalgearsloth
86590ceb1f Fix audio merge artifacts (#3061) 2022-07-20 09:58:25 +10:00
metalgearsloth
e518abd2be Version: 0.29.1.0 2022-07-19 21:31:12 +10:00
metalgearsloth
13ae59dbf6 Revert "Don't defer moveevents anymore (#3048)" (#3060) 2022-07-19 21:30:41 +10:00
20kdc
0ded41ebe1 Audio occlusion parallelization (#2776)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2022-07-19 19:40:59 +10:00
metalgearsloth
3eb295e3ef Version: 0.29.0.0 2022-07-19 18:37:35 +10:00
Leon Friedrich
1782792d30 Fix cross-grid/map container inserts (#3054) 2022-07-19 18:37:05 +10:00
metalgearsloth
d5c0776278 Don't defer moveevents anymore (#3048) 2022-07-19 18:36:45 +10:00
Pieter-Jan Briers
0822b41155 NetManager cleanup. (#3056)
Just removed a bunch of dead code related to message dispatch and instantiation.
2022-07-19 17:44:43 +10:00
Leon Friedrich
7a81c7f64a Misc Shader changes (#2974) 2022-07-19 00:32:58 +02:00
Leon Friedrich
a925b7f84d Add lookup range assert (#3049)
Co-authored-by: Kara <lunarautomaton6@gmail.com>
2022-07-17 06:25:08 +10:00
Leon Friedrich
557de01532 Dirty PVS chunk when visibility mask changes (#3045)
* Dirty PVS chunk when visibility mask changes

* fix tests?

* aaaaaa

* maybe sorta finally fix tests

* directly return vis mask,

Also defaults to 1 only if visibility component does not exist.

* make sure everything has first bit set
2022-07-17 06:23:35 +10:00
Leon Friedrich
a38cbc7188 Make recursive delete detach parents before children (#3008) 2022-07-17 06:05:10 +10:00
metalgearsloth
5146b1b3c6 Version: 0.28.6.0 2022-07-16 13:50:50 +10:00
metalgearsloth
0e97e3000f Add robust method for no lerp (#3040)
* Add robust method for no lerp

Also updated rotation lerping.

* a

* a

* Fix sleeping while I'm here + context

* I hate contexts I hate contexts
2022-07-16 13:50:18 +10:00
metalgearsloth
0c4a05dcbf Version: 0.28.5.1 2022-07-15 14:27:26 +10:00
Leon Friedrich
565fa9f046 Preserve crossgrid joints (#3050) 2022-07-15 11:40:18 +10:00
Pieter-Jan Briers
2783e89d1f SDL2 windowing backend (#2979)
* SDL2 windowing prototype.

* More stuff idk
2022-07-15 00:07:30 +10:00
metalgearsloth
d9d08dcbe3 Version: 0.28.5.0 2022-07-14 20:25:30 +10:00
metalgearsloth
6abeedae97 Clear crossmap joints properly (#3046) 2022-07-14 20:24:17 +10:00
metalgearsloth
7bc1eaabfd findgridsintersecting + metadata performance (#3047) 2022-07-14 20:23:49 +10:00
Paul Ritter
526997639b validates generic args of typeserializers (#3044)
* validates generic args

* whodunnit grrr im angry

Co-authored-by: Paul <ritter.paul1@gmail.com>
2022-07-14 10:35:38 +02:00
Leon Friedrich
9dc030c764 Better rich text error logging (#3036) 2022-07-13 01:57:21 +10:00
Pieter-Jan Briers
35308975db Client con host improvements:
* Don't disable access check outside FULL_RELEASE.
  * Content allows all commands on +HOST now
* Client-side completions are filtered for perms and sorted.
2022-07-11 23:23:12 +02:00
Pieter-Jan Briers
7649c120e9 Do not show forbidden commands in completion results. 2022-07-11 23:23:12 +02:00
Kara
610f6d88af Version: 0.28.4.0 2022-07-09 02:54:46 -07:00
metalgearsloth
0fb5b59eba Make command line config file not exception if not found (#3030) 2022-07-09 02:52:06 -07:00
Pieter-Jan Briers
77b1fd933c Fix MapLoaderTest having a nullable error in Rider. 2022-07-08 22:38:30 +02:00
Leon Friedrich
4ec019078d Add enum and custom hash set serializers (#2973) 2022-07-08 07:25:23 +10:00
metalgearsloth
fe022d4100 Version: 0.28.3.0 2022-07-06 18:52:02 +10:00
Paul Ritter
1d4eec4855 make serv3 null reading sane and yaml-complaint (#3027) 2022-07-06 14:17:10 +10:00
metalgearsloth
84fceb587b Make loadbp take degrees (#3024) 2022-07-06 14:16:57 +10:00
Paul Ritter
a4ad98519e serv3 now writes proper null values (oops) (#3026) 2022-07-06 00:23:13 +10:00
metalgearsloth
8f55a21cc4 Fix lsgrid (#3025)
* Fix lsgrid

Often worldpos wouldn't show due to formatting.

* Also MapId
2022-07-05 23:39:23 +10:00
metalgearsloth
4e40184c4a Version: 0.28.2.1 2022-07-03 14:52:03 +10:00
metalgearsloth
8bea8237f8 Fix physicsmap recursive changes (#3014)
* Fix physicsmap recursive changes

* Fix recursion
2022-07-03 14:49:32 +10:00
Leon Friedrich
00c4d68db8 Fix server shutdown error (#3011) 2022-07-02 14:21:16 +10:00
metalgearsloth
93e26fd88a Add test for recursive broadphase updates (#3010) 2022-07-02 14:10:57 +10:00
Pieter-Jan Briers
312b879b06 Fix connection timeout always being 30000f (#3013) 2022-07-01 19:43:53 -07:00
metalgearsloth
852d1874db Add test that detachparenttonull mapid is recursive (#3009) 2022-07-01 15:07:25 +10:00
Leon Friedrich
9e14a7e0d3 Lookup errors (#3007) 2022-07-01 13:46:26 +10:00
metalgearsloth
5700969945 Version: 0.28.2.0 2022-07-01 02:31:42 +10:00
metalgearsloth
6feb8b69ee Bump cfg log level to info (#2996) 2022-07-01 02:04:58 +10:00
keronshb
1ab14fa6b7 Moves fixture check in physics (#3004)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2022-07-01 02:04:24 +10:00
Leon Friedrich
445b13791e Lookup & dynamic tree changes (#3006) 2022-06-30 12:37:05 +10:00
metalgearsloth
5605149a63 Fix scale visuals (#3003)
Should be the last time
2022-06-29 22:40:13 +10:00
metalgearsloth
162b069de3 Version: 0.28.1.1 2022-06-29 19:18:15 +10:00
metalgearsloth
1c65686ee0 Fix spinbox overridevalue (#3002) 2022-06-29 19:17:03 +10:00
Pieter-Jan Briers
278755d938 Warn on startup if bad glibc version is detected. (#2998)
Yay.
2022-06-29 15:11:07 +10:00
Leon Friedrich
64b356a9bf Prevent dirty-on-init (#2999)
* prevent dirty-on-init

* Fix test
2022-06-29 15:10:51 +10:00
metalgearsloth
9681dc705e Version: 0.28.1.0 2022-06-29 13:21:06 +10:00
Leon Friedrich
fa2b0233c3 ECS detach to null (#2997)
* ECS detach to null

* fix crash
2022-06-29 13:17:58 +10:00
wrexbe
392e2fefca Fix entity manager shutdown (#2945) 2022-06-29 09:20:51 +10:00
TekuNut
47c56ffcf4 Fix crash in ReflectionManager (#2987) 2022-06-29 03:35:28 +10:00
metalgearsloth
dd602fd6d0 Version: 0.28.0.0 2022-06-28 22:56:26 +10:00
Leon Friedrich
2059d37c8f Remove implicit grid conversion (#2968)
* Remove implicit grid conversion

* fix map test

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2022-06-28 22:55:44 +10:00
metalgearsloth
6b73b765b2 Remove grid logs (#2994)
I added 2 of these and they aren't needed for me anymore.
2022-06-28 17:53:26 +10:00
metalgearsloth
fb32b55584 Sleep bodies when collision turned off (#2993)
May fix them getting through.
2022-06-28 17:53:13 +10:00
metalgearsloth
045aebfc9e Version: 0.27.1.2 2022-06-28 13:01:26 +10:00
metalgearsloth
449418b1d4 Fix cross-map contacts (#2990) 2022-06-28 13:00:51 +10:00
metalgearsloth
06cf2208f4 Bandaid findpairs issue (#2988) 2022-06-28 12:48:40 +10:00
TekuNut
ffbfdfe0b2 Fix client crash on sprite layer state change (#2984) 2022-06-27 09:18:21 +10:00
metalgearsloth
d7caa93cf5 Version: 0.27.1.1 2022-06-26 15:24:18 +10:00
metalgearsloth
0665781dfe Revert parent change (#2982) 2022-06-25 15:48:35 +10:00
metalgearsloth
a91413f1a6 Version: 0.27.1.0 2022-06-24 21:16:04 +10:00
Kara
6b9eeac228 More CompletionOption helpers (#2980) 2022-06-24 21:15:23 +10:00
wrexbe
c86e4e1ab9 Fix BuilderToMemory truncating (#2975) 2022-06-24 11:29:01 +02:00
wrexbe
269d229c2d Fix hotreload (#2976) 2022-06-23 10:40:14 +02:00
metalgearsloth
7e86065c67 Version: 0.27.0.2 2022-06-23 17:54:44 +10:00
metalgearsloth
dcb0c2eb92 Make GetEntitiesIntersecting(uid) use its bounds (#2978)
Was only using worldPos before.
2022-06-23 17:54:23 +10:00
metalgearsloth
fd667a67e7 Log deleted entities for physics (#2977)
Just crashed server and I'm too lazy to try to repro
2022-06-23 17:27:06 +10:00
metalgearsloth
bf966ee49b Version: 0.27.0.1 2022-06-23 14:38:58 +10:00
Leon Friedrich
2f75b74f1e Fix client disconnect crash (#2949) 2022-06-23 14:29:50 +10:00
metalgearsloth
a05b864952 Make transform handlestate set coordinates and not attachparent (#2965)
This makes the EntParentChangedMessage have the new position when it's issued.
2022-06-23 14:29:12 +10:00
Leon Friedrich
2d96e0cda1 "Fix" another client connection crash (#2950)
* Fix another client connection crash

* Add length info to error.

Co-authored-by: Electro <no>
2022-06-23 14:28:39 +10:00
metalgearsloth
cd1d6ee598 Version: 0.27.0.0 2022-06-23 12:13:07 +10:00
metalgearsloth
09d7ad9d62 Don't run client physics in frameupdate (#2953) 2022-06-23 12:12:54 +10:00
Kara
0c9c1366b0 Allow sprites to override container occlusion (#2971) 2022-06-22 16:07:09 -07:00
metalgearsloth
8470cf43b1 Version: 0.26.0.0 2022-06-22 09:53:15 +10:00
metalgearsloth
62a24a320c Make raiselocalevent not broadcast by default (#2972)
* Make raiselocalevent not broadcast by default

* I forgor to commit
2022-06-22 09:52:50 +10:00
Leon Friedrich
578066511f Maybe fix a placement manager crash (#2969) 2022-06-21 12:04:48 +02:00
metalgearsloth
2821492885 Version: 0.25.0.1 2022-06-20 20:51:55 +10:00
metalgearsloth
3806481f81 Fix broadphase crash (#2966) 2022-06-20 20:49:14 +10:00
metalgearsloth
e610b8a286 Hotfix recursive physics contacts (#2964) 2022-06-20 20:45:09 +10:00
ElectroJr
d283043a56 Version: 0.25.0.0 2022-06-19 20:10:37 -04:00
Leon Friedrich
4171b3ec4e Make Grid Uid Nullable (#2942)
* Make Grid Uid Nullable

* Fix recursion

* fix detach to null

* change obsolete text
2022-06-20 10:08:23 +10:00
wrexbe
f90872b085 Various test changes (#2930) 2022-06-20 10:03:17 +10:00
Leon Friedrich
077faebfc5 Fix some grid traversal misprediction (#2932)
* Fix some grid traversal misprediction

* a

* b

* c

* Revert "b"

This reverts commit ca64919a70.
2022-06-20 07:31:11 +10:00
metalgearsloth
526b37804e Expose GetLocalTilesIntersecting methods (#2961) 2022-06-20 07:27:20 +10:00
Leon Friedrich
b8cb9e6b1d Add Overlay.BeforeDraw() (#2958) 2022-06-20 06:28:09 +10:00
metalgearsloth
0dfd71c990 Version: 0.24.0.1 2022-06-17 13:57:44 +10:00
metalgearsloth
18232e946b Make broadphase updates recursive (#2959) 2022-06-17 13:56:52 +10:00
metalgearsloth
c06f3f003c Early out settiles for empty lists (#2957) 2022-06-17 07:10:11 +10:00
metalgearsloth
72cf2f6334 Version: 0.24.0.0 2022-06-16 15:34:32 +10:00
metalgearsloth
e0e47ad545 Add simple raycast method (#2937) 2022-06-16 15:33:35 +10:00
metalgearsloth
70157265b8 Fix prototype icon error textures (#2954) 2022-06-16 04:45:03 +10:00
wrexbe
1e5068f057 Make fixture init event order explicit (#2946)
* Make fixture init event order explicit

* No more physics init event

* No more physics init event

* Fixing some stuff
2022-06-14 19:25:40 +10:00
Leon Friedrich
2bdea420ae Misc rendering changes (#2948)
* Misc rendering changes

* More tiny changes
2022-06-14 19:24:27 +10:00
Leon Friedrich
be906faf42 Cache layer RSI state (#2947) 2022-06-13 17:49:28 +10:00
ElectroJr
a03eecaa36 Version: 0.23.0.0 2022-06-12 19:48:57 -04:00
keronshb
bc12a0af87 Reorders the signature for sound (#2928) 2022-06-13 09:45:26 +10:00
Leon Friedrich
d347641d00 Update save map command to show a success message. (#2944) 2022-06-13 09:45:04 +10:00
wrexbe
221dbf945e Fix localizing color (#2943) 2022-06-13 09:03:26 +10:00
Leon Friedrich
24c900aeae Small CheckFaceEyeVis() performance increase (#2940) 2022-06-13 08:36:35 +10:00
wrexbe
76aaca6260 Expose RemoveComponentDeferred (#2887) 2022-06-12 21:41:42 +02:00
metalgearsloth
d3519d799a Fix grid splitting (#2941) 2022-06-13 05:21:56 +10:00
Pieter-Jan Briers
1ea18b9448 Move analyzer tests over to separate project.
Safe to say the build system and Rider do not like the double-project-reference shenanigans going on in Robust.UnitTesting.
2022-06-12 12:35:57 +02:00
Pieter-Jan Briers
1e7956eaa8 Remove MarshalHelper
Not necessary anymore since .NET Core
2022-06-12 11:30:30 +02:00
metalgearsloth
7655aec413 Version: 0.22.0.0 2022-06-12 11:02:17 +10:00
Pieter-Jan Briers
a36a10c814 Fix deadlock on client shutdown.
This was an existing bug, but due to me moving more cleanup logic to game thread shutdown the window of opportunity for it to trigger just got much greater.
2022-06-11 16:28:14 +02:00
Pieter-Jan Briers
26cdae6877 cvar command shows completion hint showing cvar value.
Like in source!
2022-06-11 13:24:15 +02:00
Pieter-Jan Briers
c96eae620c Fix GetRegisteredCVars including unregistered CVars. 2022-06-11 13:23:35 +02:00
Pieter-Jan Briers
9591d16aed Implement res:// protocol for WebView, MIME type handling. 2022-06-10 17:09:46 +02:00
Pieter-Jan Briers
05bb361eb2 CEF cookie fixes (#2934)
* Trying to get res:// and usr:// cookies to wrok

* Update CefGlue

* Bump CEF

* Seal types in WebView

Fixes warnings

* Move most of client cleanup to game thread.

This used to run in the windowing thread which broke CEF shutdown, most notably cookie saving.

* "flushcookies" command for CEF.

* Remove unecessary res:// code.

* Fix tests

* More request handler fixes.

* Good thing I don't have to care about commit quality in PRs like this.
2022-06-10 14:30:57 +02:00
Pieter-Jan Briers
776669b789 Remove almost all allocations from F3 menu. (#2923) 2022-06-10 12:59:43 +02:00
Pieter-Jan Briers
8d5fa58e1a Avoid NRE if viewport has no eye 2022-06-09 09:39:08 +02:00
Leon Friedrich
dda544223f load & save map command update (#2926) 2022-06-09 13:13:46 +10:00
Leon Friedrich
34106195b0 Better sprite specifier errors (#2925) 2022-06-09 13:08:26 +10:00
Leon Friedrich
5bf3067342 Fix friend visualizer (#2924) 2022-06-09 03:29:32 +10:00
Leon Friedrich
ebeb504347 Make Eye use Matrix3.CreateTransform (#2921) 2022-06-09 03:10:43 +10:00
Leon Friedrich
0b824f2170 Add State application bool to IGameTiming (#2916) 2022-06-09 03:08:50 +10:00
Leon Friedrich
0d04d8a82a Add generic visualizer system (#2914) 2022-06-09 03:08:36 +10:00
Leon Friedrich
b360c4439b Matrix3 and Angle: add readonly and ref->in (#2919)
* Matrix3 and Angle readonly and ref->in

* fix precision
2022-06-08 17:53:17 +02:00
keronshb
d2cb4d102a Adds a filter to all except origin (#2922)
* Adds a filter to all except origin

* Spelling error fix
2022-06-08 14:59:53 +02:00
Leon Friedrich
b44524cd10 Matrix cleanup (#2920) 2022-06-08 14:52:48 +02:00
Vera Aguilera Puerto
7f0feef97c Version 0.21.0.0 2022-06-07 11:28:50 +02:00
Vera Aguilera Puerto
82a67ecd99 Add Access Permissions to friends, friend attributes now work in members too. (#2799) 2022-06-07 11:27:36 +02:00
metalgearsloth
42ad734a46 Version: 0.20.1.0 2022-06-07 12:11:45 +10:00
Pieter-Jan Briers
ac949a4bee Improve "monitor" command.
Has -all and +all options, code cleaned up including IDebugMonitors API and implementation.
2022-06-07 00:44:48 +02:00
Pieter-Jan Briers
60ca5beffa Put debug console below modal and popup root.
This means console completions aren't covered by F3, among other things.
2022-06-06 18:26:03 +02:00
Pieter-Jan Briers
a6ab044582 Fix shadow copies in Matrix3.TransformBoxSlow 2022-06-06 18:21:06 +02:00
Pieter-Jan Briers
d46fb519d5 Fix fullscreen disabling VSync in some cases.
I hate OpenGL.
2022-06-06 18:20:14 +02:00
Pieter-Jan Briers
832672149b Entity creation performance improvements (#2911) 2022-06-06 14:49:36 +02:00
Kara
3941930c2f Add fluent function for indefinite article (#2805) 2022-06-06 12:45:54 +02:00
metalgearsloth
4ab43cc923 Version: 0.20.0.0 2022-06-06 17:15:57 +10:00
metalgearsloth
cb0cb37e3c Remove PhysicsMap ref from physics comp (#2917) 2022-06-06 17:15:01 +10:00
metalgearsloth
df4ebd6c8c No more spoopy invisible ghosts (#2910)
Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
2022-06-06 16:50:57 +10:00
wrexbe
647aa7ecf2 Expose total fixtures mass on physics (#2908) 2022-06-05 18:28:02 -07:00
Pieter-Jan Briers
6aaf18cb27 Static dispatch ClientEntityManager from ClientGameStateManager.
Speed.
2022-06-05 17:04:25 +02:00
Pieter-Jan Briers
08e295972c TryGetComponent is AggressiveInlining 2022-06-05 17:04:04 +02:00
Pieter-Jan Briers
b4a7c5d47a Miniscule perf improvements to some component state handling.
Basically won't matter but it's a 0.3%.
2022-06-05 16:06:13 +02:00
Pieter-Jan Briers
4226976821 Ordered EventBus optimizations (#2902) 2022-06-05 14:49:59 +02:00
Pieter-Jan Briers
38bc58e77c Reduce dictionary lookups when doing char glyph stuff. 2022-06-05 00:38:00 +02:00
Leon Friedrich
386b0bc232 Cache TransformComponent in trees (#2904)
* Cache TransformComponent in trees

* add deleted check.
2022-06-05 00:25:00 +02:00
Leon Friedrich
487471c2d1 Faster box transform (#2901) 2022-06-05 00:22:00 +02:00
metalgearsloth
e46cfe1601 Ensure maploader sizes (#2906) 2022-06-05 00:14:09 +02:00
Leon Friedrich
fc4eb664e2 Make TryGetComponent output nullable (#2905)
* Make TryGetComponent output nullable

* figs

* ah. there are more. Why do you fail me VS
2022-06-05 00:13:53 +02:00
Pieter-Jan Briers
6c92d246c8 Oops I broke XAML 2022-06-03 02:50:39 +02:00
Pieter-Jan Briers
e86bd33a29 Fix XAML support in Rider EAP 2022-06-02 21:50:39 +02:00
metalgearsloth
c4787b63a8 Version: 0.19.2.0 2022-06-02 21:02:43 +10:00
metalgearsloth
6b305349c9 Fix grid deletion crashing (#2899)
* Fix grid deletion crashing

* polite

* a

* excellent
2022-06-02 21:01:56 +10:00
Alex Evgrashin
3c16779d68 Add helper function in entity prototype (#2868) 2022-06-01 17:28:47 +02:00
Pieter-Jan Briers
38fcadf649 Remove allocations from physics ComputeDistance() (#2896) 2022-06-02 00:52:43 +10:00
metalgearsloth
6cc50013be Version: 0.19.1.3 2022-06-01 22:46:28 +10:00
metalgearsloth
bb7c9ad7fa Fix grid fixtures logger woopsy (#2895) 2022-06-01 22:36:50 +10:00
metalgearsloth
b53d838b14 Version: 0.19.1.2 2022-06-01 20:01:16 +10:00
metalgearsloth
e03831586e Physics tweaks (#2890)
* Tweak awake assetr slightly

It will still log but game shouldn't blow up anymore.

* b

* a

a
2022-06-01 13:13:15 +10:00
metalgearsloth
6acb8f8b1b Add logs to grid splitting (#2888) 2022-05-31 19:18:49 +10:00
metalgearsloth
29bf2cbbc4 Version: 0.19.1.1 2022-05-31 17:53:48 +10:00
metalgearsloth
4fc238864b Update circle solver to box2d's latest (#2883) 2022-05-30 15:38:20 +10:00
Leon Friedrich
cb8d2727f4 Undo all angle lerp changes (#2884) 2022-05-30 15:38:09 +10:00
metalgearsloth
9ef433d3ed Version: 0.19.1.0 2022-05-29 16:24:48 +10:00
Pieter-Jan Briers
02de3cd437 Fix tests with concrete EntityManager 2022-05-29 01:15:52 +02:00
Pieter-Jan Briers
e7211063e7 Remove unecessary Vertex2D.SizeOf 2022-05-29 01:13:12 +02:00
Leon Friedrich
e32ee1a58e Reuse post-shader render target (#2882) 2022-05-29 01:02:19 +02:00
Pieter-Jan Briers
1eb5859f01 Expose concrete EntityManager on IoC, use it in EntitySystem.
REMOVE VIRTUAL DISPATCH.
2022-05-29 01:01:50 +02:00
Pieter-Jan Briers
ff7c3dc45c Do FramePreEngine and FramePostEngine on server 2022-05-29 00:39:54 +02:00
Pieter-Jan Briers
655b5974a3 Move sRGB -> linear conversion for vertex color to vertex shader.
This took almost 2% of CPU time on release. Jeez.
2022-05-28 23:18:05 +02:00
Leon Friedrich
47d7c7cf6c Revert ShortestDistance changes (#2881) 2022-05-29 04:03:31 +10:00
wrexbe
1c39deae6c Fix github action test output spam (#2847) 2022-05-28 16:15:37 +02:00
Pieter-Jan Briers
6c4dc7fc72 Version: 0.19.0.0 2022-05-28 15:36:59 +02:00
Pieter-Jan Briers
3c5618364c Move ValueList<T> to Robust.Shared.Collections 2022-05-28 15:34:46 +02:00
Pieter-Jan Briers
bf1cc8fd7c Minor performance improvements (#2860) 2022-05-28 15:28:08 +02:00
20kdc
72d4d50788 Tile aliases (#2840) 2022-05-28 14:59:58 +02:00
Leon Friedrich
6a86fcdeeb Fix WorldSpace overlay drawing (#2878) 2022-05-28 14:52:01 +02:00
Pieter-Jan Briers
dad95ad73a Fix KeepAspectCovered 2022-05-28 14:46:15 +02:00
20kdc
77f915acf5 Strip Lidgren "Disconnected: " prefix when a connection fails because of interruption by a disconnect with a structured message. (#2880)
Note that this otherwise retains the prefix, which may be important for debugging.
2022-05-28 14:37:17 +02:00
Pieter-Jan Briers
6fc1daf978 Some compiler warning fixes. 2022-05-28 13:36:35 +02:00
Pieter-Jan Briers
934f589778 Put Control FrameUpdate() before style & layout. (#2877) 2022-05-28 13:09:19 +02:00
Clyybber
305ea97d5b Limit audio raycast length (#2851)
* Limit audio raycast length

* Add MidiManager.MaxDistanceForCulling and cull based on MaxDistance.
2022-05-28 13:07:36 +02:00
Pieter-Jan Briers
e3b26e80bf Sync CurTime base. (#2858) 2022-05-28 13:03:42 +02:00
Leon Friedrich
810ef119b0 Remove "A:" log (#2879) 2022-05-28 11:10:41 +02:00
20kdc
393b27679d ACZ general speedups (#2873)
* Cleave the ACZ code into two parts

* SSAZip - faster-performing than ZipArchive, very small codebase

* OnDemandFile to reduce RAM usage of SSAZip

* Modify OnDemandFile to be more amiable for replacing parts of ACManifest

* Make the ACZ Manifest code a lot less reliant on an "internal zip file" for memory usage reasons

* Finally allow disabling legacy client zip creation entirely

* ZIP is now only an ingestion format for ACZ, not actually served anymore

* We do a little renaming

* We do a little namespace adjustment

* We do a little ABOMINATION OF FILE MERGING
2022-05-27 20:52:38 +02:00
Pieter-Jan Briers
a592134caf run XamlIL with internal MSBuild by default.
This only needs to be external when developing XamlIL itself, and I assume doing it external worsens build perf somewhat.
2022-05-27 17:42:27 +02:00
wrexbe
2389df7c6f Ignore missing components on the client (#2846) 2022-05-27 15:30:22 +02:00
Leon Friedrich
422202348e Change SplitContainer MeasureOverride (#2874) 2022-05-27 13:31:54 +02:00
metalgearsloth
284e08ffd9 Version: 0.18.1.3 2022-05-27 10:18:30 +10:00
Leon Friedrich
2ce3d04bba Remove EntitySystem.Get from SpriteView.DrawInternal() (#2867) 2022-05-27 10:18:01 +10:00
Acruid
8e67bfe990 Backwards compatible API additions to support removing GridId from content. (#2855) 2022-05-27 10:17:05 +10:00
Leon Friedrich
27dc9510a3 Remove ambiguity in sprite specifier (#2844) 2022-05-27 10:16:08 +10:00
Leon Friedrich
d4708cb144 Make ignored component errors more explicit (#2875) 2022-05-27 10:15:44 +10:00
Pieter-Jan Briers
986de32043 Don't try to parse JSON structured disconnects if it doesn't look like JSON.
Avoid my debugger getting caught on the exception.
2022-05-27 00:03:39 +02:00
Kara
4e90c291b3 Make ShortestDistance not reduce angle (#2869) 2022-05-25 21:55:31 -07:00
metalgearsloth
7775767687 Version: 0.18.1.2 2022-05-26 14:29:12 +10:00
Leon Friedrich
5624476e2b Reset last modified tick (#2871) 2022-05-26 14:28:37 +10:00
Leon Friedrich
9ef80864b7 Fix completion divide by zero (#2866) 2022-05-26 04:38:08 +10:00
Clyybber
c32ef136a1 Fix completion crashing on a invalid path not starting with '/' (#2861) 2022-05-25 13:39:31 +10:00
metalgearsloth
b2ea0fe1e2 Version: 0.18.1.1 2022-05-25 00:56:51 +10:00
metalgearsloth
be86b12b14 Fix collisionwake on spawn (#2859)
* Fix collisionwake on spawn

Stuff that was immediately slept wasn't checked correctly.

* Testy
2022-05-25 00:55:11 +10:00
Pieter-Jan Briers
8b8e499615 Avoid TLS lookup in IoCManager.Resolve<T>(ref T) if instance provided. 2022-05-23 23:33:01 +02:00
metalgearsloth
36b0d38b70 Version: 0.18.1.0 2022-05-22 18:56:53 +10:00
Kara
78ef6921da Fix two angle lerping bugs (#2850) 2022-05-22 18:56:16 +10:00
metalgearsloth
f6ab67e92c Fix audio being occluded by non-hard fixtures (#2849) 2022-05-22 18:32:32 +10:00
Vera Aguilera Puerto
44ffdcf429 Also look for "default.dls" soundfonts on Linux.
Technically, it still opened them fine if they were called "default.sf2" but having the correct extension is better, honestly.
2022-05-20 21:55:26 +02:00
Vera Aguilera Puerto
53f4d3fab6 Allow soundfonts shipped by Content to override system soundfonts.
If Content wants to override the system soundfont, it should be able to.
2022-05-20 21:41:12 +02:00
metalgearsloth
7dcf543443 Version: 0.18.0.1 2022-05-20 18:30:09 +10:00
metalgearsloth
4e445ee313 Physics command niceties (#2843) 2022-05-20 14:17:20 +10:00
metalgearsloth
c6be3e145a Fix help command crash (#2841) 2022-05-19 18:18:33 +10:00
Pieter-Jan Briers
f90526be22 Bump ANGLE, add ES3OnFL10_0 support (#2834) 2022-05-19 07:55:36 +10:00
metalgearsloth
df09bc2cf0 Version: 0.18.0.0 2022-05-19 07:52:46 +10:00
metalgearsloth
a1affcfd3f BodyTypeChangedEvent changes (#2838) 2022-05-19 07:51:54 +10:00
metalgearsloth
a402f3a880 Version: 0.17.0.0 2022-05-17 13:32:33 +10:00
Leon Friedrich
b0fe9fb1a4 Log error for invalid coordinate conversions (#2835)
* Log error for invalid coordinate conversions

* remove $$$
2022-05-17 13:10:33 +10:00
Pieter-Jan Briers
5057c91dcd Console command completions v1. (#2817)
* Console command completions v1.

I think it works™️

* Unify cvar commands

* Handle no-completions-at-all better.

* Don't crash if you tab complete while no completions available.

* Always show hints if available

* Properly null completion hint over the wire

* Unify help command, localize it.

* Clean up + localize cvar command.

* Remove debug logging

* List command unified & localized.

* Remove server completions debug logging

* Remote execute command.

Had to make everything async for this.

* Don't lower case enums or bools
Why

* GC commands converted and localized.

* Fix remote command completions.

Whoops

* Kick command completions

* lsasm unified & localized.

* Revert "Don't lower case enums or bools"

This reverts commit 2f825347c3.

* ToString gc_mode command enums instead of trying to fix Fluent.

Ah well.

* Unify szr_stats

* Unify log commands, completions

* Fix compile

* Improve completion with complex cases (quotes, escapes)

* Code cleanup, comments.

* Fix tab completion with empty arg ruining everything.

* Fix RegisteredCommand completions

* Add more complex completion options system.

* Refactor content directory entries into a proper resource manager API.

* Implement GetEntries for DirLoader

* Make type hint darker.

* Exec command autocomplete, pulled play global sound code out to engine.
2022-05-17 13:07:25 +10:00
Pieter-Jan Briers
84a80db21f Quick and dirty environment variable to disable sandboxing.
Make game start faster.
2022-05-16 22:07:09 +02:00
20kdc
8657e5516b Structured disconnect messages (#2831)
* net structured disco

* Structured reason into NetChannelArgs/etc.

* Enable redial flag in common cases

* Get it all done

* Disco->DisconnectMessages
2022-05-16 21:48:12 +02:00
Pieter-Jan Briers
6b24da6990 Don't emit array precisions on GLES2 2022-05-16 17:32:45 +02:00
20kdc
0ee87bc771 Colour batch reduction (#2809)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
2022-05-16 17:28:37 +02:00
metalgearsloth
6e35c89740 Significantly optimise prediction resetting (#2826)
* Significantly optimise prediction resetting

Turns out just tracking dirty entities and not iterating 30k is much faster.

* cleaner

* Slightly better again

* review

* Fix

* boop

* rebiew

* A
2022-05-16 22:08:17 +10:00
Leon Friedrich
9d69b330b5 Stop double AnchorStateChangedEvent (#2830) 2022-05-16 14:40:48 +10:00
metalgearsloth
22b3f3148c Add default ctor for mousejoint 2022-05-16 13:55:30 +10:00
metalgearsloth
b73b3007f2 Version: 0.16.0.0 2022-05-16 13:20:12 +10:00
Leon Friedrich
37dd4b0893 Pass sprite component in AppearanceChangeEvent (#2829) 2022-05-16 13:19:40 +10:00
metalgearsloth
07c5a38582 Issue collision change events on entity spawns again (#2828)
I thought I'd think of something better for pathfinding but I did not.
2022-05-16 13:17:48 +10:00
metalgearsloth
c866c6b59b Optimise grid traversal for pop-in (#2825)
This was like 1/3 of the frame spikes from PVS pop-in. The main benefit is just checking if the entity is anchored for grid traversal and the secondary was earlying-out handling component state if it's sent to nullspace.
2022-05-16 07:37:01 +10:00
ElectroJr
c3e97cb97e Version: 0.15.1.0 2022-05-15 15:25:38 +12:00
Leon Friedrich
52ffb97369 Change overlay screen texture wrapping (#2749) 2022-05-15 13:20:52 +10:00
Leon Friedrich
bad5657725 MapLoader and mapping command changes (#2744) 2022-05-15 12:28:38 +10:00
wrexbe
f8dc3c8a0e Add some CodeAnalysis attributes to whitelist (#2811) 2022-05-15 12:25:57 +10:00
Paul Ritter
77493b5d14 caches reflection in serv3 datadefinition delegates (#2790)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2022-05-14 16:37:18 +10:00
metalgearsloth
b1ceafbe4f Version: 0.15.0.0 2022-05-14 15:14:10 +10:00
Pieter-Jan Briers
41e9d9b08b Client profiling system (#2783)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2022-05-14 15:08:46 +10:00
metalgearsloth
dc32549c75 Version: 0.14.7.0 2022-05-14 14:55:56 +10:00
metalgearsloth
17dd3af3c7 ECS metadata pausing (#2800) 2022-05-14 14:55:42 +10:00
metalgearsloth
32bdc19fe9 Final grid movement optimisation (#2711) 2022-05-14 14:54:31 +10:00
metalgearsloth
70fbefbe62 Fix joints crash (#2816) 2022-05-14 14:51:45 +10:00
Vera Aguilera Puerto
64cd6ea9be Adds GridUid field to TileRef. (#2815)
* Adds GridUid field to TileRef.

* actually compiles
2022-05-13 18:00:33 +10:00
metalgearsloth
aa92c2444d Version: 0.14.6.0 2022-05-13 12:07:59 +10:00
metalgearsloth
9b19626f1b Port mousejoint from box2d (#2814) 2022-05-13 00:21:39 +10:00
Moony
2bbe5193ee Moves that disable connect option nobody can use to somewhere people can use it. (#2812) 2022-05-12 16:02:12 +02:00
metalgearsloth
d11318f082 Make tile placement much less jank (#2785) 2022-05-12 22:27:06 +10:00
wrexbe
237f948d99 BinaryPrimitives > BitConverter (#2813)
* BinaryPrimitives > BitConverter

* Forgot a :
2022-05-12 07:57:21 +02:00
Kara D
f3449be1e9 Version: 0.14.5.0 2022-05-11 13:43:58 -07:00
Vera Aguilera Puerto
b95ffda711 EntityCoordinates methods for getting grid/map EntityUid.
Uses the new Transform properties that return grid/map EntityUids.
2022-05-11 14:24:46 +02:00
Moony
0932fa0058 Add the concurrent collections and BitConverter to the allow list. (#2810) 2022-05-11 00:11:32 +02:00
Pieter-Jan Briers
da2e46b81b Increase command timeout on benchmark SSh action 2022-05-10 16:05:53 +02:00
Pieter-Jan Briers
d4a1fcc9c6 Fix database code for benchmarks. 2022-05-10 15:44:25 +02:00
Pieter-Jan Briers
c7e7f4f28f make run_benchmarks.py handle errors better. 2022-05-10 14:44:53 +02:00
Pieter-Jan Briers
87e191b8d7 Benchmarks CI attempt 6 2022-05-10 14:35:12 +02:00
Pieter-Jan Briers
05b21fcfcc Benchmark CI attempt 5 2022-05-10 11:54:25 +02:00
Pieter-Jan Briers
48e4ae87d8 Benchmark CI attempt 4(?) 2022-05-10 11:18:04 +02:00
Pieter-Jan Briers
8b090034f1 Benchmarks CI fix attempt 3 2022-05-10 11:14:17 +02:00
Pieter-Jan Briers
41c183ac09 Fix GITHUB_SHA? 2022-05-10 11:10:57 +02:00
Pieter-Jan Briers
4380b95451 Fix benchmarks attempt 1 2022-05-10 11:06:57 +02:00
Pieter-Jan Briers
90fc486a20 Allow manual dispatch of benchmarks 2022-05-10 11:00:52 +02:00
Paul Ritter
f254153962 benchmark script (#2745)
* benchmark script

* more changes

* oopsie

* adjust workflow

* Put a concurrency limit on the benchmarks action

* Update run_benchmarks.py

Co-authored-by: Paul <ritter.paul1+git@googlemail.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2022-05-10 10:58:42 +02:00
Moony
a2538d1905 Add the setter for images to the sandbox list (#2802) 2022-05-10 09:35:55 +02:00
metalgearsloth
5d7a2879a7 Fix scaling consistency between sprite and bounds (#2803) 2022-05-10 00:34:07 -07:00
20kdc
986adf6494 RobustToolbox side of Redial API. (#2804)
* RobustToolbox side of Redial API.

Please be aware that as far as I know testing this code is nigh-impossible until it ships.

* a smidge of paranoia

* paranoia on the paranoia please
2022-05-10 09:24:46 +02:00
Pieter-Jan Briers
15932fb9aa DebugTools.Assert(bool, string) does not allocate if string is a format string anymore. 2022-05-10 00:59:36 +02:00
Pieter-Jan Briers
3ae4bb03f5 Enable NetManager latency sim on release, add no-bye to INetChannel.
A minute amount of tomfoolery.
2022-05-09 15:43:30 +02:00
metalgearsloth
7f47478997 Make physics testbed slightly less annoying to use (#2794) 2022-05-08 23:28:54 +10:00
metalgearsloth
a2923450ea Optimise occluder dirtying (#2801)
Mostly when stuff spawning in.
2022-05-08 15:16:56 +10:00
metalgearsloth
5366b9a35b Cleanup collisionmanager (#2792)
1. Split it into partials because my scroll wheel was hating me.
2. Removed AABB shapetypes because contacts were made fast enough it doesn't matter.
2022-05-08 14:41:36 +10:00
metalgearsloth
5ca37c68e2 Optimise physics init (#2786) 2022-05-08 14:39:54 +10:00
Vera Aguilera Puerto
22aa274d03 Add GridUid and MapUid properties to TransformComponent. (#2798) 2022-05-07 22:43:00 +10:00
metalgearsloth
54bbe55bb9 Version: 0.14.4.0 2022-05-07 21:42:57 +10:00
metalgearsloth
9706576e66 Fix grid splits for empty chunks (#2797) 2022-05-07 13:26:26 +10:00
metalgearsloth
b2ccd65da4 Fix showgridnodes colours (#2796) 2022-05-07 11:17:28 +10:00
Paul
c587cd2e12 hm 2022-05-06 18:36:50 +02:00
Paul Ritter
ba23a989a9 make pvs account for lastack properly (#2733) 2022-05-06 18:09:30 +02:00
metalgearsloth
c6c69668c8 Fix polyshape centroids (#2793) 2022-05-05 22:42:35 +10:00
Leon Friedrich
b0a4593f44 Speed up map init, and unpause map on init (#2781)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2022-05-05 19:21:03 +10:00
metalgearsloth
2d6e699e2c Mark component name as obsolete (#2791) 2022-05-05 18:42:38 +10:00
metalgearsloth
4307509402 ECS even more transform (#2742)
Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
2022-05-05 13:20:23 +10:00
Paul
ed165b1e4c removes some iocresolves in mapmanager 2022-05-04 23:17:47 +02:00
Paul
3503300a23 minor serv3 optimization 2022-05-04 23:05:28 +02:00
Paul
3ab3d255ed fix seed benchmark 2022-05-04 18:43:17 +02:00
metalgearsloth
fd625e0b30 Fix scale command (#2784)
* Fix scale command

Everything will be visualizers.

* comment for future coders
2022-05-04 22:49:42 +10:00
ElectroJr
53af37cd56 Version: 0.14.3.1 2022-04-30 01:51:51 +12:00
Leon Friedrich
6bf4945181 Allow int uniforms to specify precision (#2779) 2022-04-29 23:48:08 +10:00
metalgearsloth
868320c513 Fix VV lineedit crash 2022-04-29 00:41:14 +10:00
Leon Friedrich
577b836420 Fix grid-traversal parenting (#2777) 2022-04-28 18:08:56 +10:00
metalgearsloth
4a36b52657 Nuke an xform log
Probably not worth it.
2022-04-27 00:35:38 +10:00
metalgearsloth
8dc944d22d Stop invalid broadphase change from crashing the game (#2717) 2022-04-26 23:25:28 +10:00
metalgearsloth
0a10170155 Fix map change crash (#2716)
* Fix map change crash

Follower really out here exposing all the ordering bugs.

* Log AttachToGridOrMap
2022-04-26 23:21:58 +10:00
metalgearsloth
dfa2c222d1 Version: 0.14.3.0 2022-04-26 01:18:07 +10:00
metalgearsloth
e288af162c Add event for post-grid-split (#2774) 2022-04-26 01:17:22 +10:00
Kara
6280820c86 Merge pull request #2768 from ShadowCommander/errorcheck-vv-lineedit
Add null check to VV string parsing
2022-04-24 22:51:49 -07:00
ShadowCommander
102b31f83d Add null check to VV string parsing 2022-04-24 02:16:42 -07:00
metalgearsloth
37ca9ca19a Version: 0.14.2.4 2022-04-24 16:40:10 +10:00
metalgearsloth
0c151ad456 Fix grid deletion for SetTiles (#2767) 2022-04-24 16:39:57 +10:00
metalgearsloth
55e3f749b4 Version: 0.14.2.3 2022-04-24 16:07:19 +10:00
metalgearsloth
16902d7fbc Hotfix anchoring (#2764) 2022-04-24 16:06:50 +10:00
metalgearsloth
c37f53e083 Issue re-parent event on split (#2765) 2022-04-24 15:25:55 +10:00
metalgearsloth
4cc499afdf Version: 0.14.2.2 2022-04-24 13:22:39 +10:00
20kdc
48895efad7 Flexible object pool for ZStd compression contexts rather than the array-based version (#2763) 2022-04-23 20:17:59 +02:00
metalgearsloth
eb46b04c0e Version: 0.14.2.1 2022-04-24 00:58:38 +10:00
metalgearsloth
442de12b99 Grid splitting (#2743)
Co-authored-by: Vera Aguilera Puerto <gradientvera@outlook.com>
2022-04-24 00:57:56 +10:00
Vera Aguilera Puerto
712c1f3559 Adds "ressys" and IEntitySystemManager dependency to scripting globals. (#2762)
"ressys" resolves an `EntitySystem`.
2022-04-24 00:55:31 +10:00
Vera Aguilera Puerto
5a5cfa1eba Adds GetGridOrMapTilePosition to SharedTransformSystem. (#2759)
A little helper method that would be VERY useful for many content things... Such as atmos.
2022-04-24 00:55:11 +10:00
metalgearsloth
7988386bc3 Version: 0.14.1.1 2022-04-24 00:53:41 +10:00
Leon Friedrich
76bfe2905d Add support for float[] and vec2[] in shaders (#2751)
* huh it works.

* vector arrays
2022-04-22 22:43:17 +02:00
ShadowCommander
23893bcacd Change LineEdit to keep cursor position (#2752)
* Change LineEdit to keep cursor position

* Revert console changes
2022-04-22 22:42:24 +02:00
Pieter-Jan Briers
c1da159e8f Rely on SharpZstd -Bsymbolic 2022-04-22 22:39:59 +02:00
20kdc
13889acb37 Fix crash caused by passing uninitialized structure to ZSTD_inBuffer (#2760) 2022-04-22 14:10:20 +02:00
Vera Aguilera Puerto
ffb3de3f2c Fix loading soundfonts from filesystem on Linux 2022-04-21 17:52:27 +02:00
Flipp Syder
87cd45fc64 Adds custom midi soundfont support (sandboxed) (#2746) 2022-04-21 10:05:57 +02:00
Leon Friedrich
1cf914813c Add PVSOverrideSystem (#2747)
* Add PVSOverrideSystem

* add session and clear functions
2022-04-20 16:00:18 +02:00
Pieter-Jan Briers
86d61f8d03 Version: 0.14.0.1 2022-04-20 15:39:32 +02:00
Pieter-Jan Briers
8f638fbf9e HOTFIX ParallelManager out of bounds
I could have sworn I made this -1.

Completely untested
2022-04-20 15:21:17 +02:00
metalgearsloth
95ac134a07 Comment out msgstate logger (#2754)
Getting spammed and I don't think we want to log here long-term anyway.
2022-04-20 13:13:15 +02:00
metalgearsloth
4e65f9b2a1 Version: 0.14.0.0 2022-04-20 18:48:06 +10:00
Paul
d60bbe9fe9 misc client optimizations 2022-04-18 22:34:49 +02:00
Pieter-Jan Briers
dec1495e1e Remove reference to ManagedHttpListener.
How did this ever compile?
2022-04-17 19:13:24 +02:00
Paul
dc72c6fe22 fix typo 2022-04-17 18:15:41 +02:00
Paul
141b1205c6 removes some todos 2022-04-17 18:09:46 +02:00
Pieter-Jan Briers
65f4a09ad5 Try to fix ZStd stuff for servers. 2022-04-17 18:02:35 +02:00
Pieter-Jan Briers
3d1545c0b9 Fix incorrect unsubscription to AssemblyLoadContext.Default.Resolving.
+= instead of -=.
2022-04-17 18:02:35 +02:00
metalgearsloth
ec26dd622b DetachParentToNull tweaks (#2741)
* DetachParentToNull tweaks

The other parent change message already has the mapid and gridid updated when issuing the event.

We'll also guard the event by checking if they're already in nullspace.

* woops
2022-04-17 17:28:07 +10:00
metalgearsloth
0ab3131964 ECS transform states (#2710)
* ECS transform states

Turns out it also saves us a GetComponent on the parent too which is nice.

* Fix test
2022-04-17 14:55:29 +10:00
Pieter-Jan Briers
588a9e9f63 ZSTD game states + other improvements (#2737) 2022-04-16 14:36:59 +02:00
Pieter-Jan Briers
f2fa930edd Block explicit layout types in sandboxing. 2022-04-16 14:17:37 +02:00
Kara D
ec47229a37 Version: 0.13.0.0 2022-04-15 14:36:50 -07:00
mirrorcult
bf5d1d58a8 Merge pull request #2715 from moonheart08/better-map-loading 2022-04-15 14:34:48 -07:00
mirrorcult
8b4da24ee7 Merge pull request #2722 from PaulRitter/2022_04_12_abstract_validation 2022-04-15 14:34:22 -07:00
mirrorcult
3fba108d70 Merge pull request #2734 from PJB3005/22-04-14-spacewizards-http 2022-04-15 14:34:01 -07:00
mirrorcult
35029f0eed Merge pull request #2692 from vulppine/color-sliders 2022-04-15 14:33:21 -07:00
mirrorcult
b66ab9d7c6 Merge pull request #2727 from ElectroJr/update-mapping-except 2022-04-15 14:31:30 -07:00
mirrorcult
5e0b745ba9 Merge pull request #2739 from PJB3005/22-04-15-remove-createnetmsg 2022-04-15 14:30:32 -07:00
Pieter-Jan Briers
45d906ba7e Deprecate CreateNetMessage<T>. 2022-04-15 18:47:42 +02:00
Pieter-Jan Briers
24b124fb17 Fix client reconnect 2022-04-15 15:28:45 +02:00
Vera Aguilera Puerto
7cb0978468 Revert "Adds custom MIDI soundfont support (#2720)"
This reverts commit 9ff46b9aad.

Sandbox violation, oops.
2022-04-15 12:46:30 +02:00
mirrorcult
44cb135a1d Even shorter pretty-print type abbreviations for VV (#2735) 2022-04-15 09:15:10 +02:00
Pieter-Jan Briers
146b673203 Move string serializer to ZStd and BLAKE2b.
Faster and smaller
2022-04-15 01:16:35 +02:00
Pieter-Jan Briers
b0d23c5665 Remove zstd & libsodium natives from client publishes.
Save a good megabyte.
2022-04-15 00:39:56 +02:00
Pieter-Jan Briers
68f89c8958 SkipIfSandboxedAttribute
Should allow something like OpenDream to provide unsandboxed-only DLLs easily.
2022-04-15 00:31:17 +02:00
Pieter-Jan Briers
1327d6bf25 Replace ManagedHttpListener submodule in favor of NuGet package.
It's SpaceWizards.HttpListener now!
2022-04-14 23:53:57 +02:00
Pieter-Jan Briers
237e37ff30 Update Lidgren submodule 2022-04-14 23:47:17 +02:00
Pieter-Jan Briers
4d707c86cb Version: 0.12.1.0 2022-04-14 17:17:17 +02:00
Pieter-Jan Briers
c7027c6e00 ACZ manifest delta downloads (#2698) 2022-04-14 17:15:54 +02:00
Paul Ritter
81ec61bcc8 overflowqueue (#2721)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2022-04-14 10:57:28 +02:00
DrSmugleaf
649178fa54 Rename engine prototypes folder to EnginePrototypes (#2723) 2022-04-14 05:46:29 +02:00
Flipp Syder
9ff46b9aad Adds custom MIDI soundfont support (#2720)
Co-authored-by: Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
2022-04-13 11:59:43 +02:00
ElectroJr
cdcbb60ca7 more comments 2022-04-13 21:46:40 +12:00
ElectroJr
d8cdb2b312 comments 2022-04-13 21:43:47 +12:00
ElectroJr
fa1c1b8e6e better equality 2022-04-13 21:39:48 +12:00
ElectroJr
2ded835602 Make MappingDataNode.Except() not recursive 2022-04-13 21:08:59 +12:00
moonheart08
a43f04818d fix map commands. 2022-04-12 09:48:45 -05:00
moonheart08
278dc60119 use a query for xform. 2022-04-12 09:43:59 -05:00
moonheart08
8a202be0cf naming. 2022-04-12 09:34:18 -05:00
moonheart08
58940a3cd7 bp/map load now take arguments. 2022-04-11 23:54:15 -05:00
moonheart08
aa9721d146 fix tests 2022-04-11 23:15:37 -05:00
Paul
79f114ad5b work 2022-04-12 02:04:41 +02:00
Leon Friedrich
197a6ddd9d Fix sprite bb calculation (#2714) 2022-04-11 18:13:32 +02:00
metalgearsloth
4a4fb15e06 Add xform comp ref to parent change message (#2709) 2022-04-11 17:01:07 +10:00
metalgearsloth
e7e83ce6e8 Optimise fixture init slightly (#2707) 2022-04-11 16:58:48 +10:00
Leon Friedrich
a82b293452 Make RemoveComp not error on missing component (#2689) 2022-04-11 16:57:35 +10:00
Vera Aguilera Puerto
bb483a3a38 Add "midipanic" command. (#2701) 2022-04-11 16:55:12 +10:00
moonheart08
2ca3d0e395 Fix map loading once and for all. 2022-04-11 00:44:28 -05:00
metalgearsloth
bda79b1e82 Cache serialized types (#2706) 2022-04-11 12:50:34 +10:00
metalgearsloth
4f4b754e2d Don't allow velocity to be set where an obj can't collide (#2691) 2022-04-11 12:49:35 +10:00
mirrorcult
214cabac43 Merge pull request #2713 from oappiah/minor_config_update 2022-04-10 13:35:00 -07:00
Appiah
7b6229c222 Corrected the map example 2022-04-10 22:24:21 +02:00
Paul
1a14a75897 nullspace viewer crash fix 2022-04-10 17:52:12 +02:00
metalgearsloth
76b75fd9b3 Remove LINQ from sprite bounds (#2708) 2022-04-10 17:48:45 +10:00
Pieter-Jan Briers
b969fd22f7 Version: 0.12.0.1 2022-04-09 21:02:56 +02:00
Profane McBane
8d27d091af Hotfix - change PVS pools to use MaxVisPoolSize (#2704) 2022-04-09 20:54:41 +02:00
DrSmugleaf
1eb7393a60 Revert "pvsrange vec2 + eyezoom (#2676)" (#2703)
This reverts commit 582d8a5587.
2022-04-09 19:41:11 +02:00
Vera Aguilera Puerto
4cf88507c2 Version: 0.11.0.1 2022-04-09 13:21:38 +02:00
Vera Aguilera Puerto
3565d8b321 Fix synth state getting reset every MIDI player loop. 2022-04-09 13:21:09 +02:00
Vera Aguilera Puerto
7094c29b2e Version: 0.11.0.0 2022-04-08 16:07:42 +02:00
Vera Aguilera Puerto
63004b270f Cleans up and improves MIDI code significantly. (#2666) 2022-04-08 15:58:15 +02:00
metalgearsloth
6714a99b38 EntityLookup anchor flag test (#2699) 2022-04-08 13:36:24 +10:00
metalgearsloth
4c3b8df1e7 Fix anchor query (#2697) 2022-04-08 09:56:30 +10:00
metalgearsloth
4bb695121f Version: 0.10.0.0 2022-04-06 19:34:47 +10:00
metalgearsloth
09fd47c421 Don't store contained entities on entitylookup (#2662) 2022-04-06 19:31:34 +10:00
vulppine
d201d9c688 adds color sliders, fixes issues with RGB->HSL/V 2022-04-05 12:21:59 -07:00
Paul
fd1e25c584 Version: 0.9.3.2 2022-04-05 18:51:03 +02:00
Paul Ritter
6bb66ae70e fixes loc (#2685) 2022-04-05 18:50:27 +02:00
Paul
cc82d6b1d9 Version: 0.9.3.1 2022-04-05 18:36:19 +02:00
Paul
956be749b6 fix prototype reload 2022-04-05 18:36:09 +02:00
Paul Ritter
6585a00608 readds expandpvsevent (#2684) 2022-04-05 19:47:14 +10:00
metalgearsloth
c0525f710f Sprite subscription shutdown (#2688) 2022-04-05 19:45:23 +10:00
Vera Aguilera Puerto
d3672807d2 Improves SpriteSystem.GetPrototypeIcon method significantly. (#2680) 2022-04-05 16:36:16 +10:00
ElectroJr
60f18d5f36 Version: 0.9.3.0 2022-04-05 18:06:43 +12:00
mirrorcult
e72d3de256 Local event for BUI opening (#2687) 2022-04-05 15:52:02 +10:00
Moony
ba9846b9c4 Fix vector2 CVars (#2686) 2022-04-05 15:03:10 +10:00
Paul
09586284dc Version: 0.9.2.0 2022-04-04 20:28:53 +02:00
Paul
a1ee4374b2 add a check for major version == 0 2022-04-04 20:28:26 +02:00
Paul Ritter
4de6f25f11 updates version-script to use the new version format (#2683) 2022-04-04 20:25:12 +02:00
Paul Ritter
582d8a5587 pvsrange vec2 + eyezoom (#2676)
Co-authored-by: Paul <ritter.paul1+git@googlemail.com>
2022-04-04 20:20:13 +02:00
Leon Friedrich
ec53b04f99 Add NotNullWhen attribute to TryComp (#2681) 2022-04-04 11:29:02 +02:00
metalgearsloth
950fc94408 Physicsmap tweaks (#2663) 2022-04-04 17:10:15 +10:00
Leon Friedrich
58d12e6e09 Remove Component.OnAdd() (#2660) 2022-04-04 16:11:47 +10:00
ElectroJr
94323005c4 Version: 0.9.1 2022-04-04 17:43:01 +12:00
metalgearsloth
4989842057 Remove IgnorePause (#2649) 2022-04-04 15:41:38 +10:00
Paul
80172636a8 version 0.9 - serv3 refactor 2022-04-03 02:00:41 +02:00
Paul Ritter
8491f7be24 New Serv3 api just dropped (#2605)
Co-authored-by: Paul Ritter <ritter.paul1@gmail.com>
2022-04-03 01:59:48 +02:00
Pieter-Jan Briers
de8c2c14bb Replace Lidgren encryption stuff with Libsodium (#2646) 2022-04-02 16:24:04 +02:00
mirrorcult
baebfff321 Merge pull request #2673 from ElectroJr/fix-description 2022-04-01 17:02:43 -07:00
Paul
24191404aa version 0.8.86 2022-04-02 01:28:12 +02:00
Paul Ritter
990842f5c2 fixes pvs dirty crash (#2674) 2022-04-02 06:09:14 +11:00
ElectroJr
2c2bd3f330 Version: 0.8.85 2022-04-02 00:38:07 +13:00
Leon Friedrich
1ae14c4bfa Add error tolerance to physics map (#2672) 2022-04-01 22:07:27 +11:00
metalgearsloth
61a1701dc9 Fix PVS take 3 (#2671) 2022-04-01 22:04:30 +11:00
ElectroJr
c6ea11346e fix entity description proxy method. 2022-04-02 00:02:58 +13:00
mirrorcult
ad7c871e28 Make effects properly clean up after itself (#2670) 2022-04-01 13:00:54 +11:00
metalgearsloth
c77b3f8022 Version: 0.8.84 2022-04-01 10:10:20 +11:00
metalgearsloth
b263f4a1df Fix PVS crash 2 (#2668)
Co-authored-by: Paul <ritter.paul1@googlemail.com>
2022-04-01 10:09:31 +11:00
Paul
1a11d41bba disable benchmarks workflow 2022-03-31 17:06:48 +02:00
Leon Friedrich
14d0a77644 Make directional sprite matrices static (#2661) 2022-04-01 00:11:17 +11:00
ElectroJr
b75045ce1a Version: 0.8.83 2022-03-31 15:25:31 +13:00
Leon Friedrich
1d8a8e15ef Add a is-In-container metadata flag. (#2585) 2022-03-31 13:23:33 +11:00
Leon Friedrich
28a087c267 Add GetEntitiesIntersectingBody (#2641) 2022-03-31 11:52:35 +11:00
Jane Lewis
8dc849b6bb Cache Sprite AABBs (#2622) 2022-03-31 11:52:00 +11:00
mirrorcult
7e56f46f35 Remove network component messages (#2659) 2022-03-31 10:24:27 +11:00
metalgearsloth
4453a23069 Version: 0.8.82 2022-03-30 23:34:50 +11:00
metalgearsloth
57be0bc845 Fix nullability (#2658) 2022-03-30 23:34:31 +11:00
Paul Ritter
430910ff36 sudo the benchmarks to elevate them to high prio 2022-03-30 14:10:13 +02:00
Paul Ritter
4c95807e2d how 2022-03-30 14:08:53 +02:00
metalgearsloth
92fd04552d Version: 0.8.81 2022-03-30 22:58:42 +11:00
Leon Friedrich
9c7e244821 ECS collision wake (#2656) 2022-03-30 22:57:57 +11:00
Vera Aguilera Puerto
41f64b5c3c Add overload to IntersectRayWithPredicate. (#2650) 2022-03-30 22:57:40 +11:00
Paul Ritter
4003003580 caching trees in pvs (#2652)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2022-03-30 22:57:31 +11:00
Paul Ritter
f49341b53c im a dummy 2022-03-30 11:16:09 +02:00
Leon Friedrich
61d9d9a832 Make the UI System TryGet functions not log failed resolves (#2657) 2022-03-30 16:37:34 +11:00
Paul
c0b7dd053f working on benchmarks workflow 2022-03-30 00:31:51 +02:00
Paul
f642e10acc versionbump to test benchmarks 2022-03-30 00:25:50 +02:00
Paul Ritter
2fb64480db benchmark workflow & storing it in db (#2653) 2022-03-29 21:43:32 +02:00
metalgearsloth
075b5ec203 Kill local comp messages (#2648) 2022-03-29 23:37:58 +11:00
metalgearsloth
21f2fe6b1b Minor spawn opt (#2651) 2022-03-29 12:34:42 +02:00
metalgearsloth
89080ef7c7 Version: 0.8.79 2022-03-29 18:40:32 +11:00
metalgearsloth
f5d36dc9ca Fix physics parenting bug (#2654) 2022-03-29 18:39:49 +11:00
wrexbe
ef87610b36 Map loader saving change (#2638)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2022-03-28 16:56:16 +11:00
mirrorcult
c89f1e4d31 Paramless ctor for joints (#2647)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2022-03-28 16:31:04 +11:00
metalgearsloth
c4805d89e0 Version: 0.8.78 2022-03-27 17:34:43 +11:00
Vera Aguilera Puerto
659ffb028a Dispose of SequencerEvents in MidiRenderer.
Oops!
2022-03-27 00:03:07 +01:00
metalgearsloth
a14c956ccc Nuke EntMapIdChangedMessage (#2621)
Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
2022-03-26 18:14:56 +01:00
metalgearsloth
facb3914a4 Fix joints crash (#2609) 2022-03-26 18:13:56 +01:00
Vera Aguilera Puerto
aab8f7876b Benchmarks for EntityManager (#2578) 2022-03-26 17:55:00 +01:00
Pieter-Jan Briers
1f199ea71c Add ITaskManager.BlockWaitOnTask()
Smugleaf needed this.

Also changed RobustSynchronizationContext to use channels instead of ConcurrentQueue internally.
2022-03-26 17:02:05 +01:00
metalgearsloth
00b557b77a Struct enumerator for anchored entities (#2626) 2022-03-26 12:53:25 +01:00
metalgearsloth
eac536cffe overlay allocs (#2642) 2022-03-26 12:48:11 +01:00
DrSmugleaf
bf75c6f247 Add IEntitySystemManager.GetEntitySystemOrNull (#2643) 2022-03-26 16:35:09 +11:00
metalgearsloth
1518c79291 Struct enumerator for GetAllGrids (#2624) 2022-03-26 03:17:42 +11:00
metalgearsloth
aae2f72d1a PVS pooling 4 (#2640) 2022-03-25 11:51:59 +01:00
Jane Lewis
273aa3d6ea Show player rotation in debug overlay (#2631) 2022-03-25 18:12:53 +11:00
metalgearsloth
756c4510eb Reduce prediction alloc (#2639) 2022-03-25 18:10:31 +11:00
Paul
cd50e89aec v0.8.77 2022-03-24 23:51:55 +01:00
metalgearsloth
25b648b929 Reduce PVS allocs a bunch (again (again)) (#2630) 2022-03-24 23:48:37 +01:00
metalgearsloth
1dbbb08250 Reduce server allocs a bunch (#2625) 2022-03-24 23:39:52 +01:00
DrSmugleaf
5432f7311e Fix keyboard focused being released and grabbed again immediately afterwards (#2634) 2022-03-24 15:25:25 +01:00
Zoldorf
e662802b4c Update build-docfx.yml 2022-03-23 17:32:12 -06:00
Vera Aguilera Puerto
bae2c390bb Improve Color.FromHex exception message.
It now includes the invalid hexcode argument.
Something in content kept getting these exceptions on prod and knowing the invalid argument would be very helpful when debugging these in the future.
2022-03-23 16:00:28 +01:00
Leon Friedrich
7976926eaf fix sequence node Except() (#2610)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2022-03-23 23:34:21 +11:00
metalgearsloth
4aee730753 Version: 0.8.76 2022-03-23 20:48:42 +11:00
metalgearsloth
e87c342aa2 inline robusttree pool (#2628) 2022-03-23 20:47:53 +11:00
Paul
d335d74d8f adds maxpoolsize to treepool 2022-03-22 18:02:00 +01:00
metalgearsloth
bc68b0e3ec Version: 0.8.75 2022-03-22 13:57:31 +11:00
metalgearsloth
b1eadbc58f Fix PVS allocation issues (#2623) 2022-03-22 13:55:57 +11:00
Silver
2d3165a16f remove inheritedmembers div 2022-03-21 18:02:35 -06:00
Zoldorf
d99d25de37 Create build-docfx.yml 2022-03-21 17:22:46 -06:00
Zoldorf
be035ab002 :mistake: 2022-03-21 17:22:08 -06:00
Zoldorf
12c8883eea Update build-test.yml 2022-03-21 15:36:41 -06:00
Zoldorf
758c7c1869 Update build-test.yml 2022-03-21 15:28:12 -06:00
Zoldorf
72ab1f5a1a Update build-test.yml 2022-03-21 15:25:40 -06:00
Zoldorf
6b9c1369c0 Update build-test.yml 2022-03-21 15:22:32 -06:00
Zoldorf
fd1f1dc64a Delete build-docfx.yml 2022-03-21 15:12:24 -06:00
Zoldorf
e211368bc4 Update build-docfx.yml 2022-03-21 15:07:41 -06:00
Zoldorf
39307f916d build-docfx.yml 2022-03-21 15:04:24 -06:00
metalgearsloth
7378cc50a1 Version: 0.8.74 2022-03-21 20:09:16 +11:00
Silver
867b9ad932 Adds Docfx to RobustToolbox 2022-03-20 23:08:59 -06:00
Paul Ritter
03064255f6 Makes Robusttree Children nullable to save allocations (#2570) 2022-03-21 03:02:52 +11:00
Pieter-Jan Briers
c9ccd0b873 Fix file dialogs crashing on macOS 2022-03-20 16:47:20 +01:00
metalgearsloth
650eceea7e Remove IoC + GetComp for every tile intersection (#2617) 2022-03-20 16:54:05 +11:00
DrSmugleaf
452ad5a6e5 Version: 0.8.73 2022-03-19 19:41:22 +01:00
Leon Friedrich
7c292c75d4 Add more information to reflection errors. (#2613) 2022-03-20 00:11:42 +11:00
DrSmugleaf
cab4113697 Add myself to CODEOWNERS 2022-03-19 11:27:54 +01:00
metalgearsloth
f1a5de79b5 Change entitylookup bounds to method (#2611) 2022-03-19 16:14:24 +11:00
metalgearsloth
191e80c175 Add EntityQuery support to filters (#2608) 2022-03-19 15:54:13 +11:00
Leon Friedrich
241bce56c8 Add Resolve() to component queries (#2607) 2022-03-19 15:53:39 +11:00
metalgearsloth
b105639b31 More transform ECS methods (#2606) 2022-03-18 10:32:49 +11:00
ElectroJr
419e63ecd5 Version: 0.8.72 2022-03-16 15:32:19 +13:00
metalgearsloth
46e632bf9d Fix effect overlay crash (#2604) 2022-03-15 18:05:13 +11:00
Leon Friedrich
a8871f4ff4 Add an assert to positional audio (#2602) 2022-03-15 14:54:50 +11:00
Paul
65f28c023d also write + bugfix + ratio 2022-03-15 00:43:40 +01:00
Paul
e506f6aba2 error for invalid customtypeserializer 2022-03-15 00:36:05 +01:00
metalgearsloth
93ae74b5a7 Update nuget dependencies (#2581) 2022-03-14 08:57:20 +01:00
Kara D
7b25fa98ee Version: 0.8.71 2022-03-13 19:30:44 -07:00
mirrorcult
e320b7abb4 Merge pull request #2599 from Sanctuary-Station/staging 2022-03-13 19:26:16 -07:00
Acruid
6b9b56ca83 Grid Components Allocate Grids (#2597)
* Deleting a map is now routed through MapComponent deletion.

* Remove map and grid deletions from map networking, just delete the entity if you want to remove the map.

* Moved the chunkSize property of created grids from the networked MapData to the MapGridComponent state.

* Remove unused IMapManager.DefaultMap property.

* Removed MapCreationTick field from MapManager.MapCollection.

* Removed _maps hashset field from MapManager.

* Removed CreatedMaps array from network MapData.

* MapGrid.ParentMapId is now derived from the bound TransformComponent, and isn't required in the MapGrid ctor.
Removed MapGrid.CreatedTick, it can be found on MapGridComponent.CreationTick.

* Remove a bunch of ApplyGameStatePre code duplication.

* Completely refactored CreateGrid.

* Adds AddComponentUninitialized to the ECS system. This allows you to access a component before it is initialized in a using block.

* Use AddComponentUninitialized to allocate a grid after the component is allocated.

* MapLoader now creates the grids after creating the map entities.

* Chunksize and TileSize properties are now actually read out of the map yaml.
TileSize has a public Setter.

* Minor cleanup.

* Moved grid allocation onto the MapGridComponent.

* Final Cleanup.

* Merge Fail.

* Fixed test, grid was getting deleted because it was empty.

* Remove DeletedChunkDatum from grid networking.

* ApplyMapGridState moved from map manager to the MapGridComponent.
2022-03-13 18:28:59 -07:00
Jezithyr
4d19790b3d This should fix the font caching issue? 2022-03-13 16:51:09 -07:00
Jezithyr
2027863d4c Addressing PR Feedback 2022-03-13 15:59:32 -07:00
Vera Aguilera Puerto
4a4444a1ee Adds MemoryContentRoot. (#2590) 2022-03-13 23:52:34 +01:00
Jezithyr
f10316d384 Fixing missing semicolons 2022-03-13 15:23:45 -07:00
Jezithyr
778be40c86 Condensing code 2022-03-13 14:43:24 -07:00
Jesse Rougeau
2046323c71 Update Robust.Client/UserInterface/UserInterfaceManager.cs
More condensing

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
2022-03-13 13:06:02 -07:00
Jesse Rougeau
71bb5cd58e Update Robust.Client/UserInterface/UserInterfaceManager.cs
Condensing sizing logic

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
2022-03-13 13:05:30 -07:00
Jezithyr
71c6e437fa Removing debug and fixing indentation 2022-03-12 20:36:23 -07:00
Jezithyr
26e1474179 Implemented auto UI Scaling :D
- Implemented autoUI scaling, scaling supports down to 520 by 520 pixel screens(Idk why you'd even have this)
- UI scaling can be adjusted by overriding the window root class
2022-03-12 20:31:13 -07:00
Kara D
89a7459fda Update .NET version for build-test workflow
This should hopefully make it catch CS8983
2022-03-12 19:06:23 -07:00
Paul Ritter
a61adf5631 makes budgets clientside & replicated (#2593) 2022-03-13 00:06:40 +11:00
Leon Friedrich
97db1712f3 Fix grid traversal velocities (#2594)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2022-03-12 23:57:30 +11:00
Paul
ea7012d114 version 0.8.70 2022-03-09 20:58:17 +01:00
Moony
d3eaea5697 Add support for tile variants. (#2577) 2022-03-09 20:56:58 +01:00
metalgearsloth
4ca3fbe4bf Version: 0.8.69 2022-03-10 00:29:08 +11:00
Vera Aguilera Puerto
81fea7595a AttachToGridOrMap checks if the grid/map is being terminated/is deleted. (#2592) 2022-03-10 00:27:18 +11:00
metalgearsloth
2e0806cc1f Version: 0.8.68 2022-03-08 15:48:39 +11:00
metalgearsloth
5325650e92 Fix disappearing grids (#2587)
Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
2022-03-08 12:25:03 +11:00
Acruid
31764d3c2d Mark C# events on MapManager as Obsolete (#2586)
* Obsoleted C# grid events from MapManager.GridCollection. Use the ECS EventBus events instead.

* Obsoleted C# events from MapManager.MapCollection. Use the ECS EventBus events instead.
2022-03-07 15:51:00 -08:00
Leon Friedrich
9df5152610 Decrease error tolerance for angular velocity updates (#2584) 2022-03-06 23:55:56 +11:00
metalgearsloth
c6cd780ab5 Remove funky merge artifact 2022-03-06 18:26:02 +11:00
Vera Aguilera Puerto
023f845c48 SpriteComponent exception specifies failing RSI path, if any. 2022-03-03 21:29:01 +01:00
Vera Aguilera Puerto
5e977da9bc Fix BaseServer.Shutdown bug when not specifying a reason.
If a shutdown was requested before the main loop had been started, it would only work if the reason was non-null. This is because `string? _shutdownReason` essentially acts as a shutdown request flag with its nullability.
2022-03-03 15:41:44 +01:00
metalgearsloth
fa1de04df7 Version: 0.8.67 2022-03-03 21:18:00 +11:00
metalgearsloth
33251222cd EntityLookup as a system (#2573) 2022-03-03 21:17:01 +11:00
Kara D
70c1e8680f Version: 0.8.66 2022-03-01 15:06:19 -07:00
Kara D
0d214769e6 vs2022 fix 2022-03-01 15:05:49 -07:00
Paul
495bbe891a obsoletes serhooks 2022-03-01 21:49:24 +01:00
Rember
5f68f569c3 BaseContainer.Insert() will now reset the entity's rotation after res… (#2576) 2022-03-01 23:23:56 +11:00
Leon Friedrich
52c883cb1f Fix lsmap and lsgrid (#2574) 2022-03-01 20:20:03 +11:00
metalgearsloth
4b20bae597 RobustUnitTest tweaks (#2568) 2022-03-01 13:35:32 +11:00
Leon Friedrich
64ff046ceb loadmap command tweak (#2572)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2022-02-28 21:17:58 +11:00
Kara D
5f2566a97d Version: 0.8.65 2022-02-27 12:59:54 -07:00
Kara D
c3735d1d5e vs2022 moment 2022-02-27 12:59:25 -07:00
metalgearsloth
749e547773 Version: 0.8.64 2022-02-28 00:45:53 +11:00
metalgearsloth
af8a010f43 Optimise PVS cangetcompstate (#2560) 2022-02-28 00:45:16 +11:00
metalgearsloth
a8a29e814f Allow content to override occlusion directions (#2528) 2022-02-27 23:15:45 +11:00
metalgearsloth
c3cb5406f6 Fix culling disabled (#2485)
Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
2022-02-27 22:59:36 +11:00
mirrorcult
73f26d93ca Merge pull request #2565 from ElectroJr/mapping-actions 2022-02-26 20:06:48 -07:00
metalgearsloth
5e86a99060 Version: 0.8.63 2022-02-27 13:00:41 +11:00
Paul Ritter
ce9070b966 changes pvs chunkorder to use a tree-structure, should fix children being sent without parents (#2562)
Co-authored-by: Paul Ritter <ritter.paul1@gmail.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2022-02-27 13:00:10 +11:00
Vera Aguilera Puerto
aa5bcefaf2 Add System.Threading.Monitor (lock keyword) to sandbox whitelist. 2022-02-26 16:50:41 +01:00
ElectroJr
2df267fc28 Merge remote-tracking branch 'upstream/master' into mapping-actions 2022-02-24 04:13:45 +13:00
ElectroJr
306fcce337 remove todo 2022-02-24 04:05:04 +13:00
ElectroJr
3683b66ef8 Allow SpriteSpecifier to load from entity prototype 2022-02-23 23:37:05 +13:00
Acruid
08a52fb892 MapChunk Cleanup (#2555)
* All IPhysShapes now expose a property to get the local AABB.

* Removed IMapChunk. It's internal, we only have 1 implementation in the engine, no need for abstraction, and removing it helps perf.

* Cleaned up issues in MapChunk file.

* Encapsulate _tiles access inside MapChunk.

* Remove IEnumerable<TileRef> from MapChunk.

* Remove CollidesWithChunk

* Move CalcWorldAABB and RegenerateCollision from MapChunk to MapGrid.
Remove MapChunk.GridId.

* Removed MapChunk.GetAllTiles

* Removed the terrible mocked unit tests.

* Moved the GetTileRef functions from MapChunk to MapGrid.

* Add an event raised on MapChunk when a tile is modified.
Completely remove the IMapGrid dependency from MapChunk.

* Fix bug where you cannot change the tile damage of a tile.
2022-02-21 20:49:30 -08:00
Pieter-Jan Briers
fd3c54b373 Seal some classes. 2022-02-21 14:02:34 +01:00
Pieter-Jan Briers
adee05b009 Make client start with non-seekable streams.
Not marking #2439 as fixed yet due to lack of thorough testing.
2022-02-21 11:23:37 +01:00
Pieter-Jan Briers
a66d40eb19 CVar to force ResourceManager to provide seekability for streams.
To help with #2439
2022-02-21 11:23:37 +01:00
metalgearsloth
d065a96e01 Don't serialize grid fixtures (#2477) 2022-02-21 20:15:30 +11:00
Kara D
ef7709aa78 Version: 0.8.62 2022-02-20 19:34:25 -07:00
Paul Ritter
305b330075 bandaid 2022-02-21 02:30:03 +01:00
Acruid
bec4297ce1 Move Map Pause data from MapManager to MapComponent. (#2543)
* Encapsulated existing _pausedMaps access in MapManager.Pause.
Added more unit tests.

* Moved the MapPaused flag from MapManager.Pause to MapComponent.

* Moved the MapPreInit flag from MapManager.Pause to MapComponent.

* Changed visibility so content can't access the flags directly.

* It's not the code that is wrong, it's the tests that are wrong!

* Removed completely obsolete bookkeeping event.
2022-02-20 13:36:45 -08:00
metalgearsloth
18b21b3d60 Version: 0.8.61 2022-02-20 17:44:49 +11:00
mirrorcult
9b263417b9 Merge pull request #2541 from metalgearsloth/2022-02-14_1 2022-02-19 12:33:46 -07:00
Acruid
13da0a7925 Adds command buffer to client, and input command injection (#2538)
Adds the command buffer to the console.
adds wait <ticks> command to console.
Adds the `incmd` command to inject input commands directly into the simulation, bypassing the frontend.
Removes client side permission check for debug builds.
2022-02-18 19:27:38 -08:00
Kara D
bb28db2412 Version: 0.8.60 2022-02-18 15:50:15 -07:00
mirrorcult
489d150ae0 Merge pull request #2558 from PaulRitter/2022_02_18_real_pvs_hours 2022-02-18 15:49:20 -07:00
Paul Ritter
077dbaf933 yo this slaps 2022-02-18 20:49:03 +01:00
Paul Ritter
26f83ac7a2 bored trainride 2022-02-17 15:08:55 +01:00
metalgearsloth
822009b429 Version: 0.8.59 2022-02-17 18:05:50 +11:00
Leon Friedrich
e07a4e516c Add random vector functions to IRobustRandom (#2551) 2022-02-17 18:05:12 +11:00
metalgearsloth
9ec38b5538 Optimise PVS recursion (#2524) 2022-02-17 18:03:14 +11:00
metalgearsloth
97da770978 More physics ECS (#2529) 2022-02-17 17:52:27 +11:00
metalgearsloth
3acbc8235d Funny struct enumerator for xform kids Part 2 (#2492) 2022-02-17 17:19:08 +11:00
Sam Weaver
a32359d5d4 Only include shadow casting lights in the "max lights per scene" count (#2446)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2022-02-17 14:24:36 +11:00
Paul
78fd39aee2 could fix a racecondition? maybe? 2022-02-16 23:55:04 +01:00
Kara D
fca5c14c67 Version: 0.8.58 2022-02-16 15:53:10 -07:00
Kara D
f60e3a14ef Fix VS2022 17.1 issue 2022-02-16 15:49:19 -07:00
Leon Friedrich
503a7032f9 Hopefully fix appearance component mispredict reconciliation (#2460) 2022-02-16 23:26:13 +01:00
metalgearsloth
918bbd3f01 Version: 0.8.57 2022-02-17 01:06:34 +11:00
Leon Friedrich
a1441d5051 Properly support sprite layer transforms. (#2533) 2022-02-17 00:06:14 +11:00
Leon Friedrich
58d6189c40 Allow sprite layer data to be set using PrototypeLayerData. (#2442) 2022-02-16 19:37:40 +11:00
Leon Friedrich
58defed1d2 Fix InteractionOutline 2: Electric boogaloo (#2511)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2022-02-16 18:32:40 +11:00
Paul
27a94384d0 v0.8.56 2022-02-15 18:16:07 +01:00
Paul Ritter
4b8f5815db pvs caching (#2547)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2022-02-15 18:14:44 +01:00
metalgearsloth
d830eef435 Version: 0.8.55 2022-02-15 21:16:35 +11:00
metalgearsloth
e7c4bf7341 Don't use worldbounds for PVS (#2473) 2022-02-15 21:07:41 +11:00
ike709
162e646404 Fix a weird issue with config (#2546)
Co-authored-by: ike709 <ike709@github.com>
2022-02-15 20:57:32 +11:00
metalgearsloth
93049fcacf More transform optimisations (#2519) 2022-02-15 20:43:49 +11:00
metalgearsloth
5b90db4beb inline 2022-02-14 18:30:33 +11:00
metalgearsloth
7692ff736b Some more ECS stuff
- Proxy methods on EntityManager
- Transform system stuff
2022-02-14 18:24:52 +11:00
Kara D
f25ad8ece9 Version: 0.8.54 2022-02-13 20:25:00 -07:00
mirrorcult
1aaf3b9250 Merge pull request #2521 from ElectroJr/public-AppearanceSystem 2022-02-13 20:24:23 -07:00
mirrorcult
11f6cff6df Merge pull request #2539 from Acruid/vv_fix_entName 2022-02-13 20:01:53 -07:00
mirrorcult
c2ea57c95a Merge pull request #2503 from Ygg01/linguini-multiline-error-fix 2022-02-13 20:00:47 -07:00
Ygg01
f61ae5da6b Update Linguini and line info in errors 2022-02-14 01:50:11 +01:00
Acruid
8ae9a5f2da Fix a typo where setting the description of an entity in VV sets the name. 2022-02-13 16:35:51 -08:00
Ygg01
3f7e89e006 Merge remote-tracking branch 'origin/master' into linguini-multiline-error-fix 2022-02-13 23:35:28 +01:00
Ygg01
cee4e4d62e Enable Fluent logs for only .ftl files (#2532) 2022-02-12 21:59:08 +11:00
metalgearsloth
14a3783760 Version: 0.8.53 2022-02-12 15:56:21 +11:00
mirrorcult
b4607f7b1f Draw effects below FOV (#2534) 2022-02-12 15:54:50 +11:00
Acruid
5a28c16cae Map Pausing Fixes (#2520) 2022-02-12 15:54:03 +11:00
ElectroJr
9e8bf861ea Merge remote-tracking branch 'upstream/master' into public-AppearanceSystem 2022-02-11 20:43:19 +13:00
ElectroJr
b540f04a7a Version: 0.8.52 2022-02-10 21:46:08 +13:00
Leon Friedrich
bcaa7001ad Hopefully fix container occlusion bug? (#2464) 2022-02-10 09:29:26 +01:00
metalgearsloth
3f0fba7b4e Version: 0.8.51 2022-02-10 12:57:00 +11:00
metalgearsloth
d7d7a53045 Raise appearance event by ref 2022-02-10 12:56:14 +11:00
metalgearsloth
40daba9adf Version: 0.8.50 2022-02-10 12:53:26 +11:00
mirrorcult
5665f8eb1c Abstract VisualizerSystem (#2522) 2022-02-10 12:52:42 +11:00
metalgearsloth
8f0d562f3e Version: 0.8.49 2022-02-10 11:21:29 +11:00
ike709
f3950e940e Re-adds UpdateEntityTree() to EntityLookup's interface (#2525) 2022-02-10 11:15:09 +11:00
Leon Friedrich
3fdca65cc9 Make occluder use try get map (#2516) 2022-02-10 01:40:11 +11:00
ElectroJr
4cfb9210d0 Make AppearanceSystem public 2022-02-09 04:55:31 +13:00
ike709
23d0b8a555 Expose LastTick on IGameTiming (#2518) 2022-02-08 14:02:36 +11:00
mirrorcult
452b03d5a6 Merge pull request #2513 from metalgearsloth/2022-02-07_EnsureCompOut 2022-02-07 13:41:59 -07:00
metalgearsloth
c8f2dab381 Don't crash on VV edit for angles (#2517) 2022-02-08 02:58:55 +11:00
metalgearsloth
7409df07f8 Merge remote-tracking branch 'upstream/master' into 2022-02-07_EnsureCompOut 2022-02-07 19:55:45 +11:00
metalgearsloth
973406b91d Cleanup contact code a lot (#2480) 2022-02-07 13:10:58 +11:00
metalgearsloth
2e646fe2b6 EntityQueryEnumerator "fix" (#2501) 2022-02-07 12:06:50 +11:00
mirrorcult
6b902d22d4 Merge pull request #2504 from metalgearsloth/2022-02-03_appearance-events
Appearance data event
2022-02-06 11:23:01 -07:00
metalgearsloth
83e6d52e58 Version: 0.8.47 2022-02-07 02:56:24 +11:00
metalgearsloth
025fdcd0b3 GetHardAABB (#2514) 2022-02-07 02:10:02 +11:00
metalgearsloth
fe3ace92bd Another helper 2022-02-07 02:04:57 +11:00
metalgearsloth
317070f167 Some animation helpers for cargo telepad too 2022-02-07 02:00:31 +11:00
metalgearsloth
3524363ad4 fix build 2022-02-07 01:44:27 +11:00
metalgearsloth
90287dbb09 Merge remote-tracking branch 'upstream/master' into 2022-02-03_appearance-events
# Conflicts:
#	Robust.Shared/GameObjects/Components/Appearance/AppearanceComponent.cs
2022-02-07 01:42:53 +11:00
metalgearsloth
9a2f35f2d3 Also pass comp 2022-02-07 01:42:32 +11:00
metalgearsloth
3f10dbe770 EnsureComponent<T> with out variable
Useful for EnsureComponent<T>(uid, out var comp) && comp.Thing
2022-02-07 00:07:01 +11:00
metalgearsloth
8fcba93ada Don't draw 0-mass non-hard fixtures as invalid (#2499) 2022-02-06 19:42:47 +11:00
ElectroJr
35366b5bc1 Version: 0.8.46 2022-02-06 15:18:56 +13:00
mirrorcult
d8bf31ecc4 Merge pull request #2510 from ElectroJr/fix-sprite-bug 2022-02-05 15:23:25 -07:00
Pieter-Jan Briers
de4d255841 Analyzer to enforce classes to be either [Virtual], abstract, or sealed. (#2469)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2022-02-05 19:31:58 +01:00
Leon Friedrich
ec768c563f Add spin command (#2484) 2022-02-05 12:38:02 +11:00
metalgearsloth
2114d2bc67 Funny struct enumerator for xform kids (#2487) 2022-02-05 12:32:13 +11:00
ElectroJr
43478d0e45 avoid unnecessary RoundToCardinal calls 2022-02-05 14:27:31 +13:00
Leon Friedrich
561699b26e Replace EntityDirtyEvent with C# event. (#2495) 2022-02-05 12:23:51 +11:00
ElectroJr
460923e54d fix sprite bug 2022-02-05 14:10:28 +13:00
Kara D
c299104f0c Version: 0.8.45 2022-02-04 14:35:35 -07:00
Kara D
224bebeeb5 ok then 2022-02-04 14:35:15 -07:00
Kara D
52c8e8ecdf Version: 0.8.44 2022-02-04 14:20:48 -07:00
mirrorcult
ac636b2703 Merge pull request #2441 from metalgearsloth/2022-01-20_more-caching 2022-02-04 14:13:26 -07:00
mirrorcult
a892f9ac99 Merge pull request #2506 from metalgearsloth/2022-02-04_xform-children 2022-02-04 14:13:18 -07:00
mirrorcult
2ebee8f40c Merge pull request #2508 from metalgearsloth/2022-02-04_powa 2022-02-04 14:13:10 -07:00
mirrorcult
43741dc5fc Merge pull request #2490 from metalgearsloth/2022-02-01_game-state 2022-02-04 14:12:56 -07:00
metalgearsloth
da9467b678 Reduce FindGridsIntersecting allocs 2022-02-04 17:44:44 +11:00
Leon Friedrich
8f24a7b4fc Reduce ContainerHelper IoCManager resolves (#2498) 2022-02-04 12:51:29 +11:00
metalgearsloth
ff48959e97 Merge remote-tracking branch 'upstream/master' into 2022-01-20_more-caching 2022-02-04 12:46:01 +11:00
metalgearsloth
09e648d086 Version: 0.8.43 2022-02-04 12:43:43 +11:00
metalgearsloth
1d1db2e109 Also that sneaky pvs one 2022-02-04 12:40:40 +11:00
metalgearsloth
6a902286cd Merge remote-tracking branch 'upstream/master' into 2022-01-20_more-caching 2022-02-04 12:38:32 +11:00
metalgearsloth
933724e4ee Nuke CompGetStateAttempt allocs (#2497) 2022-02-04 12:35:57 +11:00
metalgearsloth
53034e6f05 Replace xform children sortedset with hashset 2022-02-04 12:27:51 +11:00
Ygg01
681f77a796 Change newline append 2022-02-04 02:01:52 +01:00
metalgearsloth
6a31c5649c Tweak 2022-02-03 18:03:56 +11:00
metalgearsloth
7bd90578dc Appearance data event
We agreed that AppearanceVisualizers should probably be deprecated in favour of just using a system instead.
2022-02-03 18:01:31 +11:00
Ygg01
2a7f1cbf48 Ensure that tests work regardless of platform 2022-02-03 04:06:53 +01:00
metalgearsloth
c076be95a6 Version: 0.8.42 2022-02-03 13:26:13 +11:00
metalgearsloth
7b732dd68a Remove unnecessary resolves from MapLoader (#2462) 2022-02-03 13:25:22 +11:00
metalgearsloth
3e34b1414e The end of IMapInit (#2479) 2022-02-03 13:15:17 +11:00
Acruid
8456cd90d1 Move MapGrid data from MapManager to MapGridComponent (#2430) 2022-02-03 13:15:06 +11:00
Ygg01
c4e63cfdc7 Fix multiline errors, add some tests 2022-02-03 01:43:45 +01:00
Pieter-Jan Briers
d716e1ff62 Fix EstPixelSize for Rg32f.
This function literally isn't used but that won't stop me from making this commit.
2022-02-02 21:46:42 +01:00
metalgearsloth
8e9acc9191 Reduce broadphase allocs a l'il bit (#2493) 2022-02-03 00:52:04 +11:00
metalgearsloth
773a068b7d Merge remote-tracking branch 'upstream/master' into 2022-02-01_game-state 2022-02-02 22:13:17 +11:00
metalgearsloth
b37bfff155 Remove string allocs from client prediction (#2494) 2022-02-02 21:59:40 +11:00
Leon Friedrich
a14cce222b Misc physics/shutdown related optimizations (#2496) 2022-02-02 18:12:53 +11:00
Leon Friedrich
c077e09436 Add explicit transform matrices (#2483) 2022-02-02 10:03:45 +11:00
Leon Friedrich
213955566b remove GetBus() (#2491) 2022-02-02 10:03:03 +11:00
metalgearsloth
b98cd3e6e1 Reduce batch for lowerpop I guess 2022-02-01 23:11:35 +11:00
metalgearsloth
987c8e8229 Reduce gamestate allocs
Parallel.ForEach has no right to be that expensive.
2022-02-01 23:11:05 +11:00
metalgearsloth
fcbb97ec55 Fix edge collisions (#2482) 2022-02-01 15:28:12 +11:00
Pieter-Jan Briers
c1ac7aebdb Version: 0.8.41 2022-01-31 17:37:35 +01:00
Pieter-Jan Briers
e4b0d1a03c Hotfix servers not working due to auto pause. 2022-01-31 17:37:19 +01:00
Leon Friedrich
f13f9dc5cd Make OffsetRsiDir() and GetDir() public (#2434) 2022-01-31 19:22:56 +11:00
metalgearsloth
1f6170c000 Merge remote-tracking branch 'upstream/master' into 2022-01-20_more-caching 2022-01-31 18:21:23 +11:00
metalgearsloth
53c7ec8ddc Version: 0.8.40 2022-01-31 17:55:53 +11:00
metalgearsloth
e438e53d36 Silly caching 2022-01-31 17:50:30 +11:00
metalgearsloth
792608f0d0 Merge remote-tracking branch 'upstream/master' into 2022-01-20_more-caching 2022-01-31 17:42:09 +11:00
metalgearsloth
7b5678fd0f woops 2022-01-31 17:34:49 +11:00
metalgearsloth
88c328a636 Smol entityquery change 2022-01-31 17:33:21 +11:00
metalgearsloth
f9573530a8 Nuke entitylookup to get it merged 2022-01-31 17:30:53 +11:00
Leon Friedrich
c1df7dcca7 Move some static helpers to container system (#2470) 2022-01-31 17:21:09 +11:00
Pieter-Jan Briers
f141a0033e Automatically pause server if no players connected. (#2465) 2022-01-31 17:20:26 +11:00
metalgearsloth
227d047584 Version: 0.8.39 2022-01-31 16:25:52 +11:00
metalgearsloth
73b73cd9da Fix InvWorldMatrix helper (#2478) 2022-01-31 16:20:21 +11:00
Pieter-Jan Briers
66be082bdb Fix display.angle_force_es2 defaulting to true. 2022-01-30 20:21:35 +01:00
Pieter-Jan Briers
ac43cf0de1 Fix GLES2 support. 2022-01-30 20:20:23 +01:00
Pieter-Jan Briers
fb41601d9f CVar to force a GLES2 context with GLContextAngle. 2022-01-30 18:06:59 +01:00
metalgearsloth
f35dda3fb3 Version: 0.8.38 2022-01-31 02:09:20 +11:00
metalgearsloth
7ee14f6f4f Remove some unnecessary writer resolves (#2475) 2022-01-31 00:54:30 +11:00
metalgearsloth
97920b42ee Fix FindGridContacts (#2474) 2022-01-30 18:32:13 +11:00
metalgearsloth
8ace0ec254 Fix entity map change crash (#2461) 2022-01-30 17:44:07 +11:00
metalgearsloth
a3606f1098 Fix grid fixture deserialization (#2472) 2022-01-30 17:09:22 +11:00
metalgearsloth
616d379902 Version: 0.8.37 2022-01-29 16:18:05 +11:00
metalgearsloth
a27f475715 Proxy method for entitymanager.dirty(comp) (#2467) 2022-01-29 16:16:32 +11:00
Leon Friedrich
6ee76e8f46 Fix point light add/remove (#2466) 2022-01-29 16:05:23 +11:00
metalgearsloth
891c30c9be Fix maplinearvelocity? (#2317) 2022-01-27 18:01:20 +11:00
metalgearsloth
9757a4c3b6 Fix broadphase for rotation events (#2463) 2022-01-27 17:36:17 +11:00
Pieter-Jan Briers
5be2f610cd Fix thread pool queue histogram having buckets divided by 1000. 2022-01-27 01:55:33 +01:00
metalgearsloth
35324e0853 Version: 0.8.36 2022-01-26 17:56:54 +11:00
metalgearsloth
ac753cdb93 Revert "Reduce component / resolve calls in transformcomp (#2450)" (#2459) 2022-01-26 17:56:30 +11:00
metalgearsloth
3edd39f0eb Version: 0.8.35 2022-01-26 16:10:45 +11:00
metalgearsloth
8f790c28be Deprecate component.Paused (#2449) 2022-01-26 16:10:25 +11:00
metalgearsloth
c253afaf8e Version: 0.8.34 2022-01-26 15:15:19 +11:00
metalgearsloth
a6ac1dced0 Fix more physics ordering bugs (#2458) 2022-01-26 14:59:31 +11:00
wrexbe
d1e0f2cd94 Automatic Component Names (Alternate ending) (#2389) 2022-01-25 14:10:08 +01:00
metalgearsloth
af861d289a Remove some unnecessary resolves (#2452) 2022-01-25 14:01:44 +01:00
metalgearsloth
753f3f8c0f Add dirty method to entmanager for components (#2453) 2022-01-25 14:00:03 +01:00
Leon Friedrich
5c2a5741ee Prevent CreateAudioSource() from erroring/crashing in debug when hitting source limit (#2448) 2022-01-25 13:35:01 +01:00
metalgearsloth
26941a2013 Reduce component / resolve calls in transformcomp (#2450) 2022-01-25 13:32:28 +01:00
Moony
fad4c20da2 VV for entity systems. (#2447) 2022-01-25 13:29:17 +01:00
Pieter-Jan Briers
2b79ef301d Add prometheus-net.DotNetRuntime for more detailed runtime metrics like GC pause times. (#2457) 2022-01-25 13:23:55 +01:00
metalgearsloth
014491e674 Fix joints crash (#2454) 2022-01-25 12:39:31 +11:00
metalgearsloth
2e70cd4f2e Add HasComp to EntityQuery struct (#2451) 2022-01-24 18:48:45 +11:00
metalgearsloth
689e1baa12 Version: 0.8.33 2022-01-24 11:58:16 +11:00
metalgearsloth
c34e84378a Fix grid deletion (#2445) 2022-01-24 11:55:37 +11:00
Kara D
9a44becc73 Version: 0.8.32 2022-01-21 20:08:35 -07:00
mirrorcult
d324d9fcf3 Merge pull request #2429 from metalgearsloth/2022-01-17_grid-iter 2022-01-21 20:04:35 -07:00
Pieter-Jan Briers
74cd48401c Engine changes for launcher ContentDB/delta updates. 2022-01-21 17:24:07 +01:00
metalgearsloth
43081c57e7 Add acruid's funny entity query (#2440) 2022-01-21 10:45:10 +11:00
Leon Friedrich
b80a51d03f Raise an attempt-event when receiving client BUI messages. (#2414) 2022-01-20 02:42:48 +11:00
mirrorcult
e90d5e4977 Merge pull request #2433 from wrexbe/warningfixes 2022-01-18 15:24:14 -07:00
mirrorcult
979034906a Merge pull request #2417 from weaversam8/shutdown-pre-mainloop 2022-01-18 15:23:46 -07:00
Pieter-Jan Briers
9e4fd2905b Release DXGI Factory in VramCommand 2022-01-18 18:16:02 +01:00
Leon Friedrich
914c269411 return -> continue (#2437) 2022-01-18 23:41:55 +11:00
metalgearsloth
2cacc4cd49 Version: 0.8.31 2022-01-18 19:02:43 +11:00
Leon Friedrich
3024094584 Add IsQueuedForDeletion (#2421)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2022-01-18 19:02:10 +11:00
Leon Friedrich
4c66451324 Stop updating entity tree on pre-delete un-anchor event (#2422) 2022-01-18 17:49:31 +11:00
Leon Friedrich
7e7d808c90 Sprite offset rendering fix (#2432) 2022-01-18 17:45:49 +11:00
wrexbe
0538e89948 Fixes warnings 2022-01-17 19:13:54 -08:00
Sam Weaver
6376f7c35d Add System.Text.Json.JsonPropertyNameAttribute to sandbox allowlist (#2435) 2022-01-18 03:14:10 +01:00
metalgearsloth
37721f2327 Align rotation 2022-01-17 15:26:39 +11:00
metalgearsloth
b0d2404644 sussy init 2022-01-17 15:09:33 +11:00
metalgearsloth
5f76cb4819 Tests working let's go 2022-01-17 15:05:36 +11:00
metalgearsloth
427a54fc67 Fix tests I guess 2022-01-17 14:53:51 +11:00
metalgearsloth
1cd1fb905d Comment 2022-01-17 14:40:12 +11:00
metalgearsloth
33333f87d2 Nuke broadphase caches
Scales really poorly at high grid counts and better to just lazy load.
2022-01-17 14:26:15 +11:00
metalgearsloth
4e5b8ec1e2 Fix early move / rotate crash 2022-01-17 13:40:54 +11:00
metalgearsloth
007feb76b7 Optimise broadphase movebuffer 2022-01-17 13:27:16 +11:00
metalgearsloth
d34dcb81fb ! 2022-01-17 12:47:16 +11:00
metalgearsloth
8abb366903 aaaaaaaaaaaAAAAAAAAAAAAAAA 2022-01-17 12:43:31 +11:00
metalgearsloth
3e7ba7ca28 Just work please 2022-01-17 11:55:19 +11:00
Pieter-Jan Briers
14d52a9da9 Update ManagedHttpListener. This gives it IPv6 support 2022-01-16 16:32:46 +01:00
Pieter-Jan Briers
847f8d1fee Document most engine CVars.c 2022-01-16 15:08:10 +01:00
Pieter-Jan Briers
0c8d7adf37 Fix wrong comment in cvars 2022-01-16 14:12:23 +01:00
Leon Friedrich
d68d803709 Prevent disembowelling on tile removal. (#2418) 2022-01-16 18:51:04 +11:00
metalgearsloth
13ef514d3e Version: 0.8.30 2022-01-16 18:47:43 +11:00
Vera Aguilera Puerto
e20cd248a0 Makes VirtualController an abstract class inheriting EntitySystem (#2424) 2022-01-16 18:46:48 +11:00
mirrorcult
b8a3bda31d Don't dirty entities when NetSyncEnabled is false (#2426) 2022-01-15 19:31:05 +01:00
ElectroJr
001493d984 Version: 0.8.29 2022-01-15 15:21:54 +13:00
Paul Ritter
013a3e3e8c removes componentdependencies (#2423) 2022-01-15 13:06:29 +11:00
Vera Aguilera Puerto
4c2d984835 Fix singleplayer clients being in "prediction" always, breaking physics. 2022-01-14 19:07:16 +01:00
Paul Ritter
21bb0f15e0 i fudged it 2022-01-12 23:03:54 +01:00
Paul Ritter
8d5162ef8d forgot some 2022-01-12 22:49:10 +01:00
Paul Ritter
257913ac0e add myself to codeowners 2022-01-12 22:43:11 +01:00
metalgearsloth
c90dfccbf4 Version: 0.8.28 2022-01-12 23:15:37 +11:00
metalgearsloth
9c7dc8876f Deduplicate most of loadbp and loadmap (#2409) 2022-01-12 23:14:19 +11:00
metalgearsloth
fc8cbdf01f Entity lookup fixes (#2407) 2022-01-12 14:45:01 +11:00
Sam Weaver
5af4bfa912 Merge branch 'space-wizards:master' into shutdown-pre-mainloop 2022-01-11 22:16:33 -05:00
Sam Weaver
0c5a47ff9d Allow the server to shutdown before the main loop has started 2022-01-11 19:34:41 -05:00
metalgearsloth
b4b4a3864f Version: 0.8.27 2022-01-12 00:43:33 +11:00
metalgearsloth
dca8561881 Remove some unnecessary physics resolves and events (#2404) 2022-01-12 00:35:32 +11:00
metalgearsloth
ee58b5299d Joint serialization (#2410) 2022-01-12 00:31:39 +11:00
Leon Friedrich
7868b12279 Remove unused grid-tile-lookup related code (#2416) 2022-01-11 18:56:09 +11:00
Leon Friedrich
42e91e8c4d Deparent entities on grid tile delete (#2415) 2022-01-11 18:55:23 +11:00
Leon Friedrich
28c9326305 Move popup above modal in RootControl (#2412) 2022-01-10 16:35:04 +01:00
metalgearsloth
40b8772980 Prettify contact deletions (#2413) 2022-01-10 16:34:50 +01:00
Pieter-Jan Briers
b6a548629a More async stuff for StatusHost. 2022-01-10 16:34:16 +01:00
Vera Aguilera Puerto
291a37924d Add a method to unregister "manual" commands from IConsoleHost. (#2403) 2022-01-10 12:51:13 +01:00
Vera Aguilera Puerto
0b5eccd60a Expose ConsoleHost.RegisteredCommand and its callback. (#2394) 2022-01-10 12:50:55 +01:00
Vera Aguilera Puerto
866a324922 ServerConsoleHost logs errors as errors, not warnings. 2022-01-10 12:50:23 +01:00
Pieter-Jan Briers
baf48a8dc1 Update ManagedHttpListener submodule 2022-01-10 11:55:08 +01:00
Pieter-Jan Briers
a85b2dd43c Version: 0.8.26 2022-01-10 01:36:12 +01:00
Pieter-Jan Briers
43059b3985 Remove usages of Newtonsoft.Json from StatusHost (#2405) 2022-01-10 01:36:00 +01:00
Vera Aguilera Puerto
4d6183d6af Add new entries to CODEOWNERS for myself. 2022-01-09 19:26:22 +01:00
metalgearsloth
79f87f03ce Version: 0.8.25 2022-01-09 23:46:35 +11:00
metalgearsloth
01ede29fc4 Nuke gridtilelookup (#2399) 2022-01-09 23:45:48 +11:00
Pieter-Jan Briers
fb54d0df1c Remove usages of Newtonsoft.Json outside StatusHost 2022-01-09 11:53:06 +01:00
E F R
5b65495fbc Controls/SplitContainer: Allow Content to change the SplitState (#2392) 2022-01-09 10:26:24 +01:00
Pieter-Jan Briers
cec3a8c1c2 Remove unnecessary warning mute from Clyde. 2022-01-09 10:21:00 +01:00
Leon Friedrich
8bd0b459b9 Make entity manager proxy methods protected (#2402) 2022-01-07 11:21:28 +01:00
Leon Friedrich
7da50516f9 Fix ghost-pointing visibility (#2401) 2022-01-07 17:08:19 +11:00
Kara D
6cbb2135b8 Version: 0.8.24 2022-01-04 17:51:39 -07:00
mirrorcult
66dbc05022 Merge pull request #2390 from wrexbe/tilesid 2022-01-04 17:48:50 -07:00
Paul
18cc385c70 version bump & changes to itemlist 2022-01-04 21:11:47 +01:00
Matz05
384f672eec Engine changes for more server-pushed lighting variables (#2367)
* Engine changes for more server-pushed lighting variables, but apparently this is a deprecated way of doing things anyway

* Removed two unecessary uses of virtual
2022-01-05 02:57:49 +11:00
Paul
f49a29cfb3 smol itemlist change & version bump 2022-01-03 04:12:04 +01:00
Wrexbe
e8b70877cf Tiles Name->Id DisplayName->Name 2022-01-01 20:52:59 -08:00
Paul Ritter
9b084ea6a9 bandaid fix pvs grid crash for or14 2022-01-01 23:29:14 +01:00
ShadowCommander
51f2fc4259 TeleportTo upgrades (#2384)
* Clean up TeleportTo

* Change TeleportTo to allow teleporting to EntitiyUid

* Rename TeleportToPlayerCommand to TeleportToCommand

* Move duplicate parsing code to TryGetTransformFromUidOrUsername
2022-01-01 17:14:17 +01:00
Pieter-Jan Briers
bb27482e9f Fix release/debug serializer mismatch. 2021-12-31 10:06:32 +01:00
Pieter-Jan Briers
75912896c9 Version: 0.8.21 2021-12-31 09:37:30 +01:00
Pieter-Jan Briers
6e0632ae1b Explicitly block P/Invoke methods in AssemblyTypeChecker 2021-12-31 09:35:34 +01:00
Pieter-Jan Briers
7c90da0402 Correctly load mismatching versions from Robust modules. 2021-12-31 09:35:34 +01:00
Pieter-Jan Briers
313a3eb7f2 Minor GLContextEgl cleanup:
* Compile it in by default but leave display.egl=false by default.
* Minor code cleanup/TerraFX usage.
2021-12-31 09:35:34 +01:00
metalgearsloth
cb054f0761 Avoid touching physicscomp when removed from container (#2379) 2021-12-31 08:36:08 +01:00
Paul Ritter
579b21716d version 0.8.20 2021-12-30 22:55:06 +01:00
Paul Ritter
3ffdc8cc2d changes needed for inventory refactor (#2350)
* get that crap outta here

* reenables tests

* helper

* removes serverside itemcomp & misc fixes

* oopsie

* fixes tests

* motivation low

* container stuff

* resolves optional

* fix some tests

* fixes

Co-authored-by: Paul Ritter <ritter.paul1@gmail.com>
2021-12-30 22:54:00 +01:00
Pieter-Jan Briers
e68af15b40 Don't skip viewer entity in PVS for streaming
This causes problems on the client.
2021-12-30 21:00:52 +01:00
Pieter-Jan Briers
8e5fafaf05 Version: 0.8.19 2021-12-30 18:20:38 +01:00
Pieter-Jan Briers
95f9418e56 Remove some garbage from .gitignore
A different time
2021-12-30 18:12:35 +01:00
Pieter-Jan Briers
23af814ebc Remove Resources/.gitignore
:salute:
2021-12-30 18:10:13 +01:00
Pieter-Jan Briers
ae7dda9dab Update NetSerializer 2021-12-30 18:04:59 +01:00
Pieter-Jan Briers
c5899944a2 Uncomment stuff in manifest so it's not empty and won't break the launcher.
Whoops.
2021-12-30 17:48:22 +01:00
Pieter-Jan Briers
c0e0f65ebe Unhardcode Lidgren App Identifier.
Default value is now RobustToolbox, not SS14_NetTag
2021-12-30 17:32:49 +01:00
Pieter-Jan Briers
3bdce98964 Change X11 instance/class names to RobustToolbox 2021-12-30 17:24:25 +01:00
Pieter-Jan Briers
478ab3bec4 Remove Space Station 14 reference from a MessageBox 2021-12-30 17:23:29 +01:00
Pieter-Jan Briers
ae77ee3df4 Remove SS14 logo/icon/splash/window title branding. Make it all configurable with manifest.yml 2021-12-30 17:22:21 +01:00
Pieter-Jan Briers
86e4a558c5 F3 menu moves out of the way when console opens 2021-12-30 16:49:36 +01:00
metalgearsloth
15c1e8f7bf Run appearancevisualizers on dummy entities again (#2380) 2021-12-30 20:41:55 +11:00
metalgearsloth
f38770dbb5 Poly-edge collision optimisations (#2366) 2021-12-30 20:17:55 +11:00
Pieter-Jan Briers
75d37f8309 Version: 0.8.18 2021-12-30 03:10:50 +01:00
Pieter-Jan Briers
ed641c8cc8 Properly dispose debug console history writer so it flushes properly. 2021-12-30 03:10:01 +01:00
Pieter-Jan Briers
069ebbc8d0 Make disabled prediction work again.
Simulation input and Update() does not happen when prediction is disabled. Both of these can be re-opted in on a per-handler/system basis with a bool flag. Stuff like physics opts out of this now.
2021-12-30 03:03:39 +01:00
Pieter-Jan Briers
720f33a12a Updated webview packaging script 2021-12-29 20:27:50 +01:00
Leon Friedrich
08f1cfbc79 add CanInsertIfEmpty() (#2382)
* add CanInsertIfEmpty

* make CanInsert call CanInsertIfEmpty
2021-12-29 20:27:01 +01:00
Pieter-Jan Briers
9896697919 Viewports have configurable clear color, default to black. 2021-12-29 20:11:08 +01:00
metalgearsloth
057d50b60b BQL optimisations (#2315) 2021-12-29 14:04:19 +11:00
Pieter-Jan Briers
e3dc446e9e Version: 0.8.17 2021-12-28 22:27:33 +01:00
Pieter-Jan Briers
c529f756af Make default visibility mask if no EyeComponent 1 in PVS.
This fixes OpenDream.

@metalgearsloth
2021-12-28 22:27:20 +01:00
metalgearsloth
c07eaecacb Version: 0.8.16 2021-12-29 05:12:05 +11:00
metalgearsloth
ddc03a1d62 Cache vismask on each entity (#2312) 2021-12-29 05:11:53 +11:00
Pieter-Jan Briers
ca59cff07f WiP launcher CEF loading. (#2376) 2021-12-28 17:37:54 +01:00
Pieter-Jan Briers
df4ddfdf25 Unhardcode ACZ stuff to be more flexible (and work on master SS14). 2021-12-28 16:17:21 +01:00
Pieter-Jan Briers
c667a326a3 Fix ACZ creating invalid zip paths on Windows.
Zip files always use / path separators.
2021-12-28 16:17:21 +01:00
Vera Aguilera Puerto
0099442852 Version 0.8.15 2021-12-27 18:48:46 +01:00
Vera Aguilera Puerto
eecb104cc5 Adds help method to C# scripting. (#2368) 2021-12-27 18:47:16 +01:00
Vera Aguilera Puerto
a54283e637 ByRefEvent attribute for events. (#2375) 2021-12-27 17:59:32 +01:00
Vera Aguilera Puerto
ed06107a9f Proxy method AddComp actually returns the added component now. 2021-12-27 16:43:54 +01:00
Vera Aguilera Puerto
2d833daa57 Fix EntitySpawnWindow Erase Mode not being toggled off correctly.
It would always get toggled back on after Clear cleared the erase mode status...
2021-12-27 16:40:52 +01:00
metalgearsloth
67dd0a9433 Make gridfixture_test use fixturescomp (#2370) 2021-12-25 19:05:16 +01:00
Vera Aguilera Puerto
fcc16d67f7 Remove Eye Lerping from engine. (#2371) 2021-12-25 19:05:07 +01:00
metalgearsloth
394f51f70d Version: 0.8.14 2021-12-25 21:42:26 +11:00
metalgearsloth
538627328e Don't wake destroyed contact bodies if they can't collide (#2369)
e.g. if they're getting yeeted to nullspace or inserted into a container.
2021-12-25 11:26:47 +01:00
Vera Aguilera Puerto
b5a21ccc4d Version 0.8.13 2021-12-23 13:06:39 +01:00
metalgearsloth
2d331ff786 Broadphase fix take 2 (#2327)
Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
2021-12-23 12:20:59 +01:00
metalgearsloth
9d9ad15274 Entity deletion stuff (#2365) 2021-12-23 12:20:44 +01:00
Pieter-Jan Briers
114ec2e493 This is literally me when you need to google just to delete a submodule 2021-12-23 12:10:51 +01:00
Pieter-Jan Briers
2fb45da0d7 Switch to NuGet packages for Linguini 2021-12-23 10:42:19 +01:00
metalgearsloth
54a693dfa7 Fix attached effects 2021-12-23 15:50:19 +11:00
Pieter-Jan Briers
4be572ba58 whoops 2021-12-23 01:25:42 +01:00
Pieter-Jan Briers
e22d6ea65c Use float.IsFinite in some appropriate places previously using IsNan || IsInfinity 2021-12-23 01:21:57 +01:00
Pieter-Jan Briers
baf86b5b83 Get rid of ComponentTypeCache stuff.
It didn't really work.
2021-12-23 01:15:25 +01:00
Pieter-Jan Briers
e56c77319c Fix tests breaking due to component index stuff. 2021-12-23 01:12:56 +01:00
Pieter-Jan Briers
a170dbd716 Use BitOperations for MathHelper.NextPowerOfTwo instead. 2021-12-23 01:12:02 +01:00
Pieter-Jan Briers
b821833437 Fix compiler warning in GLContextAngle.cs 2021-12-22 20:50:53 +01:00
Pieter-Jan Briers
1bb9b8cae3 Fix launchauth command 2021-12-22 20:46:57 +01:00
metalgearsloth
1e32eb135d Version: 0.8.12 2021-12-22 10:30:23 +11:00
Pieter-Jan Briers
b695ce581e Replace Win32 interop sigs with TerraFX.
We include TerraFX in builds now so this shouldn't be a problem.
2021-12-21 17:29:06 +01:00
Pieter-Jan Briers
8138fc5fa2 Remove component get caching from PVS.
This was literally slower than simply doing it directly.
2021-12-21 17:16:58 +01:00
Pieter-Jan Briers
0b2693cb98 Optimize TryGetComponent & friends with array type -> dict lookups. 2021-12-21 17:16:08 +01:00
Vera Aguilera Puerto
3d959c98ed Version 0.8.11 2021-12-20 17:17:03 +01:00
Vera Aguilera Puerto
0ccee0b496 Fix engine status host not reporting hostname correctly.
The hostname wasn't being cached at server start.
2021-12-20 17:16:13 +01:00
Paul
b7b2a0ab5e quickly put that back 2021-12-20 15:33:50 +01:00
metalgearsloth
375402c455 Optimise DetachParentToNull for grid deletion (#2362) 2021-12-20 13:59:50 +01:00
Paul
03505da382 fixes a bunch of warnings 2021-12-20 13:59:01 +01:00
metalgearsloth
f56219746b Allow tight grid fits (#2309) 2021-12-20 13:58:33 +01:00
metalgearsloth
116c3e491c Use velocities and positions by ref in constraints solver (#2360) 2021-12-20 13:57:32 +01:00
Vera Aguilera Puerto
e94c2f039c Some fixes for map init. (#2355) 2021-12-20 13:57:26 +01:00
Pieter-Jan Briers
2fd52ef3eb Add automatic hub advertisement. 2021-12-20 13:56:17 +01:00
Paul
29659536aa version 0.8.10 2021-12-20 12:39:19 +01:00
Paul Ritter
338a2831ee Revert Rich Text (#2363) 2021-12-20 12:38:35 +01:00
metalgearsloth
c64c1aca5b Fix effect rotation (#2357) 2021-12-19 17:44:26 +11:00
Vera Aguilera Puerto
0dd72f4434 Extra MIDI sanity checks.
Makes sure the tracking entity is valid before setting source velocity based on global linear velocity.
2021-12-18 00:31:23 +01:00
Vera Aguilera Puerto
891d1da208 Version 0.8.9 2021-12-17 23:41:02 +01:00
E F R
f8e903c422 Rich Text Fixes The 3rd (#2351) 2021-12-17 23:39:46 +01:00
Vera Aguilera Puerto
b373824cf5 Various MIDI improvements and fixes.
- Fix bug where MIDI renderers in other maps than the current map in IEyeManager would be silenced forever.
- Tracking an entity now sets the TrackingCoordinates to the entity's coordinates.
- MIDI renderers not in your same IEyeManager.CurrentMap or that have invalid coordinates will have their occlusion set to the max value, essentially becoming silenced. I feel like this is a much better solution than changing the volume, as things should be able to call Source.SetVolume without it being changed by positional audio shenanigans.
2021-12-17 23:38:14 +01:00
Paul
6c3c51e816 fix FloatSerializer.cs 2021-12-16 17:52:14 +01:00
Paul
9abc3fbee2 remove allocations with this one simple trick. doctors hate em! 2021-12-16 14:25:26 +01:00
Vera Aguilera Puerto
9f20c325ab Cache transform comp in CreateEntityUninitialized.
Instead of getting it 5 times in a row.
2021-12-16 12:58:12 +01:00
Vera Aguilera Puerto
e7308efdd7 Botch VV to allow viewing remote entities that don't exist locally. (#2346) 2021-12-16 11:32:54 +01:00
Vera Aguilera Puerto
c2113b5719 Remove AggressiveOptimization flag from EntitySystem proxy methods.
Also fixes xmldoc inheritance for some methods.
2021-12-15 11:45:34 +01:00
Leon Friedrich
c43f7ea861 Add nullable overrides for the the Deleted() & Exists() proxy methods. (#2348) 2021-12-15 11:38:45 +01:00
E F R
5fac3f4adb UserInterface/RichTextEntry: Rich Text Fixes (Round 2) (#2340)
Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
2021-12-15 10:25:33 +01:00
metalgearsloth
7a31525c3c EntityQuery funnies (#2347) 2021-12-15 18:02:02 +11:00
Vera Aguilera Puerto
1613f5e982 Expose IContentRoot to content. (#2338) 2021-12-14 13:49:07 +01:00
Leon Friedrich
b6907e999d Make ContainerSystem.ContainsEntity() not log missing components (#2345) 2021-12-14 10:14:09 +01:00
Vera Aguilera Puerto
c73077014b EntityUid now shows a "View" button in VV. (#2342) 2021-12-14 09:57:46 +01:00
metalgearsloth
ce9bf26204 Minor render tree updates optimisation (#2337) 2021-12-14 09:51:27 +01:00
Paul Ritter
85f716ef03 pvs optimizations (#2341) 2021-12-14 09:50:34 +01:00
metalgearsloth
fba696ad6d Optimise client 5% with this one trick (#2334) 2021-12-14 09:50:03 +01:00
metalgearsloth
ed4267df50 Minor xform optimisations (#2335) 2021-12-14 09:49:30 +01:00
Insineer
1afeac4b95 fix(server): specify default culture for float.Parse (#2307)
Co-authored-by: Acruid <shatter66@gmail.com>
2021-12-13 11:27:16 +01:00
ShadowCommander
1c761737b6 Version: 0.8.8 2021-12-12 23:19:42 -08:00
ShadowCommander
a159db74f6 Version: 0.2.26 2021-12-12 23:19:07 -08:00
ShadowCommander
ac781e51ec Clean up unused variables in OutputPanel 2021-12-12 23:17:38 -08:00
E F R
e050af31af Controls/OutputPanel: Conslidate logic in _invalidateEntries, and get rid of some rogue LineHeight calculations (#2332) 2021-12-12 23:10:24 -08:00
1237 changed files with 58025 additions and 24264 deletions

19
.github/CODEOWNERS vendored
View File

@@ -1,7 +1,20 @@
# Last match in file takes precedence.
# Ping for all PRs
* @Acruid @PJB3005 @Silvertorch5
/Robust.*/Audio/Midi/ @Zumorica
/Robust.Client.NameGenerator @PaulRitter
/Robust.Client.Injectors @PaulRitter
/Robust.Generators @PaulRitter
/Robust.Analyzers @PaulRitter
/Robust.*/GameStates @PaulRitter
/Robust.Shared/Analyzers @PaulRitter
/Robust.*/Serialization @PaulRitter @DrSmugleaf
/Robust.*/Prototypes @PaulRitter
/Robust.Shared/GameObjects/ComponentDependencies @PaulRitter
/Robust.*/Containers @PaulRitter
# Be they Fluent translations or Freemarker templates, I know them both!
*.ftl @RemieRichards
# Ping for all PRs
* @Acruid @PJB3005 @Silvertorch5

35
.github/workflows/benchmarks.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
name: Benchmarks
on:
workflow_dispatch:
schedule:
- cron: '0 5 * * *'
push:
tags:
- 'v*'
concurrency: benchmarks
env:
ROBUST_BENCHMARKS_ENABLE_SQL: 1
ROBUST_BENCHMARKS_SQL_ADDRESS: ${{ secrets.BENCHMARKS_WRITE_ADDRESS }}
ROBUST_BENCHMARKS_SQL_PORT: ${{ secrets.BENCHMARKS_WRITE_PORT }}
ROBUST_BENCHMARKS_SQL_USER: ${{ secrets.BENCHMARKS_WRITE_USER }}
ROBUST_BENCHMARKS_SQL_PASSWORD: ${{ secrets.BENCHMARKS_WRITE_PASSWORD }}
ROBUST_BENCHMARKS_SQL_DATABASE: benchmarks
jobs:
benchmark:
name: Run Benchmarks
runs-on: ubuntu-latest
steps:
- name: Run script on centcomm
uses: appleboy/ssh-action@master
with:
host: centcomm.spacestation14.io
username: robust-benchmark-runner
key: ${{ secrets.CENTCOMM_ROBUST_BENCHMARK_RUNNER_KEY }}
command_timeout: 100000m
script: |
wget https://raw.githubusercontent.com/space-wizards/RobustToolbox/${{ github.sha }}/Tools/run_benchmarks.py
python3 run_benchmarks.py "${{ secrets.BENCHMARKS_WRITE_ADDRESS }}" "${{ secrets.BENCHMARKS_WRITE_PORT }}" "${{ secrets.BENCHMARKS_WRITE_USER }}" "${{ secrets.BENCHMARKS_WRITE_PASSWORD }}" "${{ github.sha }}"
rm run_benchmarks.py

34
.github/workflows/build-docfx.yml vendored Normal file
View File

@@ -0,0 +1,34 @@
name: Build & Publish DocFX
on:
schedule:
- cron: "0 0 * * 0"
jobs:
docfx:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Install dependencies
run: dotnet restore
- name: Build Project
run: dotnet build --no-restore /p:WarningsAsErrors=nullable
- name: Build DocFX
uses: nikeee/docfx-action@v1.0.0
with:
args: Robust.Docfx/docfx.json
- name: Publish Docfx Documentation on GitHub Pages
uses: maxheld83/ghpages@master
env:
BUILD_DIR: Robust.Docfx/_robust-site
GH_PAT: ${{ secrets.GH_PAT }}

View File

@@ -22,10 +22,12 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.100
dotnet-version: 6.0.x
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore /p:WarningsAsErrors=nullable
- name: Test Engine
run: dotnet test --no-build Robust.UnitTesting/Robust.UnitTesting.csproj -v n
run: dotnet test --no-build Robust.UnitTesting/Robust.UnitTesting.csproj -- NUnit.ConsoleOut=0

24
.gitignore vendored
View File

@@ -41,18 +41,6 @@ _ReSharper*/
# Resources
*.resources
/Resources/textures/Animations/*.*
/Resources/ResourcePack.zip
/Resources/textures/*_Animations.png
/Resources/textures/*_Decals.png
/Resources/textures/*_Effects.png
/Resources/textures/*_Items.png
/Resources/textures/*_Objects.png
/Resources/textures/*_Tiles.png
/Resources/textures/*_UserInterface.png
/Resources/textures/*.TAI
/Resources/SpriteRenderer/Ogre.log
/Resources/Spriterenderer/output
/Media
/setenv.bat
@@ -78,16 +66,6 @@ project.lock.json
# Created by NUnit.
TestResult.xml
NetSerializerDebug.dll
# We're not gonna ship Mac extlibs with the repo due to size. (11 MB)
Third-Party/extlibs/Mac/
# Or the automatically-fetched Windows natives, for that matter.
Third-Party/extlibs/Windows/
# Actually I'll make this folder because SS14.Shared.Bsdiff isn't third-party is it?
Dependencies/
# Python stuff
__pycache__
.mypy_cache
@@ -98,3 +76,5 @@ MSBuild/Robust.Custom.targets
release/
Robust.Docfx/*-site
Robust.Docfx/api

6
.gitmodules vendored
View File

@@ -10,12 +10,6 @@
[submodule "Robust.LoaderApi"]
path = Robust.LoaderApi
url = https://github.com/space-wizards/Robust.LoaderApi.git
[submodule "ManagedHttpListener"]
path = ManagedHttpListener
url = https://github.com/space-wizards/ManagedHttpListener.git
[submodule "Linguini"]
path = Linguini
url = https://github.com/space-wizards/Linguini
[submodule "cefglue"]
path = cefglue
url = https://github.com/space-wizards/cefglue.git

Submodule Linguini deleted from b3c05c2f31

View File

@@ -1,4 +1,4 @@
<Project>
<!-- This file automatically reset by Tools/version.py -->
<PropertyGroup><Version>0.8.7</Version></PropertyGroup>
<PropertyGroup><Version>0.40.3.0</Version></PropertyGroup>
</Project>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<!-- Avoid MSBuild adding a None entry for XAML files because they'd show up TWICE in the project view. -->
<DefaultItemExcludes>**/*.xaml</DefaultItemExcludes>
<RobustUseExternalMSBuild>true</RobustUseExternalMSBuild>
<RobustUseExternalMSBuild>false</RobustUseExternalMSBuild>
<_RobustUseExternalMSBuild>$(RobustUseExternalMSBuild)</_RobustUseExternalMSBuild>
<_RobustUseExternalMSBuild Condition="'$(_RobustForceInternalMSBuild)' == 'true'">false</_RobustUseExternalMSBuild>
</PropertyGroup>

View File

@@ -10,7 +10,6 @@
using System;
using System.Runtime.InteropServices;
using static OpenToolkit.GraphicsLibraryFramework.GLFWNative;
using static Robust.Shared.Utility.MarshalHelper;
namespace OpenToolkit.GraphicsLibraryFramework
{
@@ -211,7 +210,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
/// <seealso cref="GetVersion"/>
public static unsafe string GetVersionString()
{
return PtrToStringUTF8(glfwGetVersionString());
return Marshal.PtrToStringUTF8((IntPtr) glfwGetVersionString());
}
/// <summary>
@@ -272,7 +271,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
{
byte* desc;
var code = glfwGetError(&desc);
description = PtrToStringUTF8(desc);
description = Marshal.PtrToStringUTF8((IntPtr) desc);
return code;
}
@@ -590,7 +589,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
/// </remarks>
public static unsafe string GetMonitorName(Monitor* monitor)
{
return PtrToStringUTF8(glfwGetMonitorName(monitor));
return Marshal.PtrToStringUTF8((IntPtr) glfwGetMonitorName(monitor));
}
/// <summary>
@@ -902,7 +901,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
/// </remarks>
public static unsafe void WindowHint(WindowHintString hint, string value)
{
var ptr = StringToCoTaskMemUTF8(value);
var ptr = Marshal.StringToCoTaskMemUTF8(value);
try
{
@@ -1364,7 +1363,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
/// </remarks>
public static unsafe string GetKeyName(Keys key, int scanCode)
{
return PtrToStringUTF8(glfwGetKeyName(key, scanCode));
return Marshal.PtrToStringUTF8((IntPtr) glfwGetKeyName(key, scanCode));
}
/// <summary>
@@ -2278,7 +2277,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
/// </remarks>
public static unsafe string GetJoystickName(int jid)
{
return PtrToStringUTF8(glfwGetJoystickName(jid));
return Marshal.PtrToStringUTF8((IntPtr) glfwGetJoystickName(jid));
}
/// <summary>
@@ -2351,7 +2350,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
/// </remarks>
public static unsafe string GetJoystickGUID(int jid)
{
return PtrToStringUTF8(glfwGetJoystickGUID(jid));
return Marshal.PtrToStringUTF8((IntPtr) glfwGetJoystickGUID(jid));
}
/// <summary>
@@ -2509,7 +2508,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
/// </remarks>
public static unsafe bool UpdateGamepadMappings(string newMapping)
{
var ptr = StringToCoTaskMemUTF8(newMapping);
var ptr = Marshal.StringToCoTaskMemUTF8(newMapping);
try
{
return glfwUpdateGamepadMappings((byte*)ptr) == GLFW_TRUE;
@@ -2585,7 +2584,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
/// </remarks>
public static unsafe string GetGamepadName(int jid)
{
return PtrToStringUTF8(glfwGetGamepadName(jid));
return Marshal.PtrToStringUTF8((IntPtr) glfwGetGamepadName(jid));
}
/// <summary>
@@ -2854,7 +2853,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
/// </remarks>
public static unsafe bool ExtensionSupported(string extensionName)
{
var ptr = StringToCoTaskMemUTF8(extensionName);
var ptr = Marshal.StringToCoTaskMemUTF8(extensionName);
try
{
@@ -2893,7 +2892,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
/// <seealso cref="ExtensionSupported" />
public static unsafe IntPtr GetProcAddress(string procName)
{
var ptr = StringToCoTaskMemUTF8(procName);
var ptr = Marshal.StringToCoTaskMemUTF8(procName);
try
{
@@ -3085,7 +3084,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
/// </remarks>
public static unsafe Window* CreateWindow(int width, int height, string title, Monitor* monitor, Window* share)
{
var ptr = StringToCoTaskMemUTF8(title);
var ptr = Marshal.StringToCoTaskMemUTF8(title);
try
{
@@ -3306,7 +3305,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
/// <seealso cref="SetClipboardString"/>
public static unsafe string GetClipboardString(Window* window)
{
return PtrToStringUTF8(glfwGetClipboardString(window));
return Marshal.PtrToStringUTF8((IntPtr) glfwGetClipboardString(window));
}
/// <summary>
@@ -3917,7 +3916,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
/// <seealso cref="GetClipboardString"/>
public static unsafe void SetClipboardString(Window* window, string data)
{
var ptr = StringToCoTaskMemUTF8(data);
var ptr = Marshal.StringToCoTaskMemUTF8(data);
try
{
@@ -4751,7 +4750,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
/// </remarks>
public static unsafe void SetWindowTitle(Window* window, string title)
{
var ptr = StringToCoTaskMemUTF8(title);
var ptr = Marshal.StringToCoTaskMemUTF8(title);
try
{
@@ -5340,7 +5339,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
var array = new string[count];
for (var i = 0; i < count; i++)
{
array[i] = PtrToStringUTF8(ptr[i]);
array[i] = Marshal.PtrToStringUTF8((IntPtr) ptr[i]);
}
return array;
@@ -5386,7 +5385,7 @@ namespace OpenToolkit.GraphicsLibraryFramework
/// <returns>The address of the function, or <c>null</c> if an error occurred.</returns>
public static unsafe IntPtr GetInstanceProcAddress(VkHandle instance, string procName)
{
var ptr = StringToCoTaskMemUTF8(procName);
var ptr = Marshal.StringToCoTaskMemUTF8(procName);
try
{

View File

@@ -14,7 +14,4 @@
<PackageReference Condition="'$(TargetFramework)' == 'net472'" Include="System.Memory" Version="4.5.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,8 +0,0 @@
# .import files are made by Godot because the assets are exposed if using symlinks.
# IF you need to persist a .import file because of something used Godot-side (GUI-side),
# you can do a negation with !.
*.import
# Negation would be like this:
#!/Textures/UserInterface/1pxwhite.png.import
!/Scenes/SS14Window/closewindow.png.import
/I_MADE_THE_SYMLINK

View File

@@ -0,0 +1,155 @@
### Localization for engine console commands
## generic
cmd-parse-failure-integer = {$arg} is not a valid integer.
cmd-parse-failure-float = {$arg} is not a valid float.
cmd-parse-failure-bool = {$arg} is not a valid bool.
## 'help' command
cmd-help-desc = Display general help or help text for a specific command
cmd-help-help = Usage: help [command name]
When no command name is provided, displays general-purpose help text. If a command name is provided, displays help text for that command.
cmd-help-no-args = To display help for a specific command, write 'help <command>'. To list all available commands, write 'list'. To search for commands, use 'list <filter>'.
cmd-help-unknown = Unknown command: { $command }
cmd-help-top = { $command } - { $description }
cmd-help-invalid-args = Invalid amount of arguments.
cmd-help-arg-cmdname = [command name]
## 'cvar' command
cmd-cvar-desc = Gets or sets a CVar.
cmd-cvar-help = Usage: cvar <name | ?> [value]
If a value is passed, the value is parsed and stored as the new value of the CVar.
If not, the current value of the CVar is displayed.
Use 'cvar ?' to get a list of all registered CVars.
cmd-cvar-invalid-args = Must provide exactly one or two arguments.
cmd-cvar-not-registered = CVar '{ $cvar }' is not registered. Use 'cvar ?' to get a list of all registered CVars.
cmd-cvar-parse-error = Input value is in incorrect format for type { $type }
cmd-cvar-compl-list = List available CVars
cmd-cvar-arg-name = <name | ?>
cmd-cvar-value-hidden = <value hidden>
## 'list' command
cmd-list-desc = Lists available commands, with optional search filter
cmd-list-help = Usage: list [filter]
Lists all available commands. If an argument is provided, it will be used to filter commands by name.
cmd-list-heading = SIDE NAME DESC{"\u000A"}-------------------------{"\u000A"}
cmd-list-arg-filter = [filter]
## '>' command, aka remote exec
cmd-remoteexec-desc = Executes server-side commands
cmd-remoteexec-help = Usage: > <command> [arg] [arg] [arg...]
Executes a command on the server. This is necessary if a command with the same name exists on the client, as simply running the command would run the client command first.
## 'gc' command
cmd-gc-desc = Run the GC (Garbage Collector)
cmd-gc-help = Usage: gc [generation]
Uses GC.Collect() to execute the Garbage Collector.
If an argument is provided, it is parsed as a GC generation number and GC.Collect(int) is used.
Use the 'gfc' command to do an LOH-compacting full GC.
cmd-gc-failed-parse = Failed to parse argument.
cmd-gc-arg-generation = [generation]
## 'gcf' command
cmd-gcf-desc = Run the GC, fully, compacting LOH and everything.
cmd-gcf-help = Usage: gcf
Does a full GC.Collect(2, GCCollectionMode.Forced, true, true) while also compacting LOH.
This will probably lock up for hundreds of milliseconds, be warned.
## 'gc_mode' command
cmd-gc_mode-desc = Change/Read the GC Latency mode
cmd-gc_mode-help = Usage: gc_mode [type]
If no argument is provided, returns the current GC latency mode.
If an argument is passed, it is parsed as GCLatencyMode and set as the GC latency mode.
cmd-gc_mode-current = current gc latency mode: { $prevMode }
cmd-gc_mode-possible = possible modes:
cmd-gc_mode-option = - { $mode }
cmd-gc_mode-unknown = unknown gc latency mode: { $arg }
cmd-gc_mode-attempt = attempting gc latency mode change: { $prevMode } -> { $mode }
cmd-gc_mode-result = resulting gc latency mode: { $mode }
cmd-gc_mode-arg-type = [type]
## 'mem' command
cmd-mem-desc = Prints managed memory info
cmd-mem-help = Usage: mem
cmd-mem-report = Heap Size: { TOSTRING($heapSize, "N0") }
Total Allocated: { TOSTRING($totalAllocated, "N0") }
## 'physics' command
cmd-physics-overlay = {$overlay} is not a recognised overlay
## 'lsasm' command
cmd-lsasm-desc = Lists loaded assemblies by load context
cmd-lsasm-help = Usage: lsasm
## 'exec' command
cmd-exec-desc = Executes a script file from the game's writeable user data
cmd-exec-help = Usage: exec <fileName>
Each line in the file is executed as a single command, unless it starts with a #
cmd-exec-arg-filename = <fileName>
## 'dump_net_comps' command
cmd-dump_net_comps-desc = Prints the table of networked components.
cmd-dump_net_comps-help = Usage: dump_net-comps
cmd-dump_net_comps-error-writeable = Registration still writeable, network ids have not been generated.
cmd-dump_net_comps-header = Networked Component Registrations:
## 'dump_event_tables' command
cmd-dump_event_tables-desc = Prints directed event tables for an entity.
cmd-dump_event_tables-help = Usage: dump_event_tables <entityUid>
cmd-dump_event_tables-missing-arg-entity = Missing entity argument
cmd-dump_event_tables-error-entity = Invalid entity
cmd-dump_event_tables-arg-entity = <entityUid>
## 'monitor' command
cmd-monitor-desc = Toggles a debug monitor in the F3 menu.
cmd-monitor-help = Usage: monitor <name>
Possible monitors are: { $monitors }
You can also use the special values "-all" and "+all" to hide or show all monitors, respectively.
cmd-monitor-arg-monitor = <monitor>
cmd-monitor-invalid-name = Invalid monitor name
cmd-monitor-arg-count = Missing monitor argument
cmd-monitor-minus-all-hint = Hides all monitors
cmd-monitor-plus-all-hint = Shows all monitors
## Mapping commands
cmd-savemap-desc = Serializes a map to disk. Will not save a post-init map unless forced.
cmd-savemap-help = savemap <MapID> <Path> [force]
cmd-savemap-not-exist = Target map does not exist.
cmd-savemap-init-warning = Attempted to save a post-init map without forcing the save.
cmd-savemap-attempt = Attempting to save map {$mapId} to {$path}.
cmd-savemap-success = Map successfully saved.
cmd-hint-savemap-id = <MapID>
cmd-hint-savemap-path = <Path>
cmd-hint-savemap-force = [bool]
cmd-loadmap-desc = Loads a map from disk into the game.
cmd-loadmap-help = loadmap <MapID> <Path> [x] [y] [rotation] [consistentUids]
cmd-loadmap-nullspace = You cannot load into map 0.
cmd-loadmap-exists = Map {$mapId} already exists.
cmd-loadmap-success = Map {$mapId} has been loaded from {$path}.
cmd-loadmap-error = An error occurred while loading map from {$path}.
cmd-hint-loadmap-x-position = [x-position]
cmd-hint-loadmap-y-position = [y-position]
cmd-hint-loadmap-rotation = [rotation]
cmd-hint-loadmap-uids = [float]
## 'flushcookies' command
# Note: the flushcookies command is from Robust.Client.WebView, it's not in the main engine code.
cmd-flushcookies-desc = Flush CEF cookie storage to disk
cmd-flushcookies-help = This ensure cookies are properly saved to disk in the event of unclean shutdowns.
Note that the actual operation is asynchronous.

View File

@@ -0,0 +1,10 @@
color-selector-sliders-red = R
color-selector-sliders-green = G
color-selector-sliders-blue = B
color-selector-sliders-hue = H
color-selector-sliders-saturation = S
color-selector-sliders-value = V
color-selector-sliders-alpha = A
color-selector-sliders-rgb = RGB
color-selector-sliders-hsv = HSV

View File

@@ -0,0 +1 @@
defaultwindow-placeholder-title = Exemplary Window Title Here

View File

@@ -0,0 +1 @@
midi-panic-command-description = Turns off every note for every active MIDI renderer.

View File

@@ -1 +0,0 @@
ss14window-placeholder-title = Exemplary Window Title Here

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 927 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -1,2 +0,0 @@
sample:
filter: true

View File

@@ -1,152 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="113.67364mm"
height="56.37999mm"
viewBox="0 0 113.67364 56.37999"
version="1.1"
id="svg3223"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
sodipodi:docname="logo.svg"
inkscape:export-filename="/home/pj/Projects/space-station-14/RobustToolbox/Resources/Textures/Logo/logo.png"
inkscape:export-xdpi="67.034012"
inkscape:export-ydpi="67.034012">
<defs
id="defs3217" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="159.25688"
inkscape:cy="149.8376"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:pagecheckerboard="true"
inkscape:window-width="1920"
inkscape:window-height="1043"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata3220">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-56.556041,-109.30405)">
<g
transform="translate(-3.7799155,-23.482217)"
id="g2559">
<path
inkscape:connector-curvature="0"
id="path148"
style="fill:#e23229;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 143.44393,145.03077 0.1484,-0.70241 5.14257,-0.35974 -6.23062,29.75753 -0.69199,0.0483 6.08255,-29.05476 z m 1.18682,31.16724 7.31835,-35.07438 -10.43302,0.72923 -1.28514,6.12249 4.45021,-0.31125 -6.03235,28.95253 z" />
<path
sodipodi:nodetypes="cccccccccccccccccccccc"
inkscape:connector-curvature="0"
id="path152"
style="fill:#e23229;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 169.25392,142.53363 -3.53672,16.8925 4.79124,-0.32874 -0.15681,0.75402 -4.79234,0.32881 -2.53549,12.11072 -0.75405,0.052 2.53724,-12.11108 -11.37332,0.78724 z m -18.98495,21.327 11.37324,-0.78724 -2.5247,12.11146 5.98312,-0.41839 2.52513,-12.10406 4.82658,-0.33116 1.26721,-6.07903 -4.82564,0.33109 3.52398,-16.89101 -4.56014,0.33565 -16.70168,19.60839 z" />
<path
inkscape:connector-curvature="0"
id="path156"
style="fill:#fefefe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 88.591903,151.83158 -2.595368,0.18103 0.741705,-3.62685 2.595079,-0.182 z m -4.581719,-6.72375 -3.99857,19.05572 3.468889,-0.24195 1.774487,-8.38766 6.064403,-0.42299 2.224789,-10.66981 z" />
<path
inkscape:connector-curvature="0"
id="path160"
style="fill:#fefefe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 100.85029,147.82177 2.83371,-0.19837 -0.74166,3.60045 -2.83371,0.19836 z m -6.726869,15.77696 3.469312,-0.24198 1.774487,-8.38695 2.8337,-0.19837 -1.77453,8.38695 3.46938,-0.24296 3.99895,-19.05608 -9.771974,0.68329 z" />
<path
inkscape:connector-curvature="0"
id="path164"
style="fill:#fefefe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 108.80467,162.68768 9.74554,-0.68118 1.377,-6.50502 -3.4693,0.24296 -0.63527,2.9832 -2.80718,0.19654 2.51548,-12.01379 2.80731,-0.19754 -0.50239,2.4195 3.46902,-0.24294 1.24513,-5.93998 -9.74589,0.68119 z" />
<path
inkscape:connector-curvature="0"
id="path168"
style="fill:#fefefe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 135.66767,145.61788 0.7409,-3.5211 -8.95132,0.6259 -3.99824,19.0564 8.95097,-0.62626 0.74082,-3.52077 -5.4816,0.383 1.03272,-4.89224 3.78675,-0.26474 0.74189,-3.52113 -3.78675,0.26474 0.74081,-3.6011 z" />
<path
inkscape:connector-curvature="0"
id="path172"
style="fill:#d5d5d5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 71.070134,172.95255 -4.734664,0.33077 0.57447,-2.73456 2.139294,-0.14973 -0.376241,1.80924 2.595442,-0.18103 0.930868,-4.44332 -7.330114,0.5118 -1.66358,8.00131 4.734672,-0.33077 -0.773014,3.62025 -2.119829,0.1484 0.475696,-2.23174 -2.614982,0.18237 -1.030327,4.86616 7.330104,-0.5118 z" />
<path
inkscape:connector-curvature="0"
id="path176"
style="fill:#d5d5d5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 74.794828,169.99754 2.496095,-0.17422 -2.436556,11.62085 2.595151,-0.182 2.436903,-11.62086 2.496023,-0.17421 0.554678,-2.63441 -7.587516,0.53064 z" />
<path
inkscape:connector-curvature="0"
id="path180"
style="fill:#d5d5d5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 87.573322,171.75893 0.554606,-2.69318 2.119754,-0.1484 -0.554978,2.69354 z m 2.832629,8.59803 2.991888,-14.25529 -7.310379,0.51154 -2.99153,14.25493 2.595227,-0.18201 1.327293,-6.27378 2.11968,-0.14839 -1.327288,6.27414 z" />
<path
inkscape:connector-curvature="0"
id="path184"
style="fill:#d5d5d5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 98.977684,179.78056 2.436926,-11.62086 2.49608,-0.1752 0.55493,-2.63374 -7.587518,0.53065 -0.554634,2.63373 2.495947,-0.17421 -2.436599,11.6212 z" />
<path
inkscape:connector-curvature="0"
id="path188"
style="fill:#d5d5d5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 104.62426,179.38562 2.5951,-0.18101 2.9915,-14.25528 -2.59522,0.182 z" />
<path
inkscape:connector-curvature="0"
id="path192"
style="fill:#d5d5d5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 115.73198,167.18138 2.11975,-0.14839 -1.88236,8.98749 -2.11949,0.14838 z m -5.03203,11.80203 7.31001,-0.51042 2.99153,-14.25494 -7.31028,0.51044 z" />
<path
inkscape:connector-curvature="0"
id="path196"
style="fill:#d5d5d5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 124.08538,178.07141 1.36653,-6.47511 1.18856,6.29603 2.25853,-0.15792 2.99192,-14.25493 -2.59522,0.18201 -1.36734,6.57353 -1.18854,-6.39514 -2.25854,0.15791 -2.99084,14.25493 z" />
<path
inkscape:connector-curvature="0"
id="path200"
style="fill:#fefefe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 66.677649,158.65784 -1.377018,6.50538 9.798398,-0.68471 2.489415,-11.87958 -6.329111,0.44214 0.767747,-3.65465 2.860076,-0.20018 -0.503204,2.41917 3.469299,-0.24297 1.244526,-5.93996 -4.328229,0.30289 -8.728772,0.56991 2.909827,1.489 -1.87565,9.01912 6.329037,-0.44213 -1.032406,4.83973 -2.833645,0.19738 0.635302,-2.98354 z" />
<path
inkscape:connector-curvature="0"
id="path204"
style="fill:#e23229;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 70.519326,139.92277 -0.277457,1.36553 103.473271,-7.11317 0.29445,-1.38886 z" />
<path
inkscape:connector-curvature="0"
id="path208"
style="fill:#e23229;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.34773216"
d="m 60.335956,189.16626 103.473274,-7.11356 0.29444,-1.38885 -103.489968,7.13649 z" />
<path
sodipodi:nodetypes="cccccccc"
inkscape:connector-curvature="0"
id="path1772"
d="m 167.92741,145.26275 -12.87687,14.89523 9.91366,-0.68019 z m -3.743,7.27758 -1.02896,4.93612 -3.51544,0.2412 z"
style="fill:#e23229;fill-opacity:1;stroke:none;stroke-width:0.2626844px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 B

View File

@@ -0,0 +1,822 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.Testing;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.Testing.Verifiers;
using NUnit.Framework;
using Robust.Analyzers;
using VerifyCS = Microsoft.CodeAnalysis.CSharp.Testing.NUnit.AnalyzerVerifier<Robust.Analyzers.AccessAnalyzer>;
using static Microsoft.CodeAnalysis.Testing.DiagnosticResult;
namespace Robust.Analyzers.Tests;
[Parallelizable(ParallelScope.All | ParallelScope.Fixtures)]
[TestFixture]
public sealed class AccessAnalyzer_Test
{
public Task Verifier(string code, params DiagnosticResult[] expected)
{
var test = new CSharpAnalyzerTest<AccessAnalyzer, NUnitVerifier>()
{
TestState =
{
AdditionalReferences = { typeof(AccessAnalyzer).Assembly },
Sources = { code }
},
};
// ExpectedDiagnostics cannot be set, so we need to AddRange here...
test.TestState.ExpectedDiagnostics.AddRange(expected);
return test.RunAsync();
}
/*
*
*/
[Test]
public async Task ReadTest()
{
const string code = @"
using System;
using Robust.Shared.Analyzers;
// ReSharper disable RedundantAssignment
// ReSharper disable UnusedVariable
// ReSharper disable ArrangeThisQualifier
// ReSharper disable UnusedMember.Global
// ReSharper disable UnusedType.Global
public struct MyData
{
public int MyField;
public static bool operator ==(MyData lhs, MyData rhs) => lhs.MyField == rhs.MyField;
public static bool operator !=(MyData lhs, MyData rhs) => lhs.MyField != rhs.MyField;
}
[Access(typeof(FriendlyClass),
Self = AccessPermissions.None,
Friend = AccessPermissions.None,
Other = AccessPermissions.None)]
public sealed class TypeNobodyCanRead
{
public MyData Data = default;
[Access(typeof(FriendlyClass),
Self = AccessPermissions.Read,
Friend = AccessPermissions.Read,
Other = AccessPermissions.Read)]
public MyData Data2 = default;
public void TestTypeNobodyCanRead(TypeNobodyCanRead obj)
{
// None of these accesses should be allowed.
var copy = Data;
var copy2 = this.Data;
var copy3 = obj.Data;
copy = Data;
copy = this.Data;
copy = obj.Data;
var copy4 = Data.MyField;
var copy5 = this.Data.MyField;
var copy6 = obj.Data.MyField;
if (Data == copy) {}
if (this.Data == copy) {}
if (obj.Data == copy) {}
if(Data.MyField == 0) {}
if(this.Data.MyField == 0) {}
if(obj.Data.MyField == 0) {}
// All of these accesses should be fine.
var copy7 = Data2;
var copy8 = this.Data2;
var copy9 = obj.Data2;
copy = Data2;
copy = this.Data2;
copy = obj.Data2;
var copy10 = Data2.MyField;
var copy11 = this.Data2.MyField;
var copy12 = obj.Data2.MyField;
if (Data2 == copy) {}
if (this.Data2 == copy) {}
if (obj.Data2 == copy) {}
if(Data2.MyField == 0) {}
if(this.Data2.MyField == 0) {}
if(obj.Data2.MyField == 0) {}
}
}
[Access(typeof(FriendlyClass),
Self = AccessPermissions.Read,
Friend = AccessPermissions.Read,
Other = AccessPermissions.Read)]
public sealed class MemberNobodyCanRead
{
[Access(typeof(FriendlyClass),
Self = AccessPermissions.None,
Friend = AccessPermissions.None,
Other = AccessPermissions.None)]
public MyData Data = default;
public MyData Data2 = default;
public void TestMemberNobodyCanRead(TypeNobodyCanRead obj)
{
// None of these accesses should be allowed.
var copy = Data;
var copy2 = this.Data;
var copy3 = obj.Data;
copy = Data;
copy = this.Data;
copy = obj.Data;
var copy4 = Data.MyField;
var copy5 = this.Data.MyField;
var copy6 = obj.Data.MyField;
if (Data == copy) {}
if (this.Data == copy) {}
if (obj.Data == copy) {}
if(Data.MyField == 0) {}
if(this.Data.MyField == 0) {}
if(obj.Data.MyField == 0) {}
// All of these accesses should be fine.
var copy7 = Data2;
var copy8 = this.Data2;
var copy9 = obj.Data2;
copy = Data2;
copy = this.Data2;
copy = obj.Data2;
var copy10 = Data2.MyField;
var copy11 = this.Data2.MyField;
var copy12 = obj.Data2.MyField;
if (Data2 == copy) {}
if (this.Data2 == copy) {}
if (obj.Data2 == copy) {}
if(Data2.MyField == 0) {}
if(this.Data2.MyField == 0) {}
if(obj.Data2.MyField == 0) {}
}
}
public sealed class FriendlyClass
{
public void TestTypeNobodyCanRead(TypeNobodyCanRead obj)
{
// We shouldn't be able to access any of these, even if we're a friend..
var copy = obj.Data;
copy = obj.Data;
var copy2 = obj.Data.MyField;
copy2 = obj.Data.MyField;
if (obj.Data == copy) {}
if(obj.Data.MyField == 0) {}
// We should be allowed to access all of these, we're friends!
var copy3 = obj.Data2;
copy = obj.Data2;
var copy4 = obj.Data2.MyField;
copy4 = obj.Data2.MyField;
if(obj.Data2 == copy) {}
if(obj.Data2.MyField == 0) {}
}
public void TestMemberNobodyCanRead(MemberNobodyCanRead obj)
{
// We shouldn't be able to access any of these, even if we're a friend..
var copy = obj.Data;
copy = obj.Data;
var copy2 = obj.Data.MyField;
copy2 = obj.Data.MyField;
if (obj.Data == copy) {}
if(obj.Data.MyField == 0) {}
// We should be allowed to access all of these, we're friends!
var copy3 = obj.Data2;
copy = obj.Data2;
var copy4 = obj.Data2.MyField;
copy4 = obj.Data2.MyField;
if(obj.Data2 == copy) {}
if(obj.Data2.MyField == 0) {}
}
}
public sealed class OtherClass
{
public void TestTypeNobodyCanRead(TypeNobodyCanRead obj)
{
// We shouldn't be able to access any of these, as 'other types' can't..
var copy = obj.Data;
copy = obj.Data;
var copy2 = obj.Data.MyField;
copy2 = obj.Data.MyField;
if (obj.Data == copy) {}
if(obj.Data.MyField == 0) {}
// We should be allowed to access all of these, they let others read it!
var copy3 = obj.Data2;
copy = obj.Data2;
var copy4 = obj.Data2.MyField;
copy4 = obj.Data2.MyField;
if(obj.Data2 == copy) {}
if(obj.Data2.MyField == 0) {}
}
public void TestMemberNobodyCanRead(MemberNobodyCanRead obj)
{
// We shouldn't be able to access any of these, as 'other types' can't..
var copy = obj.Data;
copy = obj.Data;
var copy2 = obj.Data.MyField;
copy2 = obj.Data.MyField;
if (obj.Data == copy) {}
if(obj.Data.MyField == 0) {}
// We should be allowed to access all of these, they let others read it!
var copy3 = obj.Data2;
copy = obj.Data2;
var copy4 = obj.Data2.MyField;
copy4 = obj.Data2.MyField;
if(obj.Data2 == copy) {}
if(obj.Data2.MyField == 0) {}
}
}";
await Verifier(code,
// AUTO-GENERATED DIAGNOSTICS BELOW //
// /0/Test0.cs(35,20): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(35, 20, 35, 24).WithArguments("a 'Read' same-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(36,21): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(36, 21, 36, 30).WithArguments("a 'Read' same-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(37,21): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(37, 21, 37, 29).WithArguments("a 'Read' same-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(39,16): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(39, 16, 39, 20).WithArguments("a 'Read' same-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(40,16): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(40, 16, 40, 25).WithArguments("a 'Read' same-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(41,16): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(41, 16, 41, 24).WithArguments("a 'Read' same-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(43,21): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(43, 21, 43, 25).WithArguments("a 'Read' same-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(44,21): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(44, 21, 44, 30).WithArguments("a 'Read' same-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(45,21): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(45, 21, 45, 29).WithArguments("a 'Read' same-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(47,13): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(47, 13, 47, 17).WithArguments("a 'Read' same-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(48,13): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(48, 13, 48, 22).WithArguments("a 'Read' same-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(49,13): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(49, 13, 49, 21).WithArguments("a 'Read' same-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(51,12): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(51, 12, 51, 16).WithArguments("a 'Read' same-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(52,12): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(52, 12, 52, 21).WithArguments("a 'Read' same-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(53,12): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(53, 12, 53, 20).WithArguments("a 'Read' same-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(95,20): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(95, 20, 95, 24).WithArguments("a 'Read' same-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(96,21): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(96, 21, 96, 30).WithArguments("a 'Read' same-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(97,21): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(97, 21, 97, 29).WithArguments("a 'Read' other-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(99,16): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(99, 16, 99, 20).WithArguments("a 'Read' same-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(100,16): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(100, 16, 100, 25).WithArguments("a 'Read' same-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(101,16): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(101, 16, 101, 24).WithArguments("a 'Read' other-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(103,21): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(103, 21, 103, 25).WithArguments("a 'Read' same-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(104,21): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(104, 21, 104, 30).WithArguments("a 'Read' same-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(105,21): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(105, 21, 105, 29).WithArguments("a 'Read' other-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(107,13): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(107, 13, 107, 17).WithArguments("a 'Read' same-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(108,13): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(108, 13, 108, 22).WithArguments("a 'Read' same-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(109,13): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(109, 13, 109, 21).WithArguments("a 'Read' other-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(111,12): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(111, 12, 111, 16).WithArguments("a 'Read' same-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(112,12): error RA0002: Tried to perform a 'Read' same-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(112, 12, 112, 21).WithArguments("a 'Read' same-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(113,12): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(113, 12, 113, 20).WithArguments("a 'Read' other-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(143,20): error RA0002: Tried to perform a 'Read' friend-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(143, 20, 143, 28).WithArguments("a 'Read' friend-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(144,16): error RA0002: Tried to perform a 'Read' friend-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(144, 16, 144, 24).WithArguments("a 'Read' friend-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(146,21): error RA0002: Tried to perform a 'Read' friend-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(146, 21, 146, 29).WithArguments("a 'Read' friend-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(147,17): error RA0002: Tried to perform a 'Read' friend-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(147, 17, 147, 25).WithArguments("a 'Read' friend-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(149,13): error RA0002: Tried to perform a 'Read' friend-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(149, 13, 149, 21).WithArguments("a 'Read' friend-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(150,12): error RA0002: Tried to perform a 'Read' friend-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(150, 12, 150, 20).WithArguments("a 'Read' friend-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(166,20): error RA0002: Tried to perform a 'Read' friend-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(166, 20, 166, 28).WithArguments("a 'Read' friend-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(167,16): error RA0002: Tried to perform a 'Read' friend-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(167, 16, 167, 24).WithArguments("a 'Read' friend-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(169,21): error RA0002: Tried to perform a 'Read' friend-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(169, 21, 169, 29).WithArguments("a 'Read' friend-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(170,17): error RA0002: Tried to perform a 'Read' friend-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(170, 17, 170, 25).WithArguments("a 'Read' friend-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(172,13): error RA0002: Tried to perform a 'Read' friend-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(172, 13, 172, 21).WithArguments("a 'Read' friend-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(173,12): error RA0002: Tried to perform a 'Read' friend-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(173, 12, 173, 20).WithArguments("a 'Read' friend-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(192,20): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(192, 20, 192, 28).WithArguments("a 'Read' other-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(193,16): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(193, 16, 193, 24).WithArguments("a 'Read' other-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(195,21): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(195, 21, 195, 29).WithArguments("a 'Read' other-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(196,17): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(196, 17, 196, 25).WithArguments("a 'Read' other-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(198,13): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(198, 13, 198, 21).WithArguments("a 'Read' other-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(199,12): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'TypeNobodyCanRead', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(199, 12, 199, 20).WithArguments("a 'Read' other-type", "Data", "TypeNobodyCanRead", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(215,20): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(215, 20, 215, 28).WithArguments("a 'Read' other-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(216,16): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(216, 16, 216, 24).WithArguments("a 'Read' other-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(218,21): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(218, 21, 218, 29).WithArguments("a 'Read' other-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(219,17): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(219, 17, 219, 25).WithArguments("a 'Read' other-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(221,13): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(221, 13, 221, 21).WithArguments("a 'Read' other-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(222,12): error RA0002: Tried to perform a 'Read' other-type access to member 'Data' in type 'MemberNobodyCanRead', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(222, 12, 222, 20).WithArguments("a 'Read' other-type", "Data", "MemberNobodyCanRead", "having no", "Member Permissions: ---------")
);
}
[Test]
public async Task WriteTest()
{
const string code = @"
using System;
using Robust.Shared.Analyzers;
// ReSharper disable RedundantAssignment
// ReSharper disable UnusedVariable
// ReSharper disable ArrangeThisQualifier
// ReSharper disable UnusedMember.Global
// ReSharper disable UnusedType.Global
// ReSharper disable NotAccessedField.Global
// ReSharper disable RedundantDefaultMemberInitializer
public struct MyData
{
public int MyField;
}
[Access(typeof(FriendlyClass),
Self = AccessPermissions.None,
Friend = AccessPermissions.None,
Other = AccessPermissions.None)]
public sealed class TypeNobodyCanWrite
{
public MyData Data = default;
[Access(typeof(FriendlyClass),
Self = AccessPermissions.Write,
Friend = AccessPermissions.Write,
Other = AccessPermissions.Write)]
public MyData Data2 = default;
public void TestTypeNobodyCanWrite(TypeNobodyCanWrite obj)
{
// None of these accesses should be allowed.
Data = default;
this.Data = default;
obj.Data = default;
Data.MyField = 0;
this.Data.MyField = 0;
obj.Data.MyField = 0;
// All of these accesses should be fine.
Data2 = default;
this.Data2 = default;
obj.Data2 = default;
Data2.MyField = 0;
this.Data2.MyField = 0;
obj.Data2.MyField = 0;
}
}
[Access(typeof(FriendlyClass),
Self = AccessPermissions.Write,
Friend = AccessPermissions.Write,
Other = AccessPermissions.Write)]
public sealed class MemberNobodyCanWrite
{
[Access(typeof(FriendlyClass),
Self = AccessPermissions.None,
Friend = AccessPermissions.None,
Other = AccessPermissions.None)]
public MyData Data = default;
public MyData Data2 = default;
public void TestMemberNobodyCanWrite(TypeNobodyCanWrite obj)
{
// None of these accesses should be allowed.
Data = default;
this.Data = default;
obj.Data = default;
Data.MyField = 0;
this.Data.MyField = 0;
obj.Data.MyField = 0;
// All of these accesses should be fine.
Data2 = default;
this.Data2 = default;
obj.Data2 = default;
Data2.MyField = 0;
this.Data2.MyField = 0;
obj.Data2.MyField = 0;
}
}
public sealed class FriendlyClass
{
public void TestTypeNobodyCanWrite(TypeNobodyCanWrite obj)
{
// We shouldn't be able to access any of these, even if we're a friend..
obj.Data = default;
obj.Data.MyField = 0;
// We should be allowed to access all of these, we're friends!
obj.Data2 = default;
obj.Data2.MyField = 0;
}
public void TestMemberNobodyCanWrite(MemberNobodyCanWrite obj)
{
// We shouldn't be able to access any of these, even if we're a friend..
obj.Data = default;
obj.Data.MyField = 0;
// We should be allowed to access all of these, we're friends!
obj.Data2 = default;
obj.Data2.MyField = 0;
}
}
public sealed class OtherClass
{
public void TestTypeNobodyCanWrite(TypeNobodyCanWrite obj)
{
// We shouldn't be able to access any of these, as 'other types' can't..
obj.Data = default;
obj.Data.MyField = 0;
// We should be allowed to access all of these, they let others write!
obj.Data2 = default;
obj.Data2.MyField = 0;
}
public void TestMemberNobodyCanWrite(MemberNobodyCanWrite obj)
{
// We shouldn't be able to access any of these, as 'other types' can't..
obj.Data = default;
obj.Data.MyField = 0;
// We should be allowed to access all of these, they let others write!
obj.Data2 = default;
obj.Data2.MyField = 0;
}
}";
await Verifier(code,
// AUTO-GENERATED DIAGNOSTICS BELOW //
// /0/Test0.cs(34,9): error RA0002: Tried to perform a 'Write' same-type access to member 'Data' in type 'TypeNobodyCanWrite', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(34, 9, 34, 13).WithArguments("a 'Write' same-type", "Data", "TypeNobodyCanWrite", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(35,9): error RA0002: Tried to perform a 'Write' same-type access to member 'Data' in type 'TypeNobodyCanWrite', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(35, 9, 35, 18).WithArguments("a 'Write' same-type", "Data", "TypeNobodyCanWrite", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(36,9): error RA0002: Tried to perform a 'Write' same-type access to member 'Data' in type 'TypeNobodyCanWrite', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(36, 9, 36, 17).WithArguments("a 'Write' same-type", "Data", "TypeNobodyCanWrite", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(38,9): error RA0002: Tried to perform a 'Write' same-type access to member 'Data' in type 'TypeNobodyCanWrite', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(38, 9, 38, 13).WithArguments("a 'Write' same-type", "Data", "TypeNobodyCanWrite", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(39,9): error RA0002: Tried to perform a 'Write' same-type access to member 'Data' in type 'TypeNobodyCanWrite', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(39, 9, 39, 18).WithArguments("a 'Write' same-type", "Data", "TypeNobodyCanWrite", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(40,9): error RA0002: Tried to perform a 'Write' same-type access to member 'Data' in type 'TypeNobodyCanWrite', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(40, 9, 40, 17).WithArguments("a 'Write' same-type", "Data", "TypeNobodyCanWrite", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(70,9): error RA0002: Tried to perform a 'Write' same-type access to member 'Data' in type 'MemberNobodyCanWrite', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(70, 9, 70, 13).WithArguments("a 'Write' same-type", "Data", "MemberNobodyCanWrite", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(71,9): error RA0002: Tried to perform a 'Write' same-type access to member 'Data' in type 'MemberNobodyCanWrite', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(71, 9, 71, 18).WithArguments("a 'Write' same-type", "Data", "MemberNobodyCanWrite", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(72,9): error RA0002: Tried to perform a 'Write' other-type access to member 'Data' in type 'TypeNobodyCanWrite', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(72, 9, 72, 17).WithArguments("a 'Write' other-type", "Data", "TypeNobodyCanWrite", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(74,9): error RA0002: Tried to perform a 'Write' same-type access to member 'Data' in type 'MemberNobodyCanWrite', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(74, 9, 74, 13).WithArguments("a 'Write' same-type", "Data", "MemberNobodyCanWrite", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(75,9): error RA0002: Tried to perform a 'Write' same-type access to member 'Data' in type 'MemberNobodyCanWrite', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(75, 9, 75, 18).WithArguments("a 'Write' same-type", "Data", "MemberNobodyCanWrite", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(76,9): error RA0002: Tried to perform a 'Write' other-type access to member 'Data' in type 'TypeNobodyCanWrite', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(76, 9, 76, 17).WithArguments("a 'Write' other-type", "Data", "TypeNobodyCanWrite", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(94,9): error RA0002: Tried to perform a 'Write' friend-type access to member 'Data' in type 'TypeNobodyCanWrite', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(94, 9, 94, 17).WithArguments("a 'Write' friend-type", "Data", "TypeNobodyCanWrite", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(95,9): error RA0002: Tried to perform a 'Write' friend-type access to member 'Data' in type 'TypeNobodyCanWrite', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(95, 9, 95, 17).WithArguments("a 'Write' friend-type", "Data", "TypeNobodyCanWrite", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(105,9): error RA0002: Tried to perform a 'Write' friend-type access to member 'Data' in type 'MemberNobodyCanWrite', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(105, 9, 105, 17).WithArguments("a 'Write' friend-type", "Data", "MemberNobodyCanWrite", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(106,9): error RA0002: Tried to perform a 'Write' friend-type access to member 'Data' in type 'MemberNobodyCanWrite', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(106, 9, 106, 17).WithArguments("a 'Write' friend-type", "Data", "MemberNobodyCanWrite", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(119,9): error RA0002: Tried to perform a 'Write' other-type access to member 'Data' in type 'TypeNobodyCanWrite', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(119, 9, 119, 17).WithArguments("a 'Write' other-type", "Data", "TypeNobodyCanWrite", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(120,9): error RA0002: Tried to perform a 'Write' other-type access to member 'Data' in type 'TypeNobodyCanWrite', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(120, 9, 120, 17).WithArguments("a 'Write' other-type", "Data", "TypeNobodyCanWrite", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(130,9): error RA0002: Tried to perform a 'Write' other-type access to member 'Data' in type 'MemberNobodyCanWrite', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(130, 9, 130, 17).WithArguments("a 'Write' other-type", "Data", "MemberNobodyCanWrite", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(131,9): error RA0002: Tried to perform a 'Write' other-type access to member 'Data' in type 'MemberNobodyCanWrite', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(131, 9, 131, 17).WithArguments("a 'Write' other-type", "Data", "MemberNobodyCanWrite", "having no", "Member Permissions: ---------")
);
}
[Test]
public async Task ExecuteTest()
{
const string code = @"
using System;
using Robust.Shared.Analyzers;
// ReSharper disable RedundantAssignment
// ReSharper disable UnusedVariable
// ReSharper disable ArrangeThisQualifier
// ReSharper disable UnusedMember.Global
// ReSharper disable UnusedType.Global
// ReSharper disable NotAccessedField.Global
// ReSharper disable RedundantDefaultMemberInitializer
// ReSharper disable ReturnValueOfPureMethodIsNotUsed
public struct MyData
{
public int MyField;
public void MyMethod() {}
}
[Access(typeof(FriendlyClass),
Self = AccessPermissions.None,
Friend = AccessPermissions.None,
Other = AccessPermissions.None)]
public sealed class TypeNobodyCanExecute
{
public MyData Data = default;
[Access(typeof(FriendlyClass),
Self = AccessPermissions.Execute,
Friend = AccessPermissions.Execute,
Other = AccessPermissions.Execute)]
public MyData Data2 = default;
public void MyMethod() {}
[Access(typeof(FriendlyClass),
Self = AccessPermissions.Execute,
Friend = AccessPermissions.Execute,
Other = AccessPermissions.Execute)]
public void MyMethod2() {}
public void TestTypeNobodyCanExecute(TypeNobodyCanExecute obj)
{
// None of these accesses should be allowed.
MyMethod();
this.MyMethod();
obj.MyMethod();
Data.MyMethod();
this.Data.MyMethod();
obj.Data.MyMethod();
Data.MyField.ToString();
this.Data.MyField.ToString();
obj.Data.MyField.ToString();
// All of these accesses should be fine.
MyMethod2();
this.MyMethod2();
obj.MyMethod2();
Data2.MyMethod();
this.Data2.MyMethod();
obj.Data2.MyMethod();
Data2.MyField.ToString();
this.Data2.ToString();
obj.Data2.ToString();
}
}
[Access(typeof(FriendlyClass),
Self = AccessPermissions.Execute,
Friend = AccessPermissions.Execute,
Other = AccessPermissions.Execute)]
public sealed class MemberNobodyCanExecute
{
[Access(typeof(FriendlyClass),
Self = AccessPermissions.None,
Friend = AccessPermissions.None,
Other = AccessPermissions.None)]
public MyData Data = default;
public MyData Data2 = default;
[Access(typeof(FriendlyClass),
Self = AccessPermissions.None,
Friend = AccessPermissions.None,
Other = AccessPermissions.None)]
public void MyMethod() {}
public void MyMethod2() {}
public void TestMemberNobodyCanExecute(TypeNobodyCanExecute obj)
{
// None of these accesses should be allowed.
MyMethod();
this.MyMethod();
obj.MyMethod();
Data.MyMethod();
this.Data.MyMethod();
obj.Data.MyMethod();
Data.MyField.ToString();
this.Data.MyField.ToString();
obj.Data.MyField.ToString();
// All of these accesses should be fine.
MyMethod2();
this.MyMethod2();
obj.MyMethod2();
Data2.MyMethod();
this.Data2.MyMethod();
obj.Data2.MyMethod();
Data2.MyField.ToString();
this.Data2.ToString();
obj.Data2.ToString();
}
}
public sealed class FriendlyClass
{
public void TestTypeNobodyCanExecute(TypeNobodyCanExecute obj)
{
// We shouldn't be able to access any of these, even if we're a friend..
obj.MyMethod();
obj.Data.MyMethod();
obj.Data.MyField.ToString();
// We should be allowed to access all of these, we're friends!
obj.MyMethod2();
obj.Data2.MyMethod();
obj.Data2.MyField.ToString();
}
public void TestMemberNobodyCanExecute(MemberNobodyCanExecute obj)
{
// We shouldn't be able to access any of these, even if we're a friend..
obj.MyMethod();
obj.Data.MyMethod();
obj.Data.MyField.ToString();
// We should be allowed to access all of these, we're friends!
obj.MyMethod2();
obj.Data2.MyMethod();
obj.Data2.MyField.ToString();
}
}
public sealed class OtherClass
{
public void TestTypeNobodyCanExecute(TypeNobodyCanExecute obj)
{
// We shouldn't be able to access any of these, as 'other types' can't..
obj.MyMethod();
obj.Data.MyMethod();
obj.Data.MyField.ToString();
// We should be allowed to access all of these, they let others Execute!
obj.MyMethod2();
obj.Data2.MyMethod();
obj.Data2.MyField.ToString();
}
public void TestMemberNobodyCanExecute(MemberNobodyCanExecute obj)
{
// We shouldn't be able to access any of these, as 'other types' can't..
obj.MyMethod();
obj.Data.MyMethod();
obj.Data.MyField.ToString();
// We should be allowed to access all of these, they let others Execute!
obj.MyMethod2();
obj.Data2.MyMethod();
obj.Data2.MyField.ToString();
}
}";
await Verifier(code,
// AUTO-GENERATED DIAGNOSTICS BELOW //
// /0/Test0.cs(44,9): error RA0002: Tried to perform an 'Execute' same-type access to member 'MyMethod' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(44, 9, 44, 19).WithArguments("an 'Execute' same-type", "MyMethod", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(45,9): error RA0002: Tried to perform an 'Execute' same-type access to member 'MyMethod' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(45, 9, 45, 24).WithArguments("an 'Execute' same-type", "MyMethod", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(46,9): error RA0002: Tried to perform an 'Execute' same-type access to member 'MyMethod' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(46, 9, 46, 23).WithArguments("an 'Execute' same-type", "MyMethod", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(48,9): error RA0002: Tried to perform an 'Execute' same-type access to member 'Data' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(48, 9, 48, 13).WithArguments("an 'Execute' same-type", "Data", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(49,9): error RA0002: Tried to perform an 'Execute' same-type access to member 'Data' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(49, 9, 49, 18).WithArguments("an 'Execute' same-type", "Data", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(50,9): error RA0002: Tried to perform an 'Execute' same-type access to member 'Data' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(50, 9, 50, 17).WithArguments("an 'Execute' same-type", "Data", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(52,9): error RA0002: Tried to perform an 'Execute' same-type access to member 'Data' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(52, 9, 52, 13).WithArguments("an 'Execute' same-type", "Data", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(53,9): error RA0002: Tried to perform an 'Execute' same-type access to member 'Data' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(53, 9, 53, 18).WithArguments("an 'Execute' same-type", "Data", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(54,9): error RA0002: Tried to perform an 'Execute' same-type access to member 'Data' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(54, 9, 54, 17).WithArguments("an 'Execute' same-type", "Data", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(96,9): error RA0002: Tried to perform an 'Execute' same-type access to member 'MyMethod' in type 'MemberNobodyCanExecute', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(96, 9, 96, 19).WithArguments("an 'Execute' same-type", "MyMethod", "MemberNobodyCanExecute", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(97,9): error RA0002: Tried to perform an 'Execute' same-type access to member 'MyMethod' in type 'MemberNobodyCanExecute', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(97, 9, 97, 24).WithArguments("an 'Execute' same-type", "MyMethod", "MemberNobodyCanExecute", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(98,9): error RA0002: Tried to perform an 'Execute' other-type access to member 'MyMethod' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(98, 9, 98, 23).WithArguments("an 'Execute' other-type", "MyMethod", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(100,9): error RA0002: Tried to perform an 'Execute' same-type access to member 'Data' in type 'MemberNobodyCanExecute', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(100, 9, 100, 13).WithArguments("an 'Execute' same-type", "Data", "MemberNobodyCanExecute", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(101,9): error RA0002: Tried to perform an 'Execute' same-type access to member 'Data' in type 'MemberNobodyCanExecute', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(101, 9, 101, 18).WithArguments("an 'Execute' same-type", "Data", "MemberNobodyCanExecute", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(102,9): error RA0002: Tried to perform an 'Execute' other-type access to member 'Data' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(102, 9, 102, 17).WithArguments("an 'Execute' other-type", "Data", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(104,9): error RA0002: Tried to perform an 'Execute' same-type access to member 'Data' in type 'MemberNobodyCanExecute', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(104, 9, 104, 13).WithArguments("an 'Execute' same-type", "Data", "MemberNobodyCanExecute", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(105,9): error RA0002: Tried to perform an 'Execute' same-type access to member 'Data' in type 'MemberNobodyCanExecute', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(105, 9, 105, 18).WithArguments("an 'Execute' same-type", "Data", "MemberNobodyCanExecute", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(106,9): error RA0002: Tried to perform an 'Execute' other-type access to member 'Data' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(106, 9, 106, 17).WithArguments("an 'Execute' other-type", "Data", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(128,9): error RA0002: Tried to perform an 'Execute' friend-type access to member 'MyMethod' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(128, 9, 128, 23).WithArguments("an 'Execute' friend-type", "MyMethod", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(129,9): error RA0002: Tried to perform an 'Execute' friend-type access to member 'Data' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(129, 9, 129, 17).WithArguments("an 'Execute' friend-type", "Data", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(130,9): error RA0002: Tried to perform an 'Execute' friend-type access to member 'Data' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(130, 9, 130, 17).WithArguments("an 'Execute' friend-type", "Data", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(141,9): error RA0002: Tried to perform an 'Execute' friend-type access to member 'MyMethod' in type 'MemberNobodyCanExecute', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(141, 9, 141, 23).WithArguments("an 'Execute' friend-type", "MyMethod", "MemberNobodyCanExecute", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(142,9): error RA0002: Tried to perform an 'Execute' friend-type access to member 'Data' in type 'MemberNobodyCanExecute', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(142, 9, 142, 17).WithArguments("an 'Execute' friend-type", "Data", "MemberNobodyCanExecute", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(143,9): error RA0002: Tried to perform an 'Execute' friend-type access to member 'Data' in type 'MemberNobodyCanExecute', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(143, 9, 143, 17).WithArguments("an 'Execute' friend-type", "Data", "MemberNobodyCanExecute", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(157,9): error RA0002: Tried to perform an 'Execute' other-type access to member 'MyMethod' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(157, 9, 157, 23).WithArguments("an 'Execute' other-type", "MyMethod", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(158,9): error RA0002: Tried to perform an 'Execute' other-type access to member 'Data' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(158, 9, 158, 17).WithArguments("an 'Execute' other-type", "Data", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(159,9): error RA0002: Tried to perform an 'Execute' other-type access to member 'Data' in type 'TypeNobodyCanExecute', despite having no access. Type Permissions: ---------
VerifyCS.Diagnostic().WithSpan(159, 9, 159, 17).WithArguments("an 'Execute' other-type", "Data", "TypeNobodyCanExecute", "having no", "Type Permissions: ---------"),
// /0/Test0.cs(170,9): error RA0002: Tried to perform an 'Execute' other-type access to member 'MyMethod' in type 'MemberNobodyCanExecute', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(170, 9, 170, 23).WithArguments("an 'Execute' other-type", "MyMethod", "MemberNobodyCanExecute", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(171,9): error RA0002: Tried to perform an 'Execute' other-type access to member 'Data' in type 'MemberNobodyCanExecute', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(171, 9, 171, 17).WithArguments("an 'Execute' other-type", "Data", "MemberNobodyCanExecute", "having no", "Member Permissions: ---------"),
// /0/Test0.cs(172,9): error RA0002: Tried to perform an 'Execute' other-type access to member 'Data' in type 'MemberNobodyCanExecute', despite having no access. Member Permissions: ---------
VerifyCS.Diagnostic().WithSpan(172, 9, 172, 17).WithArguments("an 'Execute' other-type", "Data", "MemberNobodyCanExecute", "having no", "Member Permissions: ---------")
);
}
}

View File

@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\MSBuild\Robust.Properties.targets" />
<Import Project="..\MSBuild\Robust.Engine.props" />
<PropertyGroup>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzer.Testing" Version="1.1.1"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.NUnit" Version="1.1.1"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1"/>
<PackageReference Include="NUnit" Version="3.13.2"/>
<PackageReference Include="NUnit.ConsoleRunner" Version="3.15.0"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1"/>
<PackageReference Include="NUnit.Analyzers" Version="3.3.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Robust.Analyzers\Robust.Analyzers.csproj"/>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,253 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
using Robust.Shared.Analyzers.Implementation;
namespace Robust.Analyzers
{
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class AccessAnalyzer : DiagnosticAnalyzer
{
private const string AccessAttributeType = "Robust.Shared.Analyzers.AccessAttribute";
private const string PureAttributeType = "System.Diagnostics.Contracts.PureAttribute";
[SuppressMessage("ReSharper", "RS2008")]
private static readonly DiagnosticDescriptor AccessRule = new (
Diagnostics.IdAccess,
"Invalid access",
"Tried to perform {0} access to member '{1}' in type '{2}', despite {3} access. {4}.",
"Usage",
DiagnosticSeverity.Error,
true,
"Make sure to give the accessing type the correct access permissions.");
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics =>
ImmutableArray.Create(AccessRule);
public override void Initialize(AnalysisContext context)
{
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
context.EnableConcurrentExecution();
context.RegisterOperationAction(CheckFriendship,
OperationKind.FieldReference,
OperationKind.PropertyReference,
OperationKind.MethodReference,
OperationKind.Invocation);
}
private void CheckFriendship(OperationAnalysisContext context)
{
var operation = context.Operation;
// The symbol representing the member being accessed.
ISymbol member;
// The operation to target when determining access type.
IOperation targetAccess;
switch (operation)
{
case IMemberReferenceOperation memberRef:
{
member = memberRef.Member;
targetAccess = memberRef.Parent;
break;
}
case IInvocationOperation invocation:
{
member = invocation.TargetMethod;
targetAccess = invocation;
break;
}
default:
return;
}
// Get the info of the type defining the member, so we can check the attributes later...
var accessedType = member.ContainingType;
// Get the attributes
var friendAttribute = context.Compilation.GetTypeByMetadataName(AccessAttributeType);
// Get the type that is containing this expression, or, the type where this is happening.
if (context.ContainingSymbol?.ContainingType is not {} accessingType)
return;
// Determine which type of access is happening here... Read, write or execute?
var accessAttempt = DetermineAccess(context, targetAccess, operation);
// Check whether this is a "self" access, including inheritors.
var selfAccess = InheritsFromOrEquals(accessingType, accessedType);
// Helper function to deduplicate attribute-checking code.
bool CheckAttributeFriendship(AttributeData attribute, bool isMemberAttribute)
{
// If the attribute isn't the friend attribute, we don't care about it.
if (!SymbolEqualityComparer.Default.Equals(attribute.AttributeClass, friendAttribute))
return false;
var self = AccessAttribute.SelfDefaultPermissions;
var friends = AccessAttribute.FriendDefaultPermissions;
var others = AccessAttribute.OtherDefaultPermissions;
foreach (var kv in attribute.NamedArguments)
{
if (kv.Value.Value is not byte value)
continue;
var permissions = (AccessPermissions) value;
switch (kv.Key)
{
case nameof(AccessAttribute.Self):
{
self = permissions;
break;
}
case nameof(AccessAttribute.Friend):
{
friends = permissions;
break;
}
case nameof(AccessAttribute.Other):
{
others = permissions;
break;
}
default:
continue;
}
}
// By default, we will check the "other" permissions unless we find we're dealing with a friend or self.
var permissionCheck = others;
// Human-readable relation between accessing and accessed types.
var accessingRelation = "other-type";
if (!selfAccess)
{
// This is not a self-access, so we need to determine whether the accessing type is a friend.
// Check all types allowed in the friend attribute. (We assume there's only one constructor arg.)
var types = attribute.ConstructorArguments[0].Values;
foreach (var constant in types)
{
// Check if the value is a type...
if (constant.Value is not INamedTypeSymbol friendType)
continue;
// Check if the accessing type is specified in the attribute...
if (!InheritsFromOrEquals(accessingType, friendType))
continue;
// Set the permissions check to the friend permissions!
permissionCheck = friends;
accessingRelation = "friend-type";
break;
}
}
else
{
// Self-access, so simply set the permissions check to self.
permissionCheck = self;
accessingRelation = "same-type";
}
// If we allow this access, return! All is good.
if ((accessAttempt & permissionCheck) != 0)
return true;
// Access denied! Report an error.
context.ReportDiagnostic(
Diagnostic.Create(AccessRule, operation.Syntax.GetLocation(),
$"a{(accessAttempt == AccessPermissions.Execute ? "n" : "")} '{accessAttempt}' {accessingRelation}",
$"{member.Name}",
$"{accessedType.Name}",
$"{(permissionCheck == AccessPermissions.None ? "having no" : $"only having '{permissionCheck}'")}",
$"{(isMemberAttribute ? "Member" : "Type")} Permissions: {self.ToUnixPermissions()}{friends.ToUnixPermissions()}{others.ToUnixPermissions()}"));
// Only return ONE error.
return true;
}
// Check attributes in the member first, since they take priority and can override type restrictions.
foreach (var attribute in member.GetAttributes())
{
if(CheckAttributeFriendship(attribute, true))
return;
}
// Check attributes in the type containing the member last.
foreach (var attribute in accessedType.GetAttributes())
{
if(CheckAttributeFriendship(attribute, false))
return;
}
}
private static AccessPermissions DetermineAccess(OperationAnalysisContext context, IOperation operation, IOperation original)
{
switch (operation)
{
case IAssignmentOperation assign:
{
return assign.Target.Equals(original) ? AccessPermissions.Write : AccessPermissions.Read;
}
case IInvocationOperation invoke:
{
var pureAttribute = context.Compilation.GetTypeByMetadataName(PureAttributeType);
foreach (var attribute in invoke.TargetMethod.GetAttributes())
{
// Pure methods are treated as read accesses.
if (SymbolEqualityComparer.Default.Equals(attribute.AttributeClass, pureAttribute))
return AccessPermissions.Read;
}
return AccessPermissions.Execute;
}
case IMemberReferenceOperation member:
{
return DetermineAccess(context, member.Parent, operation);
}
default:
{
return AccessPermissions.Read;
}
}
}
private bool InheritsFromOrEquals(INamedTypeSymbol type, INamedTypeSymbol baseType)
{
foreach (var otherType in GetBaseTypesAndThis(type))
{
if (SymbolEqualityComparer.Default.Equals(otherType, baseType))
return true;
}
return false;
}
private IEnumerable<INamedTypeSymbol> GetBaseTypesAndThis(INamedTypeSymbol namedType)
{
var current = namedType;
while (current != null)
{
yield return current;
current = current.BaseType;
}
}
}
}

View File

@@ -1,10 +1,15 @@
using Microsoft.CodeAnalysis;
namespace Robust.Generators
namespace Robust.Analyzers;
public static class Diagnostics
{
public static class Diagnostics
{
public static SuppressionDescriptor MeansImplicitAssignment =>
new SuppressionDescriptor("RADC1000", "CS0649", "Marked as implicitly assigned.");
}
public const string IdExplicitInterface = "RA0000";
public const string IdSerializable = "RA0001";
public const string IdAccess = "RA0002";
public const string IdExplicitVirtual = "RA0003";
public const string IdTaskResult = "RA0004";
public static SuppressionDescriptor MeansImplicitAssignment =>
new SuppressionDescriptor("RADC1000", "CS0649", "Marked as implicitly assigned.");
}

View File

@@ -24,14 +24,14 @@ namespace Robust.Analyzers
SyntaxKind.OverrideKeyword
};
public const string DiagnosticId = "RA0000";
private const string Title = "No explicit interface specified";
private const string MessageFormat = "No explicit interface specified";
private const string Description = "Make sure to specify the interface in your method-declaration.";
private const string Category = "Usage";
[SuppressMessage("ReSharper", "RS2008")] private static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, Category, DiagnosticSeverity.Warning, isEnabledByDefault: true, description: Description);
[SuppressMessage("ReSharper", "RS2008")] private static readonly DiagnosticDescriptor Rule = new(
Diagnostics.IdExplicitInterface,
"No explicit interface specified",
"No explicit interface specified",
"Usage",
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "Make sure to specify the interface in your method-declaration.");
private const string RequiresExplicitImplementationAttributeMetadataName =
"Robust.Shared.Analyzers.RequiresExplicitImplementationAttribute";

View File

@@ -0,0 +1,176 @@
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace Robust.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class ExplicitVirtualAnalyzer : DiagnosticAnalyzer
{
internal const string Attribute = "Robust.Shared.Analyzers.VirtualAttribute";
[SuppressMessage("ReSharper", "RS2008")]
private static readonly DiagnosticDescriptor Rule = new(
Diagnostics.IdExplicitVirtual,
"Class must be explicitly marked as [Virtual], abstract, static or sealed",
"Class must be explicitly marked as [Virtual], abstract, static or sealed",
"Usage",
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "Class must be explicitly marked as [Virtual], abstract, static or sealed.");
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);
public override void Initialize(AnalysisContext context)
{
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
context.EnableConcurrentExecution();
context.RegisterSyntaxNodeAction(AnalyzeNode, SyntaxKind.ClassDeclaration);
}
private static bool HasAttribute(INamedTypeSymbol namedTypeSymbol, INamedTypeSymbol attrSymbol)
{
return namedTypeSymbol.GetAttributes()
.Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, attrSymbol));
}
private static void AnalyzeNode(SyntaxNodeAnalysisContext context)
{
var attrSymbol = context.Compilation.GetTypeByMetadataName(Attribute);
var classDecl = (ClassDeclarationSyntax)context.Node;
var classSymbol = context.SemanticModel.GetDeclaredSymbol(classDecl);
if (classSymbol == null)
return;
if (classSymbol.IsSealed || classSymbol.IsAbstract || classSymbol.IsStatic)
return;
if (HasAttribute(classSymbol, attrSymbol))
return;
var diag = Diagnostic.Create(Rule, classDecl.Keyword.GetLocation());
context.ReportDiagnostic(diag);
}
}
// Doesn't work as I'd hoped: Roslyn doesn't provide an API for global usings and I can't get batch changes to work.
/*
[ExportCodeFixProvider(LanguageNames.CSharp)]
public sealed class ExplicitVirtualCodeFixProvider : CodeFixProvider
{
private const string TitleSealed = "Annotate class as sealed.";
private const string TitleVirtual = "Annotate class as [Virtual].";
private const string TitleAbstract = "Annotate class as abstract.";
private const string TitleStatic = "Annotate class as static.";
public override async Task RegisterCodeFixesAsync(CodeFixContext context)
{
var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken);
foreach (var diagnostic in context.Diagnostics)
{
var span = diagnostic.Location.SourceSpan;
var classDecl = root.FindToken(span.Start).Parent.AncestorsAndSelf().OfType<ClassDeclarationSyntax>()
.First();
context.RegisterCodeFix(
CodeAction.Create(
TitleVirtual,
c => FixVirtualAsync(context.Document, classDecl, c),
TitleVirtual),
diagnostic);
context.RegisterCodeFix(
CodeAction.Create(
TitleStatic,
c => FixStaticAsync(context.Document, classDecl, c),
TitleStatic),
diagnostic);
context.RegisterCodeFix(
CodeAction.Create(
TitleSealed,
c => FixSealedAsync(context.Document, classDecl, c),
TitleSealed),
diagnostic);
context.RegisterCodeFix(
CodeAction.Create(
TitleAbstract,
c => FixAbstractAsync(context.Document, classDecl, c),
TitleAbstract),
diagnostic);
}
}
private async Task<Document> FixVirtualAsync(
Document document,
ClassDeclarationSyntax classDecl,
CancellationToken cancellationToken)
{
var ns = "Robust.Shared.Analyzers";
var attrib = SyntaxFactory.Attribute(SyntaxFactory.ParseName("Virtual"));
var newClassDecl = classDecl.AddAttributeLists(
SyntaxFactory.AttributeList(SyntaxFactory.SeparatedList(new[] { attrib })));
var root = (CompilationUnitSyntax)await document.GetSyntaxRootAsync(cancellationToken);
root = root.ReplaceNode(classDecl, newClassDecl);
var options = await document.GetOptionsAsync(cancellationToken);
if (root.Usings.All(u => u.Name.ToString() != ns))
{
root = root.AddUsings(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName(ns)));
}
return document.WithSyntaxRoot(root);
}
private async Task<Document> FixStaticAsync(
Document document,
ClassDeclarationSyntax classDecl,
CancellationToken cancellationToken)
{
var newClassDecl = classDecl.AddModifiers(SyntaxFactory.Token(SyntaxKind.StaticKeyword));
var root = (CompilationUnitSyntax)await document.GetSyntaxRootAsync(cancellationToken);
root = root.ReplaceNode(classDecl, newClassDecl);
return document.WithSyntaxRoot(root);
}
private async Task<Document> FixAbstractAsync(
Document document,
ClassDeclarationSyntax classDecl,
CancellationToken cancellationToken)
{
var newClassDecl = classDecl.AddModifiers(SyntaxFactory.Token(SyntaxKind.AbstractKeyword));
var root = (CompilationUnitSyntax)await document.GetSyntaxRootAsync(cancellationToken);
root = root.ReplaceNode(classDecl, newClassDecl);
return document.WithSyntaxRoot(root);
}
private async Task<Document> FixSealedAsync(
Document document,
ClassDeclarationSyntax classDecl,
CancellationToken cancellationToken)
{
var newClassDecl = classDecl.AddModifiers(SyntaxFactory.Token(SyntaxKind.SealedKeyword));
var root = (CompilationUnitSyntax)await document.GetSyntaxRootAsync(cancellationToken);
root = root.ReplaceNode(classDecl, newClassDecl);
return document.WithSyntaxRoot(root);
}
public override FixAllProvider GetFixAllProvider() => WellKnownFixAllProviders.BatchFixer;
public override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(Diagnostics.IdExplicitVirtual);
}
*/

View File

@@ -1,129 +0,0 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace Robust.Analyzers
{
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class FriendAnalyzer : DiagnosticAnalyzer
{
const string FriendAttribute = "Robust.Shared.Analyzers.FriendAttribute";
public const string DiagnosticId = "RA0002";
private const string Title = "Tried to access friend-only member";
private const string MessageFormat = "Tried to access member \"{0}\" in class \"{1}\" which can only be accessed by friend classes";
private const string Description = "Make sure to specify the accessing class in the friends attribute.";
private const string Category = "Usage";
[SuppressMessage("ReSharper", "RS2008")]
private static readonly DiagnosticDescriptor Rule = new (DiagnosticId, Title, MessageFormat, Category, DiagnosticSeverity.Error, true, Description);
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);
public override void Initialize(AnalysisContext context)
{
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
context.EnableConcurrentExecution();
context.RegisterSyntaxNodeAction(CheckFriendship, SyntaxKind.SimpleMemberAccessExpression);
}
private void CheckFriendship(SyntaxNodeAnalysisContext context)
{
if (context.Node is not MemberAccessExpressionSyntax memberAccess)
return;
// We only do something if our parent is one of a few types.
switch (context.Node.Parent)
{
// If we're being assigned...
case AssignmentExpressionSyntax assignParent:
{
if (assignParent.Left != memberAccess)
return;
break;
}
// If we're being invoked...
case InvocationExpressionSyntax:
break;
// Otherwise, do nothing.
default:
return;
}
// Get the friend attribute
var friendAttr = context.Compilation.GetTypeByMetadataName(FriendAttribute);
// Get the type that is containing this expression, or, the class where this is happening.
if (context.ContainingSymbol?.ContainingType is not { } containingType)
return;
// We check all of our children and get only the identifiers.
foreach (var identifier in memberAccess.ChildNodes().Select(node => node as IdentifierNameSyntax))
{
if (identifier == null) continue;
// Get the type info of the identifier, so we can check the attributes...
if (context.SemanticModel.GetTypeInfo(identifier).ConvertedType is not { } type)
continue;
// Same-type access is always fine.
if (SymbolEqualityComparer.Default.Equals(type, containingType))
continue;
// Finally, get all attributes of the type, to check if we have any friend classes.
foreach (var attribute in type.GetAttributes())
{
// If the attribute isn't the friend attribute, continue.
if (!SymbolEqualityComparer.Default.Equals(attribute.AttributeClass, friendAttr))
continue;
// Check all types allowed in the friend attribute. (We assume there's only one constructor arg.)
foreach (var constant in attribute.ConstructorArguments[0].Values)
{
// Check if the value is a type...
if (constant.Value is not INamedTypeSymbol t)
continue;
// If we find that the containing class is specified in the attribute, return! All is good.
if (InheritsFromOrEquals(containingType, t))
return;
}
// Not in a friend class! Report an error.
context.ReportDiagnostic(
Diagnostic.Create(Rule, context.Node.GetLocation(),
$"{context.Node.ToString().Split('.').LastOrDefault()}", $"{type.Name}"));
}
}
}
private bool InheritsFromOrEquals(INamedTypeSymbol type, INamedTypeSymbol baseType)
{
foreach (var otherType in GetBaseTypesAndThis(type))
{
if (SymbolEqualityComparer.Default.Equals(otherType, baseType))
return true;
}
return false;
}
private IEnumerable<INamedTypeSymbol> GetBaseTypesAndThis(INamedTypeSymbol namedType)
{
var current = namedType;
while (current != null)
{
yield return current;
current = current.BaseType;
}
}
}
}

View File

@@ -1,9 +1,7 @@
using System;
using System.Collections.Immutable;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Robust.Generators;
namespace Robust.Analyzers
{

View File

@@ -2,13 +2,19 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>9</LangVersion>
<LangVersion>10</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="3.8.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.0.1" />
</ItemGroup>
<ItemGroup>
<!-- Needed for FriendAnalyzer. -->
<Compile Include="..\Robust.Shared\Analyzers\AccessAttribute.cs" />
<Compile Include="..\Robust.Shared\Analyzers\AccessPermissions.cs" />
</ItemGroup>
</Project>

View File

@@ -17,19 +17,21 @@ namespace Robust.Analyzers
public class SerializableAnalyzer : DiagnosticAnalyzer
{
// Metadata of the analyzer
public const string DiagnosticId = "RA0001";
// You could use LocalizedString but it's a little more complicated for this sample
private const string Title = "Class not marked as (Net)Serializable";
private const string MessageFormat = "Class not marked as (Net)Serializable";
private const string Description = "The class should be marked as (Net)Serializable.";
private const string Category = "Usage";
private const string RequiresSerializableAttributeMetadataName = "Robust.Shared.Analyzers.RequiresSerializableAttribute";
private const string SerializableAttributeMetadataName = "System.SerializableAttribute";
private const string NetSerializableAttributeMetadataName = "Robust.Shared.Serialization.NetSerializableAttribute";
[SuppressMessage("ReSharper", "RS2008")] private static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, Category, DiagnosticSeverity.Warning, isEnabledByDefault: true, description: Description);
[SuppressMessage("ReSharper", "RS2008")] private static readonly DiagnosticDescriptor Rule = new(
Diagnostics.IdSerializable,
"Class not marked as (Net)Serializable",
"Class not marked as (Net)Serializable",
"Usage",
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "The class should be marked as (Net)Serializable.");
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);
@@ -139,7 +141,8 @@ namespace Robust.Analyzers
return document.WithSyntaxRoot(root);
}
public sealed override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(SerializableAnalyzer.DiagnosticId);
public sealed override ImmutableArray<string> FixableDiagnosticIds
=> ImmutableArray.Create(Diagnostics.IdSerializable);
public override FixAllProvider GetFixAllProvider()
{

View File

@@ -0,0 +1,44 @@
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
namespace Robust.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class TaskResultAnalyzer : DiagnosticAnalyzer
{
[SuppressMessage("ReSharper", "RS2008")]
private static readonly DiagnosticDescriptor ResultRule = new DiagnosticDescriptor(
Diagnostics.IdTaskResult,
"Risk of deadlock from accessing Task<T>.Result",
"Accessing Task<T>.Result is dangerous and can cause deadlocks in some contexts. If you understand how this works and are certain that you aren't causing a deadlock here, mute this error with #pragma.",
"Usage",
DiagnosticSeverity.Error,
true);
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics =>
ImmutableArray.Create(ResultRule);
public override void Initialize(AnalysisContext context)
{
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
context.EnableConcurrentExecution();
context.RegisterOperationAction(Check, OperationKind.PropertyReference);
}
private static void Check(OperationAnalysisContext context)
{
var taskType = context.Compilation.GetTypeByMetadataName("System.Threading.Tasks.Task`1");
var operation = (IPropertyReferenceOperation) context.Operation;
var member = operation.Member;
if (member.Name == "Result" && taskType.Equals(member.ContainingType.ConstructedFrom, SymbolEqualityComparer.Default))
{
var diag = Diagnostic.Create(ResultRule, operation.Syntax.GetLocation());
context.ReportDiagnostic(diag);
}
}
}

View File

@@ -0,0 +1,53 @@
using System.Collections.Generic;
using System.Globalization;
using BenchmarkDotNet.Analysers;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Filters;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Order;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Validators;
using Robust.Benchmarks.Exporters;
namespace Robust.Benchmarks.Configs;
public sealed class DefaultSQLConfig : IConfig
{
public static readonly IConfig Instance = new DefaultSQLConfig();
private DefaultSQLConfig(){}
public IEnumerable<IExporter> GetExporters()
{
yield return SQLExporter.Default;
}
public IEnumerable<IColumnProvider> GetColumnProviders() => DefaultConfig.Instance.GetColumnProviders();
public IEnumerable<ILogger> GetLoggers() => DefaultConfig.Instance.GetLoggers();
public IEnumerable<IDiagnoser> GetDiagnosers() => DefaultConfig.Instance.GetDiagnosers();
public IEnumerable<IAnalyser> GetAnalysers() => DefaultConfig.Instance.GetAnalysers();
public IEnumerable<Job> GetJobs() => DefaultConfig.Instance.GetJobs();
public IEnumerable<IValidator> GetValidators() => DefaultConfig.Instance.GetValidators();
public IEnumerable<HardwareCounter> GetHardwareCounters() => DefaultConfig.Instance.GetHardwareCounters();
public IEnumerable<IFilter> GetFilters() => DefaultConfig.Instance.GetFilters();
public IEnumerable<BenchmarkLogicalGroupRule> GetLogicalGroupRules() => DefaultConfig.Instance.GetLogicalGroupRules();
public IOrderer Orderer => DefaultConfig.Instance.Orderer!;
public SummaryStyle SummaryStyle => DefaultConfig.Instance.SummaryStyle;
public ConfigUnionRule UnionRule => DefaultConfig.Instance.UnionRule;
public string ArtifactsPath => DefaultConfig.Instance.ArtifactsPath;
public CultureInfo CultureInfo => DefaultConfig.Instance.CultureInfo!;
public ConfigOptions Options => DefaultConfig.Instance.Options;
}

View File

@@ -0,0 +1,54 @@
using BenchmarkDotNet.Attributes;
using JetBrains.Annotations;
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.UnitTesting.Server;
namespace Robust.Benchmarks.EntityManager;
[Virtual]
public class AddRemoveComponentBenchmark
{
private ISimulation _simulation = default!;
private IEntityManager _entityManager = default!;
[UsedImplicitly]
[Params(1, 10, 100, 1000)]
public int N;
[GlobalSetup]
public void GlobalSetup()
{
_simulation = RobustServerSimulation
.NewSimulation()
.RegisterComponents(f => f.RegisterClass<A>())
.InitializeInstance();
_entityManager = _simulation.Resolve<IEntityManager>();
var coords = new MapCoordinates(0, 0, new MapId(1));
_simulation.AddMap(coords.MapId);
for (var i = 0; i < N; i++)
{
_entityManager.SpawnEntity(null, coords);
}
}
[Benchmark]
public void AddRemoveComponent()
{
for (var i = 2; i <= N+1; i++)
{
var uid = new EntityUid(i);
_entityManager.AddComponent<A>(uid);
_entityManager.RemoveComponent<A>(uid);
}
}
[ComponentProtoName("A")]
public sealed class A : Component
{
}
}

View File

@@ -0,0 +1,225 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading;
using BenchmarkDotNet.Attributes;
using Robust.Shared.GameObjects;
namespace Robust.Benchmarks.EntityManager;
public class ComponentIndexBenchmark
{
// Just a bunch of types to bloat the test lists.
private readonly CompIndexFetcher _compIndexFetcherDirect;
private readonly IFetcher _compIndexFetcher;
private readonly DictFetcher _dictFetcherDirect;
private readonly IFetcher _dictFetcher;
public ComponentIndexBenchmark()
{
_compIndexFetcherDirect = new CompIndexFetcher();
_compIndexFetcher = _compIndexFetcherDirect;
_dictFetcherDirect = new DictFetcher();
_dictFetcher = _dictFetcherDirect;
}
[GlobalSetup]
public void Setup()
{
var types = typeof(ComponentIndexBenchmark)
.GetNestedTypes(BindingFlags.NonPublic)
.Where(t => t.Name.StartsWith("TestType"))
.ToArray();
_compIndexFetcher.Init(types);
_dictFetcher.Init(types);
}
[Benchmark]
public int BenchCompIndex() => _compIndexFetcher.Get<TestType50>();
[Benchmark]
public int BenchDict() => _dictFetcher.Get<TestType50>();
[Benchmark]
public int BenchCompIndexDirect() => _compIndexFetcherDirect.Get<TestType50>();
[Benchmark]
public int BenchDictDirect() => _dictFetcherDirect.Get<TestType50>();
private static CompIdx ArrayIndexFor<T>() => CompArrayIndex<T>.Idx;
private static int _compIndexMaster = -1;
private static class CompArrayIndex<T>
{
// ReSharper disable once StaticMemberInGenericType
public static readonly CompIdx Idx = new(Interlocked.Increment(ref _compIndexMaster));
}
private static CompIdx GetCompIdIndex(Type type)
{
return (CompIdx)typeof(CompArrayIndex<>)
.MakeGenericType(type)
.GetField(nameof(CompArrayIndex<int>.Idx), BindingFlags.Static | BindingFlags.Public)!
.GetValue(null)!;
}
private interface IFetcher
{
void Init(Type[] types);
int Get<T>();
}
private sealed class CompIndexFetcher : IFetcher
{
private int[] _values = Array.Empty<int>();
public void Init(Type[] types)
{
var max = types.Max(t => GetCompIdIndex(t).Value);
_values = new int[max + 1];
var i = 0;
foreach (var type in types)
{
_values[GetCompIdIndex(type).Value] = i++;
}
}
public int Get<T>()
{
return _values[CompArrayIndex<T>.Idx.Value];
}
}
private sealed class DictFetcher : IFetcher
{
private readonly Dictionary<Type, int> _values = new();
public void Init(Type[] types)
{
var i = 0;
foreach (var type in types)
{
_values[type] = i++;
}
}
public int Get<T>()
{
return _values[typeof(T)];
}
}
// Just a bunch of types to pad the size of the arrays and such.
// @formatter:off
// ReSharper disable UnusedType.Local
private sealed class TestType1{}
private sealed class TestType2{}
private sealed class TestType3{}
private sealed class TestType4{}
private sealed class TestType5{}
private sealed class TestType6{}
private sealed class TestType7{}
private sealed class TestType8{}
private sealed class TestType9{}
private sealed class TestType10{}
private sealed class TestType11{}
private sealed class TestType12{}
private sealed class TestType13{}
private sealed class TestType14{}
private sealed class TestType15{}
private sealed class TestType16{}
private sealed class TestType17{}
private sealed class TestType18{}
private sealed class TestType19{}
private sealed class TestType20{}
private sealed class TestType21{}
private sealed class TestType22{}
private sealed class TestType23{}
private sealed class TestType24{}
private sealed class TestType25{}
private sealed class TestType26{}
private sealed class TestType27{}
private sealed class TestType28{}
private sealed class TestType29{}
private sealed class TestType30{}
private sealed class TestType31{}
private sealed class TestType32{}
private sealed class TestType33{}
private sealed class TestType34{}
private sealed class TestType35{}
private sealed class TestType36{}
private sealed class TestType37{}
private sealed class TestType38{}
private sealed class TestType39{}
private sealed class TestType40{}
private sealed class TestType41{}
private sealed class TestType42{}
private sealed class TestType43{}
private sealed class TestType44{}
private sealed class TestType45{}
private sealed class TestType46{}
private sealed class TestType47{}
private sealed class TestType48{}
private sealed class TestType49{}
private sealed class TestType50{}
private sealed class TestType51{}
private sealed class TestType52{}
private sealed class TestType53{}
private sealed class TestType54{}
private sealed class TestType55{}
private sealed class TestType56{}
private sealed class TestType57{}
private sealed class TestType58{}
private sealed class TestType59{}
private sealed class TestType60{}
private sealed class TestType61{}
private sealed class TestType62{}
private sealed class TestType63{}
private sealed class TestType64{}
private sealed class TestType65{}
private sealed class TestType66{}
private sealed class TestType67{}
private sealed class TestType68{}
private sealed class TestType69{}
private sealed class TestType70{}
private sealed class TestType71{}
private sealed class TestType72{}
private sealed class TestType73{}
private sealed class TestType74{}
private sealed class TestType75{}
private sealed class TestType76{}
private sealed class TestType77{}
private sealed class TestType78{}
private sealed class TestType79{}
private sealed class TestType80{}
private sealed class TestType81{}
private sealed class TestType82{}
private sealed class TestType83{}
private sealed class TestType84{}
private sealed class TestType85{}
private sealed class TestType86{}
private sealed class TestType87{}
private sealed class TestType88{}
private sealed class TestType89{}
private sealed class TestType90{}
private sealed class TestType91{}
private sealed class TestType92{}
private sealed class TestType93{}
private sealed class TestType94{}
private sealed class TestType95{}
private sealed class TestType96{}
private sealed class TestType97{}
private sealed class TestType98{}
private sealed class TestType99{}
// ReSharper restore UnusedType.Local
// @formatter:on
}

View File

@@ -0,0 +1,61 @@
using System;
using BenchmarkDotNet.Attributes;
using JetBrains.Annotations;
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.UnitTesting.Server;
namespace Robust.Benchmarks.EntityManager;
[Virtual]
public class GetComponentBenchmark
{
private ISimulation _simulation = default!;
private IEntityManager _entityManager = default!;
[UsedImplicitly]
[Params(1, 10, 100, 1000)]
public int N;
public A[] Comps = default!;
[GlobalSetup]
public void GlobalSetup()
{
_simulation = RobustServerSimulation
.NewSimulation()
.RegisterComponents(f => f.RegisterClass<A>())
.InitializeInstance();
_entityManager = _simulation.Resolve<IEntityManager>();
Comps = new A[N+2];
var coords = new MapCoordinates(0, 0, new MapId(1));
_simulation.AddMap(coords.MapId);
for (var i = 0; i < N; i++)
{
var uid = _entityManager.SpawnEntity(null, coords);
_entityManager.AddComponent<A>(uid);
}
}
[Benchmark]
public A[] GetComponent()
{
for (var i = 2; i <= N+1; i++)
{
Comps[i] = _entityManager.GetComponent<A>(new EntityUid(i));
}
// Return something so the JIT doesn't optimize out all the GetComponent calls.
return Comps;
}
[ComponentProtoName("A")]
public sealed class A : Component
{
}
}

View File

@@ -0,0 +1,62 @@
using BenchmarkDotNet.Attributes;
using JetBrains.Annotations;
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.UnitTesting.Server;
namespace Robust.Benchmarks.EntityManager;
[Virtual]
public class SpawnDeleteEntityBenchmark
{
private ISimulation _simulation = default!;
private IEntityManager _entityManager = default!;
private MapCoordinates _mapCoords = MapCoordinates.Nullspace;
private EntityCoordinates _entCoords = EntityCoordinates.Invalid;
[UsedImplicitly]
[Params(1, 10, 100, 1000)]
public int N;
[GlobalSetup]
public void GlobalSetup()
{
_simulation = RobustServerSimulation
.NewSimulation()
.RegisterComponents(f => f.RegisterClass<A>())
.InitializeInstance();
_entityManager = _simulation.Resolve<IEntityManager>();
_mapCoords = new MapCoordinates(0, 0, new MapId(1));
var uid = _simulation.AddMap(_mapCoords.MapId);
_entCoords = new EntityCoordinates(uid, 0, 0);
}
[Benchmark(Baseline = true)]
public void SpawnDeleteEntityMapCoords()
{
for (var i = 0; i < N; i++)
{
var uid = _entityManager.SpawnEntity(null, _mapCoords);
_entityManager.DeleteEntity(uid);
}
}
[Benchmark]
public void SpawnDeleteEntityEntCoords()
{
for (var i = 0; i < N; i++)
{
var uid = _entityManager.SpawnEntity(null, _entCoords);
_entityManager.DeleteEntity(uid);
}
}
[ComponentProtoName("A")]
public sealed class A : Component
{
}
}

View File

@@ -0,0 +1,195 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Reports;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Npgsql;
using Npgsql.Internal;
using Npgsql.Internal.TypeHandlers;
using Npgsql.Internal.TypeHandling;
namespace Robust.Benchmarks.Exporters;
public sealed class SQLExporter : IExporter
{
public static readonly IExporter Default = new SQLExporter();
private SQLExporter(){}
public void ExportToLog(Summary summary, ILogger logger)
{
Export(summary, logger);
}
public IEnumerable<string> ExportToFiles(Summary summary, ILogger consoleLogger)
{
Export(summary, consoleLogger);
return Array.Empty<string>();
}
private bool TryGetEnvironmentVariable(string name, ILogger logger, [NotNullWhen(true)] out string? value)
{
value = Environment.GetEnvironmentVariable(name);
if (value == null)
logger.WriteError($"ROBUST_BENCHMARKS_ENABLE_SQL is set, but {name} is missing.");
return value != null;
}
private void Export(Summary summary, ILogger logger)
{
if (!TryGetEnvironmentVariable("ROBUST_BENCHMARKS_SQL_ADDRESS", logger, out var address) ||
!TryGetEnvironmentVariable("ROBUST_BENCHMARKS_SQL_PORT", logger, out var rawPort) ||
!TryGetEnvironmentVariable("ROBUST_BENCHMARKS_SQL_USER", logger, out var user) ||
!TryGetEnvironmentVariable("ROBUST_BENCHMARKS_SQL_PASSWORD", logger, out var password) ||
!TryGetEnvironmentVariable("ROBUST_BENCHMARKS_SQL_DATABASE", logger, out var db) ||
!TryGetEnvironmentVariable("GITHUB_SHA", logger, out var gitHash))
return;
if (!int.TryParse(rawPort, out var port))
{
logger.WriteError("Failed parsing ROBUST_BENCHMARKS_SQL_PORT to int.");
return;
}
var builder = new DbContextOptionsBuilder<BenchmarkContext>();
var connectionString = new NpgsqlConnectionStringBuilder
{
Host = address,
Port = port,
Database = db,
Username = user,
Password = password
}.ConnectionString;
builder.UseNpgsql(connectionString);
using var ctx = new BenchmarkContext(builder.Options);
try
{
ctx.Database.OpenConnection();
var con = (NpgsqlConnection) ctx.Database.GetDbConnection();
con.TypeMapper.AddTypeResolverFactory(new JsonOverrideTypeHandlerResolverFactory(new JsonSerializerOptions
{
NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals
}));
ctx.Database.Migrate();
ctx.BenchmarkRuns.Add(BenchmarkRun.FromSummary(summary, gitHash));
ctx.SaveChanges();
}
finally
{
ctx.Dispose();
}
}
public string Name => "sql";
}
// https://github.com/npgsql/efcore.pg/issues/1107#issuecomment-945126627
class JsonOverrideTypeHandlerResolverFactory : TypeHandlerResolverFactory
{
private readonly JsonSerializerOptions _options;
public JsonOverrideTypeHandlerResolverFactory(JsonSerializerOptions options)
=> _options = options;
public override TypeHandlerResolver Create(NpgsqlConnector connector)
=> new JsonOverrideTypeHandlerResolver(connector, _options);
public override string? GetDataTypeNameByClrType(Type clrType)
=> null;
public override TypeMappingInfo? GetMappingByDataTypeName(string dataTypeName)
=> null;
class JsonOverrideTypeHandlerResolver : TypeHandlerResolver
{
readonly JsonHandler _jsonbHandler;
internal JsonOverrideTypeHandlerResolver(NpgsqlConnector connector, JsonSerializerOptions options)
=> _jsonbHandler ??= new JsonHandler(
connector.DatabaseInfo.GetPostgresTypeByName("jsonb"),
connector.TextEncoding,
isJsonb: true,
options);
public override NpgsqlTypeHandler? ResolveByDataTypeName(string typeName)
=> typeName == "jsonb" ? _jsonbHandler : null;
public override NpgsqlTypeHandler? ResolveByClrType(Type type)
// You can add any user-defined CLR types which you want mapped to jsonb
=> type == typeof(JsonDocument) ? _jsonbHandler : null;
public override TypeMappingInfo? GetMappingByDataTypeName(string dataTypeName)
=> null; // Let the built-in resolver do this
}
}
public sealed class DesignTimeContextFactoryPostgres : IDesignTimeDbContextFactory<BenchmarkContext>
{
public BenchmarkContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<BenchmarkContext>();
optionsBuilder.UseNpgsql("Server=localhost");
return new BenchmarkContext(optionsBuilder.Options);
}
}
public class BenchmarkContext : DbContext
{
public DbSet<BenchmarkRun> BenchmarkRuns { get; set; } = default!;
public BenchmarkContext() { }
public BenchmarkContext(DbContextOptions<BenchmarkContext> options) : base(options) { }
}
public class BenchmarkRun
{
public int Id { get; set; }
public string GitHash { get; set; } = string.Empty;
[Column(TypeName = "timestamptz")]
public DateTime RunDate { get; set; }
public string Name { get; set; } = string.Empty;
[Column(TypeName = "jsonb")]
public BenchmarkRunReport[] Reports { get; set; } = Array.Empty<BenchmarkRunReport>();
public static BenchmarkRun FromSummary(Summary summary, string gitHash)
{
return new BenchmarkRun
{
Reports = summary.Reports.Select(r => new BenchmarkRunReport
{
Parameters = r.BenchmarkCase.Parameters.Items.Select(p => new BenchmarkRunParameter
{
Name = p.Name,
Value = p.Value
}).ToArray(),
Statistics = r.ResultStatistics
}).ToArray(),
Name = summary.BenchmarksCases.First().FolderInfo,
RunDate = DateTime.UtcNow,
GitHash = gitHash
};
}
}
public class BenchmarkRunReport
{
public BenchmarkRunParameter[] Parameters { get; set; } = Array.Empty<BenchmarkRunParameter>();
public Statistics Statistics { get; set; } = default!;
}
public class BenchmarkRunParameter
{
public string Name { get; set; } = string.Empty;
public object Value { get; set; } = default!;
}

View File

@@ -0,0 +1,55 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Robust.Benchmarks.Exporters;
#nullable disable
namespace Robust.Benchmarks.Migrations
{
[DbContext(typeof(BenchmarkContext))]
[Migration("20220328231938_InitialCreate")]
partial class InitialCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Robust.Benchmarks.Exporters.BenchmarkRun", b =>
{
b.Property<decimal>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("numeric(20,0)");
b.Property<string>("GitHash")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<BenchmarkRunReport[]>("Reports")
.IsRequired()
.HasColumnType("jsonb");
b.Property<DateTime>("RunDate")
.HasColumnType("Date");
b.HasKey("Id");
b.ToTable("BenchmarkRuns");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,35 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Robust.Benchmarks.Exporters;
#nullable disable
namespace Robust.Benchmarks.Migrations
{
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "BenchmarkRuns",
columns: table => new
{
Id = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
GitHash = table.Column<string>(type: "text", nullable: false),
RunDate = table.Column<DateTime>(type: "Date", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Reports = table.Column<BenchmarkRunReport[]>(type: "jsonb", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BenchmarkRuns", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BenchmarkRuns");
}
}
}

View File

@@ -0,0 +1,57 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Robust.Benchmarks.Exporters;
#nullable disable
namespace Robust.Benchmarks.Migrations
{
[DbContext(typeof(BenchmarkContext))]
[Migration("20220510131430_fix-pk")]
partial class fixpk
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Robust.Benchmarks.Exporters.BenchmarkRun", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("GitHash")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<BenchmarkRunReport[]>("Reports")
.IsRequired()
.HasColumnType("jsonb");
b.Property<DateTime>("RunDate")
.HasColumnType("timestamptz");
b.HasKey("Id");
b.ToTable("BenchmarkRuns");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,51 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Robust.Benchmarks.Migrations
{
public partial class fixpk : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "RunDate",
table: "BenchmarkRuns",
type: "timestamptz",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "Date");
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "BenchmarkRuns",
type: "integer",
nullable: false,
oldClrType: typeof(decimal),
oldType: "numeric(20,0)")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "RunDate",
table: "BenchmarkRuns",
type: "Date",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamptz");
migrationBuilder.AlterColumn<decimal>(
name: "Id",
table: "BenchmarkRuns",
type: "numeric(20,0)",
nullable: false,
oldClrType: typeof(int),
oldType: "integer")
.OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
}
}
}

View File

@@ -0,0 +1,55 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Robust.Benchmarks.Exporters;
#nullable disable
namespace Robust.Benchmarks.Migrations
{
[DbContext(typeof(BenchmarkContext))]
partial class BenchmarkContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Robust.Benchmarks.Exporters.BenchmarkRun", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("GitHash")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<BenchmarkRunReport[]>("Reports")
.IsRequired()
.HasColumnType("jsonb");
b.Property<DateTime>("RunDate")
.HasColumnType("timestamptz");
b.HasKey("Id");
b.ToTable("BenchmarkRuns");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,12 +1,17 @@
using BenchmarkDotNet.Attributes;
using Robust.Shared.Analyzers;
namespace Robust.Benchmarks.NumericsHelpers
{
[Virtual]
public class AddBenchmark
{
[Params(32, 128)]
public int N { get; set; }
[Params(1,2)]
public int T { get; set; }
private float[] _inputA = default!;
private float[] _inputB = default!;
private float[] _output = default!;

View File

@@ -1,10 +1,12 @@
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Running;
using System;
using Robust.Benchmarks.Configs;
using Robust.Benchmarks.Exporters;
namespace Robust.Benchmarks
{
internal class Program
internal static class Program
{
// --allCategories=ctg1,ctg2
// --anyCategories=ctg1,ctg2
@@ -16,7 +18,8 @@ namespace Robust.Benchmarks
Console.WriteLine("THE DEBUG BUILD IS ONLY GOOD FOR FIXING A CRASHING BENCHMARK\n");
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, new DebugInProcessConfig());
#else
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
var config = Environment.GetEnvironmentVariable("ROBUST_BENCHMARKS_ENABLE_SQL") != null ? DefaultSQLConfig.Instance : null;
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, config);
#endif
}
}

View File

@@ -6,13 +6,20 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>../bin/Benchmarks</OutputPath>
<OutputType>Exe</OutputType>
<NoWarn>RA0003</NoWarn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Robust.Server\Robust.Server.csproj" />
<ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" />
<ProjectReference Include="..\Robust.UnitTesting\Robust.UnitTesting.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.4" />
</ItemGroup>
<Import Project="..\MSBuild\Robust.Engine.targets" />
</Project>

View File

@@ -1,7 +1,6 @@
using System.Globalization;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Manager.Result;
using Robust.Shared.Serialization.Markdown;
using Robust.Shared.Serialization.Markdown.Validation;
using Robust.Shared.Serialization.Markdown.Value;
@@ -9,7 +8,7 @@ using Robust.Shared.Serialization.TypeSerializers.Interfaces;
namespace Robust.Benchmarks.Serialization
{
public class BenchmarkIntSerializer : ITypeSerializer<int, ValueDataNode>
public sealed class BenchmarkIntSerializer : ITypeSerializer<int, ValueDataNode>
{
public ValidationNode Validate(ISerializationManager serializationManager, ValueDataNode node,
IDependencyCollection dependencies, ISerializationContext? context = null)
@@ -19,10 +18,10 @@ namespace Robust.Benchmarks.Serialization
: new ErrorNode(node, $"Failed parsing int value: {node.Value}");
}
public DeserializationResult Read(ISerializationManager serializationManager, ValueDataNode node,
IDependencyCollection dependencies, bool skipHook, ISerializationContext? context = null)
public int Read(ISerializationManager serializationManager, ValueDataNode node,
IDependencyCollection dependencies, bool skipHook, ISerializationContext? context = null, int _ = default)
{
return new DeserializedValue<int>(int.Parse(node.Value, CultureInfo.InvariantCulture));
return int.Parse(node.Value, CultureInfo.InvariantCulture);
}
public DataNode Write(ISerializationManager serializationManager, int value, bool alwaysWrite = false,

View File

@@ -2,6 +2,7 @@
using System.Linq;
using BenchmarkDotNet.Attributes;
using Robust.Benchmarks.Serialization.Definitions;
using Robust.Shared.Analyzers;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Markdown;
using Robust.Shared.Serialization.Markdown.Mapping;
@@ -13,6 +14,7 @@ using YamlDotNet.RepresentationModel;
namespace Robust.Benchmarks.Serialization.Copy
{
[MemoryDiagnoser]
[Virtual]
public class SerializationCopyBenchmark : SerializationBenchmark
{
public SerializationCopyBenchmark()
@@ -26,7 +28,7 @@ namespace Robust.Benchmarks.Serialization.Copy
var seedMapping = yamlStream.Documents[0].RootNode.ToDataNodeCast<SequenceDataNode>().Cast<MappingDataNode>(0);
Seed = SerializationManager.ReadValueOrThrow<SeedDataDefinition>(seedMapping);
Seed = SerializationManager.Read<SeedDataDefinition>(seedMapping);
}
private const string String = "ABC";
@@ -44,25 +46,25 @@ namespace Robust.Benchmarks.Serialization.Copy
[Benchmark]
public string? CreateCopyString()
{
return SerializationManager.CreateCopy(String);
return SerializationManager.Copy(String);
}
[Benchmark]
public int? CreateCopyInteger()
{
return SerializationManager.CreateCopy(Integer);
return SerializationManager.Copy(Integer);
}
[Benchmark]
public DataDefinitionWithString? CreateCopyDataDefinitionWithString()
{
return SerializationManager.CreateCopy(DataDefinitionWithString);
return SerializationManager.Copy(DataDefinitionWithString);
}
[Benchmark]
public SeedDataDefinition? CreateCopySeedDataDefinition()
{
return SerializationManager.CreateCopy(Seed);
return SerializationManager.Copy(Seed);
}
[Benchmark]

View File

@@ -3,7 +3,7 @@ using Robust.Shared.Serialization;
namespace Robust.Benchmarks.Serialization.Definitions
{
public class BenchmarkFlags
public sealed class BenchmarkFlags
{
public const int Zero = 1 << 0;
public const int ThirtyOne = 1 << 31;

View File

@@ -1,8 +1,10 @@
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Analyzers;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Robust.Benchmarks.Serialization.Definitions
{
[DataDefinition]
[Virtual]
public class DataDefinitionWithString
{
[DataField("string")]

View File

@@ -11,7 +11,7 @@ namespace Robust.Benchmarks.Serialization.Definitions
/// Taken from content.
/// </summary>
[Prototype("seed")]
public class SeedDataDefinition : IPrototype
public sealed class SeedDataDefinition : IPrototype
{
public const string Prototype = @"
- type: seed
@@ -19,6 +19,7 @@ namespace Robust.Benchmarks.Serialization.Definitions
name: tobacco
seedName: tobacco
displayName: tobacco plant
plantRsi: Objects/Specific/Hydroponics/tobacco.rsi
productPrototypes:
- LeavesTobacco
harvestRepeat: Repeat
@@ -36,7 +37,7 @@ namespace Robust.Benchmarks.Serialization.Definitions
Max: 10
PotencyDivisor: 10";
[DataField("id", required: true)] public string ID { get; set; } = default!;
[IdDataFieldAttribute] public string ID { get; set; } = default!;
#region Tracking
[DataField("name")] public string Name { get; set; } = string.Empty;

View File

@@ -1,9 +1,11 @@
using BenchmarkDotNet.Attributes;
using Robust.Shared.Analyzers;
using Robust.Shared.Serialization.Manager;
namespace Robust.Benchmarks.Serialization.Initialize
{
[MemoryDiagnoser]
[Virtual]
public class SerializationInitializeBenchmark : SerializationBenchmark
{
[IterationCleanup]

View File

@@ -1,7 +1,7 @@
using System.IO;
using BenchmarkDotNet.Attributes;
using Robust.Benchmarks.Serialization.Definitions;
using Robust.Shared.Serialization.Manager.Result;
using Robust.Shared.Analyzers;
using Robust.Shared.Serialization.Markdown;
using Robust.Shared.Serialization.Markdown.Mapping;
using Robust.Shared.Serialization.Markdown.Sequence;
@@ -12,6 +12,7 @@ using YamlDotNet.RepresentationModel;
namespace Robust.Benchmarks.Serialization.Read
{
[MemoryDiagnoser]
[Virtual]
public class SerializationReadBenchmark : SerializationBenchmark
{
public SerializationReadBenchmark()
@@ -40,32 +41,32 @@ namespace Robust.Benchmarks.Serialization.Read
private ValueDataNode FlagThirtyOne { get; } = new("ThirtyOne");
[Benchmark]
public string? ReadString()
public string ReadString()
{
return SerializationManager.ReadValue<string>(StringNode);
return SerializationManager.Read<string>(StringNode);
}
[Benchmark]
public int? ReadInteger()
public int ReadInteger()
{
return SerializationManager.ReadValue<int>(IntNode);
return SerializationManager.Read<int>(IntNode);
}
[Benchmark]
public DataDefinitionWithString? ReadDataDefinitionWithString()
public DataDefinitionWithString ReadDataDefinitionWithString()
{
return SerializationManager.ReadValue<DataDefinitionWithString>(StringDataDefNode);
return SerializationManager.Read<DataDefinitionWithString>(StringDataDefNode);
}
[Benchmark]
public SeedDataDefinition? ReadSeedDataDefinition()
public SeedDataDefinition ReadSeedDataDefinition()
{
return SerializationManager.ReadValue<SeedDataDefinition>(SeedNode);
return SerializationManager.Read<SeedDataDefinition>(SeedNode);
}
[Benchmark]
[BenchmarkCategory("flag")]
public DeserializationResult ReadFlagZero()
public object? ReadFlagZero()
{
return SerializationManager.ReadWithTypeSerializer(
typeof(int),
@@ -75,7 +76,7 @@ namespace Robust.Benchmarks.Serialization.Read
[Benchmark]
[BenchmarkCategory("flag")]
public DeserializationResult ReadThirtyOne()
public object? ReadThirtyOne()
{
return SerializationManager.ReadWithTypeSerializer(
typeof(int),
@@ -85,7 +86,7 @@ namespace Robust.Benchmarks.Serialization.Read
[Benchmark]
[BenchmarkCategory("customTypeSerializer")]
public DeserializationResult ReadIntegerCustomSerializer()
public object? ReadIntegerCustomSerializer()
{
return SerializationManager.ReadWithTypeSerializer(
typeof(int),

View File

@@ -1,5 +1,6 @@
using BenchmarkDotNet.Attributes;
using Robust.Benchmarks.Serialization.Definitions;
using Robust.Shared.Analyzers;
using Robust.Shared.Serialization.Markdown.Mapping;
using Robust.Shared.Serialization.Markdown.Sequence;
using Robust.Shared.Serialization.Markdown.Value;
@@ -7,6 +8,7 @@ using Robust.Shared.Serialization.Markdown.Value;
namespace Robust.Benchmarks.Serialization
{
[MemoryDiagnoser]
[Virtual]
public class SerializationArrayBenchmark : SerializationBenchmark
{
public SerializationArrayBenchmark()
@@ -44,84 +46,84 @@ namespace Robust.Benchmarks.Serialization
[BenchmarkCategory("read")]
public string[]? ReadEmptyString()
{
return SerializationManager.ReadValue<string[]>(EmptyNode);
return SerializationManager.Read<string[]>(EmptyNode);
}
[Benchmark]
[BenchmarkCategory("read")]
public string[]? ReadOneString()
{
return SerializationManager.ReadValue<string[]>(OneIntNode);
return SerializationManager.Read<string[]>(OneIntNode);
}
[Benchmark]
[BenchmarkCategory("read")]
public string[]? ReadTenStrings()
{
return SerializationManager.ReadValue<string[]>(TenIntsNode);
return SerializationManager.Read<string[]>(TenIntsNode);
}
[Benchmark]
[BenchmarkCategory("read")]
public int[]? ReadEmptyInt()
{
return SerializationManager.ReadValue<int[]>(EmptyNode);
return SerializationManager.Read<int[]>(EmptyNode);
}
[Benchmark]
[BenchmarkCategory("read")]
public int[]? ReadOneInt()
{
return SerializationManager.ReadValue<int[]>(OneIntNode);
return SerializationManager.Read<int[]>(OneIntNode);
}
[Benchmark]
[BenchmarkCategory("read")]
public int[]? ReadTenInts()
{
return SerializationManager.ReadValue<int[]>(TenIntsNode);
return SerializationManager.Read<int[]>(TenIntsNode);
}
[Benchmark]
[BenchmarkCategory("read")]
public DataDefinitionWithString[]? ReadEmptyStringDataDef()
{
return SerializationManager.ReadValue<DataDefinitionWithString[]>(EmptyNode);
return SerializationManager.Read<DataDefinitionWithString[]>(EmptyNode);
}
[Benchmark]
[BenchmarkCategory("read")]
public DataDefinitionWithString[]? ReadOneStringDataDef()
{
return SerializationManager.ReadValue<DataDefinitionWithString[]>(OneStringDefNode);
return SerializationManager.Read<DataDefinitionWithString[]>(OneStringDefNode);
}
[Benchmark]
[BenchmarkCategory("read")]
public DataDefinitionWithString[]? ReadTenStringDataDefs()
{
return SerializationManager.ReadValue<DataDefinitionWithString[]>(TenStringDefsNode);
return SerializationManager.Read<DataDefinitionWithString[]>(TenStringDefsNode);
}
[Benchmark]
[BenchmarkCategory("read")]
public SealedDataDefinitionWithString[]? ReadEmptySealedStringDataDef()
{
return SerializationManager.ReadValue<SealedDataDefinitionWithString[]>(EmptyNode);
return SerializationManager.Read<SealedDataDefinitionWithString[]>(EmptyNode);
}
[Benchmark]
[BenchmarkCategory("read")]
public SealedDataDefinitionWithString[]? ReadOneSealedStringDataDef()
{
return SerializationManager.ReadValue<SealedDataDefinitionWithString[]>(OneStringDefNode);
return SerializationManager.Read<SealedDataDefinitionWithString[]>(OneStringDefNode);
}
[Benchmark]
[BenchmarkCategory("read")]
public SealedDataDefinitionWithString[]? ReadTenSealedStringDataDefs()
{
return SerializationManager.ReadValue<SealedDataDefinitionWithString[]>(TenStringDefsNode);
return SerializationManager.Read<SealedDataDefinitionWithString[]>(TenStringDefsNode);
}
}
}

View File

@@ -2,6 +2,7 @@
using System.IO;
using BenchmarkDotNet.Attributes;
using Robust.Benchmarks.Serialization.Definitions;
using Robust.Shared.Analyzers;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Markdown;
using Robust.Shared.Serialization.Markdown.Mapping;
@@ -13,6 +14,7 @@ using YamlDotNet.RepresentationModel;
namespace Robust.Benchmarks.Serialization.Write
{
[MemoryDiagnoser]
[Virtual]
public class SerializationWriteBenchmark : SerializationBenchmark
{
public SerializationWriteBenchmark()
@@ -26,7 +28,7 @@ namespace Robust.Benchmarks.Serialization.Write
var seedMapping = yamlStream.Documents[0].RootNode.ToDataNodeCast<SequenceDataNode>().Cast<MappingDataNode>(0);
Seed = SerializationManager.ReadValueOrThrow<SeedDataDefinition>(seedMapping);
Seed = SerializationManager.Read<SeedDataDefinition>(seedMapping);
}
private const string String = "ABC";

View File

@@ -0,0 +1,11 @@
#!/usr/bin/env pwsh
param([String]$name)
if ($name -eq "")
{
Write-Error "must specify migration name"
exit
}
dotnet ef migrations add --context BenchmarkContext -o Migrations $name

View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
if [ -z "$1" ] ; then
echo "Must specify migration name"
exit 1
fi
dotnet ef migrations add --context BenchmarkContext -o Migrations "$1"

View File

@@ -6,7 +6,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build.Framework" Version="16.8.0" />
<PackageReference Include="Microsoft.Build.Framework" Version="17.0.0" />
<PackageReference Include="Mono.Cecil" Version="0.11.3" />
<PackageReference Include="Pidgin" Version="2.5.0" />
</ItemGroup>

View File

@@ -76,7 +76,7 @@ namespace Robust.Build.Tasks
},
ContentAttributes =
{
typeSystem.GetType("Robust.Client.UserInterface.XAML.ContentAttribute")
typeSystem.GetType("Avalonia.Metadata.ContentAttribute")
},
UsableDuringInitializationAttributes =
{

View File

@@ -5,8 +5,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,7 +1,4 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using Robust.Shared.ContentPack;
using Xilium.CefGlue;
namespace Robust.Client.WebView.Cef
@@ -19,24 +16,11 @@ namespace Robust.Client.WebView.Cef
Array.Copy(args, 0, argv, 1, args.Length);
argv[0] = "-";
}
/*
if (OperatingSystem.IsLinux())
{
// Chromium tries to load libEGL.so and libGLESv2.so relative to the process executable on Linux.
// (Compared to Windows where it is relative to Chromium's *module*)
// There is a TODO "is this correct?" in the Chromium code for this.
// Great.
//CopyDllToExecutableDir("libEGL.so");
//CopyDllToExecutableDir("libGLESv2.so");
// System.Threading.Thread.Sleep(200000);
}
*/
var mainArgs = new CefMainArgs(argv);
// This will block executing until the subprocess is shut down.
var code = CefRuntime.ExecuteProcess(mainArgs, null, IntPtr.Zero);
var code = CefRuntime.ExecuteProcess(mainArgs, new RobustCefApp(), IntPtr.Zero);
if (code != 0)
{
@@ -45,44 +29,5 @@ namespace Robust.Client.WebView.Cef
return code;
}
/* private static void CopyDllToExecutableDir(string dllName)
{
var executableDir = PathHelpers.GetExecutableDirectory();
var targetPath = Path.Combine(executableDir, dllName);
if (File.Exists(targetPath))
return;
// Find source file.
string? srcFile = null;
foreach (var searchDir in WebViewManagerCef.NativeDllSearchDirectories())
{
var searchPath = Path.Combine(searchDir, dllName);
if (File.Exists(searchPath))
{
srcFile = searchPath;
break;
}
}
if (srcFile == null)
return;
for (var i = 0; i < 5; i++)
{
try
{
if (File.Exists(targetPath))
return;
File.Copy(srcFile, targetPath);
return;
}
catch
{
// Catching race condition lock errors and stuff I guess.
}
}
} */
}
}

View File

@@ -5,7 +5,7 @@ using Xilium.CefGlue;
namespace Robust.Client.WebView.Cef
{
internal class RobustCefApp : CefApp
internal sealed class RobustCefApp : CefApp
{
private readonly BrowserProcessHandler _browserProcessHandler = new();
private readonly RenderProcessHandler _renderProcessHandler = new();
@@ -24,12 +24,12 @@ namespace Robust.Client.WebView.Cef
{
// Disable zygote on Linux.
commandLine.AppendSwitch("--no-zygote");
// Work around https://bitbucket.org/chromiumembedded/cef/issues/3213/ozone-egl-initialization-does-not-have
// Desktop GL force makes Chromium not try to load its own ANGLE/Swiftshader so load paths aren't problematic.
if (OperatingSystem.IsLinux())
commandLine.AppendSwitch("--use-gl", "desktop");
// commandLine.AppendSwitch("--single-process");
//commandLine.AppendSwitch("--disable-gpu");
@@ -43,12 +43,18 @@ namespace Robust.Client.WebView.Cef
Logger.Debug($"{commandLine}");
}
private class BrowserProcessHandler : CefBrowserProcessHandler
protected override void OnRegisterCustomSchemes(CefSchemeRegistrar registrar)
{
registrar.AddCustomScheme("res", CefSchemeOptions.Secure | CefSchemeOptions.Standard);
registrar.AddCustomScheme("usr", CefSchemeOptions.Secure | CefSchemeOptions.Standard);
}
private sealed class BrowserProcessHandler : CefBrowserProcessHandler
{
}
// TODO CEF: Research - Is this even needed?
private class RenderProcessHandler : CefRenderProcessHandler
private sealed class RenderProcessHandler : CefRenderProcessHandler
{
}
}

View File

@@ -3,7 +3,7 @@ using Xilium.CefGlue;
namespace Robust.Client.WebView.Cef
{
// Simple CEF client.
internal class RobustCefClient : CefClient
internal sealed class RobustCefClient : CefClient
{
private readonly CefRenderHandler _renderHandler;
private readonly CefRequestHandler _requestHandler;

View File

@@ -57,6 +57,14 @@ namespace Robust.Client.WebView.Cef
string requestInitiator,
ref bool disableDefaultHandling)
{
var url = new Uri(request.Url);
if (url.Scheme == "file")
{
// Deny file:// access.
disableDefaultHandling = true;
return null;
}
lock (_resourceRequestHandlers)
{
_sawmill.Debug($"HANDLING REQUEST: {request.Url}");
@@ -113,7 +121,7 @@ namespace Robust.Client.WebView.Cef
CefFrame frame,
CefRequest request)
{
return null;
return new CookieHandler();
}
protected override CefResourceHandler GetResourceHandler(
@@ -124,5 +132,18 @@ namespace Robust.Client.WebView.Cef
return _handler;
}
}
private sealed class CookieHandler : CefCookieAccessFilter
{
protected override bool CanSendCookie(CefBrowser browser, CefFrame frame, CefRequest request, CefCookie cookie)
{
return true;
}
protected override bool CanSaveCookie(CefBrowser browser, CefFrame frame, CefRequest request, CefResponse response, CefCookie cookie)
{
return true;
}
}
}
}

View File

@@ -0,0 +1,75 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Robust.Shared.Utility;
namespace Robust.Client.WebView.Cef;
internal sealed partial class WebViewManagerCef
{
// Loosely based on:
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
private readonly Dictionary<string, string> _resourceMimeTypes = new()
{
{ "aac", "audio/aac" },
{ "avif", "image/avif" },
{ "avi", "video/x-msvideo" },
{ "bmp", "image/bmp" },
{ "css", "text/css" },
{ "gif", "image/gif" },
{ "htm", "text/html" },
{ "html", "text/html" },
{ "ico", "image/vnd.microsoft.icon" },
{ "jpeg", "image/jpeg" },
{ "jpg", "image/jpeg" },
{ "js", "text/javascript" },
{ "json", "application/json" },
{ "jsonld", "application/ld+json" },
{ "midi", "audio/midi" },
{ "mid", "audio/midi" },
{ "mjs", "text/javascript" },
{ "mp3", "audio/mpeg" },
{ "mp4", "video/mp4" },
{ "mpeg", "video/mpeg" },
{ "oga", "audio/ogg" },
{ "ogg", "audio/ogg" },
{ "ogv", "video/ogg" },
{ "ogx", "application/ogg" },
{ "opus", "audio/opus" },
{ "otf", "font/otf" },
{ "png", "image/png" },
{ "pdf", "application/pdf" },
{ "svg", "image/svg+xml" },
{ "tiff", "image/tiff" },
{ "tif", "image/tiff" },
{ "ts", "video/mp2t" },
{ "ttf", "font/ttf" },
{ "txt", "text/plain" },
{ "wav", "audio/wav" },
{ "weba", "audio/webm" },
{ "webm", "video/webm" },
{ "webp", "image/webp" },
{ "woff", "font/woff" },
{ "woff2", "font/woff2" },
{ "xhtml", "application/xhtml+xml" },
{ "xml", "application/xml" },
{ "zip", "application/zip" },
};
public void SetResourceMimeType(string extension, string mimeType)
{
DebugTools.Assert(!extension.StartsWith("."), "SetResourceMimeType extension must not include starting dot.");
lock (_resourceMimeTypes)
{
_resourceMimeTypes[extension] = mimeType;
}
}
public bool TryGetResourceMimeType(string extension, [NotNullWhen(true)] out string? mimeType)
{
lock (_resourceMimeTypes)
{
return _resourceMimeTypes.TryGetValue(extension, out mimeType);
}
}
}

View File

@@ -1,24 +1,41 @@
using System;
using System.IO;
using System.Net;
using System.Reflection;
using System.Text;
using Robust.Client.Console;
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using Xilium.CefGlue;
namespace Robust.Client.WebView.Cef
{
internal partial class WebViewManagerCef : IWebViewManagerImpl
internal sealed partial class WebViewManagerCef : IWebViewManagerImpl
{
private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location!)!;
private CefApp _app = default!;
[Dependency] private readonly IDependencyCollection _dependencyCollection = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IResourceManagerInternal _resourceManager = default!;
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
public void Initialize()
{
IoCManager.Instance!.InjectDependencies(this, oneOff: true);
_consoleHost.RegisterCommand("flushcookies", Loc.GetString("cmd-flushcookies-desc"), Loc.GetString("cmd-flushcookies-help"), (_, _, _) =>
{
CefCookieManager.GetGlobal(null).FlushStore(null);
});
string subProcessName;
if (OperatingSystem.IsWindows())
subProcessName = "Robust.Client.WebView.exe";
@@ -27,7 +44,7 @@ namespace Robust.Client.WebView.Cef
else
throw new NotSupportedException("Unsupported platform for CEF!");
var subProcessPath = PathHelpers.ExecutableRelativeFile(subProcessName);
var subProcessPath = Path.Combine(BasePath, subProcessName);
var cefResourcesPath = LocateCefResources();
// System.Console.WriteLine(AppContext.GetData("NATIVE_DLL_SEARCH_DIRECTORIES"));
@@ -35,6 +52,10 @@ namespace Robust.Client.WebView.Cef
if (cefResourcesPath == null)
throw new InvalidOperationException("Unable to locate cef_resources directory!");
var cachePath = "";
if (_resourceManager.UserData is WritableDirProvider userData)
cachePath = userData.GetFullPath(new ResourcePath("/cef_cache"));
var settings = new CefSettings()
{
WindowlessRenderingEnabled = true, // So we can render to our UI controls.
@@ -44,6 +65,8 @@ namespace Robust.Client.WebView.Cef
LocalesDirPath = Path.Combine(cefResourcesPath, "locales"),
ResourcesDirPath = cefResourcesPath,
RemoteDebuggingPort = 9222,
CookieableSchemesList = "usr,res",
CachePath = cachePath,
};
Logger.Info($"CEF Version: {CefRuntime.ChromeVersion}");
@@ -56,11 +79,17 @@ namespace Robust.Client.WebView.Cef
// TODO CEF: After this point, debugging breaks. No, literally. My client crashes but ONLY with the debugger.
// I have tried using the DEBUG and RELEASE versions of libcef.so, stripped or non-stripped...
// And nothing seemed to work. Odd.
if (_cfg.GetCVar(WCVars.WebResProtocol))
{
var handler = new ResourceSchemeFactoryHandler(this, _resourceManager, Logger.GetSawmill("web.res"));
CefRuntime.RegisterSchemeHandlerFactory("res", "", handler);
}
}
private static string? LocateCefResources()
{
if (ProbeDir(PathHelpers.GetExecutableDirectory(), out var path))
if (ProbeDir(BasePath, out var path))
return path;
@@ -99,5 +128,48 @@ namespace Robust.Client.WebView.Cef
{
CefRuntime.Shutdown();
}
private sealed class ResourceSchemeFactoryHandler : CefSchemeHandlerFactory
{
private readonly WebViewManagerCef _parent;
private readonly IResourceManager _resourceManager;
private readonly ISawmill _sawmill;
public ResourceSchemeFactoryHandler(
WebViewManagerCef parent,
IResourceManager resourceManager,
ISawmill sawmill)
{
_parent = parent;
_resourceManager = resourceManager;
_sawmill = sawmill;
}
protected override CefResourceHandler Create(
CefBrowser browser,
CefFrame frame,
string schemeName,
CefRequest request)
{
var uri = new Uri(request.Url);
_sawmill.Debug($"HANDLING: {request.Url}");
var resourcePath = new ResourcePath(uri.AbsolutePath);
if (_resourceManager.TryContentFileRead(resourcePath, out var stream))
{
if (!_parent.TryGetResourceMimeType(resourcePath.Extension, out var mime))
mime = "application/octet-stream";
return new RequestResultStream(stream, mime, HttpStatusCode.OK).MakeHandler();
}
var notFoundStream = new MemoryStream();
notFoundStream.Write(Encoding.UTF8.GetBytes("Not found"));
notFoundStream.Position = 0;
return new RequestResultStream(notFoundStream, "text/plain", HttpStatusCode.NotFound).MakeHandler();
}
}
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
@@ -11,6 +12,17 @@ namespace Robust.Client.WebView.Headless
return new WebViewWindowDummy();
}
public void SetResourceMimeType(string extension, string mimeType)
{
// Nop
}
public bool TryGetResourceMimeType(string extension, [NotNullWhen(true)] out string? mimeType)
{
mimeType = null;
return false;
}
public IWebViewControlImpl MakeControlImpl(WebViewControl owner)
{
return new WebViewControlImplDummy();

View File

@@ -1,7 +1,40 @@
namespace Robust.Client.WebView
using System.Diagnostics.CodeAnalysis;
namespace Robust.Client.WebView
{
public interface IWebViewManager
{
IWebViewWindow CreateBrowserWindow(BrowserWindowCreateParameters createParams);
/// <summary>
/// Overrides file extension -> mime type mappings for the <c>res://</c> protocol.
/// </summary>
/// <remarks>
/// <para>
/// The built-in <c>res://</c> protocol needs to guess MIME types to report to CEF when resolving files.
/// A limited set of extensions have pre-set MIME types in the engine.
/// This method allows you to replace or add entries if need be.
/// </para>
/// <para>
/// This method is thread safe.
/// </para>
/// </remarks>
/// <param name="extension">
/// The extension to specify the MIME type for.
/// The argument must not include the starting "." of the file extension.
/// </param>
/// <param name="mimeType">The mime type for this file extension.</param>
/// <seealso cref="TryGetResourceMimeType"/>
void SetResourceMimeType(string extension, string mimeType);
/// <summary>
/// Tries to resolve an entry from the <see cref="SetResourceMimeType"/> list.
/// </summary>
/// <remarks>
/// <para>
/// This method is thread safe.
/// </para>
/// </remarks>
bool TryGetResourceMimeType(string extension, [NotNullWhen(true)] out string? mimeType);
}
}

View File

@@ -14,8 +14,7 @@
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2020.3.0" />
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
<PackageReference Include="Robust.Natives.Cef" Version="95.7.14" />
<PackageReference Include="Robust.Natives.Cef" Version="102.0.9" />
</ItemGroup>
<ItemGroup>

View File

@@ -0,0 +1,17 @@
using Robust.Shared.Configuration;
namespace Robust.Client.WebView;
// ReSharper disable once InconsistentNaming
/// <summary>
/// CVars for <c>Robust.Client.WebView</c>
/// </summary>
[CVarDefs]
public static class WCVars
{
/// <summary>
/// Enable the <c>res://</c> protocol inside WebView browsers, allowing access to the Robust resources.
/// </summary>
public static readonly CVarDef<bool> WebResProtocol =
CVarDef.Create("web.res_protocol", true, CVar.CLIENTONLY);
}

View File

@@ -1,7 +1,9 @@
using Robust.Client.WebView;
using System.Diagnostics.CodeAnalysis;
using Robust.Client.WebView;
using Robust.Client.WebView.Cef;
using Robust.Client.WebView.Headless;
using Robust.Client.WebViewHook;
using Robust.Shared.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Utility;
@@ -17,6 +19,9 @@ namespace Robust.Client.WebView
{
DebugTools.Assert(_impl == null, "WebViewManager has already been initialized!");
var cfg = IoCManager.Resolve<IConfigurationManagerInternal>();
cfg.LoadCVarsFromAssembly(typeof(WebViewManager).Assembly);
IoCManager.RegisterInstance<IWebViewManager>(this);
IoCManager.RegisterInstance<IWebViewManagerInternal>(this);
@@ -49,6 +54,20 @@ namespace Robust.Client.WebView
return _impl!.CreateBrowserWindow(createParams);
}
public void SetResourceMimeType(string extension, string mimeType)
{
DebugTools.Assert(_impl != null, "WebViewManager has not yet been initialized!");
_impl!.SetResourceMimeType(extension, mimeType);
}
public bool TryGetResourceMimeType(string extension, [NotNullWhen(true)] out string? mimeType)
{
DebugTools.Assert(_impl != null, "WebViewManager has not yet been initialized!");
return _impl!.TryGetResourceMimeType(extension, out mimeType);
}
public IWebViewControlImpl MakeControlImpl(WebViewControl owner)
{
DebugTools.Assert(_impl != null, "WebViewManager has not yet been initialized!");

View File

@@ -3,7 +3,7 @@ using Robust.Shared.Animations;
namespace Robust.Client.Animations
{
public class AnimationTrackControlProperty : AnimationTrackProperty
public sealed class AnimationTrackControlProperty : AnimationTrackProperty
{
public string? Property { get; set; }

View File

@@ -37,7 +37,7 @@ namespace Robust.Client.Animations
var keyFrame = KeyFrames[keyFrameIndex];
SoundSystem.Play(Filter.Local(), keyFrame.Resource, entity, keyFrame.AudioParamsFunc.Invoke());
SoundSystem.Play(keyFrame.Resource, Filter.Local(), entity, keyFrame.AudioParamsFunc.Invoke());
}
return (keyFrameIndex, playingTime);

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Robust.Shared.Animations;
using Robust.Shared.Maths;
@@ -101,7 +101,7 @@ namespace Robust.Client.Animations
case double d:
return MathHelper.Lerp(d, (double) b, t);
case Angle angle:
return (Angle) MathHelper.Lerp(angle, (Angle) b, t);
return Angle.Lerp(angle, (Angle) b, t);
case Color color:
return Color.InterpolateBetween(color, (Color) b, t);
case int i:

View File

@@ -0,0 +1,22 @@
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
namespace Robust.Client.Audio.Midi.Commands;
public sealed class MidiPanicCommand : IConsoleCommand
{
[Dependency] private readonly IMidiManager _midiManager = default!;
public string Command => "midipanic";
public string Description => Loc.GetString("midi-panic-command-description");
public string Help => $"{Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
foreach (var renderer in _midiManager.Renderers)
{
renderer.StopAllNotes();
}
}
}

View File

@@ -0,0 +1,62 @@
using System.Collections.Generic;
using NFluidsynth;
using Robust.Shared.Audio.Midi;
namespace Robust.Client.Audio.Midi;
public interface IMidiManager
{
/// <summary>
/// A read-only list of all existing MIDI Renderers.
/// </summary>
IReadOnlyList<IMidiRenderer> Renderers { get; }
/// <summary>
/// If true, MIDI support is available.
/// </summary>
bool IsAvailable { get; }
/// <summary>
/// Volume, in db.
/// </summary>
float Volume { get; set; }
public int OcclusionCollisionMask { get; set; }
/// <summary>
/// This method tries to return a midi renderer ready to be used.
/// You only need to set the <see cref="IMidiRenderer.MidiProgram"/> afterwards.
/// </summary>
/// <remarks>
/// This method can fail if MIDI support is not available.
/// </remarks>
/// <returns>
/// <c>null</c> if MIDI support is not available.
/// </returns>
IMidiRenderer? GetNewRenderer(bool mono = true);
/// <summary>
/// Creates a <see cref="RobustMidiEvent"/> given a <see cref="MidiEvent"/> and a sequencer tick.
/// </summary>
RobustMidiEvent FromFluidEvent(MidiEvent midiEvent, uint tick);
/// <summary>
/// Creates a <see cref="SequencerEvent"/> given a <see cref="RobustMidiEvent"/>.
/// Be sure to dispose of the result after you've used it.
/// </summary>
SequencerEvent ToSequencerEvent(RobustMidiEvent midiEvent);
/// <summary>
/// Creates a <see cref="RobustMidiEvent"/> given a <see cref="SequencerEvent"/> and a sequencer tick.
/// </summary>
RobustMidiEvent FromSequencerEvent(SequencerEvent midiEvent, uint tick);
/// <summary>
/// Method called every frame.
/// Should be used to update positional audio.
/// </summary>
/// <param name="frameTime"></param>
void FrameUpdate(float frameTime);
void Shutdown();
}

View File

@@ -0,0 +1,181 @@
using System;
using Robust.Client.Graphics;
using Robust.Shared.Audio.Midi;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
namespace Robust.Client.Audio.Midi;
public enum MidiRendererStatus : byte
{
None,
Input,
File,
}
public interface IMidiRenderer : IDisposable
{
/// <summary>
/// The buffered audio source of this renderer.
/// </summary>
internal IClydeBufferedAudioSource Source { get; }
/// <summary>
/// Whether this renderer has been disposed or not.
/// </summary>
bool Disposed { get; }
/// <summary>
/// This controls whether the midi file being played will loop or not.
/// </summary>
bool LoopMidi { get; set; }
/// <summary>
/// This increases all note on velocities to 127.
/// </summary>
bool VolumeBoost { get; set; }
/// <summary>
/// The midi program (instrument) the renderer is using.
/// </summary>
byte MidiProgram { get; set; }
/// <summary>
/// The instrument bank the renderer is using.
/// </summary>
byte MidiBank { get; set; }
/// <summary>
/// The soundfont currently selected by the renderer.
/// </summary>
uint MidiSoundfont { get; set; }
/// <summary>
/// The current status of the renderer.
/// "None" if the renderer isn't playing from input or a midi file.
/// "Input" if the renderer is playing from midi input.
/// "File" if the renderer is playing from a midi file.
/// </summary>
MidiRendererStatus Status { get; }
/// <summary>
/// Whether the sound will play in stereo or mono.
/// </summary>
bool Mono { get; set; }
/// <summary>
/// Whether to drop messages on the percussion channel.
/// </summary>
bool DisablePercussionChannel { get; set; }
/// <summary>
/// Whether to drop messages for program change events.
/// </summary>
bool DisableProgramChangeEvent { get; set; }
/// <summary>
/// Gets the total number of ticks possible for the MIDI player.
/// </summary>
int PlayerTotalTick { get; }
/// <summary>
/// Gets or sets (seeks) the current tick of the MIDI player.
/// </summary>
int PlayerTick { get; set; }
/// <summary>
/// Gets the current tick of the sequencer.
/// </summary>
uint SequencerTick { get; }
/// <summary>
/// Gets the Time Scale of the sequencer in ticks per second. Default is 1000 for 1 tick per millisecond.
/// </summary>
double SequencerTimeScale { get; }
/// <summary>
/// Start listening for midi input.
/// </summary>
bool OpenInput();
/// <summary>
/// Start playing a midi file.
/// </summary>
/// <param name="buffer">Bytes of the midi file</param>
bool OpenMidi(ReadOnlySpan<byte> buffer);
/// <summary>
/// Stops listening for midi input.
/// </summary>
bool CloseInput();
/// <summary>
/// Stops playing midi files.
/// </summary>
bool CloseMidi();
/// <summary>
/// Stops all notes being played currently.
/// </summary>
void StopAllNotes();
/// <summary>
/// Render and play MIDI to the audio source.
/// </summary>
internal void Render();
/// <summary>
/// Loads a new soundfont into the renderer.
/// </summary>
void LoadSoundfont(string filename, bool resetPresets = false);
/// <summary>
/// Invoked whenever a new midi event is registered.
/// </summary>
event Action<RobustMidiEvent> OnMidiEvent;
/// <summary>
/// Invoked when the midi player finishes playing a song.
/// </summary>
event Action OnMidiPlayerFinished;
/// <summary>
/// The entity whose position will be used for positional audio.
/// This is only used if <see cref="Mono"/> is set to True.
/// </summary>
EntityUid? TrackingEntity { get; set; }
/// <summary>
/// The position that will be used for positional audio.
/// This is only used if <see cref="Mono"/> is set to True
/// and <see cref="TrackingEntity"/> is null.
/// </summary>
EntityCoordinates? TrackingCoordinates { get; set; }
MidiRendererState RendererState { get; }
/// <summary>
/// Send a midi event for the renderer to play.
/// </summary>
/// <param name="midiEvent">The midi event to be played</param>
void SendMidiEvent(RobustMidiEvent midiEvent);
/// <summary>
/// Schedule a MIDI event to be played at a later time.
/// </summary>
/// <param name="midiEvent">the midi event in question</param>
/// <param name="time"></param>
/// <param name="absolute"></param>
void ScheduleMidiEvent(RobustMidiEvent midiEvent, uint time, bool absolute);
/// <summary>
/// Apply a certain state to the renderer.
/// </summary>
void ApplyState(MidiRendererState state);
/// <summary>
/// Actually disposes of this renderer. Do NOT use outside the MIDI thread.
/// </summary>
internal void InternalDispose();
}

View File

@@ -0,0 +1,155 @@
using NFluidsynth;
using Robust.Shared.Audio.Midi;
namespace Robust.Client.Audio.Midi;
internal sealed partial class MidiManager
{
public RobustMidiEvent FromFluidEvent(MidiEvent midiEvent, uint tick)
{
var status = RobustMidiEvent.MakeStatus((byte) midiEvent.Channel, (byte) midiEvent.Type);
// Control is always the first data byte. Value is always the second data byte. Fluidsynth's API ain't great.
var data1 = (byte) midiEvent.Control;
var data2 = (byte) midiEvent.Value;
// PitchBend is handled specially.
if (midiEvent.Type == (int) RobustMidiCommand.PitchBend)
{
// We pack pitch into both data values.
var pitch = (ushort) midiEvent.Pitch;
data1 = (byte) pitch;
data2 = (byte) (pitch >> 8);
}
return new RobustMidiEvent(status, data1, data2, tick);
}
public SequencerEvent ToSequencerEvent(RobustMidiEvent midiEvent)
{
var sequencerEvent = new SequencerEvent();
switch (midiEvent.MidiCommand)
{
case RobustMidiCommand.NoteOff:
sequencerEvent.NoteOff(midiEvent.Channel, midiEvent.Key);
break;
case RobustMidiCommand.NoteOn:
sequencerEvent.NoteOn(midiEvent.Channel, midiEvent.Key, midiEvent.Velocity);
break;
case RobustMidiCommand.AfterTouch:
sequencerEvent.KeyPressure(midiEvent.Channel, midiEvent.Key, midiEvent.Value);
break;
case RobustMidiCommand.ControlChange:
sequencerEvent.ControlChange(midiEvent.Channel, midiEvent.Control, midiEvent.Value);
break;
case RobustMidiCommand.ProgramChange:
sequencerEvent.ProgramChange(midiEvent.Channel, midiEvent.Program);
break;
case RobustMidiCommand.ChannelPressure:
sequencerEvent.ChannelPressure(midiEvent.Channel, midiEvent.Value);
break;
case RobustMidiCommand.PitchBend:
sequencerEvent.PitchBend(midiEvent.Channel, midiEvent.Pitch);
break;
case RobustMidiCommand.SystemMessage:
switch (midiEvent.Control)
{
case 0x0 when midiEvent.Status == 0xFF:
sequencerEvent.SystemReset();
break;
case 0x0B:
sequencerEvent.AllNotesOff(midiEvent.Channel);
break;
default:
_midiSawmill.Warning($"Tried to convert unsupported event to sequencer event:\n{midiEvent}");
break;
}
break;
default:
_midiSawmill.Warning($"Tried to convert unsupported event to sequencer event:\n{midiEvent}");
break;
}
return sequencerEvent;
}
public RobustMidiEvent FromSequencerEvent(SequencerEvent midiEvent, uint tick)
{
byte channel = (byte) midiEvent.Channel;
RobustMidiCommand command = 0x0;
byte data1 = 0;
byte data2 = 0;
switch (midiEvent.Type)
{
case FluidSequencerEventType.NoteOn:
command = RobustMidiCommand.NoteOn;
data1 = (byte) midiEvent.Key;
data2 = (byte) midiEvent.Velocity;
break;
case FluidSequencerEventType.NoteOff:
command = RobustMidiCommand.NoteOff;
data1 = (byte) midiEvent.Key;
break;
case FluidSequencerEventType.PitchBend:
command = RobustMidiCommand.PitchBend;
// We pack pitch into both data values
var pitch = (ushort) midiEvent.Pitch;
data1 = (byte) pitch;
data2 = (byte) (pitch >> 8);
break;
case FluidSequencerEventType.ProgramChange:
command = RobustMidiCommand.ProgramChange;
data1 = (byte) midiEvent.Program;
break;
case FluidSequencerEventType.KeyPressure:
command = RobustMidiCommand.AfterTouch;
data1 = (byte) midiEvent.Key;
data2 = (byte) midiEvent.Value;
break;
case FluidSequencerEventType.ControlChange:
command = RobustMidiCommand.ControlChange;
data1 = (byte) midiEvent.Control;
data2 = (byte) midiEvent.Value;
break;
case FluidSequencerEventType.ChannelPressure:
command = RobustMidiCommand.ChannelPressure;
data1 = (byte) midiEvent.Value;
break;
case FluidSequencerEventType.AllNotesOff:
command = RobustMidiCommand.SystemMessage;
data1 = 0x0B;
break;
case FluidSequencerEventType.SystemReset:
command = RobustMidiCommand.SystemMessage;
channel = 0x0F;
break;
default:
_midiSawmill.Error($"Unsupported Sequencer Event: {tick:D8}: {SequencerEventToString(midiEvent)}");
break;
}
return new RobustMidiEvent(RobustMidiEvent.MakeStatus(channel, (byte)command), data1, data2, tick);
}
}

View File

@@ -7,6 +7,7 @@ using NFluidsynth;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Shared;
using Robust.Shared.Asynchronous;
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;
using Robust.Shared.GameObjects;
@@ -15,269 +16,279 @@ using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Broadphase;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
using Logger = Robust.Shared.Log.Logger;
namespace Robust.Client.Audio.Midi
namespace Robust.Client.Audio.Midi;
internal sealed partial class MidiManager : IMidiManager
{
public interface IMidiManager
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IResourceManagerInternal _resourceManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IConfigurationManager _cfgMan = default!;
[Dependency] private readonly IClydeAudio _clydeAudio = default!;
[Dependency] private readonly ITaskManager _taskManager = default!;
[Dependency] private readonly ILogManager _logger = default!;
private SharedPhysicsSystem _broadPhaseSystem = default!;
public IReadOnlyList<IMidiRenderer> Renderers
{
/// <summary>
/// This method tries to return a midi renderer ready to be used.
/// You only need to set the <see cref="IMidiRenderer.MidiProgram"/> afterwards.
/// </summary>
/// <remarks>
/// This method can fail if MIDI support is not available.
/// </remarks>
/// <returns>
/// <c>null</c> if MIDI support is not available.
/// </returns>
IMidiRenderer? GetNewRenderer();
/// <summary>
/// Method called every frame.
/// Should be used to update positional audio.
/// </summary>
/// <param name="frameTime"></param>
void FrameUpdate(float frameTime);
/// <summary>
/// Volume, in db.
/// </summary>
float Volume { get; set; }
/// <summary>
/// If true, MIDI support is available.
/// </summary>
bool IsAvailable { get; }
public int OcclusionCollisionMask { get; set; }
void Shutdown();
get
{
lock (_renderers)
{
// Perform a copy. Sadly, we can't return a reference to the original list due to threading concerns.
return _renderers.ToArray();
}
}
}
internal class MidiManager : IMidiManager
[ViewVariables]
public bool IsAvailable
{
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IResourceManagerInternal _resourceManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IConfigurationManager _cfgMan = default!;
private SharedPhysicsSystem _broadPhaseSystem = default!;
[ViewVariables]
public bool IsAvailable
get
{
get
{
InitializeFluidsynth();
InitializeFluidsynth();
return FluidsynthInitialized;
}
return FluidsynthInitialized;
}
}
[ViewVariables]
private readonly List<IMidiRenderer> _renderers = new();
private bool _alive = true;
private Settings? _settings;
private Thread? _midiThread;
private ISawmill _midiSawmill = default!;
private float _volume = 0f;
private bool _volumeDirty = true;
// Not reliable until Fluidsynth is initialized!
[ViewVariables(VVAccess.ReadWrite)]
public float Volume
{
get => _volume;
set
{
if (MathHelper.CloseToPercent(_volume, value))
return;
_cfgMan.SetCVar(CVars.MidiVolume, value);
_volumeDirty = true;
}
}
private static readonly string[] LinuxSoundfonts =
{
"/usr/share/soundfonts/default.sf2",
"/usr/share/soundfonts/default.dls",
"/usr/share/soundfonts/FluidR3_GM.sf2",
"/usr/share/soundfonts/freepats-general-midi.sf2",
"/usr/share/sounds/sf2/default.sf2",
"/usr/share/sounds/sf2/default.dls",
"/usr/share/sounds/sf2/FluidR3_GM.sf2",
"/usr/share/sounds/sf2/TimGM6mb.sf2",
};
private const string WindowsSoundfont = @"C:\WINDOWS\system32\drivers\gm.dls";
private const string OsxSoundfont =
"/System/Library/Components/CoreAudio.component/Contents/Resources/gs_instruments.dls";
private const string FallbackSoundfont = "/Midi/fallback.sf2";
private const float MaxDistanceForOcclusion = 1000;
private static ResourcePath CustomSoundfontDirectory = new ResourcePath("/soundfonts/");
private readonly ResourceLoaderCallbacks _soundfontLoaderCallbacks = new();
private bool FluidsynthInitialized;
private bool _failedInitialize;
private NFluidsynth.Logger.LoggerDelegate _loggerDelegate = default!;
private ISawmill _sawmill = default!;
[ViewVariables(VVAccess.ReadWrite)]
public int OcclusionCollisionMask { get; set; }
private void InitializeFluidsynth()
{
if (FluidsynthInitialized || _failedInitialize) return;
_volume = _cfgMan.GetCVar(CVars.MidiVolume);
_cfgMan.OnValueChanged(CVars.MidiVolume, value =>
{
_volume = value;
_volumeDirty = true;
}, true);
_midiSawmill = _logger.GetSawmill("midi");
_midiSawmill.Level = LogLevel.Info;
_sawmill = _logger.GetSawmill("midi.fluidsynth");
_loggerDelegate = LoggerDelegate;
if (!_resourceManager.UserData.Exists(CustomSoundfontDirectory))
{
_resourceManager.UserData.CreateDir(CustomSoundfontDirectory);
}
// not a directory, preserve the old file and create an actual directory
else if (!_resourceManager.UserData.IsDir(CustomSoundfontDirectory))
{
_resourceManager.UserData.Rename(CustomSoundfontDirectory, CustomSoundfontDirectory.WithName(CustomSoundfontDirectory.Filename + ".old"));
_resourceManager.UserData.CreateDir(CustomSoundfontDirectory);
}
[ViewVariables]
private readonly List<IMidiRenderer> _renderers = new();
private bool _alive = true;
private Settings? _settings;
private Thread? _midiThread;
private ISawmill _midiSawmill = default!;
private float _volume = 0f;
private bool _volumeDirty = true;
// Not reliable until Fluidsynth is initialized!
[ViewVariables(VVAccess.ReadWrite)]
public float Volume
try
{
get => _volume;
set
{
if (MathHelper.CloseToPercent(_volume, value))
return;
NFluidsynth.Logger.SetLoggerMethod(_loggerDelegate); // Will cause a safe DllNotFoundException if not available.
_cfgMan.SetCVar(CVars.MidiVolume, value);
_volumeDirty = true;
}
_settings = new Settings();
_settings["synth.sample-rate"].DoubleValue = 44100;
_settings["player.timing-source"].StringValue = "sample";
_settings["synth.lock-memory"].IntValue = 0;
_settings["synth.threadsafe-api"].IntValue = 1;
_settings["synth.gain"].DoubleValue = 1.0d;
_settings["synth.polyphony"].IntValue = 1024;
_settings["synth.cpu-cores"].IntValue = 2;
_settings["synth.midi-channels"].IntValue = 16;
_settings["synth.overflow.age"].DoubleValue = 3000;
_settings["audio.driver"].StringValue = "file";
_settings["audio.periods"].IntValue = 8;
_settings["audio.period-size"].IntValue = 4096;
_settings["midi.autoconnect"].IntValue = 1;
_settings["player.reset-synth"].IntValue = 0;
_settings["synth.midi-bank-select"].StringValue = "gm";
//_settings["synth.verbose"].IntValue = 1; // Useful for debugging.
}
catch (Exception e)
{
_midiSawmill.Warning(
"Failed to initialize fluidsynth due to exception, disabling MIDI support:\n{0}", e);
_failedInitialize = true;
return;
}
private static readonly string[] LinuxSoundfonts =
{
"/usr/share/soundfonts/default.sf2",
"/usr/share/soundfonts/FluidR3_GM.sf2",
"/usr/share/soundfonts/freepats-general-midi.sf2",
"/usr/share/sounds/sf2/default.sf2",
"/usr/share/sounds/sf2/FluidR3_GM.sf2",
"/usr/share/sounds/sf2/TimGM6mb.sf2",
_midiThread = new Thread(ThreadUpdate);
_midiThread.Start();
_broadPhaseSystem = EntitySystem.Get<SharedPhysicsSystem>();
FluidsynthInitialized = true;
}
private void LoggerDelegate(NFluidsynth.Logger.LogLevel level, string message, IntPtr data)
{
var rLevel = level switch {
NFluidsynth.Logger.LogLevel.Panic => LogLevel.Error,
NFluidsynth.Logger.LogLevel.Error => LogLevel.Error,
NFluidsynth.Logger.LogLevel.Warning => LogLevel.Warning,
NFluidsynth.Logger.LogLevel.Information => LogLevel.Info,
NFluidsynth.Logger.LogLevel.Debug => LogLevel.Debug,
_ => LogLevel.Debug
};
_sawmill.Log(rLevel, message);
}
private const string WindowsSoundfont = @"C:\WINDOWS\system32\drivers\gm.dls";
private const string OsxSoundfont =
"/System/Library/Components/CoreAudio.component/Contents/Resources/gs_instruments.dls";
private const string FallbackSoundfont = "/Midi/fallback.sf2";
private readonly ResourceLoaderCallbacks _soundfontLoaderCallbacks = new();
private bool FluidsynthInitialized;
private bool _failedInitialize;
private NFluidsynth.Logger.LoggerDelegate _loggerDelegate = default!;
private ISawmill _sawmill = default!;
[ViewVariables(VVAccess.ReadWrite)]
public int OcclusionCollisionMask { get; set; }
private void InitializeFluidsynth()
public IMidiRenderer? GetNewRenderer(bool mono = true)
{
if (!FluidsynthInitialized)
{
if (FluidsynthInitialized || _failedInitialize) return;
InitializeFluidsynth();
_volume = _cfgMan.GetCVar(CVars.MidiVolume);
_cfgMan.OnValueChanged(CVars.MidiVolume, value =>
if (!FluidsynthInitialized) // init failed
{
_volume = value;
_volumeDirty = true;
}, true);
_midiSawmill = Logger.GetSawmill("midi");
_sawmill = Logger.GetSawmill("midi.fluidsynth");
_loggerDelegate = LoggerDelegate;
try
{
NFluidsynth.Logger.SetLoggerMethod(_loggerDelegate); // Will cause a safe DllNotFoundException if not available.
_settings = new Settings();
_settings["synth.sample-rate"].DoubleValue = 44100;
_settings["player.timing-source"].StringValue = "sample";
_settings["synth.lock-memory"].IntValue = 0;
_settings["synth.threadsafe-api"].IntValue = 1;
_settings["synth.gain"].DoubleValue = 1.0d;
_settings["synth.polyphony"].IntValue = 1024;
_settings["synth.cpu-cores"].IntValue = 2;
_settings["synth.overflow.age"].DoubleValue = 3000;
_settings["audio.driver"].StringValue = "file";
_settings["audio.periods"].IntValue = 8;
_settings["audio.period-size"].IntValue = 4096;
_settings["midi.autoconnect"].IntValue = 1;
_settings["player.reset-synth"].IntValue = 0;
_settings["synth.midi-bank-select"].StringValue = "gm";
return null;
}
catch (Exception e)
{
Logger.WarningS("midi",
"Failed to initialize fluidsynth due to exception, disabling MIDI support:\n{0}", e);
_failedInitialize = true;
return;
}
_midiThread = new Thread(ThreadUpdate);
_midiThread.Start();
_broadPhaseSystem = EntitySystem.Get<SharedPhysicsSystem>();
FluidsynthInitialized = true;
}
private void LoggerDelegate(NFluidsynth.Logger.LogLevel level, string message, IntPtr data)
var soundfontLoader = SoundFontLoader.NewDefaultSoundFontLoader(_settings);
// Just making double sure these don't get GC'd.
// They shouldn't, MidiRenderer keeps a ref, but making sure...
var handle = GCHandle.Alloc(soundfontLoader);
try
{
var rLevel = level switch {
NFluidsynth.Logger.LogLevel.Panic => LogLevel.Error,
NFluidsynth.Logger.LogLevel.Error => LogLevel.Error,
NFluidsynth.Logger.LogLevel.Warning => LogLevel.Warning,
NFluidsynth.Logger.LogLevel.Information => LogLevel.Info,
NFluidsynth.Logger.LogLevel.Debug => LogLevel.Debug,
_ => LogLevel.Debug
};
_sawmill.Log(rLevel, message);
}
soundfontLoader.SetCallbacks(_soundfontLoaderCallbacks);
public IMidiRenderer? GetNewRenderer()
{
if (!FluidsynthInitialized)
var renderer = new MidiRenderer(_settings!, soundfontLoader, mono, this, _clydeAudio, _taskManager, _midiSawmill);
// Since the last loaded soundfont takes priority, we load the fallback soundfont before the soundfont.
renderer.LoadSoundfont(FallbackSoundfont);
if (OperatingSystem.IsLinux())
{
InitializeFluidsynth();
if (!FluidsynthInitialized) // init failed
foreach (var filepath in LinuxSoundfonts)
{
return null;
}
}
if (!File.Exists(filepath) || !SoundFont.IsSoundFont(filepath)) continue;
var soundfontLoader = SoundFontLoader.NewDefaultSoundFontLoader(_settings);
// Just making double sure these don't get GC'd.
// They shouldn't, MidiRenderer keeps a ref, but making sure...
var handle = GCHandle.Alloc(soundfontLoader);
try
{
soundfontLoader.SetCallbacks(_soundfontLoaderCallbacks);
var renderer = new MidiRenderer(_settings!, soundfontLoader);
foreach (var file in _resourceManager.ContentFindFiles(("/Audio/MidiCustom/")))
{
if (file.Extension != "sf2" && file.Extension != "dls") continue;
renderer.LoadSoundfont(file.ToString());
}
// Since the last loaded soundfont takes priority, we load the fallback soundfont before the soundfont.
renderer.LoadSoundfont(FallbackSoundfont);
if (OperatingSystem.IsLinux())
{
foreach (var filepath in LinuxSoundfonts)
try
{
if (!File.Exists(filepath) || !SoundFont.IsSoundFont(filepath)) continue;
try
{
renderer.LoadSoundfont(filepath, true);
}
catch (Exception)
{
continue;
}
break;
renderer.LoadSoundfont(filepath, true);
}
catch (Exception)
{
continue;
}
}
else if (OperatingSystem.IsMacOS())
{
if (File.Exists(OsxSoundfont) && SoundFont.IsSoundFont(OsxSoundfont))
renderer.LoadSoundfont(OsxSoundfont, true);
}
else if (OperatingSystem.IsWindows())
{
if (File.Exists(WindowsSoundfont) && SoundFont.IsSoundFont(WindowsSoundfont))
renderer.LoadSoundfont(WindowsSoundfont, true);
}
renderer.Source.SetVolume(Volume);
lock (_renderers)
{
_renderers.Add(renderer);
break;
}
return renderer;
}
finally
else if (OperatingSystem.IsMacOS())
{
handle.Free();
if (File.Exists(OsxSoundfont) && SoundFont.IsSoundFont(OsxSoundfont))
renderer.LoadSoundfont(OsxSoundfont, true);
}
else if (OperatingSystem.IsWindows())
{
if (File.Exists(WindowsSoundfont) && SoundFont.IsSoundFont(WindowsSoundfont))
renderer.LoadSoundfont(WindowsSoundfont, true);
}
// Load content-specific custom soundfonts, which could override the system/fallback soundfont.
foreach (var file in _resourceManager.ContentFindFiles(("/Audio/MidiCustom/")))
{
if (file.Extension != "sf2" && file.Extension != "dls") continue;
renderer.LoadSoundfont(file.ToString());
}
// Load every soundfont from the user data directory last, since those may override any other soundfont.
_midiSawmill.Debug($"loading soundfonts from {CustomSoundfontDirectory.ToRelativePath().ToString()}/*");
var enumerator = _resourceManager.UserData.Find($"{CustomSoundfontDirectory.ToRelativePath().ToString()}/*").Item1;
foreach (var soundfont in enumerator)
{
if (soundfont.Extension != "sf2" && soundfont.Extension != "dls") continue;
_midiSawmill.Debug($"loading soundfont {soundfont}");
renderer.LoadSoundfont(soundfont.ToString());
}
renderer.Source.SetVolume(Volume);
lock (_renderers)
{
_renderers.Add(renderer);
}
return renderer;
}
finally
{
handle.Free();
}
}
public void FrameUpdate(float frameTime)
{
if (!FluidsynthInitialized)
{
return;
}
public void FrameUpdate(float frameTime)
// Update positions of streams every frame.
lock (_renderers)
{
if (!FluidsynthInitialized)
{
return;
}
// Update positions of streams every frame.
foreach (var renderer in _renderers)
{
if (renderer.Disposed)
@@ -293,136 +304,155 @@ namespace Robust.Client.Audio.Midi
}
MapCoordinates? mapPos = null;
var trackingEntity = renderer.TrackingEntity != null && !_entityManager.Deleted(renderer.TrackingEntity);
if (trackingEntity)
{
renderer.TrackingCoordinates = _entityManager.GetComponent<TransformComponent>(renderer.TrackingEntity!.Value).Coordinates;
}
if (renderer.TrackingCoordinates != null)
{
mapPos = renderer.TrackingCoordinates.Value.ToMap(_entityManager);
}
else if (renderer.TrackingEntity != null)
{
mapPos = _entityManager.GetComponent<TransformComponent>(renderer.TrackingEntity.Value).MapPosition;
}
if (mapPos != null)
if (mapPos != null && mapPos.Value.MapId == _eyeManager.CurrentMap)
{
var pos = mapPos.Value;
if (pos.MapId != _eyeManager.CurrentMap)
{
renderer.Source.SetVolume(-10000000);
}
else
{
var sourceRelative = _eyeManager.CurrentEye.Position.Position - pos.Position;
var occlusion = 0f;
if (sourceRelative.Length > 0)
{
occlusion = _broadPhaseSystem.IntersectRayPenetration(
pos.MapId,
new CollisionRay(
pos.Position,
sourceRelative.Normalized,
OcclusionCollisionMask),
sourceRelative.Length,
renderer.TrackingEntity);
}
renderer.Source.SetOcclusion(occlusion);
var sourceRelative = _eyeManager.CurrentEye.Position.Position - pos.Position;
var occlusion = 0f;
if (sourceRelative.Length > 0)
{
occlusion = _broadPhaseSystem.IntersectRayPenetration(
pos.MapId,
new CollisionRay(
pos.Position,
sourceRelative.Normalized,
OcclusionCollisionMask),
MathF.Min(sourceRelative.Length, MaxDistanceForOcclusion),
renderer.TrackingEntity);
}
if (renderer.Source.SetPosition(pos.Position))
renderer.Source.SetOcclusion(occlusion);
if (!renderer.Source.SetPosition(pos.Position))
{
continue;
return;
}
if (renderer.TrackingEntity != null)
if (trackingEntity)
{
renderer.Source.SetVelocity(renderer.TrackingEntity.Value.GlobalLinearVelocity());
renderer.Source.SetVelocity(renderer.TrackingEntity!.Value.GlobalLinearVelocity());
}
if (float.IsNaN(pos.Position.X) || float.IsNaN(pos.Position.Y))
{
// just duck out instead of move to NaN
renderer.Source.SetOcclusion(float.MaxValue);
continue;
}
_midiSawmill?.Warning("Interrupting positional audio, can't set position.");
renderer.Source.StopPlaying();
}
}
_volumeDirty = false;
}
/// <summary>
/// Main method for the thread rendering the midi audio.
/// </summary>
private void ThreadUpdate()
{
while (_alive)
{
lock (_renderers)
else
{
for (var i = 0; i < _renderers.Count; i++)
{
var renderer = _renderers[i];
if (!renderer.Disposed)
renderer.Render();
else
{
renderer.InternalDispose();
_renderers.Remove(renderer);
}
}
renderer.Source.SetOcclusion(float.MaxValue);
}
Thread.Sleep(1);
}
}
public void Shutdown()
{
_alive = false;
_midiThread?.Join();
_settings?.Dispose();
_volumeDirty = false;
}
/// <summary>
/// Main method for the thread rendering the midi audio.
/// </summary>
private void ThreadUpdate()
{
while (_alive)
{
lock (_renderers)
{
foreach (var renderer in _renderers)
for (var i = 0; i < _renderers.Count; i++)
{
renderer?.Dispose();
var renderer = _renderers[i];
if (!renderer.Disposed)
renderer.Render();
else
{
renderer.InternalDispose();
_renderers.Remove(renderer);
}
}
}
if (FluidsynthInitialized && !_failedInitialize)
Thread.Sleep(1);
}
}
public void Shutdown()
{
_alive = false;
_midiThread?.Join();
_settings?.Dispose();
lock (_renderers)
{
foreach (var renderer in _renderers)
{
NFluidsynth.Logger.SetLoggerMethod(null);
renderer?.Dispose();
}
}
/// <summary>
/// This class is used to load soundfonts.
/// </summary>
private class ResourceLoaderCallbacks : SoundFontLoaderCallbacks
if (FluidsynthInitialized && !_failedInitialize)
{
private readonly Dictionary<int, Stream> _openStreams = new();
private int _nextStreamId = 1;
NFluidsynth.Logger.SetLoggerMethod(null);
}
}
public override IntPtr Open(string filename)
/// <summary>
/// Internal method to get a human-readable representation of a <see cref="SequencerEvent"/>.
/// </summary>
internal static string SequencerEventToString(SequencerEvent midiEvent)
{
// ReSharper disable once UseStringInterpolation
return string.Format(
"{0} chan:{1:D2} key:{2:D5} bank:{3:D2} ctrl:{4:D5} dur:{5:D5} pitch:{6:D5} prog:{7:D3} val:{8:D5} vel:{9:D5}",
midiEvent.Type.ToString().PadLeft(22),
midiEvent.Channel,
midiEvent.Key,
midiEvent.Bank,
midiEvent.Control,
midiEvent.Duration,
midiEvent.Pitch,
midiEvent.Program,
midiEvent.Value,
midiEvent.Velocity);
}
/// <summary>
/// This class is used to load soundfonts.
/// </summary>
private sealed class ResourceLoaderCallbacks : SoundFontLoaderCallbacks
{
private readonly Dictionary<int, Stream> _openStreams = new();
private int _nextStreamId = 1;
public override IntPtr Open(string filename)
{
if (string.IsNullOrEmpty(filename))
{
if (string.IsNullOrEmpty(filename))
{
return IntPtr.Zero;
}
return IntPtr.Zero;
}
Stream? stream;
var resourceCache = IoCManager.Resolve<IResourceCache>();
var resourcePath = new ResourcePath(filename);
Stream? stream;
var resourceCache = IoCManager.Resolve<IResourceCache>();
var resourcePath = new ResourcePath(filename);
if (resourcePath.IsRooted && resourceCache.ContentFileExists(filename))
if (resourcePath.IsRooted)
{
// is it in content?
if (resourceCache.ContentFileExists(filename))
{
if (!resourceCache.TryContentFileRead(filename, out stream))
return IntPtr.Zero;
}
// is it in userdata?
else if (resourceCache.UserData.Exists(resourcePath))
{
stream = resourceCache.UserData.OpenRead(resourcePath);
}
else if (File.Exists(filename))
{
stream = File.OpenRead(filename);
@@ -431,73 +461,81 @@ namespace Robust.Client.Audio.Midi
{
return IntPtr.Zero;
}
var id = _nextStreamId++;
_openStreams.Add(id, stream);
return (IntPtr) id;
}
else if (File.Exists(filename))
{
stream = File.OpenRead(filename);
}
else
{
return IntPtr.Zero;
}
public override unsafe int Read(IntPtr buf, long count, IntPtr sfHandle)
{
var length = (int) count;
var span = new Span<byte>(buf.ToPointer(), length);
var stream = _openStreams[(int) sfHandle];
var id = _nextStreamId++;
// Fluidsynth's docs state that this method should leave the buffer unmodified if it fails. (returns -1)
try
_openStreams.Add(id, stream);
return (IntPtr) id;
}
public override unsafe int Read(IntPtr buf, long count, IntPtr sfHandle)
{
var length = (int) count;
var span = new Span<byte>(buf.ToPointer(), length);
var stream = _openStreams[(int) sfHandle];
// Fluidsynth's docs state that this method should leave the buffer unmodified if it fails. (returns -1)
try
{
// Fluidsynth does a LOT of tiny allocations (frankly, way too much).
if (count < 1024)
{
// Fluidsynth does a LOT of tiny allocations (frankly, way too much).
if (count < 1024)
{
// ReSharper disable once SuggestVarOrType_Elsewhere
Span<byte> buffer = stackalloc byte[(int)count];
// ReSharper disable once SuggestVarOrType_Elsewhere
Span<byte> buffer = stackalloc byte[(int)count];
stream.ReadExact(buffer);
stream.ReadExact(buffer);
buffer.CopyTo(span);
}
else
{
var buffer = stream.ReadExact(length);
buffer.CopyTo(span);
}
buffer.CopyTo(span);
}
catch (EndOfStreamException)
else
{
return -1;
var buffer = stream.ReadExact(length);
buffer.CopyTo(span);
}
return 0;
}
public override int Seek(IntPtr sfHandle, int offset, SeekOrigin origin)
catch (EndOfStreamException)
{
var stream = _openStreams[(int) sfHandle];
stream.Seek(offset, origin);
return 0;
return -1;
}
public override int Tell(IntPtr sfHandle)
{
var stream = _openStreams[(int) sfHandle];
return 0;
}
return (int) stream.Position;
}
public override int Seek(IntPtr sfHandle, int offset, SeekOrigin origin)
{
var stream = _openStreams[(int) sfHandle];
public override int Close(IntPtr sfHandle)
{
if (!_openStreams.Remove((int) sfHandle, out var stream))
return -1;
stream.Seek(offset, origin);
stream.Dispose();
return 0;
return 0;
}
public override int Tell(IntPtr sfHandle)
{
var stream = _openStreams[(int) sfHandle];
return (int) stream.Position;
}
public override int Close(IntPtr sfHandle)
{
if (!_openStreams.Remove((int) sfHandle, out var stream))
return -1;
stream.Dispose();
return 0;
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,80 @@
using System;
using System.Runtime.InteropServices;
using Robust.Shared.Utility;
namespace Robust.Client.Audio.Midi;
public struct MidiRendererState
{
internal FixedArray16<FixedArray128<byte>> NoteVelocities;
internal FixedArray16<FixedArray128<byte>> Controllers;
internal FixedArray16<byte> Program;
internal FixedArray16<byte> ChannelPressure;
internal FixedArray16<ushort> PitchBend;
internal Span<byte> AsSpan => MemoryMarshal.CreateSpan(ref NoteVelocities._00._00, 4160);
static unsafe MidiRendererState()
{
var s = new MidiRendererState();
DebugTools.Assert(s.AsSpan.Length == sizeof(MidiRendererState),
$"{nameof(MidiRendererState)}'s {nameof(AsSpan)} length does not match struct size! Was: {s.AsSpan.Length} Expected: {sizeof(MidiRendererState)}");
}
public MidiRendererState()
{
NoteVelocities = default;
Program = default;
ChannelPressure = default;
PitchBend = default;
Controllers = default;
// PitchBend is at 8192 by default.
PitchBend.AsSpan.Fill(8192);
// Controller defaults
Controllers.AsSpan.Fill(new FixedArray128<byte>
{
// Bank selection default
_00 = 0,
// Volume controller default
_07 = 100,
// Balance controller default
_08 = 64,
// Pan controller default
_10 = 64,
// Expression controller default
_11 = 127,
// Controller 11 default
_43 = 127,
// Sound controllers 1 to 10 defaults
_70 = 64,
_71 = 64,
_72 = 64,
_73 = 64,
_74 = 64,
_75 = 64,
_76 = 64,
_77 = 64,
_78 = 64,
_79 = 64,
// Portamento default
_84 = 255,
// Non-Registered Parameter Number defaults
_98 = 127, // LSB
_99 = 127, // MSB
// Registered Parameter Number defaults
_100 = 127, // LSB
_101 = 127, // MSB
});
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Net;
using Robust.Client.Debugging;
using Robust.Client.GameObjects;
@@ -13,6 +13,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Network.Messages;
using Robust.Shared.Players;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
@@ -20,13 +21,12 @@ using Robust.Shared.Utility;
namespace Robust.Client
{
/// <inheritdoc />
public class BaseClient : IBaseClient
public sealed class BaseClient : IBaseClient
{
[Dependency] private readonly IClientNetManager _net = default!;
[Dependency] private readonly IPlayerManager _playMan = default!;
[Dependency] private readonly INetConfigurationManager _configManager = default!;
[Dependency] private readonly IClientEntityManager _entityManager = default!;
[Dependency] private readonly IEntityLookup _entityLookup = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IDiscordRichPresence _discord = default!;
[Dependency] private readonly IGameTiming _timing = default!;
@@ -46,6 +46,8 @@ namespace Robust.Client
public string? LastDisconnectReason { get; private set; }
private (TimeSpan, GameTick) _timeBase;
/// <inheritdoc />
public void Initialize()
{
@@ -53,20 +55,34 @@ namespace Robust.Client
_net.ConnectFailed += OnConnectFailed;
_net.Disconnect += OnNetDisconnect;
_net.RegisterNetMessage<MsgSyncTimeBase>(
SyncTimeBase,
NetMessageAccept.Handshake | NetMessageAccept.Client);
_configManager.OnValueChanged(CVars.NetTickrate, TickRateChanged, invokeImmediately: true);
_playMan.Initialize();
Reset();
}
private void TickRateChanged(int tickrate)
private void SyncTimeBase(MsgSyncTimeBase message)
{
Logger.DebugS("client", $"Synchronized time base: {message.Tick}: {message.Time}");
if (RunLevel >= ClientRunLevel.Connected)
_timing.TimeBase = (message.Time, message.Tick);
else
_timeBase = (message.Time, message.Tick);
}
private void TickRateChanged(int tickrate, in CVarChangeInfo info)
{
if (GameInfo != null)
{
GameInfo.TickRate = (byte) tickrate;
}
_timing.TickRate = (byte) tickrate;
_timing.SetTickRateAt((byte) tickrate, info.TickChanged);
Logger.InfoS("client", $"Tickrate changed to: {tickrate} on tick {_timing.CurTick}");
}
@@ -75,7 +91,7 @@ namespace Robust.Client
{
if (RunLevel == ClientRunLevel.Connecting)
{
_net.Shutdown("Client mashing that connect button.");
_net.Reset("Client mashing that connect button.");
Reset();
}
@@ -203,7 +219,9 @@ namespace Robust.Client
{
DebugTools.Assert(RunLevel > ClientRunLevel.Initialize);
PlayerLeaveServer?.Invoke(this, new PlayerEventArgs(_playMan.LocalPlayer?.Session));
// Don't invoke PlayerLeaveServer if PlayerJoinedServer & GameStartedSetup hasn't been called yet.
if (RunLevel > ClientRunLevel.Connecting)
PlayerLeaveServer?.Invoke(this, new PlayerEventArgs(_playMan.LocalPlayer?.Session));
LastDisconnectReason = args.Reason;
GameStoppedReset();
@@ -213,9 +231,8 @@ namespace Robust.Client
{
_entityManager.Startup();
_mapManager.Startup();
_entityLookup.Startup();
_timing.ResetSimTime();
_timing.ResetSimTime(_timeBase);
_timing.Paused = false;
}
@@ -224,7 +241,6 @@ namespace Robust.Client
IoCManager.Resolve<INetConfigurationManager>().FlushMessages();
_gameStates.Reset();
_playMan.Shutdown();
_entityLookup.Shutdown();
_entityManager.Shutdown();
_mapManager.Shutdown();
_discord.ClearPresence();
@@ -291,7 +307,7 @@ namespace Robust.Client
/// <summary>
/// Event arguments for when something changed with the player.
/// </summary>
public class PlayerEventArgs : EventArgs
public sealed class PlayerEventArgs : EventArgs
{
/// <summary>
/// The session that triggered the event.
@@ -310,7 +326,7 @@ namespace Robust.Client
/// <summary>
/// Event arguments for when the RunLevel has changed in the BaseClient.
/// </summary>
public class RunLevelChangedEventArgs : EventArgs
public sealed class RunLevelChangedEventArgs : EventArgs
{
/// <summary>
/// RunLevel that the BaseClient switched from.
@@ -335,7 +351,7 @@ namespace Robust.Client
/// <summary>
/// Info about the server and player that is sent to the client while connecting.
/// </summary>
public class ServerInfo
public sealed class ServerInfo
{
public ServerInfo(string serverName)
{

View File

@@ -11,6 +11,7 @@ using Robust.Client.Input;
using Robust.Client.Map;
using Robust.Client.Placement;
using Robust.Client.Player;
using Robust.Client.Profiling;
using Robust.Client.Prototypes;
using Robust.Client.Reflection;
using Robust.Client.ResourceManagement;
@@ -43,11 +44,10 @@ namespace Robust.Client
IoCManager.Register<IGameTiming, ClientGameTiming>();
IoCManager.Register<IClientGameTiming, ClientGameTiming>();
IoCManager.Register<IPrototypeManager, ClientPrototypeManager>();
IoCManager.Register<IMapManager, ClientMapManager>();
IoCManager.Register<IMapManagerInternal, ClientMapManager>();
IoCManager.Register<IClientMapManager, ClientMapManager>();
IoCManager.Register<IMapManager, NetworkedMapManager>();
IoCManager.Register<IMapManagerInternal, NetworkedMapManager>();
IoCManager.Register<INetworkedMapManager, NetworkedMapManager>();
IoCManager.Register<IEntityManager, ClientEntityManager>();
IoCManager.Register<IEntityLookup, EntityLookup>();
IoCManager.Register<IReflectionManager, ClientReflectionManager>();
IoCManager.Register<IConsoleHost, ClientConsoleHost>();
IoCManager.Register<IClientConsoleHost, ClientConsoleHost>();
@@ -62,6 +62,8 @@ namespace Robust.Client
IoCManager.Register<IResourceCache, ResourceCache>();
IoCManager.Register<IResourceCacheInternal, ResourceCache>();
IoCManager.Register<IClientNetManager, NetManager>();
IoCManager.Register<EntityManager, ClientEntityManager>();
IoCManager.Register<ClientEntityManager>();
IoCManager.Register<IClientEntityManager, ClientEntityManager>();
IoCManager.Register<IClientEntityManagerInternal, ClientEntityManager>();
IoCManager.Register<IEntityNetworkManager, ClientEntityManager>();
@@ -72,11 +74,11 @@ namespace Robust.Client
IoCManager.Register<IStateManager, StateManager>();
IoCManager.Register<IUserInterfaceManager, UserInterfaceManager>();
IoCManager.Register<IUserInterfaceManagerInternal, UserInterfaceManager>();
IoCManager.Register<IDebugDrawing, DebugDrawing>();
IoCManager.Register<ILightManager, LightManager>();
IoCManager.Register<IDiscordRichPresence, DiscordRichPresence>();
IoCManager.Register<IMidiManager, MidiManager>();
IoCManager.Register<IAuthManager, AuthManager>();
IoCManager.Register<ProfViewManager>();
IoCManager.Register<IPhysicsManager, PhysicsManager>();
switch (mode)
{

View File

@@ -2,7 +2,7 @@
namespace Robust.Client.Console
{
public class ClientConGroupController : IClientConGroupController
public sealed class ClientConGroupController : IClientConGroupController
{
private IClientConGroupImplementation? _implementation;
public event Action? ConGroupUpdated;

View File

@@ -0,0 +1,98 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Robust.Shared;
using Robust.Shared.Console;
using Robust.Shared.Network.Messages;
namespace Robust.Client.Console;
internal sealed partial class ClientConsoleHost
{
private readonly Dictionary<int, PendingCompletion> _completionsPending = new();
private int _completionSeq;
public async Task<CompletionResult> GetCompletions(List<string> args, CancellationToken cancel)
{
// Last element is the command currently being typed. May be empty.
// Logger.Debug($"Running completions: {string.Join(", ", args)}");
var delay = _cfg.GetCVar(CVars.ConCompletionDelay);
if (delay > 0)
await Task.Delay((int)(delay * 1000), cancel);
return await CalcCompletions(args, cancel);
}
private Task<CompletionResult> CalcCompletions(List<string> args, CancellationToken cancel)
{
if (args.Count == 1)
{
// Typing out command name, handle this ourselves.
var cmdOptions = CompletionResult.FromOptions(
RegisteredCommands.Values
.Where(c => CanExecute(c.Command))
.OrderBy(c => c.Command)
.Select(c => new CompletionOption(c.Command, c.Description)));
return Task.FromResult(cmdOptions);
}
if (!RegisteredCommands.TryGetValue(args[0], out var cmd))
return Task.FromResult(CompletionResult.Empty);
return cmd.GetCompletionAsync(LocalShell, args.ToArray()[1..], cancel).AsTask();
}
private Task<CompletionResult> DoServerCompletions(List<string> args, CancellationToken cancel)
{
var tcs = new TaskCompletionSource<CompletionResult>();
var cts = CancellationTokenSource.CreateLinkedTokenSource(cancel);
var seq = _completionSeq++;
var pending = new PendingCompletion
{
Cts = cts,
Tcs = tcs
};
var msg = new MsgConCompletion
{
Args = args.ToArray(),
Seq = seq
};
cts.Token.Register(() =>
{
tcs.SetCanceled(cts.Token);
cts.Dispose();
_completionsPending.Remove(seq);
}, true);
NetManager.ClientSendMessage(msg);
_completionsPending.Add(seq, pending);
return tcs.Task;
}
private void ProcessCompletionResp(MsgConCompletionResp message)
{
if (!_completionsPending.TryGetValue(message.Seq, out var pending))
return;
pending.Cts.Dispose();
pending.Tcs.SetResult(message.Result);
_completionsPending.Remove(message.Seq);
}
private struct PendingCompletion
{
public TaskCompletionSource<CompletionResult> Tcs;
public CancellationTokenSource Cts;
}
}

View File

@@ -1,10 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Robust.Client.Log;
using Robust.Client.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
using Robust.Shared.Enums;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Network;
using Robust.Shared.Network.Messages;
@@ -14,7 +19,7 @@ using Robust.Shared.Utility;
namespace Robust.Client.Console
{
public class AddStringArgs : EventArgs
public sealed class AddStringArgs : EventArgs
{
public string Text { get; }
@@ -30,7 +35,7 @@ namespace Robust.Client.Console
}
}
public class AddFormattedMessageArgs : EventArgs
public sealed class AddFormattedMessageArgs : EventArgs
{
public readonly FormattedMessage Message;
@@ -41,18 +46,24 @@ namespace Robust.Client.Console
}
/// <inheritdoc cref="IClientConsoleHost" />
internal class ClientConsoleHost : ConsoleHost, IClientConsoleHost
internal sealed partial class ClientConsoleHost : ConsoleHost, IClientConsoleHost, IConsoleHostInternal
{
[Dependency] private readonly IClientConGroupController _conGroup = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IPlayerManager _player = default!;
private bool _requestedCommands;
public ClientConsoleHost() : base(isServer: false) {}
/// <inheritdoc />
public void Initialize()
{
NetManager.RegisterNetMessage<MsgConCmdReg>(HandleConCmdReg);
NetManager.RegisterNetMessage<MsgConCmdAck>(HandleConCmdAck);
NetManager.RegisterNetMessage<MsgConCmd>(ProcessCommand);
NetManager.RegisterNetMessage<MsgConCompletion>();
NetManager.RegisterNetMessage<MsgConCompletionResp>(ProcessCompletionResp);
_requestedCommands = false;
NetManager.Connected += OnNetworkConnected;
@@ -88,6 +99,11 @@ namespace Robust.Client.Console
OutputText(text, true, true);
}
public bool IsCmdServer(IConsoleCommand cmd)
{
return cmd is ServerDummyCommand;
}
public override event ConAnyCommandCallback? AnyCommandExecuted;
/// <inheritdoc />
@@ -108,9 +124,7 @@ namespace Robust.Client.Console
if (AvailableCommands.ContainsKey(commandName))
{
var playerManager = IoCManager.Resolve<IPlayerManager>();
if (!_conGroup.CanCommand(commandName) && playerManager.LocalPlayer?.Session.Status > SessionStatus.Connecting)
if (!CanExecute(commandName))
{
WriteError(null, $"Insufficient perms for command: {commandName}");
return;
@@ -128,13 +142,23 @@ namespace Robust.Client.Console
WriteError(null, "Unknown command: " + commandName);
}
private bool CanExecute(string cmdName)
{
// When not connected to a server, you can run all local commands.
// When connected to a server, you can only run commands according to the con group controller.
return _player.LocalPlayer == null
|| _player.LocalPlayer.Session.Status <= SessionStatus.Connecting
|| _conGroup.CanCommand(cmdName);
}
/// <inheritdoc />
public override void RemoteExecuteCommand(ICommonSession? session, string command)
{
if (!NetManager.IsConnected) // we don't care about session on client
return;
var msg = NetManager.CreateNetMessage<MsgConCmd>();
var msg = new MsgConCmd();
msg.Text = command;
NetManager.ClientSendMessage(msg);
}
@@ -198,36 +222,69 @@ namespace Robust.Client.Console
if (!NetManager.IsConnected)
return;
var msg = NetManager.CreateNetMessage<MsgConCmdReg>();
var msg = new MsgConCmdReg();
NetManager.ClientSendMessage(msg);
_requestedCommands = true;
}
}
/// <summary>
/// These dummies are made purely so list and help can list server-side commands.
/// </summary>
[Reflect(false)]
internal class ServerDummyCommand : IConsoleCommand
{
internal ServerDummyCommand(string command, string help, string description)
/// <summary>
/// These dummies are made purely so list and help can list server-side commands.
/// </summary>
[Reflect(false)]
private sealed class ServerDummyCommand : IConsoleCommand
{
Command = command;
Help = help;
Description = description;
internal ServerDummyCommand(string command, string help, string description)
{
Command = command;
Help = help;
Description = description;
}
public string Command { get; }
public string Description { get; }
public string Help { get; }
// Always forward to server.
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
shell.RemoteExecuteCommand(argStr);
}
public async ValueTask<CompletionResult> GetCompletionAsync(
IConsoleShell shell,
string[] args,
CancellationToken cancel)
{
var host = (ClientConsoleHost)shell.ConsoleHost;
var argsList = args.ToList();
argsList.Insert(0, Command);
return await host.DoServerCompletions(argsList, cancel);
}
}
public string Command { get; }
public string Description { get; }
public string Help { get; }
// Always forward to server.
public void Execute(IConsoleShell shell, string argStr, string[] args)
private sealed class RemoteExecCommand : IConsoleCommand
{
shell.RemoteExecuteCommand(argStr);
public string Command => ">";
public string Description => Loc.GetString("cmd-remoteexec-desc");
public string Help => Loc.GetString("cmd-remoteexec-help");
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
shell.RemoteExecuteCommand(argStr["> ".Length..]);
}
public async ValueTask<CompletionResult> GetCompletionAsync(
IConsoleShell shell,
string[] args,
CancellationToken cancel)
{
var host = (ClientConsoleHost)shell.ConsoleHost;
return await host.DoServerCompletions(args.ToList(), cancel);
}
}
}
}

View File

@@ -1,5 +1,3 @@
using System;
using System.Linq;
using JetBrains.Annotations;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
@@ -8,58 +6,7 @@ using Robust.Shared.IoC;
namespace Robust.Client.Console.Commands
{
[UsedImplicitly]
internal sealed class CVarCommand : SharedCVarCommand, IConsoleCommand
{
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length < 1 || args.Length > 2)
{
shell.WriteError("Must provide exactly one or two arguments.");
return;
}
var configManager = IoCManager.Resolve<IConfigurationManager>();
var name = args[0];
if (name == "?")
{
var cvars = configManager.GetRegisteredCVars().OrderBy(c => c);
shell.WriteLine(string.Join("\n", cvars));
return;
}
if (!configManager.IsCVarRegistered(name))
{
shell.WriteError($"CVar '{name}' is not registered. Use 'cvar ?' to get a list of all registered CVars.");
return;
}
if (args.Length == 1)
{
// Read CVar
var value = configManager.GetCVar<object>(name);
shell.WriteLine(value.ToString() ?? "");
}
else
{
// Write CVar
var value = args[1];
var type = configManager.GetCVarType(name);
try
{
var parsed = ParseObject(type, value);
configManager.SetCVar(name, parsed);
}
catch (FormatException)
{
shell.WriteLine($"Input value is in incorrect format for type {type}");
}
}
}
}
[UsedImplicitly]
public class SaveConfig : IConsoleCommand
public sealed class SaveConfig : IConsoleCommand
{
public string Command => "saveconfig";
public string Description => "Saves the client configuration to the config file";

View File

@@ -6,7 +6,7 @@ using Robust.Shared.Console;
namespace Robust.Client.Console.Commands
{
class ClearCommand : IConsoleCommand
sealed class ClearCommand : IConsoleCommand
{
public string Command => "cls";
public string Help => "Clears the debug console of all messages.";
@@ -18,7 +18,7 @@ namespace Robust.Client.Console.Commands
}
}
class FillCommand : IConsoleCommand
sealed class FillCommand : IConsoleCommand
{
public string Command => "fill";
public string Help => "Fills the console with some nonsense for debugging.";

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