- floatification of g_shared.

- rewrote FraggleScript's movecamera function because it was utterly incomprehensible.
This commit is contained in:
Christoph Oelckers 2016-03-24 01:46:11 +01:00
parent 6557f3b8c8
commit 4a79602325
30 changed files with 283 additions and 418 deletions

View file

@ -957,10 +957,9 @@ void AM_StaticInit()
//
//=============================================================================
void AM_GetPosition(fixed_t &x, fixed_t &y)
DVector2 AM_GetPosition()
{
x = (m_x + m_w/2) << FRACTOMAPBITS;
y = (m_y + m_h/2) << FRACTOMAPBITS;
return DVector2((m_x + m_w / 2) / MAPUNIT, (m_y + m_h / 2) / MAPUNIT);
}
//=============================================================================

View file

@ -69,6 +69,7 @@
#include "farchive.h"
#include "p_setup.h"
#include "p_spec.h"
#include "r_utility.h"
#include "math/cmath.h"
static FRandom pr_script("FScript");
@ -1463,6 +1464,7 @@ void FParser::SF_SetCamera(void)
if (t_argc < 4) newcamera->Angles.Pitch = 0.;
else newcamera->Angles.Pitch = clamp(floatvalue(t_argv[3]), -50., 50.) * (20. / 32.);
player->camera=newcamera;
R_ResetViewInterpolation();
}
}
@ -3052,173 +3054,57 @@ void FParser::SF_SetWeapon()
//
// movecamera(camera, targetobj, targetheight, movespeed, targetangle, anglespeed)
//
// This has been completely rewritten in a sane fashion, using actual vector math.
//
//==========================================================================
void FParser::SF_MoveCamera(void)
{
fixed_t x, y, z;
fixed_t zdist, xydist, movespeed;
fixed_t xstep, ystep, zstep, targetheight;
angle_t anglespeed, anglestep, angledist, targetangle, bigangle, smallangle;
DAngle mobjangle;
// I have to use floats for the math where angles are divided
// by fixed values.
double fangledist, fanglestep, fmovestep;
int angledir;
AActor* target;
int moved;
int quad1, quad2;
AActor * cam;
angledir = moved = 0;
if (CheckArgs(6))
{
cam = actorvalue(t_argv[0]);
target = actorvalue(t_argv[1]);
if(!cam || !target)
AActor *cam = actorvalue(t_argv[0]);
AActor *target = actorvalue(t_argv[1]);
if(!cam || !target)
{
script_error("invalid target for camera\n"); return;
}
DVector2 fdist = cam->Vec2To(target);
fixed_t distx = FLOAT2FIXED(fdist.X);
fixed_t disty = FLOAT2FIXED(fdist.Y);
fixed_t camx = FLOAT2FIXED(cam->X());
fixed_t camy = FLOAT2FIXED(cam->Y());
fixed_t camz = FLOAT2FIXED(cam->Z());
double targetheight = floatvalue(t_argv[2]);
DVector3 campos = cam->Pos();
DVector3 targpos = DVector3(target->Pos(), targetheight);
if (campos != targpos)
{
DVector3 movement = targpos - campos;
double movelen = movement.Length();
double movespeed = floatvalue(t_argv[3]);
DVector3 movepos;
bool finished = (movespeed >= movelen);
if (finished) movepos = targpos;
else movepos = campos + movement.Resized(movespeed);
targetheight = fixedvalue(t_argv[2]);
movespeed = fixedvalue(t_argv[3]);
targetangle = (angle_t)FixedToAngle(fixedvalue(t_argv[4]));
anglespeed = (angle_t)FixedToAngle(fixedvalue(t_argv[5]));
// figure out how big one step will be
zdist = targetheight - camz;
// Angle checking...
// 90
// Q1|Q0
//180--+--0
// Q2|Q3
// 270
angle_t camangle = cam->Angles.Yaw.BAMs();
quad1 = targetangle / ANG90;
quad2 = camangle / ANG90;
bigangle = targetangle > camangle ? targetangle : camangle;
smallangle = targetangle < camangle ? targetangle : camangle;
if((quad1 > quad2 && quad1 - 1 == quad2) || (quad2 > quad1 && quad2 - 1 == quad1) ||
quad1 == quad2)
{
angledist = bigangle - smallangle;
angledir = targetangle > camangle ? 1 : -1;
}
else
{
angle_t diff180 = (bigangle + ANG180) - (smallangle + ANG180);
if(quad2 == 3 && quad1 == 0)
DAngle targetangle = floatvalue(t_argv[4]);
DAngle anglespeed = floatvalue(t_argv[5]);
DAngle diffangle = deltaangle(cam->Angles.Yaw, targetangle);
if (movespeed > 0 && anglespeed == 0.)
{
angledist = diff180;
angledir = 1;
}
else if(quad1 == 3 && quad2 == 0)
{
angledist = diff180;
angledir = -1;
if (!finished) targetangle = diffangle * movespeed / movelen;
}
else
{
angledist = bigangle - smallangle;
if(angledist > ANG180)
{
angledist = diff180;
angledir = targetangle > camangle ? -1 : 1;
}
else
angledir = targetangle > camangle ? 1 : -1;
targetangle = cam->Angles.Yaw + anglespeed;
}
}
// set step variables based on distance and speed
mobjangle = cam->AngleTo(target);
xydist = FLOAT2FIXED(cam->Distance2D(target, true));
xstep = (fixed_t)(movespeed * mobjangle.Cos());
ystep = (fixed_t)(movespeed * mobjangle.Sin());
if(xydist && movespeed)
zstep = FixedDiv(zdist, FixedDiv(xydist, movespeed));
else
zstep = zdist > 0 ? movespeed : -movespeed;
if(xydist && movespeed && !anglespeed)
{
fangledist = ((double)angledist / (ANG45/45));
fmovestep = ((double)FixedDiv(xydist, movespeed) / FRACUNIT);
if(fmovestep)
fanglestep = fangledist / fmovestep;
else
fanglestep = 360;
anglestep =(angle_t) (fanglestep * (ANG45/45));
}
else
anglestep = anglespeed;
if(abs(xstep) >= (abs(distx) - 1))
x = camx + distx;
else
{
x = camx + xstep;
moved = 1;
}
if(abs(ystep) >= (abs(disty) - 1))
y = camy + disty;
else
{
y = camy + ystep;
moved = 1;
}
if(abs(zstep) >= (abs(zdist) - 1))
z = targetheight;
else
{
z = camz + zstep;
moved = 1;
}
if(anglestep >= angledist)
cam->Angles.Yaw = ANGLE2DBL(targetangle);
else
{
if(angledir == 1)
{
cam->Angles.Yaw += ANGLE2DBL(anglestep);
moved = 1;
}
else if(angledir == -1)
{
cam->Angles.Yaw -= ANGLE2DBL(anglestep);
moved = 1;
}
}
cam->radius = 1 / 8192.;
cam->Height = 1 / 8192.;
if ((x != camx || y != camy) && !P_TryMove(cam, FIXED2FLOAT(x), FIXED2FLOAT(y), true))
{
Printf("Illegal camera move to (%f, %f)\n", x/65536.f, y/65536.f);
return;
cam->radius = 1 / 8192.;
cam->Height = 1 / 8192.;
cam->SetOrigin(movepos, true);
t_return.value.i = 1;
}
else
{
t_return.value.i = 0;
}
cam->SetZ(FIXED2FLOAT(z));
t_return.type = svt_int;
t_return.value.i = moved;
}
}

View file

@ -360,8 +360,7 @@ void FParser::OPmultiply(svalue_t &result,int start, int n, int stop)
// haleyjd: 8-17
if(left.type == svt_fixed || right.type == svt_fixed)
{
result.type = svt_fixed;
result.value.f = FixedMul(fixedvalue(left), fixedvalue(right));
result.setDouble(floatvalue(left) * floatvalue(right));
}
else
{

View file

@ -545,30 +545,31 @@ void G_ClearHubInfo();
enum ESkillProperty
{
SKILLP_AmmoFactor,
SKILLP_DropAmmoFactor,
SKILLP_FastMonsters,
SKILLP_Respawn,
SKILLP_RespawnLimit,
SKILLP_Aggressiveness,
SKILLP_DisableCheats,
SKILLP_AutoUseHealth,
SKILLP_SpawnFilter,
SKILLP_EasyBossBrain,
SKILLP_ACSReturn,
SKILLP_MonsterHealth,
SKILLP_FriendlyHealth,
SKILLP_NoPain,
SKILLP_ArmorFactor,
SKILLP_HealthFactor,
SKILLP_EasyKey,
SKILLP_SlowMonsters,
SKILLP_Infight,
};
enum EFSkillProperty // floating point properties
{
SKILLP_AmmoFactor,
SKILLP_DropAmmoFactor,
SKILLP_ArmorFactor,
SKILLP_HealthFactor,
SKILLP_DamageFactor,
SKILLP_Aggressiveness,
SKILLP_MonsterHealth,
SKILLP_FriendlyHealth,
};
int G_SkillProperty(ESkillProperty prop);
double G_SkillProperty(EFSkillProperty prop);
const char * G_SkillName();
@ -580,8 +581,11 @@ typedef TMap<FName, FName> SkillActorReplacement;
struct FSkillInfo
{
FName Name;
fixed_t AmmoFactor, DoubleAmmoFactor, DropAmmoFactor;
double AmmoFactor, DoubleAmmoFactor, DropAmmoFactor;
double DamageFactor;
double ArmorFactor;
double HealthFactor;
bool FastMonsters;
bool SlowMonsters;
bool DisableCheats;
@ -591,7 +595,7 @@ struct FSkillInfo
bool EasyKey;
int RespawnCounter;
int RespawnLimit;
fixed_t Aggressiveness;
double Aggressiveness;
int SpawnFilter;
int ACSReturn;
FString MenuName;
@ -603,12 +607,10 @@ struct FSkillInfo
FString TextColor;
SkillActorReplacement Replace;
SkillActorReplacement Replaced;
fixed_t MonsterHealth;
fixed_t FriendlyHealth;
double MonsterHealth;
double FriendlyHealth;
bool NoPain;
int Infighting;
fixed_t ArmorFactor;
fixed_t HealthFactor;
FSkillInfo() {}
FSkillInfo(const FSkillInfo &other)

View file

@ -96,13 +96,13 @@ bool ABasicArmor::HandlePickup (AInventory *item)
{
ABasicArmorBonus *armor = static_cast<ABasicArmorBonus*>(item);
armor->SaveAmount = FixedMul(armor->SaveAmount, G_SkillProperty(SKILLP_ArmorFactor));
armor->SaveAmount = int(armor->SaveAmount * G_SkillProperty(SKILLP_ArmorFactor));
}
else if (item->IsKindOf(RUNTIME_CLASS(ABasicArmorPickup)) && !(item->ItemFlags & IF_IGNORESKILL))
{
ABasicArmorPickup *armor = static_cast<ABasicArmorPickup*>(item);
armor->SaveAmount = FixedMul(armor->SaveAmount, G_SkillProperty(SKILLP_ArmorFactor));
armor->SaveAmount = int(armor->SaveAmount * G_SkillProperty(SKILLP_ArmorFactor));
}
if (Inventory != NULL)
{
@ -216,7 +216,7 @@ AInventory *ABasicArmorPickup::CreateCopy (AActor *other)
if (!(ItemFlags & IF_IGNORESKILL))
{
SaveAmount = FixedMul(SaveAmount, G_SkillProperty(SKILLP_ArmorFactor));
SaveAmount = int(SaveAmount * G_SkillProperty(SKILLP_ArmorFactor));
}
copy->SavePercent = SavePercent;
@ -298,7 +298,7 @@ AInventory *ABasicArmorBonus::CreateCopy (AActor *other)
if (!(ItemFlags & IF_IGNORESKILL))
{
SaveAmount = FixedMul(SaveAmount, G_SkillProperty(SKILLP_ArmorFactor));
SaveAmount = int(SaveAmount * G_SkillProperty(SKILLP_ArmorFactor));
}
copy->SavePercent = SavePercent;

View file

@ -91,8 +91,6 @@ protected:
void DoEffect ();
void EndEffect ();
int AlterWeaponSprite (visstyle_t *vis);
// FRenderStyle OwnersNormalStyle;
// fixed_t OwnersNormalAlpha;
};
class APowerIronFeet : public APowerup

View file

@ -769,9 +769,7 @@ DBaseDecal *ShootDecal(const FDecalTemplate *tpl, AActor *basisactor, sector_t *
DBaseDecal *decal;
side_t *wall;
Trace(FLOAT2FIXED(x), FLOAT2FIXED(y), FLOAT2FIXED(z), sec,
FLOAT2FIXED(angle.Cos()), FLOAT2FIXED(angle.Sin()), 0,
FLOAT2FIXED(tracedist), 0, 0, NULL, trace, TRACE_NoSky);
Trace(DVector3(x,y,z), sec, DVector3(angle.ToVector(), 0), tracedist, 0, 0, NULL, trace, TRACE_NoSky);
if (trace.HitType == TRACE_HitWall)
{

View file

@ -141,7 +141,7 @@ bool AAmmo::HandlePickup (AInventory *item)
if (!(item->ItemFlags & IF_IGNORESKILL))
{ // extra ammo in baby mode and nightmare mode
receiving = FixedMul(receiving, G_SkillProperty(SKILLP_AmmoFactor));
receiving = int(receiving * G_SkillProperty(SKILLP_AmmoFactor));
}
int oldamount = Amount;
@ -193,7 +193,7 @@ AInventory *AAmmo::CreateCopy (AActor *other)
// extra ammo in baby mode and nightmare mode
if (!(ItemFlags&IF_IGNORESKILL))
{
amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor));
amount = int(amount * G_SkillProperty(SKILLP_AmmoFactor));
}
if (GetClass()->ParentClass != RUNTIME_CLASS(AAmmo) && GetClass() != RUNTIME_CLASS(AAmmo))
@ -298,7 +298,7 @@ bool P_GiveBody (AActor *actor, int num, int max)
{
if (player->health < max)
{
num = FixedMul(num, G_SkillProperty(SKILLP_HealthFactor));
num = int(num * G_SkillProperty(SKILLP_HealthFactor));
if (num < 1) num = 1;
player->health += num;
if (player->health > max)
@ -1853,7 +1853,7 @@ AInventory *ABackpackItem::CreateCopy (AActor *other)
// extra ammo in baby mode and nightmare mode
if (!(ItemFlags&IF_IGNORESKILL))
{
amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor));
amount = int(amount * G_SkillProperty(SKILLP_AmmoFactor));
}
if (amount < 0) amount = 0;
if (ammo == NULL)
@ -1916,7 +1916,7 @@ bool ABackpackItem::HandlePickup (AInventory *item)
// extra ammo in baby mode and nightmare mode
if (!(item->ItemFlags&IF_IGNORESKILL))
{
amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor));
amount = int(amount * G_SkillProperty(SKILLP_AmmoFactor));
}
probe->Amount += amount;
if (probe->Amount > probe->MaxAmount && !sv_unlimited_pickup)

View file

@ -145,7 +145,7 @@ void DEarthquake::Tick ()
double DEarthquake::GetModWave(double waveMultiplier) const
{
double time = m_Countdown - FIXED2DBL(r_TicFrac);
double time = m_Countdown - r_TicFracF;
return g_sin(waveMultiplier * time * (M_PI * 2 / TICRATE));
}

View file

@ -382,7 +382,7 @@ AAmmo *AWeapon::AddAmmo (AActor *other, PClassActor *ammotype, int amount)
// extra ammo in baby mode and nightmare mode
if (!(this->ItemFlags&IF_IGNORESKILL))
{
amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor));
amount = int(amount * G_SkillProperty(SKILLP_AmmoFactor));
}
ammo = static_cast<AAmmo *>(other->FindInventory (ammotype));
if (ammo == NULL)
@ -418,7 +418,7 @@ bool AWeapon::AddExistingAmmo (AAmmo *ammo, int amount)
// extra ammo in baby mode and nightmare mode
if (!(ItemFlags&IF_IGNORESKILL))
{
amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor));
amount = int(amount * G_SkillProperty(SKILLP_AmmoFactor));
}
ammo->Amount += amount;
if (ammo->Amount > ammo->MaxAmount && !sv_unlimited_pickup)

