clean up launcher helpers
This commit is contained in:
parent
2bf78a94e0
commit
218e7200bb
|
|
@ -1,20 +0,0 @@
|
|||
#ifndef LAUNCHER_INCLUDE_COMMON_H_
|
||||
#define LAUNCHER_INCLUDE_COMMON_H_
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <QArgument>
|
||||
#include <QObject>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
// IWYU pragma: end_exports
|
||||
|
||||
#define KYTY_QT_CLASS_NO_COPY(name) \
|
||||
public: \
|
||||
name(const name&) = delete; /* NOLINT(bugprone-macro-parentheses) */ \
|
||||
name& operator=(const name&) = delete; /* NOLINT(bugprone-macro-parentheses) */ \
|
||||
name(name&&) noexcept = delete; /* NOLINT(bugprone-macro-parentheses) */ \
|
||||
name& operator=(name&&) noexcept = delete; /* NOLINT(bugprone-macro-parentheses) */
|
||||
|
||||
#endif /* LAUNCHER_INCLUDE_COMMON_H_ */
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef COMPATIBILITY_DATABASE_H
|
||||
#define COMPATIBILITY_DATABASE_H
|
||||
|
||||
#include "common.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#include <QMap>
|
||||
|
|
@ -15,7 +14,6 @@ struct CompatibilityEntry {
|
|||
|
||||
class CompatibilityDatabase: public QObject {
|
||||
Q_OBJECT
|
||||
KYTY_QT_CLASS_NO_COPY(CompatibilityDatabase);
|
||||
|
||||
public:
|
||||
explicit CompatibilityDatabase(bool local, QObject* parent = nullptr);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
#ifndef LAUNCHER_INCLUDE_CONFIGURATION_H_
|
||||
#define LAUNCHER_INCLUDE_CONFIGURATION_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "common/emulatorConfig.h"
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QChar>
|
||||
#include <QMetaEnum>
|
||||
#include <QMetaType>
|
||||
#include <QObject>
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
#ifndef CONFIGURATION_EDIT_DIALOG_H
|
||||
#define CONFIGURATION_EDIT_DIALOG_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
|
@ -22,7 +20,6 @@ class ConfigurationEditDialog;
|
|||
|
||||
class ConfigurationEditDialog: public QDialog {
|
||||
Q_OBJECT
|
||||
KYTY_QT_CLASS_NO_COPY(ConfigurationEditDialog);
|
||||
|
||||
public:
|
||||
explicit ConfigurationEditDialog(Configuration& info, QWidget* parent = nullptr);
|
||||
|
|
@ -31,7 +28,6 @@ public:
|
|||
static void WriteSettings(QSettings& s);
|
||||
static void ReadSettings(QSettings& s);
|
||||
|
||||
void SetTitle(const QString& str);
|
||||
void SetGameDirectories(const QStringList& dirs);
|
||||
[[nodiscard]] QStringList GetGameDirectories() const;
|
||||
|
||||
|
|
@ -55,8 +51,6 @@ protected:
|
|||
|
||||
/*slots:*/
|
||||
|
||||
void update_info();
|
||||
void adjust_size();
|
||||
void save();
|
||||
void clear();
|
||||
void add_game_directory();
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
#ifndef CONFIGURATION_ITEM_H
|
||||
#define CONFIGURATION_ITEM_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
|
|
@ -23,8 +21,6 @@ public:
|
|||
void Update();
|
||||
bool operator<(const QTreeWidgetItem& other) const override;
|
||||
|
||||
KYTY_QT_CLASS_NO_COPY(ConfigurationItem);
|
||||
|
||||
Configuration& GetInfo() { return *m_info; }
|
||||
[[nodiscard]] const Configuration& GetInfo() const { return *m_info; }
|
||||
// void SetInfo(Configuration* info);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef CONFIGURATION_LIST_WIDGET_H
|
||||
#define CONFIGURATION_LIST_WIDGET_H
|
||||
|
||||
#include "common.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#include <QMap>
|
||||
|
|
@ -14,7 +13,6 @@ class CompatibilityDatabase;
|
|||
class QEvent;
|
||||
class QTreeWidgetItem;
|
||||
class QPoint;
|
||||
class MainDialog;
|
||||
|
||||
namespace Ui {
|
||||
class ConfigurationListWidget;
|
||||
|
|
@ -22,27 +20,20 @@ class ConfigurationListWidget;
|
|||
|
||||
class ConfigurationListWidget: public QWidget {
|
||||
Q_OBJECT
|
||||
KYTY_QT_CLASS_NO_COPY(ConfigurationListWidget);
|
||||
|
||||
public:
|
||||
explicit ConfigurationListWidget(QWidget* parent = nullptr);
|
||||
~ConfigurationListWidget() override;
|
||||
|
||||
void SetRunEnabled(bool flag) { m_run_enabled = flag; }
|
||||
[[nodiscard]] bool IsRunEnabled() const { return m_run_enabled; }
|
||||
void SetRunEnabled(bool flag) { m_run_enabled = flag; }
|
||||
|
||||
[[nodiscard]] const ConfigurationItem* GetSelectedItem() const { return m_selected_item; }
|
||||
ConfigurationItem* GetSelectedItem() { return m_selected_item; }
|
||||
|
||||
void SetMainDialog(MainDialog* main_dialog) { m_main_dialog = main_dialog; }
|
||||
MainDialog* GetMainDialog() { return m_main_dialog; }
|
||||
|
||||
[[nodiscard]] const QString& GetSettingsFile() const { return m_settings_file; }
|
||||
[[nodiscard]] const QStringList& GetGameDirectories() const { return m_game_dirs; }
|
||||
[[nodiscard]] const QStringList& GetHostInputMapping() const {
|
||||
return m_global_info.host_input_mapping;
|
||||
}
|
||||
[[nodiscard]] bool CanViewSelectedTrophies() const;
|
||||
|
||||
bool EnsureGameDirectory();
|
||||
void ScanGameDirectory();
|
||||
|
|
@ -66,8 +57,6 @@ protected slots:
|
|||
void delete_configuartion();
|
||||
void edit_global_settings();
|
||||
void edit_input_mapping();
|
||||
void run_configuration();
|
||||
void list_currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
|
||||
void list_itemDoubleClicked(QTreeWidgetItem* witem, int column);
|
||||
void show_context_menu(const QPoint& pos);
|
||||
void open_game_folder();
|
||||
|
|
@ -84,7 +73,6 @@ private:
|
|||
ConfigurationItem* m_selected_item = nullptr;
|
||||
bool m_run_enabled = true;
|
||||
Ui::ConfigurationListWidget* m_ui = nullptr;
|
||||
MainDialog* m_main_dialog = nullptr;
|
||||
QString m_settings_file;
|
||||
QStringList m_game_dirs;
|
||||
Configuration m_global_info;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
#ifndef MAIN_DIALOG_H
|
||||
#define MAIN_DIALOG_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
|
||||
|
|
@ -15,11 +13,9 @@ class QResizeEvent;
|
|||
class Configuration;
|
||||
class MainDialog: public QDialog {
|
||||
Q_OBJECT
|
||||
KYTY_QT_CLASS_NO_COPY(MainDialog);
|
||||
|
||||
signals:
|
||||
void Start();
|
||||
void Quit();
|
||||
void Resize();
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
#ifndef MANDATORY_LINEEDIT_H
|
||||
#define MANDATORY_LINEEDIT_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
class QPaintEvent;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
#ifndef PATCHES_DIALOG_H
|
||||
#define PATCHES_DIALOG_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
|
||||
|
|
@ -16,8 +14,6 @@ public:
|
|||
explicit PatchesDialog(const Configuration& game, QWidget* parent = nullptr);
|
||||
~PatchesDialog() override = default;
|
||||
|
||||
KYTY_QT_CLASS_NO_COPY(PatchesDialog);
|
||||
|
||||
[[nodiscard]] static bool IsSupportedTitleId(const QString& title_id);
|
||||
[[nodiscard]] static QString PatchPlanPath(const QString& title_id);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
#ifndef TROPHY_VIEWER_DIALOG_H
|
||||
#define TROPHY_VIEWER_DIALOG_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QTabWidget;
|
||||
|
|
@ -10,8 +8,6 @@ class QWidget;
|
|||
|
||||
class Configuration;
|
||||
class TrophyViewerDialog: public QDialog {
|
||||
KYTY_QT_CLASS_NO_COPY(TrophyViewerDialog);
|
||||
|
||||
public:
|
||||
explicit TrophyViewerDialog(QWidget* parent = nullptr);
|
||||
|
||||
|
|
|
|||
|
|
@ -307,10 +307,6 @@ void ConfigurationEditDialog::InitGameDirectories() {
|
|||
update_game_directory_buttons();
|
||||
}
|
||||
|
||||
void ConfigurationEditDialog::SetTitle(const QString& str) {
|
||||
setWindowTitle(str);
|
||||
}
|
||||
|
||||
void ConfigurationEditDialog::SetGameDirectories(const QStringList& dirs) {
|
||||
m_show_game_dirs = true;
|
||||
m_game_dirs_list->clear();
|
||||
|
|
@ -401,14 +397,6 @@ static void UpdateInfo(Configuration& info, Ui::ConfigurationEditDialog& ui) {
|
|||
info.profiler_enabled = ui.checkBox_profiler->isChecked();
|
||||
}
|
||||
|
||||
void ConfigurationEditDialog::update_info() {
|
||||
UpdateInfo(m_info, *m_ui);
|
||||
}
|
||||
|
||||
void ConfigurationEditDialog::adjust_size() {
|
||||
this->adjustSize();
|
||||
}
|
||||
|
||||
void ConfigurationEditDialog::save() {
|
||||
if (MandatoryLineEdit::FindEmpty(this)) {
|
||||
QMessageBox::critical(this, tr("Save failed"), tr("Please fill all mandatory fields"));
|
||||
|
|
@ -428,7 +416,7 @@ void ConfigurationEditDialog::save() {
|
|||
return;
|
||||
}
|
||||
|
||||
update_info();
|
||||
UpdateInfo(m_info, *m_ui);
|
||||
|
||||
emit accept();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,10 +77,6 @@ void SetStatus(QComboBox* combo, Configuration::GameStatus status) {
|
|||
combo->setCurrentIndex(index >= 0 ? index : 0);
|
||||
}
|
||||
|
||||
QIcon StandardIcon(QStyle::StandardPixmap icon) {
|
||||
return QApplication::style()->standardIcon(icon);
|
||||
}
|
||||
|
||||
QString GetPathText(const Configuration& info) {
|
||||
return !info.game_path.isEmpty() ? info.game_path : info.basedir;
|
||||
}
|
||||
|
|
@ -278,11 +274,11 @@ void ConfigurationItem::UpdateIcon() {
|
|||
}
|
||||
|
||||
if (m_running) {
|
||||
setIcon(NameColumn, StandardIcon(QStyle::SP_MediaPlay));
|
||||
setIcon(NameColumn, QApplication::style()->standardIcon(QStyle::SP_MediaPlay));
|
||||
} else if (m_info->custom_settings) {
|
||||
setIcon(NameColumn, StandardIcon(QStyle::SP_FileIcon));
|
||||
setIcon(NameColumn, QApplication::style()->standardIcon(QStyle::SP_FileIcon));
|
||||
} else {
|
||||
setIcon(NameColumn, StandardIcon(QStyle::SP_ComputerIcon));
|
||||
setIcon(NameColumn, QApplication::style()->standardIcon(QStyle::SP_ComputerIcon));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include "configurationListWidget.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "compatibilityDatabase.h"
|
||||
#include "configuration.h"
|
||||
#include "configurationEditDialog.h"
|
||||
|
|
@ -232,7 +231,7 @@ ConfigurationListWidget::ConfigurationListWidget(QWidget* parent)
|
|||
connect(m_ui->delete_button, &QToolButton::clicked, this,
|
||||
&ConfigurationListWidget::delete_configuartion);
|
||||
connect(m_ui->cfgs_list, &QTreeWidget::currentItemChanged, this,
|
||||
&ConfigurationListWidget::list_currentItemChanged);
|
||||
&ConfigurationListWidget::SelectItem);
|
||||
connect(m_ui->cfgs_list, &QTreeWidget::itemDoubleClicked, this,
|
||||
&ConfigurationListWidget::list_itemDoubleClicked);
|
||||
connect(m_ui->cfgs_list, &QTreeWidget::customContextMenuRequested, this,
|
||||
|
|
@ -676,7 +675,7 @@ void ConfigurationListWidget::edit_configuration() {
|
|||
}
|
||||
|
||||
ConfigurationEditDialog dlg(item->GetInfo(), this);
|
||||
dlg.SetTitle(tr("Edit game settings"));
|
||||
dlg.setWindowTitle(tr("Edit game settings"));
|
||||
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
item->GetInfo().custom_settings = true;
|
||||
|
|
@ -708,7 +707,7 @@ void ConfigurationListWidget::edit_global_settings() {
|
|||
info.name = tr("Global settings");
|
||||
|
||||
ConfigurationEditDialog dlg(info, this);
|
||||
dlg.SetTitle(tr("Global settings"));
|
||||
dlg.setWindowTitle(tr("Global settings"));
|
||||
dlg.SetGameDirectories(m_game_dirs);
|
||||
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
|
|
@ -731,15 +730,6 @@ void ConfigurationListWidget::ClearCustomSettings(ConfigurationItem* item) {
|
|||
delete m_custom_infos.take(item->GetInfo().game_path);
|
||||
}
|
||||
|
||||
void ConfigurationListWidget::run_configuration() {
|
||||
emit Run();
|
||||
}
|
||||
|
||||
bool ConfigurationListWidget::CanViewSelectedTrophies() const {
|
||||
return m_selected_item != nullptr &&
|
||||
TrophyViewerDialog::HasTrophyData(&m_selected_item->GetInfo());
|
||||
}
|
||||
|
||||
void ConfigurationListWidget::ViewTrophies() {
|
||||
auto* current = static_cast<ConfigurationItem*>(m_ui->cfgs_list->currentItem());
|
||||
auto* item = current != nullptr ? current : m_selected_item;
|
||||
|
|
@ -852,11 +842,6 @@ void ConfigurationListWidget::SelectItem(QTreeWidgetItem* witem) {
|
|||
emit Select();
|
||||
}
|
||||
|
||||
void ConfigurationListWidget::list_currentItemChanged(QTreeWidgetItem* current,
|
||||
QTreeWidgetItem* /*previous*/) {
|
||||
SelectItem(current);
|
||||
}
|
||||
|
||||
void ConfigurationListWidget::list_itemDoubleClicked(QTreeWidgetItem* witem, int /*column*/) {
|
||||
SelectItem(witem);
|
||||
if (m_run_enabled) {
|
||||
|
|
@ -877,7 +862,8 @@ void ConfigurationListWidget::show_context_menu(const QPoint& pos) {
|
|||
const bool has_trophy_data =
|
||||
item != nullptr && TrophyViewerDialog::HasTrophyData(&item->GetInfo());
|
||||
|
||||
QAction* action_run = menu.addAction(tr("Run"), this, SLOT(run_configuration()));
|
||||
QAction* action_run = menu.addAction(tr("Run"));
|
||||
connect(action_run, &QAction::triggered, this, &ConfigurationListWidget::Run);
|
||||
QAction* action_open_folder =
|
||||
menu.addAction(style()->standardIcon(QStyle::SP_DirOpenIcon), tr("Open game folder"), this,
|
||||
SLOT(open_game_folder()));
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
#include "launcherTheme.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QArgument>
|
||||
#include <QObject>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
|
|
@ -11,8 +9,6 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
MainDialog w;
|
||||
|
||||
QObject::connect(&a, &QApplication::aboutToQuit, &w, &MainDialog::Quit);
|
||||
|
||||
w.emit Start();
|
||||
|
||||
w.show();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include "mainDialog.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "configuration.h"
|
||||
#include "configurationItem.h"
|
||||
#include "configurationListWidget.h"
|
||||
|
|
@ -17,6 +16,7 @@
|
|||
#include <QIODevice>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QProcess>
|
||||
#include <QRadioButton>
|
||||
|
|
@ -27,6 +27,8 @@
|
|||
#include <QVariant>
|
||||
#include <QtCore>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "ui_main_dialog.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
|
@ -58,20 +60,8 @@ constexpr char SETTINGS_MAIN_DIALOG[] = "MainDialog";
|
|||
constexpr char SETTINGS_MAIN_LAST_GEOMETRY[] = "geometry";
|
||||
constexpr char SETTINGS_CHECK_UPDATES[] = "check_updates_on_startup";
|
||||
|
||||
class DetachableProcess: public QProcess {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
explicit DetachableProcess(QObject* parent = nullptr): QProcess(parent) {}
|
||||
void Detach() {
|
||||
this->waitForStarted();
|
||||
setProcessState(QProcess::NotRunning);
|
||||
}
|
||||
};
|
||||
|
||||
class MainDialogPrivate: public QObject {
|
||||
Q_OBJECT
|
||||
KYTY_QT_CLASS_NO_COPY(MainDialogPrivate);
|
||||
|
||||
public:
|
||||
explicit MainDialogPrivate(QObject* parent = nullptr): QObject(parent) {}
|
||||
|
|
@ -99,7 +89,7 @@ private:
|
|||
UpdateChecker* m_update_checker = nullptr;
|
||||
QString m_interpreter;
|
||||
|
||||
/*DetachableProcess*/ QProcess m_process;
|
||||
QProcess m_process;
|
||||
|
||||
QPointer<ConfigurationItem> m_running_item;
|
||||
};
|
||||
|
|
@ -121,7 +111,6 @@ void MainDialogPrivate::Setup(MainDialog* main_dialog) {
|
|||
|
||||
m_main_dialog = main_dialog;
|
||||
m_update_checker = new UpdateChecker(main_dialog);
|
||||
m_ui->widget->SetMainDialog(main_dialog);
|
||||
m_ui->check_updates_on_startup->setChecked(g_check_updates_on_startup);
|
||||
m_ui->check_updates_link->setVisible(UpdateChecker::IsSupported());
|
||||
m_ui->check_updates_on_startup->setVisible(UpdateChecker::IsSupported());
|
||||
|
|
@ -154,8 +143,6 @@ void MainDialogPrivate::Setup(MainDialog* main_dialog) {
|
|||
Update();
|
||||
});
|
||||
|
||||
// connect(main_dialog, &MainDialog::Quit, [=]() { m_process.Detach(); });
|
||||
|
||||
m_ui->label_settings_file->setText(tr("Settings file: ") + m_ui->widget->GetSettingsFile());
|
||||
|
||||
m_main_dialog->restoreGeometry(g_last_geometry);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#include <QLabel>
|
||||
#include <QMap>
|
||||
#include <QMessageBox>
|
||||
#include <QObject>
|
||||
#include <QPixmap>
|
||||
#include <QRegularExpression>
|
||||
#include <QSet>
|
||||
|
|
@ -32,8 +33,9 @@
|
|||
#include <QVBoxLayout>
|
||||
#include <QVariant>
|
||||
#include <QWidget>
|
||||
#include <QtEndian>
|
||||
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
@ -83,21 +85,6 @@ static bool CanRead(const QByteArray& data, qsizetype offset, qsizetype size) {
|
|||
return offset >= 0 && size >= 0 && offset <= data.size() && size <= data.size() - offset;
|
||||
}
|
||||
|
||||
static quint32 ReadBe32(const QByteArray& data, qsizetype offset) {
|
||||
const auto* p = reinterpret_cast<const uchar*>(data.constData() + offset);
|
||||
return (static_cast<quint32>(p[0]) << 24u) | (static_cast<quint32>(p[1]) << 16u) |
|
||||
(static_cast<quint32>(p[2]) << 8u) | static_cast<quint32>(p[3]);
|
||||
}
|
||||
|
||||
static quint64 ReadBe64(const QByteArray& data, qsizetype offset) {
|
||||
return (static_cast<quint64>(ReadBe32(data, offset)) << 32u) |
|
||||
static_cast<quint64>(ReadBe32(data, offset + 4));
|
||||
}
|
||||
|
||||
static bool FitsQSizeType(quint64 value) {
|
||||
return value <= static_cast<quint64>(std::numeric_limits<qsizetype>::max());
|
||||
}
|
||||
|
||||
static QString ReadFixedString(const QByteArray& data, qsizetype offset, qsizetype max_size) {
|
||||
if (!CanRead(data, offset, max_size)) {
|
||||
return {};
|
||||
|
|
@ -125,33 +112,33 @@ static bool ReadUcp(const QString& file_name, QMap<QString, QByteArray>& files,
|
|||
return false;
|
||||
}
|
||||
|
||||
const auto magic = ReadBe32(data, 0x00);
|
||||
const auto magic = qFromBigEndian<quint32>(data.constData() + 0x00);
|
||||
if (magic != UCP_MAGIC) {
|
||||
error = QObject::tr("%1 has an invalid trophy package magic.")
|
||||
.arg(QFileInfo(file_name).fileName());
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto version = ReadBe32(data, 0x04);
|
||||
const auto version = qFromBigEndian<quint32>(data.constData() + 0x04);
|
||||
if (version != UCP_VERSION) {
|
||||
error = QObject::tr("%1 uses unsupported trophy package version %2.")
|
||||
.arg(QFileInfo(file_name).fileName(), QString::number(version));
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto declared_size = ReadBe64(data, 0x08);
|
||||
const auto declared_size = qFromBigEndian<quint64>(data.constData() + 0x08);
|
||||
if (declared_size > static_cast<quint64>(data.size())) {
|
||||
error = QObject::tr("%1 is truncated.").arg(QFileInfo(file_name).fileName());
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto file_count = ReadBe32(data, 0x10);
|
||||
const auto toc_offset = static_cast<quint64>(ReadBe32(data, 0x14));
|
||||
const auto file_count = qFromBigEndian<quint32>(data.constData() + 0x10);
|
||||
const auto toc_offset = static_cast<quint64>(qFromBigEndian<quint32>(data.constData() + 0x14));
|
||||
const auto data_size = static_cast<quint64>(data.size());
|
||||
|
||||
const quint64 table_size = UCP_TOC_SKIP + static_cast<quint64>(file_count) * UCP_ENTRY_LEN;
|
||||
if (toc_offset > data_size || table_size > data_size - toc_offset ||
|
||||
!FitsQSizeType(toc_offset + table_size)) {
|
||||
!std::in_range<qsizetype>(toc_offset + table_size)) {
|
||||
error = QObject::tr("%1 has an invalid table of contents.")
|
||||
.arg(QFileInfo(file_name).fileName());
|
||||
return false;
|
||||
|
|
@ -162,14 +149,14 @@ static bool ReadUcp(const QString& file_name, QMap<QString, QByteArray>& files,
|
|||
static_cast<quint64>(i) * UCP_ENTRY_LEN);
|
||||
UcpEntry entry;
|
||||
entry.name = ReadFixedString(data, entry_offset, UCP_NAME_LEN).trimmed();
|
||||
entry.offset = ReadBe64(data, entry_offset + 0x20);
|
||||
entry.size = ReadBe64(data, entry_offset + 0x28);
|
||||
entry.offset = qFromBigEndian<quint64>(data.constData() + entry_offset + 0x20);
|
||||
entry.size = qFromBigEndian<quint64>(data.constData() + entry_offset + 0x28);
|
||||
|
||||
if (entry.name.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (entry.offset > data_size || entry.size > data_size - entry.offset ||
|
||||
!FitsQSizeType(entry.offset) || !FitsQSizeType(entry.size)) {
|
||||
!std::in_range<qsizetype>(entry.offset) || !std::in_range<qsizetype>(entry.size)) {
|
||||
error = QObject::tr("%1 has an invalid entry for %2.")
|
||||
.arg(QFileInfo(file_name).fileName(), entry.name);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -48,27 +48,6 @@ function(clang_tidy_check target config headers dirs)
|
|||
endif()
|
||||
endfunction()
|
||||
|
||||
function(clang_tidy_fix target config headers dirs)
|
||||
if (KYTY_ENABLE_CLANG_TIDY AND CLANG AND ("${target}" IN_LIST KYTY_CLANG_TIDY))
|
||||
find_program (CLANG_TIDY_EXE NAMES "clang-tidy")
|
||||
if (CLANG_TIDY_EXE)
|
||||
set(std_arg "-extra-arg=-std=c++${CMAKE_CXX_STANDARD}")
|
||||
foreach(dir ${dirs})
|
||||
list(APPEND incdirs "-extra-arg=-I${dir}")
|
||||
endforeach()
|
||||
foreach(header ${headers})
|
||||
list(APPEND filter "(${header}.*)")
|
||||
endforeach()
|
||||
string(REPLACE ";" "|" filter "${filter}")
|
||||
if ("${config}" STREQUAL "")
|
||||
set_target_properties(${target} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-fix;-format-style=file;-header-filter=${filter};${std_arg};${incdirs}")
|
||||
else()
|
||||
set_target_properties(${target} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-fix;-format-style=file;-config=${config};-header-filter=${filter};${std_arg};${incdirs}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
macro(config_compiler_and_linker)
|
||||
|
||||
set(KYTY_WARNINGS_ARE_ERRORS OFF)
|
||||
|
|
|
|||
Loading…
Reference in New Issue