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
This commit is contained in:
Jaromir Wysoglad 2019-07-22 10:47:06 +02:00 committed by Thierry Crozat
parent c2177f8453
commit fc3ae4c9b9
7 changed files with 15 additions and 12 deletions

View file

@ -120,7 +120,7 @@ int writePixelData(std::ofstream &output, int imageNum, int skip) {
char *buf = new char[length]; char *buf = new char[length];
image.read(buf, length); image.read(buf, length);
output.write(buf, length); output.write(buf, length);
delete buf; delete[] buf;
return length; return length;
} }

View file

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/sh
./create_image ms2_data 15 1146 ./create_image ms2_data 15 1146

View file

@ -1 +1,3 @@
#!/bin/sh
./create_image ms2_data 27 1146 ./create_image ms2_data 27 1146

View file

@ -1 +1,3 @@
#!/bin/sh
./create_image ms2_data 28 829 ./create_image ms2_data 28 829

View file

@ -468,10 +468,9 @@ Common::SeekableReadStream *SupernovaEngine::getBlockFromDatFile(Common::String
return nullptr; return nullptr;
} }
int part;
uint32 gameBlockSize; uint32 gameBlockSize;
while (!f.eos()) { while (!f.eos()) {
part = f.readByte(); int part = f.readByte();
gameBlockSize = f.readUint32LE(); gameBlockSize = f.readUint32LE();
if (f.eos()){ if (f.eos()){
GUIErrorMessageFormat(_("Unable to find block for part %d"), _MSPart); GUIErrorMessageFormat(_("Unable to find block for part %d"), _MSPart);

View file

@ -1040,8 +1040,8 @@ void GameManager1::shock() {
void GameManager1::drawMapExits() { void GameManager1::drawMapExits() {
_vm->renderBox(281, 161, 39, 39, kColorWhite25); _vm->renderBox(281, 161, 39, 39, kColorWhite25);
int idx;
for (int i = 0; i < 25; i++) { for (int i = 0; i < 25; i++) {
int idx;
if ((idx = _exitList[i]) != -1) { if ((idx = _exitList[i]) != -1) {
byte r = _currentRoom->getObject(idx)->_direction; byte r = _currentRoom->getObject(idx)->_direction;
int x = 284 + 7 * (r % 5); int x = 284 + 7 * (r % 5);

View file

@ -431,8 +431,8 @@ void GameManager2::drawMapExits() {
(_currentRoom->getId() >= FLOORDOOR && _currentRoom->getId() <= BST_DOOR)) (_currentRoom->getId() >= FLOORDOOR && _currentRoom->getId() <= BST_DOOR))
compass(); compass();
else { else {
int idx;
for (int i = 0; i < 25; i++) { for (int i = 0; i < 25; i++) {
int idx;
if ((idx = _exitList[i]) != -1) { if ((idx = _exitList[i]) != -1) {
byte r = _currentRoom->getObject(idx)->_direction; byte r = _currentRoom->getObject(idx)->_direction;
int x = 284 + 7 * (r % 5); int x = 284 + 7 * (r % 5);
@ -1068,16 +1068,16 @@ void GameManager2::passageConstruction() {
} }
} }
_rooms[PYR_ENTRANCE]->setSectionVisible(9, _rooms[PYR_ENTRANCE]->setSectionVisible(9,
_rooms[PYR_ENTRANCE]->isSectionVisible(7) & _rooms[PYR_ENTRANCE]->isSectionVisible(7) &&
!_rooms[PYR_ENTRANCE]->isSectionVisible(1)); !_rooms[PYR_ENTRANCE]->isSectionVisible(1));
_rooms[PYR_ENTRANCE]->setSectionVisible(10, _rooms[PYR_ENTRANCE]->setSectionVisible(10,
_rooms[PYR_ENTRANCE]->isSectionVisible(7) & _rooms[PYR_ENTRANCE]->isSectionVisible(7) &&
!_rooms[PYR_ENTRANCE]->isSectionVisible(2)); !_rooms[PYR_ENTRANCE]->isSectionVisible(2));
_rooms[PYR_ENTRANCE]->setSectionVisible(11, _rooms[PYR_ENTRANCE]->setSectionVisible(11,
_rooms[PYR_ENTRANCE]->isSectionVisible(8) & _rooms[PYR_ENTRANCE]->isSectionVisible(8) &&
!_rooms[PYR_ENTRANCE]->isSectionVisible(3)); !_rooms[PYR_ENTRANCE]->isSectionVisible(3));
_rooms[PYR_ENTRANCE]->setSectionVisible(12, _rooms[PYR_ENTRANCE]->setSectionVisible(12,
_rooms[PYR_ENTRANCE]->isSectionVisible(8) & _rooms[PYR_ENTRANCE]->isSectionVisible(8) &&
!_rooms[PYR_ENTRANCE]->isSectionVisible(4)); !_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} {0,0,0,0,0,0,0,0,0,0,0,0}
} }
}; };
int newR;
if (stepsRight) { if (stepsRight) {
int newR;
if (stepsRight > 0) if (stepsRight > 0)
newR = (direction + 1) & 3; newR = (direction + 1) & 3;
else { else {
@ -1337,9 +1337,9 @@ void GameManager2::crack(int time) {
_cracking = true; _cracking = true;
_vm->_screen->changeCursor(ResourceManager::kCursorWait); _vm->_screen->changeCursor(ResourceManager::kCursorWait);
int t = 0; int t = 0;
int z;
int zv = 0; int zv = 0;
do { do {
int z;
do { do {
wait(1); wait(1);
} while ((z = (g_system->getMillis() - _state._startTime) / 600) == zv); } while ((z = (g_system->getMillis() - _state._startTime) / 600) == zv);