- fixed a few things.

This commit is contained in:
Christoph Oelckers 2018-11-09 19:51:47 +01:00
parent b7365fb70f
commit 24f5dc0b27
8 changed files with 36 additions and 41 deletions

View file

@ -53,6 +53,7 @@
#include "vm.h" #include "vm.h"
#include "actor.h" #include "actor.h"
#include "maploader/mapdata.h" #include "maploader/mapdata.h"
#include "maploader/maploader.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
@ -79,8 +80,6 @@ enum
// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- // PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
// EXTERNAL DATA DECLARATIONS ---------------------------------------------- // EXTERNAL DATA DECLARATIONS ----------------------------------------------
extern TArray<FMapThing> MapThingsConverted;
extern bool ForceNodeBuild;
// PUBLIC DATA DEFINITIONS ------------------------------------------------- // PUBLIC DATA DEFINITIONS -------------------------------------------------
@ -311,9 +310,11 @@ FName CheckCompatibility(MapData *map)
// SetCompatibilityParams // SetCompatibilityParams
// //
//========================================================================== //==========================================================================
static MapLoader *maploader; // so that the script functions have access. Should be done more cleanly later.
void SetCompatibilityParams(FName checksum) void MapLoader::SetCompatibilityParams(FName checksum)
{ {
maploader = this;
if (checksum != NAME_None) if (checksum != NAME_None)
{ {
PClass *const cls = PClass::FindClass("LevelCompatibility"); PClass *const cls = PClass::FindClass("LevelCompatibility");
@ -327,6 +328,7 @@ void SetCompatibilityParams(FName checksum)
} }
} }
} }
maploader = nullptr;
} }
DEFINE_ACTION_FUNCTION(DLevelCompatibility, OffsetSectorPlane) DEFINE_ACTION_FUNCTION(DLevelCompatibility, OffsetSectorPlane)
@ -336,7 +338,7 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, OffsetSectorPlane)
PARAM_INT(planeval); PARAM_INT(planeval);
PARAM_FLOAT(delta); PARAM_FLOAT(delta);
sector_t *sec = &level.sectors[sector]; sector_t *sec = &maploader->sectors[sector];
secplane_t& plane = sector_t::floor == planeval? sec->floorplane : sec->ceilingplane; secplane_t& plane = sector_t::floor == planeval? sec->floorplane : sec->ceilingplane;
plane.ChangeHeight(delta); plane.ChangeHeight(delta);
sec->ChangePlaneTexZ(planeval, delta); sec->ChangePlaneTexZ(planeval, delta);
@ -347,7 +349,7 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, ClearSectorTags)
{ {
PARAM_PROLOGUE; PARAM_PROLOGUE;
PARAM_INT(sector); PARAM_INT(sector);
tagManager.RemoveSectorTags(sector); maploader->tagManager->RemoveSectorTags(sector);
return 0; return 0;
} }
@ -356,7 +358,7 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, AddSectorTag)
PARAM_PROLOGUE; PARAM_PROLOGUE;
PARAM_INT(sector); PARAM_INT(sector);
PARAM_INT(tag); PARAM_INT(tag);
tagManager.AddSectorTag(sector, tag); maploader->tagManager->AddSectorTag(sector, tag);
return 0; return 0;
} }
@ -366,9 +368,9 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetThingSkills)
PARAM_INT(thing); PARAM_INT(thing);
PARAM_INT(skillmask); PARAM_INT(skillmask);
if ((unsigned)thing < MapThingsConverted.Size()) if ((unsigned)thing < maploader->MapThingsConverted.Size())
{ {
MapThingsConverted[thing].SkillFilter = skillmask; maploader->MapThingsConverted[thing].SkillFilter = skillmask;
} }
return 0; return 0;
} }
@ -380,9 +382,9 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetThingXY)
PARAM_FLOAT(x); PARAM_FLOAT(x);
PARAM_FLOAT(y); PARAM_FLOAT(y);
if ((unsigned)thing < MapThingsConverted.Size()) if ((unsigned)thing < maploader->MapThingsConverted.Size())
{ {
auto& pos = MapThingsConverted[thing].pos; auto& pos = maploader->MapThingsConverted[thing].pos;
pos.X = x; pos.X = x;
pos.Y = y; pos.Y = y;
} }
@ -395,9 +397,9 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetThingZ)
PARAM_INT(thing); PARAM_INT(thing);
PARAM_FLOAT(z); PARAM_FLOAT(z);
if ((unsigned)thing < MapThingsConverted.Size()) if ((unsigned)thing < maploader->MapThingsConverted.Size())
{ {
MapThingsConverted[thing].pos.Z = z; maploader->MapThingsConverted[thing].pos.Z = z;
} }
return 0; return 0;
} }
@ -408,9 +410,9 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetThingFlags)
PARAM_INT(thing); PARAM_INT(thing);
PARAM_INT(flags); PARAM_INT(flags);
if ((unsigned)thing < MapThingsConverted.Size()) if ((unsigned)thing < maploader->MapThingsConverted.Size())
{ {
MapThingsConverted[thing].flags = flags; maploader->MapThingsConverted[thing].flags = flags;
} }
return 0; return 0;
} }
@ -422,11 +424,11 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetVertex)
PARAM_FLOAT(x); PARAM_FLOAT(x);
PARAM_FLOAT(y); PARAM_FLOAT(y);
if (vertex < level.vertexes.Size()) if (vertex < maploader->vertexes.Size())
{ {
level.vertexes[vertex].p = DVector2(x, y); maploader->vertexes[vertex].p = DVector2(x, y);
} }
ForceNodeBuild = true; maploader->ForceNodeBuild = true;
return 0; return 0;
} }
@ -438,16 +440,16 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetLineSectorRef)
PARAM_UINT(sectoridx); PARAM_UINT(sectoridx);
if ( sideidx < 2 if ( sideidx < 2
&& lineidx < level.lines.Size() && lineidx < maploader->lines.Size()
&& sectoridx < level.sectors.Size()) && sectoridx < maploader->sectors.Size())
{ {
line_t *line = &level.lines[lineidx]; line_t *line = &maploader->lines[lineidx];
side_t *side = line->sidedef[sideidx]; side_t *side = line->sidedef[sideidx];
side->sector = &level.sectors[sectoridx]; side->sector = &maploader->sectors[sectoridx];
if (sideidx == 0) line->frontsector = side->sector; if (sideidx == 0) line->frontsector = side->sector;
else line->backsector = side->sector; else line->backsector = side->sector;
} }
ForceNodeBuild = true; maploader->ForceNodeBuild = true;
return 0; return 0;
} }

