Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce CRLF removal early #1012

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/check-crlf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: CRLF Check

on:
pull_request:
types: [ opened, reopened, synchronize, ready_for_review ]

jobs:
build:
name: CRLF Check
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.6.0
- name: Check for CRLF
run: Tools/check_crlf.py
38 changes: 19 additions & 19 deletions Content.Server/Holosign/HolosignProjectorComponent.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Holosign
{
[RegisterComponent]
public sealed partial class HolosignProjectorComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)]
[DataField("signProto", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string SignProto = "HolosignWetFloor";
/// <summary>
/// How much charge a single use expends.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("chargeUse")]
public float ChargeUse = 50f;
}
}
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Server.Holosign
{
[RegisterComponent]
public sealed partial class HolosignProjectorComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)]
[DataField("signProto", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string SignProto = "HolosignWetFloor";

/// <summary>
/// How much charge a single use expends.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("chargeUse")]
public float ChargeUse = 50f;
}
}
154 changes: 77 additions & 77 deletions Content.Server/Holosign/HolosignSystem.cs
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
using Content.Shared.Examine;
using Content.Shared.Coordinates.Helpers;
using Content.Server.Power.Components;
using Content.Server.PowerCell;
using Content.Shared.Interaction;
using Content.Shared.Storage;
namespace Content.Server.Holosign;
public sealed class HolosignSystem : EntitySystem
{
[Dependency] private readonly PowerCellSystem _powerCell = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HolosignProjectorComponent, BeforeRangedInteractEvent>(OnBeforeInteract);
SubscribeLocalEvent<HolosignProjectorComponent, ExaminedEvent>(OnExamine);
}
private void OnExamine(EntityUid uid, HolosignProjectorComponent component, ExaminedEvent args)
{
// TODO: This should probably be using an itemstatus
// TODO: I'm too lazy to do this rn but it's literally copy-paste from emag.
_powerCell.TryGetBatteryFromSlot(uid, out var battery);
var charges = UsesRemaining(component, battery);
var maxCharges = MaxUses(component, battery);
using (args.PushGroup(nameof(HolosignProjectorComponent)))
{
args.PushMarkup(Loc.GetString("limited-charges-charges-remaining", ("charges", charges)));
if (charges > 0 && charges == maxCharges)
{
args.PushMarkup(Loc.GetString("limited-charges-max-charges"));
}
}
}
private void OnBeforeInteract(EntityUid uid, HolosignProjectorComponent component, BeforeRangedInteractEvent args)
{
if (args.Handled
|| !args.CanReach // prevent placing out of range
|| HasComp<StorageComponent>(args.Target) // if it's a storage component like a bag, we ignore usage so it can be stored
|| !_powerCell.TryUseCharge(uid, component.ChargeUse) // if no battery or no charge, doesn't work
)
return;
// places the holographic sign at the click location, snapped to grid.
// overlapping of the same holo on one tile remains allowed to allow holofan refreshes
var holoUid = EntityManager.SpawnEntity(component.SignProto, args.ClickLocation.SnapToGrid(EntityManager));
var xform = Transform(holoUid);
if (!xform.Anchored)
_transform.AnchorEntity(holoUid, xform); // anchor to prevent any tempering with (don't know what could even interact with it)
args.Handled = true;
}
private int UsesRemaining(HolosignProjectorComponent component, BatteryComponent? battery = null)
{
if (battery == null ||
component.ChargeUse == 0f) return 0;
return (int) (battery.CurrentCharge / component.ChargeUse);
}
private int MaxUses(HolosignProjectorComponent component, BatteryComponent? battery = null)
{
if (battery == null ||
component.ChargeUse == 0f) return 0;
return (int) (battery.MaxCharge / component.ChargeUse);
}
}
using Content.Shared.Examine;
using Content.Shared.Coordinates.Helpers;
using Content.Server.Power.Components;
using Content.Server.PowerCell;
using Content.Shared.Interaction;
using Content.Shared.Storage;

namespace Content.Server.Holosign;

