summaryrefslogtreecommitdiffhomepage
path: root/csv/csv.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-10-06 07:07:10 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-10-06 07:09:38 +0200
commitc89ef2fe9cb1d681b1b3acdabee1786eabdf1051 (patch)
tree123531679636da3c3d84c7b4f8140243dfca1158 /csv/csv.cpp
parent629875abd995f46f99b3cba3387faa7367a6f823 (diff)
csv: cleanup
Diffstat (limited to 'csv/csv.cpp')
-rw-r--r--csv/csv.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/csv/csv.cpp b/csv/csv.cpp
index 4c754542..1ae567a4 100644
--- a/csv/csv.cpp
+++ b/csv/csv.cpp
@@ -92,7 +92,7 @@ QStringList CSV::parseLine(QString line){
return list;
}
-void CSV::getGameData( const int id, unsigned char* table, QString& gamename)
+bool CSV::getGameData( const int id, unsigned char* table, QString& gamename)
{
QString gameID = QString::number(id);
@@ -104,12 +104,11 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename)
QFile file(QCoreApplication::applicationDirPath() + "/settings/facetracknoir supported games.csv");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){
- return;
+ return false;
}
CSV csv(&file);
- gameLine = csv.parseLine();
- while (gameLine.count() > 2) {
+ while (gameLine = csv.parseLine(), gameLine.count() > 2) {
//qDebug() << "Column 0: " << gameLine.at(0); // No.
//qDebug() << "Column 1: " << gameLine.at(1); // Game Name
//qDebug() << "Column 2: " << gameLine.at(2); // Game Protocol
@@ -124,9 +123,11 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename)
QByteArray id = gameLine.at(7).toLatin1();
unsigned char tmp[8];
unsigned char fuzz[3];
+ bool ret = true;
if (gameLine.at(3) == QString("V160"))
{
qDebug() << "no table";
+ ret = false;
}
else if (sscanf(id.constData(),
"%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx",
@@ -143,6 +144,7 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename)
fuzz + 1) != 11)
{
qDebug() << "scanf failed" << fuzz[0] << fuzz[1] << fuzz[2];
+ ret = false;
}
else
for (int i = 0; i < 8; i++)
@@ -150,13 +152,12 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename)
qDebug() << gameID << "game-id" << gameLine.at(7);
gamename = gameLine.at(1);
file.close();
- return;
+ return ret;
}
}
-
- gameLine = csv.parseLine();
}
qDebug() << "Unknown game connected" << gameID;
file.close();
+ return false;
}