- Removed the third parameter from dumpclasses when it was restricted it to Actors, because

I have no idea what that was all about.
- Got rid of FActorInfo and merged it into a new PClassActor.

SVN r2240 (scripting)
This commit is contained in:
Randy Heit 2010-03-24 02:49:37 +00:00
commit f88f601230
78 changed files with 1171 additions and 1039 deletions

View file

@ -71,27 +71,26 @@ void InitThingdef();
void ParseDecorate (FScanner &sc);
// STATIC FUNCTION PROTOTYPES --------------------------------------------
const PClass *QuestItemClasses[31];
PSymbolTable GlobalSymbols;
PClassActor *QuestItemClasses[31];
PSymbolTable GlobalSymbols;
//==========================================================================
//
// Starts a new actor definition
//
//==========================================================================
FActorInfo *CreateNewActor(const FScriptPosition &sc, FName typeName, FName parentName, bool native)
PClassActor *CreateNewActor(const FScriptPosition &sc, FName typeName, FName parentName, bool native)
{
const PClass *replacee = NULL;
PClass *ti = NULL;
FActorInfo *info = NULL;
PClassActor *replacee = NULL;
PClassActor *ti = NULL;
PClass *parent = RUNTIME_CLASS(AActor);
PClassActor *parent = RUNTIME_CLASS(AActor);
if (parentName != NAME_None)
{
parent = const_cast<PClass *> (PClass::FindClass (parentName));
parent = PClass::FindActor(parentName);
const PClass *p = parent;
PClassActor *p = parent;
while (p != NULL)
{
if (p->TypeName == typeName)
@ -99,7 +98,7 @@ FActorInfo *CreateNewActor(const FScriptPosition &sc, FName typeName, FName pare
sc.Message(MSG_ERROR, "'%s' inherits from a class with the same name", typeName.GetChars());
break;
}
p = p->ParentClass;
p = dyn_cast<PClassActor>(p->ParentClass);
}
if (parent == NULL)
@ -112,19 +111,14 @@ FActorInfo *CreateNewActor(const FScriptPosition &sc, FName typeName, FName pare
sc.Message(MSG_ERROR, "Parent type '%s' is not an actor in %s", parentName.GetChars(), typeName.GetChars());
parent = RUNTIME_CLASS(AActor);
}
else if (parent->ActorInfo == NULL)
{
sc.Message(MSG_ERROR, "uninitialized parent type '%s' in %s", parentName.GetChars(), typeName.GetChars());
parent = RUNTIME_CLASS(AActor);
}
}
if (native)
{
ti = (PClass*)PClass::FindClass(typeName);
ti = PClass::FindActor(typeName);
if (ti == NULL)
{
sc.Message(MSG_ERROR, "Unknown native class '%s'", typeName.GetChars());
sc.Message(MSG_ERROR, "Unknown native actor '%s'", typeName.GetChars());
goto create;
}
else if (ti != RUNTIME_CLASS(AActor) && ti->ParentClass->NativeClass() != parent->NativeClass())
@ -133,36 +127,34 @@ FActorInfo *CreateNewActor(const FScriptPosition &sc, FName typeName, FName pare
parent = RUNTIME_CLASS(AActor);
goto create;
}
else if (ti->ActorInfo != NULL)
else if (ti->Defaults != NULL)
{
sc.Message(MSG_ERROR, "Redefinition of internal class '%s'", typeName.GetChars());
goto create;
}
ti->InitializeActorInfo();
info = ti->ActorInfo;
ti->InitializeNativeDefaults();
}
else
{
create:
ti = parent->CreateDerivedClass (typeName, parent->Size);
info = ti->ActorInfo;
ti = static_cast<PClassActor *>(parent->CreateDerivedClass (typeName, parent->Size));
}
if (parent->ActorInfo->DamageFactors != NULL)
if (parent->DamageFactors != NULL)
{
// copy damage factors from parent
info->DamageFactors = new DmgFactors;
*info->DamageFactors = *parent->ActorInfo->DamageFactors;
ti->DamageFactors = new DmgFactors;
*ti->DamageFactors = *parent->DamageFactors;
}
if (parent->ActorInfo->PainChances != NULL)
if (parent->PainChances != NULL)
{
// copy pain chances from parent
info->PainChances = new PainChanceList;
*info->PainChances = *parent->ActorInfo->PainChances;
ti->PainChances = new PainChanceList;
*ti->PainChances = *parent->PainChances;
}
info->Replacee = info->Replacement = NULL;
info->DoomEdNum = -1;
return info;
ti->Replacee = ti->Replacement = NULL;
ti->DoomEdNum = -1;
return ti;
}
//==========================================================================
@ -171,26 +163,22 @@ FActorInfo *CreateNewActor(const FScriptPosition &sc, FName typeName, FName pare
//
//==========================================================================
void SetReplacement(FActorInfo *info, FName replaceName)
void SetReplacement(PClassActor *info, FName replaceName)
{
// Check for "replaces"
if (replaceName != NAME_None)
{
// Get actor name
const PClass *replacee = PClass::FindClass (replaceName);
PClassActor *replacee = PClass::FindActor(replaceName);
if (replacee == NULL)
{
I_Error ("Replaced type '%s' not found in %s", replaceName.GetChars(), info->Class->TypeName.GetChars());
}
else if (replacee->ActorInfo == NULL)
{
I_Error ("Replaced type '%s' is not an actor in %s", replaceName.GetChars(), info->Class->TypeName.GetChars());
I_Error ("Replaced type '%s' not found in %s", replaceName.GetChars(), info->TypeName.GetChars());
}
if (replacee != NULL)
{
replacee->ActorInfo->Replacement = info;
info->Replacee = replacee->ActorInfo;
replacee->Replacement = info;
info->Replacee = replacee;
}
}
@ -202,10 +190,9 @@ void SetReplacement(FActorInfo *info, FName replaceName)
//
//==========================================================================
void FinishActor(const FScriptPosition &sc, FActorInfo *info, Baggage &bag)
void FinishActor(const FScriptPosition &sc, PClassActor *info, Baggage &bag)
{
PClass *ti = info->Class;
AActor *defaults = (AActor*)ti->Defaults;
AActor *defaults = (AActor*)info->Defaults;
try
{
@ -223,29 +210,28 @@ void FinishActor(const FScriptPosition &sc, FActorInfo *info, Baggage &bag)
{
if (bag.DropItemList == NULL)
{
if (ti->Meta.GetMetaInt (ACMETA_DropItems) != 0)
if (info->Meta.GetMetaInt (ACMETA_DropItems) != 0)
{
ti->Meta.SetMetaInt (ACMETA_DropItems, 0);
info->Meta.SetMetaInt (ACMETA_DropItems, 0);
}
}
else
{
ti->Meta.SetMetaInt (ACMETA_DropItems,
StoreDropItemChain(bag.DropItemList));
info->Meta.SetMetaInt (ACMETA_DropItems, StoreDropItemChain(bag.DropItemList));
}
}
if (ti->IsDescendantOf (RUNTIME_CLASS(AInventory)))
if (info->IsDescendantOf (RUNTIME_CLASS(AInventory)))
{
defaults->flags |= MF_SPECIAL;
}
// Weapons must be checked for all relevant states. They may crash the game otherwise.
if (ti->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
if (info->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
{
FState * ready = ti->ActorInfo->FindState(NAME_Ready);
FState * select = ti->ActorInfo->FindState(NAME_Select);
FState * deselect = ti->ActorInfo->FindState(NAME_Deselect);
FState * fire = ti->ActorInfo->FindState(NAME_Fire);
FState *ready = info->FindState(NAME_Ready);
FState *select = info->FindState(NAME_Select);
FState *deselect = info->FindState(NAME_Deselect);
FState *fire = info->FindState(NAME_Fire);
// Consider any weapon without any valid state abstract and don't output a warning
// This is for creating base classes for weapon groups that only set up some properties.
@ -253,19 +239,19 @@ void FinishActor(const FScriptPosition &sc, FActorInfo *info, Baggage &bag)
{
if (!ready)
{
sc.Message(MSG_ERROR, "Weapon %s doesn't define a ready state.\n", ti->TypeName.GetChars());
sc.Message(MSG_ERROR, "Weapon %s doesn't define a ready state.\n", info->TypeName.GetChars());
}
if (!select)
{
sc.Message(MSG_ERROR, "Weapon %s doesn't define a select state.\n", ti->TypeName.GetChars());
sc.Message(MSG_ERROR, "Weapon %s doesn't define a select state.\n", info->TypeName.GetChars());
}
if (!deselect)
{
sc.Message(MSG_ERROR, "Weapon %s doesn't define a deselect state.\n", ti->TypeName.GetChars());
sc.Message(MSG_ERROR, "Weapon %s doesn't define a deselect state.\n", info->TypeName.GetChars());
}
if (!fire)
{
sc.Message(MSG_ERROR, "Weapon %s doesn't define a fire state.\n", ti->TypeName.GetChars());
sc.Message(MSG_ERROR, "Weapon %s doesn't define a fire state.\n", info->TypeName.GetChars());
}
}
}
@ -295,7 +281,7 @@ static void FinishThingdef()
}
else
{
FCompileContext ctx(tcall->ActorInfo->Class, true);
FCompileContext ctx(tcall->ActorClass, true);
for (j = 0; j < tcall->Parameters.Size(); ++j)
{
tcall->Parameters[j]->Resolve(ctx);
@ -325,7 +311,7 @@ static void FinishThingdef()
const char *marks = "=======================================================";
char label[64];
int labellen = mysnprintf(label, countof(label), "Function %s.States[%d] (*%d)",
tcall->ActorInfo->Class->TypeName.GetChars(),
tcall->ActorClass->TypeName.GetChars(),
tcall->FirstState, tcall->NumStates);
fprintf(dump, "\n%.*s %s %.*s", MAX(3, 38 - labellen / 2), marks, label, MAX(3, 38 - labellen / 2), marks);
fprintf(dump, "\nInteger regs: %-3d Float regs: %-3d Address regs: %-3d String regs: %-3d\nStack size: %d\n",
@ -337,7 +323,7 @@ static void FinishThingdef()
}
for (int k = 0; k < tcall->NumStates; ++k)
{
tcall->ActorInfo->OwnedStates[tcall->FirstState + k].SetAction(func);
tcall->ActorClass->OwnedStates[tcall->FirstState + k].SetAction(func);
}
}
fclose(dump);
@ -371,11 +357,11 @@ static void FinishThingdef()
}
// Since these are defined in DECORATE now the table has to be initialized here.
for(int i=0;i<31;i++)
for(int i = 0; i < 31; i++)
{
char fmt[20];
mysnprintf(fmt, countof(fmt), "QuestItem%d", i+1);
QuestItemClasses[i] = PClass::FindClass(fmt);
QuestItemClasses[i] = PClass::FindActor(fmt);
}
}