Skip to content

Commit

Permalink
refactor: better logical grouping, several range detachment warnings …
Browse files Browse the repository at this point in the history
…and other small warning cleanups
  • Loading branch information
sithlord48 committed Sep 8, 2024
1 parent 6bf781a commit 562bc35
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/data/FF7Char.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ quint8 FF7Char::id(int who)

bool FF7Char::validID(int id)
{
return !(id < 0 || id > 11);
return !((id < 0) || (id > 11));
}

int FF7Char::numberOfWeapons(int who)
Expand Down
4 changes: 2 additions & 2 deletions src/data/FF7Item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ QStringList FF7Item::elementalEffects(int id)
{

QStringList elementList;
if (id < 0 || id > 319) {
if ((id < 0) || (id > 319)) {
return elementList;
}
for (int i = 0; i < 14; i++) {
Expand Down Expand Up @@ -273,7 +273,7 @@ QStringList FF7Item::statusEffects(int id)
{

QStringList statusList;
if (id < 0 || id > 319) {
if ((id < 0) || (id > 319)) {
return statusList;
}
for (int i = 0; i < 24; i++) {
Expand Down
3 changes: 3 additions & 0 deletions src/data/FF7Location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ const QString &FF7Location::fileName(int MapID, int LocID)
return it->filename;
return get()->dPtr->_emptyLocation.filename;
}

QString FF7Location::rawLocationString(int index)
{
return get()->dPtr->_locations.at(index).location;
}

QString FF7Location::rawLocationString(const QString &fileName)
{
return location(fileName).location;
}

QString FF7Location::locationString(int index)
{
return tr(get()->dPtr->_locations.at(index).location.toUtf8());
Expand Down
6 changes: 4 additions & 2 deletions src/formats/IsoArchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,8 @@ IsoDirectory *IsoArchive::_openDirectoryRecord(IsoDirectory *directories, QList<
}
}

for (IsoDirectory *dir : directories->directories()) {
const auto dirs = directories->directories();
for (IsoDirectory *dir : dirs) {
if (!dir->isSpecial()) {
if (!_openDirectoryRecord(dir, dirVisisted)) {
qWarning() << "IsoArchive::_openDirectoryRecord cannot open directory" << dir->name() << dir->location();
Expand Down Expand Up @@ -1263,7 +1264,8 @@ bool IsoArchive::extractDir(const QString &path, const QString &destination) con
QDir destDir(destination);
bool error = false;

for (IsoFile *file : dir->files()) {
const auto files = dir->files();
for (IsoFile *file : files) {
if (!file->extract(destDir.filePath(file->name()))) {
error = true;
}
Expand Down
8 changes: 4 additions & 4 deletions src/formats/IsoArchiveFF7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ IsoFile *IsoArchiveFF7::searchExe() const
}

static const QRegularExpression exeName(QRegularExpression::anchoredPattern("[A-Z]{4}_\\d{3}\\.\\d{2}"));
QList<IsoFile *> files = rootDirectory()->files();
const QList<IsoFile *> files = rootDirectory()->files();
for (IsoFile *isoFile : files) {
QRegularExpressionMatch match = exeName.match(isoFile->name());
if (match.hasMatch()) {
Expand Down Expand Up @@ -231,7 +231,7 @@ QMap<int, QString> IsoArchiveFF7::maplist()

QMap<int, QString> orderedFields, ret;
int min = -1;
QList<IsoFile *> files = fieldDirectory->files();
const QList<IsoFile *> files = fieldDirectory->files();

for (const IsoFile *field : files) {
if (!field->name().endsWith(".DAT")) {
Expand Down Expand Up @@ -381,7 +381,7 @@ IsoFile *IsoArchiveFF7::updateFieldBin()
}

QList<IsoFile *> files;
QList<IsoFile *> f = fieldDirectory->files();
const QList<IsoFile *> f = fieldDirectory->files();
for (IsoFile *file : f) {
if (!file->name().endsWith(".X")
&& file->name() != "FIELD.BIN") {
Expand Down Expand Up @@ -412,7 +412,7 @@ IsoFile *IsoArchiveFF7::updateWorldBin()
}

QList<IsoFile *> files;
QList<IsoFile *> f = worldDirectory->files();
const QList<IsoFile *> f = worldDirectory->files();
for (IsoFile *file : f) {
if (file->name() != "WORLD.BIN") {
files.append(file);
Expand Down
3 changes: 2 additions & 1 deletion src/formats/Lgp_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ bool LgpToc::hasEntries(quint16 id) const

LgpHeaderEntry *LgpToc::entry(const QString &filePath, quint16 id) const
{
for (LgpHeaderEntry *entry : entries(id)) {
const auto _entries = entries(id);
for (LgpHeaderEntry *entry : _entries) {
if (filePath.compare(entry->filePath(), Qt::CaseInsensitive) == 0) {
return entry;
}
Expand Down
2 changes: 1 addition & 1 deletion src/formats/TexFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ bool TexFile::open(const QByteArray &data)
quint16 color;
_image = QImage(w, h, QImage::Format_ARGB32);
QRgb *pixels = reinterpret_cast<QRgb *>(_image.bits());
if (header.bytesPerPixel < 2 || header.bytesPerPixel > 4) {
if ((header.bytesPerPixel < 2) || (header.bytesPerPixel > 4)) {
qWarning() << "tex invalid bytesPerPixel!" << header.bytesPerPixel;
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/common/DialogPreview.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FF7TKQTWIDGETS_EXPORT DialogPreview : public QLabel
BOTTOMRIGHT=2,
BOTTOMLEFT=3,
};
Q_ENUM(CORNER);
Q_ENUM(CORNER)

DialogPreview(QWidget *parent = nullptr);
~DialogPreview() = default;
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/common/ImageGridWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void ImageGridWidget::paintEvent(QPaintEvent *event)
QColor lightRed(0xff, 0x7f, 0x7f);

p.setPen(hasFocus() ? Qt::red : lightRed);
for (const Cell &cell: _selectedCells) {
for (const Cell &cell: std::as_const(_selectedCells)) {
drawSelection(p, cell);
}

Expand Down

0 comments on commit 562bc35

Please sign in to comment.