- Rewrote a bunch of things for stability.

This commit is contained in:
MajorCooke 2014-12-17 21:47:00 -06:00
parent 160ded99a9
commit 93ca8502dd
7 changed files with 117 additions and 17 deletions

View file

@ -983,8 +983,8 @@ public:
FNameNoInit PainType; FNameNoInit PainType;
FNameNoInit DeathType; FNameNoInit DeathType;
FNameNoInit TeleFogSourceType; const PClass *TeleFogSourceType;
FNameNoInit TeleFogDestType; const PClass *TeleFogDestType;
FState *SpawnState; FState *SpawnState;
FState *SeeState; FState *SeeState;

View file

@ -4438,6 +4438,8 @@ enum EACSFunctions
ACSF_PickActor, ACSF_PickActor,
ACSF_IsPointerEqual, ACSF_IsPointerEqual,
ACSF_CanRaiseActor, ACSF_CanRaiseActor,
ACSF_SetActorTeleFog, // 86
ACSF_SwapActorTeleFog,
/* Zandronum's - these must be skipped when we reach 99! /* Zandronum's - these must be skipped when we reach 99!
-100:ResetMap(0), -100:ResetMap(0),
@ -4749,6 +4751,72 @@ static void SetActorPitch(AActor *activator, int tid, int angle, bool interpolat
} }
} }
static void SetActorTeleFog(AActor *activator, int tid, FName telefogsrc, FName telefogdest)
{
//Simply put, if it doesn't exist, it won't change. One can use "" in this scenario.
const PClass *check;
if (tid == 0)
{
if (activator != NULL)
{
check = PClass::FindClass(telefogsrc);
if (check != NULL)
activator->TeleFogSourceType = check;
check = PClass::FindClass(telefogdest);
if (check != NULL)
activator->TeleFogDestType = check;
}
}
else
{
FActorIterator iterator(tid);
AActor *actor;
while ((actor = iterator.Next()))
{
check = PClass::FindClass(telefogsrc);
if (check != NULL)
activator->TeleFogSourceType = check;
check = PClass::FindClass(telefogdest);
if (check != NULL)
activator->TeleFogDestType = check;
}
}
}
static int SwapActorTeleFog(AActor *activator, int tid)
{
int count = 0;
if (tid == 0)
{
if ((activator == NULL) || (activator->TeleFogSourceType = activator->TeleFogDestType))
return 0; //Does nothing if they're the same.
else
{
const PClass *temp = activator->TeleFogSourceType;
activator->TeleFogSourceType = activator->TeleFogDestType;
activator->TeleFogDestType = temp;
return 1;
}
}
else
{
FActorIterator iterator(tid);
AActor *actor;
while ((actor = iterator.Next()))
{
if (activator->TeleFogSourceType == activator->TeleFogDestType)
continue; //They're the same. Save the effort.
const PClass *temp = activator->TeleFogSourceType;
activator->TeleFogSourceType = activator->TeleFogDestType;
activator->TeleFogDestType = temp;
count++;
}
}
return count;
}
int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args, const SDWORD *stack, int stackdepth) int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args, const SDWORD *stack, int stackdepth)
@ -5662,7 +5730,18 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
SetActorPitch(activator, args[0], args[1], argCount > 2 ? !!args[2] : false); SetActorPitch(activator, args[0], args[1], argCount > 2 ? !!args[2] : false);
} }
break; break;
case ACSF_SetActorTeleFog:
if (argCount >= 3)
{
SetActorTeleFog(activator, args[0], FBehavior::StaticLookupString(args[1]), FBehavior::StaticLookupString(args[2]));
}
break;
case ACSF_SwapActorTeleFog:
if (argCount >= 1)
{
return SwapActorTeleFog(activator, args[0]);
}
break;
case ACSF_PickActor: case ACSF_PickActor:
if (argCount >= 5) if (argCount >= 5)
{ {

View file

@ -333,7 +333,11 @@ void AActor::Serialize (FArchive &arc)
{ {
arc << FriendPlayer; arc << FriendPlayer;
} }
if (SaveVersion >= 4518)
{
arc << TeleFogSourceType
<< TeleFogDestType;
}
{ {
FString tagstr; FString tagstr;
if (arc.IsStoring() && Tag != NULL && Tag->Len() > 0) tagstr = *Tag; if (arc.IsStoring() && Tag != NULL && Tag->Len() > 0) tagstr = *Tag;

View file

@ -77,15 +77,13 @@ 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, fixed_t x, fixed_t y, fixed_t z, bool beforeTele, bool setTarget)
{ {
AActor *mo; AActor *mo;
FNameNoInit tf = (beforeTele ? mobj->TeleFogSourceType : mobj->TeleFogDestType); if ((beforeTele ? mobj->TeleFogSourceType : mobj->TeleFogDestType) == NULL) //If the actor doesn't have one, initialize the original.
if (!tf) //If the actor doesn't have one, initialize the original.
{ {
mo = Spawn<ATeleportFog>(x, y, z, ALLOW_REPLACE); mo = Spawn<ATeleportFog>(x, y, z, ALLOW_REPLACE);
} }
else else
{ {
mo = Spawn(tf, x, y, z, ALLOW_REPLACE); mo = Spawn((beforeTele ? mobj->TeleFogSourceType : mobj->TeleFogDestType), x, y, z, ALLOW_REPLACE);
} }
if (mo != NULL && setTarget) if (mo != NULL && setTarget)

View file

@ -5385,6 +5385,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Remove)
// //
// Sets the teleport fog(s) for the calling actor. // Sets the teleport fog(s) for the calling actor.
// Takes a name of the classes for te source and destination. // Takes a name of the classes for te source and destination.
// Can set both at the same time. Use "" to retain the previous fog without
// changing it.
//=========================================================================== //===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTeleFog) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTeleFog)
@ -5392,11 +5394,28 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTeleFog)
ACTION_PARAM_START(2); ACTION_PARAM_START(2);
ACTION_PARAM_NAME(oldpos, 0); ACTION_PARAM_NAME(oldpos, 0);
ACTION_PARAM_NAME(newpos, 1); ACTION_PARAM_NAME(newpos, 1);
const PClass *check = PClass::FindClass(oldpos);
if (check != NULL)
self->TeleFogSourceType = check;
if (oldpos) check = PClass::FindClass(newpos);
self->TeleFogSourceType = oldpos; if (check != NULL)
if (newpos) self->TeleFogDestType = check;
self->TeleFogDestType = newpos;
} }
//===========================================================================
//
// A_SwapTeleFog
//
// Switches the source and dest telefogs around.
//===========================================================================
DEFINE_ACTION_FUNCTION(AActor, A_SwapTeleFog)
{
if ((self->TeleFogSourceType != self->TeleFogDestType)) //Does nothing if they're the same.
{
const PClass *temp = self->TeleFogSourceType;
self->TeleFogSourceType = self->TeleFogDestType;
self->TeleFogDestType = temp;
}
}

View file

@ -1422,8 +1422,8 @@ DEFINE_PROPERTY(stamina, I, Actor)
DEFINE_PROPERTY(telefogsourcetype, S, Actor) DEFINE_PROPERTY(telefogsourcetype, S, Actor)
{ {
PROP_STRING_PARM(str, 0); PROP_STRING_PARM(str, 0);
if (str == NULL || *str == 0 || (!stricmp(str,""))) defaults->TeleFogSourceType = "TeleportFog"; if (!stricmp(str,"") || *str == 0) defaults->TeleFogSourceType = PClass::FindClass("TeleportFog");
else defaults->TeleFogSourceType = str; else defaults->TeleFogSourceType = FindClassTentative(str,"TeleportFog");
} }
//========================================================================== //==========================================================================
@ -1432,8 +1432,8 @@ DEFINE_PROPERTY(telefogsourcetype, S, Actor)
DEFINE_PROPERTY(telefogdesttype, S, Actor) DEFINE_PROPERTY(telefogdesttype, S, Actor)
{ {
PROP_STRING_PARM(str, 0); PROP_STRING_PARM(str, 0);
if (str == NULL || *str == 0 || (!stricmp(str, ""))) defaults->TeleFogDestType = "TeleportFog"; if (!stricmp(str, "") || *str == 0) defaults->TeleFogDestType = PClass::FindClass("TeleportFog");
else defaults->TeleFogDestType = str; else defaults->TeleFogDestType = FindClassTentative(str, "TeleportFog");
} }
//========================================================================== //==========================================================================

View file

@ -76,7 +76,7 @@ const char *GetVersionString();
// Use 4500 as the base git save version, since it's higher than the // Use 4500 as the base git save version, since it's higher than the
// SVN revision ever got. // SVN revision ever got.
#define SAVEVER 4516 #define SAVEVER 4518
#define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY2(x) #x
#define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x)