- 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; return DVector2((m_x + m_w / 2) / MAPUNIT, (m_y + m_h / 2) / MAPUNIT);
y = (m_y + m_h/2) << FRACTOMAPBITS;
} }
//============================================================================= //=============================================================================

View file

@ -69,6 +69,7 @@
#include "farchive.h" #include "farchive.h"
#include "p_setup.h" #include "p_setup.h"
#include "p_spec.h" #include "p_spec.h"
#include "r_utility.h"
#include "math/cmath.h" #include "math/cmath.h"
static FRandom pr_script("FScript"); static FRandom pr_script("FScript");
@ -1463,6 +1464,7 @@ void FParser::SF_SetCamera(void)
if (t_argc < 4) newcamera->Angles.Pitch = 0.; if (t_argc < 4) newcamera->Angles.Pitch = 0.;
else newcamera->Angles.Pitch = clamp(floatvalue(t_argv[3]), -50., 50.) * (20. / 32.); else newcamera->Angles.Pitch = clamp(floatvalue(t_argv[3]), -50., 50.) * (20. / 32.);
player->camera=newcamera; player->camera=newcamera;
R_ResetViewInterpolation();
} }
} }
@ -3052,173 +3054,57 @@ void FParser::SF_SetWeapon()
// //
// movecamera(camera, targetobj, targetheight, movespeed, targetangle, anglespeed) // 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) 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)) if (CheckArgs(6))
{ {
cam = actorvalue(t_argv[0]); AActor *cam = actorvalue(t_argv[0]);
target = actorvalue(t_argv[1]); AActor *target = actorvalue(t_argv[1]);
if(!cam || !target) if(!cam || !target)
{ {
script_error("invalid target for camera\n"); return; script_error("invalid target for camera\n"); return;
} }
DVector2 fdist = cam->Vec2To(target); double targetheight = floatvalue(t_argv[2]);
fixed_t distx = FLOAT2FIXED(fdist.X); DVector3 campos = cam->Pos();
fixed_t disty = FLOAT2FIXED(fdist.Y); DVector3 targpos = DVector3(target->Pos(), targetheight);
fixed_t camx = FLOAT2FIXED(cam->X()); if (campos != targpos)
fixed_t camy = FLOAT2FIXED(cam->Y()); {
fixed_t camz = FLOAT2FIXED(cam->Z()); 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);
DAngle targetangle = floatvalue(t_argv[4]);
targetheight = fixedvalue(t_argv[2]); DAngle anglespeed = floatvalue(t_argv[5]);
movespeed = fixedvalue(t_argv[3]); DAngle diffangle = deltaangle(cam->Angles.Yaw, targetangle);
targetangle = (angle_t)FixedToAngle(fixedvalue(t_argv[4]));
anglespeed = (angle_t)FixedToAngle(fixedvalue(t_argv[5])); if (movespeed > 0 && anglespeed == 0.)
// 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)
{ {
angledist = diff180; if (!finished) targetangle = diffangle * movespeed / movelen;
angledir = 1;
}
else if(quad1 == 3 && quad2 == 0)
{
angledist = diff180;
angledir = -1;
} }
else else
{ {
angledist = bigangle - smallangle; targetangle = cam->Angles.Yaw + anglespeed;
if(angledist > ANG180)
{
angledist = diff180;
angledir = targetangle > camangle ? -1 : 1;
}
else
angledir = targetangle > camangle ? 1 : -1;
} }
}
// 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->radius = 1 / 8192.;
cam->Height = 1 / 8192.; cam->Height = 1 / 8192.;
if ((x != camx || y != camy) && !P_TryMove(cam, FIXED2FLOAT(x), FIXED2FLOAT(y), true)) cam->SetOrigin(movepos, true);
{ t_return.value.i = 1;
Printf("Illegal camera move to (%f, %f)\n", x/65536.f, y/65536.f); }
return; else
{
t_return.value.i = 0;
} }
cam->SetZ(FIXED2FLOAT(z));
t_return.type = svt_int; 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 // haleyjd: 8-17
if(left.type == svt_fixed || right.type == svt_fixed) if(left.type == svt_fixed || right.type == svt_fixed)
{ {
result.type = svt_fixed; result.setDouble(floatvalue(left) * floatvalue(right));
result.value.f = FixedMul(fixedvalue(left), fixedvalue(right));
} }
else else
{ {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -145,7 +145,7 @@ void DEarthquake::Tick ()
double DEarthquake::GetModWave(double waveMultiplier) const 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)); 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 // extra ammo in baby mode and nightmare mode
if (!(this->ItemFlags&IF_IGNORESKILL)) 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)); ammo = static_cast<AAmmo *>(other->FindInventory (ammotype));
if (ammo == NULL) if (ammo == NULL)
@ -418,7 +418,7 @@ bool AWeapon::AddExistingAmmo (AAmmo *ammo, int amount)
// extra ammo in baby mode and nightmare mode // extra ammo in baby mode and nightmare mode
if (!(ItemFlags&IF_IGNORESKILL)) if (!(ItemFlags&IF_IGNORESKILL))
{ {
amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor)); amount = int(amount * G_SkillProperty(SKILLP_AmmoFactor));
} }
ammo->Amount += amount; ammo->Amount += amount;
if (ammo->Amount > ammo->MaxAmount && !sv_unlimited_pickup) 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; Font = font;
VisibilityFlags = 0; VisibilityFlags = 0;
Style = STYLE_Translucent; Style = STYLE_Translucent;
Alpha = FRACUNIT; Alpha = 1.;
ResetText (SourceText); ResetText (SourceText);
} }
@ -221,7 +221,7 @@ void DHUDMessage::Serialize (FArchive &arc)
if (SaveVersion < 3824) if (SaveVersion < 3824)
{ {
Style = STYLE_Translucent; Style = STYLE_Translucent;
Alpha = FRACUNIT; Alpha = 1.;
} }
else 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, screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_CleanNoMove, clean, DTA_CleanNoMove, clean,
DTA_Alpha, Alpha, DTA_AlphaF, Alpha,
DTA_RenderStyle, Style, DTA_RenderStyle, Style,
TAG_DONE); 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, screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_VirtualWidth, SCREENWIDTH/2, DTA_VirtualWidth, SCREENWIDTH/2,
DTA_VirtualHeight, SCREENHEIGHT/2, DTA_VirtualHeight, SCREENHEIGHT/2,
DTA_Alpha, Alpha, DTA_AlphaF, Alpha,
DTA_RenderStyle, Style, DTA_RenderStyle, Style,
DTA_KeepRatio, true, DTA_KeepRatio, true,
TAG_DONE); TAG_DONE);
@ -498,7 +498,7 @@ void DHUDMessage::DoDraw (int linenum, int x, int y, bool clean, int hudheight)
DTA_ClipRight, ClipRight, DTA_ClipRight, ClipRight,
DTA_ClipTop, ClipTop, DTA_ClipTop, ClipTop,
DTA_ClipBottom, ClipBot, DTA_ClipBottom, ClipBot,
DTA_Alpha, Alpha, DTA_AlphaF, Alpha,
DTA_RenderStyle, Style, DTA_RenderStyle, Style,
TAG_DONE); TAG_DONE);
} }
@ -570,15 +570,14 @@ void DHUDMessageFadeOut::DoDraw (int linenum, int x, int y, bool clean, int hudh
} }
else else
{ {
fixed_t trans = -(Tics - FadeOutTics) * FRACUNIT / FadeOutTics; float trans = float(Alpha * -(Tics - FadeOutTics) / FadeOutTics);
trans = FixedMul(trans, Alpha);
if (hudheight == 0) if (hudheight == 0)
{ {
if (con_scaletext <= 1) if (con_scaletext <= 1)
{ {
screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_CleanNoMove, clean, DTA_CleanNoMove, clean,
DTA_Alpha, trans, DTA_AlphaF, trans,
DTA_RenderStyle, Style, DTA_RenderStyle, Style,
TAG_DONE); 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, screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_VirtualWidth, SCREENWIDTH/2, DTA_VirtualWidth, SCREENWIDTH/2,
DTA_VirtualHeight, SCREENHEIGHT/2, DTA_VirtualHeight, SCREENHEIGHT/2,
DTA_Alpha, trans, DTA_AlphaF, trans,
DTA_RenderStyle, Style, DTA_RenderStyle, Style,
DTA_KeepRatio, true, DTA_KeepRatio, true,
TAG_DONE); TAG_DONE);
@ -602,7 +601,7 @@ void DHUDMessageFadeOut::DoDraw (int linenum, int x, int y, bool clean, int hudh
DTA_ClipRight, ClipRight, DTA_ClipRight, ClipRight,
DTA_ClipTop, ClipTop, DTA_ClipTop, ClipTop,
DTA_ClipBottom, ClipBot, DTA_ClipBottom, ClipBot,
DTA_Alpha, trans, DTA_AlphaF, trans,
DTA_RenderStyle, Style, DTA_RenderStyle, Style,
TAG_DONE); TAG_DONE);
} }
@ -671,15 +670,14 @@ void DHUDMessageFadeInOut::DoDraw (int linenum, int x, int y, bool clean, int hu
{ {
if (State == 0) if (State == 0)
{ {
fixed_t trans = Tics * FRACUNIT / FadeInTics; float trans = float(Alpha * Tics / FadeInTics);
trans = FixedMul(trans, Alpha);
if (hudheight == 0) if (hudheight == 0)
{ {
if (con_scaletext <= 1) if (con_scaletext <= 1)
{ {
screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_CleanNoMove, clean, DTA_CleanNoMove, clean,
DTA_Alpha, trans, DTA_AlphaF, trans,
DTA_RenderStyle, Style, DTA_RenderStyle, Style,
TAG_DONE); 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, screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_VirtualWidth, SCREENWIDTH/2, DTA_VirtualWidth, SCREENWIDTH/2,
DTA_VirtualHeight, SCREENHEIGHT/2, DTA_VirtualHeight, SCREENHEIGHT/2,
DTA_Alpha, trans, DTA_AlphaF, trans,
DTA_RenderStyle, Style, DTA_RenderStyle, Style,
DTA_KeepRatio, true, DTA_KeepRatio, true,
TAG_DONE); TAG_DONE);
@ -703,7 +701,7 @@ void DHUDMessageFadeInOut::DoDraw (int linenum, int x, int y, bool clean, int hu
DTA_ClipRight, ClipRight, DTA_ClipRight, ClipRight,
DTA_ClipTop, ClipTop, DTA_ClipTop, ClipTop,
DTA_ClipBottom, ClipBot, DTA_ClipBottom, ClipBot,
DTA_Alpha, trans, DTA_AlphaF, trans,
DTA_RenderStyle, Style, DTA_RenderStyle, Style,
TAG_DONE); 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, screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_CleanNoMove, clean, DTA_CleanNoMove, clean,
DTA_TextLen, LineVisible, DTA_TextLen, LineVisible,
DTA_Alpha, Alpha, DTA_AlphaF, Alpha,
DTA_RenderStyle, Style, DTA_RenderStyle, Style,
TAG_DONE); TAG_DONE);
} }
@ -869,7 +867,7 @@ void DHUDMessageTypeOnFadeOut::DoDraw (int linenum, int x, int y, bool clean, in
DTA_VirtualHeight, SCREENHEIGHT/2, DTA_VirtualHeight, SCREENHEIGHT/2,
DTA_KeepRatio, true, DTA_KeepRatio, true,
DTA_TextLen, LineVisible, DTA_TextLen, LineVisible,
DTA_Alpha, Alpha, DTA_AlphaF, Alpha,
DTA_RenderStyle, Style, DTA_RenderStyle, Style,
TAG_DONE); TAG_DONE);
} }
@ -883,7 +881,7 @@ void DHUDMessageTypeOnFadeOut::DoDraw (int linenum, int x, int y, bool clean, in
DTA_ClipRight, ClipRight, DTA_ClipRight, ClipRight,
DTA_ClipTop, ClipTop, DTA_ClipTop, ClipTop,
DTA_ClipBottom, ClipBot, DTA_ClipBottom, ClipBot,
DTA_Alpha, Alpha, DTA_AlphaF, Alpha,
DTA_TextLen, LineVisible, DTA_TextLen, LineVisible,
DTA_RenderStyle, Style, DTA_RenderStyle, Style,
TAG_DONE); TAG_DONE);

