--- a/src/gfx.cpp Tue Jun 17 10:32:49 2008 +0000
+++ b/src/gfx.cpp Tue Jun 17 13:22:13 2008 +0000
@@ -18,6 +18,7 @@
#include "core/math_func.hpp"
#include "settings_type.h"
#include "core/alloc_func.hpp"
+#include "core/sort_func.hpp"
#include "landscape_type.h"
#include "table/palettes.h"
@@ -689,7 +690,7 @@
}
}
-static inline void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub)
+static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub)
{
const DrawPixelInfo *dpi = _cur_dpi;
Blitter::BlitterParams bp;
@@ -715,8 +716,8 @@
bp.height = UnScaleByZoom(sprite->height - clip_top - clip_bottom, dpi->zoom);
bp.top = 0;
bp.left = 0;
- bp.skip_left = UnScaleByZoom(clip_left, dpi->zoom);
- bp.skip_top = UnScaleByZoom(clip_top, dpi->zoom);
+ bp.skip_left = UnScaleByZoomLower(clip_left, dpi->zoom);
+ bp.skip_top = UnScaleByZoomLower(clip_top, dpi->zoom);
x += ScaleByZoom(bp.skip_left, dpi->zoom);
y += ScaleByZoom(bp.skip_top, dpi->zoom);
@@ -767,6 +768,9 @@
if (bp.width <= 0) return;
}
+ assert(bp.skip_left + bp.width <= UnScaleByZoom(sprite->width, dpi->zoom));
+ assert(bp.skip_top + bp.height <= UnScaleByZoom(sprite->height, dpi->zoom));
+
BlitterFactoryBase::GetCurrentBlitter()->Draw(&bp, mode, dpi->zoom);
}
@@ -1309,14 +1313,14 @@
return result;
}
-static int CDECL compare_res(const void *pa, const void *pb)
+static int CDECL compare_res(const Dimension *pa, const Dimension *pb)
{
- int x = ((const uint16*)pa)[0] - ((const uint16*)pb)[0];
+ int x = pa->width - pb->width;
if (x != 0) return x;
- return ((const uint16*)pa)[1] - ((const uint16*)pb)[1];
+ return pa->height - pb->height;
}
void SortResolutions(int count)
{
- qsort(_resolutions, count, sizeof(_resolutions[0]), compare_res);
+ QSortT(_resolutions, count, &compare_res);
}