Skip to content

Commit

Permalink
Server|macOS: Deploy required libraries and packages
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 15d69a8 commit 3feba2b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 44 deletions.
7 changes: 6 additions & 1 deletion doomsday/apps/client/CMakeLists.txt
Expand Up @@ -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)
Expand Down Expand Up @@ -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
)
Expand Down
66 changes: 23 additions & 43 deletions doomsday/apps/server/src/serverapp.cpp
Expand Up @@ -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)
{
Expand All @@ -76,10 +76,10 @@ DE_PIMPL(ServerApp)
, DE_OBSERVES(PackageLoader, Activity)
{
std::unique_ptr<ServerSystem> serverSystem;
std::unique_ptr<Resources> resources;
std::unique_ptr<AudioSystem> audioSys;
ClientServerWorld world;
InFineSystem infineSys;
std::unique_ptr<Resources> resources;
std::unique_ptr<AudioSystem> audioSys;
ClientServerWorld world;
InFineSystem infineSys;
duint32 serverId;

Impl(Public *i)
Expand Down Expand Up @@ -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<Folder>(PATH_SERVER_FILES))
if (auto *files = FS::tryLocate<Folder>(PATH_SERVER_FILES()))
{
files->populate();
}
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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<char const *>(gx.GetPointer(DD_PLUGIN_NAME)),
reinterpret_cast<char const *>(gx.GetPointer(DD_PLUGIN_VERSION_SHORT))));

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -382,7 +362,7 @@ void ServerApp::unloadGame(GameProfile const &upcomingGame)

ServerApp &ServerApp::app()
{
DE_ASSERT(serverAppSingleton != 0);
DE_ASSERT(serverAppSingleton != nullptr);
return *serverAppSingleton;
}

Expand Down

0 comments on commit 3feba2b

Please sign in to comment.