|
From: Yoda-JM <yo...@us...> - 2009-10-25 16:37:55
|
Module: performous
Branch: master
Commit: aaeec2e9f18a00d6d030ce021d1a728bc1e63cc7
Author: Vincent Le Ligeour <yo...@us...>
Date: Sun Oct 25 17:37:31 2009 +0100
Fixed player config file, getSharePath cannot return correct path if the file does not exists
---
game/main.cc | 2 +-
game/players.cc | 8 ++++----
game/players.hh | 5 +++--
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/game/main.cc b/game/main.cc
index 7171f12..cc8993a 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -140,7 +140,7 @@ void mainLoop() {
Audio audio;
audioSetup(capture, audio);
Songs songs(songlist);
- Players players(getSharePath("performous.xml"));
+ Players players(getHomeDir() / ".config" / "performous-players.xml");
ScreenManager sm;
Window window(config["graphic/window_width"].i(), config["graphic/window_height"].i(), config["graphic/fullscreen"].b());
sm.addScreen(new ScreenIntro("Intro", audio, capture));
diff --git a/game/players.cc b/game/players.cc
index 2327493..4fe825b 100644
--- a/game/players.cc
+++ b/game/players.cc
@@ -9,7 +9,7 @@
#include <boost/regex.hpp>
#include <libxml++/libxml++.h>
-Players::Players(std::string filename):
+Players::Players(fs::path filename):
m_players(),
m_filtered(),
m_filename(filename),
@@ -29,7 +29,7 @@ Players::~Players() {
}
void Players::load() {
- xmlpp::DomParser domParser(m_filename);
+ xmlpp::DomParser domParser(m_filename.string());
xmlpp::NodeSet n = domParser.get_document()->get_root_node()->find("/performous/players/player");
for (xmlpp::NodeSet::const_iterator it = n.begin(); it != n.end(); ++it)
@@ -64,7 +64,7 @@ void Players::save() {
}
}
- doc.write_to_file_formatted(m_filename, "UTF-8");
+ doc.write_to_file_formatted(m_filename.string(), "UTF-8");
}
void Players::update() {
@@ -72,7 +72,7 @@ void Players::update() {
}
std::string Players::file() {
- return m_filename;
+ return m_filename.string();
}
void Players::addPlayer (std::string const& name, std::string const& picture) {
diff --git a/game/players.hh b/game/players.hh
index 17ea7a1..191dfe5 100644
--- a/game/players.hh
+++ b/game/players.hh
@@ -6,6 +6,7 @@
#include "player.hh"
#include "animvalue.hh"
+#include "fs.hh"
/**A collection of all Players.
@@ -22,7 +23,7 @@ class Players: boost::noncopyable {
players_t m_players;
players_t m_filtered;
- std::string m_filename;
+ fs::path m_filename;
std::string m_filter;
AnimAcceleration math_cover;
@@ -33,7 +34,7 @@ class Players: boost::noncopyable {
cur_scores_t scores;
public:
- Players(std::string filename);
+ Players(fs::path filename);
~Players();
void load();
|