From 5f56fb5a16156a0e227ae9263eedba67141d0a51 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Mon, 30 Mar 2015 21:54:58 -0400 Subject: [PATCH] Changed the behavior of SetActorTeleFog. - Don't force "null" to resolve to no actor since "none" is already defined as NULL (via FindClass). (This change also applies to the decorate properties.) - Passing an empty actor name will keep the existing fog since there's otherwise no way set only one fog. Since "none" works to remove the fog, I see no reason not to have this option. --- src/p_acs.cpp | 39 ++++++++++------------------ src/thingdef/thingdef_properties.cpp | 4 +-- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 2bbbc944a9..8894bc936a 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -4767,25 +4767,19 @@ static void SetActorRoll(AActor *activator, int tid, int angle, bool interpolate } } -static void SetActorTeleFog(AActor *activator, int tid, FName telefogsrc, FName telefogdest) +static void SetActorTeleFog(AActor *activator, int tid, FString telefogsrc, FString telefogdest) { - //Simply put, if it doesn't exist, it won't change. One can use "" in this scenario. - const PClass *check; + // Set the actor's telefog to the specified actor. Handle "" as "don't + // change" since "None" should work just fine for disabling the fog (given + // that it will resolve to NAME_None which is not a valid actor name). if (tid == 0) { if (activator != NULL) { - check = PClass::FindClass(telefogsrc); - if (check == NULL || !stricmp(telefogsrc, "none") || !stricmp(telefogsrc, "null")) - activator->TeleFogSourceType = NULL; - else - activator->TeleFogSourceType = check; - - check = PClass::FindClass(telefogdest); - if (check == NULL || !stricmp(telefogdest, "none") || !stricmp(telefogdest, "null")) - activator->TeleFogDestType = NULL; - else - activator->TeleFogDestType = check; + if (telefogsrc.IsNotEmpty()) + activator->TeleFogSourceType = PClass::FindClass(telefogsrc); + if (telefogdest.IsNotEmpty()) + activator->TeleFogDestType = PClass::FindClass(telefogdest); } } else @@ -4793,19 +4787,14 @@ static void SetActorTeleFog(AActor *activator, int tid, FName telefogsrc, FName FActorIterator iterator(tid); AActor *actor; + const PClass * const src = telefogsrc.IsNotEmpty() ? PClass::FindClass(telefogsrc) : NULL; + const PClass * const dest = telefogdest.IsNotEmpty() ? PClass::FindClass(telefogdest) : NULL; while ((actor = iterator.Next())) { - check = PClass::FindClass(telefogsrc); - if (check == NULL || !stricmp(telefogsrc, "none") || !stricmp(telefogsrc, "null")) - actor->TeleFogSourceType = NULL; - else - actor->TeleFogSourceType = check; - - check = PClass::FindClass(telefogdest); - if (check == NULL || !stricmp(telefogdest, "none") || !stricmp(telefogdest, "null")) - actor->TeleFogDestType = NULL; - else - actor->TeleFogDestType = check; + if (telefogsrc.IsNotEmpty()) + actor->TeleFogSourceType = src; + if (telefogdest.IsNotEmpty()) + actor->TeleFogDestType = dest; } } } diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 6779792767..33066828c8 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1422,7 +1422,7 @@ DEFINE_PROPERTY(stamina, I, Actor) DEFINE_PROPERTY(telefogsourcetype, S, Actor) { PROP_STRING_PARM(str, 0); - if (!stricmp(str, "") || (!stricmp(str, "none")) || (!stricmp(str, "null")) || *str == 0) defaults->TeleFogSourceType = NULL; + if (!stricmp(str, "") || !stricmp(str, "none")) defaults->TeleFogSourceType = NULL; else defaults->TeleFogSourceType = FindClassTentative(str,"TeleportFog"); } @@ -1432,7 +1432,7 @@ DEFINE_PROPERTY(telefogsourcetype, S, Actor) DEFINE_PROPERTY(telefogdesttype, S, Actor) { PROP_STRING_PARM(str, 0); - if (!stricmp(str, "") || (!stricmp(str, "none")) || (!stricmp(str, "null")) || *str == 0) defaults->TeleFogDestType = NULL; + if (!stricmp(str, "") || !stricmp(str, "none")) defaults->TeleFogDestType = NULL; else defaults->TeleFogDestType = FindClassTentative(str, "TeleportFog"); }