This commit is contained in:
Christoph Oelckers 2016-06-11 17:15:55 +02:00
commit 9eb18a9e45
24 changed files with 207 additions and 103 deletions

View file

@ -1488,6 +1488,44 @@ FBaseCVar *FindCVarSub (const char *var_name, int namelen)
return var; return var;
} }
FBaseCVar *GetCVar(AActor *activator, const char *cvarname)
{
FBaseCVar *cvar = FindCVar(cvarname, nullptr);
// Either the cvar doesn't exist, or it's for a mod that isn't loaded, so return nullptr.
if (cvar == nullptr || (cvar->GetFlags() & CVAR_IGNORE))
{
return nullptr;
}
else
{
// For userinfo cvars, redirect to GetUserCVar
if (cvar->GetFlags() & CVAR_USERINFO)
{
if (activator == nullptr || activator->player == nullptr)
{
return nullptr;
}
return GetUserCVar(int(activator->player - players), cvarname);
}
return cvar;
}
}
FBaseCVar *GetUserCVar(int playernum, const char *cvarname)
{
if ((unsigned)playernum >= MAXPLAYERS || !playeringame[playernum])
{
return nullptr;
}
FBaseCVar **cvar_p = players[playernum].userinfo.CheckKey(FName(cvarname, true));
FBaseCVar *cvar;
if (cvar_p == nullptr || (cvar = *cvar_p) == nullptr || (cvar->GetFlags() & CVAR_IGNORE))
{
return nullptr;
}
return cvar;
}
//=========================================================================== //===========================================================================
// //
// C_CreateCVar // C_CreateCVar

View file

@ -186,6 +186,10 @@ void C_BackupCVars (void);
FBaseCVar *FindCVar (const char *var_name, FBaseCVar **prev); FBaseCVar *FindCVar (const char *var_name, FBaseCVar **prev);
FBaseCVar *FindCVarSub (const char *var_name, int namelen); FBaseCVar *FindCVarSub (const char *var_name, int namelen);
// Used for ACS and DECORATE.
FBaseCVar *GetCVar(AActor *activator, const char *cvarname);
FBaseCVar *GetUserCVar(int playernum, const char *cvarname);
// Create a new cvar with the specified name and type // Create a new cvar with the specified name and type
FBaseCVar *C_CreateCVar(const char *var_name, ECVarType var_type, DWORD flags); FBaseCVar *C_CreateCVar(const char *var_name, ECVarType var_type, DWORD flags);

View file

@ -3123,21 +3123,28 @@ bool ADehackedPickup::TryPickup (AActor *&toucher)
const char *ADehackedPickup::PickupMessage () const char *ADehackedPickup::PickupMessage ()
{ {
if (RealPickup != nullptr)
return RealPickup->PickupMessage (); return RealPickup->PickupMessage ();
else return "";
} }
bool ADehackedPickup::ShouldStay () bool ADehackedPickup::ShouldStay ()
{ {
if (RealPickup != nullptr)
return RealPickup->ShouldStay (); return RealPickup->ShouldStay ();
else return true;
} }
bool ADehackedPickup::ShouldRespawn () bool ADehackedPickup::ShouldRespawn ()
{ {
if (RealPickup != nullptr)
return RealPickup->ShouldRespawn (); return RealPickup->ShouldRespawn ();
else return false;
} }
void ADehackedPickup::PlayPickupSound (AActor *toucher) void ADehackedPickup::PlayPickupSound (AActor *toucher)
{ {
if (RealPickup != nullptr)
RealPickup->PlayPickupSound (toucher); RealPickup->PlayPickupSound (toucher);
} }
@ -3146,19 +3153,19 @@ void ADehackedPickup::DoPickupSpecial (AActor *toucher)
Super::DoPickupSpecial (toucher); Super::DoPickupSpecial (toucher);
// If the real pickup hasn't joined the toucher's inventory, make sure it // If the real pickup hasn't joined the toucher's inventory, make sure it
// doesn't stick around. // doesn't stick around.
if (RealPickup->Owner != toucher) if (RealPickup != nullptr && RealPickup->Owner != toucher)
{ {
RealPickup->Destroy (); RealPickup->Destroy ();
} }
RealPickup = NULL; RealPickup = nullptr;
} }
void ADehackedPickup::Destroy () void ADehackedPickup::Destroy ()
{ {
if (RealPickup != NULL) if (RealPickup != nullptr)
{ {
RealPickup->Destroy (); RealPickup->Destroy ();
RealPickup = NULL; RealPickup = nullptr;
} }
Super::Destroy (); Super::Destroy ();
} }