View file

@ -146,7 +146,7 @@ DHUDMessage::DHUDMessage (FFont *font, const char *text, float x, float y, int h
Font = font;
VisibilityFlags = 0;
Style = STYLE_Translucent;
Alpha = FRACUNIT;
Alpha = 1.;
ResetText (SourceText);
}
@ -221,7 +221,7 @@ void DHUDMessage::Serialize (FArchive &arc)
if (SaveVersion < 3824)
{
Style = STYLE_Translucent;
Alpha = FRACUNIT;
Alpha = 1.;
}
else
{
@ -474,7 +474,7 @@ void DHUDMessage::DoDraw (int linenum, int x, int y, bool clean, int hudheight)
{
screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_CleanNoMove, clean,
DTA_Alpha, Alpha,
DTA_AlphaF, Alpha,
DTA_RenderStyle, Style,
TAG_DONE);
}
@ -483,7 +483,7 @@ void DHUDMessage::DoDraw (int linenum, int x, int y, bool clean, int hudheight)
screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_VirtualWidth, SCREENWIDTH/2,
DTA_VirtualHeight, SCREENHEIGHT/2,
DTA_Alpha, Alpha,
DTA_AlphaF, Alpha,
DTA_RenderStyle, Style,
DTA_KeepRatio, true,
TAG_DONE);
@ -498,7 +498,7 @@ void DHUDMessage::DoDraw (int linenum, int x, int y, bool clean, int hudheight)
DTA_ClipRight, ClipRight,
DTA_ClipTop, ClipTop,
DTA_ClipBottom, ClipBot,
DTA_Alpha, Alpha,
DTA_AlphaF, Alpha,
DTA_RenderStyle, Style,
TAG_DONE);
}
@ -570,15 +570,14 @@ void DHUDMessageFadeOut::DoDraw (int linenum, int x, int y, bool clean, int hudh
}
else
{
fixed_t trans = -(Tics - FadeOutTics) * FRACUNIT / FadeOutTics;
trans = FixedMul(trans, Alpha);
float trans = float(Alpha * -(Tics - FadeOutTics) / FadeOutTics);
if (hudheight == 0)
{
if (con_scaletext <= 1)
{
screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_CleanNoMove, clean,
DTA_Alpha, trans,
DTA_AlphaF, trans,
DTA_RenderStyle, Style,
TAG_DONE);
}
@ -587,7 +586,7 @@ void DHUDMessageFadeOut::DoDraw (int linenum, int x, int y, bool clean, int hudh
screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_VirtualWidth, SCREENWIDTH/2,
DTA_VirtualHeight, SCREENHEIGHT/2,
DTA_Alpha, trans,
DTA_AlphaF, trans,
DTA_RenderStyle, Style,
DTA_KeepRatio, true,
TAG_DONE);
@ -602,7 +601,7 @@ void DHUDMessageFadeOut::DoDraw (int linenum, int x, int y, bool clean, int hudh
DTA_ClipRight, ClipRight,
DTA_ClipTop, ClipTop,
DTA_ClipBottom, ClipBot,
DTA_Alpha, trans,
DTA_AlphaF, trans,
DTA_RenderStyle, Style,
TAG_DONE);
}
@ -671,15 +670,14 @@ void DHUDMessageFadeInOut::DoDraw (int linenum, int x, int y, bool clean, int hu
{
if (State == 0)
{
fixed_t trans = Tics * FRACUNIT / FadeInTics;
trans = FixedMul(trans, Alpha);
float trans = float(Alpha * Tics / FadeInTics);
if (hudheight == 0)
{
if (con_scaletext <= 1)
{
screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_CleanNoMove, clean,
DTA_Alpha, trans,
DTA_AlphaF, trans,
DTA_RenderStyle, Style,
TAG_DONE);
}
@ -688,7 +686,7 @@ void DHUDMessageFadeInOut::DoDraw (int linenum, int x, int y, bool clean, int hu
screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_VirtualWidth, SCREENWIDTH/2,
DTA_VirtualHeight, SCREENHEIGHT/2,
DTA_Alpha, trans,
DTA_AlphaF, trans,
DTA_RenderStyle, Style,
DTA_KeepRatio, true,
TAG_DONE);
@ -703,7 +701,7 @@ void DHUDMessageFadeInOut::DoDraw (int linenum, int x, int y, bool clean, int hu
DTA_ClipRight, ClipRight,
DTA_ClipTop, ClipTop,
DTA_ClipBottom, ClipBot,
DTA_Alpha, trans,
DTA_AlphaF, trans,
DTA_RenderStyle, Style,
TAG_DONE);
}
@ -858,7 +856,7 @@ void DHUDMessageTypeOnFadeOut::DoDraw (int linenum, int x, int y, bool clean, in
screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_CleanNoMove, clean,
DTA_TextLen, LineVisible,
DTA_Alpha, Alpha,
DTA_AlphaF, Alpha,
DTA_RenderStyle, Style,
TAG_DONE);
}
@ -869,7 +867,7 @@ void DHUDMessageTypeOnFadeOut::DoDraw (int linenum, int x, int y, bool clean, in
DTA_VirtualHeight, SCREENHEIGHT/2,
DTA_KeepRatio, true,
DTA_TextLen, LineVisible,
DTA_Alpha, Alpha,
DTA_AlphaF, Alpha,
DTA_RenderStyle, Style,
TAG_DONE);
}
@ -883,7 +881,7 @@ void DHUDMessageTypeOnFadeOut::DoDraw (int linenum, int x, int y, bool clean, in
DTA_ClipRight, ClipRight,
DTA_ClipTop, ClipTop,
DTA_ClipBottom, ClipBot,
DTA_Alpha, Alpha,
DTA_AlphaF, Alpha,
DTA_TextLen, LineVisible,
DTA_RenderStyle, Style,
TAG_DONE);

