- floatification of p_3dfloors, p_3dmidtex and p_acs.cpp plus some leftovers.

- removed all references to Doom specific headers from xs_Float.h and cmath.h.
This commit is contained in:
Christoph Oelckers 2016-03-26 12:36:15 +01:00
parent 35bb686281
commit dabed04d2a
26 changed files with 319 additions and 335 deletions

View file

@ -12,10 +12,6 @@ typedef uint32_t uint32;
typedef int64_t SQWORD; typedef int64_t SQWORD;
typedef uint64_t QWORD; typedef uint64_t QWORD;
typedef SDWORD int32;
typedef float real32;
typedef double real64;
// windef.h, included by windows.h, has its own incompatible definition // windef.h, included by windows.h, has its own incompatible definition
// of DWORD as a long. In files that mix Doom and Windows code, you // of DWORD as a long. In files that mix Doom and Windows code, you
// must define USE_WINDOWS_DWORD before including doomtype.h so that // must define USE_WINDOWS_DWORD before including doomtype.h so that
@ -62,7 +58,7 @@ union QWORD_UNION
}; };
// //
// Fixed point, 32bit as 16.16. // fixed point, 32bit as 16.16.
// //
#define FRACBITS 16 #define FRACBITS 16
#define FRACUNIT (1<<FRACBITS) #define FRACUNIT (1<<FRACBITS)

View file

@ -384,14 +384,13 @@ void FParser::OPdivide(svalue_t &result, int start, int n, int stop)
// haleyjd: 8-17 // haleyjd: 8-17
if(left.type == svt_fixed || right.type == svt_fixed) if(left.type == svt_fixed || right.type == svt_fixed)
{ {
auto fr = fixedvalue(right); auto fr = floatvalue(right);
if(fr == 0) if(fr == 0)
script_error("divide by zero\n"); script_error("divide by zero\n");
else else
{ {
result.type = svt_fixed; result.setDouble(floatvalue(left) / fr);
result.value.f = FixedDiv(fixedvalue(left), fr);
} }
} }
else else

View file

@ -1,10 +1,9 @@
#ifndef __CMATH_H #ifndef __CMATH_H
#define __CMATH_H #define __CMATH_H
#include "tables.h" #include "xs_Float.h"
#include "m_fixed.h"
#define USE_CUSTOM_MATH // we want reoreducably reliable results, even at the cost of performance #define USE_CUSTOM_MATH // we want repreducably reliable results, even at the cost of performance
#define USE_FAST_MATH // use faster table-based sin and cos variants with limited precision (sufficient for Doom gameplay) #define USE_FAST_MATH // use faster table-based sin and cos variants with limited precision (sufficient for Doom gameplay)
extern"C" extern"C"
@ -49,42 +48,49 @@ public:
extern FFastTrig fasttrig; extern FFastTrig fasttrig;
#define DEG2BAM(f) ((unsigned)xs_CRoundToInt((f) * (0x40000000/90.)))
#define RAD2BAM(f) ((unsigned)xs_CRoundToInt((f) * (0x80000000/3.14159265358979323846)))
inline double fastcosdeg(double v) inline double fastcosdeg(double v)
{ {
return fasttrig.cos(FLOAT2ANGLE(v)); return fasttrig.cos(DEG2BAM(v));
} }
inline double fastsindeg(double v) inline double fastsindeg(double v)
{ {
return fasttrig.sin(FLOAT2ANGLE(v)); return fasttrig.sin(DEG2BAM(v));
} }
inline double fastcos(double v) inline double fastcos(double v)
{ {
return fasttrig.cos(RAD2ANGLE(v)); return fasttrig.cos(RAD2BAM(v));
} }
inline double fastsin(double v) inline double fastsin(double v)
{ {
return fasttrig.sin(RAD2ANGLE(v)); return fasttrig.sin(RAD2BAM(v));
} }
// these are supposed to be local to this file.
#undef DEG2BAM
#undef RAD2BAM
inline double sindeg(double v) inline double sindeg(double v)
{ {
#ifdef USE_CUSTOM_MATH #ifdef USE_CUSTOM_MATH
return c_sin(v * (M_PI / 180.)); return c_sin(v * (3.14159265358979323846 / 180.));
#else #else
return sin(v * (M_PI / 180.)); return sin(v * (3.14159265358979323846 / 180.));
#endif #endif
} }
inline double cosdeg(double v) inline double cosdeg(double v)
{ {
#ifdef USE_CUSTOM_MATH #ifdef USE_CUSTOM_MATH
return c_cos(v * (M_PI / 180.)); return c_cos(v * (3.14159265358979323846 / 180.));
#else #else
return cos(v * (M_PI / 180.)); return cos(v * (3.14159265358979323846 / 180.));
#endif #endif
} }

View file

@ -35,7 +35,11 @@
#include <math.h> #include <math.h>
#include "cmath.h" #include "cmath.h"
#include "m_fixed.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
FFastTrig fasttrig; FFastTrig fasttrig;

View file