View file

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

View file

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

View file

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

View file

@ -48,7 +48,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
translatable(false), type(NORMAL_IMAGE), image(-1), maxwidth(-1), translatable(false), type(NORMAL_IMAGE), image(-1), maxwidth(-1),
maxheight(-1), spawnScaleX(1.0f), spawnScaleY(1.0f), flags(0), maxheight(-1), spawnScaleX(1.0f), spawnScaleY(1.0f), flags(0),
applyscale(false), offset(static_cast<Offset> (TOP|LEFT)), 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; int w = maxwidth, h = maxheight;
// We must calculate this per frame in order to prevent glitches with cl_capfps true. // 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) if(flags & DI_DRAWINBOX)
{ {
@ -234,7 +234,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged); SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged);
texture = NULL; texture = NULL;
alpha = OPAQUE; alpha = 1.;
if (applyscale) if (applyscale)
{ {
spawnScaleX = spawnScaleY = 1.0f; spawnScaleX = spawnScaleY = 1.0f;
@ -282,7 +282,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
if (harmor->Slots[armorType] > 0 && harmor->SlotsIncrement[armorType] > 0) if (harmor->Slots[armorType] > 0 && harmor->SlotsIncrement[armorType] > 0)
{ {
//combine the alpha values //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]; texture = statusBar->Images[image];
} }
else else
@ -350,7 +350,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
Offset offset; Offset offset;
FTexture *texture; 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, // Since we're not going to call our parent's tick() method,
// be sure to set the alpha value properly. // be sure to set the alpha value properly.
alpha = FRACUNIT; alpha = 1.;
return; return;
} }
CommandDrawImage::Tick(block, statusBar, hudChanged); CommandDrawImage::Tick(block, statusBar, hudChanged);
@ -1641,9 +1641,9 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
} }
else 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(), statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgCURSOR], imgx-4, imgy+2, block->XOffset(), block->YOffset(), flashAlpha, block->FullScreenOffsets(),
translatable, false, offset); translatable, false, offset);
} }
@ -1736,7 +1736,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
artiflashTick--; artiflashTick--;
if(itemflashFade > 0) if(itemflashFade > 0)
{ {
itemflashFade -= FRACUNIT/14; itemflashFade -= 1./14;
if(itemflashFade < 0) if(itemflashFade < 0)
itemflashFade = 0; itemflashFade = 0;
} }
@ -1747,7 +1747,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
CommandDrawNumber::Tick(block, statusBar, hudChanged); CommandDrawNumber::Tick(block, statusBar, hudChanged);
} }
static void Flash() { artiflashTick = 4; itemflashFade = FRACUNIT*3/4; } static void Flash() { artiflashTick = 4; itemflashFade = 0.75; }
protected: protected:
bool alternateOnEmpty; bool alternateOnEmpty;
bool artiflash; bool artiflash;
@ -1755,10 +1755,10 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
bool itemflash; bool itemflash;
static int artiflashTick; static int artiflashTick;
static fixed_t itemflashFade; static double itemflashFade;
}; };
int CommandDrawSelectedInventory::artiflashTick = 0; int CommandDrawSelectedInventory::artiflashTick = 0;
int CommandDrawSelectedInventory::itemflashFade = FRACUNIT*3/4; double CommandDrawSelectedInventory::itemflashFade = 0.75;
void DSBarInfo::FlashItem(const PClass *itemtype) void DSBarInfo::FlashItem(const PClass *itemtype)
{ {
@ -2110,9 +2110,9 @@ class CommandDrawInventoryBar : public SBarInfoCommand
{ {
int spacing = GetCounterSpacing(statusBar); int spacing = GetCounterSpacing(statusBar);
int bgalpha = block->Alpha(); double bgalpha = block->Alpha();
if(translucent) if(translucent)
bgalpha = fixed_t(block->Alpha() * HX_SHADOW); bgalpha *= HX_SHADOW;
AInventory *item; AInventory *item;
unsigned int i = 0; unsigned int i = 0;
@ -2492,10 +2492,10 @@ class CommandDrawBar : public SBarInfoCommand
FTexture *fg = statusBar->Images[foreground]; FTexture *fg = statusBar->Images[foreground];
FTexture *bg = (background != -1) ? statusBar->Images[background] : NULL; FTexture *bg = (background != -1) ? statusBar->Images[background] : NULL;
fixed_t value = drawValue; double value = drawValue;
if(border != 0) 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 //Draw the whole foreground
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets()); 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()) 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()); statusBar->DrawGraphic(bg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
else 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} // {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; int sizeOfImage = (horizontal ? fg->GetScaledWidth()-border*2 : fg->GetScaledHeight()-border*2);
clip[(!horizontal)|((horizontal ? !reverse : reverse)<<1)] = sizeOfImage - FixedMul(sizeOfImage, value); Clip[(!horizontal)|((horizontal ? !reverse : reverse)<<1)] = sizeOfImage - sizeOfImage *value;
// Draw background // Draw background
if(border != 0) if(border != 0)
{ {
for(unsigned int i = 0;i < 4;i++) 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()) 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 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 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) void Parse(FScanner &sc, bool fullScreenOffsets)
{ {
@ -2651,7 +2651,7 @@ class CommandDrawBar : public SBarInfoCommand
} }
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged) void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
{ {
fixed_t value = 0; double value = 0;
int max = 0; int max = 0;
switch(type) switch(type)
{ {
@ -2791,9 +2791,7 @@ class CommandDrawBar : public SBarInfoCommand
if(max != 0 && value > 0) if(max != 0 && value > 0)
{ {
value = (value << FRACBITS) / max; value = MIN(value / max, 1.);
if(value > FRACUNIT)
value = FRACUNIT;
} }
else else
value = 0; value = 0;
@ -2802,14 +2800,14 @@ class CommandDrawBar : public SBarInfoCommand
// [BL] Since we used a percentage (in order to get the most fluid animation) // [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 // 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]) 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; drawValue = value;
else if(value < drawValue) else if (value < drawValue)
drawValue -= clamp<fixed_t>((drawValue - value) >> 2, 1, FixedDiv(interpolationSpeed<<FRACBITS, FRACUNIT*100)); drawValue -= clamp<double>((drawValue - value) / 4, 1 / 65536., interpolationSpeed / 100.);
else if(drawValue < value) else if (drawValue < value)
drawValue += clamp<fixed_t>((value - drawValue) >> 2, 1, FixedDiv(interpolationSpeed<<FRACBITS, FRACUNIT*100)); drawValue += clamp<double>((value - drawValue) / 4, 1 / 65536., interpolationSpeed / 100.);
} }
else else
drawValue = value; drawValue = value;
@ -2883,8 +2881,8 @@ class CommandDrawBar : public SBarInfoCommand
SBarInfoCoordinate y; SBarInfoCoordinate y;
int interpolationSpeed; int interpolationSpeed;
fixed_t drawValue; double drawValue;
fixed_t pixel; double pixel;
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -3448,7 +3446,7 @@ class CommandAlpha : public SBarInfoMainBlock
void Parse(FScanner &sc, bool fullScreenOffsets) void Parse(FScanner &sc, bool fullScreenOffsets)
{ {
sc.MustGetToken(TK_FloatConst); 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 // We don't want to allow all the options of a regular main block
// so skip to the SBarInfoCommandFlowControl. // 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 hudwidth, hudheight; // current width/height for HUD display
static int statspace; static int statspace;
void AM_GetPosition(fixed_t & x, fixed_t & y); DVector2 AM_GetPosition();
FTextureID GetHUDIcon(PClassInventory *cls) 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()) ) 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); DrawImageToBox(TexMan[AltIcon.isValid()? AltIcon : rover->Icon], x, y, 19, 25, trans);
if (rover->Amount>1) if (rover->Amount>1)
@ -818,23 +818,20 @@ static void DrawFrags(player_t * CPlayer, int x, int y)
static void DrawCoordinates(player_t * CPlayer) static void DrawCoordinates(player_t * CPlayer)
{ {
fixed_t x; DVector3 pos;
fixed_t y;
fixed_t z;
char coordstr[18]; char coordstr[18];
int h = SmallFont->GetHeight()+1; int h = SmallFont->GetHeight()+1;
if (!map_point_coordinates || !automapactive) if (!map_point_coordinates || !automapactive)
{ {
x=CPlayer->mo->_f_X(); pos = CPlayer->mo->Pos();
y=CPlayer->mo->_f_Y();
z=CPlayer->mo->_f_Z();
} }
else else
{ {
AM_GetPosition(x,y); DVector2 apos = AM_GetPosition();
z = P_PointInSector(x, y)->floorplane.ZatPoint(x, y); double z = P_PointInSector(apos)->floorplane.ZatPoint(apos);
pos = DVector3(apos, z);
} }
int vwidth = con_scaletext==0? SCREENWIDTH : SCREENWIDTH/2; 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 xpos = vwidth - SmallFont->StringWidth("X: -00000")-6;
int ypos = 18; 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, screen->DrawText(SmallFont, hudcolor_xyco, xpos, ypos, coordstr,
DTA_KeepRatio, true, DTA_KeepRatio, true,
DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE); 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, screen->DrawText(SmallFont, hudcolor_xyco, xpos, ypos+h, coordstr,
DTA_KeepRatio, true, DTA_KeepRatio, true,
DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE); 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, screen->DrawText(SmallFont, hudcolor_xyco, xpos, ypos+2*h, coordstr,
DTA_KeepRatio, true, DTA_KeepRatio, true,
DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE); 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 width = SmallFont->GetCharWidth('0') * characterCount + 2; // small offset from screen's border
const int height = SmallFont->GetHeight(); 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() 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 width = SmallFont->GetCharWidth('0') * characterCount + 2; // small offset from screen's border
const int height = SmallFont->GetHeight() * (ST_IsTimeVisible() ? 2 : 1); 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() bool ST_IsLatencyVisible()
@ -1082,7 +1079,7 @@ void DrawHUD()
{ {
seconds = Tics2Seconds(level.totaltime); seconds = Tics2Seconds(level.totaltime);
mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60); 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; bottom -= fonth;
} }
@ -1092,14 +1089,14 @@ void DrawHUD()
{ {
seconds = Tics2Seconds(level.time); seconds = Tics2Seconds(level.time);
mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60); 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; bottom -= fonth;
} }
// Single level time for hubs // Single level time for hubs
seconds= Tics2Seconds(level.maptime); seconds= Tics2Seconds(level.maptime);
mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60); 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); ST_FormatMapName(mapname);

