From 5f97a39ee0bdc6898e6c8be2bc86d8b5f6de8008 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Wed, 19 Apr 2006 11:57:36 +0000 Subject: [PATCH] silence the 'frame out of range' warning in optimized mode SVN-Revision: 3366 --- src/sprite/sprite.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/sprite/sprite.cpp b/src/sprite/sprite.cpp index 4a0adb364..6c7cedbd2 100644 --- a/src/sprite/sprite.cpp +++ b/src/sprite/sprite.cpp @@ -114,12 +114,20 @@ Sprite::draw_part(DrawingContext& context, const Vector& source, assert(action != 0); update(); - if((int)frame >= get_frames() || (int)frame < 0) - log_warning << "frame out of range: " << (int)frame << "/" << get_frames() << " at sprite: " << get_name() << "/" << get_action_name() << std::endl; - else - context.draw_surface_part(action->surfaces[(int)frame], source, size, - pos - Vector(action->x_offset, action->y_offset), - layer + action->z_order); + int frameidx = (int) frame; + + if(frameidx >= get_frames() || frameidx < 0) { +#ifndef DEBUG + // 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_name() << std::endl; +#endif + frameidx = get_frames() - 1; + } + + context.draw_surface_part(action->surfaces[frameidx], source, size, + pos - Vector(action->x_offset, action->y_offset), + layer + action->z_order); } int -- 2.11.0