public sealed class HolosignSystem : EntitySystem
{
[Dependency] private readonly PowerCellSystem _powerCell = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;


public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HolosignProjectorComponent, BeforeRangedInteractEvent>(OnBeforeInteract);
SubscribeLocalEvent<HolosignProjectorComponent, ExaminedEvent>(OnExamine);
}

private void OnExamine(EntityUid uid, HolosignProjectorComponent component, ExaminedEvent args)
{
// TODO: This should probably be using an itemstatus
// TODO: I'm too lazy to do this rn but it's literally copy-paste from emag.
_powerCell.TryGetBatteryFromSlot(uid, out var battery);
var charges = UsesRemaining(component, battery);
var maxCharges = MaxUses(component, battery);

using (args.PushGroup(nameof(HolosignProjectorComponent)))
{
args.PushMarkup(Loc.GetString("limited-charges-charges-remaining", ("charges", charges)));

if (charges > 0 && charges == maxCharges)
{
args.PushMarkup(Loc.GetString("limited-charges-max-charges"));
}
}
}

private void OnBeforeInteract(EntityUid uid, HolosignProjectorComponent component, BeforeRangedInteractEvent args)
{

if (args.Handled
|| !args.CanReach // prevent placing out of range
|| HasComp<StorageComponent>(args.Target) // if it's a storage component like a bag, we ignore usage so it can be stored
|| !_powerCell.TryUseCharge(uid, component.ChargeUse) // if no battery or no charge, doesn't work
)
return;

// places the holographic sign at the click location, snapped to grid.
// overlapping of the same holo on one tile remains allowed to allow holofan refreshes
var holoUid = EntityManager.SpawnEntity(component.SignProto, args.ClickLocation.SnapToGrid(EntityManager));
var xform = Transform(holoUid);
if (!xform.Anchored)
_transform.AnchorEntity(holoUid, xform); // anchor to prevent any tempering with (don't know what could even interact with it)

args.Handled = true;
}

private int UsesRemaining(HolosignProjectorComponent component, BatteryComponent? battery = null)
{
if (battery == null ||
component.ChargeUse == 0f) return 0;

return (int) (battery.CurrentCharge / component.ChargeUse);
}

private int MaxUses(HolosignProjectorComponent component, BatteryComponent? battery = null)
{
if (battery == null ||
component.ChargeUse == 0f) return 0;

return (int) (battery.MaxCharge / component.ChargeUse);
}
}
6 changes: 3 additions & 3 deletions Resources/Audio/Items/Handcuffs/attributions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- files: ["ziptie_end.ogg"]
license: "CC-BY-3.0"
copyright: "Taken from cable tie.wav by THE_bizniss on Freesound.org"
- files: ["ziptie_end.ogg"]
license: "CC-BY-3.0"
copyright: "Taken from cable tie.wav by THE_bizniss on Freesound.org"
source: "https://freesound.org/people/THE_bizniss/sounds/39318/"
42 changes: 21 additions & 21 deletions Resources/ConfigPresets/DeltaV/apoapsis.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
[game]
hostname = "[EN][MRP] Delta-v (Ψ) | Apoapsis"
soft_max_players = 100
[server]
rules_file = "Rules.txt"
rules_header = "ui-rules-header"
[whitelist]
enabled = false
reason = "whitelist-not-whitelisted"
min_players = 90
[shuttle]
emergency_early_launch_allowed = true
[hub]
tags = "lang:en-US,region:am_n_e,rp:med"
[atmos]
monstermos_rip_tiles = false
[game]
hostname = "[EN][MRP] Delta-v (Ψ) | Apoapsis"
soft_max_players = 100

[server]
rules_file = "Rules.txt"
rules_header = "ui-rules-header"

[whitelist]
enabled = false
reason = "whitelist-not-whitelisted"
min_players = 90

[shuttle]
emergency_early_launch_allowed = true

[hub]
tags = "lang:en-US,region:am_n_e,rp:med"

[atmos]
monstermos_rip_tiles = false
Loading
Loading