Fix NRE in LuaUserData.GetType

This commit is contained in:
peelz
2022-09-16 22:55:49 -04:00
parent 6da732e997
commit cd8316ea4c
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@@ -11,8 +11,10 @@ namespace Barotrauma
{ {
public static Type GetType(string typeName) public static Type GetType(string typeName)
{ {
if (typeName == null || typeName.Length == 0) return null;
var byRef = false; var byRef = false;
if (typeName.StartsWith("out ") || typeName.StartsWith("ref ")) if (typeName.StartsWith("out ") || typeName.StartsWith("ref "))
{ {
typeName = typeName.Remove(0, 4); typeName = typeName.Remove(0, 4);
byRef = true; byRef = true;
@@ -266,4 +268,4 @@ namespace Barotrauma
return CreateUserDataFromDescriptor(scriptObject, descriptor); return CreateUserDataFromDescriptor(scriptObject, descriptor);
} }
} }
} }