refactor again

This commit is contained in:
Aaron Kimbre
2025-01-15 13:48:49 -06:00
parent 72ae55981b
commit 5b8fe2cba0
3 changed files with 106 additions and 101 deletions

View File

@@ -76,7 +76,9 @@ int main(int argc, char** argv) {
Game::assetManager = new AssetManager(clientPath);
} catch (std::runtime_error& ex) {
LOG("Got an error while setting up assets: %s", ex.what());
delete Game::server;
delete Game::logger;
delete Game::config;
return EXIT_FAILURE;
}
@@ -88,9 +90,21 @@ int main(int argc, char** argv) {
Database::Destroy("ChatServer");
delete Game::server;
delete Game::logger;
delete Game::config;
return EXIT_FAILURE;
}
bool web_server_enabled = Game::config->GetValue("web_server_enabled") == "1";
ChatWebAPI chatwebapi;
if (web_server_enabled && !chatwebapi.Startup()){
LOG("Failed to start web server, shutting down.");
Database::Destroy("ChatServer");
delete Game::server;
delete Game::logger;
delete Game::config;
return EXIT_FAILURE;
};
//Find out the master's IP:
std::string masterIP;
uint32_t masterPort = 1000;
@@ -124,11 +138,6 @@ int main(int argc, char** argv) {
uint32_t framesSinceMasterDisconnect = 0;
uint32_t framesSinceLastSQLPing = 0;
bool web_server_enabled = Game::config->GetValue("web_server_enabled") == "1";
ChatWebAPI chatwebapi;
if (web_server_enabled) chatwebapi.Listen();
auto lastTime = std::chrono::high_resolution_clock::now();
Game::logger->Flush(); // once immediately before main loop