1
0
Fork 0
Univerxel/src/main.cpp

60 lines
1.3 KiB
C++
Raw Normal View History

2020-07-06 19:18:29 +00:00
/**
* \file main.cpp
* \brief Univerxel game
* \author Shu
* \version 0.0.2
2020-07-06 19:18:29 +00:00
*
* Univerxel main program.
*/
2020-09-14 16:03:21 +00:00
#include "client/Client.hpp"
2020-09-20 16:41:54 +00:00
#include "server/Server.hpp"
#include "client/srvContainer.hpp"
#include "core/options_full.hpp"
#include "core/utils/tracy.hpp"
#include "core/utils/logger.hpp"
#include "version.h"
2020-07-18 12:54:07 +00:00
2020-07-06 19:18:29 +00:00
/// Entry point
2020-09-22 20:37:09 +00:00
int main(int argc, char *argv[]){
LOG("Univerxel " << UNIVERXEL_VERSION);
2020-07-06 19:18:29 +00:00
2020-08-07 17:08:02 +00:00
#if TRACY_ENABLE
2020-07-31 22:11:08 +00:00
LOG("Profiling !");
2020-07-18 12:54:07 +00:00
#endif
2020-07-06 19:18:29 +00:00
auto options = config::options(argc > 1 ? argv[1] : config::DEFAULT_FILE);
2020-09-22 20:37:09 +00:00
options.save();
2020-09-20 16:41:54 +00:00
world::module::Registry::Load();
2020-09-20 16:41:54 +00:00
if (options.hasClient()) {
2020-09-20 16:41:54 +00:00
#if TRACY_ENABLE
tracy::SetThreadName("Client");
#endif
ServerFactory* srvContainer = options.hasServer() ?
new ServerFactory(options.getServer()) : nullptr;
2020-09-20 16:41:54 +00:00
auto client = Client(options.getClient(), srvContainer);
client.run();
2020-09-20 16:41:54 +00:00
delete srvContainer;
} else if (options.hasServer()) {
#if TRACY_ENABLE
tracy::SetThreadName("Server");
#endif
LOG_I("Running only server");
auto server = Server(options.getServer());
server.run();
2020-09-20 16:41:54 +00:00
} else {
FATAL("Nothing to start");
2020-09-20 16:41:54 +00:00
}
options.save();
world::module::Registry::Unload();
2020-09-20 16:41:54 +00:00
options.save();
2020-07-12 13:46:51 +00:00
2020-07-06 19:18:29 +00:00
return 0;
}