Lunatic: new-generation map format, in-memory representation ("map-int VX").

The Lunatic build compiles with new structures for sector and wall types.
They have separate members for TROR {up,down}{bunch,nextwall}, so there are
no conflicts with other uses of members into which they were previously
shoehorned.  Also, the maximum bunch limit is bumped to 512 in that build.

Currently, loading from V7/8/9 and saving to V7 and V8 are supported.

git-svn-id: https://svn.eduke32.com/eduke32@3658 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-04-09 17:35:11 +00:00
parent a648522c68
commit 7b6bf4dda2
10 changed files with 442 additions and 114 deletions

View file

@ -41,6 +41,14 @@ enum rendmode_t {
# define MAXXDIM 7680
# define MAXYDIM 3200
#ifdef LUNATIC
# define NEW_MAP_FORMAT
#else
# ifdef NEW_MAP_FORMAT
# error "New map format can only be used with Lunatic"
# endif
#endif
// additional space beyond wall, in walltypes:
# define M32_FIXME_WALLS 512
# define M32_FIXME_SECTORS 2
@ -98,25 +106,48 @@ enum rendmode_t {
//#define YAX_DEBUG
//#define ENGINE_SCREENSHOT_DEBUG
#ifdef YAX_ENABLE
# if !defined NEW_MAP_FORMAT
# define YAX_ENABLE__COMPAT
# endif
#endif
////////// yax defs //////////
#define SECTORFLD(Sect,Fld, Cf) (*((Cf) ? (&sector[Sect].floor##Fld) : (&sector[Sect].ceiling##Fld)))
#define YAX_CEILING 0 // don't change!
#define YAX_FLOOR 1 // don't change!
# ifdef NEW_MAP_FORMAT
# define YAX_MAXBUNCHES 512
# define YAX_BIT__COMPAT 1024
# define YAX_NEXTWALLBIT__COMPAT(Cf) (1<<(10+Cf))
# define YAX_NEXTWALLBITS__COMPAT (YAX_NEXTWALLBIT__COMPAT(0)|YAX_NEXTWALLBIT__COMPAT(1))
# else
# define YAX_MAXBUNCHES 256
# define YAX_BIT 1024
// "has next wall when constrained"-bit (1<<10: ceiling, 1<<11: floor)
# define YAX_NEXTWALLBIT(Cf) (1<<(10+Cf))
# define YAX_NEXTWALLBITS (YAX_NEXTWALLBIT(0)|YAX_NEXTWALLBIT(1))
#define YAX_CEILING 0 // don't change!
#define YAX_FLOOR 1 // don't change!
# endif
int32_t get_alwaysshowgray(void); // editor only
void yax_updategrays(int32_t posze);
#ifdef YAX_ENABLE
// more user tag hijacking: lotag/extra :/
# ifdef NEW_MAP_FORMAT
// New map format -- no hijacking of otherwise used members.
# define YAX_PTRNEXTWALL(Ptr, Wall, Cf) (*(&Ptr[Wall].upwall + Cf))
# define YAX_NEXTWALLDEFAULT(Cf) (-1)
# else
// More user tag hijacking: lotag/extra. :/
# define YAX_PTRNEXTWALL(Ptr, Wall, Cf) (*(int16_t *)(&Ptr[Wall].lotag + 2*Cf))
# define YAX_NEXTWALL(Wall, Cf) YAX_PTRNEXTWALL(wall, Wall, Cf)
# define YAX_NEXTWALLDEFAULT(Cf) (((Cf)==YAX_CEILING) ? 0 : -1)
extern int16_t yax_bunchnum[MAXSECTORS][2];
extern int16_t yax_nextwall[MAXWALLS][2];
# endif
# define YAX_NEXTWALL(Wall, Cf) YAX_PTRNEXTWALL(wall, Wall, Cf)
# define YAX_ITER_WALLS(Wal, Itervar, Cfvar) Cfvar=0, Itervar=(Wal); Itervar!=-1; \
Itervar=yax_getnextwall(Itervar, Cfvar), \
@ -127,15 +158,17 @@ void yax_updategrays(int32_t posze);
extern int32_t r_tror_nomaskpass;
extern int16_t yax_bunchnum[MAXSECTORS][2];
extern int16_t yax_nextwall[MAXWALLS][2];
# ifdef NEW_MAP_FORMAT
// Moved below declarations of sector, wall, sprite.
# else
int16_t yax_getbunch(int16_t i, int16_t cf);
void yax_getbunches(int16_t i, int16_t *cb, int16_t *fb);
void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum);
void yax_setbunches(int16_t i, int16_t cb, int16_t fb);
int16_t yax_getnextwall(int16_t wal, int16_t cf);
void yax_setnextwall(int16_t wal, int16_t cf, int16_t thenextwall);
# endif
void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum);
void yax_setbunches(int16_t i, int16_t cb, int16_t fb);
int16_t yax_vnextsec(int16_t line, int16_t cf);
void yax_update(int32_t resetstat);
int32_t yax_getneighborsect(int32_t x, int32_t y, int32_t sectnum, int32_t cf);
@ -247,6 +280,8 @@ static inline void sprite_tracker_hook(uintptr_t address);
// bit 11: 1 = hitscan-sensitive ceiling/floor
// bits 12-15: reserved
//////////////////// Version 7 map format ////////////////////
//40 bytes
typedef struct
{
@ -255,14 +290,14 @@ typedef struct
Tracker(Sector, uint16_t) ceilingstat, floorstat;
Tracker(Sector, int16_t) ceilingpicnum, ceilingheinum;
Tracker(Sector, int8_t) ceilingshade;
Tracker(Sector, uint8_t) ceilingpal, ceilingxpanning, ceilingypanning;
Tracker(Sector, uint8_t) ceilingpal, /*CM_FLOORZ:*/ ceilingxpanning, ceilingypanning;
Tracker(Sector, int16_t) floorpicnum, floorheinum;
Tracker(Sector, int8_t) floorshade;
Tracker(Sector, uint8_t) floorpal, floorxpanning, floorypanning;
Tracker(Sector, uint8_t) visibility, filler;
Tracker(Sector, uint8_t) /*CM_CEILINGZ:*/ visibility, filler;
Tracker(Sector, uint16_t) lotag, hitag;
Tracker(Sector, int16_t) extra;
} sectortype;
} sectortypev7;
//cstat:
// bit 0: 1 = Blocking wall (use with clipmove, getzrange) "B"
@ -289,7 +324,7 @@ typedef struct
Tracker(Wall, uint8_t) pal, xrepeat, yrepeat, xpanning, ypanning;
Tracker(Wall, uint16_t) lotag, hitag;
Tracker(Wall, int16_t) extra;
} walltype;
} walltypev7;
//cstat:
// bit 0: 1 = Blocking sprite (use with clipmove, getzrange) "B"
@ -326,6 +361,154 @@ typedef struct
Tracker(Sprite, int16_t) extra;
} spritetype;
//////////////////// END Version 7 map format ////////////////
#ifdef NEW_MAP_FORMAT
//////////////////// Lunatic new-generation map format ////////////////////
// 44 bytes
typedef struct
{
Tracker(Sector, int16_t) wallptr, wallnum;
Tracker(Sector, int32_t) ceilingz, floorz;
Tracker(Sector, uint16_t) ceilingstat, floorstat;
Tracker(Sector, int16_t) ceilingpicnum, ceilingheinum, ceilingbunch;
Tracker(Sector, int8_t) ceilingshade;
Tracker(Sector, uint8_t) ceilingpal, /*CM_FLOORZ:*/ ceilingxpanning, ceilingypanning;
Tracker(Sector, int16_t) floorpicnum, floorheinum, floorbunch;
Tracker(Sector, int8_t) floorshade;
Tracker(Sector, uint8_t) floorpal, floorxpanning, floorypanning;
Tracker(Sector, uint8_t) /*CM_CEILINGZ:*/ visibility, filler;
Tracker(Sector, uint16_t) lotag, hitag;
Tracker(Sector, int16_t) extra;
} sectortypevx;
# define SECTORVX_SZ2 offsetof(sectortypevx, floorbunch)-offsetof(sectortypevx, ceilingshade)
# define SECTORVX_SZ3 sizeof(sectortypevx)-offsetof(sectortypevx, floorshade)
static inline void copy_v7_from_vx_sector(sectortypev7 *v7sec, const sectortypevx *vxsec)
{
/* [wallptr..ceilingheinum] */
Bmemcpy(v7sec, vxsec, offsetof(sectortypevx, ceilingbunch));
/* [ceilingshade..floorheinum] */
Bmemcpy(&v7sec->ceilingshade, &vxsec->ceilingshade, SECTORVX_SZ2);
/* [floorshade..extra] */
Bmemcpy(&v7sec->floorshade, &vxsec->floorshade, SECTORVX_SZ3);
/* Clear YAX_BIT of ceiling and floor. (New-map format build saves TROR
* maps as map-text.) */
v7sec->ceilingstat &= ~YAX_BIT__COMPAT;
v7sec->floorstat &= ~YAX_BIT__COMPAT;
}
static inline void inplace_vx_from_v7_sector(sectortypevx *vxsec)
{
const sectortypev7 *v7sec = (sectortypev7 *)vxsec;
/* [floorshade..extra] */
Bmemmove(&vxsec->floorshade, &v7sec->floorshade, SECTORVX_SZ3);
/* [ceilingshade..floorheinum] */
Bmemmove(&vxsec->ceilingshade, &v7sec->ceilingshade, SECTORVX_SZ2);
}
static inline void inplace_vx_tweak_sector(sectortypevx *vxsec, int32_t yaxp)
{
if (yaxp)
{
int32_t cisext = (vxsec->ceilingstat&YAX_BIT__COMPAT);
int32_t fisext = (vxsec->floorstat&YAX_BIT__COMPAT);
vxsec->ceilingbunch = cisext ? vxsec->ceilingxpanning : -1;
vxsec->floorbunch = fisext ? vxsec->floorxpanning : -1;
if (cisext)
vxsec->ceilingxpanning = 0;
if (fisext)
vxsec->floorxpanning = 0;
}
else
{
vxsec->ceilingbunch = vxsec->floorbunch = -1;
}
/* Clear YAX_BIT of ceiling and floor (map-int VX doesn't use it). */
vxsec->ceilingstat &= ~YAX_BIT__COMPAT;
vxsec->floorstat &= ~YAX_BIT__COMPAT;
}
# undef SECTORVX_SZ2
# undef SECTORVX_SZ3
// 36 bytes
typedef struct
{
Tracker(Wall, int32_t) x, y;
Tracker(Wall, int16_t) point2, nextwall, nextsector;
Tracker(Wall, int16_t) upwall, dnwall;
Tracker(Wall, uint16_t) cstat;
Tracker(Wall, int16_t) picnum, overpicnum;
Tracker(Wall, int8_t) shade;
Tracker(Wall, uint8_t) pal, xrepeat, yrepeat, xpanning, ypanning;
Tracker(Wall, uint16_t) lotag, hitag;
Tracker(Wall, int16_t) extra;
} walltypevx;
# define WALLVX_SZ2 sizeof(walltypevx)-offsetof(walltypevx, cstat)
static inline void copy_v7_from_vx_wall(walltypev7 *v7wal, const walltypevx *vxwal)
{
/* [x..nextsector] */
Bmemcpy(v7wal, vxwal, offsetof(walltypevx, upwall));
/* [cstat..extra] */
Bmemcpy(&v7wal->cstat, &vxwal->cstat, WALLVX_SZ2);
/* Clear YAX_NEXTWALLBITS. */
v7wal->cstat &= ~YAX_NEXTWALLBITS__COMPAT;
}
static inline void inplace_vx_from_v7_wall(walltypevx *vxwal)
{
const walltypev7 *v7wal = (walltypev7 *)vxwal;
/* [cstat..extra] */
Bmemmove(&vxwal->cstat, &v7wal->cstat, WALLVX_SZ2);
}
static inline void inplace_vx_tweak_wall(walltypevx *vxwal, int32_t yaxp)
{
if (yaxp)
{
int32_t haveupwall = (vxwal->cstat & YAX_NEXTWALLBIT__COMPAT(YAX_CEILING));
int32_t havednwall = (vxwal->cstat & YAX_NEXTWALLBIT__COMPAT(YAX_FLOOR));
vxwal->upwall = haveupwall ? vxwal->lotag : -1;
vxwal->dnwall = havednwall ? vxwal->extra : -1;
if (haveupwall)
vxwal->lotag = 0;
if (havednwall)
vxwal->extra = -1;
}
else
{
vxwal->upwall = vxwal->dnwall = -1;
}
/* Clear YAX_NEXTWALLBITS (map-int VX doesn't use it). */
vxwal->cstat &= ~YAX_NEXTWALLBITS__COMPAT;
}
# undef WALLVX_SZ2
// NOTE: spritetype is currently the same for V7/8/9 and VX in-memory map formats.
typedef sectortypevx sectortype;
typedef walltypevx walltype;
//////////////////// END Lunatic new-generation map format ////////////////
#else
typedef sectortypev7 sectortype;
typedef walltypev7 walltype;
#endif
typedef struct {
uint32_t mdanimtims;
int16_t mdanimcur;
@ -387,6 +570,29 @@ EXTERN uint32_t sectorchanged[MAXSECTORS + M32_FIXME_SECTORS];
EXTERN uint32_t wallchanged[MAXWALLS + M32_FIXME_WALLS];
EXTERN uint32_t spritechanged[MAXSPRITES];
#ifdef NEW_MAP_FORMAT
static inline int16_t yax_getbunch(int16_t i, int16_t cf)
{
return cf ? sector[i].floorbunch : sector[i].ceilingbunch;
}
static inline void yax_getbunches(int16_t i, int16_t *cb, int16_t *fb)
{
*cb = yax_getbunch(i, YAX_CEILING);
*fb = yax_getbunch(i, YAX_FLOOR);
}
static inline int16_t yax_getnextwall(int16_t wal, int16_t cf)
{
return cf ? wall[wal].dnwall : wall[wal].upwall;
}
static inline void yax_setnextwall(int16_t wal, int16_t cf, int16_t thenextwall)
{
YAX_NEXTWALL(wal, cf) = thenextwall;
}
#endif
static inline void sector_tracker_hook(uintptr_t address)
{
address -= (uintptr_t)(sector);
@ -1054,7 +1260,9 @@ int32_t loaddefinitionsfile(const char *fn);
// if loadboard() fails with -2 return, try loadoldboard(). if it fails with
// -2, board is dodgy
extern int32_t mapversion;
#if !defined NEW_MAP_FORMAT
int32_t loadoldboard(char *filename, char fromwhere, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum);
#endif
// Hash functions

View file

@ -414,7 +414,11 @@ static void yax_resetbunchnums(void)
// attach points to, etc...
static int32_t yax_islockedwall(int16_t line)
{
#ifdef NEW_MAP_FORMAT
return (wall[line].upwall>=0 || wall[line].dnwall>=0);
#else
return !!(wall[line].cstat&YAX_NEXTWALLBITS);
#endif
}
# define DEFAULT_YAX_HEIGHT (2048<<4)
@ -1630,7 +1634,7 @@ static int32_t backup_highlighted_map(mapinfofull_t *mapinfo)
if (mapinfo->numyaxbunches > 0)
mapinfo->bunchnum[2*i + j] = nbn;
# if !defined NEW_MAP_FORMAT
if (obn >= 0 && nbn < 0)
{
// if a bunch was discarded
@ -1641,6 +1645,7 @@ static int32_t backup_highlighted_map(mapinfofull_t *mapinfo)
*cs &= ~YAX_BIT;
*xp = 0;
}
#endif
}
}
#endif
@ -1763,9 +1768,10 @@ static int32_t restore_highlighted_map(mapinfofull_t *mapinfo, int32_t forreal)
if (mapinfo->numyaxbunches > 0)
yax_setnextwall(i, j, mapinfo->ynextwall[2*(i-numwalls) + j]>=0 ?
numwalls+mapinfo->ynextwall[2*(i-numwalls) + j] : -1);
# if !defined NEW_MAP_FORMAT
else
wall[i].cstat &= ~YAX_NEXTWALLBIT(j); // CLEAR_YNEXTWALLS
// yax_setnextwall(i, j, -1);
# endif
}
#endif
}
@ -8038,7 +8044,8 @@ const char *SaveBoard(const char *fn, uint32_t flags)
// 4: passed to loadboard flags (no polymer_loadboard); implies no maphack loading
int32_t LoadBoard(const char *filename, uint32_t flags)
{
int32_t i, tagstat, loadingflags=(!pathsearchmode&&grponlymode?2:0);
int32_t i, tagstat;
const int32_t loadingflags = (!pathsearchmode && grponlymode) ? 2 : 0;
if (!filename)
filename = selectedboardfilename;
@ -8046,6 +8053,7 @@ int32_t LoadBoard(const char *filename, uint32_t flags)
if (filename != boardfilename)
Bstrcpy(boardfilename, filename);
// XXX: This is pointless unless loading fails.
for (i=0; i<MAXSECTORS; i++) sector[i].extra = -1;
for (i=0; i<MAXWALLS; i++) wall[i].extra = -1;
for (i=0; i<MAXSPRITES; i++) sprite[i].extra = -1;
@ -8055,8 +8063,10 @@ int32_t LoadBoard(const char *filename, uint32_t flags)
ExtPreLoadMap();
i = loadboard(boardfilename, (flags&4)|loadingflags, &pos, &ang, &cursectnum);
#if !defined NEW_MAP_FORMAT
if (i == -2)
i = loadoldboard(boardfilename,loadingflags, &pos, &ang, &cursectnum);
#endif
if (i < 0)
{
// printmessage16("Invalid map format.");
@ -10062,7 +10072,7 @@ void showsectordata(int16_t sectnum, int16_t small)
DOPRINT(48, "Flags (hex): %x", TrackerCast(sec->ceilingstat));
{
int32_t xp=sec->ceilingxpanning, yp=sec->ceilingypanning;
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (yax_getbunch(searchsector, YAX_CEILING) >= 0)
xp = yp = 0;
#endif
@ -10083,7 +10093,7 @@ void showsectordata(int16_t sectnum, int16_t small)
DOPRINT(48, "Flags (hex): %x", TrackerCast(sec->floorstat));
{
int32_t xp=sec->floorxpanning, yp=sec->floorypanning;
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (yax_getbunch(searchsector, YAX_FLOOR) >= 0)
xp = yp = 0;
#endif

View file

@ -325,7 +325,8 @@ static uint8_t yax_tsprfrombunch[1 + 2*YAX_MAXDRAWS][MAXSPRITESONSCREEN];
// drawn sectors
uint8_t yax_gotsector[MAXSECTORS>>3]; // engine internal
// game-time YAX data structures
# if !defined NEW_MAP_FORMAT
// Game-time YAX data structures, V7-V9 map formats.
int16_t yax_bunchnum[MAXSECTORS][2];
int16_t yax_nextwall[MAXWALLS][2];
@ -354,6 +355,17 @@ void yax_getbunches(int16_t i, int16_t *cb, int16_t *fb)
*cb = yax_getbunch(i, YAX_CEILING);
*fb = yax_getbunch(i, YAX_FLOOR);
}
# else
# define YAX_PTRBUNCHNUM(Ptr, Sect, Cf) (*((Cf) ? &(Ptr)[Sect].floorbunch : &(Ptr)[Sect].ceilingbunch))
# define YAX_BUNCHNUM(Sect, Cf) YAX_PTRBUNCHNUM(sector, Sect, Cf)
# if !defined NEW_MAP_FORMAT
static int32_t yax_islockededge(int32_t line, int32_t cf)
{
return (yax_getnextwall(line, cf) >= 0);
}
# endif
# endif
// bunchnum: -1: also clear yax-nextwalls (forward and reverse)
// -2: don't clear reverse yax-nextwalls
@ -362,7 +374,11 @@ void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum)
{
if (editstatus==0)
{
#ifdef NEW_MAP_FORMAT
YAX_BUNCHNUM(i, cf) = bunchnum;
#else
yax_bunchnum[i][cf] = bunchnum;
#endif
return;
}
@ -386,12 +402,16 @@ void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum)
}
}
#if !defined NEW_MAP_FORMAT
*(&sector[i].ceilingstat + cf) &= ~YAX_BIT;
#endif
YAX_BUNCHNUM(i, cf) = 0;
return;
}
#if !defined NEW_MAP_FORMAT
*(&sector[i].ceilingstat + cf) |= YAX_BIT;
#endif
YAX_BUNCHNUM(i, cf) = bunchnum;
}
@ -401,6 +421,7 @@ void yax_setbunches(int16_t i, int16_t cb, int16_t fb)
yax_setbunch(i, YAX_FLOOR, fb);
}
# if !defined NEW_MAP_FORMAT
//// nextwall getters/setters
int16_t yax_getnextwall(int16_t wal, int16_t cf)
{
@ -433,6 +454,7 @@ void yax_setnextwall(int16_t wal, int16_t cf, int16_t thenextwall)
YAX_NEXTWALL(wal, cf) = YAX_NEXTWALLDEFAULT(cf);
}
}
# endif
// make one step in the vertical direction, and if the wall we arrive at
// is red, return its nextsector.
@ -453,32 +475,42 @@ int16_t yax_vnextsec(int16_t line, int16_t cf)
// 2: read data from game-time arrays and construct linked lists etc.
void yax_update(int32_t resetstat)
{
int32_t i, j, oeditstatus=editstatus;
int16_t cb, fb, tmpsect;
int32_t i;
#if !defined NEW_MAP_FORMAT
int32_t j;
const int32_t oeditstatus=editstatus;
#endif
int16_t cb, fb;
if (resetstat != 2)
numyaxbunches = 0;
for (i=0; i<MAXSECTORS; i++)
{
#if !defined NEW_MAP_FORMAT
if (resetstat != 2 || i>=numsectors)
yax_bunchnum[i][0] = yax_bunchnum[i][1] = -1;
#endif
nextsectbunch[0][i] = nextsectbunch[1][i] = -1;
}
for (i=0; i<YAX_MAXBUNCHES; i++)
headsectbunch[0][i] = headsectbunch[1][i] = -1;
#if !defined NEW_MAP_FORMAT
for (i=0; i<MAXWALLS; i++)
if (resetstat != 2 || i>=numwalls)
yax_nextwall[i][0] = yax_nextwall[i][1] = -1;
#endif
if (resetstat==1)
return;
// constuct singly linked list of sectors-of-bunch
// Constuct singly linked list of sectors-of-bunch.
// read bunchnums directly from the sector struct in yax_[gs]etbunch{es}!
#if !defined NEW_MAP_FORMAT
// Read bunchnums directly from the sector struct in yax_[gs]etbunch{es}!
editstatus = (resetstat==0);
// use oeditstatus to check for in-gamedness from here on!
// NOTE: Use oeditstatus to check for in-gamedness from here on!
#endif
if (resetstat==0)
{
@ -519,18 +551,22 @@ void yax_update(int32_t resetstat)
}
}
// in-struct --> array transfer (resetstat==0) and list construction
// In-struct --> array transfer (resetstat==0 and !defined NEW_MAP_FORMAT)
// and list construction.
for (i=numsectors-1; i>=0; i--)
{
yax_getbunches(i, &cb, &fb);
#if !defined NEW_MAP_FORMAT
if (resetstat==0)
{
yax_bunchnum[i][0] = cb;
yax_bunchnum[i][1] = fb;
}
#endif
if (cb >= 0)
{
#if !defined NEW_MAP_FORMAT
if (resetstat==0)
for (j=sector[i].wallptr; j<sector[i].wallptr+sector[i].wallnum; j++)
{
@ -541,7 +577,7 @@ void yax_update(int32_t resetstat)
YAX_NEXTWALL(j,0) = 0; // reset lotag!
}
}
#endif
if (headsectbunch[0][cb] == -1)
{
headsectbunch[0][cb] = i;
@ -552,7 +588,7 @@ void yax_update(int32_t resetstat)
}
else
{
tmpsect = headsectbunch[0][cb];
int32_t tmpsect = headsectbunch[0][cb];
headsectbunch[0][cb] = i;
nextsectbunch[0][i] = tmpsect;
}
@ -560,6 +596,7 @@ void yax_update(int32_t resetstat)
if (fb >= 0)
{
#if !defined NEW_MAP_FORMAT
if (resetstat==0)
for (j=sector[i].wallptr; j<sector[i].wallptr+sector[i].wallnum; j++)
{
@ -570,19 +607,21 @@ void yax_update(int32_t resetstat)
YAX_NEXTWALL(j,1) = -1; // reset extra!
}
}
#endif
if (headsectbunch[1][fb] == -1)
headsectbunch[1][fb] = i;
else
{
tmpsect = headsectbunch[1][fb];
int32_t tmpsect = headsectbunch[1][fb];
headsectbunch[1][fb] = i;
nextsectbunch[1][i] = tmpsect;
}
}
}
#if !defined NEW_MAP_FORMAT
editstatus = oeditstatus;
#endif
}
int32_t yax_getneighborsect(int32_t x, int32_t y, int32_t sectnum, int32_t cf)
@ -9640,7 +9679,7 @@ int32_t loadboard(char *filename, char flags, vec3_t *dapos, int16_t *daang, int
{
int32_t fil, i;
int16_t numsprites;
char myflags = flags&(~3);
const char myflags = flags&(~3);
flags &= 3;
@ -9665,11 +9704,20 @@ int32_t loadboard(char *filename, char flags, vec3_t *dapos, int16_t *daang, int
prepare_loadboard(fil, dapos, daang, dacursectnum);
////////// Read sectors //////////
kread(fil,&numsectors,2); numsectors = B_LITTLE16(numsectors);
if (numsectors > MYMAXSECTORS()) { kclose(fil); return(-1); }
kread(fil,&sector[0],sizeof(sectortype)*numsectors);
if ((unsigned)numsectors >= MYMAXSECTORS()+1) { kclose(fil); return(-1); }
kread(fil, sector, sizeof(sectortypev7)*numsectors);
for (i=numsectors-1; i>=0; i--)
{
#ifdef NEW_MAP_FORMAT
Bmemmove(&sector[i], &(((sectortypev7 *)sector)[i]), sizeof(sectortypevx));
inplace_vx_from_v7_sector(&sector[i]);
#endif
sector[i].wallptr = B_LITTLE16(sector[i].wallptr);
sector[i].wallnum = B_LITTLE16(sector[i].wallnum);
sector[i].ceilingz = B_LITTLE32(sector[i].ceilingz);
@ -9683,13 +9731,25 @@ int32_t loadboard(char *filename, char flags, vec3_t *dapos, int16_t *daang, int
sector[i].lotag = B_LITTLE16(sector[i].lotag);
sector[i].hitag = B_LITTLE16(sector[i].hitag);
sector[i].extra = B_LITTLE16(sector[i].extra);
#ifdef NEW_MAP_FORMAT
inplace_vx_tweak_sector(&sector[i], mapversion==9);
#endif
}
////////// Read walls //////////
kread(fil,&numwalls,2); numwalls = B_LITTLE16(numwalls);
if (numwalls > MYMAXWALLS()) { kclose(fil); return(-1); }
kread(fil,&wall[0],sizeof(walltype)*numwalls);
if ((unsigned)numwalls >= MYMAXWALLS()+1) { kclose(fil); return(-1); }
kread(fil, wall, sizeof(walltypev7)*numwalls);
for (i=numwalls-1; i>=0; i--)
{
#ifdef NEW_MAP_FORMAT
Bmemmove(&wall[i], &(((walltypev7 *)wall)[i]), sizeof(walltypevx));
inplace_vx_from_v7_wall(&wall[i]);
#endif
wall[i].x = B_LITTLE32(wall[i].x);
wall[i].y = B_LITTLE32(wall[i].y);
wall[i].point2 = B_LITTLE16(wall[i].point2);
@ -9701,11 +9761,19 @@ int32_t loadboard(char *filename, char flags, vec3_t *dapos, int16_t *daang, int
wall[i].lotag = B_LITTLE16(wall[i].lotag);
wall[i].hitag = B_LITTLE16(wall[i].hitag);
wall[i].extra = B_LITTLE16(wall[i].extra);
#ifdef NEW_MAP_FORMAT
inplace_vx_tweak_wall(&wall[i], mapversion==9);
#endif
}
////////// Read sprites //////////
kread(fil,&numsprites,2); numsprites = B_LITTLE16(numsprites);
if (numsprites > MYMAXSPRITES()) { kclose(fil); return(-1); }
kread(fil,&sprite[0],sizeof(spritetype)*numsprites);
if ((unsigned)numsprites >= MYMAXSPRITES()+1) { kclose(fil); return(-1); }
kread(fil, sprite, sizeof(spritetype)*numsprites);
for (i=numsprites-1; i>=0; i--)
{
sprite[i].x = B_LITTLE32(sprite[i].x);
@ -9749,6 +9817,8 @@ int32_t loadboard(char *filename, char flags, vec3_t *dapos, int16_t *daang, int
//
// loadboardv5/6
//
#if !defined NEW_MAP_FORMAT
// V5/V6 map format loading: NYI for NEW_MAP_FORMAT
# include "engine_oldmap.h"
@ -9929,6 +9999,7 @@ int32_t loadoldboard(char *filename, char fromwhere, vec3_t *dapos, int16_t *daa
return(0);
}
#endif
#ifdef POLYMER
void delete_maphack_lights()
@ -10262,14 +10333,14 @@ int32_t loadmaphack(const char *filename)
//
int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int16_t dacursectnum)
{
int16_t fil, i, j, numsprites, ts;
int32_t tl;
sectortype *tsect = NULL;
walltype *twall = NULL;
spritetype *tspri = NULL;
sectortype *sec;
walltype *wal;
spritetype *spri;
int16_t numsprites, ts;
int32_t i, j, fil, tl;
#ifdef NEW_MAP_FORMAT
// Writing new-format (Lunatic) maps not yet implemented; V9 not available then.
if (numyaxbunches > 0)
return -1;
#endif
if ((fil = Bopen(filename,BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1)
{
@ -10294,8 +10365,7 @@ int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int1
}
}
// Count the number of sprites.
numsprites = 0;
for (j=0; j<MAXSPRITES; j++)
{
@ -10303,8 +10373,11 @@ int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int1
numsprites++;
}
// Check consistency of sprite-in-the-world predicate (.statnum != MAXSTATUS)
// and the engine-reported number of sprites 'Numsprites'.
Bassert(numsprites == Numsprites);
// Determine the map version.
#ifdef YAX_ENABLE
if (numyaxbunches > 0)
mapversion = 9;
@ -10324,18 +10397,25 @@ int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int1
ts = B_LITTLE16(numsectors); Bwrite(fil,&ts,2);
while (1)
while (1) // if, really
{
tsect = (sectortype *)Bmalloc(sizeof(sectortype) * numsectors);
sectortypev7 *const tsect = (sectortypev7 *)Bmalloc(sizeof(sectortypev7) * numsectors);
walltypev7 *twall;
if (tsect == NULL)
break;
Bmemcpy(&tsect[0], &sector[0], sizeof(sectortype) * numsectors);
#ifdef NEW_MAP_FORMAT
for (i=0; i<numsectors; i++)
copy_v7_from_vx_sector(&tsect[i], &sector[i]);
#else
Bmemcpy(tsect, sector, sizeof(sectortypev7)*numsectors);
#endif
for (i=0; i<numsectors; i++)
{
sec = &tsect[i];
sectortypev7 *const sec = &tsect[i];
sec->wallptr = B_LITTLE16(sec->wallptr);
sec->wallnum = B_LITTLE16(sec->wallnum);
sec->ceilingz = B_LITTLE32(sec->ceilingz);
@ -10349,7 +10429,7 @@ int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int1
sec->lotag = B_LITTLE16(sec->lotag);
sec->hitag = B_LITTLE16(sec->hitag);
sec->extra = B_LITTLE16(sec->extra);
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (editstatus == 0)
{
// if in-game, pack game-time bunchnum data back into structs
@ -10362,22 +10442,28 @@ int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int1
#endif
}
Bwrite(fil,&tsect[0],sizeof(sectortype) * numsectors);
Bwrite(fil, tsect, sizeof(sectortypev7)*numsectors);
Bfree(tsect);
ts = B_LITTLE16(numwalls);
Bwrite(fil,&ts,2);
twall = (walltype *)Bmalloc(sizeof(walltype) * numwalls);
twall = (walltypev7 *)Bmalloc(sizeof(walltypev7) * numwalls);
if (twall == NULL)
break;
Bmemcpy(&twall[0], &wall[0], sizeof(walltype) * numwalls);
#ifdef NEW_MAP_FORMAT
for (i=0; i<numwalls; i++)
copy_v7_from_vx_wall(&twall[i], &wall[i]);
#else
Bmemcpy(twall, wall, sizeof(walltypev7)*numwalls);
#endif
for (i=0; i<numwalls; i++)
{
wal = &twall[i];
walltypev7 *const wal = &twall[i];
wal->x = B_LITTLE32(wal->x);
wal->y = B_LITTLE32(wal->y);
wal->point2 = B_LITTLE16(wal->point2);
@ -10386,7 +10472,7 @@ int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int1
wal->cstat = B_LITTLE16(wal->cstat);
wal->picnum = B_LITTLE16(wal->picnum);
wal->overpicnum = B_LITTLE16(wal->overpicnum);
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (editstatus == 0)
{
// if in-game, pack game-time yax-nextwall data back into structs
@ -10402,20 +10488,19 @@ int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int1
wal->extra = B_LITTLE16(wal->extra);
}
Bwrite(fil,&twall[0],sizeof(walltype) * numwalls);
Bwrite(fil, twall, sizeof(walltypev7)*numwalls);
Bfree(twall);
ts = B_LITTLE16(numsprites); Bwrite(fil,&ts,2);
if (numsprites > 0)
{
tspri = (spritetype *)Bmalloc(sizeof(spritetype) * numsprites);
spritetype *const tspri = (spritetype *)Bmalloc(sizeof(spritetype) * numsprites);
spritetype *spri = tspri;
if (tspri == NULL)
break;
spri=tspri;
for (j=0; j<MAXSPRITES; j++)
{
if (sprite[j].statnum != MAXSTATUS)
@ -10440,7 +10525,7 @@ int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int1
}
}
Bwrite(fil,&tspri[0],sizeof(spritetype) * numsprites);
Bwrite(fil, tspri, sizeof(spritetype)*numsprites);
Bfree(tspri);
}
@ -10449,16 +10534,6 @@ int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int1
}
Bclose(fil);
if (tsect != NULL)
Bfree(tsect);
if (twall != NULL)
Bfree(twall);
if (tspri != NULL)
Bfree(tspri);
return(-1);
}

View file

@ -1774,8 +1774,7 @@ static void polymer_displayrooms(int16_t dacursectnum)
while (--i >= 0);
#ifdef YAX_ENABLE
// queue ROR neighbors
if ((sec->floorstat & 1024) &&
(bunchnum = yax_getbunch(sectorqueue[front], YAX_FLOOR)) >= 0) {
if ((bunchnum = yax_getbunch(sectorqueue[front], YAX_FLOOR)) >= 0) {
for (SECTORS_OF_BUNCH(bunchnum, YAX_CEILING, ns)) {
@ -1788,8 +1787,7 @@ static void polymer_displayrooms(int16_t dacursectnum)
}
}
if ((sec->ceilingstat & 1024) &&
(bunchnum = yax_getbunch(sectorqueue[front], YAX_CEILING)) >= 0) {
if ((bunchnum = yax_getbunch(sectorqueue[front], YAX_CEILING)) >= 0) {
for (SECTORS_OF_BUNCH(bunchnum, YAX_FLOOR, ns)) {
@ -2608,7 +2606,7 @@ static void polymer_drawsector(int16_t sectnum, int32_t domasks)
// Draw masks regardless; avoid all non-masks TROR links
if (sec->floorstat & 384) {
draw = domasks;
} else if (sec->floorstat & 1024) {
} else if (yax_getbunch(sectnum, YAX_FLOOR) >= 0) {
draw = FALSE;
}
// Parallaxed
@ -2643,7 +2641,7 @@ static void polymer_drawsector(int16_t sectnum, int32_t domasks)
// Draw masks regardless; avoid all non-masks TROR links
if (sec->ceilingstat & 384) {
draw = domasks;
} else if (sec->ceilingstat & 1024) {
} else if (yax_getbunch(sectnum, YAX_CEILING) >= 0) {
draw = FALSE;
}
// Parallaxed
@ -5447,7 +5445,7 @@ static inline void polymer_culllight(int16_t lighti)
#ifdef YAX_ENABLE
// queue ROR neighbors
if (checkror && (sec->floorstat & 1024) &&
if (checkror &&
(bunchnum = yax_getbunch(sectorqueue[front], YAX_FLOOR)) >= 0) {
for (SECTORS_OF_BUNCH(bunchnum, YAX_CEILING, ns)) {
@ -5480,7 +5478,7 @@ static inline void polymer_culllight(int16_t lighti)
#ifdef YAX_ENABLE
// queue ROR neighbors
if (checkror && (sec->ceilingstat & 1024) &&
if (checkror &&
(bunchnum = yax_getbunch(sectorqueue[front], YAX_CEILING)) >= 0) {
for (SECTORS_OF_BUNCH(bunchnum, YAX_FLOOR, ns)) {

View file

@ -1293,7 +1293,7 @@ const char *ExtGetWallCaption(int16_t wallnum)
taglab_handle1(lt&2, wall[wallnum].hitag, histr);
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (yax_getnextwall(wallnum, YAX_CEILING) >= 0) // ceiling nextwall: lotag
{
if (wall[wallnum].hitag == 0)
@ -4796,6 +4796,12 @@ static int64_t lldotv2(const vec2_t *v1, const vec2_t *v2)
return (int64_t)v1->x * v2->x + (int64_t)v1->y * v2->y;
}
#ifdef NEW_MAP_FORMAT
# define YAX_BIT_PROTECT 0
#else
# define YAX_BIT_PROTECT YAX_BIT
#endif
////////// KEY PRESS HANDLER IN 3D MODE //////////
static void Keys3d(void)
{
@ -4867,7 +4873,7 @@ static void Keys3d(void)
const int32_t w = SELECT_WALL();
const int32_t swappedbot = (int32_t)(w != searchwall);
flags |= (swappedbot<<2);
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
flags |= (yax_getnextwall(searchwall, YAX_CEILING)>=0) + 2*(yax_getnextwall(searchwall, YAX_FLOOR)>=0);
#endif
drawtileinfo("Current", WIND1X,WIND1Y,
@ -4914,7 +4920,7 @@ static void Keys3d(void)
{
int32_t xp=AIMED_CEILINGFLOOR(xpanning), yp=AIMED_CEILINGFLOOR(ypanning);
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
int32_t notextended = 1;
if (yax_getbunch(searchsector, AIMING_AT_FLOOR) >= 0)
notextended = 0;
@ -5077,7 +5083,11 @@ static void Keys3d(void)
{
if (AIMING_AT_WALL_OR_MASK)
{
#ifdef NEW_MAP_FORMAT
wall[searchwall].cstat = 0;
#else
wall[searchwall].cstat &= YAX_NEXTWALLBITS;
#endif
message_nowarn("Wall %d cstat = %d", searchwall, TrackerCast(wall[searchwall].cstat));
}
else if (AIMING_AT_SPRITE)
@ -5322,7 +5332,7 @@ static void Keys3d(void)
{
if (ASSERT_AIMING)
{
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (AIMING_AT_WALL_OR_MASK && yax_getnextwall(searchwall, YAX_FLOOR)>=0)
message("Can't change extra in protected wall");
else
@ -6111,7 +6121,7 @@ static void Keys3d(void)
else
{
showinvisibility = !showinvisibility;
#ifndef YAX_ENABLE
#if !defined YAX_ENABLE
message("Show invisible sprites %s", showinvisibility?"enabled":"disabled");
#else
message("Show invisible objects %s", showinvisibility?"enabled":"disabled");
@ -6181,7 +6191,7 @@ static void Keys3d(void)
if (AIMING_AT_WALL_OR_MASK)
{
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (yax_getnextwall(searchwall, YAX_CEILING)>=0)
message("Can't change lotag in protected wall");
else
@ -6530,7 +6540,7 @@ static void Keys3d(void)
{
changedir = 1-2*(x1<0);
x1 = klabs(x1);
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (yax_getbunch(searchsector, AIMING_AT_FLOOR) < 0)
#endif
while (x1--)
@ -6637,7 +6647,7 @@ static void Keys3d(void)
}
else if (AIMING_AT_CEILING_OR_FLOOR)
{
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (YAXCHK(yax_getbunch(searchsector, AIMING_AT_FLOOR) < 0))
#endif
{
@ -6808,7 +6818,7 @@ static void Keys3d(void)
if (AIMING_AT_WALL_OR_MASK)
{
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (yax_getnextwall(searchwall, YAX_CEILING) >= 0)
templotag = 0;
if (yax_getnextwall(searchwall, YAX_FLOOR) >= 0)
@ -6820,7 +6830,11 @@ static void Keys3d(void)
tempyrepeat = AIMED_SEL_WALL(yrepeat);
tempxpanning = AIMED_SEL_WALL(xpanning);
tempypanning = AIMED_SEL_WALL(ypanning);
#ifdef NEW_MAP_FORMAT
tempcstat = AIMED_SEL_WALL(cstat);
#else
tempcstat = AIMED_SEL_WALL(cstat) & ~YAX_NEXTWALLBITS;
#endif
templenrepquot = getlenbyrep(wallength(searchwall), tempxrepeat);
tempsectornum = sectorofwall(searchwall);
@ -6831,12 +6845,16 @@ static void Keys3d(void)
tempvis = sector[searchsector].visibility;
tempxrepeat = AIMED_CEILINGFLOOR(xpanning);
tempyrepeat = AIMED_CEILINGFLOOR(ypanning);
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (yax_getbunch(searchsector, AIMING_AT_FLOOR) >= 0)
tempxrepeat = 0;
#endif
tempcstat = AIMED_CEILINGFLOOR(stat) & ~YAX_BIT;
#ifdef NEW_MAP_FORMAT
tempcstat = AIMED_CEILINGFLOOR(stat);
#else
tempcstat = AIMED_CEILINGFLOOR(stat) & ~YAX_BIT;
#endif
tempsectornum = searchsector;
}
else if (AIMING_AT_SPRITE)
@ -6876,7 +6894,7 @@ static void Keys3d(void)
message("Can't align sector %d's %s, have no reference sector",
searchsector, typestr[searchstat]);
}
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
else if (yax_getbunch(searchsector, AIMING_AT_FLOOR) >= 0)
{
yax_invalidop();
@ -7120,7 +7138,7 @@ static void Keys3d(void)
if (somethingintab == SEARCH_CEILING || somethingintab == SEARCH_FLOOR)
{
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (yax_getbunch(i, AIMING_AT_FLOOR) >= 0)
k |= 2;
else
@ -7131,7 +7149,7 @@ static void Keys3d(void)
k |= 1;
}
SET_PROTECT_BITS(CEILINGFLOOR(i, stat), tempcstat, YAX_BIT);
SET_PROTECT_BITS(CEILINGFLOOR(i, stat), tempcstat, YAX_BIT_PROTECT);
}
}
@ -7153,9 +7171,8 @@ static void Keys3d(void)
SECTORFLD(i,picnum, AIMING_AT_FLOOR) = temppicnum;
SECTORFLD(i,shade, AIMING_AT_FLOOR) = tempshade;
SECTORFLD(i,pal, AIMING_AT_FLOOR) = temppal;
if (j)
SET_PROTECT_BITS(SECTORFLD(i,stat, AIMING_AT_FLOOR), tempcstat, YAX_BIT);
SET_PROTECT_BITS(SECTORFLD(i,stat, AIMING_AT_FLOOR), tempcstat, YAX_BIT_PROTECT);
}
message("Pasted picnum+shade+pal%s to sector %ss with bunchnum %d",
@ -7221,7 +7238,8 @@ paste_ceiling_or_floor:
#endif
AIMED_CEILINGFLOOR(xpanning) = tempxrepeat;
AIMED_CEILINGFLOOR(ypanning) = tempyrepeat;
SET_PROTECT_BITS(AIMED_CEILINGFLOOR(stat), tempcstat, YAX_BIT|2);
SET_PROTECT_BITS(AIMED_CEILINGFLOOR(stat), tempcstat, YAX_BIT_PROTECT|2);
sector[searchsector].visibility = tempvis;
sector[searchsector].lotag = templotag;
@ -7337,7 +7355,11 @@ paste_ceiling_or_floor:
wall[w].ypanning = 0;
wall[w].xrepeat = 8;
wall[w].yrepeat = 8;
#ifdef NEW_MAP_FORMAT
wall[w].cstat = 0;
#else
wall[w].cstat &= YAX_NEXTWALLBITS;
#endif
fixrepeats(searchwall);
}
else if (AIMING_AT_CEILING_OR_FLOOR)
@ -7801,7 +7823,7 @@ static void Keys2d(void)
}
else if (linehighlight >= 0)
{
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (yax_getnextwall(linehighlight, YAX_CEILING)>=0)
message("Can't change lotag in protected wall");
else
@ -7875,7 +7897,7 @@ static void Keys2d(void)
}
else if (linehighlight >= 0)
{
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (yax_getnextwall(linehighlight, YAX_FLOOR)>=0)
message("Can't change extra in protected wall");
else
@ -12178,12 +12200,12 @@ static void EditSectorData(int16_t sectnum)
switch (row)
{
case 0:
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
i = sector[sectnum].ceilingstat&YAX_BIT;
#endif
handlemed(1, "Flags (hex)", "Ceiling Flags", &sector[sectnum].ceilingstat,
sizeof(sector[sectnum].ceilingstat), 65535, 0);
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
sector[sectnum].ceilingstat &= ~YAX_BIT;
sector[sectnum].ceilingstat |= i;
#endif
@ -12229,12 +12251,12 @@ static void EditSectorData(int16_t sectnum)
switch (row)
{
case 0:
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
i = sector[sectnum].ceilingstat&YAX_BIT;
#endif
handlemed(1, "Flags (hex)", "Floor Flags", &sector[sectnum].floorstat,
sizeof(sector[sectnum].floorstat), 65535, 0);
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
sector[sectnum].ceilingstat &= ~YAX_BIT;
sector[sectnum].ceilingstat |= i;
#endif
@ -12317,11 +12339,15 @@ static void EditWallData(int16_t wallnum)
switch (row)
{
case 0:
#if !defined NEW_MAP_FORMAT
i = wall[wallnum].cstat&YAX_NEXTWALLBITS;
#endif
handlemed(1, "Flags (hex)", "Flags", &wall[wallnum].cstat,
sizeof(wall[wallnum].cstat), 65535, 0);
#if !defined NEW_MAP_FORMAT
wall[wallnum].cstat &= ~YAX_NEXTWALLBITS;
wall[wallnum].cstat |= i;
#endif
break;
case 1:
handlemed(0, "Shade", "Shade", &wall[wallnum].shade,

View file

@ -5352,8 +5352,10 @@ void G_SaveMapState(mapstate_t *save)
Bmemcpy(&save->nextspritestat[0],&nextspritestat[0],sizeof(nextspritestat));
#ifdef YAX_ENABLE
Bmemcpy(&save->numyaxbunches, &numyaxbunches, sizeof(numyaxbunches));
# if !defined NEW_MAP_FORMAT
Bmemcpy(save->yax_bunchnum, yax_bunchnum, sizeof(yax_bunchnum));
Bmemcpy(save->yax_nextwall, yax_nextwall, sizeof(yax_nextwall));
# endif
#endif
Bmemcpy(&save->actor[0],&actor[0],sizeof(actor_t)*MAXSPRITES);
@ -5456,8 +5458,10 @@ void G_RestoreMapState(mapstate_t *save)
Bmemcpy(&nextspritestat[0],&save->nextspritestat[0],sizeof(nextspritestat));
#ifdef YAX_ENABLE
Bmemcpy(&numyaxbunches, &save->numyaxbunches, sizeof(numyaxbunches));
# if !defined NEW_MAP_FORMAT
Bmemcpy(yax_bunchnum, save->yax_bunchnum, sizeof(yax_bunchnum));
Bmemcpy(yax_nextwall, save->yax_nextwall, sizeof(yax_nextwall));
# endif
#endif
Bmemcpy(&actor[0],&save->actor[0],sizeof(actor_t)*MAXSPRITES);

View file

@ -123,10 +123,12 @@ struct {
uint16_t ceilingstat, floorstat;
const int16_t ceilingpicnum;
int16_t ceilingheinum;
const int16_t ceilingbunch;
int8_t ceilingshade;
uint8_t ceilingpal, ceilingxpanning, ceilingypanning;
const int16_t floorpicnum;
int16_t floorheinum;
const int16_t floorbunch;
int8_t floorshade;
uint8_t floorpal, floorxpanning, floorypanning;
uint8_t visibility, filler;
@ -158,6 +160,7 @@ local WALL_STRUCT = [[
struct {
int32_t x, y;
const int16_t point2, nextwall, nextsector;
const int16_t upwall, dnwall;
]]..bitint_member("UBit16", "cstat")..[[
const int16_t picnum, overpicnum;
int8_t shade;

View file

@ -71,7 +71,7 @@ static int32_t __fastcall VM_AccessWall(int32_t how, int32_t lVar1, int32_t lLab
case WALL_NEXTWALL: wall[i].nextwall=lValue; break;
case WALL_NEXTSECTOR: wall[i].nextsector=lValue; break;
case WALL_CSTAT:
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (!m32_script_expertmode)
SET_PROTECT_BITS(wall[i].cstat, lValue, YAX_NEXTWALLBITS);
else
@ -87,7 +87,7 @@ static int32_t __fastcall VM_AccessWall(int32_t how, int32_t lVar1, int32_t lLab
case WALL_XPANNING: wall[i].xpanning=lValue; break;
case WALL_YPANNING: wall[i].ypanning=lValue; break;
case WALL_LOTAG:
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (!m32_script_expertmode && numyaxbunches>0 && yax_getnextwall(i,YAX_CEILING)>=0)
goto yax_readonly;
#endif
@ -95,7 +95,7 @@ static int32_t __fastcall VM_AccessWall(int32_t how, int32_t lVar1, int32_t lLab
break;
case WALL_HITAG: wall[i].hitag=lValue; break;
case WALL_EXTRA:
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (!m32_script_expertmode && numyaxbunches>0 && yax_getnextwall(i,YAX_FLOOR)>=0)
goto yax_readonly;
#endif
@ -144,7 +144,7 @@ badwall:
readonly:
M32_ERROR("Wall structure member `%s' is read-only.", WallLabels[lLabelID].name);
return -1;
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
yax_readonly:
M32_ERROR("Wall structure member `%s' is read-only because it is used for TROR",
WallLabels[lLabelID].name);
@ -188,7 +188,7 @@ static int32_t __fastcall VM_AccessSector(int32_t how, int32_t lVar1, int32_t lL
case SECTOR_CEILINGZ: sector[i].ceilingz=lValue; break;
case SECTOR_FLOORZ: sector[i].floorz=lValue; break;
case SECTOR_CEILINGSTAT:
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (!m32_script_expertmode)
SET_PROTECT_BITS(sector[i].ceilingstat, lValue, YAX_BIT);
else
@ -196,7 +196,7 @@ static int32_t __fastcall VM_AccessSector(int32_t how, int32_t lVar1, int32_t lL
sector[i].ceilingstat = lValue;
break;
case SECTOR_FLOORSTAT:
#ifdef YAX_ENABLE
#ifdef YAX_ENABLE__COMPAT
if (!m32_script_expertmode)
SET_PROTECT_BITS(sector[i].floorstat, lValue, YAX_BIT);
else

View file

@ -929,8 +929,10 @@ static const dataspec_t svgm_secwsp[] =
{ DS_MAINAR, &sprite, sizeof(spritetype), MAXSPRITES },
#ifdef YAX_ENABLE
{ DS_NOCHK, &numyaxbunches, sizeof(numyaxbunches), 1 },
# if !defined NEW_MAP_FORMAT
{ DS_CNT(numsectors), yax_bunchnum, sizeof(yax_bunchnum[0]), (intptr_t)&numsectors },
{ DS_CNT(numwalls), yax_nextwall, sizeof(yax_nextwall[0]), (intptr_t)&numwalls },
# endif
{ DS_LOADFN|DS_PROTECTFN, (void *)&sv_postyaxload, 0, 1 },
#endif
{ 0, &Numsprites, sizeof(Numsprites), 1 },

View file

@ -81,9 +81,11 @@ typedef struct {
intptr_t *vars[MAXGAMEVARS];
#ifdef YAX_ENABLE
int32_t numyaxbunches;
# if !defined NEW_MAP_FORMAT
int16_t yax_bunchnum[MAXSECTORS][2];
int16_t yax_nextwall[MAXWALLS][2];
# endif
#endif
} mapstate_t;
extern void G_SaveMapState(mapstate_t *save);