mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
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.
This commit is contained in:
parent
556b9fa3fe
commit
d99134763f
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue