From 3feba2b0bfbad790f2fe18699f6f38ec6c4192fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Wed, 18 Jul 2018 15:25:53 +0300 Subject: [PATCH] Server|macOS: Deploy required libraries and packages --- doomsday/apps/client/CMakeLists.txt | 7 ++- doomsday/apps/server/src/serverapp.cpp | 66 +++++++++----------------- 2 files changed, 29 insertions(+), 44 deletions(-) diff --git a/doomsday/apps/client/CMakeLists.txt b/doomsday/apps/client/CMakeLists.txt index f2223b3de8..4f5dae52fd 100644 --- a/doomsday/apps/client/CMakeLists.txt +++ b/doomsday/apps/client/CMakeLists.txt @@ -93,6 +93,11 @@ endif () deng_filter_platform_sources (src ${SOURCES} ${HEADERS} ${API_HEADERS}) +list (APPEND DE_REQUIRED_PACKAGES + net.dengine.stdlib + net.dengine.stdlib.gui + net.dengine.base +) deng_add_package (net.dengine.client) if (IOS) @@ -263,7 +268,7 @@ endif () if (APPLE AND NOT IOS) deng_install_bundle_deps (client - Deng::libcore Deng::libshell Deng::libgui Deng::libappfw + CPlus::cplus Deng::libcore Deng::libshell Deng::libgui Deng::libappfw Deng::liblegacy Deng::libdoomsday Deng::libgamefw SDL2 SDL2_mixer ) diff --git a/doomsday/apps/server/src/serverapp.cpp b/doomsday/apps/server/src/serverapp.cpp index dbc958a0d7..129b222861 100644 --- a/doomsday/apps/server/src/serverapp.cpp +++ b/doomsday/apps/server/src/serverapp.cpp @@ -49,17 +49,17 @@ #include "world/map.h" #include "world/p_players.h" -#if WIN32 +#if defined (WIN32) # include "dd_winit.h" -#elif UNIX +#elif defined (UNIX) # include "dd_uinit.h" #endif using namespace de; -static ServerApp *serverAppSingleton = 0; +static ServerApp *serverAppSingleton = nullptr; -static String const PATH_SERVER_FILES = "/sys/server/public"; +DE_STATIC_STRING(PATH_SERVER_FILES, "/sys/server/public"); static void handleAppTerminate(char const *msg) { @@ -76,10 +76,10 @@ DE_PIMPL(ServerApp) , DE_OBSERVES(PackageLoader, Activity) { std::unique_ptr serverSystem; - std::unique_ptr resources; - std::unique_ptr audioSys; - ClientServerWorld world; - InFineSystem infineSys; + std::unique_ptr resources; + std::unique_ptr audioSys; + ClientServerWorld world; + InFineSystem infineSys; duint32 serverId; Impl(Public *i) @@ -142,19 +142,17 @@ DE_PIMPL(ServerApp) // Packages available to clients via RemoteFeed use versioned identifiers because // a client may already have a different version of the package. - Folder &files = self().fileSystem().makeFolder(PATH_SERVER_FILES); + Folder &files = self().fileSystem().makeFolder(PATH_SERVER_FILES()); auto *feed = new PackageFeed(PackageLoader::get(), PackageFeed::LinkVersionedIdentifier); - feed->setFilter([] (Package const &pkg) - { - return !pkg.matchTags(pkg.file(), "\\b(vanilla|core)\\b"); - }); + feed->setFilter( + [](Package const &pkg) { return !pkg.matchTags(pkg.file(), "\\b(vanilla|core)\\b"); }); files.attach(feed); } void setOfLoadedPackagesChanged() override { - if (Folder *files = FS::tryLocate(PATH_SERVER_FILES)) + if (auto *files = FS::tryLocate(PATH_SERVER_FILES())) { files->populate(); } @@ -163,9 +161,7 @@ DE_PIMPL(ServerApp) #ifdef UNIX void printVersionToStdOut() { - printf("%s %s\n", - DOOMSDAY_NICENAME, - DOOMSDAY_VERSION_FULLTEXT); + printf("%s %s\n", DOOMSDAY_NICENAME, DOOMSDAY_VERSION_FULLTEXT); } void printHelpToStdOut() @@ -218,7 +214,7 @@ ServerApp::~ServerApp() d.reset(); // Now that everything is shut down we can forget about the singleton instance. - serverAppSingleton = 0; + serverAppSingleton = nullptr; } duint32 ServerApp::instanceId() const @@ -260,12 +256,12 @@ void ServerApp::initialize() d->initServerFiles(); // Initialize. -#if WIN32 +#if defined (WIN32) if (!DD_Win32_Init()) { throw Error("ServerApp::initialize", "DD_Win32_Init failed"); } -#elif UNIX +#elif defined (UNIX) if (!DD_Unix_Init()) { throw Error("ServerApp::initialize", "DD_Unix_Init failed"); @@ -298,7 +294,8 @@ shell::ServerInfo ServerApp::currentServerInfo() // static // Let's figure out what we want to tell about ourselves. info.setServerId(ServerApp::app().d->serverId); info.setCompatibilityVersion(DOOMSDAY_VERSION); - info.setPluginDescription(Stringf("%s %s", + info.setPluginDescription( + Stringf("%s %s", reinterpret_cast(gx.GetPointer(DD_PLUGIN_NAME)), reinterpret_cast(gx.GetPointer(DD_PLUGIN_VERSION_SHORT)))); @@ -327,31 +324,14 @@ shell::ServerInfo ServerApp::currentServerInfo() // static info.setMap(mapPath); } - DE_ASSERT_FAIL("TODO: Check local addresses") - - // The master server will use the public IP address where an announcement came from, - // so we don't necessarily have to specify a valid address. The port is required, though. - info.setAddress({"localhost", duint16(nptIPPort)}); - -#if 0 - // This will only work if the server has a public IP address. - QHostInfo const host = QHostInfo::fromName(QHostInfo::localHostName()); - foreach (QHostAddress hostAddr, host.addresses()) - { - if (!hostAddr.isLoopback()) - { - info.setAddress(Address(hostAddr, duint16(nptIPPort))); - break; - } - } + // Check the IP address of the server. + info.setAddress(Address::localNetworkInterface(duint16(nptIPPort))); - String const publicDomain = nptIPAddress; - if (publicDomain) + if (const String publicHostName = nptIPAddress) { info.setDomainName(Stringf( - "%s:%i", publicDomain.c_str(), nptIPPort ? nptIPPort : shell::DEFAULT_PORT)); + "%s:%i", publicHostName.c_str(), nptIPPort ? nptIPPort : shell::DEFAULT_PORT)); } -#endif // Let's compile a list of client names. for (dint i = 0; i < DDMAXPLAYERS; ++i) @@ -382,7 +362,7 @@ void ServerApp::unloadGame(GameProfile const &upcomingGame) ServerApp &ServerApp::app() { - DE_ASSERT(serverAppSingleton != 0); + DE_ASSERT(serverAppSingleton != nullptr); return *serverAppSingleton; }