![]() |
Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
#include "precompiled.h"#include "GameSetup.h"#include "graphics/GameView.h"#include "gui/CGUI.h"#include "gui/GUIManager.h"#include "gui/Scripting/JSInterface_GUIManager.h"#include "i18n/L10n.h"#include "lib/app_hooks.h"#include "lib/code_annotation.h"#include "lib/code_generation.h"#include "lib/config2.h"#include "lib/debug.h"#include "lib/external_libraries/curl.h"#include "lib/file/common/file_stats.h"#include "lib/file/file_system.h"#include "lib/file/vfs/vfs.h"#include "lib/file/vfs/vfs_path.h"#include "lib/file/vfs/vfs_util.h"#include "lib/path.h"#include "lib/status.h"#include "lib/sysdep/os.h"#include "lobby/XmppClient.h"#include "network/NetClient.h"#include "network/NetHost.h"#include "network/NetMessage.h"#include "network/NetServer.h"#include "network/scripting/JSInterface_Network.h"#include "ps/CConsole.h"#include "ps/CLogger.h"#include "ps/ConfigDB.h"#include "ps/Errors.h"#include "ps/Filesystem.h"#include "ps/Game.h"#include "ps/GameSetup/CmdLineArgs.h"#include "ps/GameSetup/Config.h"#include "ps/GameSetup/HWDetect.h"#include "ps/GameSetup/Paths.h"#include "ps/Globals.h"#include "ps/Hotkey.h"#include "ps/Joystick.h"#include "ps/Loader.h"#include "ps/Mod.h"#include "ps/ModIo.h"#include "ps/Profile.h"#include "ps/ProfileViewer.h"#include "ps/Profiler2.h"#include "ps/Pyrogenesis.h"#include "ps/TemplateLoader.h"#include "ps/ThreadUtil.h"#include "ps/TouchInput.h"#include "ps/UserReport.h"#include "ps/VideoMode.h"#include "ps/World.h"#include "ps/XMB/XMBData.h"#include "ps/XMB/XMBStorage.h"#include "ps/XML/Xeromyces.h"#include "ps/scripting/JSInterface_Game.h"#include "ps/scripting/JSInterface_Main.h"#include "ps/scripting/JSInterface_VFS.h"#include "renderer/Renderer.h"#include "renderer/RenderingOptions.h"#include "renderer/SceneRenderer.h"#include "scriptinterface/FunctionWrapper.h"#include "scriptinterface/Object.h"#include "scriptinterface/Context.h"#include "scriptinterface/Conversions.h"#include "scriptinterface/Interface.h"#include "scriptinterface/Request.h"#include "scriptinterface/Stats.h"#include "simulation2/Simulation2.h"#include "simulation2/scripting/JSInterface_Simulation.h"#include "simulation2/system/Component.h"#include "soundmanager/ISoundManager.h"#include <SDL.h>#include <SDL_error.h>#include <SDL_hints.h>#include <SDL_keyboard.h>#include <SDL_version.h>#include <algorithm>#include <boost/algorithm/string/classification.hpp>#include <boost/algorithm/string/constants.hpp>#include <boost/algorithm/string/join.hpp>#include <boost/algorithm/string/split.hpp>#include <chrono>#include <cstdlib>#include <ctime>#include <filesystem>#include <fmt/format.h>#include <fstream>#include <js/CallArgs.h>#include <js/Promise.h>#include <js/RootingAPI.h>#include <js/TypeDecls.h>#include <js/Value.h>#include <locale>#include <memory>#include <optional>#include <stdexcept>#include <string>#include <thread>#include <unordered_set>#include <utility>Functions | |
| void | RestartEngine () |
| ERROR_GROUP (System) | |
| ERROR_TYPE (System, SDLInitFailed) | |
| ERROR_TYPE (System, VmodeFailed) | |
| ERROR_TYPE (System, RequiredExtensionsMissing) | |
| ErrorReactionInternal | psDisplayError (const wchar_t *, size_t) |
| void | MountMods (const Paths &paths, const std::vector< CStr > &mods) |
| Mounts all files of the given mods in the global VFS. More... | |
| void | InitVfs (const CmdLineArgs &args) |
| static void | InitPs (bool setup_gui, const CStrW &gui_page, Script::Interface *srcScriptInterface, JS::HandleValue initData) |
| std::unique_ptr< InputHandlers > | MakeInputHandlers () |
| static void | ShutdownPs () |
| static void | InitSDL () |
| static void | ShutdownSDL () |
| void | EndGame () |
| void | ShutdownNetworkAndUI () |
Has to be called before ShutdownConfigAndSubsequent. More... | |
| void | ShutdownConfigAndSubsequent () |
| static void | FixLocales () |
| void | EarlyInit () |
| initialize global modules that are be needed before Init. More... | |
| bool | Autostart (const CmdLineArgs &args) |
| Autostart arguments are parsed in javascript for convenience and moddability. More... | |
| bool | AutostartVisualReplay (const std::string &replayFile) |
| Returns true if the user has intended to start a visual replay from command line. More... | |
| bool | Init (const CmdLineArgs &args, int flags) |
| Returns true if successful, false if Init is aborted early (for instance if mods changed, or if we are using -dumpSchema). More... | |
| std::unique_ptr< InputHandlers > | InitGraphics (const CmdLineArgs &args, int flags, const std::vector< CStr > &installedMods, Script::Context &scriptContext, Script::Interface &scriptInterface) |
ShutdownNetworkAndUI has to be called later. More... | |
| bool | InitNonVisual (const CmdLineArgs &args) |
ShutdownNetworkAndUI has to be called later. More... | |
| CStr8 | LoadSettingsOfScenarioMap (const VfsPath &mapPath) |
| Temporarily loads a scenario map and retrieves the "ScriptSettings" JSON data from it. More... | |
| void | CancelLoad (const CStrW &message) |
| bool | InDevelopmentCopy () |
Variables | |
| thread_local std::shared_ptr< Script::Context > | g_ScriptContext |
| bool | g_InDevelopmentCopy |
| bool | g_CheckedIfInDevelopmentCopy = false |
| bool Autostart | ( | const CmdLineArgs & | args | ) |
Autostart arguments are parsed in javascript for convenience and moddability.
This C++ part only handles the following arguments: -autostart=MAP to enable regular autostart / host mode autostart -autostart-client=IP to enable 'MP client' autostart. -autostart-host to enable 'MP host' autostart. -autostart-nonvisual to start in non-visual mode. TODO: it might be nice to move these to JS too.
| bool AutostartVisualReplay | ( | const std::string & | replayFile | ) |
Returns true if the user has intended to start a visual replay from command line.
| void CancelLoad | ( | const CStrW & | message | ) |
| void EarlyInit | ( | ) |
initialize global modules that are be needed before Init.
must be called from the very beginning of main.
| void EndGame | ( | ) |
| ERROR_GROUP | ( | System | ) |
| ERROR_TYPE | ( | System | , |
| RequiredExtensionsMissing | |||
| ) |
| ERROR_TYPE | ( | System | , |
| SDLInitFailed | |||
| ) |
| ERROR_TYPE | ( | System | , |
| VmodeFailed | |||
| ) |
|
static |
| bool InDevelopmentCopy | ( | ) |
| bool Init | ( | const CmdLineArgs & | args, |
| int | flags | ||
| ) |
Returns true if successful, false if Init is aborted early (for instance if mods changed, or if we are using -dumpSchema).
ShutdownConfigAndSubsequent has to be called later.
| std::unique_ptr< InputHandlers > InitGraphics | ( | const CmdLineArgs & | args, |
| int | flags, | ||
| const std::vector< CStr > & | installedMods, | ||
| Script::Context & | scriptContext, | ||
| Script::Interface & | scriptInterface | ||
| ) |
ShutdownNetworkAndUI has to be called later.
| bool InitNonVisual | ( | const CmdLineArgs & | args | ) |
ShutdownNetworkAndUI has to be called later.
|
static |
|
static |
| void InitVfs | ( | const CmdLineArgs & | args | ) |
| CStr8 LoadSettingsOfScenarioMap | ( | const VfsPath & | mapPath | ) |
Temporarily loads a scenario map and retrieves the "ScriptSettings" JSON data from it.
The scenario map format is used for scenario and skirmish map types (random games do not use a "map" (format) but a small JavaScript program which creates a map on the fly). It contains a section to initialize the game setup screen.
| mapPath | Absolute path (from VFS root) to the map file to peek in. |
| std::unique_ptr< InputHandlers > MakeInputHandlers | ( | ) |
| void MountMods | ( | const Paths & | paths, |
| const std::vector< CStr > & | mods | ||
| ) |
Mounts all files of the given mods in the global VFS.
Make sure to call CacheEnabledModVersions after every call to this.
| ErrorReactionInternal psDisplayError | ( | const wchar_t * | , |
| size_t | |||
| ) |
| void RestartEngine | ( | ) |
| void ShutdownConfigAndSubsequent | ( | ) |
| void ShutdownNetworkAndUI | ( | ) |
Has to be called before ShutdownConfigAndSubsequent.
|
static |
|
static |
| bool g_CheckedIfInDevelopmentCopy = false |
| bool g_InDevelopmentCopy |
| thread_local std::shared_ptr<Script::Context> g_ScriptContext |