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

NFSD Criminal Records Fix + Shipyard Fax Records System #1578

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
dcc6418
Criminal Records initial WIP
Qulibly Apr 26, 2024
32c844f
Criminal Records and job icon fixup
Qulibly Apr 26, 2024
7d0b1fe
Shipyard record added extra info to papers
Qulibly May 4, 2024
79aa222
Merge branch 'nfsd-criminal-records' of https://github.com/Qulibly/fr…
Qulibly Jun 29, 2024
6935ef9
Merge branch 'new-frontiers-14:master' into nfsd-criminal-records
Qulibly Jun 29, 2024
8a35e77
Merge branch 'nfsd-criminal-records' of https://github.com/Qulibly/fr…
Qulibly Jun 29, 2024
26b2d48
Criminal and Shipyard records minor fixes
Qulibly Jun 29, 2024
28d683b
Merge branch 'master' into nfsd-criminal-records
dvir001 Jul 1, 2024
4575b92
Criminal and Shipyard records fax error fix
Qulibly Jul 13, 2024
ea5f81b
Merge branch 'master' into nfsd-criminal-records
Qulibly Jul 13, 2024
0e405ee
Merge branch 'nfsd-criminal-records' of https://github.com/Qulibly/fr…
Qulibly Jul 13, 2024
f90ef86
Criminal and Shipyard records fax vessel class integration
Qulibly Jul 13, 2024
5ddb0e4
Criminal and Shipyard records fax record paper and illegal informatio…
Qulibly Jul 14, 2024
c7eab94
Criminal and Shipyard records fax paper and antag record cleanup
Qulibly Jul 16, 2024
723c064
Criminal and Shipyard records fax implementing sector records to NFSD…
Qulibly Jul 16, 2024
e465e45
Update prospector.yml
Qulibly Jul 16, 2024
cb0cce2
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
whatston3 Jul 25, 2024
0fa617a
Merge branch 'master' into nfsd-criminal-records
dvir001 Aug 4, 2024
9260aab
Merge branch 'master' into nfsd-criminal-records
dvir001 Aug 6, 2024
f72e196
Merge branch 'master' into nfsd-criminal-records
Qulibly Aug 12, 2024
a5b1456
Shipyard Record ShipConnect PDA APP WIP
Qulibly Oct 1, 2024
7c3f280
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
whatston3 Oct 1, 2024
354d0b1
Merge branch 'master' into nfsd-criminal-records
whatston3 Oct 6, 2024
3183dd0
Merge branch 'master' into nfsd-criminal-records
dvir001 Oct 15, 2024
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
23 changes: 23 additions & 0 deletions Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Content.Shared.Access;
using Content.Server.Fax;
using Robust.Shared.Enums;

namespace Content.Server.Shipyard.Systems;

