[Patch #1251] by tuxdev: timelimit fudge factor
authorWolfgang Becker <uafr@gmx.de>
Sat, 16 Dec 2006 21:17:48 +0000 (21:17 +0000)
committerWolfgang Becker <uafr@gmx.de>
Sat, 16 Dec 2006 21:17:48 +0000 (21:17 +0000)
SVN-Revision: 4474

src/object/level_time.cpp
src/object/player.cpp
src/object/player.hpp

index bf86db6..65a8e36 100644 (file)
@@ -68,10 +68,18 @@ LevelTime::update(float elapsed_time)
 {
   if (!running) return;
 
-  time_left = std::max(time_left - elapsed_time, 0.0f);
+  int prev_time = (int) floor(time_left*5);
+  time_left -= elapsed_time;
   if(time_left <= 0) {
-    Sector::current()->player->kill(true);
-    stop();
+    if(time_left <= -5 || !Sector::current()->player->get_coins())
+    {
+      Sector::current()->player->kill(true);
+      stop();
+    }
+    if(prev_time != (int) floor(time_left*5))
+    {
+      Sector::current()->player->add_coins(-1);
+    }
   }
 }
 
index ad2e91e..004a838 100644 (file)
@@ -694,6 +694,12 @@ Player::add_coins(int count)
   player_status->add_coins(count);
 }
 
+int
+Player::get_coins()
+{
+  return player_status->coins;
+}
+
 bool
 Player::add_bonus(const std::string& bonustype)
 {
index 2f21f6d..de22949 100644 (file)
@@ -160,6 +160,7 @@ public:
 
   virtual bool add_bonus(const std::string& bonus);
   virtual void add_coins(int count);
+  virtual int get_coins();
 
   /**
    * picks up a bonus, taking care not to pick up lesser bonus items than we already have