73int main(
int argc,
char *argv[])
78 curl_global_init(CURL_GLOBAL_ALL);
87 App::GetConsole()->cVarSetupBuiltins();
90 App::GetAppContext()->SetUpThreads();
93 if (!App::GetAppContext()->SetUpProgramPaths())
99 App::GetAppContext()->SetUpLogging();
102 App::sys_config_dir ->setStr(PathCombine(App::sys_user_dir->getStr(),
"config"));
103 App::sys_cache_dir ->setStr(PathCombine(App::sys_user_dir->getStr(),
"cache"));
104 App::sys_thumbnails_dir->setStr(PathCombine(App::sys_user_dir->getStr(),
"thumbnails"));
105 App::sys_savegames_dir ->setStr(PathCombine(App::sys_user_dir->getStr(),
"savegames"));
106 App::sys_screenshot_dir->setStr(PathCombine(App::sys_user_dir->getStr(),
"screenshots"));
107 App::sys_scripts_dir ->setStr(PathCombine(App::sys_user_dir->getStr(),
"scripts"));
108 App::sys_projects_dir ->setStr(PathCombine(App::sys_user_dir->getStr(),
"projects"));
109 App::sys_repo_attachments_dir->setStr(PathCombine(App::sys_user_dir->getStr(),
"repo_attachments"));
112 App::GetConsole()->loadConfig();
115 App::GetConsole()->processCommandLine(argc, argv);
117 if (App::app_state->getEnum<AppState>() == AppState::PRINT_HELP_EXIT)
119 App::GetConsole()->showCommandLineUsage();
122 if (App::app_state->getEnum<AppState>() == AppState::PRINT_VERSION_EXIT)
124 App::GetConsole()->showCommandLineVersion();
129 if (!App::GetAppContext()->SetUpResourcesDir())
135 CreateFolder(App::sys_config_dir->getStr());
138 if (!App::GetAppContext()->SetUpRendering())
143 Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
146 if (!App::GetAppContext()->SetUpConfigSkeleton())
151 Ogre::OverlaySystem* overlay_system =
new Ogre::OverlaySystem();
153 Ogre::ConfigOptionMap ropts = App::GetAppContext()->GetOgreRoot()->getRenderSystem()->getConfigOptions();
154 int resolution = Ogre::StringConverter::parseInt(Ogre::StringUtil::split(ropts[
"Video Mode"].currentValue,
" x ")[0], 1024);
155 int fsaa = 2 * (Ogre::StringConverter::parseInt(ropts[
"FSAA"].currentValue, 0) / 4);
156 int res = std::pow(2, std::floor(std::log2(resolution)));
158 Ogre::TextureManager::getSingleton().createManual (
"EnvironmentTexture",
159 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_CUBE_MAP, res / 4, res / 4, 0,
160 Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET, 0,
false, fsaa);
161 Ogre::TextureManager::getSingleton ().createManual (
"Refraction",
162 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, res / 2, res / 2, 0,
163 Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET, 0,
false, fsaa);
164 Ogre::TextureManager::getSingleton ().createManual (
"Reflection",
165 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, res / 2, res / 2, 0,
166 Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET, 0,
false, fsaa);
168 if (!App::diag_warning_texture->getBool())
171 Ogre::uchar data[3] = {0};
172 Ogre::PixelBox pixels(1, 1, 1, Ogre::PF_BYTE_RGB, &data);
173 Ogre::TextureManager::getSingleton()._getWarningTexture()->getBuffer()->blitFromMemory(pixels);
176 App::GetContentManager()->AddResourcePack(ContentManager::ResourcePack::FLAGS);
177 App::GetContentManager()->AddResourcePack(ContentManager::ResourcePack::FONTS);
178 App::GetContentManager()->AddResourcePack(ContentManager::ResourcePack::ICONS);
179 App::GetContentManager()->AddResourcePack(ContentManager::ResourcePack::OGRE_CORE);
180 App::GetContentManager()->AddResourcePack(ContentManager::ResourcePack::WALLPAPERS);
181 App::GetContentManager()->AddResourcePack(ContentManager::ResourcePack::SCRIPTS);
184 App::GetLanguageEngine()->setup();
186 App::GetConsole()->regBuiltinCommands();
188 App::GetContentManager()->InitContentManager();
191 App::CreateGfxScene();
192 App::GetGfxScene()->GetSceneManager()->addRenderQueueListener(overlay_system);
193 App::CreateCameraManager();
194 App::GetGfxScene()->GetEnvMap().SetupEnvMap();
196 App::CreateGuiManager();
198 App::GetDiscordRpc()->Init();
200 App::GetAppContext()->SetUpInput();
202#ifdef USE_ANGELSCRIPT
203 App::CreateScriptEngine();
204 CreateFolder(App::sys_scripts_dir->getStr());
205 CreateFolder(App::sys_projects_dir->getStr());
208 App::GetGuiManager()->SetUpMenuWallpaper();
211 App::GetAppContext()->SetUpObsoleteConfMarker();
213 App::CreateThreadPool();
216 App::GetGameContext()->GetActorManager()->GetInertiaConfig().LoadDefaultInertiaModels();
219 if (App::app_force_cache_purge->getBool())
221 App::GetGameContext()->PushMessage(
Message(MSG_APP_MODCACHE_PURGE_REQUESTED));
223 else if (App::cli_force_cache_update->getBool() || App::app_force_cache_update->getBool())
225 App::GetGameContext()->PushMessage(
Message(MSG_APP_MODCACHE_UPDATE_REQUESTED));
229 App::GetGameContext()->PushMessage(
Message(MSG_APP_MODCACHE_LOAD_REQUESTED));
233 if (App::cli_custom_scripts->getStr() !=
"")
235 Ogre::StringVector script_names = Ogre::StringUtil::split(App::cli_custom_scripts->getStr(),
",");
236 for (Ogre::String
const& scriptname: script_names)
238 LOG(fmt::format(
"Loading startup script '{}' (from command line)", scriptname));
243 App::GetGameContext()->PushMessage(
Message(MSG_APP_LOAD_SCRIPT_REQUESTED, req));
247 if (App::app_custom_scripts->getStr() !=
"")
249 Ogre::StringVector script_names = Ogre::StringUtil::split(App::app_custom_scripts->getStr(),
",");
250 for (Ogre::String
const& scriptname: script_names)
252 LOG(fmt::format(
"Loading startup script '{}' (from config file)", scriptname));
257 App::GetGameContext()->PushMessage(
Message(MSG_APP_LOAD_SCRIPT_REQUESTED, req));
263 if (App::cli_server_host->getStr() !=
"" && App::cli_server_port->getInt() != 0)
265 App::mp_server_host->setStr(App::cli_server_host->getStr());
266 App::mp_server_port->setVal(App::cli_server_port->getInt());
267 App::GetGameContext()->PushMessage(
Message(MSG_NET_CONNECT_REQUESTED));
269 else if (App::mp_join_on_startup->getBool())
271 App::GetGameContext()->PushMessage(
Message(MSG_NET_CONNECT_REQUESTED));
275 if (App::cli_preset_terrain->getStr() !=
"")
277 App::GetGameContext()->PushMessage(
Message(MSG_SIM_LOAD_TERRN_REQUESTED, App::cli_preset_terrain->getStr()));
279 else if (App::diag_preset_terrain->getStr() !=
"")
281 App::GetGameContext()->PushMessage(
Message(MSG_SIM_LOAD_TERRN_REQUESTED, App::diag_preset_terrain->getStr()));
285 if (App::cli_resume_autosave->getBool())
287 if (FileExists(PathCombine(App::sys_savegames_dir->getStr(),
"autosave.sav")))
289 App::GetGameContext()->PushMessage(
RoR::Message(MSG_SIM_LOAD_SAVEGAME_REQUESTED,
"autosave.sav"));
292 else if (App::app_skip_main_menu->getBool())
297 App::GetGameContext()->PushMessage(m);
301 App::GetGameContext()->PushMessage(
Message(MSG_GUI_OPEN_MENU_REQUESTED));
306 App::app_state->setVal((
int)AppState::MAIN_MENU);
307 App::GetGuiManager()->MenuWallpaper->show();
310 if (App::audio_menu_music->getBool())
312 App::GetSoundScriptManager()->createInstance(
"tracks/main_menu_tune", -1);
319 App::GetGuiManager()->LoadingWindow.SetProgress(100,
"Hack",
true);
320 App::GetGuiManager()->LoadingWindow.SetVisible(
false);
326 auto start_time = std::chrono::high_resolution_clock::now();
328 while (App::app_state->getEnum<AppState>() != AppState::SHUTDOWN)
330 OgreBites::WindowEventUtilities::messagePump();
333 if (App::app_state->getEnum<AppState>() == AppState::SIMULATION)
335 App::GetGameContext()->GetActorManager()->SyncWithSimThread();
339 while (App::GetGameContext()->HasMessages())
341 Message m = App::GetGameContext()->PopMessage();
342 bool failed_m =
false;
348 case MSG_APP_SHUTDOWN_REQUESTED:
352 if (App::app_state->getEnum<AppState>() == AppState::SIMULATION)
354 App::GetGameContext()->SaveScene(
"autosave.sav");
356 App::GetConsole()->saveConfig();
357 App::GetDiscordRpc()->Shutdown();
359 if (App::mp_state->getEnum<MpState>() == MpState::CONNECTED)
361 App::GetNetwork()->Disconnect();
364 App::app_state->setVal((
int)AppState::SHUTDOWN);
365 App::GetScriptEngine()->setEventsEnabled(
false);
369 HandleMsgQueueException(m.
type);
374 case MSG_APP_SCREENSHOT_REQUESTED:
378 App::GetGuiManager()->SetMouseCursorVisibility(GUIManager::MouseCursorVisibility::HIDDEN);
379 App::GetAppContext()->CaptureScreenshot();
380 App::GetGuiManager()->SetMouseCursorVisibility(GUIManager::MouseCursorVisibility::VISIBLE);
384 HandleMsgQueueException(m.
type);
389 case MSG_APP_DISPLAY_FULLSCREEN_REQUESTED:
393 App::GetAppContext()->ActivateFullscreen(
true);
394 App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE,
395 _L(
"Display mode changed to fullscreen"));
399 HandleMsgQueueException(m.
type);
404 case MSG_APP_DISPLAY_WINDOWED_REQUESTED:
408 App::GetAppContext()->ActivateFullscreen(
false);
409 App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE,
410 _L(
"Display mode changed to windowed"));
414 HandleMsgQueueException(m.
type);
419 case MSG_APP_MODCACHE_LOAD_REQUESTED:
423 if (!App::GetCacheSystem()->IsModCacheLoaded())
425 App::GetGuiManager()->SetMouseCursorVisibility(GUIManager::MouseCursorVisibility::HIDDEN);
426 App::GetContentManager()->InitModCache(CacheValidity::UNKNOWN);
431 HandleMsgQueueException(m.
type);
436 case MSG_APP_MODCACHE_UPDATE_REQUESTED:
440 if (App::app_state->getEnum<AppState>() == AppState::MAIN_MENU)
442 RoR::Log(
"[RoR|ModCache] Cache update requested");
443 App::GetGuiManager()->SetMouseCursorVisibility(GUIManager::MouseCursorVisibility::HIDDEN);
444 App::GetContentManager()->InitModCache(CacheValidity::NEEDS_UPDATE);
449 HandleMsgQueueException(m.
type);
454 case MSG_APP_MODCACHE_PURGE_REQUESTED:
458 if (App::app_state->getEnum<AppState>() == AppState::MAIN_MENU)
460 RoR::Log(
"[RoR|ModCache] Cache rebuild requested");
461 App::GetGuiManager()->SetMouseCursorVisibility(GUIManager::MouseCursorVisibility::HIDDEN);
462 App::GetContentManager()->InitModCache(CacheValidity::NEEDS_REBUILD);
467 HandleMsgQueueException(m.
type);
472 case MSG_APP_LOAD_SCRIPT_REQUESTED:
483 HandleMsgQueueException(m.
type);
489 case MSG_APP_UNLOAD_SCRIPT_REQUESTED:
495 App::GetScriptEngine()->unloadScript(*
id);
499 HandleMsgQueueException(m.
type);
505 case MSG_APP_SCRIPT_THREAD_STATUS:
510 App::GetScriptEngine()->triggerEvent(SE_ANGELSCRIPT_THREAD_STATUS,
516 HandleMsgQueueException(m.
type);
521 case MSG_APP_REINIT_INPUT_REQUESTED:
525 LOG(fmt::format(
"[RoR] !! Reinitializing input engine !!"));
526 App::DestroyInputEngine();
527 App::GetAppContext()->SetUpInput();
528 LOG(fmt::format(
"[RoR] DONE Reinitializing input engine."));
529 App::GetGuiManager()->LoadingWindow.SetVisible(
false);
533 HandleMsgQueueException(m.
type);
540 case MSG_NET_CONNECT_REQUESTED:
545 App::GetNetwork()->StartConnecting();
549 HandleMsgQueueException(m.
type);
555 case MSG_NET_DISCONNECT_REQUESTED:
560 if (App::mp_state->getEnum<MpState>() == MpState::CONNECTED)
562 App::GetNetwork()->Disconnect();
563 if (App::app_state->getEnum<AppState>() == AppState::MAIN_MENU)
565 App::GetGuiManager()->MainSelector.Close();
566 App::GetGameContext()->PushMessage(
Message(MSG_GUI_OPEN_MENU_REQUESTED));
572 HandleMsgQueueException(m.
type);
578 case MSG_NET_SERVER_KICK:
582 App::GetGameContext()->PushMessage(
Message(MSG_NET_DISCONNECT_REQUESTED));
583 App::GetGameContext()->PushMessage(
Message(MSG_SIM_UNLOAD_TERRN_REQUESTED));
584 App::GetGameContext()->PushMessage(
Message(MSG_GUI_OPEN_MENU_REQUESTED));
585 App::GetGuiManager()->ShowMessageBox(
_LC(
"Network",
"Network disconnected"), m.
description.c_str());
589 HandleMsgQueueException(m.
type);
594 case MSG_NET_RECV_ERROR:
598 App::GetGameContext()->PushMessage(
Message(MSG_NET_DISCONNECT_REQUESTED));
599 App::GetGameContext()->PushMessage(
Message(MSG_SIM_UNLOAD_TERRN_REQUESTED));
600 App::GetGameContext()->PushMessage(
Message(MSG_GUI_OPEN_MENU_REQUESTED));
601 App::GetGuiManager()->ShowMessageBox(
_L(
"Network fatal error: "), m.
description.c_str());
605 HandleMsgQueueException(m.
type);
610 case MSG_NET_CONNECT_STARTED:
614 App::GetGuiManager()->LoadingWindow.SetProgressNetConnect(m.
description);
615 App::GetGuiManager()->MultiplayerSelector.SetVisible(
false);
616 App::GetGameContext()->PushMessage(
Message(MSG_GUI_CLOSE_MENU_REQUESTED));
620 HandleMsgQueueException(m.
type);
625 case MSG_NET_CONNECT_PROGRESS:
629 App::GetGuiManager()->LoadingWindow.SetProgressNetConnect(m.
description);
633 HandleMsgQueueException(m.
type);
638 case MSG_NET_CONNECT_SUCCESS:
643 App::GetGuiManager()->LoadingWindow.SetVisible(
false);
644 App::GetNetwork()->StopConnecting();
647 if (!App::GetMumble())
651 if (App::GetNetwork()->GetTerrainName() !=
"any")
653 App::GetGameContext()->PushMessage(
Message(MSG_SIM_LOAD_TERRN_REQUESTED, App::GetNetwork()->GetTerrainName()));
658 if (App::diag_preset_terrain->getStr().empty())
662 App::GetGameContext()->PushMessage(m);
666 App::GetGameContext()->PushMessage(
Message(MSG_SIM_LOAD_TERRN_REQUESTED, App::diag_preset_terrain->getStr()));
672 HandleMsgQueueException(m.
type);
678 case MSG_NET_CONNECT_FAILURE:
683 App::GetGuiManager()->LoadingWindow.SetVisible(
false);
684 App::GetNetwork()->StopConnecting();
685 App::GetGameContext()->PushMessage(
Message(MSG_NET_DISCONNECT_REQUESTED));
686 App::GetGameContext()->PushMessage(
Message(MSG_GUI_OPEN_MENU_REQUESTED));
687 App::GetGuiManager()->ShowMessageBox(
688 _LC(
"Network",
"Multiplayer: connection failed"), m.
description.c_str());
692 HandleMsgQueueException(m.
type);
698 case MSG_NET_REFRESH_SERVERLIST_SUCCESS:
703 App::GetGuiManager()->MultiplayerSelector.UpdateServerlist(data);
707 HandleMsgQueueException(m.
type);
713 case MSG_NET_REFRESH_SERVERLIST_FAILURE:
718 App::GetGuiManager()->MultiplayerSelector.DisplayRefreshFailed(failinfo);
722 HandleMsgQueueException(m.
type);
728 case MSG_NET_REFRESH_REPOLIST_SUCCESS:
733 App::GetGuiManager()->RepositorySelector.UpdateResources(data);
737 HandleMsgQueueException(m.
type);
743 case MSG_NET_OPEN_RESOURCE_SUCCESS:
748 App::GetGuiManager()->RepositorySelector.UpdateResourceFilesAndDescription(data);
752 HandleMsgQueueException(m.
type);
758 case MSG_NET_REFRESH_REPOLIST_FAILURE:
763 App::GetGuiManager()->RepositorySelector.ShowError(failinfo);
767 HandleMsgQueueException(m.
type);
773 case MSG_NET_FETCH_AI_PRESETS_SUCCESS:
777 App::GetGuiManager()->TopMenubar.ai_presets_extern_fetching =
false;
778 App::GetGuiManager()->TopMenubar.ai_presets_extern.Parse(m.
description.c_str());
779 App::GetGuiManager()->TopMenubar.RefreshAiPresets();
783 HandleMsgQueueException(m.
type);
788 case MSG_NET_FETCH_AI_PRESETS_FAILURE:
792 App::GetGuiManager()->TopMenubar.ai_presets_extern_fetching =
false;
793 App::GetGuiManager()->TopMenubar.ai_presets_extern_error = m.
description;
794 App::GetGuiManager()->TopMenubar.RefreshAiPresets();
798 HandleMsgQueueException(m.
type);
803 case MSG_NET_ADD_PEEROPTIONS_REQUESTED:
809 App::GetNetwork()->AddPeerOptions(request);
814 App::GetConsole()->purgeNetChatMessagesByUser(request->
por_uid);
820 for (
ActorPtr& actor : App::GetGameContext()->GetActorManager()->GetActors())
822 if (actor->ar_net_source_id == request->
por_uid)
824 App::GetGameContext()->PushMessage(
Message(MSG_SIM_MUTE_NET_ACTOR_REQUESTED,
new ActorPtr(actor)));
832 for (
ActorPtr& actor : App::GetGameContext()->GetActorManager()->GetActors())
834 if (actor->ar_net_source_id == request->
por_uid)
836 App::GetGameContext()->PushMessage(
Message(MSG_SIM_HIDE_NET_ACTOR_REQUESTED,
new ActorPtr(actor)));
843 HandleMsgQueueException(m.
type);
849 case MSG_NET_REMOVE_PEEROPTIONS_REQUESTED:
855 App::GetNetwork()->RemovePeerOptions(request);
860 for (
ActorPtr& actor : App::GetGameContext()->GetActorManager()->GetActors())
862 if (actor->ar_net_source_id == request->
por_uid)
864 App::GetGameContext()->PushMessage(
Message(MSG_SIM_UNMUTE_NET_ACTOR_REQUESTED,
new ActorPtr(actor)));
872 for (
ActorPtr& actor : App::GetGameContext()->GetActorManager()->GetActors())
874 if (actor->ar_net_source_id == request->
por_uid)
876 App::GetGameContext()->PushMessage(
Message(MSG_SIM_UNHIDE_NET_ACTOR_REQUESTED,
new ActorPtr(actor)));
883 HandleMsgQueueException(m.
type);
889 case MSG_NET_DOWNLOAD_REPOIMAGE_SUCCESS:
890 case MSG_NET_DOWNLOAD_REPOIMAGE_FAILURE:
895 App::GetGuiManager()->RepositorySelector.LoadDownloadedImage(rq);
899 HandleMsgQueueException(m.
type);
905 case MSG_NET_DOWNLOAD_REPOFILE_REQUESTED:
910 App::GetGuiManager()->RepositorySelector.QueueInstallRepoFile(request);
912 App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE,
913 fmt::format(
_LC(
"RepositorySelector",
"Repo file installation requested: {}"), request->
rfir_filename));
917 HandleMsgQueueException(m.
type);
925 case MSG_SIM_PAUSE_REQUESTED:
929 for (
ActorPtr& actor: App::GetGameContext()->GetActorManager()->GetActors())
931 actor->muteAllSounds();
933 App::sim_state->setVal((
int)SimState::PAUSED);
937 HandleMsgQueueException(m.
type);
942 case MSG_SIM_UNPAUSE_REQUESTED:
946 for (
ActorPtr& actor: App::GetGameContext()->GetActorManager()->GetActors())
948 if (!actor->ar_muted_by_peeropt)
950 actor->unmuteAllSounds();
953 App::sim_state->setVal((
int)SimState::RUNNING);
957 HandleMsgQueueException(m.
type);
962 case MSG_SIM_LOAD_TERRN_REQUESTED:
966 App::GetGuiManager()->SetMouseCursorVisibility(GUIManager::MouseCursorVisibility::HIDDEN);
967 App::GetGuiManager()->LoadingWindow.SetProgress(5,
_L(
"Loading resources"));
968 App::GetContentManager()->LoadGameplayResources();
970 if (App::GetGameContext()->LoadTerrain(m.
description))
972 App::GetGameContext()->CreatePlayerCharacter();
974 if (App::cli_preset_vehicle->getStr() !=
"")
975 App::GetGameContext()->SpawnPreselectedActor(App::cli_preset_vehicle->getStr(), App::cli_preset_veh_config->getStr());
976 else if (App::diag_preset_vehicle->getStr() !=
"")
977 App::GetGameContext()->SpawnPreselectedActor(App::diag_preset_vehicle->getStr(), App::diag_preset_veh_config->getStr());
978 App::GetGameContext()->GetSceneMouse().InitializeVisuals();
979 App::CreateOverlayWrapper();
980 App::GetGuiManager()->DirectionArrow.LoadOverlay();
981 if (App::audio_menu_music->getBool())
985 if (App::gfx_sky_mode->getEnum<GfxSkyMode>() == GfxSkyMode::SANDSTORM)
987 App::GetGfxScene()->GetSceneManager()->setAmbientLight(Ogre::ColourValue(0.7f, 0.7f, 0.7f));
991 App::GetGfxScene()->GetSceneManager()->setAmbientLight(Ogre::ColourValue(0.3f, 0.3f, 0.3f));
993 App::GetDiscordRpc()->UpdatePresence();
994 App::sim_state->setVal((
int)SimState::RUNNING);
995 App::app_state->setVal((
int)AppState::SIMULATION);
996 App::GetGuiManager()->GameMainMenu .SetVisible(
false);
997 App::GetGuiManager()->MenuWallpaper->hide();
998 App::GetGuiManager()->LoadingWindow.SetVisible(
false);
999 App::GetGuiManager()->SetMouseCursorVisibility(GUIManager::MouseCursorVisibility::VISIBLE);
1000 App::gfx_fov_external->setVal(App::gfx_fov_external_default->getInt());
1001 App::gfx_fov_internal->setVal(App::gfx_fov_internal_default->getInt());
1003 if (App::mp_state->getEnum<MpState>() == MpState::CONNECTED)
1005 App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE,
1006 fmt::format(
_LC(
"ChatBox",
"Press {} to start chatting"),
1007 App::GetInputEngine()->getEventCommandTrimmed(EV_COMMON_ENTER_CHATMODE)),
"lightbulb.png");
1010 if (App::io_outgauge_mode->getInt() > 0)
1012 App::GetOutGauge()->Connect();
1017 if (App::mp_state->getEnum<MpState>() == MpState::CONNECTED)
1019 App::GetGameContext()->PushMessage(
Message(MSG_NET_DISCONNECT_REQUESTED));
1023 App::GetGameContext()->PushMessage(
Message(MSG_GUI_OPEN_MENU_REQUESTED));
1025 App::GetGuiManager()->LoadingWindow.SetVisible(
false);
1031 HandleMsgQueueException(m.
type);
1036 case MSG_SIM_UNLOAD_TERRN_REQUESTED:
1040 if (App::sim_state->getEnum<SimState>() == SimState::EDITOR_MODE)
1042 App::GetGameContext()->GetTerrain()->GetTerrainEditor()->WriteSeparateOutputFile();
1044 App::GetGameContext()->SaveScene(
"autosave.sav");
1045 App::GetGameContext()->ChangePlayerActor(
nullptr);
1046 App::GetGameContext()->GetActorManager()->CleanUpSimulation();
1047 App::GetGameContext()->GetCharacterFactory()->DeleteAllCharacters();
1048 App::GetGameContext()->GetSceneMouse().DiscardVisuals();
1049 App::DestroyOverlayWrapper();
1050 App::GetCameraManager()->ResetAllBehaviors();
1051 App::GetGuiManager()->CollisionsDebug.CleanUp();
1052 App::GetGuiManager()->MainSelector.Close();
1053 App::GetGuiManager()->LoadingWindow.SetVisible(
false);
1054 App::GetGuiManager()->MenuWallpaper->show();
1055 App::GetGuiManager()->TopMenubar.ai_waypoints.clear();
1056 App::sim_state->setVal((
int)SimState::OFF);
1057 App::app_state->setVal((
int)AppState::MAIN_MENU);
1058 App::GetGameContext()->UnloadTerrain();
1059 App::GetGfxScene()->ClearScene();
1060 App::sim_terrain_name->setStr(
"");
1061 App::sim_terrain_gui_name->setStr(
"");
1062 App::GetOutGauge()->Close();
1063 App::GetSoundScriptManager()->SetListener(Ogre::Vector3::ZERO, Ogre::Vector3::ZERO, Ogre::Vector3::UNIT_Y, Ogre::Vector3::ZERO);
1064 App::GetSoundScriptManager()->getSoundManager()->CleanUp();
1065 App::GetGameContext()->GetRaceSystem().ResetRaceUI();
1069 HandleMsgQueueException(m.
type);
1074 case MSG_SIM_LOAD_SAVEGAME_REQUESTED:
1078 std::string terrn_filename = App::GetGameContext()->ExtractSceneTerrain(m.
description);
1079 if (terrn_filename ==
"")
1082 App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_ERROR, msg.
ToCStr());
1083 if (App::app_state->getEnum<AppState>() == AppState::MAIN_MENU)
1085 App::GetGameContext()->PushMessage(
Message(MSG_GUI_OPEN_MENU_REQUESTED));
1088 else if (terrn_filename == App::sim_terrain_name->getStr())
1092 else if (terrn_filename != App::sim_terrain_name->getStr() && App::mp_state->getEnum<MpState>() == MpState::CONNECTED)
1094 Str<400> msg; msg <<
_L(
"Error while loading scene: Terrain mismatch");
1095 App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_ERROR, msg.
ToCStr());
1099 if (App::sim_terrain_name->getStr() !=
"")
1101 App::GetGameContext()->PushMessage(
Message(MSG_SIM_UNLOAD_TERRN_REQUESTED));
1104 RoR::LogFormat(
"[RoR|Savegame] Loading terrain '%s' ...", terrn_filename.c_str());
1105 App::GetGameContext()->PushMessage(
Message(MSG_SIM_LOAD_TERRN_REQUESTED, terrn_filename));
1107 App::GetGameContext()->ChainMessage(
Message(MSG_SIM_LOAD_SAVEGAME_REQUESTED, m.
description));
1112 HandleMsgQueueException(m.
type);
1117 case MSG_SIM_SPAWN_ACTOR_REQUESTED:
1122 if (App::app_state->getEnum<AppState>() == AppState::SIMULATION)
1124 App::GetGameContext()->SpawnActor(*rq);
1129 HandleMsgQueueException(m.
type);
1135 case MSG_SIM_MODIFY_ACTOR_REQUESTED:
1140 if (App::app_state->getEnum<AppState>() == AppState::SIMULATION)
1142 App::GetGameContext()->ModifyActor(*rq);
1147 HandleMsgQueueException(m.
type);
1153 case MSG_SIM_DELETE_ACTOR_REQUESTED:
1159 if (App::app_state->getEnum<AppState>() == AppState::SIMULATION)
1161 App::GetGameContext()->DeleteActor(*actor_ptr);
1166 HandleMsgQueueException(m.
type);
1172 case MSG_SIM_SEAT_PLAYER_REQUESTED:
1178 if (App::app_state->getEnum<AppState>() == AppState::SIMULATION)
1180 App::GetGameContext()->ChangePlayerActor(*actor_ptr);
1185 HandleMsgQueueException(m.
type);
1191 case MSG_SIM_TELEPORT_PLAYER_REQUESTED:
1193 Ogre::Vector3* pos =
static_cast<Ogre::Vector3*
>(m.
payload);
1196 if (App::app_state->getEnum<AppState>() == AppState::SIMULATION)
1198 App::GetGameContext()->TeleportPlayer(pos->x, pos->z);
1203 HandleMsgQueueException(m.
type);
1209 case MSG_SIM_HIDE_NET_ACTOR_REQUESTED:
1215 if ((App::mp_state->getEnum<MpState>() == MpState::CONNECTED) &&
1216 ((*actor_ptr)->ar_state == ActorState::NETWORKED_OK))
1219 actor->ar_state = ActorState::NETWORKED_HIDDEN;
1220 App::GetGfxScene()->RemoveGfxActor(actor->GetGfxActor());
1221 actor->GetGfxActor()->GetSimDataBuffer().simbuf_actor_state = ActorState::NETWORKED_HIDDEN;
1222 actor->GetGfxActor()->SetAllMeshesVisible(
false);
1223 actor->GetGfxActor()->SetCastShadows(
false);
1224 actor->muteAllSounds();
1225 actor->forceAllFlaresOff();
1226 actor->setSmokeEnabled(
false);
1231 HandleMsgQueueException(m.
type);
1237 case MSG_SIM_UNHIDE_NET_ACTOR_REQUESTED:
1243 if (App::mp_state->getEnum<MpState>() == MpState::CONNECTED &&
1244 ((*actor_ptr)->ar_state == ActorState::NETWORKED_HIDDEN))
1247 actor->ar_state = ActorState::NETWORKED_OK;
1248 App::GetGfxScene()->RegisterGfxActor(actor->GetGfxActor());
1249 actor->GetGfxActor()->SetAllMeshesVisible(
true);
1250 actor->GetGfxActor()->SetCastShadows(
true);
1251 actor->unmuteAllSounds();
1252 actor->setSmokeEnabled(
true);
1257 HandleMsgQueueException(m.
type);
1263 case MSG_SIM_MUTE_NET_ACTOR_REQUESTED:
1269 if ((App::mp_state->getEnum<MpState>() == MpState::CONNECTED) &&
1270 ((*actor_ptr)->ar_state == ActorState::NETWORKED_OK))
1273 actor->ar_muted_by_peeropt =
true;
1274 actor->muteAllSounds();
1279 HandleMsgQueueException(m.
type);
1285 case MSG_SIM_UNMUTE_NET_ACTOR_REQUESTED:
1291 if ((App::mp_state->getEnum<MpState>() == MpState::CONNECTED) &&
1292 ((*actor_ptr)->ar_state == ActorState::NETWORKED_OK))
1295 actor->ar_muted_by_peeropt =
false;
1296 actor->unmuteAllSounds();
1301 HandleMsgQueueException(m.
type);
1307 case MSG_SIM_SCRIPT_EVENT_TRIGGERED:
1312 if (args->
type == SE_GENERIC_FREEFORCES_ACTIVITY && args->
arg1 == freeForcesActivityType::FREEFORCESACTIVITY_BROKEN)
1314 App::GetGfxScene()->OnFreeForceBroken(args->
arg2ex);
1316 else if (args->
type == SE_GENERIC_MODCACHE_ACTIVITY && args->
arg1 == modCacheActivityType::MODCACHEACTIVITY_ENTRY_ADDED && App::mp_state->getEnum<
MpState>() == MpState::CONNECTED)
1319 App::GetGameContext()->GetActorManager()->RetryFailedStreamRegistrations(args);
1326 HandleMsgQueueException(m.
type);
1332 case MSG_SIM_SCRIPT_CALLBACK_QUEUED:
1341 HandleMsgQueueException(m.
type);
1347 case MSG_SIM_ACTOR_LINKING_REQUESTED:
1361 case ActorLinkingRequestType::HOOK_LOCK:
1362 case ActorLinkingRequestType::HOOK_UNLOCK:
1363 case ActorLinkingRequestType::HOOK_TOGGLE:
1367 case ActorLinkingRequestType::HOOK_MOUSE_TOGGLE:
1372 case ActorLinkingRequestType::TIE_TOGGLE:
1376 case ActorLinkingRequestType::ROPE_TOGGLE:
1380 case ActorLinkingRequestType::SLIDENODE_TOGGLE:
1381 actor->toggleSlideNodeLock();
1388 HandleMsgQueueException(m.
type);
1394 case MSG_SIM_ADD_FREEFORCE_REQUESTED:
1399 App::GetGameContext()->GetActorManager()->AddFreeForce(rq);
1403 HandleMsgQueueException(m.
type);
1409 case MSG_SIM_MODIFY_FREEFORCE_REQUESTED:
1414 App::GetGameContext()->GetActorManager()->ModifyFreeForce(rq);
1418 HandleMsgQueueException(m.
type);
1424 case MSG_SIM_REMOVE_FREEFORCE_REQUESTED:
1429 App::GetGameContext()->GetActorManager()->RemoveFreeForce(*rq);
1430 App::GetGfxScene()->OnFreeForceRemoved(*rq);
1434 HandleMsgQueueException(m.
type);
1442 case MSG_GUI_OPEN_MENU_REQUESTED:
1446 App::GetGuiManager()->GameMainMenu.SetVisible(
true);
1450 HandleMsgQueueException(m.
type);
1455 case MSG_GUI_CLOSE_MENU_REQUESTED:
1459 App::GetGuiManager()->GameMainMenu.SetVisible(
false);
1463 HandleMsgQueueException(m.
type);
1468 case MSG_GUI_OPEN_SELECTOR_REQUESTED:
1473 App::GetGuiManager()->MainSelector.Show(*type, m.
description);
1477 HandleMsgQueueException(m.
type);
1483 case MSG_GUI_CLOSE_SELECTOR_REQUESTED:
1487 App::GetGuiManager()->MainSelector.Close();
1491 HandleMsgQueueException(m.
type);
1496 case MSG_GUI_MP_CLIENTS_REFRESH:
1500 App::GetGuiManager()->MpClientList.UpdateClients();
1504 HandleMsgQueueException(m.
type);
1509 case MSG_GUI_SHOW_MESSAGE_BOX_REQUESTED:
1514 App::GetGuiManager()->ShowMessageBox(*conf);
1518 HandleMsgQueueException(m.
type);
1524 case MSG_NET_DOWNLOAD_REPOFILE_PROGRESS:
1526 int* percentage =
static_cast<int*
>(m.
payload);
1531 App::GetGuiManager()->LoadingWindow.SetProgress(*percentage, m.
description,
false);
1536 HandleMsgQueueException(m.
type);
1542 case MSG_NET_DOWNLOAD_REPOFILE_SUCCESS:
1543 case MSG_NET_DOWNLOAD_REPOFILE_FAILURE:
1548 App::GetGuiManager()->LoadingWindow.SetVisible(
false);
1549 App::GetGuiManager()->RepositorySelector.SetVisible(
true);
1550 App::GetGuiManager()->RepositorySelector.InstallDownloadedRepoFile(m.
type, request);
1554 HandleMsgQueueException(m.
type);
1560 case MSG_GUI_REFRESH_TUNING_MENU_REQUESTED:
1564 App::GetGuiManager()->TopMenubar.RefreshTuningMenu();
1568 HandleMsgQueueException(m.
type);
1573 case MSG_GUI_SHOW_CHATBOX_REQUESTED:
1577 App::GetGuiManager()->ChatBox.SetVisible(
true);
1580 App::GetGuiManager()->ChatBox.AssignBuffer(m.
description);
1585 HandleMsgQueueException(m.
type);
1590 case MSG_GUI_OPEN_MP_SETTINGS_REQUESTED:
1594 App::GetGuiManager()->GameMainMenu.SetVisible(
false);
1595 App::GetGuiManager()->MultiplayerSelector.SetVisible(
true);
1596 App::GetGuiManager()->MultiplayerSelector.SetSettingsTabSelected();
1600 HandleMsgQueueException(m.
type);
1607 case MSG_EDI_MODIFY_GROUNDMODEL_REQUESTED:
1612 ground_model_t* live_gm = App::GetGameContext()->GetTerrain()->GetCollisions()->getGroundModelByString(modified_gm->
name);
1613 *live_gm = *modified_gm;
1618 HandleMsgQueueException(m.
type);
1623 case MSG_EDI_ENTER_TERRN_EDITOR_REQUESTED:
1627 if (App::sim_state->getEnum<SimState>() != SimState::EDITOR_MODE)
1629 App::sim_state->setVal((
int)SimState::EDITOR_MODE);
1630 App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE,
1631 _L(
"Entered terrain editing mode"));
1633 App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE,
1634 fmt::format(
_L(
"Press {} or middle mouse click to select an object"),
1635 App::GetInputEngine()->getEventCommandTrimmed(EV_COMMON_ENTER_OR_EXIT_TRUCK)),
"lightbulb.png");
1641 HandleMsgQueueException(m.
type);
1646 case MSG_EDI_LEAVE_TERRN_EDITOR_REQUESTED:
1650 if (App::sim_state->getEnum<SimState>() == SimState::EDITOR_MODE)
1652 App::GetGameContext()->GetTerrain()->GetTerrainEditor()->WriteSeparateOutputFile();
1653 App::GetGameContext()->GetTerrain()->GetTerrainEditor()->ClearSelectedObject();
1654 App::sim_state->setVal((
int)SimState::RUNNING);
1655 App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE,
1656 _L(
"Left terrain editing mode"));
1661 HandleMsgQueueException(m.
type);
1666 case MSG_EDI_SAVE_TERRN_CHANGES_REQUESTED:
1670 if (App::sim_state->getEnum<SimState>() == SimState::EDITOR_MODE
1671 && App::GetGameContext()->GetTerrain()->getCacheEntry()->resource_bundle_type ==
"FileSystem")
1674 App::GetGameContext()->GetTerrain()->GetTerrainEditor()->WriteEditsToTobjFiles();
1675 App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE,
1676 _L(
"Terrain files have been updated"));
1681 HandleMsgQueueException(m.
type);
1686 case MSG_EDI_LOAD_BUNDLE_REQUESTED:
1691 App::GetCacheSystem()->LoadResource(*entry_ptr);
1692 TRIGGER_EVENT_ASYNC(SE_GENERIC_MODCACHE_ACTIVITY,
1693 MODCACHEACTIVITY_BUNDLE_LOADED, (*entry_ptr)->number, 0, 0,
1694 (*entry_ptr)->resource_group);
1698 HandleMsgQueueException(m.
type);
1704 case MSG_EDI_RELOAD_BUNDLE_REQUESTED:
1710 bool all_clear =
true;
1711 for (
ActorPtr& actor: App::GetGameContext()->GetActorManager()->GetActors())
1713 if (actor->GetGfxActor()->GetResourceGroup() == (*entry_ptr)->resource_group)
1715 App::GetGameContext()->PushMessage(
Message(MSG_SIM_DELETE_ACTOR_REQUESTED,
static_cast<void*
>(
new ActorPtr(actor))));
1723 App::GetCacheSystem()->ReLoadResource(*entry_ptr);
1725 TRIGGER_EVENT_ASYNC(SE_GENERIC_MODCACHE_ACTIVITY,
1726 MODCACHEACTIVITY_BUNDLE_RELOADED, (*entry_ptr)->number, 0, 0,
1727 (*entry_ptr)->resource_group);
1734 App::GetGameContext()->PushMessage(m);
1740 HandleMsgQueueException(m.
type);
1745 case MSG_EDI_UNLOAD_BUNDLE_REQUESTED:
1751 bool all_clear =
true;
1752 for (
ActorPtr& actor: App::GetGameContext()->GetActorManager()->GetActors())
1756 const bool uses_actor_rg = (actor->getUsedActorEntry()->resource_group == (*entry_ptr)->resource_group);
1758 const bool uses_skin_rg = (actor->getUsedSkinEntry() && actor->getUsedSkinEntry()->resource_group == (*entry_ptr)->resource_group);
1760 const bool uses_addonpart_rg = std::find_if(
1761 actor->getUsedAddonpartEntries().begin(),
1762 actor->getUsedAddonpartEntries().end(),
1765 return ap_entry->resource_group == (*entry_ptr)->resource_group;
1766 }) != actor->getUsedAddonpartEntries().end();
1768 const bool uses_assetpack_rg = std::find_if(
1769 actor->getUsedAssetpackEntries().begin(),
1770 actor->getUsedAssetpackEntries().end(),
1773 return ap_entry->resource_group == (*entry_ptr)->resource_group;
1774 }) != actor->getUsedAssetpackEntries().end();
1775 if (uses_actor_rg || uses_skin_rg || uses_addonpart_rg || uses_assetpack_rg)
1777 App::GetGameContext()->PushMessage(
Message(MSG_SIM_DELETE_ACTOR_REQUESTED,
static_cast<void*
>(
new ActorPtr(actor))));
1782 if (App::GetGameContext()->GetTerrain()
1783 && App::GetGameContext()->GetTerrain()->getCacheEntry()->resource_group == (*entry_ptr)->resource_group)
1785 if (App::mp_state->getEnum<MpState>() == MpState::CONNECTED)
1787 App::GetGameContext()->PushMessage(
Message(MSG_NET_DISCONNECT_REQUESTED));
1791 App::GetGameContext()->PushMessage(
Message(MSG_SIM_UNLOAD_TERRN_REQUESTED));
1799 App::GetCacheSystem()->UnLoadResource(*entry_ptr);
1801 TRIGGER_EVENT_ASYNC(SE_GENERIC_MODCACHE_ACTIVITY,
1802 MODCACHEACTIVITY_BUNDLE_UNLOADED, (*entry_ptr)->number, 0, 0);
1809 App::GetGameContext()->PushMessage(m);
1815 HandleMsgQueueException(m.
type);
1821 case MSG_EDI_DELETE_BUNDLE_REQUESTED:
1825 std::string bundle_filepath;
1826 if (!App::GetCacheSystem()->IsRepoFileInstalled(m.
description, bundle_filepath))
1832 bool all_clear =
true;
1833 for (
const CacheEntryPtr& entry: App::GetCacheSystem()->GetEntries())
1835 if (entry->resource_bundle_path == bundle_filepath && entry->resource_group !=
"")
1837 App::GetGameContext()->PushMessage(
Message(MSG_EDI_UNLOAD_BUNDLE_REQUESTED,
static_cast<void*
>(
new CacheEntryPtr(entry))));
1844 std::string bundle_basename, bundle_dirpath;
1845 Ogre::StringUtil::splitFilename(bundle_filepath, bundle_basename, bundle_dirpath);
1846 App::GetCacheSystem()->DeleteResourceBundleByFilename(bundle_basename);
1847 App::GetGuiManager()->RepositorySelector.NotifyRepoFileUninstalled(bundle_basename);
1852 App::GetGameContext()->PushMessage(m);
1858 HandleMsgQueueException(m.
type);
1863 case MSG_EDI_CREATE_PROJECT_REQUESTED:
1868 if (!App::GetCacheSystem()->CreateProject(request))
1875 HandleMsgQueueException(m.
type);
1881 case MSG_EDI_MODIFY_PROJECT_REQUESTED:
1886 if (App::mp_state->getEnum<MpState>() != MpState::CONNECTED)
1888 App::GetCacheSystem()->ModifyProject(request);
1893 HandleMsgQueueException(m.
type);
1899 case MSG_EDI_DELETE_PROJECT_REQUESTED:
1904 App::GetCacheSystem()->DeleteProject(*entry_ptr);
1908 HandleMsgQueueException(m.
type);
1914 case MSG_EDI_ADD_FREEBEAMGFX_REQUESTED:
1919 App::GetGfxScene()->AddFreeBeamGfx(request);
1923 HandleMsgQueueException(m.
type);
1929 case MSG_EDI_MODIFY_FREEBEAMGFX_REQUESTED:
1934 App::GetGfxScene()->ModifyFreeBeamGfx(request);
1938 HandleMsgQueueException(m.
type);
1944 case MSG_EDI_DELETE_FREEBEAMGFX_REQUESTED:
1949 App::GetGfxScene()->RemoveFreeBeamGfx(*request);
1953 HandleMsgQueueException(m.
type);
1967 App::GetGameContext()->PushMessage(chained_msg);
1974 if (App::gfx_fps_limit->getInt() > 0)
1976 const float min_frame_time = 1.0f / Ogre::Math::Clamp(App::gfx_fps_limit->getInt(), 5, 240);
1977 float dt = std::chrono::duration<float>(std::chrono::high_resolution_clock::now() - start_time).count();
1978 while (dt < min_frame_time)
1980 dt = std::chrono::duration<float>(std::chrono::high_resolution_clock::now() - start_time).count();
1985 const auto now = std::chrono::high_resolution_clock::now();
1986 const float dt = std::chrono::duration<float>(now - start_time).count();
1991 if (App::mp_state->getEnum<MpState>() == MpState::CONNECTED)
1993 std::vector<RoR::NetRecvPacket> packets = App::GetNetwork()->GetIncomingStreamData();
1994 if (!packets.empty())
1997 if (App::app_state->getEnum<AppState>() == AppState::SIMULATION)
1999 App::GetGameContext()->GetActorManager()->HandleActorStreamData(packets);
2000 App::GetGameContext()->GetCharacterFactory()->handleStreamData(packets);
2009 App::GetInputEngine()->Capture();
2010 App::GetInputEngine()->updateKeyBounces(dt);
2012 if (!App::GetGuiManager()->GameControls.IsInteractiveKeyBindingActive())
2014 if (!App::GetGuiManager()->MainSelector.IsVisible() && !App::GetGuiManager()->MultiplayerSelector.IsVisible() &&
2015 !App::GetGuiManager()->GameSettings.IsVisible() && !App::GetGuiManager()->GameControls.IsVisible() &&
2016 !App::GetGuiManager()->GameAbout.IsVisible() && !App::GetGuiManager()->RepositorySelector.IsVisible())
2018 App::GetGameContext()->HandleSavegameHotkeys();
2020 App::GetGameContext()->UpdateGlobalInputEvents();
2021 App::GetGuiManager()->UpdateInputEvents(dt);
2023 if (App::app_state->getEnum<AppState>() == AppState::SIMULATION)
2025 if (App::sim_state->getEnum<SimState>() == SimState::EDITOR_MODE)
2027 App::GetGameContext()->UpdateSkyInputEvents(dt);
2028 App::GetGameContext()->GetTerrain()->GetTerrainEditor()->UpdateInputEvents(dt);
2032 App::GetGameContext()->GetCharacterFactory()->Update(dt);
2034 App::GetCameraManager()->UpdateInputEvents(dt);
2035 App::GetOverlayWrapper()->update(dt);
2036 App::GetGameContext()->GetRepairMode().UpdateInputEvents(dt);
2037 App::GetGameContext()->GetActorManager()->UpdateInputEvents(dt);
2038 if (App::sim_state->getEnum<SimState>() == SimState::RUNNING)
2040 if (App::GetCameraManager()->GetCurrentBehavior() != CameraManager::CAMERA_BEHAVIOR_FREE)
2042 App::GetGameContext()->UpdateSimInputEvents(dt);
2043 App::GetGameContext()->UpdateSkyInputEvents(dt);
2044 if (App::GetGameContext()->GetPlayerActor() &&
2045 App::GetGameContext()->GetPlayerActor()->ar_state != ActorState::NETWORKED_OK)
2047 App::GetGameContext()->UpdateCommonInputEvents(dt);
2048 if (App::GetGameContext()->GetPlayerActor()->ar_state != ActorState::LOCAL_REPLAY)
2050 if (App::GetGameContext()->GetPlayerActor()->ar_driveable == TRUCK)
2052 App::GetGameContext()->UpdateTruckInputEvents(dt);
2054 if (App::GetGameContext()->GetPlayerActor()->ar_driveable == AIRPLANE)
2056 App::GetGameContext()->UpdateAirplaneInputEvents(dt);
2058 if (App::GetGameContext()->GetPlayerActor()->ar_driveable == BOAT)
2060 App::GetGameContext()->UpdateBoatInputEvents(dt);
2063 App::GetGameContext()->GetPlayerActor()->UpdatePropAnimInputEvents();
2064 for (
ActorPtr linked_actor : App::GetGameContext()->GetPlayerActor()->ar_linked_actors)
2066 linked_actor->UpdatePropAnimInputEvents();
2072 App::GetGameContext()->UpdateSkyInputEvents(dt);
2080 if (App::io_outgauge_mode->getInt() > 0)
2082 App::GetOutGauge()->Update(dt, App::GetGameContext()->GetPlayerActor());
2086 App::GetGuiManager()->NewImGuiFrame(dt);
2087 if (App::app_state->getEnum<AppState>() == AppState::SIMULATION)
2089 App::GetGuiManager()->DrawSimulationGui(dt);
2090 for (
ActorPtr& actor : App::GetGameContext()->GetActorManager()->GetActors())
2092 actor->GetGfxActor()->UpdateDebugView();
2094 if (App::GetGameContext()->GetPlayerActor())
2096 App::GetGuiManager()->VehicleInfoTPanel.UpdateStats(dt, App::GetGameContext()->GetPlayerActor());
2097 if (App::GetGuiManager()->FrictionSettings.IsVisible())
2099 App::GetGuiManager()->FrictionSettings.setActiveCol(App::GetGameContext()->GetPlayerActor()->ar_last_fuzzy_ground_model);
2105 if (App::GetMumble())
2107 App::GetMumble()->Update();
2112 App::GetSoundScriptManager()->update(dt);
2115#ifdef USE_ANGELSCRIPT
2116 App::GetScriptEngine()->framestep(dt);
2119 if (App::io_ffb_enabled->getBool() &&
2120 App::sim_state->getEnum<SimState>() == SimState::RUNNING)
2122 App::GetAppContext()->GetForceFeedback().Update();
2125 if (App::sim_state->getEnum<SimState>() == SimState::RUNNING)
2127 App::GetGameContext()->GetSceneMouse().UpdateSimulation();
2131 if (App::sim_state->getEnum<SimState>() == SimState::RUNNING ||
2132 App::sim_state->getEnum<SimState>() == SimState::PAUSED ||
2133 App::sim_state->getEnum<SimState>() == SimState::EDITOR_MODE)
2135 App::GetGfxScene()->BufferSimulationData();
2140 if (App::sim_state->getEnum<SimState>() == SimState::RUNNING && !App::GetGameContext()->GetActorManager()->IsSimulationPaused())
2142 dt_sim = dt * App::GetGameContext()->GetActorManager()->GetSimulationSpeed();
2146 if (App::sim_state->getEnum<SimState>() == SimState::RUNNING)
2148 if (App::GetGameContext()->GetTerrain()->getWater())
2150 App::GetGameContext()->GetTerrain()->getWater()->FrameStepWaveField(dt_sim);
2152 App::GetGameContext()->UpdateActors();
2156 if (App::app_state->getEnum<AppState>() == AppState::MAIN_MENU)
2158 App::GetGuiManager()->DrawMainMenuGui();
2160 else if (App::app_state->getEnum<AppState>() == AppState::SIMULATION)
2162 App::GetGfxScene()->UpdateScene(dt_sim);
2167 if (render_window->isClosed())
2169 App::GetGameContext()->PushMessage(
Message(MSG_APP_SHUTDOWN_REQUESTED));
2173 App::GetAppContext()->GetOgreRoot()->renderOneFrame();
2174 if (!render_window->isActive() && render_window->isVisible())
2176 render_window->update();
2180 App::GetGuiManager()->ApplyGuiCaptureKeyboard();
2182 App::GetGuiManager()->UpdateMouseCursorVisibility();
2188 catch (Ogre::Exception& e)
2190 LOG(e.getFullDescription());
2193 catch (std::runtime_error& e)