aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaromir Wysoglad2019-07-22 10:47:06 +0200
committerThierry Crozat2019-07-28 15:09:14 +0100
commitfc3ae4c9b955f6b7e702993f38c25f61d49b593c (patch)
treee510c636593f3f932e1ad6316ad9682180fcb68e
parentc2177f84539472defe31c6fba80ad4a6f3357266 (diff)
downloadscummvm-rg350-fc3ae4c9b955f6b7e702993f38c25f61d49b593c.tar.gz
scummvm-rg350-fc3ae4c9b955f6b7e702993f38c25f61d49b593c.tar.bz2
scummvm-rg350-fc3ae4c9b955f6b7e702993f38c25f61d49b593c.zip
SUPERNOVA: Fix most of Codacy issues
* Fix mismatched delete in create_image.cpp * Add shebangs to create_ms2_data.***.sh * Reduce scopes of some variables * Substitute bitwise and for logical and in GamaManager2::passageConstruction
-rw-r--r--devtools/create_supernova/create_image/create_image.cpp2
-rwxr-xr-xdevtools/create_supernova/create_image/create_ms2_data.015.sh2
-rwxr-xr-xdevtools/create_supernova/create_image/create_ms2_data.027.sh2
-rwxr-xr-xdevtools/create_supernova/create_image/create_ms2_data.028.sh2
-rw-r--r--engines/supernova/supernova.cpp3
-rw-r--r--engines/supernova/supernova1/state.cpp2
-rw-r--r--engines/supernova/supernova2/state.cpp14
7 files changed, 15 insertions, 12 deletions
diff --git a/devtools/create_supernova/create_image/create_image.cpp b/devtools/create_supernova/create_image/create_image.cpp
index 1bf1e24f7c..6f71a0c440 100644
--- a/devtools/create_supernova/create_image/create_image.cpp
+++ b/devtools/create_supernova/create_image/create_image.cpp
@@ -120,7 +120,7 @@ int writePixelData(std::ofstream &output, int imageNum, int skip) {
char *buf = new char[length];
image.read(buf, length);
output.write(buf, length);
- delete buf;
+ delete[] buf;
return length;
}
diff --git a/devtools/create_supernova/create_image/create_ms2_data.015.sh b/devtools/create_supernova/create_image/create_ms2_data.015.sh
index 883cff6046..be3b253a57 100755
--- a/devtools/create_supernova/create_image/create_ms2_data.015.sh
+++ b/devtools/create_supernova/create_image/create_ms2_data.015.sh
@@ -1,3 +1,3 @@
-#!/bin/bash
+#!/bin/sh
./create_image ms2_data 15 1146
diff --git a/devtools/create_supernova/create_image/create_ms2_data.027.sh b/devtools/create_supernova/create_image/create_ms2_data.027.sh
index f9a744172e..fcac9442a8 100755
--- a/devtools/create_supernova/create_image/create_ms2_data.027.sh
+++ b/devtools/create_supernova/create_image/create_ms2_data.027.sh
@@ -1 +1,3 @@
+#!/bin/sh
+
./create_image ms2_data 27 1146
diff --git a/devtools/create_supernova/create_image/create_ms2_data.028.sh b/devtools/create_supernova/create_image/create_ms2_data.028.sh
index 66fda85204..1ebc280dd9 100755
--- a/devtools/create_supernova/create_image/create_ms2_data.028.sh
+++ b/devtools/create_supernova/create_image/create_ms2_data.028.sh
@@ -1 +1,3 @@
+#!/bin/sh
+
./create_image ms2_data 28 829
diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp
index 431438eb6d..8a7210720d 100644
--- a/engines/supernova/supernova.cpp
+++ b/engines/supernova/supernova.cpp
@@ -468,10 +468,9 @@ Common::SeekableReadStream *SupernovaEngine::getBlockFromDatFile(Common::String
return nullptr;
}
- int part;
uint32 gameBlockSize;
while (!f.eos()) {
- part = f.readByte();
+ int part = f.readByte();
gameBlockSize = f.readUint32LE();
if (f.eos()){
GUIErrorMessageFormat(_("Unable to find block for part %d"), _MSPart);
diff --git a/engines/supernova/supernova1/state.cpp b/engines/supernova/supernova1/state.cpp
index ee1fe46aa0..8130b2bb5a 100644
--- a/engines/supernova/supernova1/state.cpp
+++ b/engines/supernova/supernova1/state.cpp
@@ -1040,8 +1040,8 @@ void GameManager1::shock() {
void GameManager1::drawMapExits() {
_vm->renderBox(281, 161, 39, 39, kColorWhite25);
- int idx;
for (int i = 0; i < 25; i++) {
+ int idx;
if ((idx = _exitList[i]) != -1) {
byte r = _currentRoom->getObject(idx)->_direction;
int x = 284 + 7 * (r % 5);
diff --git a/engines/supernova/supernova2/state.cpp b/engines/supernova/supernova2/state.cpp
index 26f83ffb4d..8c94f1e518 100644
--- a/engines/supernova/supernova2/state.cpp
+++ b/engines/supernova/supernova2/state.cpp
@@ -431,8 +431,8 @@ void GameManager2::drawMapExits() {
(_currentRoom->getId() >= FLOORDOOR && _currentRoom->getId() <= BST_DOOR))
compass();
else {
- int idx;
for (int i = 0; i < 25; i++) {
+ int idx;
if ((idx = _exitList[i]) != -1) {
byte r = _currentRoom->getObject(idx)->_direction;
int x = 284 + 7 * (r % 5);
@@ -1068,16 +1068,16 @@ void GameManager2::passageConstruction() {
}
}
_rooms[PYR_ENTRANCE]->setSectionVisible(9,
- _rooms[PYR_ENTRANCE]->isSectionVisible(7) &
+ _rooms[PYR_ENTRANCE]->isSectionVisible(7) &&
!_rooms[PYR_ENTRANCE]->isSectionVisible(1));
_rooms[PYR_ENTRANCE]->setSectionVisible(10,
- _rooms[PYR_ENTRANCE]->isSectionVisible(7) &
+ _rooms[PYR_ENTRANCE]->isSectionVisible(7) &&
!_rooms[PYR_ENTRANCE]->isSectionVisible(2));
_rooms[PYR_ENTRANCE]->setSectionVisible(11,
- _rooms[PYR_ENTRANCE]->isSectionVisible(8) &
+ _rooms[PYR_ENTRANCE]->isSectionVisible(8) &&
!_rooms[PYR_ENTRANCE]->isSectionVisible(3));
_rooms[PYR_ENTRANCE]->setSectionVisible(12,
- _rooms[PYR_ENTRANCE]->isSectionVisible(8) &
+ _rooms[PYR_ENTRANCE]->isSectionVisible(8) &&
!_rooms[PYR_ENTRANCE]->isSectionVisible(4));
}
@@ -1141,8 +1141,8 @@ byte GameManager2::wall(int s, int z, int direction, int stepsForward, int steps
{0,0,0,0,0,0,0,0,0,0,0,0}
}
};
- int newR;
if (stepsRight) {
+ int newR;
if (stepsRight > 0)
newR = (direction + 1) & 3;
else {
@@ -1337,9 +1337,9 @@ void GameManager2::crack(int time) {
_cracking = true;
_vm->_screen->changeCursor(ResourceManager::kCursorWait);
int t = 0;
- int z;
int zv = 0;
do {
+ int z;
do {
wait(1);
} while ((z = (g_system->getMillis() - _state._startTime) / 600) == zv);