- added spawn number parser to .DEF.

This is for mapping actor classes to whatever the games use to decide what kind of actor a sprite is.
This commit is contained in:
Christoph Oelckers 2022-01-26 23:53:05 +01:00
parent d9fee902de
commit cbd8de36a9
2 changed files with 51 additions and 0 deletions

View file

@ -2226,6 +2226,39 @@ static void parseDefineQAV(FScanner& sc, FScriptPosition& pos)
fileSystem.CreatePathlessCopy(fn, res_id, 0); fileSystem.CreatePathlessCopy(fn, res_id, 0);
} }
static void parseSpawnClasses(FScanner& sc, FScriptPosition& pos)
{
FString fn;
int res_id = -1;
int numframes = -1;
bool interpolate = false;
sc.SetCMode(true);
if (!sc.CheckString("{"))
{
pos.Message(MSG_ERROR, "spawnclasses:'{' expected, unable to continue");
sc.SetCMode(false);
return;
}
while (!sc.CheckString("}"))
{
int num = -1;
int base = -1;
FName cname;
sc.GetNumber(num, true);
sc.MustGetStringName("=");
sc.MustGetString();
cname = sc.String;
if (sc.CheckString(","))
{
sc.GetNumber(base, true);
}
// todo: check for proper base class
spawnMap.Insert(num, { cname, nullptr, base });
}
sc.SetCMode(false);
}
//=========================================================================== //===========================================================================
// //
@ -2318,6 +2351,8 @@ static const dispatch basetokens[] =
{ "newgamechoices", parseEmptyBlock }, { "newgamechoices", parseEmptyBlock },
{ "rffdefineid", parseRffDefineId }, { "rffdefineid", parseRffDefineId },
{ "defineqav", parseDefineQAV }, { "defineqav", parseDefineQAV },
{ "spawnclasses", parseSpawnClasses },
{ nullptr, nullptr }, { nullptr, nullptr },
}; };

View file

@ -263,3 +263,19 @@ enum gameaction_t : int
ga_fullconsole, ga_fullconsole,
}; };
extern gameaction_t gameaction; extern gameaction_t gameaction;
struct SpawnRec
{
FName clsname;
PClass* cls;
int param;
PClass* Class()
{
if (!cls && clsname != NAME_None) cls = PClass::FindClass(clsname);
clsname = NAME_None;
return cls;
}
};
using SpawnMap = TMap<int, SpawnRec>;
inline SpawnMap spawnMap;