- fixed: Morphing to a class without a face definition crashed.

- Converted all of Heretic's actors except the weapons to DECORATE.
- Added the option to define the ActorInfos for native classes in DECORATE.


SVN r1078 (trunk)
This commit is contained in:
Christoph Oelckers 2008-07-21 17:03:30 +00:00
commit a8c283dacd
29 changed files with 1580 additions and 2009 deletions

View file

@ -287,6 +287,10 @@ static void ParseActionDef (FScanner &sc, PClass *cls)
static FActorInfo *CreateNewActor(FScanner &sc, FActorInfo **parentc, Baggage *bag)
{
FName typeName;
const PClass *replacee = NULL;
int DoomEdNum = -1;
PClass *ti = NULL;
FActorInfo *info = NULL;
// Get actor name
sc.MustGetString();
@ -339,10 +343,14 @@ static FActorInfo *CreateNewActor(FScanner &sc, FActorInfo **parentc, Baggage *b
{
sc.ScriptError ("Parent type '%s' not found", colon);
}
else if (parent->ActorInfo == NULL)
else if (!parent->IsDescendantOf(RUNTIME_CLASS(AActor)))
{
sc.ScriptError ("Parent type '%s' is not an actor", colon);
}
else if (parent->ActorInfo == NULL)
{
sc.ScriptError ("uninitialized parent type '%s'", colon);
}
else
{
*parentc = parent->ActorInfo;
@ -351,8 +359,57 @@ static FActorInfo *CreateNewActor(FScanner &sc, FActorInfo **parentc, Baggage *b
else sc.UnGet();
}
PClass *ti = parent->CreateDerivedClass (typeName, parent->Size);
FActorInfo *info = ti->ActorInfo;
// Check for "replaces"
if (sc.CheckString ("replaces"))
{
// Get actor name
sc.MustGetString ();
replacee = PClass::FindClass (sc.String);
if (replacee == NULL)
{
sc.ScriptError ("Replaced type '%s' not found", sc.String);
}
else if (replacee->ActorInfo == NULL)
{
sc.ScriptError ("Replaced type '%s' is not an actor", sc.String);
}
}
// Now, after the actor names have been parsed, it is time to switch to C-mode
// for the rest of the actor definition.
sc.SetCMode (true);
if (sc.CheckNumber())
{
if (sc.Number>=-1 && sc.Number<32768) DoomEdNum = sc.Number;
else sc.ScriptError ("DoomEdNum must be in the range [-1,32767]");
}
if (sc.CheckString("native"))
{
ti = (PClass*)PClass::FindClass(typeName);
if (ti == NULL)
{
sc.ScriptError("Unknown native class '%s'", typeName.GetChars());
}
else if (ti->ParentClass != parent)
{
sc.ScriptError("Native class '%s' does not inherit from '%s'",
typeName.GetChars(),parent->TypeName.GetChars());
}
else if (ti->ActorInfo != NULL)
{
sc.ScriptMessage("Redefinition of internal class '%s'", typeName.GetChars());
}
ti->InitializeActorInfo();
info = ti->ActorInfo;
}
else
{
ti = parent->CreateDerivedClass (typeName, parent->Size);
info = ti->ActorInfo;
}
MakeStateDefines(parent->ActorInfo->StateList);
@ -373,40 +430,14 @@ static FActorInfo *CreateNewActor(FScanner &sc, FActorInfo **parentc, Baggage *b
*info->PainChances = *parent->ActorInfo->PainChances;
}
// Check for "replaces"
sc.MustGetString ();
if (sc.Compare ("replaces"))
if (replacee != NULL)
{
const PClass *replacee;
// Get actor name
sc.MustGetString ();
replacee = PClass::FindClass (sc.String);
if (replacee == NULL)
{
sc.ScriptError ("Replaced type '%s' not found", sc.String);
}
else if (replacee->ActorInfo == NULL)
{
sc.ScriptError ("Replaced type '%s' is not an actor", sc.String);
}
replacee->ActorInfo->Replacement = ti->ActorInfo;
ti->ActorInfo->Replacee = replacee->ActorInfo;
}
else
{
sc.UnGet();
}
// Now, after the actor names have been parsed, it is time to switch to C-mode
// for the rest of the actor definition.
sc.SetCMode (true);
if (sc.CheckNumber())
{
if (sc.Number>=-1 && sc.Number<32768) info->DoomEdNum = sc.Number;
else sc.ScriptError ("DoomEdNum must be in the range [-1,32767]");
}
info->DoomEdNum = DoomEdNum;
if (parent == RUNTIME_CLASS(AWeapon))
{
// preinitialize kickback to the default for the game