Skip to content

Commit

Permalink
Maybe Fix Antag Related Crash (#1523)
Browse files Browse the repository at this point in the history
# Description

I'm trying to fix a crash caused by character profiles saving the same
antag preference twice. I have no clue why or how it's happening, but
this should probably prevent it from happening by making the profile
sanitizer remove duplicate keys before saving them to the database.

The relevant crash log: 

[goobcrash.txt](https://github.com/user-attachments/files/18391763/goobcrash.txt)

# Changelog

:cl:
- fix: Attempted to fix a crash related to antag preferences saving
multiple times.

Co-authored-by: sleepyyapril <[email protected]>
  • Loading branch information
VMSolidus and sleepyyapril authored Jan 13, 2025
1 parent e8a01bf commit 3a09bb2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Content.Shared/Preferences/HumanoidCharacterProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,17 @@ public void EnsureValid(ICommonSession session, IDependencyCollection collection

var antags = AntagPreferences
.Where(id => prototypeManager.TryIndex<AntagPrototype>(id, out var antag) && antag.SetPreference)
.Distinct()
.ToList();

var traits = TraitPreferences
.Where(prototypeManager.HasIndex<TraitPrototype>)
.Distinct()
.ToList();

var loadouts = LoadoutPreferences
.Where(l => prototypeManager.HasIndex<LoadoutPrototype>(l.LoadoutName))
.Distinct()
.ToList();

Name = name;
Expand Down

0 comments on commit 3a09bb2

Please sign in to comment.