From cbd8de36a9206672a0592ec522a565ab8f90d6af Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 26 Jan 2022 23:53:05 +0100 Subject: [PATCH] - 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. --- source/core/defparser.cpp | 35 +++++++++++++++++++++++++++++++++++ source/core/gamecontrol.h | 16 ++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/source/core/defparser.cpp b/source/core/defparser.cpp index e1148b861..8d8e37853 100644 --- a/source/core/defparser.cpp +++ b/source/core/defparser.cpp @@ -2226,6 +2226,39 @@ static void parseDefineQAV(FScanner& sc, FScriptPosition& pos) 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 }, { "rffdefineid", parseRffDefineId }, { "defineqav", parseDefineQAV }, + + { "spawnclasses", parseSpawnClasses }, { nullptr, nullptr }, }; diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index 1e33f98d0..b97b9eeec 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -263,3 +263,19 @@ enum gameaction_t : int ga_fullconsole, }; 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; +inline SpawnMap spawnMap;