From: Holger Schemel Date: Sat, 21 Feb 2004 20:20:00 +0000 (+0100) Subject: rnd-20040221-2-src X-Git-Tag: 3.1.0^2~68 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=ba68c676a24c697907748c2653d77752363170fe;p=rocksndiamonds.git rnd-20040221-2-src * fixed bug with missing properties for "mole" * fixed bug that showed up when fixing the above "mole" properties bug --- diff --git a/ChangeLog b/ChangeLog index da30093f..7824af79 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2004-02-21 * "spring push bug" reintroduced as configurable element property + * fixed bug with missing properties for "mole" + * fixed bug that showed up when fixing the above "mole" properties bug 2004-02-17 * fixed bug which caused all CE change pages to be ignored which had diff --git a/src/conftime.h b/src/conftime.h index 8b877d77..59869ce1 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2004-02-21 13:33]" +#define COMPILE_DATE_STRING "[2004-02-21 21:18]" diff --git a/src/editor.c b/src/editor.c index 4a96432c..cc05c9d2 100644 --- a/src/editor.c +++ b/src/editor.c @@ -4875,19 +4875,18 @@ static void MapCounterButtons(int id) int x_right = gi_up->x + gi_up->width + xoffset_right; int y_above = gi_down->y - yoffset_above; int x = gi_down->x; - int y = gi_up->y + yoffset; + int y; /* set after gadget position was modified */ #endif -#if 1 - /* special case needed for "score" counter gadget */ + /* set position for "score" counter gadget */ if (id == ED_COUNTER_ID_ELEMENT_SCORE) { ModifyGadget(gi_down, GDI_Y, SY + counterbutton_info[id].y, GDI_END); ModifyGadget(gi_text, GDI_Y, SY + counterbutton_info[id].y, GDI_END); ModifyGadget(gi_up, GDI_Y, SY + counterbutton_info[id].y, GDI_END); - y = gi_up->y + yoffset; } -#endif + + y = gi_up->y + yoffset; if (counterbutton_info[id].text_above) DrawText(x, y_above, counterbutton_info[id].text_above, FONT_TEXT_1); @@ -5089,16 +5088,14 @@ static void MapCheckbuttonGadget(int id) int yoffset = ED_BORDER_SIZE; int x_left = gi->x - xoffset_left; int x_right = gi->x + gi->width + xoffset_right; - int y = gi->y + yoffset; + int y; /* set after gadget position was modified */ - /* special case needed for "stickybutton" and "can move into acid" gadgets */ + /* set position for "stickybutton" and "can move into acid" gadgets */ if (id == ED_CHECKBUTTON_ID_STICK_ELEMENT || id == ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID) - { - ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, - GDI_Y, SY + checkbutton_info[id].y, GDI_END); - y = gi->y + yoffset; - } + ModifyGadget(gi, GDI_Y, SY + checkbutton_info[id].y, GDI_END); + + y = gi->y + yoffset; if (checkbutton_info[id].text_left) DrawText(x_left, y, checkbutton_info[id].text_left, FONT_TEXT_1); @@ -5106,6 +5103,8 @@ static void MapCheckbuttonGadget(int id) if (checkbutton_info[id].text_right) DrawText(x_right, y, checkbutton_info[id].text_right, FONT_TEXT_1); + ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value, GDI_END); + MapGadget(gi); } @@ -5664,6 +5663,13 @@ static void CopyGroupElementPropertiesToEditor(int element) static void CopyClassicElementPropertiesToEditor(int element) { +#if 1 + if (COULD_MOVE_INTO_ACID(element)) + custom_element_properties[EP_CAN_MOVE_INTO_ACID] = + getMoveIntoAcidProperty(&level, element); + +#else + if (COULD_MOVE_INTO_ACID(element)) { int bit_nr = get_special_property_bit(element, EP_CAN_MOVE_INTO_ACID); @@ -5672,6 +5678,7 @@ static void CopyClassicElementPropertiesToEditor(int element) custom_element_properties[EP_CAN_MOVE_INTO_ACID] = ((level.can_move_into_acid & (1 << bit_nr)) != 0); } +#endif } static void CopyElementPropertiesToEditor(int element) @@ -5832,6 +5839,12 @@ static void CopyGroupElementPropertiesToGame(int element) static void CopyClassicElementPropertiesToGame(int element) { +#if 1 + if (COULD_MOVE_INTO_ACID(element)) + setMoveIntoAcidProperty(&level, element, + custom_element_properties[EP_CAN_MOVE_INTO_ACID]); +#else + if (COULD_MOVE_INTO_ACID(element)) { int bit_nr = get_special_property_bit(element, EP_CAN_MOVE_INTO_ACID); @@ -5844,6 +5857,7 @@ static void CopyClassicElementPropertiesToGame(int element) level.can_move_into_acid |= (1 << bit_nr); } } +#endif } static void CopyElementPropertiesToGame(int element) @@ -6752,10 +6766,12 @@ static void DrawPropertiesConfig() MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS); if (COULD_MOVE_INTO_ACID(properties_element) && - !IS_CUSTOM_ELEMENT(properties_element)) + (!IS_CUSTOM_ELEMENT(properties_element) || + edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)) { checkbutton_info[ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID].y = - ED_SETTINGS_YPOS(HAS_CONTENT(properties_element) ? 1 : 0); + ED_SETTINGS_YPOS(IS_CUSTOM_ELEMENT(properties_element) ? 6 : + HAS_CONTENT(properties_element) ? 1 : 0); MapCheckbuttonGadget(ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID); } @@ -6814,6 +6830,8 @@ static void DrawPropertiesConfig() } else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2) { + /* set position for special checkbutton for "can move into acid" */ + /* draw checkbutton gadgets */ for (i = ED_CHECKBUTTON_ID_CUSTOM2_FIRST; i <= ED_CHECKBUTTON_ID_CUSTOM2_LAST; i++) diff --git a/src/files.c b/src/files.c index 52116aa9..34e3d3ac 100644 --- a/src/files.c +++ b/src/files.c @@ -29,7 +29,7 @@ #define CHUNK_SIZE_NONE -1 /* do not write chunk size */ #define FILE_VERS_CHUNK_SIZE 8 /* size of file version chunk */ #define LEVEL_HEADER_SIZE 80 /* size of level file header */ -#define LEVEL_HEADER_UNUSED 10 /* unused level header bytes */ +#define LEVEL_HEADER_UNUSED 8 /* unused level header bytes */ #define LEVEL_CHUNK_CNT2_SIZE 160 /* size of level CNT2 chunk */ #define LEVEL_CHUNK_CNT2_UNUSED 11 /* unused CNT2 chunk bytes */ #define LEVEL_CHUNK_CNT3_HEADER 16 /* size of level CNT3 header */ @@ -121,14 +121,6 @@ void setElementChangeInfoToDefaults(struct ElementChangeInfo *change) change->post_change_function = NULL; } -static void setMoveIntoAcid(struct LevelInfo *level, int element) -{ - int bit_nr = get_special_property_bit(element, EP_CAN_MOVE_INTO_ACID); - - if (bit_nr > -1) - level->can_move_into_acid |= (1 << bit_nr); -} - static void setLevelInfoToDefaults(struct LevelInfo *level) { int i, j, x, y; @@ -164,6 +156,7 @@ static void setLevelInfoToDefaults(struct LevelInfo *level) level->em_slippery_gems = FALSE; level->block_last_field = FALSE; level->sp_block_last_field = TRUE; + level->use_spring_bug = FALSE; level->can_move_into_acid = ~0; /* everything can move into acid */ @@ -267,6 +260,9 @@ static void setLevelInfoToDefaults(struct LevelInfo *level) for (j = 0; j < NUM_EP_BITFIELDS; j++) Properties[element][j] = EP_BITMASK_DEFAULT; + /* now set default properties */ + SET_PROPERTY(element, EP_CAN_MOVE_INTO_ACID, TRUE); + element_info[element].modified_settings = FALSE; } else if (IS_GROUP_ELEMENT(element) || element == EL_INTERNAL_EDITOR) @@ -656,6 +652,8 @@ static int LoadLevel_HEAD(FILE *file, int chunk_size, struct LevelInfo *level) level->use_spring_bug = (getFile8Bit(file) == 1 ? TRUE : FALSE); + level->can_move_into_acid = getFile16BitBE(file); + ReadUnusedBytesFromFile(file, LEVEL_HEADER_UNUSED); return chunk_size; @@ -2044,12 +2042,17 @@ static void LoadLevel_InitVersion(struct LevelInfo *level, char *filename) if (level->game_version < VERSION_IDENT(3,0,9,0)) { + int i; + level->can_move_into_acid = 0; /* nothing can move into acid */ - setMoveIntoAcid(level, EL_ROBOT); - setMoveIntoAcid(level, EL_SATELLITE); - setMoveIntoAcid(level, EL_PENGUIN); - setMoveIntoAcid(level, EL_BALLOON); + setMoveIntoAcidProperty(level, EL_ROBOT, TRUE); + setMoveIntoAcidProperty(level, EL_SATELLITE, TRUE); + setMoveIntoAcidProperty(level, EL_PENGUIN, TRUE); + setMoveIntoAcidProperty(level, EL_BALLOON, TRUE); + + for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++) + SET_PROPERTY(EL_CUSTOM_START + i, EP_CAN_MOVE_INTO_ACID, TRUE); } } else @@ -2319,6 +2322,8 @@ static void SaveLevel_HEAD(FILE *file, struct LevelInfo *level) putFile8Bit(file, (level->use_spring_bug ? 1 : 0)); + putFile16BitBE(file, level->can_move_into_acid); + WriteUnusedBytesToFile(file, LEVEL_HEADER_UNUSED); } diff --git a/src/game.c b/src/game.c index 5da67f0d..75508923 100644 --- a/src/game.c +++ b/src/game.c @@ -101,20 +101,21 @@ #define GET_MAX_MOVE_DELAY(e) ( (element_info[e].move_delay_fixed) + \ (element_info[e].move_delay_random)) -#if 1 #define ELEMENT_CAN_ENTER_FIELD_GENERIC(e, x, y, condition) \ (IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \ (condition) || \ (DONT_COLLIDE_WITH(e) && \ IS_PLAYER(x, y) && \ !PLAYER_ENEMY_PROTECTED(x, y)))) -#else -#define ELEMENT_CAN_ENTER_FIELD_GENERIC(e, x, y, condition) \ + +#define ELEMENT_CAN_ENTER_FIELD_GENERIC_X(e, x, y, condition) \ (IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \ (condition) || \ + (CAN_MOVE_INTO_ACID(e) && \ + Feld[x][y] == EL_ACID) || \ (DONT_COLLIDE_WITH(e) && \ - IS_FREE_OR_PLAYER(x, y)))) -#endif + IS_PLAYER(x, y) && \ + !PLAYER_ENEMY_PROTECTED(x, y)))) #define ELEMENT_CAN_ENTER_FIELD_GENERIC_2(x, y, condition) \ (IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \ @@ -153,17 +154,6 @@ Feld[x][y] == EL_EXIT_OPEN || \ Feld[x][y] == EL_ACID)) -#if 0 -#if 1 -#define MAZE_RUNNER_CAN_ENTER_FIELD(x, y) \ - (IN_LEV_FIELD(x, y) && IS_FREE(x, y)) -#else -#define MAZE_RUNNER_CAN_ENTER_FIELD(x, y) \ - (IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \ - IS_FOOD_DARK_YAMYAM(Feld[x][y]))) -#endif -#endif - #define GROUP_NR(e) ((e) - EL_GROUP_START) #define MOVE_ENTER_EL(e) (element_info[e].move_enter_element) #define IS_IN_GROUP(e, nr) (element_info[e].in_group[nr] == TRUE) @@ -172,22 +162,17 @@ #define IS_EQUAL_OR_IN_GROUP(e, ge) \ (IS_GROUP_ELEMENT(ge) ? IS_IN_GROUP(e, GROUP_NR(ge)) : (e) == (ge)) -#if 1 #define CE_ENTER_FIELD_COND(e, x, y) \ (!IS_PLAYER(x, y) && \ (Feld[x][y] == EL_ACID || \ IS_EQUAL_OR_IN_GROUP(Feld[x][y], MOVE_ENTER_EL(e)))) -#else -#define CE_ENTER_FIELD_COND(e, x, y) \ + +#define CE_ENTER_FIELD_COND_X(e, x, y) \ (!IS_PLAYER(x, y) && \ - (Feld[x][y] == EL_ACID || \ - Feld[x][y] == MOVE_ENTER_EL(e) || \ - (IS_GROUP_ELEMENT(MOVE_ENTER_EL(e)) && \ - IS_IN_GROUP_EL(Feld[x][y], MOVE_ENTER_EL(e))))) -#endif + IS_EQUAL_OR_IN_GROUP(Feld[x][y], MOVE_ENTER_EL(e))) #define CUSTOM_ELEMENT_CAN_ENTER_FIELD(e, x, y) \ - ELEMENT_CAN_ENTER_FIELD_GENERIC(e, x, y, CE_ENTER_FIELD_COND(e, x, y)) + ELEMENT_CAN_ENTER_FIELD_GENERIC_X(e, x, y, CE_ENTER_FIELD_COND_X(e, x, y)) #define MOLE_CAN_ENTER_FIELD(x, y, condition) \ (IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || (condition))) @@ -4943,6 +4928,12 @@ void StartMoving(int x, int y) #endif } +#if 1 + else if (CAN_MOVE_INTO_ACID(element) && MovDir[x][y] == MV_DOWN && + IN_LEV_FIELD(newx, newy) && Feld[newx][newy] == EL_ACID) + +#else + else if ((element == EL_PENGUIN || element == EL_ROBOT || element == EL_SATELLITE || @@ -4950,6 +4941,7 @@ void StartMoving(int x, int y) IS_CUSTOM_ELEMENT(element)) && IN_LEV_FIELD(newx, newy) && MovDir[x][y] == MV_DOWN && Feld[newx][newy] == EL_ACID) +#endif { SplashAcid(x, y); Store[x][y] = EL_ACID; diff --git a/src/init.c b/src/init.c index e0d97cca..b7ea2825 100644 --- a/src/init.c +++ b/src/init.c @@ -1569,6 +1569,92 @@ static void ReinitializeMusic() InitGameModeMusicInfo(); /* game mode music mapping */ } +static int get_special_property_bit(int element, int base_property_bit) +{ + static struct + { + int element; + int bit_nr; + } pb_can_move_into_acid[] = + { + { EL_BUG, 0 }, + { EL_BUG_LEFT, 0 }, + { EL_BUG_RIGHT, 0 }, + { EL_BUG_UP, 0 }, + { EL_BUG_DOWN, 0 }, + { EL_SPACESHIP, 0 }, + { EL_SPACESHIP_LEFT, 0 }, + { EL_SPACESHIP_RIGHT, 0 }, + { EL_SPACESHIP_UP, 0 }, + { EL_SPACESHIP_DOWN, 0 }, + { EL_BD_BUTTERFLY, 1 }, + { EL_BD_BUTTERFLY_LEFT, 1 }, + { EL_BD_BUTTERFLY_RIGHT, 1 }, + { EL_BD_BUTTERFLY_UP, 1 }, + { EL_BD_BUTTERFLY_DOWN, 1 }, + { EL_BD_FIREFLY, 1 }, + { EL_BD_FIREFLY_LEFT, 1 }, + { EL_BD_FIREFLY_RIGHT, 1 }, + { EL_BD_FIREFLY_UP, 1 }, + { EL_BD_FIREFLY_DOWN, 1 }, + { EL_YAMYAM, 2 }, + { EL_DARK_YAMYAM, 2 }, + { EL_ROBOT, 3 }, + { EL_PACMAN, 4 }, + { EL_PACMAN_LEFT, 4 }, + { EL_PACMAN_RIGHT, 4 }, + { EL_PACMAN_UP, 4 }, + { EL_PACMAN_DOWN, 4 }, + { EL_MOLE, 4 }, + { EL_MOLE_LEFT, 4 }, + { EL_MOLE_RIGHT, 4 }, + { EL_MOLE_UP, 4 }, + { EL_MOLE_DOWN, 4 }, + { EL_PENGUIN, 5 }, + { EL_PIG, 6 }, + { EL_DRAGON, 6 }, + { EL_SATELLITE, 7 }, + { EL_SP_SNIKSNAK, 8 }, + { EL_SP_ELECTRON, 8 }, + { EL_BALLOON, 9 }, + + { -1, 0 }, + }; + int i; + + if (base_property_bit != EP_CAN_MOVE_INTO_ACID) + return -1; + + for (i = 0; pb_can_move_into_acid[i].element != -1; i++) + if (pb_can_move_into_acid[i].element == element) + return pb_can_move_into_acid[i].bit_nr; + + return -1; +} + +void setMoveIntoAcidProperty(struct LevelInfo *level, int element, boolean set) +{ + int bit_nr = get_special_property_bit(element, EP_CAN_MOVE_INTO_ACID); + + if (bit_nr > -1) + { + level->can_move_into_acid &= ~(1 << bit_nr); + + if (set) + level->can_move_into_acid |= (1 << bit_nr); + } +} + +boolean getMoveIntoAcidProperty(struct LevelInfo *level, int element) +{ + int bit_nr = get_special_property_bit(element, EP_CAN_MOVE_INTO_ACID); + + if (bit_nr > -1) + return ((level->can_move_into_acid & (1 << bit_nr)) != 0); + + return FALSE; +} + void InitElementPropertiesStatic() { static int ep_diggable[] = @@ -2935,13 +3021,11 @@ void InitElementPropertiesStatic() EL_PACMAN_LEFT, EL_PACMAN_RIGHT, EL_PACMAN_UP, EL_PACMAN_DOWN }, -#if 1 { EL_MOLE, EL_MOLE_LEFT, EL_MOLE_RIGHT, EL_MOLE_UP, EL_MOLE_DOWN }, -#endif { -1, -1, -1, -1, -1 @@ -3171,7 +3255,12 @@ void InitElementPropertiesEngine(int engine_version) i == EL_BLACK_ORB)); /* ---------- COULD_MOVE_INTO_ACID ------------------------------------- */ - SET_PROPERTY(i, EP_COULD_MOVE_INTO_ACID, (CAN_MOVE(i) && i != EL_SPRING)); + SET_PROPERTY(i, EP_COULD_MOVE_INTO_ACID, ((CAN_MOVE(i) && i != EL_SPRING)|| + IS_CUSTOM_ELEMENT(i))); + + /* ---------- CAN_MOVE_INTO_ACID --------------------------------------- */ + if (getMoveIntoAcidProperty(&level, i)) + SET_PROPERTY(i, EP_CAN_MOVE_INTO_ACID, TRUE); /* ---------- SP_PORT -------------------------------------------------- */ SET_PROPERTY(i, EP_SP_PORT, (IS_SP_ELEMENT(i) && @@ -3284,69 +3373,6 @@ void InitElementPropertiesEngine(int engine_version) InitElementGraphicInfo(); } -int get_special_property_bit(int element, int base_property_bit) -{ - static struct - { - int element; - int bit_nr; - } pb_can_move_into_acid[] = - { - { EL_BUG, 0 }, - { EL_BUG_LEFT, 0 }, - { EL_BUG_RIGHT, 0 }, - { EL_BUG_UP, 0 }, - { EL_BUG_DOWN, 0 }, - { EL_SPACESHIP, 0 }, - { EL_SPACESHIP_LEFT, 0 }, - { EL_SPACESHIP_RIGHT, 0 }, - { EL_SPACESHIP_UP, 0 }, - { EL_SPACESHIP_DOWN, 0 }, - { EL_BD_BUTTERFLY, 1 }, - { EL_BD_BUTTERFLY_LEFT, 1 }, - { EL_BD_BUTTERFLY_RIGHT, 1 }, - { EL_BD_BUTTERFLY_UP, 1 }, - { EL_BD_BUTTERFLY_DOWN, 1 }, - { EL_BD_FIREFLY, 1 }, - { EL_BD_FIREFLY_LEFT, 1 }, - { EL_BD_FIREFLY_RIGHT, 1 }, - { EL_BD_FIREFLY_UP, 1 }, - { EL_BD_FIREFLY_DOWN, 1 }, - { EL_YAMYAM, 2 }, - { EL_DARK_YAMYAM, 2 }, - { EL_ROBOT, 3 }, - { EL_PACMAN, 4 }, - { EL_PACMAN_LEFT, 4 }, - { EL_PACMAN_RIGHT, 4 }, - { EL_PACMAN_UP, 4 }, - { EL_PACMAN_DOWN, 4 }, - { EL_MOLE, 4 }, - { EL_MOLE_LEFT, 4 }, - { EL_MOLE_RIGHT, 4 }, - { EL_MOLE_UP, 4 }, - { EL_MOLE_DOWN, 4 }, - { EL_PENGUIN, 5 }, - { EL_PIG, 6 }, - { EL_DRAGON, 6 }, - { EL_SATELLITE, 7 }, - { EL_SP_SNIKSNAK, 8 }, - { EL_SP_ELECTRON, 8 }, - { EL_BALLOON, 9 }, - - { -1, 0 }, - }; - int i; - - if (base_property_bit != EP_CAN_MOVE_INTO_ACID) - return -1; - - for (i = 0; pb_can_move_into_acid[i].element != -1; i++) - if (pb_can_move_into_acid[i].element == element) - return pb_can_move_into_acid[i].bit_nr; - - return -1; -} - static void InitGlobal() { global.autoplay_leveldir = NULL; diff --git a/src/init.h b/src/init.h index 7440123f..af5f3981 100644 --- a/src/init.h +++ b/src/init.h @@ -16,9 +16,10 @@ #include "main.h" +void setMoveIntoAcidProperty(struct LevelInfo *, int, boolean); +boolean getMoveIntoAcidProperty(struct LevelInfo *, int); void InitElementPropertiesStatic(void); void InitElementPropertiesEngine(int); -int get_special_property_bit(int, int); void ReloadCustomArtwork(int); diff --git a/src/tools.c b/src/tools.c index 4661ac64..b69aff20 100644 --- a/src/tools.c +++ b/src/tools.c @@ -2356,8 +2356,10 @@ unsigned int MoveDoor(unsigned int door_state) stepsize = 20; /* must be choosen to always draw last frame */ door_delay_value = 0; +#if 0 StopSound(SND_DOOR_OPENING); StopSound(SND_DOOR_CLOSING); +#endif } if (global.autoplay_leveldir) @@ -2375,7 +2377,7 @@ unsigned int MoveDoor(unsigned int door_state) door_1.anim_mode == ANIM_VERTICAL ? DYSIZE : DXSIZE); int x; - if (!(door_state & DOOR_NO_DELAY)) + if (!(door_state & DOOR_NO_DELAY) && !setup.quick_doors) { /* opening door sound has priority over simultaneously closing door */ if (door_state & (DOOR_OPEN_1 | DOOR_OPEN_2)) @@ -2558,11 +2560,13 @@ unsigned int MoveDoor(unsigned int door_state) } } +#if 0 if (setup.quick_doors) { StopSound(SND_DOOR_OPENING); StopSound(SND_DOOR_CLOSING); } +#endif if (door_state & DOOR_ACTION_1) door1 = door_state & DOOR_ACTION_1;