[Scummvm-git-logs] scummvm master -> 7ad8c6159aa839b112c51f55532fe6be0120a939
Strangerke
noreply at scummvm.org
Tue Jun 10 22:01:43 UTC 2025
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
cab79fd622 M4: Fix some PVS Studio V547 issues, some cleanup
137f092a29 M4: Fix the value of found in hash_search
7ad8c6159a M4: RIDDLE: Fix 2 issues in room 603 related to PVS Studio V547 issues
Commit: cab79fd62208dd8c244f390589e51a5a30f92a4b
https://github.com/scummvm/scummvm/commit/cab79fd62208dd8c244f390589e51a5a30f92a4b
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-06-10T23:01:29+01:00
Commit Message:
M4: Fix some PVS Studio V547 issues, some cleanup
Changed paths:
engines/m4/adv_r/adv_rails.cpp
engines/m4/adv_r/conv_io.cpp
engines/m4/burger/gui/interface.cpp
engines/m4/riddle/gui/interface.cpp
diff --git a/engines/m4/adv_r/adv_rails.cpp b/engines/m4/adv_r/adv_rails.cpp
index ef3e70aa008..d920295b866 100644
--- a/engines/m4/adv_r/adv_rails.cpp
+++ b/engines/m4/adv_r/adv_rails.cpp
@@ -33,7 +33,7 @@ namespace M4 {
#define RIGHT_EDGE 0x08
bool InitRails() {
- int32 i, edgeTableSize;
+ int32 i;
// Register with the stash the frequently used structs
if (!mem_register_stash_type(&_G(rails).memtypePATHN, sizeof(pathNode), 32, "+PATHNODE")) {
@@ -56,7 +56,7 @@ bool InitRails() {
// Calculate the size of the edge table, allocate, and initialize
// The edge table stores the upper triangle of a square matrix.
- edgeTableSize = (MAXRAILNODES * (MAXRAILNODES - 1)) >> 1;
+ const int32 edgeTableSize = (MAXRAILNODES * (MAXRAILNODES - 1)) >> 1;
if ((_G(rails).myEdges = (int16 *)mem_alloc(sizeof(int16) * edgeTableSize, "edge table")) == nullptr) {
return false;
}
@@ -92,8 +92,7 @@ void rail_system_shutdown(void) {
void ClearRails(void) {
- int32 i, edgeTableSize;
- noWalkRect *myRect;
+ int32 i;
if (_G(rails).myNodes) {
for (i = 0; i < MAXRAILNODES; i++) {
@@ -105,14 +104,14 @@ void ClearRails(void) {
}
if (_G(rails).myEdges) {
- edgeTableSize = (MAXRAILNODES * (MAXRAILNODES - 1)) >> 1;
+ int32 edgeTableSize = (MAXRAILNODES * (MAXRAILNODES - 1)) >> 1;
for (i = 0; i < edgeTableSize; i++) {
_G(rails).myEdges[i] = 0;
}
}
// Now turf the noWalkRectList
- myRect = _G(rails).noWalkRectList;
+ noWalkRect *myRect = _G(rails).noWalkRectList;
while (myRect) {
_G(rails).noWalkRectList = _G(rails).noWalkRectList->next;
mem_free((void *)myRect);
@@ -231,9 +230,6 @@ void intr_remove_no_walk_rect(noWalkRect *myRect) {
bool intr_LineCrossesRect(int32 line_x1, int32 line_y1, int32 line_x2, int32 line_y2,
int32 rect_x1, int32 rect_y1, int32 rect_x2, int32 rect_y2) {
- int32 p1X, p1Y, p2X, p2Y, mX, mY;
- uint8 endCode1, endCode2, midCode;
- bool finished;
// Ensure we have a valid rectangle
if ((rect_x1 > rect_x2) || (rect_y1 > rect_y2)) {
@@ -241,14 +237,14 @@ bool intr_LineCrossesRect(int32 line_x1, int32 line_y1, int32 line_x2, int32 lin
}
// Make copies of x1, y1, x2, y2
- p1X = line_x1;
- p1Y = line_y1;
- p2X = line_x2;
- p2Y = line_y2;
+ int32 p1X = line_x1;
+ int32 p1Y = line_y1;
+ int32 p2X = line_x2;
+ int32 p2Y = line_y2;
// Calculate the cohen sutherland codes for the endpoints of the line
// For (p1X, p1Y)
- endCode1 = 0;
+ uint8 endCode1 = 0;
if (p1X < rect_x1) {
endCode1 = LEFT_EDGE;
} else if (p1X > rect_x2) {
@@ -261,7 +257,7 @@ bool intr_LineCrossesRect(int32 line_x1, int32 line_y1, int32 line_x2, int32 lin
}
// For (p2X, p2Y)
- endCode2 = 0;
+ uint8 endCode2 = 0;
if (p2X < rect_x1) {
endCode2 = LEFT_EDGE;
} else if (p2X > rect_x2) {
@@ -278,7 +274,7 @@ bool intr_LineCrossesRect(int32 line_x1, int32 line_y1, int32 line_x2, int32 lin
return true;
}
- finished = false;
+ bool finished = false;
while (!finished) {
// If both have a bit set in common, then the line segment is completely off one edge
if (endCode1 & endCode2) {
@@ -286,8 +282,8 @@ bool intr_LineCrossesRect(int32 line_x1, int32 line_y1, int32 line_x2, int32 lin
}
// Calculate the mid point of the line segment
- mX = (p1X + p2X) >> 1;
- mY = (p1Y + p2Y) >> 1;
+ const int32 mX = (p1X + p2X) >> 1;
+ const int32 mY = (p1Y + p2Y) >> 1;
// Because the midpoint is an integer (round-off err), make sure it isn't the same
// as one of the two endpoints.
@@ -296,7 +292,7 @@ bool intr_LineCrossesRect(int32 line_x1, int32 line_y1, int32 line_x2, int32 lin
}
// Calculate the cohen sutherland codes for the midpoint of the line segment
- midCode = 0;
+ uint8 midCode = 0;
if (mX < rect_x1) {
midCode = LEFT_EDGE;
} else if (mX > rect_x2) {
@@ -332,17 +328,14 @@ bool intr_LineCrossesRect(int32 line_x1, int32 line_y1, int32 line_x2, int32 lin
static bool intr_LinePassesThroughRect(int32 x1, int32 y1, int32 x2, int32 y2) {
- noWalkRect *tempRect;
- bool intersected;
-
// If there aren't any no-walk rects, no problem, return false
if (!_G(rails).noWalkRectList) {
return false;
}
// Loop through the _G(rails).noWalkRectList
- tempRect = _G(rails).noWalkRectList;
- intersected = false;
+ noWalkRect *tempRect = _G(rails).noWalkRectList;
+ bool intersected = false;
while (tempRect && (!intersected)) {
// See if the line passes through tempRect
intersected = intr_LineCrossesRect(x1, y1, x2, y2, tempRect->x1, tempRect->y1, tempRect->x2, tempRect->y2);
@@ -356,19 +349,17 @@ static bool intr_LinePassesThroughRect(int32 x1, int32 y1, int32 x2, int32 y2) {
bool intr_LinesCross(int32 line1_x1, int32 line1_y1, int32 line1_x2, int32 line1_y2,
int32 line2_x1, int32 line2_y1, int32 line2_x2, int32 line2_y2) {
- bool intersected;
- int32 rectX1, rectY1, rectX2, rectY2;
// The theory is that either line1 intersects the rectangle created by line2, and/or line2
// intersects the rectangle reacted by line1.
// Make sure both lines are listed left to right, top to bottom when passing in the coords as a rectangle
- rectX1 = imath_min(line1_x1, line1_x2);
- rectY1 = imath_min(line1_y1, line1_y2);
- rectX2 = imath_max(line1_x1, line1_x2);
- rectY2 = imath_max(line1_y1, line1_y2);
+ int32 rectX1 = imath_min(line1_x1, line1_x2);
+ int32 rectY1 = imath_min(line1_y1, line1_y2);
+ int32 rectX2 = imath_max(line1_x1, line1_x2);
+ int32 rectY2 = imath_max(line1_y1, line1_y2);
- intersected = intr_LineCrossesRect(line2_x1, line2_y1, line2_x2, line2_y2, rectX1, rectY1, rectX2, rectY2);
+ bool intersected = intr_LineCrossesRect(line2_x1, line2_y1, line2_x2, line2_y2, rectX1, rectY1, rectX2, rectY2);
if (intersected) {
rectX1 = imath_min(line2_x1, line2_x2);
rectY1 = imath_min(line2_y1, line2_y2);
@@ -383,13 +374,9 @@ bool intr_LinesCross(int32 line1_x1, int32 line1_y1, int32 line1_x2, int32 line1
void CreateEdge(int32 node1, int32 node2, Buffer *walkCodes) {
- int32 i, temp;
- int32 index;
- int32 x1, y1, x2, y2;
- int32 y_unit, x_unit, xdiff, ydiff, scanX, scanY, width, height, error_term, stride;
- bool valid, finished;
- frac16 deltaX, deltaY, distance;
- uint8 *walkCodePtr;
+ int32 i;
+ int32 y_unit, error_term;
+ frac16 distance;
// Check for nodes and edges
if ((!_G(rails).myNodes) || (!_G(rails).myEdges)) {
@@ -404,52 +391,46 @@ void CreateEdge(int32 node1, int32 node2, Buffer *walkCodes) {
// Ensure node1 < node2
if (node2 < node1) {
- temp = node1;
- node1 = node2;
- node2 = temp;
+ SWAP(node1, node2);
}
// If node1 is y and node2 is x, first find table entry ie. tableWidth * y + x, the subtract
// n(n+1)/2 since only the upper triangle of the table is stored...
- index = (MAXRAILNODES - 1) * node1 + node2 - 1 - (node1 * (node1 + 1) >> 1);
+ const int32 index = (MAXRAILNODES - 1) * node1 + node2 - 1 - (node1 * (node1 + 1) >> 1);
_G(rails).myEdges[index] = 0;
- valid = true;
- walkCodePtr = nullptr;
- finished = false;
+ bool valid = true;
+ uint8 *walkCodePtr = nullptr;
+ bool finished = false;
if ((!_G(rails).myNodes[node1]) || (!_G(rails).myNodes[node2]))
return;
- x1 = _G(rails).myNodes[node1]->x;
- y1 = _G(rails).myNodes[node1]->y;
- x2 = _G(rails).myNodes[node2]->x;
- y2 = _G(rails).myNodes[node2]->y;
+ int32 x1 = _G(rails).myNodes[node1]->x;
+ int32 y1 = _G(rails).myNodes[node1]->y;
+ int32 x2 = _G(rails).myNodes[node2]->x;
+ int32 y2 = _G(rails).myNodes[node2]->y;
// Ensure the algorithm is symmetric...
if (x2 < x1) {
- temp = x1;
- x1 = x2;
- x2 = temp;
- temp = y1;
- y1 = y2;
- y2 = temp;
+ SWAP(x1, x2);
+ SWAP(y1, y2);
}
if (walkCodes && walkCodes->data) {
// Initialize the buffer data pointer, the maximum dimensions of the buffer, and the scan x and y
- width = walkCodes->w;
- stride = walkCodes->stride;
- height = walkCodes->h;
- scanX = x1;
- scanY = y1;
+ const int32 width = walkCodes->w;
+ const int32 stride = walkCodes->stride;
+ const int32 height = walkCodes->h;
+ int32 scanX = x1;
+ int32 scanY = y1;
// Calculate the difference along the y-axis
- ydiff = y2 - y1;
+ int32 yDiff = y2 - y1;
// If we are scanning from bottom to top
- if (ydiff < 0) {
+ if (yDiff < 0) {
- //set ydiff to be the absolute, and set the y_unit direction negative
- ydiff = -ydiff;
+ //set yDiff to be the absolute, and set the y_unit direction negative
+ yDiff = -yDiff;
y_unit = -1;
}
@@ -458,18 +439,18 @@ void CreateEdge(int32 node1, int32 node2, Buffer *walkCodes) {
y_unit = 1;
}
- // Because of the symmetry check, xdiff is always positive
- xdiff = x2 - x1;
- x_unit = 1;
+ // Because of the symmetry check, xDiff is always positive
+ int32 xDiff = x2 - x1;
+ int32 x_unit = 1;
// If the difference is bigger along the x axis
- if (xdiff > ydiff) {
+ if (xDiff > yDiff) {
// Initialize the error term
- error_term = xdiff >> 1;
+ error_term = xDiff >> 1;
// Loop along the x axis and adjust scanY as necessary
scanX = x1;
- for (i = 0; ((i <= xdiff) && valid && (!finished)); i++) {
+ for (i = 0; ((i <= xDiff) && valid && (!finished)); i++) {
// Check if we have scanned off the edge of the buffer
if ((scanX >= width) || ((y_unit > 0) && (scanY >= height)) || ((y_unit < 0) && (scanY < 0))) {
@@ -489,12 +470,12 @@ void CreateEdge(int32 node1, int32 node2, Buffer *walkCodes) {
// Update scanY if appropriate
// Update the error term
- error_term += ydiff;
+ error_term += yDiff;
// If the error_term has exceeded the xdiff, we need to move one unit along the y axis
- if (error_term >= xdiff) {
+ if (error_term >= xDiff) {
// Reset the error term
- error_term -= xdiff;
+ error_term -= xDiff;
// Move along the y axis
scanY += y_unit;
@@ -523,11 +504,11 @@ void CreateEdge(int32 node1, int32 node2, Buffer *walkCodes) {
} else {
// Else the difference is bigger along the y axis
// Initialize the error term
- error_term = ydiff >> 1;
+ error_term = yDiff >> 1;
// Loop along the y axis and adjust scanX as necessary
scanY = y1;
- for (i = 0; ((i <= ydiff) && valid && (!finished)); i++) {
+ for (i = 0; ((i <= yDiff) && valid && (!finished)); i++) {
// Check if we have scanned off the edge of the buffer
if (((x_unit > 0) && (scanX >= width)) || ((x_unit < 0) && (scanX < 0)) ||
((y_unit > 0) && (scanY >= height)) || ((y_unit < 0) && (scanY < 0))) {
@@ -547,12 +528,12 @@ void CreateEdge(int32 node1, int32 node2, Buffer *walkCodes) {
// Update scanX if appropriate
// Update the error term
- error_term += xdiff;
+ error_term += xDiff;
// If the error_term has exceeded the xdiff, we need to move one unit along the y axis
- if (error_term >= ydiff) {
+ if (error_term >= yDiff) {
// Reset the error term
- error_term -= ydiff;
+ error_term -= yDiff;
// Move along the x axis
scanX += x_unit;
@@ -591,8 +572,8 @@ void CreateEdge(int32 node1, int32 node2, Buffer *walkCodes) {
// Finally, if the edge is still valid, fill in the edge table with the distance between the nodes.
if (valid) {
- deltaX = imath_abs(((frac16)(x2 - x1)) << 16);
- deltaY = imath_abs(((frac16)(y2 - y1)) << 16);
+ frac16 deltaX = imath_abs(((frac16)(x2 - x1)) << 16);
+ frac16 deltaY = imath_abs(((frac16)(y2 - y1)) << 16);
if ((deltaX >= 0x800000) || (deltaY >= 0x800000)) {
deltaX >>= 16;
deltaY >>= 16;
@@ -607,25 +588,22 @@ void CreateEdge(int32 node1, int32 node2, Buffer *walkCodes) {
void RestoreNodeEdges(int32 nodeID, Buffer *walkCodes) {
- int32 i;
- for (i = 0; i < MAXRAILNODES; i++) {
+ for (int32 i = 0; i < MAXRAILNODES; i++) {
CreateEdge(i, nodeID, walkCodes);
}
}
void RestoreEdgeList(Buffer *walkCodes) {
- int32 i, j;
- for (i = 0; i < MAXRAILNODES; i++) {
- for (j = i + 1; j < MAXRAILNODES; j++) {
+ for (int32 i = 0; i < MAXRAILNODES; i++) {
+ for (int32 j = i + 1; j < MAXRAILNODES; j++) {
CreateEdge(i, j, walkCodes);
}
}
}
int32 AddRailNode(int32 x, int32 y, Buffer *walkCodes, bool restoreEdges) {
- int32 i, j;
- railNode *newNode;
+ int32 i;
if ((!_G(rails).myNodes) || (!_G(rails).myEdges)) {
return -1;
@@ -634,7 +612,8 @@ int32 AddRailNode(int32 x, int32 y, Buffer *walkCodes, bool restoreEdges) {
}
if (i < MAXRAILNODES) {
- if ((newNode = (railNode *)mem_alloc(sizeof(railNode), "railNode")) == nullptr) {
+ railNode *newNode = (railNode *)mem_alloc(sizeof(railNode), "railNode");
+ if (newNode == nullptr) {
return -1;
}
newNode->nodeID = (Byte)i;
@@ -643,7 +622,7 @@ int32 AddRailNode(int32 x, int32 y, Buffer *walkCodes, bool restoreEdges) {
_G(rails).myNodes[i] = newNode;
if (restoreEdges) {
- for (j = 0; j < MAXRAILNODES; j++) {
+ for (int32 j = 0; j < MAXRAILNODES; j++) {
if (_G(rails).myNodes[j]) CreateEdge(i, j, walkCodes);
}
}
@@ -696,26 +675,20 @@ bool RailNodeExists(int32 nodeID, int32 *nodeX, int32 *nodeY) {
}
int16 GetEdgeLength(int32 node1, int32 node2) {
- int32 temp;
- int32 index;
if (!_G(rails).myEdges) return 0;
if (node1 == node2) return 0;
if (node2 < node1) {
- temp = node1;
- node1 = node2;
- node2 = temp;
+ SWAP(node1, node2);
}
// If node1 is y and node2 is x, first find table entry ie. tableWidth * y + x, the subtract
// n(n+1)/2 since only the upper triangle of the table is stored...
- index = (MAXRAILNODES - 1) * node1 + node2 - 1 - (node1 * (node1 + 1) >> 1);
+ const int32 index = (MAXRAILNODES - 1) * node1 + node2 - 1 - (node1 * (node1 + 1) >> 1);
return _G(rails).myEdges[index];
}
void DisposePath(railNode *pathStart) {
- railNode *tempNode;
-
- tempNode = pathStart;
+ railNode *tempNode = pathStart;
while (tempNode) {
pathStart = pathStart->shortPath;
mem_free((void *)tempNode);
@@ -723,15 +696,15 @@ void DisposePath(railNode *pathStart) {
}
}
-
static railNode *DuplicatePath(railNode *pathStart) {
- railNode *newNode, *firstNode, *prevNode, *pathNode;
+ railNode *newNode;
// Initialize pointers
- firstNode = prevNode = nullptr;
+ railNode *firstNode = nullptr;
+ railNode *prevNode = nullptr;
// This routine assumes a valid path from _G(rails).myNodes[origID] following _G(rails).myNodes[]->shortPath until nullptr
- pathNode = pathStart;
+ railNode *pathNode = pathStart;
// Loop until nullptr - end of path
while (pathNode) {
@@ -763,11 +736,10 @@ static railNode *DuplicatePath(railNode *pathStart) {
railNode *CreateCustomPath(int coord, ...) {
va_list argPtr;
- railNode *firstNode, *prevNode = nullptr, *newNode;
- int32 x, y;
+ railNode *prevNode = nullptr;
// Initialize firstNode
- firstNode = nullptr;
+ railNode *firstNode = nullptr;
// Set argPtr to point to the beginning of the variable arg list
va_start(argPtr, coord);
@@ -775,15 +747,16 @@ railNode *CreateCustomPath(int coord, ...) {
// Loop until coord == -1
while (coord != -1) {
// Set x
- x = coord;
+ const int32 x = coord;
// Read the next arg off the arg list, and set y
coord = va_arg(argPtr, int);
- y = coord;
+ const int32 y = coord;
// Create a new node struct
- if ((newNode = (railNode *)mem_alloc(sizeof(railNode), "railNode")) == nullptr) {
+ railNode *newNode = (railNode *)mem_alloc(sizeof(railNode), "railNode");
+ if (newNode == nullptr) {
error_show(FL, 'OOM!', "could not alloc railNode");
return nullptr;
}
@@ -816,11 +789,9 @@ railNode *CreateCustomPath(int coord, ...) {
bool GetShortestPath(int32 origID, int32 destID, railNode **shortPath) {
- pathNode *thePath, *tempPathNode;
- railNode **checkStackTop, *currNode, *tempNode;
- int16 edgeDist, shortcutWeight;
- uint32 currPathNodes;
- int32 i, prevID, maxNodeID;
+ pathNode *tempPathNode;
+ railNode *tempNode;
+ int32 i, prevID;
*shortPath = nullptr;
@@ -842,7 +813,7 @@ bool GetShortestPath(int32 origID, int32 destID, railNode **shortPath) {
_G(rails).myNodes[destID]->shortPath = nullptr;
// Check to see if we can walk directly from oridID to destID
- edgeDist = GetEdgeLength(origID, destID);
+ int16 edgeDist = GetEdgeLength(origID, destID);
if (edgeDist > 0) {
_G(rails).myNodes[origID]->shortPath = _G(rails).myNodes[destID];
_G(rails).myNodes[destID]->pathWeight = edgeDist;
@@ -853,7 +824,7 @@ bool GetShortestPath(int32 origID, int32 destID, railNode **shortPath) {
// Otherwise, run the algorithm to determine the shortest path
// Initialize the railNodes and find the largest node ID to speed up for loops
- maxNodeID = 0;
+ int32 maxNodeID = 0;
for (i = 0; i < MAXRAILNODES; i++) {
tempNode = _G(rails).myNodes[i];
if (tempNode) {
@@ -867,8 +838,8 @@ bool GetShortestPath(int32 origID, int32 destID, railNode **shortPath) {
_G(rails).stackTop = _G(rails).stackBottom;
// Initialize the bitmask of the nodes and the current path list
- currPathNodes = 0;
- thePath = nullptr;
+ uint32 currPathNodes = 0;
+ pathNode *thePath = nullptr;
// Put the first node onto the stack (the address of, actually)
_G(rails).myNodes[origID]->pathWeight = 0;
@@ -878,7 +849,7 @@ bool GetShortestPath(int32 origID, int32 destID, railNode **shortPath) {
while (_G(rails).stackTop > _G(rails).stackBottom) {
// Take the first node off the stack
- currNode = *(--_G(rails).stackTop);
+ railNode *currNode = *(--_G(rails).stackTop);
// See if it is adjacent to the destination node - always 0 the first time through...
edgeDist = GetEdgeLength(currNode->nodeID, destID);
@@ -943,7 +914,7 @@ bool GetShortestPath(int32 origID, int32 destID, railNode **shortPath) {
_G(rails).stackTop++;
// Setup a temporary pointer, so we know whether any neighbors of the currNode were stacked...
- checkStackTop = _G(rails).stackTop;
+ railNode **checkStackTop = _G(rails).stackTop;
// Check to see whether the path leading to currNode is at least shorter than the current shortest path
if (currNode->pathWeight < _G(rails).myNodes[destID]->pathWeight) {
@@ -962,7 +933,7 @@ bool GetShortestPath(int32 origID, int32 destID, railNode **shortPath) {
// therefore the entire path will become shorter by the original weight to reach node i
// minus (the weight to get to the currNode plus the weight of the edge to
// get from the currNode to node i).
- shortcutWeight = (int16)(_G(rails).myNodes[i]->pathWeight - (currNode->pathWeight + edgeDist));
+ const int16 shortcutWeight = (int16)(_G(rails).myNodes[i]->pathWeight - (currNode->pathWeight + edgeDist));
// Loop from node i to the dest node, subtract the shortcutWeight, and or the bitmask
currPathNodes = 0;
@@ -1053,16 +1024,13 @@ bool GetShortestPath(int32 origID, int32 destID, railNode **shortPath) {
bool intr_PathCrossesLine(int32 startX, int32 startY, railNode *pathStart,
int32 line_x1, int32 line_y1, int32 line_x2, int32 line_y2) {
- railNode *tempNode;
- bool intersected;
- int32 prevX, prevY;
- intersected = false;
- prevX = startX;
- prevY = startY;
+ bool intersected = false;
+ int32 prevX = startX;
+ int32 prevY = startY;
// Loop through the path nodes. Each node is the end of line segment started at (prevX, prevY)
- tempNode = pathStart;
+ railNode *tempNode = pathStart;
while (tempNode && (!intersected)) {
intersected = intr_LinesCross(line_x1, line_y1, line_x2, line_y2, prevX, prevY, tempNode->x, tempNode->y);
prevX = tempNode->x;
diff --git a/engines/m4/adv_r/conv_io.cpp b/engines/m4/adv_r/conv_io.cpp
index d7cb570a5a9..89ee4fdd79a 100644
--- a/engines/m4/adv_r/conv_io.cpp
+++ b/engines/m4/adv_r/conv_io.cpp
@@ -536,27 +536,25 @@ static void conv_save_state(Conv *c) {
Common::copy(conv_save_buff, conv_save_buff + file_size, &_GC(convSave)[oldSize]);
}
- if (conv_save_buff)
- mem_free(conv_save_buff);
+ mem_free(conv_save_buff);
}
static Conv *conv_restore_state(Conv *c) {
- int32 ent = 0;
int32 tag, next;
- int32 myCNode;
-
+
entry_chunk *entry;
decl_chunk *decl;
short flag_index = 0;
int32 val;
int32 e_flags = 0;
-
+ int32 myCNode;
+
char fname[13];
- int file_size = 0;
- char *conv_save_buff = nullptr;
+ int file_size;
- ent = 0; c->myCNode = 0;
+ int32 ent = 0;
+ c->myCNode = 0;
find_and_set_conv_name(c);
Common::strcpy_s(fname, _GC(conv_name));
@@ -571,7 +569,7 @@ static Conv *conv_restore_state(Conv *c) {
return c;
}
- conv_save_buff = (char *)mem_alloc(file_size, "conv save buff");
+ char *conv_save_buff = (char *)mem_alloc(file_size, "conv save buff");
if (!conv_save_buff)
error_show(FL, 'OOM!');
@@ -663,8 +661,8 @@ static Conv *conv_restore_state(Conv *c) {
c->exit_now = CONV_OK;
i_am_so_done:
- if (conv_save_buff)
- mem_free(conv_save_buff);
+
+ mem_free(conv_save_buff);
return c;
}
diff --git a/engines/m4/burger/gui/interface.cpp b/engines/m4/burger/gui/interface.cpp
index 5c775f6a3bb..ddc1a1724e1 100644
--- a/engines/m4/burger/gui/interface.cpp
+++ b/engines/m4/burger/gui/interface.cpp
@@ -24,7 +24,6 @@
#include "m4/core/errors.h"
#include "m4/graphics/gr_series.h"
#include "m4/gui/gui_event.h"
-#include "m4/gui/gui_vmng.h"
#include "m4/burger/burger.h"
#include "m4/burger/vars.h"
#include "m4/adv_r/other.h"
@@ -402,12 +401,11 @@ ControlStatus Interface::trackHotspots(int event, int x, int y) {
_G(player).click_x = x;
_G(player).click_y = y;
- if (hotspot) {
- if (hotspot->feet_x != 0x7fff)
- _G(player).walk_x = hotspot->feet_x;
- if (hotspot->feet_y != 0x7fff)
- _G(player).walk_y = hotspot->feet_y;
- }
+ if (hotspot->feet_x != 0x7fff)
+ _G(player).walk_x = hotspot->feet_x;
+
+ if (hotspot->feet_y != 0x7fff)
+ _G(player).walk_y = hotspot->feet_y;
_G(player).walk_facing = hotspot->facing;
_hotspot = nullptr;
diff --git a/engines/m4/riddle/gui/interface.cpp b/engines/m4/riddle/gui/interface.cpp
index b357f92ac5f..b7587a360d1 100644
--- a/engines/m4/riddle/gui/interface.cpp
+++ b/engines/m4/riddle/gui/interface.cpp
@@ -315,22 +315,19 @@ ControlStatus Interface::trackHotspots(int event, int x, int y) {
_G(player).click_x = x;
_G(player).click_y = y;
- if (hotspot) {
- if (hotspot->feet_x != 0x7fff)
- _G(player).walk_x = hotspot->feet_x;
- if (hotspot->feet_y != 0x7fff)
- _G(player).walk_y = hotspot->feet_y;
- }
+ if (hotspot->feet_x != 0x7fff)
+ _G(player).walk_x = hotspot->feet_x;
+
+ if (hotspot->feet_y != 0x7fff)
+ _G(player).walk_y = hotspot->feet_y;
_G(player).walk_facing = hotspot->facing;
_hotspot = nullptr;
return SELECTED;
- } else {
- return IN_CONTROL;
}
- return ControlStatus::NOTHING;
+ return IN_CONTROL;
}
void Interface::dispatch_command() {
Commit: 137f092a292882221c3798e5e83ababb70647c2a
https://github.com/scummvm/scummvm/commit/137f092a292882221c3798e5e83ababb70647c2a
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-06-10T23:01:29+01:00
Commit Message:
M4: Fix the value of found in hash_search
Changed paths:
engines/m4/fileio/sys_file.cpp
diff --git a/engines/m4/fileio/sys_file.cpp b/engines/m4/fileio/sys_file.cpp
index c836d545ffd..77f1b3e0ad2 100644
--- a/engines/m4/fileio/sys_file.cpp
+++ b/engines/m4/fileio/sys_file.cpp
@@ -432,7 +432,7 @@ int SysFile::hash_search(const Common::String &fname, Hash_Record *current_hash_
local_name = local_hag_name;
if (!Common::File::exists(Common::Path(local_name))) {
- found = 1;
+ found = true;
find_offset = offset;
break;
}
@@ -447,7 +447,7 @@ int SysFile::hash_search(const Common::String &fname, Hash_Record *current_hash_
}
if (next_record == offset) {
// only one record of fname in hash table
- found = 1;
+ found = true;
} else {
offset = next_record;
}
Commit: 7ad8c6159aa839b112c51f55532fe6be0120a939
https://github.com/scummvm/scummvm/commit/7ad8c6159aa839b112c51f55532fe6be0120a939
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-06-10T23:01:30+01:00
Commit Message:
M4: RIDDLE: Fix 2 issues in room 603 related to PVS Studio V547 issues
Changed paths:
engines/m4/riddle/rooms/section6/room603.cpp
diff --git a/engines/m4/riddle/rooms/section6/room603.cpp b/engines/m4/riddle/rooms/section6/room603.cpp
index 1e26d50b981..b5df8856b4d 100644
--- a/engines/m4/riddle/rooms/section6/room603.cpp
+++ b/engines/m4/riddle/rooms/section6/room603.cpp
@@ -2133,7 +2133,6 @@ bool Room603::takePole() {
case 3:
_ttShould = 17;
_val9 = 5000;
- _val5 = 0;
kernel_timing_trigger(1, _val5 ? 400 : 500, KT_DAEMON, KT_PARSE);
sendWSMessage_140000(5);
return true;
@@ -2193,7 +2192,6 @@ void Room603::enter() {
case 3:
_ttShould = 17;
_val9 = 5000;
- _val5 = 0;
kernel_timing_trigger(1, _val5 ? 400 : 500, KT_DAEMON, KT_PARSE);
sendWSMessage_140000(5);
break;
More information about the Scummvm-git-logs
mailing list