X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Flevel.cpp;h=4b222bb8a25214f9d89cd9d5b69d32601333f8b6;hb=69f1f633dec2d8a8f1286cf072b6725c75eaeb6a;hp=dccfbd8702fdd4018516e97edef351f8740069a0;hpb=77d6c22146b06e5737b905795c8d7aab3f146527;p=supertux.git diff --git a/src/level.cpp b/src/level.cpp index dccfbd870..4b222bb8a 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -20,9 +20,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -44,6 +44,7 @@ #include "object/camera.hpp" #include "object/tilemap.hpp" #include "object/coin.hpp" +#include "object/block.hpp" using namespace std; @@ -57,7 +58,7 @@ Level::load(const std::string& filepath) { try { lisp::Parser parser; - std::auto_ptr root (parser.parse(filepath)); + const lisp::Lisp* root = parser.parse(filepath); const lisp::Lisp* level = root->get_lisp("supertux-level"); if(!level) @@ -70,6 +71,9 @@ Level::load(const std::string& filepath) return; } + contact = ""; + license = ""; + lisp::ListIterator iter(level); while(iter.next()) { const std::string& token = iter.item(); @@ -82,6 +86,10 @@ Level::load(const std::string& filepath) 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") { @@ -90,10 +98,11 @@ Level::load(const std::string& filepath) add_sector(sector); } else { log_warning << "Unknown token '" << token << "' in level file" << std::endl; - continue; } } - + + 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(); @@ -184,7 +193,6 @@ Level::get_sector(size_t num) int 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; @@ -192,7 +200,27 @@ Level::get_total_coins() o != sector->gameobjects.end(); ++o) { Coin* coin = dynamic_cast (*o); if(coin) + { total_coins++; + continue; + } + BonusBlock *block = dynamic_cast (*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;