X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ftools.c;h=f81ff9d90f210075e712ccb9fde88baba9ae558d;hp=82a58803ca3e15e0fb5da15a04984339c6c257c6;hb=1f8fd7a79343ce670dc62fcb8be48ba78d0c9199;hpb=115ce6f2da1914d68b0fe0e5f9082973190dacdd diff --git a/src/tools.c b/src/tools.c index 82a58803..f81ff9d9 100644 --- a/src/tools.c +++ b/src/tools.c @@ -711,7 +711,7 @@ void BlitScreenToBitmap(Bitmap *target_bitmap) redraw_mask |= REDRAW_FIELD; } -void DrawFramesPerSecond(void) +static void DrawFramesPerSecond(void) { char text[100]; int font_nr = FONT_TEXT_2; @@ -1147,7 +1147,7 @@ void FadeSkipNextFadeOut(void) FadeExt(0, FADE_MODE_SKIP_FADE_OUT, FADE_TYPE_SKIP); } -Bitmap *getBitmapFromGraphicOrDefault(int graphic, int default_graphic) +static Bitmap *getBitmapFromGraphicOrDefault(int graphic, int default_graphic) { boolean redefined = getImageListEntryFromImageID(graphic)->redefined; @@ -1157,12 +1157,12 @@ Bitmap *getBitmapFromGraphicOrDefault(int graphic, int default_graphic) graphic_info[default_graphic].bitmap); } -Bitmap *getBackgroundBitmap(int graphic) +static Bitmap *getBackgroundBitmap(int graphic) { return getBitmapFromGraphicOrDefault(graphic, IMG_BACKGROUND); } -Bitmap *getGlobalBorderBitmap(int graphic) +static Bitmap *getGlobalBorderBitmap(int graphic) { return getBitmapFromGraphicOrDefault(graphic, IMG_GLOBAL_BORDER); } @@ -1282,7 +1282,10 @@ boolean CheckIfGlobalBorderHasChanged(void) return (global_border_bitmap_last != global_border_bitmap); } -boolean CheckIfGlobalBorderRedrawIsNeeded(void) +#define ONLY_REDRAW_GLOBAL_BORDER_IF_NEEDED 0 + +#if ONLY_REDRAW_GLOBAL_BORDER_IF_NEEDED +static boolean CheckIfGlobalBorderRedrawIsNeeded(void) { // if game status has not changed, nothing has to be redrawn if (game_status == game_status_last) @@ -1318,8 +1321,9 @@ boolean CheckIfGlobalBorderRedrawIsNeeded(void) return FALSE; } +#endif -void RedrawGlobalBorderFromBitmap(Bitmap *bitmap) +static void RedrawGlobalBorderFromBitmap(Bitmap *bitmap) { if (bitmap) BlitBitmap(bitmap, backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0); @@ -1336,8 +1340,6 @@ void RedrawGlobalBorder(void) redraw_mask = REDRAW_ALL; } -#define ONLY_REDRAW_GLOBAL_BORDER_IF_NEEDED 0 - static void RedrawGlobalBorderIfNeeded(void) { #if ONLY_REDRAW_GLOBAL_BORDER_IF_NEEDED @@ -1608,8 +1610,8 @@ void getMiniGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) getSizedGraphicSource(graphic, 0, MINI_TILESIZE, bitmap, x, y); } -inline static void getGraphicSourceExt(int graphic, int frame, Bitmap **bitmap, - int *x, int *y, boolean get_backside) +static void getGraphicSourceExt(int graphic, int frame, Bitmap **bitmap, + int *x, int *y, boolean get_backside) { getSizedGraphicSourceExt(graphic, frame, TILESIZE_VAR, bitmap, x, y, get_backside); @@ -1781,9 +1783,9 @@ void DrawMiniGraphicExt(DrawBuffer *d, int x, int y, int graphic) BlitBitmap(src_bitmap, d, src_x, src_y, MINI_TILEX, MINI_TILEY, x, y); } -inline static void DrawGraphicShiftedNormal(int x, int y, int dx, int dy, - int graphic, int frame, - int cut_mode, int mask_mode) +static void DrawGraphicShiftedNormal(int x, int y, int dx, int dy, + int graphic, int frame, + int cut_mode, int mask_mode) { Bitmap *src_bitmap; int src_x, src_y; @@ -1892,9 +1894,9 @@ inline static void DrawGraphicShiftedNormal(int x, int y, int dx, int dy, } } -inline static void DrawGraphicShiftedDouble(int x, int y, int dx, int dy, - int graphic, int frame, - int cut_mode, int mask_mode) +static void DrawGraphicShiftedDouble(int x, int y, int dx, int dy, + int graphic, int frame, + int cut_mode, int mask_mode) { Bitmap *src_bitmap; int src_x, src_y; @@ -1974,8 +1976,8 @@ static void DrawGraphicShifted(int x, int y, int dx, int dy, DrawGraphicShiftedNormal(x, y, dx, dy, graphic, frame, cut_mode,mask_mode); } -void DrawGraphicShiftedThruMask(int x, int y, int dx, int dy, int graphic, - int frame, int cut_mode) +static void DrawGraphicShiftedThruMask(int x, int y, int dx, int dy, + int graphic, int frame, int cut_mode) { DrawGraphicShifted(x, y, dx, dy, graphic, frame, cut_mode, USE_MASKING); } @@ -2627,15 +2629,15 @@ void DrawSizedWallParts_MM(int x, int y, int element, int tilesize, element, tilesize, el2edimg, masked, element_bits_draw); } -void DrawSizedWall_MM(int dst_x, int dst_y, int element, int tilesize, - int (*el2img_function)(int)) +static void DrawSizedWall_MM(int dst_x, int dst_y, int element, int tilesize, + int (*el2img_function)(int)) { DrawSizedWallExt_MM(dst_x, dst_y, element, tilesize, el2img_function, FALSE, 0x000f); } -void DrawSizedElementExt(int x, int y, int element, int tilesize, - boolean masked) +static void DrawSizedElementExt(int x, int y, int element, int tilesize, + boolean masked) { if (IS_MM_WALL(element)) { @@ -2696,9 +2698,9 @@ void DrawMiniElementOrWall(int sx, int sy, int scroll_x, int scroll_y) DrawMiniGraphic(sx, sy, el2edimg(getBorderElement(x, y))); } -void DrawEnvelopeBackgroundTiles(int graphic, int startx, int starty, - int x, int y, int xsize, int ysize, - int tile_width, int tile_height) +static void DrawEnvelopeBackgroundTiles(int graphic, int startx, int starty, + int x, int y, int xsize, int ysize, + int tile_width, int tile_height) { Bitmap *src_bitmap; int src_x, src_y; @@ -2735,8 +2737,9 @@ void DrawEnvelopeBackgroundTiles(int graphic, int startx, int starty, dst_x, dst_y); } -void DrawEnvelopeBackground(int graphic, int startx, int starty, - int x, int y, int xsize, int ysize, int font_nr) +static void DrawEnvelopeBackground(int graphic, int startx, int starty, + int x, int y, int xsize, int ysize, + int font_nr) { int font_width = getFontWidth(font_nr); int font_height = getFontHeight(font_nr); @@ -2745,7 +2748,7 @@ void DrawEnvelopeBackground(int graphic, int startx, int starty, font_width, font_height); } -void AnimateEnvelope(int envelope_nr, int anim_mode, int action) +static void AnimateEnvelope(int envelope_nr, int anim_mode, int action) { int graphic = IMG_BACKGROUND_ENVELOPE_1 + envelope_nr; Bitmap *src_bitmap = graphic_info[graphic].bitmap; @@ -2917,7 +2920,7 @@ static void setRequestPosition(int *x, int *y, boolean add_border_size) setRequestPositionExt(x, y, request.width, request.height, add_border_size); } -void DrawEnvelopeRequest(char *text) +static void DrawEnvelopeRequest(char *text) { char *text_final = text; char *text_door_style = NULL; @@ -3004,7 +3007,7 @@ void DrawEnvelopeRequest(char *text) free(text_door_style); } -void AnimateEnvelopeRequest(int anim_mode, int action) +static void AnimateEnvelopeRequest(int anim_mode, int action) { int graphic = IMG_BACKGROUND_REQUEST; boolean draw_masked = graphic_info[graphic].draw_masked; @@ -3091,7 +3094,7 @@ void AnimateEnvelopeRequest(int anim_mode, int action) ClearAutoRepeatKeyEvents(); } -void ShowEnvelopeRequest(char *text, unsigned int req_state, int action) +static void ShowEnvelopeRequest(char *text, unsigned int req_state, int action) { int graphic = IMG_BACKGROUND_REQUEST; int sound_opening = SND_REQUEST_OPENING; @@ -3172,7 +3175,7 @@ void ShowEnvelopeRequest(char *text, unsigned int req_state, int action) SetDrawtoField(DRAW_TO_FIELDBUFFER); } -void DrawPreviewElement(int dst_x, int dst_y, int element, int tilesize) +static void DrawPreviewElement(int dst_x, int dst_y, int element, int tilesize) { if (IS_MM_WALL(element)) { @@ -3510,7 +3513,7 @@ static void DrawPreviewLevelExt(boolean restart) } } -void DrawPreviewPlayers(void) +static void DrawPreviewPlayers(void) { if (game_status != GAME_MODE_MAIN) return; @@ -3612,7 +3615,7 @@ static void DrawNetworkPlayer(int x, int y, int player_nr, int tile_size, DrawText(x + xoffset_text, y + yoffset_text, player_name, font_nr); } -void DrawNetworkPlayersExt(boolean force) +static void DrawNetworkPlayersExt(boolean force) { if (game_status != GAME_MODE_MAIN) return; @@ -3689,9 +3692,9 @@ void ClearNetworkPlayers(void) DrawNetworkPlayersExt(TRUE); } -inline static void DrawGraphicAnimationExt(DrawBuffer *dst_bitmap, int x, int y, - int graphic, int sync_frame, - int mask_mode) +static void DrawGraphicAnimationExt(DrawBuffer *dst_bitmap, int x, int y, + int graphic, int sync_frame, + int mask_mode) { int frame = getGraphicAnimationFrame(graphic, sync_frame); @@ -3712,7 +3715,7 @@ void DrawFixedGraphicAnimationExt(DrawBuffer *dst_bitmap, int x, int y, DrawFixedGraphicExt(dst_bitmap, x, y, graphic, frame); } -inline static void DrawGraphicAnimation(int x, int y, int graphic) +static void DrawGraphicAnimation(int x, int y, int graphic) { int lx = LEVELX(x), ly = LEVELY(y); @@ -4200,7 +4203,7 @@ void WaitForEventToContinue(void) { switch (event.type) { - case EVENT_BUTTONPRESS: + case EVENT_BUTTONRELEASE: case EVENT_KEYPRESS: #if defined(TARGET_SDL2) case SDL_CONTROLLERBUTTONDOWN: @@ -4233,13 +4236,19 @@ void WaitForEventToContinue(void) static int RequestHandleEvents(unsigned int req_state) { - boolean level_solved = (game_status == GAME_MODE_PLAYING && - local_player->LevelSolved_GameEnd); + boolean game_just_ended = (game_status == GAME_MODE_PLAYING && + checkGameEnded()); int width = request.width; int height = request.height; int sx, sy; int result; + /* when showing request dialog after game ended, deactivate game panel */ + if (game_just_ended) + game.panel.active = FALSE; + + game.request_active = TRUE; + setRequestPosition(&sx, &sy, FALSE); button_status = MB_RELEASED; @@ -4249,7 +4258,7 @@ static int RequestHandleEvents(unsigned int req_state) while (result < 0) { - if (level_solved) + if (game_just_ended) { /* the MM game engine does not use a special (scrollable) field buffer */ if (level.game_engine_type != GAME_ENGINE_TYPE_MM) @@ -4528,7 +4537,7 @@ static int RequestHandleEvents(unsigned int req_state) } } - if (level_solved) + if (game_just_ended) { if (global.use_envelope_request) { @@ -4540,6 +4549,8 @@ static int RequestHandleEvents(unsigned int req_state) BackToFront(); } + game.request_active = FALSE; + return result; } @@ -4552,7 +4563,7 @@ static boolean RequestDoor(char *text, unsigned int req_state) int result; int ty; - if (maxWordLengthInString(text) > MAX_REQUEST_LINE_FONT1_LEN) + if (maxWordLengthInRequestString(text) > MAX_REQUEST_LINE_FONT1_LEN) { max_request_line_len = MAX_REQUEST_LINE_FONT2_LEN; font_nr = FONT_TEXT_1; @@ -5070,7 +5081,7 @@ unsigned int SetDoorState(unsigned int door_state) return MoveDoor(door_state | DOOR_SET_STATE); } -int euclid(int a, int b) +static int euclid(int a, int b) { return (b ? euclid(b, a % b) : a); } @@ -8148,7 +8159,7 @@ unsigned int InitRND(int seed) static struct Mapping_EM_to_RND_object object_mapping[TILE_MAX]; static struct Mapping_EM_to_RND_player player_mapping[MAX_PLAYERS][SPR_MAX]; -inline static int get_effective_element_EM(int tile, int frame_em) +static int get_effective_element_EM(int tile, int frame_em) { int element = object_mapping[tile].element_rnd; int action = object_mapping[tile].action; @@ -8215,7 +8226,7 @@ inline static int get_effective_element_EM(int tile, int frame_em) } } -inline static boolean check_linear_animation_EM(int tile) +static boolean check_linear_animation_EM(int tile) { switch (tile) { @@ -8251,9 +8262,9 @@ inline static boolean check_linear_animation_EM(int tile) return FALSE; } -inline static void set_crumbled_graphics_EM(struct GraphicInfo_EM *g_em, - boolean has_crumbled_graphics, - int crumbled, int sync_frame) +static void set_crumbled_graphics_EM(struct GraphicInfo_EM *g_em, + boolean has_crumbled_graphics, + int crumbled, int sync_frame) { /* if element can be crumbled, but certain action graphics are just empty space (like instantly snapping sand to empty space in 1 frame), do not @@ -8290,10 +8301,12 @@ inline static void set_crumbled_graphics_EM(struct GraphicInfo_EM *g_em, } } +#if 0 void ResetGfxAnimation_EM(int x, int y, int tile) { GfxFrame[x][y] = 0; } +#endif void SetGfxAnimation_EM(struct GraphicInfo_EM *g_em, int tile, int frame_em, int x, int y) @@ -9039,10 +9052,10 @@ void InitGraphicInfo_EM(void) #endif } -void CheckSaveEngineSnapshot_EM(byte action[MAX_PLAYERS], int frame, - boolean any_player_moving, - boolean any_player_snapping, - boolean any_player_dropping) +static void CheckSaveEngineSnapshot_EM(byte action[MAX_PLAYERS], int frame, + boolean any_player_moving, + boolean any_player_snapping, + boolean any_player_dropping) { if (frame == 0 && !any_player_dropping) { @@ -9060,8 +9073,8 @@ void CheckSaveEngineSnapshot_EM(byte action[MAX_PLAYERS], int frame, } } -void CheckSaveEngineSnapshot_SP(boolean murphy_is_waiting, - boolean murphy_is_dropping) +static void CheckSaveEngineSnapshot_SP(boolean murphy_is_waiting, + boolean murphy_is_dropping) { if (murphy_is_waiting) { @@ -9079,8 +9092,8 @@ void CheckSaveEngineSnapshot_SP(boolean murphy_is_waiting, } } -void CheckSaveEngineSnapshot_MM(boolean element_clicked, - boolean button_released) +static void CheckSaveEngineSnapshot_MM(boolean element_clicked, + boolean button_released) { if (button_released) { @@ -9332,8 +9345,8 @@ void ToggleFullscreenOrChangeWindowScalingIfNeeded(void) } } -void JoinRectangles(int *x, int *y, int *width, int *height, - int x2, int y2, int width2, int height2) +static void JoinRectangles(int *x, int *y, int *width, int *height, + int x2, int y2, int width2, int height2) { // do not join with "off-screen" rectangle if (x2 == -1 || y2 == -1)