slightly better linehighlight handling in 2d side-view mode

git-svn-id: https://svn.eduke32.com/eduke32@1865 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-04-11 22:28:58 +00:00
parent 621da89b37
commit 1e937bb5aa
5 changed files with 305 additions and 168 deletions

View File

@ -64,15 +64,23 @@ extern "C" {
////////// yax defs ////////// ////////// yax defs //////////
#define YAX_MAXBUNCHES (MAXSECTORS>>1) #define YAX_MAXBUNCHES (MAXSECTORS>>1)
#define YAX_BIT 1024 #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_CEILING 0 // don't change!
#define YAX_FLOOR 1 // don't change! #define YAX_FLOOR 1 // don't change!
#define SECTORFLD(Sect,Fld, Cf) (*((Cf) ? (&sector[Sect].floor##Fld) : (&sector[Sect].ceiling##Fld))) #define SECTORFLD(Sect,Fld, Cf) (*((Cf) ? (&sector[Sect].floor##Fld) : (&sector[Sect].ceiling##Fld)))
// more user tag hijacking: lotag/extra :/
#define YAX_NEXTWALL(Wall, Cf) (*(&wall[Wall].lotag + 2*Cf))
int16_t yax_getbunch(int16_t i, int16_t cf); int16_t yax_getbunch(int16_t i, int16_t cf);
void yax_getbunches(int16_t i, int16_t *cb, int16_t *fb); 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_setbunch(int16_t i, int16_t cf, int16_t bunchnum);
void yax_setbunches(int16_t i, int16_t cb, int16_t fb); 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);
void yax_update(int32_t onlyreset); void yax_update(int32_t onlyreset);
@ -134,7 +142,8 @@ typedef struct
// bit 7: 1 = Transluscence, 0 = not "T" // bit 7: 1 = Transluscence, 0 = not "T"
// bit 8: 1 = y-flipped, 0 = normal "F" // bit 8: 1 = y-flipped, 0 = normal "F"
// bit 9: 1 = Transluscence reversing, 0 = normal "T" // bit 9: 1 = Transluscence reversing, 0 = normal "T"
// bits 10-15: reserved // bits 10 and 11: reserved (in use by YAX)
// bits 12-15: reserved
//32 bytes //32 bytes
typedef struct typedef struct

View File

@ -76,7 +76,8 @@ extern int32_t m32_sideelev;
extern int16_t m32_sideang; extern int16_t m32_sideang;
extern int32_t m32_sidecos, m32_sidesin; extern int32_t m32_sidecos, m32_sidesin;
extern int32_t m32_swcnt; extern int32_t m32_swcnt;
extern int16_t *m32_wallsprite; extern int32_t m32_wallscreenxy[MAXWALLS][2];
extern int16_t m32_wallsprite[MAXWALLS+MAXSPRITES];
extern int8_t sideview_reversehrot; extern int8_t sideview_reversehrot;
extern inline int32_t scalescreeny(int32_t sy); extern inline int32_t scalescreeny(int32_t sy);
extern void screencoords(int32_t *xres, int32_t *yres, int32_t x, int32_t y, int32_t zoome) ATTRIBUTE((nonnull)); extern void screencoords(int32_t *xres, int32_t *yres, int32_t x, int32_t y, int32_t zoome) ATTRIBUTE((nonnull));

View File

