Start a new bridge mechanism for global callbacks.
This commit is contained in:
parent
38e1c2f1f3
commit
401aa038f8
@ -47,7 +47,7 @@ SH_DECL_HOOK1_void(IVEngineServer, LogPrint, SH_NOATTRIB, false, const char *);
|
||||
static void HookLogPrint(const char *message)
|
||||
{
|
||||
g_in_game_log_hook = true;
|
||||
bool stopped = logicore.OnLogPrint(message);
|
||||
bool stopped = logicore.callbacks->OnLogPrint(message);
|
||||
g_in_game_log_hook = false;
|
||||
|
||||
if (stopped)
|
||||
|
@ -92,9 +92,6 @@ static IGameConfig *GetCoreGameConfig()
|
||||
return g_pGameConf;
|
||||
}
|
||||
|
||||
// Defined in smn_filesystem.cpp.
|
||||
extern bool OnLogPrint(const char *msg);
|
||||
|
||||
static void GenerateError(IPluginContext *ctx, cell_t idx, int err, const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@ -128,6 +125,17 @@ static void OnRootCommand(const ICommandArgs *args)
|
||||
g_RootMenu.GotRootCmd(args);
|
||||
}
|
||||
|
||||
// Defined in smn_filesystem.cpp.
|
||||
extern bool OnLogPrint(const char *msg);
|
||||
|
||||
class ProviderCallbackListener : public IProviderCallbacks
|
||||
{
|
||||
public:
|
||||
bool OnLogPrint(const char *msg) override {
|
||||
return ::OnLogPrint(msg);
|
||||
}
|
||||
} sProviderCallbackListener;
|
||||
|
||||
static sm_logic_t logic =
|
||||
{
|
||||
NULL,
|
||||
@ -141,7 +149,6 @@ static sm_logic_t logic =
|
||||
UTIL_ReplaceEx,
|
||||
UTIL_DecodeHexString,
|
||||
GetCoreGameConfig,
|
||||
OnLogPrint,
|
||||
&g_DbgReporter,
|
||||
GenerateError,
|
||||
AddNatives,
|
||||
@ -158,6 +165,7 @@ static sm_logic_t logic =
|
||||
NULL,
|
||||
&g_Logger,
|
||||
&g_RootMenu,
|
||||
&sProviderCallbackListener,
|
||||
-1.0f
|
||||
};
|
||||
|
||||
|
@ -52,7 +52,7 @@ using namespace SourceHook;
|
||||
* Add 1 to the RHS of this expression to bump the intercom file
|
||||
* This is to prevent mismatching core/logic binaries
|
||||
*/
|
||||
#define SM_LOGIC_MAGIC (0x0F47C0DE - 46)
|
||||
#define SM_LOGIC_MAGIC (0x0F47C0DE - 47)
|
||||
|
||||
#if defined SM_LOGIC
|
||||
# define IVEngineClass IVEngineServer
|
||||
@ -331,6 +331,13 @@ public:
|
||||
int (*GetGlobalTarget)();
|
||||
};
|
||||
|
||||
class IProviderCallbacks
|
||||
{
|
||||
public:
|
||||
// Called when a log message is printed. Return true to supercede.
|
||||
virtual bool OnLogPrint(const char *msg) = 0;
|
||||
};
|
||||
|
||||
struct sm_logic_t
|
||||
{
|
||||
SMGlobalClass *head;
|
||||
@ -344,14 +351,13 @@ struct sm_logic_t
|
||||
char *(*ReplaceEx)(char *, size_t, const char *, size_t, const char *, size_t, bool);
|
||||
size_t (*DecodeHexString)(unsigned char *, size_t, const char *);
|
||||
IGameConfig * (*GetCoreGameConfig)();
|
||||
bool (*OnLogPrint)(const char *msg); // true to supersede
|
||||
IDebugListener *debugger;
|
||||
void (*GenerateError)(IPluginContext *, cell_t, int, const char *, ...);
|
||||
void (*AddNatives)(sp_nativeinfo_t *natives);
|
||||
void (*DumpHandles)(void (*dumpfn)(const char *fmt, ...));
|
||||
bool (*DumpAdminCache)(const char *filename);
|
||||
void (*RegisterProfiler)(IProfilingTool *tool);
|
||||
void (*OnRootCommand)(const ICommandArgs *args);
|
||||
void (*OnRootCommand)(const ICommandArgs *args);
|
||||
IScriptManager *scripts;
|
||||
IShareSys *sharesys;
|
||||
IExtensionSys *extsys;
|
||||
@ -361,6 +367,7 @@ struct sm_logic_t
|
||||
IdentityToken_t *core_ident;
|
||||
ILogger *logger;
|
||||
IRootConsole *rootmenu;
|
||||
IProviderCallbacks *callbacks;
|
||||
float sentinel;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user