From: Ondřej Hošek Date: Sun, 28 Jan 2007 16:32:42 +0000 (+0000) Subject: * Coins inside boxes are now being counted. (We'll have to decide if we want the... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=02afe1b64f521ccc6f81701c288dfd56d459215b;p=supertux.git * Coins inside boxes are now being counted. (We'll have to decide if we want the 100-point penguins to count too.) * Made MiniSwig limit whitespace it generates. SVN-Revision: 4707 --- diff --git a/src/level.cpp b/src/level.cpp index 134f1f566..c0f5b2582 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -44,6 +44,7 @@ #include "object/camera.hpp" #include "object/tilemap.hpp" #include "object/coin.hpp" +#include "object/block.hpp" using namespace std; @@ -183,7 +184,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; @@ -191,7 +191,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; diff --git a/src/object/block.cpp b/src/object/block.cpp index 4b4a83e07..de4f31172 100644 --- a/src/object/block.cpp +++ b/src/object/block.cpp @@ -43,6 +43,7 @@ #include "object_factory.hpp" #include "lisp/list_iterator.hpp" #include "object_factory.hpp" +#include "level.hpp" static const float BOUNCY_BRICK_MAX_OFFSET = 8; static const float BOUNCY_BRICK_SPEED = 90; @@ -243,6 +244,7 @@ BonusBlock::try_open() case CONTENT_COIN: Sector::current()->add_object(new BouncyCoin(get_pos())); player.get_status()->add_coins(1); + Sector::current()->get_level()->stats.coins++; break; case CONTENT_FIREGROW: diff --git a/src/object/block.hpp b/src/object/block.hpp index c1f78b992..94f87fb04 100644 --- a/src/object/block.hpp +++ b/src/object/block.hpp @@ -63,10 +63,6 @@ public: void try_open(); -protected: - virtual void hit(Player& player); - -private: enum Contents { CONTENT_COIN, CONTENT_FIREGROW, @@ -77,6 +73,10 @@ private: }; Contents contents; +protected: + virtual void hit(Player& player); + +private: MovingObject* object; }; diff --git a/src/object/oneup.cpp b/src/object/oneup.cpp index bdbaa5e9a..322cb23a2 100644 --- a/src/object/oneup.cpp +++ b/src/object/oneup.cpp @@ -24,6 +24,8 @@ #include "player.hpp" #include "player_status.hpp" #include "sector.hpp" +#include "level.hpp" +#include "statistics.hpp" #include "video/drawing_context.hpp" OneUp::OneUp(const Vector& pos, Direction direction) @@ -47,6 +49,10 @@ OneUp::collision(GameObject& other, const CollisionHit& ) Player* player = dynamic_cast (&other); if(player) { player->get_status()->add_coins(100); +#if 0 + // FIXME: do we want this? q.v. src/level.cpp + Sector::current()->get_level()->stats.coins += 100; +#endif remove_me(); return ABORT_MOVE; } diff --git a/src/scripting/wrapper.cpp b/src/scripting/wrapper.cpp index b19a3f0a1..1f8060b1a 100644 --- a/src/scripting/wrapper.cpp +++ b/src/scripting/wrapper.cpp @@ -3253,7 +3253,6 @@ static SQInteger rand_wrapper(HSQUIRRELVM vm) } } // end of namespace Wrapper - void create_squirrel_instance(HSQUIRRELVM v, Scripting::DisplayEffect* object, bool setup_releasehook) { using namespace Wrapper; diff --git a/src/scripting/wrapper.hpp b/src/scripting/wrapper.hpp index cc6e43e3a..2143f4978 100644 --- a/src/scripting/wrapper.hpp +++ b/src/scripting/wrapper.hpp @@ -33,3 +33,4 @@ void create_squirrel_instance(HSQUIRRELVM v, Scripting::LevelTime* object, bool } #endif + diff --git a/tools/miniswig/create_wrapper.cpp b/tools/miniswig/create_wrapper.cpp index 64318fd76..9be2f5220 100644 --- a/tools/miniswig/create_wrapper.cpp +++ b/tools/miniswig/create_wrapper.cpp @@ -89,7 +89,6 @@ WrapperCreator::create_wrapper(Namespace* ns) } out << "} // end of namespace Wrapper\n"; - out << "\n"; for(std::vector::iterator i = ns->types.begin(); i != ns->types.end(); ++i) { @@ -110,8 +109,7 @@ WrapperCreator::create_wrapper(Namespace* ns) out << "}\n" << "\n" - << "} // end of namespace Scripting\n" - << "\n"; + << "} // end of namespace Scripting\n"; } void @@ -321,7 +319,7 @@ WrapperCreator::create_function_wrapper(Class* _class, Function* function) } // call function - out << ind << "\n"; + out << "\n"; out << ind << "try {\n"; out << ind << ind; if(!function->return_type.is_void()) { @@ -368,7 +366,7 @@ WrapperCreator::create_function_wrapper(Class* _class, Function* function) out << ind << "sq_setreleasehook(vm, 1, " << _class->name << "_release_hook);\n"; } - out << ind << "\n"; + out << "\n"; // push return value back on stack and return if(function->suspend) { if(!function->return_type.is_void()) { @@ -385,7 +383,7 @@ WrapperCreator::create_function_wrapper(Class* _class, Function* function) out << ind << ind << "return 1;\n"; } - out << ind << "\n"; + out << "\n"; out << ind << "} catch(std::exception& e) {\n"; out << ind << ind << "sq_throwerror(vm, e.what());\n"; out << ind << ind << "return SQ_ERROR;\n"; @@ -393,7 +391,7 @@ WrapperCreator::create_function_wrapper(Class* _class, Function* function) out << ind << ind << "sq_throwerror(vm, _SC(\"Unexpected exception while executing function '" << function->name << "'\"));\n"; out << ind << ind << "return SQ_ERROR;\n"; out << ind << "}\n"; - out << ind << "\n"; + out << "\n"; out << "}\n"; out << "\n";