- moved a few more files and copied the data related parts of p_things.cpp to g_doomedmap.cpp

This commit is contained in:
Christoph Oelckers 2019-02-01 19:48:17 +01:00
commit 32e5be83ea
16 changed files with 182 additions and 188 deletions

View file

@ -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<int, MapinfoSpawnItem> 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<FClassMap::Pair*> 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<int, bool> 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;