Skip to content

Commit

Permalink
Merge branch 'march-2024-upstream-merge' of github.com:new-frontiers-…
Browse files Browse the repository at this point in the history
…14/frontier-station-14 into march-2024-upstream-merge
  • Loading branch information
GreaseMonk committed Apr 17, 2024
2 parents 6a1e1e2 + 5829cd7 commit abbc8f6
Show file tree
Hide file tree
Showing 26 changed files with 4,176 additions and 7,642 deletions.
21 changes: 12 additions & 9 deletions Content.Server/Cargo/Systems/CargoSystem.Orders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ private void OnAddOrderMessage(EntityUid uid, CargoOrderConsoleComponent compone
if (!component.AllowedGroups.Contains(product.Group))
return;

var data = GetOrderData(args, product, GenerateOrderId(orderDatabase));
var data = GetOrderData(EntityManager.GetNetEntity(uid), args, product, GenerateOrderId(orderDatabase));

if (!TryAddOrder(orderDatabase.Owner, data, orderDatabase))
{
Expand Down Expand Up @@ -334,12 +334,15 @@ private void UpdateOrderState(CargoOrderConsoleComponent component, EntityUid? s

if (station == null || !TryGetOrderDatabase(station.Value, out var _, out var orderDatabase, component)) return;

// Frontier - we only want to see orders made on the same computer, so filter them out
var filteredOrders = orderDatabase.Orders.Where(order => order.Computer == EntityManager.GetNetEntity(component.Owner)).ToList();

var state = new CargoConsoleInterfaceState(
MetaData(player).EntityName,
GetOutstandingOrderCount(orderDatabase),
orderDatabase.Capacity,
balance,
orderDatabase.Orders);
filteredOrders);

_uiSystem.SetUiState(bui, state);
}
Expand All @@ -354,9 +357,9 @@ private void PlayDenySound(EntityUid uid, CargoOrderConsoleComponent component)
_audio.PlayPvs(_audio.GetSound(component.ErrorSound), uid);
}

private static CargoOrderData GetOrderData(CargoConsoleAddOrderMessage args, CargoProductPrototype cargoProduct, int id)
private static CargoOrderData GetOrderData(NetEntity consoleUid, CargoConsoleAddOrderMessage args, CargoProductPrototype cargoProduct, int id)
{
return new CargoOrderData(id, cargoProduct.Product, cargoProduct.Cost, args.Amount, args.Requester, args.Reason);
return new CargoOrderData(id, cargoProduct.Product, cargoProduct.Cost, args.Amount, args.Requester, args.Reason, consoleUid);
}

public static int GetOutstandingOrderCount(StationCargoOrderDatabaseComponent component)
Expand Down Expand Up @@ -417,7 +420,7 @@ StationDataComponent stationData
DebugTools.Assert(_protoMan.HasIndex<EntityPrototype>(spawnId));
// Make an order
var id = GenerateOrderId(component);
var order = new CargoOrderData(id, spawnId, cost, qty, sender, description);
var order = new CargoOrderData(id, spawnId, cost, qty, sender, description, null);

// Approve it now
order.SetApproverData(dest, sender);
Expand Down Expand Up @@ -462,9 +465,9 @@ public void ClearOrders(StationCargoOrderDatabaseComponent component)
component.Orders.Clear();
}

private static bool PopFrontOrder(StationCargoOrderDatabaseComponent orderDB, [NotNullWhen(true)] out CargoOrderData? orderOut)
private static bool PopFrontOrder(List<NetEntity> consoleUidList, StationCargoOrderDatabaseComponent orderDB, [NotNullWhen(true)] out CargoOrderData? orderOut)
{
var orderIdx = orderDB.Orders.FindIndex(order => order.Approved);
var orderIdx = orderDB.Orders.FindIndex(order => order.Approved && consoleUidList.Any(consoleUid => consoleUid == order.Computer));
if (orderIdx == -1)
{
orderOut = null;
Expand All @@ -485,9 +488,9 @@ private static bool PopFrontOrder(StationCargoOrderDatabaseComponent orderDB, [N
/// <summary>
/// Tries to fulfill the next outstanding order.
/// </summary>
private bool FulfillNextOrder(StationCargoOrderDatabaseComponent orderDB, EntityCoordinates spawn, string? paperProto)
private bool FulfillNextOrder(List<NetEntity> consoleUidList, StationCargoOrderDatabaseComponent orderDB, EntityCoordinates spawn, string? paperProto)
{
if (!PopFrontOrder(orderDB, out var order))
if (!PopFrontOrder(consoleUidList, orderDB, out var order))
return false;

return FulfillOrder(order, spawn, paperProto);
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private List<CargoOrderData> GetProjectedOrders(
// We won't be able to fit the whole order on, so make one
// which represents the space we do have left:
var reducedOrder = new CargoOrderData(order.OrderId,
order.ProductId, order.Price, spaceRemaining, order.Requester, order.Reason);
order.ProductId, order.Price, spaceRemaining, order.Requester, order.Reason, null);
orders.Add(reducedOrder);
}
else
Expand Down
6 changes: 5 additions & 1 deletion Content.Server/Cargo/Systems/CargoSystem.Telepad.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using Content.Server.Cargo.Components;
using Content.Server.Construction;
using Content.Server.Paper;
Expand Down Expand Up @@ -67,8 +68,11 @@ private void UpdateTelepad(float frameTime)
continue;
}

// Frontier - This makes sure telepads spawn goods of linked computers only.
List<NetEntity> consoleUidList = sinkComponent.LinkedSources.Select(item => EntityManager.GetNetEntity(item)).ToList();

var xform = Transform(uid);
if (FulfillNextOrder(orderDatabase, xform.Coordinates, comp.PrinterOutput))
if (FulfillNextOrder(consoleUidList, orderDatabase, xform.Coordinates, comp.PrinterOutput))
{
_audio.PlayPvs(_audio.GetSound(comp.TeleportSound), uid, AudioParams.Default.WithVolume(-8f));
UpdateOrders(station.Value, orderDatabase);
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/_NF/Smuggling/DeadDropSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private void SendDeadDrop(EntityUid uid, DeadDropComponent component, EntityUid
}

//tattle on the smuggler here, but obfuscate it a bit if possible to just the grid it was summoned from.
var channel = _prototypeManager.Index<RadioChannelPrototype>("Security");
var channel = _prototypeManager.Index<RadioChannelPrototype>("NFSD");
var sender = Transform(user).GridUid ?? uid;

_radio.SendRadioMessage(sender, Loc.GetString("deaddrop-security-report"), channel, uid);
Expand Down
5 changes: 4 additions & 1 deletion Content.Shared/Cargo/CargoOrderData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ public sealed class CargoOrderData
public bool Approved => Approver is not null;
public string? Approver;

public CargoOrderData(int orderId, string productId, int price, int amount, string requester, string reason)
public NetEntity? Computer = null;

public CargoOrderData(int orderId, string productId, int price, int amount, string requester, string reason, NetEntity? computer)
{
OrderId = orderId;
ProductId = productId;
Price = price;
OrderQuantity = amount;
Requester = requester;
Reason = reason;
Computer = computer;
}

public void SetApproverData(string? fullName, string? jobTitle)
Expand Down
Loading

0 comments on commit abbc8f6

Please sign in to comment.