-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'new-frontiers-14:master' into dragonfly
- Loading branch information
Showing
457 changed files
with
13,201 additions
and
16,574 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using System.Runtime.InteropServices; | ||
using Content.Shared.CCVar; | ||
using Content.Shared.Database; | ||
using Robust.Shared.Enums; | ||
using Robust.Shared.Player; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Server.Chat.Managers; | ||
|
||
internal sealed partial class ChatManager | ||
{ | ||
private readonly Dictionary<ICommonSession, RateLimitDatum> _rateLimitData = new(); | ||
|
||
public bool HandleRateLimit(ICommonSession player) | ||
{ | ||
ref var datum = ref CollectionsMarshal.GetValueRefOrAddDefault(_rateLimitData, player, out _); | ||
var time = _gameTiming.RealTime; | ||
if (datum.CountExpires < time) | ||
{ | ||
// Period expired, reset it. | ||
var periodLength = _configurationManager.GetCVar(CCVars.ChatRateLimitPeriod); | ||
datum.CountExpires = time + TimeSpan.FromSeconds(periodLength); | ||
datum.Count = 0; | ||
datum.Announced = false; | ||
} | ||
|
||
var maxCount = _configurationManager.GetCVar(CCVars.ChatRateLimitCount); | ||
datum.Count += 1; | ||
|
||
if (datum.Count <= maxCount) | ||
return true; | ||
|
||
// Breached rate limits, inform admins if configured. | ||
if (_configurationManager.GetCVar(CCVars.ChatRateLimitAnnounceAdmins)) | ||
{ | ||
if (datum.NextAdminAnnounce < time) | ||
{ | ||
SendAdminAlert(Loc.GetString("chat-manager-rate-limit-admin-announcement", ("player", player.Name))); | ||
var delay = _configurationManager.GetCVar(CCVars.ChatRateLimitAnnounceAdminsDelay); | ||
datum.NextAdminAnnounce = time + TimeSpan.FromSeconds(delay); | ||
} | ||
} | ||
|
||
if (!datum.Announced) | ||
{ | ||
DispatchServerMessage(player, Loc.GetString("chat-manager-rate-limited"), suppressLog: true); | ||
_adminLogger.Add(LogType.ChatRateLimited, LogImpact.Medium, $"Player {player} breached chat rate limits"); | ||
|
||
datum.Announced = true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
private void PlayerStatusChanged(object? sender, SessionStatusEventArgs e) | ||
{ | ||
if (e.NewStatus == SessionStatus.Disconnected) | ||
_rateLimitData.Remove(e.Session); | ||
} | ||
|
||
private struct RateLimitDatum | ||
{ | ||
/// <summary> | ||
/// Time stamp (relative to <see cref="IGameTiming.RealTime"/>) this rate limit period will expire at. | ||
/// </summary> | ||
public TimeSpan CountExpires; | ||
|
||
/// <summary> | ||
/// How many messages have been sent in the current rate limit period. | ||
/// </summary> | ||
public int Count; | ||
|
||
/// <summary> | ||
/// Have we announced to the player that they've been blocked in this rate limit period? | ||
/// </summary> | ||
public bool Announced; | ||
|
||
/// <summary> | ||
/// Time stamp (relative to <see cref="IGameTiming.RealTime"/>) of the | ||
/// next time we can send an announcement to admins about rate limit breach. | ||
/// </summary> | ||
public TimeSpan NextAdminAnnounce; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
Content.Server/DeltaV/Weapons/Ranged/Components/EnergyGunComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; | ||
using Content.Server.DeltaV.Weapons.Ranged.Systems; | ||
|
||
namespace Content.Server.DeltaV.Weapons.Ranged.Components; | ||
|
||
/// <summary> | ||
/// Allows for energy gun to switch between three modes. This also changes the sprite accordingly. | ||
/// </summary> | ||
/// <remarks>This is BatteryWeaponFireModesSystem with additional changes to allow for different sprites.</remarks> | ||
[RegisterComponent] | ||
[Access(typeof(EnergyGunSystem))] | ||
[AutoGenerateComponentState] | ||
public sealed partial class EnergyGunComponent : Component | ||
{ | ||
/// <summary> | ||
/// A list of the different firing modes the energy gun can switch between | ||
/// </summary> | ||
[DataField("fireModes", required: true)] | ||
[AutoNetworkedField] | ||
public List<EnergyWeaponFireMode> FireModes = new(); | ||
|
||
/// <summary> | ||
/// The currently selected firing mode | ||
/// </summary> | ||
[DataField("currentFireMode")] | ||
[AutoNetworkedField] | ||
public EnergyWeaponFireMode? CurrentFireMode = default!; | ||
} | ||
|
||
[DataDefinition] | ||
public sealed partial class EnergyWeaponFireMode | ||
{ | ||
/// <summary> | ||
/// The projectile prototype associated with this firing mode | ||
/// </summary> | ||
[DataField("proto", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] | ||
public string Prototype = default!; | ||
|
||
/// <summary> | ||
/// The battery cost to fire the projectile associated with this firing mode | ||
/// </summary> | ||
[DataField("fireCost")] | ||
public float FireCost = 100; | ||
|
||
/// <summary> | ||
/// The name of the selected firemode | ||
/// </summary> | ||
[DataField("name")] | ||
public string Name = string.Empty; | ||
|
||
/// <summary> | ||
/// What RsiState we use for that firemode if it needs to change. | ||
/// </summary> | ||
[DataField("state")] | ||
public string State = string.Empty; | ||
} |
Oops, something went wrong.