From 2de326fb23c0abb5ed288a8205c0af00c54460b6 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 29 Apr 2005 20:15:12 +0000 Subject: [PATCH] ASSERT is too assertive. If it's probably possible to continue past an unexpected case, it's better to warn loudly and then move on, instead of crashing. --- stepmania/src/RageLog.cpp | 8 ++++++++ stepmania/src/global.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/stepmania/src/RageLog.cpp b/stepmania/src/RageLog.cpp index 2db8a36ae6..17e19531f2 100644 --- a/stepmania/src/RageLog.cpp +++ b/stepmania/src/RageLog.cpp @@ -386,6 +386,14 @@ void RageLog::UnmapLog(const CString &key) UpdateMappedLog(); } +void ShowWarning( const char *file, int line, const char *message ) +{ + if( LOG != NULL ) + LOG->Warn( "%s:%i: %s", file, line, message ); + else + fprintf( stderr, "%s:%i: %s", file, line, message ); +} + /* * Copyright (c) 2001-2004 Chris Danford, Glenn Maynard * All rights reserved. diff --git a/stepmania/src/global.h b/stepmania/src/global.h index 5ac1fd7b5f..a0b084546b 100644 --- a/stepmania/src/global.h +++ b/stepmania/src/global.h @@ -106,6 +106,9 @@ void NORETURN sm_crash( const char *reason = "Internal error" ); #define ASSERT_M(COND, MESSAGE) { if(!(COND)) { FAIL_M(MESSAGE); } } #define ASSERT(COND) ASSERT_M((COND), "Assertion '" #COND "' failed") +void ShowWarning( const char *file, int line, const char *message ); // don't pull in LOG here +#define WARN(MESSAGE) (ShowWarning(__FILE__, __LINE__, MESSAGE)) + #ifdef DEBUG #define DEBUG_ASSERT(x) ASSERT(x) #else