mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-19 16:11:23 +00:00
- moved a few more files and copied the data related parts of p_things.cpp to g_doomedmap.cpp
This commit is contained in:
parent
a1cc548af4
commit
32e5be83ea
16 changed files with 182 additions and 188 deletions
|
@ -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
|
||||
|
|
|
@ -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<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);
|
||||
}
|
||||
|
||||
void ClearStrifeTypes()
|
||||
{
|
||||
StrifeTypes.Clear();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
170
src/p_things.cpp
170
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<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;
|
||||
|
|
Loading…
Reference in a new issue