From 7bb60f12d6369c20c459e165fa30beda8af67576 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 27 Nov 2004 16:26:24 +0100 Subject: [PATCH] rnd-20041127-2-src --- src/conf_gfx.c | 1 + src/conftime.h | 2 +- src/init.c | 46 ++++++++++++++++++++++++++++++++++++++-------- src/main.h | 50 ++++++++++++++++++++++++++------------------------ 4 files changed, 66 insertions(+), 33 deletions(-) diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 643866b9..d6755760 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -36,6 +36,7 @@ struct ConfigTypeInfo image_config_suffix[] = { ".2nd_offset", ARG_UNDEFINED, TYPE_INTEGER }, { ".2nd_xoffset", ARG_UNDEFINED, TYPE_INTEGER }, { ".2nd_yoffset", ARG_UNDEFINED, TYPE_INTEGER }, + { ".2nd_swap_tiles", ARG_UNDEFINED, TYPE_BOOLEAN }, { ".frames", ARG_UNDEFINED, TYPE_INTEGER }, { ".frames_per_line", ARG_UNDEFINED, TYPE_INTEGER }, { ".start_frame", ARG_UNDEFINED, TYPE_INTEGER }, diff --git a/src/conftime.h b/src/conftime.h index 0b615479..ef7de38c 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2004-11-27 04:41]" +#define COMPILE_DATE_STRING "[2004-11-27 16:19]" diff --git a/src/init.c b/src/init.c index a6caa272..f2f628b0 100644 --- a/src/init.c +++ b/src/init.c @@ -639,7 +639,9 @@ void InitElementGraphicInfo() if (act == ACTION_FALLING) /* special case */ graphic = element_info[i].graphic[act]; - if (graphic != -1 && graphic_info[graphic].double_movement) + if (graphic != -1 && + graphic_info[graphic].double_movement && + graphic_info[graphic].swap_double_tiles != 0) { struct GraphicInfo *g = &graphic_info[graphic]; int src_x_front = g->src_x; @@ -650,20 +652,40 @@ void InitElementGraphicInfo() g->offset_y != 0); boolean front_is_left_or_upper = (src_x_front < src_x_back || src_y_front < src_y_back); +#if 0 + boolean second_tile_is_back = + ((move_dir == MV_BIT_LEFT && front_is_left_or_upper) || + (move_dir == MV_BIT_UP && front_is_left_or_upper)); + boolean second_tile_is_front = + ((move_dir == MV_BIT_RIGHT && front_is_left_or_upper) || + (move_dir == MV_BIT_DOWN && front_is_left_or_upper)); + boolean second_tile_should_be_front = + (g->second_tile_is_start == 0); + boolean second_tile_should_be_back = + (g->second_tile_is_start == 1); +#endif + boolean swap_movement_tiles_always = (g->swap_double_tiles == 1); + boolean swap_movement_tiles_autodetected = + (!frames_are_ordered_diagonally && + ((move_dir == MV_BIT_LEFT && !front_is_left_or_upper) || + (move_dir == MV_BIT_UP && !front_is_left_or_upper) || + (move_dir == MV_BIT_RIGHT && front_is_left_or_upper) || + (move_dir == MV_BIT_DOWN && front_is_left_or_upper))); Bitmap *dummy; #if 0 - printf("::: CHECKING ELEMENT %d ('%s'), ACTION '%s', DIRECTION %d\n", + printf("::: CHECKING element %d ('%s'), '%s', dir %d [(%d -> %d, %d), %d => %d]\n", i, element_info[i].token_name, - element_action_info[act].suffix, move_dir); + element_action_info[act].suffix, move_dir, + g->swap_double_tiles, + swap_movement_tiles_never, + swap_movement_tiles_always, + swap_movement_tiles_autodetected, + swap_movement_tiles); #endif /* swap frontside and backside graphic tile coordinates, if needed */ - if (!frames_are_ordered_diagonally && - ((move_dir == MV_BIT_LEFT && !front_is_left_or_upper) || - (move_dir == MV_BIT_RIGHT && front_is_left_or_upper) || - (move_dir == MV_BIT_UP && !front_is_left_or_upper) || - (move_dir == MV_BIT_DOWN && front_is_left_or_upper))) + if (swap_movement_tiles_always || swap_movement_tiles_autodetected) { /* get current (wrong) backside tile coordinates */ getGraphicSourceExt(graphic, 0, &dummy, &src_x_back, &src_y_back, @@ -677,6 +699,9 @@ void InitElementGraphicInfo() g->offset2_x *= -1; g->offset2_y *= -1; + /* do not swap front and backside tiles again after correction */ + g->swap_double_tiles = 0; + #if 0 printf(" CORRECTED\n"); #endif @@ -962,6 +987,7 @@ static void set_graphic_parameters(int graphic, int graphic_copy_from) graphic_info[graphic].offset_y = 0; /* ... will be corrected later */ graphic_info[graphic].offset2_x = 0; /* one or both of these values ... */ graphic_info[graphic].offset2_y = 0; /* ... will be corrected later */ + graphic_info[graphic].swap_double_tiles = -1; /* auto-detect tile swapping */ graphic_info[graphic].crumbled_like = -1; /* do not use clone element */ graphic_info[graphic].diggable_like = -1; /* do not use clone element */ graphic_info[graphic].border_size = TILEX / 8; /* "CRUMBLED" border size */ @@ -1049,6 +1075,10 @@ static void set_graphic_parameters(int graphic, int graphic_copy_from) if (parameter[GFX_ARG_2ND_YOFFSET] != ARG_UNDEFINED_VALUE) graphic_info[graphic].offset2_y = parameter[GFX_ARG_2ND_YOFFSET]; + /* optionally, the second movement tile can be specified as start tile */ + if (parameter[GFX_ARG_2ND_SWAP_TILES] != ARG_UNDEFINED_VALUE) + graphic_info[graphic].swap_double_tiles= parameter[GFX_ARG_2ND_SWAP_TILES]; + /* automatically determine correct number of frames, if not defined */ if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE) graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES]; diff --git a/src/main.h b/src/main.h index 1374311e..4ff458ad 100644 --- a/src/main.h +++ b/src/main.h @@ -1218,30 +1218,31 @@ #define GFX_ARG_2ND_OFFSET 12 #define GFX_ARG_2ND_XOFFSET 13 #define GFX_ARG_2ND_YOFFSET 14 -#define GFX_ARG_FRAMES 15 -#define GFX_ARG_FRAMES_PER_LINE 16 -#define GFX_ARG_START_FRAME 17 -#define GFX_ARG_DELAY 18 -#define GFX_ARG_ANIM_MODE 19 -#define GFX_ARG_GLOBAL_SYNC 20 -#define GFX_ARG_CRUMBLED_LIKE 21 -#define GFX_ARG_DIGGABLE_LIKE 22 -#define GFX_ARG_BORDER_SIZE 23 -#define GFX_ARG_STEP_OFFSET 24 -#define GFX_ARG_STEP_DELAY 25 -#define GFX_ARG_DIRECTION 26 -#define GFX_ARG_POSITION 27 -#define GFX_ARG_DRAW_XOFFSET 28 -#define GFX_ARG_DRAW_YOFFSET 29 -#define GFX_ARG_DRAW_MASKED 30 -#define GFX_ARG_ANIM_DELAY_FIXED 31 -#define GFX_ARG_ANIM_DELAY_RANDOM 32 -#define GFX_ARG_POST_DELAY_FIXED 33 -#define GFX_ARG_POST_DELAY_RANDOM 34 -#define GFX_ARG_NAME 35 -#define GFX_ARG_SCALE_UP_FACTOR 36 - -#define NUM_GFX_ARGS 37 +#define GFX_ARG_2ND_SWAP_TILES 15 +#define GFX_ARG_FRAMES 16 +#define GFX_ARG_FRAMES_PER_LINE 17 +#define GFX_ARG_START_FRAME 18 +#define GFX_ARG_DELAY 19 +#define GFX_ARG_ANIM_MODE 20 +#define GFX_ARG_GLOBAL_SYNC 21 +#define GFX_ARG_CRUMBLED_LIKE 22 +#define GFX_ARG_DIGGABLE_LIKE 23 +#define GFX_ARG_BORDER_SIZE 24 +#define GFX_ARG_STEP_OFFSET 25 +#define GFX_ARG_STEP_DELAY 26 +#define GFX_ARG_DIRECTION 27 +#define GFX_ARG_POSITION 28 +#define GFX_ARG_DRAW_XOFFSET 29 +#define GFX_ARG_DRAW_YOFFSET 30 +#define GFX_ARG_DRAW_MASKED 31 +#define GFX_ARG_ANIM_DELAY_FIXED 32 +#define GFX_ARG_ANIM_DELAY_RANDOM 33 +#define GFX_ARG_POST_DELAY_FIXED 34 +#define GFX_ARG_POST_DELAY_RANDOM 35 +#define GFX_ARG_NAME 36 +#define GFX_ARG_SCALE_UP_FACTOR 37 + +#define NUM_GFX_ARGS 38 /* values for sound configuration suffixes */ @@ -1906,6 +1907,7 @@ struct GraphicInfo int offset_x, offset_y; /* x/y offset to next animation frame */ int offset2_x, offset2_y; /* x/y offset to second movement tile */ boolean double_movement; /* animation has second movement tile */ + int swap_double_tiles; /* explicitely force or forbid tile swapping */ int anim_frames; int anim_frames_per_line; int anim_start_frame; -- 2.34.1