projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
auto detect aspect ratio of monitor, so that you don't have to know/use the cryptic...
[supertux.git]
/
src
/
level.cpp
diff --git
a/src/level.cpp
b/src/level.cpp
index
57bc4a7
..
4b222bb
100644
(file)
--- a/
src/level.cpp
+++ b/
src/level.cpp
@@
-1,7
+1,7
@@
// $Id$
// $Id$
-//
+//
// SuperTux
// SuperTux
-// Copyright (C) 200
4 SuperTux Development Team, see AUTHORS for details
+// Copyright (C) 200
6 Matthias Braun <matze@braunis.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@
-12,7
+12,7
@@
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@
-20,17
+20,16
@@
#include <config.h>
#include <map>
#include <config.h>
#include <map>
-#include <
cstdlib
>
-#include <
cstdio
>
-#include <
cstring
>
+#include <
stdlib.h
>
+#include <
stdio.h
>
+#include <
string.h
>
#include <iostream>
#include <fstream>
#include <sstream>
#include <memory>
#include <stdexcept>
#include <iostream>
#include <fstream>
#include <sstream>
#include <memory>
#include <stdexcept>
-#include "video/screen.hpp"
-#include "msg.hpp"
+#include "log.hpp"
#include "lisp/parser.hpp"
#include "lisp/lisp.hpp"
#include "lisp/list_iterator.hpp"
#include "lisp/parser.hpp"
#include "lisp/lisp.hpp"
#include "lisp/list_iterator.hpp"
@@
-45,9
+44,7
@@
#include "object/camera.hpp"
#include "object/tilemap.hpp"
#include "object/coin.hpp"
#include "object/camera.hpp"
#include "object/tilemap.hpp"
#include "object/coin.hpp"
-
-// test
-#include "flip_level_transformer.hpp"
+#include "object/block.hpp"
using namespace std;
using namespace std;
@@
-61,7
+58,7
@@
Level::load(const std::string& filepath)
{
try {
lisp::Parser parser;
{
try {
lisp::Parser parser;
-
std::auto_ptr<lisp::Lisp> root (parser.parse(filepath)
);
+
const lisp::Lisp* root = parser.parse(filepath
);
const lisp::Lisp* level = root->get_lisp("supertux-level");
if(!level)
const lisp::Lisp* level = root->get_lisp("supertux-level");
if(!level)
@@
-74,28
+71,38
@@
Level::load(const std::string& filepath)
return;
}
return;
}
+ contact = "";
+ license = "";
+
lisp::ListIterator iter(level);
while(iter.next()) {
const std::string& token = iter.item();
if(token == "version") {
iter.value()->get(version);
if(version > 2) {
lisp::ListIterator iter(level);
while(iter.next()) {
const std::string& token = iter.item();
if(token == "version") {
iter.value()->get(version);
if(version > 2) {
-
msg_warning("level format newer than application")
;
+
log_warning << "level format newer than application" << std::endl
;
}
} else if(token == "name") {
iter.value()->get(name);
} else if(token == "author") {
iter.value()->get(author);
}
} else if(token == "name") {
iter.value()->get(name);
} else if(token == "author") {
iter.value()->get(author);
+ } else if(token == "contact") {
+ iter.value()->get(contact);
+ } else if(token == "license") {
+ iter.value()->get(license);
+ } 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 {
sector->parse(*(iter.lisp()));
add_sector(sector);
} else {
- msg_warning("Unknown token '" << token << "' in level file");
- continue;
+ log_warning << "Unknown token '" << token << "' in level file" << std::endl;
}
}
}
}
-
+
+ if (license == "") log_warning << "The level author did not specify a license for this level. You might not be allowed to share it." << std::endl;
+
} 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
+116,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
+135,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,18
+191,8
@@
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()
{
Level::get_total_coins()
{
- // FIXME not really correct as coins can also be inside blocks...
int total_coins = 0;
for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) {
Sector* sector = *i;
int total_coins = 0;
for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) {
Sector* sector = *i;
@@
-201,9
+200,37
@@
Level::get_total_coins()
o != sector->gameobjects.end(); ++o) {
Coin* coin = dynamic_cast<Coin*> (*o);
if(coin)
o != sector->gameobjects.end(); ++o) {
Coin* coin = dynamic_cast<Coin*> (*o);
if(coin)
+ {
total_coins++;
total_coins++;
+ continue;
+ }
+ BonusBlock *block = dynamic_cast<BonusBlock*> (*o);
+ if(block)
+ {
+ if (block->contents == BonusBlock::CONTENT_COIN)
+ {
+ total_coins++;
+ continue;
+ }
+#if 0
+ // FIXME: do we want this? q.v. src/object/oneup.cpp
+ else if (block->contents == BonusBlock::CONTENT_1UP)
+ {
+ total_coins += 100;
+ continue;
+ }
+#endif
+ }
}
}
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;
+}