Skip to content

Commit 22257c3

Browse files
committed
add libbacktrace
1 parent b123178 commit 22257c3

File tree

8 files changed

+96
-67
lines changed

8 files changed

+96
-67
lines changed

.github/workflows/codacy.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,13 @@ jobs:
3434
name: Codacy Security Scan
3535
runs-on: ubuntu-latest
3636
steps:
37-
# Install dependencies required for `ueberzug`
38-
- name: Install system dependencies
39-
run: sudo apt-get update && sudo apt-get install -y libxres-dev
40-
4137
# Checkout the repository to the GitHub Actions runner
4238
- name: Checkout code
43-
uses: actions/checkout@v3
44-
45-
# Install dependencies
46-
- name: Install dependencies
47-
run: |
48-
python -m pip install --upgrade pip
49-
pip install -r requirements.txt
39+
uses: actions/checkout@main
5040

5141
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
5242
- name: Run Codacy Analysis CLI
53-
uses: codacy/codacy-analysis-cli-action@d840f886c4bd4edc059706d09c6a1586111c540b
43+
uses: codacy/codacy-analysis-cli-action@master
5444
with:
5545
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
5646
# You can also omit the token and run the tools that support default configurations
@@ -66,6 +56,6 @@ jobs:
6656

6757
# Upload the SARIF file generated in the previous step
6858
- name: Upload SARIF results file
69-
uses: github/codeql-action/upload-sarif@v3
59+
uses: github/codeql-action/upload-sarif@main
7060
with:
7161
sarif_file: results.sarif

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "libs/LIEF"]
55
path = libs/LIEF
66
url = https://github.com/lief-project/LIEF
7+
[submodule "libs/libbacktrace"]
8+
path = libs/libbacktrace
9+
url = https://github.com/ianlancetaylor/libbacktrace

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ sudo zypper install python3-pycurl python3-tqdm python3-cryptography python3-bea
102102
```shell
103103
sudo apk add py3-pycurl py3-tqdm py3-cryptography py3-beautifulsoup4 py3-pillow
104104
```
105+
105106
Use the -sc flag to sync to trle
106107

