| 177 | //========================================================================== |
| 178 | |
| 179 | static void GameTicker() |
| 180 | { |
| 181 | handleevents(); |
| 182 | |
| 183 | // Todo: Migrate state changes to here instead of doing them ad-hoc |
| 184 | while (gameaction != ga_nothing) |
| 185 | { |
| 186 | auto ga = gameaction; |
| 187 | gameaction = ga_nothing; |
| 188 | switch (ga) |
| 189 | { |
| 190 | case ga_autoloadgame: |
| 191 | C_FlushDisplay(); |
| 192 | if (BackupSaveGame.IsNotEmpty() && cl_resumesavegame) |
| 193 | { |
| 194 | DoLoadGame(BackupSaveGame.GetChars()); |
| 195 | } |
| 196 | else |
| 197 | { |
| 198 | g_nextmap = currentLevel; |
| 199 | FX_StopAllSounds(); |
| 200 | S_SetReverb(0); |
| 201 | NewGame(g_nextmap, -1); |
| 202 | BackupSaveGame = ""; |
| 203 | } |
| 204 | break; |
| 205 | |
| 206 | case ga_completed: |
| 207 | FX_StopAllSounds(); |
| 208 | S_SetReverb(0); |
| 209 | gi->LevelCompleted(g_nextmap, g_nextskill); |
| 210 | break; |
| 211 | |
| 212 | case ga_nextlevel: |
| 213 | gi->FreeLevelData(); |
| 214 | gameaction = ga_level; |
| 215 | gi->NextLevel(g_nextmap, g_nextskill); |
| 216 | ResetStatusBar(); |
| 217 | if (!isBlood()) M_Autosave(); |
| 218 | break; |
| 219 | |
| 220 | case ga_newgame: |
| 221 | FX_StopAllSounds(); |
| 222 | [[fallthrough]]; |
| 223 | case ga_newgamenostopsound: |
| 224 | DeleteScreenJob(); |
| 225 | S_SetReverb(0); |
| 226 | C_FlushDisplay(); |
| 227 | BackupSaveGame = ""; |
| 228 | NewGame(g_nextmap, g_nextskill, ga == ga_newgamenostopsound); |
| 229 | break; |
| 230 | |
| 231 | case ga_startup: |
| 232 | Mus_Stop(); |
| 233 | FX_StopAllSounds(); |
| 234 | gi->FreeLevelData(); |
| 235 | gamestate = GS_STARTUP; |
| 236 | break; |
no test coverage detected