- 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)
This commit is contained in:
Christoph Oelckers 2007-04-22 09:06:29 +00:00
parent a370ea70c6
commit 8c7d4fb393
5 changed files with 63 additions and 69 deletions

View file

@ -1,4 +1,7 @@
April 22, 2007 (Changes by Graf Zahl) 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 - Fixed: ShowErrorPane deleted the StartScreen instead of just calling
NetDone. NetDone.
- moved the DIM_MAP define into v_palette.h so that it can be accessed - moved the DIM_MAP define into v_palette.h so that it can be accessed

View file

@ -50,6 +50,7 @@
#include "i_system.h" #include "i_system.h"
#include "p_local.h" #include "p_local.h"
#include "templates.h" #include "templates.h"
#include "cmdlib.h"
extern void LoadDecorations (void (*process)(FState *, int)); 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); FStateLabel *slabel = info->StateList->FindLabel (label);
if (slabel != NULL) if (slabel != NULL)
{ {
if (sublabel != NAME_None && slabel->Children != NULL) if (slabel->Children != NULL)
{ {
FStateLabel *slabel2 = slabel->Children->FindLabel(sublabel); FStateLabel *slabel2 = slabel->Children->FindLabel(sublabel);
if (slabel2 != NULL) if (slabel2 != NULL)
@ -494,14 +495,7 @@ FState *AActor::FindState (FName label, FName sublabel, bool exact) const
return slabel2->State; return slabel2->State;
} }
} }
if (sublabel == NAME_None && slabel->Children != NULL && exact) if (!exact) return slabel->State;
{
return NULL;
}
if (!exact)
{
return slabel->State;
}
} }
} }
return NULL; return NULL;
@ -565,6 +559,8 @@ FState *FActorInfo::FindState (int numnames, FName *names, bool exact) const
// Changes a single state // Changes a single state
// //
// If the given state does not exist it won't be changed // 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<FName> * 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;
}
//========================================================================== //==========================================================================

View file

@ -77,6 +77,7 @@
#include "farchive.h" #include "farchive.h"
#include "doomdef.h" #include "doomdef.h"
#include "name.h" #include "name.h"
#include "tarray.h"
const BYTE SF_FULLBRIGHT = 0x40; const BYTE SF_FULLBRIGHT = 0x40;
const BYTE SF_BIGTIC = 0x80; const BYTE SF_BIGTIC = 0x80;
@ -446,6 +447,7 @@ private:
extern FDoomEdMap DoomEdMap; extern FDoomEdMap DoomEdMap;
int GetSpriteIndex(const char * spritename); int GetSpriteIndex(const char * spritename);
void MakeStateNameList(const char * fname, TArray<FName> * out);
#include "infomacros.h" #include "infomacros.h"

View file

@ -65,11 +65,13 @@
#include "gi.h" #include "gi.h"
#include "sc_man.h" #include "sc_man.h"
#include "c_bind.h" #include "c_bind.h"
#include "info.h"
extern FILE *Logfile; extern FILE *Logfile;
FRandom pr_acs ("ACS"); FRandom pr_acs ("ACS");
// I imagine this much stack space is probably overkill, but it could // I imagine this much stack space is probably overkill, but it could
// potentially get used with recursive functions. // potentially get used with recursive functions.
#define STACK_SIZE 4096 #define STACK_SIZE 4096
@ -4971,23 +4973,14 @@ int DLevelScript::RunScript ()
case PCD_SETACTORSTATE: case PCD_SETACTORSTATE:
{ {
const char *statename = FBehavior::StaticLookupString (STACK(2)); const char *statename = FBehavior::StaticLookupString (STACK(2));
const char *dot; TArray<FName> statelist;
FName label1, label2;
FState *state; FState *state;
dot = strchr (statename, '.'); MakeStateNameList(statename, &statelist);
if (dot != NULL)
{
label1 = FName(statename, dot - statename, true);
label2 = FName(dot + 1, true);
}
else
{
label1 = FName(statename, true);
}
if (STACK(3) == 0) 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) if (state != NULL)
{ {
activator->SetState (state); activator->SetState (state);
@ -5006,7 +4999,7 @@ int DLevelScript::RunScript ()
while ( (actor = iterator.Next ()) ) 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) if (state != NULL)
{ {
actor->SetState (state); actor->SetState (state);

View file

@ -813,52 +813,6 @@ static FStateDefine * FindStateLabelInList(TArray<FStateDefine> & list, FName na
return NULL; return NULL;
} }
//==========================================================================
//
// Creates a list of names from a string. Dots are used as separator
//
//==========================================================================
void MakeStateNameList(const char * fname, TArray<FName> * 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. // Finds the address of a state given by name.