From 32e5be83ea529efb186cd0d522241811b7611200 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 1 Feb 2019 19:48:17 +0100 Subject: [PATCH] - moved a few more files and copied the data related parts of p_things.cpp to g_doomedmap.cpp --- src/CMakeLists.txt | 12 +- src/errors.h | 0 src/{ => g_shared}/statnums.h | 0 src/{ => gamedata}/d_dehacked.cpp | 0 src/{ => gamedata}/d_dehacked.h | 0 src/{ => gamedata}/g_doomedmap.cpp | 176 +++++++++++++++++++++++++++++ src/{ => gamedata}/info.cpp | 0 src/{ => gamedata}/info.h | 0 src/{ => gamedata}/keysections.cpp | 0 src/{ => gamedata}/p_terrain.cpp | 0 src/{ => gamedata}/p_terrain.h | 0 src/{ => gamedata}/teaminfo.cpp | 0 src/{ => gamedata}/teaminfo.h | 0 src/p_conversation.cpp | 11 -- src/p_conversation.h | 1 - src/p_things.cpp | 170 ---------------------------- 16 files changed, 182 insertions(+), 188 deletions(-) delete mode 100644 src/errors.h rename src/{ => g_shared}/statnums.h (100%) rename src/{ => gamedata}/d_dehacked.cpp (100%) rename src/{ => gamedata}/d_dehacked.h (100%) rename src/{ => gamedata}/g_doomedmap.cpp (67%) rename src/{ => gamedata}/info.cpp (100%) rename src/{ => gamedata}/info.h (100%) rename src/{ => gamedata}/keysections.cpp (100%) rename src/{ => gamedata}/p_terrain.cpp (100%) rename src/{ => gamedata}/p_terrain.h (100%) rename src/{ => gamedata}/teaminfo.cpp (100%) rename src/{ => gamedata}/teaminfo.h (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index da8e68db0..602166fe5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -892,7 +892,6 @@ set (PCH_SOURCES c_functions.cpp ct_chat.cpp cycler.cpp - d_dehacked.cpp d_iwad.cpp d_main.cpp d_anonstats.cpp @@ -905,7 +904,6 @@ set (PCH_SOURCES doomstat.cpp f_wipe.cpp g_cvars.cpp - g_doomedmap.cpp g_dumpinfo.cpp g_game.cpp g_hub.cpp @@ -914,8 +912,6 @@ set (PCH_SOURCES gitinfo.cpp hu_scores.cpp i_net.cpp - info.cpp - keysections.cpp m_cheat.cpp m_joy.cpp m_misc.cpp @@ -936,7 +932,6 @@ set (PCH_SOURCES p_setup.cpp p_spec.cpp p_states.cpp - p_terrain.cpp p_things.cpp p_tick.cpp p_usdf.cpp @@ -955,7 +950,6 @@ set (PCH_SOURCES st_stuff.cpp statistics.cpp stats.cpp - teaminfo.cpp v_2ddrawer.cpp v_blend.cpp v_draw.cpp @@ -975,6 +969,12 @@ set (PCH_SOURCES gamedata/stringtable.cpp gamedata/umapinfo.cpp gamedata/w_wad.cpp + gamedata/d_dehacked.cpp + gamedata/g_doomedmap.cpp + gamedata/info.cpp + gamedata/keysections.cpp + gamedata/p_terrain.cpp + gamedata/teaminfo.cpp g_shared/a_pickups.cpp g_shared/a_action.cpp g_shared/a_decals.cpp diff --git a/src/errors.h b/src/errors.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/statnums.h b/src/g_shared/statnums.h similarity index 100% rename from src/statnums.h rename to src/g_shared/statnums.h diff --git a/src/d_dehacked.cpp b/src/gamedata/d_dehacked.cpp similarity index 100% rename from src/d_dehacked.cpp rename to src/gamedata/d_dehacked.cpp diff --git a/src/d_dehacked.h b/src/gamedata/d_dehacked.h similarity index 100% rename from src/d_dehacked.h rename to src/gamedata/d_dehacked.h diff --git a/src/g_doomedmap.cpp b/src/gamedata/g_doomedmap.cpp similarity index 67% rename from src/g_doomedmap.cpp rename to src/gamedata/g_doomedmap.cpp index 6f99ded13..c1e3abc58 100644 --- a/src/g_doomedmap.cpp +++ b/src/gamedata/g_doomedmap.cpp @@ -97,6 +97,9 @@ static IdMap DoomEdFromMapinfo; //========================================================================== FDoomEdMap DoomEdMap; +// Set of spawnable things for the Thing_Spawn and Thing_Projectile specials. +FClassMap SpawnableThings; +FClassMap StrifeTypes; static int sortnums (const void *a, const void *b) { @@ -290,3 +293,176 @@ void InitActorNumsFromMapinfo() } DoomEdFromMapinfo.Clear(); // we do not need this any longer } + +PClassActor *P_GetSpawnableType(int spawnnum) +{ + if (spawnnum < 0) + { // A named arg from a UDMF map + FName spawnname = FName(ENamedName(-spawnnum)); + if (spawnname.IsValidName()) + { + return PClass::FindActor(spawnname); + } + } + else + { // A numbered arg from a Hexen or UDMF map + PClassActor **type = SpawnableThings.CheckKey(spawnnum); + if (type != NULL) + { + return *type; + } + } + return NULL; +} + +struct MapinfoSpawnItem +{ + FName classname; // DECORATE is read after MAPINFO so we do not have the actual classes available here yet. + // These are for error reporting. We must store the file information because it's no longer available when these items get resolved. + FString filename; + int linenum; +}; + +typedef TMap SpawnMap; +static SpawnMap SpawnablesFromMapinfo; +static SpawnMap ConversationIDsFromMapinfo; + +static int SpawnableSort(const void *a, const void *b) +{ + return (*((FClassMap::Pair **)a))->Key - (*((FClassMap::Pair **)b))->Key; +} + +static void DumpClassMap(FClassMap &themap) +{ + FClassMap::Iterator it(themap); + FClassMap::Pair *pair; + TArray allpairs(themap.CountUsed(), true); + int i = 0; + + // Sort into numerical order, since their arrangement in the map can + // be in an unspecified order. + while (it.NextPair(pair)) + { + allpairs[i++] = pair; + } + qsort(allpairs.Data(), i, sizeof(allpairs[0]), SpawnableSort); + for (int j = 0; j < i; ++j) + { + pair = allpairs[j]; + Printf ("%d %s\n", pair->Key, pair->Value->TypeName.GetChars()); + } +} + +CCMD(dumpspawnables) +{ + DumpClassMap(SpawnableThings); +} + +CCMD (dumpconversationids) +{ + DumpClassMap(StrifeTypes); +} + +void ClearStrifeTypes() +{ + StrifeTypes.Clear(); +} + + +static void ParseSpawnMap(FScanner &sc, SpawnMap & themap, const char *descript) +{ + TMap defined; + int error = 0; + + MapinfoSpawnItem editem; + + editem.filename = sc.ScriptName; + + while (true) + { + if (sc.CheckString("}")) return; + else if (sc.CheckNumber()) + { + int ednum = sc.Number; + sc.MustGetStringName("="); + sc.MustGetString(); + + bool *def = defined.CheckKey(ednum); + if (def != NULL) + { + sc.ScriptMessage("%s %d defined more than once", descript, ednum); + error++; + } + else if (ednum < 0) + { + sc.ScriptMessage("%s must be positive, got %d", descript, ednum); + error++; + } + defined[ednum] = true; + editem.classname = sc.String; + editem.linenum = sc.Line; + + themap.Insert(ednum, editem); + } + else + { + sc.ScriptError("Number expected"); + } + } + if (error > 0) + { + sc.ScriptError("%d errors encountered in %s definition", error, descript); + } +} + +void FMapInfoParser::ParseSpawnNums() +{ + ParseOpenBrace(); + ParseSpawnMap(sc, SpawnablesFromMapinfo, "Spawn number"); +} + +void FMapInfoParser::ParseConversationIDs() +{ + ParseOpenBrace(); + ParseSpawnMap(sc, ConversationIDsFromMapinfo, "Conversation ID"); +} + + +void InitClassMap(FClassMap &themap, SpawnMap &thedata) +{ + themap.Clear(); + SpawnMap::Iterator it(thedata); + SpawnMap::Pair *pair; + int error = 0; + + while (it.NextPair(pair)) + { + PClassActor *cls = NULL; + if (pair->Value.classname != NAME_None) + { + cls = PClass::FindActor(pair->Value.classname); + if (cls == NULL) + { + Printf(TEXTCOLOR_RED "Script error, \"%s\" line %d:\nUnknown actor class %s\n", + pair->Value.filename.GetChars(), pair->Value.linenum, pair->Value.classname.GetChars()); + error++; + } + themap.Insert(pair->Key, cls); + } + else + { + themap.Remove(pair->Key); + } + } + if (error > 0) + { + I_Error("%d unknown actor classes found", error); + } + thedata.Clear(); // we do not need this any longer +} + +void InitSpawnablesFromMapinfo() +{ + InitClassMap(SpawnableThings, SpawnablesFromMapinfo); + InitClassMap(StrifeTypes, ConversationIDsFromMapinfo); +} diff --git a/src/info.cpp b/src/gamedata/info.cpp similarity index 100% rename from src/info.cpp rename to src/gamedata/info.cpp diff --git a/src/info.h b/src/gamedata/info.h similarity index 100% rename from src/info.h rename to src/gamedata/info.h diff --git a/src/keysections.cpp b/src/gamedata/keysections.cpp similarity index 100% rename from src/keysections.cpp rename to src/gamedata/keysections.cpp diff --git a/src/p_terrain.cpp b/src/gamedata/p_terrain.cpp similarity index 100% rename from src/p_terrain.cpp rename to src/gamedata/p_terrain.cpp diff --git a/src/p_terrain.h b/src/gamedata/p_terrain.h similarity index 100% rename from src/p_terrain.h rename to src/gamedata/p_terrain.h diff --git a/src/teaminfo.cpp b/src/gamedata/teaminfo.cpp similarity index 100% rename from src/teaminfo.cpp rename to src/gamedata/teaminfo.cpp diff --git a/src/teaminfo.h b/src/gamedata/teaminfo.h similarity index 100% rename from src/teaminfo.h rename to src/gamedata/teaminfo.h diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index aaa46d256..92cca6185 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -97,7 +97,6 @@ struct TeaserSpeech static FRandom pr_randomspeech("RandomSpeech"); -FClassMap StrifeTypes; static int ConversationMenuY; // These two should be moved to player_t... @@ -121,16 +120,6 @@ static void TerminalResponse (const char *str); // //============================================================================ -void SetStrifeType(int convid, PClassActor *Class) -{ - StrifeTypes[convid] = Class; -} - -void ClearStrifeTypes() -{ - StrifeTypes.Clear(); -} - void FLevelLocals::SetConversation(int convid, PClassActor *Class, int dlgindex) { if (convid != -1) diff --git a/src/p_conversation.h b/src/p_conversation.h index ace3e4788..63e7707d9 100644 --- a/src/p_conversation.h +++ b/src/p_conversation.h @@ -59,7 +59,6 @@ struct FStrifeDialogueReply struct MapData; -void SetStrifeType(int convid, PClassActor *Class); PClassActor *GetStrifeType (int typenum); bool LoadScriptFile (FLevelLocals *Level, const char *name, bool include, int type = 0); diff --git a/src/p_things.cpp b/src/p_things.cpp index 9ef689e9c..e592319a4 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -47,9 +47,6 @@ #include "actorinlines.h" #include "vm.h" -// Set of spawnable things for the Thing_Spawn and Thing_Projectile specials. -FClassMap SpawnableThings; - static FRandom pr_leadtarget ("LeadTarget"); bool FLevelLocals::EV_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, int newtid) @@ -540,173 +537,6 @@ void P_Thing_SetVelocity(AActor *actor, const DVector3 &vec, bool add, bool setb } } -PClassActor *P_GetSpawnableType(int spawnnum) -{ - if (spawnnum < 0) - { // A named arg from a UDMF map - FName spawnname = FName(ENamedName(-spawnnum)); - if (spawnname.IsValidName()) - { - return PClass::FindActor(spawnname); - } - } - else - { // A numbered arg from a Hexen or UDMF map - PClassActor **type = SpawnableThings.CheckKey(spawnnum); - if (type != NULL) - { - return *type; - } - } - return NULL; -} - -struct MapinfoSpawnItem -{ - FName classname; // DECORATE is read after MAPINFO so we do not have the actual classes available here yet. - // These are for error reporting. We must store the file information because it's no longer available when these items get resolved. - FString filename; - int linenum; -}; - -typedef TMap SpawnMap; -static SpawnMap SpawnablesFromMapinfo; -static SpawnMap ConversationIDsFromMapinfo; - -static int SpawnableSort(const void *a, const void *b) -{ - return (*((FClassMap::Pair **)a))->Key - (*((FClassMap::Pair **)b))->Key; -} - -static void DumpClassMap(FClassMap &themap) -{ - FClassMap::Iterator it(themap); - FClassMap::Pair *pair; - TArray allpairs(themap.CountUsed(), true); - int i = 0; - - // Sort into numerical order, since their arrangement in the map can - // be in an unspecified order. - while (it.NextPair(pair)) - { - allpairs[i++] = pair; - } - qsort(allpairs.Data(), i, sizeof(allpairs[0]), SpawnableSort); - for (int j = 0; j < i; ++j) - { - pair = allpairs[j]; - Printf ("%d %s\n", pair->Key, pair->Value->TypeName.GetChars()); - } -} - -CCMD(dumpspawnables) -{ - DumpClassMap(SpawnableThings); -} - -CCMD (dumpconversationids) -{ - DumpClassMap(StrifeTypes); -} - - -static void ParseSpawnMap(FScanner &sc, SpawnMap & themap, const char *descript) -{ - TMap defined; - int error = 0; - - MapinfoSpawnItem editem; - - editem.filename = sc.ScriptName; - - while (true) - { - if (sc.CheckString("}")) return; - else if (sc.CheckNumber()) - { - int ednum = sc.Number; - sc.MustGetStringName("="); - sc.MustGetString(); - - bool *def = defined.CheckKey(ednum); - if (def != NULL) - { - sc.ScriptMessage("%s %d defined more than once", descript, ednum); - error++; - } - else if (ednum < 0) - { - sc.ScriptMessage("%s must be positive, got %d", descript, ednum); - error++; - } - defined[ednum] = true; - editem.classname = sc.String; - editem.linenum = sc.Line; - - themap.Insert(ednum, editem); - } - else - { - sc.ScriptError("Number expected"); - } - } - if (error > 0) - { - sc.ScriptError("%d errors encountered in %s definition", error, descript); - } -} - -void FMapInfoParser::ParseSpawnNums() -{ - ParseOpenBrace(); - ParseSpawnMap(sc, SpawnablesFromMapinfo, "Spawn number"); -} - -void FMapInfoParser::ParseConversationIDs() -{ - ParseOpenBrace(); - ParseSpawnMap(sc, ConversationIDsFromMapinfo, "Conversation ID"); -} - - -void InitClassMap(FClassMap &themap, SpawnMap &thedata) -{ - themap.Clear(); - SpawnMap::Iterator it(thedata); - SpawnMap::Pair *pair; - int error = 0; - - while (it.NextPair(pair)) - { - PClassActor *cls = NULL; - if (pair->Value.classname != NAME_None) - { - cls = PClass::FindActor(pair->Value.classname); - if (cls == NULL) - { - Printf(TEXTCOLOR_RED "Script error, \"%s\" line %d:\nUnknown actor class %s\n", - pair->Value.filename.GetChars(), pair->Value.linenum, pair->Value.classname.GetChars()); - error++; - } - themap.Insert(pair->Key, cls); - } - else - { - themap.Remove(pair->Key); - } - } - if (error > 0) - { - I_Error("%d unknown actor classes found", error); - } - thedata.Clear(); // we do not need this any longer -} - -void InitSpawnablesFromMapinfo() -{ - InitClassMap(SpawnableThings, SpawnablesFromMapinfo); - InitClassMap(StrifeTypes, ConversationIDsFromMapinfo); -} int P_Thing_CheckInputNum(player_t *p, int inputnum) { int renum = 0;