@@ -58,19 +58,14 @@ static short STEP2;
58
58
59
59
static bool IsSolidAtSpot (const column_t * column , const int spot )
60
60
{
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 );
74
69
75
70
return false;
76
71
}
@@ -125,7 +120,7 @@ static void CreatePatch(int patchnum)
125
120
int postsdatasize ;
126
121
int datasize ;
127
122
int * numpostsincolumn ;
128
- int numpoststotal ;
123
+ int numpoststotal = 0 ;
129
124
const unsigned char * oldcolumnpixeldata ;
130
125
131
126
if (!CheckIfPatch (patchnum ))
@@ -150,8 +145,6 @@ static void CreatePatch(int patchnum)
150
145
pixeldatasize = ((patch -> width * patch -> height + 4 ) & ~3 );
151
146
columnsdatasize = patch -> width * sizeof (rcolumn_t );
152
147
153
- numpoststotal = 0 ;
154
-
155
148
for (int x = 0 ; x < patch -> width ; x ++ )
156
149
{
157
150
oldcolumn = (const column_t * )((const byte * )oldpatch + LONG (oldpatch -> columnoffset [x ]));
@@ -232,33 +225,26 @@ static void CreatePatch(int patchnum)
232
225
const rcolumn_t * column = R_GetPatchColumnClamped (patch , x );
233
226
const rcolumn_t * prevcolumn = R_GetPatchColumnClamped (patch , x - 1 );
234
227
228
+ // force the first pixel (which is a hole), to use
229
+ // the color from the next solid spot in the column
235
230
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
239
231
for (int y = 0 ; y < patch -> height ; y ++ )
240
232
if (column -> pixels [y ] != 0xFF )
241
233
{
242
234
column -> pixels [0 ] = column -> pixels [y ];
243
235
break ;
244
236
}
245
- }
246
237
247
238
// copy from above or to the left
248
239
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
+ }
262
248
}
263
249
264
250
W_ReleaseLumpNum (patchnum );
@@ -312,7 +298,7 @@ static void CreateTextureCompositePatch(const int id)
312
298
int columnsdatasize ;
313
299
int postsdatasize ;
314
300
int datasize ;
315
- int numpoststotal ;
301
+ int numpoststotal = 0 ;
316
302
const unsigned char * oldcolumnpixeldata ;
317
303
count_t * countsincolumn ;
318
304
@@ -328,7 +314,6 @@ static void CreateTextureCompositePatch(const int id)
328
314
329
315
// count the number of posts in each column
330
316
countsincolumn = (count_t * )calloc (compositepatch -> width , sizeof (count_t ));
331
- numpoststotal = 0 ;
332
317
333
318
for (int i = 0 ; i < texture -> patchcount ; i ++ )
334
319
{
@@ -520,30 +505,26 @@ static void CreateTextureCompositePatch(const int id)
520
505
const rcolumn_t * column = R_GetPatchColumnClamped (compositepatch , x );
521
506
const rcolumn_t * prevcolumn = R_GetPatchColumnClamped (compositepatch , x - 1 );
522
507
508
+ // force the first pixel (which is a hole), to use
509
+ // the color from the next solid spot in the column
523
510
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
527
511
for (int y = 0 ; y < compositepatch -> height ; y ++ )
528
512
if (column -> pixels [y ] != 0xFF )
529
513
{
530
514
column -> pixels [0 ] = column -> pixels [y ];
531
515
break ;
532
516
}
533
- }
534
517
535
518
// copy from above or to the left
536
519
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
+ }
547
528
}
548
529
549
530
free (countsincolumn );
0 commit comments