forked from Mirrors/openclonk
Rename FIXED to C4Real
There's already a typedef struct _FIXED FIXED; in wingdi.h, which conflicts with the definition of FIXED in OpenClonk.
parent
938da3b30c
commit
e27ecd59b5
|
@ -346,14 +346,14 @@ set(OC_CLONK_SOURCES
|
|||
src/lib/C4NameList.h
|
||||
src/lib/C4Random.cpp
|
||||
src/lib/C4Random.h
|
||||
src/lib/C4Real.cpp
|
||||
src/lib/C4Real.h
|
||||
src/lib/C4Rect.cpp
|
||||
src/lib/C4Rect.h
|
||||
src/lib/C4RTF.cpp
|
||||
src/lib/C4RTF.h
|
||||
src/lib/C4Stat.cpp
|
||||
src/lib/C4Stat.h
|
||||
src/lib/Fixed.cpp
|
||||
src/lib/Fixed.h
|
||||
src/lib/PathFinder.cpp
|
||||
src/lib/PathFinder.h
|
||||
src/lib/Standard.cpp
|
||||
|
|
|
@ -97,14 +97,14 @@ src/lib/C4LogBuf.cpp \
|
|||
src/lib/C4LogBuf.h \
|
||||
src/lib/C4Random.cpp \
|
||||
src/lib/C4Random.h \
|
||||
src/lib/C4Real.cpp \
|
||||
src/lib/C4Real.h \
|
||||
src/lib/C4Rect.cpp \
|
||||
src/lib/C4Rect.h \
|
||||
src/lib/C4RTF.cpp \
|
||||
src/lib/C4RTF.h \
|
||||
src/lib/C4Stat.cpp \
|
||||
src/lib/C4Stat.h \
|
||||
src/lib/Fixed.cpp \
|
||||
src/lib/Fixed.h \
|
||||
src/lib/PathFinder.cpp \
|
||||
src/lib/PathFinder.h \
|
||||
src/lib/Standard.cpp \
|
||||
|
|
|
@ -978,7 +978,7 @@ bool C4Game::IsPaused()
|
|||
C4Object* C4Game::NewObject( C4PropList *pDef, C4Object *pCreator,
|
||||
int32_t iOwner, C4ObjectInfo *pInfo,
|
||||
int32_t iX, int32_t iY, int32_t iR,
|
||||
FIXED xdir, FIXED ydir, FIXED rdir,
|
||||
C4Real xdir, C4Real ydir, C4Real rdir,
|
||||
int32_t iCon, int32_t iController)
|
||||
{
|
||||
// Safety
|
||||
|
@ -1021,7 +1021,7 @@ void C4Game::DeleteObjects(bool fDeleteInactive)
|
|||
|
||||
C4Object* C4Game::CreateObject(C4ID id, C4Object *pCreator, int32_t iOwner,
|
||||
int32_t x, int32_t y, int32_t r,
|
||||
FIXED xdir, FIXED ydir, FIXED rdir, int32_t iController)
|
||||
C4Real xdir, C4Real ydir, C4Real rdir, int32_t iController)
|
||||
{
|
||||
C4Def *pDef;
|
||||
// Get pDef
|
||||
|
@ -1036,7 +1036,7 @@ C4Object* C4Game::CreateObject(C4ID id, C4Object *pCreator, int32_t iOwner,
|
|||
|
||||
C4Object* C4Game::CreateObject(C4PropList * PropList, C4Object *pCreator, int32_t iOwner,
|
||||
int32_t x, int32_t y, int32_t r,
|
||||
FIXED xdir, FIXED ydir, FIXED rdir, int32_t iController)
|
||||
C4Real xdir, C4Real ydir, C4Real rdir, int32_t iController)
|
||||
{
|
||||
C4Def *pDef;
|
||||
// Get pDef
|
||||
|
|
|
@ -200,10 +200,10 @@ public:
|
|||
void ClearPointers(C4PropList *cobj);
|
||||
C4Object *CreateObject(C4PropList * type, C4Object *pCreator, int32_t owner=NO_OWNER,
|
||||
int32_t x=50, int32_t y=50, int32_t r=0,
|
||||
FIXED xdir=Fix0, FIXED ydir=Fix0, FIXED rdir=Fix0, int32_t iController=NO_OWNER);
|
||||
C4Real xdir=Fix0, C4Real ydir=Fix0, C4Real rdir=Fix0, int32_t iController=NO_OWNER);
|
||||
C4Object *CreateObject(C4ID type, C4Object *pCreator, int32_t owner=NO_OWNER,
|
||||
int32_t x=50, int32_t y=50, int32_t r=0,
|
||||
FIXED xdir=Fix0, FIXED ydir=Fix0, FIXED rdir=Fix0, int32_t iController=NO_OWNER);
|
||||
C4Real xdir=Fix0, C4Real ydir=Fix0, C4Real rdir=Fix0, int32_t iController=NO_OWNER);
|
||||
C4Object *CreateObjectConstruction(C4PropList * type,
|
||||
C4Object *pCreator,
|
||||
int32_t owner,
|
||||
|
@ -306,7 +306,7 @@ protected:
|
|||
C4Object *NewObject( C4PropList *ndef, C4Object *pCreator,
|
||||
int32_t owner, C4ObjectInfo *info,
|
||||
int32_t tx, int32_t ty, int32_t tr,
|
||||
FIXED xdir, FIXED ydir, FIXED rdir,
|
||||
C4Real xdir, C4Real ydir, C4Real rdir,
|
||||
int32_t con, int32_t iController);
|
||||
void ClearObjectPtrs(C4Object *tptr);
|
||||
void ObjectRemovalCheck();
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "PlatformAbstraction.h"
|
||||
#include "Standard.h"
|
||||
#include "C4Prototypes.h"
|
||||
#include "Fixed.h"
|
||||
#include "C4Real.h"
|
||||
#include "StdBuf.h"
|
||||
#include "StdFile.h"
|
||||
#include "StdResStr2.h"
|
||||
|
|
|
@ -136,7 +136,7 @@ struct C4RCSetPix
|
|||
struct C4RCExecObj
|
||||
{
|
||||
int Number; // object number
|
||||
FIXED fx,fy,fr;
|
||||
C4Real fx,fy,fr;
|
||||
};
|
||||
|
||||
struct C4RCMassMover
|
||||
|
@ -175,7 +175,7 @@ struct C4RCRotVtx
|
|||
struct C4RCExecPXS
|
||||
{
|
||||
// pos
|
||||
FIXED x,y;
|
||||
C4Real x,y;
|
||||
// mat
|
||||
int32_t iMat;
|
||||
// execution pos
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#ifndef INC_C4Physics
|
||||
#define INC_C4Physics
|
||||
|
||||
#include <Fixed.h>
|
||||
#include "C4Real.h"
|
||||
|
||||
const int StableRange=10;
|
||||
const int AttachRange=5;
|
||||
|
@ -31,10 +31,10 @@ const int CornerRange=AttachRange+2;
|
|||
|
||||
#define GravAccel (::Landscape.Gravity)
|
||||
|
||||
extern const FIXED FloatAccel;
|
||||
extern const FIXED HitSpeed1,HitSpeed2,HitSpeed3,HitSpeed4;
|
||||
extern const FIXED WalkAccel,WalkBreak,ScaleAccel,SwimAccel;
|
||||
extern const FIXED FloatFriction;
|
||||
extern const FIXED RotateAccel;
|
||||
extern const C4Real FloatAccel;
|
||||
extern const C4Real HitSpeed1,HitSpeed2,HitSpeed3,HitSpeed4;
|
||||
extern const C4Real WalkAccel,WalkBreak,ScaleAccel,SwimAccel;
|
||||
extern const C4Real FloatFriction;
|
||||
extern const C4Real RotateAccel;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1237,7 +1237,7 @@ bool C4Landscape::InsertMaterial(int32_t mat, int32_t tx, int32_t ty, int32_t vx
|
|||
C4MaterialReaction *pReact; int32_t tmat;
|
||||
if ((pReact = ::MaterialMap.GetReactionUnsafe(mat, tmat=GetMat(tx,ty+Sign(GravAccel)))))
|
||||
{
|
||||
FIXED fvx=FIXED10(vx), fvy=FIXED10(vy);
|
||||
C4Real fvx=FIXED10(vx), fvy=FIXED10(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
|
||||
|
@ -2070,11 +2070,11 @@ bool PathFreeIgnoreVehicle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32
|
|||
return ForLine(x1,y1,x2,y2,&PathFreeIgnoreVehiclePix,0,ix,iy);
|
||||
}
|
||||
|
||||
int32_t TrajectoryDistance(int32_t iFx, int32_t iFy, FIXED iXDir, FIXED iYDir, int32_t iTx, int32_t iTy)
|
||||
int32_t TrajectoryDistance(int32_t iFx, int32_t iFy, C4Real iXDir, C4Real iYDir, int32_t iTx, int32_t iTy)
|
||||
{
|
||||
int32_t iClosest = Distance(iFx,iFy,iTx,iTy);
|
||||
// Follow free trajectory, take closest point distance
|
||||
FIXED cx = itofix(iFx), cy = itofix(iFy);
|
||||
C4Real cx = itofix(iFx), cy = itofix(iFy);
|
||||
int32_t cdis;
|
||||
while (Inside(fixtoi(cx),0,GBackWdt-1) && Inside(fixtoi(cy),0,GBackHgt-1) && !GBackSolid(fixtoi(cx), fixtoi(cy)))
|
||||
{
|
||||
|
@ -2088,7 +2088,7 @@ int32_t TrajectoryDistance(int32_t iFx, int32_t iFy, FIXED iXDir, FIXED iYDir, i
|
|||
const int32_t C4LSC_Throwing_MaxVertical = 50,
|
||||
C4LSC_Throwing_MaxHorizontal = 60;
|
||||
|
||||
bool FindThrowingPosition(int32_t iTx, int32_t iTy, FIXED fXDir, FIXED fYDir, int32_t iHeight, int32_t &rX, int32_t &rY)
|
||||
bool FindThrowingPosition(int32_t iTx, int32_t iTy, C4Real fXDir, C4Real fYDir, int32_t iHeight, int32_t &rX, int32_t &rY)
|
||||
{
|
||||
|
||||
// Start underneath throwing target
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
bool NoScan; // ExecuteScan() disabled
|
||||
int32_t ScanX,ScanSpeed; // SyncClearance-NoSave //
|
||||
int32_t LeftOpen,RightOpen,TopOpen,BottomOpen;
|
||||
FIXED Gravity;
|
||||
C4Real Gravity;
|
||||
uint32_t Modulation; // landscape blit modulation; 0 means normal
|
||||
int32_t MapSeed; // random seed for MapToLandscape
|
||||
C4Sky Sky;
|
||||
|
@ -262,7 +262,7 @@ bool FindLiquid(int32_t &rx, int32_t &ry, int32_t width, int32_t height);
|
|||
bool FindSurfaceLiquid(int32_t &rx, int32_t &ry, int32_t width, int32_t height);
|
||||
bool FindLevelGround(int32_t &rx, int32_t &ry, int32_t width, int32_t hrange);
|
||||
bool FindConSiteSpot(int32_t &rx, int32_t &ry, int32_t wdt, int32_t hgt, DWORD category, int32_t hrange=-1);
|
||||
bool FindThrowingPosition(int32_t iTx, int32_t iTy, FIXED fXDir, FIXED fYDir, int32_t iHeight, int32_t &rX, int32_t &rY);
|
||||
bool FindThrowingPosition(int32_t iTx, int32_t iTy, C4Real fXDir, C4Real fYDir, int32_t iHeight, int32_t &rX, int32_t &rY);
|
||||
bool PathFree(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t *ix=NULL, int32_t *iy=NULL);
|
||||
bool PathFreeIgnoreVehicle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t *ix=NULL, int32_t *iy=NULL);
|
||||
bool FindClosestFree(int32_t &rX, int32_t &rY, int32_t iAngle1, int32_t iAngle2, int32_t iExcludeAngle1, int32_t iExcludeAngle2);
|
||||
|
|
|
@ -509,18 +509,18 @@ bool C4MCOverlay::CheckMask(int32_t iX, int32_t iY)
|
|||
rc.x=iX; rc.y=iY; rc.Rotate=Rotate; rc.Turbulence=Turbulence;
|
||||
AddDbgRec(RCT_MCT1, &rc, sizeof(rc));
|
||||
#endif
|
||||
FIXED dX=itofix(iX); FIXED dY=itofix(iY);
|
||||
C4Real dX=itofix(iX); C4Real dY=itofix(iY);
|
||||
// apply turbulence
|
||||
if (Turbulence)
|
||||
{
|
||||
const FIXED Rad2Grad = itofix(3754936, 65536);
|
||||
const C4Real Rad2Grad = itofix(3754936, 65536);
|
||||
int32_t j=3;
|
||||
for (int32_t i=10; i<=Turbulence; i*=10)
|
||||
{
|
||||
int32_t Seed2; Seed2=Seed;
|
||||
for (int32_t l=0; l<Lambda+1; ++l)
|
||||
{
|
||||
for (FIXED d=itofix(2); d<6; d+=FIXED10(15))
|
||||
for (C4Real d=itofix(2); d<6; d+=FIXED10(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;
|
||||
|
@ -538,7 +538,7 @@ bool C4MCOverlay::CheckMask(int32_t iX, int32_t iY)
|
|||
double o=atan(dY/dX);
|
||||
dX=cos(o+dRot)*l;
|
||||
dY=sin(o+dRot)*l;*/
|
||||
FIXED dXo(dX), dYo(dY);
|
||||
C4Real dXo(dX), dYo(dY);
|
||||
dX = dXo*Cos(itofix(Rotate)) - dYo*Sin(itofix(Rotate));
|
||||
dY = dYo*Cos(itofix(Rotate)) + dXo*Sin(itofix(Rotate));
|
||||
}
|
||||
|
|
|
@ -186,7 +186,7 @@ bool C4MassMover::Corrosion(int32_t dx, int32_t dy)
|
|||
C4MaterialReaction *pReact = ::MaterialMap.GetReactionUnsafe(Mat, tmat);
|
||||
if (pReact)
|
||||
{
|
||||
FIXED xdir=Fix0, ydir=Fix0;
|
||||
C4Real xdir=Fix0, ydir=Fix0;
|
||||
if ((*pReact->pFunc)(pReact, x,y, x+dx,y+dy, xdir,ydir, Mat,tmat, meeMassMove, NULL))
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -593,7 +593,7 @@ C4MaterialReaction *C4MaterialMap::GetReaction(int32_t iPXSMat, int32_t iLandsca
|
|||
}
|
||||
|
||||
|
||||
bool mrfInsertCheck(int32_t &iX, int32_t &iY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, bool *pfPosChanged)
|
||||
bool mrfInsertCheck(int32_t &iX, int32_t &iY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, bool *pfPosChanged)
|
||||
{
|
||||
// always manipulating pos/speed here
|
||||
if (pfPosChanged) *pfPosChanged = true;
|
||||
|
@ -636,7 +636,7 @@ bool mrfInsertCheck(int32_t &iX, int32_t &iY, FIXED &fXDir, FIXED &fYDir, int32_
|
|||
return true;
|
||||
}
|
||||
|
||||
bool mrfUserCheck(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
|
||||
bool mrfUserCheck(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
|
||||
{
|
||||
// check execution mask
|
||||
if ((1<<evEvent) & ~pReaction->iExecMask) return false;
|
||||
|
@ -648,7 +648,7 @@ bool mrfUserCheck(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32
|
|||
return true;
|
||||
}
|
||||
|
||||
bool C4MaterialMap::mrfConvert(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
|
||||
bool C4MaterialMap::mrfConvert(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
|
||||
{
|
||||
if (pReaction->fUserDefined) if (!mrfUserCheck(pReaction, iX, iY, iLSPosX, iLSPosY, fXDir, fYDir, iPxsMat, iLsMat, evEvent, pfPosChanged)) return false;
|
||||
switch (evEvent)
|
||||
|
@ -685,7 +685,7 @@ bool C4MaterialMap::mrfConvert(C4MaterialReaction *pReaction, int32_t &iX, int32
|
|||
return false;
|
||||
}
|
||||
|
||||
bool C4MaterialMap::mrfPoof(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
|
||||
bool C4MaterialMap::mrfPoof(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
|
||||
{
|
||||
if (pReaction->fUserDefined) if (!mrfUserCheck(pReaction, iX, iY, iLSPosX, iLSPosY, fXDir, fYDir, iPxsMat, iLsMat, evEvent, pfPosChanged)) return false;
|
||||
switch (evEvent)
|
||||
|
@ -713,7 +713,7 @@ bool C4MaterialMap::mrfPoof(C4MaterialReaction *pReaction, int32_t &iX, int32_t
|
|||
return false;
|
||||
}
|
||||
|
||||
bool C4MaterialMap::mrfCorrode(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
|
||||
bool C4MaterialMap::mrfCorrode(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
|
||||
{
|
||||
if (pReaction->fUserDefined) if (!mrfUserCheck(pReaction, iX, iY, iLSPosX, iLSPosY, fXDir, fYDir, iPxsMat, iLsMat, evEvent, pfPosChanged)) return false;
|
||||
switch (evEvent)
|
||||
|
@ -770,7 +770,7 @@ bool C4MaterialMap::mrfCorrode(C4MaterialReaction *pReaction, int32_t &iX, int32
|
|||
return false;
|
||||
}
|
||||
|
||||
bool C4MaterialMap::mrfIncinerate(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
|
||||
bool C4MaterialMap::mrfIncinerate(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
|
||||
{
|
||||
// not available as user reaction
|
||||
assert(!pReaction->fUserDefined);
|
||||
|
@ -796,7 +796,7 @@ bool C4MaterialMap::mrfIncinerate(C4MaterialReaction *pReaction, int32_t &iX, in
|
|||
return false;
|
||||
}
|
||||
|
||||
bool C4MaterialMap::mrfInsert(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
|
||||
bool C4MaterialMap::mrfInsert(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
|
||||
{
|
||||
if (pReaction->fUserDefined) if (!mrfUserCheck(pReaction, iX, iY, iLSPosX, iLSPosY, fXDir, fYDir, iPxsMat, iLsMat, evEvent, pfPosChanged)) return false;
|
||||
switch (evEvent)
|
||||
|
@ -823,7 +823,7 @@ bool C4MaterialMap::mrfInsert(C4MaterialReaction *pReaction, int32_t &iX, int32_
|
|||
return false;
|
||||
}
|
||||
|
||||
bool C4MaterialMap::mrfScript(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
|
||||
bool C4MaterialMap::mrfScript(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
|
||||
{
|
||||
// do generic checks for user-defined reactions
|
||||
if (!mrfUserCheck(pReaction, iX, iY, iLSPosX, iLSPosY, fXDir, fYDir, iPxsMat, iLsMat, evEvent, pfPosChanged))
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#ifndef INC_C4Material
|
||||
#define INC_C4Material
|
||||
|
||||
#include <Fixed.h>
|
||||
#include "C4Real.h"
|
||||
#include <C4Id.h>
|
||||
#include <C4Shape.h>
|
||||
#include <C4Facet.h>
|
||||
|
@ -43,11 +43,11 @@ enum MaterialInteractionEvent
|
|||
meeMassMove=2 // MassMover-movement
|
||||
};
|
||||
|
||||
typedef bool (*C4MaterialReactionFunc)(struct C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);
|
||||
typedef bool (*C4MaterialReactionFunc)(struct C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);
|
||||
|
||||
struct C4MaterialReaction
|
||||
{
|
||||
static inline bool NoReaction(struct C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged) { return false; }
|
||||
static inline bool NoReaction(struct C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged) { return false; }
|
||||
|
||||
C4MaterialReactionFunc pFunc; // Guarantueed to be non-NULL
|
||||
bool fUserDefined; // false for internal reactions generated by material parameters
|
||||
|
@ -160,13 +160,13 @@ public:
|
|||
C4MaterialReaction DefReactConvert, DefReactPoof, DefReactCorrode, DefReactIncinerate, DefReactInsert;
|
||||
public:
|
||||
// default reactions
|
||||
static bool mrfConvert(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);
|
||||
static bool mrfPoof (C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);
|
||||
static bool mrfCorrode(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);
|
||||
static bool mrfIncinerate(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);
|
||||
static bool mrfInsert (C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);
|
||||
static bool mrfConvert(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);
|
||||
static bool mrfPoof (C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);
|
||||
static bool mrfCorrode(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);
|
||||
static bool mrfIncinerate(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);
|
||||
static bool mrfInsert (C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);
|
||||
// user-defined actions
|
||||
static bool mrfScript(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);
|
||||
static bool mrfScript(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);
|
||||
public:
|
||||
void Default();
|
||||
void Clear();
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <C4Game.h>
|
||||
#include <C4Record.h>
|
||||
|
||||
static const FIXED WindDrift_Factor = itofix(1, 800);
|
||||
static const C4Real WindDrift_Factor = itofix(1, 800);
|
||||
|
||||
void C4PXS::Execute()
|
||||
{
|
||||
|
@ -66,8 +66,8 @@ void C4PXS::Execute()
|
|||
{
|
||||
// Air speed: Wind plus some random
|
||||
int32_t iWind = GBackWind(iX, iY);
|
||||
FIXED txdir = itofix(iWind, 15) + FIXED256(Random(1200) - 600);
|
||||
FIXED tydir = FIXED256(Random(1200) - 600);
|
||||
C4Real txdir = itofix(iWind, 15) + FIXED256(Random(1200) - 600);
|
||||
C4Real tydir = FIXED256(Random(1200) - 600);
|
||||
|
||||
// Air friction, based on WindDrift. MaxSpeed is ignored.
|
||||
int32_t iWindDrift = Max(::MaterialMap.Map[Mat].WindDrift - 20, 0);
|
||||
|
@ -75,8 +75,8 @@ void C4PXS::Execute()
|
|||
ydir += ((tydir - ydir) * iWindDrift) * WindDrift_Factor;
|
||||
}
|
||||
|
||||
FIXED ctcox = x + xdir;
|
||||
FIXED ctcoy = y + ydir;
|
||||
C4Real ctcox = x + xdir;
|
||||
C4Real ctcoy = y + ydir;
|
||||
|
||||
int32_t iToX = fixtoi(ctcox), iToY = fixtoi(ctcoy);
|
||||
|
||||
|
@ -202,7 +202,7 @@ C4PXS* C4PXSSystem::New()
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool C4PXSSystem::Create(int32_t mat, FIXED ix, FIXED iy, FIXED ixdir, FIXED iydir)
|
||||
bool C4PXSSystem::Create(int32_t mat, C4Real ix, C4Real iy, C4Real ixdir, C4Real iydir)
|
||||
{
|
||||
C4PXS *pxp;
|
||||
if (!MatValid(mat)) return false;
|
||||
|
@ -349,7 +349,7 @@ bool C4PXSSystem::Save(C4Group &hGroup)
|
|||
CStdFile hTempFile;
|
||||
if (!hTempFile.Create(Config.AtTempPath(C4CFN_TempPXS)))
|
||||
return false;
|
||||
#ifdef USE_FIXED
|
||||
#ifdef C4REAL_USE_FIXNUM
|
||||
int32_t iNumFormat = 1;
|
||||
#else
|
||||
int32_t iNumFormat = 2;
|
||||
|
@ -380,7 +380,7 @@ bool C4PXSSystem::Load(C4Group &hGroup)
|
|||
if (!hGroup.AccessEntry(C4CFN_PXS,&iBinSize)) return false;
|
||||
// clear previous
|
||||
Clear();
|
||||
// using FIXED or float?
|
||||
// using C4Real or float?
|
||||
int32_t iNumForm = 1;
|
||||
if (iBinSize % iChunkSize == 4)
|
||||
{
|
||||
|
@ -405,7 +405,7 @@ bool C4PXSSystem::Load(C4Group &hGroup)
|
|||
{
|
||||
++iChunkPXS[cnt];
|
||||
// convert number format
|
||||
#ifdef USE_FIXED
|
||||
#ifdef C4REAL_USE_FIXNUM
|
||||
if (iNumForm == 2) { FLOAT_TO_FIXED(&pxp->x); FLOAT_TO_FIXED(&pxp->y); FLOAT_TO_FIXED(&pxp->xdir); FLOAT_TO_FIXED(&pxp->ydir); }
|
||||
#else
|
||||
if (iNumForm == 1) { FIXED_TO_FLOAT(&pxp->x); FIXED_TO_FLOAT(&pxp->y); FIXED_TO_FLOAT(&pxp->xdir); FIXED_TO_FLOAT(&pxp->ydir); }
|
||||
|
|
|
@ -30,7 +30,7 @@ class C4PXS
|
|||
friend class C4PXSSystem;
|
||||
protected:
|
||||
int32_t Mat;
|
||||
FIXED x,y,xdir,ydir;
|
||||
C4Real x,y,xdir,ydir;
|
||||
protected:
|
||||
void Execute();
|
||||
void Deactivate();
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
void Synchronize();
|
||||
void SyncClearance();
|
||||
void Cast(int32_t mat, int32_t num, int32_t tx, int32_t ty, int32_t level);
|
||||
bool Create(int32_t mat, FIXED ix, FIXED iy, FIXED ixdir=Fix0, FIXED iydir=Fix0);
|
||||
bool Create(int32_t mat, C4Real ix, C4Real iy, C4Real ixdir=Fix0, C4Real iydir=Fix0);
|
||||
bool Load(C4Group &hGroup);
|
||||
bool Save(C4Group &hGroup);
|
||||
protected:
|
||||
|
|
|
@ -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));
|
||||
//FIXED txdir = itofix(wind_speed, 15) + FIXED256(Random(1200) - 600);
|
||||
//C4Real txdir = itofix(wind_speed, 15) + FIXED256(Random(1200) - 600);
|
||||
float txdir = wind_speed / 15.0f;
|
||||
//FIXED tydir = FIXED256(Random(1200) - 600);
|
||||
//C4Real tydir = FIXED256(Random(1200) - 600);
|
||||
float tydir = 0;
|
||||
|
||||
// Air friction, based on WindDrift.
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#ifndef INC_C4Sky
|
||||
#define INC_C4Sky
|
||||
|
||||
#include <Fixed.h>
|
||||
#include "C4Real.h"
|
||||
|
||||
#define C4SkyPM_Fixed 0 // sky parallax mode: fixed
|
||||
#define C4SkyPM_Wind 1 // sky parallax mode: blown by the wind
|
||||
|
@ -57,8 +57,8 @@ protected:
|
|||
bool BackClrEnabled; // is the background color enabled?
|
||||
public:
|
||||
class C4Surface * Surface;
|
||||
FIXED xdir,ydir; // sky movement speed
|
||||
FIXED x,y; // sky movement pos
|
||||
C4Real xdir,ydir; // sky movement speed
|
||||
C4Real x,y; // sky movement pos
|
||||
int32_t ParX, ParY; // parallax movement in xdir/ydir
|
||||
uint32_t FadeClr1, FadeClr2;
|
||||
int32_t ParallaxMode; // sky scrolling mode
|
||||
|
|
|
@ -114,7 +114,7 @@ void C4SolidMask::Put(bool fCauseInstability, C4TargetRect *pClipRect, bool fRes
|
|||
else
|
||||
{
|
||||
// calc matrix for given rotation
|
||||
FIXED Ma1 = Cos(itofix(-MaskPutRotation)), Ma2 = -Sin(itofix(-MaskPutRotation)),
|
||||
C4Real Ma1 = Cos(itofix(-MaskPutRotation)), Ma2 = -Sin(itofix(-MaskPutRotation)),
|
||||
Mb1 = Sin(itofix(-MaskPutRotation)), Mb2 = Cos(itofix(-MaskPutRotation));
|
||||
// get upper-left corner of landscape copy rect
|
||||
int centerx = pForObject->Def->Shape.x + pForObject->SolidMask.tx + pForObject->SolidMask.Wdt / 2;
|
||||
|
@ -134,19 +134,19 @@ void C4SolidMask::Put(bool fCauseInstability, C4TargetRect *pClipRect, bool fRes
|
|||
MaskPutRect.Hgt = Min<int32_t>(ystart + MatBuffPitch, GBackHgt) - MaskPutRect.y;
|
||||
}
|
||||
// go through clipping rect
|
||||
const FIXED y0 = itofix(pClipRect->ty - MatBuffPitch/2);
|
||||
const FIXED x0 = itofix(pClipRect->tx - MatBuffPitch/2);
|
||||
const C4Real y0 = itofix(pClipRect->ty - MatBuffPitch/2);
|
||||
const C4Real x0 = itofix(pClipRect->tx - MatBuffPitch/2);
|
||||
iTy=pClipRect->y;
|
||||
int w = pForObject->SolidMask.Wdt;
|
||||
int h = pForObject->SolidMask.Hgt;
|
||||
FIXED ya = y0 * Ma2;
|
||||
FIXED yb = y0 * Mb2;
|
||||
C4Real ya = y0 * Ma2;
|
||||
C4Real yb = y0 * Mb2;
|
||||
for (ycnt = 0; ycnt < pClipRect->Hgt; ycnt++)
|
||||
{
|
||||
iTx=pClipRect->x;
|
||||
int i = (ycnt + pClipRect->ty) * MatBuffPitch + pClipRect->tx;
|
||||
FIXED xa = x0 * Ma1;
|
||||
FIXED xb = x0 * Mb1;
|
||||
C4Real xa = x0 * Ma1;
|
||||
C4Real xb = x0 * Mb1;
|
||||
for (xcnt = 0; xcnt < pClipRect->Wdt; xcnt++)
|
||||
{
|
||||
// calc position in solidmask buffer
|
||||
|
|
|
@ -387,9 +387,9 @@ void C4Command::MoveTo()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
case DFA_FLOAT:
|
||||
{
|
||||
FIXED dx = itofix(Tx._getInt()) - cObj->fix_x, dy = itofix(Ty) - cObj->fix_y;
|
||||
C4Real dx = itofix(Tx._getInt()) - cObj->fix_x, dy = itofix(Ty) - cObj->fix_y;
|
||||
// normalize
|
||||
FIXED dScale = FIXED100(cObj->GetPhysical()->Float) / Max(Abs(dx), Abs(dy));
|
||||
C4Real dScale = FIXED100(cObj->GetPhysical()->Float) / Max(Abs(dx), Abs(dy));
|
||||
dx *= dScale; dy *= dScale;
|
||||
// difference to momentum
|
||||
dx -= cObj->xdir; dy -= cObj->ydir;
|
||||
|
@ -883,7 +883,7 @@ void C4Command::Throw()
|
|||
|
||||
// Find throwing position
|
||||
int32_t iTx,iTy;
|
||||
FIXED pthrow=ValByPhysical(400, cObj->GetPhysical()->Throw);
|
||||
C4Real pthrow=ValByPhysical(400, cObj->GetPhysical()->Throw);
|
||||
int32_t iHeight = cObj->Shape.Hgt;
|
||||
if (!FindThrowingPosition(Tx._getInt(),Ty,pthrow*iDir,-pthrow,iHeight,iTx,iTy))
|
||||
if (!FindThrowingPosition(Tx._getInt(),Ty,pthrow*iDir*-1,-pthrow,iHeight,iTx,iTy))
|
||||
|
@ -1374,7 +1374,7 @@ void C4Command::Put() // Notice: Put command is currently using Ty as an interna
|
|||
{
|
||||
int32_t iTx = Target->GetX() + Target->Def->Collection.x + Target->Def->Collection.Wdt/2;
|
||||
int32_t iTy = Target->GetY() + Target->Def->Collection.y + Target->Def->Collection.Hgt/2;
|
||||
FIXED pthrow=ValByPhysical(400, cObj->GetPhysical()->Throw);
|
||||
C4Real pthrow=ValByPhysical(400, cObj->GetPhysical()->Throw);
|
||||
int32_t iHeight = cObj->Shape.Hgt;
|
||||
int32_t iPosX,iPosY;
|
||||
int32_t iObjDist = Distance(cObj->GetX(),cObj->GetY(),Target->GetX(),Target->GetY());
|
||||
|
|
|
@ -279,7 +279,7 @@ void C4GameObjects::CrossCheck() // Every Tick1 by ExecObjects
|
|||
{
|
||||
if (true /* "realistic" hit energy */)
|
||||
{
|
||||
FIXED dXDir = obj2->xdir - obj1->xdir, dYDir = obj2->ydir - obj1->ydir;
|
||||
C4Real dXDir = obj2->xdir - obj1->xdir, dYDir = obj2->ydir - obj1->ydir;
|
||||
int32_t iHitEnergy = fixtoi((dXDir * dXDir + dYDir * dYDir) * obj2->Mass / 5 );
|
||||
iHitEnergy = Max<int32_t>(iHitEnergy/3, !!iHitEnergy); // hit energy reduced to 1/3rd, but do not drop to zero because of this division
|
||||
obj1->DoEnergy(-iHitEnergy/5, false, C4FxCall_EngObjHit, obj2->Controller);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include <C4Id.h>
|
||||
#include <C4ValueMap.h>
|
||||
#include <Fixed.h>
|
||||
#include "C4Real.h"
|
||||
#include "C4InputValidation.h"
|
||||
|
||||
const int32_t C4MaxPhysical = 100000,
|
||||
|
@ -217,7 +217,7 @@ public:
|
|||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
|
||||
inline FIXED ValByPhysical(int32_t iPercent, int32_t iPhysical) // get percentage of max physical value
|
||||
inline C4Real ValByPhysical(int32_t iPercent, int32_t iPhysical) // get percentage of max physical value
|
||||
{
|
||||
return itofix(iPhysical * (iPercent / 5),C4MaxPhysical * 20);
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ StdMeshInstance::ValueProvider* CreateValueProviderFromArray(C4Object* pForObj,
|
|||
}
|
||||
}
|
||||
|
||||
C4ValueProviderConst::C4ValueProviderConst(FIXED value)
|
||||
C4ValueProviderConst::C4ValueProviderConst(C4Real value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ bool C4ValueProviderConst::Execute()
|
|||
return true;
|
||||
}
|
||||
|
||||
C4ValueProviderLinear::C4ValueProviderLinear(FIXED pos, FIXED begin, FIXED end, int32_t length, C4AnimationEnding ending):
|
||||
C4ValueProviderLinear::C4ValueProviderLinear(C4Real pos, C4Real begin, C4Real end, int32_t length, C4AnimationEnding ending):
|
||||
Begin(begin), End(end), Length(length), Ending(ending), LastTick(Game.FrameCounter)
|
||||
{
|
||||
Value = pos;
|
||||
|
@ -157,7 +157,7 @@ void C4ValueProviderLinear::CompileFunc(StdCompiler* pComp)
|
|||
pComp->Value(LastTick);
|
||||
}
|
||||
|
||||
C4ValueProviderX::C4ValueProviderX(C4Object* object, FIXED pos, FIXED begin, FIXED end, int32_t length):
|
||||
C4ValueProviderX::C4ValueProviderX(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length):
|
||||
Object(object), Begin(begin), End(end), Length(length), LastX(object->fix_x)
|
||||
{
|
||||
Value = pos;
|
||||
|
@ -165,7 +165,7 @@ C4ValueProviderX::C4ValueProviderX(C4Object* object, FIXED pos, FIXED begin, FIX
|
|||
|
||||
bool C4ValueProviderX::Execute()
|
||||
{
|
||||
//const FIXED obj_x = fixtof(Object->fix_x);
|
||||
//const C4Real obj_x = fixtof(Object->fix_x);
|
||||
Value += (End - Begin) * (Object->fix_x - LastX) / Length; // TODO: Use xdir instead?
|
||||
LastX = Object->fix_x;
|
||||
|
||||
|
@ -202,7 +202,7 @@ void C4ValueProviderX::CompileFunc(StdCompiler* pComp)
|
|||
pComp->Value(LastX);
|
||||
}
|
||||
|
||||
C4ValueProviderY::C4ValueProviderY(C4Object* object, FIXED pos, FIXED begin, FIXED end, int32_t length):
|
||||
C4ValueProviderY::C4ValueProviderY(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length):
|
||||
Object(object), Begin(begin), End(end), Length(length), LastY(object->fix_y)
|
||||
{
|
||||
Value = pos;
|
||||
|
@ -210,7 +210,7 @@ C4ValueProviderY::C4ValueProviderY(C4Object* object, FIXED pos, FIXED begin, FIX
|
|||
|
||||
bool C4ValueProviderY::Execute()
|
||||
{
|
||||
//const FIXED obj_y = fixtof(Object->fix_y);
|
||||
//const C4Real obj_y = fixtof(Object->fix_y);
|
||||
Value += (End - Begin) * (Object->fix_y - LastY) / Length; // TODO: Use ydir instead?
|
||||
LastY = Object->fix_y;
|
||||
|
||||
|
@ -247,7 +247,7 @@ void C4ValueProviderY::CompileFunc(StdCompiler* pComp)
|
|||
pComp->Value(LastY);
|
||||
}
|
||||
|
||||
C4ValueProviderAbsX::C4ValueProviderAbsX(C4Object* object, FIXED pos, FIXED begin, FIXED end, int32_t length):
|
||||
C4ValueProviderAbsX::C4ValueProviderAbsX(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length):
|
||||
Object(object), Begin(begin), End(end), Length(length), LastX(object->fix_x)
|
||||
{
|
||||
Value = pos;
|
||||
|
@ -280,7 +280,7 @@ void C4ValueProviderAbsX::CompileFunc(StdCompiler* pComp)
|
|||
pComp->Value(LastX);
|
||||
}
|
||||
|
||||
C4ValueProviderAbsY::C4ValueProviderAbsY(C4Object* object, FIXED pos, FIXED begin, FIXED end, int32_t length):
|
||||
C4ValueProviderAbsY::C4ValueProviderAbsY(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length):
|
||||
Object(object), Begin(begin), End(end), Length(length), LastY(object->fix_y)
|
||||
{
|
||||
Value = pos;
|
||||
|
@ -313,7 +313,7 @@ void C4ValueProviderAbsY::CompileFunc(StdCompiler* pComp)
|
|||
pComp->Value(LastY);
|
||||
}
|
||||
|
||||
C4ValueProviderXDir::C4ValueProviderXDir(C4Object* object, FIXED begin, FIXED end, FIXED max_xdir):
|
||||
C4ValueProviderXDir::C4ValueProviderXDir(C4Object* object, C4Real begin, C4Real end, C4Real max_xdir):
|
||||
Object(object), Begin(begin), End(end), MaxXDir(max_xdir)
|
||||
{
|
||||
Execute();
|
||||
|
@ -321,7 +321,7 @@ C4ValueProviderXDir::C4ValueProviderXDir(C4Object* object, FIXED begin, FIXED en
|
|||
|
||||
bool C4ValueProviderXDir::Execute()
|
||||
{
|
||||
Value = Begin + (End - Begin) * Min<FIXED>(Abs(Object->xdir/MaxXDir), itofix(1));
|
||||
Value = Begin + (End - Begin) * Min<C4Real>(Abs(Object->xdir/MaxXDir), itofix(1));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ void C4ValueProviderXDir::CompileFunc(StdCompiler* pComp)
|
|||
pComp->Value(MaxXDir);
|
||||
}
|
||||
|
||||
C4ValueProviderYDir::C4ValueProviderYDir(C4Object* object, FIXED begin, FIXED end, FIXED max_ydir):
|
||||
C4ValueProviderYDir::C4ValueProviderYDir(C4Object* object, C4Real begin, C4Real end, C4Real max_ydir):
|
||||
Object(object), Begin(begin), End(end), MaxYDir(max_ydir)
|
||||
{
|
||||
Execute();
|
||||
|
@ -346,7 +346,7 @@ C4ValueProviderYDir::C4ValueProviderYDir(C4Object* object, FIXED begin, FIXED en
|
|||
|
||||
bool C4ValueProviderYDir::Execute()
|
||||
{
|
||||
Value = Begin + (End - Begin) * Min<FIXED>(Abs(Object->ydir/MaxYDir), itofix(1));
|
||||
Value = Begin + (End - Begin) * Min<C4Real>(Abs(Object->ydir/MaxYDir), itofix(1));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -363,7 +363,7 @@ void C4ValueProviderYDir::CompileFunc(StdCompiler* pComp)
|
|||
pComp->Value(MaxYDir);
|
||||
}
|
||||
|
||||
C4ValueProviderRDir::C4ValueProviderRDir(C4Object* object, FIXED begin, FIXED end, FIXED max_rdir):
|
||||
C4ValueProviderRDir::C4ValueProviderRDir(C4Object* object, C4Real begin, C4Real end, C4Real max_rdir):
|
||||
Object(object), Begin(begin), End(end), MaxRDir(max_rdir)
|
||||
{
|
||||
Execute();
|
||||
|
@ -371,7 +371,7 @@ C4ValueProviderRDir::C4ValueProviderRDir(C4Object* object, FIXED begin, FIXED en
|
|||
|
||||
bool C4ValueProviderRDir::Execute()
|
||||
{
|
||||
Value = Begin + (End - Begin) * Min<FIXED>(Abs(Object->rdir/MaxRDir), itofix(1));
|
||||
Value = Begin + (End - Begin) * Min<C4Real>(Abs(Object->rdir/MaxRDir), itofix(1));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ void C4ValueProviderRDir::CompileFunc(StdCompiler* pComp)
|
|||
pComp->Value(MaxRDir);
|
||||
}
|
||||
|
||||
C4ValueProviderCosR::C4ValueProviderCosR(C4Object* object, FIXED begin, FIXED end, FIXED offset):
|
||||
C4ValueProviderCosR::C4ValueProviderCosR(C4Object* object, C4Real begin, C4Real end, C4Real offset):
|
||||
Object(object), Begin(begin), End(end), Offset(offset)
|
||||
{
|
||||
Execute();
|
||||
|
@ -413,7 +413,7 @@ void C4ValueProviderCosR::CompileFunc(StdCompiler* pComp)
|
|||
pComp->Value(Offset);
|
||||
}
|
||||
|
||||
C4ValueProviderSinR::C4ValueProviderSinR(C4Object* object, FIXED begin, FIXED end, FIXED offset):
|
||||
C4ValueProviderSinR::C4ValueProviderSinR(C4Object* object, C4Real begin, C4Real end, C4Real offset):
|
||||
Object(object), Begin(begin), End(end), Offset(offset)
|
||||
{
|
||||
Execute();
|
||||
|
@ -438,7 +438,7 @@ void C4ValueProviderSinR::CompileFunc(StdCompiler* pComp)
|
|||
pComp->Value(Offset);
|
||||
}
|
||||
|
||||
C4ValueProviderCosV::C4ValueProviderCosV(C4Object* object, FIXED begin, FIXED end, FIXED offset):
|
||||
C4ValueProviderCosV::C4ValueProviderCosV(C4Object* object, C4Real begin, C4Real end, C4Real offset):
|
||||
Object(object), Begin(begin), End(end), Offset(offset)
|
||||
{
|
||||
Execute();
|
||||
|
@ -467,7 +467,7 @@ void C4ValueProviderCosV::CompileFunc(StdCompiler* pComp)
|
|||
pComp->Value(Offset);
|
||||
}
|
||||
|
||||
C4ValueProviderSinV::C4ValueProviderSinV(C4Object* object, FIXED begin, FIXED end, FIXED offset):
|
||||
C4ValueProviderSinV::C4ValueProviderSinV(C4Object* object, C4Real begin, C4Real end, C4Real offset):
|
||||
Object(object), Begin(begin), End(end), Offset(offset)
|
||||
{
|
||||
Execute();
|
||||
|
|
|
@ -58,7 +58,7 @@ class C4ValueProviderConst: public StdMeshInstance::SerializableValueProvider
|
|||
{
|
||||
public:
|
||||
C4ValueProviderConst() {}
|
||||
C4ValueProviderConst(FIXED value);
|
||||
C4ValueProviderConst(C4Real value);
|
||||
virtual bool Execute();
|
||||
};
|
||||
|
||||
|
@ -67,13 +67,13 @@ class C4ValueProviderLinear: public StdMeshInstance::SerializableValueProvider
|
|||
{
|
||||
public:
|
||||
C4ValueProviderLinear(): Begin(Fix0), End(Fix0), Length(0), Ending(ANIM_Loop), LastTick(0) {}
|
||||
C4ValueProviderLinear(FIXED pos, FIXED begin, FIXED end, int32_t length, C4AnimationEnding ending);
|
||||
C4ValueProviderLinear(C4Real pos, C4Real begin, C4Real end, int32_t length, C4AnimationEnding ending);
|
||||
virtual bool Execute();
|
||||
|
||||
virtual void CompileFunc(StdCompiler* pComp);
|
||||
private:
|
||||
FIXED Begin;
|
||||
FIXED End;
|
||||
C4Real Begin;
|
||||
C4Real End;
|
||||
int32_t Length;
|
||||
C4AnimationEnding Ending;
|
||||
|
||||
|
@ -84,7 +84,7 @@ class C4ValueProviderX: public StdMeshInstance::SerializableValueProvider
|
|||
{
|
||||
public:
|
||||
C4ValueProviderX(): Object(NULL), Begin(Fix0), End(Fix0), Length(0), LastX(Fix0) {}
|
||||
C4ValueProviderX(C4Object* object, FIXED pos, FIXED begin, FIXED end, int32_t length);
|
||||
C4ValueProviderX(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length);
|
||||
virtual bool Execute();
|
||||
|
||||
virtual void CompileFunc(StdCompiler* pComp);
|
||||
|
@ -92,18 +92,18 @@ public:
|
|||
virtual void EnumeratePointers() { Object.EnumeratePointers(); }
|
||||
private:
|
||||
C4ObjectPtr Object;
|
||||
FIXED Begin;
|
||||
FIXED End;
|
||||
C4Real Begin;
|
||||
C4Real End;
|
||||
int32_t Length;
|
||||
|
||||
FIXED LastX;
|
||||
C4Real LastX;
|
||||
};
|
||||
|
||||
class C4ValueProviderY: public StdMeshInstance::SerializableValueProvider
|
||||
{
|
||||
public:
|
||||
C4ValueProviderY(): Object(NULL), Begin(Fix0), End(Fix0), Length(0), LastY(Fix0) {}
|
||||
C4ValueProviderY(C4Object* object, FIXED pos, FIXED begin, FIXED end, int32_t length);
|
||||
C4ValueProviderY(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length);
|
||||
virtual bool Execute();
|
||||
|
||||
virtual void CompileFunc(StdCompiler* pComp);
|
||||
|
@ -111,18 +111,18 @@ public:
|
|||
virtual void EnumeratePointers() { Object.EnumeratePointers(); }
|
||||
private:
|
||||
C4ObjectPtr Object;
|
||||
FIXED Begin;
|
||||
FIXED End;
|
||||
C4Real Begin;
|
||||
C4Real End;
|
||||
int32_t Length;
|
||||
|
||||
FIXED LastY;
|
||||
C4Real LastY;
|
||||
};
|
||||
|
||||
class C4ValueProviderAbsX: public StdMeshInstance::SerializableValueProvider
|
||||
{
|
||||
public:
|
||||
C4ValueProviderAbsX(): Object(NULL), Begin(Fix0), End(Fix0), Length(0), LastX(Fix0) {}
|
||||
C4ValueProviderAbsX(C4Object* object, FIXED pos, FIXED begin, FIXED end, int32_t length);
|
||||
C4ValueProviderAbsX(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length);
|
||||
virtual bool Execute();
|
||||
|
||||
virtual void CompileFunc(StdCompiler* pComp);
|
||||
|
@ -130,18 +130,18 @@ public:
|
|||
virtual void EnumeratePointers() { Object.EnumeratePointers(); }
|
||||
private:
|
||||
C4ObjectPtr Object;
|
||||
FIXED Begin;
|
||||
FIXED End;
|
||||
C4Real Begin;
|
||||
C4Real End;
|
||||
int32_t Length;
|
||||
|
||||
FIXED LastX;
|
||||
C4Real LastX;
|
||||
};
|
||||
|
||||
class C4ValueProviderAbsY: public StdMeshInstance::SerializableValueProvider
|
||||
{
|
||||
public:
|
||||
C4ValueProviderAbsY(): Object(NULL), Begin(Fix0), End(Fix0), Length(0), LastY(Fix0) {}
|
||||
C4ValueProviderAbsY(C4Object* object, FIXED pos, FIXED begin, FIXED end, int32_t length);
|
||||
C4ValueProviderAbsY(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length);
|
||||
virtual bool Execute();
|
||||
|
||||
virtual void CompileFunc(StdCompiler* pComp);
|
||||
|
@ -149,18 +149,18 @@ public:
|
|||
virtual void EnumeratePointers() { Object.EnumeratePointers(); }
|
||||
private:
|
||||
C4ObjectPtr Object;
|
||||
FIXED Begin;
|
||||
FIXED End;
|
||||
C4Real Begin;
|
||||
C4Real End;
|
||||
int32_t Length;
|
||||
|
||||
FIXED LastY;
|
||||
C4Real LastY;
|
||||
};
|
||||
|
||||
class C4ValueProviderXDir: public StdMeshInstance::SerializableValueProvider
|
||||
{
|
||||
public:
|
||||
C4ValueProviderXDir(): Object(NULL), Begin(Fix0), End(Fix0), MaxXDir(Fix0) {}
|
||||
C4ValueProviderXDir(C4Object* object, FIXED begin, FIXED end, FIXED max_xdir);
|
||||
C4ValueProviderXDir(C4Object* object, C4Real begin, C4Real end, C4Real max_xdir);
|
||||
virtual bool Execute();
|
||||
|
||||
virtual void CompileFunc(StdCompiler* pComp);
|
||||
|
@ -168,16 +168,16 @@ public:
|
|||
virtual void EnumeratePointers() { Object.EnumeratePointers(); }
|
||||
private:
|
||||
C4ObjectPtr Object;
|
||||
FIXED Begin;
|
||||
FIXED End;
|
||||
FIXED MaxXDir;
|
||||
C4Real Begin;
|
||||
C4Real End;
|
||||
C4Real MaxXDir;
|
||||
};
|
||||
|
||||
class C4ValueProviderYDir: public StdMeshInstance::SerializableValueProvider
|
||||
{
|
||||
public:
|
||||
C4ValueProviderYDir(): Object(NULL), Begin(Fix0), End(Fix0), MaxYDir(Fix0) {}
|
||||
C4ValueProviderYDir(C4Object* object, FIXED begin, FIXED end, FIXED max_ydir);
|
||||
C4ValueProviderYDir(C4Object* object, C4Real begin, C4Real end, C4Real max_ydir);
|
||||
virtual bool Execute();
|
||||
|
||||
virtual void CompileFunc(StdCompiler* pComp);
|
||||
|
@ -185,16 +185,16 @@ public:
|
|||
virtual void EnumeratePointers() { Object.EnumeratePointers(); }
|
||||
private:
|
||||
C4ObjectPtr Object;
|
||||
FIXED Begin;
|
||||
FIXED End;
|
||||
FIXED MaxYDir;
|
||||
C4Real Begin;
|
||||
C4Real End;
|
||||
C4Real MaxYDir;
|
||||
};
|
||||
|
||||
class C4ValueProviderRDir: public StdMeshInstance::SerializableValueProvider
|
||||
{
|
||||
public:
|
||||
C4ValueProviderRDir(): Object(NULL), Begin(Fix0), End(Fix0), MaxRDir(Fix0) {}
|
||||
C4ValueProviderRDir(C4Object* object, FIXED begin, FIXED end, FIXED max_rdir);
|
||||
C4ValueProviderRDir(C4Object* object, C4Real begin, C4Real end, C4Real max_rdir);
|
||||
virtual bool Execute();
|
||||
|
||||
virtual void CompileFunc(StdCompiler* pComp);
|
||||
|
@ -202,16 +202,16 @@ public:
|
|||
virtual void EnumeratePointers() { Object.EnumeratePointers(); }
|
||||
private:
|
||||
C4ObjectPtr Object;
|
||||
FIXED Begin;
|
||||
FIXED End;
|
||||
FIXED MaxRDir;
|
||||
C4Real Begin;
|
||||
C4Real End;
|
||||
C4Real MaxRDir;
|
||||
};
|
||||
|
||||
class C4ValueProviderCosR: public StdMeshInstance::SerializableValueProvider
|
||||
{
|
||||
public:
|
||||
C4ValueProviderCosR(): Object(NULL), Begin(Fix0), End(Fix0), Offset(Fix0) {}
|
||||
C4ValueProviderCosR(C4Object* object, FIXED begin, FIXED end, FIXED offset);
|
||||
C4ValueProviderCosR(C4Object* object, C4Real begin, C4Real end, C4Real offset);
|
||||
virtual bool Execute();
|
||||
|
||||
virtual void CompileFunc(StdCompiler* pComp);
|
||||
|
@ -219,16 +219,16 @@ public:
|
|||
virtual void EnumeratePointers() { Object.EnumeratePointers(); }
|
||||
private:
|
||||
C4ObjectPtr Object;
|
||||
FIXED Begin;
|
||||
FIXED End;
|
||||
FIXED Offset;
|
||||
C4Real Begin;
|
||||
C4Real End;
|
||||
C4Real Offset;
|
||||
};
|
||||
|
||||
class C4ValueProviderSinR: public StdMeshInstance::SerializableValueProvider
|
||||
{
|
||||
public:
|
||||
C4ValueProviderSinR(): Object(NULL), Begin(Fix0), End(Fix0), Offset(Fix0) {}
|
||||
C4ValueProviderSinR(C4Object* object, FIXED begin, FIXED end, FIXED offset);
|
||||
C4ValueProviderSinR(C4Object* object, C4Real begin, C4Real end, C4Real offset);
|
||||
virtual bool Execute();
|
||||
|
||||
virtual void CompileFunc(StdCompiler* pComp);
|
||||
|
@ -236,16 +236,16 @@ public:
|
|||
virtual void EnumeratePointers() { Object.EnumeratePointers(); }
|
||||
private:
|
||||
C4ObjectPtr Object;
|
||||
FIXED Begin;
|
||||
FIXED End;
|
||||
FIXED Offset;
|
||||
C4Real Begin;
|
||||
C4Real End;
|
||||
C4Real Offset;
|
||||
};
|
||||
|
||||
class C4ValueProviderCosV: public StdMeshInstance::SerializableValueProvider
|
||||
{
|
||||
public:
|
||||
C4ValueProviderCosV(): Object(NULL), Begin(Fix0), End(Fix0), Offset(Fix0) {}
|
||||
C4ValueProviderCosV(C4Object* object, FIXED begin, FIXED end, FIXED offset);
|
||||
C4ValueProviderCosV(C4Object* object, C4Real begin, C4Real end, C4Real offset);
|
||||
virtual bool Execute();
|
||||
|
||||
virtual void CompileFunc(StdCompiler* pComp);
|
||||
|
@ -253,16 +253,16 @@ public:
|
|||
virtual void EnumeratePointers() { Object.EnumeratePointers(); }
|
||||
private:
|
||||
C4ObjectPtr Object;
|
||||
FIXED Begin;
|
||||
FIXED End;
|
||||
FIXED Offset;
|
||||
C4Real Begin;
|
||||
C4Real End;
|
||||
C4Real Offset;
|
||||
};
|
||||
|
||||
class C4ValueProviderSinV: public StdMeshInstance::SerializableValueProvider
|
||||
{
|
||||
public:
|
||||
C4ValueProviderSinV(): Object(NULL), Begin(Fix0), End(Fix0), Offset(Fix0) {}
|
||||
C4ValueProviderSinV(C4Object* object, FIXED begin, FIXED end, FIXED offset);
|
||||
C4ValueProviderSinV(C4Object* object, C4Real begin, C4Real end, C4Real offset);
|
||||
virtual bool Execute();
|
||||
|
||||
virtual void CompileFunc(StdCompiler* pComp);
|
||||
|
@ -270,9 +270,9 @@ public:
|
|||
virtual void EnumeratePointers() { Object.EnumeratePointers(); }
|
||||
private:
|
||||
C4ObjectPtr Object;
|
||||
FIXED Begin;
|
||||
FIXED End;
|
||||
FIXED Offset;
|
||||
C4Real Begin;
|
||||
C4Real End;
|
||||
C4Real Offset;
|
||||
};
|
||||
|
||||
class C4ValueProviderAction: public StdMeshInstance::SerializableValueProvider
|
||||
|
@ -289,12 +289,12 @@ private:
|
|||
C4ObjectPtr Object;
|
||||
};
|
||||
|
||||
// Reference another value (which is convertible to FIXED), and optionally scale it
|
||||
// Reference another value (which is convertible to C4Real), and optionally scale it
|
||||
template<typename SourceT>
|
||||
class C4ValueProviderRef: public StdMeshInstance::ValueProvider
|
||||
{
|
||||
public:
|
||||
C4ValueProviderRef(const SourceT& ref, FIXED scale):
|
||||
C4ValueProviderRef(const SourceT& ref, C4Real scale):
|
||||
Ref(ref), Scale(scale) {}
|
||||
|
||||
virtual bool Execute()
|
||||
|
@ -305,7 +305,7 @@ public:
|
|||
|
||||
private:
|
||||
const SourceT& Ref;
|
||||
FIXED Scale;
|
||||
C4Real Scale;
|
||||
};
|
||||
|
||||
StdMeshInstance::ValueProvider* CreateValueProviderFromArray(C4Object* pForObj, C4ValueArray& Data);
|
||||
|
|
|
@ -31,34 +31,34 @@
|
|||
|
||||
/* Some physical constants */
|
||||
|
||||
const FIXED FRedirect=FIXED100(50);
|
||||
const FIXED FFriction=FIXED100(30);
|
||||
const FIXED FixFullCircle=itofix(360),FixHalfCircle=FixFullCircle/2;
|
||||
const FIXED FloatFriction=FIXED100(2);
|
||||
const FIXED RotateAccel=FIXED100(20);
|
||||
const FIXED FloatAccel=FIXED100(10);
|
||||
const FIXED WalkAccel=FIXED100(8);
|
||||
const FIXED WalkBreak=FIXED100(16);
|
||||
const FIXED ScaleAccel=FIXED100(20);
|
||||
const FIXED SwimAccel=FIXED100(7);
|
||||
const FIXED HitSpeed1=FIXED100(150); // Hit Event
|
||||
const FIXED HitSpeed2=itofix(2); // Cross Check Hit
|
||||
const FIXED HitSpeed3=itofix(6); // Scale disable, kneel
|
||||
const FIXED HitSpeed4=itofix(8); // Flat
|
||||
const C4Real FRedirect=FIXED100(50);
|
||||
const C4Real FFriction=FIXED100(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 HitSpeed2=itofix(2); // Cross Check Hit
|
||||
const C4Real HitSpeed3=itofix(6); // Scale disable, kneel
|
||||
const C4Real HitSpeed4=itofix(8); // Flat
|
||||
|
||||
/* Some helper functions */
|
||||
|
||||
void RedirectForce(FIXED &from, FIXED &to, int32_t tdir)
|
||||
void RedirectForce(C4Real &from, C4Real &to, int32_t tdir)
|
||||
{
|
||||
FIXED fred;
|
||||
C4Real fred;
|
||||
fred=Min(Abs(from), FRedirect);
|
||||
from-=fred*Sign(from);
|
||||
to+=fred*tdir;
|
||||
}
|
||||
|
||||
void ApplyFriction(FIXED &tval, int32_t percent)
|
||||
void ApplyFriction(C4Real &tval, int32_t percent)
|
||||
{
|
||||
FIXED ffric=FFriction*percent/100;
|
||||
C4Real ffric=FFriction*percent/100;
|
||||
if (tval>+ffric) { tval-=ffric; return; }
|
||||
if (tval<-ffric) { tval+=ffric; return; }
|
||||
tval=0;
|
||||
|
@ -133,14 +133,14 @@ void C4Object::DoMotion(int32_t mx, int32_t my)
|
|||
fix_x += mx; fix_y += my;
|
||||
}
|
||||
|
||||
static inline int32_t ForceLimits(FIXED &rVal, int32_t iLow, int32_t iHi)
|
||||
static inline int32_t ForceLimits(C4Real &rVal, int32_t iLow, int32_t iHi)
|
||||
{
|
||||
if (rVal<iLow) { rVal=iLow; return -1; }
|
||||
if (rVal>iHi) { rVal=iHi; return +1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
void C4Object::TargetBounds(FIXED &ctco, int32_t limit_low, int32_t limit_hi, int32_t cnat_low, int32_t cnat_hi)
|
||||
void C4Object::TargetBounds(C4Real &ctco, int32_t limit_low, int32_t limit_hi, int32_t cnat_low, int32_t cnat_hi)
|
||||
{
|
||||
switch (ForceLimits(ctco,limit_low,limit_hi))
|
||||
{
|
||||
|
@ -178,7 +178,7 @@ int32_t C4Object::ContactCheck(int32_t iAtX, int32_t iAtY)
|
|||
return Shape.ContactCount;
|
||||
}
|
||||
|
||||
void C4Object::SideBounds(FIXED &ctcox)
|
||||
void C4Object::SideBounds(C4Real &ctcox)
|
||||
{
|
||||
// layer bounds
|
||||
if (Layer) if (Layer->Def->BorderBound & C4D_Border_Layer)
|
||||
|
@ -197,7 +197,7 @@ void C4Object::SideBounds(FIXED &ctcox)
|
|||
TargetBounds(ctcox,0-Shape.GetX(),GBackWdt+Shape.GetX(),CNAT_Left,CNAT_Right);
|
||||
}
|
||||
|
||||
void C4Object::VerticalBounds(FIXED &ctcoy)
|
||||
void C4Object::VerticalBounds(C4Real &ctcoy)
|
||||
{
|
||||
// layer bounds
|
||||
if (Layer) if (Layer->Def->BorderBound & C4D_Border_Layer)
|
||||
|
@ -250,11 +250,11 @@ void C4Object::DoMovement()
|
|||
int32_t ix0=GetX(); int32_t iy0=GetY();
|
||||
|
||||
// store previous movement and ocf
|
||||
FIXED oldxdir(xdir), oldydir(ydir);
|
||||
C4Real oldxdir(xdir), oldydir(ydir);
|
||||
uint32_t old_ocf = OCF;
|
||||
|
||||
FIXED new_x = fix_x + xdir;
|
||||
FIXED new_y = fix_y + ydir;
|
||||
C4Real new_x = fix_x + xdir;
|
||||
C4Real new_y = fix_y + ydir;
|
||||
SideBounds(new_x);
|
||||
ctcox = fixtoi(new_x);
|
||||
|
||||
|
@ -262,10 +262,10 @@ void C4Object::DoMovement()
|
|||
{
|
||||
// Horizontal movement - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// Move to target
|
||||
while (Abs<FIXED>(fix_x - ctcox) > FIXED10(5))
|
||||
while (Abs<C4Real>(fix_x - ctcox) > FIXED10(5))
|
||||
{
|
||||
// Next step
|
||||
int step = Sign<FIXED>(new_x - fix_x);
|
||||
int step = Sign<C4Real>(new_x - fix_x);
|
||||
if ((iContact=ContactCheck(GetX() + step, GetY())))
|
||||
{
|
||||
fAnyContact=true; iContacts |= t_contact;
|
||||
|
@ -286,10 +286,10 @@ void C4Object::DoMovement()
|
|||
VerticalBounds(new_y);
|
||||
ctcoy=fixtoi(new_y);
|
||||
// Move to target
|
||||
while (Abs<FIXED>(fix_y - ctcoy) > FIXED10(5))
|
||||
while (Abs<C4Real>(fix_y - ctcoy) > FIXED10(5))
|
||||
{
|
||||
// Next step
|
||||
int step = Sign<FIXED>(new_y - fix_y);
|
||||
int step = Sign<C4Real>(new_y - fix_y);
|
||||
if ((iContact=ContactCheck(GetX(), GetY() + step)))
|
||||
{
|
||||
fAnyContact=true; iContacts |= t_contact;
|
||||
|
@ -326,10 +326,10 @@ void C4Object::DoMovement()
|
|||
bool at_xovr = false, at_yovr = false;
|
||||
// Set next step target
|
||||
int step_x = 0, step_y = 0;
|
||||
if (Abs<FIXED>(fix_x - ctcox) > FIXED10(5))
|
||||
step_x = Sign<FIXED>(new_x - fix_x);
|
||||
if (Abs<FIXED>(fix_y - ctcoy) > FIXED10(5))
|
||||
step_y = Sign<FIXED>(new_y - fix_y);
|
||||
if (Abs<C4Real>(fix_x - ctcox) > FIXED10(5))
|
||||
step_x = Sign<C4Real>(new_x - fix_x);
|
||||
if (Abs<C4Real>(fix_y - ctcoy) > FIXED10(5))
|
||||
step_y = Sign<C4Real>(new_y - fix_y);
|
||||
int32_t ctx = GetX() + step_x; int32_t cty = GetY() + step_y;
|
||||
// Attachment check
|
||||
if (!Shape.Attach(ctx,cty,Action.t_attach))
|
||||
|
@ -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<FIXED>(fix_x - ctcox) > FIXED10(5) || Abs<FIXED>(fix_y - ctcoy) > FIXED10(5));
|
||||
while (Abs<C4Real>(fix_x - ctcox) > FIXED10(5) || Abs<C4Real>(fix_y - ctcoy) > FIXED10(5));
|
||||
}
|
||||
fix_x = new_x;
|
||||
fix_y = new_y;
|
||||
|
@ -592,7 +592,7 @@ bool C4Object::ExecMovement() // Every Tick1 by Execute
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SimFlight(FIXED &x, FIXED &y, FIXED &xdir, FIXED &ydir, int32_t iDensityMin, int32_t iDensityMax, int32_t iIter)
|
||||
bool SimFlight(C4Real &x, C4Real &y, C4Real &xdir, C4Real &ydir, int32_t iDensityMin, int32_t iDensityMax, int32_t iIter)
|
||||
{
|
||||
bool fBreak = false;
|
||||
int32_t ctcox,ctcoy,cx,cy;
|
||||
|
@ -626,7 +626,7 @@ bool SimFlight(FIXED &x, FIXED &y, FIXED &xdir, FIXED &ydir, int32_t iDensityMin
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SimFlightHitsLiquid(FIXED fcx, FIXED fcy, FIXED xdir, FIXED ydir)
|
||||
bool SimFlightHitsLiquid(C4Real fcx, C4Real fcy, C4Real xdir, C4Real ydir)
|
||||
{
|
||||
// Start in water?
|
||||
if (DensityLiquid(GBackDensity(fixtoi(fcx), fixtoi(fcy))))
|
||||
|
|
|
@ -227,7 +227,7 @@ void C4Object::Default()
|
|||
bool C4Object::Init(C4PropList *pDef, C4Object *pCreator,
|
||||
int32_t iOwner, C4ObjectInfo *pInfo,
|
||||
int32_t nx, int32_t ny, int32_t nr,
|
||||
FIXED nxdir, FIXED nydir, FIXED nrdir, int32_t iController)
|
||||
C4Real nxdir, C4Real nydir, C4Real nrdir, int32_t iController)
|
||||
{
|
||||
C4PropListNumbered::AcquireNumber();
|
||||
// currently initializing
|
||||
|
@ -729,7 +729,7 @@ void C4Object::SetOCF()
|
|||
uint32_t dwOCFOld = OCF;
|
||||
#endif
|
||||
// Update the object character flag according to the object's current situation
|
||||
FIXED cspeed=GetSpeed();
|
||||
C4Real cspeed=GetSpeed();
|
||||
#ifdef _DEBUG
|
||||
if (Contained && !::Objects.ObjectNumber(Contained))
|
||||
{ LogF("Warning: contained in wild object %p!", static_cast<void*>(Contained)); }
|
||||
|
@ -868,7 +868,7 @@ void C4Object::UpdateOCF()
|
|||
uint32_t dwOCFOld = OCF;
|
||||
#endif
|
||||
// Update the object character flag according to the object's current situation
|
||||
FIXED cspeed=GetSpeed();
|
||||
C4Real cspeed=GetSpeed();
|
||||
#ifdef _DEBUG
|
||||
if (Contained && !::Objects.ObjectNumber(Contained))
|
||||
{ LogF("Warning: contained in wild object %p!", static_cast<void*>(Contained)); }
|
||||
|
@ -1449,7 +1449,7 @@ void C4Object::DoCon(int32_t iChange, bool fInitial, bool fNoComponentChange)
|
|||
int32_t iStepSize=FullCon/100;
|
||||
int32_t lRHgt=Shape.Hgt,lRy=Shape.GetY();
|
||||
int32_t iLastStep=Con/iStepSize;
|
||||
FIXED strgt_con_b = fix_y + Shape.GetY() + Shape.Hgt;
|
||||
C4Real strgt_con_b = fix_y + Shape.GetY() + Shape.Hgt;
|
||||
bool fWasFull = (Con>=FullCon);
|
||||
|
||||
// Change con
|
||||
|
@ -1549,7 +1549,7 @@ void C4Object::DoExperience(int32_t change)
|
|||
Promote(Info->Rank+1, false, false);
|
||||
}
|
||||
|
||||
bool C4Object::Exit(int32_t iX, int32_t iY, int32_t iR, FIXED iXDir, FIXED iYDir, FIXED iRDir, bool fCalls)
|
||||
bool C4Object::Exit(int32_t iX, int32_t iY, int32_t iR, C4Real iXDir, C4Real iYDir, C4Real iRDir, bool fCalls)
|
||||
{
|
||||
// 1. Exit the current container.
|
||||
// 2. Update Contents of container object and set Contained to NULL.
|
||||
|
@ -1652,7 +1652,7 @@ bool C4Object::Enter(C4Object *pTarget, bool fCalls, bool fCopyMotion, bool *pfR
|
|||
return true;
|
||||
}
|
||||
|
||||
void C4Object::Fling(FIXED txdir, FIXED tydir, bool fAddSpeed)
|
||||
void C4Object::Fling(C4Real txdir, C4Real tydir, bool fAddSpeed)
|
||||
{
|
||||
if (fAddSpeed) { txdir+=xdir/2; tydir+=ydir/2; }
|
||||
if (!ObjectActionTumble(this,(txdir<0),txdir,tydir))
|
||||
|
@ -1779,7 +1779,7 @@ bool C4Object::Chop(C4Object *pByObject)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool C4Object::Push(FIXED txdir, FIXED dforce, bool fStraighten)
|
||||
bool C4Object::Push(C4Real txdir, C4Real dforce, bool fStraighten)
|
||||
{
|
||||
// Valid check
|
||||
if (!Status || !Def || Contained || !(OCF & OCF_Grab)) return false;
|
||||
|
@ -1829,7 +1829,7 @@ bool C4Object::Push(FIXED txdir, FIXED dforce, bool fStraighten)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool C4Object::Lift(FIXED tydir, FIXED dforce)
|
||||
bool C4Object::Lift(C4Real tydir, C4Real dforce)
|
||||
{
|
||||
// Valid check
|
||||
if (!Status || !Def || Contained) return false;
|
||||
|
@ -2088,7 +2088,7 @@ BYTE C4Object::GetEntranceArea(int32_t &aX, int32_t &aY, int32_t &aWdt, int32_t
|
|||
return 1;
|
||||
}
|
||||
|
||||
BYTE C4Object::GetMomentum(FIXED &rxdir, FIXED &rydir)
|
||||
BYTE C4Object::GetMomentum(C4Real &rxdir, C4Real &rydir)
|
||||
{
|
||||
rxdir=rydir=0;
|
||||
if (!Status || !Def) return 0;
|
||||
|
@ -2096,9 +2096,9 @@ BYTE C4Object::GetMomentum(FIXED &rxdir, FIXED &rydir)
|
|||
return 1;
|
||||
}
|
||||
|
||||
FIXED C4Object::GetSpeed()
|
||||
C4Real C4Object::GetSpeed()
|
||||
{
|
||||
FIXED cobjspd=Fix0;
|
||||
C4Real cobjspd=Fix0;
|
||||
if (xdir<0) cobjspd-=xdir; else cobjspd+=xdir;
|
||||
if (ydir<0) cobjspd-=ydir; else cobjspd+=ydir;
|
||||
return cobjspd;
|
||||
|
@ -3569,7 +3569,7 @@ bool ContactVtxCNAT(C4Object *cobj, BYTE cnat_dir);
|
|||
void C4Object::ContactAction()
|
||||
{
|
||||
// Take certain action on contact. Evaluate t_contact-CNAT and Procedure.
|
||||
FIXED last_xdir;
|
||||
C4Real last_xdir;
|
||||
|
||||
int32_t iDir;
|
||||
C4PhysicalInfo *pPhysical=GetPhysical();
|
||||
|
@ -3796,7 +3796,7 @@ void C4Object::ContactAction()
|
|||
}
|
||||
}
|
||||
|
||||
void Towards(FIXED &val, FIXED target, FIXED step)
|
||||
void Towards(C4Real &val, C4Real target, C4Real step)
|
||||
{
|
||||
if (val==target) return;
|
||||
if (Abs(val-target)<=step) { val=target; return; }
|
||||
|
@ -3925,8 +3925,8 @@ void C4Object::ExecAction()
|
|||
{
|
||||
Action.t_attach=CNAT_None;
|
||||
DWORD ocf;
|
||||
FIXED iTXDir;
|
||||
FIXED lftspeed,tydir;
|
||||
C4Real iTXDir;
|
||||
C4Real lftspeed,tydir;
|
||||
int32_t iTargetX;
|
||||
int32_t iPushRange,iPushDistance;
|
||||
|
||||
|
@ -3957,8 +3957,8 @@ void C4Object::ExecAction()
|
|||
// Determine ActDef & Physical Info
|
||||
//C4PropList * pAction = Action.pActionDef;
|
||||
C4PhysicalInfo *pPhysical=GetPhysical();
|
||||
FIXED lLimit;
|
||||
FIXED fWalk,fMove;
|
||||
C4Real lLimit;
|
||||
C4Real fWalk,fMove;
|
||||
int32_t smpx,smpy;
|
||||
|
||||
// Energy usage
|
||||
|
@ -4003,14 +4003,14 @@ void C4Object::ExecAction()
|
|||
// Handle Default Action Procedure: evaluates Procedure and Action.ComDir
|
||||
// Update xdir,ydir,Action.Dir,attachment,iPhaseAdvance
|
||||
int32_t dir = Action.Dir;
|
||||
FIXED accel = WalkAccel;
|
||||
C4Real accel = WalkAccel;
|
||||
|
||||
FIXED xlFloatAccel;
|
||||
FIXED xrFloatAccel;
|
||||
FIXED yuFloatAccel;
|
||||
FIXED ydFloatAccel;
|
||||
FIXED lFloatAccel;
|
||||
FIXED rFloatAccel;
|
||||
C4Real xlFloatAccel;
|
||||
C4Real xrFloatAccel;
|
||||
C4Real yuFloatAccel;
|
||||
C4Real ydFloatAccel;
|
||||
C4Real lFloatAccel;
|
||||
C4Real rFloatAccel;
|
||||
|
||||
switch (pActionDef->GetPropertyInt(P_Procedure))
|
||||
{
|
||||
|
|
|
@ -155,8 +155,8 @@ public:
|
|||
int32_t ViewEnergy; // NoSave //
|
||||
int32_t Audible, AudiblePan; // NoSave //
|
||||
int32_t PlrViewRange;
|
||||
FIXED fix_x,fix_y,fix_r; // SyncClearance-Fix //
|
||||
FIXED xdir,ydir,rdir;
|
||||
C4Real fix_x,fix_y,fix_r; // SyncClearance-Fix //
|
||||
C4Real xdir,ydir,rdir;
|
||||
int32_t iLastAttachMovementFrame; // last frame in which Attach-movement by a SolidMask was done
|
||||
bool Mobile;
|
||||
bool Select;
|
||||
|
@ -250,7 +250,7 @@ public:
|
|||
bool Init(C4PropList *ndef, C4Object *pCreator,
|
||||
int32_t owner, C4ObjectInfo *info,
|
||||
int32_t nx, int32_t ny, int32_t nr,
|
||||
FIXED nxdir, FIXED nydir, FIXED nrdir, int32_t iController);
|
||||
C4Real nxdir, C4Real nydir, C4Real nrdir, int32_t iController);
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
void DrawLine(C4TargetFacet &cgo);
|
||||
bool SetPhase(int32_t iPhase);
|
||||
|
@ -294,7 +294,7 @@ public:
|
|||
void AutoContextMenu(int32_t iMenuSelect);
|
||||
int32_t ContactCheck(int32_t atx, int32_t aty);
|
||||
bool Contact(int32_t cnat);
|
||||
void TargetBounds(FIXED &ctco, int32_t limit_low, int32_t limit_hi, int32_t cnat_low, int32_t cnat_hi);
|
||||
void TargetBounds(C4Real &ctco, int32_t limit_low, int32_t limit_hi, int32_t cnat_low, int32_t cnat_hi);
|
||||
enum { SAC_StartCall = 1, SAC_EndCall = 2, SAC_AbortCall = 4 };
|
||||
C4PropList* GetAction();
|
||||
bool SetAction(C4PropList * Act, C4Object *pTarget=NULL, C4Object *pTarget2=NULL, int32_t iCalls = SAC_StartCall | SAC_AbortCall, bool fForce = false);
|
||||
|
@ -304,7 +304,7 @@ public:
|
|||
void SetCategory(int32_t Category) { this->Category = Category; Resort(); SetOCF(); }
|
||||
int32_t GetProcedure();
|
||||
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=NULL);
|
||||
bool Exit(int32_t iX=0, int32_t iY=0, int32_t iR=0, FIXED iXDir=Fix0, FIXED iYDir=Fix0, FIXED iRDir=Fix0, bool fCalls=true);
|
||||
bool Exit(int32_t iX=0, int32_t iY=0, int32_t iR=0, C4Real iXDir=Fix0, C4Real iYDir=Fix0, C4Real iRDir=Fix0, bool fCalls=true);
|
||||
void CopyMotion(C4Object *from);
|
||||
void ForcePosition(int32_t tx, int32_t ty);
|
||||
void MovePosition(int32_t dx, int32_t dy);
|
||||
|
@ -323,9 +323,9 @@ public:
|
|||
void Blast(int32_t iLevel, int32_t iCausedBy);
|
||||
bool Build(int32_t iLevel, C4Object *pBuilder);
|
||||
bool Chop(C4Object *pByObject);
|
||||
bool Push(FIXED txdir, FIXED dforce, bool fStraighten);
|
||||
bool Lift(FIXED tydir, FIXED dforce);
|
||||
void Fling(FIXED txdir, FIXED tydir, bool fAddSpeed); // set/add given speed to current, setting jump/tumble-actions
|
||||
bool Push(C4Real txdir, C4Real dforce, bool fStraighten);
|
||||
bool Lift(C4Real tydir, C4Real dforce);
|
||||
void Fling(C4Real txdir, C4Real tydir, bool fAddSpeed); // set/add given speed to current, setting jump/tumble-actions
|
||||
C4Object* CreateContents(C4PropList *);
|
||||
bool CreateContentsByList(C4IDList &idlist);
|
||||
BYTE GetArea(int32_t &aX, int32_t &aY, int32_t &aWdt, int32_t &aHgt);
|
||||
|
@ -336,11 +336,11 @@ public:
|
|||
inline int32_t Height() { return Shape.Hgt+addtop(); } // height of shape (+build-top)
|
||||
inline int32_t GetX() { return fixtoi(fix_x); }
|
||||
inline int32_t GetY() { return fixtoi(fix_y); }
|
||||
inline FIXED GetFixedX() { return fix_x; }
|
||||
inline FIXED GetFixedY() { return fix_y; }
|
||||
inline C4Real GetFixedX() { return fix_x; }
|
||||
inline C4Real GetFixedY() { return fix_y; }
|
||||
BYTE GetEntranceArea(int32_t &aX, int32_t &aY, int32_t &aWdt, int32_t &aHgt);
|
||||
BYTE GetMomentum(FIXED &rxdir, FIXED &rydir);
|
||||
FIXED GetSpeed();
|
||||
BYTE GetMomentum(C4Real &rxdir, C4Real &rydir);
|
||||
C4Real GetSpeed();
|
||||
C4PhysicalInfo *GetPhysical(bool fPermanent=false);
|
||||
bool TrainPhysical(C4PhysicalInfo::Offset mpiOffset, int32_t iTrainBy, int32_t iMaxTrain);
|
||||
void SetName (const char *NewName = 0);
|
||||
|
@ -372,11 +372,11 @@ public:
|
|||
bool GetDragImage(C4Object **drag_object, C4ID *drag_id); // return true if object is draggable; assign drag_object/drag_id to gfx to be used for dragging
|
||||
|
||||
protected:
|
||||
void SideBounds(FIXED &ctcox); // apply bounds at side; regarding bourder bound and pLayer
|
||||
void VerticalBounds(FIXED &ctcoy); // apply bounds at top and bottom; regarding border bound and pLayer
|
||||
void SideBounds(C4Real &ctcox); // apply bounds at side; regarding bourder bound and pLayer
|
||||
void VerticalBounds(C4Real &ctcoy); // apply bounds at top and bottom; regarding border bound and pLayer
|
||||
|
||||
public:
|
||||
void BoundsCheck(FIXED &ctcox, FIXED &ctcoy) // do bound checks, correcting target positions as necessary and doing contact-calls
|
||||
void BoundsCheck(C4Real &ctcox, C4Real &ctcoy) // do bound checks, correcting target positions as necessary and doing contact-calls
|
||||
{ SideBounds(ctcox); VerticalBounds(ctcoy); }
|
||||
|
||||
public:
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <C4PlayerList.h>
|
||||
#include <C4GameObjects.h>
|
||||
|
||||
bool SimFlightHitsLiquid(FIXED fcx, FIXED fcy, FIXED xdir, FIXED ydir);
|
||||
bool SimFlightHitsLiquid(C4Real fcx, C4Real fcy, C4Real xdir, C4Real ydir);
|
||||
bool CreateConstructionSite(int32_t ctx, int32_t bty, C4ID strid, int32_t owner, C4Object *pByObj);
|
||||
|
||||
bool ObjectActionWalk(C4Object *cObj)
|
||||
|
@ -57,7 +57,7 @@ bool ObjectActionStand(C4Object *cObj)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ObjectActionJump(C4Object *cObj, FIXED xdir, FIXED ydir, bool fByCom)
|
||||
bool ObjectActionJump(C4Object *cObj, C4Real xdir, C4Real ydir, bool fByCom)
|
||||
{
|
||||
// scripted jump?
|
||||
assert(cObj);
|
||||
|
@ -73,7 +73,7 @@ bool ObjectActionJump(C4Object *cObj, FIXED xdir, FIXED ydir, bool fByCom)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ObjectActionDive(C4Object *cObj, FIXED xdir, FIXED ydir)
|
||||
bool ObjectActionDive(C4Object *cObj, C4Real xdir, C4Real ydir)
|
||||
{
|
||||
if (!cObj->SetActionByName("Dive")) return false;
|
||||
cObj->xdir=xdir; cObj->ydir=ydir;
|
||||
|
@ -84,7 +84,7 @@ bool ObjectActionDive(C4Object *cObj, FIXED xdir, FIXED ydir)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ObjectActionTumble(C4Object *cObj, int32_t dir, FIXED xdir, FIXED ydir)
|
||||
bool ObjectActionTumble(C4Object *cObj, int32_t dir, C4Real xdir, C4Real ydir)
|
||||
{
|
||||
if (!cObj->SetActionByName("Tumble")) return false;
|
||||
cObj->SetDir(dir);
|
||||
|
@ -92,7 +92,7 @@ bool ObjectActionTumble(C4Object *cObj, int32_t dir, FIXED xdir, FIXED ydir)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ObjectActionGetPunched(C4Object *cObj, FIXED xdir, FIXED ydir)
|
||||
bool ObjectActionGetPunched(C4Object *cObj, C4Real xdir, C4Real ydir)
|
||||
{
|
||||
if (!cObj->SetActionByName("GetPunched")) return false;
|
||||
cObj->xdir=xdir; cObj->ydir=ydir;
|
||||
|
@ -137,7 +137,7 @@ bool ObjectActionThrow(C4Object *cObj, C4Object *pThing)
|
|||
// Nothing to throw
|
||||
if (!pThing) return false;
|
||||
// Force and direction
|
||||
FIXED pthrow=ValByPhysical(400, cObj->GetPhysical()->Throw);
|
||||
C4Real pthrow=ValByPhysical(400, cObj->GetPhysical()->Throw);
|
||||
int32_t iDir=1; if (cObj->Action.Dir==DIR_Left) iDir=-1;
|
||||
// Set action
|
||||
if (!cObj->SetActionByName("Throw")) return false;
|
||||
|
@ -301,10 +301,10 @@ bool ObjectComJump(C4Object *cObj) // by ObjectComUp, ExecCMDFMoveTo, FnJump
|
|||
// Only if walking
|
||||
if (cObj->GetProcedure()!=DFA_WALK) return false;
|
||||
// Calculate direction & forces
|
||||
FIXED TXDir=Fix0;
|
||||
C4Real TXDir=Fix0;
|
||||
C4PhysicalInfo *pPhysical=cObj->GetPhysical();
|
||||
FIXED iPhysicalWalk = ValByPhysical(280, pPhysical->Walk) * itofix(cObj->GetCon(), FullCon);
|
||||
FIXED iPhysicalJump = ValByPhysical(1000, pPhysical->Jump) * itofix(cObj->GetCon(), FullCon);
|
||||
C4Real iPhysicalWalk = ValByPhysical(280, pPhysical->Walk) * itofix(cObj->GetCon(), FullCon);
|
||||
C4Real iPhysicalJump = ValByPhysical(1000, pPhysical->Jump) * itofix(cObj->GetCon(), FullCon);
|
||||
|
||||
if (cObj->Action.ComDir==COMD_Left || cObj->Action.ComDir==COMD_UpLeft) TXDir=-iPhysicalWalk;
|
||||
else if (cObj->Action.ComDir==COMD_Right || cObj->Action.ComDir==COMD_UpRight) TXDir=+iPhysicalWalk;
|
||||
|
@ -313,7 +313,7 @@ bool ObjectComJump(C4Object *cObj) // by ObjectComUp, ExecCMDFMoveTo, FnJump
|
|||
if (cObj->Action.Dir==DIR_Left) TXDir=-iPhysicalWalk;
|
||||
if (cObj->Action.Dir==DIR_Right) TXDir=+iPhysicalWalk;
|
||||
}
|
||||
FIXED x = cObj->fix_x, y = cObj->fix_y;
|
||||
C4Real x = cObj->fix_x, y = cObj->fix_y;
|
||||
// find bottom-most vertex, correct starting position for simulation
|
||||
int32_t iBtmVtx = cObj->Shape.GetBottomVertex();
|
||||
if (iBtmVtx != -1) { x += cObj->Shape.GetVertexX(iBtmVtx); y += cObj->Shape.GetVertexY(iBtmVtx); }
|
||||
|
@ -659,7 +659,7 @@ bool ObjectComDrop(C4Object *cObj, C4Object *pThing)
|
|||
// When dropping diagonally, drop from edge of shape
|
||||
// When doing a diagonal forward drop during flight, exit a bit closer to the Clonk to allow planned tumbling
|
||||
// Except when hangling, so you can mine effectively form the ceiling, and when swimming because you cannot tumble then
|
||||
FIXED pthrow=ValByPhysical(400, cObj->GetPhysical()->Throw);
|
||||
C4Real pthrow=ValByPhysical(400, cObj->GetPhysical()->Throw);
|
||||
int32_t tdir=0; int right=0;
|
||||
bool isHanglingOrSwimming = false;
|
||||
int32_t iProc = DFA_NONE;
|
||||
|
@ -788,7 +788,7 @@ bool ObjectComCancelAttach(C4Object *cObj)
|
|||
void ObjectComStopDig(C4Object *cObj)
|
||||
{
|
||||
// Stand - but keep momentum to allow more dyanamic digging
|
||||
FIXED o_xdir = cObj->xdir, o_ydir = cObj->ydir;
|
||||
C4Real o_xdir = cObj->xdir, o_ydir = cObj->ydir;
|
||||
ObjectActionStand(cObj);
|
||||
cObj->xdir = o_xdir; cObj->ydir = o_ydir;
|
||||
// Clear digging command
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef INC_C4ObjectCom
|
||||
#define INC_C4ObjectCom
|
||||
|
||||
#include <Fixed.h>
|
||||
#include "C4Real.h"
|
||||
#include <C4Id.h>
|
||||
|
||||
class C4Facet;
|
||||
|
@ -42,10 +42,10 @@ bool PlayerObjectCommand(int32_t plr, int32_t cmdf, C4Object *pTarget=NULL, int3
|
|||
|
||||
bool ObjectActionWalk(C4Object *cObj);
|
||||
bool ObjectActionStand(C4Object *cObj);
|
||||
bool ObjectActionJump(C4Object *cObj, FIXED xdir, FIXED ydir, bool fByCom);
|
||||
bool ObjectActionDive(C4Object *cObj, FIXED xdir, FIXED ydir);
|
||||
bool ObjectActionTumble(C4Object *cObj, int32_t dir, FIXED xdir, FIXED ydir);
|
||||
bool ObjectActionGetPunched(C4Object *cObj, FIXED xdir, FIXED ydir);
|
||||
bool ObjectActionJump(C4Object *cObj, C4Real xdir, C4Real ydir, bool fByCom);
|
||||
bool ObjectActionDive(C4Object *cObj, C4Real xdir, C4Real ydir);
|
||||
bool ObjectActionTumble(C4Object *cObj, int32_t dir, C4Real xdir, C4Real ydir);
|
||||
bool ObjectActionGetPunched(C4Object *cObj, C4Real xdir, C4Real ydir);
|
||||
bool ObjectActionKneel(C4Object *cObj);
|
||||
bool ObjectActionFlat(C4Object *cObj, int32_t dir);
|
||||
bool ObjectActionScale(C4Object *cObj, int32_t dir);
|
||||
|
|
|
@ -68,8 +68,8 @@ void C4Shape::Rotate(int32_t iAngle, bool bUpdateVertices)
|
|||
|
||||
//int32_t *vtx=VtxX;
|
||||
//int32_t *vty=VtxY;
|
||||
FIXED mtx[4];
|
||||
FIXED fAngle = itofix(iAngle);
|
||||
C4Real mtx[4];
|
||||
C4Real fAngle = itofix(iAngle);
|
||||
|
||||
if (bUpdateVertices)
|
||||
{
|
||||
|
|
|
@ -474,8 +474,8 @@ static C4Void FnSetPosition(C4AulObjectContext *cthr, long iX, long iY, bool fCh
|
|||
{
|
||||
if (fCheckBounds)
|
||||
{
|
||||
// BoundsCheck takes ref to FIXED and not to long
|
||||
FIXED i_x = itofix(iX), i_y = itofix(iY);
|
||||
// BoundsCheck takes ref to C4Real and not to long
|
||||
C4Real i_x = itofix(iX), i_y = itofix(iY);
|
||||
cthr->Obj->BoundsCheck(i_x, i_y);
|
||||
iX = fixtoi(i_x); iY = fixtoi(i_y);
|
||||
}
|
||||
|
@ -4688,7 +4688,7 @@ static bool FnSetObjDrawTransform2(C4AulObjectContext *ctx, long iA, long iB, lo
|
|||
? Par->GetData().Int \
|
||||
: Std)
|
||||
|
||||
bool SimFlight(FIXED &x, FIXED &y, FIXED &xdir, FIXED &ydir, int32_t iDensityMin, int32_t iDensityMax, int32_t iIter);
|
||||
bool SimFlight(C4Real &x, C4Real &y, C4Real &xdir, C4Real &ydir, int32_t iDensityMin, int32_t iDensityMax, int32_t iIter);
|
||||
|
||||
static C4Value FnSimFlight(C4AulContext *ctx, C4Value *pvrX, C4Value *pvrY, C4Value *pvrXDir, C4Value *pvrYDir, C4Value *pviDensityMin, C4Value *pviDensityMax, C4Value *pviIter, C4Value *pviPrec)
|
||||
{
|
||||
|
@ -4700,8 +4700,8 @@ static C4Value FnSimFlight(C4AulContext *ctx, C4Value *pvrX, C4Value *pvrY, C4Va
|
|||
COPY_C4V_PAR(int iIter, pviIter, C4V_Int, -1);
|
||||
COPY_C4V_PAR(int iPrec, pviPrec, C4V_Int, 10);
|
||||
|
||||
// convert to FIXED
|
||||
FIXED x = itofix(pvrX->GetData().Int), y = itofix(pvrY->GetData().Int),
|
||||
// convert to C4Real
|
||||
C4Real x = itofix(pvrX->GetData().Int), y = itofix(pvrY->GetData().Int),
|
||||
xdir = itofix(pvrXDir->GetData().Int, iPrec), ydir = itofix(pvrYDir->GetData().Int, iPrec);
|
||||
|
||||
// simulate
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
// fixed numbers - sine functions
|
||||
|
||||
#include "C4Include.h"
|
||||
#include <Fixed.h>
|
||||
#include "C4Real.h"
|
||||
|
||||
#include "StdCompiler.h"
|
||||
#include "StdAdaptors.h"
|
||||
|
||||
#ifdef USE_FIXED
|
||||
#ifdef C4REAL_USE_FIXNUM
|
||||
|
||||
// static table with sinus values from 0.00 degree to 90.00 degree inclusively
|
||||
long SineTable[9001] =
|
||||
|
@ -9030,11 +9030,11 @@ long SineTable[9001] =
|
|||
65535,
|
||||
65536
|
||||
};
|
||||
#endif // USE_FIXED
|
||||
#endif // C4REAL_USE_FIXNUM
|
||||
|
||||
void CompileFunc(FIXED &rValue, StdCompiler *pComp)
|
||||
void CompileFunc(C4Real &rValue, StdCompiler *pComp)
|
||||
{
|
||||
#ifdef USE_FIXED
|
||||
#ifdef C4REAL_USE_FIXNUM
|
||||
char cFormat = 'F';
|
||||
#else
|
||||
char cFormat = 'f';
|
||||
|
@ -9054,7 +9054,7 @@ void CompileFunc(FIXED &rValue, StdCompiler *pComp)
|
|||
// Read value (as int32_t)
|
||||
pComp->Value(mkCastAdapt<int32_t>(rValue));
|
||||
// convert, if neccessary
|
||||
#ifdef USE_FIXED
|
||||
#ifdef C4REAL_USE_FIXNUM
|
||||
if (cFormat == 'f')
|
||||
FLOAT_TO_FIXED(&rValue);
|
||||
#else
|
|
@ -33,13 +33,13 @@
|
|||
floating point code, leading to desyncs between linux and windows
|
||||
engines. */
|
||||
|
||||
#ifndef FIXED_H_INC
|
||||
#define FIXED_H_INC
|
||||
#ifndef INC_C4Real
|
||||
#define INC_C4Real
|
||||
|
||||
#include <math.h>
|
||||
|
||||
// activate to switch to classic fixed-point math
|
||||
#define USE_FIXED 1
|
||||
#define C4REAL_USE_FIXNUM 1
|
||||
#define inline ALWAYS_INLINE
|
||||
#define FIXED_EMULATE_64BIT
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
|||
// any more. It is used to convert old-format fixed values
|
||||
// to the new-format float ones.
|
||||
|
||||
#ifdef USE_FIXED
|
||||
#ifdef C4REAL_USE_FIXNUM
|
||||
extern long SineTable[9001]; // external table of sine values
|
||||
#endif
|
||||
|
||||
|
@ -58,7 +58,7 @@ extern long SineTable[9001]; // external table of sine values
|
|||
|
||||
class C4Fixed
|
||||
{
|
||||
#ifdef USE_FIXED
|
||||
#ifdef C4REAL_USE_FIXNUM
|
||||
friend int fixtoi(const C4Fixed &x);
|
||||
friend int fixtoi(const C4Fixed &x, int32_t prec);
|
||||
friend C4Fixed itofix(int32_t x);
|
||||
|
@ -223,7 +223,7 @@ public:
|
|||
inline bool operator != (int iVal2) const { return operator != (C4Fixed(int32_t(iVal2))); }
|
||||
#endif
|
||||
|
||||
#ifdef USE_FIXED
|
||||
#ifdef C4REAL_USE_FIXNUM
|
||||
C4Fixed sin_deg() const
|
||||
{
|
||||
// adjust angle
|
||||
|
@ -258,11 +258,9 @@ public:
|
|||
|
||||
};
|
||||
|
||||
#ifdef USE_FIXED
|
||||
#ifdef C4REAL_USE_FIXNUM
|
||||
|
||||
// *** wrap FIXED to C4Fixed
|
||||
|
||||
#define FIXED C4Fixed
|
||||
typedef C4Fixed C4Real;
|
||||
|
||||
// conversion
|
||||
inline float fixtof(const C4Fixed &x) { return x.to_float(); }
|
||||
|
@ -273,21 +271,21 @@ inline C4Fixed itofix(int32_t x) { return C4Fixed(x); }
|
|||
inline C4Fixed itofix(int32_t x, int32_t prec) { return C4Fixed(x, prec); }
|
||||
|
||||
// additional functions
|
||||
inline FIXED Sin(const FIXED &fAngle) { return fAngle.sin_deg(); }
|
||||
inline FIXED Cos(const FIXED &fAngle) { return fAngle.cos_deg(); }
|
||||
inline FIXED FIXED100(int x) { return itofix(x, 100); }
|
||||
//inline FIXED FIXED256(int x) { return itofix(x, 256); }
|
||||
inline FIXED FIXED256(int x) { C4Fixed r; r.val = x * FIXED_FPF / 256; return r; }
|
||||
inline FIXED FIXED10(int x) { return itofix(x, 10); }
|
||||
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); }
|
||||
|
||||
#else
|
||||
|
||||
// *** wrap FIXED to float
|
||||
// *** wrap C4Real to float
|
||||
|
||||
#define FIXED float
|
||||
typedef float C4Real;
|
||||
|
||||
// fixtoi: use asm fistp, round up
|
||||
inline int fixtoi(FIXED x)
|
||||
inline int fixtoi(C4Real x)
|
||||
{
|
||||
int e;
|
||||
#ifdef _MSC_VER
|
||||
|
@ -306,33 +304,33 @@ asm ("fistp%z0 %0" : "=om" (e) : "t" (x) : "st");
|
|||
}
|
||||
|
||||
// conversion
|
||||
inline int fixtoi(const FIXED &x, int32_t prec) { return fixtoi(x*prec); }
|
||||
inline FIXED itofix(int x) { return static_cast<FIXED>(x); }
|
||||
inline FIXED itofix(int x, int prec) { return static_cast<FIXED>(x) / prec; }
|
||||
inline float fixtof(const FIXED &x) { return x; }
|
||||
inline FIXED ftofix(float x) { return x; }
|
||||
inline int fixtoi(const C4Real &x, int32_t prec) { return fixtoi(x*prec); }
|
||||
inline C4Real itofix(int x) { return static_cast<C4Real>(x); }
|
||||
inline C4Real itofix(int x, int prec) { return static_cast<C4Real>(x) / prec; }
|
||||
inline float fixtof(const C4Real &x) { return x; }
|
||||
inline C4Real ftofix(float x) { return x; }
|
||||
|
||||
// additional functions
|
||||
inline FIXED Sin(FIXED x) { return float(sin(x * 3.141592f / 180)); }
|
||||
inline FIXED Cos(FIXED x) { return float(cos(x * 3.141592f / 180)); }
|
||||
inline FIXED FIXED100(int x) { return float(x) / 100; }
|
||||
inline FIXED FIXED256(int x) { return float(x) / 256; }
|
||||
inline FIXED FIXED10(int x) { return float(x) / 10; }
|
||||
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; }
|
||||
|
||||
#endif
|
||||
|
||||
// define 0
|
||||
const FIXED Fix0 = itofix(0);
|
||||
const C4Real Fix0 = itofix(0);
|
||||
|
||||
// conversion...
|
||||
// note: keep out! really dirty casts!
|
||||
#ifdef USE_FIXED
|
||||
inline void FLOAT_TO_FIXED(FIXED *pVal)
|
||||
#ifdef C4REAL_USE_FIXNUM
|
||||
inline void FLOAT_TO_FIXED(C4Real *pVal)
|
||||
{
|
||||
*pVal = ftofix (*reinterpret_cast<float *>(pVal));
|
||||
}
|
||||
#else
|
||||
inline void FIXED_TO_FLOAT(FIXED *pVal)
|
||||
inline void FIXED_TO_FLOAT(C4Real *pVal)
|
||||
{
|
||||
*pVal = reinterpret_cast<C4Fixed *>(pVal)->to_float();
|
||||
}
|
||||
|
@ -340,7 +338,7 @@ inline void FIXED_TO_FLOAT(FIXED *pVal)
|
|||
|
||||
#undef inline
|
||||
|
||||
// CompileFunc for FIXED
|
||||
void CompileFunc(FIXED &rValue, StdCompiler *pComp);
|
||||
// CompileFunc for C4Real
|
||||
void CompileFunc(C4Real &rValue, StdCompiler *pComp);
|
||||
|
||||
#endif //FIXED_H_INC
|
|
@ -132,13 +132,13 @@ namespace
|
|||
|
||||
if(pComp->isCompiler())
|
||||
{
|
||||
FIXED f;
|
||||
C4Real f;
|
||||
pComp->Value(f);
|
||||
Matrix(i,j) = fixtof(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
FIXED f = ftofix(Matrix(i,j));
|
||||
C4Real f = ftofix(Matrix(i,j));
|
||||
pComp->Value(f);
|
||||
}
|
||||
}
|
||||
|
@ -1711,8 +1711,8 @@ StdMeshInstance::AnimationNodeList::iterator StdMeshInstance::GetStackIterForSlo
|
|||
bool StdMeshInstance::ExecuteAnimationNode(AnimationNode* node)
|
||||
{
|
||||
ValueProvider* provider = NULL;
|
||||
FIXED min;
|
||||
FIXED max;
|
||||
C4Real min;
|
||||
C4Real max;
|
||||
|
||||
switch (node->GetType())
|
||||
{
|
||||
|
@ -1728,7 +1728,7 @@ bool StdMeshInstance::ExecuteAnimationNode(AnimationNode* node)
|
|||
break;
|
||||
}
|
||||
|
||||
const FIXED old_value = provider->Value;
|
||||
const C4Real old_value = provider->Value;
|
||||
if (!provider->Execute())
|
||||
{
|
||||
if (node->GetType() == AnimationNode::LeafNode) return false;
|
||||
|
|
|
@ -369,7 +369,7 @@ public:
|
|||
// otherwise.
|
||||
virtual bool Execute() = 0;
|
||||
|
||||
FIXED Value; // Current provider value
|
||||
C4Real Value; // Current provider value
|
||||
};
|
||||
|
||||
// Serializable value providers need to be registered with SerializeableValueProvider::Register.
|
||||
|
@ -459,12 +459,12 @@ public:
|
|||
|
||||
const StdMeshAnimation* GetAnimation() const { assert(Type == LeafNode); return Leaf.Animation; }
|
||||
ValueProvider* GetPositionProvider() { assert(Type == LeafNode); return Leaf.Position; }
|
||||
FIXED GetPosition() const { assert(Type == LeafNode); return Leaf.Position->Value; }
|
||||
C4Real GetPosition() const { assert(Type == LeafNode); return Leaf.Position->Value; }
|
||||
|
||||
AnimationNode* GetLeftChild() { assert(Type == LinearInterpolationNode); return LinearInterpolation.ChildLeft; }
|
||||
AnimationNode* GetRightChild() { assert(Type == LinearInterpolationNode); return LinearInterpolation.ChildRight; }
|
||||
ValueProvider* GetWeightProvider() { assert(Type == LinearInterpolationNode); return LinearInterpolation.Weight; }
|
||||
FIXED GetWeight() const { assert(Type == LinearInterpolationNode); return LinearInterpolation.Weight->Value; }
|
||||
C4Real GetWeight() const { assert(Type == LinearInterpolationNode); return LinearInterpolation.Weight->Value; }
|
||||
|
||||
void CompileFunc(StdCompiler* pComp, const StdMesh* Mesh);
|
||||
void EnumeratePointers();
|
||||
|
|
Loading…
Reference in New Issue