* Make debugprint.c a C++ file instead of C

* Use std::ostream instead of FILE* for debug printing

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@2198 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2007-07-26 09:36:45 +00:00
parent 595c4838ac
commit f10cdeb157
28 changed files with 58 additions and 79 deletions

View File

@ -126,7 +126,7 @@ SOURCE=.\ddimage.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\debugprint.c SOURCE=.\debugprint.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -294,7 +294,7 @@ SOURCE=.\debug.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\debugprint.h SOURCE=.\debugprint.hpp
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@ -25,7 +25,7 @@
#include "winstuff.h" #include "winstuff.h"
#include "stdio.h" #include "stdio.h"
#include "assert.h" #include "assert.h"
#include "debugprint.h" #include "debugprint.hpp"
#include "bmphandler.h" #include "bmphandler.h"
BMPHandler::BMPHandler() : BMPHandler::BMPHandler() :

View File

@ -27,7 +27,7 @@
#include "bteditdoc.h" #include "bteditdoc.h"
#include "brush.h" #include "brush.h"
#include "tiletypes.h" #include "tiletypes.h"
#include "debugprint.h" #include "debugprint.hpp"
#include "assert.h" #include "assert.h"
#ifdef _DEBUG #ifdef _DEBUG

View File

@ -28,7 +28,7 @@
#include "btedit.h" #include "btedit.h"
#include "bteditdoc.h" #include "bteditdoc.h"
#include "wfview.h" #include "wfview.h"
#include "debugprint.h" #include "debugprint.hpp"
#include "brushprop.h" #include "brushprop.h"

View File

@ -32,7 +32,7 @@
#include "mapprefs.h" #include "mapprefs.h"
#include "textureprefs.h" #include "textureprefs.h"
#include "dibdraw.h" #include "dibdraw.h"
#include "debugprint.h" #include "debugprint.hpp"
#include "wfview.h" #include "wfview.h"
#include "textureview.h" #include "textureview.h"
#include "bteditview.h" #include "bteditview.h"

View File

@ -31,7 +31,7 @@
#include "bteditdoc.h" #include "bteditdoc.h"
#include "bteditview.h" #include "bteditview.h"
//#include "editstats.h" //#include "editstats.h"
#include "debugprint.h" #include "debugprint.hpp"
//#include "statsview.h" //#include "statsview.h"
#include "tiletypes.h" #include "tiletypes.h"
#include "objectproperties.h" #include "objectproperties.h"

View File

@ -26,7 +26,7 @@
#include "windowsx.h" #include "windowsx.h"
#include "stdio.h" #include "stdio.h"
#include "typedefs.h" #include "typedefs.h"
#include "debugprint.h" #include "debugprint.hpp"
#include "chnkio.h" #include "chnkio.h"

View File

@ -27,7 +27,7 @@
#include "windowsx.h" #include "windowsx.h"
#include "stdio.h" #include "stdio.h"
#include "typedefs.h" #include "typedefs.h"
#include "debugprint.h" #include "debugprint.hpp"
#include "directx.h" #include "directx.h"

View File

@ -24,33 +24,29 @@
#include "windows.h" #include "windows.h"
#include "windowsx.h" #include "windowsx.h"
#include "stdio.h" #include <fstream>
#include "tchar.h" #include "tchar.h"
#include "debugprint.hpp"
#ifdef _DEBUG #ifdef _DEBUG
extern void DebugWinPrint(char *String); extern void DebugWinPrint(char *String);
FILE* DebugStream=NULL; static std::ostream* DebugStream = NULL;
void DebugOpen(char* LogName) void DebugOpen(const char* LogName)
{ {
if(DebugStream) { DebugClose();
fclose(DebugStream);
DebugStream = NULL;
}
DebugStream = fopen(LogName,"wb"); DebugStream = new std::ofstream(LogName, std::ios_base::binary);
fprintf(DebugStream,"This build : %s %s\n\n",__DATE__,__TIME__); *DebugStream << "This build : " << __DATE__ << " " << __TIME__ << "\n" << std::endl;
} }
void DebugClose(void) void DebugClose()
{ {
if(DebugStream) { delete DebugStream;
fclose(DebugStream); DebugStream = NULL;
}
DebugStream=NULL;
} }
void DebugPrint(const TCHAR *format, ...) void DebugPrint(const TCHAR *format, ...)
@ -61,23 +57,12 @@ void DebugPrint(const TCHAR *format, ...)
va_start(args,format); va_start(args,format);
_vsntprintf(buf,4096,format,args); _vsntprintf(buf,4096,format,args);
va_end(args); va_end(args);
// Display the debug string in any debugger (WINAPI function)
OutputDebugString(buf); OutputDebugString(buf);
if(DebugStream!=NULL) {
fprintf(DebugStream,"%s",buf);
}
// DebugWinPrint(buf); if(DebugStream)
*DebugStream << buf << std::endl;
} }
#else
void DebugOpen(char* LogName)
{
}
void DebugClose(void)
{
}
#endif #endif

