From d02eab1f7ab3398c4e6c383d48fb7dee0a8a76f2 Mon Sep 17 00:00:00 2001 From: Wolfgang Becker Date: Sat, 16 Dec 2006 21:17:48 +0000 Subject: [PATCH] [Patch #1251] by tuxdev: timelimit fudge factor SVN-Revision: 4474 --- src/object/level_time.cpp | 14 +++++++++++--- src/object/player.cpp | 6 ++++++ src/object/player.hpp | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/object/level_time.cpp b/src/object/level_time.cpp index bf86db633..65a8e3697 100644 --- a/src/object/level_time.cpp +++ b/src/object/level_time.cpp @@ -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); + } } } diff --git a/src/object/player.cpp b/src/object/player.cpp index ad2e91e3e..004a838b2 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -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) { diff --git a/src/object/player.hpp b/src/object/player.hpp index 2f21f6d0a..de229492e 100644 --- a/src/object/player.hpp +++ b/src/object/player.hpp @@ -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 -- 2.11.0