C4Real: Rename FIXEDnnn functions to C4REALnnn

stable-5.1
Nicolas Hake 2010-05-19 05:19:49 +02:00
parent c9c59264cf
commit 59f5ee646c
14 changed files with 55 additions and 56 deletions

View File

@ -1505,8 +1505,8 @@ void C4Game::CastObjects(C4ID id, C4Object *pCreator, int32_t num, int32_t level
{
CreateObject(id,pCreator,iOwner,
tx,ty,Random(360),
FIXED10(Random(2*level+1)-level),
FIXED10(Random(2*level+1)-level),
C4REAL10(Random(2*level+1)-level),
C4REAL10(Random(2*level+1)-level),
itofix(Random(3)+1), iController);
}
}
@ -1518,7 +1518,7 @@ void C4Game::BlastCastObjects(C4ID id, C4Object *pCreator, int32_t num, int32_t
{
CreateObject(id,pCreator,NO_OWNER,
tx,ty,Random(360),
FIXED10(Random(61)-30), FIXED10(Random(61)-40),
C4REAL10(Random(61)-30), C4REAL10(Random(61)-40),
itofix(Random(3)+1), iController);
}
}

View File

@ -68,7 +68,7 @@ C4Landscape::~C4Landscape()
void C4Landscape::ScenarioInit()
{
// Gravity
Gravity = FIXED100(Game.C4S.Landscape.Gravity.Evaluate()) /5;
Gravity = C4REAL100(Game.C4S.Landscape.Gravity.Evaluate()) /5;
// Opens
LeftOpen=Game.C4S.Landscape.LeftOpen;
RightOpen=Game.C4S.Landscape.RightOpen;
@ -1231,13 +1231,13 @@ bool C4Landscape::InsertMaterial(int32_t mat, int32_t tx, int32_t ty, int32_t vx
// Try slide
while (FindMatSlide(tx,ty,+1,mdens,::MaterialMap.Map[mat].MaxSlide))
if (GetDensity(tx,ty+1)<mdens)
{ ::PXS.Create(mat,itofix(tx),itofix(ty),FIXED10(vx),FIXED10(vy)); return true; }
{ ::PXS.Create(mat,itofix(tx),itofix(ty),C4REAL10(vx),C4REAL10(vy)); return true; }
// Try reaction with material below
C4MaterialReaction *pReact; int32_t tmat;
if ((pReact = ::MaterialMap.GetReactionUnsafe(mat, tmat=GetMat(tx,ty+Sign(GravAccel)))))
{
C4Real fvx=FIXED10(vx), fvy=FIXED10(vy);
C4Real fvx=C4REAL10(vx), fvy=C4REAL10(vy);
if ((*pReact->pFunc)(pReact, tx,ty, tx,ty+Sign(GravAccel), fvx,fvy, mat,tmat, meePXSPos,NULL))
{
// the material to be inserted killed itself in some material reaction below
@ -1695,7 +1695,7 @@ void C4Landscape::Default()
ScanX=0;
ScanSpeed=2;
LeftOpen=RightOpen=TopOpen=BottomOpen=0;
Gravity=FIXED100(20); // == 0.2
Gravity=C4REAL100(20); // == 0.2
MapSeed=0; NoScan=false;
pMapCreator=NULL;
Modulation=0;
@ -3027,7 +3027,7 @@ void C4Landscape::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(RightOpen, "RightOpen", 0));
pComp->Value(mkNamingAdapt(TopOpen, "TopOpen", 0));
pComp->Value(mkNamingAdapt(BottomOpen, "BottomOpen", 0));
pComp->Value(mkNamingAdapt(mkCastIntAdapt(Gravity), "Gravity", FIXED100(20)));
pComp->Value(mkNamingAdapt(mkCastIntAdapt(Gravity), "Gravity", C4REAL100(20)));
pComp->Value(mkNamingAdapt(Modulation, "MatModulation", 0U));
pComp->Value(mkNamingAdapt(Mode, "Mode", C4LSC_Undefined));
}

View File

@ -520,7 +520,7 @@ bool C4MCOverlay::CheckMask(int32_t iX, int32_t iY)
int32_t Seed2; Seed2=Seed;
for (int32_t l=0; l<Lambda+1; ++l)
{
for (C4Real d=itofix(2); d<6; d+=FIXED10(15))
for (C4Real d=itofix(2); d<6; d+=C4REAL10(15))
{
dX += Sin(((dX / 7 + itofix(Seed2) / ZoomX + dY) / j + d) * Rad2Grad) * j / 2;
dY += Cos(((dY / 7 + itofix(Seed2) / ZoomY + dX) / j - d) * Rad2Grad) * j / 2;

View File

@ -603,7 +603,7 @@ bool mrfInsertCheck(int32_t &iX, int32_t &iY, C4Real &fXDir, C4Real &fYDir, int3
if (::MaterialMap.Map[iPxsMat].SplashRate && !Random(::MaterialMap.Map[iPxsMat].SplashRate))
{
fYDir = -fYDir/8;
fXDir = fXDir/8 + FIXED100(Random(200) - 100);
fXDir = fXDir/8 + C4REAL100(Random(200) - 100);
if (fYDir) return false;
}
@ -621,7 +621,7 @@ bool mrfInsertCheck(int32_t &iX, int32_t &iY, C4Real &fXDir, C4Real &fYDir, int3
if (iPxsMat == iLsMat)
{ iX = iSlideX; iY = iSlideY; fXDir = 0; return false; }
// Accelerate into the direction
fXDir = (fXDir * 10 + Sign(iSlideX - iX)) / 11 + FIXED10(Random(5)-2);
fXDir = (fXDir * 10 + Sign(iSlideX - iX)) / 11 + C4REAL10(Random(5)-2);
// Slide target in range? Move there directly.
if (Abs(iX - iSlideX) <= Abs(fixtoi(fXDir)))
{
@ -849,8 +849,8 @@ bool C4MaterialMap::mrfScript(C4MaterialReaction *pReaction, int32_t &iX, int32_
// changes to pos/speed detected
if (pfPosChanged) *pfPosChanged = true;
iX=iX2; iY=iY2;
fXDir = FIXED100(iXDir2);
fYDir = FIXED100(iYDir2);
fXDir = C4REAL100(iXDir2);
fYDir = C4REAL100(iYDir2);
}
// OK; done
return false;

View File

@ -66,8 +66,8 @@ void C4PXS::Execute()
{
// Air speed: Wind plus some random
int32_t iWind = GBackWind(iX, iY);
C4Real txdir = itofix(iWind, 15) + FIXED256(Random(1200) - 600);
C4Real tydir = FIXED256(Random(1200) - 600);
C4Real txdir = itofix(iWind, 15) + C4REAL256(Random(1200) - 600);
C4Real tydir = C4REAL256(Random(1200) - 600);
// Air friction, based on WindDrift. MaxSpeed is ignored.
int32_t iWindDrift = Max(::MaterialMap.Map[Mat].WindDrift - 20, 0);

View File

@ -712,9 +712,9 @@ bool fxStdExec(C4Particle *particle, C4Object *target)
{
// Air speed: Wind plus some random
int32_t wind_speed = GBackWind(int32_t(dx), int32_t(dy));
//C4Real txdir = itofix(wind_speed, 15) + FIXED256(Random(1200) - 600);
//C4Real txdir = itofix(wind_speed, 15) + C4REAL256(Random(1200) - 600);
float txdir = wind_speed / 15.0f;
//C4Real tydir = FIXED256(Random(1200) - 600);
//C4Real tydir = C4REAL256(Random(1200) - 600);
float tydir = 0;
// Air friction, based on WindDrift.

View File

@ -217,7 +217,7 @@ void C4Sky::Execute()
if (x>=itofix(Width)) x-=itofix(Width);
if (y>=itofix(Height)) y-=itofix(Height);
// update speed
if (ParallaxMode == C4SkyPM_Wind) xdir=FIXED100(::Weather.Wind);
if (ParallaxMode == C4SkyPM_Wind) xdir=C4REAL100(::Weather.Wind);
}
void C4Sky::Draw(C4TargetFacet &cgo)

View File

@ -389,12 +389,12 @@ void C4Command::MoveTo()
{
C4Real dx = itofix(Tx._getInt()) - cObj->fix_x, dy = itofix(Ty) - cObj->fix_y;
// normalize
C4Real dScale = FIXED100(cObj->GetPhysical()->Float) / Max(Abs(dx), Abs(dy));
C4Real dScale = C4REAL100(cObj->GetPhysical()->Float) / Max(Abs(dx), Abs(dy));
dx *= dScale; dy *= dScale;
// difference to momentum
dx -= cObj->xdir; dy -= cObj->ydir;
// steer
if (Abs(dx)+Abs(dy) < FIXED100(20)) cObj->Action.ComDir = COMD_None;
if (Abs(dx)+Abs(dy) < C4REAL100(20)) cObj->Action.ComDir = COMD_None;
else if (Abs(dy) * 3 < dx) cObj->Action.ComDir = COMD_Right;
else if (Abs(dy) * 3 < -dx) cObj->Action.ComDir = COMD_Left;
else if (Abs(dx) * 3 < dy) cObj->Action.ComDir = COMD_Down;

View File

@ -31,17 +31,17 @@
/* Some physical constants */
const C4Real FRedirect=FIXED100(50);
const C4Real FFriction=FIXED100(30);
const C4Real FRedirect=C4REAL100(50);
const C4Real FFriction=C4REAL100(30);
const C4Real FixFullCircle=itofix(360),FixHalfCircle=FixFullCircle/2;
const C4Real FloatFriction=FIXED100(2);
const C4Real RotateAccel=FIXED100(20);
const C4Real FloatAccel=FIXED100(10);
const C4Real WalkAccel=FIXED100(8);
const C4Real WalkBreak=FIXED100(16);
const C4Real ScaleAccel=FIXED100(20);
const C4Real SwimAccel=FIXED100(7);
const C4Real HitSpeed1=FIXED100(150); // Hit Event
const C4Real FloatFriction=C4REAL100(2);
const C4Real RotateAccel=C4REAL100(20);
const C4Real FloatAccel=C4REAL100(10);
const C4Real WalkAccel=C4REAL100(8);
const C4Real WalkBreak=C4REAL100(16);
const C4Real ScaleAccel=C4REAL100(20);
const C4Real SwimAccel=C4REAL100(7);
const C4Real HitSpeed1=C4REAL100(150); // Hit Event
const C4Real HitSpeed2=itofix(2); // Cross Check Hit
const C4Real HitSpeed3=itofix(6); // Scale disable, kneel
const C4Real HitSpeed4=itofix(8); // Flat
@ -262,7 +262,7 @@ void C4Object::DoMovement()
{
// Horizontal movement - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Move to target
while (Abs<C4Real>(fix_x - ctcox) > FIXED10(5))
while (Abs<C4Real>(fix_x - ctcox) > C4REAL10(5))
{
// Next step
int step = Sign<C4Real>(new_x - fix_x);
@ -286,7 +286,7 @@ void C4Object::DoMovement()
VerticalBounds(new_y);
ctcoy=fixtoi(new_y);
// Move to target
while (Abs<C4Real>(fix_y - ctcoy) > FIXED10(5))
while (Abs<C4Real>(fix_y - ctcoy) > C4REAL10(5))
{
// Next step
int step = Sign<C4Real>(new_y - fix_y);
@ -326,9 +326,9 @@ void C4Object::DoMovement()
bool at_xovr = false, at_yovr = false;
// Set next step target
int step_x = 0, step_y = 0;
if (Abs<C4Real>(fix_x - ctcox) > FIXED10(5))
if (Abs<C4Real>(fix_x - ctcox) > C4REAL10(5))
step_x = Sign<C4Real>(new_x - fix_x);
if (Abs<C4Real>(fix_y - ctcoy) > FIXED10(5))
if (Abs<C4Real>(fix_y - ctcoy) > C4REAL10(5))
step_y = Sign<C4Real>(new_y - fix_y);
int32_t ctx = GetX() + step_x; int32_t cty = GetY() + step_y;
// Attachment check
@ -353,7 +353,7 @@ void C4Object::DoMovement()
if (at_xovr) { ctcox=GetX(); xdir=Fix0; new_x = fix_x; }
if (at_yovr) { ctcoy=GetY(); ydir=Fix0; new_y = fix_y; }
}
while (Abs<C4Real>(fix_x - ctcox) > FIXED10(5) || Abs<C4Real>(fix_y - ctcoy) > FIXED10(5));
while (Abs<C4Real>(fix_x - ctcox) > C4REAL10(5) || Abs<C4Real>(fix_y - ctcoy) > C4REAL10(5));
}
fix_x = new_x;
fix_y = new_y;

View File

@ -3671,7 +3671,7 @@ void C4Object::ContactAction()
case DFA_FLIGHT:
// High Speed Flight: Tumble
if ((OCF & OCF_HitSpeed3) || fDisabled)
{ ObjectActionTumble(this,DIR_Left,FIXED100(+150),Fix0); break; }
{ ObjectActionTumble(this,DIR_Left,C4REAL100(+150),Fix0); break; }
// Else
else if (pPhysical->CanScale)
{ ObjectActionScale(this,DIR_Left); return; }
@ -3722,7 +3722,7 @@ void C4Object::ContactAction()
case DFA_FLIGHT:
// High Speed Flight: Tumble
if ((OCF & OCF_HitSpeed3) || fDisabled)
{ ObjectActionTumble(this,DIR_Right,FIXED100(-150),Fix0); break; }
{ ObjectActionTumble(this,DIR_Right,C4REAL100(-150),Fix0); break; }
// Else Scale
else if (pPhysical->CanScale)
{ ObjectActionScale(this,DIR_Right); return; }
@ -4509,7 +4509,7 @@ void C4Object::ExecAction()
case COMD_Down: tydir=+lftspeed; break;
}
// Lift object
if (!Action.Target->Lift(tydir,FIXED100(50)))
if (!Action.Target->Lift(tydir,C4REAL100(50)))
{ SetAction(0); return; }
// Check LiftTop
if (Def->LiftTop)
@ -4522,7 +4522,7 @@ void C4Object::ExecAction()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case DFA_FLOAT:
// Float speed
lLimit=FIXED100(pPhysical->Float);
lLimit=C4REAL100(pPhysical->Float);
xlFloatAccel = Max(Min(lLimit+xdir,FloatAccel),itofix(0));
xrFloatAccel = Max(Min(lLimit-xdir,FloatAccel),itofix(0));
yuFloatAccel = Max(Min(lLimit+ydir,FloatAccel),itofix(0));

View File

@ -672,8 +672,8 @@ bool ObjectComDrop(C4Object *cObj, C4Object *pThing)
int32_t iOutposReduction = 1; // don't exit object too far forward during jump
if (iProc != DFA_SCALE) // never diagonal during scaling (can have com into wall during scaling!)
{
if (ComDirLike(cObj->Action.ComDir, COMD_Left)) { tdir=-1; right = 0; if (cObj->xdir < FIXED10(15) && !isHanglingOrSwimming) --iOutposReduction; }
if (ComDirLike(cObj->Action.ComDir, COMD_Right)) { tdir=+1; right = 1; if (cObj->xdir > FIXED10(-15) && !isHanglingOrSwimming) --iOutposReduction; }
if (ComDirLike(cObj->Action.ComDir, COMD_Left)) { tdir=-1; right = 0; if (cObj->xdir < C4REAL10(15) && !isHanglingOrSwimming) --iOutposReduction; }
if (ComDirLike(cObj->Action.ComDir, COMD_Right)) { tdir=+1; right = 1; if (cObj->xdir > C4REAL10(-15) && !isHanglingOrSwimming) --iOutposReduction; }
}
// Exit object
pThing->Exit(cObj->GetX() + (cObj->Shape.x + cObj->Shape.Wdt * right) * !!tdir * iOutposReduction,
@ -760,7 +760,7 @@ bool ObjectComPunch(C4Object *cObj, C4Object *pTarget, int32_t punch)
if (fBlowStopped) return false;
// Hard punch
if (punch>=10)
if (ObjectActionTumble(pTarget,pTarget->Action.Dir,FIXED100(150)*tdir,itofix(-2)))
if (ObjectActionTumble(pTarget,pTarget->Action.Dir,C4REAL100(150)*tdir,itofix(-2)))
{
pTarget->Call(PSF_CatchBlow,&C4AulParSet(C4VInt(punch),
C4VObj(cObj)));
@ -768,7 +768,7 @@ bool ObjectComPunch(C4Object *cObj, C4Object *pTarget, int32_t punch)
}
// Regular punch
if (ObjectActionGetPunched(pTarget,FIXED100(250)*tdir,Fix0))
if (ObjectActionGetPunched(pTarget,C4REAL100(250)*tdir,Fix0))
{
pTarget->Call(PSF_CatchBlow,&C4AulParSet(C4VInt(punch),
C4VObj(cObj)));

View File

@ -808,8 +808,8 @@ void Splash(int32_t tx, int32_t ty, int32_t amt, C4Object *pByObj)
if (GBackLiquid(tx,ty) && !GBackSemiSolid(tx, sy))
::PXS.Create(::Landscape.ExtractMaterial(tx,ty),
itofix(tx),itofix(sy),
FIXED100(Random(151)-75),
FIXED100(-Random(200)));
C4REAL100(Random(151)-75),
C4REAL100(-Random(200)));
}
}
// Splash sound

View File

@ -737,7 +737,7 @@ static C4Void FnSetXDir(C4AulObjectContext *cthr, long nxdir, long iPrec)
// update xdir
cthr->Obj->xdir=itofix(nxdir, iPrec);
// special: negative dirs must be rounded
//if (nxdir<0) pObj->xdir += FIXED100(-50)/iPrec;
//if (nxdir<0) pObj->xdir += C4REAL100(-50)/iPrec;
cthr->Obj->Mobile=1;
// success
return C4VNull;
@ -750,7 +750,7 @@ static C4Void FnSetRDir(C4AulObjectContext *cthr, long nrdir, long iPrec)
// update rdir
cthr->Obj->rdir=itofix(nrdir, iPrec);
// special: negative dirs must be rounded
//if (nrdir<0) pObj->rdir += FIXED100(-50)/iPrec;
//if (nrdir<0) pObj->rdir += C4REAL100(-50)/iPrec;
cthr->Obj->Mobile=1;
// success
return C4VNull;
@ -763,7 +763,7 @@ static C4Void FnSetYDir(C4AulObjectContext *cthr, long nydir, long iPrec)
// update ydir
cthr->Obj->ydir=itofix(nydir, iPrec);
// special: negative dirs must be rounded
//if (nydir<0) pObj->ydir += FIXED100(-50)/iPrec;
//if (nydir<0) pObj->ydir += C4REAL100(-50)/iPrec;
cthr->Obj->Mobile=1;
return C4VNull;
}

View File

@ -273,10 +273,10 @@ inline C4Fixed itofix(int32_t x, int32_t prec) { return C4Fixed(x, prec); }
// additional functions
inline C4Real Sin(const C4Real &fAngle) { return fAngle.sin_deg(); }
inline C4Real Cos(const C4Real &fAngle) { return fAngle.cos_deg(); }
inline C4Real FIXED100(int x) { return itofix(x, 100); }
//inline C4Real FIXED256(int x) { return itofix(x, 256); }
inline C4Real FIXED256(int x) { C4Fixed r; r.val = x * FIXED_FPF / 256; return r; }
inline C4Real FIXED10(int x) { return itofix(x, 10); }
inline C4Real C4REAL100(int x) { return itofix(x, 100); }
//inline C4Real C4REAL256(int x) { return itofix(x, 256); }
inline C4Real C4REAL256(int x) { C4Fixed r; r.val = x * FIXED_FPF / 256; return r; }
inline C4Real C4REAL10(int x) { return itofix(x, 10); }
#else
@ -313,12 +313,11 @@ inline C4Real ftofix(float x) { return x; }
// additional functions
inline C4Real Sin(C4Real x) { return float(sin(x * 3.141592f / 180)); }
inline C4Real Cos(C4Real x) { return float(cos(x * 3.141592f / 180)); }
inline C4Real FIXED100(int x) { return float(x) / 100; }
inline C4Real FIXED256(int x) { return float(x) / 256; }
inline C4Real FIXED10(int x) { return float(x) / 10; }
inline C4Real C4REAL100(int x) { return float(x) / 100; }
inline C4Real C4REAL256(int x) { return float(x) / 256; }
inline C4Real C4REAL10(int x) { return float(x) / 10; }
#endif
// define 0
const C4Real Fix0 = itofix(0);