From: Holger Schemel Date: Sat, 23 Aug 2003 14:59:40 +0000 (+0200) Subject: rnd-20030823-2-src X-Git-Tag: 3.0.3^2~14 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=80b3b0a5109b5678a9a921fcd1b4f7046e5e76d0;p=rocksndiamonds.git rnd-20030823-2-src --- diff --git a/CHANGES b/CHANGES index 3f2aa6d7..9ee229b4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ Release Version 3.0.3 [?? ??? ????] ----------------------------------- - - fixed bug (missing boundary check) which could crash the game + - fixed bug (missing array boundary check) which could crash the game + - fixed problem with setting mouse cursor in SDL version in fullscreen + - fixed problem with flickering when drawing toon animations Release Version 3.0.2 [22 AUG 2003] ----------------------------------- diff --git a/src/cartoons.c b/src/cartoons.c index 5bacdf29..e6892ebb 100644 --- a/src/cartoons.c +++ b/src/cartoons.c @@ -51,10 +51,16 @@ static void PrepareBackbuffer() boolean ToonNeedsRedraw() { +#if 1 + return TRUE; +#else return (game_status == GAME_MODE_INFO || + game_status == GAME_MODE_LEVELS || + game_status == GAME_MODE_SETUP || (game_status == GAME_MODE_MAIN && ((redraw_mask & REDRAW_MICROLEVEL) || (redraw_mask & REDRAW_MICROLABEL)))); +#endif } void InitToons() diff --git a/src/conftime.h b/src/conftime.h index a6529f2d..6f353088 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-08-23 14:29]" +#define COMPILE_DATE_STRING "[2003-08-23 16:57]" diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index d2af524a..7b704120 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -22,6 +22,7 @@ /* values for DrawGadget() */ #define DG_UNPRESSED 0 #define DG_PRESSED 1 + #define DG_BUFFERED 0 #define DG_DIRECT 1 @@ -590,6 +591,12 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) gi->active = (boolean)va_arg(ap, int); break; + case GDI_DIRECT_DRAW: + /* take care here: "boolean" is typedef'ed as "unsigned char", + which gets promoted to "int" */ + gi->direct_draw = (boolean)va_arg(ap, int); + break; + case GDI_CHECKED: /* take care here: "boolean" is typedef'ed as "unsigned char", which gets promoted to "int" */ @@ -923,7 +930,7 @@ void ModifyGadget(struct GadgetInfo *gi, int first_tag, ...) void RedrawGadget(struct GadgetInfo *gi) { if (gi->mapped) - DrawGadget(gi, gi->state, DG_DIRECT); + DrawGadget(gi, gi->state, gi->direct_draw); } struct GadgetInfo *CreateGadget(int first_tag, ...) @@ -936,6 +943,8 @@ struct GadgetInfo *CreateGadget(int first_tag, ...) new_gadget->callback_info = default_callback_info; new_gadget->callback_action = default_callback_action; new_gadget->active = TRUE; + new_gadget->direct_draw = TRUE; + new_gadget->next = NULL; va_start(ap, first_tag); @@ -1170,13 +1179,13 @@ void HandleGadgets(int mx, int my, int button) gi->text.cursor_position = strlen(gi->text.value); if (gi->text.cursor_position != old_cursor_position) - DrawGadget(gi, DG_PRESSED, DG_DIRECT); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); } else { /* if mouse button pressed outside text input gadget, deactivate it */ CheckRangeOfNumericInputGadget(gi); - DrawGadget(gi, DG_UNPRESSED, DG_DIRECT); + DrawGadget(gi, DG_UNPRESSED, gi->direct_draw); gi->event.type = GD_EVENT_TEXT_LEAVING; @@ -1207,12 +1216,12 @@ void HandleGadgets(int mx, int my, int button) gi->selectbox.current_index = gi->selectbox.num_values - 1; if (gi->selectbox.current_index != old_index) - DrawGadget(gi, DG_PRESSED, DG_DIRECT); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); } else { /* if mouse button pressed outside selectbox gadget, deactivate it */ - DrawGadget(gi, DG_UNPRESSED, DG_DIRECT); + DrawGadget(gi, DG_UNPRESSED, gi->direct_draw); gi->event.type = GD_EVENT_TEXT_LEAVING; @@ -1312,7 +1321,7 @@ void HandleGadgets(int mx, int my, int button) gi->selectbox.current_index = gi->selectbox.num_values - 1; if (gi->selectbox.current_index != old_index) - DrawGadget(gi, DG_PRESSED, DG_DIRECT); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); } } @@ -1361,7 +1370,7 @@ void HandleGadgets(int mx, int my, int button) rgi != gi) { rgi->checked = FALSE; - DrawGadget(rgi, DG_UNPRESSED, DG_DIRECT); + DrawGadget(rgi, DG_UNPRESSED, rgi->direct_draw); } rgi = rgi->next; @@ -1431,7 +1440,7 @@ void HandleGadgets(int mx, int my, int button) } } - DrawGadget(gi, DG_PRESSED, DG_DIRECT); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); gi->state = GD_BUTTON_PRESSED; gi->event.type = GD_EVENT_PRESSED; @@ -1459,9 +1468,9 @@ void HandleGadgets(int mx, int my, int button) if (gi->type & GD_TYPE_BUTTON) { if (gadget_moving_inside && gi->state == GD_BUTTON_UNPRESSED) - DrawGadget(gi, DG_PRESSED, DG_DIRECT); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); else if (gadget_moving_off_borders && gi->state == GD_BUTTON_PRESSED) - DrawGadget(gi, DG_UNPRESSED, DG_DIRECT); + DrawGadget(gi, DG_UNPRESSED, gi->direct_draw); } else if (gi->type & GD_TYPE_SELECTBOX) { @@ -1478,7 +1487,7 @@ void HandleGadgets(int mx, int my, int button) gi->selectbox.current_index = gi->selectbox.num_values - 1; if (gi->selectbox.current_index != old_index) - DrawGadget(gi, DG_PRESSED, DG_DIRECT); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); } else if (gi->type & GD_TYPE_SCROLLBAR) { @@ -1506,7 +1515,7 @@ void HandleGadgets(int mx, int my, int button) changed_position = TRUE; } - DrawGadget(gi, DG_PRESSED, DG_DIRECT); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); } gi->state = (gadget_moving_inside || gi->type & GD_TYPE_SCROLLBAR ? @@ -1534,7 +1543,7 @@ void HandleGadgets(int mx, int my, int button) if (deactivate_gadget && !(gi->type & GD_TYPE_TEXTINPUT)) /* text input stays open */ - DrawGadget(gi, DG_UNPRESSED, DG_DIRECT); + DrawGadget(gi, DG_UNPRESSED, gi->direct_draw); gi->state = GD_BUTTON_UNPRESSED; gi->event.type = GD_EVENT_RELEASED; @@ -1546,7 +1555,7 @@ void HandleGadgets(int mx, int my, int button) if (gadget_released_off_borders) { if (gi->type & GD_TYPE_SCROLLBAR) - DrawGadget(gi, DG_UNPRESSED, DG_DIRECT); + DrawGadget(gi, DG_UNPRESSED, gi->direct_draw); gi->event.type = GD_EVENT_RELEASED; @@ -1575,7 +1584,7 @@ void HandleGadgetsKeyInput(Key key) else if (gi->type & GD_TYPE_SELECTBOX) gi->selectbox.index = gi->selectbox.current_index; - DrawGadget(gi, DG_UNPRESSED, DG_DIRECT); + DrawGadget(gi, DG_UNPRESSED, gi->direct_draw); gi->event.type = GD_EVENT_TEXT_RETURN; @@ -1601,30 +1610,30 @@ void HandleGadgetsKeyInput(Key key) gi->text.value[cursor_pos] = letter; gi->text.cursor_position++; - DrawGadget(gi, DG_PRESSED, DG_DIRECT); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); } else if (key == KSYM_Left && cursor_pos > 0) { gi->text.cursor_position--; - DrawGadget(gi, DG_PRESSED, DG_DIRECT); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); } else if (key == KSYM_Right && cursor_pos < text_length) { gi->text.cursor_position++; - DrawGadget(gi, DG_PRESSED, DG_DIRECT); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); } else if (key == KSYM_BackSpace && cursor_pos > 0) { strcpy(text, gi->text.value); strcpy(&gi->text.value[cursor_pos - 1], &text[cursor_pos]); gi->text.cursor_position--; - DrawGadget(gi, DG_PRESSED, DG_DIRECT); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); } else if (key == KSYM_Delete && cursor_pos < text_length) { strcpy(text, gi->text.value); strcpy(&gi->text.value[cursor_pos], &text[cursor_pos + 1]); - DrawGadget(gi, DG_PRESSED, DG_DIRECT); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); } } else if (gi->type & GD_TYPE_SELECTBOX) /* only valid for selectbox */ @@ -1635,12 +1644,12 @@ void HandleGadgetsKeyInput(Key key) if (key == KSYM_Up && index > 0) { gi->selectbox.current_index--; - DrawGadget(gi, DG_PRESSED, DG_DIRECT); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); } else if (key == KSYM_Down && index < num_values - 1) { gi->selectbox.current_index++; - DrawGadget(gi, DG_PRESSED, DG_DIRECT); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); } } } diff --git a/src/libgame/gadgets.h b/src/libgame/gadgets.h index 0bf8cc5a..e486a2b7 100644 --- a/src/libgame/gadgets.h +++ b/src/libgame/gadgets.h @@ -102,6 +102,7 @@ #define GDI_SCROLLBAR_ITEM_POSITION 39 #define GDI_INFO_TEXT 40 #define GDI_ACTIVE 41 +#define GDI_DIRECT_DRAW 42 typedef void (*gadget_function)(void *); @@ -202,6 +203,7 @@ struct GadgetInfo int radio_nr; /* number of radio button series */ boolean mapped; /* gadget is mapped on the screen */ boolean active; /* gadget is active */ + boolean direct_draw; /* directly draw to frontbuffer */ int font; /* font to use when inactive */ int font_active; /* font to use when active */ struct GadgetBorder border; /* gadget border design */ diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 95ef6eef..74123228 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -1277,19 +1277,26 @@ static SDL_Cursor *create_cursor(struct MouseCursorInfo *cursor_info) void SDLSetMouseCursor(struct MouseCursorInfo *cursor_info) { static struct MouseCursorInfo *last_cursor_info = NULL; + static struct MouseCursorInfo *last_cursor_info2 = NULL; static SDL_Cursor *cursor_default = NULL; static SDL_Cursor *cursor_current = NULL; + /* if invoked for the first time, store the SDL default cursor */ if (cursor_default == NULL) cursor_default = SDL_GetCursor(); + /* only create new cursor if cursor info (custom only) has changed */ if (cursor_info != NULL && cursor_info != last_cursor_info) { cursor_current = create_cursor(cursor_info); last_cursor_info = cursor_info; } - SDL_SetCursor(cursor_info ? cursor_current : cursor_default); + /* only set new cursor if cursor info (custom or NULL) has changed */ + if (cursor_info != last_cursor_info2) + SDL_SetCursor(cursor_info ? cursor_current : cursor_default); + + last_cursor_info2 = cursor_info; } diff --git a/src/libgame/toons.c b/src/libgame/toons.c index 01229f01..f2684b40 100644 --- a/src/libgame/toons.c +++ b/src/libgame/toons.c @@ -310,6 +310,7 @@ void HandleAnimation(int mode) { static unsigned long animstart_delay = -1; static unsigned long animstart_delay_value = 0; + static boolean anim_running = FALSE; static boolean anim_restart = TRUE; static boolean reset_delay = TRUE; static int toon_nr = 0; @@ -326,12 +327,17 @@ void HandleAnimation(int mode) { case ANIM_START: screen_info.prepare_backbuffer_function(); + + anim_running = TRUE; anim_restart = TRUE; reset_delay = TRUE; return; case ANIM_CONTINUE: + if (!anim_running) + return; + break; case ANIM_STOP: @@ -343,6 +349,8 @@ void HandleAnimation(int mode) screen_info.update_function(); setup.direct_draw = draw_mode; + anim_running = FALSE; + return; default: diff --git a/src/screens.c b/src/screens.c index b158d0db..2b13ad56 100644 --- a/src/screens.c +++ b/src/screens.c @@ -472,8 +472,6 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } } - BackToFront(); - out: if (game_status == GAME_MODE_MAIN) @@ -481,6 +479,8 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE); DoAnimation(); } + + BackToFront(); } @@ -1131,10 +1131,9 @@ void HandleHelpScreen(int button) #else PlaySound_Menu_Continue(SND_BACKGROUND_INFO); #endif - - DoAnimation(); } + DoAnimation(); BackToFront(); } @@ -1537,10 +1536,12 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, } } - BackToFront(); - +#if 0 if (game_status == GAME_MODE_LEVELS || game_status == GAME_MODE_SETUP) DoAnimation(); + + BackToFront(); +#endif } void DrawChooseLevel() @@ -1553,6 +1554,9 @@ void DrawChooseLevel() void HandleChooseLevel(int mx, int my, int dx, int dy, int button) { HandleChooseTree(mx, my, dx, dy, button, &leveldir_current); + + DoAnimation(); + BackToFront(); } void DrawHallOfFame(int highlight_position) @@ -1606,6 +1610,8 @@ static void drawHallOfFameList(int first_entry, int highlight_position) DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2); DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4); } + + redraw_mask |= REDRAW_FIELD; } void HandleHallOfFame(int mx, int my, int dx, int dy, int button) @@ -1636,8 +1642,6 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) first_entry = 0; drawHallOfFameList(first_entry, highlight_position); - - return; } } else if (dy > 0) @@ -1649,27 +1653,22 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN); drawHallOfFameList(first_entry, highlight_position); - - return; } } - - if (button_released) + else if (button_released) { FadeSound(SND_BACKGROUND_SCORES); game_status = GAME_MODE_MAIN; DrawMainMenu(); } - BackToFront(); - - if (game_status == GAME_MODE_SCORES) - { - DoAnimation(); #if 1 + if (game_status == GAME_MODE_SCORES) PlaySound_Menu_Continue(SND_BACKGROUND_SCORES); #endif - } + + DoAnimation(); + BackToFront(); } @@ -1914,8 +1913,8 @@ static Key getSetupKey() } } - BackToFront(); DoAnimation(); + BackToFront(); /* don't eat all CPU time */ Delay(10); @@ -2163,10 +2162,12 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) } } +#if 0 BackToFront(); if (game_status == GAME_MODE_SETUP) DoAnimation(); +#endif } void DrawSetupScreen_Input() @@ -2343,7 +2344,11 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button) static unsigned long delay = 0; if (!DelayReached(&delay, GADGET_FRAME_DELAY)) +#if 1 + return; +#else goto out; +#endif player_nr = (player_nr + (x == 10 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS; @@ -2407,12 +2412,14 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button) } } +#if 0 BackToFront(); out: if (game_status == GAME_MODE_SETUP) DoAnimation(); +#endif } void CustomizeKeyboard(int player_nr) @@ -2530,8 +2537,8 @@ void CustomizeKeyboard(int player_nr) } } - BackToFront(); DoAnimation(); + BackToFront(); /* don't eat all CPU time */ Delay(10); @@ -2693,8 +2700,8 @@ static boolean CalibrateJoystickMain(int player_nr) } - BackToFront(); DoAnimation(); + BackToFront(); /* don't eat all CPU time */ Delay(10); @@ -2771,6 +2778,9 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current); else HandleSetupScreen_Generic(mx, my, dx, dy, button); + + DoAnimation(); + BackToFront(); } void HandleGameActions() @@ -2909,6 +2919,7 @@ static void CreateScreenScrollbuttons() GDI_STATE, GD_BUTTON_UNPRESSED, GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1, GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2, + GDI_DIRECT_DRAW, FALSE, GDI_EVENT_MASK, event_mask, GDI_CALLBACK_ACTION, HandleScreenGadgets, GDI_END); @@ -2985,6 +2996,7 @@ static void CreateScreenScrollbars() GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1, GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2, GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE, + GDI_DIRECT_DRAW, FALSE, GDI_EVENT_MASK, event_mask, GDI_CALLBACK_ACTION, HandleScreenGadgets, GDI_END);