2018-12-27 16:11:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-12-28 22:14:11 +00:00
|
|
|
#include "nodebuild.h"
|
|
|
|
|
2018-12-27 16:11:10 +00:00
|
|
|
struct EDMapthing
|
|
|
|
{
|
|
|
|
int recordnum;
|
|
|
|
int tid;
|
|
|
|
int type;
|
|
|
|
double height;
|
|
|
|
int args[5];
|
|
|
|
uint16_t skillfilter;
|
|
|
|
uint32_t flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct EDLinedef
|
|
|
|
{
|
|
|
|
int recordnum;
|
|
|
|
int special;
|
|
|
|
int tag;
|
|
|
|
int id;
|
|
|
|
int args[5];
|
|
|
|
double alpha;
|
|
|
|
uint32_t flags;
|
|
|
|
uint32_t activation;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct EDSector
|
|
|
|
{
|
|
|
|
int recordnum;
|
|
|
|
|
|
|
|
uint32_t flags;
|
|
|
|
uint32_t flagsRemove;
|
|
|
|
uint32_t flagsAdd;
|
|
|
|
|
|
|
|
int damageamount;
|
|
|
|
int damageinterval;
|
|
|
|
FName damagetype;
|
|
|
|
uint8_t leaky;
|
|
|
|
uint8_t leakyadd;
|
|
|
|
uint8_t leakyremove;
|
|
|
|
int floorterrain;
|
|
|
|
int ceilingterrain;
|
|
|
|
|
|
|
|
uint32_t color;
|
|
|
|
|
|
|
|
uint32_t damageflags;
|
|
|
|
uint32_t damageflagsAdd;
|
|
|
|
uint32_t damageflagsRemove;
|
|
|
|
|
|
|
|
bool flagsSet;
|
|
|
|
bool damageflagsSet;
|
|
|
|
bool colorSet;
|
|
|
|
|
|
|
|
// colormaptop//bottom cannot be used because ZDoom has no corresponding properties.
|
|
|
|
double xoffs[2], yoffs[2];
|
|
|
|
DAngle angle[2];
|
|
|
|
uint32_t portalflags[2];
|
|
|
|
double Overlayalpha[2];
|
|
|
|
};
|
|
|
|
|
2018-12-28 14:30:23 +00:00
|
|
|
struct sidei_t // [RH] Only keep BOOM sidedef init stuff around for init
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
// Used when unpacking sidedefs and assigning
|
|
|
|
// properties based on linedefs.
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
short tag, special;
|
|
|
|
short alpha;
|
|
|
|
uint32_t map;
|
|
|
|
} a;
|
|
|
|
|
|
|
|
// Used when grouping sidedefs into loops.
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32_t first, next;
|
|
|
|
char lineside;
|
|
|
|
} b;
|
|
|
|
};
|
|
|
|
};
|
2018-12-27 16:11:10 +00:00
|
|
|
|
|
|
|
struct FMissingCount
|
|
|
|
{
|
|
|
|
int Count = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef TMap<FString,FMissingCount> FMissingTextureTracker;
|
|
|
|
struct FLevelLocals;
|
2018-12-28 22:14:11 +00:00
|
|
|
struct MapData;
|
2018-12-27 16:11:10 +00:00
|
|
|
|
|
|
|
class MapLoader
|
|
|
|
{
|
|
|
|
friend class UDMFParser;
|
|
|
|
void *level; // this is to hide the global variable and produce an error for referencing it.
|
|
|
|
FLevelLocals *Level;
|
|
|
|
|
|
|
|
int firstglvertex; // helpers for loading GL nodes from GWA files.
|
|
|
|
bool format5;
|
|
|
|
|
|
|
|
TArray<vertexdata_t> vertexdatas;
|
|
|
|
|
|
|
|
TMap<unsigned, unsigned> MapThingsUserDataIndex; // from mapthing idx -> user data idx
|
|
|
|
TArray<FUDMFKey> MapThingsUserData;
|
2018-12-28 09:08:39 +00:00
|
|
|
int sidecount = 0;
|
2018-12-27 16:11:10 +00:00
|
|
|
TArray<int> linemap;
|
2018-12-28 14:30:23 +00:00
|
|
|
TArray<sidei_t> sidetemp;
|
2018-12-28 22:14:11 +00:00
|
|
|
public: // for the scripted compatibility system these two members need to be public.
|
|
|
|
TArray<FMapThing> MapThingsConverted;
|
|
|
|
bool ForceNodeBuild = false;
|
|
|
|
private:
|
2018-12-27 16:11:10 +00:00
|
|
|
|
2018-12-28 13:48:10 +00:00
|
|
|
// Extradata loader
|
2018-12-27 16:11:10 +00:00
|
|
|
TMap<int, EDLinedef> EDLines;
|
|
|
|
TMap<int, EDSector> EDSectors;
|
|
|
|
TMap<int, EDMapthing> EDThings;
|
|
|
|
|
2018-12-28 13:48:10 +00:00
|
|
|
// Polyobject init
|
|
|
|
TArray<int32_t> KnownPolySides;
|
|
|
|
|
2018-12-28 22:14:11 +00:00
|
|
|
FName CheckCompatibility(MapData *map);
|
|
|
|
void SetCompatibilityParams(FName checksum);
|
|
|
|
|
2018-12-28 14:51:32 +00:00
|
|
|
// Slopes
|
2018-12-27 16:11:10 +00:00
|
|
|
void SlopeLineToPoint(int lineid, const DVector3 &pos, bool slopeCeil);
|
|
|
|
void CopyPlane(int tag, sector_t *dest, bool copyCeil);
|
|
|
|
void CopyPlane(int tag, const DVector2 &pos, bool copyCeil);
|
|
|
|
void SetSlope(secplane_t *plane, bool setCeil, int xyangi, int zangi, const DVector3 &pos);
|
|
|
|
void VavoomSlope(sector_t * sec, int id, const DVector3 &pos, int which);
|
|
|
|
void SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt, const int *oldvertextable);
|
|
|
|
void AlignPlane(sector_t *sec, line_t *line, int which);
|
|
|
|
|
2018-12-28 14:51:32 +00:00
|
|
|
// Extradata
|
2018-12-27 16:11:10 +00:00
|
|
|
void InitED();
|
|
|
|
void ProcessEDMapthing(FMapThing *mt, int recordnum);
|
|
|
|
void ProcessEDLinedef(line_t *line, int recordnum);
|
|
|
|
void ProcessEDSector(sector_t *sec, int recordnum);
|
2018-12-28 13:48:10 +00:00
|
|
|
|
2018-12-28 14:51:32 +00:00
|
|
|
// Polyobjects
|
2018-12-28 13:48:10 +00:00
|
|
|
void InitSideLists();
|
|
|
|
void IterFindPolySides(FPolyObj *po, side_t *side);
|
|
|
|
void SpawnPolyobj(int index, int tag, int type);
|
|
|
|
void TranslateToStartSpot(int tag, const DVector2 &origin);
|
|
|
|
void InitPolyBlockMap(void);
|
2018-12-27 16:11:10 +00:00
|
|
|
|
2018-12-28 14:51:32 +00:00
|
|
|
// GL nodes
|
2018-12-27 16:11:10 +00:00
|
|
|
int checkGLVertex(int num);
|
|
|
|
int checkGLVertex3(int num);
|
|
|
|
int CheckForMissingSegs();
|
|
|
|
bool LoadGLVertexes(FileReader &lump);
|
|
|
|
bool LoadGLSegs(FileReader &lump);
|
|
|
|
bool LoadGLSubsectors(FileReader &lump);
|
|
|
|
bool LoadNodes(FileReader &lump);
|
|
|
|
bool DoLoadGLNodes(FileReader * lumps);
|
|
|
|
void CreateCachedNodes(MapData *map);
|
|
|
|
|
2018-12-28 14:51:32 +00:00
|
|
|
// Render info
|
|
|
|
void PrepareSectorData();
|
|
|
|
void PrepareTransparentDoors(sector_t * sector);
|
|
|
|
void InitVertexData();
|
|
|
|
void GetSideVertices(int sdnum, DVector2 *v1, DVector2 *v2);
|
|
|
|
void PrepareSegs();
|
|
|
|
void InitRenderInfo();
|
|
|
|
void FixMinisegReferences();
|
|
|
|
void FixHoles();
|
|
|
|
void ReportUnpairedMinisegs();
|
2019-01-05 23:41:46 +00:00
|
|
|
void CalcIndices();
|
2018-12-28 14:51:32 +00:00
|
|
|
|
2018-12-27 16:11:10 +00:00
|
|
|
void SetTexture(side_t *side, int position, const char *name, FMissingTextureTracker &track);
|
|
|
|
void SetTexture(sector_t *sector, int index, int position, const char *name, FMissingTextureTracker &track, bool truncate);
|
|
|
|
void SetTexture(side_t *side, int position, uint32_t *blend, const char *name);
|
|
|
|
void SetTextureNoErr(side_t *side, int position, uint32_t *color, const char *name, bool *validcolor, bool isFog);
|
|
|
|
|
|
|
|
void FloodZone(sector_t *sec, int zonenum);
|
|
|
|
void LoadGLZSegs(FileReader &data, int type);
|
|
|
|
void LoadZSegs(FileReader &data);
|
|
|
|
void LoadZNodes(FileReader &data, int glnodes);
|
|
|
|
|
|
|
|
int DetermineTranslucency(int lumpnum);
|
|
|
|
void SetLineID(int i, line_t *ld);
|
|
|
|
void SaveLineSpecial(line_t *ld);
|
|
|
|
void FinishLoadingLineDef(line_t *ld, int alpha);
|
|
|
|
void SetSideNum(side_t **sidenum_p, uint16_t sidenum);
|
|
|
|
void AllocateSideDefs(MapData *map, int count);
|
|
|
|
void ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec, intmapsidedef_t *msd, int special, int tag, short *alpha, FMissingTextureTracker &missingtex);
|
|
|
|
void SetMapThingUserData(AActor *actor, unsigned udi);
|
|
|
|
void CreateBlockMap();
|
2018-12-28 09:08:39 +00:00
|
|
|
void PO_Init(void);
|
2018-12-27 16:11:10 +00:00
|
|
|
|
2019-01-05 23:41:46 +00:00
|
|
|
// During map init the items' own Index functions should not be used.
|
|
|
|
inline int Index(vertex_t *v) const
|
|
|
|
{
|
|
|
|
return int(v - &Level->vertexes[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int Index(side_t *v) const
|
|
|
|
{
|
|
|
|
return int(v - &Level->sides[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int Index(line_t *v) const
|
|
|
|
{
|
|
|
|
return int(v - &Level->lines[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int Index(seg_t *v) const
|
|
|
|
{
|
|
|
|
return int(v - &Level->segs[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int Index(subsector_t *v) const
|
|
|
|
{
|
|
|
|
return int(v - &Level->subsectors[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int Index(node_t *v) const
|
|
|
|
{
|
|
|
|
return int(v - &Level->nodes[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int Index(sector_t *v) const
|
|
|
|
{
|
|
|
|
return int(v - &Level->sectors[0]);
|
|
|
|
}
|
|
|
|
|
2018-12-27 16:11:10 +00:00
|
|
|
public:
|
|
|
|
void LoadMapinfoACSLump();
|
|
|
|
void ProcessEDSectors();
|
|
|
|
|
|
|
|
void FloodZones();
|
|
|
|
void LoadVertexes(MapData * map);
|
|
|
|
void LoadExtendedNodes(FileReader &dalump, uint32_t id);
|
|
|
|
template<class segtype> void LoadSegs(MapData * map);
|
|
|
|
template<class subsectortype, class segtype> void LoadSubsectors(MapData * map);
|
|
|
|
template<class nodetype, class subsectortype> void LoadNodes(MapData * map);
|
|
|
|
bool LoadGLNodes(MapData * map);
|
|
|
|
bool CheckCachedNodes(MapData *map);
|
|
|
|
bool CheckNodes(MapData * map, bool rebuilt, int buildtime);
|
|
|
|
bool CheckForGLNodes();
|
|
|
|
|
|
|
|
void LoadSectors(MapData *map, FMissingTextureTracker &missingtex);
|
|
|
|
void LoadThings(MapData * map);
|
|
|
|
void LoadThings2(MapData * map);
|
|
|
|
|
|
|
|
void SpawnThings(int position);
|
|
|
|
void FinishLoadingLineDefs();
|
|
|
|
void LoadLineDefs(MapData * map);
|
|
|
|
void LoadLineDefs2(MapData * map);
|
|
|
|
void LoopSidedefs(bool firstloop);
|
|
|
|
void LoadSideDefs2(MapData *map, FMissingTextureTracker &missingtex);
|
|
|
|
void LoadBlockMap(MapData * map);
|
|
|
|
void LoadReject(MapData * map, bool junk);
|
|
|
|
void LoadBehavior(MapData * map);
|
|
|
|
void GetPolySpots(MapData * map, TArray<FNodeBuilder::FPolyStart> &spots, TArray<FNodeBuilder::FPolyStart> &anchors);
|
|
|
|
void GroupLines(bool buildmap);
|
|
|
|
void ParseTextMap(MapData *map, FMissingTextureTracker &missingtex);
|
|
|
|
void SummarizeMissingTextures(const FMissingTextureTracker &missing);
|
|
|
|
void SetRenderSector();
|
|
|
|
void SpawnSlopeMakers(FMapThing *firstmt, FMapThing *lastmt, const int *oldvertextable);
|
|
|
|
void SetSlopes();
|
|
|
|
void CopySlopes();
|
|
|
|
|
2018-12-27 22:34:07 +00:00
|
|
|
void LoadLevel(MapData *map, const char *lumpname, int position);
|
|
|
|
|
2018-12-27 16:11:10 +00:00
|
|
|
MapLoader(FLevelLocals *lev)
|
|
|
|
{
|
|
|
|
Level = lev;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|