View file

@ -57,8 +57,8 @@
#include "../version.h" #include "../version.h"
#define XHAIRSHRINKSIZE (FRACUNIT/18) #define XHAIRSHRINKSIZE (1./18)
#define XHAIRPICKUPSIZE (FRACUNIT*2+XHAIRSHRINKSIZE) #define XHAIRPICKUPSIZE (2+XHAIRSHRINKSIZE)
#define POWERUPICONSIZE 32 #define POWERUPICONSIZE 32
IMPLEMENT_POINTY_CLASS(DBaseStatusBar) IMPLEMENT_POINTY_CLASS(DBaseStatusBar)
@ -233,7 +233,7 @@ DBaseStatusBar::DBaseStatusBar (int reltop, int hres, int vres)
CompleteBorder = false; CompleteBorder = false;
Centering = false; Centering = false;
FixedOrigin = false; FixedOrigin = false;
CrosshairSize = FRACUNIT; CrosshairSize = 1.;
RelTop = reltop; RelTop = reltop;
memset(Messages, 0, sizeof(Messages)); memset(Messages, 0, sizeof(Messages));
Displacement = 0; Displacement = 0;
@ -287,7 +287,7 @@ void DBaseStatusBar::SetScaled (bool scale, bool force)
::ST_Y = ST_Y; ::ST_Y = ST_Y;
if (RelTop > 0) if (RelTop > 0)
{ {
Displacement = ((ST_Y * VirticalResolution / SCREENHEIGHT) - (VirticalResolution - RelTop))*FRACUNIT/RelTop; Displacement = double((ST_Y * VirticalResolution / SCREENHEIGHT) - (VirticalResolution - RelTop))/RelTop;
} }
else else
{ {
@ -377,12 +377,12 @@ void DBaseStatusBar::Tick ()
} }
// If the crosshair has been enlarged, shrink it. // If the crosshair has been enlarged, shrink it.
if (CrosshairSize > FRACUNIT) if (CrosshairSize > 1.)
{ {
CrosshairSize -= XHAIRSHRINKSIZE; 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 // PROC DrawPartialImage
@ -1113,7 +1092,7 @@ void DBaseStatusBar::DrawCrosshair ()
static int palettecolor = 0; static int palettecolor = 0;
DWORD color; DWORD color;
fixed_t size; double size;
int w, h; int w, h;
// Don't draw the crosshair in chasecam mode // Don't draw the crosshair in chasecam mode
@ -1130,19 +1109,19 @@ void DBaseStatusBar::DrawCrosshair ()
if (crosshairscale) if (crosshairscale)
{ {
size = SCREENHEIGHT * FRACUNIT / 200; size = SCREENHEIGHT / 200.;
} }
else else
{ {
size = FRACUNIT; size = 1.;
} }
if (crosshairgrow) if (crosshairgrow)
{ {
size = FixedMul (size, CrosshairSize); size *= CrosshairSize;
} }
w = (CrosshairImage->GetWidth() * size) >> FRACBITS; w = int(CrosshairImage->GetWidth() * size);
h = (CrosshairImage->GetHeight() * size) >> FRACBITS; h = int(CrosshairImage->GetHeight() * size);
if (crosshairhealth) if (crosshairhealth)
{ {
@ -1255,7 +1234,6 @@ void DBaseStatusBar::Draw (EHudState state)
{ // Draw current coordinates { // Draw current coordinates
int height = SmallFont->GetHeight(); int height = SmallFont->GetHeight();
char labels[3] = { 'X', 'Y', 'Z' }; char labels[3] = { 'X', 'Y', 'Z' };
fixed_t *value;
int i; int i;
int vwidth; int vwidth;
@ -1286,10 +1264,10 @@ void DBaseStatusBar::Draw (EHudState state)
y -= height * 2; y -= height * 2;
} }
fixedvec3 pos = CPlayer->mo->_f_Pos(); DVector3 pos = CPlayer->mo->Pos();
for (i = 2, value = &pos.z; i >= 0; y -= height, --value, --i) 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, screen->DrawText (SmallFont, CR_GREEN, xpos, y, line,
DTA_KeepRatio, true, DTA_KeepRatio, true,
DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight,

View file

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

View file

@ -576,7 +576,7 @@ private:
int bars = (CurrentPop == POP_Status) ? imgINVPOP : imgINVPOP2; int bars = (CurrentPop == POP_Status) ? imgINVPOP : imgINVPOP2;
int back = (CurrentPop == POP_Status) ? imgINVPBAK : imgINVPBAK2; int back = (CurrentPop == POP_Status) ? imgINVPBAK : imgINVPBAK2;
// Extrapolate the height of the popscreen for smoother movement // 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; xscale = CleanXfac;
yscale = CleanYfac; yscale = CleanYfac;
@ -627,7 +627,7 @@ private:
if (KeyPopScroll > 0) if (KeyPopScroll > 0)
{ {
// Extrapolate the scroll position for smoother scrolling // 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; pos -= 10;
leftcol = leftcol - 280 + scroll; leftcol = leftcol - 280 + scroll;
} }

View file

@ -262,7 +262,7 @@ void DIntermissionScreenFader::Drawer ()
{ {
double factor = clamp(double(mTicker) / mDuration, 0., 1.); double factor = clamp(double(mTicker) / mDuration, 0., 1.);
if (mType == FADE_In) factor = 1.0 - factor; 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)) if (screen->Begin2D(false))
{ {

View file

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

View file

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

View file

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

View file

@ -6457,12 +6457,12 @@ int AActor::SpawnHealth() const
} }
else if (flags & MF_FRIENDLY) 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; return (adj <= 0) ? 1 : adj;
} }
else else
{ {
int adj = FixedMul(defhealth, G_SkillProperty(SKILLP_MonsterHealth)); int adj = int(defhealth * G_SkillProperty(SKILLP_MonsterHealth));
return (adj <= 0) ? 1 : adj; 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, DWORD traceFlags=0,
ETraceStatus (*callback)(FTraceResults &res, void *)=NULL, void *callbackdata=NULL); 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__ #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 else
{ {
vis->texturemid -= FixedMul (StatusBar->GetDisplacement (), vis->texturemid -= FLOAT2FIXED(StatusBar->GetDisplacement () * weapon->YAdjust);
FLOAT2FIXED(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 AActor *camera; // [RH] camera to draw from. doesn't have to be a player
fixed_t r_TicFrac; // [RH] Fractional tic to render 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) DWORD r_FrameTime; // [RH] Time this frame started drawing (in ms)
bool r_NoInterpolate; bool r_NoInterpolate;
bool r_showviewer; bool r_showviewer;
@ -1010,6 +1011,7 @@ void R_SetupFrame (AActor *actor)
{ {
r_TicFrac = FRACUNIT; r_TicFrac = FRACUNIT;
} }
r_TicFracF = FIXED2DBL(r_TicFrac);
R_InterpolateView (player, r_TicFrac, iview); 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 int WidescreenRatio;
extern fixed_t r_TicFrac; extern fixed_t r_TicFrac;
extern double r_TicFracF;
extern DWORD r_FrameTime; extern DWORD r_FrameTime;
extern int extralight; extern int extralight;
extern unsigned int R_OldBlend; extern unsigned int R_OldBlend;

View file

@ -1284,7 +1284,7 @@ static void ParseDamageDefinition(FScanner &sc)
{ {
sc.MustGetFloat(); sc.MustGetFloat();
dtd.DefaultFactor = sc.Float; 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")) else if (sc.Compare("REPLACEFACTOR"))
{ {

View file

@ -1031,7 +1031,7 @@ struct TAngle
return FLOAT2ANGLE(Degrees); 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()); return TVector2<vec_t>(length * Cos(), length * Sin());
} }