- sector extension basics.

This commit is contained in:
Christoph Oelckers 2021-11-20 17:35:41 +01:00
parent 46f4f17644
commit 14907a9a97
7 changed files with 98 additions and 15 deletions

View file

@ -1,6 +1,7 @@
#ifndef buildtypes_h__
#define buildtypes_h__
#include "ns.h"
//ceilingstat/floorstat:
// bit 0: 1 = parallaxing, 0 = not "P"
// bit 1: 1 = sloped, 0 = not
@ -49,12 +50,11 @@ enum
PORTAL_SECTOR_GEOMETRY = 8,
};
namespace Blood
{
BEGIN_BLD_NS
struct XWALL;
struct XSECTOR;
}
class DBloodActor;
END_BLD_NS
namespace ShadowWarrior
{
@ -87,6 +87,55 @@ struct sectortype
uint8_t portalflags;
int8_t portalnum;
// section reference (not written to a savegame
int numsections;
int* sections;
union
{
struct // DukeRR
{
uint8_t keyinfo;
uint8_t shadedsector;
};
struct // Blood
{
BLD_NS::XSECTOR* _xs;
uint8_t q_filler;
int baseFloor, baseCeil;
int velFloor, velCeil;
BLD_NS::DBloodActor* upperLink;
BLD_NS::DBloodActor* lowerLink;
};
struct // Exhumed
{
int SoundSect;
int Depth;
int Above;
int Below;
short Sound;
short Flag;
short Damage;
short Speed;
};
struct // SW
{
// No need to allocate this on demand as it is smaller than what Blood needs.
bool defined;
int dist, flags;
int depth_fixed;
short stag, // ST? tag number - for certain things it helps to know it
ang,
height,
speed,
damage,
number; // usually used for matching number
uint8_t flags2;
};
};
int ceilingxpan() const { return int(ceilingxpan_); }
int ceilingypan() const { return int(ceilingypan_); }
int floorxpan() const { return int(floorxpan_); }
@ -101,10 +150,11 @@ struct sectortype
void addceilingypan(float add) { ceilingypan_ = fmodf(ceilingypan_ + add + 512, 256); } // +512 is for handling negative offsets
walltype *firstWall() const;
// These will unfortunately have to be within the base struct to refactor Blood properly. They can later be removed again, once everything is done.
Blood::XSECTOR& xs() const;
bool hasX() const { return extra > 0; } // 0 is invalid!
void addX();
void allocX();
// same for SW
ShadowWarrior::SECT_USER* u() const;

View file

@ -194,6 +194,11 @@ inline bool isShareware()
return g_gameType & GAMEFLAG_SHAREWARE;
}
inline bool isDukeLike()
{
return g_gameType & (GAMEFLAG_NAM | GAMEFLAG_NAPALM | GAMEFLAG_WW2GI | GAMEFLAG_DUKE | GAMEFLAG_RRALL);
}
inline bool isBlood()
{
return g_gameType & GAMEFLAG_BLOOD;

View file

@ -69,6 +69,12 @@ void walltype::allocX()
memset(_xw, 0, sizeof(XWALL));
}
void sectortype::allocX()
{
using XSECTOR = BLD_NS::XSECTOR;
_xs = (XSECTOR*)mapDataArena.Alloc(sizeof(XSECTOR));
memset(_xs, 0, sizeof(XSECTOR));
}
static void ReadSectorV7(FileReader& fr, sectortype& sect)
{
@ -406,7 +412,7 @@ void allocateMapArrays(int numsprites)
memset(sector, 0, sizeof(*sector) * MAXSECTORS);
memset(wall, 0, sizeof(*wall) * MAXWALLS);
memset(sprite, 0, sizeof(*sector) * MAXSPRITES);
memset(sprite, 0, sizeof(*sprite) * MAXSPRITES);
memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
memset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES + MAXUNIQHUDID));

View file

@ -82,6 +82,7 @@ CVAR(String, cl_savedir, "", CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
BEGIN_BLD_NS
FSerializer& Serialize(FSerializer& arc, const char* keyname, XWALL& w, XWALL* def);
FSerializer& Serialize(FSerializer& arc, const char* keyname, XSECTOR& w, XSECTOR* def);
END_BLD_NS
@ -535,8 +536,34 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sectortype &c, sectort
("hitag", c.hitag, def->hitag)
("extra", c.extra, def->extra)
("portalflags", c.portalflags, def->portalflags)
("portalnum", c.portalnum, def->portalnum)
.EndObject();
("portalnum", c.portalnum, def->portalnum);
// Save the blood-specific extensions only when playing Blood
if (isDukeLike())
{
arc("keyinfo", c.keyinfo, def->keyinfo);
arc("shadedsector", c.shadedsector, def->shadedsector);
}
else if (isBlood())
{
if (arc.isWriting())
{
if (c.hasX())
{
BLD_NS::Serialize(arc, "xsector", *c._xs, nullptr);
}
}
else
{
if (arc.HasObject("xsector"))
{
c.allocX();
BLD_NS::Serialize(arc, "xsector", *c._xs, nullptr);
}
}
}
arc.EndObject();
}
return arc;
}

View file

@ -992,8 +992,4 @@ void qloadboard(const char* filename, char flags, vec3_t* dapos, int16_t* daang,
Blood::dbLoadMap(filename, &dapos->x, &dapos->y, &dapos->z, daang, dacursectnum, NULL);
Blood::dbInit(); // clean up immediately.
}
inline void sectortype::addX()
{
extra = Blood::dbInsertXSector(sectnum(this));
}

View file

@ -3237,7 +3237,7 @@ void useSectorWindGen(DBloodActor* sourceactor, sectortype* pSector)
else
{
pSector = pSource->sector();
pSector->addX();
pSector->allocX();
pXSector = &pSector->xs();
pXSector->windAlways = 1;
}

View file

@ -1483,7 +1483,6 @@ enum ShrapType
typedef struct SECT_USER
{
SECT_USER() { memset(this, 0, sizeof(*this)); }
int dist, flags;
int depth_fixed;
short stag, // ST? tag number - for certain things it helps to know it