X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=627c77c61f842840eefe6ca162e4482776df9728;hb=9e5b242142cda73a8b1ae8ae52aa927999b5481d;hp=d00b01d46d74a5abd9ac177b1ae5ee62e91512c5;hpb=e89a21e95b3cb84d1515c0fb3378ce902a48c1c8;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index d00b01d4..627c77c6 100644 --- a/src/tools.c +++ b/src/tools.c @@ -165,6 +165,14 @@ static struct DoorPartControlInfo door_part_controls[] = } }; +static struct XY xy_topdown[] = +{ + { 0, -1 }, + { -1, 0 }, + { +1, 0 }, + { 0, +1 } +}; + // forward declaration for internal use static void UnmapToolButtons(void); @@ -767,7 +775,7 @@ void BackToFront(void) DrawFramesPerSecond(); // remove playfield redraw before potentially merging with doors redraw - if (DrawingDeactivated(REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE)) + if (DrawingDeactivated(REAL_SX, REAL_SY)) redraw_mask &= ~REDRAW_FIELD; // redraw complete window if both playfield and (some) doors need redraw @@ -1102,7 +1110,7 @@ static int getGlobalGameStatus(int status) status); } -static Bitmap *getBitmapFromGraphicOrDefault(int graphic, int default_graphic) +Bitmap *getBitmapFromGraphicOrDefault(int graphic, int default_graphic) { if (graphic == IMG_UNDEFINED) return NULL; @@ -1433,7 +1441,7 @@ void FloodFillLevelExt(int start_x, int start_y, int fill_element, int max_fieldx, int max_fieldy) { static struct XY stack_buffer[MAX_LEV_FIELDX * MAX_LEV_FIELDY]; - static struct XY check[4] = { { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 } }; + struct XY *check = xy_topdown; int old_element = field[start_x][start_y]; int stack_pos = 0; @@ -2293,13 +2301,7 @@ static void DrawLevelFieldCrumbledExt(int x, int y, int graphic, int frame) int sx = SCREENX(x), sy = SCREENY(y); int element; int i; - static int xy[4][2] = - { - { 0, -1 }, - { -1, 0 }, - { +1, 0 }, - { 0, +1 } - }; + struct XY *xy = xy_topdown; if (!IN_LEV_FIELD(x, y)) return; @@ -2314,8 +2316,8 @@ static void DrawLevelFieldCrumbledExt(int x, int y, int graphic, int frame) // crumble field borders towards direct neighbour fields for (i = 0; i < 4; i++) { - int xx = x + xy[i][0]; - int yy = y + xy[i][1]; + int xx = x + xy[i].x; + int yy = y + xy[i].y; element = (IN_LEV_FIELD(xx, yy) ? TILE_GFX_ELEMENT(xx, yy) : BorderElement); @@ -2349,10 +2351,10 @@ static void DrawLevelFieldCrumbledExt(int x, int y, int graphic, int frame) // crumble field borders of direct neighbour fields for (i = 0; i < 4; i++) { - int xx = x + xy[i][0]; - int yy = y + xy[i][1]; - int sxx = sx + xy[i][0]; - int syy = sy + xy[i][1]; + int xx = x + xy[i].x; + int yy = y + xy[i].y; + int sxx = sx + xy[i].x; + int syy = sy + xy[i].y; if (!IN_LEV_FIELD(xx, yy) || !IN_SCR_FIELD(sxx, syy)) @@ -2445,22 +2447,16 @@ void DrawLevelFieldCrumbledDigging(int x, int y, int direction, void DrawLevelFieldCrumbledNeighbours(int x, int y) { int sx = SCREENX(x), sy = SCREENY(y); - static int xy[4][2] = - { - { 0, -1 }, - { -1, 0 }, - { +1, 0 }, - { 0, +1 } - }; + struct XY *xy = xy_topdown; int i; // crumble direct neighbour fields (required for field borders) for (i = 0; i < 4; i++) { - int xx = x + xy[i][0]; - int yy = y + xy[i][1]; - int sxx = sx + xy[i][0]; - int syy = sy + xy[i][1]; + int xx = x + xy[i].x; + int yy = y + xy[i].y; + int sxx = sx + xy[i].x; + int syy = sy + xy[i].y; if (!IN_LEV_FIELD(xx, yy) || !IN_SCR_FIELD(sxx, syy) || @@ -4607,7 +4603,7 @@ static int RequestHandleEvents(unsigned int req_state, int draw_buffer_game) case EVENT_KEYPRESS: { - Key key = GetEventKey((KeyEvent *)&event, TRUE); + Key key = GetEventKey((KeyEvent *)&event); switch (key) { @@ -9968,7 +9964,13 @@ void ChangeViewportPropertiesIfNeeded(void) void OpenURL(char *url) { +#if SDL_VERSION_ATLEAST(2,0,14) SDL_OpenURL(url); +#else + Warn("SDL_OpenURL(\"%s\") not supported by SDL %d.%d.%d!", + url, SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL); + Warn("Please upgrade to at least SDL 2.0.14 for URL support!"); +#endif } void OpenURLFromHash(SetupFileHash *hash, int hash_key)