From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Wed, 12 Apr 2023 00:18:30 +0000 (+1200) Subject: Fix misc bugs (#15314) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=21378f6e41434c61d876020006b2a41190527a12;p=space-station-14.git Fix misc bugs (#15314) --- diff --git a/Content.Client/Construction/ConstructionSystem.cs b/Content.Client/Construction/ConstructionSystem.cs index c16d533a2e..4800b76b3a 100644 --- a/Content.Client/Construction/ConstructionSystem.cs +++ b/Content.Client/Construction/ConstructionSystem.cs @@ -44,7 +44,7 @@ namespace Content.Client.Construction .Bind(ContentKeyFunctions.OpenCraftingMenu, new PointerInputCmdHandler(HandleOpenCraftingMenu)) .Bind(EngineKeyFunctions.Use, - new PointerInputCmdHandler(HandleUse)) + new PointerInputCmdHandler(HandleUse, outsidePrediction: true)) .Register(); SubscribeLocalEvent(HandleConstructionGhostExamined); diff --git a/Content.Server/Body/Systems/BodySystem.cs b/Content.Server/Body/Systems/BodySystem.cs index 472b6b8acd..bdc40c52e8 100644 --- a/Content.Server/Body/Systems/BodySystem.cs +++ b/Content.Server/Body/Systems/BodySystem.cs @@ -98,11 +98,13 @@ public sealed class BodySystem : SharedBodySystem public override bool DropPart(EntityUid? partId, BodyPartComponent? part = null) { - var oldBody = CompOrNull(partId)?.Body; + if (partId == null || !Resolve(partId.Value, ref part)) + return false; if (!base.DropPart(partId, part)) return false; + var oldBody = part.Body; if (oldBody == null || !TryComp(oldBody, out var humanoid)) return true; diff --git a/Content.Server/Construction/ConstructionSystem.Interactions.cs b/Content.Server/Construction/ConstructionSystem.Interactions.cs index e2f538b27f..fcbea8efdc 100644 --- a/Content.Server/Construction/ConstructionSystem.Interactions.cs +++ b/Content.Server/Construction/ConstructionSystem.Interactions.cs @@ -34,7 +34,7 @@ namespace Content.Server.Construction SubscribeLocalEvent(EnqueueEvent); // Event handling. Add your subscriptions here! Just make sure they're all handled by EnqueueEvent. - SubscribeLocalEvent(EnqueueEvent, new []{typeof(AnchorableSystem), typeof(EncryptionKeySystem)}); + SubscribeLocalEvent(EnqueueEvent, new []{typeof(AnchorableSystem)}, new []{typeof(EncryptionKeySystem)}); SubscribeLocalEvent(EnqueueEvent); } diff --git a/Content.Server/Tools/ToolSystem.LatticeCutting.cs b/Content.Server/Tools/ToolSystem.LatticeCutting.cs index c9d08eb29a..eb4b721d86 100644 --- a/Content.Server/Tools/ToolSystem.LatticeCutting.cs +++ b/Content.Server/Tools/ToolSystem.LatticeCutting.cs @@ -54,7 +54,7 @@ public sealed partial class ToolSystem private bool TryCut(EntityUid toolEntity, EntityUid user, LatticeCuttingComponent component, EntityCoordinates clickLocation) { - if (!_mapManager.TryGetGrid(clickLocation.GetGridUid(EntityManager), out var mapGrid)) + if (!_mapManager.TryFindGridAt(clickLocation.ToMap(EntityManager, _transformSystem), out var mapGrid)) return false; var tile = mapGrid.GetTileRef(clickLocation); @@ -71,7 +71,7 @@ public sealed partial class ToolSystem || tile.IsBlockedTurf(true)) return false; - var ev = new LatticeCuttingCompleteEvent(clickLocation); + var ev = new LatticeCuttingCompleteEvent(coordinates); return UseTool(toolEntity, user, toolEntity, component.Delay, component.QualityNeeded, ev); } } diff --git a/Content.Server/Tools/ToolSystem.TilePrying.cs b/Content.Server/Tools/ToolSystem.TilePrying.cs index cefeccbf74..8d760dc053 100644 --- a/Content.Server/Tools/ToolSystem.TilePrying.cs +++ b/Content.Server/Tools/ToolSystem.TilePrying.cs @@ -52,7 +52,7 @@ public sealed partial class ToolSystem if (!TryComp(toolEntity, out var tool) && component.ToolComponentNeeded) return false; - if (!_mapManager.TryGetGrid(clickLocation.GetGridUid(EntityManager), out var mapGrid)) + if (!_mapManager.TryFindGridAt(clickLocation.ToMap(EntityManager, _transformSystem), out var mapGrid)) return false; var tile = mapGrid.GetTileRef(clickLocation); @@ -67,7 +67,7 @@ public sealed partial class ToolSystem if (!tileDef.CanCrowbar) return false; - var ev = new TilePryingDoAfterEvent(clickLocation); + var ev = new TilePryingDoAfterEvent(coordinates); return UseTool(toolEntity, user, toolEntity, component.Delay, component.QualityNeeded, ev, toolComponent: tool); } diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs b/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs index 3c2ada65b2..1b446dff92 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs @@ -232,7 +232,7 @@ public partial class SharedBodySystem return true; } - public virtual bool DropPart(EntityUid? partId, [NotNullWhen(true)] BodyPartComponent? part = null) + public virtual bool DropPart(EntityUid? partId, BodyPartComponent? part = null) { if (partId == null || !Resolve(partId.Value, ref part, false) || diff --git a/Content.Shared/Maps/TurfHelpers.cs b/Content.Shared/Maps/TurfHelpers.cs index ea9b0f9e2f..3f14e6ed47 100644 --- a/Content.Shared/Maps/TurfHelpers.cs +++ b/Content.Shared/Maps/TurfHelpers.cs @@ -37,13 +37,11 @@ namespace Content.Shared.Maps if (!coordinates.IsValid(entityManager)) return null; - mapManager ??= IoCManager.Resolve(); - - if (!mapManager.TryGetGrid(coordinates.GetGridUid(entityManager), out var grid)) + var pos = coordinates.ToMap(entityManager, entityManager.System()); + if (!mapManager.TryFindGridAt(pos, out var grid)) return null; - if (!grid.TryGetTileRef(coordinates, out var tile)) return null; diff --git a/Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs b/Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs index 16d6960d99..8fca649f7a 100644 --- a/Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs +++ b/Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs @@ -56,9 +56,13 @@ public sealed class EncryptionKeySystem : EntitySystem _hands.PickupOrDrop(args.User, ent); } - // if tool use ever gets predicted this needs changing. - _popup.PopupEntity(Loc.GetString("encryption-keys-all-extracted"), uid, args.User); - _audio.PlayPvs(component.KeyExtractionSound, uid); + if (!_timing.IsFirstTimePredicted) + return; + + // TODO add predicted pop-up overrides. + if (_net.IsServer) + _popup.PopupEntity(Loc.GetString("encryption-keys-all-extracted"), uid, args.User); + _audio.PlayPredicted(component.KeyExtractionSound, uid, args.User); } public void UpdateChannels(EntityUid uid, EncryptionKeyHolderComponent component) @@ -89,7 +93,7 @@ public sealed class EncryptionKeySystem : EntitySystem private void OnInteractUsing(EntityUid uid, EncryptionKeyHolderComponent component, InteractUsingEvent args) { - if ( args.Handled || !TryComp(uid, out var storage)) + if (args.Handled) return; if (HasComp(args.Used)) @@ -97,7 +101,9 @@ public sealed class EncryptionKeySystem : EntitySystem args.Handled = true; TryInsertKey(uid, component, args); } - else if (TryComp(args.Used, out var tool) && tool.Qualities.Contains(component.KeysExtractionMethod)) + else if (TryComp(args.Used, out var tool) + && tool.Qualities.Contains(component.KeysExtractionMethod) + && component.KeyContainer.ContainedEntities.Count > 0) // dont block deconstruction { args.Handled = true; TryRemoveKey(uid, component, args, tool); diff --git a/Content.Shared/Tiles/FloorTileSystem.cs b/Content.Shared/Tiles/FloorTileSystem.cs index 0e4c335476..0720de468b 100644 --- a/Content.Shared/Tiles/FloorTileSystem.cs +++ b/Content.Shared/Tiles/FloorTileSystem.cs @@ -67,7 +67,7 @@ public sealed class FloorTileSystem : EntitySystem var results = _physics.IntersectRay(locationMap.MapId, ray, dir.Length, returnOnFirstHit: true); canAccessCenter = !results.Any(); } - + // if user can access tile center then they can place floor // otherwise check it isn't blocked by a wall if (!canAccessCenter) @@ -117,12 +117,18 @@ public sealed class FloorTileSystem : EntitySystem } else if (HasBaseTurf(currentTileDefinition, ContentTileDefinition.SpaceID)) { + if (!_stackSystem.Use(uid, 1, stack)) + continue; + + args.Handled = true; + if (_netManager.IsClient) + return; + mapGrid = _mapManager.CreateGrid(locationMap.MapId); var gridXform = Transform(mapGrid.Owner); _transform.SetWorldPosition(gridXform, locationMap.Position); location = new EntityCoordinates(mapGrid.Owner, Vector2.Zero); PlaceAt(args.User, mapGrid, location, _tileDefinitionManager[component.OutputTiles[0]].TileId, component.PlaceTileSound, mapGrid.TileSize / 2f); - args.Handled = true; return; } }