Skip to content

Commit

Permalink
Miscellaneous tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
bradharding committed Apr 9, 2016
1 parent 6c6cfc0 commit eb9477d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/m_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ char *M_TempFile(char *s)
return M_StringJoin(tempdir, DIR_SEPARATOR_S, s, NULL);
}

dboolean M_StrToInt(const char *str, int *result)
dboolean M_StrToInt(const char *str, unsigned int *result)
{
return (sscanf(str, " 0x%2x", result) == 1 || sscanf(str, " 0X%2x", result) == 1
|| sscanf(str, " 0%3o", result) == 1 || sscanf(str, " %10d", result) == 1);
Expand Down
2 changes: 1 addition & 1 deletion src/m_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ char *M_GetResourceFolder(void);
char *M_GetAppDataFolder(void);

char *M_GetExecutableFolder(void);
dboolean M_StrToInt(const char *str, int *result);
dboolean M_StrToInt(const char *str, unsigned int *result);
char *M_StrCaseStr(char *haystack, char *needle);
dboolean M_StringCopy(char *dest, char *src, size_t dest_size);
char *M_StringReplace(char *haystack, char *needle, char *replacement);
Expand Down
56 changes: 4 additions & 52 deletions src/r_patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,42 +278,10 @@ static void createPatch(int id)
numPostsUsedSoFar = 0;
for (x = 0; x < patch->width; ++x)
{
int top = -1;
const column_t *oldPrevColumn;
const column_t *oldNextColumn;
int top = -1;

oldColumn = (const column_t *)((const byte *)oldPatch + LONG(oldPatch->columnofs[x]));

if (patch->flags & PATCH_ISNOTTILEABLE)
{
// non-tiling
if (!x)
oldPrevColumn = 0;
else
oldPrevColumn = (const column_t *)((const byte *)oldPatch
+ LONG(oldPatch->columnofs[x - 1]));
if (x == patch->width - 1)
oldNextColumn = 0;
else
oldNextColumn = (const column_t *)((const byte *)oldPatch
+ LONG(oldPatch->columnofs[x + 1]));
}
else
{
// tiling
int prevColumnIndex = x - 1;
int nextColumnIndex = x + 1;

while (prevColumnIndex < 0)
prevColumnIndex += patch->width;
while (nextColumnIndex >= patch->width)
nextColumnIndex -= patch->width;
oldPrevColumn = (const column_t *)((const byte *)oldPatch
+ LONG(oldPatch->columnofs[prevColumnIndex]));
oldNextColumn = (const column_t *)((const byte *)oldPatch
+ LONG(oldPatch->columnofs[nextColumnIndex]));
}

// setup the column's data
patch->columns[x].pixels = patch->pixels + x * patch->height;
patch->columns[x].numPosts = numPostsInColumn[x];
Expand Down Expand Up @@ -541,10 +509,8 @@ static void createTextureCompositePatch(int id)

for (x = 0; x < SHORT(oldPatch->width); ++x)
{
int top = -1;
int tx = texpatch->originx + x;
const column_t *oldPrevColumn;
const column_t *oldNextColumn;
int top = -1;
int tx = texpatch->originx + x;

if (tx < 0)
continue;
Expand All @@ -553,21 +519,6 @@ static void createTextureCompositePatch(int id)

oldColumn = (const column_t *)((const byte *)oldPatch + LONG(oldPatch->columnofs[x]));

{
// tiling
int prevColumnIndex = x - 1;
int nextColumnIndex = x + 1;

while (prevColumnIndex < 0)
prevColumnIndex += SHORT(oldPatch->width);
while (nextColumnIndex >= SHORT(oldPatch->width))
nextColumnIndex -= SHORT(oldPatch->width);
oldPrevColumn = (const column_t *)((const byte *)oldPatch
+ LONG(oldPatch->columnofs[prevColumnIndex]));
oldNextColumn = (const column_t *)((const byte *)oldPatch
+ LONG(oldPatch->columnofs[nextColumnIndex]));
}

while (oldColumn->topdelta != 0xFF)
{
rpost_t *post = &composite_patch->columns[tx].posts[countsInColumn[tx].posts_used];
Expand All @@ -581,6 +532,7 @@ static void createTextureCompositePatch(int id)
oldColumnPixelData = (const byte *)oldColumn + 3;
oy = texpatch->originy;
count = oldColumn->length;

// the original renderer had several bugs which we reproduce here
if (countsInColumn[tx].patches > 1)
{
Expand Down

0 comments on commit eb9477d

Please sign in to comment.