Backport (and fix) SDL-agnostic SDL_TimerID check to SDL2.0 branch

This commit is contained in:
Bill Kendrick 2022-05-19 01:18:54 -07:00
parent dfba73d327
commit 91a37acf1a

View file

@ -2371,10 +2371,16 @@ int shape_reverse;
on_screen_keyboard *new_kbd;
SDL_Rect kbd_rect;
#if (SDL_MAJOR_VERSION < 2)
#define TIMERID_NONE NULL
#else
#define TIMERID_NONE 0
#endif
int brushflag, xnew, ynew, eraflag, lineflag, magicflag, keybd_flag, keybd_position, keyglobal, initial_y, gen_key_flag,
ide, activeflag, old_x, old_y;
int cur_thing;
SDL_TimerID scrolltimer_dialog = 0; /* Used by Open, Open->Slideshow, and New dialogs */
SDL_TimerID scrolltimer_dialog = TIMERID_NONE; /* Used by Open, Open->Slideshow, and New dialogs */
Uint32 TP_SDL_MOUSEBUTTONSCROLL;
/**
* --- MAIN LOOP! ---
@ -2403,7 +2409,7 @@ static void mainloop(void)
#endif
TP_SDL_MOUSEBUTTONSCROLL = SDL_RegisterEvents(1);
SDL_TimerID scrolltimer_selector = 0, scrolltimer_tool = 0;
SDL_TimerID scrolltimer_selector = TIMERID_NONE, scrolltimer_tool = TIMERID_NONE;
SDL_Event event;
SDLKey key;
SDLMod mod;
@ -2436,11 +2442,11 @@ static void mainloop(void)
last_cursor_blink = cur_toggle_count = 0;
texttool_len = 0;
scrolling_selector = 0;
scrolltimer_selector = 0;
scrolltimer_selector = TIMERID_NONE;
scrolling_tool = 0;
scrolltimer_tool = 0;
scrolltimer_tool = TIMERID_NONE;
scrolling_dialog = 0;
scrolltimer_dialog = 0;
scrolltimer_dialog = TIMERID_NONE;
val_x = 0;
val_y = 0;
valhat_x = 0;
@ -4571,10 +4577,10 @@ static void mainloop(void)
do_draw = 1;
playsound(screen, 1, SND_SCROLL, 1, SNDPOS_RIGHT, SNDDIST_NEAR);
if (scrolltimer_selector != 0)
if (scrolltimer_selector != TIMERID_NONE)
{
SDL_RemoveTimer(scrolltimer_selector);
scrolltimer_selector = 0;
scrolltimer_selector = TIMERID_NONE;
}
if (!scrolling_selector && event.type == SDL_MOUSEBUTTONDOWN)
@ -4607,10 +4613,10 @@ static void mainloop(void)
do_setcursor(cursor_arrow);
if (scrolling_selector)
{
if (scrolltimer_selector != 0)
if (scrolltimer_selector != TIMERID_NONE)
{
SDL_RemoveTimer(scrolltimer_selector);
scrolltimer_selector = 0;
scrolltimer_selector = TIMERID_NONE;
}
scrolling_selector = 0;
SDL_QuitSubSystem(SDL_INIT_TIMER);
@ -5622,10 +5628,10 @@ static void mainloop(void)
{
if (scrolling_selector)
{
if (scrolltimer_selector != 0)
if (scrolltimer_selector != TIMERID_NONE)
{
SDL_RemoveTimer(scrolltimer_selector);
scrolltimer_selector = 0;
scrolltimer_selector = TIMERID_NONE;
}
scrolling_selector = 0;
SDL_QuitSubSystem(SDL_INIT_TIMER);
@ -5635,10 +5641,10 @@ static void mainloop(void)
else if (scrolling_tool)
{
if (scrolltimer_tool != 0)
if (scrolltimer_tool != TIMERID_NONE)
{
SDL_RemoveTimer(scrolltimer_tool);
scrolltimer_tool = 0;
scrolltimer_tool = TIMERID_NONE;
}
scrolling_tool = 0;
SDL_QuitSubSystem(SDL_INIT_TIMER);
@ -16480,10 +16486,10 @@ static int do_open(void)
which = which + 4;
}
if (scrolltimer_dialog != 0)
if (scrolltimer_dialog != TIMERID_NONE)
{
SDL_RemoveTimer(scrolltimer_dialog);
scrolltimer_dialog = 0;
scrolltimer_dialog = TIMERID_NONE;
}
if (!scrolling_dialog && event.type == SDL_MOUSEBUTTONDOWN)
@ -16663,10 +16669,10 @@ static int do_open(void)
#endif
if (scrolling_dialog)
{
if (scrolltimer_dialog != 0)
if (scrolltimer_dialog != TIMERID_NONE)
{
SDL_RemoveTimer(scrolltimer_dialog);
scrolltimer_dialog = 0;
scrolltimer_dialog = TIMERID_NONE;
}
scrolling_dialog = 0;
SDL_QuitSubSystem(SDL_INIT_TIMER);
@ -17574,10 +17580,10 @@ static int do_slideshow(void)
}
}
if (scrolltimer_dialog != 0)
if (scrolltimer_dialog != TIMERID_NONE)
{
SDL_RemoveTimer(scrolltimer_dialog);
scrolltimer_dialog = 0;
scrolltimer_dialog = TIMERID_NONE;
}
if (!scrolling_dialog && event.type == SDL_MOUSEBUTTONDOWN)
@ -17823,10 +17829,10 @@ static int do_slideshow(void)
if (scrolling_dialog)
{
if (scrolltimer_dialog != 0)
if (scrolltimer_dialog != TIMERID_NONE)
{
SDL_RemoveTimer(scrolltimer_dialog);
scrolltimer_dialog = 0;
scrolltimer_dialog = TIMERID_NONE;
}
scrolling_dialog = 0;
SDL_QuitSubSystem(SDL_INIT_TIMER);
@ -21698,10 +21704,10 @@ static int do_new_dialog(void)
which = which + 4;
}
if (scrolltimer_dialog != 0)
if (scrolltimer_dialog != TIMERID_NONE)
{
SDL_RemoveTimer(scrolltimer_dialog);
scrolltimer_dialog = 0;
scrolltimer_dialog = TIMERID_NONE;
}
if (!scrolling_dialog && event.type == SDL_MOUSEBUTTONDOWN)
@ -21849,10 +21855,10 @@ static int do_new_dialog(void)
if (scrolling_dialog)
{
if (scrolltimer_dialog != 0)
if (scrolltimer_dialog != TIMERID_NONE)
{
SDL_RemoveTimer(scrolltimer_dialog);
scrolltimer_dialog = 0;
scrolltimer_dialog = TIMERID_NONE;
}
scrolling_dialog = 0;
SDL_QuitSubSystem(SDL_INIT_TIMER);