Skip to content

Commit

Permalink
dont use static for staic data
Browse files Browse the repository at this point in the history
  • Loading branch information
noisecode3 committed Dec 22, 2024
1 parent db50473 commit ffa0c55
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 40 deletions.
4 changes: 4 additions & 0 deletions database/ideas.txt
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ and have curl use certificate pinning
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY, "sha256//base64_encoded_hash_here"); // Pin the public key

One way to get the base64 hash sum
openssl s_client -connect trle.net:443 -servername trle.net < /dev/null | openssl x509 -pubkey -noout > pubkey.pem
openssl pkey -pubin -inform PEM -in pubkey.pem -outform DER | sha256sum | xxd -r -p | base64

and make sure the index database can't every change the host name,
unless someone use a quantum computer or specialized illegal hardware, it could
be difficult to tampered with the download of files. We must make sure we install
Expand Down
1 change: 1 addition & 0 deletions src/Data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class Data : public QObject {

public:
static Data& getInstance() {
// cppcheck-suppress threadsafety-threadsafety
static Data instance;
return instance;
}
Expand Down
9 changes: 5 additions & 4 deletions src/TombRaiderLinuxLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,11 @@ void TombRaiderLinuxLauncher::generateList() {
}
}

auto& mapType = StaticType::getMap();
auto& mapClass = StaticClass::getMap();
auto& mapDifficulty = StaticDifficulty::getMap();
auto& mapDuration = StaticDuration::getMap();
StaticData staticData;
auto mapType = staticData.getType();
auto mapClass = staticData.getClass();
auto mapDifficulty = staticData.getDifficulty();
auto mapDuration = staticData.getDuration();

QVector<ListItemData> list;
controller.getList(&list);
Expand Down
57 changes: 21 additions & 36 deletions src/staticData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@
#include <QString>
#include <unordered_map>

class StaticClass {
public:
static const std::unordered_map<qint64, QString>& getMap() {
static const std::unordered_map<qint64, QString> idToString = {
struct StaticData {
std::unordered_map<qint64, QString> getDifficulty() const {
return {
{0, "null"},
{1, "easy"},
{2, "medium"},
{3, "challenging"},
{4, "very challenging"}
};
}
std::unordered_map<qint64, QString> getClass() const {
return {
{0, "null"},
{1, "Alien/Space"},
{2, "Atlantis"},
{3, "Base/Lab"},
Expand Down Expand Up @@ -58,50 +67,26 @@ class StaticClass {
{36, "Xmas"},
{36, "Young Lara"}
};
return idToString;
}
};

class StaticDifficulty {
public:
static const std::unordered_map<qint64, QString>& getMap() {
static const std::unordered_map<qint64, QString> idToString = {
std::unordered_map<qint64, QString> getDuration() const {
return {
{0, "null"},
{1, "easy"},
{1, "short"},
{2, "medium"},
{3, "challenging"},
{4, "very challenging"}
{3, "long"},
{4, "very long"}
};
return idToString;
}
};

class StaticType {
public:
static const std::unordered_map<qint64, QString>& getMap() {
static const std::unordered_map<qint64, QString> idToString = {
std::unordered_map<qint64, QString> getType() const {
return {
{0, "null"},
{1, "TR1"},
{2, "TR2"},
{3, "TR3"},
{4, "TR4"},
{5, "TR5"},
{6, "TEN"}
};
return idToString;
}
};

class StaticDuration {
public:
static const std::unordered_map<qint64, QString>& getMap() {
static const std::unordered_map<qint64, QString> idToString = {
{0, "null"},
{1, "short"},
{2, "medium"},
{3, "long"},
{4, "very long"}
};
return idToString;
}
};

Expand Down

0 comments on commit ffa0c55

Please sign in to comment.