From e03974a0a208fa6c718ca6bf8a2f28932f438185 Mon Sep 17 00:00:00 2001
From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
Date: Sat, 29 Jul 2023 00:14:39 -0400
Subject: [PATCH] Add logs for research (#18388)
* Add logs for research
* Update Content.Server/Research/Systems/ResearchSystem.Technology.cs
Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com>
* dumb but ok
* wacka wacka
* Update LogType.cs
---------
Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com>
---
.../Research/Systems/ResearchSystem.Console.cs | 2 +-
.../Research/Systems/ResearchSystem.Technology.cs | 12 ++++++++++--
Content.Server/Research/Systems/ResearchSystem.cs | 2 ++
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/Content.Server/Research/Systems/ResearchSystem.Console.cs b/Content.Server/Research/Systems/ResearchSystem.Console.cs
index 369c007cdb..2721a9f294 100644
--- a/Content.Server/Research/Systems/ResearchSystem.Console.cs
+++ b/Content.Server/Research/Systems/ResearchSystem.Console.cs
@@ -31,7 +31,7 @@ public sealed partial class ResearchSystem
return;
}
- if (!UnlockTechnology(uid, args.Id))
+ if (!UnlockTechnology(uid, args.Id, ent))
return;
SyncClientWithServer(uid);
diff --git a/Content.Server/Research/Systems/ResearchSystem.Technology.cs b/Content.Server/Research/Systems/ResearchSystem.Technology.cs
index f18a0ca33f..107d51ccd8 100644
--- a/Content.Server/Research/Systems/ResearchSystem.Technology.cs
+++ b/Content.Server/Research/Systems/ResearchSystem.Technology.cs
@@ -1,3 +1,4 @@
+using Content.Shared.Database;
using Content.Shared.Research.Components;
using Content.Shared.Research.Prototypes;
using JetBrains.Annotations;
@@ -47,13 +48,16 @@ public sealed partial class ResearchSystem
/// Tries to add a technology to a database, checking if it is able to
///
/// If the technology was successfully added
- public bool UnlockTechnology(EntityUid client, string prototypeid, ResearchClientComponent? component = null,
+ public bool UnlockTechnology(EntityUid client,
+ string prototypeid,
+ EntityUid user,
+ ResearchClientComponent? component = null,
TechnologyDatabaseComponent? clientDatabase = null)
{
if (!PrototypeManager.TryIndex(prototypeid, out var prototype))
return false;
- return UnlockTechnology(client, prototype, component, clientDatabase);
+ return UnlockTechnology(client, prototype, user, component, clientDatabase);
}
///
@@ -62,6 +66,7 @@ public sealed partial class ResearchSystem
/// If the technology was successfully added
public bool UnlockTechnology(EntityUid client,
TechnologyPrototype prototype,
+ EntityUid user,
ResearchClientComponent? component = null,
TechnologyDatabaseComponent? clientDatabase = null)
{
@@ -78,6 +83,9 @@ public sealed partial class ResearchSystem
TrySetMainDiscipline(prototype, serverEnt.Value);
ModifyServerPoints(serverEnt.Value, -prototype.Cost);
UpdateTechnologyCards(serverEnt.Value);
+
+ _adminLog.Add(LogType.Action, LogImpact.Medium,
+ $"{ToPrettyString(user):player} unlocked {prototype.ID} (discipline: {prototype.Discipline}, tier: {prototype.Tier}) at {ToPrettyString(client)}, for server {ToPrettyString(serverEnt.Value)}.");
return true;
}
diff --git a/Content.Server/Research/Systems/ResearchSystem.cs b/Content.Server/Research/Systems/ResearchSystem.cs
index dd73c60df2..7adc30ea29 100644
--- a/Content.Server/Research/Systems/ResearchSystem.cs
+++ b/Content.Server/Research/Systems/ResearchSystem.cs
@@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
+using Content.Server.Administration.Logs;
using Content.Shared.Access.Systems;
using Content.Shared.Popups;
using Content.Shared.Research.Components;
@@ -13,6 +14,7 @@ namespace Content.Server.Research.Systems
[UsedImplicitly]
public sealed partial class ResearchSystem : SharedResearchSystem
{
+ [Dependency] private readonly IAdminLogManager _adminLog = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;