From eb9477d8ca0dc4e571070fdb7b00f20ba2c43b56 Mon Sep 17 00:00:00 2001 From: Brad Harding Date: Sat, 9 Apr 2016 10:09:51 +1000 Subject: [PATCH] Miscellaneous tweaks --- src/m_misc.c | 2 +- src/m_misc.h | 2 +- src/r_patch.c | 56 ++++----------------------------------------------- 3 files changed, 6 insertions(+), 54 deletions(-) diff --git a/src/m_misc.c b/src/m_misc.c index aa3da97f67..c798c8dd86 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -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); diff --git a/src/m_misc.h b/src/m_misc.h index 636482d791..604bdb8aff 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -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); diff --git a/src/r_patch.c b/src/r_patch.c index 3b2187e8c0..2d64a4b3d4 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -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]; @@ -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; @@ -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]; @@ -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) {