View file

@ -37,9 +37,10 @@ struct FMD5HashTraits
}; };
extern TMap<FMD5Holder, FCompatValues, FMD5HashTraits> BCompatMap; extern TMap<FMD5Holder, FCompatValues, FMD5HashTraits> BCompatMap;
class MapLoader;
void ParseCompatibility(); void ParseCompatibility();
FName CheckCompatibility(MapData *map); FName CheckCompatibility(MapData *map);
void SetCompatibilityParams(FName); void SetCompatibilityParams(MapLoader *ml, FName checksum);
#endif #endif

View file

@ -1374,8 +1374,8 @@ void MapLoader::LoadThings (MapData * map)
int lumplen = map->Size(ML_THINGS); int lumplen = map->Size(ML_THINGS);
int numthings = lumplen / sizeof(mapthing_t); int numthings = lumplen / sizeof(mapthing_t);
TArray<uint8_t> mtp; TArray<uint8_t> mtp(lumplen, true);
map->Read(ML_THINGS, mtp.Data()); map->Read(ML_THINGS, mtp.Data());
auto mt = (mapthing_t*)mtp.Data(); auto mt = (mapthing_t*)mtp.Data();
MapThingsConverted.Resize(numthings); MapThingsConverted.Resize(numthings);
@ -1467,7 +1467,7 @@ void MapLoader::LoadThings2 (MapData * map)
MapThingsConverted.Resize(numthings); MapThingsConverted.Resize(numthings);
FMapThing *mti = &MapThingsConverted[0]; FMapThing *mti = &MapThingsConverted[0];
TArray<uint8_t> mtp; TArray<uint8_t> mtp(lumplen, true);
map->Read(ML_THINGS, mtp.Data()); map->Read(ML_THINGS, mtp.Data());
auto mth = (mapthinghexen_t*)mtp.Data(); auto mth = (mapthinghexen_t*)mtp.Data();
@ -1488,7 +1488,7 @@ void MapLoader::LoadThings2 (MapData * map)
mti[i].SkillFilter = MakeSkill(mti[i].flags); mti[i].SkillFilter = MakeSkill(mti[i].flags);
mti[i].ClassFilter = (mti[i].flags & MTF_CLASS_MASK) >> MTF_CLASS_SHIFT; mti[i].ClassFilter = (mti[i].flags & MTF_CLASS_MASK) >> MTF_CLASS_SHIFT;
mti[i].flags &= ~(MTF_SKILLMASK|MTF_CLASS_MASK); mti[i].flags &= ~(MTF_SKILLMASK|MTF_CLASS_MASK);
if (level->flags2 & LEVEL2_HEXENHACK) if (level && (level->flags2 & LEVEL2_HEXENHACK))
{ {
mti[i].flags &= 0x7ff; // mask out Strife flags if playing an original Hexen map. mti[i].flags &= 0x7ff; // mask out Strife flags if playing an original Hexen map.
} }

