Skip to content

Commit

Permalink
1.0.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
paissaheavyindustries committed Nov 28, 2023
1 parent f878b3c commit 5380c1c
Show file tree
Hide file tree
Showing 8 changed files with 2,040 additions and 807 deletions.
64 changes: 52 additions & 12 deletions Lemegeton/Content/Debugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,11 @@ public class EventLogger : Core.ContentItem
[AttributeOrderNumber(3003)]
public string CurrentLogFilename { get; private set; } = "";

[AttributeOrderNumber(4000)]
public bool IncludeLocation { get; set; } = false;
[AttributeOrderNumber(4001)]
public bool ResolveNames { get; set; } = false;

private bool _subbed = false;

public EventLogger(State state) : base(state)
Expand Down Expand Up @@ -529,7 +534,42 @@ private bool GoodToLog()

private string FormatGameObject(GameObject go)
{
return go == null ? "null" : String.Format("{0}({1} - {2}) at {3}", go.ObjectId.ToString("X"), go.Name.ToString(), go.ObjectKind, go.Address.ToString("X"));
if (IncludeLocation == true)
{
return go == null ? "null" : String.Format("{0}({1} - {2}) at {3} pos {4},{5},{6} rot {7}", go.ObjectId.ToString("X"), go.Name.ToString(), go.ObjectKind, go.Address.ToString("X"),
go.Position.X, go.Position.Y, go.Position.Z, go.Rotation
);
}
else
{
return go == null ? "null" : String.Format("{0}({1} - {2}) at {3}", go.ObjectId.ToString("X"), go.Name.ToString(), go.ObjectKind, go.Address.ToString("X"));
}
}

private string FormatStatusId(uint statusId)
{
if (ResolveNames == true)
{
string name = _state.plug.GetStatusName(statusId).Trim();
return String.Format("{0} ({1})", statusId, name.Length > 0 ? name : "(null)");
}
else
{
return String.Format("{0}", statusId);
}
}

private string FormatActionId(uint actionId)
{
if (ResolveNames == true)
{
string name = _state.plug.GetActionName(actionId).Trim();
return String.Format("{0} ({1})", actionId, name.Length > 0 ? name : "(null)");
}
else
{
return String.Format("{0}", actionId);
}
}

private void LogEventToFile(string msg)
Expand Down Expand Up @@ -582,7 +622,7 @@ private void _state_OnEventPlay(uint actorId, uint eventId, ushort scene, uint f
string fmt = "InvokeEventPlay: {0:X8} {1} {2} {3} {4} {5} {6} {7}";
if (LogToDalamudLog == true)
{
Log(LogLevelEnum.Debug, null, fmt, actor, eventId, scene, flags, param1, param2, param3, param4);
Log(LogLevelEnum.Debug, null, fmt, FormatGameObject(actor), eventId, scene, flags, param1, param2, param3, param4);
}
if (LogToFile == true)
{
Expand Down Expand Up @@ -640,7 +680,7 @@ private void _state_OnTether(uint src, uint dest, uint tetherId)
GameObject dstgo = _state.GetActorById(dest);
if (LogToDalamudLog == true)
{
Log(LogLevelEnum.Debug, null, fmt, srcgo, dstgo, tetherId);
Log(LogLevelEnum.Debug, null, fmt, FormatGameObject(srcgo), FormatGameObject(dstgo), tetherId);
}
if (LogToFile == true)
{
Expand Down Expand Up @@ -676,11 +716,11 @@ private void _state_OnStatusChange(uint src, uint dest, uint statusId, bool gain
GameObject dstgo = _state.GetActorById(dest);
if (LogToDalamudLog == true)
{
Log(LogLevelEnum.Debug, null, fmt, srcgo, dstgo, gained == true ? "Gained" : "Lost", statusId, duration, stacks);
Log(LogLevelEnum.Debug, null, fmt, FormatGameObject(srcgo), FormatGameObject(dstgo), gained == true ? "Gained" : "Lost", FormatStatusId(statusId), duration, stacks);
}
if (LogToFile == true)
{
LogEventToFile(String.Format(fmt, FormatGameObject(srcgo), FormatGameObject(dstgo), gained == true ? "Gained" : "Lost", statusId, duration, stacks));
LogEventToFile(String.Format(fmt, FormatGameObject(srcgo), FormatGameObject(dstgo), gained == true ? "Gained" : "Lost", FormatStatusId(statusId), duration, stacks));
}
}

Expand All @@ -694,7 +734,7 @@ private void _state_OnHeadMarker(uint dest, uint markerId)
GameObject dstgo = _state.GetActorById(dest);
if (LogToDalamudLog == true)
{
Log(LogLevelEnum.Debug, null, fmt, dstgo, markerId);
Log(LogLevelEnum.Debug, null, fmt, FormatGameObject(dstgo), markerId);
}
if (LogToFile == true)
{
Expand Down Expand Up @@ -725,16 +765,16 @@ private void _state_OnCastBegin(uint src, uint dest, ushort actionId, float cast
{
return;
}
string fmt = "InvokeCastBegin {0} -> {1}: {2} in {3} s (rot {4})";
string fmt = "InvokeCastBegin {0} -> {1}: {2} in {3} s";
GameObject srcgo = _state.GetActorById(src);
GameObject dstgo = _state.GetActorById(dest);
if (LogToDalamudLog == true)
{
Log(LogLevelEnum.Debug, null, fmt, _state.GetActorById(src), _state.GetActorById(dest), actionId, castTime, rotation);
Log(LogLevelEnum.Debug, null, fmt, FormatGameObject(srcgo), FormatGameObject(dstgo), FormatActionId(actionId), castTime);
}
if (LogToFile == true)
{
LogEventToFile(String.Format(fmt, FormatGameObject(srcgo), FormatGameObject(dstgo), actionId, castTime, rotation));
LogEventToFile(String.Format(fmt, FormatGameObject(srcgo), FormatGameObject(dstgo), FormatActionId(actionId), castTime));
}
}

Expand All @@ -749,11 +789,11 @@ private void _state_OnAction(uint src, uint dest, ushort actionId)
GameObject dstgo = _state.GetActorById(dest);
if (LogToDalamudLog == true)
{
Log(LogLevelEnum.Debug, null, fmt, _state.GetActorById(src), _state.GetActorById(dest), actionId);
Log(LogLevelEnum.Debug, null, fmt, FormatGameObject(srcgo), FormatGameObject(dstgo), FormatActionId(actionId));
}
if (LogToFile == true)
{
LogEventToFile(String.Format(fmt, FormatGameObject(srcgo), FormatGameObject(dstgo), actionId));
LogEventToFile(String.Format(fmt, FormatGameObject(srcgo), FormatGameObject(dstgo), FormatActionId(actionId)));
}
}

Expand All @@ -766,7 +806,7 @@ private void _state_OnCombatantAdded(GameObject go)
string fmt = "CombatantAdded {0}";
if (LogToDalamudLog == true)
{
Log(LogLevelEnum.Debug, null, fmt, go);
Log(LogLevelEnum.Debug, null, fmt, FormatGameObject(go));
}
if (LogToFile == true)
{
Expand Down
Loading

0 comments on commit 5380c1c

Please sign in to comment.