public override void OnBeforeSimulationFrame() { base.OnBeforeSimulationFrame(); if (firstFrame) { firstFrame = false; Log.Info($"ThreadingExtension.OnBeforeSimulationFrame: First frame detected. Checking detours."); List <string> missingDetours = new List <string>(); foreach (Detour detour in LoadingExtension.Detours) { if (!RedirectionHelper.IsRedirected(detour.OriginalMethod, detour.CustomMethod)) { missingDetours.Add($"<Manual> {detour.OriginalMethod.DeclaringType.Name}.{detour.OriginalMethod.Name} with {detour.OriginalMethod.GetParameters().Length} parameters ({detour.OriginalMethod.DeclaringType.AssemblyQualifiedName})"); } } foreach (KeyValuePair <MethodBase, RedirectCallsState> entry in LoadingExtension.HarmonyMethodStates) { MethodBase method = entry.Key; RedirectCallsState oldState = entry.Value; RedirectCallsState newState = RedirectionHelper.GetState(method.MethodHandle.GetFunctionPointer()); if (!oldState.Equals(newState)) { missingDetours.Add($"<Harmony> {method.DeclaringType.Name}.{method.Name} with {method.GetParameters().Length} parameters ({method.DeclaringType.AssemblyQualifiedName})"); } } Log.Info($"ThreadingExtension.OnBeforeSimulationFrame: First frame detected. Detours checked. Result: {missingDetours.Count} missing detours"); if (missingDetours.Count > 0) { string error = "Traffic Manager: President Edition detected an incompatibility with another mod! You can continue playing but it's NOT recommended. Traffic Manager will not work as expected. See TMPE.log for technical details."; Log.Error(error); string log = "The following methods were overriden by another mod:"; foreach (string missingDetour in missingDetours) { log += $"\n\t{missingDetour}"; } Log.Info(log); if (GlobalConfig.Instance.Main.ShowCompatibilityCheckErrorMessage) { Singleton <SimulationManager> .instance.m_ThreadingWrapper.QueueMainThread(() => { UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Incompatibility Issue", error, true); }); } } } if (Options.timedLightsEnabled) { tlsMan.SimulationStep(); } }
public override void OnBeforeSimulationFrame() { base.OnBeforeSimulationFrame(); if (firstFrame) { firstFrame = false; Log.Info($"ThreadingExtension.OnBeforeSimulationFrame: First frame detected. Checking detours."); List <string> missingDetours = new List <string>(); foreach (Detour detour in LoadingExtension.Detours) { if (!RedirectionHelper.IsRedirected(detour.OriginalMethod, detour.CustomMethod)) { missingDetours.Add($"{detour.OriginalMethod.DeclaringType.Name}.{detour.OriginalMethod.Name} with {detour.OriginalMethod.GetParameters().Length} parameters ({detour.OriginalMethod.DeclaringType.AssemblyQualifiedName})"); } } Log.Info($"ThreadingExtension.OnBeforeSimulationFrame: First frame detected. Detours checked. Result: {missingDetours.Count} missing detours"); if (missingDetours.Count > 0) { string error = "Traffic Manager: President Edition detected an incompatibility with another mod! You can continue playing but it's NOT recommended. Traffic Manager will not work as expected. See TMPE.log for technical details."; Log.Error(error); string log = "The following methods were overriden by another mod:"; foreach (string missingDetour in missingDetours) { log += $"\n\t{missingDetour}"; } Log.Info(log); if (GlobalConfig.Instance.Main.ShowCompatibilityCheckErrorMessage) { Singleton <SimulationManager> .instance.m_ThreadingWrapper.QueueMainThread(() => { UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Incompatibility Issue", error, true); }); } } } #if BENCHMARK using (var bm = new Benchmark(null, "RoutingManager.SimulationStep")) { #endif routeMan.SimulationStep(); #if BENCHMARK } #endif #if BENCHMARK using (var bm = new Benchmark(null, "TrafficLightSimulationManager.SimulationStep")) { #endif if (Options.timedLightsEnabled) { //try { tlsMan.SimulationStep(); /*} catch (Exception ex) { * Log.Warning($"Error occured while simulating traffic lights: {ex.ToString()}"); * }*/ } #if BENCHMARK } #endif }
public override void OnBeforeSimulationFrame() { base.OnBeforeSimulationFrame(); if (firstFrame) { firstFrame = false; Log.Info("ThreadingExtension.OnBeforeSimulationFrame: First frame detected. Checking detours."); List <string> missingDetours = new List <string>(); foreach (Detour detour in Detours) { if (!RedirectionHelper.IsRedirected( detour.OriginalMethod, detour.CustomMethod)) { missingDetours.Add( string.Format( "<Manual> {0}.{1} with {2} parameters ({3})", detour.OriginalMethod.DeclaringType.Name, detour.OriginalMethod.Name, detour.OriginalMethod.GetParameters().Length, detour.OriginalMethod.DeclaringType.AssemblyQualifiedName)); } } foreach (KeyValuePair <MethodBase, RedirectCallsState> entry in HarmonyMethodStates) { MethodBase method = entry.Key; RedirectCallsState oldState = entry.Value; RedirectCallsState newState = RedirectionHelper.GetState(method.MethodHandle.GetFunctionPointer()); if (!oldState.Equals(newState)) { missingDetours.Add( string.Format( "<Harmony> {0}.{1} with {2} parameters ({3})", method.DeclaringType.Name, method.Name, method.GetParameters().Length, method.DeclaringType.AssemblyQualifiedName)); } } Log.Info($"ThreadingExtension.OnBeforeSimulationFrame: First frame detected. " + $"Detours checked. Result: {missingDetours.Count} missing detours"); if (missingDetours.Count > 0) { string error = "Traffic Manager: President Edition detected an incompatibility with another " + "mod! You can continue playing but it's NOT recommended. Traffic Manager will " + "not work as expected. See TMPE.log for technical details."; Log.Error(error); string log = "The following methods were overriden by another mod:"; foreach (string missingDetour in missingDetours) { log += $"\n\t{missingDetour}"; } Log.Info(log); if (GlobalConfig.Instance.Main.ShowCompatibilityCheckErrorMessage) { Prompt.Error("TM:PE Incompatibility Issue", error); } } } if (Options.timedLightsEnabled) { tlsMan.SimulationStep(); } }