Skip to content

Commit

Permalink
Fix multiple research consoles exploit
Browse files Browse the repository at this point in the history
  • Loading branch information
themias committed Jan 9, 2025
1 parent 66810ef commit ab58ea6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions Content.Server/Research/Systems/ResearchSystem.Console.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ private void OnConsoleRegistrationChanged(EntityUid uid, ResearchConsoleComponen

private void OnConsoleDatabaseModified(EntityUid uid, ResearchConsoleComponent component, ref TechnologyDatabaseModifiedEvent args)
{
SyncClientWithServer(uid, raiseEvents: false);
UpdateConsoleInterface(uid, component);
}

Expand Down
13 changes: 8 additions & 5 deletions Content.Server/Research/Systems/ResearchSystem.Technology.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public sealed partial class ResearchSystem
/// <summary>
/// Syncs the primary entity's database to that of the secondary entity's database.
/// </summary>
public void Sync(EntityUid primaryUid, EntityUid otherUid, TechnologyDatabaseComponent? primaryDb = null, TechnologyDatabaseComponent? otherDb = null)
public void Sync(EntityUid primaryUid, EntityUid otherUid, TechnologyDatabaseComponent? primaryDb = null, TechnologyDatabaseComponent? otherDb = null, bool raiseEvents = true)
{
if (!Resolve(primaryUid, ref primaryDb) || !Resolve(otherUid, ref otherDb))
return;
Expand All @@ -23,8 +23,11 @@ public void Sync(EntityUid primaryUid, EntityUid otherUid, TechnologyDatabaseCom

Dirty(primaryUid, primaryDb);

var ev = new TechnologyDatabaseModifiedEvent();
RaiseLocalEvent(primaryUid, ref ev);
if (raiseEvents)
{
var ev = new TechnologyDatabaseModifiedEvent();
RaiseLocalEvent(primaryUid, ref ev);
}
}

/// <summary>
Expand All @@ -33,15 +36,15 @@ public void Sync(EntityUid primaryUid, EntityUid otherUid, TechnologyDatabaseCom
/// syncs against the research server, and the server against the local database.
/// </summary>
/// <returns>Whether it could sync or not</returns>
public void SyncClientWithServer(EntityUid uid, TechnologyDatabaseComponent? databaseComponent = null, ResearchClientComponent? clientComponent = null)
public void SyncClientWithServer(EntityUid uid, TechnologyDatabaseComponent? databaseComponent = null, ResearchClientComponent? clientComponent = null, bool raiseEvents = true)
{
if (!Resolve(uid, ref databaseComponent, ref clientComponent, false))
return;

if (!TryComp<TechnologyDatabaseComponent>(clientComponent.Server, out var serverDatabase))
return;

Sync(uid, clientComponent.Server.Value, databaseComponent, serverDatabase);
Sync(uid, clientComponent.Server.Value, databaseComponent, serverDatabase, raiseEvents);
}

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions Content.Shared/Research/Systems/SharedResearchSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ public void TrySetMainDiscipline(TechnologyPrototype prototype, EntityUid uid, T
return;
component.MainDiscipline = prototype.Discipline;
Dirty(uid, component);

var ev = new TechnologyDatabaseModifiedEvent();
RaiseLocalEvent(uid, ref ev);
}

/// <summary>
Expand Down

0 comments on commit ab58ea6

Please sign in to comment.