コード例 #1
0
ファイル: Patcher.cs プロジェクト: me22/TMPE
        public void Uninstall()
        {
            if (!initialized_)
            {
                return;
            }

            var harmony = new Harmony(HARMONY_ID);

            Shortcuts.Assert(harmony != null, "HarmonyInst!=null");
            harmony.UnpatchAll(HARMONY_ID);

            initialized_ = false;
            Log.Info("Reverting detours finished.");
        }
コード例 #2
0
ファイル: Patcher.cs プロジェクト: me22/TMPE
        public void Install()
        {
            if (initialized_)
            {
                return;
            }

            Log.Info("Init detours");
            bool fail = false;

            try {
#if DEBUG
                Harmony.DEBUG = true;
#endif
                // Harmony attribute-driven patching
                Log.Info($"Performing Harmony attribute-driven patching");
                var harmony = new Harmony(HARMONY_ID);
                Shortcuts.Assert(harmony != null, "HarmonyInst!=null");
                harmony.PatchAll();
                Log.Info($"Harmony attribute-driven patching successfull!");
            }
            catch (Exception e) {
                Log.Error("Could not deploy Harmony patches");
                Log.Info(e.Message);
                Log.Info(e.StackTrace);
                fail = true;
            }

            try {
                Log.Info("Deploying attribute-driven detours");
                AssemblyRedirector.Deploy();
            }
            catch (Exception e) {
                Log.Error("Could not deploy attribute-driven detours");
                Log.Info(e.ToString());
                Log.Info(e.StackTrace);
                fail = true;
            }

            if (fail)
            {
                Log.Info("Detours failed");
                Singleton <SimulationManager> .instance.m_ThreadingWrapper.QueueMainThread(
                    () => {
                    UIView.library
                    .ShowModal <ExceptionPanel>("ExceptionPanel")
                    .SetMessage(
                        "TM:PE failed to load",
                        "Traffic Manager: President Edition failed to load. You can " +
                        "continue playing but it's NOT recommended. Traffic Manager will " +
                        "not work as expected.",
                        true);
                });
            }
            else
            {
                Log.Info("Detours successful");
            }

            initialized_ = true;
        }
コード例 #3
0
 internal void GetSegmentAndNodeFromIndex(int index, out ushort segmentId, out bool startNode)
 {
     Shortcuts.Assert(index < 2 * NetManager.MAX_SEGMENT_COUNT && index > 0);
     startNode = index < NetManager.MAX_SEGMENT_COUNT;
     segmentId = (ushort)(index - (startNode ? 0 : NetManager.MAX_SEGMENT_COUNT));
 }