X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=5d1f08f90516fbf347f65246e676f1c2fce9b631;hb=b06f921c487c5b1e30e44ec00ec2c08f366f83df;hp=4f3b21efbe945297eb8dda2778220deadcc5e6cc;hpb=efbd589db2977f140135f247cd4aacfe6c546410;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 4f3b21ef..5d1f08f9 100644 --- a/src/game.c +++ b/src/game.c @@ -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) @@ -363,6 +364,8 @@ void RemovePlayer(struct PlayerInfo *); boolean SnapField(struct PlayerInfo *, int, int); boolean DropElement(struct PlayerInfo *); +static int getInvisibleActiveFromInvisibleElement(int); +static int getInvisibleFromInvisibleActiveElement(int); static struct GadgetInfo *game_gadget[NUM_GAME_BUTTONS]; @@ -1126,6 +1129,14 @@ static void InitField(int x, int y, boolean init_game) game.light_time_left = level.time_light * FRAMES_PER_SECOND; break; + case EL_INVISIBLE_STEELWALL: + case EL_INVISIBLE_WALL: + case EL_INVISIBLE_SAND: + if (game.light_time_left > 0 || + game.lenses_time_left > 0) + Feld[x][y] = getInvisibleActiveFromInvisibleElement(element); + break; + case EL_EMC_MAGIC_BALL: if (game.ball_state) Feld[x][y] = EL_EMC_MAGIC_BALL_ACTIVE; @@ -1236,12 +1247,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 +1282,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 +2922,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 +2938,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; @@ -2998,10 +3022,24 @@ void InitPlayerGfxAnimation(struct PlayerInfo *player, int action, int dir) } } -static void ResetRandomAnimationValue(int x, int y) +#if USE_GFX_RESET_GFX_ANIMATION +static void ResetGfxFrame(int x, int y, boolean redraw) { - GfxRandom[x][y] = INIT_GFX_RANDOM(); + int element = Feld[x][y]; + int graphic = el_act_dir2img(element, GfxAction[x][y], GfxDir[x][y]); + int last_gfx_frame = GfxFrame[x][y]; + + if (graphic_info[graphic].anim_global_sync) + GfxFrame[x][y] = FrameCounter; + else if (ANIM_MODE(graphic) == ANIM_CE_VALUE) + GfxFrame[x][y] = CustomValue[x][y]; + else if (ANIM_MODE(graphic) == ANIM_CE_SCORE) + GfxFrame[x][y] = element_info[element].collect_score; + + if (redraw && GfxFrame[x][y] != last_gfx_frame) + DrawLevelGraphicAnimation(x, y, graphic); } +#endif static void ResetGfxAnimation(int x, int y) { @@ -3009,9 +3047,9 @@ static void ResetGfxAnimation(int x, int y) int element, graphic; #endif - GfxFrame[x][y] = 0; GfxAction[x][y] = ACTION_DEFAULT; GfxDir[x][y] = MovDir[x][y]; + GfxFrame[x][y] = 0; #if 0 element = Feld[x][y]; @@ -3024,6 +3062,15 @@ static void ResetGfxAnimation(int x, int y) else if (ANIM_MODE(graphic) == ANIM_CE_SCORE) GfxFrame[x][y] = element_info[element].collect_score; #endif + +#if USE_GFX_RESET_GFX_ANIMATION + ResetGfxFrame(x, y, FALSE); +#endif +} + +static void ResetRandomAnimationValue(int x, int y) +{ + GfxRandom[x][y] = INIT_GFX_RANDOM(); } void InitMovingField(int x, int y, int direction) @@ -5683,7 +5730,7 @@ inline static void TurnRoundExt(int x, int y) static void TurnRound(int x, int y) { int direction = MovDir[x][y]; -#if 1 +#if 0 int element, graphic; #endif @@ -5698,6 +5745,8 @@ static void TurnRound(int x, int y) GfxAction[x][y] = ACTION_TURNING_FROM_LEFT + MV_DIR_TO_BIT(direction); #if 1 + ResetGfxFrame(x, y, FALSE); +#else element = Feld[x][y]; graphic = el_act_dir2img(element, GfxAction[x][y], GfxDir[x][y]); @@ -8233,15 +8282,15 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) case CA_SET_CE_VALUE: { #if USE_NEW_CUSTOM_VALUE - int last_custom_value = CustomValue[x][y]; + int last_ce_value = CustomValue[x][y]; CustomValue[x][y] = action_arg_number_new; #if 0 - printf("::: Count == %d\n", CustomValue[x][y]); + printf("::: CE value == %d\n", CustomValue[x][y]); #endif - if (CustomValue[x][y] == 0 && last_custom_value > 0) + if (CustomValue[x][y] == 0 && last_ce_value > 0) { #if 0 printf("::: CE_VALUE_GETS_ZERO\n"); @@ -8261,8 +8310,30 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) case CA_SET_CE_SCORE: { +#if USE_NEW_CUSTOM_VALUE + int last_ce_score = ei->collect_score; + ei->collect_score = action_arg_number_new; +#if 0 + printf("::: CE score == %d\n", ei->collect_score); +#endif + + if (ei->collect_score == 0 && last_ce_score > 0) + { +#if 0 + printf("::: CE_SCORE_GETS_ZERO\n"); +#endif + + CheckElementChange(x, y, element, EL_UNDEFINED, CE_SCORE_GETS_ZERO); + CheckTriggeredElementChange(x, y, element, CE_SCORE_GETS_ZERO_OF_X); + +#if 0 + printf("::: RESULT: %d, %d\n", Feld[x][y], ChangePage[x][y]); +#endif + } +#endif + break; } @@ -8312,8 +8383,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 +8400,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)) @@ -9699,6 +9777,9 @@ void GameActions_RND() printf("::: Yo man! Rocks can fall!\n"); #endif +#if 1 + ResetGfxFrame(x, y, TRUE); +#else if (graphic_info[graphic].anim_global_sync) GfxFrame[x][y] = FrameCounter; else if (ANIM_MODE(graphic) == ANIM_CE_VALUE) @@ -9723,6 +9804,7 @@ void GameActions_RND() #endif DrawLevelGraphicAnimation(x, y, graphic); } +#endif if (ANIM_MODE(graphic) == ANIM_RANDOM && IS_NEXT_FRAME(GfxFrame[x][y], graphic))