- trimmed down the AActor Spawn interface and removed all non-float variants.

This still needs some cleanup in a few calling functions.
This commit is contained in:
Christoph Oelckers 2016-03-23 10:42:41 +01:00
parent 2a0d5a621a
commit f8cf4bcf3d
29 changed files with 214 additions and 277 deletions

View file

@ -580,7 +580,7 @@ public:
void Serialize (FArchive &arc); void Serialize (FArchive &arc);
static AActor *StaticSpawn (PClassActor *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement, bool SpawningMapThing = false); static AActor *StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t allowreplacement, bool SpawningMapThing = false);
inline AActor *GetDefault () const inline AActor *GetDefault () const
{ {
@ -1666,96 +1666,36 @@ public:
bool P_IsTIDUsed(int tid); bool P_IsTIDUsed(int tid);
int P_FindUniqueTID(int start_tid, int limit); int P_FindUniqueTID(int start_tid, int limit);
inline AActor *Spawn (PClassActor *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement) PClassActor *ClassForSpawn(FName classname);
{
return AActor::StaticSpawn (type, x, y, z, allowreplacement);
}
inline AActor *Spawn(PClassActor *type) inline AActor *Spawn(PClassActor *type)
{ {
return AActor::StaticSpawn(type, 0, 0, 0, NO_REPLACE); return AActor::StaticSpawn(type, DVector3(0, 0, 0), NO_REPLACE);
}
inline AActor *Spawn (PClassActor *type, const fixedvec3 &pos, replace_t allowreplacement)
{
return AActor::StaticSpawn (type, pos.x, pos.y, pos.z, allowreplacement);
} }
inline AActor *Spawn(PClassActor *type, const DVector3 &pos, replace_t allowreplacement) inline AActor *Spawn(PClassActor *type, const DVector3 &pos, replace_t allowreplacement)
{ {
fixed_t zz; return AActor::StaticSpawn(type, pos, allowreplacement);
if (pos.Z != ONFLOORZ && pos.Z != ONCEILINGZ && pos.Z != FLOATRANDZ) zz = FLOAT2FIXED(pos.Z);
else zz = (int)pos.Z;
return Spawn(type, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), zz, allowreplacement);
} }
AActor *Spawn (const char *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement);
AActor *Spawn (FName classname, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement);
inline AActor *Spawn(FName type) inline AActor *Spawn(FName type)
{ {
return Spawn(type, 0, 0, 0, NO_REPLACE); return AActor::StaticSpawn(ClassForSpawn(type), DVector3(0, 0, 0), NO_REPLACE);
}
inline AActor *Spawn (const char *type, const fixedvec3 &pos, replace_t allowreplacement)
{
return Spawn (type, pos.x, pos.y, pos.z, allowreplacement);
}
inline AActor *Spawn(const char *type, const DVector3 &pos, replace_t allowreplacement)
{
fixed_t zz;
if (pos.Z != ONFLOORZ && pos.Z != ONCEILINGZ && pos.Z != FLOATRANDZ) zz = FLOAT2FIXED(pos.Z);
else zz = (int)pos.Z;
return Spawn(type, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), zz, allowreplacement);
}
inline AActor *Spawn (FName classname, const fixedvec3 &pos, replace_t allowreplacement)
{
return Spawn (classname, pos.x, pos.y, pos.z, allowreplacement);
} }
inline AActor *Spawn(FName type, const DVector3 &pos, replace_t allowreplacement) inline AActor *Spawn(FName type, const DVector3 &pos, replace_t allowreplacement)
{ {
fixed_t zz; return AActor::StaticSpawn(ClassForSpawn(type), pos, allowreplacement);
if (pos.Z != ONFLOORZ && pos.Z != ONCEILINGZ && pos.Z != FLOATRANDZ) zz = FLOAT2FIXED(pos.Z);
else zz = (int)pos.Z;
return Spawn(type, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), zz, allowreplacement);
} }
template<class T> inline T *Spawn(const DVector3 &pos, replace_t allowreplacement)
template<class T>
inline T *Spawn (fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement)
{ {
return static_cast<T *>(AActor::StaticSpawn (RUNTIME_TEMPLATE_CLASS(T), x, y, z, allowreplacement)); return static_cast<T *>(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), pos, allowreplacement));
} }
template<class T> template<class T> inline T *Spawn() // for inventory items we do not need coordinates and replacement info.
inline T *Spawn (const fixedvec3 &pos, replace_t allowreplacement)
{ {
return static_cast<T *>(AActor::StaticSpawn (RUNTIME_TEMPLATE_CLASS(T), pos.x, pos.y, pos.z, allowreplacement)); return static_cast<T *>(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), DVector3(0, 0, 0), NO_REPLACE));
}
template<class T>
inline T *Spawn(const DVector3 &pos, replace_t allowreplacement)
{
fixed_t zz;
if (pos.Z != ONFLOORZ && pos.Z != ONCEILINGZ && pos.Z != FLOATRANDZ) zz = FLOAT2FIXED(pos.Z);
else zz = (int)pos.Z;
return static_cast<T *>(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), zz, allowreplacement));
}
template<class T>
inline T *Spawn(double x, double y, double z, replace_t allowreplacement)
{
fixed_t zz;
if (z != ONFLOORZ && z != ONCEILINGZ && z != FLOATRANDZ) zz = FLOAT2FIXED(z);
else zz = (int)z;
return static_cast<T *>(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), FLOAT2FIXED(x), FLOAT2FIXED(y), zz, allowreplacement));
}
template<class T>
inline T *Spawn() // for inventory items we do not need coordinates and replacement info.
{
return static_cast<T *>(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), 0, 0, 0, NO_REPLACE));
} }
inline fixedvec2 Vec2Angle(fixed_t length, angle_t angle) inline fixedvec2 Vec2Angle(fixed_t length, angle_t angle)

View file

@ -103,7 +103,7 @@ public:
void StartTravel (); void StartTravel ();
void FinishTravel (); void FinishTravel ();
bool IsLeader (player_t *player); bool IsLeader (player_t *player);
void SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum); void SetBodyAt (const DVector3 &pos, int hostnum);
fixed_t FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd); fixed_t FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd);
bool SafeCheckPosition (AActor *actor, fixed_t x, fixed_t y, FCheckPosition &tm); bool SafeCheckPosition (AActor *actor, fixed_t x, fixed_t y, FCheckPosition &tm);

View file

