Changeset View
Changeset View
Standalone View
Standalone View
source/main.cpp
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | |||||
#include "network/NetServer.h" | #include "network/NetServer.h" | ||||
#include "network/NetSession.h" | #include "network/NetSession.h" | ||||
#include "lobby/IXmppClient.h" | #include "lobby/IXmppClient.h" | ||||
#include "graphics/Camera.h" | #include "graphics/Camera.h" | ||||
#include "graphics/GameView.h" | #include "graphics/GameView.h" | ||||
#include "graphics/TextureManager.h" | #include "graphics/TextureManager.h" | ||||
#include "gui/GUIManager.h" | #include "gui/GUIManager.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "rlinterface/RLInterface.cpp" | #include "rlinterface/RLInterface.h" | ||||
#include "scriptinterface/ScriptEngine.h" | #include "scriptinterface/ScriptEngine.h" | ||||
#include "simulation2/Simulation2.h" | #include "simulation2/Simulation2.h" | ||||
#include "simulation2/system/TurnManager.h" | #include "simulation2/system/TurnManager.h" | ||||
#include "soundmanager/ISoundManager.h" | #include "soundmanager/ISoundManager.h" | ||||
#if OS_UNIX | #if OS_UNIX | ||||
#include <unistd.h> // geteuid | #include <unistd.h> // geteuid | ||||
#endif // OS_UNIX | #endif // OS_UNIX | ||||
▲ Show 20 Lines • Show All 387 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
std::string server_address; | std::string server_address; | ||||
CFG_GET_VAL("rlinterface.address", server_address); | CFG_GET_VAL("rlinterface.address", server_address); | ||||
if (!args.Get("rl-interface").empty()) | if (!args.Get("rl-interface").empty()) | ||||
server_address = args.Get("rl-interface"); | server_address = args.Get("rl-interface"); | ||||
g_RLInterface = new RLInterface(); | g_RLInterface = new RLInterface(); | ||||
g_RLInterface->EnableHTTP(server_address.c_str()); | g_RLInterface->EnableHTTP(server_address.c_str()); | ||||
vladislavbelov: `g_RLInterface = std::make_unique<RL::Interface>(server_address.c_str());`, since we have C++17. | |||||
debug_printf("RL interface listening on %s\n", server_address.c_str()); | debug_printf("RL interface listening on %s\n", server_address.c_str()); | ||||
} | } | ||||
static void RunRLServer(const bool isNonVisual, const std::vector<OsPath> modsToInstall, const CmdLineArgs args) | static void RunRLServer(const bool isNonVisual, const std::vector<OsPath> modsToInstall, const CmdLineArgs args) | ||||
{ | { | ||||
int flags = INIT_MODS; | int flags = INIT_MODS; | ||||
while (!Init(args, flags)) | while (!Init(args, flags)) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Lines | if (!modsToInstall.empty()) | ||||
installer.Install(modPath, g_ScriptRuntime, true); | installer.Install(modPath, g_ScriptRuntime, true); | ||||
installedMods = installer.GetInstalledMods(); | installedMods = installer.GetInstalledMods(); | ||||
} | } | ||||
if (isNonVisual) | if (isNonVisual) | ||||
{ | { | ||||
InitNonVisual(args); | InitNonVisual(args); | ||||
while (g_Shutdown == ShutdownType::None) | while (g_Shutdown == ShutdownType::None) | ||||
Done Inline ActionsIt's better to add braces to the while. vladislavbelov: It's better to add braces to the `while`. | |||||
NonVisualFrame(); | NonVisualFrame(); | ||||
} | } | ||||
else | else | ||||
Done Inline ActionsWhat's about the visual case? vladislavbelov: What's about the visual case? | |||||
Done Inline ActionsIn the visual case, the game messages are applied in the Frame function similar to when the game simulation step is called when running w/o --rl-interface (should be line 397) irishninja: In the visual case, the game messages are applied in the `Frame` function similar to when the… | |||||
{ | { | ||||
InitGraphics(args, 0, installedMods); | InitGraphics(args, 0, installedMods); | ||||
MainControllerInit(); | MainControllerInit(); | ||||
while (g_Shutdown == ShutdownType::None) | while (g_Shutdown == ShutdownType::None) | ||||
Frame(); | Frame(); | ||||
} | } | ||||
// Do not install mods again in case of restart (typically from the mod selector) | // Do not install mods again in case of restart (typically from the mod selector) | ||||
modsToInstall.clear(); | modsToInstall.clear(); | ||||
Shutdown(0); | Shutdown(0); | ||||
MainControllerShutdown(); | MainControllerShutdown(); | ||||
flags &= ~INIT_MODS; | flags &= ~INIT_MODS; | ||||
} while (g_Shutdown == ShutdownType::Restart); | } while (g_Shutdown == ShutdownType::Restart); | ||||
Done Inline ActionsUsing pure pointers isn't safe, are you sure that it can't be replaced by std::unique_ptr for example? vladislavbelov: Using pure pointers isn't safe, are you sure that it can't be replaced by `std::unique_ptr` for… | |||||
#if OS_MACOSX | #if OS_MACOSX | ||||
if (g_Shutdown == ShutdownType::RestartAsAtlas) | if (g_Shutdown == ShutdownType::RestartAsAtlas) | ||||
startNewAtlasProcess(); | startNewAtlasProcess(); | ||||
#else | #else | ||||
if (g_Shutdown == ShutdownType::RestartAsAtlas) | if (g_Shutdown == ShutdownType::RestartAsAtlas) | ||||
ATLAS_RunIfOnCmdLine(args, true); | ATLAS_RunIfOnCmdLine(args, true); | ||||
#endif | #endif | ||||
Show All 39 Lines |
Wildfire Games · Phabricator
g_RLInterface = std::make_unique<RL::Interface>(server_address.c_str());, since we have C++17.