View file

@ -88,7 +88,7 @@ public:
{
Style = style;
}
void SetAlpha(fixed_t alpha)
void SetAlpha(float alpha)
{
Alpha = alpha;
}
@ -127,7 +127,7 @@ protected:
EColorRange TextColor;
FFont *Font;
FRenderStyle Style;
fixed_t Alpha;
double Alpha;
void CalcClipCoords(int hudheight);
DHUDMessage () : SourceText(NULL) {}
@ -349,7 +349,7 @@ public:
DHUDMessage *DetachMessage (uint32 id);
void DetachAllMessages ();
void ShowPlayerName ();
fixed_t GetDisplacement () { return Displacement; }
double GetDisplacement() { return Displacement; }
int GetPlayer ();
static void AddBlend (float r, float g, float b, float a, float v_blend[4]);
@ -380,7 +380,6 @@ protected:
void UpdateRect (int x, int y, int width, int height) const;
void DrawImage (FTexture *image, int x, int y, FRemapTable *translation=NULL) const;
void DrawDimImage (FTexture *image, int x, int y, bool dimmed) const;
void DrawFadedImage (FTexture *image, int x, int y, fixed_t shade) const;
void DrawPartialImage (FTexture *image, int wx, int ww) const;
void DrINumber (signed int val, int x, int y, int imgBase=imgINumbers) const;
@ -407,8 +406,8 @@ public:
bool Centering;
bool FixedOrigin;
bool CompleteBorder;
fixed_t CrosshairSize;
fixed_t Displacement;
double CrosshairSize;
double Displacement;
enum
{

View file

@ -76,6 +76,7 @@ EXTERN_CVAR(Bool, vid_fps)
EXTERN_CVAR(Bool, hud_scale)
class DSBarInfo;
static double nulclip[] = { 0,0,0,0 };
////////////////////////////////////////////////////////////////////////////////
@ -294,22 +295,22 @@ class SBarInfoMainBlock : public SBarInfoCommandFlowControl
{
public:
SBarInfoMainBlock(SBarInfo *script) : SBarInfoCommandFlowControl(script),
alpha(OPAQUE), currentAlpha(OPAQUE), forceScaled(false),
alpha(1.), currentAlpha(1.), forceScaled(false),
fullScreenOffsets(false)
{
SetTruth(true, NULL, NULL);
}
int Alpha() const { return currentAlpha; }
double Alpha() const { return currentAlpha; }
// Same as Draw but takes into account ForceScaled and temporarily sets the scaling if needed.
void DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statusBar, int xOffset, int yOffset, int alpha);
void DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statusBar, int xOffset, int yOffset, double alpha);
// Silence hidden overload warning since this is a special use class.
using SBarInfoCommandFlowControl::Draw;
void Draw(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, int xOffset, int yOffset, int alpha)
void Draw(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, int xOffset, int yOffset, double alpha)
{
this->xOffset = xOffset;
this->yOffset = yOffset;
this->currentAlpha = FixedMul(this->alpha, alpha);
this->currentAlpha = this->alpha * alpha;
SBarInfoCommandFlowControl::Draw(this, statusBar);
}
bool ForceScaled() const { return forceScaled; }
@ -334,7 +335,7 @@ class SBarInfoMainBlock : public SBarInfoCommandFlowControl
}
}
sc.MustGetToken(TK_FloatConst);
alpha = fixed_t(OPAQUE * sc.Float);
alpha = sc.Float;
}
SBarInfoCommandFlowControl::Parse(sc, this->fullScreenOffsets);
}
@ -343,8 +344,8 @@ class SBarInfoMainBlock : public SBarInfoCommandFlowControl
int YOffset() const { return yOffset; }
protected:
int alpha;
int currentAlpha;
double alpha;
double currentAlpha;
bool forceScaled;
bool fullScreenOffsets;
int xOffset;
@ -698,24 +699,24 @@ void SBarInfo::ParseSBarInfo(int lump)
popup.transition = Popup::TRANSITION_SLIDEINBOTTOM;
sc.MustGetToken(',');
sc.MustGetToken(TK_IntConst);
popup.speed = sc.Number;
popup.ispeed = sc.Number;
}
else if(sc.Compare("pushup"))
{
popup.transition = Popup::TRANSITION_PUSHUP;
sc.MustGetToken(',');
sc.MustGetToken(TK_IntConst);
popup.speed = sc.Number;
popup.ispeed = sc.Number;
}
else if(sc.Compare("fade"))
{
popup.transition = Popup::TRANSITION_FADE;
sc.MustGetToken(',');
sc.MustGetToken(TK_FloatConst);
popup.speed = fixed_t(FRACUNIT * (1.0 / (35.0 * sc.Float)));
popup.speed = 1.0 / (35.0 * sc.Float);
sc.MustGetToken(',');
sc.MustGetToken(TK_FloatConst);
popup.speed2 = fixed_t(FRACUNIT * (1.0 / (35.0 * sc.Float)));
popup.speed2 = 1.0 / (35.0 * sc.Float);
}
else
sc.ScriptError("Unkown transition type: '%s'", sc.String);
@ -820,7 +821,7 @@ SBarInfo::~SBarInfo()
//Popup
Popup::Popup() : transition(TRANSITION_NONE), opened(false), moving(false),
height(320), width(200), speed(0), speed2(0), alpha(FRACUNIT), x(320),
height(320), width(200), ispeed(0), speed(0), speed2(0), alpha(1.), x(320),
y(200), displacementX(0), displacementY(0)
{
}
@ -855,9 +856,9 @@ void Popup::tick()
{
int oldY = y;
if(opened)
y -= clamp(height + (y - height), 1, speed);
y -= clamp(height + (y - height), 1, ispeed);
else
y += clamp(height - y, 1, speed);
y += clamp(height - y, 1, ispeed);
if(transition == TRANSITION_PUSHUP)
displacementY += y - oldY;
}
@ -870,11 +871,11 @@ void Popup::tick()
if(moving)
{
if(opened)
alpha = clamp<int>(alpha + speed, 0, OPAQUE);
alpha = clamp(alpha + speed, 0., 1.);
else
alpha = clamp<int>(alpha - speed2, 0, OPAQUE);
alpha = clamp(alpha - speed2, 0., 1.);
}
if(alpha == 0 || alpha == OPAQUE)
if(alpha == 0 || alpha == 1.)
moving = false;
else
moving = true;
@ -910,9 +911,9 @@ int Popup::getYOffset()
return y;
}
int Popup::getAlpha(int maxAlpha)
double Popup::getAlpha(double maxAlpha)
{
return FixedMul(alpha, maxAlpha);
return alpha * maxAlpha;
}
int Popup::getXDisplacement()
@ -1057,9 +1058,9 @@ public:
}
if(currentPopup != POP_None && !script->huds[hud]->FullScreenOffsets())
script->huds[hud]->Draw(NULL, this, script->popups[currentPopup-1].getXDisplacement(), script->popups[currentPopup-1].getYDisplacement(), FRACUNIT);
script->huds[hud]->Draw(NULL, this, script->popups[currentPopup-1].getXDisplacement(), script->popups[currentPopup-1].getYDisplacement(), 1.);
else
script->huds[hud]->Draw(NULL, this, 0, 0, FRACUNIT);
script->huds[hud]->Draw(NULL, this, 0, 0, 1.);
lastHud = hud;
// Handle inventory bar drawing
@ -1073,7 +1074,7 @@ public:
if(inventoryBar->NumCommands() == 0)
CPlayer->inventorytics = 0;
else
inventoryBar->DrawAux(NULL, this, 0, 0, FRACUNIT);
inventoryBar->DrawAux(NULL, this, 0, 0, 1.);
}
}
@ -1177,7 +1178,7 @@ public:
}
//draws an image with the specified flags
void DrawGraphic(FTexture* texture, SBarInfoCoordinate x, SBarInfoCoordinate y, int xOffset, int yOffset, int alpha, bool fullScreenOffsets, bool translate=false, bool dim=false, int offsetflags=0, bool alphaMap=false, int forceWidth=-1, int forceHeight=-1, fixed_t cx=0, fixed_t cy=0, fixed_t cr=0, fixed_t cb=0, bool clearDontDraw=false) const
void DrawGraphic(FTexture* texture, SBarInfoCoordinate x, SBarInfoCoordinate y, int xOffset, int yOffset, double Alpha, bool fullScreenOffsets, bool translate=false, bool dim=false, int offsetflags=0, bool alphaMap=false, int forceWidth=-1, int forceHeight=-1, const double *clip = nulclip, bool clearDontDraw=false) const
{
if (texture == NULL)
return;
@ -1205,20 +1206,20 @@ public:
dy += ST_Y - (Scaled ? script->resH : 200) + script->height;
w = forceWidth < 0 ? texture->GetScaledWidthDouble() : forceWidth;
h = forceHeight < 0 ? texture->GetScaledHeightDouble() : forceHeight;
double dcx = cx == 0 ? 0 : dx + ((double) cx / FRACUNIT) - texture->GetScaledLeftOffsetDouble();
double dcy = cy == 0 ? 0 : dy + ((double) cy / FRACUNIT) - texture->GetScaledTopOffsetDouble();
double dcr = cr == 0 ? INT_MAX : dx + w - ((double) cr / FRACUNIT) - texture->GetScaledLeftOffsetDouble();
double dcb = cb == 0 ? INT_MAX : dy + h - ((double) cb / FRACUNIT) - texture->GetScaledTopOffsetDouble();
double dcx = clip[0] == 0 ? 0 : dx + clip[0] - texture->GetScaledLeftOffsetDouble();
double dcy = clip[1] == 0 ? 0 : dy + clip[1] - texture->GetScaledTopOffsetDouble();
double dcr = clip[2] == 0 ? INT_MAX : dx + w - clip[2] - texture->GetScaledLeftOffsetDouble();
double dcb = clip[3] == 0 ? INT_MAX : dy + h - clip[3] - texture->GetScaledTopOffsetDouble();
if(Scaled)
{
if(cx != 0 || cy != 0)
if(clip[0] != 0 || clip[1] != 0)
{
screen->VirtualToRealCoords(dcx, dcy, tmp, tmp, script->resW, script->resH, true);
if (cx == 0) dcx = 0;
if (cy == 0) dcy = 0;
if (clip[0] == 0) dcx = 0;
if (clip[1] == 0) dcy = 0;
}
if(cr != 0 || cb != 0 || clearDontDraw)
if(clip[2] != 0 || clip[3] != 0 || clearDontDraw)
screen->VirtualToRealCoords(dcr, dcb, tmp, tmp, script->resW, script->resH, true);
screen->VirtualToRealCoords(dx, dy, w, h, script->resW, script->resH, true);
}
@ -1245,7 +1246,7 @@ public:
DTA_Translation, translate ? GetTranslation() : 0,
DTA_ColorOverlay, dim ? DIM_OVERLAY : 0,
DTA_CenterBottomOffset, (offsetflags & SBarInfoCommand::CENTER_BOTTOM) == SBarInfoCommand::CENTER_BOTTOM,
DTA_Alpha, alpha,
DTA_AlphaF, Alpha,
DTA_AlphaChannel, alphaMap,
DTA_FillColor, 0,
TAG_DONE);
@ -1262,7 +1263,7 @@ public:
DTA_Translation, translate ? GetTranslation() : 0,
DTA_ColorOverlay, dim ? DIM_OVERLAY : 0,
DTA_CenterBottomOffset, (offsetflags & SBarInfoCommand::CENTER_BOTTOM) == SBarInfoCommand::CENTER_BOTTOM,
DTA_Alpha, alpha,
DTA_AlphaF, Alpha,
TAG_DONE);
}
}
@ -1298,12 +1299,12 @@ public:
ry = SCREENHEIGHT + ry;
// Check for clipping
if(cx != 0 || cy != 0 || cr != 0 || cb != 0)
if(clip[0] != 0 || clip[1] != 0 || clip[2] != 0 || clip[3] != 0)
{
rcx = cx == 0 ? 0 : rx+((((double) cx/FRACUNIT) - texture->GetScaledLeftOffsetDouble())*xScale);
rcy = cy == 0 ? 0 : ry+((((double) cy/FRACUNIT) - texture->GetScaledTopOffsetDouble())*yScale);
rcr = cr == 0 ? INT_MAX : rx+w-((((double) cr/FRACUNIT) + texture->GetScaledLeftOffsetDouble())*xScale);
rcb = cb == 0 ? INT_MAX : ry+h-((((double) cb/FRACUNIT) + texture->GetScaledTopOffsetDouble())*yScale);
rcx = clip[0] == 0 ? 0 : rx+((clip[0] - texture->GetScaledLeftOffsetDouble())*xScale);
rcy = clip[1] == 0 ? 0 : ry+((clip[1] - texture->GetScaledTopOffsetDouble())*yScale);
rcr = clip[2] == 0 ? INT_MAX : rx+w-((clip[2] + texture->GetScaledLeftOffsetDouble())*xScale);
rcb = clip[3] == 0 ? INT_MAX : ry+h-((clip[3] + texture->GetScaledTopOffsetDouble())*yScale);
}
if(clearDontDraw)
@ -1322,7 +1323,7 @@ public:
DTA_Translation, translate ? GetTranslation() : 0,
DTA_ColorOverlay, dim ? DIM_OVERLAY : 0,
DTA_CenterBottomOffset, (offsetflags & SBarInfoCommand::CENTER_BOTTOM) == SBarInfoCommand::CENTER_BOTTOM,
DTA_Alpha, alpha,
DTA_AlphaF, Alpha,
DTA_AlphaChannel, alphaMap,
DTA_FillColor, 0,
TAG_DONE);
@ -1339,14 +1340,14 @@ public:
DTA_Translation, translate ? GetTranslation() : 0,
DTA_ColorOverlay, dim ? DIM_OVERLAY : 0,
DTA_CenterBottomOffset, (offsetflags & SBarInfoCommand::CENTER_BOTTOM) == SBarInfoCommand::CENTER_BOTTOM,
DTA_Alpha, alpha,
DTA_AlphaF, Alpha,
TAG_DONE);
}
}
}
}
void DrawString(FFont *font, const char* cstring, SBarInfoCoordinate x, SBarInfoCoordinate y, int xOffset, int yOffset, int alpha, bool fullScreenOffsets, EColorRange translation, int spacing=0, bool drawshadow=false, int shadowX=2, int shadowY=2) const
void DrawString(FFont *font, const char* cstring, SBarInfoCoordinate x, SBarInfoCoordinate y, int xOffset, int yOffset, double Alpha, bool fullScreenOffsets, EColorRange translation, int spacing=0, bool drawshadow=false, int shadowX=2, int shadowY=2) const
{
x += spacing;
double ax = *x;
@ -1456,13 +1457,13 @@ public:
}
if(drawshadow)
{
fixed_t salpha = fixed_t(alpha *HR_SHADOW);
double salpha = (Alpha *HR_SHADOW);
double srx = rx + (shadowX*xScale);
double sry = ry + (shadowY*yScale);
screen->DrawTexture(character, srx, sry,
DTA_DestWidthF, rw,
DTA_DestHeightF, rh,
DTA_Alpha, salpha,
DTA_AlphaF, salpha,
DTA_FillColor, 0,
TAG_DONE);
}
@ -1470,7 +1471,7 @@ public:
DTA_DestWidthF, rw,
DTA_DestHeightF, rh,
DTA_Translation, remap,
DTA_Alpha, alpha,
DTA_AlphaF, Alpha,
TAG_DONE);
if(script->spacingCharacter == '\0')
ax += width + spacing - (character->LeftOffset+1);
@ -1516,7 +1517,7 @@ DBaseStatusBar *CreateCustomStatusBar (int script)
return new DSBarInfo(SBarInfoScript[script]);
}
void SBarInfoMainBlock::DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statusBar, int xOffset, int yOffset, int alpha)
void SBarInfoMainBlock::DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statusBar, int xOffset, int yOffset, double alpha)
{
// Popups can also be forced to scale
bool rescale = false;

View file

@ -61,9 +61,10 @@ struct Popup
bool moving;
int height;
int width;
int speed;
int speed2;
int alpha;
int ispeed;
double speed;
double speed2;
double alpha;
int x;
int y;
int displacementX;
@ -77,7 +78,7 @@ struct Popup
bool isDoneMoving();
int getXOffset();
int getYOffset();
int getAlpha(int maxAlpha=OPAQUE);
double getAlpha(double maxAlpha=1.);
int getXDisplacement();
int getYDisplacement();
};

