Skip to content

Commit

Permalink
fix automap background drawing/parallaxing
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiangreffrath committed Nov 27, 2023
1 parent 07b42b3 commit b15db45
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/heretic/am_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,7 @@ void AM_clearFB(int color)

for (i = 0; i < finit_height; i++)
{
#ifndef CRISPY_TRUECOLOR

Check warning on line 1121 in src/heretic/am_map.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

/src/heretic/am_map.c:1121:9 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]

Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11

Check warning on line 1121 in src/heretic/am_map.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

/src/heretic/am_map.c:1121:16 [bugprone-implicit-widening-of-multiplication-result]

result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t'
memcpy(I_VideoBuffer + i * finit_width,
maplump + j + (MAPBGROUNDWIDTH << crispy->hires) - x3, x3);

Expand All @@ -1126,7 +1127,30 @@ void AM_clearFB(int color)

memcpy(I_VideoBuffer + i * finit_width + x2 + x3,
maplump + j, x1);
#else
int z;
pixel_t *dest = I_VideoBuffer + i * finit_width;
byte *src = maplump + j + (MAPBGROUNDWIDTH << crispy->hires) - x3;

for (z = 0; z < x3; z++)
{
dest[z] = colormaps[src[z]];
}

dest += x3;
src += x3 - x2;
for (z = 0; z < x2; z++)
{
dest[z] = colormaps[src[z]];
}

dest += x2;
src = maplump + j;
for (z = 0; z < x1; z++)
{
dest[z] = colormaps[src[z]];

Check warning on line 1151 in src/heretic/am_map.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

/src/heretic/am_map.c:1151:53 [readability-braces-around-statements]

statement should be inside braces
}
#endif
j += MAPBGROUNDWIDTH << crispy->hires;
if (j >= MAPBGROUNDHEIGHT * MAPBGROUNDWIDTH)
j = 0;
Expand Down

0 comments on commit b15db45

Please sign in to comment.