Skip to content

Commit

Permalink
Fix mind logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectroJr committed Sep 22, 2024
1 parent da8894c commit 50ae6a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions Content.Shared/Mind/SharedMindSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public bool TryAddObjective(EntityUid mindId, MindComponent mind, string proto)
public void AddObjective(EntityUid mindId, MindComponent mind, EntityUid objective)
{
var title = Name(objective);
_adminLogger.Add(LogType.Mind, LogImpact.Low, $"Objective {objective} ({title}) added to mind of {MindOwnerLoggingString(mind)}");
_adminLogger.Add(LogType.Mind, LogImpact.Low, $"Objective {objective} ({title}) added to mind of {mind.OwnedEntity} ({(mind.UserId == null ? "originally " : "")} {mind.UserId ?? mind.OriginalOwnerUserId})");
mind.Objectives.Add(objective);
}

Expand All @@ -362,7 +362,7 @@ public bool TryRemoveObjective(EntityUid mindId, MindComponent mind, int index)
var objective = mind.Objectives[index];

var title = Name(objective);
_adminLogger.Add(LogType.Mind, LogImpact.Low, $"Objective {objective} ({title}) removed from the mind of {MindOwnerLoggingString(mind)}");
_adminLogger.Add(LogType.Mind, LogImpact.Low, $"Objective {objective} ({title}) removed from the mind of {mind.OwnedEntity} ({(mind.UserId == null ? "originally " : "")} {mind.UserId ?? mind.OriginalOwnerUserId})");
mind.Objectives.Remove(objective);
Del(objective);
return true;
Expand Down Expand Up @@ -526,7 +526,8 @@ public bool IsCharacterDeadIc(MindComponent mind)
}

/// <summary>
/// A string to represent the mind for logging
/// A string to represent the mind for logging. Note that this should not be used for admin logs, as the
/// entity information will get lost.
/// </summary>
public string MindOwnerLoggingString(MindComponent mind)
{
Expand Down
8 changes: 4 additions & 4 deletions Content.Shared/Roles/SharedRoleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void MindAddRoles(EntityUid mindId, ComponentRegistry components, MindCom
}

_adminLogger.Add(LogType.Mind, LogImpact.Low,
$"Role components {string.Join(components.Keys.ToString(), ", ")} added to mind of {_minds.MindOwnerLoggingString(mind)}");
$"Role components {string.Join(components.Keys.ToString(), ", ")} added to mind of {mind.OwnedEntity} ({(mind.UserId == null ? "originally " : "")} {mind.UserId ?? mind.OriginalOwnerUserId})");
}

public void MindAddRole(EntityUid mindId, Component component, MindComponent? mind = null, bool silent = false)
Expand All @@ -136,7 +136,7 @@ public void MindAddRole(EntityUid mindId, Component component, MindComponent? mi
}

_adminLogger.Add(LogType.Mind, LogImpact.Low,
$"'Role {component}' added to mind of {_minds.MindOwnerLoggingString(mind)}");
$"'Role {component}' added to mind of {mind.OwnedEntity} ({(mind.UserId == null ? "originally " : "")} {mind.UserId ?? mind.OriginalOwnerUserId})");
}

/// <summary>
Expand Down Expand Up @@ -173,7 +173,7 @@ public void MindAddRole(EntityUid mindId, Component component, MindComponent? mi
}

_adminLogger.Add(LogType.Mind, LogImpact.Low,
$"'Role {typeof(T).Name}' added to mind of {_minds.MindOwnerLoggingString(mind)}");
$"'Role {typeof(T).Name}' added to mind of {mind.OwnedEntity} ({(mind.UserId == null ? "originally " : "")} {mind.UserId ?? mind.OriginalOwnerUserId})");
}

/// <summary>
Expand All @@ -200,7 +200,7 @@ public void MindRemoveRole<T>(EntityUid mindId) where T : IComponent
RaiseLocalEvent(mind.OwnedEntity.Value, message, true);
}
_adminLogger.Add(LogType.Mind, LogImpact.Low,
$"'Role {typeof(T).Name}' removed from mind of {_minds.MindOwnerLoggingString(mind)}");
$"'Role {typeof(T).Name}' removed from mind of {mind.OwnedEntity} ({(mind.UserId == null ? "originally " : "")} {mind.UserId ?? mind.OriginalOwnerUserId})");
}

public bool MindTryRemoveRole<T>(EntityUid mindId) where T : IComponent
Expand Down

0 comments on commit 50ae6a3

Please sign in to comment.