From b04118032ee1b0ee6e03ee3293543e7155fe73ed Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 1 Nov 2016 22:58:53 +0100 Subject: [PATCH 1/5] Fix wrapping and scaling issue for the U texture coordinate for sprites --- src/r_things.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index cad434fa5c..6ef4e8027a 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -954,15 +954,14 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor return; tx += tex->GetWidth() * thingxscalemul; - double dtx2 = tx * xscale; - x2 = centerx + xs_RoundToInt(dtx2); + x2 = centerx + xs_RoundToInt(tx * xscale); // off the left side or too small? if ((x2 < WindowLeft || x2 <= x1)) return; xscale = spriteScale.X * xscale / tex->Scale.X; - iscale = (fixed_t)(tex->GetWidth() / (dtx2 - dtx1) * FRACUNIT); + iscale = (fixed_t)(FRACUNIT / xscale); // Round towards zero to avoid wrapping in edge cases double yscale = spriteScale.Y / tex->Scale.Y; @@ -990,7 +989,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor vis->xiscale = iscale; } - vis->startfrac += (fixed_t)(vis->xiscale * (vis->x1 - centerx - dtx1 + 0.5 * thingxscalemul)); + vis->startfrac += (fixed_t)(vis->xiscale * (vis->x1 - centerx + 0.5 - dtx1)); } else { From 4b4d7a07685c5cbf752db9c9b8df4b1a8015d37d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 4 Nov 2016 02:03:23 +0100 Subject: [PATCH 2/5] Add texturefrac bounds clamping to R_DrawMaskedColumn to avoid buffer overruns --- src/r_things.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/r_things.cpp b/src/r_things.cpp index 6ef4e8027a..e7d130fa85 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -281,6 +281,15 @@ void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span, bool us dc_source = column; dc_dest = (ylookup[dc_yl] + dc_x) + dc_destorg; dc_count = dc_yh - dc_yl + 1; + + fixed_t maxfrac = ((top + length) << FRACBITS) - 1; + dc_texturefrac = MAX(dc_texturefrac, 0); + dc_texturefrac = MIN(dc_texturefrac, maxfrac); + if (dc_iscale > 0) + dc_count = MIN(dc_count, (maxfrac - dc_texturefrac + dc_iscale - 1) / dc_iscale); + else if (dc_iscale < 0) + dc_count = MIN(dc_count, (dc_texturefrac - dc_iscale) / (-dc_iscale)); + if (useRt) hcolfunc_pre(); else From 7755a3525aeff2936baaad1d1d79ed89045186a4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 4 Nov 2016 11:17:22 +0100 Subject: [PATCH 3/5] - do not allow menu slider values very close to zero. They not only can produce a glitched number display but also some weird inconsistencies when operating a slider. --- src/menu/optionmenuitems.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/menu/optionmenuitems.h b/src/menu/optionmenuitems.h index 76718809e1..0fadeca374 100644 --- a/src/menu/optionmenuitems.h +++ b/src/menu/optionmenuitems.h @@ -671,6 +671,7 @@ public: { return FOptionMenuItem::MenuEvent(mkey, fromcontroller); } + if (fabs(value) < FLT_EPSILON) value = 0; SetSliderValue(clamp(value, mMin, mMax)); S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", snd_menuvolume, ATTN_NONE); return true; From 540f20882ee1a9827feec5ff7125cc1f8d9241b8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 4 Nov 2016 11:32:57 +0100 Subject: [PATCH 4/5] - fixed: Degeneration should use the same base health value as all the rest of the engine. - also replaced deh.MaxHealth in the bot code which was the only other remaining case where this was used as health limiter. --- src/b_think.cpp | 2 +- src/p_user.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/b_think.cpp b/src/b_think.cpp index 5a98b5c1ae..d097db8640 100644 --- a/src/b_think.cpp +++ b/src/b_think.cpp @@ -358,7 +358,7 @@ void DBot::WhatToGet (AActor *item) } else if ((typeis (Megasphere) || typeis (Soulsphere) || typeis (HealthBonus)) && player->mo->health >= deh.MaxSoulsphere) return; - else if (item->IsKindOf (RUNTIME_CLASS(AHealth)) && player->mo->health >= deh.MaxHealth /*MAXHEALTH*/) + else if (item->IsKindOf (RUNTIME_CLASS(AHealth)) && player->mo->health >= player->mo->GetMaxHealth() + player->mo->stamina) return; if ((dest == NULL || diff --git a/src/p_user.cpp b/src/p_user.cpp index b7bd4c2ec4..4a15e7f180 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2677,10 +2677,11 @@ void P_PlayerThink (player_t *player) // Apply degeneration. if (dmflags2 & DF2_YES_DEGENERATION) { - if ((level.time % TICRATE) == 0 && player->health > deh.MaxHealth) + int maxhealth = player->mo->GetMaxHealth() + player->mo->stamina; + if ((level.time % TICRATE) == 0 && player->health > maxhealth) { - if (player->health - 5 < deh.MaxHealth) - player->health = deh.MaxHealth; + if (player->health - 5 < maxhealth) + player->health = maxhealth; else player->health--; From faea61cf0177832ff668b1c07bb24c9064c33104 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 4 Nov 2016 12:43:23 +0100 Subject: [PATCH 5/5] - fixed: Turbo messages were printed, even when no turbo mode was active. --- src/g_game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index ec79d59e60..810a29da10 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1172,7 +1172,7 @@ void G_Ticker () } // check for turbo cheats - if (cmd->ucmd.forwardmove > TURBOTHRESHOLD && + if (turbo > 100.f && cmd->ucmd.forwardmove > TURBOTHRESHOLD && !(gametic&31) && ((gametic>>5)&(MAXPLAYERS-1)) == i ) { Printf ("%s is turbo!\n", players[i].userinfo.GetName());