View file

@ -60,6 +60,7 @@
// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- // PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
// EXTERNAL DATA DECLARATIONS ---------------------------------------------- // EXTERNAL DATA DECLARATIONS ----------------------------------------------
EXTERN_CVAR(Bool, strictdecorate);
// PUBLIC DATA DEFINITIONS ------------------------------------------------- // PUBLIC DATA DEFINITIONS -------------------------------------------------
@ -3067,7 +3068,8 @@ void PClass::InsertIntoHash ()
if (found != NULL) if (found != NULL)
{ // This type has already been inserted { // This type has already been inserted
// ... but there is no need whatsoever to make it a fatal error! // ... but there is no need whatsoever to make it a fatal error!
Printf (TEXTCOLOR_RED"Tried to register class '%s' more than once.\n", TypeName.GetChars()); if (!strictdecorate) Printf (TEXTCOLOR_RED"Tried to register class '%s' more than once.\n", TypeName.GetChars());
else I_Error("Tried to register class '%s' more than once.\n", TypeName.GetChars());
TypeTable.ReplaceType(this, found, bucket); TypeTable.ReplaceType(this, found, bucket);
} }
else else

View file

@ -287,8 +287,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_GenWizard)
self->SetState (self->FindState(NAME_Death)); self->SetState (self->FindState(NAME_Death));
self->flags &= ~MF_MISSILE; self->flags &= ~MF_MISSILE;
mo->master = self->target; mo->master = self->target;
// Heretic did not offset it by TELEFOGHEIGHT, so I won't either. P_SpawnTeleportFog(self, self->Pos(), false, true);
Spawn<ATeleportFog> (self->Pos(), ALLOW_REPLACE);
} }
} }
return 0; return 0;

View file

@ -17,6 +17,7 @@
#include "farchive.h" #include "farchive.h"
#include "d_player.h" #include "d_player.h"
#include "a_morph.h" #include "a_morph.h"
#include "p_spec.h"
// Include all the other Heretic stuff here to reduce compile time // Include all the other Heretic stuff here to reduce compile time
#include "a_chicken.cpp" #include "a_chicken.cpp"

View file

