@@ -58,19 +58,14 @@ static short STEP2;
5858
5959static bool IsSolidAtSpot (const column_t * column , const int spot )
6060{
61- if (!column )
62- return false;
63-
64- while (column -> topdelta != 0xFF )
65- {
66- if (spot < column -> topdelta )
67- return false;
68-
69- if (spot <= column -> topdelta + column -> length )
70- return true;
71-
72- column = (const column_t * )((const byte * )column + 3 + column -> length + 1 );
73- }
61+ if (column )
62+ while (column -> topdelta != 0xFF )
63+ if (spot < column -> topdelta )
64+ return false;
65+ else if (spot <= column -> topdelta + column -> length )
66+ return true;
67+ else
68+ column = (const column_t * )((const byte * )column + 3 + column -> length + 1 );
7469
7570 return false;
7671}
@@ -125,7 +120,7 @@ static void CreatePatch(int patchnum)
125120 int postsdatasize ;
126121 int datasize ;
127122 int * numpostsincolumn ;
128- int numpoststotal ;
123+ int numpoststotal = 0 ;
129124 const unsigned char * oldcolumnpixeldata ;
130125
131126 if (!CheckIfPatch (patchnum ))
@@ -150,8 +145,6 @@ static void CreatePatch(int patchnum)
150145 pixeldatasize = ((patch -> width * patch -> height + 4 ) & ~3 );
151146 columnsdatasize = patch -> width * sizeof (rcolumn_t );
152147
153- numpoststotal = 0 ;
154-
155148 for (int x = 0 ; x < patch -> width ; x ++ )
156149 {
157150 oldcolumn = (const column_t * )((const byte * )oldpatch + LONG (oldpatch -> columnoffset [x ]));
@@ -232,33 +225,26 @@ static void CreatePatch(int patchnum)
232225 const rcolumn_t * column = R_GetPatchColumnClamped (patch , x );
233226 const rcolumn_t * prevcolumn = R_GetPatchColumnClamped (patch , x - 1 );
234227
228+ // force the first pixel (which is a hole), to use
229+ // the color from the next solid spot in the column
235230 if (column -> pixels [0 ] == 0xFF )
236- {
237- // force the first pixel (which is a hole), to use
238- // the color from the next solid spot in the column
239231 for (int y = 0 ; y < patch -> height ; y ++ )
240232 if (column -> pixels [y ] != 0xFF )
241233 {
242234 column -> pixels [0 ] = column -> pixels [y ];
243235 break ;
244236 }
245- }
246237
247238 // copy from above or to the left
248239 for (int y = 1 ; y < patch -> height ; y ++ )
249- {
250- if (IsSolidAtSpot (oldcolumn , y ))
251- continue ;
252-
253- if (column -> pixels [y ] != 0xFF )
254- continue ;
255-
256- // this pixel is a hole
257- if (x && prevcolumn -> pixels [y - 1 ] != 0xFF )
258- column -> pixels [y ] = prevcolumn -> pixels [y ]; // copy the color from the left
259- else
260- column -> pixels [y ] = column -> pixels [y - 1 ]; // copy the color from above
261- }
240+ if (!IsSolidAtSpot (oldcolumn , y ) && column -> pixels [y ] == 0xFF )
241+ {
242+ // this pixel is a hole
243+ if (x && prevcolumn -> pixels [y - 1 ] != 0xFF )
244+ column -> pixels [y ] = prevcolumn -> pixels [y ]; // copy the color from the left
245+ else
246+ column -> pixels [y ] = column -> pixels [y - 1 ]; // copy the color from above
247+ }
262248 }
263249
264250 W_ReleaseLumpNum (patchnum );
@@ -312,7 +298,7 @@ static void CreateTextureCompositePatch(const int id)
312298 int columnsdatasize ;
313299 int postsdatasize ;
314300 int datasize ;
315- int numpoststotal ;
301+ int numpoststotal = 0 ;
316302 const unsigned char * oldcolumnpixeldata ;
317303 count_t * countsincolumn ;
318304
@@ -328,7 +314,6 @@ static void CreateTextureCompositePatch(const int id)
328314
329315 // count the number of posts in each column
330316 countsincolumn = (count_t * )calloc (compositepatch -> width , sizeof (count_t ));
331- numpoststotal = 0 ;
332317
333318 for (int i = 0 ; i < texture -> patchcount ; i ++ )
334319 {
@@ -520,30 +505,26 @@ static void CreateTextureCompositePatch(const int id)
520505 const rcolumn_t * column = R_GetPatchColumnClamped (compositepatch , x );
521506 const rcolumn_t * prevcolumn = R_GetPatchColumnClamped (compositepatch , x - 1 );
522507
508+ // force the first pixel (which is a hole), to use
509+ // the color from the next solid spot in the column
523510 if (column -> pixels [0 ] == 0xFF )
524- {
525- // force the first pixel (which is a hole), to use
526- // the color from the next solid spot in the column
527511 for (int y = 0 ; y < compositepatch -> height ; y ++ )
528512 if (column -> pixels [y ] != 0xFF )
529513 {
530514 column -> pixels [0 ] = column -> pixels [y ];
531515 break ;
532516 }
533- }
534517
535518 // copy from above or to the left
536519 for (int y = 1 ; y < compositepatch -> height ; y ++ )
537- {
538- if (column -> pixels [y ] != 0xFF )
539- continue ;
540-
541- // this pixel is a hole
542- if (x && prevcolumn -> pixels [y - 1 ] != 0xFF )
543- column -> pixels [y ] = prevcolumn -> pixels [y ]; // copy the color from the left
544- else
545- column -> pixels [y ] = column -> pixels [y - 1 ]; // copy the color from above
546- }
520+ if (column -> pixels [y ] == 0xFF )
521+ {
522+ // this pixel is a hole
523+ if (x && prevcolumn -> pixels [y - 1 ] != 0xFF )
524+ column -> pixels [y ] = prevcolumn -> pixels [y ]; // copy the color from the left
525+ else
526+ column -> pixels [y ] = column -> pixels [y - 1 ]; // copy the color from above
527+ }
547528 }
548529
549530 free (countsincolumn );
0 commit comments