[rocksndiamonds] 01/03: New upstream version 4.0.1.3+dfsg

Stephen Kitt skitt at moszumanska.debian.org
Sat Mar 3 19:39:55 UTC 2018


This is an automated email from the git hooks/post-receive script.

skitt pushed a commit to branch master
in repository rocksndiamonds.

commit c54d805b9acc93225b3080785ebdc97d9d210516
Author: Stephen Kitt <skitt at debian.org>
Date:   Sat Mar 3 20:37:10 2018 +0100

    New upstream version 4.0.1.3+dfsg
---
 src/conftime.h          |  2 +-
 src/files.c             | 28 ++++++++++++++++++++++++----
 src/game.c              |  7 +++++++
 src/game_em/convert.c   |  8 ++++++--
 src/game_em/export.h    |  1 +
 src/game_em/graphics.c  |  4 ++++
 src/game_em/input.c     |  4 ++++
 src/game_em/synchro_3.c |  2 +-
 src/game_sp/main.c      |  4 ++++
 src/init.c              | 13 +++++++------
 src/libgame/system.c    | 11 +++++++++++
 src/libgame/system.h    |  1 +
 src/libgame/text.c      | 33 +++++++++++++++++++++------------
 src/main.h              |  4 ++--
 src/tape.c              | 10 +++++++++-
 src/tools.c             |  7 -------
 src/tools.h             |  1 -
 17 files changed, 103 insertions(+), 37 deletions(-)

diff --git a/src/conftime.h b/src/conftime.h
index a4bd598..d8c5a5e 100644
--- a/src/conftime.h
+++ b/src/conftime.h
@@ -1 +1 @@
-#define SOURCE_DATE_STRING "2018-02-03 00:17"
+#define SOURCE_DATE_STRING "2018-02-25 10:16"
diff --git a/src/files.c b/src/files.c
index 6c150ea..85d1712 100644
--- a/src/files.c
+++ b/src/files.c
@@ -3664,7 +3664,8 @@ void CopyNativeLevel_SP_to_RND(struct LevelInfo *level)
 {
   struct LevelInfo_SP *level_sp = level->native_sp_level;
   LevelInfoType *header = &level_sp->header;
-  int i, x, y;
+  boolean num_invalid_elements = 0;
+  int i, j, x, y;
 
   level->fieldx = level_sp->width;
   level->fieldy = level_sp->height;
@@ -3677,20 +3678,39 @@ void CopyNativeLevel_SP_to_RND(struct LevelInfo *level)
       int element_new = getMappedElement(map_element_SP_to_RND(element_old));
 
       if (element_new == EL_UNKNOWN)
-	Error(ERR_WARN, "invalid element %d at position %d, %d",
+      {
+	num_invalid_elements++;
+
+	Error(ERR_DEBUG, "invalid element %d at position %d, %d",
 	      element_old, x, y);
+      }
 
       level->field[x][y] = element_new;
     }
   }
 
+  if (num_invalid_elements > 0)
+    Error(ERR_WARN, "found %d invalid elements%s", num_invalid_elements,
+	  (!options.debug ? " (use '--debug' for more details)" : ""));
+
   for (i = 0; i < MAX_PLAYERS; i++)
     level->initial_player_gravity[i] =
       (header->InitialGravity == 1 ? TRUE : FALSE);
 
+  /* skip leading spaces */
   for (i = 0; i < SP_LEVEL_NAME_LEN; i++)
-    level->name[i] = header->LevelTitle[i];
-  level->name[SP_LEVEL_NAME_LEN] = '\0';
+    if (header->LevelTitle[i] != ' ')
+      break;
+
+  /* copy level title */
+  for (j = 0; i < SP_LEVEL_NAME_LEN; i++, j++)
+    level->name[j] = header->LevelTitle[i];
+  level->name[j] = '\0';
+
+  /* cut trailing spaces */
+  for (; j > 0; j--)
+    if (level->name[j - 1] == ' ' && level->name[j] == '\0')
+      level->name[j - 1] = '\0';
 
   level->gems_needed = header->InfotronsNeeded;
 
