[Scummvm-cvs-logs] SF.net SVN: scummvm:[33687] scummvm/trunk/engines/cine/gfx.cpp
buddha_ at users.sourceforge.net
buddha_ at users.sourceforge.net
Thu Aug 7 21:31:13 CEST 2008
Revision: 33687
http://scummvm.svn.sourceforge.net/scummvm/?rev=33687&view=rev
Author: buddha_
Date: 2008-08-07 19:31:12 +0000 (Thu, 07 Aug 2008)
Log Message:
-----------
Made drawPlainBox handle border cases so it won't corrupt memory so easily. This may help with some memory corruption issues when for an example trying to draw the player's command string out of screen.
Modified Paths:
--------------
scummvm/trunk/engines/cine/gfx.cpp
Modified: scummvm/trunk/engines/cine/gfx.cpp
===================================================================
--- scummvm/trunk/engines/cine/gfx.cpp 2008-08-07 19:04:19 UTC (rev 33686)
+++ scummvm/trunk/engines/cine/gfx.cpp 2008-08-07 19:31:12 UTC (rev 33687)
@@ -282,21 +282,44 @@
*/
void FWRenderer::drawPlainBox(int x, int y, int width, int height, byte color) {
int i;
- byte *dest = _backBuffer + y * 320 + x;
+ // Handle horizontally flipped boxes
if (width < 0) {
x += width;
- width = -width;
+ width = ABS(width);
}
+ // Handle vertically flipped boxes
if (height < 0) {
y += height;
- height = -height;
+ height = ABS(height);
}
- for (i = 0; i < height; i++) {
- memset(dest + i * 320, color, width);
+ // Handle horizontal boundaries
+ if (x < 0) {
+ width += x; // Remove invisible columns
+ x = 0; // Start drawing at the screen's left border
+ } else if (x > 319) {
+ // Nothing left to draw as we're over the screen's right border
+ width = 0;
}
+
+ // Handle vertical boundaries
+ if (y < 0) {
+ height += y; // Remove invisible rows
+ y = 0; // Start drawing at the screen's top border
+ } else if (y > 199) {
+ // Nothing left to draw as we're below the screen's bottom border
+ height = 0;
+ }
+
+ // Draw the box if it's not empty
+ if (width > 0 && height > 0) {
+ byte *dest = _backBuffer + y * 320 + x;
+ for (i = 0; i < height; i++) {
+ memset(dest + i * 320, color, width);
+ }
+ }
}
/*! \brief Draw empty rectangle
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list