Expand Down Expand Up @@ -248,6 +250,27 @@ private void OnPurchaseMessage(EntityUid uid, ShipyardConsoleComponent component
_records.Synchronize(shuttleStation!.Value);
_records.Synchronize(station);

//Sends vessel details to all dedicated faxes
//Sends vessel details to all dedicated faxes
if(_mind.TryGetMind(args.Actor, out var _mindUid, out var _mindComp)
&& _prefManager.GetPreferences(_mind.GetSession(_mindComp)!.UserId).SelectedCharacter is HumanoidCharacterProfile _profile)
{
var metaData = MetaData((EntityUid) shuttleStation);
name = metaData.EntityName;

TryComp<FingerprintComponent>(player, out var _fingerprintComponent);
TryComp<DnaComponent>(player, out var _dnaComponent);

var faxQuery = EntityQueryEnumerator<ShipyardRecordPaperComponent>();

while (faxQuery.MoveNext(out var faxUid, out var recordPaperComp))
{
var ev = new ShipyardRecordPaperTransmitEvent(name, _profile.Name, _profile.Species, _profile.Gender, _profile.Age, _fingerprintComponent!.Fingerprint!, _dnaComponent!.DNA!, vessel.Category, vessel.Class, vessel.Group, vessel.Price, vessel.Description);
RaiseLocalEvent(faxUid, ref ev);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does a broadcast event work here instead?

Suggested change
var faxQuery = EntityQueryEnumerator<ShipyardRecordPaperComponent>();
while (faxQuery.MoveNext(out var faxUid, out var recordPaperComp))
{
var ev = new ShipyardRecordPaperTransmitEvent(name, _profile.Name, _profile.Species, _profile.Gender, _profile.Age, _fingerprintComponent!.Fingerprint!, _dnaComponent!.DNA!, vessel.Category, vessel.Class, vessel.Group, vessel.Price, vessel.Description);
RaiseLocalEvent(faxUid, ref ev);
}
RaiseLocalEvent(ref ev);

}


//if (ShipyardConsoleUiKey.Security == (ShipyardConsoleUiKey) args.UiKey) Enable in the case we force this on every security ship
// EnsureComp<StationEmpImmuneComponent>(shuttle.Owner); Enable in the case we force this on every security ship

Expand Down
77 changes: 77 additions & 0 deletions Content.Server/StationRecords/Systems/StationRecordsSystem.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using System.Diagnostics.CodeAnalysis;
using Content.Server.Forensics;
using Content.Server.GameTicking;
using Content.Server.Station.Components;
using Content.Shared.Inventory;
using Content.Shared.PDA;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.StationRecords;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Robust.Shared.Random; //Frontier modification

namespace Content.Server.StationRecords.Systems;

Expand Down Expand Up @@ -35,6 +37,7 @@ public sealed class StationRecordsSystem : SharedStationRecordsSystem
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly StationRecordKeyStorageSystem _keyStorage = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;

public override void Initialize()
{
Expand All @@ -49,6 +52,28 @@ private void OnPlayerSpawn(PlayerSpawnCompleteEvent args)
return;

CreateGeneralRecord(args.Station, args.Mob, args.Profile, args.JobId, stationRecords);

/*var query = EntityQueryEnumerator<SectorStationRecordComponent>();

while (query.MoveNext(out var stationGridUid, out var comp))
{
if (TryComp<StationMemberComponent>(stationGridUid, out var stationMemberComponent))
{
var stationEntityUid = stationMemberComponent.Station;

CreateGeneralRecord(stationEntityUid, args.Mob, args.Profile, args.JobId, stationRecords);

/*
if (TryComp<StationRecordKeyStorageComponent>(targetId, out var keyStorage)
&& stationEntityUid != null
&& keyStorage.Key != null)
{
if (!TryGetRecord<GeneralStationRecord>(Key.Value, out var record))
continue;
}
}

}*/
Comment on lines +60 to +81
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this here for a reason?

Suggested change
/*var query = EntityQueryEnumerator<SectorStationRecordComponent>();
while (query.MoveNext(out var stationGridUid, out var comp))
{
if (TryComp<StationMemberComponent>(stationGridUid, out var stationMemberComponent))
{
var stationEntityUid = stationMemberComponent.Station;
CreateGeneralRecord(stationEntityUid, args.Mob, args.Profile, args.JobId, stationRecords);
/*
if (TryComp<StationRecordKeyStorageComponent>(targetId, out var keyStorage)
&& stationEntityUid != null
&& keyStorage.Key != null)
{
if (!TryGetRecord<GeneralStationRecord>(Key.Value, out var record))
continue;
}
}
}*/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With it I believe initially reason for leaving it was to make it easier to in future to upstream merges.
As the original code wiukd ecist as commwnted and in case new changes broke whole aystwm then changes could be disabled if needed.

Though there is chance that the idea behind the commented out block has changed

}

private void CreateGeneralRecord(EntityUid station, EntityUid player, HumanoidCharacterProfile profile,
Expand All @@ -66,6 +91,58 @@ private void CreateGeneralRecord(EntityUid station, EntityUid player, HumanoidCh
TryComp<DnaComponent>(player, out var dnaComponent);

CreateGeneralRecord(station, idUid.Value, profile.Name, profile.Age, profile.Species, profile.Gender, jobId, fingerprintComponent?.Fingerprint, dnaComponent?.DNA, profile, records);

var query = EntityQueryEnumerator<SectorStationRecordComponent>();

while (query.MoveNext(out var stationEntityUid, out var comp))
{
if (!TryComp<IgnoreSectorStationRecordComponent>(player, out var playerComp))
{
Comment on lines +128 to +129
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If statement avoids the entire while body. Push to the outside.

var stationList = EntityQueryEnumerator<StationRecordsComponent>();

while (stationList.MoveNext(out var stationUid, out var stationRecComp))
{
if (TryComp<StationRecordKeyStorageComponent>(idUid.Value, out var keyStorage)
&& stationEntityUid != null
&& keyStorage.Key != null)
{
if (!TryGetRecord<GeneralStationRecord>(keyStorage.Key.Value, out var record))
continue;

AddRecordEntry((EntityUid) stationEntityUid, record);
break;
}
}
Comment on lines +132 to +144
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this loop? Neither stationUid and stationRecComp are used. Why would the global/sector record set need two separate station records, one for each station?

Might be missing something, but I don't quite get it.

If you want all of the criminal records computers to work on a global database, I think this needs a few changes in order to work, and at that point the access to the computer should probably be locked behind access groups.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have utilised code from the Shipyard that created new record.

Basically wanted to allow another station [NFSD Outpost in current state] to posses these records WITHOUT messing up other aspects like latejoining.

As the current station crew records are very one station heavy at moment codewise


TryComp<StationRecordsComponent>(stationEntityUid, out var stationRec);

//Checks if certain information should be faked, is yes then will randomise it
string playerJob = jobId;
if(TryComp<FakeSectorStationRecordComponent>(player, out var playerComponent))
{
// Randomises job
var random = _robustRandom.Next(1, 3);

switch(random)
{
case 1:
playerJob = "Contractor";
break;
case 2:
playerJob = "Pilot";
break;
case 3:
playerJob = "Mercenary";
break;
default:
//Do nothing, when real job is visible that means something bad happened
break;
}
Comment on lines +152 to +169
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
I don't think Mercenary will ever be selected. Also,

Suggested change
// Randomises job
var random = _robustRandom.Next(1, 3);
switch(random)
{
case 1:
playerJob = "Contractor";
break;
case 2:
playerJob = "Pilot";
break;
case 3:
playerJob = "Mercenary";
break;
default:
//Do nothing, when real job is visible that means something bad happened
break;
}
string[] jobs = { "Contractor", "Pilot", "Mercenary" };
// Randomises job
var random = _robustRandom.Next(jobs.Length);
playerJob = jobs[random];

}
CreateGeneralRecord(stationEntityUid, idUid.Value, profile.Name, profile.Age, profile.Species, profile.Gender, playerJob, fingerprintComponent?.Fingerprint, dnaComponent?.DNA, profile, stationRec!);
}

}
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Content.Server.StationRecords.Systems;

namespace Content.Server.StationRecords;

[Access(typeof(StationRecordsSystem))]
[RegisterComponent]
public sealed partial class FakeSectorStationRecordComponent : Component
{
// Makes it so that a person with this will create additional records BUT the job is gonna be random between 3 most common types
// Mainly used for antags like pirates where they won't be outed immiedietly, but can still try to effectively hide within
// Most commonly used on Pirates
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Content.Server.StationRecords.Systems;

namespace Content.Server.StationRecords;

[Access(typeof(StationRecordsSystem))]
[RegisterComponent]
public sealed partial class IgnoreSectorStationRecordComponent : Component
{
// Makes it so that a person with this won't create additional records in other places
// Mainly used for antags syndicates so that they aren't suddenly in NFSD records and outed the minute they exist
// Most commonly used on Syndicate
}
12 changes: 12 additions & 0 deletions Content.Server/_NF/NFSD_Records/SectorStationRecordComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Content.Server.StationRecords.Systems;

namespace Content.Server.StationRecords;

[Access(typeof(StationRecordsSystem))]
[RegisterComponent]
public sealed partial class SectorStationRecordComponent : Component
{
// Determines if station should receive additional copy of records
// Mainly used for places which require accurate records of every single player
// Most commonly at NFSD outpost, possibly at coming Prison POI or even in Hospital POI if needed
}
14 changes: 14 additions & 0 deletions Content.Server/_NF/NFSD_Records/ShipyardRecordPaperComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Content.Shared.Fax.Components;

namespace Content.Server.Fax
{
/// <summary>
/// Paper with a written description of vessel owner.
/// Can be used in mapping or admins spawn.
/// </summary>
[RegisterComponent]
public sealed partial class ShipyardRecordPaperComponent : Component
{

}
}
196 changes: 196 additions & 0 deletions Content.Server/_NF/NFSD_Records/ShipyardRecordPaperSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
using System.Diagnostics.CodeAnalysis;
using Content.Server.Chat.Systems;
using Content.Server.Fax;
using Content.Server.Paper;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Shared.Paper;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using Robust.Shared.Timing;
using Robust.Shared.Enums;
using Content.Shared.Fax.Components;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Content.Shared.Preferences;
using Content.Shared.Shipyard.Prototypes;
using Robust.Shared.Prototypes;
using System.Net.NetworkInformation;

namespace Content.Server.Fax;

public sealed class ShipyardRecordPaperSystem : EntitySystem
{
[Dependency] private readonly PaperSystem _paper = default!;
[Dependency] private readonly FaxSystem _faxSystem = default!;

[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;

[Dependency] private readonly IRobustRandom _robustRandom = default!;


public override void Initialize()
{
base.Initialize();
//SubscribeLocalEvent<ShipyardRecordPaperComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<ShipyardRecordPaperComponent, ShipyardRecordPaperTransmitEvent>(SendShuttleRecords);
}

/*private void OnMapInit(EntityUid uid, ShipyardRecordPaperComponent component, MapInitEvent args)
{
SetupPaper(uid, component);
}*/

private void SetupPaper(EntityUid uid, ShipyardRecordPaperComponent? component = null, EntityUid? station = null)
{
if (!Resolve(uid, ref component))
return;


_paper.SetContent(uid, "paperContent");

}

/// <summary>
/// Send a fax to each fax machine with details regarding purchase and ownership of a vessel
/// </summary>
private void SendShuttleRecords(EntityUid faxEnt, ShipyardRecordPaperComponent recordPaper, ShipyardRecordPaperTransmitEvent args)
{
var currentTime = _gameTiming.RealTime.ToString(@"hh\:mm\:ss");

//Sets record paper type based on vessel's class
var shipyardRecordPaperPrototype = "PaperShipyardRecordBase";
switch(args.VesselClass)
{
case "Undetermined":
shipyardRecordPaperPrototype = "PaperShipyardRecordBase";
break;
case "Civilian":
shipyardRecordPaperPrototype = "PaperShipyardRecordCivilian";
break;
case "Expedition":
shipyardRecordPaperPrototype = "PaperShipyardRecordExpedition";
break;
case "Medical":
shipyardRecordPaperPrototype = "PaperShipyardRecordMedical";
break;
case "Blackmarket":
shipyardRecordPaperPrototype = "PaperShipyardRecordBlackmarket";
break;
case "NFSD":
shipyardRecordPaperPrototype = "PaperShipyardRecordNFSD";
break;
case "Scrap":
shipyardRecordPaperPrototype = "PaperShipyardRecordScrap";
break;
case "Science":
shipyardRecordPaperPrototype = "PaperShipyardRecordScience";
break;
case "Service":
shipyardRecordPaperPrototype = "PaperShipyardRecordService";
break;
case "Engineering":
shipyardRecordPaperPrototype = "PaperShipyardRecordEngineering";
break;
case "Syndicate":
shipyardRecordPaperPrototype = "PaperShipyardRecordSyndicate";
break;
case "Cargo":
shipyardRecordPaperPrototype = "PaperShipyardRecordCargo";
break;
case "Salvage":
shipyardRecordPaperPrototype = "PaperShipyardRecordSalvage";
break;
default:
shipyardRecordPaperPrototype = "PaperShipyardRecordBase";
break;
}

//check if vessel's class is Blackmarket or Syndicate, If yes then scramble
if(args.VesselClass == "Blackmarket" || args.VesselClass == "Syndicate")
{
//generate random person
HumanoidCharacterProfile fakeOwner = HumanoidCharacterProfile.Random();


//Gets information from all vessels into lists
List<string> vesselNameList = new List<string>();
List<string> vesselCategoryList = new List<string>();
List<string> vesselDescriptionList = new List<string>();
List<string> vesselPriceList = new List<string>();
foreach (var vessel in _prototypeManager.EnumeratePrototypes<VesselPrototype>())
{
//Saves information into lists
vesselNameList.Add(vessel.Name);
vesselCategoryList.Add(vessel.Category);
vesselDescriptionList.Add(vessel.Description);
vesselPriceList.Add(vessel.Price.ToString());
}
//Converts lists into arrays
string[] vesselName = vesselNameList.ToArray();
string[] vesselCategory = vesselCategoryList.ToArray();
string[] vesselDescription = vesselDescriptionList.ToArray();
string[] vesselPrice = vesselPriceList.ToArray();

//Chooses random vessel which information will be utilised
var ran_int = _robustRandom.Next(0, vesselName.Length);

//Combines real and fake information to then scramble it
string scramVesselOwnerName = args.VesselOwnerName + fakeOwner.Name;
string scramVesselOwnerSpecies = args.VesselOwnerSpecies + fakeOwner.Species;

string scramVesselName = args.VesselName + vesselName[ran_int];
string scramVesselCategory = args.VesselCategory + vesselCategory[ran_int];
string scramVesselDescription = args.VesselDescription + vesselDescription[ran_int];

//Given with just two prices it was too easy for players to metagame, additional 2 numbers will be added to make it bit harder
int randPriceValue = _robustRandom.Next(10, 99);
string scramVesselPrice = args.VesselPrice + randPriceValue + vesselPrice[ran_int];

//save elements that can be properly scrambled
string[] elements = {scramVesselName, scramVesselOwnerName, scramVesselOwnerSpecies, args.VesselOwnerFingerprints, args.VesselOwnerDNA, scramVesselCategory, scramVesselDescription, scramVesselPrice};

//Scrambles each element
for(int ii = 0; ii < elements.Length; ii++)
{
string input = elements[ii];
char[] chars = input.ToCharArray();
for (int i = 0; i < chars.Length; i++)
{
int randomIndex = _robustRandom.Next(0, chars.Length);
char temp = chars[randomIndex];
chars[randomIndex] = chars[i];
chars[i] = temp;
}
string scrambled = new string(chars);
elements[ii] = scrambled;
}


TryComp<FaxMachineComponent>(faxEnt, out var fax);
var printout = new FaxPrintout(
Loc.GetString("shipyard-record-paper-content", ("vessel_name", elements[0]), ("vessel_owner_name", elements[1]), ("vessel_owner_species", elements[2]), ("vessel_owner_gender", fakeOwner.Gender), ("vessel_owner_age", fakeOwner.Age), ("vessel_owner_fingerprints", elements[3]), ("vessel_owner_dna", elements[4]), ("time", currentTime), ("vessel_category", elements[5]), ("vessel_class", args.VesselClass), ("vessel_group", args.VesselGroup), ("vessel_price", elements[7]), ("vessel_description", elements[6])),
Loc.GetString("shipyard-record-paper-name", ("vessel_name", elements[0]), ("time", currentTime)),
null,
shipyardRecordPaperPrototype,
null);
_faxSystem.Receive(faxEnt, printout, null, fax);


} else {

TryComp<FaxMachineComponent>(faxEnt, out var fax);
var printout = new FaxPrintout(
Loc.GetString("shipyard-record-paper-content", ("vessel_name", args.VesselName), ("vessel_owner_name", args.VesselOwnerName), ("vessel_owner_species", args.VesselOwnerSpecies), ("vessel_owner_gender", args.VesselOwnerGender), ("vessel_owner_age", args.VesselOwnerAge), ("vessel_owner_fingerprints", args.VesselOwnerFingerprints), ("vessel_owner_dna", args.VesselOwnerDNA), ("time", currentTime), ("vessel_category", args.VesselCategory), ("vessel_class", args.VesselClass), ("vessel_group", args.VesselGroup), ("vessel_price", args.VesselPrice), ("vessel_description", args.VesselDescription) ),
Loc.GetString("shipyard-record-paper-name", ("vessel_name", args.VesselName), ("time", currentTime)),
null,
shipyardRecordPaperPrototype,
null);
_faxSystem.Receive(faxEnt, printout, null, fax);
}
}

}

[ByRefEvent]
public readonly record struct ShipyardRecordPaperTransmitEvent(string VesselName, string VesselOwnerName, string VesselOwnerSpecies, Gender VesselOwnerGender, int VesselOwnerAge, string VesselOwnerFingerprints, string VesselOwnerDNA, string VesselCategory, string VesselClass, string VesselGroup, int VesselPrice, string VesselDescription);
Loading
Loading