View File

@ -22,9 +22,8 @@
$HeadURL$ $HeadURL$
*/ */
#ifdef __cplusplus #ifndef __INCLUDE_DEBUGPRINT_HPP__
extern "C" { #define __INCLUDE_DEBUGPRINT_HPP__
#endif
//#define DEBUG0 //#define DEBUG0
//#define DEBUG1 //#define DEBUG1
@ -33,9 +32,6 @@ extern "C" {
//#define DEBUG4 //#define DEBUG4
#define DEBUG5 #define DEBUG5
void DebugOpen(char* LogName);
void DebugClose(void);
#ifndef _TCHAR_DEFINED #ifndef _TCHAR_DEFINED
typedef char TCHAR, *PTCHAR; typedef char TCHAR, *PTCHAR;
typedef unsigned char TBYTE , *PTBYTE ; typedef unsigned char TBYTE , *PTBYTE ;
@ -44,26 +40,27 @@ typedef unsigned char TBYTE , *PTBYTE ;
#ifdef _DEBUG #ifdef _DEBUG
void DebugOpen(const char* LogName);
void DebugClose();
void DebugPrint(const TCHAR *format, ...); void DebugPrint(const TCHAR *format, ...);
#else #else
#define DebugOpen
#define DebugClose
#define DebugPrint #define DebugPrint
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
#ifndef ASSERT # ifndef ASSERT
# define ASSERT
#define ASSERT # endif
#endif
#else #else
#ifndef ASSERT # ifndef ASSERT
# define DBG_ASSERT(a,b) if(!(a)) { DebugPrint("Assertion Failure in %s, line : %d\n",__FILE__, __LINE__); \
DebugPrint(b); \
DebugPrint("\n"); }
# define ASSERT(a) DBG_ASSERT a
#define DBG_ASSERT(a,b) if(!(a)) { DebugPrint("Assertion Failure in %s, line : %d\n",__FILE__, __LINE__); \ # endif
DebugPrint(b); \
DebugPrint("\n"); }
#define ASSERT(a) DBG_ASSERT a
#endif
#endif #endif
#define DBERROR(a) DebugPrint a; #define DBERROR(a) DebugPrint a;
@ -106,7 +103,4 @@ void DebugPrint(const TCHAR *format, ...);
#define DBP5 #define DBP5
#endif #endif
#ifdef __cplusplus #endif // __INCLUDE_DEBUGPRINT_HPP__
}
#endif

View File

@ -32,7 +32,7 @@
#include <assert.h> #include <assert.h>
#include "dibdraw.h" #include "dibdraw.h"
#include "debugprint.h" #include "debugprint.hpp"
// Create a DIBDraw class with user specified dimensions and colour depth. // Create a DIBDraw class with user specified dimensions and colour depth.

View File

@ -33,7 +33,7 @@
#include "directx.h" #include "directx.h"
#include "geometry.h" #include "geometry.h"
#include "debugprint.h" #include "debugprint.hpp"
//#define FOGGY //#define FOGGY
#define FILTER #define FILTER

View File

@ -26,7 +26,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "btedit.h" #include "btedit.h"
#include "debugprint.h" #include "debugprint.hpp"
#include "expandlimitsdlg.h" #include "expandlimitsdlg.h"
#ifdef _DEBUG #ifdef _DEBUG

View File

@ -30,7 +30,7 @@
#include <assert.h> #include <assert.h>
#include "fileparse.h" #include "fileparse.h"
#include "debugprint.h" #include "debugprint.hpp"
fileParser::fileParser(std::istream& file, short flags) : fileParser::fileParser(std::istream& file, short flags) :

View File