View file

@ -48,7 +48,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
translatable(false), type(NORMAL_IMAGE), image(-1), maxwidth(-1),
maxheight(-1), spawnScaleX(1.0f), spawnScaleY(1.0f), flags(0),
applyscale(false), offset(static_cast<Offset> (TOP|LEFT)),
texture(NULL), alpha(OPAQUE)
texture(NULL), alpha(1.)
{
}
@ -63,7 +63,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
int w = maxwidth, h = maxheight;
// We must calculate this per frame in order to prevent glitches with cl_capfps true.
fixed_t frameAlpha = FixedMul(block->Alpha(), alpha);
double frameAlpha = block->Alpha() * alpha;
if(flags & DI_DRAWINBOX)
{
@ -234,7 +234,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged);
texture = NULL;
alpha = OPAQUE;
alpha = 1.;
if (applyscale)
{
spawnScaleX = spawnScaleY = 1.0f;
@ -282,7 +282,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
if (harmor->Slots[armorType] > 0 && harmor->SlotsIncrement[armorType] > 0)
{
//combine the alpha values
alpha = int(alpha * MIN(1., harmor->Slots[armorType] / harmor->SlotsIncrement[armorType]));
alpha *= MIN(1., harmor->Slots[armorType] / harmor->SlotsIncrement[armorType]);
texture = statusBar->Images[image];
}
else
@ -350,7 +350,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
Offset offset;
FTexture *texture;
int alpha;
double alpha;
};
////////////////////////////////////////////////////////////////////////////////
@ -641,7 +641,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
// Since we're not going to call our parent's tick() method,
// be sure to set the alpha value properly.
alpha = FRACUNIT;
alpha = 1.;
return;
}
CommandDrawImage::Tick(block, statusBar, hudChanged);
@ -1641,9 +1641,9 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
}
else
{
if(itemflash && itemflashFade)
if(itemflash && itemflashFade != 0)
{
fixed_t flashAlpha = FixedMul(block->Alpha(), itemflashFade);
double flashAlpha = block->Alpha() * itemflashFade;
statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgCURSOR], imgx-4, imgy+2, block->XOffset(), block->YOffset(), flashAlpha, block->FullScreenOffsets(),
translatable, false, offset);
}
@ -1736,7 +1736,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
artiflashTick--;
if(itemflashFade > 0)
{
itemflashFade -= FRACUNIT/14;
itemflashFade -= 1./14;
if(itemflashFade < 0)
itemflashFade = 0;
}
@ -1747,7 +1747,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
CommandDrawNumber::Tick(block, statusBar, hudChanged);
}
static void Flash() { artiflashTick = 4; itemflashFade = FRACUNIT*3/4; }
static void Flash() { artiflashTick = 4; itemflashFade = 0.75; }
protected:
bool alternateOnEmpty;
bool artiflash;
@ -1755,10 +1755,10 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
bool itemflash;
static int artiflashTick;
static fixed_t itemflashFade;
static double itemflashFade;
};
int CommandDrawSelectedInventory::artiflashTick = 0;
int CommandDrawSelectedInventory::itemflashFade = FRACUNIT*3/4;
double CommandDrawSelectedInventory::itemflashFade = 0.75;
void DSBarInfo::FlashItem(const PClass *itemtype)
{
@ -2110,9 +2110,9 @@ class CommandDrawInventoryBar : public SBarInfoCommand
{
int spacing = GetCounterSpacing(statusBar);
int bgalpha = block->Alpha();
double bgalpha = block->Alpha();
if(translucent)
bgalpha = fixed_t(block->Alpha() * HX_SHADOW);
bgalpha *= HX_SHADOW;
AInventory *item;
unsigned int i = 0;
@ -2492,10 +2492,10 @@ class CommandDrawBar : public SBarInfoCommand
FTexture *fg = statusBar->Images[foreground];
FTexture *bg = (background != -1) ? statusBar->Images[background] : NULL;
fixed_t value = drawValue;
double value = drawValue;
if(border != 0)
{
value = FRACUNIT - value; //invert since the new drawing method requires drawing the bg on the fg.
value = 1. - value; //invert since the new drawing method requires drawing the bg on the fg.
//Draw the whole foreground
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
@ -2506,27 +2506,27 @@ class CommandDrawBar : public SBarInfoCommand
if (bg != NULL && bg->GetScaledWidth() == fg->GetScaledWidth() && bg->GetScaledHeight() == fg->GetScaledHeight())
statusBar->DrawGraphic(bg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
else
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, 0, 0, 0, 0, true);
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, nulclip, true);
}
// {cx, cy, cr, cb}
fixed_t clip[4] = {0, 0, 0, 0};
double Clip[4] = {0, 0, 0, 0};
fixed_t sizeOfImage = (horizontal ? fg->GetScaledWidth()-border*2 : fg->GetScaledHeight()-border*2)<<FRACBITS;
clip[(!horizontal)|((horizontal ? !reverse : reverse)<<1)] = sizeOfImage - FixedMul(sizeOfImage, value);
int sizeOfImage = (horizontal ? fg->GetScaledWidth()-border*2 : fg->GetScaledHeight()-border*2);
Clip[(!horizontal)|((horizontal ? !reverse : reverse)<<1)] = sizeOfImage - sizeOfImage *value;
// Draw background
if(border != 0)
{
for(unsigned int i = 0;i < 4;i++)
clip[i] += border<<FRACBITS;
Clip[i] += border;
if (bg != NULL && bg->GetScaledWidth() == fg->GetScaledWidth() && bg->GetScaledHeight() == fg->GetScaledHeight())
statusBar->DrawGraphic(bg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, clip[0], clip[1], clip[2], clip[3]);
statusBar->DrawGraphic(bg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, Clip);
else
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, clip[0], clip[1], clip[2], clip[3], true);
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, Clip, true);
}
else
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, clip[0], clip[1], clip[2], clip[3]);
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, Clip);
}
void Parse(FScanner &sc, bool fullScreenOffsets)
{
@ -2651,7 +2651,7 @@ class CommandDrawBar : public SBarInfoCommand
}
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
{
fixed_t value = 0;
double value = 0;
int max = 0;
switch(type)
{
@ -2791,9 +2791,7 @@ class CommandDrawBar : public SBarInfoCommand
if(max != 0 && value > 0)
{
value = (value << FRACBITS) / max;
if(value > FRACUNIT)
value = FRACUNIT;
value = MIN(value / max, 1.);
}
else
value = 0;
@ -2802,14 +2800,14 @@ class CommandDrawBar : public SBarInfoCommand
// [BL] Since we used a percentage (in order to get the most fluid animation)
// we need to establish a cut off point so the last pixel won't hang as the animation slows
if(pixel == -1 && statusBar->Images[foreground])
pixel = MAX(1, FRACUNIT/statusBar->Images[foreground]->GetWidth());
pixel = MAX(1., 1./statusBar->Images[foreground]->GetWidth());
if(abs(drawValue - value) < pixel)
if(fabs(drawValue - value) < pixel)
drawValue = value;
else if(value < drawValue)
drawValue -= clamp<fixed_t>((drawValue - value) >> 2, 1, FixedDiv(interpolationSpeed<<FRACBITS, FRACUNIT*100));
else if(drawValue < value)
drawValue += clamp<fixed_t>((value - drawValue) >> 2, 1, FixedDiv(interpolationSpeed<<FRACBITS, FRACUNIT*100));
else if (value < drawValue)
drawValue -= clamp<double>((drawValue - value) / 4, 1 / 65536., interpolationSpeed / 100.);
else if (drawValue < value)
drawValue += clamp<double>((value - drawValue) / 4, 1 / 65536., interpolationSpeed / 100.);
}
else
drawValue = value;
@ -2883,8 +2881,8 @@ class CommandDrawBar : public SBarInfoCommand
SBarInfoCoordinate y;
int interpolationSpeed;
fixed_t drawValue;
fixed_t pixel;
double drawValue;
double pixel;
};
////////////////////////////////////////////////////////////////////////////////
@ -3448,7 +3446,7 @@ class CommandAlpha : public SBarInfoMainBlock
void Parse(FScanner &sc, bool fullScreenOffsets)
{
sc.MustGetToken(TK_FloatConst);
alpha = fixed_t(FRACUNIT * sc.Float);
alpha = sc.Float;
// We don't want to allow all the options of a regular main block
// so skip to the SBarInfoCommandFlowControl.

View file

@ -116,7 +116,7 @@ static FTexture * invgems[4]; // Inventory arrows
static int hudwidth, hudheight; // current width/height for HUD display
static int statspace;
void AM_GetPosition(fixed_t & x, fixed_t & y);
DVector2 AM_GetPosition();
FTextureID GetHUDIcon(PClassInventory *cls)
@ -766,7 +766,7 @@ static void DrawInventory(player_t * CPlayer, int x,int y)
if (AltIcon.Exists() && (rover->Icon.isValid() || AltIcon.isValid()) )
{
int trans = rover==CPlayer->mo->InvSel ? OPAQUE : 0x6666;
int trans = rover==CPlayer->mo->InvSel ? 0x10000 : 0x6666;
DrawImageToBox(TexMan[AltIcon.isValid()? AltIcon : rover->Icon], x, y, 19, 25, trans);
if (rover->Amount>1)
@ -818,23 +818,20 @@ static void DrawFrags(player_t * CPlayer, int x, int y)
static void DrawCoordinates(player_t * CPlayer)
{
fixed_t x;
fixed_t y;
fixed_t z;
DVector3 pos;
char coordstr[18];
int h = SmallFont->GetHeight()+1;
if (!map_point_coordinates || !automapactive)
{
x=CPlayer->mo->_f_X();
y=CPlayer->mo->_f_Y();
z=CPlayer->mo->_f_Z();
pos = CPlayer->mo->Pos();
}
else
{
AM_GetPosition(x,y);
z = P_PointInSector(x, y)->floorplane.ZatPoint(x, y);
DVector2 apos = AM_GetPosition();
double z = P_PointInSector(apos)->floorplane.ZatPoint(apos);
pos = DVector3(apos, z);
}
int vwidth = con_scaletext==0? SCREENWIDTH : SCREENWIDTH/2;
@ -842,17 +839,17 @@ static void DrawCoordinates(player_t * CPlayer)
int xpos = vwidth - SmallFont->StringWidth("X: -00000")-6;
int ypos = 18;
mysnprintf(coordstr, countof(coordstr), "X: %d", x>>FRACBITS);
mysnprintf(coordstr, countof(coordstr), "X: %d", int(pos.X));
screen->DrawText(SmallFont, hudcolor_xyco, xpos, ypos, coordstr,
DTA_KeepRatio, true,
DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE);
mysnprintf(coordstr, countof(coordstr), "Y: %d", y>>FRACBITS);
mysnprintf(coordstr, countof(coordstr), "Y: %d", int(pos.Y));
screen->DrawText(SmallFont, hudcolor_xyco, xpos, ypos+h, coordstr,
DTA_KeepRatio, true,
DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE);
mysnprintf(coordstr, countof(coordstr), "Z: %d", z>>FRACBITS);
mysnprintf(coordstr, countof(coordstr), "Z: %d", int(pos.Z));
screen->DrawText(SmallFont, hudcolor_xyco, xpos, ypos+2*h, coordstr,
DTA_KeepRatio, true,
DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE);
@ -933,7 +930,7 @@ static void DrawTime()
const int width = SmallFont->GetCharWidth('0') * characterCount + 2; // small offset from screen's border
const int height = SmallFont->GetHeight();
DrawHudText(SmallFont, hud_timecolor, timeString, hudwidth - width, height, OPAQUE);
DrawHudText(SmallFont, hud_timecolor, timeString, hudwidth - width, height, 0x10000);
}
static bool IsAltHUDTextVisible()
@ -991,7 +988,7 @@ static void DrawLatency()
const int width = SmallFont->GetCharWidth('0') * characterCount + 2; // small offset from screen's border
const int height = SmallFont->GetHeight() * (ST_IsTimeVisible() ? 2 : 1);
DrawHudText(SmallFont, color, tempstr, hudwidth - width, height, OPAQUE);
DrawHudText(SmallFont, color, tempstr, hudwidth - width, height, 0x10000);
}
bool ST_IsLatencyVisible()
@ -1082,7 +1079,7 @@ void DrawHUD()
{
seconds = Tics2Seconds(level.totaltime);
mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
DrawHudText(SmallFont, hudcolor_ttim, printstr, hudwidth-length, bottom, OPAQUE);
DrawHudText(SmallFont, hudcolor_ttim, printstr, hudwidth-length, bottom, 0x10000);
bottom -= fonth;
}
@ -1092,14 +1089,14 @@ void DrawHUD()
{
seconds = Tics2Seconds(level.time);
mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
DrawHudText(SmallFont, hudcolor_time, printstr, hudwidth-length, bottom, OPAQUE);
DrawHudText(SmallFont, hudcolor_time, printstr, hudwidth-length, bottom, 0x10000);
bottom -= fonth;
}
// Single level time for hubs
seconds= Tics2Seconds(level.maptime);
mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
DrawHudText(SmallFont, hudcolor_ltim, printstr, hudwidth-length, bottom, OPAQUE);
DrawHudText(SmallFont, hudcolor_ltim, printstr, hudwidth-length, bottom, 0x10000);
}
ST_FormatMapName(mapname);

