aboutsummaryrefslogtreecommitdiff
path: root/Core/GameInfo
diff options
context:
space:
mode:
Diffstat (limited to 'Core/GameInfo')
-rw-r--r--Core/GameInfo/gameinfostructure.h24
-rw-r--r--Core/GameInfo/loadsupportedgames.cpp97
-rw-r--r--Core/GameInfo/loadsupportedgames.h16
3 files changed, 0 insertions, 137 deletions
diff --git a/Core/GameInfo/gameinfostructure.h b/Core/GameInfo/gameinfostructure.h
deleted file mode 100644
index b73e9ef..0000000
--- a/Core/GameInfo/gameinfostructure.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef STRUCTGAMEINFO_H
-#define STRUCTGAMEINFO_H
-
-#include <QString>
-
-struct GameInfo
-{
- // gamename is the unique identifier
- QString gamename;
-
- // 6-byte GameSpy identifier
- QString cipher;
-
- // game label
- QString label;
-
- // default port
- unsigned short port = 0;
-
- // known protocol
- QString protocol;
-};
-
-#endif // STRUCTGAMEINFO_H
diff --git a/Core/GameInfo/loadsupportedgames.cpp b/Core/GameInfo/loadsupportedgames.cpp
deleted file mode 100644
index 9a73947..0000000
--- a/Core/GameInfo/loadsupportedgames.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-#include "loadsupportedgames.h"
-
-QHash<QString, GameInfo> loadSupportedGames (const QString &applicationPath)
-{
- // return hash
- QHash<QString, GameInfo> supportedGames;
-
- // supported games file path (following README structure)
- const QString supportPath = applicationPath + "/" + _supportedPath;
-
- // determine if file exists
- if ( ! QFile(supportPath).exists() )
- {
- // no game info file exists
- logPrimitive() << "No games file found at " << supportPath << endl
- << "Please provide the correct file . " << endl;
- return supportedGames;
- }
-
- // load config file
- QFile supportedFile(supportPath);
- if ( ! supportedFile.open(QIODevice::ReadOnly) )
- {
- // error occurred. report and quit.
- logPrimitive() << "Unable to open the game file. Is the file open or in use?" << endl;
- return supportedGames;
- }
-
- // stats
- int total = 0;
-
- // load as json object
- QJsonDocument supportedJsonData(QJsonDocument::fromJson(supportedFile.readAll()));
-
- /* Optimisation for web interface: add games to the database.
- *
- * If database/json data do not match, replace database table
- * with json data. This should only occur during database creation
- * or when manual changes were made to the json file (which is rare).
- */
- bool dbInsert = supportedJsonData.array().count() != getNumGames(0).value("numTotal", 0);
- QSqlQuery q;
- if (dbInsert)
- {
- // no game info file exists
- logPrimitive() << "Game info mismatch in database. Reloading json data. ("
- << supportedJsonData.array().count() << "/"
- << getNumGames(0).value("numTotal", 0) << ")" << endl;
-
- // void existing data
- q.prepare("DELETE FROM gameinfo");
- if ( ! q.exec() )
- reportQuery(q);
- }
-
- for (int i = 0; i < supportedJsonData.array().count(); i++)
- {
- // get the game object
- QJsonObject thisGame = supportedJsonData.array().at(i).toObject();
-
- GameInfo gameInfo;
- gameInfo.gamename = thisGame.value("gamename").toString("");
- gameInfo.cipher = thisGame.value("cipher").toString("");
- gameInfo.port = static_cast<unsigned short>(thisGame.value("port").toDouble(0));
- gameInfo.label = thisGame.value("label").toString("");
-
- // insert in db if needed
- if (dbInsert)
- {
- QString insertString = "INSERT INTO gameinfo (gamename, label) "
- "VALUES (:gamename, :label)";
-
- q.prepare(insertString);
- q.bindValue(":gamename", gameInfo.gamename );
- q.bindValue(":label", gameInfo.label);
-
- if ( ! q.exec() )
- reportQuery(q);
- }
-
- // add to list
- supportedGames.insert(gameInfo.gamename, gameInfo);
- total++;
- }
-
- // no games found? report this!
- if (total <= 0)
- {
- // no game info exists
- logPrimitive() << "No game info found in file at " << supportPath << endl
- << "Please provide the correct file . " << endl;
- return supportedGames;
- }
-
- // all games parsed. done.
- return supportedGames;
-}
diff --git a/Core/GameInfo/loadsupportedgames.h b/Core/GameInfo/loadsupportedgames.h
deleted file mode 100644
index 333dd0b..0000000
--- a/Core/GameInfo/loadsupportedgames.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef LOADSUPPORTEDGAMES_H
-#define LOADSUPPORTEDGAMES_H
-
-#include <QFile>
-#include <QJsonObject>
-#include <QJsonArray>
-#include <QJsonDocument>
-#include "Database/Common/commonactions.h"
-#include "gameinfostructure.h"
-
-// load supported games from json file
-
-const QString _supportedPath = "../data/SupportedGames.json";
-QHash<QString, GameInfo> loadSupportedGames (const QString &applicationPath);
-
-#endif // LOADSUPPORTEDGAMES_H