@ -141,8 +141,10 @@ void DBot::Dofire (ticcmd_t *cmd)
int aiming_penalty=0; //For shooting at shading target, if screen is red, MAKEME: When screen red. int aiming_penalty=0; //For shooting at shading target, if screen is red, MAKEME: When screen red.
int aiming_value; //The final aiming value. int aiming_value; //The final aiming value.
fixed_t dist; fixed_t dist;
double fdist;
angle_t an; angle_t an;
int m; int m;
double fm;
if (!enemy || !(enemy->flags & MF_SHOOTABLE) || enemy->health <= 0) if (!enemy || !(enemy->flags & MF_SHOOTABLE) || enemy->health <= 0)
return; return;
@ -221,9 +223,9 @@ void DBot::Dofire (ticcmd_t *cmd)
} }
// prediction aiming // prediction aiming
shootmissile: shootmissile:
dist = player->mo->AproxDistance (enemy); fdist = player->mo->Distance2D(enemy);
m = dist / GetDefaultByType (player->ReadyWeapon->ProjectileType)->_f_speed(); fm = fdist / GetDefaultByType (player->ReadyWeapon->ProjectileType)->Speed;
bglobal.SetBodyAt (enemy->_f_X() + enemy->_f_velx()*m*2, enemy->_f_Y() + enemy->_f_vely()*m*2, enemy->_f_Z(), 1); bglobal.SetBodyAt(enemy->Pos() + enemy->Vel.XY() * fm * 2, 1);
angle = player->mo->__f_AngleTo(bglobal.body1); angle = player->mo->__f_AngleTo(bglobal.body1);
if (Check_LOS (enemy, SHOOTFOV)) if (Check_LOS (enemy, SHOOTFOV))
no_fire = false; no_fire = false;
@ -425,28 +427,28 @@ AActor *DBot::Find_enemy ()
//Creates a temporary mobj (invisible) at the given location. //Creates a temporary mobj (invisible) at the given location.
void FCajunMaster::SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum) void FCajunMaster::SetBodyAt (const DVector3 &pos, int hostnum)
{ {
if (hostnum == 1) if (hostnum == 1)
{ {
if (body1) if (body1)
{ {
body1->SetOrigin (x, y, z, false); body1->SetOrigin (pos, false);
} }
else else
{ {
body1 = Spawn ("CajunBodyNode", x, y, z, NO_REPLACE); body1 = Spawn ("CajunBodyNode", pos, NO_REPLACE);
} }
} }
else if (hostnum == 2) else if (hostnum == 2)
{ {
if (body2) if (body2)
{ {
body2->SetOrigin (x, y, z, false); body2->SetOrigin (pos, false);
} }
else else
{ {
body2 = Spawn ("CajunBodyNode", x, y, z, NO_REPLACE); body2 = Spawn ("CajunBodyNode", pos, NO_REPLACE);
} }
} }
} }
@ -463,7 +465,7 @@ void FCajunMaster::SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum)
//Emulates missile travel. Returns distance travelled. //Emulates missile travel. Returns distance travelled.
fixed_t FCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd) fixed_t FCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd)
{ {
AActor *th = Spawn ("CajunTrace", source->PosPlusZ(4*8*FRACUNIT), NO_REPLACE); AActor *th = Spawn ("CajunTrace", source->PosPlusZ(4*8.), NO_REPLACE);
th->target = source; // where it came from th->target = source; // where it came from
@ -485,25 +487,22 @@ fixed_t FCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd)
angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd) angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd)
{ {
fixed_t dist; double dist;
angle_t ang; angle_t ang;
AActor *actor; AActor *actor;
int m; double m;
bglobal.SetBodyAt (player->mo->_f_X() + FixedMul(player->mo->_f_velx(), 5*FRACUNIT), bglobal.SetBodyAt(player->mo->PosPlusZ(player->mo->Height / 2) + player->mo->Vel.XY() * 5, 2);
player->mo->_f_Y() + FixedMul(player->mo->_f_vely(), 5*FRACUNIT),
player->mo->_f_Z() + (player->mo->_f_height() / 2), 2);
actor = bglobal.body2; actor = bglobal.body2;
dist = actor->AproxDistance (enemy); dist = actor->Distance2D (enemy);
if (dist < SAFE_SELF_MISDIST) if (dist < SAFE_SELF_MISDIST/FRACUNIT)
return 0; return 0;
//Predict. //Predict.
m = (((dist+1)/FRACUNIT) / GetDefaultByName("Rocket")->_f_speed()); m = ((dist+1) / GetDefaultByName("Rocket")->Speed);
bglobal.SetBodyAt (enemy->_f_X() + FixedMul(enemy->_f_velx(), (m+2*FRACUNIT)), bglobal.SetBodyAt(DVector3((enemy->Pos() + enemy->Vel * (m + 2)), ONFLOORZ), 1);
enemy->_f_Y() + FixedMul(enemy->_f_vely(), (m+2*FRACUNIT)), ONFLOORZ, 1);
//try the predicted location //try the predicted location
if (P_CheckSight (actor, bglobal.body1, SF_IGNOREVISIBILITY)) //See the predicted location, so give a test missile if (P_CheckSight (actor, bglobal.body1, SF_IGNOREVISIBILITY)) //See the predicted location, so give a test missile

View file

@ -2321,7 +2321,7 @@ void Net_DoCommand (int type, BYTE **stream, int player)
else else
{ {
const AActor *def = GetDefaultByType (typeinfo); const AActor *def = GetDefaultByType (typeinfo);
fixedvec3 spawnpos = source->_f_Vec3Angle(def->_f_radius() * 2 + source->_f_radius(), source->_f_angle(), 8 * FRACUNIT); DVector3 spawnpos = source->Vec3Angle(def->radius * 2 + source->radius, source->Angles.Yaw, 8.);
AActor *spawned = Spawn (typeinfo, spawnpos, ALLOW_REPLACE); AActor *spawned = Spawn (typeinfo, spawnpos, ALLOW_REPLACE);
if (spawned != NULL) if (spawned != NULL)

View file

@ -862,7 +862,7 @@ void FParser::SF_Player(void)
void FParser::SF_Spawn(void) void FParser::SF_Spawn(void)
{ {
int x, y, z; DVector3 pos;
PClassActor *pclass; PClassActor *pclass;
DAngle angle = 0.; DAngle angle = 0.;
@ -870,22 +870,22 @@ void FParser::SF_Spawn(void)
{ {
if (!(pclass=T_GetMobjType(t_argv[0]))) return; if (!(pclass=T_GetMobjType(t_argv[0]))) return;
x = fixedvalue(t_argv[1]); pos.X = floatvalue(t_argv[1]);
y = fixedvalue(t_argv[2]); pos.Y = floatvalue(t_argv[2]);
if(t_argc >= 5) if(t_argc >= 5)
{ {
z = fixedvalue(t_argv[4]); pos.Z = floatvalue(t_argv[4]);
// [Graf Zahl] added option of spawning with a relative z coordinate // [Graf Zahl] added option of spawning with a relative z coordinate
if(t_argc > 5) if(t_argc > 5)
{ {
if (intvalue(t_argv[5])) z+=P_PointInSector(x, y)->floorplane.ZatPoint(x,y); if (intvalue(t_argv[5])) pos.Z += P_PointInSector(pos)->floorplane.ZatPoint(pos);
} }
} }
else else
{ {
// Legacy compatibility is more important than correctness. // Legacy compatibility is more important than correctness.
z = ONFLOORZ;// (GetDefaultByType(PClass)->flags & MF_SPAWNCEILING) ? ONCEILINGZ : ONFLOORZ; pos.Z = ONFLOORZ;// (GetDefaultByType(PClass)->flags & MF_SPAWNCEILING) ? ONCEILINGZ : ONFLOORZ;
} }
if(t_argc >= 4) if(t_argc >= 4)
@ -894,7 +894,7 @@ void FParser::SF_Spawn(void)
} }
t_return.type = svt_mobj; t_return.type = svt_mobj;
t_return.value.mobj = Spawn(pclass, x, y, z, ALLOW_REPLACE); t_return.value.mobj = Spawn(pclass, pos, ALLOW_REPLACE);
if (t_return.value.mobj) if (t_return.value.mobj)
{ {
@ -3340,7 +3340,7 @@ void FParser::SF_FixedValue(void)
void FParser::SF_SpawnExplosion() void FParser::SF_SpawnExplosion()
{ {
fixed_t x, y, z; DVector3 pos;
AActor* spawn; AActor* spawn;
PClassActor * pclass; PClassActor * pclass;
@ -3348,14 +3348,14 @@ void FParser::SF_SpawnExplosion()
{ {
if (!(pclass=T_GetMobjType(t_argv[0]))) return; if (!(pclass=T_GetMobjType(t_argv[0]))) return;
x = fixedvalue(t_argv[1]); pos.X = floatvalue(t_argv[1]);
y = fixedvalue(t_argv[2]); pos.Y = floatvalue(t_argv[2]);
if(t_argc > 3) if(t_argc > 3)
z = fixedvalue(t_argv[3]); pos.Z = floatvalue(t_argv[3]);
else else
z = P_PointInSector(x, y)->floorplane.ZatPoint(x,y); pos.Z = P_PointInSector(pos)->floorplane.ZatPoint(pos);
spawn = Spawn (pclass, x, y, z, ALLOW_REPLACE); spawn = Spawn (pclass, pos, ALLOW_REPLACE);
t_return.type = svt_int; t_return.type = svt_int;
t_return.value.i=0; t_return.value.i=0;
if (spawn) if (spawn)
@ -4239,31 +4239,31 @@ void FParser::SF_SpawnShot2(void)
{ {
AActor *source = NULL; AActor *source = NULL;
PClassActor * pclass; PClassActor * pclass;
int z=0; double z = 0;
// t_argv[0] = type to spawn // t_argv[0] = type to spawn
// t_argv[1] = source mobj, optional, -1 to default // t_argv[1] = source mobj, optional, -1 to default
// shoots at source's angle // shoots at source's angle
if (CheckArgs(2)) if (CheckArgs(2))
{ {
if(t_argv[1].type == svt_int && t_argv[1].value.i < 0) if (t_argv[1].type == svt_int && t_argv[1].value.i < 0)
source = Script->trigger; source = Script->trigger;
else else
source = actorvalue(t_argv[1]); source = actorvalue(t_argv[1]);
if (t_argc>2) z=fixedvalue(t_argv[2]); if (t_argc > 2) z = floatvalue(t_argv[2]);
if(!source) return; if (!source) return;
if (!(pclass=T_GetMobjType(t_argv[0]))) return; if (!(pclass = T_GetMobjType(t_argv[0]))) return;
t_return.type = svt_mobj; t_return.type = svt_mobj;
AActor *mo = Spawn (pclass, source->PosPlusZ(z), ALLOW_REPLACE); AActor *mo = Spawn(pclass, source->PosPlusZ(z), ALLOW_REPLACE);
if (mo) if (mo)
{ {
S_Sound (mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_NORM); S_Sound(mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_NORM);
mo->target = source; mo->target = source;
mo->Angles.Yaw = source->Angles.Yaw; mo->Angles.Yaw = source->Angles.Yaw;
mo->Thrust(); mo->Thrust();

View file

@ -66,7 +66,7 @@ void AFastProjectile::Tick ()
tm.LastRipped.Clear(); // [RH] Do rip damage each step, like Hexen tm.LastRipped.Clear(); // [RH] Do rip damage each step, like Hexen
} }
if (!P_TryMove (this, X() + frac.X, Y() + frac.Y, true, NULL, tm)) if (!P_TryMove (this, Pos() + frac, true, NULL, tm))
{ // Blocked move { // Blocked move
if (!(flags3 & MF3_SKYEXPLODE)) if (!(flags3 & MF3_SKYEXPLODE))
{ {

View file

@ -787,7 +787,7 @@ AInventory *AInventory::CreateTossable ()
flags &= ~(MF_SPECIAL|MF_SOLID); flags &= ~(MF_SPECIAL|MF_SOLID);
return this; return this;
} }
copy = static_cast<AInventory *>(Spawn (GetClass(), Owner->_f_Pos(), NO_REPLACE)); copy = static_cast<AInventory *>(Spawn (GetClass(), Owner->Pos(), NO_REPLACE));
if (copy != NULL) if (copy != NULL)
{ {
copy->MaxAmount = MaxAmount; copy->MaxAmount = MaxAmount;

View file

@ -77,7 +77,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnEntity)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
AActor *entity = Spawn("EntityBoss", self->PosPlusZ(70), ALLOW_REPLACE); AActor *entity = Spawn("EntityBoss", self->PosPlusZ(70.), ALLOW_REPLACE);
if (entity != NULL) if (entity != NULL)
{ {
entity->Angles.Yaw = self->Angles.Yaw; entity->Angles.Yaw = self->Angles.Yaw;

View file

@ -127,7 +127,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_TossArm)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
AActor *foo = Spawn("InquisitorArm", self->PosPlusZ(24), ALLOW_REPLACE); AActor *foo = Spawn("InquisitorArm", self->PosPlusZ(24.), ALLOW_REPLACE);
foo->Angles.Yaw = self->Angles.Yaw - 90. + pr_inq.Random2() * (360./1024.); foo->Angles.Yaw = self->Angles.Yaw - 90. + pr_inq.Random2() * (360./1024.);
foo->VelFromAngle(foo->Speed / 8); foo->VelFromAngle(foo->Speed / 8);
foo->Vel.Z = pr_inq() / 64.; foo->Vel.Z = pr_inq() / 64.;

View file

@ -130,7 +130,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnProgrammerBase)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
AActor *foo = Spawn("ProgrammerBase", self->PosPlusZ(24), ALLOW_REPLACE); AActor *foo = Spawn("ProgrammerBase", self->PosPlusZ(24.), ALLOW_REPLACE);
if (foo != NULL) if (foo != NULL)
{ {
foo->Angles.Yaw = self->Angles.Yaw + 180. + pr_prog.Random2() * (360. / 1024.); foo->Angles.Yaw = self->Angles.Yaw + 180. + pr_prog.Random2() * (360. / 1024.);

View file

@ -251,7 +251,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_TossGib)
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
const char *gibtype = (self->flags & MF_NOBLOOD) ? "Junk" : "Meat"; const char *gibtype = (self->flags & MF_NOBLOOD) ? "Junk" : "Meat";
AActor *gib = Spawn (gibtype, self->PosPlusZ(24), ALLOW_REPLACE); AActor *gib = Spawn (gibtype, self->PosPlusZ(24.), ALLOW_REPLACE);
if (gib == NULL) if (gib == NULL)
{ {

View file

@ -667,7 +667,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Burnination)
pos = self->Pos(); pos = self->Pos();
} }
AActor *drop = Spawn<APhosphorousFire> (pos.X, pos.Y, self->Z() + 4., ALLOW_REPLACE); AActor *drop = Spawn<APhosphorousFire> (DVector3(pos, self->Z() + 4.), ALLOW_REPLACE);
if (drop != NULL) if (drop != NULL)
{ {
drop->Vel.X = self->Vel.X + pr_phburn.Random2 (7); drop->Vel.X = self->Vel.X + pr_phburn.Random2 (7);

View file

@ -3462,7 +3462,7 @@ void DLevelScript::ReplaceTextures (int fromnamei, int tonamei, int flags)
} }
} }
int DLevelScript::DoSpawn (int type, fixed_t x, fixed_t y, fixed_t z, int tid, int angle, bool force) int DLevelScript::DoSpawn (int type, const DVector3 &pos, int tid, DAngle angle, bool force)
{ {
PClassActor *info = PClass::FindActor(FBehavior::StaticLookupString (type)); PClassActor *info = PClass::FindActor(FBehavior::StaticLookupString (type));
AActor *actor = NULL; AActor *actor = NULL;
@ -3478,14 +3478,14 @@ int DLevelScript::DoSpawn (int type, fixed_t x, fixed_t y, fixed_t z, int tid, i
return 0; return 0;
} }
actor = Spawn (info, x, y, z, ALLOW_REPLACE); actor = Spawn (info, pos, ALLOW_REPLACE);
if (actor != NULL) if (actor != NULL)
{ {
ActorFlags2 oldFlags2 = actor->flags2; ActorFlags2 oldFlags2 = actor->flags2;
actor->flags2 |= MF2_PASSMOBJ; actor->flags2 |= MF2_PASSMOBJ;
if (force || P_TestMobjLocation (actor)) if (force || P_TestMobjLocation (actor))
{ {
actor->Angles.Yaw = angle * (360. / 256); actor->Angles.Yaw = angle;
actor->tid = tid; actor->tid = tid;
actor->AddToHash (); actor->AddToHash ();
if (actor->flags & MF_SPECIAL) if (actor->flags & MF_SPECIAL)
@ -3506,6 +3506,12 @@ int DLevelScript::DoSpawn (int type, fixed_t x, fixed_t y, fixed_t z, int tid, i
return spawncount; return spawncount;
} }
int DLevelScript::DoSpawn(int type, int x, int y, int z, int tid, int angle, bool force)
{
return DoSpawn(type, DVector3(ACSToDouble(x), ACSToDouble(y), ACSToDouble(z)), tid, angle * (360. / 256), force);
}
int DLevelScript::DoSpawnSpot (int type, int spot, int tid, int angle, bool force) int DLevelScript::DoSpawnSpot (int type, int spot, int tid, int angle, bool force)
{ {
int spawned = 0; int spawned = 0;
@ -3517,12 +3523,12 @@ int DLevelScript::DoSpawnSpot (int type, int spot, int tid, int angle, bool forc
while ( (aspot = iterator.Next ()) ) while ( (aspot = iterator.Next ()) )
{ {
spawned += DoSpawn (type, aspot->_f_X(), aspot->_f_Y(), aspot->_f_Z(), tid, angle, force); spawned += DoSpawn (type, aspot->Pos(), tid, angle * (360. / 256), force);
} }
} }
else if (activator != NULL) else if (activator != NULL)
{ {
spawned += DoSpawn (type, activator->_f_X(), activator->_f_Y(), activator->_f_Z(), tid, angle, force); spawned += DoSpawn (type, activator->Pos(), tid, angle * (360. / 256), force);
} }
return spawned; return spawned;
} }
@ -3538,12 +3544,12 @@ int DLevelScript::DoSpawnSpotFacing (int type, int spot, int tid, bool force)
while ( (aspot = iterator.Next ()) ) while ( (aspot = iterator.Next ()) )
{ {
spawned += DoSpawn (type, aspot->_f_X(), aspot->_f_Y(), aspot->_f_Z(), tid, aspot->_f_angle() >> 24, force); spawned += DoSpawn (type, aspot->Pos(), tid, aspot->Angles.Yaw, force);
} }
} }
else if (activator != NULL) else if (activator != NULL)
{ {
spawned += DoSpawn (type, activator->_f_X(), activator->_f_Y(), activator->_f_Z(), tid, activator->_f_angle() >> 24, force); spawned += DoSpawn (type, activator->Pos(), tid, activator->Angles.Yaw, force);
} }
return spawned; return spawned;
} }

View file

@ -907,7 +907,8 @@ protected:
static int CountPlayers (); static int CountPlayers ();
static void SetLineTexture (int lineid, int side, int position, int name); static void SetLineTexture (int lineid, int side, int position, int name);
static void ReplaceTextures (int fromname, int toname, int flags); static void ReplaceTextures (int fromname, int toname, int flags);
static int DoSpawn (int type, fixed_t x, fixed_t y, fixed_t z, int tid, int angle, bool force); static int DoSpawn (int type, const DVector3 &pos, int tid, DAngle angle, bool force);
static int DoSpawn(int type, int x, int y, int z, int tid, int angle, bool force);
static bool DoCheckActorTexture(int tid, AActor *activator, int string, bool floor); static bool DoCheckActorTexture(int tid, AActor *activator, int string, bool floor);
int DoSpawnSpot (int type, int spot, int tid, int angle, bool forced); int DoSpawnSpot (int type, int spot, int tid, int angle, bool forced);
int DoSpawnSpotFacing (int type, int spot, int tid, bool forced); int DoSpawnSpotFacing (int type, int spot, int tid, bool forced);

View file

@ -862,9 +862,7 @@ void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end,
if (rnd & 4) if (rnd & 4)
diff.Z = clamp<double>(diff.Z + ((rnd & 32) ? 1 : -1), -maxdiff, maxdiff); diff.Z = clamp<double>(diff.Z + ((rnd & 32) ? 1 : -1), -maxdiff, maxdiff);
} }
DVector3 postmp = pos + diff; AActor *thing = Spawn (spawnclass, pos + diff, ALLOW_REPLACE);
AActor *thing = Spawn (spawnclass, FLOAT2FIXED(postmp.X), FLOAT2FIXED(postmp.Y), FLOAT2FIXED(postmp.Z), ALLOW_REPLACE);
if (thing) if (thing)
thing->Angles.Yaw = ANGLE2DBL(angle); thing->Angles.Yaw = ANGLE2DBL(angle);
pos += trail_step; pos += trail_step;

View file

@ -3161,9 +3161,8 @@ AInventory *P_DropItem (AActor *source, PClassActor *type, int dropamount, int c
if (type != NULL && pr_dropitem() <= chance) if (type != NULL && pr_dropitem() <= chance)
{ {
AActor *mo; AActor *mo;
fixed_t spawnz; double spawnz = 0;
spawnz = source->_f_Z();
if (!(i_compatflags & COMPATF_NOTOSSDROPS)) if (!(i_compatflags & COMPATF_NOTOSSDROPS))
{ {
int style = sv_dropstyle; int style = sv_dropstyle;
@ -3173,14 +3172,14 @@ AInventory *P_DropItem (AActor *source, PClassActor *type, int dropamount, int c
} }
if (style == 2) if (style == 2)
{ {
spawnz += 24*FRACUNIT; spawnz = 24*FRACUNIT;
} }
else else
{ {
spawnz += source->_f_height() / 2; spawnz = source->Height / 2;
} }
} }
mo = Spawn(type, source->_f_X(), source->_f_Y(), spawnz, ALLOW_REPLACE); mo = Spawn(type, source->PosPlusZ(spawnz), ALLOW_REPLACE);
if (mo != NULL) if (mo != NULL)
{ {
mo->flags |= MF_DROPPED; mo->flags |= MF_DROPPED;

View file

@ -3268,19 +3268,23 @@ FUNC(LS_GlassBreak)
{ {
if (!arg0) if (!arg0)
{ // Break some glass { // Break some glass
fixed_t x, y;
AActor *glass; AActor *glass;
x = ln->v1->x + ln->dx/2; DVector2 linemid((ln->v1->fX() + ln->v2->fX()) / 2, (ln->v1->fY() + ln->v2->fY()) / 2);
y = ln->v1->y + ln->dy/2;
// remove dependence on sector size and always spawn 2 map units in front of the line.
DVector2 normal(ln->Delta().Y, -ln->Delta().X);
linemid += normal.Unit() * 2;
/* old code:
x += (ln->frontsector->centerspot.x - x) / 5; x += (ln->frontsector->centerspot.x - x) / 5;
y += (ln->frontsector->centerspot.y - y) / 5; y += (ln->frontsector->centerspot.y - y) / 5;
*/
for (int i = 0; i < 7; ++i) for (int i = 0; i < 7; ++i)
{ {
glass = Spawn("GlassJunk", x, y, ONFLOORZ, ALLOW_REPLACE); glass = Spawn("GlassJunk", DVector3(linemid, ONFLOORZ), ALLOW_REPLACE);
glass->_f_AddZ(24 * FRACUNIT); glass->AddZ(24.);
glass->SetState (glass->SpawnState + (pr_glass() % glass->health)); glass->SetState (glass->SpawnState + (pr_glass() % glass->health));
glass->Angles.Yaw = pr_glass() * (360 / 256.); glass->Angles.Yaw = pr_glass() * (360 / 256.);

View file

@ -23,10 +23,13 @@
#ifndef __P_LOCAL__ #ifndef __P_LOCAL__
#define __P_LOCAL__ #define __P_LOCAL__
#include <float.h>
#include "doomtype.h" #include "doomtype.h"
#include "tables.h" #include "tables.h"
#include "vectors.h" #include "vectors.h"
const double NO_VALUE = FLT_MAX;
class player_t; class player_t;
class AActor; class AActor;
struct FPlayerStart; struct FPlayerStart;
@ -301,6 +304,10 @@ inline bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const sec
{ {
return P_TryMove(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), dropoff, onfloor); return P_TryMove(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), dropoff, onfloor);
} }
inline bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const secplane_t * onfloor, FCheckPosition &tm, bool missileCheck = false)
{
return P_TryMove(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), dropoff, onfloor, tm, missileCheck);
}
bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y); bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y);
void P_ApplyTorque(AActor *mo); void P_ApplyTorque(AActor *mo);
bool P_TeleportMove (AActor* thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag, bool modifyactor = true); // [RH] Added z and telefrag parameters bool P_TeleportMove (AActor* thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag, bool modifyactor = true); // [RH] Added z and telefrag parameters

View file

@ -4749,7 +4749,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i
// used as damage inflictor // used as damage inflictor
AActor *thepuff = NULL; AActor *thepuff = NULL;
if (puffclass != NULL) thepuff = Spawn(puffclass, source->_f_Pos(), ALLOW_REPLACE); if (puffclass != NULL) thepuff = Spawn(puffclass, source->Pos(), ALLOW_REPLACE);
for (i = 0; i < rail_data.RailHits.Size(); i++) for (i = 0; i < rail_data.RailHits.Size(); i++)
{ {
@ -5636,7 +5636,7 @@ void P_DoCrunch(AActor *thing, FChangePosition *cpos)
{ {
AActor *mo; AActor *mo;
mo = Spawn(bloodcls, thing->PosPlusZ(thing->_f_height() / 2), ALLOW_REPLACE); mo = Spawn(bloodcls, thing->PosPlusZ(thing->Height / 2), ALLOW_REPLACE);
mo->Vel.X = pr_crunch.Random2() / 16.; mo->Vel.X = pr_crunch.Random2() / 16.;
mo->Vel.Y = pr_crunch.Random2() / 16.; mo->Vel.Y = pr_crunch.Random2() / 16.;

View file

@ -838,7 +838,7 @@ AInventory *AActor::DropInventory (AInventory *item)
{ {
return NULL; return NULL;
} }
drop->SetOrigin(PosPlusZ(10*FRACUNIT), false); drop->SetOrigin(PosPlusZ(10.), false);
drop->Angles.Yaw = Angles.Yaw; drop->Angles.Yaw = Angles.Yaw;
drop->VelFromAngle(5.); drop->VelFromAngle(5.);
drop->Vel.Z = 1.; drop->Vel.Z = 1.;
@ -2754,7 +2754,7 @@ void P_NightmareRespawn (AActor *mobj)
z = ONFLOORZ; z = ONFLOORZ;
// spawn it // spawn it
mo = AActor::StaticSpawn(mobj->GetClass(), mobj->SpawnPoint.X, mobj->SpawnPoint.Y, z, NO_REPLACE, true); mo = AActor::StaticSpawn(mobj->GetClass(), DVector3(mobj->SpawnPoint.X, mobj->SpawnPoint.Y, z), NO_REPLACE, true);
if (z == ONFLOORZ) if (z == ONFLOORZ)
{ {
@ -2803,7 +2803,7 @@ void P_NightmareRespawn (AActor *mobj)
return; // no respawn return; // no respawn
} }
z = mo->_f_Z(); z = mo->Z();
// inherit attributes from deceased one // inherit attributes from deceased one
mo->SpawnPoint = mobj->SpawnPoint; mo->SpawnPoint = mobj->SpawnPoint;
@ -2824,7 +2824,7 @@ void P_NightmareRespawn (AActor *mobj)
P_SpawnTeleportFog(mobj, mobj->PosPlusZ(TELEFOGHEIGHT), true, true); P_SpawnTeleportFog(mobj, mobj->PosPlusZ(TELEFOGHEIGHT), true, true);
// spawn a teleport fog at the new spot // spawn a teleport fog at the new spot
P_SpawnTeleportFog(mobj, mobj->SpawnPoint.X, mobj->SpawnPoint.Y, z + TELEFOGHEIGHT, false, true); P_SpawnTeleportFog(mobj, DVector3(mobj->SpawnPoint, z + TELEFOGHEIGHT), false, true);
// remove the old monster // remove the old monster
mobj->Destroy (); mobj->Destroy ();
@ -3441,7 +3441,7 @@ void AActor::Tick ()
{ {
// add some smoke behind the rocket // add some smoke behind the rocket
smokecounter = 0; smokecounter = 0;
AActor *th = Spawn("RocketSmokeTrail", Vec3Offset(-_f_velx(), -_f_vely(), -_f_velz()), ALLOW_REPLACE); AActor *th = Spawn("RocketSmokeTrail", Vec3Offset(-Vel), ALLOW_REPLACE);
if (th) if (th)
{ {
th->tics -= pr_rockettrail()&3; th->tics -= pr_rockettrail()&3;
@ -4128,12 +4128,8 @@ bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash)
// //
//========================================================================== //==========================================================================
AActor *AActor::StaticSpawn (PClassActor *type, fixed_t _ix, fixed_t _iy, fixed_t _iz, replace_t allowreplacement, bool SpawningMapThing) AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t allowreplacement, bool SpawningMapThing)
{ {
double ix = FIXED2DBL(_ix);
double iy = FIXED2DBL(_iy);
double iz = FIXED2DBL(_iz);
if (type == NULL) if (type == NULL)
{ {
I_Error ("Tried to spawn a class-less actor\n"); I_Error ("Tried to spawn a class-less actor\n");
@ -4159,7 +4155,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t _ix, fixed_t _iy, fixed_
actor->Conversation = NULL; actor->Conversation = NULL;
} }
actor->SetXYZ(ix, iy, iz); actor->SetXYZ(pos);
actor->picnum.SetInvalid(); actor->picnum.SetInvalid();
actor->health = actor->SpawnHealth(); actor->health = actor->SpawnHealth();
@ -4196,17 +4192,17 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t _ix, fixed_t _iy, fixed_
actor->LinkToWorld (SpawningMapThing); actor->LinkToWorld (SpawningMapThing);
actor->ClearInterpolation(); actor->ClearInterpolation();
actor->floorz = actor->Sector->floorplane.ZatPoint (ix, iy); actor->floorz = actor->Sector->floorplane.ZatPoint(pos);
actor->dropoffz = FLOAT2FIXED(actor->floorz); // killough 11/98: for tracking dropoffs actor->dropoffz = FLOAT2FIXED(actor->floorz); // killough 11/98: for tracking dropoffs
actor->ceilingz = actor->Sector->ceilingplane.ZatPoint (ix, iy); actor->ceilingz = actor->Sector->ceilingplane.ZatPoint(pos);
// The z-coordinate needs to be set once before calling P_FindFloorCeiling // The z-coordinate needs to be set once before calling P_FindFloorCeiling
// For FLOATRANDZ just use the floor here. // For FLOATRANDZ just use the floor here.
if (iz == ONFLOORZ || iz == FLOATRANDZ) if (pos.Z == ONFLOORZ || pos.Z == FLOATRANDZ)
{ {
actor->SetZ(actor->floorz); actor->SetZ(actor->floorz);
} }
else if (iz == ONCEILINGZ) else if (pos.Z == ONCEILINGZ)
{ {
actor->SetZ(actor->ceilingz - actor->Height); actor->SetZ(actor->ceilingz - actor->Height);
} }
@ -4242,18 +4238,19 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t _ix, fixed_t _iy, fixed_
actor->ceilingsector = actor->Sector; actor->ceilingsector = actor->Sector;
} }
actor->SpawnPoint.X = ix; actor->SpawnPoint.X = pos.X;
actor->SpawnPoint.Y = iy; actor->SpawnPoint.Y = pos.Y;
// do not copy Z!
if (iz == ONFLOORZ) if (pos.Z == ONFLOORZ)
{ {
actor->SetZ(actor->floorz); actor->SetZ(actor->floorz);
} }
else if (iz == ONCEILINGZ) else if (pos.Z == ONCEILINGZ)
{ {
actor->SetZ(actor->ceilingz - actor->Height); actor->SetZ(actor->ceilingz - actor->Height);
} }
else if (iz == FLOATRANDZ) else if (pos.Z == FLOATRANDZ)
{ {
double space = actor->ceilingz - actor->Height - actor->floorz; double space = actor->ceilingz - actor->Height - actor->floorz;
if (space > 48) if (space > 48)
@ -4280,7 +4277,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t _ix, fixed_t _iy, fixed_
{ {
actor->Floorclip = 0; actor->Floorclip = 0;
} }
actor->UpdateWaterLevel (actor->_f_Z(), false); actor->UpdateWaterLevel (actor->Z(), false);
if (!SpawningMapThing) if (!SpawningMapThing)
{ {
actor->BeginPlay (); actor->BeginPlay ();
@ -4311,20 +4308,10 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t _ix, fixed_t _iy, fixed_
return actor; return actor;
} }
AActor *Spawn (const char *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement) PClassActor *ClassForSpawn(FName classname)
{ {
FName classname(type, true); PClass *cls = PClass::FindClass(classname);
if (classname == NAME_None) if (cls == NULL)
{
I_Error("Attempt to spawn actor of unknown type '%s'\n", type);
}
return Spawn(classname, x, y, z, allowreplacement);
}
AActor *Spawn (FName classname, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement)
{
const PClass *cls = PClass::FindClass(classname);
if (cls == NULL)
{ {
I_Error("Attempt to spawn actor of unknown type '%s'\n", classname.GetChars()); I_Error("Attempt to spawn actor of unknown type '%s'\n", classname.GetChars());
} }
@ -4332,7 +4319,7 @@ AActor *Spawn (FName classname, fixed_t x, fixed_t y, fixed_t z, replace_t allow
{ {
I_Error("Attempt to spawn non-actor of type '%s'\n", classname.GetChars()); I_Error("Attempt to spawn non-actor of type '%s'\n", classname.GetChars());
} }
return AActor::StaticSpawn (const_cast<PClassActor *>(static_cast<const PClassActor *>(cls)), x, y, z, allowreplacement); return static_cast<PClassActor*>(cls);
} }
void AActor::LevelSpawned () void AActor::LevelSpawned ()
@ -4571,7 +4558,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
player_t *p; player_t *p;
APlayerPawn *mobj, *oldactor; APlayerPawn *mobj, *oldactor;
BYTE state; BYTE state;
fixed_t spawn_x, spawn_y, spawn_z; DVector3 spawn;
DAngle SpawnAngle; DAngle SpawnAngle;
if (mthing == NULL) if (mthing == NULL)
@ -4627,16 +4614,13 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
( NULL != p->attacker ) && // don't respawn on damaging floors ( NULL != p->attacker ) && // don't respawn on damaging floors
( p->mo->Sector->damageamount < TELEFRAG_DAMAGE )) // this really should be a bit smarter... ( p->mo->Sector->damageamount < TELEFRAG_DAMAGE )) // this really should be a bit smarter...
{ {
spawn_x = p->mo->_f_X(); spawn = p->mo->Pos();
spawn_y = p->mo->_f_Y();
spawn_z = p->mo->_f_Z();
SpawnAngle = p->mo->Angles.Yaw; SpawnAngle = p->mo->Angles.Yaw;
} }
else else
{ {
spawn_x = mthing->_f_X(); spawn.X = mthing->pos.X;
spawn_y = mthing->_f_Y(); spawn.Y = mthing->pos.Y;
// Allow full angular precision // Allow full angular precision
SpawnAngle = (double)mthing->angle; SpawnAngle = (double)mthing->angle;
@ -4646,21 +4630,21 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
} }
if (GetDefaultByType(p->cls)->flags & MF_SPAWNCEILING) if (GetDefaultByType(p->cls)->flags & MF_SPAWNCEILING)
spawn_z = ONCEILINGZ; spawn.Z = ONCEILINGZ;
else if (GetDefaultByType(p->cls)->flags2 & MF2_SPAWNFLOAT) else if (GetDefaultByType(p->cls)->flags2 & MF2_SPAWNFLOAT)
spawn_z = FLOATRANDZ; spawn.Z = FLOATRANDZ;
else else
spawn_z = ONFLOORZ; spawn.Z = ONFLOORZ;
} }
mobj = static_cast<APlayerPawn *> mobj = static_cast<APlayerPawn *>
(Spawn (p->cls, spawn_x, spawn_y, spawn_z, NO_REPLACE)); (Spawn (p->cls, spawn, NO_REPLACE));
if (level.flags & LEVEL_USEPLAYERSTARTZ) if (level.flags & LEVEL_USEPLAYERSTARTZ)
{ {
if (spawn_z == ONFLOORZ) if (spawn.Z == ONFLOORZ)
mobj->AddZ(mthing->pos.Z); mobj->AddZ(mthing->pos.Z);
else if (spawn_z == ONCEILINGZ) else if (spawn.Z == ONCEILINGZ)
mobj->AddZ(-mthing->pos.Z); mobj->AddZ(-mthing->pos.Z);
P_FindFloorCeiling(mobj, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT); P_FindFloorCeiling(mobj, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT);
} }
@ -4781,7 +4765,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
if (multiplayer) if (multiplayer)
{ {
Spawn ("TeleportFog", mobj->Vec3Angle(20, mobj->Angles.Yaw, TELEFOGHEIGHT), ALLOW_REPLACE); Spawn ("TeleportFog", mobj->Vec3Angle(20., mobj->Angles.Yaw, TELEFOGHEIGHT), ALLOW_REPLACE);
} }
// "Fix" for one of the starts on exec.wad MAP01: If you start inside the ceiling, // "Fix" for one of the starts on exec.wad MAP01: If you start inside the ceiling,
@ -5115,7 +5099,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
else else
z = ONFLOORZ; z = ONFLOORZ;
mobj = AActor::StaticSpawn (i, x, y, z, NO_REPLACE, true); mobj = AActor::StaticSpawn (i, DVector3(FIXED2DBL(mthing->x), FIXED2DBL(mthing->y), z), NO_REPLACE, true);
if (z == ONFLOORZ) if (z == ONFLOORZ)
{ {
@ -5222,7 +5206,8 @@ AActor *P_SpawnPuff (AActor *source, PClassActor *pufftype, fixed_t x, fixed_t y
if (!(flags & PF_NORANDOMZ)) if (!(flags & PF_NORANDOMZ))
z += pr_spawnpuff.Random2 () << 10; z += pr_spawnpuff.Random2 () << 10;
puff = Spawn (pufftype, x, y, z, ALLOW_REPLACE); DVector3 pos(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z));
puff = Spawn (pufftype, pos, ALLOW_REPLACE);
if (puff == NULL) return NULL; if (puff == NULL) return NULL;
if ((puff->flags4 & MF4_RANDOMIZE) && puff->tics > 0) if ((puff->flags4 & MF4_RANDOMIZE) && puff->tics > 0)
@ -5296,6 +5281,7 @@ AActor *P_SpawnPuff (AActor *source, PClassActor *pufftype, fixed_t x, fixed_t y
void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AActor *originator) void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AActor *originator)
{ {
DVector3 pos(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z));
AActor *th; AActor *th;
PalEntry bloodcolor = originator->GetBloodColor(); PalEntry bloodcolor = originator->GetBloodColor();
PClassActor *bloodcls = originator->GetBloodType(); PClassActor *bloodcls = originator->GetBloodType();
@ -5308,7 +5294,7 @@ void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AAc
if (bloodcls != NULL) if (bloodcls != NULL)
{ {
z += pr_spawnblood.Random2 () << 10; z += pr_spawnblood.Random2 () << 10;
th = Spawn (bloodcls, x, y, z, NO_REPLACE); // GetBloodType already performed the replacement th = Spawn (bloodcls, pos, NO_REPLACE); // GetBloodType already performed the replacement
th->Vel.Z = 2; th->Vel.Z = 2;
th->Angles.Yaw = ANGLE2DBL(dir); th->Angles.Yaw = ANGLE2DBL(dir);
// [NG] Applying PUFFGETSOWNER to the blood will make it target the owner // [NG] Applying PUFFGETSOWNER to the blood will make it target the owner
@ -5389,8 +5375,9 @@ void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AAc
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void P_BloodSplatter (fixedvec3 pos, AActor *originator) void P_BloodSplatter (fixedvec3 _pos, AActor *originator)
{ {
DVector3 pos(FIXED2DBL(_pos.x), FIXED2DBL(_pos.y), FIXED2DBL(_pos.z));
PalEntry bloodcolor = originator->GetBloodColor(); PalEntry bloodcolor = originator->GetBloodColor();
PClassActor *bloodcls = originator->GetBloodType(1); PClassActor *bloodcls = originator->GetBloodType(1);
@ -5419,7 +5406,7 @@ void P_BloodSplatter (fixedvec3 pos, AActor *originator)
} }
if (bloodtype >= 1) if (bloodtype >= 1)
{ {
P_DrawSplash2 (40, pos.x, pos.y, pos.z, 0u - originator->__f_AngleTo(pos), 2, bloodcolor); //P_DrawSplash2 (40, pos.X, pos.Y, pos.Z, -originator->AngleTo(pos), 2, bloodcolor);
} }
} }
@ -5429,8 +5416,9 @@ void P_BloodSplatter (fixedvec3 pos, AActor *originator)
// //
//=========================================================================== //===========================================================================
void P_BloodSplatter2 (fixedvec3 pos, AActor *originator) void P_BloodSplatter2 (fixedvec3 _pos, AActor *originator)
{ {
DVector3 pos(FIXED2DBL(_pos.x), FIXED2DBL(_pos.y), FIXED2DBL(_pos.z));
PalEntry bloodcolor = originator->GetBloodColor(); PalEntry bloodcolor = originator->GetBloodColor();
PClassActor *bloodcls = originator->GetBloodType(2); PClassActor *bloodcls = originator->GetBloodType(2);
@ -5443,8 +5431,8 @@ void P_BloodSplatter2 (fixedvec3 pos, AActor *originator)
{ {
AActor *mo; AActor *mo;
pos.x += ((pr_splat()-128)<<11); pos.X += (pr_splat()-128) / 32.;
pos.y += ((pr_splat()-128)<<11); pos.Y += (pr_splat()-128) / 32.;
mo = Spawn (bloodcls, pos, NO_REPLACE); // GetBloodType already performed the replacement mo = Spawn (bloodcls, pos, NO_REPLACE); // GetBloodType already performed the replacement
mo->target = originator; mo->target = originator;
@ -5459,7 +5447,7 @@ void P_BloodSplatter2 (fixedvec3 pos, AActor *originator)
} }
if (bloodtype >= 1) if (bloodtype >= 1)
{ {
P_DrawSplash2 (100, pos.x, pos.y, pos.z, 0u - originator->__f_AngleTo(pos), 2, bloodcolor); //P_DrawSplash2 (100, pos.x, pos.y, pos.z, 0u - originator->__f_AngleTo(pos), 2, bloodcolor);
} }
} }
@ -5474,10 +5462,10 @@ void P_RipperBlood (AActor *mo, AActor *bleeder)
PalEntry bloodcolor = bleeder->GetBloodColor(); PalEntry bloodcolor = bleeder->GetBloodColor();
PClassActor *bloodcls = bleeder->GetBloodType(); PClassActor *bloodcls = bleeder->GetBloodType();
fixed_t xo = (pr_ripperblood.Random2() << 12); double xo = pr_ripperblood.Random2() / 16.;
fixed_t yo = (pr_ripperblood.Random2() << 12); double yo = pr_ripperblood.Random2() / 16.;
fixed_t zo = (pr_ripperblood.Random2() << 12); double zo = pr_ripperblood.Random2() / 16.;
fixedvec3 pos = mo->Vec3Offset(xo, yo, zo); DVector3 pos = mo->Vec3Offset(xo, yo, zo);
int bloodtype = cl_bloodtype; int bloodtype = cl_bloodtype;
@ -5506,7 +5494,7 @@ void P_RipperBlood (AActor *mo, AActor *bleeder)
} }
if (bloodtype >= 1) if (bloodtype >= 1)
{ {
P_DrawSplash2 (28, pos.x, pos.y, pos.z, 0, 0, bloodcolor); //P_DrawSplash2 (28, pos.X, pos.Y, pos.Z, 0, 0, bloodcolor);
} }
} }
@ -5562,6 +5550,7 @@ bool P_HitWater (AActor * thing, sector_t * sec, fixed_t x, fixed_t y, fixed_t z
if (z > compare_z) if (z > compare_z)
return false; return false;
} }
DVector3 pos(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z));
#if 0 // needs some rethinking before activation #if 0 // needs some rethinking before activation
@ -5633,14 +5622,14 @@ foundone:
if (smallsplash && splash->SmallSplash) if (smallsplash && splash->SmallSplash)
{ {
mo = Spawn (splash->SmallSplash, x, y, z, ALLOW_REPLACE); mo = Spawn (splash->SmallSplash, pos, ALLOW_REPLACE);
if (mo) mo->Floorclip += FIXED2DBL(splash->SmallSplashClip); if (mo) mo->Floorclip += FIXED2DBL(splash->SmallSplashClip);
} }
else else
{ {
if (splash->SplashChunk) if (splash->SplashChunk)
{ {
mo = Spawn (splash->SplashChunk, x, y, z, ALLOW_REPLACE); mo = Spawn (splash->SplashChunk, pos, ALLOW_REPLACE);
mo->target = thing; mo->target = thing;
if (splash->ChunkXVelShift != 255) if (splash->ChunkXVelShift != 255)
{ {
@ -5654,7 +5643,7 @@ foundone:
} }
if (splash->SplashBase) if (splash->SplashBase)
{ {
mo = Spawn (splash->SplashBase, x, y, z, ALLOW_REPLACE); mo = Spawn (splash->SplashBase, pos, ALLOW_REPLACE);
} }
if (thing->player && !splash->NoAlert && alert) if (thing->player && !splash->NoAlert && alert)
{ {
@ -5928,7 +5917,8 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z,
z -= source->_f_floorclip(); z -= source->_f_floorclip();
} }
AActor *th = Spawn (type, x, y, z, ALLOW_REPLACE); DVector3 pos(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z));
AActor *th = Spawn (type, pos, ALLOW_REPLACE);
P_PlaySpawnSound(th, source); P_PlaySpawnSound(th, source);
@ -5988,7 +5978,7 @@ AActor *P_OldSpawnMissile(AActor *source, AActor *owner, AActor *dest, PClassAct
{ {
return NULL; return NULL;
} }
AActor *th = Spawn (type, source->PosPlusZ(4*8*FRACUNIT), ALLOW_REPLACE); AActor *th = Spawn (type, source->PosPlusZ(32.), ALLOW_REPLACE);
P_PlaySpawnSound(th, source); P_PlaySpawnSound(th, source);
th->target = owner; // record missile's originator th->target = owner; // record missile's originator
@ -6094,7 +6084,7 @@ AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z,
z -= source->_f_floorclip(); z -= source->_f_floorclip();
} }
mo = Spawn (type, source->_f_X(), source->_f_Y(), z, ALLOW_REPLACE); mo = Spawn (type, source->PosAtZ(FIXED2FLOAT(z)), ALLOW_REPLACE);
P_PlaySpawnSound(mo, source); P_PlaySpawnSound(mo, source);
if (owner == NULL) owner = source; if (owner == NULL) owner = source;

View file

@ -3609,7 +3609,7 @@ void P_SetupLevel (const char *lumpname, int position)
translationtables[TRANSLATION_LevelScripted].Clear(); translationtables[TRANSLATION_LevelScripted].Clear();
// Initial height of PointOfView will be set by player think. // Initial height of PointOfView will be set by player think.
players[consoleplayer].viewz = -FLT_MAX; players[consoleplayer].viewz = NO_VALUE;
// Make sure all sounds are stopped before Z_FreeTags. // Make sure all sounds are stopped before Z_FreeTags.
S_Start (); S_Start ();

View file

@ -1036,22 +1036,19 @@ void P_SpawnPortal(line_t *line, int sectortag, int plane, int alpha, int linked
lines[i].args[3] == 1) lines[i].args[3] == 1)
{ {
// beware of overflows. // beware of overflows.
fixed_t x1 = fixed_t((SQWORD(line->v1->x) + SQWORD(line->v2->x)) >> 1); DVector3 pos1((line->v1->fX() + line->v2->fX()) / 2, (line->v1->fY() + line->v2->fY()) / 2, 0);
fixed_t y1 = fixed_t((SQWORD(line->v1->y) + SQWORD(line->v2->y)) >> 1); DVector3 pos2((lines[i].v1->fX() + lines[i].v2->fX()) / 2, (lines[i].v1->fY() + lines[i].v2->fY()) / 2, 0);
fixed_t x2 = fixed_t((SQWORD(lines[i].v1->x) + SQWORD(lines[i].v2->x)) >> 1); double z = linked ? line->frontsector->GetPlaneTexZF(plane) : 0; // the map's sector height defines the portal plane for linked portals
fixed_t y2 = fixed_t((SQWORD(lines[i].v1->y) + SQWORD(lines[i].v2->y)) >> 1);
fixed_t z = linked ? line->frontsector->planes[plane].TexZ : 0; // the map's sector height defines the portal plane for linked portals
fixed_t alpha = Scale (lines[i].args[4], OPAQUE, 255); fixed_t alpha = Scale (lines[i].args[4], OPAQUE, 255);
AStackPoint *anchor = Spawn<AStackPoint>(x1, y1, 0, NO_REPLACE); AStackPoint *anchor = Spawn<AStackPoint>(pos1, NO_REPLACE);
AStackPoint *reference = Spawn<AStackPoint>(x2, y2, 0, NO_REPLACE); AStackPoint *reference = Spawn<AStackPoint>(pos2, NO_REPLACE);
reference->special1 = linked ? SKYBOX_LINKEDPORTAL : SKYBOX_PORTAL; reference->special1 = linked ? SKYBOX_LINKEDPORTAL : SKYBOX_PORTAL;
anchor->special1 = SKYBOX_ANCHOR; anchor->special1 = SKYBOX_ANCHOR;
// store the portal displacement in the unused scaleX/Y members of the portal reference actor. // store the portal displacement in the unused scaleX/Y members of the portal reference actor.
anchor->Scale.X = -(reference->Scale.X = FIXED2DBL(x2 - x1)); anchor->Scale = -(reference->Scale = pos2 - pos1);
anchor->Scale.Y = -(reference->Scale.Y = FIXED2DBL(y2 - y1)); anchor->specialf1 = reference->specialf1 = z;
anchor->specialf1 = reference->specialf1 = FIXED2FLOAT(z);
reference->Mate = anchor; reference->Mate = anchor;
anchor->Mate = reference; anchor->Mate = reference;

View file

@ -924,19 +924,18 @@ enum
TELF_KEEPHEIGHT = 16, TELF_KEEPHEIGHT = 16,
}; };
void P_SpawnTeleportFog(AActor *mobj, fixed_t x, fixed_t y, fixed_t z, bool beforeTele = true, bool setTarget = false); //Spawns teleport fog. Pass the actor to pluck TeleFogFromType and TeleFogToType. 'from' determines if this is the fog to spawn at the old position (true) or new (false). //Spawns teleport fog. Pass the actor to pluck TeleFogFromType and TeleFogToType. 'from' determines if this is the fog to spawn at the old position (true) or new (false).
inline void P_SpawnTeleportFog(AActor *mobj, const fixedvec3 &pos, bool beforeTele = true, bool setTarget = false) void P_SpawnTeleportFog(AActor *mobj, const DVector3 &pos, bool beforeTele = true, bool setTarget = false);
{
P_SpawnTeleportFog(mobj, pos.x, pos.y, pos.z, beforeTele, setTarget); void P_SpawnTeleportFog(AActor *mobj, fixed_t x, fixed_t y, fixed_t z, bool beforeTele = true, bool setTarget = false) = delete;
} inline void P_SpawnTeleportFog(AActor *mobj, const fixedvec3 &pos, bool beforeTele = true, bool setTarget = false) = delete;
inline void P_SpawnTeleportFog(AActor *mobj, const DVector3 &pos, bool beforeTele = true, bool setTarget = false) inline void P_SpawnTeleportFog(AActor *mobj, double x, double y, double z, bool beforeTele = true, bool setTarget = false) = delete;
{ /*
P_SpawnTeleportFog(mobj, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), beforeTele, setTarget);
}
inline void P_SpawnTeleportFog(AActor *mobj, double x, double y, double z, bool beforeTele = true, bool setTarget = false)
{ {
P_SpawnTeleportFog(mobj, FLOAT2FIXED(x), FLOAT2FIXED(y), FLOAT2FIXED(z), beforeTele, setTarget); P_SpawnTeleportFog(mobj, FLOAT2FIXED(x), FLOAT2FIXED(y), FLOAT2FIXED(z), beforeTele, setTarget);
} }
*/
bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, int flags); // bool useFog, bool sourceFog, bool keepOrientation, bool haltVelocity = true, bool keepHeight = false bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, int flags); // bool useFog, bool sourceFog, bool keepOrientation, bool haltVelocity = true, bool keepHeight = false
inline bool P_Teleport(AActor *thing, const DVector3 &pos, DAngle angle, int flags) inline bool P_Teleport(AActor *thing, const DVector3 &pos, DAngle angle, int flags)
{ {

View file

@ -78,7 +78,7 @@ void ATeleportFog::PostBeginPlay ()
// //
//========================================================================== //==========================================================================
void P_SpawnTeleportFog(AActor *mobj, fixed_t x, fixed_t y, fixed_t z, bool beforeTele, bool setTarget) void P_SpawnTeleportFog(AActor *mobj, const DVector3 &pos, bool beforeTele, bool setTarget)
{ {
AActor *mo; AActor *mo;
if ((beforeTele ? mobj->TeleFogSourceType : mobj->TeleFogDestType) == NULL) if ((beforeTele ? mobj->TeleFogSourceType : mobj->TeleFogDestType) == NULL)
@ -88,7 +88,7 @@ void P_SpawnTeleportFog(AActor *mobj, fixed_t x, fixed_t y, fixed_t z, bool befo
} }
else else
{ {
mo = Spawn((beforeTele ? mobj->TeleFogSourceType : mobj->TeleFogDestType), x, y, z, ALLOW_REPLACE); mo = Spawn((beforeTele ? mobj->TeleFogSourceType : mobj->TeleFogDestType), pos, ALLOW_REPLACE);
} }
if (mo != NULL && setTarget) if (mo != NULL && setTarget)
@ -103,7 +103,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, i
{ {
bool predicting = (thing->player && (thing->player->cheats & CF_PREDICTING)); bool predicting = (thing->player && (thing->player->cheats & CF_PREDICTING));
fixedvec3 old; DVector3 old;
fixed_t aboveFloor; fixed_t aboveFloor;
player_t *player; player_t *player;
sector_t *destsect; sector_t *destsect;
@ -111,7 +111,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, i
fixed_t floorheight, ceilingheight; fixed_t floorheight, ceilingheight;
double missilespeed = 0; double missilespeed = 0;
old = thing->_f_Pos(); old = thing->Pos();
aboveFloor = thing->_f_Z() - thing->_f_floorz(); aboveFloor = thing->_f_Z() - thing->_f_floorz();
destsect = P_PointInSector (x, y); destsect = P_PointInSector (x, y);
// killough 5/12/98: exclude voodoo dolls: // killough 5/12/98: exclude voodoo dolls:
@ -194,7 +194,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, i
double fogDelta = thing->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT; double fogDelta = thing->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT;
DVector2 vector = angle.ToVector(20); DVector2 vector = angle.ToVector(20);
DVector2 fogpos = P_GetOffsetPosition(FIXED2DBL(x), FIXED2DBL(y), vector.X, vector.Y); DVector2 fogpos = P_GetOffsetPosition(FIXED2DBL(x), FIXED2DBL(y), vector.X, vector.Y);
P_SpawnTeleportFog(thing, fogpos.X, fogpos.Y, thing->Z() + fogDelta, false, true); P_SpawnTeleportFog(thing, DVector3(fogpos, thing->Z() + fogDelta), false, true);
} }
if (thing->player) if (thing->player)

View file

@ -125,19 +125,16 @@ bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, i
bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog) bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog)
{ {
fixed_t oldx, oldy, oldz; DVector3 pos(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z));
DVector3 old = source->Pos();
oldx = source->_f_X(); source->SetOrigin (pos, true);
oldy = source->_f_Y();
oldz = source->_f_Z();
source->SetOrigin (x, y, z, true);
if (P_TestMobjLocation (source)) if (P_TestMobjLocation (source))
{ {
if (fog) if (fog)
{ {
P_SpawnTeleportFog(source, x, y, z, false, true); P_SpawnTeleportFog(source, pos, false, true);
P_SpawnTeleportFog(source, oldx, oldy, oldz, true, true); P_SpawnTeleportFog(source, old, true, true);
} }
source->ClearInterpolation(); source->ClearInterpolation();
if (source == players[consoleplayer].camera) if (source == players[consoleplayer].camera)
@ -148,7 +145,7 @@ bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog)
} }
else else
{ {
source->SetOrigin (oldx, oldy, oldz, true); source->SetOrigin (old, true);
return false; return false;
} }
} }
@ -221,7 +218,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam
{ {
do do
{ {
fixed_t z = spot->_f_Z(); double z = spot->Z();
if (defflags3 & MF3_FLOORHUGGER) if (defflags3 & MF3_FLOORHUGGER)
{ {
z = ONFLOORZ; z = ONFLOORZ;
@ -232,9 +229,9 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam
} }
else if (z != ONFLOORZ) else if (z != ONFLOORZ)
{ {
z -= spot->_f_floorclip(); z -= spot->Floorclip;
} }
mobj = Spawn (kind, spot->_f_X(), spot->_f_Y(), z, ALLOW_REPLACE); mobj = Spawn (kind, spot->PosAtZ(z), ALLOW_REPLACE);
if (mobj) if (mobj)
{ {

View file

@ -57,7 +57,7 @@ bool P_CheckTickerPaused ()
ConsoleState == c_down || ConsoleState == c_falling) ConsoleState == c_down || ConsoleState == c_falling)
&& !demoplayback && !demoplayback
&& !demorecording && !demorecording
&& players[consoleplayer].viewz != -FLT_MAX && players[consoleplayer].viewz != NO_VALUE
&& wipegamestate == gamestate) && wipegamestate == gamestate)
{ {
S_PauseSound (!(level.flags2 & LEVEL2_PAUSE_MUSIC_IN_MENUS), false); S_PauseSound (!(level.flags2 & LEVEL2_PAUSE_MUSIC_IN_MENUS), false);

View file

@ -1650,7 +1650,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SkullPop)
} }
self->flags &= ~MF_SOLID; self->flags &= ~MF_SOLID;
mo = (APlayerPawn *)Spawn (spawntype, self->PosPlusZ(48*FRACUNIT), NO_REPLACE); mo = (APlayerPawn *)Spawn (spawntype, self->PosPlusZ(48.), NO_REPLACE);
//mo->target = self; //mo->target = self;
mo->Vel.X = pr_skullpop.Random2() / 128.; mo->Vel.X = pr_skullpop.Random2() / 128.;
mo->Vel.Y = pr_skullpop.Random2() / 128.; mo->Vel.Y = pr_skullpop.Random2() / 128.;

View file

@ -2638,7 +2638,7 @@ CCMD (loopsound)
} }
else else
{ {
AActor *icon = Spawn("SpeakerIcon", players[consoleplayer].mo->PosPlusZ(32*FRACUNIT), ALLOW_REPLACE); AActor *icon = Spawn("SpeakerIcon", players[consoleplayer].mo->PosPlusZ(32.), ALLOW_REPLACE);
if (icon != NULL) if (icon != NULL)
{ {
S_Sound(icon, CHAN_BODY | CHAN_LOOP, id, 1.f, ATTN_IDLE); S_Sound(icon, CHAN_BODY | CHAN_LOOP, id, 1.f, ATTN_IDLE);

View file

@ -616,7 +616,7 @@ static void DoAttack (AActor *self, bool domelee, bool domissile,
// This seemingly senseless code is needed for proper aiming. // This seemingly senseless code is needed for proper aiming.
double add = MissileHeight + FIXED2FLOAT(self->GetBobOffset()) - 32; double add = MissileHeight + FIXED2FLOAT(self->GetBobOffset()) - 32;
self->AddZ(add); self->AddZ(add);
AActor *missile = P_SpawnMissileXYZ (self->PosPlusZ(32*FRACUNIT), self, self->target, MissileType, false); AActor *missile = P_SpawnMissileXYZ (self->PosPlusZ(32.), self, self->target, MissileType, false);
self->AddZ(-add); self->AddZ(-add);
if (missile) if (missile)
@ -1227,7 +1227,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile)
default: default:
// same adjustment as above (in all 3 directions this time) - for better aiming! // same adjustment as above (in all 3 directions this time) - for better aiming!
self->SetXYZ(self->Vec3Offset(x, y, z)); self->SetXYZ(self->Vec3Offset(x, y, z));
missile = P_SpawnMissileXYZ(self->PosPlusZ(32*FRACUNIT), self, ref, ti, false); missile = P_SpawnMissileXYZ(self->PosPlusZ(32.), self, ref, ti, false);
self->SetXYZ(pos); self->SetXYZ(pos);
break; break;
@ -1467,7 +1467,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomComboAttack)
{ {
// This seemingly senseless code is needed for proper aiming. // This seemingly senseless code is needed for proper aiming.
self->_f_AddZ(spawnheight + self->GetBobOffset() - 32*FRACUNIT); self->_f_AddZ(spawnheight + self->GetBobOffset() - 32*FRACUNIT);
AActor *missile = P_SpawnMissileXYZ (self->PosPlusZ(32*FRACUNIT), self, self->target, ti, false); AActor *missile = P_SpawnMissileXYZ (self->PosPlusZ(32.), self, self->target, ti, false);
self->_f_AddZ(-(spawnheight + self->GetBobOffset() - 32*FRACUNIT)); self->_f_AddZ(-(spawnheight + self->GetBobOffset() - 32*FRACUNIT));
if (missile) if (missile)
@ -2378,7 +2378,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem)
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_CLASS_OPT (missile, AActor) { missile = PClass::FindActor("Unknown"); } PARAM_CLASS_OPT (missile, AActor) { missile = PClass::FindActor("Unknown"); }
PARAM_FIXED_OPT (distance) { distance = 0; } PARAM_FIXED_OPT (distance) { distance = 0; }
PARAM_FIXED_OPT (zheight) { zheight = 0; } PARAM_FLOAT_OPT (zheight) { zheight = 0; }
PARAM_BOOL_OPT (useammo) { useammo = true; } PARAM_BOOL_OPT (useammo) { useammo = true; }
PARAM_BOOL_OPT (transfer_translation) { transfer_translation = false; } PARAM_BOOL_OPT (transfer_translation) { transfer_translation = false; }
@ -2414,7 +2414,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem)
} }
} }
AActor *mo = Spawn( missile, self->_f_Vec3Angle(distance, self->_f_angle(), -self->_f_floorclip() + self->GetBobOffset() + zheight), ALLOW_REPLACE); AActor *mo = Spawn( missile, self->Vec3Angle(distance, self->Angles.Yaw, -self->Floorclip + self->GetBobOffset() + zheight), ALLOW_REPLACE);
int flags = (transfer_translation ? SIXF_TRANSFERTRANSLATION : 0) + (useammo ? SIXF_SETMASTER : 0); int flags = (transfer_translation ? SIXF_TRANSFERTRANSLATION : 0) + (useammo ? SIXF_SETMASTER : 0);
ACTION_RETURN_BOOL(InitSpawnedItem(self, mo, flags)); // for an inventory item's use state ACTION_RETURN_BOOL(InitSpawnedItem(self, mo, flags)); // for an inventory item's use state
@ -2431,9 +2431,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_CLASS (missile, AActor); PARAM_CLASS (missile, AActor);
PARAM_FIXED_OPT (xofs) { xofs = 0; } PARAM_FLOAT_OPT (xofs) { xofs = 0; }
PARAM_FIXED_OPT (yofs) { yofs = 0; } PARAM_FLOAT_OPT (yofs) { yofs = 0; }
PARAM_FIXED_OPT (zofs) { zofs = 0; } PARAM_FLOAT_OPT (zofs) { zofs = 0; }
PARAM_FLOAT_OPT (xvel) { xvel = 0; } PARAM_FLOAT_OPT (xvel) { xvel = 0; }
PARAM_FLOAT_OPT (yvel) { yvel = 0; } PARAM_FLOAT_OPT (yvel) { yvel = 0; }
PARAM_FLOAT_OPT (zvel) { zvel = 0; } PARAM_FLOAT_OPT (zvel) { zvel = 0; }
@ -2456,7 +2456,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx)
ACTION_RETURN_BOOL(true); ACTION_RETURN_BOOL(true);
} }
fixedvec2 pos; DVector2 pos;
if (!(flags & SIXF_ABSOLUTEANGLE)) if (!(flags & SIXF_ABSOLUTEANGLE))
{ {
@ -2473,7 +2473,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx)
{ {
// in relative mode negative y values mean 'left' and positive ones mean 'right' // in relative mode negative y values mean 'left' and positive ones mean 'right'
// This is the inverse orientation of the absolute mode! // This is the inverse orientation of the absolute mode!
pos = self->Vec2Offset(fixed_t(xofs * c + yofs * s), fixed_t(xofs * s - yofs*c)); pos = self->Vec2Offset(xofs * c + yofs * s, xofs * s - yofs*c);
} }
if (!(flags & SIXF_ABSOLUTEVELOCITY)) if (!(flags & SIXF_ABSOLUTEVELOCITY))
@ -2484,7 +2484,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx)
xvel = newxvel; xvel = newxvel;
} }
AActor *mo = Spawn(missile, pos.x, pos.y, self->_f_Z() - self->_f_floorclip() + self->GetBobOffset() + zofs, ALLOW_REPLACE); AActor *mo = Spawn(missile, DVector3(pos, self->Z() - self->Floorclip + self->GetBobOffset() + zofs), ALLOW_REPLACE);
bool res = InitSpawnedItem(self, mo, flags); bool res = InitSpawnedItem(self, mo, flags);
if (res) if (res)
{ {
@ -2542,7 +2542,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade)
AActor *bo; AActor *bo;
bo = Spawn(missile, bo = Spawn(missile,
self->PosPlusZ(-self->_f_floorclip() + self->GetBobOffset() + zheight + 35*FRACUNIT + (self->player? FLOAT2FIXED(self->player->crouchoffset) : 0)), self->PosPlusZ(-self->Floorclip + self->GetBobOffset() + zheight + 35 + (self->player? self->player->crouchoffset : 0.)),
ALLOW_REPLACE); ALLOW_REPLACE);
if (bo) if (bo)
{ {
@ -2936,9 +2936,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnDebris)
for (i = 0; i < GetDefaultByType(debris)->health; i++) for (i = 0; i < GetDefaultByType(debris)->health; i++)
{ {
fixed_t xo = ((pr_spawndebris() - 128) << 12); double xo = (pr_spawndebris() - 128) / 16.;
fixed_t yo = ((pr_spawndebris() - 128) << 12); double yo = (pr_spawndebris() - 128) / 16.;
fixed_t zo = (pr_spawndebris()*self->_f_height() / 256 + self->GetBobOffset()); double zo = pr_spawndebris()*self->Height / 256 + self->GetBobOffset();
mo = Spawn(debris, self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE); mo = Spawn(debris, self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
if (mo) if (mo)
{ {
@ -3435,7 +3435,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn)
PARAM_INT_OPT(flags) { flags = RSF_FOG; } PARAM_INT_OPT(flags) { flags = RSF_FOG; }
bool oktorespawn = false; bool oktorespawn = false;
fixedvec3 pos = self->_f_Pos(); DVector3 pos = self->Pos();
self->flags |= MF_SOLID; self->flags |= MF_SOLID;
self->Height = self->GetDefault()->Height; self->Height = self->GetDefault()->Height;
@ -3445,11 +3445,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn)
if (flags & RSF_TELEFRAG) if (flags & RSF_TELEFRAG)
{ {
// [KS] DIE DIE DIE DIE erm *ahem* =) // [KS] DIE DIE DIE DIE erm *ahem* =)
oktorespawn = P_TeleportMove(self, self->_f_Pos(), true, false); oktorespawn = P_TeleportMove(self, self->Pos(), true, false);
} }
else else
{ {
oktorespawn = P_CheckPosition(self, self->_f_X(), self->_f_Y(), true); oktorespawn = P_CheckPosition(self, self->Pos(), true);
} }
if (oktorespawn) if (oktorespawn)
@ -3487,7 +3487,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn)
if (flags & RSF_FOG) if (flags & RSF_FOG)
{ {
P_SpawnTeleportFog(self, pos, true, true); P_SpawnTeleportFog(self, pos, true, true);
P_SpawnTeleportFog(self, self->_f_Pos(), false, true); P_SpawnTeleportFog(self, self->Pos(), false, true);
} }
if (self->CountsAsKill()) if (self->CountsAsKill())
{ {