View file

@ -57,8 +57,8 @@
#include "../version.h"
#define XHAIRSHRINKSIZE (FRACUNIT/18)
#define XHAIRPICKUPSIZE (FRACUNIT*2+XHAIRSHRINKSIZE)
#define XHAIRSHRINKSIZE (1./18)
#define XHAIRPICKUPSIZE (2+XHAIRSHRINKSIZE)
#define POWERUPICONSIZE 32
IMPLEMENT_POINTY_CLASS(DBaseStatusBar)
@ -233,7 +233,7 @@ DBaseStatusBar::DBaseStatusBar (int reltop, int hres, int vres)
CompleteBorder = false;
Centering = false;
FixedOrigin = false;
CrosshairSize = FRACUNIT;
CrosshairSize = 1.;
RelTop = reltop;
memset(Messages, 0, sizeof(Messages));
Displacement = 0;
@ -287,7 +287,7 @@ void DBaseStatusBar::SetScaled (bool scale, bool force)
::ST_Y = ST_Y;
if (RelTop > 0)
{
Displacement = ((ST_Y * VirticalResolution / SCREENHEIGHT) - (VirticalResolution - RelTop))*FRACUNIT/RelTop;
Displacement = double((ST_Y * VirticalResolution / SCREENHEIGHT) - (VirticalResolution - RelTop))/RelTop;
}
else
{
@ -377,12 +377,12 @@ void DBaseStatusBar::Tick ()
}
// If the crosshair has been enlarged, shrink it.
if (CrosshairSize > FRACUNIT)
if (CrosshairSize > 1.)
{
CrosshairSize -= XHAIRSHRINKSIZE;
if (CrosshairSize < FRACUNIT)
if (CrosshairSize < 1.)
{
CrosshairSize = FRACUNIT;
CrosshairSize = 1.;
}
}
}
@ -567,27 +567,6 @@ void DBaseStatusBar::DrawDimImage (FTexture *img,
}
}
//---------------------------------------------------------------------------
//
// PROC DrawImage
//
// Draws a translucent image with the status bar's upper-left corner as the
// origin.
//
//---------------------------------------------------------------------------
void DBaseStatusBar::DrawFadedImage (FTexture *img,
int x, int y, fixed_t shade) const
{
if (img != NULL)
{
screen->DrawTexture (img, x + ST_X, y + ST_Y,
DTA_Alpha, shade,
DTA_Bottom320x200, Scaled,
TAG_DONE);
}
}
//---------------------------------------------------------------------------
//
// PROC DrawPartialImage
@ -1113,7 +1092,7 @@ void DBaseStatusBar::DrawCrosshair ()
static int palettecolor = 0;
DWORD color;
fixed_t size;
double size;
int w, h;
// Don't draw the crosshair in chasecam mode
@ -1130,19 +1109,19 @@ void DBaseStatusBar::DrawCrosshair ()
if (crosshairscale)
{
size = SCREENHEIGHT * FRACUNIT / 200;
size = SCREENHEIGHT / 200.;
}
else
{
size = FRACUNIT;
size = 1.;
}
if (crosshairgrow)
{
size = FixedMul (size, CrosshairSize);
size *= CrosshairSize;
}
w = (CrosshairImage->GetWidth() * size) >> FRACBITS;
h = (CrosshairImage->GetHeight() * size) >> FRACBITS;
w = int(CrosshairImage->GetWidth() * size);
h = int(CrosshairImage->GetHeight() * size);
if (crosshairhealth)
{
@ -1255,7 +1234,6 @@ void DBaseStatusBar::Draw (EHudState state)
{ // Draw current coordinates
int height = SmallFont->GetHeight();
char labels[3] = { 'X', 'Y', 'Z' };
fixed_t *value;
int i;
int vwidth;
@ -1286,10 +1264,10 @@ void DBaseStatusBar::Draw (EHudState state)
y -= height * 2;
}
fixedvec3 pos = CPlayer->mo->_f_Pos();
for (i = 2, value = &pos.z; i >= 0; y -= height, --value, --i)
DVector3 pos = CPlayer->mo->Pos();
for (i = 2; i >= 0; y -= height, --i)
{
mysnprintf (line, countof(line), "%c: %d", labels[i], *value >> FRACBITS);
mysnprintf (line, countof(line), "%c: %d", labels[i], int(pos[i]));
screen->DrawText (SmallFont, CR_GREEN, xpos, y, line,
DTA_KeepRatio, true,
DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight,

View file

@ -59,10 +59,12 @@ void FMapInfoParser::ParseSkill ()
bool thisisdefault = false;
bool acsreturnisset = false;
skill.AmmoFactor = FRACUNIT;
skill.DoubleAmmoFactor = 2*FRACUNIT;
skill.DropAmmoFactor = -1;
skill.AmmoFactor = 1.;
skill.DoubleAmmoFactor = 2.;
skill.DropAmmoFactor = -1.;
skill.DamageFactor = 1.;
skill.ArmorFactor = 1.;
skill.HealthFactor = 1.;
skill.FastMonsters = false;
skill.SlowMonsters = false;
skill.DisableCheats = false;
@ -71,7 +73,7 @@ void FMapInfoParser::ParseSkill ()
skill.AutoUseHealth = false;
skill.RespawnCounter = 0;
skill.RespawnLimit = 0;
skill.Aggressiveness = FRACUNIT;
skill.Aggressiveness = 1.;
skill.SpawnFilter = 0;
skill.ACSReturn = 0;
skill.MustConfirm = false;
@ -79,12 +81,10 @@ void FMapInfoParser::ParseSkill ()
skill.TextColor = "";
skill.Replace.Clear();
skill.Replaced.Clear();
skill.MonsterHealth = FRACUNIT;
skill.FriendlyHealth = FRACUNIT;
skill.MonsterHealth = 1.;
skill.FriendlyHealth = 1.;
skill.NoPain = false;
skill.ArmorFactor = FRACUNIT;
skill.Infighting = 0;
skill.HealthFactor = FRACUNIT;
sc.MustGetString();
skill.Name = sc.String;
@ -97,19 +97,19 @@ void FMapInfoParser::ParseSkill ()
{
ParseAssign();
sc.MustGetFloat ();
skill.AmmoFactor = FLOAT2FIXED(sc.Float);
skill.AmmoFactor = sc.Float;
}
else if (sc.Compare ("doubleammofactor"))
{
ParseAssign();
sc.MustGetFloat ();
skill.DoubleAmmoFactor = FLOAT2FIXED(sc.Float);
skill.DoubleAmmoFactor = sc.Float;
}
else if (sc.Compare ("dropammofactor"))
{
ParseAssign();
sc.MustGetFloat ();
skill.DropAmmoFactor = FLOAT2FIXED(sc.Float);
skill.DropAmmoFactor = sc.Float;
}
else if (sc.Compare ("damagefactor"))
{
@ -157,7 +157,7 @@ void FMapInfoParser::ParseSkill ()
{
ParseAssign();
sc.MustGetFloat ();
skill.Aggressiveness = FRACUNIT - FLOAT2FIXED(clamp(sc.Float, 0.,1.));
skill.Aggressiveness = 1. - clamp(sc.Float, 0.,1.);
}
else if (sc.Compare("SpawnFilter"))
{
@ -250,13 +250,13 @@ void FMapInfoParser::ParseSkill ()
{
ParseAssign();
sc.MustGetFloat();
skill.MonsterHealth = FLOAT2FIXED(sc.Float);
skill.MonsterHealth = sc.Float;
}
else if (sc.Compare("FriendlyHealth"))
{
ParseAssign();
sc.MustGetFloat();
skill.FriendlyHealth = FLOAT2FIXED(sc.Float);
skill.FriendlyHealth = sc.Float;
}
else if (sc.Compare("NoPain"))
{
@ -266,13 +266,13 @@ void FMapInfoParser::ParseSkill ()
{
ParseAssign();
sc.MustGetFloat();
skill.ArmorFactor = FLOAT2FIXED(sc.Float);
skill.ArmorFactor = sc.Float;
}
else if (sc.Compare("HealthFactor"))
{
ParseAssign();
sc.MustGetFloat();
skill.HealthFactor = FLOAT2FIXED(sc.Float);
skill.HealthFactor = sc.Float;
}
else if (sc.Compare("NoInfighting"))
{
@ -341,16 +341,6 @@ int G_SkillProperty(ESkillProperty prop)
{
switch(prop)
{
case SKILLP_AmmoFactor:
if (dmflags2 & DF2_YES_DOUBLEAMMO)
{
return AllSkills[gameskill].DoubleAmmoFactor;
}
return AllSkills[gameskill].AmmoFactor;
case SKILLP_DropAmmoFactor:
return AllSkills[gameskill].DropAmmoFactor;
case SKILLP_FastMonsters:
return AllSkills[gameskill].FastMonsters || (dmflags & DF_FAST_MONSTERS);
@ -365,9 +355,6 @@ int G_SkillProperty(ESkillProperty prop)
case SKILLP_RespawnLimit:
return AllSkills[gameskill].RespawnLimit;
case SKILLP_Aggressiveness:
return AllSkills[gameskill].Aggressiveness;
case SKILLP_DisableCheats:
return AllSkills[gameskill].DisableCheats;
@ -386,21 +373,9 @@ int G_SkillProperty(ESkillProperty prop)
case SKILLP_ACSReturn:
return AllSkills[gameskill].ACSReturn;
case SKILLP_MonsterHealth:
return AllSkills[gameskill].MonsterHealth;
case SKILLP_FriendlyHealth:
return AllSkills[gameskill].FriendlyHealth;
case SKILLP_NoPain:
return AllSkills[gameskill].NoPain;
case SKILLP_ArmorFactor:
return AllSkills[gameskill].ArmorFactor;
case SKILLP_HealthFactor:
return AllSkills[gameskill].HealthFactor;
case SKILLP_Infight:
// This property also needs to consider the level flags for the same info.
if (level.flags2 & LEVEL2_TOTALINFIGHTING) return 1;
@ -425,9 +400,34 @@ double G_SkillProperty(EFSkillProperty prop)
{
switch (prop)
{
case SKILLP_AmmoFactor:
if (dmflags2 & DF2_YES_DOUBLEAMMO)
{
return AllSkills[gameskill].DoubleAmmoFactor;
}
return AllSkills[gameskill].AmmoFactor;
case SKILLP_DropAmmoFactor:
return AllSkills[gameskill].DropAmmoFactor;
case SKILLP_ArmorFactor:
return AllSkills[gameskill].ArmorFactor;
case SKILLP_HealthFactor:
return AllSkills[gameskill].HealthFactor;
case SKILLP_DamageFactor:
return AllSkills[gameskill].DamageFactor;
break;
case SKILLP_Aggressiveness:
return AllSkills[gameskill].Aggressiveness;
case SKILLP_MonsterHealth:
return AllSkills[gameskill].MonsterHealth;
case SKILLP_FriendlyHealth:
return AllSkills[gameskill].FriendlyHealth;
}
}
return 0;

View file

@ -576,7 +576,7 @@ private:
int bars = (CurrentPop == POP_Status) ? imgINVPOP : imgINVPOP2;
int back = (CurrentPop == POP_Status) ? imgINVPBAK : imgINVPBAK2;
// Extrapolate the height of the popscreen for smoother movement
int height = clamp<int> (PopHeight + FixedMul (r_TicFrac, PopHeightChange), -POP_HEIGHT, 0);
int height = clamp<int> (PopHeight + int(r_TicFracF * PopHeightChange), -POP_HEIGHT, 0);
xscale = CleanXfac;
yscale = CleanYfac;
@ -627,7 +627,7 @@ private:
if (KeyPopScroll > 0)
{
// Extrapolate the scroll position for smoother scrolling
int scroll = MAX<int> (0,KeyPopScroll - FixedMul (r_TicFrac, 280/KEY_TIME));
int scroll = MAX<int> (0,KeyPopScroll - int(r_TicFracF * (280./KEY_TIME)));
pos -= 10;
leftcol = leftcol - 280 + scroll;
}

View file

@ -262,7 +262,7 @@ void DIntermissionScreenFader::Drawer ()
{
double factor = clamp(double(mTicker) / mDuration, 0., 1.);
if (mType == FADE_In) factor = 1.0 - factor;
int color = MAKEARGB(xs_RoundToInt(factor*255), 0,0,0);
int color = MAKEARGB(int(factor*255), 0,0,0);
if (screen->Begin2D(false))
{

View file

@ -113,7 +113,7 @@ bool FIntermissionAction::ParseKey(FScanner &sc)
if (!sc.CheckToken('-'))
{
sc.MustGetFloat();
mDuration = xs_RoundToInt(sc.Float*TICRATE);
mDuration = int(sc.Float*TICRATE);
}
else
{
@ -329,7 +329,7 @@ bool FIntermissionActionTextscreen::ParseKey(FScanner &sc)
if (!sc.CheckToken('-'))
{
sc.MustGetFloat();
mTextDelay = xs_RoundToInt(sc.Float*TICRATE);
mTextDelay = int(sc.Float*TICRATE);
}
else
{
@ -438,7 +438,7 @@ bool FIntermissionActionScroller::ParseKey(FScanner &sc)
if (!sc.CheckToken('-'))
{
sc.MustGetFloat();
mScrollDelay = xs_RoundToInt(sc.Float*TICRATE);
mScrollDelay = int(sc.Float*TICRATE);
}
else
{
@ -453,7 +453,7 @@ bool FIntermissionActionScroller::ParseKey(FScanner &sc)
if (!sc.CheckToken('-'))
{
sc.MustGetFloat();
mScrollTime = xs_RoundToInt(sc.Float*TICRATE);
mScrollTime = int(sc.Float*TICRATE);
}
else
{

View file

@ -7993,7 +7993,7 @@ scriptwait:
float x = ACSToFloat(Stack[optstart-3]);
float y = ACSToFloat(Stack[optstart-2]);
float holdTime = ACSToFloat(Stack[optstart-1]);
fixed_t alpha;
float alpha;
DHUDMessage *msg;
if (type & HUDMSG_COLORSTRING)
@ -8008,13 +8008,13 @@ scriptwait:
switch (type & 0xFF)
{
default: // normal
alpha = (optstart < sp) ? Stack[optstart] : OPAQUE;
alpha = (optstart < sp) ? ACSToFloat(Stack[optstart]) : 1.f;
msg = new DHUDMessage (activefont, work, x, y, hudwidth, hudheight, color, holdTime);
break;
case 1: // fade out
{
float fadeTime = (optstart < sp) ? ACSToFloat(Stack[optstart]) : 0.5f;
alpha = (optstart < sp-1) ? Stack[optstart+1] : OPAQUE;
alpha = (optstart < sp-1) ? ACSToFloat(Stack[optstart+1]) : 1.f;
msg = new DHUDMessageFadeOut (activefont, work, x, y, hudwidth, hudheight, color, holdTime, fadeTime);
}
break;
@ -8022,7 +8022,7 @@ scriptwait:
{
float typeTime = (optstart < sp) ? ACSToFloat(Stack[optstart]) : 0.05f;
float fadeTime = (optstart < sp-1) ? ACSToFloat(Stack[optstart+1]) : 0.5f;
alpha = (optstart < sp-2) ? Stack[optstart+2] : FRACUNIT;
alpha = (optstart < sp-2) ? ACSToFloat(Stack[optstart+2]) : 1.f;
msg = new DHUDMessageTypeOnFadeOut (activefont, work, x, y, hudwidth, hudheight, color, typeTime, holdTime, fadeTime);
}
break;
@ -8030,7 +8030,7 @@ scriptwait:
{
float inTime = (optstart < sp) ? ACSToFloat(Stack[optstart]) : 0.5f;
float outTime = (optstart < sp-1) ? ACSToFloat(Stack[optstart+1]) : 0.5f;
alpha = (optstart < sp-2) ? Stack[optstart+2] : OPAQUE;
alpha = (optstart < sp-2) ? ACSToFloat(Stack[optstart + 2]) : 1.f;
msg = new DHUDMessageFadeInOut (activefont, work, x, y, hudwidth, hudheight, color, holdTime, inTime, outTime);
}
break;

View file

@ -410,7 +410,7 @@ bool AActor::SuggestMissileAttack (fixed_t dist)
if (flags4 & MF4_MISSILEMORE) dist >>= 1;
if (flags4 & MF4_MISSILEEVENMORE) dist >>= 3;
int mmc = FixedMul(MinMissileChance, G_SkillProperty(SKILLP_Aggressiveness));
int mmc = int(MinMissileChance * G_SkillProperty(SKILLP_Aggressiveness));
return pr_checkmissilerange() >= MIN<int> (dist >> FRACBITS, mmc);
}
@ -3097,11 +3097,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_ActiveAndUnblock)
void ModifyDropAmount(AInventory *inv, int dropamount)
{
int flagmask = IF_IGNORESKILL;
fixed_t dropammofactor = G_SkillProperty(SKILLP_DropAmmoFactor);
double dropammofactor = G_SkillProperty(SKILLP_DropAmmoFactor);
// Default drop amount is half of regular amount * regular ammo multiplication
if (dropammofactor == -1)
{
dropammofactor = FRACUNIT/2;
dropammofactor = 0.5;
flagmask = 0;
}
@ -3109,7 +3109,7 @@ void ModifyDropAmount(AInventory *inv, int dropamount)
{
if (flagmask != 0 && inv->IsKindOf(RUNTIME_CLASS(AAmmo)))
{
inv->Amount = FixedMul(dropamount, dropammofactor);
inv->Amount = int(dropamount * dropammofactor);
inv->ItemFlags |= IF_IGNORESKILL;
}
else
@ -3123,21 +3123,21 @@ void ModifyDropAmount(AInventory *inv, int dropamount)
int amount = static_cast<PClassAmmo *>(inv->GetClass())->DropAmount;
if (amount <= 0)
{
amount = MAX(1, FixedMul(inv->Amount, dropammofactor));
amount = MAX(1, int(inv->Amount * dropammofactor));
}
inv->Amount = amount;
inv->ItemFlags |= flagmask;
}
else if (inv->IsKindOf (RUNTIME_CLASS(AWeaponGiver)))
{
static_cast<AWeaponGiver *>(inv)->DropAmmoFactor = FIXED2DBL(dropammofactor);
static_cast<AWeaponGiver *>(inv)->DropAmmoFactor = dropammofactor;
inv->ItemFlags |= flagmask;
}
else if (inv->IsKindOf (RUNTIME_CLASS(AWeapon)))
{
// The same goes for ammo from a weapon.
static_cast<AWeapon *>(inv)->AmmoGive1 = FixedMul(static_cast<AWeapon *>(inv)->AmmoGive1, dropammofactor);
static_cast<AWeapon *>(inv)->AmmoGive2 = FixedMul(static_cast<AWeapon *>(inv)->AmmoGive2, dropammofactor);
static_cast<AWeapon *>(inv)->AmmoGive1 = int(static_cast<AWeapon *>(inv)->AmmoGive1 * dropammofactor);
static_cast<AWeapon *>(inv)->AmmoGive2 = int(static_cast<AWeapon *>(inv)->AmmoGive2 * dropammofactor);
inv->ItemFlags |= flagmask;
}
else if (inv->IsKindOf (RUNTIME_CLASS(ADehackedPickup)))

View file

@ -6457,12 +6457,12 @@ int AActor::SpawnHealth() const
}
else if (flags & MF_FRIENDLY)
{
int adj = FixedMul(defhealth, G_SkillProperty(SKILLP_FriendlyHealth));
int adj = int(defhealth * G_SkillProperty(SKILLP_FriendlyHealth));
return (adj <= 0) ? 1 : adj;
}
else
{
int adj = FixedMul(defhealth, G_SkillProperty(SKILLP_MonsterHealth));
int adj = int(defhealth * G_SkillProperty(SKILLP_MonsterHealth));
return (adj <= 0) ? 1 : adj;
}
}

View file

@ -131,4 +131,13 @@ bool Trace (fixed_t x, fixed_t y, fixed_t z, sector_t *sector,
DWORD traceFlags=0,
ETraceStatus (*callback)(FTraceResults &res, void *)=NULL, void *callbackdata=NULL);
inline bool Trace(const DVector3 &start, sector_t *sector, const DVector3 &direction, double maxDist,
ActorFlags ActorMask, DWORD WallMask, AActor *ignore, FTraceResults &res, DWORD traceFlags = 0,
ETraceStatus(*callback)(FTraceResults &res, void *) = NULL, void *callbackdata = NULL)
{
return Trace(FLOAT2FIXED(start.X), FLOAT2FIXED(start.Y), FLOAT2FIXED(start.Z), sector,
FLOAT2FIXED(direction.X), FLOAT2FIXED(direction.Y), FLOAT2FIXED(direction.Z), FLOAT2FIXED(maxDist),
ActorMask, WallMask, ignore, res, traceFlags, callback, callbackdata);
}
#endif //__P_TRACE_H__

View file

@ -1354,8 +1354,7 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_
}
else
{
vis->texturemid -= FixedMul (StatusBar->GetDisplacement (),
FLOAT2FIXED(weapon->YAdjust));
vis->texturemid -= FLOAT2FIXED(StatusBar->GetDisplacement () * weapon->YAdjust);
}
}
}

View file

@ -126,6 +126,7 @@ fixed_t viewsin, viewtansin;
AActor *camera; // [RH] camera to draw from. doesn't have to be a player
fixed_t r_TicFrac; // [RH] Fractional tic to render
double r_TicFracF; // same as floating point
DWORD r_FrameTime; // [RH] Time this frame started drawing (in ms)
bool r_NoInterpolate;
bool r_showviewer;
@ -1010,6 +1011,7 @@ void R_SetupFrame (AActor *actor)
{
r_TicFrac = FRACUNIT;
}
r_TicFracF = FIXED2DBL(r_TicFrac);
R_InterpolateView (player, r_TicFrac, iview);

View file

@ -34,6 +34,7 @@ extern bool LocalKeyboardTurner; // [RH] The local player used the keyboard t
extern int WidescreenRatio;
extern fixed_t r_TicFrac;
extern double r_TicFracF;
extern DWORD r_FrameTime;
extern int extralight;
extern unsigned int R_OldBlend;

View file

@ -1284,7 +1284,7 @@ static void ParseDamageDefinition(FScanner &sc)
{
sc.MustGetFloat();
dtd.DefaultFactor = sc.Float;
if (dtd.DefaultFactor == 0) dtd.ReplaceFactor = true; // Multiply by 0 yields 0: FixedMul(damage, FixedMul(factor, 0)) is more wasteful than FixedMul(factor, 0)
if (dtd.DefaultFactor == 0) dtd.ReplaceFactor = true;
}
else if (sc.Compare("REPLACEFACTOR"))
{

View file

@ -1031,7 +1031,7 @@ struct TAngle
return FLOAT2ANGLE(Degrees);
}
TVector2<vec_t> ToVector(vec_t length) const
TVector2<vec_t> ToVector(vec_t length = 1) const
{
return TVector2<vec_t>(length * Cos(), length * Sin());
}