107108
```shell
@@ -139,6 +140,7 @@ I tested the original, unpatched Tomb Raider III on an i7-4800MQ using its integ
139140
```shell
140141
WINEPREFIX="/home/noisecode3/.newtombprefix" PROTONPATH="/home/noisecode3/.steam/steam/compatibilitytools.d/GE-Proton10-10" GAMEID="225320" MESA_SHADER_CACHE="true"
141142
```
143+
142144
It ran nearly perfectly — only a tiny framedrop once per hour, or sometimes not at all. Timing jitter caused by Wine’s threading system is largely eliminated under NTSync.
143145
NTSync can help DDraw, DirectSound other I/O thread workers in wine. On Arch Linux (or other distros with a modular kernel), you’ll need to manually load the ntsync driver to enable proper synchronization support:
144146

libs/libbacktrace

Submodule libbacktrace added at 7939218

src/LevelViewList.cpp

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ int LevelListModel::rowCount(const QModelIndex &parent) const {
2626
return parent.isValid() ? 0 : m_levels.size();
2727
}
2828

29+
void LevelListModel::setInstalled(const QModelIndex &index) {
30+
ListItemData &item = *m_levels[index.row()];
31+
item.m_installed = true;
32+
}
33+
2934
QVariant LevelListModel::data(const QModelIndex &index, int role) const {
3035
QVariant result;
3136

@@ -41,45 +46,56 @@ QVariant LevelListModel::data(const QModelIndex &index, int role) const {
4146
}
4247

4348
void LevelListModel::setScrollChange(const quint64 index) {
44-
m_scrollCoversCursorChanged = true;
45-
m_scrollCoversCursor = index;
49+
if (!m_levels.empty()) {
50+
m_scrollCursorChanged = true;
51+
m_seq_cursor_a = m_cursor_a.row();
52+
53+
quint64 size = m_levels.size();
54+
quint64 i = qMin(index, size);
55+
m_cursor_a = this->index(i, 0);
56+
}
4657
}
4758

4859
QVector<QSharedPointer<ListItemData>> LevelListModel::getDataBuffer(quint64 items) {
4960
QVector<QSharedPointer<ListItemData>> buffer;
5061

5162
if ((items > 0) && !m_levels.isEmpty()) {
5263
quint64 size = m_levels.size();
53-
quint64 index_a;
54-
quint64 index_b;
55-
56-
if (m_scrollCoversCursorChanged) {
57-
m_scrollCoversCursorChanged = false;
58-
index_a = m_scrollCoversCursor;
59-
index_b = qMin(m_scrollCoversCursor + items, size);
60-
m_scrollCoversCursor = index_b;
61-
} else {
62-
index_a = m_sequentialCoversCursor;
63-
index_b = qMin(m_sequentialCoversCursor + items, size);
64-
m_sequentialCoversCursor = index_b;
65-
}
64+
// m_cursor_a starts on -1
65+
// there is no way to inialize it
66+
quint64 a = m_cursor_a.row() + 1;
67+
quint64 b = qMin(a + items, size);
6668

67-
buffer.reserve(index_b - index_a);
68-
for (quint64 i = index_a; i < index_b; ++i) {
69+
m_cursor_b = this->index(b, 0);
70+
71+
buffer.reserve(b - a);
72+
for (quint64 i = a; i < b; ++i) {
6973
buffer.append(m_levels[i]);
7074
}
7175
}
7276

73-
beginResetModel();
7477
return buffer;
7578
}
7679

7780
void LevelListModel::reset() {
78-
endResetModel();
81+
if (m_cursor_a.isValid() && m_cursor_b.isValid()) {
82+
emit dataChanged(m_cursor_a, m_cursor_b);
83+
}
84+
85+
if (m_scrollCursorChanged == true) {
86+
m_cursor_a = this->index(m_seq_cursor_a, 0);
87+
m_scrollCursorChanged = false;
88+
} else {
89+
m_cursor_a = this->index(m_cursor_b.row(), 0);
90+
}
7991
}
8092

8193
bool LevelListModel::stop() {
82-
return (m_sequentialCoversCursor == m_levels.size());
94+
bool status = false;
95+
if (m_scrollCursorChanged == false) {
96+
status = (m_cursor_b.row() >= m_levels.size());
97+
}
98+
return status;
8399
}
84100

85101
quint64 LevelListProxy::getLid(const QModelIndex &i) {

src/LevelViewList.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ class LevelListModel : public QAbstractListModel {
2929
public:
3030
explicit LevelListModel(QObject *parent = nullptr)
3131
: QAbstractListModel(parent),
32-
m_scrollCoversCursor(0),
33-
m_sequentialCoversCursor(0),
34-
m_scrollCoversCursorChanged(false),
32+
m_scrollCursorChanged(false),
33+
m_seq_cursor_a(0),
3534
m_roleTable({
3635
{ Qt::DisplayRole, [](const ListItemData &i){ return i.m_title; }},
3736
{ Qt::UserRole+1, [](const ListItemData &i){ return i.m_game_id; }},
@@ -48,9 +47,10 @@ class LevelListModel : public QAbstractListModel {
4847
})
4948
{}
5049

50+
QVector<QSharedPointer<ListItemData>> getDataBuffer(const quint64 items);
5151
void setLevels(const QVector<QSharedPointer<ListItemData>>& levels);
5252
void setScrollChange(const quint64 index);
53-
QVector<QSharedPointer<ListItemData>> getDataBuffer(const quint64 items);
53+
void setInstalled(const QModelIndex &index);
5454
bool stop();
5555
void reset();
5656
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
@@ -59,9 +59,10 @@ class LevelListModel : public QAbstractListModel {
5959
private:
6060
const QHash<int, std::function<QVariant(const ListItemData&)>> m_roleTable;
6161
QVector<QSharedPointer<ListItemData>> m_levels;
62-
bool m_scrollCoversCursorChanged;
63-
quint64 m_scrollCoversCursor;
64-
quint64 m_sequentialCoversCursor;
62+
bool m_scrollCursorChanged;
63+
quint64 m_seq_cursor_a;
64+
QModelIndex m_cursor_a;
65+
QModelIndex m_cursor_b;
6566
};
6667

6768

src/TombRaiderLinuxLauncher.cpp

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "ui_TombRaiderLinuxLauncher.h"
1616
#include <QLineEdit>
1717

18-
1918
TombRaiderLinuxLauncher::TombRaiderLinuxLauncher(QWidget *parent)
2019
: QMainWindow(parent) {
2120
ui = new Ui::TombRaiderLinuxLauncher;
@@ -137,8 +136,7 @@ TombRaiderLinuxLauncher::TombRaiderLinuxLauncher(QWidget *parent)
137136
ui->listViewLevels->verticalScrollBar(),
138137
&QScrollBar::valueChanged,
139138
this,
140-
&TombRaiderLinuxLauncher::levelListScrolled
141-
);
139+
&TombRaiderLinuxLauncher::levelListScrolled);
142140

143141
connect(ui->checkBoxInstalled, &QCheckBox::toggled,
144142
levelListProxy, &LevelListProxy::setInstalledFilter);
@@ -167,6 +165,21 @@ TombRaiderLinuxLauncher::TombRaiderLinuxLauncher(QWidget *parent)
167165
}
168166
}
169167

168+
void TombRaiderLinuxLauncher::setList() {
169+
QVector<QSharedPointer<ListItemData>> list;
170+
controller.getList(&list);
171+
InstalledStatus installedStatus = getInstalled();
172+
173+
for (const auto &item : list) {
174+
Q_ASSERT(item != nullptr);
175+
bool trle = installedStatus.trle.value(item->m_trle_id, false);
176+
item->m_installed = trle;
177+
}
178+
179+
levelListModel->setLevels(list);
180+
loadMoreCovers();
181+
}
182+
170183
void TombRaiderLinuxLauncher::generateList(const QList<int>& availableGames) {
171184
// Update list only when 24 hours past
172185
QDateTime now = QDateTime::currentDateTime();
@@ -191,31 +204,27 @@ void TombRaiderLinuxLauncher::generateList(const QList<int>& availableGames) {
191204
settings.setValue("lastUpdated", now.toString(Qt::ISODate));
192205
m_availableGames = availableGames;
193206
} else {
194-
QVector<QSharedPointer<ListItemData>> list;
195-
controller.getList(&list);
196-
levelListModel->setLevels(list);
197-
setInstalled();
198-
loadMoreCovers();
207+
setList();
199208
ui->stackedWidget->setCurrentWidget(
200209
ui->stackedWidget->findChild<QWidget*>("select"));
201210
}
202211
}
203212

204-
void TombRaiderLinuxLauncher::setInstalled() {
213+
InstalledStatus TombRaiderLinuxLauncher::getInstalled() {
205214
QStringList keys = settings.allKeys();
206-
QHash<int, bool> installedLevel;
207-
QHash<int, bool> installedGame;
215+
InstalledStatus list;
208216
for (const auto &key : std::as_const(keys)) {
209217
if (key.startsWith("installed/game")) {
210-
qint64 id = key.midRef(QString("installed/game").length()).toInt();
211-
installedGame.insert(id, settings.value(key).toBool());
218+
quint64 id =
219+
key.midRef(QString("installed/game").length()).toUInt();
220+
list.game.insert(id, settings.value(key).toBool());
212221
} else if (key.startsWith("installed/level")) {
213-
qint64 id = key.midRef(QString("installed/level").length()).toInt();
214-
installedLevel.insert(id, settings.value(key).toBool());
222+
quint64 id =
223+
key.midRef(QString("installed/level").length()).toUInt();
224+
list.trle.insert(id, settings.value(key).toBool());
215225
}
216226
}
217-
// levelListModel->setInstalledListOriginal(installedGame);
218-
// levelListModel->setInstalledList(installedLevel);
227+
return list;
219228
}
220229

221230
bool TombRaiderLinuxLauncher::setStartupSetting(const StartupSetting settings) {
@@ -509,7 +518,7 @@ void TombRaiderLinuxLauncher::downloadClicked() {
509518
void TombRaiderLinuxLauncher::infoClicked() {
510519
QModelIndex current = ui->listViewLevels->currentIndex();
511520
if (current.isValid()) {
512-
qint64 id = levelListProxy->getLid(current); // getLid(current);
521+
qint64 id = levelListProxy->getLid(current); // getLid(current);
513522
if (id != 0) {
514523
InfoData info = controller.getInfo(id);
515524
if (info.m_body == "" && info.m_imageList.size() == 0) {
@@ -597,7 +606,8 @@ void TombRaiderLinuxLauncher::loadMoreCovers() {
597606
levelListModel->reset();
598607
}
599608
if (!levelListModel->stop()) {
600-
QVector<QSharedPointer<ListItemData>> buffer = levelListModel->getDataBuffer(100);
609+
QVector<QSharedPointer<ListItemData>> buffer =
610+
levelListModel->getDataBuffer(100);
601611
if (!buffer.isEmpty()) {
602612
controller.getCoverList(buffer);
603613
} else {
@@ -631,8 +641,8 @@ void TombRaiderLinuxLauncher::workTick() {
631641
QModelIndex current = ui->listViewLevels->currentIndex();
632642
if (current.isValid()) {
633643
qint64 id = levelListProxy->getLid(current);
634-
//levelListProxy->setInstalled(current);
635-
if (levelListProxy->getItemType(current)) { // its the original game
644+
levelListModel->setInstalled(current);
645+
if (levelListProxy->getItemType(current)) {
636646
settings.setValue(
637647
QString("installed/game%1").arg(id),
638648
"true");
@@ -679,11 +689,7 @@ void TombRaiderLinuxLauncher::downloadError(int status) {
679689
void TombRaiderLinuxLauncher::UpdateLevelDone() {
680690
m_loadingIndicatorWidget->hide();
681691
if (m_loadingDoneGoTo == "select") {
682-
QVector<QSharedPointer<ListItemData>> list;
683-
controller.getList(&list);
684-
levelListModel->setLevels(list);
685-
setInstalled();
686-
loadMoreCovers();
692+
setList();
687693
ui->stackedWidget->setCurrentWidget(
688694
ui->stackedWidget->findChild<QWidget*>("select"));
689695
} else if (m_loadingDoneGoTo == "info") {

src/TombRaiderLinuxLauncher.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
#include "../src/LevelViewList.hpp"
3434
#include "../src/LoadingIndicator.hpp"
3535

36+
struct InstalledStatus {
37+
QHash<quint64, bool> game;
38+
QHash<quint64, bool> trle;
39+
};
40+
3641
QT_BEGIN_NAMESPACE
3742
namespace Ui { class TombRaiderLinuxLauncher; }
3843
QT_END_NAMESPACE
@@ -152,7 +157,12 @@ class TombRaiderLinuxLauncher : public QMainWindow {
152157
/**
153158
*
154159
*/
155-
void setInstalled();
160+
void setList();
161+
162+
/**
163+
*
164+
*/
165+
InstalledStatus getInstalled();
156166

157167
/**
158168
*

0 commit comments

Comments
 (0)