-
Notifications
You must be signed in to change notification settings - Fork 16
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
💀 #174
💀 #174
Changes from all commits
5af62a8
2d6d852
d361ece
f9d5f34
801d5d4
b7610e4
d4519a6
d74450a
bf7be6d
2ff232e
3983e0d
c0f6293
87693ac
1e45bd7
45c2bbf
5a61853
d699757
7fb28d9
02c690f
3472522
4e175ea
1e886e0
b3a9cb8
6ebe75b
056c98c
5af2d0b
bd3dab2
3270d4d
5069863
a9aa81d
9065183
4a06fae
239d397
4bccb4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared._DV.Surgery; | ||
|
||
/// <summary> | ||
/// Exists for use as a status effect. Allows surgical operations to not cause immense pain. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class AnesthesiaComponent : Component; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared._DV.Traits.Assorted; | ||
|
||
/// <summary> | ||
/// This is used for the unborgable trait, which blacklists a brain from MMIs. | ||
/// If this is added to a body, it gets moved to its brain if it has one. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class UnborgableComponent : Component; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Content.Shared.Body.Components; | ||
using Content.Shared.Body.Organ; | ||
using Content.Shared.Body.Systems; | ||
using Content.Shared.Examine; | ||
using Content.Shared.Movement.Components; // TODO: use BrainComponent instead of InputMover when shitmed is merged | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Shared._DV.Traits.Assorted; | ||
|
||
/// <summary> | ||
/// Adds a warning examine message to brains with <see cref="UnborgableComponent"/>. | ||
/// </summary> | ||
public sealed class UnborgableSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedBodySystem _body = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<UnborgableComponent, MapInitEvent>(OnMapInit); | ||
SubscribeLocalEvent<UnborgableComponent, ExaminedEvent>(OnExamined); | ||
} | ||
|
||
/// <summary> | ||
/// Returns true if a mob's brain has <see cref="UnborgableComponent"/>. | ||
/// </summary> | ||
public bool IsUnborgable(Entity<BodyComponent?> ent) | ||
{ | ||
// technically this will apply for any organ not just brain, but assume nobody will be evil and do that | ||
return _body.GetBodyOrganEntityComps<UnborgableComponent>(ent).Count > 0; | ||
Comment on lines
+30
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security concern: Potential component abuse. The comment "assume nobody will be evil" suggests a potential security vulnerability. The system should enforce strict validation rather than relying on assumptions. Consider implementing proper validation: -// technically this will apply for any organ not just brain, but assume nobody will be evil and do that
-return _body.GetBodyOrganEntityComps<UnborgableComponent>(ent).Count > 0;
+var organs = _body.GetBodyOrganEntityComps<UnborgableComponent>(ent);
+return organs.Any(organ => HasComp<BrainComponent>(organ.Owner));
|
||
} | ||
Comment on lines
+29
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security concern: Validate organ type in IsUnborgable. The comment "technically this will apply for any organ not just brain" indicates a potential security issue. The method should explicitly check for brain organs to prevent misuse. public bool IsUnborgable(Entity<BodyComponent?> ent)
{
- // technically this will apply for any organ not just brain, but assume nobody will be evil and do that
- return _body.GetBodyOrganEntityComps<UnborgableComponent>(ent).Count > 0;
+ var brainOrgans = _body.GetBodyOrganEntityComps<BrainComponent>(ent);
+ return brainOrgans.Any(brain => HasComp<UnborgableComponent>(brain));
}
|
||
|
||
private void OnMapInit(Entity<UnborgableComponent> ent, ref MapInitEvent args) | ||
{ | ||
if (!TryComp<BodyComponent>(ent, out var body)) | ||
return; | ||
|
||
var brains = _body.GetBodyOrganEntityComps<InputMoverComponent>((ent.Owner, body)); | ||
foreach (var brain in brains) | ||
{ | ||
EnsureComp<UnborgableComponent>(brain); | ||
} | ||
} | ||
|
||
private void OnExamined(Entity<UnborgableComponent> ent, ref ExaminedEvent args) | ||
{ | ||
// need a health analyzer to see if someone can't be borged, can't just look at them and know | ||
if (!args.IsInDetailsRange || HasComp<BodyComponent>(ent)) | ||
return; | ||
|
||
args.PushMarkup(Loc.GetString("brain-cannot-be-borged-message")); | ||
} | ||
Comment on lines
+46
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Review examination message visibility logic. The examination message is only shown when the entity has no BodyComponent, which seems counterintuitive. Shouldn't this be visible when examining the brain itself? Consider this alternative implementation: - if (!args.IsInDetailsRange || HasComp<BodyComponent>(ent))
+ if (!args.IsInDetailsRange)
return;
+ // Only show message when examining the brain itself
+ if (!TryComp<InputMoverComponent>(ent, out _))
+ return;
args.PushMarkup(Loc.GetString("brain-cannot-be-borged-message"));
|
||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -283,6 +283,9 @@ private void OnToolCanPerform(Entity<SurgeryStepComponent> ent, ref SurgeryCanPe | |||||||||||||||||||||||
if (!containerSlot.ContainedEntity.HasValue) | ||||||||||||||||||||||||
continue; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if (_tagSystem.HasTag(containerSlot.ContainedEntity.Value, "PermissibleForSurgery")) // DeltaV: allow some clothing items to be operated through | ||||||||||||||||||||||||
continue; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
Comment on lines
+286
to
+288
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider adding validation for the contained entity. The code assumes the contained entity is valid. Consider adding explicit validation. if (!containerSlot.ContainedEntity.HasValue)
continue;
+ var containedEntity = containerSlot.ContainedEntity.Value;
+ if (!_entityManager.IsAlive(containedEntity))
+ continue;
+
- if (_tagSystem.HasTag(containerSlot.ContainedEntity.Value, "PermissibleForSurgery"))
+ if (_tagSystem.HasTag(containedEntity, PermissibleForSurgeryTag))
continue; 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||
args.Invalid = StepInvalidReason.Armor; | ||||||||||||||||||||||||
args.Popup = Loc.GetString("surgery-ui-window-steps-error-armor"); | ||||||||||||||||||||||||
return; | ||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- files: ["reptillian_hiss1.ogg"] | ||
license: "CC-BY-SA-3.0" | ||
copyright: "Taken from https://github.com/ss220-space/Paradise/commit/6572a5f522e32cb5e0af7fb3ca3e45a725e2e992. Downmixed to 1 channel, volume edited" | ||
source: "https://github.com/ss220-space/Paradise/blob/4bbfb9eb00771b3fae7108fca1a1ba5879926e3e/sound/effects/unathihiss.ogg" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
TODO comment is stale - BrainComponent is available
The code is still using
InputMoverComponent
even thoughBrainComponent
is now available in the codebase (Content.Server/Body/Components/BrainComponent.cs). The TODO comment should be addressed by updating the implementation to useBrainComponent
.Content.Shared/_DV/Traits/Assorted/UnborgableSystem.cs
: ReplaceInputMoverComponent
withBrainComponent
in both the import statement andGetBodyOrganEntityComps<>
call.🔗 Analysis chain
Address TODO comment regarding BrainComponent.
The comment indicates a temporary solution using InputMoverComponent. This should be updated when shitmed is merged.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 600
Script:
Length of output: 1669