[Scummvm-git-logs] scummvm master -> 0079e20c61156388c00061cb1954ffbf32ff11b6
sev-
noreply at scummvm.org
Thu Sep 5 11:58:44 UTC 2024
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
508ab7b2d7 QDEGNINE: Added sanity checks to tile decompressor
dfb7a7a32d QDENGINE: Improved logging for tile loading
6221e52470 QDENGINE: Moved scale computation to a separate method
0079e20c61 QDENGINE: Renames in ScaleArray struct
Commit: 508ab7b2d7be5f1ec5feae91449e5891429dbf80
https://github.com/scummvm/scummvm/commit/508ab7b2d7be5f1ec5feae91449e5891429dbf80
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-05T13:58:23+02:00
Commit Message:
QDEGNINE: Added sanity checks to tile decompressor
Changed paths:
engines/qdengine/system/graphics/gr_tile_animation.cpp
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.cpp b/engines/qdengine/system/graphics/gr_tile_animation.cpp
index 0257bd48c5a..33fbe44465a 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_animation.cpp
@@ -129,11 +129,20 @@ grTileSprite grTileAnimation::getTile(int tile_index) const {
case TILE_UNCOMPRESSED:
return grTileSprite(&*_tileData.begin() + _tileOffsets[tile_index]);
default:
+ if (tile_index >= _tileOffsets.size()) {
+ warning("grTileAnimation::getTile(): Too big tile index %d >= %d", tile_index, _tileOffsets.size());
+ break;
+ }
+ if (_tileOffsets[tile_index] >= _tileData.size()) {
+ warning("grTileAnimation::getTile(): Too big tile offset %d (%d >= %d)", tile_index, _tileOffsets[tile_index], _tileData.size());
+ break;
+ }
if (!grTileSprite::uncompress(&*_tileData.begin() + _tileOffsets[tile_index], GR_TILE_SPRITE_SIZE, tile_buf, _compression)) {
assert(0 && "Unknown compression algorithm");
}
- return grTileSprite(tile_buf);
}
+
+ return grTileSprite(tile_buf);
}
void grTileAnimation::addFrame(const uint32 *frame_data) {
@@ -483,6 +492,9 @@ void grTileAnimation::dumpTiles(Common::Path basename, int tilesPerRow) {
break;
}
+ if (index >= _tileOffsets.size())
+ break;
+
y += GR_TILE_SPRITE_SIZE_X + 1;
}
Commit: dfb7a7a32ddaeb48440443f7e0128c39fc913e80
https://github.com/scummvm/scummvm/commit/dfb7a7a32ddaeb48440443f7e0128c39fc913e80
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-05T13:58:26+02:00
Commit Message:
QDENGINE: Improved logging for tile loading
Changed paths:
engines/qdengine/system/graphics/gr_tile_animation.cpp
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.cpp b/engines/qdengine/system/graphics/gr_tile_animation.cpp
index 33fbe44465a..2a392ac1e30 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_animation.cpp
@@ -270,7 +270,10 @@ bool grTileAnimation::load(Common::SeekableReadStream *fh, int version) {
debugCN(dL + 1, kDebugLoad, " ");
for (uint i = 0; i < size; i++) {
_frameIndex[i] = fh->readUint32LE();
- debugCN(dL + 1, kDebugLoad, " %d ", _frameIndex[i]);
+ debugCN(dL + 1, kDebugLoad, " %5d ", _frameIndex[i]);
+
+ if ((i + 1) % 20 == 0)
+ debugCN(dL + 1, kDebugLoad, "\n ");
}
debugCN(dL + 1, kDebugLoad, "\n");
@@ -283,7 +286,10 @@ bool grTileAnimation::load(Common::SeekableReadStream *fh, int version) {
debugCN(dL, kDebugLoad, " ");
for (uint i = 0; i < size; i++) {
_tileOffsets[i] = fh->readUint32LE();
- debugCN(dL + 1, kDebugLoad, " %d ", _tileOffsets[i]);
+ debugCN(dL + 1, kDebugLoad, " %6d ", _tileOffsets[i]);
+
+ if ((i + 1) % 20 == 0)
+ debugCN(dL + 1, kDebugLoad, "\n ");
}
debugCN(dL + 1, kDebugLoad, "\n");
@@ -293,13 +299,8 @@ bool grTileAnimation::load(Common::SeekableReadStream *fh, int version) {
_tileData.resize(size);
- debugCN(dL, kDebugLoad, " ");
-
- for (uint i = 0; i < size; i++) {
+ for (uint i = 0; i < size; i++)
_tileData[i] = fh->readUint32LE();
- debugCN(dL + 1, kDebugLoad, " %08x ", _tileData[i]);
- }
- debugCN(dL + 1, kDebugLoad, "\n");
debugC(dL + 1, kDebugLoad, " --> grTileAnimation::load(): pos: %ld remaining: %ld", fh->pos(), fh->size() - fh->pos());
Commit: 6221e52470004963ea117bd2776e0df9e3bafd81
https://github.com/scummvm/scummvm/commit/6221e52470004963ea117bd2776e0df9e3bafd81
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-05T13:58:26+02:00
Commit Message:
QDENGINE: Moved scale computation to a separate method
Changed paths:
engines/qdengine/system/graphics/gr_tile_animation.cpp
engines/qdengine/system/graphics/gr_tile_animation.h
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.cpp b/engines/qdengine/system/graphics/gr_tile_animation.cpp
index 2a392ac1e30..685aeb52bc5 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_animation.cpp
@@ -225,17 +225,7 @@ bool grTileAnimation::load(Common::SeekableReadStream *fh, int version) {
for (uint i = 0; i < size; i++) {
float scale = fh->readFloatLE();
- _scaleArray[i]._scale = scale;
- _scaleArray[i]._frameSize.x = (int)((float)_frameSize.x * scale);
- _scaleArray[i]._frameSize.y = (int)((float)_frameSize.y * scale);
- _scaleArray[i]._pitch.x = (_scaleArray[i]._frameSize.x + 15) / 16;
- _scaleArray[i]._pitch.y = (_scaleArray[i]._frameSize.y + 15) / 16;
-
- if (i == 0)
- _scaleArray[i]._numTiles = _frameTileSize.x * _frameTileSize.y * _frameCount;
- else
- _scaleArray[i]._numTiles = _scaleArray[i - 1]._numTiles
- + _frameCount * _scaleArray[i - 1]._pitch.y * _scaleArray[i - 1]._pitch.x;
+ addScale(i, scale);
debugCN(dL + 1, kDebugLoad, " %f, { %d x %d, [%d x %d], tiles: %d } ", _scaleArray[i]._scale,
_scaleArray[i]._frameSize.x, _scaleArray[i]._frameSize.y, _scaleArray[i]._pitch.x,
@@ -396,6 +386,20 @@ void grTileAnimation::drawFrame_scale(const Vect2i &position, int frame_index, f
//// New version 105 & 106 code
//////////////////////////////////////////////////////////////////////
+void grTileAnimation::addScale(int i, float scale) {
+ _scaleArray[i]._scale = scale;
+ _scaleArray[i]._frameSize.x = (int)((float)_frameSize.x * scale);
+ _scaleArray[i]._frameSize.y = (int)((float)_frameSize.y * scale);
+ _scaleArray[i]._pitch.x = (_scaleArray[i]._frameSize.x + 15) / 16;
+ _scaleArray[i]._pitch.y = (_scaleArray[i]._frameSize.y + 15) / 16;
+
+ if (i == 0)
+ _scaleArray[i]._numTiles = _frameTileSize.x * _frameTileSize.y * _frameCount;
+ else
+ _scaleArray[i]._numTiles = _scaleArray[i - 1]._numTiles
+ + _frameCount * _scaleArray[i - 1]._pitch.y * _scaleArray[i - 1]._pitch.x;
+}
+
byte *grTileAnimation::decode_frame_data(int frame_index, int closest_scale) const {
Vect2i frameSize;
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.h b/engines/qdengine/system/graphics/gr_tile_animation.h
index 03c51ca1e9e..1c0ddb0a436 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.h
+++ b/engines/qdengine/system/graphics/gr_tile_animation.h
@@ -80,6 +80,7 @@ public:
_progressHandlerContext = context;
}
+ void addScale(int i, float scale);
byte *decode_frame_data(int frame_index, int closest_scale) const;
int find_closest_scale(float *scale) const;
bool wasFrameSizeChanged(int frame_index, int scaleIdx, float scale) const;
Commit: 0079e20c61156388c00061cb1954ffbf32ff11b6
https://github.com/scummvm/scummvm/commit/0079e20c61156388c00061cb1954ffbf32ff11b6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-05T13:58:26+02:00
Commit Message:
QDENGINE: Renames in ScaleArray struct
Changed paths:
engines/qdengine/system/graphics/gr_tile_animation.cpp
engines/qdengine/system/graphics/gr_tile_animation.h
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.cpp b/engines/qdengine/system/graphics/gr_tile_animation.cpp
index 685aeb52bc5..c89729367b3 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_animation.cpp
@@ -228,8 +228,8 @@ bool grTileAnimation::load(Common::SeekableReadStream *fh, int version) {
addScale(i, scale);
debugCN(dL + 1, kDebugLoad, " %f, { %d x %d, [%d x %d], tiles: %d } ", _scaleArray[i]._scale,
- _scaleArray[i]._frameSize.x, _scaleArray[i]._frameSize.y, _scaleArray[i]._pitch.x,
- _scaleArray[i]._pitch.y, _scaleArray[i]._numTiles);
+ _scaleArray[i]._frameSize.x, _scaleArray[i]._frameSize.y, _scaleArray[i]._frameTileSize.x,
+ _scaleArray[i]._frameTileSize.y, _scaleArray[i]._frameStart);
}
debugCN(dL + 1, kDebugLoad, "\n");
}
@@ -300,12 +300,12 @@ bool grTileAnimation::load(Common::SeekableReadStream *fh, int version) {
void grTileAnimation::drawFrame(const Vect2i &position, int32 frame_index, int32 mode, int closest_scale) const {
Vect2i frameSize = _frameSize;
Vect2i frameTileSize = _frameTileSize;
- int numTiles = 0;
+ int frameStart = 0;
if (closest_scale != -1) {
frameSize = _scaleArray[closest_scale]._frameSize;
- frameTileSize = _scaleArray[closest_scale]._pitch;
- numTiles = _scaleArray[closest_scale]._numTiles;
+ frameTileSize = _scaleArray[closest_scale]._frameTileSize;
+ frameStart = _scaleArray[closest_scale]._frameStart;
}
Vect2i pos0 = position - frameSize / 2;
@@ -324,7 +324,7 @@ void grTileAnimation::drawFrame(const Vect2i &position, int32 frame_index, int32
// grDispatcher::instance()->Rectangle(position.x - _frameSize.x/2, position.y - _frameSize.y/2, _frameSize.x, _frameSize.y, 0xFFFFF, 0, GR_OUTLINED);
- const uint32 *index_ptr = &_frameIndex[numTiles] + frameTileSize.x * frameTileSize.y * frame_index;
+ const uint32 *index_ptr = &_frameIndex[frameStart] + frameTileSize.x * frameTileSize.y * frame_index;
Vect2i pos = pos0;
for (int32 i = 0; i < frameTileSize.y; i++) {
@@ -390,14 +390,14 @@ void grTileAnimation::addScale(int i, float scale) {
_scaleArray[i]._scale = scale;
_scaleArray[i]._frameSize.x = (int)((float)_frameSize.x * scale);
_scaleArray[i]._frameSize.y = (int)((float)_frameSize.y * scale);
- _scaleArray[i]._pitch.x = (_scaleArray[i]._frameSize.x + 15) / 16;
- _scaleArray[i]._pitch.y = (_scaleArray[i]._frameSize.y + 15) / 16;
+ _scaleArray[i]._frameTileSize.x = (_scaleArray[i]._frameSize.x + 15) / 16;
+ _scaleArray[i]._frameTileSize.y = (_scaleArray[i]._frameSize.y + 15) / 16;
if (i == 0)
- _scaleArray[i]._numTiles = _frameTileSize.x * _frameTileSize.y * _frameCount;
+ _scaleArray[i]._frameStart = _frameTileSize.x * _frameTileSize.y * _frameCount;
else
- _scaleArray[i]._numTiles = _scaleArray[i - 1]._numTiles
- + _frameCount * _scaleArray[i - 1]._pitch.y * _scaleArray[i - 1]._pitch.x;
+ _scaleArray[i]._frameStart = _scaleArray[i - 1]._frameStart
+ + _frameCount * _scaleArray[i - 1]._frameTileSize.y * _scaleArray[i - 1]._frameTileSize.x;
}
byte *grTileAnimation::decode_frame_data(int frame_index, int closest_scale) const {
@@ -412,17 +412,17 @@ byte *grTileAnimation::decode_frame_data(int frame_index, int closest_scale) con
if (closest_scale == -1)
frameTileSize = _frameTileSize;
else
- frameTileSize = _scaleArray[closest_scale]._pitch;
+ frameTileSize = _scaleArray[closest_scale]._frameTileSize;
- int numTiles;
+ int frameStart;
if (closest_scale == -1)
- numTiles = 0;
+ frameStart = 0;
else
- numTiles = _scaleArray[closest_scale]._numTiles;
+ frameStart = _scaleArray[closest_scale]._frameStart;
byte *buf = (byte *)grDispatcher::instance()->temp_buffer(frameSize.x * frameSize.y * 4);
- const uint32 *index_ptr = &_frameIndex[numTiles] + frameTileSize.x * frameTileSize.y * frame_index;
+ const uint32 *index_ptr = &_frameIndex[frameStart] + frameTileSize.x * frameTileSize.y * frame_index;
for (int i = 0; i < frameTileSize.y; i++) {
for (int j = 0; j < frameTileSize.x; j++) {
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.h b/engines/qdengine/system/graphics/gr_tile_animation.h
index 1c0ddb0a436..2af342d8b3f 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.h
+++ b/engines/qdengine/system/graphics/gr_tile_animation.h
@@ -109,8 +109,8 @@ private:
struct ScaleArray {
float _scale;
Vect2i _frameSize;
- Vect2i _pitch;
- int _numTiles;
+ Vect2i _frameTileSize;
+ int _frameStart;
};
Std::vector<ScaleArray> _scaleArray;
More information about the Scummvm-git-logs
mailing list