[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Enigma-cvs] enigma/src options.cc,1.25,1.26
From: |
Ralf Westram <address@hidden> |
Subject: |
[Enigma-cvs] enigma/src options.cc,1.25,1.26 |
Date: |
Wed, 22 Oct 2003 21:36:47 +0000 |
Update of /cvsroot/enigma/enigma/src
In directory subversions:/tmp/cvs-serv4287/src
Modified Files:
options.cc
Log Message:
- SetLevelTime/SetLevelFinished: added parameter 'revision'
- Interface of LevelStatus changed (gets revision instead of time)
- Save status sorted (into config file)
- saves revision number (instead of moddate of .lua)
Index: options.cc
===================================================================
RCS file: /cvsroot/enigma/enigma/src/options.cc,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** options.cc 20 Oct 2003 18:30:31 -0000 1.25
--- options.cc 22 Oct 2003 21:36:45 -0000 1.26
***************
*** 32,35 ****
--- 32,36 ----
#include <cstdlib>
#include <string>
+ #include <set>
using namespace options;
***************
*** 79,91 ****
! LevelStatus::LevelStatus(int easy, int hard, int fin, time_t solv)
: time_easy(easy),
time_hard(hard),
finished(fin),
! solved_at(solv),
! solved_revision(0)
{
! if (!solved_at && fin>0)
! solved_at = time(0); // default to now
}
--- 80,91 ----
! LevelStatus::LevelStatus(int easy, int hard, int fin, int solved_rev)
: time_easy(easy),
time_hard(hard),
finished(fin),
! solved_revision(solved_rev)
{
! // if (!solved_at && fin>0)
! // solved_at = time(0); // default to now
}
***************
*** 95,99 ****
time_hard == other.time_hard &&
finished == other.finished &&
! solved_at == other.solved_at);
}
--- 95,99 ----
time_hard == other.time_hard &&
finished == other.finished &&
! solved_revision == other.solved_revision);
}
***************
*** 137,143 ****
bool
! options::SetLevelTime(const string &pack, const string &level, int
difficulty, int time)
{
! SetLevelFinished(pack, level, difficulty);
LevelStatus *stat = GetLevelStatus(pack, level);
--- 137,143 ----
bool
! options::SetLevelTime(const string &pack, const string &level, int
difficulty, int revision, int time)
{
! SetLevelFinished(pack, level, difficulty, revision);
LevelStatus *stat = GetLevelStatus(pack, level);
***************
*** 164,177 ****
void
! options::SetLevelFinished(const string &pack, const string &level, int
difficulty)
{
assert(difficulty==enigma::DIFFICULTY_EASY ||
difficulty==enigma::DIFFICULTY_HARD);
if (LevelStatus *stat = GetLevelStatus(pack, level)) {
! stat->finished |= difficulty;
! stat->solved_at = time(0);
}
else {
! SetLevelStatus(pack, level, LevelStatus(-1, -1, difficulty));
}
--- 164,177 ----
void
! options::SetLevelFinished(const string &pack, const string &level, int
difficulty, int revision)
{
assert(difficulty==enigma::DIFFICULTY_EASY ||
difficulty==enigma::DIFFICULTY_HARD);
if (LevelStatus *stat = GetLevelStatus(pack, level)) {
! stat->finished |= difficulty;
! stat->solved_revision = revision;
}
else {
! SetLevelStatus(pack, level, LevelStatus(-1, -1, difficulty,
revision));
}
***************
*** 266,279 ****
// Save level information
! px::Dict<LevelStatus>::iterator i=level_status_dict.begin();
for (; i!=level_status_dict.end(); ++i) {
LevelStatus& ls = i->second;
! fprintf (fp, "options.LevelStat(\"%s\", {%d, %d, %d, %ld})\n",
i->first.c_str(),
ls.time_easy,
ls.time_hard,
ls.finished,
! ls.solved_at);
}
--- 266,287 ----
// Save level information
! set<string> sorted;
! px::Dict<LevelStatus>::iterator i = level_status_dict.begin();
for (; i!=level_status_dict.end(); ++i) {
+ sorted.insert(i->first.c_str());
+ }
+
+ set<string>::const_iterator ni = sorted.begin();
+ for (; ni != sorted.end(); ++ni) {
+ i = level_status_dict.find(*ni);
+ assert(i != level_status_dict.end()); // has to be found!
LevelStatus& ls = i->second;
! fprintf (fp, "options.LevelStat2(\"%s\", {%d, %d, %d, %d})\n",
i->first.c_str(),
ls.time_easy,
ls.time_hard,
ls.finished,
! ls.solved_revision);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Enigma-cvs] enigma/src options.cc,1.25,1.26,
Ralf Westram <address@hidden> <=