gg.easy.airship 0.1.2141 → 0.1.2144
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/LuauPluginUpdateCheck.cs +1 -1
- package/Editor/TypescriptServices/Editor/TypescriptLogService.cs +1 -2
- package/Runtime/Code/AirshipConst.cs +2 -2
- package/Runtime/Code/Authentication/EasyAuthenticator.cs +2 -2
- package/Runtime/Code/Authentication/TransferData.cs +1 -1
- package/Runtime/Code/Bootstrap/LuauScriptsDtoSerializer.cs +48 -19
- package/Runtime/Code/Bundles/SystemRoot.cs +14 -7
- package/Runtime/Code/Easy.Airship.asmdef +2 -1
- package/Runtime/Code/Health/AirshipProfileExporter.cs +14 -9
- package/Runtime/Code/Luau/LuauCore.cs +1 -1
- package/Runtime/Code/Luau/LuauCoreCallbacks.cs +26 -57
- package/Runtime/Code/Luau/LuauCoreReflection.cs +7 -0
- package/Runtime/Code/Luau/LuauPlugin.cs +2 -2
- package/Runtime/Code/Network/ServerConsole.cs +15 -8
- package/Runtime/Code/Network/Simulation/AirshipSimulationManager.cs +5 -1
- package/Runtime/Code/Network/StateSystem/AirshipNetworkedStateManager.cs +1 -1
- package/Runtime/Code/Player/Character/MovementSystems/Character/CharacterMovement.cs +77 -94
- package/Runtime/Code/Player/Character/MovementSystems/Character/Structures/CharacterSnapshotData.cs +103 -52
- package/Runtime/Code/Player/PlayerInfo.cs +4 -0
- package/Runtime/Code/Player/PlayerManagerBridge.cs +2 -1
- package/Runtime/Code/VoxelWorld/ChunkSerializer.cs +37 -30
- package/Runtime/Code/Zstd/Zstd.cs +85 -19
- package/Runtime/DevConsole/Runtime/DevConsoleMono.cs +0 -3
- package/Runtime/Plugins/Android/libLuauPlugin.so +0 -0
- package/Runtime/Plugins/Linux/libLuauPlugin.so +0 -0
- package/Runtime/Plugins/Mac/LuauPlugin.bundle/Contents/MacOS/LuauPlugin +0 -0
- package/Runtime/Plugins/Windows/x64/LuauPlugin.dll +0 -0
- package/Runtime/Plugins/Windows/x64/LuauPlugin.pdb +0 -0
- package/Runtime/Plugins/iOS/LuauPluginIos.a +0 -0
- package/ScriptableBuildPipeline/Editor/Tasks/CalculateAssetDependencyData.cs +7 -5
- package/ThirdParty/Mirror/Core/NetworkClient.cs +2 -0
- package/package.json +1 -1
|
@@ -57,7 +57,7 @@ public static class LuauPluginUpdateCheck {
|
|
|
57
57
|
if (lastHash != "") {
|
|
58
58
|
// Check if user wants to restart
|
|
59
59
|
var acceptsRestart = EditorUtility.DisplayDialog("Luau Plugin Updated",
|
|
60
|
-
"The Luau plugin has updated. Restart Unity to apply changes.", "Quit", "Cancel");
|
|
60
|
+
"The Luau plugin has updated. Restart Unity to apply changes. We're sorry for this..", "Quit", "Cancel");
|
|
61
61
|
if (acceptsRestart) {
|
|
62
62
|
// Verify any unsaved changes are saved
|
|
63
63
|
var confirmedSaveState = EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// ReSharper disable InconsistentNaming
|
|
2
2
|
namespace Code {
|
|
3
3
|
public static class AirshipConst {
|
|
4
|
-
public const int playerVersion =
|
|
4
|
+
public const int playerVersion = 9;
|
|
5
5
|
|
|
6
6
|
/// <summary>
|
|
7
7
|
/// The server will kick clients that have a playerVersion lower than this value.
|
|
8
8
|
/// </summary>
|
|
9
|
-
public const int minAcceptedPlayerVersionOnServer =
|
|
9
|
+
public const int minAcceptedPlayerVersionOnServer = 9;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -205,14 +205,14 @@ namespace Code.Authentication {
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
})).Then((res) => {
|
|
208
|
-
// print($"[Transfer Packet]
|
|
208
|
+
// print($"[Transfer Packet] {res.Text}");
|
|
209
209
|
string fullTransferPacket = res.Text;
|
|
210
210
|
TransferData transferData = JsonUtility.FromJson<TransferData>(fullTransferPacket);
|
|
211
211
|
tcs.SetResult(new UserData() {
|
|
212
212
|
uid = transferData.user.uid,
|
|
213
213
|
username = transferData.user.username,
|
|
214
214
|
profileImageId = transferData.user.profileImageId,
|
|
215
|
-
orgRoleName = transferData.
|
|
215
|
+
orgRoleName = transferData.orgRoleName,
|
|
216
216
|
fullTransferPacket = fullTransferPacket
|
|
217
217
|
});
|
|
218
218
|
}).Catch((err) => {
|
|
@@ -12,11 +12,11 @@ public class User {
|
|
|
12
12
|
public string usernameLower;
|
|
13
13
|
public string lastUsernameChangeTime;
|
|
14
14
|
public string profileImageId;
|
|
15
|
-
public string orgRoleName;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
[Serializable]
|
|
20
19
|
public class TransferData {
|
|
21
20
|
public User user;
|
|
21
|
+
public string orgRoleName;
|
|
22
22
|
}
|
|
@@ -1,14 +1,36 @@
|
|
|
1
1
|
using System;
|
|
2
|
+
using System.Buffers;
|
|
2
3
|
using System.Collections.Generic;
|
|
3
4
|
using System.IO;
|
|
4
5
|
using System.IO.Compression;
|
|
5
6
|
using Mirror;
|
|
6
7
|
using UnityEngine;
|
|
8
|
+
using UnityEngine.Profiling;
|
|
7
9
|
|
|
8
10
|
namespace Code.Bootstrap {
|
|
11
|
+
|
|
12
|
+
class CachedCompressedFile {
|
|
13
|
+
public byte[] compressedBytes;
|
|
14
|
+
public int compressedLength;
|
|
15
|
+
|
|
16
|
+
public CachedCompressedFile(byte[] compressedBytes, int compressedLength) {
|
|
17
|
+
this.compressedBytes = compressedBytes;
|
|
18
|
+
this.compressedLength = compressedLength;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
9
22
|
public static class LuauScriptsDtoSerializer {
|
|
23
|
+
private static Zstd.Zstd zstd = new(1024 * 4);
|
|
24
|
+
private static readonly Dictionary<string, CachedCompressedFile> compressedFileCache = new();
|
|
25
|
+
|
|
26
|
+
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
|
27
|
+
private static void OnReload() {
|
|
28
|
+
compressedFileCache.Clear();
|
|
29
|
+
}
|
|
30
|
+
|
|
10
31
|
public static void WriteLuauScriptsDto(this NetworkWriter writer, LuauScriptsDto scripts) {
|
|
11
|
-
|
|
32
|
+
Profiler.BeginSample("WriteLuauScriptsDto");
|
|
33
|
+
writer.WriteInt(scripts.files.Count);
|
|
12
34
|
foreach (var pair in scripts.files) {
|
|
13
35
|
string packageId = pair.Key;
|
|
14
36
|
writer.WriteString(packageId);
|
|
@@ -16,22 +38,30 @@ namespace Code.Bootstrap {
|
|
|
16
38
|
foreach (var file in pair.Value) {
|
|
17
39
|
writer.WriteString(file.path);
|
|
18
40
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
41
|
+
string cacheId = $"{packageId}:{file.path}";
|
|
42
|
+
if (compressedFileCache.TryGetValue(cacheId, out var cache)) {
|
|
43
|
+
writer.WriteInt(cache.compressedLength);
|
|
44
|
+
writer.WriteBytes(cache.compressedBytes, 0, cache.compressedLength);
|
|
45
|
+
} else {
|
|
46
|
+
// Compress the byte array
|
|
47
|
+
Profiler.BeginSample("Luau Compress");
|
|
48
|
+
var maxCompressionSize = Zstd.Zstd.GetCompressionBound(file.bytes);
|
|
49
|
+
byte[] compressedBytes = new byte[maxCompressionSize];
|
|
50
|
+
var compressedSize = zstd.Compress(file.bytes, compressedBytes);
|
|
51
|
+
writer.WriteInt(compressedSize);
|
|
52
|
+
writer.WriteBytes(compressedBytes, 0, compressedSize);
|
|
53
|
+
|
|
54
|
+
compressedFileCache.Add(cacheId, new CachedCompressedFile(compressedBytes, compressedSize));
|
|
26
55
|
}
|
|
27
|
-
|
|
56
|
+
|
|
28
57
|
writer.WriteBool(file.airshipBehaviour);
|
|
58
|
+
Profiler.EndSample();
|
|
29
59
|
}
|
|
30
60
|
}
|
|
61
|
+
Profiler.EndSample();
|
|
31
62
|
}
|
|
32
63
|
|
|
33
64
|
public static LuauScriptsDto ReadLuauScriptsDto(this NetworkReader reader) {
|
|
34
|
-
var totalBytes = reader.Remaining;
|
|
35
65
|
LuauScriptsDto dto = new LuauScriptsDto();
|
|
36
66
|
int packagesLength = reader.ReadInt();
|
|
37
67
|
for (int pkgI = 0; pkgI < packagesLength; pkgI++) {
|
|
@@ -44,15 +74,14 @@ namespace Code.Bootstrap {
|
|
|
44
74
|
LuauFileDto script = new LuauFileDto();
|
|
45
75
|
script.path = reader.ReadString();
|
|
46
76
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
77
|
+
// Read the compressed bytes
|
|
78
|
+
var compressedBytesLen = reader.ReadInt();
|
|
79
|
+
byte[] compressedBytes = ArrayPool<byte>.Shared.Rent(compressedBytesLen);
|
|
80
|
+
reader.ReadBytes(compressedBytes, compressedBytesLen);
|
|
81
|
+
|
|
82
|
+
// Decompress the bytes
|
|
83
|
+
script.bytes = new byte[Zstd.Zstd.GetDecompressionBound(compressedBytes)];
|
|
84
|
+
zstd.Decompress(new ReadOnlySpan<byte>(compressedBytes, 0, compressedBytesLen), script.bytes);
|
|
56
85
|
|
|
57
86
|
script.airshipBehaviour = reader.ReadBool();
|
|
58
87
|
|
|
@@ -267,20 +267,24 @@ public class SystemRoot : Singleton<SystemRoot> {
|
|
|
267
267
|
this.networkCollectionIdCounter = 1;
|
|
268
268
|
|
|
269
269
|
// sort packages by load order
|
|
270
|
-
List<List<IEnumerator>> loadLists = new(
|
|
270
|
+
List<List<IEnumerator>> loadLists = new(2);
|
|
271
271
|
for (int i = 0; i < loadLists.Capacity; i++) {
|
|
272
272
|
loadLists.Add(new());
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
List<IEnumerator> GetLoadList(AirshipPackage package) {
|
|
276
|
-
|
|
277
|
-
// if (package.id == "@Easy/CoreMaterials") {
|
|
276
|
+
// // Load core first because packages may depend them
|
|
277
|
+
// if (package.id == "@Easy/CoreMaterials" || package.id == "@Easy/Core") {
|
|
278
278
|
// return loadLists[0];
|
|
279
279
|
// }
|
|
280
|
-
|
|
281
|
-
//
|
|
282
|
-
|
|
283
|
-
|
|
280
|
+
|
|
281
|
+
// All packages first
|
|
282
|
+
if (package.packageType == AirshipPackageType.Package) {
|
|
283
|
+
return loadLists[0];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// Games go last
|
|
287
|
+
return loadLists[1];
|
|
284
288
|
}
|
|
285
289
|
|
|
286
290
|
// Find packages to load
|
|
@@ -334,7 +338,10 @@ public class SystemRoot : Singleton<SystemRoot> {
|
|
|
334
338
|
}
|
|
335
339
|
#endif
|
|
336
340
|
|
|
341
|
+
Debug.Log("Loading packages...");
|
|
337
342
|
yield return this.WaitAll(loadLists[0].ToArray());
|
|
343
|
+
Debug.Log("Loading game...");
|
|
344
|
+
yield return this.WaitAll(loadLists[1].ToArray());
|
|
338
345
|
|
|
339
346
|
foreach (var ao in this.extraBundleLoadRequests) {
|
|
340
347
|
if (!ao.isDone) {
|
|
@@ -52,7 +52,8 @@
|
|
|
52
52
|
"GUID:325984b52e4128546bc7558552f8b1d2",
|
|
53
53
|
"GUID:3b5390adca4e2bb4791cb930316d6f3e",
|
|
54
54
|
"GUID:725ee7191c021de4dbf9269590ded755",
|
|
55
|
-
"GUID:2a0340569ab0e1245a38e0d6c7b2529b"
|
|
55
|
+
"GUID:2a0340569ab0e1245a38e0d6c7b2529b",
|
|
56
|
+
"GUID:befe48b9a36afc04ea625c93daad910e"
|
|
56
57
|
],
|
|
57
58
|
"includePlatforms": [],
|
|
58
59
|
"excludePlatforms": [],
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
using System;
|
|
2
|
-
using System.Diagnostics;
|
|
3
2
|
using System.IO;
|
|
4
3
|
using System.Threading.Tasks;
|
|
5
4
|
using Airship.DevConsole;
|
|
6
5
|
using Code.Http.Internal;
|
|
7
6
|
using Code.Platform.Shared;
|
|
8
|
-
using Code.
|
|
7
|
+
using Code.Player;
|
|
9
8
|
using JetBrains.Annotations;
|
|
10
9
|
using Mirror;
|
|
11
10
|
using UnityEngine;
|
|
@@ -56,6 +55,7 @@ namespace Code.Health
|
|
|
56
55
|
|
|
57
56
|
public struct StartServerProfileMessage : NetworkMessage {
|
|
58
57
|
public int DurationSecs;
|
|
58
|
+
public bool CallstacksEnabled;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
public struct ServerProfileCompleteMessage : NetworkMessage
|
|
@@ -88,13 +88,14 @@ namespace Code.Health
|
|
|
88
88
|
NetworkClient.RegisterHandler<ClientProfileUploadResponse>(OnClientUploadResponse);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
DevConsole.AddCommand(Command.Create<string, int>(
|
|
91
|
+
DevConsole.AddCommand(Command.Create<string, int, bool>(
|
|
92
92
|
"profile",
|
|
93
93
|
"",
|
|
94
94
|
"Starts and uploads a profile. Once complete the download link will be printed.",
|
|
95
95
|
Parameter.Create("Context", "Options: Server | Client"),
|
|
96
96
|
Parameter.Create("Duration", "Duration of profile in seconds (max 5s)"),
|
|
97
|
-
(
|
|
97
|
+
Parameter.Create("Callstacks", "Enable callstacks for profile (this is laggy)"),
|
|
98
|
+
(context, d, callstacks) => {
|
|
98
99
|
if (d is < 0 or > 5) {
|
|
99
100
|
Debug.LogError("You can only profile for a max of 5s.");
|
|
100
101
|
return;
|
|
@@ -106,10 +107,10 @@ namespace Code.Health
|
|
|
106
107
|
"Unable to capture profile log because debug mode is not enabled. Use the development build branch on Steam to enable debug mode.");
|
|
107
108
|
return;
|
|
108
109
|
}
|
|
109
|
-
StartProfiling(d, null);
|
|
110
|
+
StartProfiling(d, null, callstacks);
|
|
110
111
|
} else if (context.Equals("server", StringComparison.OrdinalIgnoreCase)) {
|
|
111
112
|
Debug.Log("Starting a server profile, view server console to monitor progress.");
|
|
112
|
-
NetworkClient.Send(new StartServerProfileMessage { DurationSecs = d });
|
|
113
|
+
NetworkClient.Send(new StartServerProfileMessage { DurationSecs = d, CallstacksEnabled = callstacks });
|
|
113
114
|
}
|
|
114
115
|
}));
|
|
115
116
|
}
|
|
@@ -142,8 +143,10 @@ namespace Code.Health
|
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
public void OnStartProfilingMessage(NetworkConnectionToClient sender, StartServerProfileMessage msg) {
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
var player = PlayerManagerBridge.Instance.GetPlayerInfoByConnectionId(sender.connectionId);
|
|
147
|
+
if (player.IsInGameOrg()) {
|
|
148
|
+
StartProfiling(msg.DurationSecs, sender, msg.CallstacksEnabled);
|
|
149
|
+
}
|
|
147
150
|
}
|
|
148
151
|
|
|
149
152
|
public async void OnServerProfileCompleteMessage(ServerProfileCompleteMessage msg)
|
|
@@ -163,7 +166,7 @@ namespace Code.Health
|
|
|
163
166
|
GUIUtility.systemCopyBuffer = data.url;
|
|
164
167
|
}
|
|
165
168
|
|
|
166
|
-
public void StartProfiling(int durationSecs, [CanBeNull] NetworkConnectionToClient profileInitiator) {
|
|
169
|
+
public void StartProfiling(int durationSecs, [CanBeNull] NetworkConnectionToClient profileInitiator, bool enableCallstacks) {
|
|
167
170
|
// TODO check that sender is game dev
|
|
168
171
|
// if (Profiler.enabled) {
|
|
169
172
|
// Debug.LogWarning("Profiler is already running.");
|
|
@@ -183,12 +186,14 @@ namespace Code.Health
|
|
|
183
186
|
|
|
184
187
|
Debug.Log($"Starting profiler for {durationSecs} seconds.");
|
|
185
188
|
Profiler.enabled = true;
|
|
189
|
+
Profiler.enableAllocationCallstacks = enableCallstacks;
|
|
186
190
|
StopProfilingAfterDelay(logPath, fileName, durationSecs, profileInitiator);
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
private async void StopProfilingAfterDelay(string logPath, string fileName, float durationSecs, [CanBeNull] NetworkConnectionToClient profileInitiator) {
|
|
190
194
|
await Task.Delay((int)(durationSecs * 1000));
|
|
191
195
|
Profiler.enabled = false;
|
|
196
|
+
Profiler.enableAllocationCallstacks = false;
|
|
192
197
|
var info = new FileInfo(logPath);
|
|
193
198
|
|
|
194
199
|
Debug.Log($"Profiling completed. Retrieving upload URL...");
|
|
@@ -173,8 +173,8 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
173
173
|
requirePathCallback = requirePathCallback_holder,
|
|
174
174
|
constructorCallback = constructorCallback_holder,
|
|
175
175
|
toStringCallback = toStringCallback_holder,
|
|
176
|
-
toggleProfilerCallback = toggleProfilerCallback_holder,
|
|
177
176
|
isObjectDestroyedCallback = isObjectDestroyedCallback_holder,
|
|
177
|
+
getUnityObjectNameCallback = getUnityObjectNameCallback_holder,
|
|
178
178
|
staticList = stringAddresses.AddrOfPinnedObject(),
|
|
179
179
|
staticCount = stringCount,
|
|
180
180
|
isServer = RunCore.IsServer() ? 1 : 0,
|
|
@@ -41,8 +41,8 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
41
41
|
private LuauPlugin.ConstructorCallback constructorCallback_holder;
|
|
42
42
|
private LuauPlugin.RequirePathCallback requirePathCallback_holder;
|
|
43
43
|
private LuauPlugin.ToStringCallback toStringCallback_holder;
|
|
44
|
-
private LuauPlugin.ToggleProfilerCallback toggleProfilerCallback_holder;
|
|
45
44
|
private LuauPlugin.IsObjectDestroyedCallback isObjectDestroyedCallback_holder;
|
|
45
|
+
private LuauPlugin.GetUnityObjectName getUnityObjectNameCallback_holder;
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
private struct AwaitingTask {
|
|
@@ -116,8 +116,8 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
116
116
|
requirePathCallback_holder = RequirePathCallback;
|
|
117
117
|
toStringCallback_holder = ToStringCallback;
|
|
118
118
|
componentSetEnabledCallback_holder = SetComponentEnabledCallback;
|
|
119
|
-
toggleProfilerCallback_holder = ToggleProfilerCallback;
|
|
120
119
|
isObjectDestroyedCallback_holder = IsObjectDestroyedCallback;
|
|
120
|
+
getUnityObjectNameCallback_holder = GetUnityObjectNameCallback;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
private static int LuauError(IntPtr thread, string err) {
|
|
@@ -190,41 +190,27 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
190
190
|
|
|
191
191
|
Marshal.Copy(bytes, 0, str, len);
|
|
192
192
|
}
|
|
193
|
-
|
|
194
|
-
[AOT.MonoPInvokeCallback(typeof(LuauPlugin.ToggleProfilerCallback))]
|
|
195
|
-
static void ToggleProfilerCallback(int componentId, IntPtr strPtr, int strLen) {
|
|
196
|
-
// Disable
|
|
197
|
-
if (componentId == -1) {
|
|
198
|
-
Profiler.EndSample();
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
// Not tagged to component
|
|
202
|
-
if (componentId < -1) {
|
|
203
|
-
if (strLen > 0) {
|
|
204
|
-
// No need to free strPtr -- it is stack allocated
|
|
205
|
-
var str = PtrToStringUTF8(strPtr, strLen);
|
|
206
|
-
Profiler.BeginSample($"{str}");
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (AirshipComponent.ComponentIdToScriptName.TryGetValue(componentId, out var componentName)) {
|
|
213
|
-
if (strLen > 0) {
|
|
214
|
-
var str = PtrToStringUTF8(strPtr, strLen);
|
|
215
|
-
Profiler.BeginSample($"{componentName}{str}");
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
Profiler.BeginSample($"{componentName}");
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
193
|
|
|
223
194
|
[AOT.MonoPInvokeCallback(typeof(LuauPlugin.IsObjectDestroyedCallback))]
|
|
224
195
|
static int IsObjectDestroyedCallback(int instanceId) {
|
|
225
196
|
return ThreadDataManager.IsUnityObjectReferenceDestroyed(instanceId) ? 1 : 0;
|
|
226
197
|
}
|
|
227
198
|
|
|
199
|
+
[AOT.MonoPInvokeCallback(typeof(LuauPlugin.GetUnityObjectName))]
|
|
200
|
+
static void GetUnityObjectNameCallback(IntPtr thread, int instanceId, IntPtr str, int maxLen, out int len) {
|
|
201
|
+
var obj = ThreadDataManager.GetObjectReference(thread, instanceId, true, true);
|
|
202
|
+
if (obj is UnityEngine.Object unityObj) {
|
|
203
|
+
var n = unityObj.name;
|
|
204
|
+
var bytes = Encoding.UTF8.GetBytes(n);
|
|
205
|
+
len = bytes.Length > maxLen ? maxLen : bytes.Length;
|
|
206
|
+
Marshal.Copy(bytes, 0, str, len);
|
|
207
|
+
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
len = 0;
|
|
212
|
+
}
|
|
213
|
+
|
|
228
214
|
//when a lua thread gc releases an object, make sure our GC knows too
|
|
229
215
|
[AOT.MonoPInvokeCallback(typeof(LuauPlugin.ObjectGCCallback))]
|
|
230
216
|
static unsafe int ObjectGcCallback(int instanceId, IntPtr objectDebugPointer) {
|
|
@@ -713,16 +699,22 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
713
699
|
private static int GetPropertySafeCallback(LuauContext context, IntPtr thread, int instanceId, IntPtr classNamePtr, int classNameSize, IntPtr propertyName, int propertyNameLength) {
|
|
714
700
|
var ret = 0;
|
|
715
701
|
try {
|
|
716
|
-
|
|
717
|
-
|
|
702
|
+
Profiler.BeginSample("GetProperty");
|
|
703
|
+
ret = GetProperty(context, thread, instanceId, classNamePtr, classNameSize, propertyName,
|
|
704
|
+
propertyNameLength);
|
|
705
|
+
}
|
|
706
|
+
catch (Exception e) {
|
|
718
707
|
ret = LuauError(thread, e.Message);
|
|
708
|
+
} finally {
|
|
709
|
+
Profiler.EndSample();
|
|
719
710
|
}
|
|
720
711
|
|
|
721
712
|
return ret;
|
|
722
713
|
}
|
|
723
714
|
|
|
715
|
+
// private static readonly ProfilerMarker<string> getPropertyMarker = new ProfilerMarker<string>("LuauCore.GetProperty", "asd");
|
|
716
|
+
|
|
724
717
|
private static int GetProperty(LuauContext context, IntPtr thread, int instanceId, IntPtr classNamePtr, int classNameSize, IntPtr propertyName, int propertyNameLength) {
|
|
725
|
-
Profiler.BeginSample("LuauCore.GetProperty");
|
|
726
718
|
CurrentContext = context;
|
|
727
719
|
|
|
728
720
|
string propName = LuauCore.PtrToStringUTF8(propertyName, propertyNameLength, out ulong propNameHash);
|
|
@@ -756,14 +748,12 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
756
748
|
// Type t = propertyInfo.PropertyType;
|
|
757
749
|
System.Object value = cacheData.Value.propertyInfo.GetValue(null);
|
|
758
750
|
WritePropertyToThread(thread, value, cacheData.Value.t);
|
|
759
|
-
Profiler.EndSample();
|
|
760
751
|
return 1;
|
|
761
752
|
}
|
|
762
753
|
|
|
763
754
|
// Get C# event:
|
|
764
755
|
var eventInfo = objectType.GetRuntimeEvent(propName);
|
|
765
756
|
if (eventInfo != null) {
|
|
766
|
-
Profiler.EndSample();
|
|
767
757
|
return LuauSignalWrapper.HandleCsEvent(context, thread, staticClassApi, instanceId, propNameHash,
|
|
768
758
|
eventInfo, true);
|
|
769
759
|
}
|
|
@@ -774,11 +764,9 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
774
764
|
Type t = fieldInfo.FieldType;
|
|
775
765
|
System.Object value = fieldInfo.GetValue(null);
|
|
776
766
|
WritePropertyToThread(thread, value, t);
|
|
777
|
-
Profiler.EndSample();
|
|
778
767
|
return 1;
|
|
779
768
|
}
|
|
780
769
|
|
|
781
|
-
Profiler.EndSample();
|
|
782
770
|
return LuauError(thread, "ERROR - " + propName + " get property not found on class " + staticClassName);
|
|
783
771
|
}
|
|
784
772
|
else {
|
|
@@ -788,7 +776,6 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
788
776
|
System.Object objectReference = ThreadDataManager.GetObjectReference(thread, instanceId);
|
|
789
777
|
// Profiler.EndSample();
|
|
790
778
|
if (objectReference == null) {
|
|
791
|
-
Profiler.EndSample();
|
|
792
779
|
return LuauError(thread,
|
|
793
780
|
"Error: InstanceId not currently available:" + instanceId + ". propName=" + propName);
|
|
794
781
|
}
|
|
@@ -801,7 +788,6 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
801
788
|
if (objectReference is GameObject targetGo) {
|
|
802
789
|
// var target = (GameObject)objectReference;
|
|
803
790
|
if (IsAccessBlocked(context, targetGo)) {
|
|
804
|
-
Profiler.EndSample();
|
|
805
791
|
return LuauError(thread,
|
|
806
792
|
"[Airship] Access denied when trying to read " + targetGo.name + ".");
|
|
807
793
|
}
|
|
@@ -809,7 +795,6 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
809
795
|
else if (sourceType.IsAssignableFrom(typeof(Component))) {
|
|
810
796
|
var target = (Component)objectReference;
|
|
811
797
|
if (target && IsAccessBlocked(context, target.gameObject)) {
|
|
812
|
-
Profiler.EndSample();
|
|
813
798
|
return LuauError(thread,
|
|
814
799
|
"[Airship] Access denied when trying to read " + target.name + ".");
|
|
815
800
|
}
|
|
@@ -821,7 +806,6 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
821
806
|
if (valueTypeAPI != null) {
|
|
822
807
|
var retValue = valueTypeAPI.OverrideMemberGetter(context, thread, objectReference, propName);
|
|
823
808
|
if (retValue >= 0) {
|
|
824
|
-
Profiler.EndSample();
|
|
825
809
|
return retValue;
|
|
826
810
|
}
|
|
827
811
|
}
|
|
@@ -841,7 +825,6 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
841
825
|
try {
|
|
842
826
|
// Try a fast write on value type (Vector3, int, etc. Not objects)
|
|
843
827
|
if (FastGetAndWriteValueProperty(thread, objectReference, cacheData.Value)) {
|
|
844
|
-
Profiler.EndSample();
|
|
845
828
|
return 1;
|
|
846
829
|
}
|
|
847
830
|
|
|
@@ -876,16 +859,11 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
876
859
|
}
|
|
877
860
|
}
|
|
878
861
|
|
|
879
|
-
// Profiler.BeginSample("WriteToThread");
|
|
880
862
|
WritePropertyToThread(thread, value, t);
|
|
881
|
-
// Profiler.EndSample();
|
|
882
|
-
Profiler.EndSample();
|
|
883
863
|
return 1;
|
|
884
864
|
}
|
|
885
865
|
else {
|
|
886
|
-
// Debug.Log("Value was null in dictionary. propName=" + propName + ", object=" + sourceType.Name);
|
|
887
866
|
WritePropertyToThread(thread, null, null);
|
|
888
|
-
Profiler.EndSample();
|
|
889
867
|
return 1;
|
|
890
868
|
}
|
|
891
869
|
}
|
|
@@ -902,11 +880,8 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
902
880
|
// If we failed to get a reference to a non-primitive, just assume a null value (write nil to the stack):
|
|
903
881
|
if (!cacheData.Value.propertyInfo.PropertyType.IsPrimitive) {
|
|
904
882
|
WritePropertyToThread(thread, null, null);
|
|
905
|
-
Profiler.EndSample();
|
|
906
883
|
return 1;
|
|
907
884
|
}
|
|
908
|
-
|
|
909
|
-
Profiler.EndSample();
|
|
910
885
|
return LuauError(thread, "Failed to get property in dictionary. propName=" + propName +
|
|
911
886
|
", object=" +
|
|
912
887
|
sourceType.Name + ", msg=" + e.Message);
|
|
@@ -936,7 +911,6 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
936
911
|
// print("key: " + propName + " " + keyInt);
|
|
937
912
|
// Debug.Log("[Luau]: Dictionary had key but value was null. propName=" + propName + ", sourceType=" + sourceType.Name + ", obj=" + objectReference);
|
|
938
913
|
WritePropertyToThread(thread, null, null);
|
|
939
|
-
Profiler.EndSample();
|
|
940
914
|
return 1;
|
|
941
915
|
}
|
|
942
916
|
|
|
@@ -944,14 +918,12 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
944
918
|
object value = dict[propName];
|
|
945
919
|
Type t = value.GetType();
|
|
946
920
|
WritePropertyToThread(thread, value, t);
|
|
947
|
-
Profiler.EndSample();
|
|
948
921
|
return 1;
|
|
949
922
|
}
|
|
950
923
|
else {
|
|
951
924
|
// Debug.Log("[Luau]: Dictionary was found but key was not found. propName=" + propName +
|
|
952
925
|
// ", sourceType=" + sourceType.Name);
|
|
953
926
|
WritePropertyToThread(thread, null, null);
|
|
954
|
-
Profiler.EndSample();
|
|
955
927
|
return 1;
|
|
956
928
|
}
|
|
957
929
|
}
|
|
@@ -959,7 +931,6 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
959
931
|
// Get C# event:
|
|
960
932
|
var eventInfo = sourceType.GetRuntimeEvent(propName);
|
|
961
933
|
if (eventInfo != null) {
|
|
962
|
-
Profiler.EndSample();
|
|
963
934
|
return LuauSignalWrapper.HandleCsEvent(context, thread, objectReference, instanceId, propNameHash,
|
|
964
935
|
eventInfo, false);
|
|
965
936
|
}
|
|
@@ -970,11 +941,9 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
970
941
|
Type t = field.FieldType;
|
|
971
942
|
System.Object value = field.GetValue(objectReference);
|
|
972
943
|
WritePropertyToThread(thread, value, t);
|
|
973
|
-
Profiler.EndSample();
|
|
974
944
|
return 1;
|
|
975
945
|
}
|
|
976
946
|
|
|
977
|
-
Profiler.EndSample();
|
|
978
947
|
return LuauError(thread, $"ERROR - ({sourceType.Name}).{propName} property/field not found");
|
|
979
948
|
}
|
|
980
949
|
}
|
|
@@ -483,6 +483,13 @@ public partial class LuauCore : MonoBehaviour
|
|
|
483
483
|
return true;
|
|
484
484
|
}
|
|
485
485
|
|
|
486
|
+
if (t == byteType) {
|
|
487
|
+
byte byteVal = (byte)value;
|
|
488
|
+
System.Int32 integer = byteVal;
|
|
489
|
+
LuauPlugin.LuauPushValueToThread(thread, (int)PODTYPE.POD_INT32, new IntPtr(value: &integer), 0); // 0, because we know how big an intPtr is
|
|
490
|
+
return true;
|
|
491
|
+
}
|
|
492
|
+
|
|
486
493
|
if (t == longType) {
|
|
487
494
|
Int64 intVal = (Int64)value;
|
|
488
495
|
System.Int32 integer = unchecked((int)intVal);
|
|
@@ -22,8 +22,8 @@ public static class LuauPlugin {
|
|
|
22
22
|
public delegate void RequirePathCallback(LuauContext context, IntPtr thread, IntPtr scriptName, int scriptNameLen, IntPtr fileName, int fileNameLen);
|
|
23
23
|
public delegate void ToStringCallback(IntPtr thread, int instanceId, IntPtr str, int maxLen, out int len);
|
|
24
24
|
public delegate void ComponentSetEnabledCallback(IntPtr thread, int instanceId, int componentId, int enabled);
|
|
25
|
-
public delegate void ToggleProfilerCallback(int componentId, IntPtr str, int strLen);
|
|
26
25
|
public delegate int IsObjectDestroyedCallback(int instanceId);
|
|
26
|
+
public delegate void GetUnityObjectName(IntPtr thread, int instanceId, IntPtr str, int maxLen, out int len);
|
|
27
27
|
|
|
28
28
|
public static int unityMainThreadId = -1;
|
|
29
29
|
public static bool s_currentlyExecuting = false;
|
|
@@ -62,8 +62,8 @@ public static class LuauPlugin {
|
|
|
62
62
|
public RequirePathCallback requirePathCallback;
|
|
63
63
|
public ConstructorCallback constructorCallback;
|
|
64
64
|
public ToStringCallback toStringCallback;
|
|
65
|
-
public ToggleProfilerCallback toggleProfilerCallback;
|
|
66
65
|
public IsObjectDestroyedCallback isObjectDestroyedCallback;
|
|
66
|
+
public GetUnityObjectName getUnityObjectNameCallback;
|
|
67
67
|
|
|
68
68
|
public IntPtr staticList;
|
|
69
69
|
public int staticCount;
|
|
@@ -35,7 +35,9 @@ namespace Code.RemoteConsole {
|
|
|
35
35
|
private Task writeTask;
|
|
36
36
|
|
|
37
37
|
private void Awake() {
|
|
38
|
-
|
|
38
|
+
if (RunCore.IsClient() && !RunCore.IsServer()) {
|
|
39
|
+
writeTask = Task.Run(ProcessQueue);
|
|
40
|
+
}
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
private async Task ProcessQueue() {
|
|
@@ -48,7 +50,7 @@ namespace Code.RemoteConsole {
|
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
await Task.Delay(
|
|
53
|
+
await Task.Delay(100); // tune as needed
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
|
|
@@ -74,8 +76,11 @@ namespace Code.RemoteConsole {
|
|
|
74
76
|
Application.logMessageReceived += LogCallback;
|
|
75
77
|
}
|
|
76
78
|
NetworkServer.RegisterHandler<RequestServerConsoleStartupLogs>((conn, data) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
var player = PlayerManagerBridge.Instance.GetPlayerInfoByConnectionId(conn.connectionId);
|
|
80
|
+
if (player.IsInGameOrg()) {
|
|
81
|
+
foreach (var startupMessage in startupMessages) {
|
|
82
|
+
conn.Send(startupMessage);
|
|
83
|
+
}
|
|
79
84
|
}
|
|
80
85
|
}, false);
|
|
81
86
|
}
|
|
@@ -127,7 +132,10 @@ namespace Code.RemoteConsole {
|
|
|
127
132
|
}
|
|
128
133
|
|
|
129
134
|
private void SendServerLogMessage(string message, LogType logType = LogType.Log, string stackTrace = "") {
|
|
130
|
-
if (RunCore.
|
|
135
|
+
if (RunCore.IsEditor()) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (RunCore.IsServer()) {
|
|
131
139
|
var time = DateTime.Now.ToString("HH:mm:ss");
|
|
132
140
|
if (this.startupMessages.Count < maxStartupMessages) {
|
|
133
141
|
this.startupMessages.Add(new ServerConsoleBroadcast() {
|
|
@@ -147,10 +155,9 @@ namespace Code.RemoteConsole {
|
|
|
147
155
|
stackTrace = stackTrace,
|
|
148
156
|
time = time,
|
|
149
157
|
};
|
|
150
|
-
// bool sendToReadyOnly = Application.isEditor;
|
|
151
158
|
foreach (var player in PlayerManagerBridge.Instance.players) {
|
|
152
|
-
if (
|
|
153
|
-
player.connectionToClient.Send(packet
|
|
159
|
+
if (player.IsInGameOrg()) {
|
|
160
|
+
player.connectionToClient.Send(packet);
|
|
154
161
|
}
|
|
155
162
|
}
|
|
156
163
|
}
|