2020-07-06 19:18:29 +00:00
|
|
|
/**
|
|
|
|
* \file main.cpp
|
|
|
|
* \brief Univerxel game
|
2021-01-20 16:13:15 +00:00
|
|
|
* \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"
|
2021-01-20 16:13:15 +00:00
|
|
|
#include "client/srvContainer.hpp"
|
|
|
|
#include "core/options_full.hpp"
|
2020-09-25 18:50:46 +00:00
|
|
|
#include "core/utils/tracy.hpp"
|
2021-01-20 16:13:15 +00:00
|
|
|
#include "core/utils/logger.hpp"
|
2020-11-16 20:29:26 +00:00
|
|
|
#include "version.h"
|
2020-07-18 12:54:07 +00:00
|
|
|
|
2021-01-20 16:13:15 +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[]){
|
2020-11-16 20:29:26 +00:00
|
|
|
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
|
|
|
|
2020-09-25 18:50:46 +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
|
|
|
|
2021-01-20 16:13:15 +00:00
|
|
|
world::module::Registry::Load();
|
2020-09-20 16:41:54 +00:00
|
|
|
|
2021-01-20 16:13:15 +00:00
|
|
|
if (options.hasClient()) {
|
2020-09-20 16:41:54 +00:00
|
|
|
#if TRACY_ENABLE
|
|
|
|
tracy::SetThreadName("Client");
|
|
|
|
#endif
|
2021-01-20 16:13:15 +00:00
|
|
|
ServerFactory* srvContainer = options.hasServer() ?
|
|
|
|
new ServerFactory(options.getServer()) : nullptr;
|
2020-09-20 16:41:54 +00:00
|
|
|
|
2021-01-20 16:13:15 +00:00
|
|
|
auto client = Client(options.getClient(), srvContainer);
|
|
|
|
client.run();
|
2020-09-20 16:41:54 +00:00
|
|
|
|
2021-01-20 16:13:15 +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 {
|
2021-01-20 16:13:15 +00:00
|
|
|
FATAL("Nothing to start");
|
2020-09-20 16:41:54 +00:00
|
|
|
}
|
|
|
|
|
2021-01-20 16:13:15 +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;
|
|
|
|
}
|