diff --git a/source/audiolib/src/driver_adlib.h b/source/audiolib/src/driver_adlib.h index 5b2e8d036..1ddd90544 100644 --- a/source/audiolib/src/driver_adlib.h +++ b/source/audiolib/src/driver_adlib.h @@ -23,7 +23,6 @@ #include "opl3.h" extern int AL_Stereo; -extern int AL_AdditiveMode; int AdLibDrv_GetError(void); const char *AdLibDrv_ErrorString(int ErrorNumber); diff --git a/source/build/src/osd.cpp b/source/build/src/osd.cpp index fb2343341..9c0a80335 100644 --- a/source/build/src/osd.cpp +++ b/source/build/src/osd.cpp @@ -1518,15 +1518,7 @@ void OSD_Puts(const char *tmpstr) // void OSD_DispatchQueued(void) { - if (!osd->history.exec) - return; - - int cmd = osd->history.exec - 1; - - osd->history.exec = 0; - - for (; cmd >= 0; cmd--) - OSD_Dispatch((const char *)osd->history.buf[cmd]); + C_RunDelayedCommands(); } @@ -1537,6 +1529,7 @@ void OSD_Dispatch(const char *cmd) } +#if 0 // // OSD_RegisterFunction() -- Registers a new function // @@ -1558,6 +1551,7 @@ int OSD_RegisterFunction(const char *pszName, const char *pszDesc, int (*func)(o return 0; } +#endif // // OSD_SetVersionString() diff --git a/source/common/console/c_dispatch.cpp b/source/common/console/c_dispatch.cpp index 8e01d12c0..ce0f934e9 100644 --- a/source/common/console/c_dispatch.cpp +++ b/source/common/console/c_dispatch.cpp @@ -1027,3 +1027,26 @@ bool C_ExecFile (const char *file) return exec != NULL; } +#include "osd.h" + +static TArray dynccmds; // This needs to be explicitly deleted before shutdown - the names in here may not be valid during the exit handler. +// +// OSD_RegisterFunction() -- Reroutes a Bulid-style CCMD to the new console. +// +int OSD_RegisterFunction(const char* pszName, const char* pszDesc, int (*func)(osdcmdptr_t)) +{ + FString nname = pszName; + auto callback = [nname, pszDesc, func](FCommandLine& args, int key) + { + if (args.argc() > 0) args.operator[](0); + osdfuncparm_t param = { args.argc(), nname.GetChars(), (const char**)args._argv + 1, args.cmd }; + if (func(¶m) != OSDCMD_OK) + { + Printf("%s\n", pszDesc); + } + }; + auto ccmd = new FConsoleCommand(pszName, callback); + dynccmds.Push(ccmd); + return 0; +} + diff --git a/source/common/console/c_dispatch.h b/source/common/console/c_dispatch.h index 0fe7997a6..a8668b288 100644 --- a/source/common/console/c_dispatch.h +++ b/source/common/console/c_dispatch.h @@ -37,6 +37,7 @@ #include "printf.h" #include "zstring.h" #include "c_commandline.h" +#include "zstring.h" class FConfigFile; @@ -78,7 +79,7 @@ void C_ClearAliases (); // build a single string out of multiple strings FString BuildString (int argc, FString *argv); -typedef void (*CCmdRun) (FCommandLine &argv, void *instigator, int key); +typedef std::function CCmdRun;; class FConsoleCommand { @@ -86,7 +87,7 @@ public: FConsoleCommand (const char *name, CCmdRun RunFunc); virtual ~FConsoleCommand (); virtual bool IsAlias (); - void PrintCommand () { Printf ("%s\n", m_Name); } + void PrintCommand () { Printf ("%s\n", m_Name.GetChars()); } virtual void Run (FCommandLine &args, void *instigator, int key); static FConsoleCommand* FindByName (const char* name);