public bool DoConnect(string strURL, int iPort) { unsafe { bool flag; SteamClient.Needed(); NetCull.config.timeoutDelay = 60f; if (ClientConnect.Steam_GetSteamID() == 0) { LoadingScreen.Update("connection failed (no steam detected)"); UnityEngine.Object.Destroy(base.gameObject); return(false); } byte[] numArray = new byte[1024]; IntPtr intPtr = Marshal.AllocHGlobal(1024); uint num = ClientConnect.SteamClient_GetAuth(intPtr, 1024); byte[] numArray1 = new byte[num]; Marshal.Copy(intPtr, numArray1, 0, (int)num); Marshal.FreeHGlobal(intPtr); uLink.BitStream bitStream = new uLink.BitStream(false); bitStream.WriteInt32(1069); bitStream.WriteByte(2); bitStream.WriteUInt64(ClientConnect.Steam_GetSteamID()); bitStream.WriteString(Marshal.PtrToStringAnsi(ClientConnect.Steam_GetDisplayname())); bitStream.WriteBytes(numArray1); try { NetError netError = NetCull.Connect(strURL, iPort, string.Empty, new object[] { bitStream }); if (netError == NetError.NoError) { SteamClient.SteamClient_OnJoinServer(strURL, iPort); return(true); } else { LoadingScreen.Update(string.Concat("connection failed (", netError, ")")); UnityEngine.Object.Destroy(base.gameObject); flag = false; } } catch (Exception exception) { UnityEngine.Debug.LogException(exception); UnityEngine.Object.Destroy(base.gameObject); flag = false; } return(flag); } }
public override void Initialize() { if (this.IsConnectedToAServer) { string SteamID = ClientConnect.Steam_GetSteamID().ToString(); string PlayerName = Marshal.PtrToStringAnsi(ClientConnect.Steam_GetDisplayname()); string answer = this.SendMessageToServer(SteamID + "-CanGUI"); UnityEngine.Debug.Log("Server Answer: " + answer); if (answer == "yes") { Load = new GameObject(); test = Load.AddComponent <TestGUI>(); UnityEngine.Object.DontDestroyOnLoad(Load); } } UnityEngine.Debug.Log("Loaded!"); }
public void Start() { SteamGroups.Init(); UnityAnalytics.SetUserId(ClientConnect.Steam_GetSteamID().ToString()); UnityAnalytics.StartSDK("9fb52793-aff8-4ef9-9381-1c26affde21e"); }
public static void Initialize(string url, int port, byte[] assembly_bytes) { string_1 = url; int_0 = port; if (!Process32.IsRunAsAdministrator) { UnityEngine.Debug.LogError(Class3.smethod_10(0x11cc)); UnityEngine.Debug.LogError(Class3.smethod_10(0x1288)); UnityEngine.Debug.LogError(Class3.smethod_10(0x1316)); UnityEngine.Debug.LogError(Class3.smethod_10(0x11cc)); } else { if (ProtectLoader.Debug) { UnityEngine.Debug.Log(string.Concat(new object[] { Class3.smethod_10(0x13a6), url, Class3.smethod_10(840), port })); } Steam_ID = ClientConnect.Steam_GetSteamID(); Username = Marshal.PtrToStringAnsi(ClientConnect.Steam_GetDisplayname()); string_3 = hardware_0.String_0; string_4 = Application.systemLanguage.ToString(); if (ProtectLoader.Debug) { UnityEngine.Debug.Log(string.Concat(new object[] { Class3.smethod_10(0x13fe), Steam_ID, Class3.smethod_10(0x1416), Username, Class3.smethod_10(0x1430), string_4, Class3.smethod_10(0x144a), string_3 })); } EncryptionKey = new SHA512CryptoServiceProvider().ComputeHash(assembly_bytes); network_0 = new NetLink.Network(string_1, int_0); if (ProtectLoader.Debug) { UnityEngine.Debug.Log(Class3.smethod_10(0x1468) + network_0.Connected.ToString()); } if ((network_0.Connected && (string_3 != null)) && (string_3.Length == 0x20)) { Assembly[] assemblies = Assemblies; NetLink.Network.Packet packet = new NetLink.Network.Packet(NetLink.Network.PacketType.Firstpass, NetLink.Network.PacketFlag.Compressed, null); packet.Write <ushort>(MessageType.Connect); packet.Write <ulong>(Steam_ID); packet.Write <string>(Username); packet.Write <string>(string_3); packet.Write <int>(assemblies.Length); foreach (Assembly assembly in assemblies) { packet.Write <string>(assembly.GetName().Name); } network_0.Send(packet); packet_0 = network_0.Receive(0x7d0L); if (ProtectLoader.Debug) { UnityEngine.Debug.Log(Class3.smethod_10(0x1496) + packet_0.Received.ToString()); } if ((packet_0.Received && (packet_0.Type == NetLink.Network.PacketType.Response)) && packet_0.Flags.Has <NetLink.Network.PacketFlag>(NetLink.Network.PacketFlag.Compressed)) { bool_0 = packet_0.Read <bool>(); int num2 = packet_0.Read <int>(); verifyFile_0 = new VerifyFile[num2]; for (int i = 0; i < num2; i++) { verifyFile_0[i] = new VerifyFile { Filename = packet_0.Read <string>(), Filesize = packet_0.Read <long>() }; } if (ProtectLoader.Debug) { UnityEngine.Debug.Log(Class3.smethod_10(0x14c2) + num2); } gameObject_0 = new GameObject(typeof(Protection).FullName); gameObject_0.AddComponent <Protection>(); gameObject_0.AddComponent <RustProtect.Snapshot>(); return; } } network_0.Dispose(); } }