Fix validate create instance

This commit is contained in:
Jiga228
2025-10-05 14:28:39 +07:00
parent e7d5cf920e
commit bd8b0aec96
3 changed files with 17 additions and 4 deletions
+10 -2
View File
@@ -71,10 +71,18 @@ CoreInstance::CoreInstance()
} catch (const std::exception& e)
{
std::cout << "[!] Init render engine: " << e.what() << '\n';
throw;
return;
}
game_ = GameFactory(*this);
try
{
game_ = GameFactory(*this);
} catch (const std::exception& e)
{
std::cout << "[!] Init game instance: " << e.what() << '\n';
return;
}
is_ready = true;
}
CoreInstance::~CoreInstance()
+3
View File
@@ -47,6 +47,8 @@ class CoreInstance {
static CoreInstance* self;
CoreCallBacks callbacks_;
bool is_ready = false;
#pragma region Callbacks
static void Quit_callback();
#pragma endregion
@@ -57,6 +59,7 @@ public:
void start();
void quit();
bool IsReady() const { return is_ready; }
int getCountCPU() const { return countCPU_; }
double getMemorySize() const { return memorySize_; }
const std::string& getBaseWorldName() const { return main_config_.base_world; }
+2
View File
@@ -5,6 +5,8 @@
int main(int argc, char* argv[]) {
try {
CoreInstance core;
if (core.IsReady() == false)
return 0;
std::cout << "CPU: " << core.getCountCPU() << std::endl;
std::cout << "Memory: " << core.getMemorySize() << std::endl;
core.start();