@ -115,7 +115,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Beacon)
rebel->SetState (rebel->SeeState); rebel->SetState (rebel->SeeState);
rebel->Angles.Yaw = self->Angles.Yaw; rebel->Angles.Yaw = self->Angles.Yaw;
Spawn<ATeleportFog> (rebel->Vec3Angle(20., self->Angles.Yaw, TELEFOGHEIGHT), ALLOW_REPLACE); P_SpawnTeleportFog(rebel, rebel->Vec3Angle(20., self->Angles.Yaw, 0), false, true);
if (--self->health < 0) if (--self->health < 0)
{ {
self->SetState(self->FindState(NAME_Death)); self->SetState(self->FindState(NAME_Death));

View file

@ -3968,6 +3968,7 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value)
case APROP_Friction: case APROP_Friction:
actor->Friction = ACSToDouble(value); actor->Friction = ACSToDouble(value);
break;
case APROP_MaxStepHeight: case APROP_MaxStepHeight:
actor->MaxStepHeight = ACSToDouble(value); actor->MaxStepHeight = ACSToDouble(value);
@ -4656,7 +4657,11 @@ static int DoGetCVar(FBaseCVar *cvar, bool is_string)
{ {
UCVarValue val; UCVarValue val;
if (is_string) if (cvar == nullptr)
{
return 0;
}
else if (is_string)
{ {
val = cvar->GetGenericRep(CVAR_String); val = cvar->GetGenericRep(CVAR_String);
return GlobalACSStrings.AddString(val.String); return GlobalACSStrings.AddString(val.String);
@ -4673,44 +4678,6 @@ static int DoGetCVar(FBaseCVar *cvar, bool is_string)
} }
} }
static int GetUserCVar(int playernum, const char *cvarname, bool is_string)
{
if ((unsigned)playernum >= MAXPLAYERS || !playeringame[playernum])
{
return 0;
}
FBaseCVar **cvar_p = players[playernum].userinfo.CheckKey(FName(cvarname, true));
FBaseCVar *cvar;
if (cvar_p == NULL || (cvar = *cvar_p) == NULL || (cvar->GetFlags() & CVAR_IGNORE))
{
return 0;
}
return DoGetCVar(cvar, is_string);
}
static int GetCVar(AActor *activator, const char *cvarname, bool is_string)
{
FBaseCVar *cvar = FindCVar(cvarname, NULL);
// Either the cvar doesn't exist, or it's for a mod that isn't loaded, so return 0.
if (cvar == NULL || (cvar->GetFlags() & CVAR_IGNORE))
{
return 0;
}
else
{
// For userinfo cvars, redirect to GetUserCVar
if (cvar->GetFlags() & CVAR_USERINFO)
{
if (activator == NULL || activator->player == NULL)
{
return 0;
}
return GetUserCVar(int(activator->player - players), cvarname, is_string);
}
return DoGetCVar(cvar, is_string);
}
}
static int SetUserCVar(int playernum, const char *cvarname, int value, bool is_string) static int SetUserCVar(int playernum, const char *cvarname, int value, bool is_string)
{ {
if ((unsigned)playernum >= MAXPLAYERS || !playeringame[playernum]) if ((unsigned)playernum >= MAXPLAYERS || !playeringame[playernum])
@ -5395,7 +5362,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args)
case ACSF_GetCVarString: case ACSF_GetCVarString:
if (argCount == 1) if (argCount == 1)
{ {
return GetCVar(activator, FBehavior::StaticLookupString(args[0]), true); return DoGetCVar(GetCVar(activator, FBehavior::StaticLookupString(args[0])), true);
} }
break; break;
@ -5416,14 +5383,14 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args)
case ACSF_GetUserCVar: case ACSF_GetUserCVar:
if (argCount == 2) if (argCount == 2)
{ {
return GetUserCVar(args[0], FBehavior::StaticLookupString(args[1]), false); return DoGetCVar(GetUserCVar(args[0], FBehavior::StaticLookupString(args[1])), false);
} }
break; break;
case ACSF_GetUserCVarString: case ACSF_GetUserCVarString:
if (argCount == 2) if (argCount == 2)
{ {
return GetUserCVar(args[0], FBehavior::StaticLookupString(args[1]), true); return DoGetCVar(GetUserCVar(args[0], FBehavior::StaticLookupString(args[1])), true);
} }
break; break;
@ -6047,7 +6014,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
PalEntry color = args[0]; PalEntry color = args[0];
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; double size = argCount > 3 ? args[3] : 1.;
int x = argCount > 4 ? args[4] : 0; int x = argCount > 4 ? args[4] : 0;
int y = argCount > 5 ? args[5] : 0; int y = argCount > 5 ? args[5] : 0;
int z = argCount > 6 ? args[6] : 0; int z = argCount > 6 ? args[6] : 0;
@ -6059,17 +6026,18 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
int 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;
double endsize = argCount > 15 ? args[15] : -1.;
startalpha = clamp<int>(startalpha, 0, 255); // Clamp to byte startalpha = clamp<int>(startalpha, 0, 255); // Clamp to byte
lifetime = clamp<int>(lifetime, 0, 255); // Clamp to byte lifetime = clamp<int>(lifetime, 0, 255); // Clamp to byte
fadestep = clamp<int>(fadestep, -1, 255); // Clamp to byte inc. -1 (indicating automatic) fadestep = clamp<int>(fadestep, -1, 255); // Clamp to byte inc. -1 (indicating automatic)
size = clamp<int>(size, 0, 65535); // Clamp to word size = fabs(size);
if (lifetime != 0) if (lifetime != 0)
P_SpawnParticle(DVector3(ACSToDouble(x), ACSToDouble(y), ACSToDouble(z)), P_SpawnParticle(DVector3(ACSToDouble(x), ACSToDouble(y), ACSToDouble(z)),
DVector3(ACSToDouble(xvel), ACSToDouble(yvel), ACSToDouble(zvel)), DVector3(ACSToDouble(xvel), ACSToDouble(yvel), ACSToDouble(zvel)),
DVector3(ACSToDouble(accelx), ACSToDouble(accely), ACSToDouble(accelz)), DVector3(ACSToDouble(accelx), ACSToDouble(accely), ACSToDouble(accelz)),
color, fullbright, startalpha/255., lifetime, size, fadestep/255.); color, startalpha/255., lifetime, size, endsize, fadestep/255., fullbright);
} }
break; break;
@ -9130,7 +9098,7 @@ scriptwait:
break; break;
case PCD_GETCVAR: case PCD_GETCVAR:
STACK(1) = GetCVar(activator, FBehavior::StaticLookupString(STACK(1)), false); STACK(1) = DoGetCVar(GetCVar(activator, FBehavior::StaticLookupString(STACK(1))), false);
break; break;
case PCD_SETHUDSIZE: case PCD_SETHUDSIZE:

View file

