[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Enigma-cvs] enigma/src levelpack.cc,1.12,1.13
From: |
Ralf Westram <address@hidden> |
Subject: |
[Enigma-cvs] enigma/src levelpack.cc,1.12,1.13 |
Date: |
Thu, 06 Nov 2003 07:19:54 +0000 |
Update of /cvsroot/enigma/enigma/src
In directory subversions:/tmp/cvs-serv14179/src
Modified Files:
levelpack.cc
Log Message:
- scans value,name pairs for par settings
Index: levelpack.cc
===================================================================
RCS file: /cvsroot/enigma/enigma/src/levelpack.cc,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** levelpack.cc 3 Nov 2003 14:22:10 -0000 1.12
--- levelpack.cc 6 Nov 2003 07:19:52 -0000 1.13
***************
*** 124,127 ****
--- 124,145 ----
}
+ namespace {
+ const char *parsePar(const string& par, int& par_value, string& par_text)
{
+ // 'par' is in format "value,text"
+ // The value is stored in 'par_value' and the text in 'par_text'.
+
+ size_t komma = par.find(',');
+ if (komma == string::npos) {
+ return "komma expected in par";
+ }
+
+ string value = par.substr(0, komma);
+ par_text = par.substr(komma+1);
+ par_value = atoi(value.c_str());
+
+ return 0;
+ }
+ }
+
const char *LevelPack_Enigma::load_index (istream &is)
{
***************
*** 145,149 ****
--- 163,169 ----
int par_time_easy = -1;
int par_time_normal = -1;
+ string par_time_by, par_time_easy_by, par_time_normal_by;
int par_moves = -1;
+ string par_moves_by;
string hint1, hint2;
***************
*** 194,212 ****
}
content = line.substr(content_start,
content_end-content_start);
! p = content_end;
}
}
! if (tag == "file") filename = content;
! else if (tag == "name") name = content;
! else if (tag == "author") author = content;
! else if (tag == "revision") revision =
atoi(content.c_str());
! else if (tag == "easymode") easymode = (content
== "1");
! else if (tag == "par_time") par_time =
atoi(content.c_str());
! else if (tag == "par_time_easy") par_time_easy =
atoi(content.c_str());
! else if (tag == "par_time_normal") par_time_normal =
atoi(content.c_str());
! else if (tag == "par_moves") par_moves =
atoi(content.c_str());
! else if (tag == "hint1") hint1 = content;
! else if (tag == "hint2") hint2 = content;
else {
xerror = strf("unknown tag '%s'", tag.c_str());
--- 214,232 ----
}
content = line.substr(content_start,
content_end-content_start);
! p = content_end;
}
}
! if (tag == "file") filename = content;
! else if (tag == "name") name = content;
! else if (tag == "author") author = content;
! else if (tag == "revision") revision =
atoi(content.c_str());
! else if (tag == "easymode") easymode = (content == "1");
! else if (tag == "par_time") error = parsePar(content,
par_time, par_time_by);
! else if (tag == "par_time_easy") error = parsePar(content,
par_time_easy, par_time_easy_by);
! else if (tag == "par_time_normal") error = parsePar(content,
par_time_normal, par_time_normal_by);
! else if (tag == "par_moves") error = parsePar(content,
par_moves, par_moves_by);
! else if (tag == "hint1") hint1 = content;
! else if (tag == "hint2") hint2 = content;
else {
xerror = strf("unknown tag '%s'", tag.c_str());
***************
*** 219,230 ****
if (!error) {
if (easymode) {
! if (par_time>0) {
! error = "'par_time' not allowed when easymode=1 (use
par_time_easy and par_time_normal)";
! }
}
else {
! if (par_time_normal>0 || par_time_easy>0) {
! error = "'par_time_easy' and 'par_time_normal' are
not allowed when easymode=0 (use par_time)";
! }
}
}
--- 239,248 ----
if (!error) {
if (easymode) {
! if (par_time>0)
! error = "'par_time' not allowed when easymode=1 (use
'par_time_easy' and 'par_time_normal')";
}
else {
! if (par_time_normal>0 || par_time_easy>0)
! error = "'par_time_easy' and 'par_time_normal' are
not allowed when easymode=0 (use 'par_time')";
}
}
***************
*** 232,241 ****
if (!error) {
if (!easymode) {
! par_time_easy = par_time_normal = par_time;
}
m_levels.push_back(LevelInfo(GAMET_ENIGMA, filename, name,
author, revision,
easymode,
! par_time_easy, par_time_normal,
par_moves,
hint1, hint2));
--- 250,261 ----
if (!error) {
if (!easymode) {
! par_time_easy = par_time_normal = par_time;
! par_time_easy_by = par_time_normal_by = par_time_by;
}
m_levels.push_back(LevelInfo(GAMET_ENIGMA, filename, name,
author, revision,
easymode,
! par_time_easy, par_time_easy_by,
! par_time_normal,
par_time_normal_by,
par_moves,
hint1, hint2));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Enigma-cvs] enigma/src levelpack.cc,1.12,1.13,
Ralf Westram <address@hidden> <=