@ -26,24 +26,6 @@ static int32_t crctable[256];
static char kensig[64]; static char kensig[64];
extern const char *ExtGetVer(void); extern const char *ExtGetVer(void);
extern int32_t ExtInit(void);
extern int32_t ExtPreInit(int32_t argc,const char **argv);
extern void ExtUnInit(void);
extern void ExtPreCheckKeys(void);
extern void ExtAnalyzeSprites(void);
extern void ExtCheckKeys(void);
extern void ExtLoadMap(const char *mapname);
extern void ExtSaveMap(const char *mapname);
extern const char *ExtGetSectorCaption(int16_t sectnum);
extern const char *ExtGetWallCaption(int16_t wallnum);
extern const char *ExtGetSpriteCaption(int16_t spritenum);
extern void ExtShowSectorData(int16_t sectnum);
extern void ExtShowWallData(int16_t wallnum);
extern void ExtShowSpriteData(int16_t spritenum);
extern void ExtEditSectorData(int16_t sectnum);
extern void ExtEditWallData(int16_t wallnum);
extern void ExtEditSpriteData(int16_t spritenum);
extern const char *ExtGetSectorType(int32_t lotag);
extern char spritecol2d[MAXTILES][2]; extern char spritecol2d[MAXTILES][2];
@ -232,7 +214,8 @@ void fixspritesectors(void);
static int32_t movewalls(int32_t start, int32_t offs); static int32_t movewalls(int32_t start, int32_t offs);
int32_t loadnames(const char *namesfile); int32_t loadnames(const char *namesfile);
void updatenumsprites(void); void updatenumsprites(void);
static void getclosestpointonwall(int32_t x, int32_t y, int32_t dawall, int32_t *nx, int32_t *ny); static void getclosestpointonwall(int32_t x, int32_t y, int32_t dawall, int32_t *nx, int32_t *ny,
int32_t maybe_screen_coord_p);
static void initcrc(void); static void initcrc(void);
int32_t gettile(int32_t tilenum); int32_t gettile(int32_t tilenum);
@ -357,6 +340,21 @@ static void M32_drawdebug(void)
#endif #endif
#ifdef YAX_ENABLE #ifdef YAX_ENABLE
static void yax_tweakwalls(int16_t start, int16_t offs)
{
int32_t i, nw;
for (i=0; i<numwalls; i++)
{
nw = yax_getnextwall(i, YAX_CEILING);
if (nw >= start)
yax_setnextwall(i, YAX_CEILING, nw+offs);
nw = yax_getnextwall(i, YAX_FLOOR);
if (nw >= start)
yax_setnextwall(i, YAX_FLOOR, nw+offs);
}
}
static void yax_resetbunchnums(void) static void yax_resetbunchnums(void)
{ {
int32_t i; int32_t i;
@ -384,6 +382,12 @@ static void setslope(int32_t sectnum, int32_t cf, int16_t slope)
// If false, it's a wall that you can freely move around, // If false, it's a wall that you can freely move around,
// attach points to, etc... // attach points to, etc...
static int32_t yax_islockedwall(int16_t sec, int16_t line) static int32_t yax_islockedwall(int16_t sec, int16_t line)
#if 1
{
UNREFERENCED_PARAMETER(sec);
return !!(wall[line].cstat&YAX_NEXTWALLBITS);
}
#else
{ {
int16_t cb,fb, cbn,fbn; int16_t cb,fb, cbn,fbn;
int16_t ns = wall[line].nextsector; int16_t ns = wall[line].nextsector;
@ -397,26 +401,6 @@ static int32_t yax_islockedwall(int16_t sec, int16_t line)
return (cb!=cbn || fb!=fbn); return (cb!=cbn || fb!=fbn);
} }
#if 0
static int32_t yax_nextwall(int16_t sec, int16_t line, int32_t downp)
{
int16_t bunchnum = yax_getbunch(sec, downp);
int32_t i, j;
if (bunchnum==-1)
return -1;
for (i=headsectbunch[!downp][bunchnum]; i!=-1; i=nextsectbunch[!downp][i])
{
for (j=sector[i].wallptr; j<sector[i].wallptr+sector[i].wallnum; j++)
if (*(int64_t *)&wall[j] == *(int64_t *)&wall[line])
if (*(int64_t *)&POINT2(j) == *(int64_t *)&POINT2(line))
return j;
}
return -1;
}
#endif #endif
# define DEFAULT_YAX_HEIGHT 32768 # define DEFAULT_YAX_HEIGHT 32768
@ -1933,11 +1917,16 @@ static int32_t ask_above_or_below(void);
// 0: continue // 0: continue
// >0: newnumwalls // >0: newnumwalls
// <0: error // <0: error
static int32_t trace_loop(int32_t j, uint8_t *visitedwall, int16_t *ignore_ret, int16_t *refsect_ret) static int32_t trace_loop(int32_t j, uint8_t *visitedwall, int16_t *ignore_ret, int16_t *refsect_ret,
int16_t trace_loop_yaxcf)
{ {
int16_t refsect, ignore; int16_t refsect, ignore;
int32_t k, n, refwall; int32_t k, n, refwall;
#ifndef YAX_ENABLE
UNREFERENCED_PARAMETER(trace_loop_yaxcf);
#endif
if (wall[j].nextwall>=0 || (visitedwall[j>>3]&(1<<(j&7)))) if (wall[j].nextwall>=0 || (visitedwall[j>>3]&(1<<(j&7))))
return 0; return 0;
@ -1978,6 +1967,10 @@ static int32_t trace_loop(int32_t j, uint8_t *visitedwall, int16_t *ignore_ret,
Bmemcpy(&wall[k], &wall[j], sizeof(walltype)); Bmemcpy(&wall[k], &wall[j], sizeof(walltype));
wall[k].point2 = k+1; wall[k].point2 = k+1;
wall[k].nextsector = wall[k].nextwall = wall[k].extra = -1; wall[k].nextsector = wall[k].nextwall = wall[k].extra = -1;
#ifdef YAX_ENABLE
if (trace_loop_yaxcf >= 0)
yax_setnextwall(k, trace_loop_yaxcf, j);
#endif
k++; k++;
} }
@ -2079,7 +2072,8 @@ static int32_t compare_wall_coords(const void *w1, const void *w2)
void overheadeditor(void) void overheadeditor(void)
{ {
char buffer[80], *dabuffer, ch; char buffer[80], ch;
const char *dabuffer;
int32_t i, j, k, m=0, mousxplc, mousyplc, firstx=0, firsty=0, oposz, col; int32_t i, j, k, m=0, mousxplc, mousyplc, firstx=0, firsty=0, oposz, col;
int32_t tempint, tempint1, tempint2; int32_t tempint, tempint1, tempint2;
int32_t startwall=0, endwall, dax, day, x1, y1, x2, y2, x3, y3, x4, y4; int32_t startwall=0, endwall, dax, day, x1, y1, x2, y2, x3, y3, x4, y4;
@ -2276,7 +2270,7 @@ void overheadeditor(void)
{ {
int16_t secshort = i; int16_t secshort = i;
dabuffer = (char *)ExtGetSectorCaption(i); dabuffer = ExtGetSectorCaption(i);
if (dabuffer[0] == 0) if (dabuffer[0] == 0)
continue; continue;
@ -2299,24 +2293,28 @@ void overheadeditor(void)
} }
i = numwalls-1; i = numwalls-1;
j = numsectors-1;
if (newnumwalls >= 0) if (newnumwalls >= 0)
i = newnumwalls-1; i = newnumwalls-1;
for (wal=&wall[i]; i>=0; i--,wal--) for (wal=&wall[i]; i>=0; i--,wal--)
{ {
if (sector[j].wallptr > i)
j--;
if (zoom < 768 && !(wal->cstat & (1<<14))) if (zoom < 768 && !(wal->cstat & (1<<14)))
continue; continue;
//Get average point of wall //Get average point of wall
dax = (wal->x+wall[wal->point2].x)>>1; // if ((dax > x3) && (dax < x4) && (day > y3) && (day < y4))
day = (wal->y+wall[wal->point2].y)>>1;
if ((dax > x3) && (dax < x4) && (day > y3) && (day < y4))
{ {
dabuffer = (char *)ExtGetWallCaption(i); dabuffer = ExtGetWallCaption(i);
if (dabuffer[0] == 0) if (dabuffer[0] == 0)
continue; continue;
dax = (wal->x+wall[wal->point2].x)>>1;
day = (wal->y+wall[wal->point2].y)>>1;
drawsmallabel(dabuffer, editorcolors[0], editorcolors[31], drawsmallabel(dabuffer, editorcolors[0], editorcolors[31],
dax, day, getflorzofslope(sectorofwall(i), dax,day)); dax, day, getflorzofslope(j, dax,day));
} }
} }
@ -2334,7 +2332,7 @@ void overheadeditor(void)
if (sprite[i].statnum < MAXSTATUS) if (sprite[i].statnum < MAXSTATUS)
{ {
dabuffer = (char *)ExtGetSpriteCaption(i); dabuffer = ExtGetSpriteCaption(i);
if (dabuffer[0] != 0) if (dabuffer[0] != 0)
{ {
int32_t blocking = (sprite[i].cstat&1); int32_t blocking = (sprite[i].cstat&1);
@ -2446,14 +2444,23 @@ void overheadeditor(void)
drawline16base(searchx,searchy, +2,+1, +9,+1, col); drawline16base(searchx,searchy, +2,+1, +9,+1, col);
////// Draw the white pixel closest to mouse cursor on linehighlight ////// Draw the white pixel closest to mouse cursor on linehighlight
if (linehighlight>=0 && !m32_sideview) if (linehighlight>=0)
{ {
getclosestpointonwall(mousxplc,mousyplc, linehighlight, &dax,&day); char col = wall[linehighlight].nextsector >= 0 ? editorcolors[15] : editorcolors[5];
x2 = mulscale14(dax-pos.x,zoom);
y2 = mulscale14(day-pos.y,zoom);
drawline16base(halfxdim16+x2,midydim16+y2, 0,0, 0,0, if (m32_sideview)
wall[linehighlight].nextsector >= 0 ? editorcolors[15] : editorcolors[5]); {
getclosestpointonwall(searchx,searchy, linehighlight, &dax,&day, 1);
drawline16base(dax,day, 0,0, 0,0, col);
}
else
{
getclosestpointonwall(mousxplc,mousyplc, linehighlight, &dax,&day, 0);
x2 = mulscale14(dax-pos.x,zoom);
y2 = mulscale14(day-pos.y,zoom);
drawline16base(halfxdim16+x2,midydim16+y2, 0,0, 0,0, col);
}
} }
enddrawing(); //}}} enddrawing(); //}}}
@ -2887,7 +2894,7 @@ void overheadeditor(void)
for (i=0; i<highlightsectorcnt; i++) for (i=0; i<highlightsectorcnt; i++)
for (WALLS_OF_SECTOR(highlightsector[i], j)) for (WALLS_OF_SECTOR(highlightsector[i], j))
{ {
k = trace_loop(j, visited, NULL, NULL); k = trace_loop(j, visited, NULL, NULL, !cf);
if (k == 0) if (k == 0)
continue; continue;
else if (k < 0) else if (k < 0)
@ -2900,6 +2907,23 @@ void overheadeditor(void)
numwalls = k; numwalls = k;
} }
for (i=m; i<numwalls; i++) // try
{
j = YAX_NEXTWALL(i, !cf);
if (j < 0)
{
message("Internal error while constructing sector: "
"YAX_NEXTWALL(%d, %d)<0!", i, !cf);
numwalls = m;
goto end_yax;
}
}
for (i=m; i<numwalls; i++) // do!
{
j = YAX_NEXTWALL(i, !cf);
yax_setnextwall(j, cf, i);
}
// create new sector based on first highlighted one // create new sector based on first highlighted one
i = highlightsector[0]; i = highlightsector[0];
Bmemcpy(&sector[numsectors], &sector[i], sizeof(sectortype)); Bmemcpy(&sector[numsectors], &sector[i], sizeof(sectortype));
@ -3202,7 +3226,7 @@ end_yax: ;
{ {
for (WALLS_OF_SECTOR(highlightsector[i], j)) for (WALLS_OF_SECTOR(highlightsector[i], j))
{ {
k = trace_loop(j, visited, &ignore, &refsect); k = trace_loop(j, visited, &ignore, &refsect, -1);
if (k == 0) if (k == 0)
continue; continue;
else if (k < 0) else if (k < 0)
@ -3242,6 +3266,9 @@ end_yax: ;
if (wall[m].nextwall >= begwalltomove) if (wall[m].nextwall >= begwalltomove)
wall[m].nextwall += n; wall[m].nextwall += n;
} }
#ifdef YAX_ENABLE
yax_tweakwalls(begwalltomove, n);
#endif
for (m=refsect+1; m<numsectors; m++) for (m=refsect+1; m<numsectors; m++)
sector[m].wallptr += n; sector[m].wallptr += n;
for (m=begwalltomove; m<numwalls; m++) for (m=begwalltomove; m<numwalls; m++)
@ -4473,6 +4500,9 @@ check_next_sector: ;
if (wall[i].point2 >= suckwall) if (wall[i].point2 >= suckwall)
wall[i].point2 += j; wall[i].point2 += j;
} }
#ifdef YAX_ENABLE
yax_tweakwalls(suckwall, j);
#endif
Bmemmove(&wall[suckwall+j], &wall[suckwall], (newnumwalls-suckwall)*sizeof(walltype)); Bmemmove(&wall[suckwall+j], &wall[suckwall], (newnumwalls-suckwall)*sizeof(walltype));
Bmemmove(&wall[suckwall], &wall[newnumwalls], j*sizeof(walltype)); Bmemmove(&wall[suckwall], &wall[newnumwalls], j*sizeof(walltype));
@ -4962,12 +4992,32 @@ end_space_handling:
} }
else else
{ {
getclosestpointonwall(mousxplc,mousyplc, linehighlight, &dax,&day); getclosestpointonwall(m32_sideview?searchx:mousxplc, m32_sideview?searchy:mousyplc,
adjustmark(&dax,&day, newnumwalls); linehighlight, &dax,&day, 1);
i = linehighlight; i = linehighlight;
if (m32_sideview)
{
int32_t y_p, d, dx, dy, frac;
dx = dax - m32_wallscreenxy[i][0];
dy = day - m32_wallscreenxy[i][1];
d = max(dx, dy);
y_p = (dy>dx);
if (d==0)
goto point_not_inserted;
frac = divscale24(d, m32_wallscreenxy[wall[i].point2][y_p]-m32_wallscreenxy[i][y_p]);
dax = POINT2(i).x - wall[i].x;
day = POINT2(i).y - wall[i].y;
dax = wall[i].x + mulscale24(dax,frac);
day = wall[i].y + mulscale24(day,frac);
}
adjustmark(&dax,&day, newnumwalls);
if ((wall[i].x == dax && wall[i].y == day) || (POINT2(i).x == dax && POINT2(i).y == day)) if ((wall[i].x == dax && wall[i].y == day) || (POINT2(i).x == dax && POINT2(i).y == day))
{ {
point_not_inserted:
printmessage16("Point not inserted."); printmessage16("Point not inserted.");
} }
else else
@ -5572,6 +5622,7 @@ void getpoint(int32_t searchxe, int32_t searchye, int32_t *x, int32_t *y)
static int32_t getlinehighlight(int32_t xplc, int32_t yplc, int32_t line) static int32_t getlinehighlight(int32_t xplc, int32_t yplc, int32_t line)
{ {
int32_t i, dst, dist, closest, x1, y1, x2, y2, nx, ny; int32_t i, dst, dist, closest, x1, y1, x2, y2, nx, ny;
int32_t daxplc, dayplc;
if (numwalls == 0) if (numwalls == 0)
return -1; return -1;
@ -5583,11 +5634,23 @@ static int32_t getlinehighlight(int32_t xplc, int32_t yplc, int32_t line)
return -1; return -1;
dist = 1024; dist = 1024;
if (m32_sideview)
{
daxplc = searchx;
dayplc = searchy;
dist = mulscale14(dist, zoom);
}
else
{
daxplc = xplc;
dayplc = yplc;
}
closest = -1; closest = -1;
for (i=0; i<numwalls; i++) for (i=0; i<numwalls; i++)
{ {
getclosestpointonwall(xplc,yplc, i, &nx,&ny); getclosestpointonwall(daxplc,dayplc, i, &nx,&ny, 1);
dst = klabs(xplc-nx) + klabs(yplc-ny); dst = klabs(daxplc-nx) + klabs(dayplc-ny);
if (dst <= dist) if (dst <= dist)
{ {
dist = dst; dist = dst;
@ -5602,7 +5665,7 @@ static int32_t getlinehighlight(int32_t xplc, int32_t yplc, int32_t line)
y1 = wall[closest].y; y1 = wall[closest].y;
x2 = POINT2(closest).x; x2 = POINT2(closest).x;
y2 = POINT2(closest).y; y2 = POINT2(closest).y;
if (dmulscale32(xplc-x1,y2-y1,-(x2-x1),yplc-y1) >= 0) if (dmulscale32(daxplc-x1,y2-y1,-(x2-x1),dayplc-y1) >= 0)
closest = wall[closest].nextwall; closest = wall[closest].nextwall;
} }
@ -5970,6 +6033,9 @@ static int32_t movewalls(int32_t start, int32_t offs)
if (wall[i].nextwall >= start) wall[i].nextwall += offs; if (wall[i].nextwall >= start) wall[i].nextwall += offs;
if (wall[i].point2 >= start) wall[i].point2 += offs; if (wall[i].point2 >= start) wall[i].point2 += offs;
} }
#ifdef YAX_ENABLE
yax_tweakwalls(start, offs);
#endif
return(0); return(0);
} }
@ -7258,7 +7324,8 @@ void showwalldata(int16_t wallnum, int16_t small)
if (small) if (small)
{ {
_printmessage16("^10Wall %d %s ^O(F8 to edit)", wallnum, ExtGetWallCaption(wallnum)); _printmessage16("^10Wall %d %s ^O(F8 to edit)", wallnum,
ExtGetWallCaption(wallnum));
return; return;
} }
@ -7440,21 +7507,35 @@ void printmessage256(int32_t x, int32_t y, const char *name)
} }
//Find closest point (*dax, *day) on wall (dawall) to (x, y) //Find closest point (*dax, *day) on wall (dawall) to (x, y)
static void getclosestpointonwall(int32_t x, int32_t y, int32_t dawall, int32_t *nx, int32_t *ny) static void getclosestpointonwall(int32_t x, int32_t y, int32_t dawall, int32_t *nx, int32_t *ny,
int32_t maybe_screen_coord_p)
{ {
walltype *wal; int64_t i, j, wx,wy, wx2,wy2, dx, dy;
int64_t i, j, dx, dy;
wal = &wall[dawall]; if (m32_sideview && maybe_screen_coord_p)
dx = wall[wal->point2].x - wal->x; {
dy = wall[wal->point2].y - wal->y; wx = m32_wallscreenxy[dawall][0];
i = dx*(x-wal->x) + dy*(y-wal->y); wy = m32_wallscreenxy[dawall][1];
if (i <= 0) { *nx = wal->x; *ny = wal->y; return; } wx2 = m32_wallscreenxy[wall[dawall].point2][0];
j = dx*dx+dy*dy; wy2 = m32_wallscreenxy[wall[dawall].point2][1];
if (i >= j) { *nx = wal->x+dx; *ny = wal->y+dy; return; } }
else
{
wx = wall[dawall].x;
wy = wall[dawall].y;
wx2 = POINT2(dawall).x;
wy2 = POINT2(dawall).y;
}
dx = wx2 - wx;
dy = wy2 - wy;
i = dx*(x-wx) + dy*(y-wy);
if (i <= 0) { *nx = wx; *ny = wy; return; }
j = dx*dx + dy*dy;
if (i >= j) { *nx = wx2; *ny = wy2; return; }
i=((i<<15)/j)<<15; i=((i<<15)/j)<<15;
*nx = wal->x + ((dx*i)>>30); *nx = wx + ((dx*i)>>30);
*ny = wal->y + ((dy*i)>>30); *ny = wy + ((dy*i)>>30);
} }
static void initcrc(void) static void initcrc(void)

View File

@ -192,8 +192,33 @@ int16_t editstatus = 0;
// game-time YAX data structures // game-time YAX data structures
static int16_t yax_bunchnum[MAXSECTORS][2]; static int16_t yax_bunchnum[MAXSECTORS][2];
static int16_t yax_nextwall[MAXWALLS][2];
static int32_t yax_islockededge(/*int16_t sec,*/ int16_t line, int16_t cf)
#if 1
{
// UNREFERENCED_PARAMETER(sec);
return !!(wall[line].cstat&(YAX_NEXTWALLBIT(cf)));
}
#else
{
int16_t bunchnum, nextbunch;
int16_t ns = wall[line].nextsector;
bunchnum = yax_getbunch(sec, cf);
if (ns < 0)
return (bunchnum >= 0);
nextbunch = yax_getbunch(ns, cf);
return (bunchnum != nextbunch);
}
#endif
#define YAX_BUNCHNUM(Sect, Cf) (*(int16_t *)(&sector[Sect].ceilingxpanning + 6*Cf)) #define YAX_BUNCHNUM(Sect, Cf) (*(int16_t *)(&sector[Sect].ceilingxpanning + 6*Cf))
//// bunch getters/setters
int16_t yax_getbunch(int16_t i, int16_t cf) int16_t yax_getbunch(int16_t i, int16_t cf)
{ {
if (editstatus==0) if (editstatus==0)
@ -214,7 +239,10 @@ 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_setbunch(int16_t i, int16_t cf, int16_t bunchnum)
{ {
if (editstatus==0) if (editstatus==0)
{
yax_bunchnum[i][cf] = bunchnum; yax_bunchnum[i][cf] = bunchnum;
return;
}
if (bunchnum<0) if (bunchnum<0)
{ {
@ -233,9 +261,38 @@ void yax_setbunches(int16_t i, int16_t cb, int16_t fb)
yax_setbunch(i, YAX_FLOOR, fb); yax_setbunch(i, YAX_FLOOR, fb);
} }
//// nextwall getters/setters
int16_t yax_getnextwall(int16_t wal, int16_t cf)
{
if (editstatus==0)
return yax_nextwall[wal][cf];
if (!yax_islockededge(wal, cf))
return -1;
return YAX_NEXTWALL(wal, cf);
}
// unchecked!
void yax_setnextwall(int16_t wal, int16_t cf, int16_t thenextwall)
{
if (editstatus==0)
{
yax_nextwall[wal][cf] = thenextwall;
return;
}
if (thenextwall >= 0)
wall[wal].cstat |= YAX_NEXTWALLBIT(cf);
else
wall[wal].cstat &= ~YAX_NEXTWALLBIT(cf);
YAX_NEXTWALL(wal, cf) = thenextwall;
}
//// in-struct --> array transfer; list construction
void yax_update(int32_t onlyreset) void yax_update(int32_t onlyreset)
{ {
int32_t i, oeditstatus=editstatus; int32_t i, j, oeditstatus=editstatus;
int16_t cb, fb, tmpsect; int16_t cb, fb, tmpsect;
numyaxbunches = 0; numyaxbunches = 0;
@ -247,6 +304,8 @@ void yax_update(int32_t onlyreset)
} }
for (i=0; i<YAX_MAXBUNCHES; i++) for (i=0; i<YAX_MAXBUNCHES; i++)
headsectbunch[0][i] = headsectbunch[1][i] = -1; headsectbunch[0][i] = headsectbunch[1][i] = -1;
for (i=0; i<MAXWALLS; i++)
yax_nextwall[i][0] = yax_nextwall[i][1] = -1;
if (onlyreset) if (onlyreset)
return; return;
@ -261,6 +320,12 @@ void yax_update(int32_t onlyreset)
if (cb >= 0) if (cb >= 0)
{ {
for (j=sector[i].wallptr; j<sector[i].wallptr+sector[i].wallnum; j++)
{
if (yax_islockededge(j,YAX_CEILING))
yax_nextwall[j][0] = YAX_NEXTWALL(j,0);
}
if (headsectbunch[0][cb] == -1) if (headsectbunch[0][cb] == -1)
{ {
headsectbunch[0][cb] = i; headsectbunch[0][cb] = i;
@ -278,6 +343,12 @@ void yax_update(int32_t onlyreset)
if (fb >= 0) if (fb >= 0)
{ {
for (j=sector[i].wallptr; j<sector[i].wallptr+sector[i].wallnum; j++)
{
if (yax_islockededge(j,YAX_FLOOR))
yax_nextwall[j][1] = YAX_NEXTWALL(j,1);
}
if (headsectbunch[1][fb] == -1) if (headsectbunch[1][fb] == -1)
headsectbunch[1][fb] = i; headsectbunch[1][fb] = i;
else else
@ -301,8 +372,9 @@ int16_t m32_sideang = 200; // azimuth, 0..2047
int32_t m32_sidecos, m32_sidesin; int32_t m32_sidecos, m32_sidesin;
int32_t m32_swcnt; int32_t m32_swcnt;
int16_t *m32_wallsprite; // [MAXSWALLS+MAXSPRITES] int32_t m32_wallscreenxy[MAXWALLS][2];
static int32_t *m32_sidedist; // [MAXSWALLS+MAXSPRITES] int16_t m32_wallsprite[MAXWALLS+MAXSPRITES];
static int32_t m32_sidedist[MAXWALLS+MAXSPRITES];
static vec3_t m32_viewplane; static vec3_t m32_viewplane;
@ -12032,6 +12104,26 @@ void setfirstwall(int16_t sectnum, int16_t newfirstwall)
for (i=startwall; i<endwall; i++) for (i=startwall; i<endwall; i++)
if (wall[i].nextwall >= 0) wall[wall[i].nextwall].nextwall = i; if (wall[i].nextwall >= 0) wall[wall[i].nextwall].nextwall = i;
#ifdef YAX_ENABLE
{
int16_t cb, fb;
yax_getbunches(sectnum, &cb, &fb);
if (cb>=0 || fb>=0)
{
for (i=startwall; i<endwall; i++)
{
j = yax_getnextwall(i, YAX_CEILING);
if (j >= 0)
yax_setnextwall(j, YAX_FLOOR, i);
j = yax_getnextwall(i, YAX_FLOOR);
if (j >= 0)
yax_setnextwall(j, YAX_CEILING, i);
}
}
}
#endif
Bfree(tmpwall); Bfree(tmpwall);
} }
@ -12854,6 +12946,9 @@ static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t
// if (i < wall[j].point2) // if (i < wall[j].point2)
drawline16mid(x1,y1, x1,y1+getscreenvdisp(fzn-fz,zoome), editorcolors[col]); drawline16mid(x1,y1, x1,y1+getscreenvdisp(fzn-fz,zoome), editorcolors[col]);
} }
m32_wallscreenxy[i][0] = halfxdim16+x1;
m32_wallscreenxy[i][1] = midydim16+y1;
} }
if (wal->cstat&64) // if hitscan bit set if (wal->cstat&64) // if hitscan bit set
@ -13117,18 +13212,6 @@ void draw2dscreen(const vec3_t *pos, int16_t cursectnum, int16_t ange, int32_t z
if (qsetmode == 200) return; if (qsetmode == 200) return;
setup_sideview_sincos(); setup_sideview_sincos();
if (m32_sideview && !m32_wallsprite)
{
m32_wallsprite = Bmalloc((MAXWALLS+MAXSPRITES)*sizeof(int16_t));
m32_sidedist = Bmalloc((MAXWALLS+MAXSPRITES)*sizeof(m32_sidedist[0]));
if (!m32_wallsprite || !m32_sidedist)
{
if (m32_wallsprite) Bfree(m32_wallsprite);
if (m32_sidedist) { Bfree(m32_sidedist); m32_sidedist=NULL; }
initprintf("out of memory!");
m32_sideview = 0;
}
}
begindrawing(); //{{{ begindrawing(); //{{{

View File

@ -795,81 +795,36 @@ static int32_t tileInGroup(int32_t group, int32_t tilenum)
const char *ExtGetSectorType(int32_t lotag) const char *ExtGetSectorType(int32_t lotag)
{ {
static char tempbuf[64];
Bmemset(tempbuf,0,sizeof(tempbuf));
switch (lotag) switch (lotag)
{ {
case 1: case 1: return "WATER (SE 7)";
Bsprintf(tempbuf,"WATER (SE 7)"); case 2: return "UNDERWATER (SE 7)";
break; case 9: return "STAR TREK DOORS";
case 2: case 15: return "ELEVATOR TRANSPORT (SE 17)";
Bsprintf(tempbuf,"UNDERWATER (SE 7)"); case 16: return "ELEVATOR PLATFORM DOWN";
break; case 17: return "ELEVATOR PLATFORM UP";
case 9: case 18: return "ELEVATOR DOWN";
Bsprintf(tempbuf,"STAR TREK DOORS"); case 19: return "ELEVATOR UP";
break; case 20: return "CEILING DOOR";
case 15: case 21: return "FLOOR DOOR";
Bsprintf(tempbuf,"ELEVATOR TRANSPORT (SE 17)"); case 22: return "SPLIT DOOR";
break; case 23: return "SWING DOOR (SE 11)";
case 16: case 25: return "SLIDE DOOR (SE 15)";
Bsprintf(tempbuf,"ELEVATOR PLATFORM DOWN"); case 26: return "SPLIT STAR TREK DOOR";
break; case 27: return "BRIDGE (SE 20)";
case 17: case 28: return "DROP FLOOR (SE 21)";
Bsprintf(tempbuf,"ELEVATOR PLATFORM UP"); case 29: return "TEETH DOOR (SE 22)";
break; case 30: return "ROTATE RISE BRIDGE";
case 18: case 31: return "2 WAY TRAIN (SE=30)";
Bsprintf(tempbuf,"ELEVATOR DOWN"); case 32767: return "SECRET ROOM";
break; case -1: return "END OF LEVEL";
case 19: default:
Bsprintf(tempbuf,"ELEVATOR UP");
break;
case 20:
Bsprintf(tempbuf,"CEILING DOOR");
break;
case 21:
Bsprintf(tempbuf,"FLOOR DOOR");
break;
case 22:
Bsprintf(tempbuf,"SPLIT DOOR");
break;
case 23:
Bsprintf(tempbuf,"SWING DOOR (SE 11)");
break;
case 25:
Bsprintf(tempbuf,"SLIDE DOOR (SE 15)");
break;
case 26:
Bsprintf(tempbuf,"SPLIT STAR TREK DOOR");
break;
case 27:
Bsprintf(tempbuf,"BRIDGE (SE 20)");
break;
case 28:
Bsprintf(tempbuf,"DROP FLOOR (SE 21)");
break;
case 29:
Bsprintf(tempbuf,"TEETH DOOR (SE 22)");
break;
case 30:
Bsprintf(tempbuf,"ROTATE RISE BRIDGE");
break;
case 31:
Bsprintf(tempbuf,"2 WAY TRAIN (SE=30)");
break;
case 32767:
Bsprintf(tempbuf,"SECRET ROOM");
break;
case -1:
Bsprintf(tempbuf,"END OF LEVEL");
break;
default :
if (lotag > 10000 && lotag < 32767) if (lotag > 10000 && lotag < 32767)
Bsprintf(tempbuf,"1 TIME SOUND"); return "1 TIME SOUND";
// else Bsprintf(tempbuf,"%hu",lotag); // else Bsprintf(tempbuf,"%hu",lotag);
break;
} }
return(tempbuf);
return "";
} }
const char *ExtGetSectorCaption(int16_t sectnum) const char *ExtGetSectorCaption(int16_t sectnum)
@ -916,7 +871,19 @@ const char *ExtGetWallCaption(int16_t wallnum)
if ((wall[wallnum].lotag|wall[wallnum].hitag) == 0) if ((wall[wallnum].lotag|wall[wallnum].hitag) == 0)
tempbuf[0] = 0; tempbuf[0] = 0;
else else
{
#ifdef YAX_ENABLE
if (yax_getnextwall(wallnum, YAX_CEILING) >= 0) // ceiling nextwall: lotag
{
if (wall[wallnum].hitag == 0)
tempbuf[0] = 0;
else
Bsprintf(tempbuf, "%hu,*", wall[wallnum].hitag);
}
else
#endif
Bsprintf(tempbuf, "%hu,%hu", wall[wallnum].hitag, wall[wallnum].lotag); Bsprintf(tempbuf, "%hu,%hu", wall[wallnum].hitag, wall[wallnum].lotag);
}
return(tempbuf); return(tempbuf);
} //end } //end
@ -1104,8 +1071,7 @@ void ExtShowSectorData(int16_t sectnum) //F5
for (i=0; i<numsectors; i++) for (i=0; i<numsectors; i++)
secrets += (sector[i].lotag==32767); secrets += (sector[i].lotag==32767);
i = headspritestat[0]; for (i=headspritestat[0]; i != -1; i=nextspritestat[i])
while (i != -1)
{ {
// Count all non-player actors. // Count all non-player actors.
if (tileInGroup(tilegroupActors, sprite[i].picnum)) if (tileInGroup(tilegroupActors, sprite[i].picnum))
@ -1118,8 +1084,6 @@ void ExtShowSectorData(int16_t sectnum) //F5
if (sprite[i].picnum == RESPAWN) if (sprite[i].picnum == RESPAWN)
totalrespawn++; totalrespawn++;
i = nextspritestat[i];
} }
Bmemset(numsprite, 0, sizeof(numsprite)); Bmemset(numsprite, 0, sizeof(numsprite));
@ -1613,7 +1577,6 @@ static void ReadHelpFile(const char *name)
return; return;
HELPFILE_ERROR: HELPFILE_ERROR:
Bfclose(fp); Bfclose(fp);
initprintf("ReadHelpFile(): ERROR allocating memory.\n"); initprintf("ReadHelpFile(): ERROR allocating memory.\n");
return; return;