diff --git a/src/game.c b/src/game.c
index a3ad6f1..e159b96 100644
--- a/src/game.c
+++ b/src/game.c
@@ -2702,6 +2702,9 @@ static void InitGameEngine()
   game_em.use_single_button =
     (game.engine_version > VERSION_IDENT(4,0,0,2));
 
+  game_em.use_snap_key_bug =
+    (game.engine_version < VERSION_IDENT(4,0,1,0));
+
   /* ---------------------------------------------------------------------- */
 
   /* set maximal allowed number of custom element changes per game frame */
@@ -4596,6 +4599,10 @@ void InitPlayerGfxAnimation(struct PlayerInfo *player, int action, int dir)
 
 static void ResetGfxFrame(int x, int y)
 {
+  // profiling showed that "autotest" spends 10~20% of its time in this function
+  if (DrawingDeactivatedField())
+    return;
+
   int element = Feld[x][y];
   int graphic = el_act_dir2img(element, GfxAction[x][y], GfxDir[x][y]);
 
diff --git a/src/game_em/convert.c b/src/game_em/convert.c
index 086bc7a..cbc7187 100644
--- a/src/game_em/convert.c
+++ b/src/game_em/convert.c
@@ -1107,11 +1107,15 @@ void prepare_em_level(void)
     ply[i].joy_stick = ply[i].joy_spin = 0;
   }
 
+  // the following engine variables are initialized to version-specific values
+  // in function InitGameEngine() (src/game.c):
+  //
+  // - game_em.use_single_button (default: TRUE)
+  // - game_em.use_snap_key_bug (default: FALSE)
+
   game_em.any_player_moving = FALSE;
   game_em.any_player_snapping = FALSE;
 
-  game_em.use_single_button = TRUE;
-
   game_em.last_moving_player = 0;	/* default: first player */
 
   for (i = 0; i < MAX_PLAYERS; i++)
diff --git a/src/game_em/export.h b/src/game_em/export.h
index 365cafe..69c92d8 100644
--- a/src/game_em/export.h
+++ b/src/game_em/export.h
@@ -668,6 +668,7 @@ struct GameInfo_EM
   boolean any_player_snapping;
 
   boolean use_single_button;
+  boolean use_snap_key_bug;
 
   int last_moving_player;
   int last_player_direction[MAX_PLAYERS];
diff --git a/src/game_em/graphics.c b/src/game_em/graphics.c
index 727b2b8..fee2a18 100644
--- a/src/game_em/graphics.c
+++ b/src/game_em/graphics.c
@@ -760,6 +760,10 @@ void RedrawPlayfield_EM(boolean force_redraw)
       screen_y = screen_y_old;
   }
 
+  // skip redrawing playfield in warp mode or when testing tapes with "autotest"
+  if (DrawingDeactivatedField())
+    return;
+
   animscreen();
 
   for (i = 0; i < MAX_PLAYERS; i++)
diff --git a/src/game_em/input.c b/src/game_em/input.c
index b8e2e66..4a2be29 100644
--- a/src/game_em/input.c
+++ b/src/game_em/input.c
@@ -161,6 +161,10 @@ void readjoy(byte action, struct PLAYER *ply)
       !ply->joy_s &&
       !ply->joy_w)
     ply->joy_snap = snap;
+
+  /* use bug with snap key (mainly TAS keys) sometimes moving the player */
+  if (game_em.use_snap_key_bug)
+    ply->joy_snap = snap;
 }
 
 void SaveEngineSnapshotValues_EM()
diff --git a/src/game_em/synchro_3.c b/src/game_em/synchro_3.c
index 307d285..ca83a82 100644
--- a/src/game_em/synchro_3.c
+++ b/src/game_em/synchro_3.c
@@ -13,7 +13,7 @@ void synchro_3(void)
   int x;
   int y;
   int count;
-  unsigned long random;
+  unsigned int random;
 
   /* update variables */
 
