Skip to content

Commit 71d6a45

Browse files
committed
cleanup (aleks's suggestions)
1 parent 22b6609 commit 71d6a45

File tree

3 files changed

+4
-23
lines changed

3 files changed

+4
-23
lines changed

QSB/OrbSync/OrbSlotManager.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ namespace QSB.OrbSync
66
public class OrbSlotManager : MonoBehaviour
77
{
88
private void Awake()
9-
{
10-
QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
11-
}
12-
13-
private void OnSceneLoaded(OWScene scene, bool isInUniverse)
149
{
1510
QSB.Helper.Events.Unity.RunWhen(() => QSB.HasWokenUp, InitSlots);
1611
}
@@ -22,7 +17,6 @@ private void InitSlots()
2217
{
2318
var qsbOrbSlot = WorldRegistry.GetObject<QSBOrbSlot>(id) ?? new QSBOrbSlot();
2419
qsbOrbSlot.Init(orbSlots[id], id);
25-
WorldRegistry.AddObject(qsbOrbSlot);
2620
}
2721
}
2822
}

QSB/OrbSync/QSBOrbSlot.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public void Init(NomaiInterfaceSlot slot, int id)
1414
ObjectId = id;
1515
InterfaceSlot = slot;
1616
_initialized = true;
17+
WorldRegistry.AddObject(this);
1718
}
1819

1920
public void HandleEvent(bool state)

QSB/Utility/DebugLog.cs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ public static void ToConsole(string message, MessageType type = MessageType.Mess
1414
.GetMethods(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)
1515
.Last(x => x.Name == "WriteLine");
1616
var callingType = GetCallingType(new StackTrace());
17-
if (callingType == "DebugLog")
18-
{
19-
callingType = GetCallingType(new StackTrace(), 2);
20-
}
21-
if (callingType == "DebugLog")
22-
{
23-
callingType = GetCallingType(new StackTrace(), 3);
24-
}
2517
method.Invoke(console, new object[] { type, message, callingType });
2618
}
2719

@@ -56,16 +48,10 @@ public static void LogState(string name, bool state)
5648
DebugWrite($"* {name} {status}", messageType);
5749
}
5850

59-
private static string GetCallingType(StackTrace frame, int index = 1)
51+
private static string GetCallingType(StackTrace frame)
6052
{
61-
try
62-
{
63-
return frame.GetFrame(index).GetMethod().DeclaringType.Name;
64-
}
65-
catch
66-
{
67-
return "";
68-
}
53+
var stackFrame = frame.GetFrames().First(x => x.GetMethod().DeclaringType.Name != "DebugLog");
54+
return stackFrame.GetMethod().DeclaringType.Name;
6955
}
7056
}
7157
}

0 commit comments

Comments
 (0)