@ -252,7 +252,6 @@ void P_InitEffects ()
blood2 = ParticleColor(RPART(kind)/3, GPART(kind)/3, BPART(kind)/3); blood2 = ParticleColor(RPART(kind)/3, GPART(kind)/3, BPART(kind)/3);
} }
void P_ThinkParticles () void P_ThinkParticles ()
{ {
int i; int i;
@ -262,13 +261,19 @@ void P_ThinkParticles ()
prev = NULL; prev = NULL;
while (i != NO_PARTICLE) while (i != NO_PARTICLE)
{ {
BYTE oldtrans;
particle = Particles + i; particle = Particles + i;
i = particle->tnext; i = particle->tnext;
if (!particle->notimefreeze && ((bglobal.freeze) || (level.flags2 & LEVEL2_FROZEN)))
{
prev = particle;
continue;
}
BYTE oldtrans;
oldtrans = particle->trans; oldtrans = particle->trans;
particle->trans -= particle->fade; particle->trans -= particle->fade;
if (oldtrans < particle->trans || --particle->ttl == 0) particle->size += particle->sizestep;
if (oldtrans < particle->trans || --particle->ttl <= 0 || (particle->size <= 0))
{ // The particle has expired, so free it { // The particle has expired, so free it
memset (particle, 0, sizeof(particle_t)); memset (particle, 0, sizeof(particle_t));
if (prev) if (prev)
@ -309,8 +314,14 @@ void P_ThinkParticles ()
} }
} }
enum PSFlag
{
PS_FULLBRIGHT = 1,
PS_NOTIMEFREEZE = 1 << 5,
};
void P_SpawnParticle(const DVector3 &pos, const DVector3 &vel, const DVector3 &accel, PalEntry color, bool fullbright, double startalpha, int lifetime, WORD size, double fadestep) void P_SpawnParticle(const DVector3 &pos, const DVector3 &vel, const DVector3 &accel, PalEntry color, double startalpha, int lifetime, double size,
double fadestep, double sizestep, int flags)
{ {
particle_t *particle = NewParticle(); particle_t *particle = NewParticle();
@ -324,8 +335,10 @@ void P_SpawnParticle(const DVector3 &pos, const DVector3 &vel, const DVector3 &a
if (fadestep < 0) particle->fade = FADEFROMTTL(lifetime); if (fadestep < 0) particle->fade = FADEFROMTTL(lifetime);
else particle->fade = int(fadestep * 255); else particle->fade = int(fadestep * 255);
particle->ttl = lifetime; particle->ttl = lifetime;
particle->bright = fullbright; particle->bright = !!(flags & PS_FULLBRIGHT);
particle->size = (WORD)size; particle->size = size;
particle->sizestep = sizestep;
particle->notimefreeze = !!(flags & PS_NOTIMEFREEZE);
} }
} }

View file

@ -59,13 +59,15 @@ struct particle_t
DVector3 Acc; DVector3 Acc;
BYTE ttl; BYTE ttl;
BYTE trans; BYTE trans;
WORD size; double size;
double sizestep;
BYTE bright; BYTE bright;
BYTE fade; BYTE fade;
int color; int color;
WORD tnext; WORD tnext;
WORD snext; WORD snext;
subsector_t * subsector; subsector_t * subsector;
bool notimefreeze;
}; };
extern particle_t *Particles; extern particle_t *Particles;
@ -83,7 +85,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(const DVector3 &pos, const DVector3 &vel, const DVector3 &accel, PalEntry color, bool fullbright, double startalpha, int lifetime, WORD size, double fadestep); void P_SpawnParticle(const DVector3 &pos, const DVector3 &vel, const DVector3 &accel, PalEntry color, double startalpha, int lifetime, double size, double fadestep, double sizestep, int flags = 0);
void P_InitEffects (void); void P_InitEffects (void);
void P_RunEffects (void); void P_RunEffects (void);

View file

@ -2789,10 +2789,10 @@ void P_NightmareRespawn (AActor *mobj)
mo->Prev.Z = z; // Do not interpolate Z position if we changed it since spawning. mo->Prev.Z = z; // Do not interpolate Z position if we changed it since spawning.
// spawn a teleport fog at old spot because of removal of the body? // spawn a teleport fog at old spot because of removal of the body?
P_SpawnTeleportFog(mobj, mobj->PosPlusZ(TELEFOGHEIGHT), true, true); P_SpawnTeleportFog(mobj, mobj->Pos(), true, true);
// spawn a teleport fog at the new spot // spawn a teleport fog at the new spot
P_SpawnTeleportFog(mobj, DVector3(mobj->SpawnPoint, z + TELEFOGHEIGHT), false, true); P_SpawnTeleportFog(mobj, DVector3(mobj->SpawnPoint, z), false, true);
// remove the old monster // remove the old monster
mobj->Destroy (); mobj->Destroy ();
@ -4685,7 +4685,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); P_SpawnTeleportFog(mobj, mobj->Vec3Angle(20., mobj->Angles.Yaw, 0.), false, true);
} }
// "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,

