2023-12-29 13:09:56 +02:00
|
|
|
/*
|
|
|
|
* EntryPoint.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "StdInc.h"
|
|
|
|
|
|
|
|
#include "LobbyServer.h"
|
|
|
|
|
2024-02-02 00:21:52 +02:00
|
|
|
#include "../lib/logging/CBasicLogConfigurator.h"
|
2024-03-08 14:22:09 +02:00
|
|
|
#include "../lib/filesystem/CFilesystemLoader.h"
|
|
|
|
#include "../lib/filesystem/Filesystem.h"
|
2023-12-30 00:41:16 +02:00
|
|
|
#include "../lib/VCMIDirs.h"
|
|
|
|
|
2024-03-27 21:34:59 +02:00
|
|
|
static const int LISTENING_PORT = 3031;
|
2023-12-29 13:09:56 +02:00
|
|
|
|
|
|
|
int main(int argc, const char * argv[])
|
|
|
|
{
|
2024-03-08 14:22:09 +02:00
|
|
|
CResourceHandler::initialize();
|
|
|
|
CResourceHandler::load("config/filesystem.json"); // FIXME: we actually need only config directory for schemas, can be reduced
|
|
|
|
|
2024-02-02 00:21:52 +02:00
|
|
|
#ifndef VCMI_IOS
|
|
|
|
console = new CConsoleHandler();
|
|
|
|
#endif
|
|
|
|
CBasicLogConfigurator logConfig(VCMIDirs::get().userLogsPath() / "VCMI_Lobby_log.txt", console);
|
|
|
|
logConfig.configureDefault();
|
|
|
|
|
2023-12-30 00:41:16 +02:00
|
|
|
auto databasePath = VCMIDirs::get().userDataPath() / "vcmiLobby.db";
|
2024-02-02 00:21:52 +02:00
|
|
|
logGlobal->info("Opening database %s", databasePath.string());
|
2023-12-30 00:41:16 +02:00
|
|
|
|
|
|
|
LobbyServer server(databasePath);
|
2024-02-02 00:21:52 +02:00
|
|
|
logGlobal->info("Starting server on port %d", LISTENING_PORT);
|
2023-12-29 13:09:56 +02:00
|
|
|
|
2024-03-25 16:50:26 +02:00
|
|
|
try
|
|
|
|
{
|
|
|
|
server.start(LISTENING_PORT);
|
|
|
|
}
|
|
|
|
catch (const boost::system::system_error & e)
|
|
|
|
{
|
|
|
|
logGlobal->error("Failed to start server! Another server already uses the same port? Reason: '%s'", e.what());
|
|
|
|
return 1;
|
|
|
|
}
|
2023-12-29 13:09:56 +02:00
|
|
|
server.run();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|