* Coins inside boxes are now being counted. (We'll have to decide if we want the...
authorOndřej Hošek <ondra.hosek@gmail.com>
Sun, 28 Jan 2007 16:32:42 +0000 (16:32 +0000)
committerOndřej Hošek <ondra.hosek@gmail.com>
Sun, 28 Jan 2007 16:32:42 +0000 (16:32 +0000)
* Made MiniSwig limit whitespace it generates.

SVN-Revision: 4707

src/level.cpp
src/object/block.cpp
src/object/block.hpp
src/object/oneup.cpp
src/scripting/wrapper.cpp
src/scripting/wrapper.hpp
tools/miniswig/create_wrapper.cpp

index 134f1f5..c0f5b25 100644 (file)
@@ -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<Coin*> (*o);
       if(coin)
+      {
         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;
index 4b4a83e..de4f311 100644 (file)
@@ -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:
index c1f78b9..94f87fb 100644 (file)
@@ -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;
 };
 
index bdbaa5e..322cb23 100644 (file)
@@ -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<Player*> (&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;
   }
index b19a3f0..1f8060b 100644 (file)
@@ -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;
index cc6e43e..2143f49 100644 (file)
@@ -33,3 +33,4 @@ void create_squirrel_instance(HSQUIRRELVM v, Scripting::LevelTime* object, bool
 }
 
 #endif
+
index 64318fd..9be2f52 100644 (file)
@@ -89,7 +89,6 @@ WrapperCreator::create_wrapper(Namespace* ns)
     }
 
     out << "} // end of namespace Wrapper\n";
-    out << "\n";
 
     for(std::vector<AtomicType*>::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";