You can subscribe to this list here.
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(25) |
Jul
(288) |
Aug
(119) |
Sep
(31) |
Oct
(59) |
Nov
(458) |
Dec
(359) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
(268) |
Feb
(26) |
Mar
(36) |
Apr
(48) |
May
(119) |
Jun
(37) |
Jul
(173) |
Aug
(429) |
Sep
(137) |
Oct
(156) |
Nov
(59) |
Dec
(45) |
| 2011 |
Jan
(398) |
Feb
(257) |
Mar
(49) |
Apr
(5) |
May
(34) |
Jun
(11) |
Jul
(38) |
Aug
(12) |
Sep
(1) |
Oct
(49) |
Nov
(5) |
Dec
(10) |
| 2012 |
Jan
(21) |
Feb
(32) |
Mar
(20) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(173) |
Aug
|
Sep
(25) |
Oct
(6) |
Nov
(44) |
Dec
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:34:14
|
Module: performous
Branch: hiscore
Commit: 10ffe1bca8ff11bc9563bb892bc40e0ca87c452b
Author: Markus Raab <un...@ma...>
Date: Fri Jul 24 12:31:27 2009 +0200
a very very basic Players implementation
---
game/.gitignore | 2 ++
game/player.hh | 15 ---------------
game/players.cc | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
game/players.hh | 26 ++++++++++++++++++++++++--
4 files changed, 72 insertions(+), 19 deletions(-)
diff --git a/game/.gitignore b/game/.gitignore
index 179d259..13ba250 100644
--- a/game/.gitignore
+++ b/game/.gitignore
@@ -2,3 +2,5 @@
Makefile
highscore
highscore.txt
+players
+players.txt
diff --git a/game/player.hh b/game/player.hh
index 5d3e7eb..8c49384 100644
--- a/game/player.hh
+++ b/game/player.hh
@@ -41,18 +41,3 @@ struct Player {
return 10000.0 * m_score;
}
};
-
-/** Static Information of a player, not
- dependent from current song.
-
- Used for Players Management.
- */
-struct PlayerItem
-{
- std::string name; /// unique name, link to highscore
-/* Future ideas
- std::string displayedName; /// artist name, short name, nick (can be changed)
- std::string picture; /// a path to a picture shown
- std::map<std::string, int> scores; /// map between a Song and the highest score the Player achieved
-*/
-};
diff --git a/game/players.cc b/game/players.cc
index e9eb96c..eb33f87 100644
--- a/game/players.cc
+++ b/game/players.cc
@@ -1,7 +1,51 @@
#include "players.hh"
-void Players::load()
+#include <fstream>
+
+Players::Players(std::string filename):
+ m_filename(filename)
{}
-void Players::save()
+Players::~Players()
{}
+
+void Players::load()
+{
+ std::ifstream in (m_filename.c_str());
+
+ std::string str;
+ while (getline(in, str))
+ {
+ addPlayer(str);
+ }
+}
+
+void Players::save()
+{
+ std::ofstream out (m_filename.c_str());
+
+ for (players_t::const_iterator it = m_players.begin(); it!=m_players.end(); ++it)
+ {
+ out << it->name << std::endl;
+ }
+}
+
+void Players::addPlayer (std::string name)
+{
+ PlayerItem pi;
+ pi.name = name;
+ m_players.push_back(pi);
+}
+
+#include <iostream>
+
+int main(int argc, char** argv)
+{
+ if (argc != 2) return 1;
+
+ std::string name = argv[1];
+ Players p("players.txt");
+ p.load();
+ p.addPlayer(name);
+ p.save();
+}
diff --git a/game/players.hh b/game/players.hh
index 8d3187d..ac94092 100644
--- a/game/players.hh
+++ b/game/players.hh
@@ -1,6 +1,22 @@
#pragma once
+#include <list>
+#include <string>
-#include "player.hh"
+
+/** Static Information of a player, not
+ dependent from current song.
+
+ Used for Players Management.
+ */
+struct PlayerItem
+{
+ std::string name; /// unique name, link to highscore
+/* Future ideas
+ std::string displayedName; /// artist name, short name, nick (can be changed)
+ std::string picture; /// a path to a picture shown
+ std::map<std::string, int> scores; /// map between a Song and the highest score the Player achieved
+*/
+};
/**A collection of all Players.
@@ -8,9 +24,15 @@
be retrieved with Engine::getPlayers().*/
class Players
{
+ public:
+ typedef std::list<PlayerItem> players_t;
private:
- std::list<PlayerItem> m_players;
+ players_t m_players;
+ std::string m_filename;
public:
+ Players(std::string filename);
+ ~Players();
void load();
void save();
+ void addPlayer (std::string name);
};
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:34:13
|
Module: performous
Branch: hiscore
Commit: 54f381e4c47697c1f995b0656dcb5d0150bb3c4d
Author: Markus Raab <un...@ma...>
Date: Fri Jul 24 12:06:05 2009 +0200
Introduce PlayerItem
---
game/player.hh | 14 ++++++++++++++
game/players.hh | 2 +-
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/game/player.hh b/game/player.hh
index a983e51..5d3e7eb 100644
--- a/game/player.hh
+++ b/game/player.hh
@@ -40,5 +40,19 @@ struct Player {
int getScore() const {
return 10000.0 * m_score;
}
+};
+
+/** Static Information of a player, not
+ dependent from current song.
+ Used for Players Management.
+ */
+struct PlayerItem
+{
+ std::string name; /// unique name, link to highscore
+/* Future ideas
+ std::string displayedName; /// artist name, short name, nick (can be changed)
+ std::string picture; /// a path to a picture shown
+ std::map<std::string, int> scores; /// map between a Song and the highest score the Player achieved
+*/
};
diff --git a/game/players.hh b/game/players.hh
index e400984..8d3187d 100644
--- a/game/players.hh
+++ b/game/players.hh
@@ -9,7 +9,7 @@
class Players
{
private:
- std::list<Player> m_players;
+ std::list<PlayerItem> m_players;
public:
void load();
void save();
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:34:11
|
Module: performous
Branch: hiscore
Commit: 440be91e969bea142095c2d4bbb24c1ab4b169d9
Author: Markus Raab <un...@ma...>
Date: Fri Jul 24 09:03:12 2009 +0200
player in separate class
prepare for players
---
game/engine.cc | 20 --------------------
game/engine.hh | 40 +---------------------------------------
game/player.cc | 24 ++++++++++++++++++++++++
game/player.hh | 44 ++++++++++++++++++++++++++++++++++++++++++++
game/players.cc | 7 +++++++
game/players.hh | 16 ++++++++++++++++
6 files changed, 92 insertions(+), 59 deletions(-)
diff --git a/game/engine.cc b/game/engine.cc
index b9e2f53..c774bea 100644
--- a/game/engine.cc
+++ b/game/engine.cc
@@ -2,23 +2,3 @@
const double Engine::TIMESTEP = 0.01;
-void Player::update() {
- if (m_pos == m_pitch.size()) return; // End of song already
- Tone const* t = m_analyzer.findTone();
- if (t) {
- m_activitytimer = 1000;
- double beginTime = Engine::TIMESTEP * m_pos;
- m_pitch[m_pos++] = std::make_pair(t->freq, t->stabledb);
- double endTime = Engine::TIMESTEP * m_pos;
- while (m_scoreIt != m_song.notes.end()) {
- m_score += m_song.m_scoreFactor * m_scoreIt->score(m_song.scale.getNote(t->freq), beginTime, endTime);
- if (endTime < m_scoreIt->end) break;
- ++m_scoreIt;
- }
- m_score = clamp(m_score, 0.0, 1.0);
- } else {
- if (m_activitytimer > 0) --m_activitytimer;
- m_pitch[m_pos++] = std::make_pair(getNaN(), -getInf());
- }
-}
-
diff --git a/game/engine.hh b/game/engine.hh
index d1c2625..ac8c2bd 100644
--- a/game/engine.hh
+++ b/game/engine.hh
@@ -5,52 +5,14 @@
#include "audio.hh"
#include "color.hh"
#include "pitch.hh"
-#include "screen.hh"
#include "songs.hh"
-#include "util.hh"
#include "xtime.hh"
#include "configuration.hh"
+#include "player.hh"
#include <boost/bind.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
-#include <limits>
#include <list>
-#include <utility>
-
-/// player class
-struct Player {
- /// currently playing song
- Song& m_song;
- /// sound analyzer
- Analyzer& m_analyzer;
- /// player color for bars, waves, scores
- Color m_color;
- /// typedef for pitch
- typedef std::vector<std::pair<double, double> > pitch_t;
- /// player's pitch
- pitch_t m_pitch;
- /// current position in pitch vector (first unused spot)
- size_t m_pos;
- /// score for current song
- double m_score;
- /// activity timer
- unsigned m_activitytimer;
- /// score iterator
- Notes::const_iterator m_scoreIt;
- /// constructor
- Player(Song& song, Analyzer& analyzer, size_t frames): m_song(song), m_analyzer(analyzer), m_pitch(frames, std::make_pair(getNaN(), -getInf())), m_pos(), m_score(), m_activitytimer(), m_scoreIt(m_song.notes.begin()) {}
- /// prepares analyzer
- void prepare() { m_analyzer.process(); }
- /// updates player stats
- void update();
- /// player activity singing
- float activity() const { return m_activitytimer / 300.0; }
- /// get player's score
- int getScore() const {
- return 10000.0 * m_score;
- }
-
-};
namespace {
const Color playerColors[] = {
diff --git a/game/player.cc b/game/player.cc
new file mode 100644
index 0000000..697ad5e
--- /dev/null
+++ b/game/player.cc
@@ -0,0 +1,24 @@
+#include "player.hh"
+
+#include "engine.hh" // just for Engine::TIMESTEP
+
+void Player::update() {
+ if (m_pos == m_pitch.size()) return; // End of song already
+ Tone const* t = m_analyzer.findTone();
+ if (t) {
+ m_activitytimer = 1000;
+ double beginTime = Engine::TIMESTEP * m_pos;
+ m_pitch[m_pos++] = std::make_pair(t->freq, t->stabledb);
+ double endTime = Engine::TIMESTEP * m_pos;
+ while (m_scoreIt != m_song.notes.end()) {
+ m_score += m_song.m_scoreFactor * m_scoreIt->score(m_song.scale.getNote(t->freq), beginTime, endTime);
+ if (endTime < m_scoreIt->end) break;
+ ++m_scoreIt;
+ }
+ m_score = clamp(m_score, 0.0, 1.0);
+ } else {
+ if (m_activitytimer > 0) --m_activitytimer;
+ m_pitch[m_pos++] = std::make_pair(getNaN(), -getInf());
+ }
+}
+
diff --git a/game/player.hh b/game/player.hh
new file mode 100644
index 0000000..a983e51
--- /dev/null
+++ b/game/player.hh
@@ -0,0 +1,44 @@
+#pragma once
+#include "songs.hh"
+#include "color.hh"
+#include "pitch.hh"
+#include "util.hh"
+
+#include <vector>
+#include <limits>
+
+
+/// player class
+struct Player {
+ /// currently playing song
+ Song& m_song;
+ /// sound analyzer
+ Analyzer& m_analyzer;
+ /// player color for bars, waves, scores
+ Color m_color;
+ /// typedef for pitch
+ typedef std::vector<std::pair<double, double> > pitch_t;
+ /// player's pitch
+ pitch_t m_pitch;
+ /// current position in pitch vector (first unused spot)
+ size_t m_pos;
+ /// score for current song
+ double m_score;
+ /// activity timer
+ unsigned m_activitytimer;
+ /// score iterator
+ Notes::const_iterator m_scoreIt;
+ /// constructor
+ Player(Song& song, Analyzer& analyzer, size_t frames): m_song(song), m_analyzer(analyzer), m_pitch(frames, std::make_pair(getNaN(), -getInf())), m_pos(), m_score(), m_activitytimer(), m_scoreIt(m_song.notes.begin()) {}
+ /// prepares analyzer
+ void prepare() { m_analyzer.process(); }
+ /// updates player stats
+ void update();
+ /// player activity singing
+ float activity() const { return m_activitytimer / 300.0; }
+ /// get player's score
+ int getScore() const {
+ return 10000.0 * m_score;
+ }
+
+};
diff --git a/game/players.cc b/game/players.cc
new file mode 100644
index 0000000..e9eb96c
--- /dev/null
+++ b/game/players.cc
@@ -0,0 +1,7 @@
+#include "players.hh"
+
+void Players::load()
+{}
+
+void Players::save()
+{}
diff --git a/game/players.hh b/game/players.hh
new file mode 100644
index 0000000..e400984
--- /dev/null
+++ b/game/players.hh
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "player.hh"
+
+/**A collection of all Players.
+
+ The current players plugged in a song can
+ be retrieved with Engine::getPlayers().*/
+class Players
+{
+ private:
+ std::list<Player> m_players;
+ public:
+ void load();
+ void save();
+};
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:34:10
|
Module: performous
Branch: hiscore
Commit: c2119b87fbf54d136864aa14eb603e007c09b17a
Author: Markus Raab <un...@ma...>
Date: Fri Jul 24 08:38:20 2009 +0200
Take path of song
needs songdir writeable to save highscore
---
game/screen_sing.cc | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 7044366..a3f39d1 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -221,8 +221,8 @@ ScoreWindow::ScoreWindow(Engine& e, Song const& song):
e.kill(); // kill the engine thread (to avoid consuming memory)
- // TODO correct path and filename
- HighScore hi ("", "High.sco");
+ HighScore hi (m_song.path, "High.sco");
+ // TODO fallback path if not writeable?
try {
hi.load();
} catch (HighScoreException const& hi) {
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:34:08
|
Module: performous Branch: hiscore Commit: 47973d0500dbaeb1aa289211c2fda114daef35bd Author: Markus Raab <un...@ma...> Date: Fri Jul 24 08:29:11 2009 +0200 only one song is passed to ScreenSing also pass the current Song to ScoreWindow --- game/layout_singer.cc | 6 +++--- game/layout_singer.hh | 4 ++-- game/main.cc | 2 +- game/screen_sing.cc | 33 ++++++++++++++++----------------- game/screen_sing.hh | 14 ++++++++++---- game/screen_songs.cc | 31 ++++++++++++++++++++++--------- game/screen_songs.hh | 1 + game/songs.hh | 2 ++ 8 files changed, 57 insertions(+), 36 deletions(-) |
|
From: Markus R. <god...@us...> - 2009-07-29 15:34:07
|
Module: performous Branch: hiscore Commit: 761ca1ed6cf6c38700d705cda92bc14bf24001e3 Author: Markus Raab <un...@ma...> Date: Thu Jul 23 17:10:36 2009 +0200 utf8 converting --- game/highscore.cc | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/game/highscore.cc b/game/highscore.cc index ef74176..559aab2 100644 --- a/game/highscore.cc +++ b/game/highscore.cc @@ -34,7 +34,7 @@ void HighScore::load() std::stringstream ss; ss.write(&data[0], size); - // XXX convertToUTF8(ss, m_path + m_filename); + convertToUTF8(ss, m_path + m_filename); // now parse line by line and build up highscore std::string str; |
|
From: Markus R. <god...@us...> - 2009-07-29 15:34:06
|
Module: performous
Branch: hiscore
Commit: e7b84f6167e152d3ab84a98b17f89f26ed5d79f5
Author: Markus Raab <un...@ma...>
Date: Thu Jul 23 16:33:20 2009 +0200
highscore is now a int number between 0 and 10000
---
game/highscore.cc | 19 +++++++++++--------
game/highscore.hh | 11 +++++++----
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/game/highscore.cc b/game/highscore.cc
index 46bdc87..ef74176 100644
--- a/game/highscore.cc
+++ b/game/highscore.cc
@@ -74,15 +74,16 @@ void HighScore::load()
std::string sscore = str.substr(8, str.length()-8);
if (sscore.empty()) throw HighScoreException("Did not find score", linenum);
+ int score = 0;
try {
- double score = boost::lexical_cast<int>(sscore) / 10000.0;
- if (score < 0.0 || score > 1.0) throw HighScoreException("Number not between 0 and 10000", linenum);
- if (playernum>0 && m_scores[playernum-1].score < score) throw HighScoreException("Lower ranked highscore is higher", linenum);
- m_scores[playernum].score = score;
+ score = boost::lexical_cast<int>(sscore);
} catch (boost::bad_lexical_cast const& blc)
{
- throw HighScoreException("Did not find valid double number", linenum);
+ throw HighScoreException("Did not find valid int number", linenum);
}
+ if (score < 0 || score > 10000) throw HighScoreException("Number not between 0 and 10000", linenum);
+ if (playernum>0 && m_scores[playernum-1].score < score) throw HighScoreException("Lower ranked highscore is higher", linenum);
+ m_scores[playernum].score = score;
playernum++;
@@ -98,11 +99,13 @@ void HighScore::save()
out.exceptions ( std::ofstream::eofbit | std::ofstream::failbit | std::ofstream::badbit );
for (size_t i=0; i<m_scores.size();i++)
{
+ if (m_scores[i].score <= 0) break; // maybe change to 500?
+
try {
out << "#PLAYER" << i << ":"
<< m_scores[i].name << std::endl;
out << "#SCORE" << i << ":"
- << m_scores[i].score*10000 << std::endl;
+ << m_scores[i].score << std::endl;
} catch (std::ofstream::failure const&) {
throw HighScoreException("Unexpected I/O error", i);
}
@@ -110,7 +113,7 @@ void HighScore::save()
out << "E" << std::endl;
}
-void HighScore::addNewHighscore(std::string name, double score)
+void HighScore::addNewHighscore(std::string name, int score)
{
HighScoreItem hsi;
hsi.name = name;
@@ -130,7 +133,7 @@ int main()
try {
HighScore hi ("", "highscore.txt");
hi.load();
- double new_score = 0.9;
+ int new_score = 9000;
if (hi.reachedNewHighscore(new_score))
{
std::cout << "Reached new highscore" << std::endl;
diff --git a/game/highscore.hh b/game/highscore.hh
index ea50b93..032eb14 100644
--- a/game/highscore.hh
+++ b/game/highscore.hh
@@ -20,7 +20,7 @@ struct HighScoreException: public std::runtime_error {
single item of a highscore.*/
struct HighScoreItem {
std::string name;
- double score;
+ int score;
// std::string song;
/**Operator for sorting by score.*/
@@ -40,15 +40,18 @@ class HighScore {
void save();
/**Check if you reached a new highscore.
+ @param score is a value between 0 and 10000
+ values below 500 will lead to returning false
@return true if the score make it into the top.
@return false if addNewHighscore does not make sense
for that score.*/
- bool reachedNewHighscore(double score)
+ bool reachedNewHighscore(int score)
{
- return score > m_scores.back().score;
+ if (score < 500) return false;
+ return score > m_scores[2].score;
}
/**Add a new entry to the highscore.*/
- void addNewHighscore(std::string name, double score);
+ void addNewHighscore(std::string name, int score);
private:
static const int m_maxEntries = 10;
std::string m_path;
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:34:05
|
Module: performous
Branch: hiscore
Commit: 7ec7250d7b2d8e342927fdfc455fc8b32d615314
Author: Markus Raab <un...@ma...>
Date: Thu Jul 23 15:56:19 2009 +0200
loading and saving Highscore now works
---
game/.gitignore | 1 +
game/highscore.cc | 73 ++++++++++++++++++++++++++++++++++++++++++----------
game/highscore.hh | 34 +++++++++++++++++++++++-
3 files changed, 92 insertions(+), 16 deletions(-)
diff --git a/game/.gitignore b/game/.gitignore
index 6899cb8..179d259 100644
--- a/game/.gitignore
+++ b/game/.gitignore
@@ -1,3 +1,4 @@
.ctags
Makefile
+highscore
highscore.txt
diff --git a/game/highscore.cc b/game/highscore.cc
index 8c67110..46bdc87 100644
--- a/game/highscore.cc
+++ b/game/highscore.cc
@@ -5,10 +5,18 @@
#include <fstream>
#include <sstream>
+#include <algorithm>
HighScore::HighScore (std::string const& path_, std::string const& filename_) :
m_path(path_),
- m_filename(filename_)
+ m_filename(filename_),
+ m_scores(m_maxEntries)
+{}
+
+HighScore::~HighScore()
+{}
+
+void HighScore::load()
{
std::ifstream in((m_path + m_filename).c_str());
@@ -26,7 +34,7 @@ HighScore::HighScore (std::string const& path_, std::string const& filename_) :
std::stringstream ss;
ss.write(&data[0], size);
- convertToUTF8(ss, m_path + m_filename);
+ // XXX convertToUTF8(ss, m_path + m_filename);
// now parse line by line and build up highscore
std::string str;
@@ -49,8 +57,7 @@ HighScore::HighScore (std::string const& path_, std::string const& filename_) :
std::string name = str.substr(9, str.length()-9);
if (name.empty()) throw HighScoreException("Did not find name", linenum);
- std::cout << "name: " << name << std::endl;
- m_names.push_back(name);
+ m_scores[playernum].name = name;
std::getline(ss, str);
linenum++;
@@ -64,34 +71,72 @@ HighScore::HighScore (std::string const& path_, std::string const& filename_) :
if (nr != playernum + '0') throw HighScoreException("Did not find correct playernum", linenum);
if (str[7] != ':') throw HighScoreException("Did not find :", linenum);
- std::string score = str.substr(8, str.length()-8);
- if (score.empty()) throw HighScoreException("Did not find score", linenum);
- std::cout << "score: " << score << std::endl;
+ std::string sscore = str.substr(8, str.length()-8);
+ if (sscore.empty()) throw HighScoreException("Did not find score", linenum);
try {
- double dscore = boost::lexical_cast<int>(score) / 10000.0;
- if (dscore < 0.0 || dscore > 1.0) throw HighScoreException("Number not between 0 and 10000", linenum);
- if (playernum>0 && m_scores.back() < dscore) throw HighScoreException("Lower ranked highscore is higher", linenum);
- m_scores.push_back(dscore);
+ double score = boost::lexical_cast<int>(sscore) / 10000.0;
+ if (score < 0.0 || score > 1.0) throw HighScoreException("Number not between 0 and 10000", linenum);
+ if (playernum>0 && m_scores[playernum-1].score < score) throw HighScoreException("Lower ranked highscore is higher", linenum);
+ m_scores[playernum].score = score;
} catch (boost::bad_lexical_cast const& blc)
{
throw HighScoreException("Did not find valid double number", linenum);
}
+
playernum++;
}
}
-HighScore::~HighScore()
-{}
+void HighScore::save()
+{
+ std::ofstream out ((m_path + m_filename).c_str());
+
+ if (!out.is_open()) throw HighScoreException("Could not open file for writing", 0);
+
+ out.exceptions ( std::ofstream::eofbit | std::ofstream::failbit | std::ofstream::badbit );
+ for (size_t i=0; i<m_scores.size();i++)
+ {
+ try {
+ out << "#PLAYER" << i << ":"
+ << m_scores[i].name << std::endl;
+ out << "#SCORE" << i << ":"
+ << m_scores[i].score*10000 << std::endl;
+ } catch (std::ofstream::failure const&) {
+ throw HighScoreException("Unexpected I/O error", i);
+ }
+ }
+ out << "E" << std::endl;
+}
+
+void HighScore::addNewHighscore(std::string name, double score)
+{
+ HighScoreItem hsi;
+ hsi.name = name;
+ hsi.score = score;
+
+ m_scores.push_back(hsi);
+ std::sort(m_scores.begin(), m_scores.end());
+
+ m_scores.resize(m_maxEntries); // throw away worst score
+}
/*
-#include <iostream> // TODO debug
+#include <iostream>
int main()
{
try {
HighScore hi ("", "highscore.txt");
+ hi.load();
+ double new_score = 0.9;
+ if (hi.reachedNewHighscore(new_score))
+ {
+ std::cout << "Reached new highscore" << std::endl;
+ hi.addNewHighscore("new player", new_score);
+ }
+ hi.save();
} catch (HighScoreException const& hie)
{
std::cerr << "Exception: " << hie.what()
diff --git a/game/highscore.hh b/game/highscore.hh
index 5f4d766..ea50b93 100644
--- a/game/highscore.hh
+++ b/game/highscore.hh
@@ -4,24 +4,54 @@
#include <vector>
#include <stdexcept>
+/**Exception which will be thrown when loading or
+ saving a HighScore fails.*/
struct HighScoreException: public std::runtime_error {
HighScoreException (std::string const& msg, unsigned int linenum) :
runtime_error(msg), m_linenum(linenum)
{}
+ /**Line information where the problem occured.*/
unsigned int line() const {return m_linenum;}
private:
unsigned int m_linenum;
};
+/**This struct holds together information for a
+ single item of a highscore.*/
+struct HighScoreItem {
+ std::string name;
+ double score;
+ // std::string song;
+
+ /**Operator for sorting by score.*/
+ bool operator < (HighScoreItem const& other) const
+ {
+ return other.score < score;
+ }
+};
+
+/**HighScore loads and saves a list of HighScoreItems.*/
class HighScore {
public:
HighScore (std::string const& path_, std::string const& filename_);
~HighScore ();
+ void load();
void save();
+
+ /**Check if you reached a new highscore.
+ @return true if the score make it into the top.
+ @return false if addNewHighscore does not make sense
+ for that score.*/
+ bool reachedNewHighscore(double score)
+ {
+ return score > m_scores.back().score;
+ }
+ /**Add a new entry to the highscore.*/
+ void addNewHighscore(std::string name, double score);
private:
+ static const int m_maxEntries = 10;
std::string m_path;
std::string m_filename;
- std::vector <std::string> m_names;
- std::vector <double> m_scores;
+ std::vector <HighScoreItem> m_scores;
};
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:34:04
|
Module: performous
Branch: hiscore
Commit: 03504520d99ebba6d95a6898b4d9be67a45d9d2e
Author: Markus Raab <un...@ma...>
Date: Thu Jul 23 16:53:18 2009 +0200
write highscore after song
---
game/screen_sing.cc | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 3a21b47..2df6466 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -3,6 +3,7 @@
#include "util.hh"
#include "configuration.hh"
#include "xtime.hh"
+#include "highscore.hh"
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
#include "songs.hh"
@@ -218,13 +219,32 @@ ScoreWindow::ScoreWindow(Engine& e):
m_players(e.getPlayers())
{
m_pos.setTarget(0.0);
- unsigned int topScore = 0;
e.kill(); // kill the engine thread (to avoid consuming memory)
+
+
+ // TODO correct path and filename
+ HighScore hi ("", "High.sco");
+ try {
+ hi.load();
+ } catch (HighScoreException const& hi) {
+ std::cerr << "high.sco:" << hi.line() << " " << hi.what() << std::endl;
+ }
+ unsigned int topScore = 0;
for (std::list<Player>::iterator p = m_players.begin(); p != m_players.end();) {
unsigned int score = p->getScore();
if (score < 500) { p = m_players.erase(p); continue; }
if (score > topScore) topScore = score;
++p;
+ if (hi.reachedNewHighscore(score))
+ {
+ // TODO ask for name...
+ hi.addNewHighscore(getenv ("USER"), score);
+ }
+ }
+ try {
+ hi.save();
+ } catch (HighScoreException const& hi) {
+ std::cerr << "high.sco:" << hi.line() << " " << hi.what() << std::endl;
}
if (m_players.empty()) m_rank = "No singer!";
else if (topScore > 8000) m_rank = "Hit singer";
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:33:59
|
Module: performous
Branch: hiscore
Commit: 7e7937546cee1ef1aaebe1a137584dd9ba10ff3e
Author: Markus Raab <un...@ma...>
Date: Thu Jul 23 10:42:16 2009 +0200
highscore implementation
---
game/.gitignore | 3 ++
game/highscore.cc | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++
game/highscore.hh | 27 ++++++++++++++
3 files changed, 132 insertions(+), 0 deletions(-)
diff --git a/game/.gitignore b/game/.gitignore
new file mode 100644
index 0000000..6899cb8
--- /dev/null
+++ b/game/.gitignore
@@ -0,0 +1,3 @@
+.ctags
+Makefile
+highscore.txt
diff --git a/game/highscore.cc b/game/highscore.cc
new file mode 100644
index 0000000..8c67110
--- /dev/null
+++ b/game/highscore.cc
@@ -0,0 +1,102 @@
+#include "highscore.hh"
+#include <boost/lexical_cast.hpp>
+
+#include "unicode.hh"
+
+#include <fstream>
+#include <sstream>
+
+HighScore::HighScore (std::string const& path_, std::string const& filename_) :
+ m_path(path_),
+ m_filename(filename_)
+{
+ std::ifstream in((m_path + m_filename).c_str());
+
+ if (!in.is_open()) throw HighScoreException("Could not open highscore file", 0);
+
+
+ in.seekg(0, std::ios::end);
+ size_t size = in.tellg();
+ if (size < 10 || size > 100000) throw HighScoreException("Does not look like a highscore file (wrong size)", 1);
+ in.seekg(0);
+
+ std::vector<char> data(size);
+ if (!in.read(&data[0], size)) throw HighScoreException("Unexpected I/O error", 0);
+
+ std::stringstream ss;
+ ss.write(&data[0], size);
+
+ convertToUTF8(ss, m_path + m_filename);
+
+ // now parse line by line and build up highscore
+ std::string str;
+ unsigned int linenum = 0;
+ unsigned int playernum = 0;
+ while (std::getline(ss, str))
+ {
+ if (str == "E") break;
+ linenum++;
+ if (playernum > 9) throw HighScoreException("Not more than 10 highscores expected in file", linenum);
+ if (str.empty()) continue; // ignore empty player lines
+ if (str.length() <= 9) throw HighScoreException("Line not long enough for player information", linenum);
+
+ if (str[0] != '#') throw HighScoreException("No # found at begin of line", linenum);
+ if (str.substr(1,6) != "PLAYER") throw HighScoreException("Expected PLAYER not found", linenum);
+
+ unsigned int nr = str[7];
+ if (nr != playernum + '0') throw HighScoreException("Did not find correct playernum", linenum);
+ if (str[8] != ':') throw HighScoreException("Did not find :", linenum);
+
+ std::string name = str.substr(9, str.length()-9);
+ if (name.empty()) throw HighScoreException("Did not find name", linenum);
+ std::cout << "name: " << name << std::endl;
+ m_names.push_back(name);
+
+ std::getline(ss, str);
+ linenum++;
+ if (str.empty()) throw HighScoreException("Expected Score, but found empty line", linenum);
+ if (str.length() <= 8) throw HighScoreException("Line not long enough for score information", linenum);
+
+ if (str[0] != '#') throw HighScoreException("No # found at begin of line", linenum);
+ if (str.substr(1,5) != "SCORE") throw HighScoreException("Expected SCORE not found", linenum);
+
+ nr = str[6];
+ if (nr != playernum + '0') throw HighScoreException("Did not find correct playernum", linenum);
+ if (str[7] != ':') throw HighScoreException("Did not find :", linenum);
+
+ std::string score = str.substr(8, str.length()-8);
+ if (score.empty()) throw HighScoreException("Did not find score", linenum);
+ std::cout << "score: " << score << std::endl;
+
+ try {
+ double dscore = boost::lexical_cast<int>(score) / 10000.0;
+ if (dscore < 0.0 || dscore > 1.0) throw HighScoreException("Number not between 0 and 10000", linenum);
+ if (playernum>0 && m_scores.back() < dscore) throw HighScoreException("Lower ranked highscore is higher", linenum);
+ m_scores.push_back(dscore);
+ } catch (boost::bad_lexical_cast const& blc)
+ {
+ throw HighScoreException("Did not find valid double number", linenum);
+ }
+
+ playernum++;
+ }
+}
+
+HighScore::~HighScore()
+{}
+
+/*
+#include <iostream> // TODO debug
+
+int main()
+{
+ try {
+ HighScore hi ("", "highscore.txt");
+ } catch (HighScoreException const& hie)
+ {
+ std::cerr << "Exception: " << hie.what()
+ << " at line: " << hie.line()
+ << std::endl;
+ }
+}
+*/
diff --git a/game/highscore.hh b/game/highscore.hh
new file mode 100644
index 0000000..5f4d766
--- /dev/null
+++ b/game/highscore.hh
@@ -0,0 +1,27 @@
+#pragma once
+
+#include <string>
+#include <vector>
+#include <stdexcept>
+
+struct HighScoreException: public std::runtime_error {
+ HighScoreException (std::string const& msg, unsigned int linenum) :
+ runtime_error(msg), m_linenum(linenum)
+ {}
+ unsigned int line() const {return m_linenum;}
+ private:
+ unsigned int m_linenum;
+};
+
+class HighScore {
+ public:
+ HighScore (std::string const& path_, std::string const& filename_);
+ ~HighScore ();
+
+ void save();
+ private:
+ std::string m_path;
+ std::string m_filename;
+ std::vector <std::string> m_names;
+ std::vector <double> m_scores;
+};
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:33:56
|
Module: performous Branch: hiscore Commit: ba813b3730474c05f3431d32c181b9c26e78316b Author: Markus Raab <un...@ma...> Date: Thu Jul 23 10:26:03 2009 +0200 small fixes in Compiling.txt --- docs/Compiling.txt | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Compiling.txt b/docs/Compiling.txt index 8156f6c..8f1128d 100644 --- a/docs/Compiling.txt +++ b/docs/Compiling.txt @@ -14,7 +14,7 @@ To install from git: performous # Should you need to change building settings (e.g. installation prefix) - ccmake . + ccmake .. Dependencies: @@ -55,7 +55,7 @@ After that make sure that all the characters display correctly. If they don't, you need to guess which charset the original used (instead of CP1252) and retry. If you want to improve the game, join our IRC channel #Performous (Freenode) and -you'll get SVN write access. +you'll get git write access. For more (up to date) information, see http://performous.org/ |
|
From: Markus R. <god...@us...> - 2009-07-29 15:33:55
|
Module: performous
Branch: hiscore
Commit: 47770d645728a085eecb435cfcaf228b36f7bf09
Author: Markus Raab <un...@ma...>
Date: Thu Jul 23 08:35:26 2009 +0200
missing include file
performous builds now on debian etch
---
game/joystick.cc | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index a787e68..d105b7f 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -1,6 +1,8 @@
#include "joystick.hh"
#include <iostream>
+#include <boost/lexical_cast.hpp>
+
Joysticks joysticks;
Joystick::Joystick(unsigned int _id): m_id(_id) {
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:19:37
|
Module: performous
Branch: hiscore
Commit: 2a377f5090f75356522602f22df081d0d8193f92
Author: Vincent Le Ligeour <yo...@us...>
Date: Tue Jul 28 23:38:58 2009 +0200
Removed double installed file
---
data/CMakeLists.txt | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
index 49891bd..e7b7aa9 100644
--- a/data/CMakeLists.txt
+++ b/data/CMakeLists.txt
@@ -5,7 +5,6 @@ set(CONFIG_FILE "performous.xml")
if(UNIX)
install(FILES ${APPLICATION_FILE} DESTINATION "share/applications/")
install(FILES ${PIXMAP_FILE} DESTINATION "share/pixmaps")
- install(FILES ${PIXMAP_FILE} DESTINATION "share/pixmaps")
endif(UNIX)
install(FILES ${CONFIG_FILE} DESTINATION "${SHARE_INSTALL}/config/")
|
|
From: Yoda-JM <yo...@us...> - 2009-07-28 21:39:32
|
Module: performous
Branch: master
Commit: 2a377f5090f75356522602f22df081d0d8193f92
Author: Vincent Le Ligeour <yo...@us...>
Date: Tue Jul 28 23:38:58 2009 +0200
Removed double installed file
---
data/CMakeLists.txt | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
index 49891bd..e7b7aa9 100644
--- a/data/CMakeLists.txt
+++ b/data/CMakeLists.txt
@@ -5,7 +5,6 @@ set(CONFIG_FILE "performous.xml")
if(UNIX)
install(FILES ${APPLICATION_FILE} DESTINATION "share/applications/")
install(FILES ${PIXMAP_FILE} DESTINATION "share/pixmaps")
- install(FILES ${PIXMAP_FILE} DESTINATION "share/pixmaps")
endif(UNIX)
install(FILES ${CONFIG_FILE} DESTINATION "${SHARE_INSTALL}/config/")
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-07-28 08:35:09
|
Module: performous
Branch: master
Commit: dfed8c6bab086333dfac8e7f94e985cb66996e22
Author: Lasse Karkkainen <tro...@tr...>
Date: Tue Jul 28 11:02:58 2009 +0300
Better guitar gameplay.
---
game/guitargraph.cc | 40 +++++++++++++++++++++++++++++++++-------
1 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 4178b29..d4deeef 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -65,24 +65,50 @@ void GuitarGraph::engine(double time) {
m_pickValue.setValue(1.0);
for (NoteStatus::iterator it = m_notes.begin(); it != m_notes.end(); ++it) if (it->second == 1) it->second = 2;
int basepitch = diffv[m_level].basepitch;
+ Duration const* dIt[5] = {};
+ double begin = getNaN();
+ double tolerance = 0.2;
for (int fret = 0; fret < 5; ++fret) {
- if (!fretPressed[fret]) continue;
NoteMap const& nm = m_song.tracks[m_instrument].nm;
NoteMap::const_iterator it = nm.find(basepitch + fret);
if (it == nm.end()) continue;
Durations const& dur = it->second;
Durations::const_iterator it2 = dur.begin(), it2tmp, it2end = dur.end();
- double tolerance = 0.2;
- while (it2 != it2end && it2->begin < time - tolerance) ++it2;
+ // Find any suitable note within the tolerance
+ while (it2 != it2end && (it2->begin < time - tolerance || m_notes[&*it2] != 0)) ++it2;
+ // If we are already past the accepted region, skip further processing
if (it2 == it2end || it2->begin > time + tolerance) continue;
+ // Find the note with the smallest error
it2tmp = it2;
do {
it2 = it2tmp;
- tolerance = std::abs(it2->begin - time);
+ if (m_notes[&*it2] != 0) continue; // Notes already played are ignored
+ dIt[fret] = &*it2;
+ begin = it2->begin;
+ tolerance = std::abs(begin - time);
} while (++it2tmp != it2end && std::abs(it2tmp->begin - time) < tolerance);
- if (m_notes[&*it2] != 0) continue;
- m_notes[&*it2] = 1;
- m_score += (tolerance < 0.1 ? 50 : 25);
+ }
+ bool need[5] = {};
+ int count = 0;
+ for (int fret = 0; fret < 5; ++fret) {
+ if (!dIt[fret] || dIt[fret]->begin != begin) continue;
+ need[fret] = true;
+ ++count;
+ }
+ bool shadowed = (count == 1); // If the chord only requires one fret, frets on the left side of that are "shadowed" (ignored)
+ for (int fret = 0; fret < 5; ++fret) {
+ if (need[fret] && !fretPressed[fret]) return; // Fret missing -> fail
+ if (need[fret]) shadowed = false;
+ if (!shadowed && fretPressed[fret] && !need[fret]) return; // Pressing non-shadowed fret that is not needed -> fail
+ }
+ // Okay, got this far, we have a match, let's score it
+ for (int fret = 0; fret < 5; ++fret) {
+ if (!need[fret]) continue;
+ m_notes[dIt[fret]] = 1;
+ m_score += 15;
+ if (tolerance < 0.1) m_score += 15;
+ if (tolerance < 0.05) m_score += 15;
+ if (tolerance < 0.03) m_score += 5;
}
}
|
|
From: Yoda-JM <yo...@us...> - 2009-07-28 00:55:22
|
Module: performous
Branch: master
Commit: 4eae4bb83a8e963950d3fab0aa8f7ae84e73e310
Author: Vincent Le Ligeour <yo...@us...>
Date: Tue Jul 28 02:54:59 2009 +0200
Cleaned up dependencies
---
game/CMakeLists.txt | 2 +-
.../games-arcade/performous/performous-9999.ebuild | 7 ++-----
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt
index 848567e..97e70ff 100644
--- a/game/CMakeLists.txt
+++ b/game/CMakeLists.txt
@@ -14,7 +14,7 @@ include_directories(${Boost_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Boost_LIBRARIES})
# Find all the libs that don't require extra parameters
-foreach(lib SDL PangoCairo LibRSVG LibXML++ Magick++ OpenGL GLEW AVFormat SWScale)
+foreach(lib SDL PangoCairo LibRSVG LibXML++ Magick++ GLEW AVFormat SWScale)
find_package(${lib} REQUIRED)
include_directories(${${lib}_INCLUDE_DIRS})
set(LIBS ${LIBS} ${${lib}_LIBRARIES})
diff --git a/portage-overlay/games-arcade/performous/performous-9999.ebuild b/portage-overlay/games-arcade/performous/performous-9999.ebuild
index 491960c..f068622 100644
--- a/portage-overlay/games-arcade/performous/performous-9999.ebuild
+++ b/portage-overlay/games-arcade/performous/performous-9999.ebuild
@@ -33,12 +33,9 @@ RDEPEND="gnome-base/librsvg
dev-libs/boost
x11-libs/pango
dev-cpp/libxmlpp
+ media-libs/glew
media-libs/libsdl[joystick,opengl]
- media-gfx/imagemagick
- (
- virtual/opengl
- virtual/glu
- )
+ media-gfx/imagemagick[png]
>=media-video/ffmpeg-0.4.9_p20070616-r20
alsa? ( media-libs/alsa-lib )
jack? ( media-sound/jack-audio-connection-kit )
|
|
From: Yoda-JM <yo...@us...> - 2009-07-27 17:44:13
|
Module: performous
Branch: 0.3
Commit: dad9b78325eb6379b9c8f927cf48fb26e93ac6c6
Author: Vincent Le Ligeour <yo...@us...>
Date: Mon Jul 27 19:42:07 2009 +0200
Removed libsamplerate dependency (was only required during a few commits)
---
cmake/performous-packaging.cmake | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/cmake/performous-packaging.cmake b/cmake/performous-packaging.cmake
index 8ed4848..acc3027 100644
--- a/cmake/performous-packaging.cmake
+++ b/cmake/performous-packaging.cmake
@@ -51,16 +51,16 @@ if(UNIX)
endif("${CPACK_PACKAGE_ARCHITECTURE}" MATCHES "x86_64")
# Set the dependencies based on the distro version
if("${LSB_DISTRIB}" MATCHES "Ubuntu8.04")
- set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl1.2debian, libcairo2, librsvg2-2, libboost-thread1.34.1, libboost-serialization1.34.1, libboost-program-options1.34.1, libboost-regex1.34.1, libboost-filesystem1.34.1, libboost-date-time1.34.1, libavcodec1d, libavformat1d, libswscale1d, libmagick++10, libsamplerate0, libxml++2.6c2a, libglew1.5")
+ set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl1.2debian, libcairo2, librsvg2-2, libboost-thread1.34.1, libboost-serialization1.34.1, libboost-program-options1.34.1, libboost-regex1.34.1, libboost-filesystem1.34.1, libboost-date-time1.34.1, libavcodec1d, libavformat1d, libswscale1d, libmagick++10, libxml++2.6c2a, libglew1.5")
endif("${LSB_DISTRIB}" MATCHES "Ubuntu8.04")
if("${LSB_DISTRIB}" MATCHES "Ubuntu8.10")
- set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl1.2debian, libcairo2, librsvg2-2, libboost-thread1.35.0, libboost-serialization1.35.0, libboost-program-options1.35.0, libboost-regex1.35.0, libboost-filesystem1.35.0, libboost-date-time1.35.0, libavcodec51, libavformat52, libswscale0, libmagick++10, libsamplerate0, libxml++2.6-2, libglew1.5")
+ set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl1.2debian, libcairo2, librsvg2-2, libboost-thread1.35.0, libboost-serialization1.35.0, libboost-program-options1.35.0, libboost-regex1.35.0, libboost-filesystem1.35.0, libboost-date-time1.35.0, libavcodec51, libavformat52, libswscale0, libmagick++10, libxml++2.6-2, libglew1.5")
endif("${LSB_DISTRIB}" MATCHES "Ubuntu8.10")
if("${LSB_DISTRIB}" MATCHES "Ubuntu9.04")
- set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl1.2debian, libcairo2, librsvg2-2, libboost-thread1.35.0, libboost-program-options1.35.0, libboost-regex1.35.0, libboost-filesystem1.35.0, libboost-date-time1.35.0, libavcodec52, libavformat52, libswscale0, libmagick++1, libsamplerate0, libxml++2.6-2, libglew1.5")
+ set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl1.2debian, libcairo2, librsvg2-2, libboost-thread1.35.0, libboost-program-options1.35.0, libboost-regex1.35.0, libboost-filesystem1.35.0, libboost-date-time1.35.0, libavcodec52, libavformat52, libswscale0, libmagick++1, libxml++2.6-2, libglew1.5")
endif("${LSB_DISTRIB}" MATCHES "Ubuntu9.04")
if("${LSB_DISTRIB}" MATCHES "Ubuntu9.10")
- set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl1.2debian, libcairo2, librsvg2-2, libboost-thread1.38.0, libboost-program-options1.38.0, libboost-regex1.38.0, libboost-filesystem1.38.0, libboost-date-time1.38.0, libavcodec52, libavformat52, libswscale0, libmagick++1, libsamplerate0, libxml++2.6-2, libglew1.5")
+ set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl1.2debian, libcairo2, librsvg2-2, libboost-thread1.38.0, libboost-program-options1.38.0, libboost-regex1.38.0, libboost-filesystem1.38.0, libboost-date-time1.38.0, libavcodec52, libavformat52, libswscale0, libmagick++1, libxml++2.6-2, libglew1.5")
endif("${LSB_DISTRIB}" MATCHES "Ubuntu9.10")
if(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
message("WARNING: ${LSB_DISTRIB} not supported yet.\nPlease set deps in cmake/performous-packaging.cmake before packaging.")
|
|
From: Yoda-JM <yo...@us...> - 2009-07-27 11:24:12
|
Module: performous Branch: master Commit: d0b952b0cb9e409788a59f0d0558a445bd6a9a66 Author: Vincent Le Ligeour <yo...@us...> Date: Mon Jul 27 13:23:26 2009 +0200 Added instrument documentation file --- docs/instruments.txt | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 70 insertions(+), 0 deletions(-) diff --git a/docs/instruments.txt b/docs/instruments.txt new file mode 100644 index 0000000..d8cbb23 --- /dev/null +++ b/docs/instruments.txt @@ -0,0 +1,70 @@ +This file aims to list common band instruments (including dance carpet). +B means button +A means axis (+: positive values, -: negative values) +SDL report axis or button ID minus one. + +Ex: A5- => SDL axis 4 with negative value + +[Guitar Hero III: Legends of Rock] PS3 Guitar + USB id: 12ba:0100 + SDL name: Licensed by Sony Computer Entertainment Guitar Hero3 for PlayStation (R) 3 + GREEN FRET: B2 + RED FRET: B3 + YELLOW FRET: B1 + BLUE FRET: B4 + ORANGE FRET: B5 + START: B10 + SELECT: B9 + PS3: B13 + DOWN: A6+ + UP: A6- + LEFT: A5- + RIGHT: A5+ + BEND: A3+ + PICK DOWN: A6+ + PICK UP: A6- + +[Guitar Hero World Tour] PS3 Guitar + USB id: 12ba:0100 + SDL name: Licensed by Sony Computer Entertainment Guitar Hero4 for PlayStation (R) 3 + GREEN FRET: B2 + RED FRET: B3 + YELLOW FRET: B1 + BLUE FRET: B4 + ORANGE FRET: B5 + HAMMER ZONE: A4 APPROX VALUES: + - GREEN -26000 + - RED -10000 + - YELLOW 2000 + - BLUE 16000 + - ORANGE 32000 + START: B10 + SELECT: B9 (Also activate star power) + PS3: B13 + DOWN: A6+ + UP: A6- + LEFT: A5- + RIGHT: A5+ + BEND: A3+ + PICK DOWN: A6+ + PICK UP: A6- + +[Guitar Hero World Tour] PS3 Drumkit + USB id: 12ba:0120 + SDL name: Licensed by Sony Computer Entertainment Guitar Hero4 for PlayStation (R) 3 + GREEN FRET or CROSS: B2 + RED FRET or CIRCLE: B3 + YELLOW FRET or TRIANGLE: B4 + BLUE FRET or SQUARE: B1 + ORANGE FRET: B6 + KICK: B5 + START: B10 + SELECT: B9 + PS3: B13 + DOWN: A6+ + UP: A6- + LEFT: A5- + RIGHT: A5+ + BEND: A3+ + PICK DOWN: A6+ + PICK UP: A6- |
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-07-27 05:10:36
|
Module: performous
Branch: master
Commit: b253d8fe88cf3a584e8d07b86f33e488da3b89bb
Author: Lasse Karkkainen <tro...@tr...>
Date: Mon Jul 27 08:10:03 2009 +0300
Revert the other, wasn't a leak actually.
---
game/ffmpeg.cc | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/game/ffmpeg.cc b/game/ffmpeg.cc
index df6374e..98a7bc6 100644
--- a/game/ffmpeg.cc
+++ b/game/ffmpeg.cc
@@ -164,9 +164,6 @@ void FFmpeg::operator()() {
m_running = false;
m_eof = true;
videoQueue.push(new VideoFrame()); // EOF marker
-#ifdef USE_FFMPEG_CRASH_RECOVERY
- ffmpeg_ptr.reset(); // Free the memory
-#endif
}
void FFmpeg::seek(double time, bool wait) {
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-07-27 04:28:44
|
Module: performous
Branch: master
Commit: b430fc092ba36020c07338320b0500d22e443e9e
Author: Lasse Karkkainen <tro...@tr...>
Date: Mon Jul 27 07:27:56 2009 +0300
Fix two memory leaks in our FFMPEG code.
---
game/ffmpeg.cc | 19 ++++++++++---------
game/ffmpeg.hh | 13 ++++++-------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/game/ffmpeg.cc b/game/ffmpeg.cc
index a9a53b8..df6374e 100644
--- a/game/ffmpeg.cc
+++ b/game/ffmpeg.cc
@@ -154,7 +154,6 @@ void FFmpeg::operator()() {
errors = 0;
} catch (eof_error&) {
m_eof = true;
- audioQueue.push(new AudioFrame()); // EOF marker
videoQueue.push(new VideoFrame()); // EOF marker
boost::thread::sleep(now() + 0.1);
} catch (std::exception& e) {
@@ -164,8 +163,10 @@ void FFmpeg::operator()() {
}
m_running = false;
m_eof = true;
- audioQueue.push(new AudioFrame()); // EOF marker
videoQueue.push(new VideoFrame()); // EOF marker
+#ifdef USE_FFMPEG_CRASH_RECOVERY
+ ffmpeg_ptr.reset(); // Free the memory
+#endif
}
void FFmpeg::seek(double time, bool wait) {
@@ -249,9 +250,10 @@ void FFmpeg::decodeNextFrame() {
sws_scale(img_convert_ctx, videoFrame->data, videoFrame->linesize, 0, h, &data, &linesize);
}
if (packet.time() == packet.time()) m_position = packet.time();
+ // Construct a new video frame and push it to output queue
VideoFrame* tmp = new VideoFrame(m_position, w, h);
tmp->data.swap(buffer);
- videoQueue.push(tmp);
+ videoQueue.push(tmp); // Takes ownership and may block
}
}
} else if (decodeAudio && packet.stream_index==audioStream) {
@@ -272,13 +274,12 @@ void FFmpeg::decodeNextFrame() {
outsize /= sizeof(int16_t) * pAudioCodecCtx->channels;
std::vector<int16_t> resampled(AVCODEC_MAX_AUDIO_FRAME_SIZE);
int frames = audio_resample(pResampleCtx, &resampled[0], audioFrames, outsize);
- // Construct AudioFrame and add it to the queue
- AudioFrame* tmp = new AudioFrame();
- std::copy(resampled.begin(), resampled.begin() + frames * AUDIO_CHANNELS, std::back_inserter(tmp->data));
+ resampled.resize(frames * AUDIO_CHANNELS);
+ // Calculate new positions
if (packet.time() == packet.time()) m_position = packet.time();
- else m_position += double(tmp->data.size())/double(audioQueue.getSamplesPerSecond());
- tmp->timestamp = m_position;
- audioQueue.push(tmp);
+ else m_position += double(resampled.size())/double(audioQueue.getSamplesPerSecond());
+ // Push to output queue (may block)
+ audioQueue.push(resampled, m_position);
}
// Audio frames are always finished
frameFinished = 1;
diff --git a/game/ffmpeg.hh b/game/ffmpeg.hh
index 2056e99..e1f97dd 100644
--- a/game/ffmpeg.hh
+++ b/game/ffmpeg.hh
@@ -130,17 +130,16 @@ class AudioBuffer {
void setSamplesPerSecond(unsigned sps) { m_sps = sps; }
/// get samples per second
unsigned getSamplesPerSecond() { return m_sps; }
- void push(AudioFrame* f) {
- if (f->data.empty()) return;
+ void push(std::vector<int16_t> const& data, double timestamp) {
boost::mutex::scoped_lock l(m_mutex);
while (!condition()) m_cond.wait(l);
if (m_quit) return;
- if (m_pos == 0 && f->timestamp != 0.0) {
- //std::cerr << "Warning: The first audio frame begins at " << f->timestamp << " seconds instead of zero, compensating." << std::endl;
- m_pos = f->timestamp * m_sps;
+ if (m_pos == 0 && timestamp != 0.0) {
+ //std::cerr << "Warning: The first audio frame begins at " << timestamp << " seconds instead of zero, compensating." << std::endl;
+ m_pos = timestamp * m_sps;
}
- m_data.insert(m_data.end(), f->data.begin(), f->data.end());
- m_pos += f->data.size();
+ m_data.insert(m_data.end(), data.begin(), data.end());
+ m_pos += data.size();
}
bool operator()(da::pcm_data data, int64_t& pos) {
boost::mutex::scoped_lock l(m_mutex);
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-07-27 04:28:42
|
Module: performous
Branch: master
Commit: f6265e3ebac937abadf26bb3c46b8dff1a2f930d
Author: Lasse Karkkainen <tro...@tr...>
Date: Mon Jul 27 07:27:31 2009 +0300
Proper handling of drum tracks (zero length notes).
---
game/songparser-ini.cc | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/game/songparser-ini.cc b/game/songparser-ini.cc
index 5173cd3..f22d965 100644
--- a/game/songparser-ini.cc
+++ b/game/songparser-ini.cc
@@ -52,6 +52,7 @@ void SongParser::iniParse() {
else name.erase(0, 5);
// Process non-vocal tracks
if (name != "VOCALS") {
+ bool drums = (name == "DRUMS");
s.tracks.push_back(Track(name));
NoteMap& nm = s.tracks.back().nm;
for (MidiFileParser::NoteMap::const_iterator it2 = it->notes.begin(); it2 != it->notes.end(); ++it2) {
@@ -60,7 +61,10 @@ void SongParser::iniParse() {
for (MidiFileParser::Notes::const_iterator it3 = notes.begin(); it3 != notes.end(); ++it3) {
double beg = midi.get_seconds(it3->begin);
double end = midi.get_seconds(it3->end);
- if (beg < end) dur.push_back(Duration(beg, end));
+ if (end == 0) continue; // Note with no ending
+ if (beg > end) throw std::runtime_error("Reversed notes");
+ if (drums) end = beg;
+ dur.push_back(Duration(beg, end));
}
}
continue;
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-07-27 04:28:41
|
Module: performous Branch: master Commit: 8d00282892b69c14eb10bc18f187bce08aad1ead Author: Lasse Karkkainen <tro...@tr...> Date: Mon Jul 27 07:03:47 2009 +0300 Bump version number to 0.4-pre2. --- CMakeLists.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 717f85b..e6a4814 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ project(Performous CXX) cmake_minimum_required(VERSION 2.6) -set(PROJECT_VERSION "0.4-pre1") +set(PROJECT_VERSION "0.4-pre2") # Avoid source tree pollution if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) |
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-07-26 13:10:21
|
Module: performous
Branch: master
Commit: dcecee532fc8f3f88919f291969859d233792ee0
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Jul 26 15:53:55 2009 +0300
Fix regression by an earlier change, causing instrument selection to repeat quickly.
---
game/guitargraph.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 9d1816b..4178b29 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -50,6 +50,7 @@ void GuitarGraph::inputProcess() {
void GuitarGraph::engine(double time) {
if (!picked) return; // TODO: hammering etc. later, remove this
+ picked = false;
if (time < -0.5) {
if (fretPressed[4]) {
m_instrument = (m_instrument + 1) % m_song.tracks.size();
@@ -83,7 +84,6 @@ void GuitarGraph::engine(double time) {
m_notes[&*it2] = 1;
m_score += (tolerance < 0.1 ? 50 : 25);
}
- picked = false;
}
void GuitarGraph::difficultyAuto() {
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-07-26 13:10:20
|
Module: performous
Branch: master
Commit: 339e94e9f8cff82560f14d0bcb742d6a33ea97b7
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Jul 26 15:53:26 2009 +0300
Restore that nice oneliner. The less lines of code, the better the program.
---
game/guitargraph.cc | 12 +-----------
1 files changed, 1 insertions(+), 11 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index a2b816c..9d1816b 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -43,17 +43,7 @@ void GuitarGraph::inputProcess() {
if (b >= 5) continue;
static const int gh[] = { 2, 0, 1, 3, 4 };
static const int rb[] = { 3, 0, 1, 2, 4 };
- switch( it->second.getType() ) {
- case Joystick::ROCKBAND:
- fretPressed[rb[b]] = (ev.type == JoystickEvent::BUTTON_DOWN);
- break;
- case Joystick::GUITARHERO:
- fretPressed[gh[b]] = (ev.type == JoystickEvent::BUTTON_DOWN);
- break;
- default:
- fretPressed[gh[b]] = (ev.type == JoystickEvent::BUTTON_DOWN);
- break;
- }
+ fretPressed[(it->second.getType() == Joystick::ROCKBAND ? rb : gh)[b]] = (ev.type == JoystickEvent::BUTTON_DOWN);
}
}
}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-07-26 12:47:19
|
Module: performous
Branch: master
Commit: 104b40beba03d06a228babb43df36f71e5f39054
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Jul 26 15:43:37 2009 +0300
Simple gameplay and score calculation for guitars.
---
game/guitargraph.cc | 37 ++++++++++++++++++++++++++++++++-----
game/guitargraph.hh | 3 +++
2 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index d21a66f..a2b816c 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -22,7 +22,7 @@ namespace {
bool picked = false;
}
-GuitarGraph::GuitarGraph(Song const& song): m_song(song), m_button("button.svg"), m_pickValue(0.0, 5.0), m_instrument(), m_level(), m_text(getThemePath("sing_timetxt.svg"), config["graphic/text_lod"].f()) {
+GuitarGraph::GuitarGraph(Song const& song): m_song(song), m_button("button.svg"), m_pickValue(0.0, 5.0), m_instrument(), m_level(), m_text(getThemePath("sing_timetxt.svg"), config["graphic/text_lod"].f()), m_score() {
std::size_t tracks = m_song.tracks.size();
if (tracks == 0) throw std::runtime_error("No tracks");
m_necks.push_back(new Texture("guitarneck.svg"));
@@ -59,7 +59,8 @@ void GuitarGraph::inputProcess() {
}
void GuitarGraph::engine(double time) {
- if (picked && time < -0.5) {
+ if (!picked) return; // TODO: hammering etc. later, remove this
+ if (time < -0.5) {
if (fretPressed[4]) {
m_instrument = (m_instrument + 1) % m_song.tracks.size();
if (!difficulty(m_level)) difficultyAuto();
@@ -68,8 +69,30 @@ void GuitarGraph::engine(double time) {
else if (fretPressed[1]) difficulty(DIFFICULTY_EASY);
else if (fretPressed[2]) difficulty(DIFFICULTY_MEDIUM);
else if (fretPressed[3]) difficulty(DIFFICULTY_AMAZING);
+ return;
+ }
+ m_pickValue.setValue(1.0);
+ for (NoteStatus::iterator it = m_notes.begin(); it != m_notes.end(); ++it) if (it->second == 1) it->second = 2;
+ int basepitch = diffv[m_level].basepitch;
+ for (int fret = 0; fret < 5; ++fret) {
+ if (!fretPressed[fret]) continue;
+ NoteMap const& nm = m_song.tracks[m_instrument].nm;
+ NoteMap::const_iterator it = nm.find(basepitch + fret);
+ if (it == nm.end()) continue;
+ Durations const& dur = it->second;
+ Durations::const_iterator it2 = dur.begin(), it2tmp, it2end = dur.end();
+ double tolerance = 0.2;
+ while (it2 != it2end && it2->begin < time - tolerance) ++it2;
+ if (it2 == it2end || it2->begin > time + tolerance) continue;
+ it2tmp = it2;
+ do {
+ it2 = it2tmp;
+ tolerance = std::abs(it2->begin - time);
+ } while (++it2tmp != it2end && std::abs(it2tmp->begin - time) < tolerance);
+ if (m_notes[&*it2] != 0) continue;
+ m_notes[&*it2] = 1;
+ m_score += (tolerance < 0.1 ? 50 : 25);
}
- if (picked) { m_pickValue.setValue(1.0); }
picked = false;
}
@@ -89,11 +112,14 @@ bool GuitarGraph::difficulty(Difficulty level) {
}
void GuitarGraph::draw(double time) {
- m_text.dimensions.screenBottom(-0.05).middle(0.0);
if (time < -0.5) {
std::string txt = "Play a fret to change:\n";
txt += m_song.tracks[m_instrument].name + "/" + diffv[m_level].name;
+ m_text.dimensions.screenBottom(-0.05).middle(0.0);
m_text.draw(txt);
+ } else {
+ m_text.dimensions.screenBottom(-0.1).middle(0.2);
+ m_text.draw(boost::lexical_cast<std::string>(m_score));
}
engine(time);
Dimensions dimensions(1.0); // FIXME: bogus aspect ratio (is this fixable?)
@@ -135,7 +161,6 @@ void GuitarGraph::draw(double time) {
for (int fret = 0; fret < 5; ++fret) {
float x = -2.0f + fret;
float w = 0.5f;
- glutil::Color c = fretColors[fret];
NoteMap::const_iterator it = nm.find(basepitch + fret);
if (it == nm.end()) continue;
Durations const& durs = it->second;
@@ -144,6 +169,8 @@ void GuitarGraph::draw(double time) {
float tEnd = it2->end - time;
if (tEnd < past) continue;
if (tBeg > future) break;
+ glutil::Color c = fretColors[fret];
+ if (m_notes[&*it2] == 1) c.r = c.g = c.b = 1.0f;
float wLine = 0.5f * w;
if (tEnd > future) tEnd = future;
{
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index 3af4053..a42b892 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -36,5 +36,8 @@ class GuitarGraph {
void difficultyAuto();
bool difficulty(Difficulty level);
SvgTxtTheme m_text;
+ typedef std::map<Duration const*, int> NoteStatus;
+ NoteStatus m_notes;
+ int m_score;
};
|