@@ -1556,6 +1556,8 @@ TPT_INLINE int create_part(int p, int x, int y, int tv)//the function for creati
15561556int create_property (int x , int y , size_t propoffset , void * propvalue , int proptype )
15571557{
15581558 int i = pmap [y ][x ];
1559+ if (!i )
1560+ i = photons [y ][x ];
15591561 if (!propvalue )
15601562 return -1 ;
15611563 if (i & 0xFF )
@@ -3687,21 +3689,31 @@ void create_box(int x1, int y1, int x2, int y2, int c, int flags)
36873689 create_parts (i , j , 0 , 0 , c , flags , 1 );
36883690}
36893691
3692+ int FloodFillPmapCheck (int x , int y , int type )
3693+ {
3694+ if (type == 0 )
3695+ return !pmap [y ][x ] && !photons [y ][x ];
3696+ if (ptypes [type ].properties & TYPE_ENERGY )
3697+ return (photons [y ][x ]& 0xFF ) == type ;
3698+ else
3699+ return (pmap [y ][x ]& 0xFF ) == type ;
3700+ }
3701+
36903702int flood_prop_2 (int x , int y , size_t propoffset , void * propvalue , int proptype , int parttype , char * bitmap )
36913703{
3692- int x1 , x2 , i , dy = 1 ;
3704+ int x1 , x2 , dy = 1 ;
36933705 x1 = x2 = x ;
36943706 while (x1 >=CELL )
36953707 {
3696- if (( pmap [ y ][ x1 - 1 ] & 0xFF ) != parttype || bitmap [(y * XRES )+ x1 - 1 ])
3708+ if (! FloodFillPmapCheck ( x1 - 1 , y , parttype ) || bitmap [(y * XRES )+ x1 - 1 ])
36973709 {
36983710 break ;
36993711 }
37003712 x1 -- ;
37013713 }
37023714 while (x2 < XRES - CELL )
37033715 {
3704- if (( pmap [ y ][ x2 + 1 ] & 0xFF ) != parttype || bitmap [(y * XRES )+ x2 + 1 ])
3716+ if (! FloodFillPmapCheck ( x2 + 1 , y , parttype ) || bitmap [(y * XRES )+ x2 + 1 ])
37053717 {
37063718 break ;
37073719 }
@@ -3714,12 +3726,12 @@ int flood_prop_2(int x, int y, size_t propoffset, void * propvalue, int proptype
37143726 }
37153727 if (y >=CELL + dy )
37163728 for (x = x1 ; x <=x2 ; x ++ )
3717- if (( pmap [ y - dy ][ x ] & 0xFF ) == parttype && !bitmap [((y - dy )* XRES )+ x ])
3729+ if (FloodFillPmapCheck ( x , y - dy , parttype ) && !bitmap [((y - dy )* XRES )+ x ])
37183730 if (!flood_prop_2 (x , y - dy , propoffset , propvalue , proptype , parttype , bitmap ))
37193731 return 0 ;
37203732 if (y < YRES - CELL - dy )
37213733 for (x = x1 ; x <=x2 ; x ++ )
3722- if (( pmap [ y + dy ][ x ] & 0xFF ) == parttype && !bitmap [((y + dy )* XRES )+ x ])
3734+ if (FloodFillPmapCheck ( x , y + dy , parttype ) && !bitmap [((y + dy )* XRES )+ x ])
37233735 if (!flood_prop_2 (x , y + dy , propoffset , propvalue , proptype , parttype , bitmap ))
37243736 return 0 ;
37253737 return 1 ;
@@ -3733,6 +3745,10 @@ int flood_prop(int x, int y, size_t propoffset, void * propvalue, int proptype)
37333745 return 0 ;
37343746 memset (bitmap , 0 , XRES * YRES );
37353747 r = pmap [y ][x ];
3748+ if (!r )
3749+ r = photons [y ][x ];
3750+ if (!r )
3751+ return 1 ;
37363752 flood_prop_2 (x , y , propoffset , propvalue , proptype , r & 0xFF , bitmap );
37373753 free (bitmap );
37383754 return 0 ;
@@ -3894,7 +3910,6 @@ int flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
38943910{
38953911 int c = fullc & 0xFF ;
38963912 int x1 , x2 , dy = (c < PT_NUM )?1 :CELL ;
3897- int co = c ;
38983913 int coord_stack_limit = XRES * YRES ;
38993914 unsigned short (* coord_stack )[2 ];
39003915 int coord_stack_size = 0 ;
@@ -3908,6 +3923,8 @@ int flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
39083923 if (c == 0 )
39093924 {
39103925 cm = pmap [y ][x ]& 0xFF ;
3926+ if (!cm )
3927+ cm = photons [y ][x ]& 0xFF ;
39113928 if (!cm )
39123929 {
39133930 c = fullc = WL_ERASE + 100 ; //Try to erase walls if there is no particle in this spot
@@ -3931,7 +3948,7 @@ int flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
39313948 bm = 0 ;
39323949 }
39333950
3934- if ((( pmap [ y ][ x ] & 0xFF ) != cm || bmap [y /CELL ][x /CELL ]!= bm ) || ( (flags & BRUSH_SPECIFIC_DELETE ) && cm != SLALT ))
3951+ if ((! FloodFillPmapCheck ( x , y , cm ) || bmap [y /CELL ][x /CELL ] != bm ) || ( (flags & BRUSH_SPECIFIC_DELETE ) && cm != SLALT ))
39353952 return 1 ;
39363953
39373954 coord_stack = (unsigned short (* )[2 ])malloc (sizeof (unsigned short )* 2 * coord_stack_limit );
@@ -3948,7 +3965,7 @@ int flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
39483965 // go left as far as possible
39493966 while (x1 >=CELL )
39503967 {
3951- if (( pmap [ y ][ x1 - 1 ] & 0xFF ) != cm || bmap [y /CELL ][(x1 - 1 )/CELL ]!= bm )
3968+ if (! FloodFillPmapCheck ( x1 - 1 , y , cm ) || bmap [y /CELL ][(x1 - 1 )/CELL ]!= bm )
39523969 {
39533970 break ;
39543971 }
@@ -3957,7 +3974,7 @@ int flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
39573974 // go right as far as possible
39583975 while (x2 < XRES - CELL )
39593976 {
3960- if (( pmap [ y ][ x2 + 1 ] & 0xFF ) != cm || bmap [y /CELL ][(x2 + 1 )/CELL ]!= bm )
3977+ if (! FloodFillPmapCheck ( x2 + 1 , y , cm ) || bmap [y /CELL ][(x2 + 1 )/CELL ]!= bm )
39613978 {
39623979 break ;
39633980 }
@@ -3973,7 +3990,7 @@ int flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
39733990 // add vertically adjacent pixels to stack
39743991 if (y >=CELL + dy )
39753992 for (x = x1 ; x <=x2 ; x ++ )
3976- if (( pmap [ y - dy ][ x ] & 0xFF ) == cm && bmap [(y - dy )/CELL ][x /CELL ]== bm )
3993+ if (FloodFillPmapCheck ( x , y - dy , cm ) && bmap [(y - dy )/CELL ][x /CELL ]== bm )
39773994 {
39783995 coord_stack [coord_stack_size ][0 ] = x ;
39793996 coord_stack [coord_stack_size ][1 ] = y - dy ;
@@ -3986,7 +4003,7 @@ int flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
39864003 }
39874004 if (y < YRES - CELL - dy )
39884005 for (x = x1 ; x <=x2 ; x ++ )
3989- if (( pmap [ y + dy ][ x ] & 0xFF ) == cm && bmap [(y + dy )/CELL ][x /CELL ]== bm )
4006+ if (FloodFillPmapCheck ( x , y + dy , cm ) && bmap [(y + dy )/CELL ][x /CELL ]== bm )
39904007 {
39914008 coord_stack [coord_stack_size ][0 ] = x ;
39924009 coord_stack [coord_stack_size ][1 ] = y + dy ;
0 commit comments