diff --git a/include/gameinfo.hpp b/include/gameinfo.hpp index ee6fa9a..72e4966 100644 --- a/include/gameinfo.hpp +++ b/include/gameinfo.hpp @@ -46,7 +46,7 @@ struct GameInfo { // find a plugin file to load bool LoadPlugin(std::string plugin_path); // route syscall or vmMain call to plugins and mod - intptr_t Route(bool is_syscall, intptr_t cmd, intptr_t* args); + intptr_t Route(bool is_syscall, intptr_t cmd, intptr_t* args) const; // cache some dynamic message values that get evaluated a lot static intptr_t msg_G_PRINT, msg_GAME_INIT, msg_GAME_CONSOLE_COMMAND, msg_GAME_SHUTDOWN; diff --git a/include/log.hpp b/include/log.hpp index c032f13..72b781a 100644 --- a/include/log.hpp +++ b/include/log.hpp @@ -17,6 +17,8 @@ Created By: #include #include +#define QMMLOG(severity, tag) if (log_level_match(severity)) LOG(severity, tag) + #ifdef _DEBUG constexpr AixLog::Severity QMM2_LOG_DEFAULT_SEVERITY = AixLog::Severity::debug; #else @@ -25,6 +27,7 @@ constexpr AixLog::Severity QMM2_LOG_DEFAULT_SEVERITY = AixLog::Severity::info; constexpr AixLog::Severity QMM2_LOG_CONSOLE_SEVERITY = AixLog::Severity::info; +bool log_level_match(int severity); void log_init(std::string file, AixLog::Severity severity = QMM2_LOG_DEFAULT_SEVERITY, bool append = false); diff --git a/include/qmmapi.h b/include/qmmapi.h index 296c7e1..d20b957 100644 --- a/include/qmmapi.h +++ b/include/qmmapi.h @@ -71,6 +71,8 @@ typedef void* (*mod_GetGameAPI)(void*, void*); // 4:3 // - changed type names away from those ending with "_t" - added typedefs for old names marked deprecated. define QMM_USE_DEPRECATED_TYPES to use old types without warning // - added QMM_MODDIR +// 4:4 +// - swapped order of severity and text in QMM_WRITEQMMLOG and also made it vararg. string construction is ignored if log won't write // holds plugin info to pass back to QMM typedef struct { @@ -120,8 +122,8 @@ typedef enum { // prototype struct for QMM plugin util funcs typedef struct { - void (*pfnWriteQMMLog)(plugin_id plid, const char* text, int severity); // write to the QMM log - char* (*pfnVarArgs)(plugin_id plid, const char* format, ...); // simple vsprintf helper with rotating buffer + void (*pfnWriteQMMLog)(plugin_id plid, int severity, const char* fmt, ...); // write to the QMM log + char* (*pfnVarArgs)(plugin_id plid, const char* fmt, ...); // simple vsprintf helper with rotating buffer int (*pfnIsQVM)(plugin_id plid); // returns 1 if the mod is QVM const char* (*pfnEngMsgName)(plugin_id plid, intptr_t msg); // get the string name of a syscall code const char* (*pfnModMsgName)(plugin_id plid, intptr_t msg); // get the string name of a vmMain code @@ -146,8 +148,8 @@ typedef struct { } plugin_funcs; // macros for QMM plugin util funcs -#define QMM_WRITEQMMLOG(text, severity) (g_pluginfuncs->pfnWriteQMMLog)(PLID, text, severity) // write to the QMM log -#define QMM_VARARGS(format, ...) (g_pluginfuncs->pfnVarArgs)(PLID, format, __VA_ARGS__) // simple vsprintf helper +#define QMM_WRITEQMMLOG(sev, fmt, ...) (g_pluginfuncs->pfnWriteQMMLog)(PLID, sev, fmt, __VA_ARGS__) // write to the QMM log +#define QMM_VARARGS(fmt, ...) (g_pluginfuncs->pfnVarArgs)(PLID, fmt, __VA_ARGS__) // simple vsprintf helper #define QMM_ISQVM() (g_pluginfuncs->pfnIsQVM)(PLID) // returns 1 if the mod is QVM #define QMM_ENGMSGNAME(cmd) (g_pluginfuncs->pfnEngMsgName)(PLID, cmd) // get the string name of a syscall code #define QMM_MODMSGNAME(cmd) (g_pluginfuncs->pfnModMsgName)(PLID, cmd) // get the string name of a vmMain code diff --git a/include/version.h b/include/version.h index 35f389d..04cb95a 100644 --- a/include/version.h +++ b/include/version.h @@ -16,7 +16,7 @@ Created By: #define STRINGIFY2(x) #x #define QMM_VERSION_MAJOR 2 -#define QMM_VERSION_MINOR 5 +#define QMM_VERSION_MINOR 6 #define QMM_VERSION_REV 0 #define QMM_VERSION STRINGIFY(QMM_VERSION_MAJOR) "." STRINGIFY(QMM_VERSION_MINOR) "." STRINGIFY(QMM_VERSION_REV) diff --git a/src/game_cod11mp.cpp b/src/game_cod11mp.cpp index 9f696c2..e78e87b 100644 --- a/src/game_cod11mp.cpp +++ b/src/game_cod11mp.cpp @@ -17,7 +17,6 @@ Created By: #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" #include // QMM-specific COD11MP header #include "game_cod11mp.h" @@ -66,10 +65,9 @@ bool COD11MP_GameSupport::AutoDetect(APIType) { intptr_t COD11MP_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("COD11MP_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "COD11MP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; + intptr_t ret = 0; @@ -99,10 +97,8 @@ intptr_t COD11MP_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("COD11MP_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "COD11MP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -113,9 +109,7 @@ intptr_t COD11MP_GameSupport::syscall(intptr_t cmd, ...) { intptr_t COD11MP_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("COD11MP_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "COD11MP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_vmMain) return 0; @@ -126,21 +120,19 @@ intptr_t COD11MP_GameSupport::vmMain(intptr_t cmd, ...) { // all normal mod functions go to vmMain ret = orig_vmMain(cmd, QMM_PUT_VMMAIN_ARGS()); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("COD11MP_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "COD11MP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* COD11MP_GameSupport::Entry(void* syscall, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("COD11MP_GameSupport::Entry({}) called\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "COD11MP_GameSupport::Entry(" << syscall << ") called\n"; // store original syscall from engine orig_syscall = (eng_syscall)syscall; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("COD11MP_GameSupport::Entry({}) returning\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "COD11MP_GameSupport::Entry(" << syscall << ") returning\n"; return nullptr; } diff --git a/src/game_codmp.cpp b/src/game_codmp.cpp index dd115dc..4627230 100644 --- a/src/game_codmp.cpp +++ b/src/game_codmp.cpp @@ -17,7 +17,6 @@ Created By: #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" #include // QMM-specific CODMP header #include "game_codmp.h" @@ -78,10 +77,9 @@ bool CODMP_GameSupport::AutoDetect(APIType engineapi) { intptr_t CODMP_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("CODMP_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "CODMP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; + intptr_t ret = 0; @@ -111,10 +109,8 @@ intptr_t CODMP_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("CODMP_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "CODMP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -125,9 +121,7 @@ intptr_t CODMP_GameSupport::syscall(intptr_t cmd, ...) { intptr_t CODMP_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("CODMP_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "CODMP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_vmMain) return 0; @@ -138,21 +132,19 @@ intptr_t CODMP_GameSupport::vmMain(intptr_t cmd, ...) { // all normal mod functions go to vmMain ret = orig_vmMain(cmd, QMM_PUT_VMMAIN_ARGS()); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("CODMP_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "CODMP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* CODMP_GameSupport::Entry(void* syscall, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("CODMP_GameSupport::Entry({}) called\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "CODMP_GameSupport::Entry(" << syscall << ") called\n"; // store original syscall from engine orig_syscall = (eng_syscall)syscall; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("CODMP_GameSupport::Entry({}) returning\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "CODMP_GameSupport::Entry(" << syscall << ") returning\n"; return nullptr; } diff --git a/src/game_coduomp.cpp b/src/game_coduomp.cpp index 79ba47b..1a33918 100644 --- a/src/game_coduomp.cpp +++ b/src/game_coduomp.cpp @@ -17,7 +17,6 @@ Created By: #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" #include // QMM-specific CODUOMP header #include "game_coduomp.h" @@ -78,10 +77,9 @@ bool CODUOMP_GameSupport::AutoDetect(APIType engineapi) { intptr_t CODUOMP_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("CODUOMP_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "CODUOMP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; + intptr_t ret = 0; @@ -111,10 +109,8 @@ intptr_t CODUOMP_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("CODUOMP_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "CODUOMP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -125,9 +121,7 @@ intptr_t CODUOMP_GameSupport::syscall(intptr_t cmd, ...) { intptr_t CODUOMP_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("CODUOMP_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "CODUOMP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_vmMain) return 0; @@ -138,21 +132,19 @@ intptr_t CODUOMP_GameSupport::vmMain(intptr_t cmd, ...) { // all normal mod functions go to vmMain ret = orig_vmMain(cmd, QMM_PUT_VMMAIN_ARGS()); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("CODUOMP_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "CODUOMP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* CODUOMP_GameSupport::Entry(void* syscall, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("CODUOMP_GameSupport::Entry({}) called\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "CODUOMP_GameSupport::Entry(" << syscall << ") called\n"; // store original syscall from engine orig_syscall = (eng_syscall)syscall; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("CODUOMP_GameSupport::Entry({}) returning\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "CODUOMP_GameSupport::Entry(" << syscall << ") returning\n"; return nullptr; } diff --git a/src/game_jamp.cpp b/src/game_jamp.cpp index 23814f6..103e7cf 100644 --- a/src/game_jamp.cpp +++ b/src/game_jamp.cpp @@ -14,7 +14,6 @@ Created By: #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" #include // QMM-specific JAMP header #include "game_jamp.h" @@ -100,10 +99,9 @@ bool JAMP_GameSupport::AutoDetect(APIType engineapi) { intptr_t JAMP_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JAMP_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JAMP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; + // store return value since we do some stuff after the function call is over intptr_t ret = 0; @@ -472,10 +470,8 @@ intptr_t JAMP_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JAMP_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JAMP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -486,9 +482,7 @@ intptr_t JAMP_GameSupport::syscall(intptr_t cmd, ...) { intptr_t JAMP_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JAMP_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JAMP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; // store return value since we do some stuff after the function call is over intptr_t ret = 0; @@ -547,16 +541,14 @@ intptr_t JAMP_GameSupport::vmMain(intptr_t cmd, ...) { }; } -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JAMP_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JAMP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* JAMP_GameSupport::Entry(void* arg0, void* arg1, APIType engine) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JAMP_GameSupport::Entry({}, {}, {}) called\n", arg0, arg1, APIType_Name(engine)); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "JAMP_GameSupport::Entry(" << arg0 << ", " << arg1 << ", " << APIType_Name(engine) << ") called\n"; if (engine == QMM_API_GETMODULEAPI) { orig_apiversion = (intptr_t)arg0; @@ -568,7 +560,7 @@ void* JAMP_GameSupport::Entry(void* arg0, void* arg1, APIType engine) { // fill in variables of our hooked import struct to pass to the mod - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JAMP_GameSupport::Entry({}, {}, {}) returning {}\n", arg0, arg1, APIType_Name(engine), fmt::ptr(&qmm_export)); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "JAMP_GameSupport::Entry(" << arg0 << ", " << arg1 << ", " << APIType_Name(engine) << ") returning " << &qmm_export << "\n"; // struct full of export lambdas to QMM's vmMain // this gets returned to the game engine, but we haven't loaded the mod yet. @@ -578,7 +570,7 @@ void* JAMP_GameSupport::Entry(void* arg0, void* arg1, APIType engine) { // store original syscall from engine orig_syscall = (eng_syscall)arg0; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JAMP_GameSupport::Entry({}, {}, {}) returning\n", arg0, arg1, APIType_Name(engine)); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "JAMP_GameSupport::Entry(" << arg0 << ", " << arg1 << ", " << APIType_Name(engine) << ") returning\n"; return nullptr; } diff --git a/src/game_jasp.cpp b/src/game_jasp.cpp index a6825b1..e1557b8 100644 --- a/src/game_jasp.cpp +++ b/src/game_jasp.cpp @@ -14,7 +14,6 @@ Created By: #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" #include #include #include @@ -91,10 +90,9 @@ bool JASP_GameSupport::AutoDetect(APIType engineapi) { intptr_t JASP_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JASP_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JASP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; + // update export vars before calling into the engine update_exports(); @@ -323,10 +321,8 @@ intptr_t JASP_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JASP_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JASP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -337,9 +333,7 @@ intptr_t JASP_GameSupport::syscall(intptr_t cmd, ...) { intptr_t JASP_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JASP_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JASP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_export) return 0; @@ -377,16 +371,14 @@ intptr_t JASP_GameSupport::vmMain(intptr_t cmd, ...) { // update export vars after returning from the mod update_exports(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JASP_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JASP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* JASP_GameSupport::Entry(void* import, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JASP_GameSupport::Entry({}) called\n", import); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "JASP_GameSupport::Entry(" << import << ") called\n"; // original import struct from engine // the struct given by the engine goes out of scope after this returns so we have to copy the whole thing @@ -396,7 +388,7 @@ void* JASP_GameSupport::Entry(void* import, void*, APIType) { // fill in variables of our hooked import struct to pass to the mod qmm_import.VoiceVolume = orig_import.VoiceVolume; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JASP_GameSupport::Entry({}) returning {}\n", import, fmt::ptr(&qmm_export)); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "JASP_GameSupport::Entry(" << import << ") returning " << &qmm_export << "\n"; // struct full of export lambdas to QMM's vmMain // this gets returned to the game engine, but we haven't loaded the mod yet. diff --git a/src/game_jk2mp.cpp b/src/game_jk2mp.cpp index 6b45815..21f826c 100644 --- a/src/game_jk2mp.cpp +++ b/src/game_jk2mp.cpp @@ -14,7 +14,6 @@ Created By: #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" #include // QMM-specific JK2MP header #include "game_jk2mp.h" @@ -79,10 +78,9 @@ bool JK2MP_GameSupport::AutoDetect(APIType engineapi) { intptr_t JK2MP_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JK2MP_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JK2MP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; + intptr_t ret = 0; @@ -112,10 +110,8 @@ intptr_t JK2MP_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JK2MP_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JK2MP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -126,9 +122,7 @@ intptr_t JK2MP_GameSupport::syscall(intptr_t cmd, ...) { intptr_t JK2MP_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JK2MP_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JK2MP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_vmMain) return 0; @@ -141,7 +135,7 @@ intptr_t JK2MP_GameSupport::vmMain(intptr_t cmd, ...) { // original engine AND by OpenJK if (cmd == GAME_ROFF_NOTETRACK_CALLBACK && g_mod.vmbase && args[1]) { // G_ROFF_NotetrackCallback( &g_entities[arg0], (const char *)arg1 ); - int arg1len = strlen((char*)args[1]) + 1; + size_t arg1len = strlen((char*)args[1]) + 1; int arg1 = qvm_hunk_alloc(&g_mod.vm, arg1len, (void*)args[1]); ret = orig_vmMain(cmd, args[0], arg1); qvm_hunk_free(&g_mod.vm, arg1, arg1len, (void*)args[1]); @@ -156,21 +150,19 @@ intptr_t JK2MP_GameSupport::vmMain(intptr_t cmd, ...) { ret += g_mod.vmbase; } -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JK2MP_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JK2MP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* JK2MP_GameSupport::Entry(void* syscall, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JK2MP_GameSupport::Entry({}) called\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "JK2MP_GameSupport::Entry(" << syscall << ") called\n"; // store original syscall from engine orig_syscall = (eng_syscall)syscall; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JK2MP_GameSupport::Entry({}) returning\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "JK2MP_GameSupport::Entry(" << syscall << ") returning\n"; return nullptr; } @@ -459,9 +451,7 @@ const char* JK2MP_GameSupport::ModMsgName(intptr_t cmd) { // do NOT convert the "ghoul" void pointers, treat them as plain ints // for double pointers (gentity_t**, vec3_t*, void**), convert them once with vmptr() int JK2MP_GameSupport::QVMSyscall(uint8_t* membase, int cmd, int* args) { -#ifdef _DEBUG - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("JK2MP_GameSupport::QVMSyscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JK2MP_GameSupport::QVMSyscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; int ret = 0; @@ -784,9 +774,8 @@ int JK2MP_GameSupport::QVMSyscall(uint8_t* membase, int cmd, int* args) { ret = 0; } -#ifdef _DEBUG - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("JK2MP_GameSupport::QVMSyscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JK2MP_GameSupport::QVMSyscall(" << EngMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; + return ret; } diff --git a/src/game_jk2sp.cpp b/src/game_jk2sp.cpp index b53d3e4..ef329c4 100644 --- a/src/game_jk2sp.cpp +++ b/src/game_jk2sp.cpp @@ -13,7 +13,6 @@ Created By: #include #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" #include #include // QMM-specific JK2SP header @@ -90,10 +89,9 @@ bool JK2SP_GameSupport::AutoDetect(APIType engineapi) { intptr_t JK2SP_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JK2SP_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JK2SP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; + // update export vars before calling into the engine update_exports(); @@ -272,10 +270,8 @@ intptr_t JK2SP_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JK2SP_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JK2SP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -286,9 +282,7 @@ intptr_t JK2SP_GameSupport::syscall(intptr_t cmd, ...) { intptr_t JK2SP_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JK2SP_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JK2SP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_export) return 0; @@ -326,16 +320,14 @@ intptr_t JK2SP_GameSupport::vmMain(intptr_t cmd, ...) { // update export vars after returning from the mod update_exports(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JK2SP_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "JK2SP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* JK2SP_GameSupport::Entry(void* import, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JK2SP_GameSupport::Entry({}) called\n", import); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "JK2SP_GameSupport::Entry(" << import << ") called\n"; // original import struct from engine // the struct given by the engine goes out of scope after this returns so we have to copy the whole thing @@ -345,7 +337,7 @@ void* JK2SP_GameSupport::Entry(void* import, void*, APIType) { // fill in variables of our hooked import struct to pass to the mod qmm_import.VoiceVolume = orig_import.VoiceVolume; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("JK2SP_GameSupport::Entry({}) returning {}\n", import, fmt::ptr(&qmm_export)); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "JK2SP_GameSupport::Entry(" << import << ") returning " << &qmm_export << "\n"; // struct full of export lambdas to QMM's vmMain // this gets returned to the game engine, but we haven't loaded the mod yet. diff --git a/src/game_mohaa.cpp b/src/game_mohaa.cpp index d811565..e65245d 100644 --- a/src/game_mohaa.cpp +++ b/src/game_mohaa.cpp @@ -98,10 +98,9 @@ bool MOHAA_GameSupport::AutoDetect(APIType engineapi) { intptr_t MOHAA_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHAA_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "MOHAA_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; + // update export vars before calling into the engine update_exports(); @@ -427,10 +426,8 @@ intptr_t MOHAA_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHAA_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "MOHAA_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -441,9 +438,7 @@ intptr_t MOHAA_GameSupport::syscall(intptr_t cmd, ...) { intptr_t MOHAA_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHAA_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "MOHAA_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_export) return 0; @@ -503,16 +498,14 @@ intptr_t MOHAA_GameSupport::vmMain(intptr_t cmd, ...) { // update export vars after returning from the mod update_exports(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHAA_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "MOHAA_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* MOHAA_GameSupport::Entry(void* import, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHAA_GameSupport::Entry({}) called\n", import); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "MOHAA_GameSupport::Entry(" << import << ") called\n"; // original import struct from engine // the struct given by the engine goes out of scope after this returns so we have to copy the whole thing @@ -526,7 +519,7 @@ void* MOHAA_GameSupport::Entry(void* import, void*, APIType) { qmm_import.numDebugStrings = orig_import.numDebugStrings; qmm_import.fsDebug = orig_import.fsDebug; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHAA_GameSupport::Entry({}) returning {}\n", import, fmt::ptr(&qmm_export)); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "MOHAA_GameSupport::Entry(" << import << ") returning " << &qmm_export << "\n"; // struct full of export lambdas to QMM's vmMain // this gets returned to the game engine, but we haven't loaded the mod yet. diff --git a/src/game_mohbt.cpp b/src/game_mohbt.cpp index 4c55072..aa8329b 100644 --- a/src/game_mohbt.cpp +++ b/src/game_mohbt.cpp @@ -97,10 +97,8 @@ bool MOHBT_GameSupport::AutoDetect(APIType engineapi) { intptr_t MOHBT_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHBT_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "MOHBT_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; // update export vars before calling into the engine update_exports(); @@ -457,10 +455,8 @@ intptr_t MOHBT_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHBT_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "MOHBT_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -471,9 +467,7 @@ intptr_t MOHBT_GameSupport::syscall(intptr_t cmd, ...) { intptr_t MOHBT_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHBT_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "MOHBT_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_export) return 0; @@ -533,16 +527,14 @@ intptr_t MOHBT_GameSupport::vmMain(intptr_t cmd, ...) { // update export vars after returning from the mod update_exports(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHBT_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "MOHBT_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* MOHBT_GameSupport::Entry(void* import, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHBT_GameSupport::Entry({}) called\n", import); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "MOHBT_GameSupport::Entry(" << import << ") called\n"; // original import struct from engine // the struct given by the engine goes out of scope after this returns so we have to copy the whole thing @@ -556,7 +548,7 @@ void* MOHBT_GameSupport::Entry(void* import, void*, APIType) { qmm_import.numDebugStrings = orig_import.numDebugStrings; qmm_import.fsDebug = orig_import.fsDebug; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHBT_GameSupport::Entry({}) returning {}\n", import, fmt::ptr(&qmm_export)); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "MOHBT_GameSupport::Entry(" << import << ") returning " << &qmm_export << "\n"; // struct full of export lambdas to QMM's vmMain // this gets returned to the game engine, but we haven't loaded the mod yet. diff --git a/src/game_mohsh.cpp b/src/game_mohsh.cpp index c93fd0f..beccdb6 100644 --- a/src/game_mohsh.cpp +++ b/src/game_mohsh.cpp @@ -97,10 +97,8 @@ bool MOHSH_GameSupport::AutoDetect(APIType engineapi) { intptr_t MOHSH_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHSH_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "MOHSH_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; // update export vars before calling into the engine update_exports(); @@ -457,10 +455,8 @@ intptr_t MOHSH_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHSH_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "MOHSH_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -471,9 +467,7 @@ intptr_t MOHSH_GameSupport::syscall(intptr_t cmd, ...) { intptr_t MOHSH_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHSH_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "MOHSH_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_export) return 0; @@ -533,16 +527,14 @@ intptr_t MOHSH_GameSupport::vmMain(intptr_t cmd, ...) { // update export vars after returning from the mod update_exports(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHSH_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "MOHSH_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* MOHSH_GameSupport::Entry(void* import, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHSH_GameSupport::Entry({}) called\n", import); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "MOHSH_GameSupport::Entry(" << import << ") called\n"; // original import struct from engine // the struct given by the engine goes out of scope after this returns so we have to copy the whole thing @@ -556,7 +548,7 @@ void* MOHSH_GameSupport::Entry(void* import, void*, APIType) { qmm_import.numDebugStrings = orig_import.numDebugStrings; qmm_import.fsDebug = orig_import.fsDebug; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("MOHSH_GameSupport::Entry({}) returning {}\n", import, fmt::ptr(&qmm_export)); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "MOHSH_GameSupport::Entry(" << import << ") returning " << &qmm_export << "\n"; // struct full of export lambdas to QMM's vmMain // this gets returned to the game engine, but we haven't loaded the mod yet. diff --git a/src/game_q2r.cpp b/src/game_q2r.cpp index 9cb2271..e7584b7 100644 --- a/src/game_q2r.cpp +++ b/src/game_q2r.cpp @@ -109,10 +109,8 @@ bool Q2R_GameSupport::AutoDetect(APIType engineapi) { intptr_t Q2R_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Q2R_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Q2R_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; // update export vars before calling into the engine update_exports(); @@ -348,10 +346,8 @@ intptr_t Q2R_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Q2R_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Q2R_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -362,9 +358,7 @@ intptr_t Q2R_GameSupport::syscall(intptr_t cmd, ...) { intptr_t Q2R_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Q2R_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Q2R_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_export) return 0; @@ -417,16 +411,14 @@ intptr_t Q2R_GameSupport::vmMain(intptr_t cmd, ...) { // update export vars after returning from the mod update_exports(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Q2R_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Q2R_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* Q2R_GameSupport::Entry(void* import, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Q2R_GameSupport::Entry({}) called\n", import); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "Q2R_GameSupport::Entry(" << import << ") called\n"; // original import struct from engine // the struct given by the engine goes out of scope after this returns so we have to copy the whole thing @@ -438,7 +430,7 @@ void* Q2R_GameSupport::Entry(void* import, void*, APIType) { qmm_import.frame_time_s = orig_import.frame_time_s; qmm_import.frame_time_ms = orig_import.frame_time_ms; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Q2R_GameSupport::Entry({}) returning {}\n", import, fmt::ptr(&qmm_export)); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "Q2R_GameSupport::Entry(" << import << ") returning " << &qmm_export << "\n"; // struct full of export lambdas to QMM's vmMain // this gets returned to the game engine, but we haven't loaded the mod yet. diff --git a/src/game_q3a.cpp b/src/game_q3a.cpp index a4519d9..9a76f39 100644 --- a/src/game_q3a.cpp +++ b/src/game_q3a.cpp @@ -14,7 +14,6 @@ Created By: #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" #include // QMM-specific Q3A header #include "game_q3a.h" @@ -79,10 +78,8 @@ bool Q3A_GameSupport::AutoDetect(APIType engine_api) { intptr_t Q3A_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Q3A_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Q3A_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; intptr_t ret = 0; @@ -111,10 +108,8 @@ intptr_t Q3A_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Q3A_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Q3A_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -125,9 +120,7 @@ intptr_t Q3A_GameSupport::syscall(intptr_t cmd, ...) { intptr_t Q3A_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Q3A_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Q3A_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_vmMain) return 0; @@ -144,21 +137,19 @@ intptr_t Q3A_GameSupport::vmMain(intptr_t cmd, ...) { ret += g_mod.vmbase; } -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Q3A_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Q3A_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* Q3A_GameSupport::Entry(void* syscall, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Q3A_GameSupport::Entry({}) called\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "Q3A_GameSupport::Entry(" << syscall << ") called\n"; // store original syscall from engine orig_syscall = (eng_syscall)syscall; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Q3A_GameSupport::Entry({}) returning\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "Q3A_GameSupport::Entry(" << syscall << ") returning\n"; return nullptr; } @@ -415,9 +406,8 @@ const char* Q3A_GameSupport::ModMsgName(intptr_t cmd) { // vec3_t are arrays, so convert them as pointers // for double pointers (gentity_t** and vec3_t*), convert them once with vmptr() int Q3A_GameSupport::QVMSyscall(uint8_t* membase, int cmd, int* args) { -#ifdef _DEBUG - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("Q3A_GameSupport::QVMSyscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Q3A_GameSupport::QVMSyscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; + intptr_t ret = 0; @@ -700,9 +690,8 @@ int Q3A_GameSupport::QVMSyscall(uint8_t* membase, int cmd, int* args) { ret = 0; } -#ifdef _DEBUG - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("Q3A_GameSupport::QVMSyscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Q3A_GameSupport::QVMSyscall(" << EngMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; + return ret; } diff --git a/src/game_quake2.cpp b/src/game_quake2.cpp index 840c5ee..e31c6e9 100644 --- a/src/game_quake2.cpp +++ b/src/game_quake2.cpp @@ -102,10 +102,8 @@ bool QUAKE2_GameSupport::AutoDetect(APIType engineapi) { intptr_t QUAKE2_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("QUAKE2_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "QUAKE2_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; // update export vars before calling into the engine update_exports(); @@ -331,10 +329,9 @@ intptr_t QUAKE2_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("QUAKE2_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "QUAKE2_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; + return ret; } @@ -345,9 +342,7 @@ intptr_t QUAKE2_GameSupport::syscall(intptr_t cmd, ...) { intptr_t QUAKE2_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("QUAKE2_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "QUAKE2_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_export) return 0; @@ -386,16 +381,14 @@ intptr_t QUAKE2_GameSupport::vmMain(intptr_t cmd, ...) { // update export vars after returning from the mod update_exports(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("QUAKE2_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "QUAKE2_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* QUAKE2_GameSupport::Entry(void* import, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("QUAKE2_GameSupport::Entry({}) called\n", import); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "QUAKE2_GameSupport::Entry(" << import << ") called\n"; // original import struct from engine // the struct given by the engine goes out of scope after this returns so we have to copy the whole thing @@ -405,7 +398,7 @@ void* QUAKE2_GameSupport::Entry(void* import, void*, APIType) { // fill in variables of our hooked import struct to pass to the mod // qmm_import.x = orig_import.x; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("QUAKE2_GameSupport::Entry({}) returning {}\n", import, fmt::ptr(&qmm_export)); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "QUAKE2_GameSupport::Entry(" << import << ") returning " << &qmm_export << "\n"; // struct full of export lambdas to QMM's vmMain // this gets returned to the game engine, but we haven't loaded the mod yet. diff --git a/src/game_rtcwmp.cpp b/src/game_rtcwmp.cpp index 1543c7c..5dfacfd 100644 --- a/src/game_rtcwmp.cpp +++ b/src/game_rtcwmp.cpp @@ -14,7 +14,6 @@ Created By: #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" #include // QMM-specific RTCWMP header #include "game_rtcwmp.h" @@ -78,10 +77,8 @@ bool RTCWMP_GameSupport::AutoDetect(APIType engineapi) { intptr_t RTCWMP_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("RTCWMP_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "RTCWMP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; intptr_t ret = 0; @@ -111,10 +108,8 @@ intptr_t RTCWMP_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("RTCWMP_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "RTCWMP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -125,9 +120,7 @@ intptr_t RTCWMP_GameSupport::syscall(intptr_t cmd, ...) { intptr_t RTCWMP_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("RTCWMP_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "RTCWMP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_vmMain) return 0; @@ -154,7 +147,7 @@ intptr_t RTCWMP_GameSupport::vmMain(intptr_t cmd, ...) { } else if (cmd == GAME_RETRIEVE_MOVESPEEDS_FROM_CLIENT && g_mod.vmbase && args[1]) { // G_RetrieveMoveSpeedsFromClient( arg0, (char *)arg1 ); - int arg1len = strlen((char*)args[1]) + 1; + size_t arg1len = strlen((char*)args[1]) + 1; int arg1 = qvm_hunk_alloc(&g_mod.vm, arg1len, (void*)args[1]); ret = orig_vmMain(cmd, args[0], arg1); qvm_hunk_free(&g_mod.vm, arg1, arg1len, (void*)args[1]); @@ -170,21 +163,19 @@ intptr_t RTCWMP_GameSupport::vmMain(intptr_t cmd, ...) { ret += g_mod.vmbase; } -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("RTCWMP_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "RTCWMP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* RTCWMP_GameSupport::Entry(void* syscall, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("RTCWMP_GameSupport::Entry({}) called\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "RTCWMP_GameSupport::Entry(" << syscall << ") called\n"; // store original syscall from engine orig_syscall = (eng_syscall)syscall; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("RTCWMP_GameSupport::Entry({}) returning\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "RTCWMP_GameSupport::Entry(" << syscall << ") returning\n"; return nullptr; } @@ -455,9 +446,8 @@ const char* RTCWMP_GameSupport::ModMsgName(intptr_t cmd) { // vec3_t are arrays, so convert them as pointers // for double pointers (gentity_t** and vec3_t*), convert them once with vmptr() int RTCWMP_GameSupport::QVMSyscall(uint8_t* membase, int cmd, int* args) { -#ifdef _DEBUG - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("RTCWMP_GameSupport::QVMSyscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "RTCWMP_GameSupport::QVMSyscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; + intptr_t ret = 0; @@ -752,9 +742,8 @@ int RTCWMP_GameSupport::QVMSyscall(uint8_t* membase, int cmd, int* args) { ret = 0; } -#ifdef _DEBUG - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("RTCWMP_GameSupport::QVMSyscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "RTCWMP_GameSupport::QVMSyscall(" << EngMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; + return ret; } diff --git a/src/game_rtcwsp.cpp b/src/game_rtcwsp.cpp index 74919ab..fc5d2b3 100644 --- a/src/game_rtcwsp.cpp +++ b/src/game_rtcwsp.cpp @@ -14,7 +14,6 @@ Created By: #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" #include #include // QMM-specific RTCWSP header @@ -95,10 +94,8 @@ bool RTCWSP_GameSupport::AutoDetect(APIType engineapi) { intptr_t RTCWSP_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("RTCWSP_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "RTCWSP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; intptr_t ret = 0; @@ -140,10 +137,9 @@ intptr_t RTCWSP_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("RTCWSP_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "RTCWSP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; + return ret; } @@ -154,9 +150,7 @@ intptr_t RTCWSP_GameSupport::syscall(intptr_t cmd, ...) { intptr_t RTCWSP_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("RTCWSP_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "RTCWSP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_vmMain) return 0; @@ -167,21 +161,19 @@ intptr_t RTCWSP_GameSupport::vmMain(intptr_t cmd, ...) { // all normal mod functions go to vmMain ret = orig_vmMain(cmd, QMM_PUT_VMMAIN_ARGS()); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("RTCWSP_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "RTCWSP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* RTCWSP_GameSupport::Entry(void* syscall, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("RTCWSP_GameSupport::Entry({}) called\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "RTCWSP_GameSupport::Entry(" << syscall << ") called\n"; // store original syscall from engine orig_syscall = (eng_syscall)syscall; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("RTCWSP_GameSupport::Entry({}) returning\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "RTCWSP_GameSupport::Entry(" << syscall << ") returning\n"; return nullptr; } diff --git a/src/game_sin.cpp b/src/game_sin.cpp index fc72774..cfc632c 100644 --- a/src/game_sin.cpp +++ b/src/game_sin.cpp @@ -106,10 +106,8 @@ bool SIN_GameSupport::AutoDetect(APIType engineapi) { intptr_t SIN_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SIN_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "SIN_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; // update export vars before calling into the engine update_exports(); @@ -376,10 +374,9 @@ intptr_t SIN_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SIN_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "SIN_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; + return ret; } @@ -390,9 +387,7 @@ intptr_t SIN_GameSupport::syscall(intptr_t cmd, ...) { intptr_t SIN_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SIN_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "SIN_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_export) return 0; @@ -441,16 +436,14 @@ intptr_t SIN_GameSupport::vmMain(intptr_t cmd, ...) { // update export vars after returning from the mod update_exports(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SIN_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "SIN_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* SIN_GameSupport::Entry(void* import, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SIN_GameSupport::Entry({}) called\n", import); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "SIN_GameSupport::Entry(" << import << ") called\n"; // original import struct from engine // the struct given by the engine goes out of scope after this returns so we have to copy the whole thing @@ -461,7 +454,7 @@ void* SIN_GameSupport::Entry(void* import, void*, APIType) { qmm_import.DebugLines = orig_import.DebugLines; qmm_import.numDebugLines = orig_import.numDebugLines; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SIN_GameSupport::Entry({}) returning {}\n", import, fmt::ptr(&qmm_export)); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "SIN_GameSupport::Entry(" << import << ") returning " << &qmm_export << "\n"; // struct full of export lambdas to QMM's vmMain // this gets returned to the game engine, but we haven't loaded the mod yet. diff --git a/src/game_sof2mp.cpp b/src/game_sof2mp.cpp index c10c938..121cad0 100644 --- a/src/game_sof2mp.cpp +++ b/src/game_sof2mp.cpp @@ -19,7 +19,6 @@ Created By: #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" #include // QMM-specific SOF2MP header #include "game_sof2mp.h" @@ -83,10 +82,8 @@ bool SOF2MP_GameSupport::AutoDetect(APIType engineapi) { intptr_t SOF2MP_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SOF2MP_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "SOF2MP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; intptr_t ret = 0; @@ -117,10 +114,8 @@ intptr_t SOF2MP_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SOF2MP_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "SOF2MP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -131,9 +126,7 @@ intptr_t SOF2MP_GameSupport::syscall(intptr_t cmd, ...) { intptr_t SOF2MP_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SOF2MP_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "SOF2MP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_vmMain) return 0; @@ -246,21 +239,19 @@ intptr_t SOF2MP_GameSupport::vmMain(intptr_t cmd, ...) { ret += g_mod.vmbase; } -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SOF2MP_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "SOF2MP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* SOF2MP_GameSupport::Entry(void* syscall, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SOF2MP_GameSupport::Entry({}) called\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "SOF2MP_GameSupport::Entry(" << syscall << ") called\n"; // store original syscall from engine orig_syscall = (eng_syscall)syscall; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SOF2MP_GameSupport::Entry({}) returning\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "SOF2MP_GameSupport::Entry(" << syscall << ") returning\n"; return nullptr; } @@ -587,9 +578,8 @@ const char* SOF2MP_GameSupport::ModMsgName(intptr_t cmd) { // TGPValue, TGPGroup, and TGenericParser2 are void*, but treat them as plain ints // for double pointers (gentity_t**, vec3_t*, void**), convert them once with vmptr() int SOF2MP_GameSupport::QVMSyscall(uint8_t* membase, int cmd, int* args) { -#ifdef _DEBUG - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("SOF2MP_GameSupport::QVMSyscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "SOF2MP_GameSupport::QVMSyscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; + int ret = 0; @@ -972,9 +962,7 @@ int SOF2MP_GameSupport::QVMSyscall(uint8_t* membase, int cmd, int* args) { ret = 0; } -#ifdef _DEBUG - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("SOF2MP_GameSupport::QVMSyscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "SOF2MP_GameSupport::QVMSyscall(" << EngMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } diff --git a/src/game_sof2sp.cpp b/src/game_sof2sp.cpp index 3925d07..ff2baa0 100644 --- a/src/game_sof2sp.cpp +++ b/src/game_sof2sp.cpp @@ -17,7 +17,6 @@ Created By: #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" // QMM-specific SOF2SP header #include "game_sof2sp.h" #include "gameinfo.hpp" @@ -88,10 +87,8 @@ bool SOF2SP_GameSupport::AutoDetect(APIType engineapi) { intptr_t SOF2SP_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SOF2SP_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "SOF2SP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; // update export vars before calling into the engine update_exports(); @@ -250,10 +247,9 @@ intptr_t SOF2SP_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SOF2SP_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "SOF2SP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; + return ret; } @@ -264,9 +260,8 @@ intptr_t SOF2SP_GameSupport::syscall(intptr_t cmd, ...) { intptr_t SOF2SP_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SOF2SP_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "SOF2SP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; + if (!orig_export) return 0; @@ -310,9 +305,7 @@ intptr_t SOF2SP_GameSupport::vmMain(intptr_t cmd, ...) { // update export vars after returning from the mod update_exports(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SOF2SP_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "SOF2SP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } @@ -320,7 +313,7 @@ intptr_t SOF2SP_GameSupport::vmMain(intptr_t cmd, ...) { void* SOF2SP_GameSupport::Entry(void* apiversion, void* import, APIType) { orig_apiversion = (intptr_t)apiversion; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SOF2SP_GameSupport::Entry({}, {}) called\n", orig_apiversion, import); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "SOF2SP_GameSupport::Entry(" << orig_apiversion << ", " << import << ") called\n"; // original import struct from engine // the struct given by the engine goes out of scope after this returns so we have to copy the whole thing @@ -330,7 +323,7 @@ void* SOF2SP_GameSupport::Entry(void* apiversion, void* import, APIType) { // fill in variables of our hooked import struct to pass to the mod // qmm_import.unknown = orig_import.unknown; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("SOF2SP_Entry({}, {}) returning {}\n", orig_apiversion, import, fmt::ptr(&qmm_export)); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "SOF2SP_GameSupport::Entry(" << orig_apiversion << ", " << import << ") returning " << &qmm_export << "\n"; // struct full of export lambdas to QMM's vmMain // this gets returned to the game engine, but we haven't loaded the mod yet. diff --git a/src/game_stef2.cpp b/src/game_stef2.cpp index 6c9f919..3e86662 100644 --- a/src/game_stef2.cpp +++ b/src/game_stef2.cpp @@ -20,7 +20,6 @@ Created By: #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" #include #include // QMM-specific STEF2 header @@ -95,10 +94,8 @@ bool STEF2_GameSupport::AutoDetect(APIType engineapi) { intptr_t STEF2_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STEF2_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "STEF2_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; // update export vars before calling into the engine update_exports(); @@ -488,10 +485,9 @@ intptr_t STEF2_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STEF2_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "STEF2_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; + return ret; } @@ -502,9 +498,7 @@ intptr_t STEF2_GameSupport::syscall(intptr_t cmd, ...) { intptr_t STEF2_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STEF2_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "STEF2_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_export) return 0; @@ -560,16 +554,14 @@ intptr_t STEF2_GameSupport::vmMain(intptr_t cmd, ...) { // update export vars after returning from the mod update_exports(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STEF2_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "STEF2_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* STEF2_GameSupport::Entry(void* import, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STEF2_GameSupport::Entry({}) called\n", import); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "STEF2_GameSupport::Entry(" << import << ") called\n"; // original import struct from engine // the struct given by the engine goes out of scope after this returns so we have to copy the whole thing @@ -580,7 +572,7 @@ void* STEF2_GameSupport::Entry(void* import, void*, APIType) { qmm_import.DebugLines = orig_import.DebugLines; qmm_import.numDebugLines = orig_import.numDebugLines; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STEF2_GameSupport::Entry({}) returning {}\n", import, fmt::ptr(&qmm_export)); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "STEF2_GameSupport::Entry(" << import << ") returning " << &qmm_export << "\n"; // struct full of export lambdas to QMM's vmMain // this gets returned to the game engine, but we haven't loaded the mod yet. diff --git a/src/game_stvoyhm.cpp b/src/game_stvoyhm.cpp index 5abe555..7ce6fc2 100644 --- a/src/game_stvoyhm.cpp +++ b/src/game_stvoyhm.cpp @@ -18,7 +18,6 @@ Created By: #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" #include // QMM-specific STVOYHM header #include "game_stvoyhm.h" @@ -82,10 +81,8 @@ bool STVOYHM_GameSupport::AutoDetect(APIType engineapi) { intptr_t STVOYHM_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STVOYHM_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "STVOYHM_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; intptr_t ret = 0; @@ -115,10 +112,8 @@ intptr_t STVOYHM_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STVOYHM_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "STVOYHM_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -129,9 +124,7 @@ intptr_t STVOYHM_GameSupport::syscall(intptr_t cmd, ...) { intptr_t STVOYHM_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STVOYHM_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "STVOYHM_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_vmMain) return 0; @@ -148,21 +141,19 @@ intptr_t STVOYHM_GameSupport::vmMain(intptr_t cmd, ...) { ret += g_mod.vmbase; } -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STVOYHM_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "STVOYHM_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* STVOYHM_GameSupport::Entry(void* syscall, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STVOYHM_GameSupport::Entry({}) called\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "STVOYHM_GameSupport::Entry(" << syscall << ") called\n"; // store original syscall from engine orig_syscall = (eng_syscall)syscall; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STVOYHM_GameSupport::Entry({}) returning\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "STVOYHM_GameSupport::Entry(" << syscall << ") returning\n"; return nullptr; } @@ -410,9 +401,8 @@ const char* STVOYHM_GameSupport::ModMsgName(intptr_t cmd) { // vec3_t are arrays, so convert them as pointers // for double pointers (gentity_t** and vec3_t*), convert them once with vmptr() int STVOYHM_GameSupport::QVMSyscall(uint8_t* membase, int cmd, int* args) { -#ifdef _DEBUG - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("STVOYHM_GameSupport::QVMSyscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "STVOYHM_GameSupport::QVMSyscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; + int ret = 0; @@ -675,9 +665,7 @@ int STVOYHM_GameSupport::QVMSyscall(uint8_t* membase, int cmd, int* args) { ret = 0; } -#ifdef _DEBUG - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("STVOYHM_GameSupport::QVMSyscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "STVOYHM_GameSupport::QVMSyscall(" << EngMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } diff --git a/src/game_stvoysp.cpp b/src/game_stvoysp.cpp index d5eded7..c6699eb 100644 --- a/src/game_stvoysp.cpp +++ b/src/game_stvoysp.cpp @@ -18,7 +18,6 @@ Created By: #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" #include #include // QMM-specific STVOYSP header @@ -95,10 +94,8 @@ bool STVOYSP_GameSupport::AutoDetect(APIType engineapi) { intptr_t STVOYSP_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STVOYSP_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "STVOYSP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; // update export vars before calling into the engine update_exports(); @@ -216,10 +213,8 @@ intptr_t STVOYSP_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STVOYSP_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "STVOYSP_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -230,9 +225,7 @@ intptr_t STVOYSP_GameSupport::syscall(intptr_t cmd, ...) { intptr_t STVOYSP_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STVOYSP_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "STVOYSP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_export) return 0; @@ -268,16 +261,14 @@ intptr_t STVOYSP_GameSupport::vmMain(intptr_t cmd, ...) { // update export vars after returning from the mod update_exports(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STVOYSP_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "STVOYSP_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* STVOYSP_GameSupport::Entry(void* import, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STVOYSP_GameSupport::Entry({}) called\n", import); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "STVOYSP_GameSupport::Entry(" << import << ") called\n"; // original import struct from engine // the struct given by the engine goes out of scope after this returns so we have to copy the whole thing @@ -287,7 +278,7 @@ void* STVOYSP_GameSupport::Entry(void* import, void*, APIType) { // fill in variables of our hooked import struct to pass to the mod qmm_import.S_Override = orig_import.S_Override; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("STVOYSP_GameSupport::Entry({}) returning {}\n", import, fmt::ptr(&qmm_export)); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "STVOYSP_GameSupport::Entry(" << import << ") returning " << &qmm_export << "\n"; // struct full of export lambdas to QMM's vmMain // this gets returned to the game engine, but we haven't loaded the mod yet. diff --git a/src/game_wet.cpp b/src/game_wet.cpp index 7f952b1..c757738 100644 --- a/src/game_wet.cpp +++ b/src/game_wet.cpp @@ -14,7 +14,6 @@ Created By: #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" #include // QMM-specific WET header #include "game_wet.h" @@ -74,10 +73,9 @@ bool WET_GameSupport::AutoDetect(APIType engineapi) { intptr_t WET_GameSupport::syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("WET_GameSupport::syscall({} {}) called\n", EngMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "WET_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) called\n"; + intptr_t ret = 0; @@ -107,10 +105,8 @@ intptr_t WET_GameSupport::syscall(intptr_t cmd, ...) { // do anything that needs to be done after function call here -#ifdef _DEBUG if (cmd != G_PRINT) - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("WET_GameSupport::syscall({} {}) returning {}\n", EngMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "WET_GameSupport::syscall(" << EngMsgName(cmd) << "(" << cmd << ")) reutrning " << ret << "\n"; return ret; } @@ -121,9 +117,7 @@ intptr_t WET_GameSupport::syscall(intptr_t cmd, ...) { intptr_t WET_GameSupport::vmMain(intptr_t cmd, ...) { QMM_GET_VMMAIN_ARGS(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("WET_GameSupport::vmMain({} {}) called\n", ModMsgName(cmd), cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "WET_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (!orig_vmMain) return 0; @@ -134,21 +128,19 @@ intptr_t WET_GameSupport::vmMain(intptr_t cmd, ...) { // all normal mod functions go to vmMain ret = orig_vmMain(cmd, QMM_PUT_VMMAIN_ARGS()); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("WET_GameSupport::vmMain({} {}) returning {}\n", ModMsgName(cmd), cmd, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "WET_GameSupport::vmMain(" << ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } void* WET_GameSupport::Entry(void* syscall, void*, APIType) { - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("WET_GameSupport::Entry({}) called\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "WET_GameSupport::Entry(" << syscall << ") called\n"; // store original syscall from engine orig_syscall = (eng_syscall)syscall; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("WET_GameSupport::Entry({}) returning\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "WET_GameSupport::Entry(" << syscall << ") returning\n"; return nullptr; } diff --git a/src/gameinfo.cpp b/src/gameinfo.cpp index 15eb357..b255c29 100644 --- a/src/gameinfo.cpp +++ b/src/gameinfo.cpp @@ -90,14 +90,14 @@ void* GameInfo::HandleEntry(void* import, void* extra, APIType engine) { log_init(fmt::format("{}/qmm2.log", this->qmm_dir)); - LOG(QMM_LOG_NOTICE, "QMM") << fmt::format("QMM v" QMM_VERSION " (" QMM_OS " " QMM_ARCH ") ({}) loaded!\n", APIType_Function(engine)); - LOG(QMM_LOG_INFO, "QMM") << fmt::format("QMM path: \"{}\"\n", this->qmm_path); - LOG(QMM_LOG_INFO, "QMM") << fmt::format("Engine path: \"{}\"\n", this->exe_path); - LOG(QMM_LOG_INFO, "QMM") << fmt::format("Mod directory (?): \"{}\"\n", this->mod_dir); + QMMLOG(QMM_LOG_NOTICE, "QMM") << "QMM v" QMM_VERSION " (" QMM_OS " " QMM_ARCH ") (" << APIType_Function(engine) << ") loaded!\n"; + QMMLOG(QMM_LOG_INFO, "QMM") << "QMM path: \"" << this->qmm_path << "\"\n"; + QMMLOG(QMM_LOG_INFO, "QMM") << "Engine path: \"" << this->exe_path << "\"\n"; + QMMLOG(QMM_LOG_INFO, "QMM") << "Mod directory (?): \"" << this->mod_dir << "\"\n"; // syscall, import, or apiversion are null/0 if (!import) { - LOG(QMM_LOG_FATAL, "QMM") << fmt::format("{}(): engine pointer is NULL!\n", APIType_Function(engine)); + QMMLOG(QMM_LOG_FATAL, "QMM") << APIType_Function(engine) << "(): engine pointer is NULL!\n"; return nullptr; } @@ -115,7 +115,7 @@ void* GameInfo::HandleEntry(void* import, void* extra, APIType engine) { cfg_game = util_get_cmdline_arg("--qmm_game", cfg_game); // failed to get engine information if (!this->DetectGame(cfg_game, engine) || !this->game) { - LOG(QMM_LOG_FATAL, "QMM") << fmt::format("{}(): Unable to determine game engine using \"{}\"\n", APIType_Function(engine), cfg_game); + QMMLOG(QMM_LOG_FATAL, "QMM") << APIType_Function(engine) << "(): Unable to determine game engine using \"" << cfg_game << "\"\n"; return nullptr; } @@ -184,13 +184,13 @@ void GameInfo::LoadConfig(std::string config_filename) { g_cfg = cfg_load(try_path); if (!g_cfg.empty()) { this->cfg_path = try_path; - LOG(QMM_LOG_NOTICE, "QMM") << fmt::format("Config file found! Path: \"{}\"\n", this->cfg_path); + QMMLOG(QMM_LOG_NOTICE, "QMM") << "Config file found! Path: \"" << this->cfg_path << "\"\n"; return; } } // a default constructed json object is a blank {}, so in case of load failure, we can still try to read from it and assume defaults - LOG(QMM_LOG_WARNING, "QMM") << fmt::format("GameInfo::LoadConfig(): Unable to load config file \"{}\", all settings will use default values\n", config_filename); + QMMLOG(QMM_LOG_WARNING, "QMM") << "GameInfo::LoadConfig(): Unable to load config file \"" << config_filename << "\", all settings will use default values\n"; } @@ -205,7 +205,7 @@ bool GameInfo::DetectGame(std::string cfg_game, APIType engine) { for (GameSupport* gamesupport : api_supportedgames) { // if short name matches config option, we found it! if (!is_auto && str_striequal(cfg_game, gamesupport->GameCode())) { - LOG(QMM_LOG_NOTICE, "QMM") << fmt::format("Found game match for config option \"{}\"\n", cfg_game); + QMMLOG(QMM_LOG_INFO, "QMM") << "Found game match for config option \"" << cfg_game << "\"\n"; this->game = gamesupport; this->is_auto_detected = false; // call the game's auto-detect function, since it may do some logic @@ -214,7 +214,7 @@ bool GameInfo::DetectGame(std::string cfg_game, APIType engine) { } // otherwise, if auto, call the game's auto-detect function else if (is_auto && gamesupport->AutoDetect(engine)) { - LOG(QMM_LOG_INFO, "QMM") << fmt::format("Found game match with auto-detection - \"{}\"\n", gamesupport->GameCode()); + QMMLOG(QMM_LOG_INFO, "QMM") << "Found game match with auto-detection - \"" << gamesupport->GameCode() << "\"\n"; this->game = gamesupport; this->is_auto_detected = true; return true; @@ -230,10 +230,10 @@ bool GameInfo::LoadMod(std::string cfg_mod) { if (cfg_mod.empty()) cfg_mod = "auto"; - LOG(QMM_LOG_INFO, "QMM") << fmt::format("Attempting to find mod using \"{}\"\n", cfg_mod); + QMMLOG(QMM_LOG_INFO, "QMM") << "Attempting to find mod using \"" << cfg_mod << "\"\n"; // if "mod" config setting is an absolute path, just attempt to load it directly if (!str_striequal(cfg_mod, "auto") && path_is_absolute(cfg_mod)) { - LOG(QMM_LOG_INFO, "QMM") << fmt::format("Attempting to load mod \"{}\"\n", cfg_mod); + QMMLOG(QMM_LOG_INFO, "QMM") << "Attempting to load mod \"" << cfg_mod << "\"\n"; return g_mod.Load(cfg_mod); } // if "mod" config setting is "auto", try the following locations in order: @@ -264,7 +264,7 @@ bool GameInfo::LoadMod(std::string cfg_mod) { try_path = path_normalize(try_path); if (try_path.empty() || !path_is_allowed(try_path)) continue; - LOG(QMM_LOG_INFO, "QMM") << fmt::format("Attempting to load mod \"{}\"\n", try_path); + QMMLOG(QMM_LOG_INFO, "QMM") << "Attempting to load mod \"" << try_path << "\"\n"; if (g_mod.Load(try_path)) return true; } @@ -312,7 +312,7 @@ bool GameInfo::LoadPlugin(std::string plugin_path) { // route syscall or vmMain call to plugins and mod -intptr_t GameInfo::Route(bool is_syscall, intptr_t cmd, intptr_t* args) { +intptr_t GameInfo::Route(bool is_syscall, intptr_t cmd, intptr_t* args) const { const char* msg_name; const char* func_name; GameSupport* gamesupport = this->game; @@ -344,9 +344,7 @@ intptr_t GameInfo::Route(bool is_syscall, intptr_t cmd, intptr_t* args) { // allow plugins to see the current final_ret value g_plugin_globals.final_return = final_ret; -#ifdef _DEBUG - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("Plugin {} QMM_{}({} {}) called\n", p.plugininfo->name, func_name, msg_name, cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << p.plugininfo->name << "\" QMM_" << func_name << "( " << msg_name << "(" << cmd << ")) called\n"; // call plugin's pre-hook and store return value if (is_syscall) @@ -354,44 +352,38 @@ intptr_t GameInfo::Route(bool is_syscall, intptr_t cmd, intptr_t* args) { else plugin_ret = p.QMM_vmMain(cmd, args); -#ifdef _DEBUG - if (g_plugin_globals.plugin_result != QMM_IGNORED) - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("Plugin {} QMM_{}({} {}) returning {} with result {}\n", p.plugininfo->name, func_name, msg_name, cmd, plugin_ret, plugin_result_to_str(g_plugin_globals.plugin_result)); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << p.plugininfo->name << "\" QMM_" << func_name << "( " << msg_name << "(" << cmd << ")) returning " << plugin_ret << " with result " << plugin_result_to_str(g_plugin_globals.plugin_result) << "\n"; // set new max result max_result = util_max(g_plugin_globals.plugin_result, max_result); // store current max result in global for plugins g_plugin_globals.high_result = max_result; // invalid/error result values - if (g_plugin_globals.plugin_result == QMM_UNUSED) - LOG(QMM_LOG_WARNING, "QMM") << fmt::format("{}({}): Plugin \"{}\" did not set result flag\n", func_name, msg_name, p.plugininfo->name); - else if (g_plugin_globals.plugin_result == QMM_ERROR) - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("{}({}): Plugin \"{}\" set result flag QMM_ERROR\n", func_name, msg_name, p.plugininfo->name); - + if (g_plugin_globals.plugin_result == QMM_UNUSED) { + QMMLOG(QMM_LOG_WARNING, "QMM") << func_name << "(" << msg_name << "): Plugin \"" << p.plugininfo->name << "\" did not set result flag\n"; + } + else if (g_plugin_globals.plugin_result == QMM_ERROR) { + QMMLOG(QMM_LOG_ERROR, "QMM") << func_name << "(" << msg_name << "): Plugin \"" << p.plugininfo->name << "\" set result flag QMM_ERROR\n"; + } // if plugin resulted in QMM_OVERRIDE or QMM_SUPERCEDE, set final_ret to this return value - else if (g_plugin_globals.plugin_result >= QMM_OVERRIDE) + else if (g_plugin_globals.plugin_result >= QMM_OVERRIDE) { final_ret = plugin_ret; + } } // call real function (unless a plugin resulted in QMM_SUPERCEDE) if (max_result < QMM_SUPERCEDE) { -#ifdef _DEBUG - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("Real {}({} {}) called\n", func_name, msg_name, cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Real " << func_name << "(" << msg_name << "(" << cmd << ")) called\n"; + if (is_syscall) real_ret = gamesupport->syscall(cmd, QMM_PUT_SYSCALL_ARGS()); else real_ret = gamesupport->vmMain(cmd, QMM_PUT_VMMAIN_ARGS()); -#ifdef _DEBUG - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("Real {}({} {}) returning {}\n", func_name, msg_name, cmd, real_ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Real " << func_name << "(" << msg_name << "(" << cmd << ")) returning " << real_ret << "\n"; } else { -#ifdef _DEBUG - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("Real {}({} {}) superceded\n", func_name, msg_name, cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Real " << func_name << "(" << msg_name << "(" << cmd << ")) superceded\n"; } // store real_ret in global for plugins @@ -407,9 +399,7 @@ intptr_t GameInfo::Route(bool is_syscall, intptr_t cmd, intptr_t* args) { // allow plugins to see the current final_ret value g_plugin_globals.final_return = final_ret; -#ifdef _DEBUG - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("Plugin {} QMM_{}_Post({} {}) called\n", p.plugininfo->name, func_name, msg_name, cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << p.plugininfo->name << "\" QMM_" << func_name << "_Post( " << msg_name << "(" << cmd << ")) called\n"; // call plugin's post-hook and store return value if (is_syscall) @@ -417,18 +407,16 @@ intptr_t GameInfo::Route(bool is_syscall, intptr_t cmd, intptr_t* args) { else plugin_ret = p.QMM_vmMain_Post(cmd, args); -#ifdef _DEBUG - if (g_plugin_globals.plugin_result != QMM_IGNORED) - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("Plugin {} QMM_{}_Post({} {}) returning {} with result {}\n", p.plugininfo->name, func_name, msg_name, cmd, plugin_ret, plugin_result_to_str(g_plugin_globals.plugin_result)); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << p.plugininfo->name << "\" QMM_" << func_name << "_Post( " << msg_name << "(" << cmd << ")) returning " << plugin_ret << " with result " << plugin_result_to_str(g_plugin_globals.plugin_result) << "\n"; // ignore QMM_UNUSED so plugins can just use return, but still show a message for QMM_ERROR - if (g_plugin_globals.plugin_result == QMM_ERROR) - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("syscall({}): Plugin \"{}\" set result flag QMM_ERROR\n", msg_name, p.plugininfo->name); - + if (g_plugin_globals.plugin_result == QMM_ERROR) { + QMMLOG(QMM_LOG_ERROR, "QMM") << func_name << "(" << msg_name << "): Plugin \"" << p.plugininfo->name << "\" set result flag QMM_ERROR\n"; + } // if plugin resulted in QMM_OVERRIDE or QMM_SUPERCEDE, set final_ret to this return value - else if (g_plugin_globals.plugin_result >= QMM_OVERRIDE) + else if (g_plugin_globals.plugin_result >= QMM_OVERRIDE) { final_ret = plugin_ret; + } } // restore previous globals (stored in case of re-entrancy) diff --git a/src/log.cpp b/src/log.cpp index 8442304..5d16ace 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -16,6 +16,11 @@ Created By: static AixLog::log_sink_ptr s_log_sink_file = nullptr; +static AixLog::Severity s_log_level = QMM2_LOG_DEFAULT_SEVERITY; + +bool log_level_match(int severity) { + return severity >= (int)QMM2_LOG_CONSOLE_SEVERITY || severity >= (int)s_log_level; +} void log_init(std::string file, AixLog::Severity severity, bool append) { if (append) @@ -38,6 +43,7 @@ std::string log_name_from_severity(int severity) { void log_set_severity(int severity) { + s_log_level = (AixLog::Severity)severity; (*s_log_sink_file).filter.add_filter((AixLog::Severity)severity); } @@ -63,6 +69,10 @@ std::string log_format(const AixLog::Metadata& metadata, const std::string& mess // so qvm.c can log stuff extern "C" void log_c(int severity, const char* tag, const char* fmt, ...) { + // exit early if neither log level (game console and log file) is met + if (!log_level_match(severity)) + return; + va_list argptr; static char buf[1024]; @@ -70,5 +80,6 @@ extern "C" void log_c(int severity, const char* tag, const char* fmt, ...) { vsnprintf(buf, sizeof(buf), fmt, argptr); va_end(argptr); + // not QMMLOG since we already checked log_level_match() LOG(severity, tag) << buf; } diff --git a/src/main.cpp b/src/main.cpp index b46e333..bc1e422 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,14 +12,10 @@ Created By: #define _CRT_SECURE_NO_WARNINGS #include "version.h" -// #include -// #include #include "log.hpp" #include "format.hpp" #include "config.hpp" #include "gameinfo.hpp" -// #include "game_api.hpp" -// #include "qmmapi.h" #include "plugin.hpp" // g_plugins #include "main.hpp" // ArgV #include "mod.hpp" // g_mod @@ -79,7 +75,7 @@ C_DLLEXPORT void dllEntry(void* syscall) { // just store the syscall pointer and pass it to the mod once it's loaded in vmMain(GAME_INIT) if (gameinfo.game && gameinfo.api == QMM_API_GETGAMEAPI) { cgameinfo.syscall = (eng_syscall)syscall; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("QMM passthrough_syscall = {}\n", syscall); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "QMM passthrough_syscall = " << syscall << "\n"; return; } @@ -182,17 +178,16 @@ C_DLLEXPORT intptr_t vmMain(intptr_t cmd, ...) { if (!cgameinfo.vmMain) return 0; -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Passthrough vmMain({}) called\n", cmd); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Passthrough vmMain(" << cmd << ") called\n"; + intptr_t ret = cgameinfo.vmMain(cmd, QMM_PUT_VMMAIN_ARGS()); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Passthrough vmMain({}) returning {}\n", cmd, ret); -#endif - // next call into combined mod after GAME_SHUTDOWN should be CGAME_SHUTDOWN so unload mod now + + QMMLOG(QMM_LOG_TRACE, "QMM") << "Passthrough vmMain(" << cmd << ") returning " << ret << "\n"; + + // next call into combined mod DLL after GAME_SHUTDOWN should be CGAME_SHUTDOWN so unload mod now if (cgameinfo.is_shutdown) { // unload mod (dlclose) - LOG(QMM_LOG_NOTICE, "QMM") << "Shutting down mod\n"; + QMMLOG(QMM_LOG_NOTICE, "QMM") << "Shutting down mod\n"; g_mod.Unload(); } @@ -206,7 +201,7 @@ C_DLLEXPORT intptr_t vmMain(intptr_t cmd, ...) { if (!gameinfo.game) { if (!gameinfo.is_shutdown) { gameinfo.is_shutdown = true; - LOG(QMM_LOG_FATAL, "QMM") << "QMM was unable to determine the game engine. Please set the \"game\" option in qmm2.json. Refer to the documentation for more information."; + QMMLOG(QMM_LOG_FATAL, "QMM") << "QMM was unable to determine the game engine. Please set the \"game\" option in qmm2.json. Refer to the documentation for more information.\n"; // if syscall passed to dllEntry was null, revert to std::exit because *shrug* if (!gameinfo.syscall) { printf("\nFatal QMM Error:\nQMM was unable to determine the game engine.\nPlease set the \"game\" option in qmm2.json.\nRefer to the documentation for more information.\n"); @@ -217,7 +212,7 @@ C_DLLEXPORT intptr_t vmMain(intptr_t cmd, ...) { return 0; } - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("vmMain({} {}) called\n", gameinfo.game->ModMsgName(cmd), cmd); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "vmMain(" << gameinfo.game->ModMsgName(cmd) << "(" << cmd << ")) called\n"; if (cmd == GameInfo::msg_GAME_INIT) { // initialize our polyfill milliseconds tracker so that now is 0 @@ -229,7 +224,7 @@ C_DLLEXPORT intptr_t vmMain(intptr_t cmd, ...) { }, QMM2_LOG_CONSOLE_SEVERITY); - LOG(QMM_LOG_NOTICE, "QMM") << "QMM v" QMM_VERSION " (" QMM_OS " " QMM_ARCH ") initializing\n"; + QMMLOG(QMM_LOG_NOTICE, "QMM") << "QMM v" QMM_VERSION " (" QMM_OS " " QMM_ARCH ") initializing\n"; // get mod dir from engine char moddir[256]; @@ -240,12 +235,12 @@ C_DLLEXPORT intptr_t vmMain(intptr_t cmd, ...) { if (gameinfo.mod_dir.empty()) gameinfo.mod_dir = gameinfo.game->DefaultModDir(); - LOG(QMM_LOG_INFO, "QMM") << fmt::format("Game: {}/\"{}\" (Source: {})\n", gameinfo.game->GameCode(), gameinfo.game->GameName(), gameinfo.is_auto_detected ? "Auto-detected" : "Config file"); - LOG(QMM_LOG_INFO, "QMM") << fmt::format("ModDir: {}\n", gameinfo.mod_dir); - LOG(QMM_LOG_INFO, "QMM") << fmt::format("Config file: \"{}\" {}\n", gameinfo.cfg_path, g_cfg.is_discarded() ? "(error)" : ""); + QMMLOG(QMM_LOG_INFO, "QMM") << "Game: " << gameinfo.game->GameCode() << "/\"" << gameinfo.game->GameName() << "\" (Source: " << (gameinfo.is_auto_detected ? "Auto-detected" : "Config file") << ")\n"; + QMMLOG(QMM_LOG_INFO, "QMM") << "ModDir: " << gameinfo.mod_dir << "\n"; + QMMLOG(QMM_LOG_INFO, "QMM") << "Config file: \"" << gameinfo.cfg_path << "\" " << (g_cfg.is_discarded() ? "(error)" : "") << "\n"; - LOG(QMM_LOG_INFO, "QMM") << "Built: " QMM_COMPILE " by " QMM_BUILDER "\n"; - LOG(QMM_LOG_INFO, "QMM") << "URL: " QMM_URL "\n"; + QMMLOG(QMM_LOG_INFO, "QMM") << "Built: " QMM_COMPILE " by " QMM_BUILDER "\n"; + QMMLOG(QMM_LOG_INFO, "QMM") << "URL: " QMM_URL "\n"; // create qmm_version cvar ENG_SYSCALL(QMM_ENG_MSG(QMM_G_CVAR_REGISTER), nullptr, "qmm_version", "v" QMM_VERSION, QMM_ENG_MSG(QMM_CVAR_ROM) | QMM_ENG_MSG(QMM_CVAR_SERVERINFO)); @@ -256,11 +251,11 @@ C_DLLEXPORT intptr_t vmMain(intptr_t cmd, ...) { cfg_mod = util_get_cmdline_arg("--qmm_mod", cfg_mod); if (!gameinfo.LoadMod(cfg_mod)) { gameinfo.is_shutdown = true; - LOG(QMM_LOG_FATAL, "QMM") << fmt::format("vmMain({}): Unable to load mod using \"{}\"\n", gameinfo.game->ModMsgName(cmd), cfg_mod); + QMMLOG(QMM_LOG_FATAL, "QMM") << "vmMain(" << gameinfo.game->ModMsgName(cmd) << "): Unable to load mod using \"" << cfg_mod << "\"\n"; ENG_SYSCALL(QMM_FAIL_G_ERROR, "\nFatal QMM Error:\nQMM was unable to load the mod file.\nPlease set the \"mod\" option in qmm2.json.\nRefer to the documentation for more information.\n"); return 0; } - LOG(QMM_LOG_NOTICE, "QMM") << fmt::format("Successfully loaded {} mod \"{}\"\n", APIType_Function(g_mod.api), g_mod.path); + QMMLOG(QMM_LOG_NOTICE, "QMM") << "Successfully loaded " << APIType_Function(g_mod.api) << " mod \"" << g_mod.path << "\"\n"; // cgame passthrough hack: // mod DLL is loaded, so find the vmMain and dllEntry functions and call dllEntry. @@ -268,34 +263,36 @@ C_DLLEXPORT intptr_t vmMain(intptr_t cmd, ...) { // so make sure we store vmMain first in case there's some re-entrancy if (cgameinfo.syscall) { cgameinfo.vmMain = (mod_vmMain)dll_symbol(g_mod.dll, "vmMain"); - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Storing cgame vmMain = {}\n", fmt::ptr(cgameinfo.vmMain)); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "Storing cgame vmMain = " << cgameinfo.vmMain << "\n"; // pass original cgame syscall to dllEntry in mod mod_dllEntry pfndllEntry = (mod_dllEntry)dll_symbol(g_mod.dll, "dllEntry"); - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Passing cgame syscall to dllEntry = {}\n", fmt::ptr(pfndllEntry)); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "Passing cgame syscall to dllEntry = " << pfndllEntry << "\n"; pfndllEntry(cgameinfo.syscall); } // load plugins - LOG(QMM_LOG_INFO, "QMM") << "Attempting to load plugins\n"; + QMMLOG(QMM_LOG_INFO, "QMM") << "Attempting to load plugins\n"; for (std::string& plugin_path : cfg_get_array_str(g_cfg, "plugins")) { - LOG(QMM_LOG_INFO, "QMM") << fmt::format("Attempting to load plugin \"{}\"...\n", plugin_path); - if (gameinfo.LoadPlugin(plugin_path)) - LOG(QMM_LOG_INFO, "QMM") << fmt::format("Plugin \"{}\" loaded\n", plugin_path); - else - LOG(QMM_LOG_INFO, "QMM") << fmt::format("Plugin \"{}\" not loaded\n", plugin_path); + QMMLOG(QMM_LOG_INFO, "QMM") << "Attempting to load plugin \"" << plugin_path << "\"...\n"; + if (gameinfo.LoadPlugin(plugin_path)) { + QMMLOG(QMM_LOG_INFO, "QMM") << "Plugin \"" << plugin_path << "\" loaded\n"; + } + else { + QMMLOG(QMM_LOG_INFO, "QMM") << "Plugin \"" << plugin_path << "\" not loaded\n"; + } } - LOG(QMM_LOG_NOTICE, "QMM") << fmt::format("Successfully loaded {} plugin(s)\n", g_plugins.size()); + QMMLOG(QMM_LOG_NOTICE, "QMM") << "Successfully loaded " << g_plugins.size() << " plugin(s)\n"; // exec the qmmexec cfg std::string cfg_execcfg = cfg_get_string(g_cfg, "execcfg", "qmmexec.cfg"); if (!cfg_execcfg.empty()) { - LOG(QMM_LOG_NOTICE, "QMM") << fmt::format("Executing config file \"{}\"\n", cfg_execcfg); + QMMLOG(QMM_LOG_NOTICE, "QMM") << "Executing config file \"" << cfg_execcfg << "\"\n"; ENG_SYSCALL(QMM_ENG_MSG(QMM_G_SEND_CONSOLE_COMMAND), QMM_ENG_MSG(QMM_EXEC_APPEND), fmt::format("exec {}\n", cfg_execcfg).c_str()); } // we're done! - LOG(QMM_LOG_NOTICE, "QMM") << "Startup successful!\n"; + QMMLOG(QMM_LOG_NOTICE, "QMM") << "Startup successful!\n"; } else if (cmd == GameInfo::msg_GAME_CONSOLE_COMMAND) { @@ -312,7 +309,7 @@ C_DLLEXPORT intptr_t vmMain(intptr_t cmd, ...) { } // check for "qmm" command if (str_striequal("qmm", arg_cmd) || str_striequal("/qmm", arg_cmd)) { - // pass 0 or 1 which gets added to argn in the handler function + // because of "sv", pass 0 or 1 which gets added to argn in the handler function HandleQMMCommand(argn); return 1; } @@ -323,31 +320,31 @@ C_DLLEXPORT intptr_t vmMain(intptr_t cmd, ...) { // handle shut down (this is after the plugins and mod get called with GAME_SHUTDOWN) if (cmd == GameInfo::msg_GAME_SHUTDOWN) { - LOG(QMM_LOG_NOTICE, "QMM") << "Shutdown initiated!\n"; + QMMLOG(QMM_LOG_NOTICE, "QMM") << "Shutdown initiated!\n"; // cgame passthrough hack: // hack to keep single player games shutting down correctly between levels/cutscenes/etc if (cgameinfo.syscall) { cgameinfo.is_shutdown = true; - LOG(QMM_LOG_NOTICE, "QMM") << "Delaying shutting down mod so cgame shutdown can run\n"; + QMMLOG(QMM_LOG_NOTICE, "QMM") << "Delaying shutting down mod so cgame shutdown can run\n"; } else { // unload mod - LOG(QMM_LOG_NOTICE, "QMM") << "Shutting down mod\n"; + QMMLOG(QMM_LOG_NOTICE, "QMM") << "Shutting down mod\n"; g_mod.Unload(); } // unload each plugin (call QMM_Detach, and then dlclose) - LOG(QMM_LOG_NOTICE, "QMM") << "Shutting down plugins\n"; + QMMLOG(QMM_LOG_NOTICE, "QMM") << "Shutting down plugins\n"; for (Plugin& p : g_plugins) { plugin_unload(p); } g_plugins.clear(); - LOG(QMM_LOG_NOTICE, "QMM") << "Finished shutting down\n"; + QMMLOG(QMM_LOG_NOTICE, "QMM") << "Finished shutting down\n"; } - LOG(QMM_LOG_TRACE, "QMM") << fmt::format("vmMain({} {}) returning {}\n", gameinfo.game->ModMsgName(cmd), cmd, ret); + QMMLOG(QMM_LOG_TRACE, "QMM") << "vmMain(" << gameinfo.game->ModMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } @@ -361,12 +358,12 @@ C_DLLEXPORT intptr_t vmMain(intptr_t cmd, ...) { intptr_t qmm_syscall(intptr_t cmd, ...) { QMM_GET_SYSCALL_ARGS(); - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("syscall({} {}) called\n", gameinfo.game->EngMsgName(cmd), cmd); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "syscall(" << gameinfo.game->EngMsgName(cmd) << "(" << cmd << ")) called\n"; // route call to plugins and mod intptr_t ret = gameinfo.Route(true, cmd, args); // true = is_syscall - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("syscall({} {}) returning {}\n", gameinfo.game->EngMsgName(cmd), cmd, ret); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "syscall(" << gameinfo.game->EngMsgName(cmd) << "(" << cmd << ")) returning " << ret << "\n"; return ret; } @@ -500,10 +497,10 @@ C_DLLEXPORT void* GetCGameAPI(void* import) { if (gameinfo.game) { // ?? if (!g_mod.dll) { - LOG(QMM_LOG_DEBUG, "QMM") << "GetCGameAPI() called! Mod DLL not loaded?\n"; + QMMLOG(QMM_LOG_DEBUG, "QMM") << "GetCGameAPI() called! Mod DLL not loaded?\n"; return nullptr; } - LOG(QMM_LOG_DEBUG, "QMM") << "GetCGameAPI() called! Passing on call to mod DLL.\n"; + QMMLOG(QMM_LOG_DEBUG, "QMM") << "GetCGameAPI() called! Passing on call to mod DLL.\n"; mod_GetGameAPI pfnGCGA = (mod_GetGameAPI)dll_symbol(g_mod.dll, "GetCGameAPI"); return pfnGCGA ? pfnGCGA(import, nullptr) : nullptr; } diff --git a/src/mod.cpp b/src/mod.cpp index d2a3f1d..1da7587 100644 --- a/src/mod.cpp +++ b/src/mod.cpp @@ -13,7 +13,6 @@ Created By: #include #include #include "log.hpp" -#include "format.hpp" #include "qmmapi.h" #include "game_api.hpp" #include "gameinfo.hpp" @@ -45,13 +44,13 @@ bool Mod::Load(std::string file) { // load DLL this->dll = dll_load(file.c_str()); if (!this->dll) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("Mod::Load(\"{}\"): DLL load failed: {}\n", file, dll_error()); + QMMLOG(QMM_LOG_ERROR, "QMM") << "Mod::Load(\"" << file << "\"): DLL load failed: " << dll_error() << "\n"; goto fail; } // if this DLL is the same as QMM, cancel if (this->dll == gameinfo.qmm_module_ptr) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("Mod::Load(\"{}\"): DLL is actually QMM?\n", file); + QMMLOG(QMM_LOG_ERROR, "QMM") << "Mod::Load(\"" << path_basename(file) << "\"): DLL is actually QMM?\n"; goto fail; } @@ -64,11 +63,11 @@ bool Mod::Load(std::string file) { if (this->LoadDLL(QMM_API_DLLENTRY)) return true; - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("Mod::Load(\"{}\"): Unable to locate mod entry point\n", file); + QMMLOG(QMM_LOG_ERROR, "QMM") << "Mod::Load(\"" << path_basename(file) << "\"): Unable to locate mod entry point\n"; goto fail; } else { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("Mod::Load(\"{}\"): Unknown mod file format\n", file); + QMMLOG(QMM_LOG_ERROR, "QMM") << "Mod::Load(\"" << path_basename(file) << "\"): Unknown mod file format\n"; } fail: @@ -92,7 +91,7 @@ intptr_t Mod::QVM_vmMain(intptr_t cmd, ...) { if (!g_mod.vm.memory) { if (!gameinfo.is_shutdown) { gameinfo.is_shutdown = true; - LOG(QMM_LOG_FATAL, "QMM") << fmt::format("s_mod_vmmain({}): QVM unloaded during previous execution due to a run-time error\n", gameinfo.game->ModMsgName(cmd)); + QMMLOG(QMM_LOG_FATAL, "QMM") << "Mod::QVM_vmMain(" << gameinfo.game->ModMsgName(cmd) << "(" << cmd << ")): QVM unloaded during previous execution due to a run-time error\n"; ENG_SYSCALL(QMM_ENG_MSG(QMM_G_ERROR), "\nFatal QMM Error:\nThe QVM was unloaded during previous execution due to a run-time error.\n"); } return 0; @@ -140,7 +139,7 @@ bool Mod::LoadQVM() { // load file using engine functions to read into pk3s if necessary filelen = ENG_SYSCALL(QMM_ENG_MSG(QMM_G_FS_FOPEN_FILE), this->path.c_str(), &fpk3, QMM_ENG_MSG(QMM_FS_READ)); if (filelen <= 0 || !fpk3) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("Mod::LoadQVM(\"{}\"): Could not open QVM for reading\n", this->path); + QMMLOG(QMM_LOG_ERROR, "QMM") << "Mod::LoadQVM(\"" << this->path << "\"): Could not open QVM for reading\n"; if (fpk3) ENG_SYSCALL(QMM_ENG_MSG(QMM_G_FS_FCLOSE_FILE), fpk3); goto fail; @@ -158,7 +157,7 @@ bool Mod::LoadQVM() { // attempt to load mod loaded = qvm_load(&this->vm, filemem.data(), filemem.size(), QVM_syscall, verify_data, hunk_size, nullptr); if (!loaded) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("Mod::LoadQVM(\"{}\"): QVM load failed\n", this->path); + QMMLOG(QMM_LOG_ERROR, "QMM") << "Mod::LoadQVM(\"" << this->path << "\"): QVM load failed\n"; goto fail; } @@ -167,13 +166,13 @@ bool Mod::LoadQVM() { // pass the qvm vmMain function pointer to the game-specific mod load handler if (!gameinfo.game->ModLoad((void*)QVM_vmMain, QMM_API_QVM)) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("Mod::LoadQVM(\"{}\"): Mod load failed?\n", path_basename(this->path)); + QMMLOG(QMM_LOG_ERROR, "QMM") << "Mod::LoadQVM(\"" << path_basename(this->path) << "\"): Mod load failed?\n"; goto fail; } this->api = QMM_API_QVM; - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Mod::LoadQVM(\"{}\"): QVM loaded successfully with verify_data {} and hunk size {}\n", path_basename(this->path), this->vm.verify_data ? "on" : "off", this->vm.hunksize); + QMMLOG(QMM_LOG_DEBUG, "QMM") << "Mod::LoadQVM(\"" << path_basename(this->path) << "\"): QVM loaded successfully with verify_data " << (this->vm.verify_data ? "on" : "off") << " and hunk size " << this->vm.hunksize << "\n"; return true; @@ -194,7 +193,7 @@ bool Mod::LoadDLL(APIType dll_api) { // look for GetGameAPI/GetModuleAPI function mod_GetGameAPI pfnGGA = (mod_GetGameAPI)dll_symbol(this->dll, APIType_Function(dll_api)); if (!pfnGGA) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("Mod::LoadDLL(\"{}\"): Could not locate mod entry point \"{}\"\n", this->path, APIType_Function(dll_api)); + QMMLOG(QMM_LOG_ERROR, "QMM") << "Mod::LoadDLL(\"" << path_basename(this->path) << "\"): Could not locate mod entry point \"" << APIType_Function(dll_api) << "\"\n"; return false; } @@ -204,7 +203,7 @@ bool Mod::LoadDLL(APIType dll_api) { return true; } - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("Mod::LoadDLL(\"{}\"): {}_GameSupport::ModLoad returned false\n", this->path, gameinfo.game->GameCode()); + QMMLOG(QMM_LOG_ERROR, "QMM") << "Mod::LoadDLL(\"" << path_basename(this->path) << "\"): " << gameinfo.game->GameCode() << "_GameSupport::ModLoad returned false\n"; return false; } @@ -212,7 +211,7 @@ bool Mod::LoadDLL(APIType dll_api) { mod_dllEntry pfndllEntry = (mod_dllEntry)dll_symbol(this->dll, "dllEntry"); mod_vmMain pfnvmMain = (mod_vmMain)dll_symbol(this->dll, "vmMain"); if (!pfndllEntry || !pfnvmMain) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("Mod::LoadDLL(\"{}\"): Could not locate mod entry point \"dllEntry\" and/or \"vmMain\"\n", this->path); + QMMLOG(QMM_LOG_ERROR, "QMM") << "Mod::LoadDLL(\"" << path_basename(this->path) << "\"): Could not locate mod entry point \"dllEntry\" and/or \"vmMain\"\n"; return false; } @@ -223,7 +222,7 @@ bool Mod::LoadDLL(APIType dll_api) { return true; } - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("Mod::LoadDLL(\"{}\"): {}_GameSupport::ModLoad returned false\n", this->path, gameinfo.game->GameCode()); + QMMLOG(QMM_LOG_ERROR, "QMM") << "Mod::LoadDLL(\"" << path_basename(this->path) << "\"): " << gameinfo.game->GameCode() << "_GameSupport::ModLoad returned false\n"; return false; } diff --git a/src/plugin.cpp b/src/plugin.cpp index de85f1a..c276dc6 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -17,7 +17,6 @@ Created By: #include "qmmapi.h" #include "game_api.hpp" #include "log.hpp" -#include "format.hpp" #include "config.hpp" #include "gameinfo.hpp" #include "main.hpp" // ArgV @@ -30,8 +29,8 @@ constexpr int ROTATING_BUFFER_NUM = 16; // must be power of 2 constexpr int ROTATING_BUFFER_MASK = ROTATING_BUFFER_NUM - 1; constexpr int ROTATING_BUFFER_SIZE = 1024; -static void s_plugin_helper_WriteQMMLog(plugin_id plid, const char* text, int severity); -static char* s_plugin_helper_VarArgs(plugin_id plid [[maybe_unused]], const char* format, ...); +static void s_plugin_helper_WriteQMMLog(plugin_id plid, int severity, const char* fmt, ...); +static char* s_plugin_helper_VarArgs(plugin_id plid [[maybe_unused]], const char* fmt, ...); static int s_plugin_helper_IsQVM(plugin_id plid [[maybe_unused]]); static const char* s_plugin_helper_EngMsgName(plugin_id plid [[maybe_unused]], intptr_t msg); static const char* s_plugin_helper_ModMsgName(plugin_id plid [[maybe_unused]], intptr_t msg); @@ -139,13 +138,13 @@ int plugin_load(Plugin& p, std::string file) { // load DLL if (!(p.dll = dll_load(file.c_str()))) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("plugin_load(\"{}\"): DLL load failed for plugin: {}\n", file, dll_error()); + QMMLOG(QMM_LOG_ERROR, "QMM") << "plugin_load(\"" << file << "\"): DLL load failed for plugin: " << dll_error() << "\n"; goto fail; } // if this DLL is the same as QMM, cancel if ((void*)p.dll == gameinfo.qmm_module_ptr) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("plugin_load(\"{}\"): DLL is actually QMM?\n", file); + QMMLOG(QMM_LOG_ERROR, "QMM") << "plugin_load(\"" << path_basename(file) << "\"): DLL is actually QMM?\n"; // treat this failure specially. this is a valid DLL, but it is QMM ret = -1; goto fail; @@ -154,7 +153,7 @@ int plugin_load(Plugin& p, std::string file) { // if this DLL is the same as another loaded plugin, cancel for (Plugin& t : g_plugins) { if (p.dll == t.dll) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("plugin_load(\"{}\"): DLL is already loaded as plugin\n", file); + QMMLOG(QMM_LOG_ERROR, "QMM") << "plugin_load(\"" << path_basename(file) << "\"): DLL is already loaded as plugin\n"; // treat this failure specially. this is a valid plugin, but it is already loaded ret = -1; goto fail; @@ -162,14 +161,14 @@ int plugin_load(Plugin& p, std::string file) { } if (!(p.QMM_Query = (Plugin::plugin_query)dll_symbol(p.dll, "QMM_Query"))) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("plugin_load(\"{}\"): Unable to find \"QMM_Query\" function\n", file); + QMMLOG(QMM_LOG_ERROR, "QMM") << "plugin_load(\"" << path_basename(file) << "\"): Unable to find \"QMM_Query\" function\n"; goto fail; } // call initial plugin entry point, get interface version p.QMM_Query(&p.plugininfo); if (!p.plugininfo) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("plugin_load(\"{}\"): QMM_Query() returned NULL Plugininfo\n", file); + QMMLOG(QMM_LOG_ERROR, "QMM") << "plugin_load(\"" << path_basename(file) << "\"): QMM_Query() returned NULL Plugininfo\n"; goto fail; } @@ -182,41 +181,41 @@ int plugin_load(Plugin& p, std::string file) { // if the plugin's major interface version is lower, don't load and suggest to upgrade plugin if (p.plugininfo->pifv_major < QMM_PIFV_MAJOR) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("plugin_load(\"{}\"): Plugin's interface version ({}:{}) is less than QMM's ({}:{}), suggest upgrading plugin.\n", file, p.plugininfo->pifv_major, p.plugininfo->pifv_minor, QMM_PIFV_MAJOR, QMM_PIFV_MINOR); + QMMLOG(QMM_LOG_ERROR, "QMM") << "plugin_load(\"" << path_basename(file) << "\"): Plugin's interface version (" << p.plugininfo->pifv_major << ":" << p.plugininfo->pifv_minor << ") is less than QMM's (" STRINGIFY(QMM_PIFV_MAJOR) ":" STRINGIFY(QMM_PIFV_MINOR) "), suggest upgrading plugin.\n"; goto fail; } // if the plugin's interface version is higher, don't load and suggest to upgrade QMM else if (p.plugininfo->pifv_major > QMM_PIFV_MAJOR || p.plugininfo->pifv_minor > QMM_PIFV_MINOR) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("plugin_load(\"{}\"): Plugin's interface version ({}:{}) is greater than QMM's ({}:{}), suggest upgrading QMM.\n", file, p.plugininfo->pifv_major, p.plugininfo->pifv_minor, QMM_PIFV_MAJOR, QMM_PIFV_MINOR); + QMMLOG(QMM_LOG_ERROR, "QMM") << "plugin_load(\"" << path_basename(file) << "\"): Plugin's interface version (" << p.plugininfo->pifv_major << ":" << p.plugininfo->pifv_minor << ") is greater than QMM's (" STRINGIFY(QMM_PIFV_MAJOR) ":" STRINGIFY(QMM_PIFV_MINOR) "), suggest upgrading QMM.\n"; goto fail; } // at this point, major versions match and the plugin's minor version is less than or equal to QMM's // find remaining QMM api functions or fail if (!(p.QMM_Attach = (Plugin::plugin_attach)dll_symbol(p.dll, "QMM_Attach"))) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("plugin_load(\"{}\"): Unable to find \"QMM_Attach\" function\n", file); + QMMLOG(QMM_LOG_ERROR, "QMM") << "plugin_load(\"" << path_basename(file) << "\"): Unable to find \"QMM_Attach\" function\n"; goto fail; } if (!(p.QMM_Detach = (Plugin::plugin_detach)dll_symbol(p.dll, "QMM_Detach"))) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("plugin_load(\"{}\"): Unable to find \"QMM_Detach\" function\n", file); + QMMLOG(QMM_LOG_ERROR, "QMM") << "plugin_load(\"" << path_basename(file) << "\"): Unable to find \"QMM_Detach\" function\n"; goto fail; } // find hook callback functions if (!(p.QMM_vmMain = (Plugin::plugin_callback)dll_symbol(p.dll, "QMM_vmMain"))) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("plugin_load(\"{}\"): Unable to find \"QMM_vmMain\" function\n", file); + QMMLOG(QMM_LOG_ERROR, "QMM") << "plugin_load(\"" << path_basename(file) << "\"): Unable to find \"QMM_vmMain\" function\n"; goto fail; } if (!(p.QMM_syscall = (Plugin::plugin_callback)dll_symbol(p.dll, "QMM_syscall"))) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("plugin_load(\"{}\"): Unable to find \"QMM_syscall\" function\n", file); + QMMLOG(QMM_LOG_ERROR, "QMM") << "plugin_load(\"" << path_basename(file) << "\"): Unable to find \"QMM_syscall\" function\n"; goto fail; } if (!(p.QMM_vmMain_Post = (Plugin::plugin_callback)dll_symbol(p.dll, "QMM_vmMain_Post"))) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("plugin_load(\"{}\"): Unable to find \"QMM_vmMain_Post\" function\n", file); + QMMLOG(QMM_LOG_ERROR, "QMM") << "plugin_load(\"" << path_basename(file) << "\"): Unable to find \"QMM_vmMain_Post\" function\n"; goto fail; } if (!(p.QMM_syscall_Post = (Plugin::plugin_callback)dll_symbol(p.dll, "QMM_syscall_Post"))) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("plugin_load(\"{}\"): Unable to find \"QMM_syscall_Post\" function\n", file); + QMMLOG(QMM_LOG_ERROR, "QMM") << "plugin_load(\"" << path_basename(file) << "\"): Unable to find \"QMM_syscall_Post\" function\n"; goto fail; } @@ -230,7 +229,7 @@ int plugin_load(Plugin& p, std::string file) { // call QMM_Attach. if it fails (returns 0), call QMM_Detach and unload DLL // QMM_Attach(engine syscall, mod vmmain, pointer to plugin result int, table of plugin helper functions, table of plugin variables) if (!(p.QMM_Attach(s_plugin_game_syscall, s_plugin_game_vmMain, &g_plugin_globals.plugin_result, &s_pluginfuncs, &s_pluginvars))) { - LOG(QMM_LOG_ERROR, "QMM") << fmt::format("plugin_load(\"{}\"): QMM_Attach() returned 0\n", file); + QMMLOG(QMM_LOG_ERROR, "QMM") << "plugin_load(\"" << path_basename(file) << "\"): QMM_Attach() returned 0\n"; // treat this failure specially. this is a valid plugin, but it decided on its own that it shouldn't be loaded ret = -1; goto fail; @@ -257,18 +256,38 @@ void plugin_unload(Plugin& p) { } -static void s_plugin_helper_WriteQMMLog(plugin_id plid, const char* text, int severity) { +static void s_plugin_helper_WriteQMMLog(plugin_id plid, int severity, const char* fmt, ...) { + if (!fmt) { + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called WriteQMMLog() with null fmt\n"; + return; + } + if (severity < QMM_LOG_TRACE || severity > QMM_LOG_FATAL) severity = QMM_LOG_INFO; + + // if log severity is below thresholds, don't log + if (!log_level_match(severity)) + return; + + // get log tag from plugin plugin_info* plinfo = (plugin_info*)plid; const char* logtag = plinfo->logtag; if (!logtag || !*logtag) logtag = plinfo->name; - LOG(severity, str_toupper(logtag)) << text; + + va_list argptr; + static char buf[1024]; + + va_start(argptr, fmt); + vsnprintf(buf, sizeof(buf), fmt, argptr); + va_end(argptr); + + // not QMMLOG since we already checked log_level_match() + LOG(severity, str_toupper(logtag)) << buf; } -static char* s_plugin_helper_VarArgs(plugin_id plid [[maybe_unused]], const char* format, ...) { +static char* s_plugin_helper_VarArgs(plugin_id plid [[maybe_unused]], const char* fmt, ...) { va_list argptr; static char str[ROTATING_BUFFER_NUM][ROTATING_BUFFER_SIZE]; static int index = 0; @@ -276,15 +295,13 @@ static char* s_plugin_helper_VarArgs(plugin_id plid [[maybe_unused]], const char // cycle rotating buffer and store string index = (index + 1) & ROTATING_BUFFER_MASK; - va_start(argptr, format); - vsnprintf(str[index], sizeof(str[index]), format, argptr); + va_start(argptr, fmt); + vsnprintf(str[index], sizeof(str[index]), fmt, argptr); va_end(argptr); char* ret = str[index]; -#ifdef _DEBUG - // LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnVarArgs(\"{}\", \"{}\") = \"{}\"\n", ((plugin_info*)plid)->name, format, ret); -#endif + // QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called VarArgs(\"" << format << "\") = \"" << ret << "\"\n"; return ret; } @@ -292,9 +309,7 @@ static char* s_plugin_helper_VarArgs(plugin_id plid [[maybe_unused]], const char static int s_plugin_helper_IsQVM(plugin_id plid [[maybe_unused]]) { int ret = g_mod.vmbase != 0; -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnIsQVM(\"{}\") = {}\n", ((plugin_info*)plid)->name, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called IsQVM() = " << ret << "\n"; return ret; } @@ -303,9 +318,7 @@ static int s_plugin_helper_IsQVM(plugin_id plid [[maybe_unused]]) { static const char* s_plugin_helper_EngMsgName(plugin_id plid [[maybe_unused]], intptr_t msg) { const char* ret = gameinfo.game->EngMsgName(msg); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnEngMsgName(\"{}\", {}) = \"{}\"\n", ((plugin_info*)plid)->name, msg, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called EngMsgName(" << msg << ") = \"" << ret << "\"\n"; return ret; } @@ -314,9 +327,7 @@ static const char* s_plugin_helper_EngMsgName(plugin_id plid [[maybe_unused]], i static const char* s_plugin_helper_ModMsgName(plugin_id plid [[maybe_unused]], intptr_t msg) { const char* ret = gameinfo.game->ModMsgName(msg); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnModMsgName(\"{}\", {}) = \"{}\"\n", ((plugin_info*)plid)->name, msg, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called ModMsgName(" << msg << ") = \"" << ret << "\"\n"; return ret; } @@ -327,9 +338,7 @@ static intptr_t s_plugin_helper_GetIntCvar(plugin_id plid [[maybe_unused]], cons if (cvar && *cvar) ret = ENG_SYSCALL(QMM_ENG_MSG(QMM_G_CVAR_VARIABLE_INTEGER_VALUE), cvar); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnGetIntCvar(\"{}\", \"{}\") = \"{}\"\n", ((plugin_info*)plid)->name, cvar, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called GetIntCvar(\"" << cvar << "\") = " << ret << "\n"; return ret; } @@ -348,9 +357,7 @@ static const char* s_plugin_helper_GetStrCvar(plugin_id plid [[maybe_unused]], c ret = str[index]; } -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnGetStrCvar(\"{}\", \"{}\") = \"{}\"\n", ((plugin_info*)plid)->name, cvar, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called GetStrCvar(\"" << cvar << "\") = \"" << ret << "\"\n"; return ret; } @@ -359,9 +366,7 @@ static const char* s_plugin_helper_GetStrCvar(plugin_id plid [[maybe_unused]], c static const char* s_plugin_helper_GetGameEngine(plugin_id plid [[maybe_unused]]) { const char* ret = gameinfo.game->GameCode(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnGetGameEngine(\"{}\") = \"{}\"\n", ((plugin_info*)plid)->name, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called GetGameEngine() = \"" << ret << "\"\n"; return ret; } @@ -371,10 +376,7 @@ static void s_plugin_helper_Argv(plugin_id plid [[maybe_unused]], intptr_t argn, if (buf && buflen) ArgV(argn, buf, buflen); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnArgv(\"{}\", {}) = \"{}\"\n", ((plugin_info*)plid)->name, argn, buf); -#endif - + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called Argv(" << argn << ") = \"" << buf << "\"\n"; } @@ -390,7 +392,7 @@ static const char* s_plugin_helper_InfoValueForKey(plugin_id plid [[maybe_unused // userinfo strings are "\key\value\key\value\" // so search for "\key\" and then get everything up to the next "\" - std::string fkey = fmt::format("\\{}\\", key); + std::string fkey = "\\" + std::string(key) + "\\"; size_t keypos = s.find(fkey); if (keypos != std::string::npos) { // key found // find next "\" @@ -409,9 +411,7 @@ static const char* s_plugin_helper_InfoValueForKey(plugin_id plid [[maybe_unused } } -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnInfoValueForKey(\"{}\", \"{}\", \"{}\") = \"{}\"\n", ((plugin_info*)plid)->name, userinfo, key, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called InfoValueForKey(\"" << userinfo << "\", \"" << key << "\") = \"" << ret << "\"\n"; return ret; } @@ -441,7 +441,9 @@ static const char* s_plugin_helper_ConfigGetStr(plugin_id plid [[maybe_unused]], index = (index + 1) & ROTATING_BUFFER_MASK; value[index] = cfg_get_string(node, path_basename(key)); const char* ret = value[index].c_str(); - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnConfigGetStr(\"{}\", \"{}\") = \"{}\"\n", ((plugin_info*)plid)->name, key, ret); + + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called ConfigGetStr(\"" << key << "\") = \"" << ret << "\"\n"; + return ret; } @@ -449,7 +451,9 @@ static const char* s_plugin_helper_ConfigGetStr(plugin_id plid [[maybe_unused]], static int s_plugin_helper_ConfigGetInt(plugin_id plid [[maybe_unused]], const char* key) { nlohmann::json node = s_plugin_cfg_get_node(key); int ret = cfg_get_int(node, path_basename(key)); - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnConfigGetInt(\"{}\", \"{}\") = {}\n", ((plugin_info*)plid)->name, key, ret); + + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called ConfigGetInt(\"" << key << "\") = " << ret << "\n"; + return ret; } @@ -457,7 +461,9 @@ static int s_plugin_helper_ConfigGetInt(plugin_id plid [[maybe_unused]], const c static int s_plugin_helper_ConfigGetBool(plugin_id plid [[maybe_unused]], const char* key) { nlohmann::json node = s_plugin_cfg_get_node(key); int ret = (int)cfg_get_bool(node, path_basename(key)); - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnConfigGetBool(\"{}\", \"{}\") = {}\n", ((plugin_info*)plid)->name, key, ret); + + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called ConfigGetBool(\"" << key << "\") = " << ret << "\n"; + return ret; } @@ -479,7 +485,9 @@ static const char** s_plugin_helper_ConfigGetArrayStr(plugin_id plid [[maybe_unu valuep[index].push_back(s.c_str()); } valuep[index].push_back(nullptr); // null-terminate the array - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin ConfigGetArrayStr(\"{}\", \"{}\") = [{} items]\n", ((plugin_info*)plid)->name, key, value[index].size()); + + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called ConfigGetArrayStr(\"" << key << "\") = [" << value[index].size() << " items]\n"; + return valuep[index].data(); } @@ -495,7 +503,9 @@ static int* s_plugin_helper_ConfigGetArrayInt(plugin_id plid [[maybe_unused]], c value[index] = cfg_get_array_int(node, path_basename(key)); // insert length of the array as the first element value[index].insert(value[index].begin(), (int)value[index].size()); - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin ConfigGetArrayInt(\"{}\", \"{}\") = [{} items]\n", ((plugin_info*)plid)->name, key, value[index].size() - 1); + + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called ConfigGetArrayInt(\"" << key << "\") = [" << value[index].size() - 1 << " items]\n"; + return value[index].data(); } @@ -513,10 +523,7 @@ static void s_plugin_helper_GetConfigString(plugin_id plid [[maybe_unused]], int strncpyz(buf, (const char*)ret, (size_t)buflen); } -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnGetConfigString(\"{}\", {}) = \"{}\"\n", ((plugin_info*)plid)->name, index, buf); -#endif - + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called GetConfigString(" << index << ") = \"" << buf << "\"\n"; } @@ -535,9 +542,7 @@ static int s_plugin_helper_PluginBroadcast(plugin_id plid, const char* message, total++; } -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnPluginBroadcast(\"{}\", \"{}\", {}, {}) = {} plugins called\n", ((plugin_info*)plid)->name, message, buf, buflen, total); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called PluginBroadcast(\"" << message << "\") = " << total << " plugins called\n"; return total; } @@ -557,9 +562,7 @@ static int s_plugin_helper_PluginSend(plugin_id plid, plugin_id to_plid, const c return 0; p.QMM_PluginMessage(plid, message, buf, buflen, 0); // 0 = is_broadcast -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnPluginSend(\"{}\", \"{}\", \"{}\", {}, {}) called\n", ((plugin_info*)plid)->name, ((plugin_info*)to_plid)->name, message, buf, buflen); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called PluginSend(\"" << message << "\")\n"; return 1; } @@ -591,7 +594,7 @@ static int s_plugin_helper_QVMRegisterFunc(plugin_id plid) { } } - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnRegisterQVMFunc(\"{}\") = {}\n", ((plugin_info*)plid)->name, ret); + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called QVMRegisterFunc() = " << ret << "\n"; return ret; } @@ -601,9 +604,7 @@ static int s_plugin_helper_QVMRegisterFunc(plugin_id plid) { static int s_plugin_helper_QVMExecFunc(plugin_id plid [[maybe_unused]], int instruction, int argc, int* argv) { int ret = qvm_exec_ex(&g_mod.vm, (size_t)instruction, argc, argv); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnQVMExecFunc(\"{}\", {}, {}) = {}\n", ((plugin_info*)plid)->name, instruction, argc, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called QVMExecFunc(" << instruction << ", " << argc << ") = " << ret << "\n"; return ret; } @@ -618,9 +619,7 @@ static const char* s_plugin_helper_Argv2(plugin_id plid [[maybe_unused]], intptr ArgV(argn, str[index], sizeof(str[index])); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnArgv2(\"{}\", {}) = \"{}\"\n", ((plugin_info*)plid)->name, argn, str[index]); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called Argv2(" << argn << ") = \"" << str[index] << "\"\n"; return str[index]; } @@ -642,9 +641,7 @@ static const char* s_plugin_helper_GetConfigString2(plugin_id plid [[maybe_unuse if (ret > 1) strncpyz(str[index], (const char*)ret, sizeof(str[index])); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnGetConfigString2(\"{}\", {}) = \"{}\"\n", ((plugin_info*)plid)->name, configindex, str[index]); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called GetConfigString2(" << configindex << ") = \"" << str[index] << "\"\n"; return str[index]; } @@ -653,9 +650,7 @@ static const char* s_plugin_helper_GetConfigString2(plugin_id plid [[maybe_unuse static const char* s_plugin_helper_ModDir(plugin_id plid [[maybe_unused]]) { const char* ret = gameinfo.mod_dir.c_str(); -#ifdef _DEBUG - LOG(QMM_LOG_DEBUG, "QMM") << fmt::format("Plugin pfnModDir(\"{}\") = \"{}\"\n", ((plugin_info*)plid)->name, ret); -#endif + QMMLOG(QMM_LOG_TRACE, "QMM") << "Plugin \"" << ((plugin_info*)plid)->name << " called ModDir() = \"" << ret << "\"\n"; return ret; }