[Scummvm-git-logs] scummvm master -> 456c55d89f54cc5e26bce5e29e5d1e7aaef37805
mgerhardy
noreply at scummvm.org
Mon Nov 29 15:57:59 UTC 2021
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
27dd214bd0 TWINE: fixed off-by-one in clipping code
456c55d89f TWINE: converted member to local variable
Commit: 27dd214bd04466c04e3ab276883a8b28b086def1
https://github.com/scummvm/scummvm/commit/27dd214bd04466c04e3ab276883a8b28b086def1
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-11-29T16:52:44+01:00
Commit Message:
TWINE: fixed off-by-one in clipping code
Changed paths:
engines/twine/scene/grid.cpp
diff --git a/engines/twine/scene/grid.cpp b/engines/twine/scene/grid.cpp
index 1be6b1abe0..997acef3fb 100644
--- a/engines/twine/scene/grid.cpp
+++ b/engines/twine/scene/grid.cpp
@@ -475,7 +475,7 @@ bool Grid::drawSprite(int32 index, int32 posX, int32 posY, const uint8 *ptr) {
bool Grid::drawSprite(int32 posX, int32 posY, const SpriteData &ptr, int spriteIndex) {
const int32 left = posX + ptr.offsetX(spriteIndex);
- if (left > _engine->_interface->_clip.right) {
+ if (left >= _engine->_interface->_clip.right) {
return false;
}
const int32 right = ptr.surface(spriteIndex).w + left;
@@ -483,7 +483,7 @@ bool Grid::drawSprite(int32 posX, int32 posY, const SpriteData &ptr, int spriteI
return false;
}
const int32 top = posY + ptr.offsetY(spriteIndex);
- if (top > _engine->_interface->_clip.bottom) {
+ if (top >= _engine->_interface->_clip.bottom) {
return false;
}
const int32 bottom = ptr.surface(spriteIndex).h + top;
@@ -506,7 +506,7 @@ bool Grid::drawBrickSprite(int32 index, int32 posX, int32 posY, const uint8 *ptr
}
const int32 left = posX + *(ptr + 2);
- if (left > _engine->_interface->_clip.right) {
+ if (left >= _engine->_interface->_clip.right) {
return false;
}
const int32 right = *ptr + left;
@@ -514,7 +514,7 @@ bool Grid::drawBrickSprite(int32 index, int32 posX, int32 posY, const uint8 *ptr
return false;
}
const int32 top = posY + *(ptr + 3);
- if (top > _engine->_interface->_clip.bottom) {
+ if (top >= _engine->_interface->_clip.bottom) {
return false;
}
const int32 bottom = (int32)*(ptr + 1) + top;
Commit: 456c55d89f54cc5e26bce5e29e5d1e7aaef37805
https://github.com/scummvm/scummvm/commit/456c55d89f54cc5e26bce5e29e5d1e7aaef37805
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-11-29T16:56:11+01:00
Commit Message:
TWINE: converted member to local variable
Changed paths:
engines/twine/scene/grid.cpp
engines/twine/scene/grid.h
diff --git a/engines/twine/scene/grid.cpp b/engines/twine/scene/grid.cpp
index 997acef3fb..d3676f9fe7 100644
--- a/engines/twine/scene/grid.cpp
+++ b/engines/twine/scene/grid.cpp
@@ -613,9 +613,9 @@ const BlockData *Grid::getBlockLibrary(int32 blockIdx) const {
return _currentBlockLibrary.getLayout(blockIdx - 1);
}
-void Grid::getBrickPos(int32 x, int32 y, int32 z) {
- _brickPixelPosX = (x - z) * 24 + _engine->width() / 2 - GRID_SIZE_X / 2;
- _brickPixelPosY = ((x + z) * 12) - (y * 15) + _engine->height() / 2 - GRID_SIZE_Y;
+void Grid::getBrickPos(int32 x, int32 y, int32 z, int32 &posx, int32 &posy) const {
+ posx = (x - z) * 24 + _engine->width() / 2 - GRID_SIZE_X / 2;
+ posy = ((x + z) * 12) - (y * 15) + _engine->height() / 2 - GRID_SIZE_Y;
}
void Grid::drawColumnGrid(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y, int32 z) {
@@ -627,25 +627,28 @@ void Grid::drawColumnGrid(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y,
return;
}
- getBrickPos(x - _newCamera.x, y - _newCamera.y, z - _newCamera.z);
+ int32 brickPixelPosX = 0;
+ int32 brickPixelPosY = 0;
- if (_brickPixelPosX < -24) {
+ getBrickPos(x - _newCamera.x, y - _newCamera.y, z - _newCamera.z, brickPixelPosX, brickPixelPosY);
+
+ if (brickPixelPosX < -24) {
return;
}
- if (_brickPixelPosX >= _engine->width()) {
+ if (brickPixelPosX >= _engine->width()) {
return;
}
- if (_brickPixelPosY < -38) {
+ if (brickPixelPosY < -38) {
return;
}
- if (_brickPixelPosY >= _engine->height()) {
+ if (brickPixelPosY >= _engine->height()) {
return;
}
// draw the background brick
- drawBrick(brickIdx - 1, _brickPixelPosX, _brickPixelPosY);
+ drawBrick(brickIdx - 1, brickPixelPosX, brickPixelPosY);
- int32 brickBuffIdx = (_brickPixelPosX + 24) / 24;
+ int32 brickBuffIdx = (brickPixelPosX + 24) / 24;
if (_brickInfoBuffer[brickBuffIdx] >= MAXBRICKS) {
warning("GRID: brick buffer exceeded");
@@ -657,8 +660,8 @@ void Grid::drawColumnGrid(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y,
currBrickEntry->x = x;
currBrickEntry->y = y;
currBrickEntry->z = z;
- currBrickEntry->posX = _brickPixelPosX;
- currBrickEntry->posY = _brickPixelPosY;
+ currBrickEntry->posX = brickPixelPosX;
+ currBrickEntry->posY = brickPixelPosY;
currBrickEntry->index = brickIdx - 1;
currBrickEntry->shape = brickShape;
currBrickEntry->sound = brickSound;
diff --git a/engines/twine/scene/grid.h b/engines/twine/scene/grid.h
index 4c99576cfd..572bfe5792 100644
--- a/engines/twine/scene/grid.h
+++ b/engines/twine/scene/grid.h
@@ -110,7 +110,7 @@ private:
* @param y column y position in the current camera
* @param z column z position in the current camera
*/
- void getBrickPos(int32 x, int32 y, int32 z);
+ void getBrickPos(int32 x, int32 y, int32 z, int32 &_brickPixelPosX, int32 &_brickPixelPosY) const;
/**
* Create celling grid map from celling grid to block library buffer
* @param gridPtr celling grid buffer pointer
@@ -170,11 +170,6 @@ private:
int16 *_brickInfoBuffer = nullptr;
int32 _brickInfoBufferSize = 0;
- /** Current brick pixel X position */
- int32 _brickPixelPosX = 0;
- /** Current brick pixel Y position */
- int32 _brickPixelPosY = 0;
-
/** Celling grid brick block buffer */
int32 _blockBufferSize = 0;
uint8 *_blockBuffer = nullptr;
More information about the Scummvm-git-logs
mailing list