From: Holger Schemel Date: Tue, 7 Mar 2017 22:46:19 +0000 (+0100) Subject: extended level flood fill function for variable array sizes X-Git-Tag: 4.1.0.0~174 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=d798911a09cd2a58ccb0378f4a94e6d44b3e0039;p=rocksndiamonds.git extended level flood fill function for variable array sizes --- diff --git a/src/tools.c b/src/tools.c index bfaad2ac..4f0206e3 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1377,9 +1377,10 @@ void SetBorderElement() } } -void FloodFillLevel(int from_x, int from_y, int fill_element, - short field[MAX_LEV_FIELDX][MAX_LEV_FIELDY], - int max_fieldx, int max_fieldy) +void FloodFillLevelExt(int from_x, int from_y, int fill_element, + int max_array_fieldx, int max_array_fieldy, + short field[max_array_fieldx][max_array_fieldy], + int max_fieldx, int max_fieldy) { int i,x,y; int old_element; @@ -1404,12 +1405,22 @@ void FloodFillLevel(int from_x, int from_y, int fill_element, y = from_y + check[i][1]; if (IN_FIELD(x, y, max_fieldx, max_fieldy) && field[x][y] == old_element) - FloodFillLevel(x, y, fill_element, field, max_fieldx, max_fieldy); + FloodFillLevelExt(x, y, fill_element, max_array_fieldx, max_array_fieldy, + field, max_fieldx, max_fieldy); } safety--; } +void FloodFillLevel(int from_x, int from_y, int fill_element, + short field[MAX_LEV_FIELDX][MAX_LEV_FIELDY], + int max_fieldx, int max_fieldy) +{ + FloodFillLevelExt(from_x, from_y, fill_element, + MAX_LEV_FIELDX, MAX_LEV_FIELDY, field, + max_fieldx, max_fieldy); +} + void SetRandomAnimationValue(int x, int y) { gfx.anim_random_frame = GfxRandom[x][y]; diff --git a/src/tools.h b/src/tools.h index 4f26f72e..b1f67434 100644 --- a/src/tools.h +++ b/src/tools.h @@ -119,8 +119,8 @@ void RedrawGlobalBorder(); void MarkTileDirty(int, int); void SetBorderElement(); -void FloodFillLevel(int, int, int, short[MAX_LEV_FIELDX][MAX_LEV_FIELDY], - int, int); +void FloodFillLevel(int, int, int, short[][MAX_LEV_FIELDY], int, int); +void FloodFillLevelExt(int, int, int, int, int y, short field[][y], int, int); void SetRandomAnimationValue(int, int); int getGraphicAnimationFrame(int, int);