diff --git a/src/game_sp/main.c b/src/game_sp/main.c
index 3373d46..c7239cc 100644
--- a/src/game_sp/main.c
+++ b/src/game_sp/main.c
@@ -54,6 +54,10 @@ void InitGameEngine_SP()
 
 void RedrawPlayfield_SP(boolean force_redraw)
 {
+  // skip redrawing playfield in warp mode or when testing tapes with "autotest"
+  if (DrawingDeactivatedField())
+    return;
+
   if (force_redraw)
     RestorePlayfield();
 
diff --git a/src/init.c b/src/init.c
index 54f4277..6980eb9 100644
--- a/src/init.c
+++ b/src/init.c
@@ -1717,10 +1717,10 @@ static void InitGraphicInfo()
 
   for (i = 0; i < num_images; i++)
   {
-    Bitmap *src_bitmap;
+    Bitmap *src_bitmap = graphic_info[i].bitmap;
     int src_x, src_y;
     int width, height;
-    int first_frame, last_frame;
+    int last_frame;
     int src_bitmap_width, src_bitmap_height;
 
     /* now check if no animation frames are outside of the loaded image */
@@ -1738,9 +1738,7 @@ static void InitGraphicInfo()
 
     /* check if first animation frame is inside specified bitmap */
 
-    first_frame = 0;
-    getFixedGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
-
+    /* do not use getGraphicSourceXY() here to get position of first frame; */
     /* this avoids calculating wrong start position for out-of-bounds frame */
     src_x = graphic_info[i].src_x;
     src_y = graphic_info[i].src_y;
@@ -1770,12 +1768,15 @@ static void InitGraphicInfo()
       Error(ERR_INFO_LINE, "-");
 
       graphic_info[i] = graphic_info[fallback_graphic];
+
+      /* if first frame out of bounds, do not check last frame anymore */
+      continue;
     }
 
     /* check if last animation frame is inside specified bitmap */
 
     last_frame = graphic_info[i].anim_frames - 1;
-    getFixedGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
+    getGraphicSourceXY(i, last_frame, &src_x, &src_y, FALSE);
 
     if (src_x < 0 || src_y < 0 ||
 	src_x + width  > src_bitmap_width ||
diff --git a/src/libgame/system.c b/src/libgame/system.c
index a87ecc8..6f063d1 100644
--- a/src/libgame/system.c
+++ b/src/libgame/system.c
@@ -600,6 +600,17 @@ inline static boolean CheckDrawingArea(int x, int y, int width, int height,
   return FALSE;
 }
 
+boolean DrawingDeactivatedField()
+{
+  if (program.headless)
+    return TRUE;
+
+  if (gfx.draw_deactivation_mask & REDRAW_FIELD)
+    return TRUE;
+
+  return FALSE;
+}
+
 boolean DrawingDeactivated(int x, int y, int width, int height)
 {
   return CheckDrawingArea(x, y, width, height, gfx.draw_deactivation_mask);
diff --git a/src/libgame/system.h b/src/libgame/system.h
index 3cf8bea..efc4490 100644
--- a/src/libgame/system.h
+++ b/src/libgame/system.h
@@ -1505,6 +1505,7 @@ void FillRectangle(Bitmap *, int, int, int, int, Pixel);
 void ClearRectangle(Bitmap *, int, int, int, int);
 void ClearRectangleOnBackground(Bitmap *, int, int, int, int);
 void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int);
+boolean DrawingDeactivatedField(void);
 boolean DrawingDeactivated(int, int, int, int);
 boolean DrawingOnBackground(int, int);
 boolean DrawingAreaChanged();
diff --git a/src/libgame/text.c b/src/libgame/text.c
index eb755ba..c8e90d1 100644
--- a/src/libgame/text.c
+++ b/src/libgame/text.c
@@ -457,18 +457,17 @@ static boolean getCheckedTokenValueFromString(char *string, char **token,
 
 static void DrawTextBuffer_Flush(int x, int y, char *buffer, int font_nr,
 				 int line_length, int cut_length,
-				 int line_spacing, int mask_mode,
-				 boolean centered, int current_line)
+				 int mask_mode, boolean centered,
+				 int current_ypos)
 {
   int buffer_len = strlen(buffer);
   int font_width = getFontWidth(font_nr);
-  int font_height = getFontHeight(font_nr);
   int offset_chars = (centered ? (line_length - buffer_len) / 2 : 0);
   int offset_xsize =
     (centered ? font_width * (line_length - buffer_len) / 2 : 0);
   int final_cut_length = MAX(0, cut_length - offset_chars);
   int xx = x + offset_xsize;
-  int yy = y + current_line * (font_height + line_spacing);
+  int yy = y + current_ypos;
 
   buffer[final_cut_length] = '\0';
 
@@ -485,7 +484,11 @@ int DrawTextBuffer(int x, int y, char *text_buffer, int font_nr,
 {
   char buffer[line_length + 1];
   int buffer_len;
+  int font_height = getFontHeight(font_nr);
+  int line_height = font_height + line_spacing;
   int current_line = 0;
+  int current_ypos = 0;
+  int max_ysize = max_lines * line_height;
 
   if (text_buffer == NULL || *text_buffer == '\0')
     return 0;
@@ -499,7 +502,7 @@ int DrawTextBuffer(int x, int y, char *text_buffer, int font_nr,
   buffer[0] = '\0';
   buffer_len = 0;
 
-  while (*text_buffer && current_line < max_lines)
+  while (*text_buffer && current_ypos < max_ysize)
   {
     char line[MAX_LINE_LEN + 1];
     char *line_ptr;
@@ -526,11 +529,11 @@ int DrawTextBuffer(int x, int y, char *text_buffer, int font_nr,
       if (getCheckedTokenValueFromString(line + 1, &token, &value))
       {
 	/* if found, flush the current buffer, if non-empty */
-	if (buffer_len > 0 && current_line < max_lines)
+	if (buffer_len > 0 && current_ypos < max_ysize)
 	{
 	  DrawTextBuffer_Flush(x, y, buffer, font_nr, line_length, cut_length,
-			       line_spacing, mask_mode, centered, current_line);
-
+			       mask_mode, centered, current_ypos);
+	  current_ypos += line_height;
 	  current_line++;
 
 	  buffer[0] = '\0';
@@ -545,6 +548,10 @@ int DrawTextBuffer(int x, int y, char *text_buffer, int font_nr,
 	  centered = get_boolean_from_string(value);
 	else if (strEqual(token, ".parse_comments"))
 	  parse_comments = get_boolean_from_string(value);
+
+	// if font has changed, depending values need to be updated as well
+	font_height = getFontHeight(font_nr);
+	line_height = font_height + line_spacing;
       }
 
       continue;
@@ -565,7 +572,7 @@ int DrawTextBuffer(int x, int y, char *text_buffer, int font_nr,
 
     line_ptr = line;
 
-    while (*line_ptr && current_line < max_lines)
+    while (*line_ptr && current_ypos < max_ysize)
     {
       boolean buffer_filled;
 
@@ -596,7 +603,8 @@ int DrawTextBuffer(int x, int y, char *text_buffer, int font_nr,
       if (buffer_filled)
       {
 	DrawTextBuffer_Flush(x, y, buffer, font_nr, line_length, cut_length,
-			     line_spacing, mask_mode, centered, current_line);
+			     mask_mode, centered, current_ypos);
+	current_ypos += line_height;
 	current_line++;
 
 	last_line_was_empty = (buffer_len == 0);
@@ -607,10 +615,11 @@ int DrawTextBuffer(int x, int y, char *text_buffer, int font_nr,
     }
   }
 
-  if (buffer_len > 0 && current_line < max_lines)
+  if (buffer_len > 0 && current_ypos < max_ysize)
   {
     DrawTextBuffer_Flush(x, y, buffer, font_nr, line_length, cut_length,
-			 line_spacing, mask_mode, centered, current_line);
+			 mask_mode, centered, current_ypos);
+    current_ypos += line_height;
     current_line++;
   }
 
diff --git a/src/main.h b/src/main.h
index 7b15ad9..05cc90b 100644
--- a/src/main.h
+++ b/src/main.h
@@ -2080,14 +2080,14 @@
 #define PROGRAM_VERSION_MAJOR		4
 #define PROGRAM_VERSION_MINOR		0
 #define PROGRAM_VERSION_PATCH		1
-#define PROGRAM_VERSION_BUILD		1
+#define PROGRAM_VERSION_BUILD		3
 #define PROGRAM_VERSION_EXTRA		""
 
 #define PROGRAM_TITLE_STRING		"Rocks'n'Diamonds"
 #define PROGRAM_AUTHOR_STRING		"Holger Schemel"
 #define PROGRAM_EMAIL_STRING		"info at artsoft.org"
 #define PROGRAM_WEBSITE_STRING		"http://www.artsoft.org/"
-#define PROGRAM_COPYRIGHT_STRING	"Copyright \xa9""1995-2017 by Holger Schemel"
+#define PROGRAM_COPYRIGHT_STRING	"Copyright \xa9""1995-2018 by Holger Schemel"
 #define PROGRAM_COMPANY_STRING		"A Game by Artsoft Entertainment"
 
 #define PROGRAM_ICON_FILENAME		"RocksIcon32x32.png"
diff --git a/src/tape.c b/src/tape.c
index e425403..2c0661a 100644
--- a/src/tape.c
+++ b/src/tape.c
@@ -37,6 +37,7 @@
 /* forward declaration for internal use */
 static void HandleTapeButtons(struct GadgetInfo *);
 static void TapeStopWarpForward();
+static float GetTapeLengthSecondsFloat();
 
 static struct GadgetInfo *tape_gadget[NUM_TAPE_BUTTONS];
 
@@ -484,11 +485,13 @@ void PrintTapeReplayProgress(boolean replay_finished)
   }
   else
   {
+    float tape_length_seconds = GetTapeLengthSecondsFloat();
+
     PrintNoLog("\r");
     Print("Level %03d [%02d:%02d]: (%02d:%02d.%03d / %.2f %%) - %s.\n",
 	  level_nr, tape.length_seconds / 60, tape.length_seconds % 60,
 	  counter_seconds / 60, counter_seconds % 60, counter % 1000,
-	  (float)counter / tape.length_seconds / 10,
+	  (float)counter / tape_length_seconds / 10,
 	  tape.auto_play_level_solved ? "solved" : "NOT SOLVED");
 
     counter_last = -1;
@@ -943,6 +946,11 @@ unsigned int GetTapeLengthSeconds()
   return (GetTapeLengthFrames() * GAME_FRAME_DELAY / 1000);
 }
 
+static float GetTapeLengthSecondsFloat()
+{
+  return ((float)GetTapeLengthFrames() * GAME_FRAME_DELAY / 1000);
+}
+
 static void TapeStartWarpForward(int mode)
 {
   tape.fast_forward = (mode & AUTOPLAY_FFWD);
diff --git a/src/tools.c b/src/tools.c
index 1230cf0..8718bbe 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -1444,13 +1444,6 @@ void getSizedGraphicSourceExt(int graphic, int frame, int tilesize,
   *y = *y * tilesize / g->tile_size;
 }
 
-void getFixedGraphicSourceExt(int graphic, int frame, Bitmap **bitmap,
-			      int *x, int *y, boolean get_backside)
-{
-  getSizedGraphicSourceExt(graphic, frame, TILESIZE, bitmap, x, y,
-			   get_backside);
-}
-
 void getSizedGraphicSource(int graphic, int frame, int tilesize,
 			   Bitmap **bitmap, int *x, int *y)
 {
diff --git a/src/tools.h b/src/tools.h
index b267c8b..38b1c5c 100644
--- a/src/tools.h
+++ b/src/tools.h
@@ -140,7 +140,6 @@ void DrawPlayer(struct PlayerInfo *);
 void getGraphicSourceBitmap(int, int, Bitmap **);
 void getGraphicSourceXY(int, int, int *, int *, boolean);
 void getSizedGraphicSourceExt(int, int, int, Bitmap **, int *, int *, boolean);
-void getFixedGraphicSourceExt(int, int, Bitmap **, int *, int *, boolean);
 void getSizedGraphicSource(int, int, int, Bitmap **, int *, int *);
 void getFixedGraphicSource(int, int, Bitmap **, int *, int *);
 void getMiniGraphicSource(int, Bitmap **, int *, int *);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/rocksndiamonds.git



More information about the Pkg-games-commits mailing list