Changeset View
Changeset View
Standalone View
Standalone View
source/ps/GameSetup/GameSetup.cpp
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
extern void RestartEngine(); | extern void RestartEngine(); | ||||
#include <fstream> | #include <fstream> | ||||
#include <iostream> | #include <iostream> | ||||
#include <boost/algorithm/string/classification.hpp> | #include <boost/algorithm/string/classification.hpp> | ||||
#include <boost/algorithm/string/join.hpp> | |||||
#include <boost/algorithm/string/split.hpp> | #include <boost/algorithm/string/split.hpp> | ||||
ERROR_GROUP(System); | ERROR_GROUP(System); | ||||
ERROR_TYPE(System, SDLInitFailed); | ERROR_TYPE(System, SDLInitFailed); | ||||
ERROR_TYPE(System, VmodeFailed); | ERROR_TYPE(System, VmodeFailed); | ||||
ERROR_TYPE(System, RequiredExtensionsMissing); | ERROR_TYPE(System, RequiredExtensionsMissing); | ||||
bool g_DoRenderGui = true; | bool g_DoRenderGui = true; | ||||
▲ Show 20 Lines • Show All 260 Lines • ▼ Show 20 Lines | if (!reentering) | ||||
reentering = false; | reentering = false; | ||||
} | } | ||||
} | } | ||||
// We don't actually implement the error display here, so return appropriately | // We don't actually implement the error display here, so return appropriately | ||||
return ERI_NOT_IMPLEMENTED; | return ERI_NOT_IMPLEMENTED; | ||||
} | } | ||||
const std::vector<CStr>& GetMods(const CmdLineArgs& args, int flags) | |||||
{ | |||||
const bool init_mods = (flags & INIT_MODS) == INIT_MODS; | |||||
const bool add_public = (flags & INIT_MODS_PUBLIC) == INIT_MODS_PUBLIC; | |||||
if (!init_mods) | |||||
return g_modsLoaded; | |||||
g_modsLoaded = args.GetMultiple("mod"); | |||||
if (add_public) | |||||
g_modsLoaded.insert(g_modsLoaded.begin(), "public"); | |||||
g_modsLoaded.insert(g_modsLoaded.begin(), "mod"); | |||||
return g_modsLoaded; | |||||
} | |||||
void MountMods(const Paths& paths, const std::vector<CStr>& mods) | void MountMods(const Paths& paths, const std::vector<CStr>& mods) | ||||
{ | { | ||||
OsPath modPath = paths.RData()/"mods"; | OsPath modPath = paths.RData()/"mods"; | ||||
OsPath modUserPath = paths.UserData()/"mods"; | OsPath modUserPath = paths.UserData()/"mods"; | ||||
size_t userFlags = VFS_MOUNT_WATCH|VFS_MOUNT_ARCHIVABLE; | size_t userFlags = VFS_MOUNT_WATCH|VFS_MOUNT_ARCHIVABLE; | ||||
size_t baseFlags = userFlags|VFS_MOUNT_MUST_EXIST; | size_t baseFlags = userFlags|VFS_MOUNT_MUST_EXIST; | ||||
size_t priority = 0; | size_t priority = 0; | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | if (readonlyConfig != paths.Config()) | ||||
g_VFS->Mount(L"config/", readonlyConfig, 0, VFS_MAX_PRIORITY-1); | g_VFS->Mount(L"config/", readonlyConfig, 0, VFS_MAX_PRIORITY-1); | ||||
g_VFS->Mount(L"config/", paths.Config(), 0, VFS_MAX_PRIORITY); | g_VFS->Mount(L"config/", paths.Config(), 0, VFS_MAX_PRIORITY); | ||||
g_VFS->Mount(L"screenshots/", paths.UserData()/"screenshots"/"", 0, VFS_MAX_PRIORITY); | g_VFS->Mount(L"screenshots/", paths.UserData()/"screenshots"/"", 0, VFS_MAX_PRIORITY); | ||||
g_VFS->Mount(L"saves/", paths.UserData()/"saves"/"", VFS_MOUNT_WATCH, VFS_MAX_PRIORITY); | g_VFS->Mount(L"saves/", paths.UserData()/"saves"/"", VFS_MOUNT_WATCH, VFS_MAX_PRIORITY); | ||||
// Engine localization files (regular priority, these can be overwritten). | // Engine localization files (regular priority, these can be overwritten). | ||||
g_VFS->Mount(L"l10n/", paths.RData()/"l10n"/""); | g_VFS->Mount(L"l10n/", paths.RData()/"l10n"/""); | ||||
MountMods(paths, GetMods(args, flags)); | MountMods(paths, Mod::GetModsFromArguments(args, flags)); | ||||
Silier: same? | |||||
// note: don't bother with g_VFS->TextRepresentation - directories | // note: don't bother with g_VFS->TextRepresentation - directories | ||||
// haven't yet been populated and are empty. | // haven't yet been populated and are empty. | ||||
} | } | ||||
static void InitPs(bool setup_gui, const CStrW& gui_page, ScriptInterface* srcScriptInterface, JS::HandleValue initData) | static void InitPs(bool setup_gui, const CStrW& gui_page, ScriptInterface* srcScriptInterface, JS::HandleValue initData) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 390 Lines • ▼ Show 20 Lines | |||||
bool Autostart(const CmdLineArgs& args); | bool Autostart(const CmdLineArgs& args); | ||||
/** | /** | ||||
* Returns true if the user has intended to start a visual replay from command line. | * Returns true if the user has intended to start a visual replay from command line. | ||||
*/ | */ | ||||
bool AutostartVisualReplay(const std::string& replayFile); | bool AutostartVisualReplay(const std::string& replayFile); | ||||
bool EnableModsOrSetDefault(const CmdLineArgs& args, int flags, const std::vector<CStr>& mods, bool fromConfig) | |||||
{ | |||||
ScriptInterface scriptInterface("Engine", "CheckAndEnableMods", g_ScriptContext); | |||||
if (Mod::CheckAndEnableMods(scriptInterface, mods)) | |||||
Not Done Inline Actionsearly return. Stan: early return. | |||||
return true; | |||||
// Here we refuse to start as there is no gui anyway | |||||
if (args.Has("autostart-nonvisual")) | |||||
{ | |||||
if (fromConfig) | |||||
Not Done Inline ActionsDoes this work or do you have to use debug_printf? (or both) Stan: Does this work or do you have to use debug_printf? (or both) | |||||
Done Inline Actionsit is same as in main. though it does not display on command line Silier: it is same as in main. though it does not display on command line | |||||
LOGERROR("Trying to start with incompatible mods from configuration file: %s.", boost::algorithm::join(Mod::GetIncompatibleMods(), ", ")); | |||||
else | |||||
LOGERROR("Trying to start with incompatible mods: %s.", boost::algorithm::join(Mod::GetIncompatibleMods(), ", ")); | |||||
return false; | |||||
} | |||||
Mod::SetDefaultMods(args, flags); | |||||
Done Inline Actionsremove this comment Silier: remove this comment | |||||
RestartEngine(); | |||||
return false; | |||||
} | |||||
bool Init(const CmdLineArgs& args, int flags) | bool Init(const CmdLineArgs& args, int flags) | ||||
{ | { | ||||
h_mgr_init(); | h_mgr_init(); | ||||
// Do this as soon as possible, because it chdirs | // Do this as soon as possible, because it chdirs | ||||
// and will mess up the error reporting if anything | // and will mess up the error reporting if anything | ||||
// crashes before the working directory is set. | // crashes before the working directory is set. | ||||
InitVfs(args, flags); | InitVfs(args, flags); | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | if (!args.Has("autostart-nonvisual") && !g_DisableAudio) | ||||
ISoundManager::CreateSoundManager(); | ISoundManager::CreateSoundManager(); | ||||
#endif | #endif | ||||
// Check if there are mods specified on the command line, | // Check if there are mods specified on the command line, | ||||
// or if we already set the mods (~INIT_MODS), | // or if we already set the mods (~INIT_MODS), | ||||
// else check if there are mods that should be loaded specified | // else check if there are mods that should be loaded specified | ||||
// in the config and load those (by aborting init and restarting | // in the config and load those (by aborting init and restarting | ||||
// the engine). | // the engine). | ||||
if (!args.Has("mod") && (flags & INIT_MODS) == INIT_MODS) | if ((flags & INIT_MODS) == INIT_MODS) | ||||
{ | |||||
if (!args.Has("mod")) | |||||
{ | { | ||||
CStr modstring; | CStr modstring; | ||||
CFG_GET_VAL("mod.enabledmods", modstring); | CFG_GET_VAL("mod.enabledmods", modstring); | ||||
if (!modstring.empty()) | if (!modstring.empty()) | ||||
{ | { | ||||
std::vector<CStr> mods; | std::vector<CStr> mods; | ||||
boost::split(mods, modstring, boost::is_any_of(" "), boost::token_compress_on); | boost::split(mods, modstring, boost::is_any_of(" "), boost::token_compress_on); | ||||
std::swap(g_modsLoaded, mods); | if (!EnableModsOrSetDefault(args, flags, mods, true)) | ||||
return false; | |||||
// Abort init and restart | |||||
RestartEngine(); | RestartEngine(); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
else if (!EnableModsOrSetDefault(args, flags, g_modsLoaded, false)) | |||||
return false; | |||||
} | |||||
Not Done Inline ActionsCould invert or at least merge the below if; Stan: Could invert or at least merge the below if; | |||||
new L10n; | new L10n; | ||||
// Optionally start profiler HTTP output automatically | // Optionally start profiler HTTP output automatically | ||||
Done Inline Actionsugh, should be |= Silier: ugh, should be |= | |||||
// (By default it's only enabled by a hotkey, for security/performance) | // (By default it's only enabled by a hotkey, for security/performance) | ||||
bool profilerHTTPEnable = false; | bool profilerHTTPEnable = false; | ||||
CFG_GET_VAL("profiler2.autoenable", profilerHTTPEnable); | CFG_GET_VAL("profiler2.autoenable", profilerHTTPEnable); | ||||
if (profilerHTTPEnable) | if (profilerHTTPEnable) | ||||
g_Profiler2.EnableHTTP(); | g_Profiler2.EnableHTTP(); | ||||
// Initialise everything except Win32 sockets (because our networking | // Initialise everything except Win32 sockets (because our networking | ||||
// system already inits those) | // system already inits those) | ||||
▲ Show 20 Lines • Show All 693 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
same?