[Scummvm-git-logs] scummvm branch-2-5 -> bb6f77952c05ed50d223a14035b1fc9ad4832c0d
ccawley2011
ccawley2011 at gmail.com
Mon Oct 4 19:59:39 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:
813b3158b4 TWINE: Additional stream checks when loading the body data
bb6f77952c TWINE: changed access to BlockEntry data
Commit: 813b3158b4b411f3ed49cdeb931feb4c1da6ce85
https://github.com/scummvm/scummvm/commit/813b3158b4b411f3ed49cdeb931feb4c1da6ce85
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2021-10-04T20:01:46+01:00
Commit Message:
TWINE: Additional stream checks when loading the body data
This fixes a crash on startup on RISC OS.
Changed paths:
engines/twine/parser/body.cpp
diff --git a/engines/twine/parser/body.cpp b/engines/twine/parser/body.cpp
index 9e870e0503..9edab0143e 100644
--- a/engines/twine/parser/body.cpp
+++ b/engines/twine/parser/body.cpp
@@ -37,6 +37,9 @@ void BodyData::reset() {
void BodyData::loadVertices(Common::SeekableReadStream &stream) {
const uint16 numVertices = stream.readUint16LE();
+ if (stream.eos())
+ return;
+
_vertices.reserve(numVertices);
for (uint16 i = 0U; i < numVertices; ++i) {
const int16 x = stream.readSint16LE();
@@ -49,6 +52,9 @@ void BodyData::loadVertices(Common::SeekableReadStream &stream) {
void BodyData::loadBones(Common::SeekableReadStream &stream) {
const uint16 numBones = stream.readUint16LE();
+ if (stream.eos())
+ return;
+
_bones.reserve(numBones);
for (uint16 i = 0; i < numBones; ++i) {
const int16 firstPoint = stream.readSint16LE() / 6;
@@ -88,6 +94,9 @@ void BodyData::loadBones(Common::SeekableReadStream &stream) {
void BodyData::loadShades(Common::SeekableReadStream &stream) {
const uint16 numShades = stream.readUint16LE();
+ if (stream.eos())
+ return;
+
_shades.reserve(numShades);
for (uint16 i = 0; i < numShades; ++i) {
BodyShade shape;
@@ -101,6 +110,9 @@ void BodyData::loadShades(Common::SeekableReadStream &stream) {
void BodyData::loadPolygons(Common::SeekableReadStream &stream) {
const uint16 numPolygons = stream.readUint16LE();
+ if (stream.eos())
+ return;
+
_polygons.reserve(numPolygons);
for (uint16 i = 0; i < numPolygons; ++i) {
BodyPolygon poly;
@@ -130,6 +142,9 @@ void BodyData::loadPolygons(Common::SeekableReadStream &stream) {
void BodyData::loadLines(Common::SeekableReadStream &stream) {
const uint16 numLines = stream.readUint16LE();
+ if (stream.eos())
+ return;
+
_lines.reserve(numLines);
for (uint16 i = 0; i < numLines; ++i) {
BodyLine line;
@@ -144,6 +159,9 @@ void BodyData::loadLines(Common::SeekableReadStream &stream) {
void BodyData::loadSpheres(Common::SeekableReadStream &stream) {
const uint16 numSpheres = stream.readUint16LE();
+ if (stream.eos())
+ return;
+
_spheres.reserve(numSpheres);
for (uint16 i = 0; i < numSpheres; ++i) {
BodySphere sphere;
Commit: bb6f77952c05ed50d223a14035b1fc9ad4832c0d
https://github.com/scummvm/scummvm/commit/bb6f77952c05ed50d223a14035b1fc9ad4832c0d
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-10-04T20:02:03+01:00
Commit Message:
TWINE: changed access to BlockEntry data
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 287dd9bc18..eea31b1b8b 100644
--- a/engines/twine/scene/grid.cpp
+++ b/engines/twine/scene/grid.cpp
@@ -41,7 +41,7 @@
namespace TwinE {
Grid::Grid(TwinEEngine *engine) : _engine(engine) {
- _blockBufferSize = GRID_SIZE_X * GRID_SIZE_Z * GRID_SIZE_Y * 2 * sizeof(uint8);
+ _blockBufferSize = GRID_SIZE_X * GRID_SIZE_Z * GRID_SIZE_Y * sizeof(BlockEntry);
_blockBuffer = (uint8 *)malloc(_blockBufferSize);
}
@@ -661,8 +661,6 @@ void Grid::drawColumnGrid(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y,
}
void Grid::redrawGrid() {
- blockMap *map = (blockMap *)_blockBuffer;
-
_camera.x = _newCamera.x * BRICK_SIZE;
_camera.y = _newCamera.y * BRICK_HEIGHT;
_camera.z = _newCamera.z * BRICK_SIZE;
@@ -676,15 +674,27 @@ void Grid::redrawGrid() {
for (int32 z = 0; z < GRID_SIZE_Z; z++) {
for (int32 x = 0; x < GRID_SIZE_X; x++) {
for (int32 y = 0; y < GRID_SIZE_Y; y++) {
- const uint8 blockIdx = (*map)[z][x][y].blockIdx;
- if (blockIdx) {
- drawColumnGrid(blockIdx, (*map)[z][x][y].brickBlockIdx, x, y, z);
+ const BlockEntry entry = getBlockEntry(x, y, z);
+ if (entry.blockIdx) {
+ drawColumnGrid(entry.blockIdx, entry.brickBlockIdx, x, y, z);
}
}
}
}
}
+BlockEntry Grid::getBlockEntry(int32 x, int32 y, int32 z) const {
+ const uint8 *blockBufferPtr = _blockBuffer;
+ blockBufferPtr += x * GRID_SIZE_Y * 2;
+ blockBufferPtr += y * 2;
+ blockBufferPtr += (z * GRID_SIZE_X * 2) * GRID_SIZE_Y;
+
+ BlockEntry entry;
+ entry.blockIdx = *blockBufferPtr;
+ entry.brickBlockIdx = *(blockBufferPtr + 1);
+ return entry;
+}
+
ShapeType Grid::getBrickShape(int32 x, int32 y, int32 z) {
const IVec3 &collision = updateCollisionCoordinates(x, y, z);
@@ -700,19 +710,12 @@ ShapeType Grid::getBrickShape(int32 x, int32 y, int32 z) {
return ShapeType::kNone;
}
- const uint8 *blockBufferPtr = _blockBuffer;
- blockBufferPtr += collision.x * GRID_SIZE_Y * 2;
- blockBufferPtr += collision.y * 2;
- blockBufferPtr += (collision.z * GRID_SIZE_X * 2) * GRID_SIZE_Y;
-
- const uint8 blockIdx = *blockBufferPtr;
-
- if (blockIdx) {
- const uint8 tmpBrickIdx = *(blockBufferPtr + 1);
- const BlockDataEntry *blockPtr = getBlockPointer(blockIdx, tmpBrickIdx);
+ const BlockEntry entry = getBlockEntry(collision.x, collision.y, collision.z);
+ if (entry.blockIdx) {
+ const BlockDataEntry *blockPtr = getBlockPointer(entry.blockIdx, entry.brickBlockIdx);
return (ShapeType)blockPtr->brickShape;
}
- return (ShapeType) * (blockBufferPtr + 1);
+ return (ShapeType)entry.brickBlockIdx;
}
const IVec3 &Grid::updateCollisionCoordinates(int32 x, int32 y, int32 z) {
@@ -803,16 +806,9 @@ uint8 Grid::getBrickSoundType(int32 x, int32 y, int32 z) {
return 0; // none
}
- const uint8 *blockBufferPtr = _blockBuffer;
- blockBufferPtr += collision.x * GRID_SIZE_Y * 2;
- blockBufferPtr += collision.y * 2;
- blockBufferPtr += (collision.z * GRID_SIZE_X * 2) * GRID_SIZE_Y;
-
- uint8 blockIdx = *blockBufferPtr;
-
- if (blockIdx) {
- uint8 tmpBrickIdx = *(blockBufferPtr + 1);
- const BlockDataEntry *blockPtr = getBlockPointer(blockIdx, tmpBrickIdx);
+ const BlockEntry entry = getBlockEntry(collision.x, collision.y, collision.z);
+ if (entry.blockIdx) {
+ const BlockDataEntry *blockPtr = getBlockPointer(entry.blockIdx, entry.brickBlockIdx);
return blockPtr->brickType;
}
diff --git a/engines/twine/scene/grid.h b/engines/twine/scene/grid.h
index e2e1c93740..4ab519b653 100644
--- a/engines/twine/scene/grid.h
+++ b/engines/twine/scene/grid.h
@@ -180,15 +180,14 @@ private:
const BrickEntry* getBrickEntry(int32 j, int32 i) const;
const IVec3 &updateCollisionCoordinates(int32 x, int32 y, int32 z);
+
+ BlockEntry getBlockEntry(int32 x, int32 y, int32 z) const;
public:
Grid(TwinEEngine *engine);
~Grid();
void init(int32 w, int32 h);
- /** Grid block entry types */
- typedef struct BlockEntry blockMap[GRID_SIZE_X][GRID_SIZE_Z][GRID_SIZE_Y];
-
/**
* search down until either ground is found or lower border of the cube is reached
*/
More information about the Scummvm-git-logs
mailing list