/
CVars.cs
1745 lines (1475 loc) · 76.7 KB
/
CVars.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Runtime.InteropServices;
using System.Threading;
using Lidgren.Network;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.GameObjects;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Network;
using Robust.Shared.Physics;
namespace Robust.Shared
{
/// <seealso cref="CVarDefaultOverrides"/>
[CVarDefs]
public abstract class CVars
{
protected CVars()
{
throw new InvalidOperationException("This class must not be instantiated");
}
/*
* NET
*/
/// <summary>
/// Hard max-cap of concurrent connections for the main game networking.
/// </summary>
/// <remarks>
/// This cannot be bypassed in any way, since it is used by Lidgren internally.
/// </remarks>
public static readonly CVarDef<int> NetMaxConnections =
CVarDef.Create("net.max_connections", 256, CVar.ARCHIVE | CVar.REPLICATED | CVar.SERVER);
/// <summary>
/// UDP port to bind to for main game networking.
/// Each address specified in <c>net.bindto</c> is bound with this port.
/// </summary>
public static readonly CVarDef<int> NetPort =
CVarDef.Create("net.port", 1212, CVar.ARCHIVE);
/// <summary>
/// Send buffer size on the UDP sockets used for main game networking.
/// </summary>
public static readonly CVarDef<int> NetSendBufferSize =
CVarDef.Create("net.sendbuffersize", 131071, CVar.ARCHIVE);
/// <summary>
/// Receive buffer size on the UDP sockets used for main game networking.
/// </summary>
public static readonly CVarDef<int> NetReceiveBufferSize =
CVarDef.Create("net.receivebuffersize", 131071, CVar.ARCHIVE);
/// <summary>
/// Size of the pool for Lidgren's array buffers to send messages.
/// Set to 0 to disable pooling; max is 8192.
/// </summary>
/// <remarks>
/// Higher just means more potentially wasted space and slower pool retrieval.
/// </remarks>
public static readonly CVarDef<int> NetPoolSize =
CVarDef.Create("net.pool_size", 512, CVar.CLIENT | CVar.SERVER);
/// <summary>
/// Maximum UDP payload size to send by default, for IPv4.
/// </summary>
/// <seealso cref="NetMtuExpand"/>
/// <seealso cref="NetMtuIpv6"/>
public static readonly CVarDef<int> NetMtu =
CVarDef.Create("net.mtu", 900, CVar.ARCHIVE);
/// <summary>
/// Maximum UDP payload size to send by default, for IPv6.
/// </summary>
/// <seealso cref="NetMtu"/>
/// <seealso cref="NetMtuExpand"/>
public static readonly CVarDef<int> NetMtuIpv6 =
CVarDef.Create("net.mtu_ipv6", NetPeerConfiguration.kDefaultMTUV6, CVar.ARCHIVE);
/// <summary>
/// If set, automatically try to detect MTU above <see cref="NetMtu"/>.
/// </summary>
/// <seealso cref="NetMtu"/>
/// <seealso cref="NetMtuIpv6"/>
/// <seealso cref="NetMtuExpandFrequency"/>
/// <seealso cref="NetMtuExpandFailAttempts"/>
public static readonly CVarDef<bool> NetMtuExpand =
CVarDef.Create("net.mtu_expand", false, CVar.ARCHIVE);
/// <summary>
/// Interval between MTU expansion attempts, in seconds.
/// </summary>
/// <remarks>
/// This property is named incorrectly: it is actually an interval, not a frequency.
/// The name is chosen to match Lidgren's <see cref="NetPeerConfiguration.ExpandMTUFrequency"/>.
/// </remarks>
/// <seealso cref="NetMtuExpand"/>
public static readonly CVarDef<float> NetMtuExpandFrequency =
CVarDef.Create("net.mtu_expand_frequency", 2f, CVar.ARCHIVE);
/// <summary>
/// How many times an MTU expansion attempt can fail before settling on a final MTU value.
/// </summary>
/// <seealso cref="NetMtuExpand"/>
public static readonly CVarDef<int> NetMtuExpandFailAttempts =
CVarDef.Create("net.mtu_expand_fail_attempts", 5, CVar.ARCHIVE);
/// <summary>
/// Whether to enable verbose debug logging in Lidgren.
/// </summary>
/// <seealso cref="NetMtuExpand"/>
public static readonly CVarDef<bool> NetVerbose =
CVarDef.Create("net.verbose", false);
/// <summary>
/// Comma-separated list of IP addresses to bind to for the main game networking port.
/// The port bound is the value of <c>net.port</c> always.
/// </summary>
public static readonly CVarDef<string> NetBindTo =
CVarDef.Create("net.bindto", "0.0.0.0,::", CVar.ARCHIVE | CVar.SERVERONLY);
/// <summary>
/// Whether to bind IPv6 sockets in dual-stack mode (for main game networking).
/// </summary>
public static readonly CVarDef<bool> NetDualStack =
CVarDef.Create("net.dualstack", false, CVar.ARCHIVE | CVar.SERVERONLY);
/// <summary>
/// Whether to interpolate between server game states for render frames on the client.
/// </summary>
public static readonly CVarDef<bool> NetInterp =
CVarDef.Create("net.interp", true, CVar.ARCHIVE | CVar.CLIENTONLY);
/// <summary>
/// The target number of game states to keep buffered up to smooth out network inconsistency.
/// </summary>
public static readonly CVarDef<int> NetBufferSize =
CVarDef.Create("net.buffer_size", 2, CVar.ARCHIVE | CVar.CLIENTONLY);
/// <summary>
/// The maximum size of the game state buffer. If this is exceeded the client will request a full game state.
/// Values less than <see cref="GameStateProcessor.MinimumMaxBufferSize"/> will be ignored.
/// </summary>
public static readonly CVarDef<int> NetMaxBufferSize =
CVarDef.Create("net.max_buffer_size", 512, CVar.ARCHIVE | CVar.CLIENTONLY);
/// <summary>
/// Enable verbose game state/networking logging.
/// </summary>
public static readonly CVarDef<bool> NetLogging =
CVarDef.Create("net.logging", false, CVar.ARCHIVE);
/// <summary>
/// Whether prediction is enabled on the client.
/// </summary>
/// <remarks>
/// If off, simulation input commands will not fire and most entity methods will not run update.
/// </remarks>
public static readonly CVarDef<bool> NetPredict =
CVarDef.Create("net.predict", true, CVar.CLIENTONLY | CVar.ARCHIVE);
/// <summary>
/// Extra amount of ticks to run-ahead for prediction on the client.
/// </summary>
public static readonly CVarDef<int> NetPredictTickBias =
CVarDef.Create("net.predict_tick_bias", 1, CVar.CLIENTONLY | CVar.ARCHIVE);
// On Windows we default this to 16ms lag bias, to account for time period lag in the Lidgren thread.
// Basically due to how time periods work on Windows, messages are (at worst) time period-delayed when sending.
// BUT! Lidgren's latency calculation *never* measures this due to how it works.
// This broke some prediction calculations quite badly so we bias them to mask it.
// This is not necessary on Linux because Linux, for better or worse,
// just has the Lidgren thread go absolute brr polling.
/// <summary>
/// Extra amount of seconds to run-ahead for prediction on the client.
/// </summary>
public static readonly CVarDef<float> NetPredictLagBias = CVarDef.Create(
"net.predict_lag_bias",
OperatingSystem.IsWindows() ? 0.016f : 0,
CVar.CLIENTONLY | CVar.ARCHIVE);
public static readonly CVarDef<int> NetStateBufMergeThreshold =
CVarDef.Create("net.state_buf_merge_threshold", 5, CVar.CLIENTONLY | CVar.ARCHIVE);
/// <summary>
/// Whether to cull entities sent to clients from the server.
/// If this is on, only entities immediately close to a client will be sent.
/// Otherwise, all entities will be sent to all clients.
/// </summary>
public static readonly CVarDef<bool> NetPVS =
CVarDef.Create("net.pvs", true, CVar.ARCHIVE | CVar.REPLICATED | CVar.SERVER);
/// <summary>
/// Size increments for the automatic growth of Pvs' entity data storage. 0 will increase it by factors of 2
/// </summary>
public static readonly CVarDef<int> NetPvsEntityGrowth =
CVarDef.Create("net.pvs_entity_growth", 1 << 16, CVar.ARCHIVE | CVar.SERVERONLY);
/// <summary>
/// Initial size of PVS' entity data storage.
/// </summary>
public static readonly CVarDef<int> NetPvsEntityInitial =
CVarDef.Create("net.pvs_entity_initial", 1 << 16, CVar.ARCHIVE | CVar.SERVERONLY);
/// <summary>
/// Maximum ever size of PVS' entity data storage.
/// </summary>
/// <remarks>
/// <para>
/// Arbitrarily set to a default of 16 million entities.
/// Increasing this parameter does not increase real memory usage, only virtual.
/// </para>
/// </remarks>
public static readonly CVarDef<int> NetPvsEntityMax =
CVarDef.Create("net.pvs_entity_max", 1 << 24, CVar.ARCHIVE | CVar.SERVERONLY);
/// <summary>
/// If false, this will run more parts of PVS synchronously. This will generally slow it down, can be useful
/// for collecting tick timing metrics.
/// </summary>
public static readonly CVarDef<bool> NetPvsAsync =
CVarDef.Create("net.pvs_async", true, CVar.ARCHIVE | CVar.SERVERONLY);
/// <summary>
/// View size to take for PVS calculations, as the size of the sides of a square centered on the view points of
/// clients. See also <see cref="NetPvsPriorityRange"/>.
/// </summary>
public static readonly CVarDef<float> NetMaxUpdateRange =
CVarDef.Create("net.pvs_range", 25f, CVar.ARCHIVE | CVar.REPLICATED | CVar.SERVER);
/// <summary>
/// A variant of <see cref="NetMaxUpdateRange"/> that is used to limit the view-distance of entities with the
/// <see cref="MetaDataFlags.PvsPriority"/> flag set. This can be used to extend the range at which certain
/// entities become visible.
/// </summary>
/// <remarks>
/// This is useful for entities like lights and occluders to try and prevent noticeable pop-in as players
/// move around. Note that this has no effect if it is less than <see cref="NetMaxUpdateRange"/>, and that this
/// only works for entities that are directly parented to a grid or map.
/// </remarks>
public static readonly CVarDef<float> NetPvsPriorityRange =
CVarDef.Create("net.pvs_priority_range", 32.5f, CVar.ARCHIVE | CVar.REPLICATED | CVar.SERVER);
/// <summary>
/// Maximum allowed delay between the current tick and a client's last acknowledged tick before we send the
/// next game state reliably and simply force update the acked tick,
/// </summary>
public static readonly CVarDef<int> NetForceAckThreshold =
CVarDef.Create("net.force_ack_threshold", 60, CVar.ARCHIVE | CVar.SERVERONLY);
/// <summary>
/// This limits the number of new entities that can be sent to a client in a single game state. This exists to
/// avoid stuttering on the client when it has to spawn a bunch of entities in a single tick. If ever entity
/// spawning isn't hot garbage, this can be increased.
/// </summary>
public static readonly CVarDef<int> NetPVSEntityBudget =
CVarDef.Create("net.pvs_budget", 50, CVar.ARCHIVE | CVar.REPLICATED | CVar.CLIENT);
/// <summary>
/// This limits the number of entities that can re-enter a client's view in a single game state. This exists to
/// avoid stuttering on the client when it has to update the transform of a bunch (700+) of entities in a single
/// tick. Ideally this would just be handled client-side somehow.
/// </summary>
public static readonly CVarDef<int> NetPVSEntityEnterBudget =
CVarDef.Create("net.pvs_enter_budget", 200, CVar.ARCHIVE | CVar.REPLICATED | CVar.CLIENT);
/// <summary>
/// The amount of pvs-exiting entities that a client will process in a single tick.
/// </summary>
public static readonly CVarDef<int> NetPVSEntityExitBudget =
CVarDef.Create("net.pvs_exit_budget", 75, CVar.ARCHIVE | CVar.CLIENTONLY);
/// <summary>
/// ZSTD compression level to use when compressing game states. Used by both networking and replays.
/// </summary>
public static readonly CVarDef<int> NetPvsCompressLevel =
CVarDef.Create("net.pvs_compress_level", 3, CVar.ARCHIVE);
/// <summary>
/// Log late input messages from clients.
/// </summary>
public static readonly CVarDef<bool> NetLogLateMsg =
CVarDef.Create("net.log_late_msg", true);
/// <summary>
/// Ticks per second on the server.
/// This influences both how frequently game code processes, and how frequently updates are sent to clients.
/// </summary>
public static readonly CVarDef<int> NetTickrate =
CVarDef.Create("net.tickrate", 60, CVar.ARCHIVE | CVar.REPLICATED | CVar.SERVER);
/// <summary>
/// Offset CurTime at server start by this amount (in seconds).
/// </summary>
public static readonly CVarDef<int> NetTimeStartOffset =
CVarDef.Create("net.time_start_offset", 0, CVar.SERVERONLY);
/// <summary>
/// How many seconds after the last message from the server before we consider it timed out.
/// </summary>
public static readonly CVarDef<float> ConnectionTimeout =
CVarDef.Create("net.connection_timeout", 25.0f, CVar.ARCHIVE | CVar.CLIENTONLY);
/// <summary>
/// When doing the connection handshake, how long to wait before initial connection attempt packets.
/// </summary>
public static readonly CVarDef<float> ResendHandshakeInterval =
CVarDef.Create("net.handshake_interval", 3.0f, CVar.ARCHIVE | CVar.CLIENTONLY);
/// <summary>
/// When doing the connection handshake, how many times to try sending initial connection attempt packets.
/// </summary>
public static readonly CVarDef<int> MaximumHandshakeAttempts =
CVarDef.Create("net.handshake_attempts", 5, CVar.ARCHIVE | CVar.CLIENTONLY);
/// <summary>
/// If true, encrypt connections when possible.
/// </summary>
/// <remarks>
/// Encryption is currently only possible when the client has authenticated with the auth server.
/// </remarks>
public static readonly CVarDef<bool> NetEncrypt =
CVarDef.Create("net.encrypt", true, CVar.CLIENTONLY);
/// <summary>
/// If true, use UPnP to automatically forward ports on startup if possible.
/// </summary>
public static readonly CVarDef<bool> NetUPnP =
CVarDef.Create("net.upnp", false, CVar.SERVERONLY);
/// <summary>
/// App identifier used by Lidgren. This must match between client and server for them to be able to connect.
/// </summary>
public static readonly CVarDef<string> NetLidgrenAppIdentifier =
CVarDef.Create("net.lidgren_app_identifier", "RobustToolbox");
/// <summary>
/// Add random fake network loss to all outgoing UDP network packets, as a ratio of how many packets to drop.
/// 0 = no packet loss, 1 = all packets dropped
/// </summary>
public static readonly CVarDef<float> NetFakeLoss = CVarDef.Create("net.fakeloss", 0f, CVar.CHEAT);
/// <summary>
/// Add fake extra delay to all outgoing UDP network packets, in seconds.
/// </summary>
/// <seealso cref="NetFakeLagRand"/>
public static readonly CVarDef<float> NetFakeLagMin = CVarDef.Create("net.fakelagmin", 0f, CVar.CHEAT);
/// <summary>
/// Add fake extra random delay to all outgoing UDP network packets, in seconds.
/// The actual delay added for each packet is random between 0 and the specified value.
/// </summary>
/// <seealso cref="NetFakeLagMin"/>
public static readonly CVarDef<float> NetFakeLagRand = CVarDef.Create("net.fakelagrand", 0f, CVar.CHEAT);
/// <summary>
/// Add random fake duplicates to all outgoing UDP network packets, as a ratio of how many packets to duplicate.
/// 0 = no packets duplicated, 1 = all packets duplicated.
/// </summary>
public static readonly CVarDef<float> NetFakeDuplicates = CVarDef.Create("net.fakeduplicates", 0f, CVar.CHEAT);
/// <summary>
/// When using Happy Eyeballs to try both IPv6 over IPv4, the delay that IPv4 gets to get less priority.
/// </summary>
public static readonly CVarDef<float> NetHappyEyeballsDelay =
CVarDef.Create("net.happy_eyeballs_delay", 0.025f, CVar.CLIENTONLY);
/// <summary>
/// Controls whether the networking library will log warning messages.
/// </summary>
/// <remarks>
/// Disabling this should make the networking layer more resilient against some DDoS attacks.
/// </remarks>
public static readonly CVarDef<bool> NetLidgrenLogWarning =
CVarDef.Create("net.lidgren_log_warning", true);
/// <summary>
/// Controls whether the networking library will log error messages.
/// </summary>
public static readonly CVarDef<bool> NetLidgrenLogError =
CVarDef.Create("net.lidgren_log_error", true);
/**
* SUS
*/
/// <summary>
/// If not zero on Windows, the server will sent the tick period for its own process via <c>TimeBeginPeriod</c>.
/// This increases polling and sleep precision of the network and main thread,
/// but may negatively affect battery life or such.
/// </summary>
public static readonly CVarDef<int> SysWinTickPeriod =
CVarDef.Create("sys.win_tick_period", 3, CVar.SERVERONLY);
/// <summary>
/// On non-FULL_RELEASE builds, use ProfileOptimization/tiered JIT to speed up game startup.
/// </summary>
public static readonly CVarDef<bool> SysProfileOpt =
CVarDef.Create("sys.profile_opt", true);
/// <summary>
/// Controls stack size of the game logic thread, in bytes.
/// </summary>
public static readonly CVarDef<int> SysGameThreadStackSize =
CVarDef.Create("sys.game_thread_stack_size", 8 * 1024 * 1024);
/// <summary>
/// Controls thread priority of the game logic thread.
/// </summary>
public static readonly CVarDef<int> SysGameThreadPriority =
CVarDef.Create("sys.game_thread_priority", (int) ThreadPriority.AboveNormal);
/// <summary>
/// Whether to run a <see cref="GC.Collect()"/> operation after the engine is finished initializing.
/// </summary>
public static readonly CVarDef<bool> SysGCCollectStart =
CVarDef.Create("sys.gc_collect_start", true);
/// <summary>
/// Use precise sleeping methods in the game loop.
/// </summary>
public static readonly CVarDef<bool> SysPreciseSleep =
CVarDef.Create("sys.precise_sleep", true);
/*
* METRICS
*/
/// <summary>
/// Whether to enable a prometheus metrics server.
/// </summary>
public static readonly CVarDef<bool> MetricsEnabled =
CVarDef.Create("metrics.enabled", false, CVar.SERVERONLY);
/// <summary>
/// The IP address to host the metrics server on.
/// </summary>
public static readonly CVarDef<string> MetricsHost =
CVarDef.Create("metrics.host", "localhost", CVar.SERVERONLY);
/// <summary>
/// The port to host the metrics server on.
/// </summary>
public static readonly CVarDef<int> MetricsPort =
CVarDef.Create("metrics.port", 44880, CVar.SERVERONLY);
/// <summary>
/// Sets a fixed interval (seconds) for internal collection of certain metrics,
/// when not using the Prometheus metrics server.
/// </summary>
/// <remarks>
/// <para>
/// Most metrics are internally implemented directly via the prometheus-net library.
/// These metrics can only be scraped by the Prometheus metrics server (<see cref="MetricsEnabled"/>).
/// However, newer metrics are implemented with the <c>System.Diagnostics.Metrics</c> library in the .NET runtime.
/// These metrics can be scraped through more means, such as <c>dotnet counters</c>.
/// </para>
/// <para>
/// While many metrics are simple counters that can "just" be reported,
/// some metrics require more advanced internal work and need some code to be ran internally
/// before their values are made current. When collecting metrics via a
/// method other than the Prometheus metrics server, these metrics pose a problem,
/// as there is no way for the game to update them before collection properly.
/// </para>
/// <para>
/// This CVar acts as a fallback: if set to a value other than 0 (disabled),
/// these metrics will be internally updated at the interval provided.
/// </para>
/// <para>
/// This does not need to be enabled if metrics are collected exclusively via the Prometheus metrics server.
/// </para>
/// </remarks>
public static readonly CVarDef<float> MetricsUpdateInterval =
CVarDef.Create("metrics.update_interval", 0f, CVar.SERVERONLY);
/// <summary>
/// Enable detailed runtime metrics. Empty to disable.
/// </summary>
/// <remarks>
/// Runtime metrics are provided by https://github.com/djluck/prometheus-net.DotNetRuntime.
/// Granularity of metrics can be further configured with related CVars.
/// </remarks>
public static readonly CVarDef<bool> MetricsRuntime =
CVarDef.Create("metrics.runtime", true, CVar.SERVERONLY);
/// <summary>
/// Mode for runtime GC metrics. Empty to disable.
/// </summary>
/// <remarks>
/// See the documentation for prometheus-net.DotNetRuntime for values and their metrics:
/// https://github.com/djluck/prometheus-net.DotNetRuntime/blob/master/docs/metrics-exposed-5.0.md
/// </remarks>
public static readonly CVarDef<string> MetricsRuntimeGc =
CVarDef.Create("metrics.runtime_gc", "Counters", CVar.SERVERONLY);
/// <summary>
/// Histogram buckets for GC and pause times. Comma-separated list of floats, in milliseconds.
/// </summary>
public static readonly CVarDef<string> MetricsRuntimeGcHistogram =
CVarDef.Create("metrics.runtime_gc_histogram", "0.5,1.0,2.0,4.0,6.0,10.0,15.0,20.0", CVar.SERVERONLY);
/// <summary>
/// Mode for runtime lock contention metrics. Empty to disable.
/// </summary>
/// <remarks>
/// See the documentation for prometheus-net.DotNetRuntime for values and their metrics:
/// https://github.com/djluck/prometheus-net.DotNetRuntime/blob/master/docs/metrics-exposed-5.0.md
/// </remarks>
public static readonly CVarDef<string> MetricsRuntimeContention =
CVarDef.Create("metrics.runtime_contention", "Counters", CVar.SERVERONLY);
/// <summary>
/// Sample lock contention every N events. Higher numbers increase accuracy but also memory use.
/// </summary>
public static readonly CVarDef<int> MetricsRuntimeContentionSampleRate =
CVarDef.Create("metrics.runtime_contention_sample_rate", 50, CVar.SERVERONLY);
/// <summary>
/// Mode for runtime thread pool metrics. Empty to disable.
/// </summary>
/// <remarks>
/// See the documentation for prometheus-net.DotNetRuntime for values and their metrics:
/// https://github.com/djluck/prometheus-net.DotNetRuntime/blob/master/docs/metrics-exposed-5.0.md
/// </remarks>
public static readonly CVarDef<string> MetricsRuntimeThreadPool =
CVarDef.Create("metrics.runtime_thread_pool", "Counters", CVar.SERVERONLY);
/// <summary>
/// Histogram buckets for thread pool queue length.
/// </summary>
public static readonly CVarDef<string> MetricsRuntimeThreadPoolQueueHistogram =
CVarDef.Create("metrics.runtime_thread_pool_queue_histogram", "0,10,30,60,120,180", CVar.SERVERONLY);
/// <summary>
/// Mode for runtime JIT metrics. Empty to disable.
/// </summary>
/// <remarks>
/// See the documentation for prometheus-net.DotNetRuntime for values and their metrics:
/// https://github.com/djluck/prometheus-net.DotNetRuntime/blob/master/docs/metrics-exposed-5.0.md
/// </remarks>
public static readonly CVarDef<string> MetricsRuntimeJit =
CVarDef.Create("metrics.runtime_jit", "Counters", CVar.SERVERONLY);
/// <summary>
/// Sample JIT every N events. Higher numbers increase accuracy but also memory use.
/// </summary>
public static readonly CVarDef<int> MetricsRuntimeJitSampleRate =
CVarDef.Create("metrics.runtime_jit_sample_rate", 10, CVar.SERVERONLY);
/// <summary>
/// Mode for runtime exception metrics. Empty to disable.
/// </summary>
/// <remarks>
/// See the documentation for prometheus-net.DotNetRuntime for values and their metrics:
/// https://github.com/djluck/prometheus-net.DotNetRuntime/blob/master/docs/metrics-exposed-5.0.md
/// </remarks>
public static readonly CVarDef<string> MetricsRuntimeException =
CVarDef.Create("metrics.runtime_exception", "Counters", CVar.SERVERONLY);
/// <summary>
/// Mode for runtime TCP socket metrics. Empty to disable.
/// </summary>
/// <remarks>
/// See the documentation for prometheus-net.DotNetRuntime for values and their metrics:
/// https://github.com/djluck/prometheus-net.DotNetRuntime/blob/master/docs/metrics-exposed-5.0.md
/// </remarks>
public static readonly CVarDef<string> MetricsRuntimeSocket =
CVarDef.Create("metrics.runtime_socket", "Counters", CVar.SERVERONLY);
/*
* STATUS
*/
/// <summary>
/// Whether to enable the HTTP status API server.
/// </summary>
/// <remarks>
/// This is necessary for people to be able to connect via the launcher.
/// </remarks>
public static readonly CVarDef<bool> StatusEnabled =
CVarDef.Create("status.enabled", true, CVar.ARCHIVE | CVar.SERVERONLY);
/// <summary>
/// Prefix address to bind the HTTP status API server to.
/// This is in the form of addr:port, with * serving as a wildcard "all".
/// If empty (the default), this is automatically generated to match the UDP ports.
/// </summary>
public static readonly CVarDef<string> StatusBind =
CVarDef.Create("status.bind", "", CVar.ARCHIVE | CVar.SERVERONLY);
/// <summary>
/// Max amount of concurrent connections to the HTTP status server.
/// Note that this is for actively processing requests, not kept-alive/pooled connections.
/// </summary>
public static readonly CVarDef<int> StatusMaxConnections =
CVarDef.Create("status.max_connections", 5, CVar.SERVERONLY);
/// <summary>
/// UDP address that should be advertised and the launcher will use to connect to.
/// If not set, the launcher will automatically infer this based on the address it already has.
/// </summary>
public static readonly CVarDef<string> StatusConnectAddress =
CVarDef.Create("status.connectaddress", "", CVar.ARCHIVE | CVar.SERVERONLY);
/*
* BUILD
*/
/// <summary>
/// Engine version that launcher needs to connect to this server.
/// </summary>
public static readonly CVarDef<string> BuildEngineVersion =
CVarDef.Create("build.engine_version",
typeof(CVars).Assembly.GetName().Version?.ToString(3) ?? String.Empty);
/// <summary>
/// Fork ID, as a hint to the launcher to manage local files.
/// This can be anything, it does not need a strict format.
/// </summary>
public static readonly CVarDef<string> BuildForkId =
CVarDef.Create("build.fork_id", "");
/// <summary>
/// Version string, as a hint to the launcher to manage local files.
/// This can be anything, it does not need a strict format.
/// </summary>
public static readonly CVarDef<string> BuildVersion =
CVarDef.Create("build.version", "");
/// <summary>
/// Content pack the launcher should download to connect to this server.
/// </summary>
public static readonly CVarDef<string> BuildDownloadUrl =
CVarDef.Create("build.download_url", string.Empty);
/// <summary>
/// URL of the content manifest the launcher should download to connect to this server.
/// </summary>
public static readonly CVarDef<string> BuildManifestUrl =
CVarDef.Create("build.manifest_url", string.Empty);
/// <summary>
/// URL at which the launcher can download the manifest game files.
/// </summary>
public static readonly CVarDef<string> BuildManifestDownloadUrl =
CVarDef.Create("build.manifest_download_url", string.Empty);
/// <summary>
/// SHA-256 hash of the content pack hosted at <c>build.download_url</c>
/// </summary>
public static readonly CVarDef<string> BuildHash =
CVarDef.Create("build.hash", "");
/// <summary>
/// SHA-256 hash of the manifest hosted at <c>build.manifest_url</c>
/// </summary>
public static readonly CVarDef<string> BuildManifestHash =
CVarDef.Create("build.manifest_hash", "");
/*
* WATCHDOG
*/
/// <summary>
/// API token set by the watchdog to communicate to the server.
/// </summary>
public static readonly CVarDef<string> WatchdogToken =
CVarDef.Create("watchdog.token", "", CVar.SERVERONLY | CVar.CONFIDENTIAL);
/// <summary>
/// Watchdog server identifier for this server.
/// </summary>
public static readonly CVarDef<string> WatchdogKey =
CVarDef.Create("watchdog.key", "", CVar.SERVERONLY);
/// <summary>
/// Base URL of the watchdog on the local machine.
/// </summary>
public static readonly CVarDef<string> WatchdogBaseUrl =
CVarDef.Create("watchdog.baseUrl", "http://localhost:5000", CVar.SERVERONLY);
/*
* GAME
*/
/// <summary>
/// Hard max-cap of concurrent connections for the main game networking.
/// </summary>
/// <remarks>
/// This cannot be bypassed in any way, since it is used by Lidgren internally.
/// </remarks>
[Obsolete("Use net.max_connections instead")]
public static readonly CVarDef<int> GameMaxPlayers =
CVarDef.Create("game.maxplayers", 0, CVar.ARCHIVE | CVar.REPLICATED | CVar.SERVER);
/// <summary>
/// Name of the game server. This shows up in the launcher and potentially parts of the UI.
/// </summary>
public static readonly CVarDef<string> GameHostName =
CVarDef.Create("game.hostname", "MyServer", CVar.ARCHIVE | CVar.REPLICATED | CVar.SERVER);
/// <summary>
/// Description of the game server in the launcher.
/// </summary>
public static readonly CVarDef<string> GameDesc =
CVarDef.Create("game.desc", "Just another server, don't mind me!", CVar.SERVERONLY);
/// <summary>
/// If a grid is shrunk to include no more tiles should it be deleted.
/// </summary>
public static readonly CVarDef<bool> GameDeleteEmptyGrids =
CVarDef.Create("game.delete_empty_grids", true, CVar.ARCHIVE | CVar.SERVER);
/// <summary>
/// Automatically pause simulation if there are no players connected to the game server.
/// </summary>
public static readonly CVarDef<bool> GameAutoPauseEmpty =
CVarDef.Create("game.auto_pause_empty", true, CVar.SERVERONLY);
/*
* LOG
*/
/// <summary>
/// Write server log to disk.
/// </summary>
public static readonly CVarDef<bool> LogEnabled =
CVarDef.Create("log.enabled", true, CVar.ARCHIVE | CVar.SERVERONLY);
/// <summary>
/// Path to put log files in if log writing is enabled.
/// </summary>
public static readonly CVarDef<string> LogPath =
CVarDef.Create("log.path", "logs", CVar.ARCHIVE | CVar.SERVERONLY);
/// <summary>
/// Format for individual log files, based on current date and time replacement.
/// </summary>
public static readonly CVarDef<string> LogFormat =
CVarDef.Create("log.format", "log_%(date)s-T%(time)s.txt", CVar.ARCHIVE | CVar.SERVERONLY);
/// <summary>
/// Minimum log level for all server logging.
/// </summary>
public static readonly CVarDef<LogLevel> LogLevel =
CVarDef.Create("log.level", Log.LogLevel.Info, CVar.ARCHIVE | CVar.SERVERONLY);
/// <summary>
/// Log a separate exception log for all exceptions that occur.
/// </summary>
public static readonly CVarDef<bool> LogRuntimeLog =
CVarDef.Create("log.runtimelog", true, CVar.ARCHIVE | CVar.SERVERONLY);
/*
* Light
*/
/// <summary>
/// This is the maximum the viewport is enlarged to check for any intersecting render-trees for lights.
/// This should be set to your maximum light radius.
/// </summary>
/// <remarks>
/// If this value is too small it just means there may be pop-in where a light is located on a render-tree
/// outside of our viewport.
/// </remarks>
public static readonly CVarDef<float> MaxLightRadius =
CVarDef.Create("light.max_radius", 32.1f, CVar.CLIENTONLY | CVar.ARCHIVE);
/// <summary>
/// Maximum number of lights that the client will draw.
/// </summary>
public static readonly CVarDef<int> MaxLightCount =
CVarDef.Create("light.max_light_count", 2048, CVar.CLIENTONLY | CVar.ARCHIVE);
/// <summary>
/// Maximum number of occluders that the client will draw. Values below 1024 have no effect.
/// </summary>
public static readonly CVarDef<int> MaxOccluderCount =
CVarDef.Create("light.max_occluder_count", 2048, CVar.CLIENTONLY | CVar.ARCHIVE);
/// <summary>
/// Scale used to modify the horizontal and vertical resolution of lighting framebuffers,
/// relative to the viewport framebuffer size.
/// </summary>
public static readonly CVarDef<float> LightResolutionScale =
CVarDef.Create("light.resolution_scale", 0.5f, CVar.CLIENTONLY | CVar.ARCHIVE);
/// <summary>
/// Maximum amount of shadow-casting lights that can be rendered in a single viewport at once.
/// </summary>
public static readonly CVarDef<int> MaxShadowcastingLights =
CVarDef.Create("light.max_shadowcasting_lights", 128, CVar.CLIENTONLY | CVar.ARCHIVE);
/// <summary>
/// Whether to give shadows a soft edge when rendering.
/// </summary>
public static readonly CVarDef<bool> LightSoftShadows =
CVarDef.Create("light.soft_shadows", true, CVar.CLIENTONLY | CVar.ARCHIVE);
/// <summary>
/// Apply a gaussian blur to the final lighting framebuffer to smoothen it out a little.
/// </summary>
public static readonly CVarDef<bool> LightBlur=
CVarDef.Create("light.blur", true, CVar.CLIENTONLY | CVar.ARCHIVE);
/// <summary>
/// Factor by which to blur the lighting framebuffer under <c>light.blur</c>.
/// </summary>
public static readonly CVarDef<float> LightBlurFactor =
CVarDef.Create("light.blur_factor", 0.001f, CVar.CLIENTONLY | CVar.ARCHIVE);
/*
* Lookup
*/
/// <summary>
/// Like MaxLightRadius this is how far we enlarge lookups to find intersecting components.
/// This should be set to your maximum entity size.
/// </summary>
public static readonly CVarDef<float> LookupEnlargementRange =
CVarDef.Create("lookup.enlargement_range", 10.0f, CVar.ARCHIVE | CVar.REPLICATED | CVar.CHEAT);
/*
* LOKI
*/
/// <summary>
/// Whether to send the server log to Grafana Loki.
/// </summary>
public static readonly CVarDef<bool> LokiEnabled =
CVarDef.Create("loki.enabled", false, CVar.SERVERONLY);
/// <summary>
/// The name of the current server, set as the value of the "Server" label in Loki.
/// </summary>
public static readonly CVarDef<string> LokiName =
CVarDef.Create("loki.name", "", CVar.SERVERONLY);
/// <summary>
/// The address of the Loki server to send to.
/// </summary>
public static readonly CVarDef<string> LokiAddress =
CVarDef.Create("loki.address", "", CVar.SERVERONLY);
/// <summary>
/// If set, a HTTP Basic auth username to use when talking to Loki.
/// </summary>
public static readonly CVarDef<string> LokiUsername =
CVarDef.Create("loki.username", "", CVar.SERVERONLY);
/// <summary>
/// If set, a HTTP Basic auth password to use when talking to Loki.
/// </summary>
public static readonly CVarDef<string> LokiPassword =
CVarDef.Create("loki.password", "", CVar.SERVERONLY);
/*
* AUTH
*/
/// <summary>
/// Mode with which to handle authentication on the server.
/// See the documentation of the <see cref="Network.AuthMode"/> enum for values.
/// </summary>
public static readonly CVarDef<int> AuthMode =
CVarDef.Create("auth.mode", (int) Network.AuthMode.Required, CVar.SERVERONLY);
/// <summary>
/// Allow unauthenticated localhost connections, even if the auth mode is set to required.
/// These connections have a "localhost@" prefix as username.
/// </summary>
public static readonly CVarDef<bool> AuthAllowLocal =
CVarDef.Create("auth.allowlocal", true, CVar.SERVERONLY);
// Only respected on server, client goes through IAuthManager for security.
/// <summary>
/// Authentication server address.
/// </summary>
public static readonly CVarDef<string> AuthServer =
CVarDef.Create("auth.server", AuthManager.DefaultAuthServer, CVar.SERVERONLY);
/*
* RENDERING
*/
/// <summary>
/// This biases the RSI-direction used to draw diagonally oriented 4-directional sprites to avoid flickering between directions. A positive
/// value biases towards facing N/S, while a negative value will bias towards E/W.
/// </summary>
/// <remarks>
/// The bias needs to be large enough to prevent sprites on rotating grids from flickering, but should be
/// small enough that it is generally unnoticeable. Currently it is somewhat large to combat issues with
/// eye-lerping & grid rotations.
/// </remarks>
public static readonly CVarDef<double> RenderSpriteDirectionBias =
CVarDef.Create("render.sprite_direction_bias", -0.05, CVar.ARCHIVE | CVar.CLIENTONLY);
public static readonly CVarDef<string> RenderFOVColor =
CVarDef.Create("render.fov_color", Color.Black.ToHex(), CVar.ARCHIVE | CVar.CLIENTONLY);
/*
* CONTROLS
*/
/// <summary>
/// Milliseconds to wait to consider double-click delays.
/// </summary>
public static readonly CVarDef<int> DoubleClickDelay =
CVarDef.Create("controls.double_click_delay", 250, CVar.ARCHIVE | CVar.CLIENTONLY);
/// <summary>
/// Range in pixels for double-clicks
/// </summary>
public static readonly CVarDef<int> DoubleClickRange =
CVarDef.Create("controls.double_click_range", 10, CVar.ARCHIVE | CVar.CLIENTONLY);
/*
* DISPLAY
*/
/// <summary>
/// Enable VSync for rendering.
/// </summary>
public static readonly CVarDef<bool> DisplayVSync =
CVarDef.Create("display.vsync", true, CVar.ARCHIVE | CVar.CLIENTONLY);
/// <summary>
/// Window mode for the main game window. 0 = windowed, 1 = fullscreen.
/// </summary>
public static readonly CVarDef<int> DisplayWindowMode =
CVarDef.Create("display.windowmode", 0, CVar.ARCHIVE | CVar.CLIENTONLY);
/// <summary>
/// Initial width of the game window when running on windowed mode.
/// </summary>
public static readonly CVarDef<int> DisplayWidth =
CVarDef.Create("display.width", 1280, CVar.CLIENTONLY);
/// <summary>
/// Initial height of the game window when running on windowed mode.
/// </summary>
public static readonly CVarDef<int> DisplayHeight =
CVarDef.Create("display.height", 720, CVar.CLIENTONLY);
/// <summary>
/// UI scale for all UI controls. If zero, this value is automatically calculated from the OS.
/// </summary>
public static readonly CVarDef<float> DisplayUIScale =
CVarDef.Create("display.uiScale", 0f, CVar.ARCHIVE | CVar.CLIENTONLY);
// Clyde related enums are in Clyde.Constants.cs.
/// <summary>
/// Which renderer to use to render the game.
/// </summary>
public static readonly CVarDef<int> DisplayRenderer =
CVarDef.Create("display.renderer", 0, CVar.CLIENTONLY);
/// <summary>
/// Whether to use compatibility mode.
/// </summary>
/// <remarks>
/// This can change certain behaviors like GL version selection to try to avoid driver crashes/bugs.
/// </remarks>
public static readonly CVarDef<bool> DisplayCompat =
CVarDef.Create("display.compat", false, CVar.CLIENTONLY);
/// <summary>
/// Which OpenGL version to use for the OpenGL renderer.
/// Values correspond to the (private) RendererOpenGLVersion enum in Clyde.
/// </summary>
public static readonly CVarDef<int> DisplayOpenGLVersion =
CVarDef.Create("display.opengl_version", 0, CVar.CLIENTONLY);
/// <summary>
/// On Windows, use ANGLE as OpenGL implementation.
/// </summary>
public static readonly CVarDef<bool> DisplayAngle =
CVarDef.Create("display.angle", false, CVar.CLIENTONLY);
/// <summary>
/// Use a custom DXGI swap chain when using ANGLE.
/// Should improve performance and fixes main window sRGB handling with ANGLE.
/// </summary>
public static readonly CVarDef<bool> DisplayAngleCustomSwapChain =
CVarDef.Create("display.angle_custom_swap_chain", true, CVar.CLIENTONLY);
/// <summary>
/// Force ANGLE to create a GLES2 context (not a compatible GLES3 context).
/// </summary>
public static readonly CVarDef<bool> DisplayAngleForceEs2 =
CVarDef.Create("display.angle_force_es2", false, CVar.CLIENTONLY);
/// <summary>
/// Force ANGLE to create a context from a D3D11 FL 10_0 device.
/// </summary>
public static readonly CVarDef<bool> DisplayAngleForce10_0 =