rnd-20060415-1-src
[rocksndiamonds.git] / src / game.c
index 4f3b21efbe945297eb8dda2778220deadcc5e6cc..bf409f086759b55851e1b2906433ad2329a10a1c 100644 (file)
@@ -41,6 +41,7 @@
 #define USE_STOP_CHANGED_ELEMENTS      (USE_NEW_STUFF          * 1)
 #define USE_ELEMENT_TOUCHING_BUGFIX    (USE_NEW_STUFF          * 1)
 #define USE_NEW_CONTINUOUS_SNAPPING    (USE_NEW_STUFF          * 1)
+#define USE_GFX_RESET_GFX_ANIMATION    (USE_NEW_STUFF          * 1)
 
 #define USE_QUICKSAND_IMPACT_BUGFIX    (USE_NEW_STUFF          * 0)
 
@@ -1236,12 +1237,16 @@ static inline void InitField_WithBug2(int x, int y, boolean init_game)
 
 inline void DrawGameValue_Emeralds(int value)
 {
-  DrawText(DX_EMERALDS, DY_EMERALDS, int2str(value, 3), FONT_TEXT_2);
+  int xpos = (3 * 14 - 3 * getFontWidth(FONT_TEXT_2)) / 2;
+
+  DrawText(DX_EMERALDS + xpos, DY_EMERALDS, int2str(value, 3), FONT_TEXT_2);
 }
 
 inline void DrawGameValue_Dynamite(int value)
 {
-  DrawText(DX_DYNAMITE, DY_DYNAMITE, int2str(value, 3), FONT_TEXT_2);
+  int xpos = (3 * 14 - 3 * getFontWidth(FONT_TEXT_2)) / 2;
+
+  DrawText(DX_DYNAMITE + xpos, DY_DYNAMITE, int2str(value, 3), FONT_TEXT_2);
 }
 
 inline void DrawGameValue_Keys(int key[MAX_NUM_KEYS])
@@ -1267,15 +1272,24 @@ inline void DrawGameValue_Keys(int key[MAX_NUM_KEYS])
 
 inline void DrawGameValue_Score(int value)
 {
-  DrawText(DX_SCORE, DY_SCORE, int2str(value, 5), FONT_TEXT_2);
+  int xpos = (5 * 14 - 5 * getFontWidth(FONT_TEXT_2)) / 2;
+
+  DrawText(DX_SCORE + xpos, DY_SCORE, int2str(value, 5), FONT_TEXT_2);
 }
 
 inline void DrawGameValue_Time(int value)
 {
+  int xpos3 = (3 * 14 - 3 * getFontWidth(FONT_TEXT_2)) / 2;
+  int xpos4 = (4 * 10 - 4 * getFontWidth(FONT_LEVEL_NUMBER)) / 2;
+
+  /* clear background if value just changed its size */
+  if (value == 999 || value == 1000)
+    ClearRectangle(drawto, DX_TIME1, DY_TIME, 14 * 3, 14);
+
   if (value < 1000)
-    DrawText(DX_TIME1, DY_TIME, int2str(value, 3), FONT_TEXT_2);
+    DrawText(DX_TIME1 + xpos3, DY_TIME, int2str(value, 3), FONT_TEXT_2);
   else
-    DrawText(DX_TIME2, DY_TIME, int2str(value, 4), FONT_LEVEL_NUMBER);
+    DrawText(DX_TIME2 + xpos4, DY_TIME, int2str(value, 4), FONT_LEVEL_NUMBER);
 }
 
 inline void DrawGameValue_Level(int value)
@@ -2898,7 +2912,7 @@ int NewHiScore()
 
   LoadScore(level_nr);
 
-  if (strcmp(setup.player_name, EMPTY_PLAYER_NAME) == 0 ||
+  if (strEqual(setup.player_name, EMPTY_PLAYER_NAME) ||
       local_player->score < highscore[MAX_SCORE_ENTRIES - 1].Score) 
     return -1;
 
@@ -2914,7 +2928,7 @@ int NewHiScore()
 
 #ifdef ONE_PER_NAME
        for (l = k; l < MAX_SCORE_ENTRIES; l++)
-         if (!strcmp(setup.player_name, highscore[l].Name))
+         if (strEqual(setup.player_name, highscore[l].Name))
            m = l;
        if (m == k)     /* player's new highscore overwrites his old one */
          goto put_into_list;
@@ -3005,7 +3019,7 @@ static void ResetRandomAnimationValue(int x, int y)
 
 static void ResetGfxAnimation(int x, int y)
 {
-#if 0
+#if USE_GFX_RESET_GFX_ANIMATION
   int element, graphic;
 #endif
 
@@ -3013,7 +3027,7 @@ static void ResetGfxAnimation(int x, int y)
   GfxAction[x][y] = ACTION_DEFAULT;
   GfxDir[x][y] = MovDir[x][y];
 
-#if 0
+#if USE_GFX_RESET_GFX_ANIMATION
   element = Feld[x][y];
   graphic = el_act_dir2img(element, GfxAction[x][y], GfxDir[x][y]);
 
@@ -8312,8 +8326,10 @@ static void CreateFieldExt(int x, int y, int element, boolean is_change)
 
     Feld[x][y] = new_element;
 
+#if !USE_GFX_RESET_GFX_ANIMATION
     ResetGfxAnimation(x, y);
     ResetRandomAnimationValue(x, y);
+#endif
 
     if (element_info[new_element].move_direction_initial == MV_START_PREVIOUS)
       MovDir[x][y] = previous_move_direction;
@@ -8327,6 +8343,11 @@ static void CreateFieldExt(int x, int y, int element, boolean is_change)
 
     new_element = Feld[x][y];  /* element may have changed */
 
+#if USE_GFX_RESET_GFX_ANIMATION
+    ResetGfxAnimation(x, y);
+    ResetRandomAnimationValue(x, y);
+#endif
+
     DrawLevelField(x, y);
 
     if (GFX_CRUMBLED(new_element))