From 5239c2f4777d7f06fae59dd1750d70c4e56a855c Mon Sep 17 00:00:00 2001 From: Andrew Kurushin Date: Fri, 11 Feb 2005 20:59:29 +0000 Subject: - fix min->MIN - implemented horizontal tile cliping svn-id: r16774 --- saga/isomap.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'saga') diff --git a/saga/isomap.cpp b/saga/isomap.cpp index 314e3c31d0..eeca38ea30 100644 --- a/saga/isomap.cpp +++ b/saga/isomap.cpp @@ -393,7 +393,7 @@ void IsoMap::drawTile(SURFACE *ds, uint16 tileIndex, const Point &point) { Point drawPoint; int height; int widthCount = 0; - int row, col, lowBound; + int row, col, count, lowBound; int bgRunCount; int fgRunCount; @@ -403,13 +403,11 @@ void IsoMap::drawTile(SURFACE *ds, uint16 tileIndex, const Point &point) { } - /* temporary x clip */ - if (point.x < 0) { + if (point.x + SAGA_ISOTILE_WIDTH < _tileClip.left) { return; } - /* temporary x clip */ - if (point.x >= _tileClip.right - 32) { + if (point.x - SAGA_ISOTILE_WIDTH >= _tileClip.right) { return; } @@ -430,7 +428,7 @@ void IsoMap::drawTile(SURFACE *ds, uint16 tileIndex, const Point &point) { } readPointer = tilePointer; - lowBound = min(drawPoint.y + height, _tileClip.bottom); + lowBound = MIN((int)(drawPoint.y + height), (int)_tileClip.bottom); for (row = drawPoint.y; row < lowBound; row++) { widthCount = 0; if (row >= _tileClip.top) { @@ -448,12 +446,18 @@ void IsoMap::drawTile(SURFACE *ds, uint16 tileIndex, const Point &point) { fgRunCount = *readPointer++; widthCount += fgRunCount; - - while(fgRunCount-- > 0) { - *drawPointer++ = *readPointer++; + count = 0; + while ((col < _tileClip.left) && (count < fgRunCount)) { + count++; + col++; + } + while ((col < _tileClip.right) && (count < fgRunCount)) { + drawPointer[count] = readPointer[count]; + count++; + col++; } -// readPointer += fgRunCount; -// drawPointer += fgRunCount; + readPointer += fgRunCount; + drawPointer += fgRunCount; } } else { for (;;) { -- cgit v1.2.3