| 139 | } |
| 140 | |
| 141 | void ScriptExtender::OnGameStateChanged(GameState fromState, GameState toState) |
| 142 | { |
| 143 | if (gExtender->GetConfig().SendCrashReports) { |
| 144 | // We need to initialize the crash reporter after the game engine has started, |
| 145 | // otherwise the game will overwrite the top level exception filter |
| 146 | InitCrashReporting(); |
| 147 | } |
| 148 | |
| 149 | // Check to make sure that startup is done even if the extender was loaded when the game was already in GameState::Init |
| 150 | if (toState != GameState::Unknown |
| 151 | && toState != GameState::StartLoading |
| 152 | && toState != GameState::InitMenu |
| 153 | && !gExtender->GetLibraryManager().CriticalInitializationFailed()) { |
| 154 | // We need to initialize the function library here, as GlobalAllocator isn't available in Init(). |
| 155 | gExtender->PostStartup(); |
| 156 | } |
| 157 | |
| 158 | if (toState == GameState::Menu |
| 159 | && gExtender->GetLibraryManager().InitializationFailed()) { |
| 160 | gExtender->PostStartup(); |
| 161 | } |
| 162 | |
| 163 | if ((toState == GameState::InitMenu || toState == GameState::StartLoading) |
| 164 | && !gExtender->GetLibraryManager().CriticalInitializationFailed() |
| 165 | && gExtender->GetConfig().InsanityCheck) { |
| 166 | CleanupSanityCheck(); |
| 167 | } |
| 168 | |
| 169 | #if defined(DEBUG_SERVER_CLIENT) |
| 170 | DEBUG("ecl::ScriptExtender::OnGameStateChanged(): %s -> %s", |
| 171 | GameStateNames[(unsigned)fromState], ClientGameStateNames[(unsigned)toState]); |
| 172 | #endif |
| 173 | |
| 174 | if (fromState != GameState::Unknown) { |
| 175 | BindToThreadPersistent(); |
| 176 | } |
| 177 | |
| 178 | if (gExtender->WasInitialized() && !gExtender->GetLibraryManager().CriticalInitializationFailed()) { |
| 179 | if (IsLoadingState(toState)) { |
| 180 | UpdateClientProgress(EnumInfo<GameState>::Find(toState).GetString()); |
| 181 | } else { |
| 182 | UpdateClientProgress(""); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | switch (fromState) { |
| 187 | case GameState::LoadModule: |
| 188 | INFO("ecl::ScriptExtender::OnGameStateChanged(): Loaded module"); |
| 189 | gExtender->GetVirtualTextureHelpers().Load(); |
| 190 | ShowVersionNumber(); |
| 191 | LoadExtensionState(ExtensionStateContext::Game); |
| 192 | break; |
| 193 | |
| 194 | // Initialize client state when exiting from a game and returning to menu |
| 195 | case GameState::LoadMenu: |
| 196 | LoadExtensionState(ExtensionStateContext::Game); |
| 197 | break; |
| 198 |
nothing calls this directly
no test coverage detected