Skip to content

Commit ffa0c55

Browse files
committed
dont use static for staic data
1 parent db50473 commit ffa0c55

File tree

4 files changed

+31
-40
lines changed

4 files changed

+31
-40
lines changed

database/ideas.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ and have curl use certificate pinning
267267
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
268268
curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY, "sha256//base64_encoded_hash_here"); // Pin the public key
269269

270+
One way to get the base64 hash sum
271+
openssl s_client -connect trle.net:443 -servername trle.net < /dev/null | openssl x509 -pubkey -noout > pubkey.pem
272+
openssl pkey -pubin -inform PEM -in pubkey.pem -outform DER | sha256sum | xxd -r -p | base64
273+
270274
and make sure the index database can't every change the host name,
271275
unless someone use a quantum computer or specialized illegal hardware, it could
272276
be difficult to tampered with the download of files. We must make sure we install

src/Data.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ class Data : public QObject {
161161

162162
public:
163163
static Data& getInstance() {
164+
// cppcheck-suppress threadsafety-threadsafety
164165
static Data instance;
165166
return instance;
166167
}

src/TombRaiderLinuxLauncher.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,11 @@ void TombRaiderLinuxLauncher::generateList() {
184184
}
185185
}
186186

187-
auto& mapType = StaticType::getMap();
188-
auto& mapClass = StaticClass::getMap();
189-
auto& mapDifficulty = StaticDifficulty::getMap();
190-
auto& mapDuration = StaticDuration::getMap();
187+
StaticData staticData;
188+
auto mapType = staticData.getType();
189+
auto mapClass = staticData.getClass();
190+
auto mapDifficulty = staticData.getDifficulty();
191+
auto mapDuration = staticData.getDuration();
191192

192193
QVector<ListItemData> list;
193194
controller.getList(&list);

src/staticData.hpp

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,19 @@
1616
#include <QString>
1717
#include <unordered_map>
1818

19-
class StaticClass {
20-
public:
21-
static const std::unordered_map<qint64, QString>& getMap() {
22-
static const std::unordered_map<qint64, QString> idToString = {
19+
struct StaticData {
20+
std::unordered_map<qint64, QString> getDifficulty() const {
21+
return {
22+
{0, "null"},
23+
{1, "easy"},
24+
{2, "medium"},
25+
{3, "challenging"},
26+
{4, "very challenging"}
27+
};
28+
}
29+
std::unordered_map<qint64, QString> getClass() const {
30+
return {
31+
{0, "null"},
2332
{1, "Alien/Space"},
2433
{2, "Atlantis"},
2534
{3, "Base/Lab"},
@@ -58,50 +67,26 @@ class StaticClass {
5867
{36, "Xmas"},
5968
{36, "Young Lara"}
6069
};
61-
return idToString;
6270
}
63-
};
64-
65-
class StaticDifficulty {
66-
public:
67-
static const std::unordered_map<qint64, QString>& getMap() {
68-
static const std::unordered_map<qint64, QString> idToString = {
71+
std::unordered_map<qint64, QString> getDuration() const {
72+
return {
6973
{0, "null"},
70-
{1, "easy"},
74+
{1, "short"},
7175
{2, "medium"},
72-
{3, "challenging"},
73-
{4, "very challenging"}
76+
{3, "long"},
77+
{4, "very long"}
7478
};
75-
return idToString;
7679
}
77-
};
78-
79-
class StaticType {
80-
public:
81-
static const std::unordered_map<qint64, QString>& getMap() {
82-
static const std::unordered_map<qint64, QString> idToString = {
80+
std::unordered_map<qint64, QString> getType() const {
81+
return {
82+
{0, "null"},
8383
{1, "TR1"},
8484
{2, "TR2"},
8585
{3, "TR3"},
8686
{4, "TR4"},
8787
{5, "TR5"},
8888
{6, "TEN"}
8989
};
90-
return idToString;
91-
}
92-
};
93-
94-
class StaticDuration {
95-
public:
96-
static const std::unordered_map<qint64, QString>& getMap() {
97-
static const std::unordered_map<qint64, QString> idToString = {
98-
{0, "null"},
99-
{1, "short"},
100-
{2, "medium"},
101-
{3, "long"},
102-
{4, "very long"}
103-
};
104-
return idToString;
10590
}
10691
};
10792

0 commit comments

Comments
 (0)