From 8c7d4fb393128eb7724db19f3a7085e68ec4ddee Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 22 Apr 2007 09:06:29 +0000 Subject: [PATCH] - Changed ACS's SetActorState so that it isn't limited to only one sublabel. This change also enables the implicit mapping of the old special death state names. SVN r515 (trunk) --- docs/rh-log.txt | 3 +++ src/info.cpp | 60 ++++++++++++++++++++++++++++++++++++++++-------- src/info.h | 2 ++ src/p_acs.cpp | 21 ++++++----------- src/thingdef.cpp | 46 ------------------------------------- 5 files changed, 63 insertions(+), 69 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 151820990..70159dbae 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,7 @@ April 22, 2007 (Changes by Graf Zahl) +- Changed ACS's SetActorState so that it isn't limited to only one sublabel. + This change also enables the implicit mapping of the old special death + state names. - Fixed: ShowErrorPane deleted the StartScreen instead of just calling NetDone. - moved the DIM_MAP define into v_palette.h so that it can be accessed diff --git a/src/info.cpp b/src/info.cpp index ceec71285..d08300cf0 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -50,6 +50,7 @@ #include "i_system.h" #include "p_local.h" #include "templates.h" +#include "cmdlib.h" extern void LoadDecorations (void (*process)(FState *, int)); @@ -486,7 +487,7 @@ FState *AActor::FindState (FName label, FName sublabel, bool exact) const FStateLabel *slabel = info->StateList->FindLabel (label); if (slabel != NULL) { - if (sublabel != NAME_None && slabel->Children != NULL) + if (slabel->Children != NULL) { FStateLabel *slabel2 = slabel->Children->FindLabel(sublabel); if (slabel2 != NULL) @@ -494,14 +495,7 @@ FState *AActor::FindState (FName label, FName sublabel, bool exact) const return slabel2->State; } } - if (sublabel == NAME_None && slabel->Children != NULL && exact) - { - return NULL; - } - if (!exact) - { - return slabel->State; - } + if (!exact) return slabel->State; } } return NULL; @@ -565,6 +559,8 @@ FState *FActorInfo::FindState (int numnames, FName *names, bool exact) const // Changes a single state // // If the given state does not exist it won't be changed +// This is only used for postprocessing of actors that use different +// spawn states for different games so more complex checks are not needed. // //=========================================================================== @@ -582,6 +578,52 @@ void FActorInfo::ChangeState (FName label, FState * newstate) const } } +//========================================================================== +// +// Creates a list of names from a string. Dots are used as separator +// +//========================================================================== + +void MakeStateNameList(const char * fname, TArray * out) +{ + FName firstpart, secondpart; + char * c; + + // Handle the old names for the existing death states + char * name = copystring(fname); + firstpart = strtok(name, "."); + switch (firstpart) + { + case NAME_Burn: + firstpart = NAME_Death; + secondpart = NAME_Fire; + break; + case NAME_Ice: + firstpart = NAME_Death; + secondpart = NAME_Ice; + break; + case NAME_Disintegrate: + firstpart = NAME_Death; + secondpart = NAME_Disintegrate; + break; + case NAME_XDeath: + firstpart = NAME_Death; + secondpart = NAME_Extreme; + break; + } + + out->Clear(); + out->Push(firstpart); + if (secondpart!=NAME_None) out->Push(secondpart); + + while ((c = strtok(NULL, "."))!=NULL) + { + FName cc = c; + out->Push(cc); + } + delete [] name; +} + //========================================================================== diff --git a/src/info.h b/src/info.h index 0956ba1f6..6e58389ad 100644 --- a/src/info.h +++ b/src/info.h @@ -77,6 +77,7 @@ #include "farchive.h" #include "doomdef.h" #include "name.h" +#include "tarray.h" const BYTE SF_FULLBRIGHT = 0x40; const BYTE SF_BIGTIC = 0x80; @@ -446,6 +447,7 @@ private: extern FDoomEdMap DoomEdMap; int GetSpriteIndex(const char * spritename); +void MakeStateNameList(const char * fname, TArray * out); #include "infomacros.h" diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 223898ac1..30b9a4dd7 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -65,11 +65,13 @@ #include "gi.h" #include "sc_man.h" #include "c_bind.h" +#include "info.h" extern FILE *Logfile; FRandom pr_acs ("ACS"); + // I imagine this much stack space is probably overkill, but it could // potentially get used with recursive functions. #define STACK_SIZE 4096 @@ -4971,23 +4973,14 @@ int DLevelScript::RunScript () case PCD_SETACTORSTATE: { const char *statename = FBehavior::StaticLookupString (STACK(2)); - const char *dot; - FName label1, label2; + TArray statelist; FState *state; - dot = strchr (statename, '.'); - if (dot != NULL) - { - label1 = FName(statename, dot - statename, true); - label2 = FName(dot + 1, true); - } - else - { - label1 = FName(statename, true); - } + MakeStateNameList(statename, &statelist); + if (STACK(3) == 0) { - state = activator->FindState (label1, label2, !!STACK(1)); + state = RUNTIME_TYPE(activator)->ActorInfo->FindState (statelist.Size(), &statelist[0], !!STACK(1)); if (state != NULL) { activator->SetState (state); @@ -5006,7 +4999,7 @@ int DLevelScript::RunScript () while ( (actor = iterator.Next ()) ) { - state = actor->FindState (label1, label2, !!STACK(1)); + state = RUNTIME_TYPE(activator)->ActorInfo->FindState (statelist.Size(), &statelist[0], !!STACK(1)); if (state != NULL) { actor->SetState (state); diff --git a/src/thingdef.cpp b/src/thingdef.cpp index 194be23a9..63253486e 100644 --- a/src/thingdef.cpp +++ b/src/thingdef.cpp @@ -813,52 +813,6 @@ static FStateDefine * FindStateLabelInList(TArray & list, FName na return NULL; } -//========================================================================== -// -// Creates a list of names from a string. Dots are used as separator -// -//========================================================================== - -void MakeStateNameList(const char * fname, TArray * out) -{ - FName firstpart, secondpart; - char * c; - - // Handle the old names for the existing death states - char * name = copystring(fname); - firstpart = strtok(name, "."); - switch (firstpart) - { - case NAME_Burn: - firstpart = NAME_Death; - secondpart = NAME_Fire; - break; - case NAME_Ice: - firstpart = NAME_Death; - secondpart = NAME_Ice; - break; - case NAME_Disintegrate: - firstpart = NAME_Death; - secondpart = NAME_Disintegrate; - break; - case NAME_XDeath: - firstpart = NAME_Death; - secondpart = NAME_Extreme; - break; - } - - out->Clear(); - out->Push(firstpart); - if (secondpart!=NAME_None) out->Push(secondpart); - - while ((c = strtok(NULL, "."))!=NULL) - { - FName cc = c; - out->Push(cc); - } - delete [] name; -} - //========================================================================== // // Finds the address of a state given by name.