From 2ad9cd3aeb8b97f1cb869dd70f26abd0f7468a81 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 6 Mar 2007 02:29:21 +0100 Subject: [PATCH] rnd-20070306-1-src --- src/conftime.h | 2 +- src/editor.c | 32 ++++++++++++++++++++++++++++++++ src/game.c | 17 ++++++++++++----- src/game.h | 1 + src/init.c | 23 +++++++++++++---------- src/init.h | 1 + src/libgame/misc.c | 2 +- 7 files changed, 61 insertions(+), 17 deletions(-) diff --git a/src/conftime.h b/src/conftime.h index ef368f3c..c39bf070 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2007-03-05 22:24" +#define COMPILE_DATE_STRING "2007-03-06 02:28" diff --git a/src/editor.c b/src/editor.c index f16d5aa3..9f2ec785 100644 --- a/src/editor.c +++ b/src/editor.c @@ -9091,6 +9091,26 @@ static void SetElementIntelliDraw(int x, int y, int new_element, new_element = (nr == 0 ? EL_SP_HARDWARE_GREEN : nr == 1 ? EL_SP_HARDWARE_BLUE : EL_SP_HARDWARE_RED); } + else if (IS_GROUP_ELEMENT(new_element)) + { + boolean connected_drawing = FALSE; + int i; + + for (i = 0; i < NUM_DIRECTIONS; i++) + { + int xx = x + xy[i][0]; + int yy = y + xy[i][1]; + + if (last_x == xx && last_y == yy && IN_LEV_FIELD(last_x, last_y) && + IS_IN_GROUP_EL(IntelliDrawBuffer[last_x][last_y], new_element)) + connected_drawing = TRUE; + } + + if (!connected_drawing) + ResolveGroupElement(new_element); + + new_element = GetElementFromGroupElement(new_element); + } else if (IS_BELT_SWITCH(old_element)) { int belt_nr = getBeltNrFromBeltSwitchElement(old_element); @@ -9862,6 +9882,10 @@ static void RandomPlacement(int new_element) int num_percentage, num_elements; int x, y; +#if 1 + ResetIntelliDraw(); +#endif + /* determine number of free positions for randomly placing the new element */ for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++) { @@ -9885,7 +9909,11 @@ static void RandomPlacement(int new_element) for (x = 0; x < lev_fieldx; x++) for (y = 0; y < lev_fieldy; y++) if (free_position[x][y]) +#if 1 + SetElement(x, y, new_element); +#else Feld[x][y] = new_element; +#endif } else { @@ -9898,7 +9926,11 @@ static void RandomPlacement(int new_element) if (free_position[x][y]) { free_position[x][y] = FALSE; +#if 1 + SetElement(x, y, new_element); +#else Feld[x][y] = new_element; +#endif num_elements--; } } diff --git a/src/game.c b/src/game.c index a52780cb..104b6e4d 100644 --- a/src/game.c +++ b/src/game.c @@ -942,7 +942,7 @@ void GetPlayerConfig() InitJoysticks(); } -static int get_element_from_group_element(int element) +int GetElementFromGroupElement(int element) { if (IS_GROUP_ELEMENT(element)) { @@ -1240,7 +1240,7 @@ static void InitField(int x, int y, boolean init_game) } else if (IS_GROUP_ELEMENT(element)) { - Feld[x][y] = get_element_from_group_element(element); + Feld[x][y] = GetElementFromGroupElement(element); InitField(x, y, init_game); } @@ -8732,7 +8732,7 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) static void CreateFieldExt(int x, int y, int element, boolean is_change) { int old_element = Feld[x][y]; - int new_element = get_element_from_group_element(element); + int new_element = GetElementFromGroupElement(element); int previous_move_direction = MovDir[x][y]; #if USE_NEW_CUSTOM_VALUE int last_ce_value = CustomValue[x][y]; @@ -9064,12 +9064,13 @@ static void HandleElementChange(int x, int y, int page) if (change->can_change) { -#if 0 +#if 1 /* !!! not clear why graphic animation should be reset at all here !!! */ + /* !!! UPDATE: but is needed for correct Snake Bite tail animation !!! */ #if USE_GFX_RESET_WHEN_NOT_MOVING /* when a custom element is about to change (for example by change delay), do not reset graphic animation when the custom element is moving */ - if (IS_MOVING(x, y)) + if (!IS_MOVING(x, y)) #endif { ResetGfxAnimation(x, y); @@ -10782,14 +10783,19 @@ void ScrollLevel(int dx, int dy) int i, x, y; #endif +#if 0 + /* !!! THIS IS APPARENTLY WRONG FOR PLAYER RELOCATION !!! */ /* only horizontal XOR vertical scroll direction allowed */ if ((dx == 0 && dy == 0) || (dx != 0 && dy != 0)) return; +#endif #if 1 if (bitmap_db_field2 == NULL) bitmap_db_field2 = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH); + /* needed when blitting directly to same bitmap -- should not be needed with + recent SDL libraries, but apparently does not work in 1.2.11 directly */ BlitBitmap(drawto_field, bitmap_db_field2, FX + TILEX * (dx == -1) - softscroll_offset, FY + TILEY * (dy == -1) - softscroll_offset, @@ -10808,6 +10814,7 @@ void ScrollLevel(int dx, int dy) #else #if 1 + /* !!! DOES NOT WORK FOR DIAGONAL PLAYER RELOCATION !!! */ int xsize = (BX2 - BX1 + 1); int ysize = (BY2 - BY1 + 1); int start = (dx != 0 ? (dx == -1 ? BX1 : BX2) : (dy == -1 ? BY1 : BY2)); diff --git a/src/game.h b/src/game.h index 92ab3451..a18b3f0c 100644 --- a/src/game.h +++ b/src/game.h @@ -229,6 +229,7 @@ void DEBUG_SetMaximumDynamite(); #endif void GetPlayerConfig(void); +int GetElementFromGroupElement(int); void DrawGameValue_Time(int); void DrawGameDoorValues(void); diff --git a/src/init.c b/src/init.c index 4e715dff..9b9497f4 100644 --- a/src/init.c +++ b/src/init.c @@ -1965,7 +1965,7 @@ boolean getBitfieldProperty(int *bitfield, int property_bit_nr, int element) return FALSE; } -static void resolve_group_element(int group_element, int recursion_depth) +static void ResolveGroupElementExt(int group_element, int recursion_depth) { static int group_nr; static struct ElementGroupInfo *group; @@ -1989,10 +1989,13 @@ static void resolve_group_element(int group_element, int recursion_depth) if (recursion_depth == 0) /* initialization */ { group = actual_group; - group_nr = group_element - EL_GROUP_START; + group_nr = GROUP_NR(group_element); group->num_elements_resolved = 0; group->choice_pos = 0; + + for (i = 0; i < MAX_NUM_ELEMENTS; i++) + element_info[i].in_group[group_nr] = FALSE; } for (i = 0; i < actual_group->num_elements; i++) @@ -2003,7 +2006,7 @@ static void resolve_group_element(int group_element, int recursion_depth) break; if (IS_GROUP_ELEMENT(element)) - resolve_group_element(element, recursion_depth + 1); + ResolveGroupElementExt(element, recursion_depth + 1); else { group->element_resolved[group->num_elements_resolved++] = element; @@ -2012,6 +2015,11 @@ static void resolve_group_element(int group_element, int recursion_depth) } } +void ResolveGroupElement(int group_element) +{ + ResolveGroupElementExt(group_element, 0); +} + void InitElementPropertiesStatic() { static int ep_diggable[] = @@ -4023,14 +4031,9 @@ void InitElementPropertiesEngine(int engine_version) property (which means that conditional property changes must be set to a reliable default value before) */ - /* ---------- recursively resolve group elements ------------------------- */ - - for (i = 0; i < MAX_NUM_ELEMENTS; i++) - for (j = 0; j < NUM_GROUP_ELEMENTS; j++) - element_info[i].in_group[j] = FALSE; - + /* resolve group elements */ for (i = 0; i < NUM_GROUP_ELEMENTS; i++) - resolve_group_element(EL_GROUP_START + i, 0); + ResolveGroupElement(EL_GROUP_START + i); /* set all special, combined or engine dependent element properties */ for (i = 0; i < MAX_NUM_ELEMENTS; i++) diff --git a/src/init.h b/src/init.h index 165c2a78..3df39d26 100644 --- a/src/init.h +++ b/src/init.h @@ -32,6 +32,7 @@ void setBitfieldProperty(int *, int, int, boolean); boolean getBitfieldProperty(int *, int, int); +void ResolveGroupElement(int); void InitElementPropertiesStatic(void); void InitElementPropertiesEngine(int); void InitElementPropertiesAfterLoading(int); diff --git a/src/libgame/misc.c b/src/libgame/misc.c index e0e8a0ff..eb3e7a0f 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -2806,7 +2806,7 @@ void NotifyUserAboutErrorFile() #if DEBUG #define DEBUG_NUM_TIMESTAMPS 3 -#define DEBUG_TIME_IN_MICROSECONDS 1 +#define DEBUG_TIME_IN_MICROSECONDS 0 #if DEBUG_TIME_IN_MICROSECONDS static double Counter_Microseconds() -- 2.34.1