* 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
# Begin Source File
SOURCE=.\debugprint.c
SOURCE=.\debugprint.cpp
# End Source File
# Begin Source File
@ -294,7 +294,7 @@ SOURCE=.\debug.h
# End Source File
# Begin Source File
SOURCE=.\debugprint.h
SOURCE=.\debugprint.hpp
# End Source File
# Begin Source File

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,9 +22,8 @@
$HeadURL$
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __INCLUDE_DEBUGPRINT_HPP__
#define __INCLUDE_DEBUGPRINT_HPP__
//#define DEBUG0
//#define DEBUG1
@ -33,9 +32,6 @@ extern "C" {
//#define DEBUG4
#define DEBUG5
void DebugOpen(char* LogName);
void DebugClose(void);
#ifndef _TCHAR_DEFINED
typedef char TCHAR, *PTCHAR;
typedef unsigned char TBYTE , *PTBYTE ;
@ -44,26 +40,27 @@ typedef unsigned char TBYTE , *PTBYTE ;
#ifdef _DEBUG
void DebugOpen(const char* LogName);
void DebugClose();
void DebugPrint(const TCHAR *format, ...);
#else
#define DebugOpen
#define DebugClose
#define DebugPrint
#endif
#ifdef __cplusplus
#ifndef ASSERT
#define ASSERT
#endif
# ifndef ASSERT
# define ASSERT
# endif
#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__); \
DebugPrint(b); \
DebugPrint("\n"); }
#define ASSERT(a) DBG_ASSERT a
#endif
# endif
#endif
#define DBERROR(a) DebugPrint a;
@ -106,7 +103,4 @@ void DebugPrint(const TCHAR *format, ...);
#define DBP5
#endif
#ifdef __cplusplus
}
#endif
#endif // __INCLUDE_DEBUGPRINT_HPP__

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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