- Duke/RR: Fix remaining issues with drug mode.

* Primary issue was call to `renderSetAspect()` within `setdrugmode()` wasn't mulscaling with `viewingrange`.
* Changed `setdrugmode()` to `getdrugmode()` to return `p->drug_aspect`. This is so `renderSetAspect()` needs to only be called from one place only.
This commit is contained in:
Mitchell Richters 2020-11-06 20:52:43 +11:00
parent 4e6e564e14
commit c823e33bb3

View file

@ -311,7 +311,7 @@ void animatecamsprite(double smoothratio)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
int DrugTimer; int DrugTimer;
void setdrugmode(player_struct *p, int oyrepeat) static int getdrugmode(player_struct *p, int oyrepeat)
{ {
int now = I_GetBuildTime() >> 1; // this function works on a 60 fps setup. int now = I_GetBuildTime() >> 1; // this function works on a 60 fps setup.
if (playrunning() && p->DrugMode > 0) if (playrunning() && p->DrugMode > 0)
@ -345,6 +345,7 @@ void setdrugmode(player_struct *p, int oyrepeat)
p->drug_stat[0] = 0; p->drug_stat[0] = 0;
p->drug_stat[2] = 0; p->drug_stat[2] = 0;
p->drug_stat[1] = 0; p->drug_stat[1] = 0;
p->drug_aspect = oyrepeat;
} }
else else
{ {
@ -379,11 +380,12 @@ void setdrugmode(player_struct *p, int oyrepeat)
} }
} }
} }
return p->drug_aspect;
} }
else DrugTimer = now; else
if (p->DrugMode > 0)
{ {
renderSetAspect(p->drug_aspect, yxaspect); DrugTimer = now;
return oyrepeat;
} }
} }
@ -525,19 +527,11 @@ void displayrooms(int snum, double smoothratio)
renderDrawMasks(); renderDrawMasks();
} }
else else
{
int i = divscale22(1, isRR() ? 64 : p->GetActor()->s.yrepeat + 28);
fixed_t dang = IntToFixed(1024);
if (!isRRRA() || !p->DrugMode)
{ {
// Fixme: This should get the aspect ratio from the backend, not the current viewport size. // Fixme: This should get the aspect ratio from the backend, not the current viewport size.
int viewingRange = xs_CRoundToInt(double(i) * tan(r_fov * (pi::pi() / 360.))); int i = divscale22(1, isRR() ? 64 : p->GetActor()->s.yrepeat + 28);
renderSetAspect(mulscale16(viewingRange, viewingrange), yxaspect); int viewingaspect = !isRRRA() || !p->DrugMode ? xs_CRoundToInt(double(i) * tan(r_fov * (pi::pi() / 360.))) : getdrugmode(p, i);
} renderSetAspect(mulscale16(viewingaspect, viewingrange), yxaspect);
else
{
setdrugmode(p, i);
}
// The camera texture must be rendered with the base palette, so this is the only place where the current global palette can be set. // The camera texture must be rendered with the base palette, so this is the only place where the current global palette can be set.
// The setting here will be carried over to the rendering of the weapon sprites, but other 2D content will always default to the main palette. // The setting here will be carried over to the rendering of the weapon sprites, but other 2D content will always default to the main palette.