- added a system-include independent wrapper for Windows's OutputDebugString, so that this can be used more easily in files that cannot include windows.h.

This commit is contained in:
Christoph Oelckers 2016-04-10 13:03:44 +02:00
parent ef08e29d51
commit 12129b0f07
8 changed files with 24 additions and 8 deletions

View file

@ -41,13 +41,14 @@
#include "m_swap.h" #include "m_swap.h"
#include "w_wad.h" #include "w_wad.h"
#include "v_text.h" #include "v_text.h"
#include "i_system.h"
#include "opl.h" #include "opl.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
#if defined(_DEBUG) && defined(_WIN32) && defined(_MSC_VER) #if defined(_DEBUG) && defined(_WIN32) && defined(_MSC_VER)
#define DEBUGOUT(m,c,s,t) \ #define DEBUGOUT(m,c,s,t) \
{ char foo[128]; mysnprintf(foo, countof(foo), m, c, s, t); OutputDebugString(foo); } { char foo[128]; mysnprintf(foo, countof(foo), m, c, s, t); I_DebugPrint(foo); }
#else #else
#define DEBUGOUT(m,c,s,t) #define DEBUGOUT(m,c,s,t)
#endif #endif

View file

@ -183,6 +183,12 @@ void I_SetIWADInfo()
} }
void I_DebugPrint(const char *cp)
{
NSLog(@"%s", cp);
}
void I_PrintStr(const char* const message) void I_PrintStr(const char* const message)
{ {
FConsoleWindow::GetInstance().AddText(message); FConsoleWindow::GetInstance().AddText(message);

View file

@ -111,6 +111,8 @@ void addterm (void (*func)(void), const char *name);
#define atterm(t) addterm (t, #t) #define atterm(t) addterm (t, #t)
void popterm (); void popterm ();
void I_DebugPrint (const char *cp);
// Print a console string // Print a console string
void I_PrintStr (const char *str); void I_PrintStr (const char *str);

View file

@ -232,6 +232,10 @@ void I_SetIWADInfo ()
{ {
} }
void I_DebugPrint(const char *cp)
{
}
void I_PrintStr (const char *cp) void I_PrintStr (const char *cp)
{ {
// Strip out any color escape sequences before writing to the log file // Strip out any color escape sequences before writing to the log file

View file

@ -40,6 +40,7 @@
#include "m_swap.h" #include "m_swap.h"
#include "w_wad.h" #include "w_wad.h"
#include "v_text.h" #include "v_text.h"
#include "i_system.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
@ -337,7 +338,7 @@ int SoftSynthMIDIDevice::PlayTick()
char buffer[128]; char buffer[128];
mysnprintf(buffer, countof(buffer), "C%02d: %11s %3d %3d\n", (status & 15) + 1, commands[(status >> 4) & 7], parm1, parm2); mysnprintf(buffer, countof(buffer), "C%02d: %11s %3d %3d\n", (status & 15) + 1, commands[(status >> 4) & 7], parm1, parm2);
#ifdef _WIN32 #ifdef _WIN32
OutputDebugString(buffer); I_DebugPrint(buffer);
#else #else
fputs(buffer, stderr); fputs(buffer, stderr);
#endif #endif

View file

@ -782,11 +782,6 @@ void Renderer::MarkInstrument(int banknum, int percussion, int instr)
} }
} }
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
void cmsg(int type, int verbosity_level, const char *fmt, ...) void cmsg(int type, int verbosity_level, const char *fmt, ...)
{ {
/* /*
@ -801,7 +796,7 @@ void cmsg(int type, int verbosity_level, const char *fmt, ...)
va_start(args, fmt); va_start(args, fmt);
vsprintf(buf, fmt, args); vsprintf(buf, fmt, args);
va_end(args); va_end(args);
OutputDebugString(buf); I_DebugPrint(buf);
#endif #endif
} }

View file

@ -1051,6 +1051,11 @@ static void DoPrintStr(const char *cp, HWND edit, HANDLE StdOut)
static TArray<FString> bufferedConsoleStuff; static TArray<FString> bufferedConsoleStuff;
void I_DebugPrint(const char *cp)
{
OutputDebugStringA(cp);
}
void I_PrintStr(const char *cp) void I_PrintStr(const char *cp)
{ {
if (con_debugoutput) if (con_debugoutput)

View file

@ -145,6 +145,8 @@ bool I_SetCursor(FTexture *cursor);
// Repaint the pre-game console // Repaint the pre-game console
void I_PaintConsole (void); void I_PaintConsole (void);
void I_DebugPrint (const char *cp);
// Print a console string // Print a console string
void I_PrintStr (const char *cp); void I_PrintStr (const char *cp);