@ -41,7 +41,7 @@
#define MAP_MAXWIDTH 256 #define MAP_MAXWIDTH 256
#define MAP_MAXHEIGHT 256 #define MAP_MAXHEIGHT 256
#include "debugprint.h" #include "debugprint.hpp"
#include "gateway.hpp" #include "gateway.hpp"

View File

@ -49,7 +49,7 @@
#define MAP_MAXWIDTH 256 #define MAP_MAXWIDTH 256
#define MAP_MAXHEIGHT 256 #define MAP_MAXHEIGHT 256
#include "debugprint.h" #include "debugprint.hpp"
#include "assert.h" #include "assert.h"
#include "gateway.hpp" #include "gateway.hpp"

View File

@ -32,7 +32,7 @@
#include <io.h> #include <io.h>
#include <math.h> #include <math.h>
#include "debugprint.h" #include "debugprint.hpp"
#include "geometry.h" #include "geometry.h"
#include "directx.h" #include "directx.h"

View File

@ -27,7 +27,7 @@
#include "windowsx.h" #include "windowsx.h"
#include "stdio.h" #include "stdio.h"
#include "typedefs.h" #include "typedefs.h"
#include "debugprint.h" #include "debugprint.hpp"
#include "grdland.h" #include "grdland.h"

View File

@ -28,7 +28,7 @@
#include "stdio.h" #include "stdio.h"
#include "math.h" #include "math.h"
#include "typedefs.h" #include "typedefs.h"
#include "debugprint.h" #include "debugprint.hpp"
#include "directx.h" #include "directx.h"
#include "geometry.h" #include "geometry.h"

View File

@ -26,7 +26,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "btedit.h" #include "btedit.h"
#include "debugprint.h" #include "debugprint.hpp"
#include "initiallimitsdlg.h" #include "initiallimitsdlg.h"
#ifdef _DEBUG #ifdef _DEBUG

View File

@ -26,7 +26,7 @@
#include "windowsx.h" #include "windowsx.h"
#include "stdio.h" #include "stdio.h"
#include "typedefs.h" #include "typedefs.h"
#include "debugprint.h" #include "debugprint.hpp"
#include "keyhandler.h" #include "keyhandler.h"

View File

@ -26,7 +26,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "btedit.h" #include "btedit.h"
#include "debugprint.h" #include "debugprint.hpp"
#include "limitsdialog.h" #include "limitsdialog.h"
#ifdef _DEBUG #ifdef _DEBUG

View File

@ -28,7 +28,7 @@
#include "stdio.h" #include "stdio.h"
#include "math.h" #include "math.h"
#include "typedefs.h" #include "typedefs.h"
#include "debugprint.h" #include "debugprint.hpp"
#include "directx.h" #include "directx.h"
#include "geometry.h" #include "geometry.h"

View File

@ -27,7 +27,7 @@
#include "windowsx.h" #include "windowsx.h"
#include "stdio.h" #include "stdio.h"
#include "typedefs.h" #include "typedefs.h"
#include "debugprint.h" #include "debugprint.hpp"
#include "pcxhandler.h" #include "pcxhandler.h"

View File

@ -25,7 +25,7 @@
// //
#include "stdafx.h" #include "stdafx.h"
#include "debugprint.h" #include "debugprint.hpp"
#include "textsel.h" #include "textsel.h"
#include "heightmap.h" #include "heightmap.h"
#include "tiletypes.h" #include "tiletypes.h"

View File

@ -30,7 +30,7 @@
#include "textureview.h" #include "textureview.h"
#include "tiletypes.h" #include "tiletypes.h"
#include "autoflagdialog.h" #include "autoflagdialog.h"
#include "debugprint.h" #include "debugprint.hpp"
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW

View File

@ -32,7 +32,7 @@
#include "directx.h" #include "directx.h"
#include "geometry.h" #include "geometry.h"
#include "debugprint.h" #include "debugprint.hpp"
#include "ddimage.h" #include "ddimage.h"
#include "heightmap.h" #include "heightmap.h"

View File

@ -31,7 +31,7 @@
//#include "DBView.h" //#include "DBView.h"
#include "tiletypes.h" #include "tiletypes.h"
//#include "EditStats.h" //#include "EditStats.h"
#include "debugprint.h" #include "debugprint.hpp"
//#include "DebugWin.h" //#include "DebugWin.h"
#include "objectproperties.h" #include "objectproperties.h"