View file

@ -88,7 +88,8 @@ void P_SpawnTeleportFog(AActor *mobj, const DVector3 &pos, bool beforeTele, bool
} }
else else
{ {
mo = Spawn((beforeTele ? mobj->TeleFogSourceType : mobj->TeleFogDestType), pos, ALLOW_REPLACE); double fogDelta = mobj->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT;
mo = Spawn((beforeTele ? mobj->TeleFogSourceType : mobj->TeleFogDestType), DVector3(pos, pos.Z + fogDelta), ALLOW_REPLACE);
} }
if (mo != NULL && setTarget) if (mo != NULL && setTarget)
@ -191,10 +192,9 @@ bool P_Teleport (AActor *thing, DVector3 pos, DAngle angle, int flags)
{ {
if (!predicting) if (!predicting)
{ {
double fogDelta = thing->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT;
DVector2 vector = angle.ToVector(20); DVector2 vector = angle.ToVector(20);
DVector2 fogpos = P_GetOffsetPosition(pos.X, pos.Y, vector.X, vector.Y); DVector2 fogpos = P_GetOffsetPosition(pos.X, pos.Y, vector.X, vector.Y);
P_SpawnTeleportFog(thing, DVector3(fogpos, thing->Z() + fogDelta), false, true); P_SpawnTeleportFog(thing, DVector3(fogpos, thing->Z()), false, true);
} }
if (thing->player) if (thing->player)

View file

@ -98,7 +98,7 @@ bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, i
mobj->Angles.Yaw = (angle != 1000000. ? angle : spot->Angles.Yaw); mobj->Angles.Yaw = (angle != 1000000. ? angle : spot->Angles.Yaw);
if (fog) if (fog)
{ {
P_SpawnTeleportFog(mobj, spot->PosPlusZ(TELEFOGHEIGHT), false, true); P_SpawnTeleportFog(mobj, spot->Pos(), false, true);
} }
if (mobj->flags & MF_SPECIAL) if (mobj->flags & MF_SPECIAL)
mobj->flags |= MF_DROPPED; // Don't respawn mobj->flags |= MF_DROPPED; // Don't respawn
@ -673,7 +673,7 @@ bool P_Thing_CheckProximity(AActor *self, PClass *classname, double distance, in
// We need these to check out. // We need these to check out.
if (!ref || !classname || distance <= 0) if (!ref || !classname || distance <= 0)
return nullptr; return false;
int counter = 0; int counter = 0;
bool result = false; bool result = false;

View file

@ -117,10 +117,7 @@ void P_Ticker (void)
// Since things will be moving, it's okay to interpolate them in the renderer. // Since things will be moving, it's okay to interpolate them in the renderer.
r_NoInterpolate = false; r_NoInterpolate = false;
if (!bglobal.freeze && !(level.flags2 & LEVEL2_FROZEN)) P_ThinkParticles(); // [RH] make the particles think
{
P_ThinkParticles (); // [RH] make the particles think
}
for (i = 0; i<MAXPLAYERS; i++) for (i = 0; i<MAXPLAYERS; i++)
if (playeringame[i] && if (playeringame[i] &&

View file

@ -1038,11 +1038,17 @@ FScriptPosition &FScriptPosition::operator=(const FScriptPosition &other)
// //
//========================================================================== //==========================================================================
CVAR(Bool, strictdecorate, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
void FScriptPosition::Message (int severity, const char *message, ...) const void FScriptPosition::Message (int severity, const char *message, ...) const
{ {
FString composed; FString composed;
if ((severity == MSG_DEBUG || severity == MSG_DEBUGLOG) && !developer) return; if ((severity == MSG_DEBUG || severity == MSG_DEBUGLOG) && !developer) return;
if (severity == MSG_OPTERROR)
{
severity = strictdecorate ? MSG_ERROR : MSG_WARNING;
}
if (message == NULL) if (message == NULL)
{ {

View file

@ -124,6 +124,7 @@ enum
MSG_WARNING, MSG_WARNING,
MSG_FATAL, MSG_FATAL,
MSG_ERROR, MSG_ERROR,
MSG_OPTERROR,
MSG_DEBUG, MSG_DEBUG,
MSG_LOG, MSG_LOG,
MSG_DEBUGLOG, MSG_DEBUGLOG,

View file

@ -431,11 +431,11 @@ void LoadActors ()
FScanner sc(lump); FScanner sc(lump);
ParseDecorate (sc); ParseDecorate (sc);
} }
FinishThingdef();
if (FScriptPosition::ErrorCounter > 0) if (FScriptPosition::ErrorCounter > 0)
{ {
I_Error("%d errors while parsing DECORATE scripts", FScriptPosition::ErrorCounter); I_Error("%d errors while parsing DECORATE scripts", FScriptPosition::ErrorCounter);
} }
FinishThingdef();
timer.Unclock(); timer.Unclock();
if (!batchrun) Printf("DECORATE parsing took %.2f ms\n", timer.TimeMS()); if (!batchrun) Printf("DECORATE parsing took %.2f ms\n", timer.TimeMS());
// Base time: ~52 ms // Base time: ~52 ms

View file

@ -513,6 +513,36 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetCrouchFactor)
return 0; return 0;
} }
//==========================================================================
//
// GetCVar
//
// NON-ACTION function that works like ACS's GetCVar.
//
//==========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetCVar)
{
if (numret > 0)
{
assert(ret != nullptr);
PARAM_SELF_PROLOGUE(AActor);
PARAM_STRING(cvarname);
FBaseCVar *cvar = GetCVar(self, cvarname);
if (cvar == nullptr)
{
ret->SetFloat(0);
}
else
{
ret->SetFloat(cvar->GetGenericRep(CVAR_Float).Float);
}
return 1;
}
return 0;
}
//=========================================================================== //===========================================================================
// //
// __decorate_internal_state__ // __decorate_internal_state__
@ -3147,6 +3177,7 @@ enum SPFflag
SPF_RELVEL = 1 << 2, SPF_RELVEL = 1 << 2,
SPF_RELACCEL = 1 << 3, SPF_RELACCEL = 1 << 3,
SPF_RELANG = 1 << 4, SPF_RELANG = 1 << 4,
SPF_NOTIMEFREEZE = 1 << 5,
}; };
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle)
@ -3155,7 +3186,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle)
PARAM_COLOR (color); PARAM_COLOR (color);
PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (flags) { flags = 0; }
PARAM_INT_OPT (lifetime) { lifetime = 35; } PARAM_INT_OPT (lifetime) { lifetime = 35; }
PARAM_INT_OPT (size) { size = 1; } PARAM_FLOAT_OPT (size) { size = 1.; }
PARAM_ANGLE_OPT (angle) { angle = 0.; } PARAM_ANGLE_OPT (angle) { angle = 0.; }
PARAM_FLOAT_OPT (xoff) { xoff = 0; } PARAM_FLOAT_OPT (xoff) { xoff = 0; }
PARAM_FLOAT_OPT (yoff) { yoff = 0; } PARAM_FLOAT_OPT (yoff) { yoff = 0; }
@ -3168,11 +3199,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle)
PARAM_FLOAT_OPT (accelz) { accelz = 0; } PARAM_FLOAT_OPT (accelz) { accelz = 0; }
PARAM_FLOAT_OPT (startalpha) { startalpha = 1.; } PARAM_FLOAT_OPT (startalpha) { startalpha = 1.; }
PARAM_FLOAT_OPT (fadestep) { fadestep = -1.; } PARAM_FLOAT_OPT (fadestep) { fadestep = -1.; }
PARAM_FLOAT_OPT (sizestep) { sizestep = 0.; }
startalpha = clamp(startalpha, 0., 1.); startalpha = clamp(startalpha, 0., 1.);
if (fadestep > 0) fadestep = clamp(fadestep, 0., 1.); if (fadestep > 0) fadestep = clamp(fadestep, 0., 1.);
size = clamp<int>(size, 0, 65535); // Clamp to word size = fabs(size);
if (lifetime != 0) if (lifetime != 0)
{ {
if (flags & SPF_RELANG) angle += self->Angles.Yaw; if (flags & SPF_RELANG) angle += self->Angles.Yaw;
@ -3199,7 +3230,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle)
acc.X = accelx * c + accely * s; acc.X = accelx * c + accely * s;
acc.Y = accelx * s - accely * c; acc.Y = accelx * s - accely * c;
} }
P_SpawnParticle(self->Vec3Offset(pos), vel, acc, color, !!(flags & SPF_FULLBRIGHT), startalpha, lifetime, size, fadestep); P_SpawnParticle(self->Vec3Offset(pos), vel, acc, color, startalpha, lifetime, size, fadestep, sizestep, flags);
} }
return 0; return 0;
} }

