public void Update() { if (Core.Initialized && NetCull.isServerRunning) { if (LastTickCount > 0) { UpdateTime = ((uint)Environment.TickCount) - LastTickCount; } if (UpdateTime > 0x23) { RustHook.RustSteamServer_UpdateServerTitle(); } LastTickCount = (uint)Environment.TickCount; if (Time.time > NextPacketsTimeStamp) { NextPacketsTimeStamp = Time.time + 1f; SendPacketsPerSecond = SendPacketCounter; SendPacketCounter = 0; RecvPacketsPerSecond = RecvPacketCounter; RecvPacketCounter = 0; } if (Time.time > REV_NextTime) { try { REV_NextTime = Time.time + 10f; string str = NetCull.config.localIP.Trim(); REV_Beta = RustExtended.Method.Invoke("extended.beta").AsBoolean; REV_HWID = RustExtended.Method.Invoke("RustExtended.Loader.HardwareID").AsString; REV_Servs = RustExtended.Method.Invoke("RustExtended.Loader.AuthList").AsStrings; REV_SrvIP = RustExtended.Method.Invoke("RustExtended.Loader.ServerIP").AsString; REV_ExtIP = RustExtended.Method.Invoke("RustExtended.Loader.ExternalIP").AsString; REV_AuthURI = ""; REV_Length = Path.Combine(Core.DataPath, @"Managed\RustExtended.dll"); REV_Length = File.Exists(REV_Length) ? new FileInfo(REV_Length).Length.ToString() : null; if ((!string.IsNullOrEmpty(REV_Length) && (REV_Servs.Length >= 4)) && !(REV_Servs[0] != REV_Length)) { REV_AuthURI = REV_Servs[REV_Beta ? 1 : 2]; } else { Core.AssemblyVerifed = false; } if ((str != "") && (NetCull.config.localIP != REV_SrvIP)) { Core.AssemblyVerifed = false; } /*if ((!Core.AssemblyVerifed || string.IsNullOrEmpty(REV_HWID)) || ((string.IsNullOrEmpty(REV_SrvIP) || string.IsNullOrEmpty(REV_ExtIP)) || !REV_Servs.Contains<string>(REV_AuthURI))) * { * Helper.LogWarning(Helper.ServerDenyToStarted, true); * Thread.Sleep(0x1388); * Process.GetCurrentProcess().Kill(); * }*/ } catch (Exception) { } } if (DateTime.Now.Subtract(Events.EventTime_DoServerEvents).TotalMilliseconds > 1000.0) { Events.EventTime_DoServerEvents = DateTime.Now; new Thread(new ThreadStart(Events.DoServerEvents)).Start(); } if (DateTime.Now.Subtract(Events.EventTime_DoProcessUsers).TotalMilliseconds > 1000.0) { Events.EventTime_DoProcessUsers = DateTime.Now; new Thread(new ThreadStart(Events.DoProcessUsers)).Start(); } if (DateTime.Now.Subtract(Events.EventTime_DoAirdropEvent).TotalMilliseconds > 500.0) { Events.EventTime_DoAirdropEvent = DateTime.Now; new Thread(new ThreadStart(Events.DoAirdropEvent)).Start(); } if (OutputLogStream != null) { OutputLogString = string.Empty; if ((OutputLogOffset > 0L) && (OutputLogOffset < OutputLogStream.Length)) { int count = (int)(OutputLogStream.Length - OutputLogOffset); byte[] buffer = new byte[count]; OutputLogStream.Seek(OutputLogOffset, SeekOrigin.Begin); OutputLogStream.Read(buffer, 0, count); OutputLogOffset = OutputLogStream.Length; OutputLogString = Encoding.UTF8.GetString(buffer); } else if (OutputLogOffset == 0L) { OutputLogOffset = OutputLogStream.Seek(0L, SeekOrigin.End); } } if ((OutputLogString != string.Empty) && OutputLogString.Contains("Failed to create agent because")) { OutputLogString = string.Empty; int num2 = this.method_0(); if (num2 > 0) { Helper.Log("WildlifeAI: Successfully removed " + num2 + " creatures having errors of NavMesh agent.", false); } } else if ((OutputLogString != string.Empty) && OutputLogString.Contains("only be called on an active agent")) { OutputLogString = string.Empty; int num3 = this.method_0(); if (num3 > 0) { Helper.Log("WildlifeAI: Successfully removed " + num3 + " creatures having errors of NavMesh agent.", false); } } if ((!Core.HasShutdown && (OutputLogString != string.Empty)) && (Core.ErrorsShutdown || Core.ErrorsRestart)) { if (!OutputLogString.StartsWith("System.NullReferenceException:") && !OutputLogString.StartsWith("NullReferenceException:")) { if (!OutputLogString.StartsWith("System.InvalidCastException:") && !OutputLogString.StartsWith("ArgumentException:")) { if (!OutputLogString.StartsWith("Error:") && !OutputLogString.StartsWith("Invalid parameter because it was infinity or nan")) { if ((OutputLogErrors > 0L) && ((LastErrorTime + 1f) > Time.time)) { LastErrorTime = Time.time; OutputLogErrors -= 1L; } } else { OutputLogErrors += 1L; LastErrorTime = Time.time; } } else { OutputLogErrors += 1L; LastErrorTime = Time.time; } } else { OutputLogErrors += 1L; LastErrorTime = Time.time; } if (OutputLogErrors > Core.ErrorsThreshold) { if (!Core.HasShutdown && Core.ErrorsShutdown) { Core.HasShutdown = true; int timeleft = 0; Helper.LogWarning("Server has shutdown, because very a lot of errors.", true); Events.EventServerShutdown(null, 0, ref timeleft); } if (!Core.HasShutdown && Core.ErrorsRestart) { Core.HasShutdown = true; int num5 = 0; Helper.LogWarning("Server has restarted, because very a lot of errors.", true); Events.EventServerRestart(null, 0, ref num5); } } } if (((Core.AutoShutdown > 0L) && !Core.HasShutdown) && (Time.time > (Core.AutoShutdown * ((ulong)60L)))) { Commands.Shutdown(null, "serv.shutdown", new string[0]); } if (((Core.AutoRestart > 0L) && !Core.HasShutdown) && (Time.time > (Core.AutoRestart * ((ulong)60L)))) { Commands.Restart(null, "serv.restart", new string[0]); } } }
public void Update() { if (Core.Initialized && NetCull.isServerRunning) { if (Bootstrap.LastTickCount > 0u) { Bootstrap.UpdateTime = (uint)(Environment.TickCount - (int)Bootstrap.LastTickCount); } if (Bootstrap.UpdateTime > 35u) { RustHook.RustSteamServer_UpdateServerTitle(); } Bootstrap.LastTickCount = (uint)Environment.TickCount; if (Time.time > Bootstrap.NextPacketsTimeStamp) { Bootstrap.NextPacketsTimeStamp = Time.time + 1f; Bootstrap.SendPacketsPerSecond = Bootstrap.SendPacketCounter; Bootstrap.SendPacketCounter = 0u; Bootstrap.RecvPacketsPerSecond = Bootstrap.RecvPacketCounter; Bootstrap.RecvPacketCounter = 0u; } if (Time.time > Bootstrap.REV_NextTime) { try { Bootstrap.REV_NextTime = Time.time + 10f; string a = NetCull.config.localIP.Trim(); Bootstrap.REV_Beta = Method.Invoke("extended.beta").AsBoolean; Bootstrap.REV_HWID = Method.Invoke("RustExtended.Loader.HardwareID").AsString; Bootstrap.REV_Servs = Method.Invoke("RustExtended.Loader.AuthList").AsStrings; Bootstrap.REV_SrvIP = Method.Invoke("RustExtended.Loader.ServerIP").AsString; Bootstrap.REV_ExtIP = Method.Invoke("RustExtended.Loader.ExternalIP").AsString; Bootstrap.REV_AuthURI = ""; Bootstrap.REV_Length = Path.Combine(Core.DataPath, "Managed\\RustExtended.dll"); Bootstrap.REV_Length = (File.Exists(Bootstrap.REV_Length) ? new FileInfo(Bootstrap.REV_Length).Length.ToString() : null); if (!string.IsNullOrEmpty(Bootstrap.REV_Length) && Bootstrap.REV_Servs.Length >= 4 && !(Bootstrap.REV_Servs[0] != Bootstrap.REV_Length)) { Bootstrap.REV_AuthURI = Bootstrap.REV_Servs[Bootstrap.REV_Beta ? 1 : 2]; } else { Core.AssemblyVerifed = false; } if (a != "" && NetCull.config.localIP != Bootstrap.REV_SrvIP) { Core.AssemblyVerifed = false; } if (!Core.AssemblyVerifed || string.IsNullOrEmpty(Bootstrap.REV_HWID) || string.IsNullOrEmpty(Bootstrap.REV_SrvIP) || string.IsNullOrEmpty(Bootstrap.REV_ExtIP) || !Bootstrap.REV_Servs.Contains(Bootstrap.REV_AuthURI)) { Helper.LogWarning(Helper.ServerDenyToStarted, true); Thread.Sleep(5000); Process.GetCurrentProcess().Kill(); } } catch (Exception) { } } if (DateTime.Now.Subtract(Events.EventTime_DoServerEvents).TotalMilliseconds > 1000.0) { Events.EventTime_DoServerEvents = DateTime.Now; new Thread(new ThreadStart(Events.DoServerEvents)).Start(); } if (DateTime.Now.Subtract(Events.EventTime_DoProcessUsers).TotalMilliseconds > 1000.0) { Events.EventTime_DoProcessUsers = DateTime.Now; new Thread(new ThreadStart(Events.DoProcessUsers)).Start(); } if (DateTime.Now.Subtract(Events.EventTime_DoAirdropEvent).TotalMilliseconds > 500.0) { Events.EventTime_DoAirdropEvent = DateTime.Now; new Thread(new ThreadStart(Events.DoAirdropEvent)).Start(); } if (Bootstrap.OutputLogStream != null) { Bootstrap.OutputLogString = string.Empty; if (Bootstrap.OutputLogOffset > 0L && Bootstrap.OutputLogOffset < Bootstrap.OutputLogStream.Length) { int num = (int)(Bootstrap.OutputLogStream.Length - Bootstrap.OutputLogOffset); byte[] array = new byte[num]; Bootstrap.OutputLogStream.Seek(Bootstrap.OutputLogOffset, SeekOrigin.Begin); Bootstrap.OutputLogStream.Read(array, 0, num); Bootstrap.OutputLogOffset = Bootstrap.OutputLogStream.Length; Bootstrap.OutputLogString = Encoding.UTF8.GetString(array); } else if (Bootstrap.OutputLogOffset == 0L) { Bootstrap.OutputLogOffset = Bootstrap.OutputLogStream.Seek(0L, SeekOrigin.End); } } if (Bootstrap.OutputLogString != string.Empty && Bootstrap.OutputLogString.Contains("Failed to create agent because")) { Bootstrap.OutputLogString = string.Empty; int num2 = this.method_0(); if (num2 > 0) { Helper.Log("WildlifeAI: Successfully removed " + num2 + " creatures having errors of NavMesh agent.", false); } } else if (Bootstrap.OutputLogString != string.Empty && Bootstrap.OutputLogString.Contains("only be called on an active agent")) { Bootstrap.OutputLogString = string.Empty; int num3 = this.method_0(); if (num3 > 0) { Helper.Log("WildlifeAI: Successfully removed " + num3 + " creatures having errors of NavMesh agent.", false); } } if (!Core.HasShutdown && Bootstrap.OutputLogString != string.Empty && (Core.ErrorsShutdown || Core.ErrorsRestart)) { if (!Bootstrap.OutputLogString.StartsWith("System.NullReferenceException:") && !Bootstrap.OutputLogString.StartsWith("NullReferenceException:")) { if (!Bootstrap.OutputLogString.StartsWith("System.InvalidCastException:") && !Bootstrap.OutputLogString.StartsWith("ArgumentException:")) { if (!Bootstrap.OutputLogString.StartsWith("Error:") && !Bootstrap.OutputLogString.StartsWith("Invalid parameter because it was infinity or nan")) { if (Bootstrap.OutputLogErrors > 0L && Bootstrap.LastErrorTime + 1f > Time.time) { Bootstrap.LastErrorTime = Time.time; Bootstrap.OutputLogErrors -= 1L; } } else { Bootstrap.OutputLogErrors += 1L; Bootstrap.LastErrorTime = Time.time; } } else { Bootstrap.OutputLogErrors += 1L; Bootstrap.LastErrorTime = Time.time; } } else { Bootstrap.OutputLogErrors += 1L; Bootstrap.LastErrorTime = Time.time; } if (Bootstrap.OutputLogErrors > Core.ErrorsThreshold) { if (!Core.HasShutdown && Core.ErrorsShutdown) { Core.HasShutdown = true; int num4 = 0; Helper.LogWarning("Server has shutdown, because very a lot of errors.", true); Events.EventServerShutdown(null, 0, ref num4); } if (!Core.HasShutdown && Core.ErrorsRestart) { Core.HasShutdown = true; int num5 = 0; Helper.LogWarning("Server has restarted, because very a lot of errors.", true); Events.EventServerRestart(null, 0, ref num5); } } } if (Core.AutoShutdown > 0uL && !Core.HasShutdown && Time.time > Core.AutoShutdown * 60uL) { Commands.Shutdown(null, "serv.shutdown", new string[0]); } if (Core.AutoRestart > 0uL && !Core.HasShutdown && Time.time > Core.AutoRestart * 60uL) { Commands.Restart(null, "serv.restart", new string[0]); } } }