Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/main.cpp
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | |||||
#if MSC_VERSION | #if MSC_VERSION | ||||
#include <process.h> | #include <process.h> | ||||
#define getpid _getpid // Use the non-deprecated function name | #define getpid _getpid // Use the non-deprecated function name | ||||
#endif | #endif | ||||
#include <chrono> | #include <chrono> | ||||
extern CmdLineArgs g_args; | extern CmdLineArgs g_CmdLineArgs; | ||||
extern CStrW g_UniqueLogPostfix; | extern CStrW g_UniqueLogPostfix; | ||||
// Marks terrain as modified so the minimap can repaint (is there a cleaner way of handling this?) | // Marks terrain as modified so the minimap can repaint (is there a cleaner way of handling this?) | ||||
bool g_GameRestarted = false; | bool g_GameRestarted = false; | ||||
// Determines the lifetime of the mainloop | // Determines the lifetime of the mainloop | ||||
enum ShutdownType | enum ShutdownType | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | static InReaction MainInputHandler(const SDL_Event_* ev) | ||||
case SDL_QUIT: | case SDL_QUIT: | ||||
QuitEngine(); | QuitEngine(); | ||||
break; | break; | ||||
case SDL_DROPFILE: | case SDL_DROPFILE: | ||||
{ | { | ||||
char* dropped_filedir = ev->ev.drop.file; | char* dropped_filedir = ev->ev.drop.file; | ||||
const Paths paths(g_args); | const Paths paths(g_CmdLineArgs); | ||||
CModInstaller installer(paths.UserData() / "mods", paths.Cache()); | CModInstaller installer(paths.UserData() / "mods", paths.Cache()); | ||||
installer.Install(std::string(dropped_filedir), g_ScriptContext, true); | installer.Install(std::string(dropped_filedir), g_ScriptContext, true); | ||||
SDL_free(dropped_filedir); | SDL_free(dropped_filedir); | ||||
if (installer.GetInstalledMods().empty()) | if (installer.GetInstalledMods().empty()) | ||||
LOGERROR("Failed to install mod %s", dropped_filedir); | LOGERROR("Failed to install mod %s", dropped_filedir); | ||||
else | else | ||||
{ | { | ||||
LOGMESSAGE("Installed mod %s", installer.GetInstalledMods().front()); | LOGMESSAGE("Installed mod %s", installer.GetInstalledMods().front()); | ||||
▲ Show 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
// moved into a helper function to ensure args is destroyed before | // moved into a helper function to ensure args is destroyed before | ||||
// exit(), which may result in a memory leak. | // exit(), which may result in a memory leak. | ||||
static void RunGameOrAtlas(int argc, const char* argv[]) | static void RunGameOrAtlas(int argc, const char* argv[]) | ||||
{ | { | ||||
CmdLineArgs args(argc, argv); | CmdLineArgs args(argc, argv); | ||||
g_args = args; | g_CmdLineArgs = args; | ||||
if (args.Has("version")) | if (args.Has("version")) | ||||
{ | { | ||||
debug_printf("Pyrogenesis %s\n", engine_version); | debug_printf("Pyrogenesis %s\n", engine_version); | ||||
return; | return; | ||||
} | } | ||||
if (args.Has("autostart-nonvisual") && args.Get("autostart").empty() && !args.Has("rl-interface")) | if (args.Has("autostart-nonvisual") && args.Get("autostart").empty() && !args.Has("rl-interface")) | ||||
▲ Show 20 Lines • Show All 231 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator