From feed359d5fcba7ec90f66d3fa55a36ca31a3ed9b Mon Sep 17 00:00:00 2001 From: mathnerd314 Date: Sun, 24 Jan 2010 20:04:45 +0000 Subject: [PATCH] Use NDEBUG a bit less. git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6270 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- src/audio/ogg_sound_file.cpp | 3 --- src/audio/sound_manager.cpp | 10 ---------- src/lisp/parser.cpp | 1 + src/object/anchor_point.cpp | 12 ------------ src/sprite/sprite.cpp | 3 --- src/supertux/main.cpp | 8 -------- src/util/log.cpp | 12 ++---------- src/util/log.hpp | 21 ++++++++++----------- src/video/gl/gl_texture.cpp | 4 +++- src/video/glutil.hpp | 8 -------- 10 files changed, 16 insertions(+), 66 deletions(-) diff --git a/src/audio/ogg_sound_file.cpp b/src/audio/ogg_sound_file.cpp index 182371c38..fd7c7fc3e 100644 --- a/src/audio/ogg_sound_file.cpp +++ b/src/audio/ogg_sound_file.cpp @@ -135,11 +135,8 @@ OggSoundFile::cb_seek(void* source, ogg_int64_t offset, int whence) return -1; break; default: -#ifndef NDEBUG assert(false); -#else return -1; -#endif } return 0; } diff --git a/src/audio/sound_manager.cpp b/src/audio/sound_manager.cpp index a65f38f25..6bd2c31d1 100644 --- a/src/audio/sound_manager.cpp +++ b/src/audio/sound_manager.cpp @@ -27,16 +27,6 @@ #include "audio/stream_sound_source.hpp" #include "util/log.hpp" -#ifdef NDEBUG -/** Older openal versions often miss this function and it isn't that vital for - * supertux... - */ -#ifdef alcGetString -# undef alcGetString -#endif -# define alcGetString(x,y) "" -#endif - SoundManager::SoundManager() : device(0), context(0), diff --git a/src/lisp/parser.cpp b/src/lisp/parser.cpp index 86609a67a..fad69a111 100644 --- a/src/lisp/parser.cpp +++ b/src/lisp/parser.cpp @@ -202,6 +202,7 @@ Parser::read() default: // this should never happen + result = NULL; assert(false); } diff --git a/src/object/anchor_point.cpp b/src/object/anchor_point.cpp index 0c0519124..2499c9ed8 100644 --- a/src/object/anchor_point.cpp +++ b/src/object/anchor_point.cpp @@ -91,9 +91,6 @@ Vector get_anchor_pos(const Rectf& rect, AnchorPoint point) result.x = rect.get_right(); break; default: -#ifndef NDEBUG - throw std::runtime_error("Invalid anchor point found"); -#endif log_warning << "Invalid anchor point found" << std::endl; result.x = rect.get_left(); break; @@ -110,9 +107,6 @@ Vector get_anchor_pos(const Rectf& rect, AnchorPoint point) result.y = rect.get_bottom(); break; default: -#ifndef NDEBUG - throw std::runtime_error("Invalid anchor point found"); -#endif log_warning << "Invalid anchor point found" << std::endl; result.y = rect.get_top(); break; @@ -137,9 +131,6 @@ Vector get_anchor_pos(const Rectf& destrect, float width, float height, result.x = destrect.get_right() - width; break; default: -#ifndef NDEBUG - throw std::runtime_error("Invalid anchor point found"); -#endif log_warning << "Invalid anchor point found" << std::endl; result.x = destrect.get_left(); break; @@ -156,9 +147,6 @@ Vector get_anchor_pos(const Rectf& destrect, float width, float height, result.y = destrect.get_bottom() - height; break; default: -#ifndef NDEBUG - throw std::runtime_error("Invalid anchor point found"); -#endif log_warning << "Invalid anchor point found" << std::endl; result.y = destrect.get_top(); break; diff --git a/src/sprite/sprite.cpp b/src/sprite/sprite.cpp index 2ee515a96..01c41cfe8 100644 --- a/src/sprite/sprite.cpp +++ b/src/sprite/sprite.cpp @@ -149,11 +149,8 @@ Sprite::draw_part(DrawingContext& context, const Vector& source, int frameidx = (int) frame; if(frameidx >= get_frames() || frameidx < 0) { -#ifdef NDEBUG // in optimized mode we get some small rounding errors in floating point // number sometimes... - log_warning << "frame out of range: " << frameidx << "/" << get_frames() << " at sprite: " << get_name() << "/" << get_action() << std::endl; -#endif frameidx = get_frames() - 1; } diff --git a/src/supertux/main.cpp b/src/supertux/main.cpp index 0ffd43ca6..048ebab73 100644 --- a/src/supertux/main.cpp +++ b/src/supertux/main.cpp @@ -432,11 +432,9 @@ Main::init_video() SDL_WM_SetIcon(icon, 0); SDL_FreeSurface(icon); } -#ifndef NDEBUG else { log_warning << "Couldn't load icon '" << icon_fname << "'" << std::endl; } -#endif SDL_ShowCursor(0); @@ -505,7 +503,6 @@ Main::wait_for_event(float min_delay, float max_delay) } } -#ifndef NDEBUG static Uint32 last_timelog_ticks = 0; static const char* last_timelog_component = 0; @@ -520,11 +517,6 @@ static inline void timelog(const char* component) last_timelog_ticks = current_ticks; last_timelog_component = component; } -#else -static inline void timelog(const char* ) -{ -} -#endif int Main::run(int argc, char** argv) diff --git a/src/util/log.cpp b/src/util/log.cpp index eafc99bfc..7b0107b9d 100644 --- a/src/util/log.cpp +++ b/src/util/log.cpp @@ -39,22 +39,14 @@ std::ostream& log_warning_f(const char* file, int line) return Console::output; } +#endif + std::ostream& log_fatal_f(const char* file, int line) { Console::output << "[FATAL] " << file << ":" << line << " "; return Console::output; } -#else - -std::ostream& log_fatal_f() -{ - Console::output << "Fatal: "; - return Console::output; -} - -#endif - std::ostream& operator<<(std::ostream& out, const Vector& vector) { out << '[' << vector.x << ',' << vector.y << ']'; diff --git a/src/util/log.hpp b/src/util/log.hpp index 54bcb789a..b5219b292 100644 --- a/src/util/log.hpp +++ b/src/util/log.hpp @@ -18,34 +18,33 @@ #define HEADER_SUPERTUX_UTIL_LOG_HPP #include +#include #ifndef NDEBUG -#include - std::ostream& log_debug_f(const char* file, int line); -std::ostream& log_info_f(const char* file, int line); -std::ostream& log_warning_f(const char* file, int line); -std::ostream& log_fatal_f(const char* file, int line); - #define log_debug log_debug_f(__FILE__, __LINE__) + +std::ostream& log_info_f(const char* file, int line); #define log_info log_info_f(__FILE__, __LINE__) + +std::ostream& log_warning_f(const char* file, int line); #define log_warning log_warning_f(__FILE__, __LINE__) -#define log_fatal log_fatal_f(__FILE__, __LINE__) #else #include -std::ostream& log_fatal_f(); - -#define log_debug if (0) std::cerr +#define log_debug std::cout #define log_info std::cout #define log_warning std::cerr -#define log_fatal log_fatal_f() #endif +std::ostream& log_fatal_f(const char* file, int line); + +#define log_fatal log_fatal_f(__FILE__, __LINE__) + class Vector; std::ostream& operator<< (std::ostream& str, const Vector& vector); class Rectf; diff --git a/src/video/gl/gl_texture.cpp b/src/video/gl/gl_texture.cpp index 008e96fa3..9e2b70dda 100644 --- a/src/video/gl/gl_texture.cpp +++ b/src/video/gl/gl_texture.cpp @@ -118,8 +118,10 @@ GLTexture::GLTexture(SDL_Surface* image) : sdl_format = GL_RGB; else if(convert->format->BytesPerPixel == 4) sdl_format = GL_RGBA; - else + else { + sdl_format = GL_RGBA; assert(false); + } glBindTexture(GL_TEXTURE_2D, handle); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); diff --git a/src/video/glutil.hpp b/src/video/glutil.hpp index 2b46f6d7f..e51240dfa 100644 --- a/src/video/glutil.hpp +++ b/src/video/glutil.hpp @@ -41,7 +41,6 @@ static inline void check_gl_error(const char* message) { -#ifndef NDEBUG GLenum error = glGetError(); if(error != GL_NO_ERROR) { std::ostringstream msg; @@ -79,18 +78,11 @@ static inline void check_gl_error(const char* message) throw std::runtime_error(msg.str()); } -#else - (void) message; -#endif } static inline void assert_gl(const char* message) { -#ifndef NDEBUG check_gl_error(message); -#else - (void) message; -#endif } #else -- 2.11.0