Changeset - r8051:d67dab6255c1
[Not reviewed]
master
0 4 0
glx - 16 years ago 2007-12-09 21:20:21
glx@openttd.org
(svn r11611) -Codechange: it is now possible to use a define to enable asserts and show them in crash.log for MSVC release builds
4 files changed with 20 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/blitter/factory.hpp
Show inline comments
 
@@ -32,25 +32,25 @@ private:
 
protected:
 
	/**
 
	 * Register a blitter internally, based on his name.
 
	 * @param name the name of the blitter.
 
	 * @note an assert() will be trigger if 2 blitters with the same name try to register.
 
	 */
 
	void RegisterBlitter(const char *name)
 
	{
 
		/* Don't register nameless Blitters */
 
		if (name == NULL) return;
 

	
 
		this->name = strdup(name);
 
#if !defined(NDEBUG)
 
#if !defined(NDEBUG) || defined(WITH_ASSERT)
 
		/* NDEBUG disables asserts and gives a warning: unused variable 'P' */
 
		std::pair<Blitters::iterator, bool> P =
 
#endif /* !NDEBUG */
 
		GetBlitters().insert(Blitters::value_type(name, this));
 
		assert(P.second);
 
	}
 

	
 
public:
 
	BlitterFactoryBase() :
 
		name(NULL)
 
	{}
 

	
src/driver.h
Show inline comments
 
@@ -70,25 +70,25 @@ protected:
 
		/* Don't register nameless Drivers */
 
		if (name == NULL) return;
 

	
 
		this->name = strdup(name);
 
		this->type = type;
 
		this->priority = priority;
 

	
 
		/* Prefix the name with driver type to make it unique */
 
		char buf[32];
 
		strecpy(buf, GetDriverTypeName(type), lastof(buf));
 
		strecpy(buf + 5, name, lastof(buf));
 

	
 
#if !defined(NDEBUG)
 
#if !defined(NDEBUG) || defined(WITH_ASSERT)
 
		/* NDEBUG disables asserts and gives a warning: unused variable 'P' */
 
		std::pair<Drivers::iterator, bool> P =
 
#endif /* !NDEBUG */
 
		GetDrivers().insert(Drivers::value_type(buf, this));
 
		assert(P.second);
 
	}
 

	
 
public:
 
	DriverFactoryBase() :
 
		name(NULL)
 
	{}
 

	
src/stdafx.h
Show inline comments
 
@@ -198,24 +198,31 @@
 
			#define ZLIB_WINAPI
 
		#endif
 
	#endif
 

	
 
	#if defined(WINCE)
 
		#define strcasecmp _stricmp
 
		#define strncasecmp _strnicmp
 
		#undef DEBUG
 
	#else
 
		#define strcasecmp stricmp
 
		#define strncasecmp strnicmp
 
	#endif
 

	
 
	void SetExceptionString(const char* s, ...);
 

	
 
	#if defined(NDEBUG) && defined(WITH_ASSERT)
 
		#undef assert
 
		#define assert(expression) if (!(expression)) { SetExceptionString("Assertion failed at %s:%d: %s", __FILE__, __LINE__, #expression); *(byte*)0 = 0; }
 
	#endif
 
#endif /* defined(_MSC_VER) */
 

	
 
#if defined(WINCE)
 
	#define strdup _strdup
 
#endif /* WINCE */
 

	
 
/* NOTE: the string returned by these functions is only valid until the next
 
 * call to the same function and is not thread- or reentrancy-safe */
 
#if !defined(STRGEN)
 
	#if defined(WIN32) || defined(WIN64)
 
		char *getcwd(char *buf, size_t size);
 
		#include <tchar.h>
src/win32.cpp
Show inline comments
 
@@ -72,24 +72,35 @@ bool LoadLibraryList(Function proc[], co
 
			p = GetProcAddress(lib, dll);
 
#endif
 
			if (p == NULL) return false;
 
			*proc++ = (Function)p;
 
		}
 
		dll++;
 
	}
 
	return true;
 
}
 

	
 
#ifdef _MSC_VER
 
static const char *_exception_string = NULL;
 
void SetExceptionString(const char *s, ...)
 
{
 
	va_list va;
 
	char buf[512];
 

	
 
	va_start(va, s);
 
	vsnprintf(buf, lengthof(buf), s, va);
 
	va_end(va);
 

	
 
	_exception_string = strdup(buf);
 
}
 
#endif
 

	
 
void ShowOSErrorBox(const char *buf)
 
{
 
	MyShowCursor(true);
 
	MessageBox(GetActiveWindow(), MB_TO_WIDE(buf), _T("Error!"), MB_ICONSTOP);
 

	
 
/* if exception tracker is enabled, we crash here to let the exception handler handle it. */
 
#if defined(WIN32_EXCEPTION_TRACKER) && !defined(_DEBUG)
 
	if (*buf == '!') {
 
		_exception_string = buf;
 
		*(byte*)0 = 0;
0 comments (0 inline, 0 general)