View file

@ -175,6 +175,7 @@ public:
void SetRenderSector(); void SetRenderSector();
void FixMinisegReferences(); void FixMinisegReferences();
void FixHoles(); void FixHoles();
void SetCompatibilityParams(FName checksum);
void ParseTextMap(MapData *map, FMissingTextureTracker &missingtex); void ParseTextMap(MapData *map, FMissingTextureTracker &missingtex);

View file

@ -49,10 +49,6 @@
#include "m_misc.h" #include "m_misc.h"
#include "g_levellocals.h" #include "g_levellocals.h"
// should be moved into the map loader later but for now it is referenced from too many parts elsewhere.
extern TArray<FMapThing> MapThingsConverted;
CVAR(Bool, gl_cachenodes, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, gl_cachenodes, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(Float, gl_cachetime, 0.6f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_cachetime, 0.6f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)

View file

@ -279,7 +279,6 @@ void MapLoader::VavoomSlope(sector_t * sec, int id, const DVector3 &pos, int whi
void MapLoader::SetSlopesFromVertexHeights() void MapLoader::SetSlopesFromVertexHeights()
{ {
TMap<int, double> vt_heights[2]; TMap<int, double> vt_heights[2];
FMapThing *mt;
bool vt_found = false; bool vt_found = false;
for (unsigned i=0;i<MapThingsConverted.Size(); i++) for (unsigned i=0;i<MapThingsConverted.Size(); i++)

View file

@ -563,6 +563,7 @@ void P_SetupLevel (const char *lumpname, int position, bool newGame)
MapLoader maploader(level, &tagManager); MapLoader maploader(level, &tagManager);
maploader.maptype = level.maptype; maploader.maptype = level.maptype;
maploader.ForceNodeBuild = gennodes; maploader.ForceNodeBuild = gennodes;
maploader.level = &level;
if (ib_compatflags & BCOMPATF_REBUILDNODES) if (ib_compatflags & BCOMPATF_REBUILDNODES)
{ {
@ -597,7 +598,7 @@ void P_SetupLevel (const char *lumpname, int position, bool newGame)
} }
times[0].Unclock(); times[0].Unclock();
SetCompatibilityParams(checksum); maploader.SetCompatibilityParams(checksum);
maploader.LoopSidedefs (true); maploader.LoopSidedefs (true);

View file

@ -126,11 +126,6 @@ enum
// namespace for each game // namespace for each game
}; };
void SpawnMapThing(int index, FMapThing *mt, int position);
extern bool ForceNodeBuild;
extern TArray<FMapThing> MapThingsConverted;
#define CHECK_N(f) if (!(namespace_bits&(f))) break; #define CHECK_N(f) if (!(namespace_bits&(f))) break;
@ -1967,7 +1962,7 @@ public:
{ {
Printf ("Removing 0-length line %d\n", i+skipped); Printf ("Removing 0-length line %d\n", i+skipped);
ParsedLines.Delete(i); ParsedLines.Delete(i);
ForceNodeBuild = true; maploader->ForceNodeBuild = true;
skipped++; skipped++;
} }
else else
@ -2134,10 +2129,10 @@ public:
FMapThing th; FMapThing th;
unsigned userdatastart = maploader->MapThingsUserData.Size(); unsigned userdatastart = maploader->MapThingsUserData.Size();
ParseThing(&th); ParseThing(&th);
MapThingsConverted.Push(th); maploader->MapThingsConverted.Push(th);
if (userdatastart < maploader->MapThingsUserData.Size()) if (userdatastart < maploader->MapThingsUserData.Size())
{ // User data added { // User data added
maploader->MapThingsUserDataIndex[MapThingsConverted.Size()-1] = userdatastart; maploader->MapThingsUserDataIndex[maploader->MapThingsConverted.Size()-1] = userdatastart;
// Mark end of the user data for this map thing // Mark end of the user data for this map thing
FUDMFKey ukey; FUDMFKey ukey;
ukey.Key = NAME_None; ukey.Key = NAME_None;