From d99134763fedec2d04b9ae41a053405423424007 Mon Sep 17 00:00:00 2001 From: Bim Overbohm Date: Fri, 28 Jun 2013 16:13:57 +0200 Subject: [PATCH] Convert rating to float. Fix reading of timesPlayed. http://thegamesdb.net API seems to use a float. Fix a but where the times played was read into the rating member. --- src/GameData.cpp | 6 +++--- src/GameData.h | 6 +++--- src/XMLReader.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/GameData.cpp b/src/GameData.cpp index f72d9f9a4..908e5603a 100644 --- a/src/GameData.cpp +++ b/src/GameData.cpp @@ -14,7 +14,7 @@ const std::string GameData::xmlTagTimesPlayed = "timesplayed"; GameData::GameData(SystemData* system, std::string path, std::string name) - : mSystem(system), mPath(path), mName(name), mRating(0), mTimesPlayed(0) + : mSystem(system), mPath(path), mName(name), mRating(0.0f), mTimesPlayed(0) { } @@ -63,12 +63,12 @@ void GameData::setImagePath(const std::string & imagePath) mImagePath = imagePath; } -size_t GameData::getRating() const +float GameData::getRating() const { return mRating; } -void GameData::setRating(size_t rating) +void GameData::setRating(float rating) { mRating = rating; } diff --git a/src/GameData.h b/src/GameData.h index bd34be4ea..edcede2c2 100644 --- a/src/GameData.h +++ b/src/GameData.h @@ -34,8 +34,8 @@ public: const std::string & getImagePath() const; void setImagePath(const std::string & imagePath); - size_t getRating() const; - void setRating(size_t rating); + float getRating() const; + void setRating(float rating); size_t getTimesPlayed() const; void setTimesPlayed(size_t timesPlayed); @@ -52,7 +52,7 @@ private: //extra data std::string mDescription; std::string mImagePath; - size_t mRating; + float mRating; size_t mTimesPlayed; }; diff --git a/src/XMLReader.cpp b/src/XMLReader.cpp index 928fbd8ff..47e6527aa 100644 --- a/src/XMLReader.cpp +++ b/src/XMLReader.cpp @@ -182,7 +182,7 @@ void parseGamelist(SystemData* system) //get rating and the times played from the XML doc if(gameNode.child(GameData::xmlTagRating.c_str())) { - size_t rating; + float rating; std::istringstream(gameNode.child(GameData::xmlTagRating.c_str()).text().get()) >> rating; game->setRating(rating); } @@ -190,7 +190,7 @@ void parseGamelist(SystemData* system) { size_t timesPlayed; std::istringstream(gameNode.child(GameData::xmlTagTimesPlayed.c_str()).text().get()) >> timesPlayed; - game->setRating(timesPlayed); + game->setTimesPlayed(timesPlayed); } } else{ @@ -222,7 +222,7 @@ void addGameDataNode(pugi::xml_node & parent, const GameData * game) } //all other values are added regardless of their value pugi::xml_node ratingNode = newGame.append_child(GameData::xmlTagRating.c_str()); - ratingNode.text().set(std::to_string((unsigned long long)game->getRating()).c_str()); + ratingNode.text().set(std::to_string((long double)game->getRating()).c_str()); pugi::xml_node timesPlayedNode = newGame.append_child(GameData::xmlTagTimesPlayed.c_str()); timesPlayedNode.text().set(std::to_string((unsigned long long)game->getTimesPlayed()).c_str()); }