From 65aaa37f59f0b89dc18ea29fab1bc75c29b102e1 Mon Sep 17 00:00:00 2001 From: MatPoliquin Date: Wed, 15 Jan 2025 19:30:36 +0800 Subject: [PATCH] Replace assert with retro_assert --- ai/game_ai.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/ai/game_ai.cpp b/ai/game_ai.cpp index 96b06316ef53..dd567817e59b 100644 --- a/ai/game_ai.cpp +++ b/ai/game_ai.cpp @@ -106,7 +106,7 @@ void GameAIManager::Init() BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; hinstLib = LoadLibrary(TEXT("game_ai.dll")); - assert(hinstLib); + retro_assert(hinstLib); char full_module_path[MAX_PATH]; DWORD dwLen = GetModuleFileNameA(hinstLib, static_cast(&full_module_path), MAX_PATH); @@ -115,16 +115,19 @@ void GameAIManager::Init() { CreateGameAI = (creategameai_t) GetProcAddress(hinstLib, "CreateGameAI"); - assert(CreateGameAI); + retro_assert(CreateGameAI); } #else void *myso = dlopen("libgame_ai.so", RTLD_NOW); - assert(myso); + retro_assert(myso); - dlinfo(myso, RTLD_DI_ORIGIN, (void *) &game_ai_lib_path); + if(myso != NULL) + { + dlinfo(myso, RTLD_DI_ORIGIN, (void *) &game_ai_lib_path); - CreateGameAI = reinterpret_cast(dlsym(myso, "CreateGameAI")); - assert(CreateGameAI); + CreateGameAI = reinterpret_cast(dlsym(myso, "CreateGameAI")); + retro_assert(CreateGameAI); + } #endif } } @@ -153,15 +156,18 @@ void GameAIManager::Think(bool override_p1, bool override_p2, bool show_debug, c if (ga == nullptr && g_ram_ptr != nullptr) { ga = CreateGameAI(g_game_name.c_str()); - assert(ga); + retro_assert(ga); - std::string data_path((char *)game_ai_lib_path); - data_path += "/data/"; - data_path += g_game_name; + if (ga) + { + std::string data_path((char *)game_ai_lib_path); + data_path += "/data/"; + data_path += g_game_name; - ga->Init((void *) g_ram_ptr, g_ram_size); + ga->Init((void *) g_ram_ptr, g_ram_size); - ga->SetDebugLog(game_ai_debug_log); + ga->SetDebugLog(game_ai_debug_log); + } } if (g_frameCount >= 3)