VERY experimental Nintendo Switch 2 emulator
C++
Remove the useless msg_handler compilation unit that was left over from Dolphin
archshift5efd149ad56e
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txtindex 8c87deaa45..0a8ef6dab4 100644--- a/src/common/CMakeLists.txt+++ b/src/common/CMakeLists.txt@@ -16,7 +16,6 @@ set(SRCSmem_arena.cppmemory_util.cppmisc.cpp- msg_handler.cppscm_rev.cppstring_util.cppsymbols.cpp@@ -53,7 +52,6 @@ set(HEADERSmath_util.hmem_arena.hmemory_util.h- msg_handler.hplatform.hscm_rev.hscope_exit.hdiff --git a/src/common/chunk_file.h b/src/common/chunk_file.hindex dc27da088c..3f97d56bfd 100644--- a/src/common/chunk_file.h+++ b/src/common/chunk_file.h@@ -637,7 +637,7 @@ public:Do(cookie);if(mode == PointerWrap::MODE_READ && cookie != arbitraryNumber){- PanicAlertT("Error: After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). Aborting savestate load...", prevName, cookie, cookie, arbitraryNumber, arbitraryNumber);+ LOG_ERROR(Common, "After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). Aborting savestate load...", prevName, cookie, cookie, arbitraryNumber, arbitraryNumber);SetError(ERROR_FAILURE);}}diff --git a/src/common/common.h b/src/common/common.hindex ad2de6f2eb..f5f2f8c34c 100644--- a/src/common/common.h+++ b/src/common/common.h@@ -28,7 +28,6 @@ private:#include "common/assert.h"#include "common/logging/log.h"#include "common/common_types.h"-#include "common/msg_handler.h"#include "common/common_funcs.h"#include "common/common_paths.h"#include "common/platform.h"diff --git a/src/common/mem_arena.cpp b/src/common/mem_arena.cppindex a20361d6fe..cc31a88ccf 100644--- a/src/common/mem_arena.cpp+++ b/src/common/mem_arena.cpp@@ -218,7 +218,7 @@ u8* MemArena::Find4GBBase()void* base = mmap(0, 0x10000000, PROT_READ | PROT_WRITE,MAP_ANON | MAP_SHARED, -1, 0);if (base == MAP_FAILED) {- PanicAlert("Failed to map 256 MB of memory space: %s", strerror(errno));+ LOG_ERROR(Common_Memory, "Failed to map 256 MB of memory space: %s", strerror(errno));return 0;}munmap(base, 0x10000000);@@ -338,7 +338,7 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena// address space.if (!Memory_TryBase(base, views, num_views, flags, arena)){- PanicAlert("MemoryMap_Setup: Failed finding a memory base.");+ LOG_ERROR(Common_Memory, "MemoryMap_Setup: Failed finding a memory base.");return 0;}#elif defined(_WIN32)@@ -363,12 +363,11 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArenaif (!Memory_TryBase(base, views, num_views, flags, arena)){LOG_ERROR(Common_Memory, "MemoryMap_Setup: Failed finding a memory base.");- PanicAlert("MemoryMap_Setup: Failed finding a memory base.");return 0;}#endifif (base_attempts)- PanicAlert("No possible memory base pointer found!");+ LOG_ERROR(Common_Memory, "No possible memory base pointer found!");return base;}diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cppindex 8f982da894..7e69d31cb6 100644--- a/src/common/memory_util.cpp+++ b/src/common/memory_util.cpp@@ -56,7 +56,7 @@ void* AllocateExecutableMemory(size_t size, bool low){ptr = nullptr;#endif- PanicAlert("Failed to allocate executable memory");+ LOG_ERROR(Common_Memory, "Failed to allocate executable memory");}#if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT)else@@ -72,7 +72,7 @@ void* AllocateExecutableMemory(size_t size, bool low)#if defined(_M_X64)if ((u64)ptr >= 0x80000000 && low == true)- PanicAlert("Executable memory ended up above 2GB!");+ LOG_ERROR(Common_Memory, "Executable memory ended up above 2GB!");#endifreturn ptr;@@ -94,7 +94,7 @@ void* AllocateMemoryPages(size_t size)// (unsigned long)size);if (ptr == nullptr)- PanicAlert("Failed to allocate raw memory");+ LOG_ERROR(Common_Memory, "Failed to allocate raw memory");return ptr;}@@ -117,7 +117,7 @@ void* AllocateAlignedMemory(size_t size,size_t alignment)// (unsigned long)size);if (ptr == nullptr)- PanicAlert("Failed to allocate aligned memory");+ LOG_ERROR(Common_Memory, "Failed to allocate aligned memory");return ptr;}@@ -129,7 +129,7 @@ void FreeMemoryPages(void* ptr, size_t size)#ifdef _WIN32if (!VirtualFree(ptr, 0, MEM_RELEASE))- PanicAlert("FreeMemoryPages failed!\n%s", GetLastErrorMsg());+ LOG_ERROR(Common_Memory, "FreeMemoryPages failed!\n%s", GetLastErrorMsg());ptr = nullptr; // Is this our responsibility?#else@@ -155,7 +155,7 @@ void WriteProtectMemory(void* ptr, size_t size, bool allowExecute)#ifdef _WIN32DWORD oldValue;if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READ : PAGE_READONLY, &oldValue))- PanicAlert("WriteProtectMemory failed!\n%s", GetLastErrorMsg());+ LOG_ERROR(Common_Memory, "WriteProtectMemory failed!\n%s", GetLastErrorMsg());#elsemprotect(ptr, size, allowExecute ? (PROT_READ | PROT_EXEC) : PROT_READ);#endif@@ -166,7 +166,7 @@ void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute)#ifdef _WIN32DWORD oldValue;if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE, &oldValue))- PanicAlert("UnWriteProtectMemory failed!\n%s", GetLastErrorMsg());+ LOG_ERROR(Common_Memory, "UnWriteProtectMemory failed!\n%s", GetLastErrorMsg());#elsemprotect(ptr, size, allowExecute ? (PROT_READ | PROT_WRITE | PROT_EXEC) : PROT_WRITE | PROT_READ);#endifdiff --git a/src/common/msg_handler.cpp b/src/common/msg_handler.cppdeleted file mode 100644index 4a47b518eb..0000000000--- a/src/common/msg_handler.cpp+++ /dev/null@@ -1,107 +0,0 @@-// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project-// Licensed under GPLv2 or any later version-// Refer to the license.txt file included.--#include <cstdio>--#include "common/common.h" // Local-#include "common/string_util.h"--bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int Style);-static MsgAlertHandler msg_handler = DefaultMsgHandler;-static bool AlertEnabled = true;--std::string DefaultStringTranslator(const char* text);-static StringTranslator str_translator = DefaultStringTranslator;--// Select which of these functions that are used for message boxes. If-// wxWidgets is enabled we will use wxMsgAlert() that is defined in Main.cpp-void RegisterMsgAlertHandler(MsgAlertHandler handler)-{- msg_handler = handler;-}--// Select translation function. For wxWidgets use wxStringTranslator in Main.cpp-void RegisterStringTranslator(StringTranslator translator)-{- str_translator = translator;-}--// enable/disable the alert handler-void SetEnableAlert(bool enable)-{- AlertEnabled = enable;-}--// This is the first stop for gui alerts where the log is updated and the-// correct window is shown-bool MsgAlert(bool yes_no, int Style, const char* format, ...)-{- // Read message and write it to the log- std::string caption;- char buffer[2048];-- static std::string info_caption;- static std::string warn_caption;- static std::string ques_caption;- static std::string crit_caption;-- if (!info_caption.length())- {- info_caption = str_translator(_trans("Information"));- ques_caption = str_translator(_trans("Question"));- warn_caption = str_translator(_trans("Warning"));- crit_caption = str_translator(_trans("Critical"));- }-- switch(Style)- {- case INFORMATION:- caption = info_caption;- break;- case QUESTION:- caption = ques_caption;- break;- case WARNING:- caption = warn_caption;- break;- case CRITICAL:- caption = crit_caption;- break;- }-- va_list args;- va_start(args, format);- Common::CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args);- va_end(args);-- LOG_INFO(Common, "%s: %s", caption.c_str(), buffer);-- // Don't ignore questions, especially AskYesNo, PanicYesNo could be ignored- if (msg_handler && (AlertEnabled || Style == QUESTION || Style == CRITICAL))- return msg_handler(caption.c_str(), buffer, yes_no, Style);-- return true;-}--// Default non library dependent panic alert-bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int Style)-{-//#ifdef _WIN32-// int STYLE = MB_ICONINFORMATION;-// if (Style == QUESTION) STYLE = MB_ICONQUESTION;-// if (Style == WARNING) STYLE = MB_ICONWARNING;-//-// return IDYES == MessageBox(0, UTF8ToTStr(text).c_str(), UTF8ToTStr(caption).c_str(), STYLE | (yes_no ? MB_YESNO : MB_OK));-//#else- printf("%s\n", text);- return true;-//#endif-}--// Default (non) translator-std::string DefaultStringTranslator(const char* text)-{- return text;-}-diff --git a/src/common/msg_handler.h b/src/common/msg_handler.hdeleted file mode 100644index 421f93e23e..0000000000--- a/src/common/msg_handler.h+++ /dev/null@@ -1,56 +0,0 @@-// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project-// Licensed under GPLv2 or any later version-// Refer to the license.txt file included.--#pragma once--#include <string>--// Message alerts-enum MSG_TYPE-{- INFORMATION,- QUESTION,- WARNING,- CRITICAL-};--typedef bool (*MsgAlertHandler)(const char* caption, const char* text,- bool yes_no, int Style);-typedef std::string (*StringTranslator)(const char* text);--void RegisterMsgAlertHandler(MsgAlertHandler handler);-void RegisterStringTranslator(StringTranslator translator);--extern bool MsgAlert(bool yes_no, int Style, const char* format, ...)-#ifdef __GNUC__- __attribute__((format(printf, 3, 4)))-#endif- ;-void SetEnableAlert(bool enable);--#ifdef _MSC_VER- #define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__)- #define PanicAlert(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__)- #define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__)- #define AskYesNo(format, ...) MsgAlert(true, QUESTION, format, __VA_ARGS__)- #define CriticalAlert(format, ...) MsgAlert(false, CRITICAL, format, __VA_ARGS__)- // Use these macros (that do the same thing) if the message should be translated.- #define SuccessAlertT(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__)- #define PanicAlertT(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__)- #define PanicYesNoT(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__)- #define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, __VA_ARGS__)- #define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, __VA_ARGS__)-#else- #define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, ##__VA_ARGS__)- #define PanicAlert(format, ...) MsgAlert(false, WARNING, format, ##__VA_ARGS__)- #define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, ##__VA_ARGS__)- #define AskYesNo(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__)- #define CriticalAlert(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__)- // Use these macros (that do the same thing) if the message should be translated.- #define SuccessAlertT(format, ...) MsgAlert(false, INFORMATION, format, ##__VA_ARGS__)- #define PanicAlertT(format, ...) MsgAlert(false, WARNING, format, ##__VA_ARGS__)- #define PanicYesNoT(format, ...) MsgAlert(true, WARNING, format, ##__VA_ARGS__)- #define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__)- #define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__)-#endifdiff --git a/src/core/core_timing.cpp b/src/core/core_timing.cppindex cabe2a0746..6f716b1caf 100644--- a/src/core/core_timing.cpp+++ b/src/core/core_timing.cpp@@ -147,7 +147,7 @@ void RestoreRegisterEvent(int event_type, const char* name, TimedCallback callbavoid UnregisterAllEvents() {if (first)- PanicAlert("Cannot unregister events with events pending");+ LOG_ERROR(Core_Timing, "Cannot unregister events with events pending");event_types.clear();}@@ -535,7 +535,7 @@ std::string GetScheduledEventsSummary() {while (event) {unsigned int t = event->type;if (t >= event_types.size())- PanicAlert("Invalid event type"); // %i", t);+ LOG_ERROR(Core_Timing, "Invalid event type"); // %i", t);const char* name = event_types[event->type].name;if (!name)name = "[unknown]";