fixed drawing with brush using middle/right button set to space or MM walls
[rocksndiamonds.git] / src / game.c
index b9e35f070f753940d2529653aa37e8bc72bad277..572373e51248d7bd86bbf28a0a4b9d75e03b4d59 100644 (file)
@@ -4472,6 +4472,7 @@ static void PlayerWins(struct PlayerInfo *player)
 
 void GameWon()
 {
+  static int time_count_steps;
   static int time, time_final;
   static int score, score_final;
   static int health, health_final;
@@ -4506,7 +4507,7 @@ void GameWon()
 
     TapeStop();
 
-    game_over_delay_1 = game_over_delay_value_1;
+    game_over_delay_1 = 0;
     game_over_delay_2 = 0;
     game_over_delay_3 = game_over_delay_value_3;
 
@@ -4514,27 +4515,34 @@ void GameWon()
     score = score_final = local_player->score_final;
     health = health_final = local_player->health_final;
 
-    if (TimeLeft > 0)
+    if (level.score[SC_TIME_BONUS] > 0)
     {
-      time_final = 0;
-      score_final += TimeLeft * level.score[SC_TIME_BONUS];
-    }
-    else if (game.no_time_limit && TimePlayed < 999)
-    {
-      time_final = 999;
-      score_final += (999 - TimePlayed) * level.score[SC_TIME_BONUS];
-    }
+      if (TimeLeft > 0)
+      {
+       time_final = 0;
+       score_final += TimeLeft * level.score[SC_TIME_BONUS];
+      }
+      else if (game.no_time_limit && TimePlayed < 999)
+      {
+       time_final = 999;
+       score_final += (999 - TimePlayed) * level.score[SC_TIME_BONUS];
+      }
 
-    if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
-    {
-      health_final = 0;
-      score_final += health * level.score[SC_TIME_BONUS];
+      time_count_steps = MAX(1, ABS(time_final - time) / 100);
 
-      game_over_delay_2 = game_over_delay_value_2;
-    }
+      game_over_delay_1 = game_over_delay_value_1;
+
+      if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
+      {
+       health_final = 0;
+       score_final += health * level.score[SC_TIME_BONUS];
 
-    local_player->score_final = score_final;
-    local_player->health_final = health_final;
+       game_over_delay_2 = game_over_delay_value_2;
+      }
+
+      local_player->score_final = score_final;
+      local_player->health_final = health_final;
+    }
 
     if (level_editor_test_game)
     {
@@ -4606,7 +4614,9 @@ void GameWon()
   {
     int time_to_go = ABS(time_final - time);
     int time_count_dir = (time < time_final ? +1 : -1);
-    int time_count_steps = (time_to_go > 100 && time_to_go % 10 == 0 ? 10 : 1);
+
+    if (time_to_go < time_count_steps)
+      time_count_steps = 1;
 
     time  += time_count_steps * time_count_dir;
     score += time_count_steps * level.score[SC_TIME_BONUS];