View file

@ -208,7 +208,7 @@ public:
virtual bool isConstant() const; virtual bool isConstant() const;
virtual void RequestAddress(); virtual void RequestAddress();
virtual VMFunction *GetDirectFunction(); virtual VMFunction *GetDirectFunction();
bool IsNumeric() const { return ValueType->GetRegType() == REGT_INT || ValueType->GetRegType() == REGT_FLOAT; } bool IsNumeric() const { return ValueType != TypeName && (ValueType->GetRegType() == REGT_INT || ValueType->GetRegType() == REGT_FLOAT); }
bool IsPointer() const { return ValueType->GetRegType() == REGT_POINTER; } bool IsPointer() const { return ValueType->GetRegType() == REGT_POINTER; }
virtual ExpEmit Emit(VMFunctionBuilder *build); virtual ExpEmit Emit(VMFunctionBuilder *build);

View file

@ -357,12 +357,24 @@ FxExpression *FxIntCast::Resolve(FCompileContext &ctx)
SAFE_RESOLVE(basex, ctx); SAFE_RESOLVE(basex, ctx);
if (basex->ValueType->GetRegType() == REGT_INT) if (basex->ValueType->GetRegType() == REGT_INT)
{
if (basex->ValueType != TypeName)
{ {
FxExpression *x = basex; FxExpression *x = basex;
basex = NULL; basex = NULL;
delete this; delete this;
return x; return x;
} }
else
{
// Ugh. This should abort, but too many mods fell into this logic hole somewhere, so this seroious error needs to be reduced to a warning. :(
if (!basex->isConstant()) ScriptPosition.Message(MSG_OPTERROR, "Numeric type expected, got a name");
else ScriptPosition.Message(MSG_OPTERROR, "Numeric type expected, got \"%s\"", static_cast<FxConstant*>(basex)->GetValue().GetName().GetChars());
FxExpression * x = new FxConstant(0, ScriptPosition);
delete this;
return x;
}
}
else if (basex->ValueType->GetRegType() == REGT_FLOAT) else if (basex->ValueType->GetRegType() == REGT_FLOAT)
{ {
if (basex->isConstant()) if (basex->isConstant())
@ -374,12 +386,9 @@ FxExpression *FxIntCast::Resolve(FCompileContext &ctx)
} }
return this; return this;
} }
else
{
ScriptPosition.Message(MSG_ERROR, "Numeric type expected"); ScriptPosition.Message(MSG_ERROR, "Numeric type expected");
delete this; delete this;
return NULL; return NULL;
}
} }
//========================================================================== //==========================================================================
@ -442,6 +451,8 @@ FxExpression *FxFloatCast::Resolve(FCompileContext &ctx)
return x; return x;
} }
else if (basex->ValueType->GetRegType() == REGT_INT) else if (basex->ValueType->GetRegType() == REGT_INT)
{
if (basex->ValueType != TypeName)
{ {
if (basex->isConstant()) if (basex->isConstant())
{ {
@ -453,6 +464,16 @@ FxExpression *FxFloatCast::Resolve(FCompileContext &ctx)
return this; return this;
} }
else else
{
// Ugh. This should abort, but too many mods fell into this logic hole somewhere, so this seroious error needs to be reduced to a warning. :(
if (!basex->isConstant()) ScriptPosition.Message(MSG_OPTERROR, "Numeric type expected, got a name");
else ScriptPosition.Message(MSG_OPTERROR, "Numeric type expected, got \"%s\"", static_cast<FxConstant*>(basex)->GetValue().GetName().GetChars());
FxExpression *x = new FxConstant(0.0, ScriptPosition);
delete this;
return x;
}
}
else
{ {
ScriptPosition.Message(MSG_ERROR, "Numeric type expected"); ScriptPosition.Message(MSG_ERROR, "Numeric type expected");
delete this; delete this;
@ -3903,7 +3924,7 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx)
{ {
/* lax */ /* lax */
// Since this happens in released WADs it must pass without a terminal error... :( // Since this happens in released WADs it must pass without a terminal error... :(
ScriptPosition.Message(MSG_WARNING, ScriptPosition.Message(MSG_OPTERROR,
"Unknown class name '%s'", "Unknown class name '%s'",
clsname.GetChars(), desttype->TypeName.GetChars()); clsname.GetChars(), desttype->TypeName.GetChars());
} }
@ -4074,7 +4095,7 @@ FxExpression *FxMultiNameState::Resolve(FCompileContext &ctx)
destination = scope->FindState(names.Size()-1, &names[1], false); destination = scope->FindState(names.Size()-1, &names[1], false);
if (destination == NULL) if (destination == NULL)
{ {
ScriptPosition.Message(MSG_WARNING, "Unknown state jump destination"); ScriptPosition.Message(MSG_OPTERROR, "Unknown state jump destination");
/* lax */ /* lax */
return this; return this;
} }

View file

@ -457,7 +457,7 @@ DEFINE_PROPERTY(skip_super, 0, Actor)
} }
if (bag.StateSet) if (bag.StateSet)
{ {
bag.ScriptPosition.Message(MSG_WARNING, bag.ScriptPosition.Message(MSG_OPTERROR,
"'skip_super' must appear before any state definitions."); "'skip_super' must appear before any state definitions.");
return; return;
} }

View file

@ -47,6 +47,7 @@ ACTOR Actor native //: Thinker
native int GetSpawnHealth(); native int GetSpawnHealth();
native int GetGibHealth(); native int GetGibHealth();
native float GetCrouchFactor(int ptr = AAPTR_PLAYER1); native float GetCrouchFactor(int ptr = AAPTR_PLAYER1);
native float GetCVar(string cvar);
// Action functions // Action functions
// Meh, MBF redundant functions. Only for DeHackEd support. // Meh, MBF redundant functions. Only for DeHackEd support.
@ -214,7 +215,7 @@ ACTOR Actor native //: Thinker
native void A_SetScale(float scalex, float scaley = 0, int ptr = AAPTR_DEFAULT, bool usezero = false); native void A_SetScale(float scalex, float scaley = 0, int ptr = AAPTR_DEFAULT, bool usezero = false);
native void A_SetMass(int mass); native void A_SetMass(int mass);
native void A_SpawnDebris(class<Actor> spawntype, bool transfer_translation = false, float mult_h = 1, float mult_v = 1); native void A_SpawnDebris(class<Actor> spawntype, bool transfer_translation = false, float mult_h = 1, float mult_v = 1);
native void A_SpawnParticle(color color1, int flags = 0, int lifetime = 35, int size = 1, float angle = 0, float xoff = 0, float yoff = 0, float zoff = 0, float velx = 0, float vely = 0, float velz = 0, float accelx = 0, float accely = 0, float accelz = 0, float startalphaf = 1, float fadestepf = -1); native void A_SpawnParticle(color color1, int flags = 0, int lifetime = 35, float size = 1, float angle = 0, float xoff = 0, float yoff = 0, float zoff = 0, float velx = 0, float vely = 0, float velz = 0, float accelx = 0, float accely = 0, float accelz = 0, float startalphaf = 1, float fadestepf = -1, float sizestep = 0);
native state A_CheckSight(state label); native state A_CheckSight(state label);
native void A_ExtChase(bool usemelee, bool usemissile, bool playactive = true, bool nightmarefast = false); native void A_ExtChase(bool usemelee, bool usemissile, bool playactive = true, bool nightmarefast = false);
native void A_DropInventory(class<Inventory> itemtype); native void A_DropInventory(class<Inventory> itemtype);

View file

@ -539,6 +539,7 @@ enum
SPF_RELVEL = 1 << 2, SPF_RELVEL = 1 << 2,
SPF_RELACCEL = 1 << 3, SPF_RELACCEL = 1 << 3,
SPF_RELANG = 1 << 4, SPF_RELANG = 1 << 4,
SPF_NOTIMEFREEZE = 1 << 5,
SPF_RELATIVE = SPF_RELPOS|SPF_RELVEL|SPF_RELACCEL|SPF_RELANG SPF_RELATIVE = SPF_RELPOS|SPF_RELVEL|SPF_RELACCEL|SPF_RELANG
}; };

View file

@ -1,5 +1,16 @@
// Must be sorted in identification order (easiest to recognize first!) // Must be sorted in identification order (easiest to recognize first!)
IWad
{
Name = "Delaweare"
Autoname = "delaweare"
Game = "Doom"
Config = "Delaweare"
Mapinfo = "mapinfo/doom2.txt"
MustContain = "TITLEMAP", "ROVEA0", "GRLURD01", "SQOUI01"
BannerColors = "00 00 00", "ff ff ff"
}
IWad IWad
{ {
Name = "The Adventures of Square" Name = "The Adventures of Square"
@ -393,4 +404,5 @@ Names
"hacx.wad" "hacx.wad"
"hacx2.wad" "hacx2.wad"
"square1.pk3" "square1.pk3"
"delaweare.wad"
} }