projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
No more count-to-infinity for the coins display
[supertux.git]
/
src
/
level.cpp
diff --git
a/src/level.cpp
b/src/level.cpp
index
1da7530
..
134f1f5
100644
(file)
--- a/
src/level.cpp
+++ b/
src/level.cpp
@@
-29,7
+29,6
@@
#include <memory>
#include <stdexcept>
#include <memory>
#include <stdexcept>
-#include "video/screen.hpp"
#include "log.hpp"
#include "lisp/parser.hpp"
#include "lisp/lisp.hpp"
#include "log.hpp"
#include "lisp/parser.hpp"
#include "lisp/lisp.hpp"
@@
-46,9
+45,6
@@
#include "object/tilemap.hpp"
#include "object/coin.hpp"
#include "object/tilemap.hpp"
#include "object/coin.hpp"
-// test
-#include "flip_level_transformer.hpp"
-
using namespace std;
Level::Level()
using namespace std;
Level::Level()
@@
-86,16
+82,17
@@
Level::load(const std::string& filepath)
iter.value()->get(name);
} else if(token == "author") {
iter.value()->get(author);
iter.value()->get(name);
} else if(token == "author") {
iter.value()->get(author);
+ } else if(token == "on-menukey-script") {
+ iter.value()->get(on_menukey_script);
} else if(token == "sector") {
} else if(token == "sector") {
- Sector* sector = new Sector;
+ Sector* sector = new Sector
(this)
;
sector->parse(*(iter.lisp()));
add_sector(sector);
} else {
log_warning << "Unknown token '" << token << "' in level file" << std::endl;
sector->parse(*(iter.lisp()));
add_sector(sector);
} else {
log_warning << "Unknown token '" << token << "' in level file" << std::endl;
- continue;
}
}
}
}
-
+
} catch(std::exception& e) {
std::stringstream msg;
msg << "Problem when reading level '" << filepath << "': " << e.what();
} catch(std::exception& e) {
std::stringstream msg;
msg << "Problem when reading level '" << filepath << "': " << e.what();
@@
-109,7
+106,7
@@
Level::load_old_format(const lisp::Lisp& reader)
reader.get("name", name);
reader.get("author", author);
reader.get("name", name);
reader.get("author", author);
- Sector* sector = new Sector;
+ Sector* sector = new Sector
(this)
;
sector->parse_old_format(reader);
add_sector(sector);
}
sector->parse_old_format(reader);
add_sector(sector);
}
@@
-128,6
+125,8
@@
Level::save(const std::string& filename)
writer->write_string("name", name, true);
writer->write_string("author", author);
writer->write_string("name", name, true);
writer->write_string("author", author);
+ if(on_menukey_script != "")
+ writer->write_string("on-menukey-script", on_menukey_script);
for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) {
Sector* sector = *i;
for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) {
Sector* sector = *i;
@@
-182,15
+181,6
@@
Level::get_sector(size_t num)
}
int
}
int
-Level::get_total_badguys()
-{
- int total_badguys = 0;
- for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i)
- total_badguys += (*i)->get_total_badguys();
- return total_badguys;
-}
-
-int
Level::get_total_coins()
{
// FIXME not really correct as coins can also be inside blocks...
Level::get_total_coins()
{
// FIXME not really correct as coins can also be inside blocks...
@@
-207,3
+197,11
@@
Level::get_total_coins()
return total_coins;
}
return total_coins;
}
+int
+Level::get_total_badguys()
+{
+ int total_badguys = 0;
+ for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i)
+ total_badguys += (*i)->get_total_badguys();
+ return total_badguys;
+}