@ -422,10 +422,10 @@ void P_Recalculate3DFloors(sector_t * sector)
unsigned pickindex; unsigned pickindex;
F3DFloor * clipped=NULL; F3DFloor * clipped=NULL;
F3DFloor * solid=NULL; F3DFloor * solid=NULL;
fixed_t solid_bottom=0; double solid_bottom=0;
fixed_t clipped_top; double clipped_top;
fixed_t clipped_bottom=0; double clipped_bottom=0;
fixed_t maxheight, minheight; double maxheight, minheight;
unsigned i, j; unsigned i, j;
lightlist_t newlight; lightlist_t newlight;
lightlist_t resetlight; // what it goes back to after FF_DOUBLESHADOW lightlist_t resetlight; // what it goes back to after FF_DOUBLESHADOW
@ -464,13 +464,13 @@ void P_Recalculate3DFloors(sector_t * sector)
while (oldlist.Size()) while (oldlist.Size())
{ {
pick=oldlist[0]; pick=oldlist[0];
fixed_t height=pick->top.plane->ZatPoint(sector->_f_centerspot()); double height=pick->top.plane->ZatPoint(sector->centerspot);
// find highest starting ffloor - intersections are not supported! // find highest starting ffloor - intersections are not supported!
pickindex=0; pickindex=0;
for (j=1;j<oldlist.Size();j++) for (j=1;j<oldlist.Size();j++)
{ {
fixed_t h2=oldlist[j]->top.plane->ZatPoint(sector->_f_centerspot()); double h2=oldlist[j]->top.plane->ZatPoint(sector->centerspot);
if (h2>height) if (h2>height)
{ {
@ -481,7 +481,7 @@ void P_Recalculate3DFloors(sector_t * sector)
} }
oldlist.Delete(pickindex); oldlist.Delete(pickindex);
fixed_t pick_bottom=pick->bottom.plane->ZatPoint(sector->_f_centerspot()); double pick_bottom=pick->bottom.plane->ZatPoint(sector->centerspot);
if (pick->flags & FF_THISINSIDE) if (pick->flags & FF_THISINSIDE)
{ {
@ -586,8 +586,8 @@ void P_Recalculate3DFloors(sector_t * sector)
resetlight = lightlist[0]; resetlight = lightlist[0];
maxheight = sector->CenterCeiling(); maxheight = sector->ceilingplane.ZatPoint(sector->centerspot);
minheight = sector->CenterFloor(); minheight = sector->floorplane.ZatPoint(sector->centerspot);
for(i = 0; i < ffloors.Size(); i++) for(i = 0; i < ffloors.Size(); i++)
{ {
rover=ffloors[i]; rover=ffloors[i];
@ -595,7 +595,7 @@ void P_Recalculate3DFloors(sector_t * sector)
if ( !(rover->flags & FF_EXISTS) || rover->flags & FF_NOSHADE ) if ( !(rover->flags & FF_EXISTS) || rover->flags & FF_NOSHADE )
continue; continue;
fixed_t ff_top=rover->top.plane->ZatPoint(sector->_f_centerspot()); double ff_top=rover->top.plane->ZatPoint(sector->centerspot);
if (ff_top < minheight) break; // reached the floor if (ff_top < minheight) break; // reached the floor
if (ff_top < maxheight) if (ff_top < maxheight)
{ {
@ -610,7 +610,7 @@ void P_Recalculate3DFloors(sector_t * sector)
} }
else else
{ {
fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sector->_f_centerspot()); double ff_bottom=rover->bottom.plane->ZatPoint(sector->centerspot);
if (ff_bottom<maxheight) if (ff_bottom<maxheight)
{ {
// this segment begins over the ceiling and extends beyond it // this segment begins over the ceiling and extends beyond it
@ -636,7 +636,7 @@ void P_Recalculate3DFloors(sector_t * sector)
if (rover->flags&FF_DOUBLESHADOW) if (rover->flags&FF_DOUBLESHADOW)
{ {
fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sector->_f_centerspot()); double ff_bottom=rover->bottom.plane->ZatPoint(sector->centerspot);
if(ff_bottom < maxheight && ff_bottom>minheight) if(ff_bottom < maxheight && ff_bottom>minheight)
{ {
newlight.caster = rover; newlight.caster = rover;
@ -724,11 +724,11 @@ lightlist_t * P_GetPlaneLight(sector_t * sector, secplane_t * plane, bool unders
unsigned i; unsigned i;
TArray<lightlist_t> &lightlist = sector->e->XFloor.lightlist; TArray<lightlist_t> &lightlist = sector->e->XFloor.lightlist;
fixed_t planeheight=plane->ZatPoint(sector->_f_centerspot()); double planeheight=plane->ZatPoint(sector->centerspot);
if(underside) planeheight--; if(underside) planeheight--;
for(i = 1; i < lightlist.Size(); i++) for(i = 1; i < lightlist.Size(); i++)
if (lightlist[i].plane.ZatPoint(sector->_f_centerspot()) <= planeheight) if (lightlist[i].plane.ZatPoint(sector->centerspot) <= planeheight)
return &lightlist[i - 1]; return &lightlist[i - 1];
return &lightlist[lightlist.Size() - 1]; return &lightlist[lightlist.Size() - 1];
@ -851,12 +851,6 @@ void P_Spawn3DFloors (void)
switch(line->special) switch(line->special)
{ {
case ExtraFloor_LightOnly: case ExtraFloor_LightOnly:
// Note: I am spawning both this and ZDoom's ExtraLight data
// I don't want to mess with both at the same time during rendering
// so inserting this into the 3D-floor table as well seemed to be
// the best option.
//
// This does not yet handle case 0 properly!
if (line->args[1] < 0 || line->args[1] > 2) line->args[1] = 0; if (line->args[1] < 0 || line->args[1] > 2) line->args[1] = 0;
P_Set3DFloor(line, 3, flagvals[line->args[1]], 0); P_Set3DFloor(line, 3, flagvals[line->args[1]], 0);
break; break;
@ -900,17 +894,16 @@ void P_Spawn3DFloors (void)
// //
//========================================================================== //==========================================================================
secplane_t P_FindFloorPlane(sector_t * sector, fixed_t x, fixed_t y, fixed_t z) secplane_t P_FindFloorPlane(sector_t * sector, const DVector3 &pos)
{ {
secplane_t retplane = sector->floorplane; secplane_t retplane = sector->floorplane;
if (sector->e) // apparently this can be called when the data is already gone if (sector->e) // apparently this can be called when the data is already gone
{ {
for(unsigned int i=0;i<sector->e->XFloor.ffloors.Size();i++) for(auto rover : sector->e->XFloor.ffloors)
{ {
F3DFloor * rover= sector->e->XFloor.ffloors[i];
if(!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; if(!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue;
if (rover->top.plane->ZatPoint(x, y) == z) if (rover->top.plane->ZatPoint(pos) == pos.Z)
{ {
retplane = *rover->top.plane; retplane = *rover->top.plane;
if (retplane.c<0) retplane.FlipVert(); if (retplane.c<0) retplane.FlipVert();
@ -928,20 +921,20 @@ secplane_t P_FindFloorPlane(sector_t * sector, fixed_t x, fixed_t y, fixed_t z)
// //
//========================================================================== //==========================================================================
int P_Find3DFloor(sector_t * sec, fixed_t x, fixed_t y, fixed_t z, bool above, bool floor, fixed_t &cmpz) int P_Find3DFloor(sector_t * sec, const DVector3 &pos, bool above, bool floor, double &cmpz)
{ {
// If no sector given, find the one appropriate // If no sector given, find the one appropriate
if (sec == NULL) if (sec == NULL)
sec = R_PointInSubsector(x, y)->sector; sec = P_PointInSector(pos);
// Above normal ceiling // Above normal ceiling
cmpz = sec->ceilingplane.ZatPoint(x, y); cmpz = sec->ceilingplane.ZatPoint(pos);
if (z >= cmpz) if (pos.Z >= cmpz)
return -1; return -1;
// Below normal floor // Below normal floor
cmpz = sec->floorplane.ZatPoint(x, y); cmpz = sec->floorplane.ZatPoint(pos);
if (z <= cmpz) if (pos.Z <= cmpz)
return -1; return -1;
// Looking through planes from top to bottom // Looking through planes from top to bottom
@ -955,19 +948,19 @@ int P_Find3DFloor(sector_t * sec, fixed_t x, fixed_t y, fixed_t z, bool above, b
if (above) if (above)
{ {
// z is above that floor // z is above that floor
if (floor && (z >= (cmpz = rover->top.plane->ZatPoint(x, y)))) if (floor && (pos.Z >= (cmpz = rover->top.plane->ZatPoint(pos))))
return i - 1; return i - 1;
// z is above that ceiling // z is above that ceiling
if (z >= (cmpz = rover->bottom.plane->ZatPoint(x, y))) if (pos.Z >= (cmpz = rover->bottom.plane->ZatPoint(pos)))
return i - 1; return i - 1;
} }
else // below else // below
{ {
// z is below that ceiling // z is below that ceiling
if (!floor && (z <= (cmpz = rover->bottom.plane->ZatPoint(x, y)))) if (!floor && (pos.Z <= (cmpz = rover->bottom.plane->ZatPoint(pos))))
return i; return i;
// z is below that floor // z is below that floor
if (z <= (cmpz = rover->top.plane->ZatPoint(x, y))) if (pos.Z <= (cmpz = rover->top.plane->ZatPoint(pos)))
return i; return i;
} }
} }
@ -989,13 +982,13 @@ CCMD (dump3df)
for (unsigned int i = 0; i < ffloors.Size(); i++) for (unsigned int i = 0; i < ffloors.Size(); i++)
{ {
fixed_t height=ffloors[i]->top.plane->ZatPoint(sector->_f_centerspot()); double height=ffloors[i]->top.plane->ZatPoint(sector->centerspot);
fixed_t bheight=ffloors[i]->bottom.plane->ZatPoint(sector->_f_centerspot()); double bheight=ffloors[i]->bottom.plane->ZatPoint(sector->centerspot);
IGNORE_FORMAT_PRE IGNORE_FORMAT_PRE
Printf("FFloor %d @ top = %f (model = %d), bottom = %f (model = %d), flags = %B, alpha = %d %s %s\n", Printf("FFloor %d @ top = %f (model = %d), bottom = %f (model = %d), flags = %B, alpha = %d %s %s\n",
i, height / 65536., ffloors[i]->top.model->sectornum, i, height, ffloors[i]->top.model->sectornum,
bheight / 65536., ffloors[i]->bottom.model->sectornum, bheight, ffloors[i]->bottom.model->sectornum,
ffloors[i]->flags, ffloors[i]->alpha, (ffloors[i]->flags&FF_EXISTS)? "Exists":"", (ffloors[i]->flags&FF_DYNAMIC)? "Dynamic":""); ffloors[i]->flags, ffloors[i]->alpha, (ffloors[i]->flags&FF_EXISTS)? "Exists":"", (ffloors[i]->flags&FF_DYNAMIC)? "Dynamic":"");
IGNORE_FORMAT_POST IGNORE_FORMAT_POST
} }

View file

@ -86,8 +86,6 @@ struct F3DFloor
short *toplightlevel; short *toplightlevel;
fixed_t delta;
unsigned int flags; unsigned int flags;
line_t* master; line_t* master;
@ -125,7 +123,6 @@ struct lightlist_t
class player_s; class player_s;
void P_PlayerOnSpecial3DFloor(player_t* player); void P_PlayerOnSpecial3DFloor(player_t* player);
void P_Get3DFloorAndCeiling(AActor * thing, sector_t * sector, fixed_t * floorz, fixed_t * ceilingz, int * floorpic);
bool P_CheckFor3DFloorHit(AActor * mo); bool P_CheckFor3DFloorHit(AActor * mo);
bool P_CheckFor3DCeilingHit(AActor * mo); bool P_CheckFor3DCeilingHit(AActor * mo);
void P_Recalculate3DFloors(sector_t *); void P_Recalculate3DFloors(sector_t *);
@ -141,19 +138,7 @@ struct FLineOpening;
void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *linedef, void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *linedef,
double x, double y, bool restrict); double x, double y, bool restrict);
secplane_t P_FindFloorPlane(sector_t * sector, fixed_t x, fixed_t y, fixed_t z); secplane_t P_FindFloorPlane(sector_t * sector, const DVector3 &pos);
int P_Find3DFloor(sector_t * sec, fixed_t x, fixed_t y, fixed_t z, bool above, bool floor, fixed_t &cmpz); int P_Find3DFloor(sector_t * sec, const DVector3 &pos, bool above, bool floor, double &cmpz);
inline int P_Find3DFloor(sector_t * sec, const fixedvec3 &pos, bool above, bool floor, fixed_t &cmpz)
{
return P_Find3DFloor(sec, pos.x, pos.y, pos.z, above, floor, cmpz);
}
inline int P_Find3DFloor(sector_t * sec, const DVector3 &pos, bool above, bool floor, double &cmpz)
{
fixed_t fr = FLOAT2FIXED(cmpz);
int ret = P_Find3DFloor(sec, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), above, floor, fr);
cmpz = FIXED2DBL(fr);
return ret;
}
#endif #endif

View file

@ -221,7 +221,7 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c
// Retrieves top and bottom of the current line's mid texture. // Retrieves top and bottom of the current line's mid texture.
// //
//============================================================================ //============================================================================
bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, fixed_t *ptexbot) bool P_GetMidTexturePosition(const line_t *line, int sideno, double *ptextop, double *ptexbot)
{ {
if (line->sidedef[0]==NULL || line->sidedef[1]==NULL) return false; if (line->sidedef[0]==NULL || line->sidedef[1]==NULL) return false;
@ -231,45 +231,31 @@ bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, f
FTexture * tex= TexMan(texnum); FTexture * tex= TexMan(texnum);
if (!tex) return false; if (!tex) return false;
double totalscale = fabs(FIXED2DBL(side->GetTextureYScale(side_t::mid)) * tex->GetScaleY()); double totalscale = fabs(side->GetTextureYScaleF(side_t::mid)) * tex->GetScaleY();
fixed_t y_offset = side->GetTextureYOffset(side_t::mid); double y_offset = side->GetTextureYOffsetF(side_t::mid);
fixed_t textureheight = tex->GetScaledHeight(totalscale) << FRACBITS; double textureheight = tex->GetHeight() / totalscale;
if (totalscale != 1. && !tex->bWorldPanning) if (totalscale != 1. && !tex->bWorldPanning)
{ {
y_offset = fixed_t(y_offset * totalscale); y_offset *= totalscale;
} }
if(line->flags & ML_DONTPEGBOTTOM) if(line->flags & ML_DONTPEGBOTTOM)
{ {
*ptexbot = y_offset + *ptexbot = y_offset +
MAX<fixed_t>(line->frontsector->GetPlaneTexZ(sector_t::floor), line->backsector->GetPlaneTexZ(sector_t::floor)); MAX(line->frontsector->GetPlaneTexZF(sector_t::floor), line->backsector->GetPlaneTexZF(sector_t::floor));
*ptextop = *ptexbot + textureheight; *ptextop = *ptexbot + textureheight;
} }
else else
{ {
*ptextop = y_offset + *ptextop = y_offset +
MIN<fixed_t>(line->frontsector->GetPlaneTexZ(sector_t::ceiling), line->backsector->GetPlaneTexZ(sector_t::ceiling)); MIN(line->frontsector->GetPlaneTexZF(sector_t::ceiling), line->backsector->GetPlaneTexZF(sector_t::ceiling));
*ptexbot = *ptextop - textureheight; *ptexbot = *ptextop - textureheight;
} }
return true; return true;
} }
bool P_GetMidTexturePosition(const line_t *line, int sideno, double *ptextop, double *ptexbot)
{
fixed_t t, b;
if (P_GetMidTexturePosition(line, sideno, &t, &b))
{
*ptextop = FIXED2DBL(t);
*ptexbot = FIXED2DBL(b);
return true;
}
return false;
}
//============================================================================ //============================================================================
// //
// P_LineOpening_3dMidtex // P_LineOpening_3dMidtex
@ -308,8 +294,8 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, FLineOpening &
open.abovemidtex = true; open.abovemidtex = true;
open.floorpic = linedef->sidedef[0]->GetTexture(side_t::mid); open.floorpic = linedef->sidedef[0]->GetTexture(side_t::mid);
open.floorterrain = TerrainTypes[open.floorpic]; open.floorterrain = TerrainTypes[open.floorpic];
open.frontfloorplane.SetAtHeight(FLOAT2FIXED(tt), sector_t::floor); open.frontfloorplane.SetAtHeight(tt, sector_t::floor);
open.backfloorplane.SetAtHeight(FLOAT2FIXED(tt), sector_t::floor); open.backfloorplane.SetAtHeight(tt, sector_t::floor);
} }
// returns true if it touches the midtexture // returns true if it touches the midtexture
@ -321,7 +307,7 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, FLineOpening &
/* still have to figure out what this code from Eternity means... /* still have to figure out what this code from Eternity means...
if((linedef->flags & ML_BLOCKMONSTERS) && if((linedef->flags & ML_BLOCKMONSTERS) &&
!(mo->flags & (MF_FLOAT | MF_DROPOFF)) && !(mo->flags & (MF_FLOAT | MF_DROPOFF)) &&
D_abs(mo->z - textop) <= 24*FRACUNIT) fabs(mo->Z() - tt) <= 24)
{ {
opentop = openbottom; opentop = openbottom;
openrange = 0; openrange = 0;

View file

@ -12,7 +12,7 @@ class AActor;
bool P_Scroll3dMidtex(sector_t *sector, int crush, fixed_t move, bool ceiling); bool P_Scroll3dMidtex(sector_t *sector, int crush, fixed_t move, bool ceiling);
void P_Start3dMidtexInterpolations(TArray<DInterpolation *> &list, sector_t *sec, bool ceiling); void P_Start3dMidtexInterpolations(TArray<DInterpolation *> &list, sector_t *sec, bool ceiling);
void P_Attach3dMidtexLinesToSector(sector_t *dest, int lineid, int tag, bool ceiling); void P_Attach3dMidtexLinesToSector(sector_t *dest, int lineid, int tag, bool ceiling);
bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, fixed_t *ptexbot); bool P_GetMidTexturePosition(const line_t *line, int sideno, double *ptextop, double *ptexbot);
bool P_Check3dMidSwitch(AActor *actor, line_t *line, int side); bool P_Check3dMidSwitch(AActor *actor, line_t *line, int side);
bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, struct FLineOpening &open, bool restrict=false); bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, struct FLineOpening &open, bool restrict=false);

View file

@ -175,7 +175,7 @@ inline DAngle ACSToAngle(int acsval)
inline int AngleToACS(DAngle ang) inline int AngleToACS(DAngle ang)
{ {
xs_CRoundToInt(ang.Degrees * (65536. / 360.)); return ang.BAMs() >> 16;
} }
struct CallReturn struct CallReturn
@ -722,7 +722,7 @@ void ACSStringPool::ReadStrings(PNGHandle *png, DWORD id)
if (len != 0) if (len != 0)
{ {
FPNGChunkArchive arc(png->File->GetFile(), id, len); FPNGChunkArchive arc(png->File->GetFile(), id, len);
int32 i, j, poolsize; int32_t i, j, poolsize;
unsigned int h, bucketnum; unsigned int h, bucketnum;
char *str = NULL; char *str = NULL;
@ -768,7 +768,7 @@ void ACSStringPool::ReadStrings(PNGHandle *png, DWORD id)
void ACSStringPool::WriteStrings(FILE *file, DWORD id) const void ACSStringPool::WriteStrings(FILE *file, DWORD id) const
{ {
int32 i, poolsize = (int32)Pool.Size(); int32_t i, poolsize = (int32_t)Pool.Size();
if (poolsize == 0) if (poolsize == 0)
{ // No need to write if we don't have anything. { // No need to write if we don't have anything.
@ -3554,13 +3554,13 @@ int DLevelScript::DoSpawnSpotFacing (int type, int spot, int tid, bool force)
return spawned; return spawned;
} }
void DLevelScript::DoFadeTo (int r, int g, int b, int a, fixed_t time) void DLevelScript::DoFadeTo (int r, int g, int b, int a, int time)
{ {
DoFadeRange (0, 0, 0, -1, clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255), clamp(a, 0, FRACUNIT), time); DoFadeRange (0, 0, 0, -1, clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255), clamp(a, 0, 65536), time);
} }
void DLevelScript::DoFadeRange (int r1, int g1, int b1, int a1, void DLevelScript::DoFadeRange (int r1, int g1, int b1, int a1,
int r2, int g2, int b2, int a2, fixed_t time) int r2, int g2, int b2, int a2, int time)
{ {
player_t *viewer; player_t *viewer;
float ftime = (float)time / 65536.f; float ftime = (float)time / 65536.f;
@ -4220,12 +4220,12 @@ bool DLevelScript::DoCheckActorTexture(int tid, AActor *activator, int string, b
if (floor) if (floor)
{ {
actor->Sector->NextLowestFloorAt(actor->_f_X(), actor->_f_Y(), actor->_f_Z(), 0, actor->_f_MaxStepHeight(), &resultsec, &resffloor); actor->Sector->NextLowestFloorAt(actor->X(), actor->Y(), actor->Z(), 0, actor->MaxStepHeight, &resultsec, &resffloor);
secpic = resffloor ? *resffloor->top.texture : resultsec->planes[sector_t::floor].Texture; secpic = resffloor ? *resffloor->top.texture : resultsec->planes[sector_t::floor].Texture;
} }
else else
{ {
actor->Sector->NextHighestCeilingAt(actor->_f_X(), actor->_f_Y(), actor->_f_Z(), actor->_f_Top(), 0, &resultsec, &resffloor); actor->Sector->NextHighestCeilingAt(actor->X(), actor->Y(), actor->Z(), actor->Top(), 0, &resultsec, &resffloor);
secpic = resffloor ? *resffloor->bottom.texture : resultsec->planes[sector_t::ceiling].Texture; secpic = resffloor ? *resffloor->bottom.texture : resultsec->planes[sector_t::ceiling].Texture;
} }
return tex == TexMan[secpic]; return tex == TexMan[secpic];
@ -5957,22 +5957,22 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
case ACSF_GetActorRoll: case ACSF_GetActorRoll:
actor = SingleActorFromTID(args[0], activator); actor = SingleActorFromTID(args[0], activator);
return actor != NULL? actor->Angles.Roll.FixedAngle() : 0; return actor != NULL? AngleToACS(actor->Angles.Roll) : 0;
// [ZK] A_Warp in ACS // [ZK] A_Warp in ACS
case ACSF_Warp: case ACSF_Warp:
{ {
int tid_dest = args[0]; int tid_dest = args[0];
fixed_t xofs = args[1]; int xofs = args[1];
fixed_t yofs = args[2]; int yofs = args[2];
fixed_t zofs = args[3]; int zofs = args[3];
angle_t angle = args[4]; int angle = args[4];
int flags = args[5]; int flags = args[5];
const char *statename = argCount > 6 ? FBehavior::StaticLookupString(args[6]) : ""; const char *statename = argCount > 6 ? FBehavior::StaticLookupString(args[6]) : "";
bool exact = argCount > 7 ? !!args[7] : false; bool exact = argCount > 7 ? !!args[7] : false;
fixed_t heightoffset = argCount > 8 ? args[8] : 0; int heightoffset = argCount > 8 ? args[8] : 0;
fixed_t radiusoffset = argCount > 9 ? args[9] : 0; int radiusoffset = argCount > 9 ? args[9] : 0;
fixed_t pitch = argCount > 10 ? args[10] : 0; int pitch = argCount > 10 ? args[10] : 0;
FState *state = argCount > 6 ? activator->GetClass()->FindStateByString(statename, exact) : 0; FState *state = argCount > 6 ? activator->GetClass()->FindStateByString(statename, exact) : 0;
@ -6047,15 +6047,15 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
bool fullbright = argCount > 1 ? !!args[1] : false; bool fullbright = argCount > 1 ? !!args[1] : false;
int lifetime = argCount > 2 ? args[2] : 35; int lifetime = argCount > 2 ? args[2] : 35;
int size = argCount > 3 ? args[3] : 1; int size = argCount > 3 ? args[3] : 1;
fixed_t x = argCount > 4 ? args[4] : 0; int x = argCount > 4 ? args[4] : 0;
fixed_t y = argCount > 5 ? args[5] : 0; int y = argCount > 5 ? args[5] : 0;
fixed_t z = argCount > 6 ? args[6] : 0; int z = argCount > 6 ? args[6] : 0;
fixed_t xvel = argCount > 7 ? args[7] : 0; int xvel = argCount > 7 ? args[7] : 0;
fixed_t yvel = argCount > 8 ? args[8] : 0; int yvel = argCount > 8 ? args[8] : 0;
fixed_t zvel = argCount > 9 ? args[9] : 0; int zvel = argCount > 9 ? args[9] : 0;
fixed_t accelx = argCount > 10 ? args[10] : 0; int accelx = argCount > 10 ? args[10] : 0;
fixed_t accely = argCount > 11 ? args[11] : 0; int accely = argCount > 11 ? args[11] : 0;
fixed_t accelz = argCount > 12 ? args[12] : 0; int accelz = argCount > 12 ? args[12] : 0;
int startalpha = argCount > 13 ? args[13] : 0xFF; // Byte trans int startalpha = argCount > 13 ? args[13] : 0xFF; // Byte trans
int fadestep = argCount > 14 ? args[14] : -1; int fadestep = argCount > 14 ? args[14] : -1;
@ -6065,7 +6065,10 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
size = clamp<int>(size, 0, 65535); // Clamp to word size = clamp<int>(size, 0, 65535); // Clamp to word
if (lifetime != 0) if (lifetime != 0)
P_SpawnParticle(x, y, z, xvel, yvel, zvel, color, fullbright, startalpha, lifetime, size, fadestep, accelx, accely, accelz); P_SpawnParticle(DVector3(ACSToDouble(x), ACSToDouble(y), ACSToDouble(z)),
DVector3(ACSToDouble(xvel), ACSToDouble(yvel), ACSToDouble(zvel)),
DVector3(ACSToDouble(accelx), ACSToDouble(accely), ACSToDouble(accelz)),
color, fullbright, startalpha/255., lifetime, size, fadestep/255.);
} }
break; break;
@ -8730,21 +8733,21 @@ scriptwait:
case PCD_GETACTORANGLE: case PCD_GETACTORANGLE:
{ {
AActor *actor = SingleActorFromTID(STACK(1), activator); AActor *actor = SingleActorFromTID(STACK(1), activator);
STACK(1) = actor == NULL ? 0 : actor->Angles.Yaw.FixedAngle(); STACK(1) = actor == NULL ? 0 : AngleToACS(actor->Angles.Yaw);
} }
break; break;
case PCD_GETACTORPITCH: case PCD_GETACTORPITCH:
{ {
AActor *actor = SingleActorFromTID(STACK(1), activator); AActor *actor = SingleActorFromTID(STACK(1), activator);
STACK(1) = actor == NULL ? 0 : actor->Angles.Pitch.FixedAngle(); STACK(1) = actor == NULL ? 0 : AngleToACS(actor->Angles.Pitch);
} }
break; break;
case PCD_GETLINEROWOFFSET: case PCD_GETLINEROWOFFSET:
if (activationline != NULL) if (activationline != NULL)
{ {
PushToStack (activationline->sidedef[0]->GetTextureYOffset(side_t::mid) >> FRACBITS); PushToStack (int(activationline->sidedef[0]->GetTextureYOffsetF(side_t::mid)));
} }
else else
{ {
@ -8761,28 +8764,27 @@ scriptwait:
{ {
int tag = STACK(3); int tag = STACK(3);
int secnum; int secnum;
fixed_t x = STACK(2) << FRACBITS; DVector2 pos(ACSToDouble(STACK(2)), ACSToDouble(STACK(1)));
fixed_t y = STACK(1) << FRACBITS; double z = 0;
fixed_t z = 0;
if (tag != 0) if (tag != 0)
secnum = P_FindFirstSectorFromTag (tag); secnum = P_FindFirstSectorFromTag (tag);
else else
secnum = int(P_PointInSector (x, y) - sectors); secnum = int(P_PointInSector (pos) - sectors);
if (secnum >= 0) if (secnum >= 0)
{ {
if (pcd == PCD_GETSECTORFLOORZ) if (pcd == PCD_GETSECTORFLOORZ)
{ {
z = sectors[secnum].floorplane.ZatPoint (x, y); z = sectors[secnum].floorplane.ZatPoint (pos);
} }
else else
{ {
z = sectors[secnum].ceilingplane.ZatPoint (x, y); z = sectors[secnum].ceilingplane.ZatPoint (pos);
} }
} }
sp -= 2; sp -= 2;
STACK(1) = z; STACK(1) = DoubleToACS(z);
} }
break; break;
@ -8863,12 +8865,12 @@ scriptwait:
{ // translation using desaturation { // translation using desaturation
int start = STACK(8); int start = STACK(8);
int end = STACK(7); int end = STACK(7);
fixed_t r1 = STACK(6); int r1 = STACK(6);
fixed_t g1 = STACK(5); int g1 = STACK(5);
fixed_t b1 = STACK(4); int b1 = STACK(4);
fixed_t r2 = STACK(3); int r2 = STACK(3);
fixed_t g2 = STACK(2); int g2 = STACK(2);
fixed_t b2 = STACK(1); int b2 = STACK(1);
sp -= 8; sp -= 8;
if (translation != NULL) if (translation != NULL)
@ -8886,15 +8888,15 @@ scriptwait:
break; break;
case PCD_SIN: case PCD_SIN:
STACK(1) = finesine[angle_t(STACK(1)<<16)>>ANGLETOFINESHIFT]; STACK(1) = DoubleToACS(ACSToAngle(STACK(1)).Sin());
break; break;
case PCD_COS: case PCD_COS:
STACK(1) = finecosine[angle_t(STACK(1)<<16)>>ANGLETOFINESHIFT]; STACK(1) = DoubleToACS(ACSToAngle(STACK(1)).Cos());
break; break;
case PCD_VECTORANGLE: case PCD_VECTORANGLE:
STACK(2) = R_PointToAngle2 (0, 0, STACK(2), STACK(1)) >> 16; STACK(2) = AngleToACS(VecToAngle(STACK(2), STACK(1)).Degrees);
sp--; sp--;
break; break;
@ -9075,14 +9077,14 @@ scriptwait:
// projectile a TID. // projectile a TID.
// Thing_Projectile2 (tid, type, angle, speed, vspeed, gravity, newtid); // Thing_Projectile2 (tid, type, angle, speed, vspeed, gravity, newtid);
P_Thing_Projectile(STACK(7), activator, STACK(6), NULL, STACK(5) * (360. / 256.), P_Thing_Projectile(STACK(7), activator, STACK(6), NULL, STACK(5) * (360. / 256.),
STACK(4) << (FRACBITS - 3), STACK(3) << (FRACBITS - 3), 0, NULL, STACK(2), STACK(1), false); ACSToDouble(STACK(4)) / 8., ACSToDouble(STACK(3)) / 8., 0, NULL, STACK(2), STACK(1), false);
sp -= 7; sp -= 7;
break; break;
case PCD_SPAWNPROJECTILE: case PCD_SPAWNPROJECTILE:
// Same, but takes an actor name instead of a spawn ID. // Same, but takes an actor name instead of a spawn ID.
P_Thing_Projectile(STACK(7), activator, 0, FBehavior::StaticLookupString(STACK(6)), STACK(5) * (360. / 256.), P_Thing_Projectile(STACK(7), activator, 0, FBehavior::StaticLookupString(STACK(6)), STACK(5) * (360. / 256.),
STACK(4) << (FRACBITS - 3), STACK(3) << (FRACBITS - 3), 0, NULL, STACK(2), STACK(1), false); ACSToDouble(STACK(4)) / 8., ACSToDouble(STACK(3)) / 8., 0, NULL, STACK(2), STACK(1), false);
sp -= 7; sp -= 7;
break; break;

View file

@ -915,9 +915,9 @@ protected:
int DoClassifyActor (int tid); int DoClassifyActor (int tid);
int CallFunction(int argCount, int funcIndex, SDWORD *args); int CallFunction(int argCount, int funcIndex, SDWORD *args);
void DoFadeTo (int r, int g, int b, int a, fixed_t time); void DoFadeTo (int r, int g, int b, int a, int time);
void DoFadeRange (int r1, int g1, int b1, int a1, void DoFadeRange (int r1, int g1, int b1, int a1,
int r2, int g2, int b2, int a2, fixed_t time); int r2, int g2, int b2, int a2, int time);
void DoSetFont (int fontnum); void DoSetFont (int fontnum);
void SetActorProperty (int tid, int property, int value); void SetActorProperty (int tid, int property, int value);
void DoSetActorProperty (AActor *actor, int property, int value); void DoSetActorProperty (AActor *actor, int property, int value);

View file

@ -313,26 +313,27 @@ void P_ThinkParticles ()
} }
} }
void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t vx, fixed_t vy, fixed_t vz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, int size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz)
void P_SpawnParticle(const DVector3 &pos, const DVector3 &vel, const DVector3 &accel, PalEntry color, bool fullbright, double startalpha, int lifetime, WORD size, double fadestep)
{ {
particle_t *particle = NewParticle(); particle_t *particle = NewParticle();
if (particle) if (particle)
{ {
particle->x = x; particle->x = FLOAT2FIXED(pos.X);
particle->y = y; particle->y = FLOAT2FIXED(pos.Y);
particle->z = z; particle->z = FLOAT2FIXED(pos.Z);
particle->vel.x = vx; particle->vel.x = FLOAT2FIXED(vel.X);
particle->vel.y = vy; particle->vel.y = FLOAT2FIXED(vel.Y);
particle->vel.z = vz; particle->vel.z = FLOAT2FIXED(vel.Z);
particle->color = ParticleColor(color); particle->color = ParticleColor(color);
particle->trans = startalpha; particle->trans = BYTE(startalpha*255);
if (fadestep < 0) fadestep = FADEFROMTTL(lifetime); if (fadestep < 0) particle->fade = FADEFROMTTL(lifetime);
particle->fade = fadestep; else particle->fade = int(fadestep * 255);
particle->ttl = lifetime; particle->ttl = lifetime;
particle->accx = accelx; particle->accx = FLOAT2FIXED(accel.X);
particle->accy = accely; particle->accy = FLOAT2FIXED(accel.Y);
particle->accz = accelz; particle->accz = FLOAT2FIXED(accel.Z);
particle->bright = fullbright; particle->bright = fullbright;
particle->size = (WORD)size; particle->size = (WORD)size;
} }

View file

@ -83,12 +83,7 @@ particle_t *JitterParticle (int ttl);
particle_t *JitterParticle (int ttl, double drift); particle_t *JitterParticle (int ttl, double drift);
void P_ThinkParticles (void); void P_ThinkParticles (void);
void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t vx, fixed_t vy, fixed_t vz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, int size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz); void P_SpawnParticle(const DVector3 &pos, const DVector3 &vel, const DVector3 &accel, PalEntry color, bool fullbright, double startalpha, int lifetime, WORD size, double fadestep);
inline void P_SpawnParticle(const DVector3 &pos, const DVector3 &vel, const DVector3 &accel, PalEntry color, bool fullbright, double startalpha, int lifetime, WORD size, double fadestep)
{
P_SpawnParticle(FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), FLOAT2FIXED(vel.X), FLOAT2FIXED(vel.Y), FLOAT2FIXED(vel.Z),
color, fullbright, BYTE(startalpha * 255), BYTE(lifetime), WORD(size), fadestep < 0 ? -1 : int(fadestep * 255), FLOAT2FIXED(accel.X), FLOAT2FIXED(accel.Y), FLOAT2FIXED(accel.Z));
}
void P_InitEffects (void); void P_InitEffects (void);
void P_RunEffects (void); void P_RunEffects (void);

View file

@ -2636,12 +2636,12 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates)
(vilesec != corpsec && corpsec->e->XFloor.ffloors.Size()) ? corpsec : NULL; (vilesec != corpsec && corpsec->e->XFloor.ffloors.Size()) ? corpsec : NULL;
if (testsec) if (testsec)
{ {
fixed_t zdist1, zdist2; double zdist1, zdist2;
if (P_Find3DFloor(testsec, corpsehit->_f_Pos(), false, true, zdist1) if (P_Find3DFloor(testsec, corpsehit->Pos(), false, true, zdist1)
!= P_Find3DFloor(testsec, self->_f_Pos(), false, true, zdist2)) != P_Find3DFloor(testsec, self->Pos(), false, true, zdist2))
{ {
// Not on same floor // Not on same floor
if (vilesec == corpsec || abs(zdist1 - self->_f_Z()) > self->_f_height()) if (vilesec == corpsec || fabs(zdist1 - self->Z()) > self->Height)
continue; continue;
} }
} }

View file

@ -79,7 +79,8 @@ static const BYTE ChangeMap[8] = { 0, 1, 5, 3, 7, 2, 6, 0 };
#define FUNC(a) static int a (line_t *ln, AActor *it, bool backSide, \ #define FUNC(a) static int a (line_t *ln, AActor *it, bool backSide, \
int arg0, int arg1, int arg2, int arg3, int arg4) int arg0, int arg1, int arg2, int arg3, int arg4)
#define SPEED(a) ((a)*(FRACUNIT/8)) #define SPEED(a) ((a) / 8.)
#define _f_SPEED(a) ((a)*(FRACUNIT/8))
#define TICS(a) (((a)*TICRATE)/35) #define TICS(a) (((a)*TICRATE)/35)
#define OCTICS(a) (((a)*TICRATE)/8) #define OCTICS(a) (((a)*TICRATE)/8)
#define _f_BYTEANGLE(a) ((angle_t)((a)<<24)) #define _f_BYTEANGLE(a) ((angle_t)((a)<<24))
@ -147,19 +148,19 @@ FUNC(LS_Polyobj_RotateRight)
FUNC(LS_Polyobj_Move) FUNC(LS_Polyobj_Move)
// Polyobj_Move (po, speed, angle, distance) // Polyobj_Move (po, speed, angle, distance)
{ {
return EV_MovePoly (ln, arg0, SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT, false); return EV_MovePoly (ln, arg0, _f_SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT, false);
} }
FUNC(LS_Polyobj_MoveTimes8) FUNC(LS_Polyobj_MoveTimes8)
// Polyobj_MoveTimes8 (po, speed, angle, distance) // Polyobj_MoveTimes8 (po, speed, angle, distance)
{ {
return EV_MovePoly (ln, arg0, SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT * 8, false); return EV_MovePoly (ln, arg0, _f_SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT * 8, false);
} }
FUNC(LS_Polyobj_MoveTo) FUNC(LS_Polyobj_MoveTo)
// Polyobj_MoveTo (po, speed, x, y) // Polyobj_MoveTo (po, speed, x, y)
{ {
return EV_MovePolyTo (ln, arg0, SPEED(arg1), arg2 << FRACBITS, arg3 << FRACBITS, false); return EV_MovePolyTo (ln, arg0, _f_SPEED(arg1), arg2 << FRACBITS, arg3 << FRACBITS, false);
} }
FUNC(LS_Polyobj_MoveToSpot) FUNC(LS_Polyobj_MoveToSpot)
@ -168,7 +169,7 @@ FUNC(LS_Polyobj_MoveToSpot)
FActorIterator iterator (arg2); FActorIterator iterator (arg2);
AActor *spot = iterator.Next(); AActor *spot = iterator.Next();
if (spot == NULL) return false; if (spot == NULL) return false;
return EV_MovePolyTo (ln, arg0, SPEED(arg1), spot->_f_X(), spot->_f_Y(), false); return EV_MovePolyTo (ln, arg0, _f_SPEED(arg1), spot->_f_X(), spot->_f_Y(), false);
} }
FUNC(LS_Polyobj_DoorSwing) FUNC(LS_Polyobj_DoorSwing)
@ -180,7 +181,7 @@ FUNC(LS_Polyobj_DoorSwing)
FUNC(LS_Polyobj_DoorSlide) FUNC(LS_Polyobj_DoorSlide)
// Polyobj_DoorSlide (po, speed, angle, distance, delay) // Polyobj_DoorSlide (po, speed, angle, distance, delay)
{ {
return EV_OpenPolyDoor (ln, arg0, SPEED(arg1), _f_BYTEANGLE(arg2), arg4, arg3*FRACUNIT, PODOOR_SLIDE); return EV_OpenPolyDoor (ln, arg0, _f_SPEED(arg1), _f_BYTEANGLE(arg2), arg4, arg3*FRACUNIT, PODOOR_SLIDE);
} }
FUNC(LS_Polyobj_OR_RotateLeft) FUNC(LS_Polyobj_OR_RotateLeft)
@ -198,19 +199,19 @@ FUNC(LS_Polyobj_OR_RotateRight)
FUNC(LS_Polyobj_OR_Move) FUNC(LS_Polyobj_OR_Move)
// Polyobj_OR_Move (po, speed, angle, distance) // Polyobj_OR_Move (po, speed, angle, distance)
{ {
return EV_MovePoly (ln, arg0, SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT, true); return EV_MovePoly (ln, arg0, _f_SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT, true);
} }
FUNC(LS_Polyobj_OR_MoveTimes8) FUNC(LS_Polyobj_OR_MoveTimes8)
// Polyobj_OR_MoveTimes8 (po, speed, angle, distance) // Polyobj_OR_MoveTimes8 (po, speed, angle, distance)
{ {
return EV_MovePoly (ln, arg0, SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT * 8, true); return EV_MovePoly (ln, arg0, _f_SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT * 8, true);
} }
FUNC(LS_Polyobj_OR_MoveTo) FUNC(LS_Polyobj_OR_MoveTo)
// Polyobj_OR_MoveTo (po, speed, x, y) // Polyobj_OR_MoveTo (po, speed, x, y)
{ {
return EV_MovePolyTo (ln, arg0, SPEED(arg1), arg2 << FRACBITS, arg3 << FRACBITS, true); return EV_MovePolyTo (ln, arg0, _f_SPEED(arg1), arg2 << FRACBITS, arg3 << FRACBITS, true);
} }
FUNC(LS_Polyobj_OR_MoveToSpot) FUNC(LS_Polyobj_OR_MoveToSpot)
@ -219,7 +220,7 @@ FUNC(LS_Polyobj_OR_MoveToSpot)
FActorIterator iterator (arg2); FActorIterator iterator (arg2);
AActor *spot = iterator.Next(); AActor *spot = iterator.Next();
if (spot == NULL) return false; if (spot == NULL) return false;
return EV_MovePolyTo (ln, arg0, SPEED(arg1), spot->_f_X(), spot->_f_Y(), true); return EV_MovePolyTo (ln, arg0, _f_SPEED(arg1), spot->_f_X(), spot->_f_Y(), true);
} }
FUNC(LS_Polyobj_Stop) FUNC(LS_Polyobj_Stop)
@ -231,44 +232,44 @@ FUNC(LS_Polyobj_Stop)
FUNC(LS_Door_Close) FUNC(LS_Door_Close)
// Door_Close (tag, speed, lighttag) // Door_Close (tag, speed, lighttag)
{ {
return EV_DoDoor (DDoor::doorClose, ln, it, arg0, SPEED(arg1), 0, 0, arg2); return EV_DoDoor (DDoor::doorClose, ln, it, arg0, _f_SPEED(arg1), 0, 0, arg2);
} }
FUNC(LS_Door_Open) FUNC(LS_Door_Open)
// Door_Open (tag, speed, lighttag) // Door_Open (tag, speed, lighttag)
{ {
return EV_DoDoor (DDoor::doorOpen, ln, it, arg0, SPEED(arg1), 0, 0, arg2); return EV_DoDoor (DDoor::doorOpen, ln, it, arg0, _f_SPEED(arg1), 0, 0, arg2);
} }
FUNC(LS_Door_Raise) FUNC(LS_Door_Raise)
// Door_Raise (tag, speed, delay, lighttag) // Door_Raise (tag, speed, delay, lighttag)
{ {
return EV_DoDoor (DDoor::doorRaise, ln, it, arg0, SPEED(arg1), TICS(arg2), 0, arg3); return EV_DoDoor (DDoor::doorRaise, ln, it, arg0, _f_SPEED(arg1), TICS(arg2), 0, arg3);
} }
FUNC(LS_Door_LockedRaise) FUNC(LS_Door_LockedRaise)
// Door_LockedRaise (tag, speed, delay, lock, lighttag) // Door_LockedRaise (tag, speed, delay, lock, lighttag)
{ {
return EV_DoDoor (arg2 ? DDoor::doorRaise : DDoor::doorOpen, ln, it, return EV_DoDoor (arg2 ? DDoor::doorRaise : DDoor::doorOpen, ln, it,
arg0, SPEED(arg1), TICS(arg2), arg3, arg4); arg0, _f_SPEED(arg1), TICS(arg2), arg3, arg4);
} }
FUNC(LS_Door_CloseWaitOpen) FUNC(LS_Door_CloseWaitOpen)
// Door_CloseWaitOpen (tag, speed, delay, lighttag) // Door_CloseWaitOpen (tag, speed, delay, lighttag)
{ {
return EV_DoDoor (DDoor::doorCloseWaitOpen, ln, it, arg0, SPEED(arg1), OCTICS(arg2), 0, arg3); return EV_DoDoor (DDoor::doorCloseWaitOpen, ln, it, arg0, _f_SPEED(arg1), OCTICS(arg2), 0, arg3);
} }
FUNC(LS_Door_WaitRaise) FUNC(LS_Door_WaitRaise)
// Door_WaitRaise(tag, speed, delay, wait, lighttag) // Door_WaitRaise(tag, speed, delay, wait, lighttag)
{ {
return EV_DoDoor(DDoor::doorWaitRaise, ln, it, arg0, SPEED(arg1), TICS(arg2), 0, arg4, false, TICS(arg3)); return EV_DoDoor(DDoor::doorWaitRaise, ln, it, arg0, _f_SPEED(arg1), TICS(arg2), 0, arg4, false, TICS(arg3));
} }
FUNC(LS_Door_WaitClose) FUNC(LS_Door_WaitClose)
// Door_WaitRaise(tag, speed, wait, lighttag) // Door_WaitRaise(tag, speed, wait, lighttag)
{ {
return EV_DoDoor(DDoor::doorWaitClose, ln, it, arg0, SPEED(arg1), 0, 0, arg3, false, TICS(arg2)); return EV_DoDoor(DDoor::doorWaitClose, ln, it, arg0, _f_SPEED(arg1), 0, 0, arg3, false, TICS(arg2));
} }
FUNC(LS_Door_Animated) FUNC(LS_Door_Animated)
@ -308,55 +309,55 @@ FUNC(LS_Generic_Door)
tag = arg0; tag = arg0;
lightTag = 0; lightTag = 0;
} }
return EV_DoDoor (type, ln, it, tag, SPEED(arg1), OCTICS(arg3), arg4, lightTag, boomgen); return EV_DoDoor (type, ln, it, tag, _f_SPEED(arg1), OCTICS(arg3), arg4, lightTag, boomgen);
} }
FUNC(LS_Floor_LowerByValue) FUNC(LS_Floor_LowerByValue)
// Floor_LowerByValue (tag, speed, height, change) // Floor_LowerByValue (tag, speed, height, change)
{ {
return EV_DoFloor (DFloor::floorLowerByValue, ln, arg0, SPEED(arg1), FRACUNIT*arg2, -1, CHANGE(arg3), false); return EV_DoFloor (DFloor::floorLowerByValue, ln, arg0, _f_SPEED(arg1), FRACUNIT*arg2, -1, CHANGE(arg3), false);
} }
FUNC(LS_Floor_LowerToLowest) FUNC(LS_Floor_LowerToLowest)
// Floor_LowerToLowest (tag, speed, change) // Floor_LowerToLowest (tag, speed, change)
{ {
return EV_DoFloor (DFloor::floorLowerToLowest, ln, arg0, SPEED(arg1), 0, -1, CHANGE(arg2), false); return EV_DoFloor (DFloor::floorLowerToLowest, ln, arg0, _f_SPEED(arg1), 0, -1, CHANGE(arg2), false);
} }
FUNC(LS_Floor_LowerToHighest) FUNC(LS_Floor_LowerToHighest)
// Floor_LowerToHighest (tag, speed, adjust, hereticlower) // Floor_LowerToHighest (tag, speed, adjust, hereticlower)
{ {
return EV_DoFloor (DFloor::floorLowerToHighest, ln, arg0, SPEED(arg1), (arg2-128)*FRACUNIT, -1, 0, false, arg3==1); return EV_DoFloor (DFloor::floorLowerToHighest, ln, arg0, _f_SPEED(arg1), (arg2-128)*FRACUNIT, -1, 0, false, arg3==1);
} }
FUNC(LS_Floor_LowerToHighestEE) FUNC(LS_Floor_LowerToHighestEE)
// Floor_LowerToHighest (tag, speed, change) // Floor_LowerToHighest (tag, speed, change)
{ {
return EV_DoFloor (DFloor::floorLowerToHighest, ln, arg0, SPEED(arg1), 0, -1, CHANGE(arg2), false); return EV_DoFloor (DFloor::floorLowerToHighest, ln, arg0, _f_SPEED(arg1), 0, -1, CHANGE(arg2), false);
} }
FUNC(LS_Floor_LowerToNearest) FUNC(LS_Floor_LowerToNearest)
// Floor_LowerToNearest (tag, speed, change) // Floor_LowerToNearest (tag, speed, change)
{ {
return EV_DoFloor (DFloor::floorLowerToNearest, ln, arg0, SPEED(arg1), 0, -1, CHANGE(arg2), false); return EV_DoFloor (DFloor::floorLowerToNearest, ln, arg0, _f_SPEED(arg1), 0, -1, CHANGE(arg2), false);
} }
FUNC(LS_Floor_RaiseByValue) FUNC(LS_Floor_RaiseByValue)
// Floor_RaiseByValue (tag, speed, height, change, crush) // Floor_RaiseByValue (tag, speed, height, change, crush)
{ {
return EV_DoFloor (DFloor::floorRaiseByValue, ln, arg0, SPEED(arg1), FRACUNIT*arg2, CRUSH(arg4), CHANGE(arg3), true); return EV_DoFloor (DFloor::floorRaiseByValue, ln, arg0, _f_SPEED(arg1), FRACUNIT*arg2, CRUSH(arg4), CHANGE(arg3), true);
} }
FUNC(LS_Floor_RaiseToHighest) FUNC(LS_Floor_RaiseToHighest)
// Floor_RaiseToHighest (tag, speed, change, crush) // Floor_RaiseToHighest (tag, speed, change, crush)
{ {
return EV_DoFloor (DFloor::floorRaiseToHighest, ln, arg0, SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); return EV_DoFloor (DFloor::floorRaiseToHighest, ln, arg0, _f_SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true);
} }
FUNC(LS_Floor_RaiseToNearest) FUNC(LS_Floor_RaiseToNearest)
// Floor_RaiseToNearest (tag, speed, change, crush) // Floor_RaiseToNearest (tag, speed, change, crush)
{ {
return EV_DoFloor (DFloor::floorRaiseToNearest, ln, arg0, SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); return EV_DoFloor (DFloor::floorRaiseToNearest, ln, arg0, _f_SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true);
} }
FUNC(LS_Floor_RaiseToLowest) FUNC(LS_Floor_RaiseToLowest)
@ -369,25 +370,25 @@ FUNC(LS_Floor_RaiseToLowest)
FUNC(LS_Floor_RaiseAndCrush) FUNC(LS_Floor_RaiseAndCrush)
// Floor_RaiseAndCrush (tag, speed, crush, crushmode) // Floor_RaiseAndCrush (tag, speed, crush, crushmode)
{ {
return EV_DoFloor (DFloor::floorRaiseAndCrush, ln, arg0, SPEED(arg1), 0, arg2, 0, CRUSHTYPE(arg3)); return EV_DoFloor (DFloor::floorRaiseAndCrush, ln, arg0, _f_SPEED(arg1), 0, arg2, 0, CRUSHTYPE(arg3));
} }
FUNC(LS_Floor_RaiseAndCrushDoom) FUNC(LS_Floor_RaiseAndCrushDoom)
// Floor_RaiseAndCrushDoom (tag, speed, crush, crushmode) // Floor_RaiseAndCrushDoom (tag, speed, crush, crushmode)
{ {
return EV_DoFloor (DFloor::floorRaiseAndCrushDoom, ln, arg0, SPEED(arg1), 0, arg2, 0, CRUSHTYPE(arg3)); return EV_DoFloor (DFloor::floorRaiseAndCrushDoom, ln, arg0, _f_SPEED(arg1), 0, arg2, 0, CRUSHTYPE(arg3));
} }
FUNC(LS_Floor_RaiseByValueTimes8) FUNC(LS_Floor_RaiseByValueTimes8)
// FLoor_RaiseByValueTimes8 (tag, speed, height, change, crush) // FLoor_RaiseByValueTimes8 (tag, speed, height, change, crush)
{ {
return EV_DoFloor (DFloor::floorRaiseByValue, ln, arg0, SPEED(arg1), FRACUNIT*arg2*8, CRUSH(arg4), CHANGE(arg3), true); return EV_DoFloor (DFloor::floorRaiseByValue, ln, arg0, _f_SPEED(arg1), FRACUNIT*arg2*8, CRUSH(arg4), CHANGE(arg3), true);
} }
FUNC(LS_Floor_LowerByValueTimes8) FUNC(LS_Floor_LowerByValueTimes8)
// Floor_LowerByValueTimes8 (tag, speed, height, change) // Floor_LowerByValueTimes8 (tag, speed, height, change)
{ {
return EV_DoFloor (DFloor::floorLowerByValue, ln, arg0, SPEED(arg1), FRACUNIT*arg2*8, -1, CHANGE(arg3), false); return EV_DoFloor (DFloor::floorLowerByValue, ln, arg0, _f_SPEED(arg1), FRACUNIT*arg2*8, -1, CHANGE(arg3), false);
} }
FUNC(LS_Floor_CrushStop) FUNC(LS_Floor_CrushStop)
@ -417,57 +418,57 @@ FUNC(LS_Floor_ToCeilingInstant)
FUNC(LS_Floor_MoveToValueTimes8) FUNC(LS_Floor_MoveToValueTimes8)
// Floor_MoveToValueTimes8 (tag, speed, height, negative, change) // Floor_MoveToValueTimes8 (tag, speed, height, negative, change)
{ {
return EV_DoFloor (DFloor::floorMoveToValue, ln, arg0, SPEED(arg1), return EV_DoFloor (DFloor::floorMoveToValue, ln, arg0, _f_SPEED(arg1),
arg2*FRACUNIT*8*(arg3?-1:1), -1, CHANGE(arg4), false); arg2*FRACUNIT*8*(arg3?-1:1), -1, CHANGE(arg4), false);
} }
FUNC(LS_Floor_MoveToValue) FUNC(LS_Floor_MoveToValue)
// Floor_MoveToValue (tag, speed, height, negative, change) // Floor_MoveToValue (tag, speed, height, negative, change)
{ {
return EV_DoFloor (DFloor::floorMoveToValue, ln, arg0, SPEED(arg1), return EV_DoFloor (DFloor::floorMoveToValue, ln, arg0, _f_SPEED(arg1),
arg2*FRACUNIT*(arg3?-1:1), -1, CHANGE(arg4), false); arg2*FRACUNIT*(arg3?-1:1), -1, CHANGE(arg4), false);
} }
FUNC(LS_Floor_RaiseToLowestCeiling) FUNC(LS_Floor_RaiseToLowestCeiling)
// Floor_RaiseToLowestCeiling (tag, speed, change, crush) // Floor_RaiseToLowestCeiling (tag, speed, change, crush)
{ {
return EV_DoFloor (DFloor::floorRaiseToLowestCeiling, ln, arg0, SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); return EV_DoFloor (DFloor::floorRaiseToLowestCeiling, ln, arg0, _f_SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true);
} }
FUNC(LS_Floor_LowerToLowestCeiling) FUNC(LS_Floor_LowerToLowestCeiling)
// Floor_LowerToLowestCeiling (tag, speed, change) // Floor_LowerToLowestCeiling (tag, speed, change)
{ {
return EV_DoFloor (DFloor::floorLowerToLowestCeiling, ln, arg0, SPEED(arg1), 0, -1, CHANGE(arg2), true); return EV_DoFloor (DFloor::floorLowerToLowestCeiling, ln, arg0, _f_SPEED(arg1), 0, -1, CHANGE(arg2), true);
} }
FUNC(LS_Floor_RaiseByTexture) FUNC(LS_Floor_RaiseByTexture)
// Floor_RaiseByTexture (tag, speed, change, crush) // Floor_RaiseByTexture (tag, speed, change, crush)
{ {
return EV_DoFloor (DFloor::floorRaiseByTexture, ln, arg0, SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); return EV_DoFloor (DFloor::floorRaiseByTexture, ln, arg0, _f_SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true);
} }
FUNC(LS_Floor_LowerByTexture) FUNC(LS_Floor_LowerByTexture)
// Floor_LowerByTexture (tag, speed, change, crush) // Floor_LowerByTexture (tag, speed, change, crush)
{ {
return EV_DoFloor (DFloor::floorLowerByTexture, ln, arg0, SPEED(arg1), 0, -1, CHANGE(arg2), true); return EV_DoFloor (DFloor::floorLowerByTexture, ln, arg0, _f_SPEED(arg1), 0, -1, CHANGE(arg2), true);
} }
FUNC(LS_Floor_RaiseToCeiling) FUNC(LS_Floor_RaiseToCeiling)
// Floor_RaiseToCeiling (tag, speed, change, crush) // Floor_RaiseToCeiling (tag, speed, change, crush)
{ {
return EV_DoFloor (DFloor::floorRaiseToCeiling, ln, arg0, SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); return EV_DoFloor (DFloor::floorRaiseToCeiling, ln, arg0, _f_SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true);
} }
FUNC(LS_Floor_RaiseByValueTxTy) FUNC(LS_Floor_RaiseByValueTxTy)
// Floor_RaiseByValueTxTy (tag, speed, height) // Floor_RaiseByValueTxTy (tag, speed, height)
{ {
return EV_DoFloor (DFloor::floorRaiseAndChange, ln, arg0, SPEED(arg1), arg2*FRACUNIT, -1, 0, false); return EV_DoFloor (DFloor::floorRaiseAndChange, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, -1, 0, false);
} }
FUNC(LS_Floor_LowerToLowestTxTy) FUNC(LS_Floor_LowerToLowestTxTy)
// Floor_LowerToLowestTxTy (tag, speed) // Floor_LowerToLowestTxTy (tag, speed)
{ {
return EV_DoFloor (DFloor::floorLowerAndChange, ln, arg0, SPEED(arg1), arg2*FRACUNIT, -1, 0, false); return EV_DoFloor (DFloor::floorLowerAndChange, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, -1, 0, false);
} }
FUNC(LS_Floor_Waggle) FUNC(LS_Floor_Waggle)
@ -497,7 +498,7 @@ FUNC(LS_Floor_TransferNumeric)
FUNC(LS_Floor_Donut) FUNC(LS_Floor_Donut)
// Floor_Donut (pillartag, pillarspeed, slimespeed) // Floor_Donut (pillartag, pillarspeed, slimespeed)
{ {
return EV_DoDonut (arg0, ln, SPEED(arg1), SPEED(arg2)); return EV_DoDonut (arg0, ln, _f_SPEED(arg1), _f_SPEED(arg2));
} }
FUNC(LS_Generic_Floor) FUNC(LS_Generic_Floor)
@ -532,7 +533,7 @@ FUNC(LS_Generic_Floor)
} }
} }
return EV_DoFloor (type, ln, arg0, SPEED(arg1), arg2*FRACUNIT, return EV_DoFloor (type, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT,
(arg4 & 16) ? 20 : -1, arg4 & 7, false); (arg4 & 16) ? 20 : -1, arg4 & 7, false);
} }
@ -541,56 +542,56 @@ FUNC(LS_Stairs_BuildDown)
// Stair_BuildDown (tag, speed, height, delay, reset) // Stair_BuildDown (tag, speed, height, delay, reset)
{ {
return EV_BuildStairs (arg0, DFloor::buildDown, ln, return EV_BuildStairs (arg0, DFloor::buildDown, ln,
arg2 * FRACUNIT, SPEED(arg1), TICS(arg3), arg4, 0, DFloor::stairUseSpecials); arg2 * FRACUNIT, _f_SPEED(arg1), TICS(arg3), arg4, 0, DFloor::stairUseSpecials);
} }
FUNC(LS_Stairs_BuildUp) FUNC(LS_Stairs_BuildUp)
// Stairs_BuildUp (tag, speed, height, delay, reset) // Stairs_BuildUp (tag, speed, height, delay, reset)
{ {
return EV_BuildStairs (arg0, DFloor::buildUp, ln, return EV_BuildStairs (arg0, DFloor::buildUp, ln,
arg2 * FRACUNIT, SPEED(arg1), TICS(arg3), arg4, 0, DFloor::stairUseSpecials); arg2 * FRACUNIT, _f_SPEED(arg1), TICS(arg3), arg4, 0, DFloor::stairUseSpecials);
} }
FUNC(LS_Stairs_BuildDownSync) FUNC(LS_Stairs_BuildDownSync)
// Stairs_BuildDownSync (tag, speed, height, reset) // Stairs_BuildDownSync (tag, speed, height, reset)
{ {
return EV_BuildStairs (arg0, DFloor::buildDown, ln, return EV_BuildStairs (arg0, DFloor::buildDown, ln,
arg2 * FRACUNIT, SPEED(arg1), 0, arg3, 0, DFloor::stairUseSpecials|DFloor::stairSync); arg2 * FRACUNIT, _f_SPEED(arg1), 0, arg3, 0, DFloor::stairUseSpecials|DFloor::stairSync);
} }
FUNC(LS_Stairs_BuildUpSync) FUNC(LS_Stairs_BuildUpSync)
// Stairs_BuildUpSync (tag, speed, height, reset) // Stairs_BuildUpSync (tag, speed, height, reset)
{ {
return EV_BuildStairs (arg0, DFloor::buildUp, ln, return EV_BuildStairs (arg0, DFloor::buildUp, ln,
arg2 * FRACUNIT, SPEED(arg1), 0, arg3, 0, DFloor::stairUseSpecials|DFloor::stairSync); arg2 * FRACUNIT, _f_SPEED(arg1), 0, arg3, 0, DFloor::stairUseSpecials|DFloor::stairSync);
} }
FUNC(LS_Stairs_BuildUpDoom) FUNC(LS_Stairs_BuildUpDoom)
// Stairs_BuildUpDoom (tag, speed, height, delay, reset) // Stairs_BuildUpDoom (tag, speed, height, delay, reset)
{ {
return EV_BuildStairs (arg0, DFloor::buildUp, ln, return EV_BuildStairs (arg0, DFloor::buildUp, ln,
arg2 * FRACUNIT, SPEED(arg1), TICS(arg3), arg4, 0, 0); arg2 * FRACUNIT, _f_SPEED(arg1), TICS(arg3), arg4, 0, 0);
} }
FUNC(LS_Stairs_BuildDownDoom) FUNC(LS_Stairs_BuildDownDoom)
// Stair_BuildDownDoom (tag, speed, height, delay, reset) // Stair_BuildDownDoom (tag, speed, height, delay, reset)
{ {
return EV_BuildStairs (arg0, DFloor::buildDown, ln, return EV_BuildStairs (arg0, DFloor::buildDown, ln,
arg2 * FRACUNIT, SPEED(arg1), TICS(arg3), arg4, 0, 0); arg2 * FRACUNIT, _f_SPEED(arg1), TICS(arg3), arg4, 0, 0);
} }
FUNC(LS_Stairs_BuildDownDoomSync) FUNC(LS_Stairs_BuildDownDoomSync)
// Stairs_BuildDownDoomSync (tag, speed, height, reset) // Stairs_BuildDownDoomSync (tag, speed, height, reset)
{ {
return EV_BuildStairs (arg0, DFloor::buildDown, ln, return EV_BuildStairs (arg0, DFloor::buildDown, ln,
arg2 * FRACUNIT, SPEED(arg1), 0, arg3, 0, DFloor::stairSync); arg2 * FRACUNIT, _f_SPEED(arg1), 0, arg3, 0, DFloor::stairSync);
} }
FUNC(LS_Stairs_BuildUpDoomSync) FUNC(LS_Stairs_BuildUpDoomSync)
// Stairs_BuildUpDoomSync (tag, speed, height, reset) // Stairs_BuildUpDoomSync (tag, speed, height, reset)
{ {
return EV_BuildStairs (arg0, DFloor::buildUp, ln, return EV_BuildStairs (arg0, DFloor::buildUp, ln,
arg2 * FRACUNIT, SPEED(arg1), 0, arg3, 0, DFloor::stairSync); arg2 * FRACUNIT, _f_SPEED(arg1), 0, arg3, 0, DFloor::stairSync);
} }
@ -599,7 +600,7 @@ FUNC(LS_Generic_Stairs)
{ {
DFloor::EStair type = (arg3 & 1) ? DFloor::buildUp : DFloor::buildDown; DFloor::EStair type = (arg3 & 1) ? DFloor::buildUp : DFloor::buildDown;
bool res = EV_BuildStairs (arg0, type, ln, bool res = EV_BuildStairs (arg0, type, ln,
arg2 * FRACUNIT, SPEED(arg1), 0, arg4, arg3 & 2, 0); arg2 * FRACUNIT, _f_SPEED(arg1), 0, arg4, arg3 & 2, 0);
if (res && ln && (ln->flags & ML_REPEAT_SPECIAL) && ln->special == Generic_Stairs) if (res && ln && (ln->flags & ML_REPEAT_SPECIAL) && ln->special == Generic_Stairs)
// Toggle direction of next activation of repeatable stairs // Toggle direction of next activation of repeatable stairs
@ -611,61 +612,61 @@ FUNC(LS_Generic_Stairs)
FUNC(LS_Pillar_Build) FUNC(LS_Pillar_Build)
// Pillar_Build (tag, speed, height) // Pillar_Build (tag, speed, height)
{ {
return EV_DoPillar (DPillar::pillarBuild, ln, arg0, SPEED(arg1), arg2*FRACUNIT, 0, -1, false); return EV_DoPillar (DPillar::pillarBuild, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, 0, -1, false);
} }
FUNC(LS_Pillar_BuildAndCrush) FUNC(LS_Pillar_BuildAndCrush)
// Pillar_BuildAndCrush (tag, speed, height, crush, crushtype) // Pillar_BuildAndCrush (tag, speed, height, crush, crushtype)
{ {
return EV_DoPillar (DPillar::pillarBuild, ln, arg0, SPEED(arg1), arg2*FRACUNIT, 0, arg3, CRUSHTYPE(arg4)); return EV_DoPillar (DPillar::pillarBuild, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, 0, arg3, CRUSHTYPE(arg4));
} }
FUNC(LS_Pillar_Open) FUNC(LS_Pillar_Open)
// Pillar_Open (tag, speed, f_height, c_height) // Pillar_Open (tag, speed, f_height, c_height)
{ {
return EV_DoPillar (DPillar::pillarOpen, ln, arg0, SPEED(arg1), arg2*FRACUNIT, arg3*FRACUNIT, -1, false); return EV_DoPillar (DPillar::pillarOpen, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, arg3*FRACUNIT, -1, false);
} }
FUNC(LS_Ceiling_LowerByValue) FUNC(LS_Ceiling_LowerByValue)
// Ceiling_LowerByValue (tag, speed, height, change, crush) // Ceiling_LowerByValue (tag, speed, height, change, crush)
{ {
return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3), false); return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, _f_SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3), false);
} }
FUNC(LS_Ceiling_RaiseByValue) FUNC(LS_Ceiling_RaiseByValue)
// Ceiling_RaiseByValue (tag, speed, height, change) // Ceiling_RaiseByValue (tag, speed, height, change)
{ {
return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3), false); return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, _f_SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3), false);
} }
FUNC(LS_Ceiling_LowerByValueTimes8) FUNC(LS_Ceiling_LowerByValueTimes8)
// Ceiling_LowerByValueTimes8 (tag, speed, height, change, crush) // Ceiling_LowerByValueTimes8 (tag, speed, height, change, crush)
{ {
return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3), false); return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, _f_SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3), false);
} }
FUNC(LS_Ceiling_RaiseByValueTimes8) FUNC(LS_Ceiling_RaiseByValueTimes8)
// Ceiling_RaiseByValueTimes8 (tag, speed, height, change) // Ceiling_RaiseByValueTimes8 (tag, speed, height, change)
{ {
return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3), false); return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, _f_SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3), false);
} }
FUNC(LS_Ceiling_CrushAndRaise) FUNC(LS_Ceiling_CrushAndRaise)
// Ceiling_CrushAndRaise (tag, speed, crush, crushtype) // Ceiling_CrushAndRaise (tag, speed, crush, crushtype)
{ {
return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3));
} }
FUNC(LS_Ceiling_LowerAndCrush) FUNC(LS_Ceiling_LowerAndCrush)
// Ceiling_LowerAndCrush (tag, speed, crush, crushtype) // Ceiling_LowerAndCrush (tag, speed, crush, crushtype)
{ {
return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, SPEED(arg1), SPEED(arg1), 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg1), 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3));
} }
FUNC(LS_Ceiling_LowerAndCrushDist) FUNC(LS_Ceiling_LowerAndCrushDist)
// Ceiling_LowerAndCrush (tag, speed, crush, dist, crushtype) // Ceiling_LowerAndCrush (tag, speed, crush, dist, crushtype)
{ {
return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, SPEED(arg1), SPEED(arg1), arg3*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg4)); return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg1), arg3*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg4));
} }
FUNC(LS_Ceiling_CrushStop) FUNC(LS_Ceiling_CrushStop)
@ -677,27 +678,27 @@ FUNC(LS_Ceiling_CrushStop)
FUNC(LS_Ceiling_CrushRaiseAndStay) FUNC(LS_Ceiling_CrushRaiseAndStay)
// Ceiling_CrushRaiseAndStay (tag, speed, crush, crushtype) // Ceiling_CrushRaiseAndStay (tag, speed, crush, crushtype)
{ {
return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3));
} }
FUNC(LS_Ceiling_MoveToValueTimes8) FUNC(LS_Ceiling_MoveToValueTimes8)
// Ceiling_MoveToValueTimes8 (tag, speed, height, negative, change) // Ceiling_MoveToValueTimes8 (tag, speed, height, negative, change)
{ {
return EV_DoCeiling (DCeiling::ceilMoveToValue, ln, arg0, SPEED(arg1), 0, return EV_DoCeiling (DCeiling::ceilMoveToValue, ln, arg0, _f_SPEED(arg1), 0,
arg2*FRACUNIT*8*((arg3) ? -1 : 1), -1, 0, CHANGE(arg4), false); arg2*FRACUNIT*8*((arg3) ? -1 : 1), -1, 0, CHANGE(arg4), false);
} }
FUNC(LS_Ceiling_MoveToValue) FUNC(LS_Ceiling_MoveToValue)
// Ceiling_MoveToValue (tag, speed, height, negative, change) // Ceiling_MoveToValue (tag, speed, height, negative, change)
{ {
return EV_DoCeiling (DCeiling::ceilMoveToValue, ln, arg0, SPEED(arg1), 0, return EV_DoCeiling (DCeiling::ceilMoveToValue, ln, arg0, _f_SPEED(arg1), 0,
arg2*FRACUNIT*((arg3) ? -1 : 1), -1, 0, CHANGE(arg4), false); arg2*FRACUNIT*((arg3) ? -1 : 1), -1, 0, CHANGE(arg4), false);
} }
FUNC(LS_Ceiling_LowerToHighestFloor) FUNC(LS_Ceiling_LowerToHighestFloor)
// Ceiling_LowerToHighestFloor (tag, speed, change, crush) // Ceiling_LowerToHighestFloor (tag, speed, change, crush)
{ {
return EV_DoCeiling (DCeiling::ceilLowerToHighestFloor, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); return EV_DoCeiling (DCeiling::ceilLowerToHighestFloor, ln, arg0, _f_SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false);
} }
FUNC(LS_Ceiling_LowerInstant) FUNC(LS_Ceiling_LowerInstant)
@ -715,79 +716,79 @@ FUNC(LS_Ceiling_RaiseInstant)
FUNC(LS_Ceiling_CrushRaiseAndStayA) FUNC(LS_Ceiling_CrushRaiseAndStayA)
// Ceiling_CrushRaiseAndStayA (tag, dnspeed, upspeed, damage, crushtype) // Ceiling_CrushRaiseAndStayA (tag, dnspeed, upspeed, damage, crushtype)
{ {
return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 0, 0, CRUSHTYPE(arg4)); return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg2), 0, arg3, 0, 0, CRUSHTYPE(arg4));
} }
FUNC(LS_Ceiling_CrushRaiseAndStaySilA) FUNC(LS_Ceiling_CrushRaiseAndStaySilA)
// Ceiling_CrushRaiseAndStaySilA (tag, dnspeed, upspeed, damage, crushtype) // Ceiling_CrushRaiseAndStaySilA (tag, dnspeed, upspeed, damage, crushtype)
{ {
return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4)); return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4));
} }
FUNC(LS_Ceiling_CrushAndRaiseA) FUNC(LS_Ceiling_CrushAndRaiseA)
// Ceiling_CrushAndRaiseA (tag, dnspeed, upspeed, damage, crushtype) // Ceiling_CrushAndRaiseA (tag, dnspeed, upspeed, damage, crushtype)
{ {
return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 0, 0, CRUSHTYPE(arg4)); return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg2), 0, arg3, 0, 0, CRUSHTYPE(arg4));
} }
FUNC(LS_Ceiling_CrushAndRaiseDist) FUNC(LS_Ceiling_CrushAndRaiseDist)
// Ceiling_CrushAndRaiseDist (tag, dist, speed, damage, crushtype) // Ceiling_CrushAndRaiseDist (tag, dist, speed, damage, crushtype)
{ {
return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg2), SPEED(arg2), arg1*FRACUNIT, arg3, 0, 0, CRUSHTYPE(arg4)); return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg2), _f_SPEED(arg2), arg1*FRACUNIT, arg3, 0, 0, CRUSHTYPE(arg4));
} }
FUNC(LS_Ceiling_CrushAndRaiseSilentA) FUNC(LS_Ceiling_CrushAndRaiseSilentA)
// Ceiling_CrushAndRaiseSilentA (tag, dnspeed, upspeed, damage, crushtype) // Ceiling_CrushAndRaiseSilentA (tag, dnspeed, upspeed, damage, crushtype)
{ {
return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4)); return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4));
} }
FUNC(LS_Ceiling_CrushAndRaiseSilentDist) FUNC(LS_Ceiling_CrushAndRaiseSilentDist)
// Ceiling_CrushAndRaiseSilentDist (tag, dist, upspeed, damage, crushtype) // Ceiling_CrushAndRaiseSilentDist (tag, dist, upspeed, damage, crushtype)
{ {
return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg2), SPEED(arg2), arg1*FRACUNIT, arg3, 1, 0, CRUSHTYPE(arg4)); return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg2), _f_SPEED(arg2), arg1*FRACUNIT, arg3, 1, 0, CRUSHTYPE(arg4));
} }
FUNC(LS_Ceiling_RaiseToNearest) FUNC(LS_Ceiling_RaiseToNearest)
// Ceiling_RaiseToNearest (tag, speed, change) // Ceiling_RaiseToNearest (tag, speed, change)
{ {
return EV_DoCeiling (DCeiling::ceilRaiseToNearest, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); return EV_DoCeiling (DCeiling::ceilRaiseToNearest, ln, arg0, _f_SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false);
} }
FUNC(LS_Ceiling_RaiseToHighest) FUNC(LS_Ceiling_RaiseToHighest)
// Ceiling_RaiseToHighest (tag, speed, change) // Ceiling_RaiseToHighest (tag, speed, change)
{ {
return EV_DoCeiling (DCeiling::ceilRaiseToHighest, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); return EV_DoCeiling (DCeiling::ceilRaiseToHighest, ln, arg0, _f_SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false);
} }
FUNC(LS_Ceiling_RaiseToLowest) FUNC(LS_Ceiling_RaiseToLowest)
// Ceiling_RaiseToLowest (tag, speed, change) // Ceiling_RaiseToLowest (tag, speed, change)
{ {
return EV_DoCeiling (DCeiling::ceilRaiseToLowest, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); return EV_DoCeiling (DCeiling::ceilRaiseToLowest, ln, arg0, _f_SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false);
} }
FUNC(LS_Ceiling_RaiseToHighestFloor) FUNC(LS_Ceiling_RaiseToHighestFloor)
// Ceiling_RaiseToHighestFloor (tag, speed, change) // Ceiling_RaiseToHighestFloor (tag, speed, change)
{ {
return EV_DoCeiling (DCeiling::ceilRaiseToHighestFloor, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); return EV_DoCeiling (DCeiling::ceilRaiseToHighestFloor, ln, arg0, _f_SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false);
} }
FUNC(LS_Ceiling_RaiseByTexture) FUNC(LS_Ceiling_RaiseByTexture)
// Ceiling_RaiseByTexture (tag, speed, change) // Ceiling_RaiseByTexture (tag, speed, change)
{ {
return EV_DoCeiling (DCeiling::ceilRaiseByTexture, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); return EV_DoCeiling (DCeiling::ceilRaiseByTexture, ln, arg0, _f_SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false);
} }
FUNC(LS_Ceiling_LowerToLowest) FUNC(LS_Ceiling_LowerToLowest)
// Ceiling_LowerToLowest (tag, speed, change, crush) // Ceiling_LowerToLowest (tag, speed, change, crush)
{ {
return EV_DoCeiling (DCeiling::ceilLowerToLowest, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); return EV_DoCeiling (DCeiling::ceilLowerToLowest, ln, arg0, _f_SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false);
} }
FUNC(LS_Ceiling_LowerToNearest) FUNC(LS_Ceiling_LowerToNearest)
// Ceiling_LowerToNearest (tag, speed, change, crush) // Ceiling_LowerToNearest (tag, speed, change, crush)
{ {
return EV_DoCeiling (DCeiling::ceilLowerToNearest, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); return EV_DoCeiling (DCeiling::ceilLowerToNearest, ln, arg0, _f_SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false);
} }
FUNC(LS_Ceiling_ToHighestInstant) FUNC(LS_Ceiling_ToHighestInstant)
@ -805,13 +806,13 @@ FUNC(LS_Ceiling_ToFloorInstant)
FUNC(LS_Ceiling_LowerToFloor) FUNC(LS_Ceiling_LowerToFloor)
// Ceiling_LowerToFloor (tag, speed, change, crush) // Ceiling_LowerToFloor (tag, speed, change, crush)
{ {
return EV_DoCeiling (DCeiling::ceilLowerToFloor, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg4), false); return EV_DoCeiling (DCeiling::ceilLowerToFloor, ln, arg0, _f_SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg4), false);
} }
FUNC(LS_Ceiling_LowerByTexture) FUNC(LS_Ceiling_LowerByTexture)
// Ceiling_LowerByTexture (tag, speed, change, crush) // Ceiling_LowerByTexture (tag, speed, change, crush)
{ {
return EV_DoCeiling (DCeiling::ceilLowerByTexture, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg4), false); return EV_DoCeiling (DCeiling::ceilLowerByTexture, ln, arg0, _f_SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg4), false);
} }
FUNC(LS_Generic_Ceiling) FUNC(LS_Generic_Ceiling)
@ -841,35 +842,35 @@ FUNC(LS_Generic_Ceiling)
} }
} }
return EV_DoCeiling (type, ln, arg0, SPEED(arg1), SPEED(arg1), arg2*FRACUNIT, return EV_DoCeiling (type, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg1), arg2*FRACUNIT,
(arg4 & 16) ? 20 : -1, 0, arg4 & 7, false); (arg4 & 16) ? 20 : -1, 0, arg4 & 7, false);
} }
FUNC(LS_Generic_Crusher) FUNC(LS_Generic_Crusher)
// Generic_Crusher (tag, dnspeed, upspeed, silent, damage) // Generic_Crusher (tag, dnspeed, upspeed, silent, damage)
{ {
return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg1),
SPEED(arg2), 0, arg4, arg3 ? 2 : 0, 0, false); _f_SPEED(arg2), 0, arg4, arg3 ? 2 : 0, 0, false);
} }
FUNC(LS_Generic_Crusher2) FUNC(LS_Generic_Crusher2)
// Generic_Crusher2 (tag, dnspeed, upspeed, silent, damage) // Generic_Crusher2 (tag, dnspeed, upspeed, silent, damage)
{ {
// same as above but uses Hexen's crushing method. // same as above but uses Hexen's crushing method.
return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg1),
SPEED(arg2), 0, arg4, arg3 ? 2 : 0, 0, true); _f_SPEED(arg2), 0, arg4, arg3 ? 2 : 0, 0, true);
} }
FUNC(LS_Plat_PerpetualRaise) FUNC(LS_Plat_PerpetualRaise)
// Plat_PerpetualRaise (tag, speed, delay) // Plat_PerpetualRaise (tag, speed, delay)
{ {
return EV_DoPlat (arg0, ln, DPlat::platPerpetualRaise, 0, SPEED(arg1), TICS(arg2), 8, 0); return EV_DoPlat (arg0, ln, DPlat::platPerpetualRaise, 0, _f_SPEED(arg1), TICS(arg2), 8, 0);
} }
FUNC(LS_Plat_PerpetualRaiseLip) FUNC(LS_Plat_PerpetualRaiseLip)
// Plat_PerpetualRaiseLip (tag, speed, delay, lip) // Plat_PerpetualRaiseLip (tag, speed, delay, lip)
{ {
return EV_DoPlat (arg0, ln, DPlat::platPerpetualRaise, 0, SPEED(arg1), TICS(arg2), arg3, 0); return EV_DoPlat (arg0, ln, DPlat::platPerpetualRaise, 0, _f_SPEED(arg1), TICS(arg2), arg3, 0);
} }
FUNC(LS_Plat_Stop) FUNC(LS_Plat_Stop)
@ -882,7 +883,7 @@ FUNC(LS_Plat_Stop)
FUNC(LS_Plat_DownWaitUpStay) FUNC(LS_Plat_DownWaitUpStay)
// Plat_DownWaitUpStay (tag, speed, delay) // Plat_DownWaitUpStay (tag, speed, delay)
{ {
return EV_DoPlat (arg0, ln, DPlat::platDownWaitUpStay, 0, SPEED(arg1), TICS(arg2), 8, 0); return EV_DoPlat (arg0, ln, DPlat::platDownWaitUpStay, 0, _f_SPEED(arg1), TICS(arg2), 8, 0);
} }
FUNC(LS_Plat_DownWaitUpStayLip) FUNC(LS_Plat_DownWaitUpStayLip)
@ -890,31 +891,31 @@ FUNC(LS_Plat_DownWaitUpStayLip)
{ {
return EV_DoPlat (arg0, ln, return EV_DoPlat (arg0, ln,
arg4 ? DPlat::platDownWaitUpStayStone : DPlat::platDownWaitUpStay, arg4 ? DPlat::platDownWaitUpStayStone : DPlat::platDownWaitUpStay,
0, SPEED(arg1), TICS(arg2), arg3, 0); 0, _f_SPEED(arg1), TICS(arg2), arg3, 0);
} }
FUNC(LS_Plat_DownByValue) FUNC(LS_Plat_DownByValue)
// Plat_DownByValue (tag, speed, delay, height) // Plat_DownByValue (tag, speed, delay, height)
{ {
return EV_DoPlat (arg0, ln, DPlat::platDownByValue, FRACUNIT*arg3*8, SPEED(arg1), TICS(arg2), 0, 0); return EV_DoPlat (arg0, ln, DPlat::platDownByValue, FRACUNIT*arg3*8, _f_SPEED(arg1), TICS(arg2), 0, 0);
} }
FUNC(LS_Plat_UpByValue) FUNC(LS_Plat_UpByValue)
// Plat_UpByValue (tag, speed, delay, height) // Plat_UpByValue (tag, speed, delay, height)
{ {
return EV_DoPlat (arg0, ln, DPlat::platUpByValue, FRACUNIT*arg3*8, SPEED(arg1), TICS(arg2), 0, 0); return EV_DoPlat (arg0, ln, DPlat::platUpByValue, FRACUNIT*arg3*8, _f_SPEED(arg1), TICS(arg2), 0, 0);
} }
FUNC(LS_Plat_UpWaitDownStay) FUNC(LS_Plat_UpWaitDownStay)
// Plat_UpWaitDownStay (tag, speed, delay) // Plat_UpWaitDownStay (tag, speed, delay)
{ {
return EV_DoPlat (arg0, ln, DPlat::platUpWaitDownStay, 0, SPEED(arg1), TICS(arg2), 0, 0); return EV_DoPlat (arg0, ln, DPlat::platUpWaitDownStay, 0, _f_SPEED(arg1), TICS(arg2), 0, 0);
} }
FUNC(LS_Plat_UpNearestWaitDownStay) FUNC(LS_Plat_UpNearestWaitDownStay)
// Plat_UpNearestWaitDownStay (tag, speed, delay) // Plat_UpNearestWaitDownStay (tag, speed, delay)
{ {
return EV_DoPlat (arg0, ln, DPlat::platUpNearestWaitDownStay, 0, SPEED(arg1), TICS(arg2), 0, 0); return EV_DoPlat (arg0, ln, DPlat::platUpNearestWaitDownStay, 0, _f_SPEED(arg1), TICS(arg2), 0, 0);
} }
FUNC(LS_Plat_RaiseAndStayTx0) FUNC(LS_Plat_RaiseAndStayTx0)
@ -936,13 +937,13 @@ FUNC(LS_Plat_RaiseAndStayTx0)
} }
return EV_DoPlat (arg0, ln, type, 0, SPEED(arg1), 0, 0, 1); return EV_DoPlat (arg0, ln, type, 0, _f_SPEED(arg1), 0, 0, 1);
} }
FUNC(LS_Plat_UpByValueStayTx) FUNC(LS_Plat_UpByValueStayTx)
// Plat_UpByValueStayTx (tag, speed, height) // Plat_UpByValueStayTx (tag, speed, height)
{ {
return EV_DoPlat (arg0, ln, DPlat::platUpByValueStay, FRACUNIT*arg2*8, SPEED(arg1), 0, 0, 2); return EV_DoPlat (arg0, ln, DPlat::platUpByValueStay, FRACUNIT*arg2*8, _f_SPEED(arg1), 0, 0, 2);
} }
FUNC(LS_Plat_ToggleCeiling) FUNC(LS_Plat_ToggleCeiling)
@ -975,7 +976,7 @@ FUNC(LS_Generic_Lift)
break; break;
} }
return EV_DoPlat (arg0, ln, type, arg4*8*FRACUNIT, SPEED(arg1), OCTICS(arg2), 0, 0); return EV_DoPlat (arg0, ln, type, arg4*8*FRACUNIT, _f_SPEED(arg1), OCTICS(arg2), 0, 0);
} }
FUNC(LS_Exit_Normal) FUNC(LS_Exit_Normal)
@ -1457,15 +1458,15 @@ FUNC(LS_Thing_Damage)
FUNC(LS_Thing_Projectile) FUNC(LS_Thing_Projectile)
// Thing_Projectile (tid, type, angle, speed, vspeed) // Thing_Projectile (tid, type, angle, speed, vspeed)
{ {
return P_Thing_Projectile (arg0, it, arg1, NULL, BYTEANGLE(arg2), arg3<<(FRACBITS-3), return P_Thing_Projectile (arg0, it, arg1, NULL, BYTEANGLE(arg2), SPEED(arg3),
arg4<<(FRACBITS-3), 0, NULL, 0, 0, false); SPEED(arg4), 0, NULL, 0, 0, false);
} }
FUNC(LS_Thing_ProjectileGravity) FUNC(LS_Thing_ProjectileGravity)
// Thing_ProjectileGravity (tid, type, angle, speed, vspeed) // Thing_ProjectileGravity (tid, type, angle, speed, vspeed)
{ {
return P_Thing_Projectile (arg0, it, arg1, NULL, BYTEANGLE(arg2), arg3<<(FRACBITS-3), return P_Thing_Projectile (arg0, it, arg1, NULL, BYTEANGLE(arg2), SPEED(arg3),
arg4<<(FRACBITS-3), 0, NULL, 1, 0, false); SPEED(arg4), 0, NULL, 1, 0, false);
} }
FUNC(LS_Thing_Hate) FUNC(LS_Thing_Hate)
@ -1634,13 +1635,13 @@ FUNC(LS_Thing_Hate)
FUNC(LS_Thing_ProjectileAimed) FUNC(LS_Thing_ProjectileAimed)
// Thing_ProjectileAimed (tid, type, speed, target, newtid) // Thing_ProjectileAimed (tid, type, speed, target, newtid)
{ {
return P_Thing_Projectile (arg0, it, arg1, NULL, 0., arg2<<(FRACBITS-3), 0, arg3, it, 0, arg4, false); return P_Thing_Projectile (arg0, it, arg1, NULL, 0., SPEED(arg2), 0, arg3, it, 0, arg4, false);
} }
FUNC(LS_Thing_ProjectileIntercept) FUNC(LS_Thing_ProjectileIntercept)
// Thing_ProjectileIntercept (tid, type, speed, target, newtid) // Thing_ProjectileIntercept (tid, type, speed, target, newtid)
{ {
return P_Thing_Projectile (arg0, it, arg1, NULL, 0., arg2<<(FRACBITS-3), 0, arg3, it, 0, arg4, true); return P_Thing_Projectile (arg0, it, arg1, NULL, 0., SPEED(arg2), 0, arg3, it, 0, arg4, true);
} }
// [BC] added newtid for next two // [BC] added newtid for next two
@ -1930,26 +1931,26 @@ FUNC(LS_FS_Execute)
FUNC(LS_FloorAndCeiling_LowerByValue) FUNC(LS_FloorAndCeiling_LowerByValue)
// FloorAndCeiling_LowerByValue (tag, speed, height) // FloorAndCeiling_LowerByValue (tag, speed, height)
{ {
return EV_DoElevator (ln, DElevator::elevateLower, SPEED(arg1), arg2*FRACUNIT, arg0); return EV_DoElevator (ln, DElevator::elevateLower, _f_SPEED(arg1), arg2*FRACUNIT, arg0);
} }
FUNC(LS_FloorAndCeiling_RaiseByValue) FUNC(LS_FloorAndCeiling_RaiseByValue)
// FloorAndCeiling_RaiseByValue (tag, speed, height) // FloorAndCeiling_RaiseByValue (tag, speed, height)
{ {
return EV_DoElevator (ln, DElevator::elevateRaise, SPEED(arg1), arg2*FRACUNIT, arg0); return EV_DoElevator (ln, DElevator::elevateRaise, _f_SPEED(arg1), arg2*FRACUNIT, arg0);
} }
FUNC(LS_FloorAndCeiling_LowerRaise) FUNC(LS_FloorAndCeiling_LowerRaise)
// FloorAndCeiling_LowerRaise (tag, fspeed, cspeed, boomemu) // FloorAndCeiling_LowerRaise (tag, fspeed, cspeed, boomemu)
{ {
bool res = EV_DoCeiling (DCeiling::ceilRaiseToHighest, ln, arg0, SPEED(arg2), 0, 0, 0, 0, 0, false); bool res = EV_DoCeiling (DCeiling::ceilRaiseToHighest, ln, arg0, _f_SPEED(arg2), 0, 0, 0, 0, 0, false);
// The switch based Boom equivalents of FloorandCeiling_LowerRaise do incorrect checks // The switch based Boom equivalents of FloorandCeiling_LowerRaise do incorrect checks
// which cause the floor only to move when the ceiling fails to do so. // which cause the floor only to move when the ceiling fails to do so.
// To avoid problems with maps that have incorrect args this only uses a // To avoid problems with maps that have incorrect args this only uses a
// more or less unintuitive value for the fourth arg to trigger Boom's broken behavior // more or less unintuitive value for the fourth arg to trigger Boom's broken behavior
if (arg3 != 1998 || !res) // (1998 for the year in which Boom was released... :P) if (arg3 != 1998 || !res) // (1998 for the year in which Boom was released... :P)
{ {
res |= EV_DoFloor (DFloor::floorLowerToLowest, ln, arg0, SPEED(arg1), 0, -1, 0, false); res |= EV_DoFloor (DFloor::floorLowerToLowest, ln, arg0, _f_SPEED(arg1), 0, -1, 0, false);
} }
return res; return res;
} }
@ -1957,19 +1958,19 @@ FUNC(LS_FloorAndCeiling_LowerRaise)
FUNC(LS_Elevator_MoveToFloor) FUNC(LS_Elevator_MoveToFloor)
// Elevator_MoveToFloor (tag, speed) // Elevator_MoveToFloor (tag, speed)
{ {
return EV_DoElevator (ln, DElevator::elevateCurrent, SPEED(arg1), 0, arg0); return EV_DoElevator (ln, DElevator::elevateCurrent, _f_SPEED(arg1), 0, arg0);
} }
FUNC(LS_Elevator_RaiseToNearest) FUNC(LS_Elevator_RaiseToNearest)
// Elevator_RaiseToNearest (tag, speed) // Elevator_RaiseToNearest (tag, speed)
{ {
return EV_DoElevator (ln, DElevator::elevateUp, SPEED(arg1), 0, arg0); return EV_DoElevator (ln, DElevator::elevateUp, _f_SPEED(arg1), 0, arg0);
} }
FUNC(LS_Elevator_LowerToNearest) FUNC(LS_Elevator_LowerToNearest)
// Elevator_LowerToNearest (tag, speed) // Elevator_LowerToNearest (tag, speed)
{ {
return EV_DoElevator (ln, DElevator::elevateDown, SPEED(arg1), 0, arg0); return EV_DoElevator (ln, DElevator::elevateDown, _f_SPEED(arg1), 0, arg0);
} }
FUNC(LS_Light_ForceLightning) FUNC(LS_Light_ForceLightning)
@ -2893,7 +2894,7 @@ enum
PROP_FLIGHT, PROP_FLIGHT,
PROP_UNUSED1, PROP_UNUSED1,
PROP_UNUSED2, PROP_UNUSED2,
PROP_SPEED, PROP__f_SPEED,
PROP_BUDDHA, PROP_BUDDHA,
}; };
@ -2908,7 +2909,7 @@ FUNC(LS_SetPlayerProperty)
return false; return false;
// Add or remove a power // Add or remove a power
if (arg2 >= PROP_INVULNERABILITY && arg2 <= PROP_SPEED) if (arg2 >= PROP_INVULNERABILITY && arg2 <= PROP__f_SPEED)
{ {
static PClass * const *powers[11] = static PClass * const *powers[11] =
{ {

View file

@ -210,8 +210,9 @@ extern FClassMap StrifeTypes;
bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, int newtid); bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, int newtid);
bool P_Thing_Projectile (int tid, AActor *source, int type, const char * type_name, DAngle angle, bool P_Thing_Projectile (int tid, AActor *source, int type, const char * type_name, DAngle angle,
fixed_t speed, fixed_t vspeed, int dest, AActor *forcedest, int gravity, int newtid, double speed, double vspeed, int dest, AActor *forcedest, int gravity, int newtid,
bool leadTarget); bool leadTarget);
bool P_MoveThing(AActor *source, const DVector3 &pos, bool fog); bool P_MoveThing(AActor *source, const DVector3 &pos, bool fog);
bool P_Thing_Move (int tid, AActor *source, int mapspot, bool fog); bool P_Thing_Move (int tid, AActor *source, int mapspot, bool fog);
int P_Thing_Damage (int tid, AActor *whofor0, int amount, FName type); int P_Thing_Damage (int tid, AActor *whofor0, int amount, FName type);

View file

@ -243,8 +243,8 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, co
open.floorterrain = -1; open.floorterrain = -1;
open.bottom = LINEOPEN_MIN; open.bottom = LINEOPEN_MIN;
open.lowfloor = LINEOPEN_MAX; open.lowfloor = LINEOPEN_MAX;
open.frontfloorplane.SetAtHeight(FIXED_MIN, sector_t::floor); open.frontfloorplane.SetAtHeight(LINEOPEN_MIN, sector_t::floor);
open.backfloorplane.SetAtHeight(FIXED_MIN, sector_t::floor); open.backfloorplane.SetAtHeight(LINEOPEN_MIN, sector_t::floor);
} }
// Check 3D floors // Check 3D floors

View file

@ -3683,7 +3683,7 @@ void AActor::Tick ()
secplane_t floorplane; secplane_t floorplane;
// Check 3D floors as well // Check 3D floors as well
floorplane = P_FindFloorPlane(floorsector, _f_X(), _f_Y(), _f_floorz()); floorplane = P_FindFloorPlane(floorsector, PosAtZ(floorz));
if (floorplane.c < STEEPSLOPE && if (floorplane.c < STEEPSLOPE &&
floorplane.ZatPoint (_f_PosRelative(floorsector)) <= _f_floorz()) floorplane.ZatPoint (_f_PosRelative(floorsector)) <= _f_floorz())

View file

@ -119,8 +119,8 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo
if (side == NULL) if (side == NULL)
return true; return true;
fixed_t checktop; double checktop;
fixed_t checkbot; double checkbot;
sector_t *front = side->sector; sector_t *front = side->sector;
FLineOpening open; FLineOpening open;
int flags = line->flags; int flags = line->flags;
@ -229,7 +229,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo
// to keep compatibility with Eternity's implementation. // to keep compatibility with Eternity's implementation.
if (!P_GetMidTexturePosition(line, sideno, &checktop, &checkbot)) if (!P_GetMidTexturePosition(line, sideno, &checktop, &checkbot))
return false; return false;
return user->_f_Z() < checktop && user->_f_Top() > checkbot; return user->Z() < checktop && user->Top() > checkbot;
} }
else else
{ {

View file

@ -169,15 +169,13 @@ bool P_Thing_Move (int tid, AActor *source, int mapspot, bool fog)
} }
bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_name, DAngle angle, bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_name, DAngle angle,
fixed_t _speed, fixed_t _vspeed, int dest, AActor *forcedest, int gravity, int newtid, double speed, double vspeed, int dest, AActor *forcedest, int gravity, int newtid,
bool leadTarget) bool leadTarget)
{ {
int rtn = 0; int rtn = 0;
PClassActor *kind; PClassActor *kind;
AActor *spot, *mobj, *targ = forcedest; AActor *spot, *mobj, *targ = forcedest;
FActorIterator iterator (tid); FActorIterator iterator (tid);
double speed = FIXED2DBL(_speed);
double vspeed = FIXED2DBL(_vspeed);
int defflags3; int defflags3;
if (type_name == NULL) if (type_name == NULL)

View file

@ -150,8 +150,8 @@ static int WriteSIDEDEFS (FILE *file)
for (int i = 0; i < numsides; ++i) for (int i = 0; i < numsides; ++i)
{ {
msd.textureoffset = LittleShort(short(sides[i].GetTextureXOffset(side_t::mid) >> FRACBITS)); msd.textureoffset = LittleShort(short(sides[i].GetTextureXOffsetF(side_t::mid)));
msd.rowoffset = LittleShort(short(sides[i].GetTextureYOffset(side_t::mid) >> FRACBITS)); msd.rowoffset = LittleShort(short(sides[i].GetTextureYOffsetF(side_t::mid)));
msd.sector = LittleShort(short(sides[i].sector - sectors)); msd.sector = LittleShort(short(sides[i].sector - sectors));
uppercopy (msd.toptexture, GetTextureName (sides[i].GetTexture(side_t::top))); uppercopy (msd.toptexture, GetTextureName (sides[i].GetTexture(side_t::top)));
uppercopy (msd.bottomtexture, GetTextureName (sides[i].GetTexture(side_t::bottom))); uppercopy (msd.bottomtexture, GetTextureName (sides[i].GetTexture(side_t::bottom)));

View file

@ -405,6 +405,11 @@ struct secplane_t
} }
} }
inline void SetAtHeight(double height, int ceiling)
{
SetAtHeight(FLOAT2FIXED(clamp(height, -32767., 32767.)), ceiling);
}
bool CopyPlaneIfValid (secplane_t *dest, const secplane_t *opp) const; bool CopyPlaneIfValid (secplane_t *dest, const secplane_t *opp) const;
}; };
@ -1113,6 +1118,10 @@ struct side_t
{ {
return textures[which].xoffset; return textures[which].xoffset;
} }
double GetTextureXOffsetF(int which) const
{
return FIXED2DBL(textures[which].xoffset);
}
void AddTextureXOffset(int which, fixed_t delta) void AddTextureXOffset(int which, fixed_t delta)
{ {
textures[which].xoffset += delta; textures[which].xoffset += delta;
@ -1132,6 +1141,10 @@ struct side_t
{ {
return textures[which].yoffset; return textures[which].yoffset;
} }
double GetTextureYOffsetF(int which) const
{
return FIXED2DBL(textures[which].yoffset);
}
void AddTextureYOffset(int which, fixed_t delta) void AddTextureYOffset(int which, fixed_t delta)
{ {
textures[which].yoffset += delta; textures[which].yoffset += delta;
@ -1167,6 +1180,10 @@ struct side_t
{ {
return textures[which].yscale; return textures[which].yscale;
} }
double GetTextureYScaleF(int which) const
{
return FIXED2DBL(textures[which].yscale);
}
void MultiplyTextureYScale(int which, fixed_t delta) void MultiplyTextureYScale(int which, fixed_t delta)
{ {
textures[which].yscale = FixedMul(textures[which].yscale, delta); textures[which].yscale = FixedMul(textures[which].yscale, delta);

View file

@ -100,7 +100,7 @@ typedef uint32 angle_t;
// note: remove the call to 'abs' since unsigned values cannot be negative // note: remove the call to 'abs' since unsigned values cannot be negative
inline angle_t absangle(angle_t a) inline angle_t absangle(angle_t a)
{ {
return (angle_t)abs((int32)a); return (angle_t)abs((int32_t)a);
} }
// Effective size is 2049; // Effective size is 2049;

View file

@ -205,7 +205,6 @@ public:
int GetScaledWidth () { int foo = (Width << 17) / xScale; return (foo >> 1) + (foo & 1); } int GetScaledWidth () { int foo = (Width << 17) / xScale; return (foo >> 1) + (foo & 1); }
int GetScaledHeight () { int foo = (Height << 17) / yScale; return (foo >> 1) + (foo & 1); } int GetScaledHeight () { int foo = (Height << 17) / yScale; return (foo >> 1) + (foo & 1); }
int GetScaledHeight(double scale) { int foo = (Height << 17) / FLOAT2FIXED(scale); return (foo >> 1) + (foo & 1); }
double GetScaledWidthDouble () { return (Width * 65536.) / xScale; } double GetScaledWidthDouble () { return (Width * 65536.) / xScale; }
double GetScaledHeightDouble () { return (Height * 65536.) / yScale; } double GetScaledHeightDouble () { return (Height * 65536.) / yScale; }
double GetScaleY() const { return FIXED2DBL(yScale); } double GetScaleY() const { return FIXED2DBL(yScale); }

View file

@ -43,6 +43,7 @@
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include "m_fixed.h" #include "m_fixed.h"
#include "tables.h"
#include "math/cmath.h" #include "math/cmath.h"
@ -1036,11 +1037,6 @@ struct TAngle
return TVector2<vec_t>(length * Cos(), length * Sin()); return TVector2<vec_t>(length * Cos(), length * Sin());
} }
int FixedAngle() // for ACS. This must be normalized so it just converts to BAM first and then shifts 16 bits right.
{
return FLOAT2ANGLE(Degrees) >> 16;
}
vec_t Cos() const vec_t Cos() const
{ {
return vec_t(g_cosdeg(Degrees)); return vec_t(g_cosdeg(Degrees));

View file

@ -3074,7 +3074,8 @@ void D3DFB::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints,
DAngle rotation, FDynamicColormap *colormap, int lightlevel) DAngle rotation, FDynamicColormap *colormap, int lightlevel)
{ {
// Use an equation similar to player sprites to determine shade // Use an equation similar to player sprites to determine shade
fixed_t shade = LIGHT2SHADE(lightlevel) - 12*FRACUNIT; double fadelevel = clamp((LIGHT2SHADE(lightlevel)/65536. - 12) / NUMCOLORMAPS, 0.0, 1.0);
BufferedTris *quad; BufferedTris *quad;
FBVERTEX *verts; FBVERTEX *verts;
D3DTex *tex; D3DTex *tex;
@ -3128,7 +3129,6 @@ void D3DFB::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints,
quad->ShaderNum = BQS_InGameColormap; quad->ShaderNum = BQS_InGameColormap;
quad->Desat = colormap->Desaturate; quad->Desat = colormap->Desaturate;
color0 = D3DCOLOR_ARGB(255, colormap->Color.r, colormap->Color.g, colormap->Color.b); color0 = D3DCOLOR_ARGB(255, colormap->Color.r, colormap->Color.g, colormap->Color.b);
double fadelevel = clamp(shade / (NUMCOLORMAPS * 65536.0), 0.0, 1.0);
color1 = D3DCOLOR_ARGB(DWORD((1 - fadelevel) * 255), color1 = D3DCOLOR_ARGB(DWORD((1 - fadelevel) * 255),
DWORD(colormap->Fade.r * fadelevel), DWORD(colormap->Fade.r * fadelevel),
DWORD(colormap->Fade.g * fadelevel), DWORD(colormap->Fade.g * fadelevel),

View file

@ -15,6 +15,8 @@
#ifndef _xs_FLOAT_H_ #ifndef _xs_FLOAT_H_
#define _xs_FLOAT_H_ #define _xs_FLOAT_H_
#include <stdint.h>
// ==================================================================================================================== // ====================================================================================================================
// Defines // Defines
// ==================================================================================================================== // ====================================================================================================================
@ -37,15 +39,18 @@
#define finline __forceinline #define finline __forceinline
#endif #endif
typedef double real64;
union _xs_doubleints union _xs_doubleints
{ {
real64 val; real64 val;
uint32 ival[2]; uint32_t ival[2];
}; };
#if 0 #if 0
#define _xs_doublecopysgn(a,b) ((int32*)&a)[_xs_iexp_]&=~(((int32*)&b)[_xs_iexp_]&0x80000000) #define _xs_doublecopysgn(a,b) ((int32_t*)&a)[_xs_iexp_]&=~(((int32_t*)&b)[_xs_iexp_]&0x80000000)
#define _xs_doubleisnegative(a) ((((int32*)&a)[_xs_iexp_])|0x80000000) #define _xs_doubleisnegative(a) ((((int32_t*)&a)[_xs_iexp_])|0x80000000)
#endif #endif
// ==================================================================================================================== // ====================================================================================================================
@ -59,37 +64,37 @@ const real64 _xs_doublemagicroundeps = (.5f-_xs_doublemagicdelta); //almos
// ==================================================================================================================== // ====================================================================================================================
// Prototypes // Prototypes
// ==================================================================================================================== // ====================================================================================================================
static int32 xs_CRoundToInt (real64 val, real64 dmr = _xs_doublemagic); static int32_t xs_CRoundToInt (real64 val, real64 dmr = _xs_doublemagic);
static int32 xs_ToInt (real64 val, real64 dme = -_xs_doublemagicroundeps); static int32_t xs_ToInt (real64 val, real64 dme = -_xs_doublemagicroundeps);
static int32 xs_FloorToInt (real64 val, real64 dme = _xs_doublemagicroundeps); static int32_t xs_FloorToInt (real64 val, real64 dme = _xs_doublemagicroundeps);
static int32 xs_CeilToInt (real64 val, real64 dme = _xs_doublemagicroundeps); static int32_t xs_CeilToInt (real64 val, real64 dme = _xs_doublemagicroundeps);
static int32 xs_RoundToInt (real64 val); static int32_t xs_RoundToInt (real64 val);
//int32 versions //int32_t versions
finline static int32 xs_CRoundToInt (int32 val) {return val;} finline static int32_t xs_CRoundToInt (int32_t val) {return val;}
finline static int32 xs_ToInt (int32 val) {return val;} finline static int32_t xs_ToInt (int32_t val) {return val;}
// ==================================================================================================================== // ====================================================================================================================
// Fix Class // Fix Class
// ==================================================================================================================== // ====================================================================================================================
template <int32 N> class xs_Fix template <int32_t N> class xs_Fix
{ {
public: public:
typedef int32 Fix; typedef int32_t Fix;
// ==================================================================================================================== // ====================================================================================================================
// Basic Conversion from Numbers // Basic Conversion from Numbers
// ==================================================================================================================== // ====================================================================================================================
finline static Fix ToFix (int32 val) {return val<<N;} finline static Fix ToFix (int32_t val) {return val<<N;}
finline static Fix ToFix (real64 val) {return xs_ConvertToFixed(val);} finline static Fix ToFix (real64 val) {return xs_ConvertToFixed(val);}
// ==================================================================================================================== // ====================================================================================================================
// Basic Conversion to Numbers // Basic Conversion to Numbers
// ==================================================================================================================== // ====================================================================================================================
finline static real64 ToReal (Fix f) {return real64(f)/real64(1<<N);} finline static real64 ToReal (Fix f) {return real64(f)/real64(1<<N);}
finline static int32 ToInt (Fix f) {return f>>N;} finline static int32_t ToInt (Fix f) {return f>>N;}
@ -97,7 +102,7 @@ protected:
// ==================================================================================================================== // ====================================================================================================================
// Helper function - mainly to preserve _xs_DEFAULT_CONVERSION // Helper function - mainly to preserve _xs_DEFAULT_CONVERSION
// ==================================================================================================================== // ====================================================================================================================
finline static int32 xs_ConvertToFixed (real64 val) finline static int32_t xs_ConvertToFixed (real64 val)
{ {
#if _xs_DEFAULT_CONVERSION==0 #if _xs_DEFAULT_CONVERSION==0
return xs_CRoundToInt(val, _xs_doublemagic/(1<<N)); return xs_CRoundToInt(val, _xs_doublemagic/(1<<N));
@ -116,20 +121,20 @@ protected:
// Inline implementation // Inline implementation
// ==================================================================================================================== // ====================================================================================================================
// ==================================================================================================================== // ====================================================================================================================
finline static int32 xs_CRoundToInt(real64 val, real64 dmr) finline static int32_t xs_CRoundToInt(real64 val, real64 dmr)
{ {
#if _xs_DEFAULT_CONVERSION==0 #if _xs_DEFAULT_CONVERSION==0
_xs_doubleints uval; _xs_doubleints uval;
uval.val = val + dmr; uval.val = val + dmr;
return uval.ival[_xs_iman_]; return uval.ival[_xs_iman_];
#else #else
return int32(floor(val+.5)); return int32_t(floor(val+.5));
#endif #endif
} }
// ==================================================================================================================== // ====================================================================================================================
finline static int32 xs_ToInt(real64 val, real64 dme) finline static int32_t xs_ToInt(real64 val, real64 dme)
{ {
/* unused - something else I tried... /* unused - something else I tried...
_xs_doublecopysgn(dme,val); _xs_doublecopysgn(dme,val);
@ -143,20 +148,20 @@ finline static int32 xs_ToInt(real64 val, real64 dme)
// fastest C-style float->int conversion, but unfortunately, // fastest C-style float->int conversion, but unfortunately,
// checking for SSE support every time you need to do a // checking for SSE support every time you need to do a
// conversion completely negates its performance advantage. // conversion completely negates its performance advantage.
return int32(val); return int32_t(val);
#else #else
#if _xs_DEFAULT_CONVERSION==0 #if _xs_DEFAULT_CONVERSION==0
return (val<0) ? xs_CRoundToInt(val-dme) : return (val<0) ? xs_CRoundToInt(val-dme) :
xs_CRoundToInt(val+dme); xs_CRoundToInt(val+dme);
#else #else
return int32(val); return int32_t(val);
#endif #endif
#endif #endif
} }
// ==================================================================================================================== // ====================================================================================================================
finline static int32 xs_FloorToInt(real64 val, real64 dme) finline static int32_t xs_FloorToInt(real64 val, real64 dme)
{ {
#if _xs_DEFAULT_CONVERSION==0 #if _xs_DEFAULT_CONVERSION==0
return xs_CRoundToInt (val - dme); return xs_CRoundToInt (val - dme);
@ -167,7 +172,7 @@ finline static int32 xs_FloorToInt(real64 val, real64 dme)
// ==================================================================================================================== // ====================================================================================================================
finline static int32 xs_CeilToInt(real64 val, real64 dme) finline static int32_t xs_CeilToInt(real64 val, real64 dme)
{ {
#if _xs_DEFAULT_CONVERSION==0 #if _xs_DEFAULT_CONVERSION==0
return xs_CRoundToInt (val + dme); return xs_CRoundToInt (val + dme);
@ -178,7 +183,7 @@ finline static int32 xs_CeilToInt(real64 val, real64 dme)
// ==================================================================================================================== // ====================================================================================================================
finline static int32 xs_RoundToInt(real64 val) finline static int32_t xs_RoundToInt(real64 val)
{ {
#if _xs_DEFAULT_CONVERSION==0 #if _xs_DEFAULT_CONVERSION==0
// Yes, it is important that two fadds be generated, so you cannot override the dmr // Yes, it is important that two fadds be generated, so you cannot override the dmr
@ -197,24 +202,24 @@ finline static int32 xs_RoundToInt(real64 val)
// Unsigned variants // Unsigned variants
// ==================================================================================================================== // ====================================================================================================================
// ==================================================================================================================== // ====================================================================================================================
finline static uint32 xs_CRoundToUInt(real64 val) finline static uint32_t xs_CRoundToUInt(real64 val)
{ {
return (uint32)xs_CRoundToInt(val); return (uint32_t)xs_CRoundToInt(val);
} }
finline static uint32 xs_FloorToUInt(real64 val) finline static uint32_t xs_FloorToUInt(real64 val)
{ {
return (uint32)xs_FloorToInt(val); return (uint32_t)xs_FloorToInt(val);
} }
finline static uint32 xs_CeilToUInt(real64 val) finline static uint32_t xs_CeilToUInt(real64 val)
{ {
return (uint32)xs_CeilToInt(val); return (uint32_t)xs_CeilToInt(val);
} }
finline static uint32 xs_RoundToUInt(real64 val) finline static uint32_t xs_RoundToUInt(real64 val)
{ {
return (uint32)xs_RoundToInt(val); return (uint32_t)xs_RoundToInt(val);
} }