- 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)
- 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

View file

@ -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<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 "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<FName> * out);
#include "infomacros.h"

View file

@ -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<FName> 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);

View file

@ -813,52 +813,6 @@ static FStateDefine * FindStateLabelInList(TArray<FStateDefine> & list, FName na
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.