| 65 | } |
| 66 | |
| 67 | void ScriptExtender::Initialize() |
| 68 | { |
| 69 | if (config_.SendCrashReports) { |
| 70 | InitCrashReporting(); |
| 71 | } |
| 72 | |
| 73 | startTime_ = GetTickCount64(); |
| 74 | |
| 75 | if (Libraries.GetGameVersion(gameVersion_)) { |
| 76 | if (gameVersion_.IsSupported()) { |
| 77 | INFO("Game version v%d.%d.%d.%d OK", gameVersion_.Major, gameVersion_.Minor, gameVersion_.Revision, gameVersion_.Build); |
| 78 | } else { |
| 79 | ERR("Game version v%d.%d.%d.%d is not supported, please upgrade!", gameVersion_.Major, gameVersion_.Minor, gameVersion_.Revision, gameVersion_.Build); |
| 80 | // Hard exit below a certain version as the EoCClient error display UI won't work anymore |
| 81 | Fail("Script Extender doesn't support game versions below v4.68, please upgrade!"); |
| 82 | } |
| 83 | } else { |
| 84 | ERR("Failed to retrieve game version info."); |
| 85 | } |
| 86 | |
| 87 | WarnIfOffline(); |
| 88 | |
| 89 | DEBUG("ScriptExtender::Initialize: Starting"); |
| 90 | auto initStart = std::chrono::high_resolution_clock::now(); |
| 91 | |
| 92 | InitStaticSymbols(); |
| 93 | |
| 94 | if (!Libraries.FindLibraries(gameVersion_.Revision)) { |
| 95 | ERR("ScriptExtender::Initialize: Could not load libraries; skipping scripting extension initialization."); |
| 96 | } |
| 97 | |
| 98 | if (!Libraries.CriticalInitializationFailed()) { |
| 99 | imgui_.EnableHooks(); |
| 100 | updaterApi_.MarkReadyToDisplayErrors(); |
| 101 | } |
| 102 | |
| 103 | server_.Initialize(); |
| 104 | client_.Initialize(); |
| 105 | |
| 106 | DetourTransactionBegin(); |
| 107 | DetourUpdateThread(GetCurrentThread()); |
| 108 | |
| 109 | if (GetStaticSymbols().App__Ctor != nullptr) { |
| 110 | CoreLibInit.Wrap(GetStaticSymbols().App__Ctor); |
| 111 | CoreLibInit.SetPreHook(&ScriptExtender::OnCoreLibInit, this); |
| 112 | } |
| 113 | |
| 114 | if (GetStaticSymbols().App__UpdatePaths != nullptr) { |
| 115 | AppUpdatePaths.Wrap(GetStaticSymbols().App__UpdatePaths); |
| 116 | AppUpdatePaths.SetPostHook(&ScriptExtender::OnAppUpdatePaths, this); |
| 117 | } |
| 118 | |
| 119 | if (GetStaticSymbols().App__LoadGraphicSettings != nullptr) { |
| 120 | AppLoadGraphicSettings.Wrap(GetStaticSymbols().App__LoadGraphicSettings); |
| 121 | AppLoadGraphicSettings.SetPostHook(&ScriptExtender::OnAppLoadGraphicSettings, this); |
| 122 | } |
| 123 | |
| 124 | DetourTransactionCommit(); |
no test coverage detected