Insert two divide-by-zero checks that seem to fix the overhead map crash, but only with NOASM=1. Fix a couple of Mapster32 bugs and prettify some code there. Fix EDuke32 bug where the demo system overwrote boardname[] while using the file picker, making navigation between directories impossible.

git-svn-id: https://svn.eduke32.com/eduke32@1869 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-04-22 22:48:06 +00:00
parent e35be69a0c
commit 243e50db4b
5 changed files with 691 additions and 194 deletions

View file

@ -85,7 +85,17 @@ 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_updategrays(int32_t posze);
int32_t yax_getneighborsect(int32_t x, int32_t y, int32_t sectnum, int32_t cf, int16_t *ret_bunchnum);
void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectnum);
#ifdef YAX_ENABLE
# define YAX_SKIPSECTOR(i) if (graysectbitmap[(i)>>3]&(1<<((i)&7))) continue
# define YAX_SKIPWALL(i) if (graywallbitmap[(i)>>3]&(1<<((i)&7))) continue
#else
# define YAX_SKIPSECTOR(i) (i)=(i)
# define YAX_SKIPWALL(i) (i)=(i)
#endif
#define CLIPMASK0 (((1L)<<16)+1L)
#define CLIPMASK1 (((256L)<<16)+64L)

View file

@ -204,7 +204,7 @@ static void deletepoint(int16_t point);
static int32_t deletesector(int16_t sucksect);
void fixrepeats(int16_t i);
static int16_t loopinside(int32_t x, int32_t y, int16_t startwall);
int32_t fillsector(int16_t sectnum, char fillcolor);
int32_t fillsector(int16_t sectnum, int32_t fillcolor); // fillcolor == -1: default (pulsating)
static int16_t whitelinescan(int16_t sucksect, int16_t dalinehighlight);
void printcoords16(int32_t posxe, int32_t posye, int16_t ange);
static void copysector(int16_t soursector, int16_t destsector, int16_t deststartwall, char copystat, const int16_t *oldtonewsect);
@ -363,6 +363,7 @@ static void yax_resetbunchnums(void)
for (i=0; i<MAXSECTORS; i++)
yax_setbunches(i, -1, -1);
yax_update(1);
yax_updategrays(pos.z);
}
// Whether a wall is constrained by sector extensions.
@ -502,6 +503,42 @@ int32_t app_main(int32_t argc, const char **argv)
loadpics("tiles000.art", 1048576*16);
#ifdef YAX_ENABLE
// init dummy texture for YAX
// must be after loadpics(), which inits BUILD's cache
i = MAXTILES-1;
if (tilesizx[i]==0 && tilesizy[i]==0)
{
static char R[8*16] = { //
0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0,
0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0,
0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0,
0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0,
0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0,
0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0,
0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0,
};
char *newtile;
int32_t sx=32, sy=32, col, j;
walock[i] = 255; // permanent tile
picsiz[i] = 5 + (5<<4);
tilesizx[i] = sx; tilesizy[i] = sy;
allocache(&waloff[i], sx*sy, &walock[i]);
newtile = (char *)waloff[i];
col = getclosestcol(128>>2, 128>>2, 0);
for (j=0; j<(signed)sizeof(R); j++)
R[j] *= col;
Bmemset(newtile, 0, sx*sy);
for (j=0; j<8; j++)
Bmemcpy(&newtile[32*j], &R[16*j], 16);
}
#endif
Bstrcpy(kensig,"Uses BUILD technology by Ken Silverman");
initcrc();
@ -598,6 +635,9 @@ CANCEL:
ExtPreCheckKeys();
drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum);
#ifdef YAX_ENABLE
yax_drawrooms(ExtAnalyzeSprites, horiz, cursectnum);
#endif
ExtAnalyzeSprites();
drawmasks();
@ -1268,6 +1308,22 @@ char changechar(char dachar, int32_t dadir, char smooshyalign, char boundcheck)
////////////////////// OVERHEADEDITOR //////////////////////
#if 0
static int32_t inside_nogray(int32_t x, int32_t y, int16_t sectnum)
{
#ifdef YAX_ENABLE
if (sectnum>=0 && (graysectbitmap[sectnum>>3]&(1<<(sectnum&7))))
return 0;
#endif
return inside(x, y, sectnum);
}
#endif
static int32_t inside_editor_curpos(int16_t sectnum)
{
return inside_editor(&pos, searchx,searchy, zoom, mousxplc,mousyplc, sectnum);
}
int32_t inside_editor(const vec3_t *pos, int32_t searchx, int32_t searchy, int32_t zoom,
int32_t x, int32_t y, int16_t sectnum)
{
@ -1825,7 +1881,7 @@ void correct_sprite_yoffset(int32_t i)
sprite[i].yoffset = 0;
}
void fade_editor_screen(void)
void fade_editor_screen(int32_t keepcol)
{
char blackcol=editorcolors[0], greycol=whitecol-25, *cp;
int32_t i;
@ -1833,10 +1889,15 @@ void fade_editor_screen(void)
begindrawing();
cp = (char *)frameplace;
for (i=0; i<bytesperline*(ydim-STATUS2DSIZ2); i++, cp++)
{
if ((int32_t)(*cp) == keepcol)
continue;
if (*cp==greycol)
*cp = blackcol;
else if (*cp != blackcol)
*cp = greycol;
}
enddrawing();
showframe(1);
}
@ -1870,6 +1931,32 @@ static void copy_some_wall_members(int16_t dst, int16_t src)
#endif
}
static void init_new_wall1(int16_t *suckwall, int32_t *mousxplc, int32_t *mousyplc)
{
int32_t i;
Bmemset(&wall[newnumwalls], 0, sizeof(walltype));
wall[newnumwalls].extra = -1;
wall[newnumwalls].x = *mousxplc;
wall[newnumwalls].y = *mousyplc;
wall[newnumwalls].nextsector = -1;
wall[newnumwalls].nextwall = -1;
for (i=0; i<numwalls; i++)
{
YAX_SKIPWALL(i);
if (wall[i].nextwall >= 0)
YAX_SKIPWALL(wall[i].nextwall);
if (wall[i].x == *mousxplc && wall[i].y == *mousyplc)
*suckwall = i;
}
wall[newnumwalls].point2 = newnumwalls+1;
newnumwalls++;
}
// helpers for often needed ops:
static int32_t do_while_copyloop1(int16_t startwall, int16_t endwall,
int16_t *danumwalls, int16_t lastpoint2)
@ -2070,6 +2157,62 @@ static int32_t compare_wall_coords(const void *w1, const void *w2)
circlepoints = 7; \
} while (0)
// breadth-first search helpers
void bfirst_search_init(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int32_t maxnum, int16_t firstelt)
{
Bmemset(bitmap, 0, (maxnum+7)>>3);
*eltnumptr = 0;
list[*eltnumptr] = firstelt;
bitmap[*eltnumptr>>3] |= (1<<(*eltnumptr&7));
(*eltnumptr)++;
}
void bfirst_search_try(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int16_t elt)
{
if (elt < 0)
return;
if ((bitmap[elt>>3]&(1<<(elt&7)))==0)
{
bitmap[elt>>3] |= (1<<(elt&7));
list[*eltnumptr] = elt;
(*eltnumptr)++;
}
}
#ifdef YAX_ENABLE
// whether all highlighted sectors are in one connected component
// wrt the nextsector relation
static int32_t highlighted_sectors_in_one_component()
{
int32_t j, k, startwall, endwall, sectcnt, sectnum;
static int16_t sectlist[MAXSECTORS];
static uint8_t sectbitmap[MAXSECTORS>>3];
if (highlightsectorcnt<1)
return 0;
if (highlightsectorcnt==1)
return 1;
bfirst_search_init(sectlist, sectbitmap, &sectnum, MAXSECTORS, highlightsector[0]);
for (sectcnt=0; sectcnt<sectnum; sectcnt++)
for (WALLS_OF_SECTOR(sectlist[sectcnt], j))
bfirst_search_try(sectlist, sectbitmap, &sectnum, wall[j].nextsector);
for (k=0; k<highlightsectorcnt; k++)
{
j = highlightsector[k];
if ((sectbitmap[j>>3]&(1<<(j&7)))==0)
return 0;
}
return 1;
}
#endif
void overheadeditor(void)
{
char buffer[80], ch;
@ -2367,7 +2510,7 @@ void overheadeditor(void)
ydim16 = ydim-STATUS2DSIZ2;
for (i=0; i<numsectors; i++)
if (hlsectorbitmap[i>>3]&(1<<(i&7)))
fillsector(i,2);
fillsector(i, -1);
ydim16 = oydim16;
}
@ -2758,7 +2901,7 @@ void overheadeditor(void)
keystatus[0x41] = 0;
for (i=0; i<numsectors; i++)
if (inside_editor(&pos, searchx,searchy, zoom, mousxplc,mousyplc,i) == 1)
if (inside_editor_curpos(i) == 1)
{
ExtEditSectorData(i);
break;
@ -2821,7 +2964,7 @@ void overheadeditor(void)
else
{
for (i=0; i<numsectors; i++)
if (inside_editor(&pos, searchx,searchy, zoom, mousxplc,mousyplc,i) == 1)
if (inside_editor_curpos(i) == 1)
{
Bsprintf(buffer, "Sector (%d) Hi-tag: ", i);
sector[i].hitag = getnumber16(buffer, sector[i].hitag, BTAG_MAX, 0);
@ -2835,7 +2978,7 @@ void overheadeditor(void)
keystatus[0x19] = 0;
for (i=0; i<numsectors; i++)
if (inside_editor(&pos, searchx,searchy, zoom, mousxplc,mousyplc,i) == 1)
if (inside_editor_curpos(i) == 1)
{
Bsprintf(buffer, "Sector (%d) Ceilingpal: ", i);
sector[i].ceilingpal = getnumber16(buffer, sector[i].ceilingpal, M32_MAXPALOOKUPS, 0);
@ -2866,6 +3009,12 @@ void overheadeditor(void)
int32_t cf, thez;
if (!highlighted_sectors_in_one_component())
{
message("Sectors to extend must be in one connected component");
goto end_yax;
}
cf = ask_above_or_below();
if (cf==-1)
goto end_yax;
@ -2906,13 +3055,6 @@ void overheadeditor(void)
numwalls = m;
goto end_yax;
}
if (numwalls != m)
{
message("Sectors to extend must be in one connected component");
numwalls = m;
goto end_yax;
}
//message("loop");
wall[k-1].point2 = numwalls;
numwalls = k;
@ -2947,6 +3089,8 @@ void overheadeditor(void)
setslope(numsectors, !cf, 0);
setslope(numsectors, cf, 0);
SECTORFLD(numsectors,stat, !cf) &= ~1; // no plax
SECTORFLD(numsectors,z, !cf) = SECTORFLD(i,z, cf);
SECTORFLD(numsectors,z, cf) = SECTORFLD(i,z, cf) - (1-2*cf)*DEFAULT_YAX_HEIGHT;
@ -2965,6 +3109,8 @@ void overheadeditor(void)
// restore red walls of the selected sectors
for (i=0; i<highlightsectorcnt; i++)
{
SECTORFLD(highlightsector[i],stat, cf) &= ~1; // no plax
for (WALLS_OF_SECTOR(highlightsector[i], j))
if (wall[j].nextwall < 0)
checksectorpointer(j, highlightsector[i]);
@ -2980,6 +3126,7 @@ void overheadeditor(void)
numsectors++;
yax_update(0);
yax_updategrays(pos.z);
Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap));
update_highlightsector();
@ -3221,9 +3368,9 @@ end_yax: ;
if (!didmakered && !hadouterpoint && newnumwalls<0)
{
// fade the screen to have the user's attention
fade_editor_screen();
fade_editor_screen(-1);
didmakered |= !ask_if_sure("Insert outer loop and make red walls?", 0);
didmakered |= !ask_if_sure("Insert outer loop and make red walls? (Y/N)", 0);
clearkeys();
}
@ -3395,7 +3542,7 @@ end_yax: ;
if (((bstatus&1) < (oldmousebstatus&1)) && highlightsectorcnt < 0) //after dragging
{
int32_t runi;
int32_t runi, numdelpoints=0;
if (backup_drawn_walls(0))
goto end_after_dragging;
@ -3435,12 +3582,10 @@ end_yax: ;
for (i=numwalls-1; i>=0; i--) //delete points
{
if (wall[i].x == POINT2(i).x && wall[i].y == POINT2(i).y
&& sector[sectorofwall(i)].wallnum > 3
&& sector[sectorofwall(wall[i].point2)].wallnum > 3)
&& sector[sectorofwall(i)].wallnum > 3)
{
int32_t b = (wall[i].nextwall == -1 ||
(sector[sectorofwall(wall[i].nextwall)].wallnum > 3 &&
sector[sectorofwall(NEXTWALL(i).point2)].wallnum > 3));
sector[sectorofwall(wall[i].nextwall)].wallnum > 3);
if (runi==0 && !b)
{
printmessage16("Invalid operation, delete or join sector instead.");
@ -3449,12 +3594,20 @@ end_yax: ;
else if (runi==1 && b)
{
deletepoint(i);
printmessage16("Point deleted.");
asksave = 1;
numdelpoints++;
}
}
}
if (numdelpoints)
{
if (numdelpoints > 1)
printmessage16("Deleted %d points.", numdelpoints);
else
printmessage16("Point deleted.");
asksave = 1;
}
for (i=0; i<numwalls; i++) //make new red lines?
{
if ((wall[i].x == dax && wall[i].y == day)
@ -3466,9 +3619,9 @@ end_yax: ;
}
}
end_after_dragging:
backup_drawn_walls(1);
}
end_after_dragging:
if ((bstatus&1) > 0) //drag points
{
@ -3482,7 +3635,7 @@ end_after_dragging:
// updatesector(mousxplc,mousyplc,&cursectorhighlight);
cursectorhighlight = -1;
for (i=0; i<highlightsectorcnt; i++)
if (inside_editor(&pos, searchx,searchy, zoom, mousxplc, mousyplc, highlightsector[i])==1)
if (inside_editor_curpos(highlightsector[i])==1)
{
cursectorhighlight = highlightsector[i];
break;
@ -3663,20 +3816,17 @@ end_point_dragging:
int16_t cursectornum;
for (cursectornum=0; cursectornum<numsectors; cursectornum++)
if (inside_editor(&pos, searchx,searchy, zoom, mousxplc,mousyplc,cursectornum) == 1)
if (inside_editor_curpos(cursectornum) == 1)
break;
if (cursectornum < numsectors)
{
if (pointhighlight >= 16384)
{
i = pointhighlight-16384;
ExtEditSpriteData((int16_t)i);
}
ExtEditSpriteData(pointhighlight-16384);
else if ((linehighlight >= 0) && (bstatus&1 || sectorofwall(linehighlight) == cursectornum))
ExtEditWallData((int16_t)linehighlight);
ExtEditWallData(linehighlight);
else if (cursectornum >= 0)
ExtEditSectorData((int16_t)cursectornum);
ExtEditSectorData(cursectornum);
}
bstatus &= ~6;
@ -3687,6 +3837,9 @@ end_point_dragging:
{
pos.z += divscale18(searchy-midydim16,zoom);
getpoint(searchx,midydim16, &pos.x, &pos.y);
#ifdef YAX_ENABLE
yax_updategrays(pos.z);
#endif
}
else
{
@ -3862,7 +4015,7 @@ end_point_dragging:
{
joinsector[0] = -1;
for (i=0; i<numsectors; i++)
if (inside_editor(&pos, searchx,searchy, zoom, mousxplc,mousyplc,i) == 1)
if (inside_editor_curpos(i) == 1)
{
joinsector[0] = i;
printmessage16("Join sector - press J again on sector to join with.");
@ -3880,7 +4033,7 @@ end_point_dragging:
for (i=0; i<numsectors; i++)
{
if (inside_editor(&pos, searchx,searchy, zoom, mousxplc,mousyplc,i) == 1)
if (inside_editor_curpos(i) == 1)
{
startwall = sector[i].wallptr;
endwall = startwall + sector[i].wallnum;
@ -3906,7 +4059,7 @@ end_point_dragging:
}
#endif
{
fade_editor_screen();
fade_editor_screen(-1);
if (!ask_if_sure("Join non-adjacent sectors? (Y/N)", 0))
joinsector[1] = joinsector[0];
@ -4040,6 +4193,10 @@ end_point_dragging:
printmessage16("Sectors joined.");
asksave = 1;
#ifdef YAX_ENABLE
yax_update(0);
yax_updategrays(pos.z);
#endif
}
joinsector[0] = -1;
@ -4094,7 +4251,7 @@ end_join_sectors:
sucksect = -1;
for (i=0; i<numsectors; i++)
if (inside_editor(&pos, searchx,searchy, zoom, mousxplc,mousyplc,i) == 1)
if (inside_editor_curpos(i) == 1)
{
sucksect = i;
break;
@ -4299,20 +4456,7 @@ end_join_sectors:
suckwall = -1;
split = 0;
Bmemset(&wall[newnumwalls], 0, sizeof(walltype));
wall[newnumwalls].extra = -1;
wall[newnumwalls].x = mousxplc;
wall[newnumwalls].y = mousyplc;
wall[newnumwalls].nextsector = -1;
wall[newnumwalls].nextwall = -1;
for (i=0; i<numwalls; i++)
if (wall[i].x == mousxplc && wall[i].y == mousyplc)
suckwall = i;
wall[newnumwalls].point2 = newnumwalls+1;
newnumwalls++;
init_new_wall1(&suckwall, &mousxplc, &mousyplc);
printmessage16("Sector drawing started.");
}
@ -4342,6 +4486,7 @@ end_join_sectors:
for (i=0; i<numsectors; i++)
{
YAX_SKIPSECTOR(i);
if (inside(dax,day,i) != 1)
continue;
@ -4350,6 +4495,10 @@ end_join_sectors:
for (WALLS_OF_SECTOR(i, k))
if (wall[k].x==wall[numwalls].x && wall[k].y==wall[numwalls].y)
{
YAX_SKIPWALL(k);
if (wall[k].nextwall >= 0)
YAX_SKIPWALL(wall[k].nextwall);
m = k;
break;
}
@ -4372,11 +4521,15 @@ end_join_sectors:
bad = 0;
for (i=0; i<numwalls; i++)
{
YAX_SKIPWALL(i);
if (wall[i].nextwall >= 0)
{
int32_t lastwalx = wall[newnumwalls-1].x;
int32_t lastwaly = wall[newnumwalls-1].y;
YAX_SKIPWALL(wall[i].nextwall);
if (wall[i].x == mousxplc && wall[i].y == mousyplc)
if (POINT2(i).x == lastwalx && POINT2(i).y == lastwaly)
bad = 1;
@ -4388,20 +4541,7 @@ end_join_sectors:
if (bad == 0)
{
Bmemset(&wall[newnumwalls], 0, sizeof(walltype));
wall[newnumwalls].extra = -1;
wall[newnumwalls].x = mousxplc;
wall[newnumwalls].y = mousyplc;
wall[newnumwalls].nextsector = -1;
wall[newnumwalls].nextwall = -1;
for (i=0; i<numwalls; i++)
if (wall[i].x == mousxplc && wall[i].y == mousyplc)
suckwall = i;
wall[newnumwalls].point2 = newnumwalls+1;
newnumwalls++;
init_new_wall1(&suckwall, &mousxplc, &mousyplc);
}
else
{
@ -4424,6 +4564,8 @@ end_join_sectors:
k = -1;
for (i=0; i<numsectors; i++)
{
YAX_SKIPSECTOR(i);
if (inside(firstx,firsty,i) == 1)
{
// if all points inside that one sector i,
@ -4600,6 +4742,7 @@ check_next_sector: ;
asksave = 1;
#ifdef YAX_ENABLE
yax_update(0);
yax_updategrays(pos.z);
#endif
goto end_space_handling;
@ -4827,6 +4970,7 @@ split_not_enough_walls:
asksave = 1;
#ifdef YAX_ENABLE
yax_update(0);
yax_updategrays(pos.z);
#endif
}
}
@ -4905,22 +5049,34 @@ end_space_handling:
if (keystatus[0xd3] && eitherCTRL && numwalls > 0) //sector delete
{
int32_t numdelsectors = 0, didbak=0;
char *origframe=NULL;
#ifdef YAX_ENABLE
int16_t cb, fb;
// used as a bunch bitmap here
Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap));
#endif
keystatus[0xd3] = 0;
sucksect = -1;
for (i=0; i<numsectors; i++)
{
if (inside_editor(&pos, searchx,searchy, zoom, mousxplc,mousyplc,i) != 1)
YAX_SKIPSECTOR(i);
numdelsectors += (inside_editor_curpos(i) == 1);
}
for (i=0; i<numsectors; i++)
{
YAX_SKIPSECTOR(i);
if (inside_editor_curpos(i) != 1)
continue;
#ifdef YAX_ENABLE
// used as a bunch bitmap here
Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap));
#endif
k = 0;
if (highlightsectorcnt >= 0)
if (k==0 && highlightsectorcnt >= 0)
{
for (j=0; j<highlightsectorcnt; j++)
if (highlightsector[j] == i)
@ -4946,6 +5102,33 @@ end_space_handling:
if (k == 0)
{
if (numdelsectors > 1)
{
if (!didbak)
{
origframe = Bmalloc(xdim*ydim);
if (origframe)
{
begindrawing();
Bmemcpy(origframe, (char *)frameplace, xdim*ydim);
enddrawing();
didbak = 1;
}
}
else
{
begindrawing();
Bmemcpy((char *)frameplace, origframe, xdim*ydim);
enddrawing();
}
fillsector(i, editorcolors[9]);
fade_editor_screen(editorcolors[9]);
if (!ask_if_sure("Delete this sector? (Y/N)", 0))
continue;
}
#ifdef YAX_ENABLE
yax_getbunches(i, &cb, &fb);
if (cb>=0) hlsectorbitmap[cb>>3] |= (1<<(cb&7));
@ -4955,6 +5138,9 @@ end_space_handling:
printmessage16("Sector deleted.");
}
if (origframe)
Bfree(origframe);
#ifdef YAX_ENABLE
for (j=0; j<numsectors; j++)
{
@ -4973,7 +5159,10 @@ end_space_handling:
newnumwalls = -1;
asksave = 1;
#ifdef YAX_ENABLE
yax_update(0);
yax_updategrays(pos.z);
#endif
break;
}
}
@ -5112,6 +5301,9 @@ point_not_inserted:
insertpoint(linehighlight, dax,day);
printmessage16("Point inserted.");
}
#ifdef YAX_ENABLE
yax_updategrays(pos.z);
#endif
}
}
#ifdef YAX_ENABLE
@ -5391,7 +5583,7 @@ CANCEL:
bad = 0;
if (CheckMapCorruption(4, 0)>=4)
if (!ask_if_sure("Map is corrupt. Are you sure you want to save?", 0))
if (!ask_if_sure("Map is corrupt. Are you sure you want to save? (Y/N)", 0))
break;
_printmessage16("Saving board...");
@ -5708,7 +5900,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)
{
int32_t i, dst, dist, closest, x1, y1, x2, y2, nx, ny;
int32_t i, j, dst, dist, closest, x1, y1, x2, y2, nx, ny;
int32_t daxplc, dayplc;
if (numwalls == 0)
@ -5736,6 +5928,9 @@ static int32_t getlinehighlight(int32_t xplc, int32_t yplc, int32_t line)
closest = -1;
for (i=0; i<numwalls; i++)
{
if (!m32_sideview)
YAX_SKIPWALL(i);
getclosestpointonwall(daxplc,dayplc, i, &nx,&ny, 1);
dst = klabs(daxplc-nx) + klabs(dayplc-ny);
if (dst <= dist)
@ -5745,7 +5940,11 @@ static int32_t getlinehighlight(int32_t xplc, int32_t yplc, int32_t line)
}
}
if (closest>=0 && wall[closest].nextwall >= 0)
j = wall[closest].nextwall;
if (closest>=0 && j >= 0)
#ifdef YAX_ENABLE
if (m32_sideview || ((graywallbitmap[j>>3]&(1<<(j&7)))==0))
#endif
{
//if red line, allow highlighting of both sides
if (m32_sideview)
@ -5765,10 +5964,10 @@ static int32_t getlinehighlight(int32_t xplc, int32_t yplc, int32_t line)
i = wall[closest].nextwall;
if (!m32_sideview ||
((*(int64_t *)m32_wallscreenxy[closest]==*(int64_t *)m32_wallscreenxy[wall[i].point2]) &&
(*(int64_t *)m32_wallscreenxy[wall[closest].point2]==*(int64_t *)m32_wallscreenxy[i])))
((*(int64_t *)m32_wallscreenxy[closest]==*(int64_t *)m32_wallscreenxy[wall[j].point2]) &&
(*(int64_t *)m32_wallscreenxy[wall[closest].point2]==*(int64_t *)m32_wallscreenxy[j])))
if (dmulscale32(daxplc-x1,y2-y1,-(x2-x1),dayplc-y1) >= 0)
closest = wall[closest].nextwall;
closest = j;
}
return closest;
@ -5789,6 +5988,10 @@ int32_t getpointhighlight(int32_t xplc, int32_t yplc, int32_t point)
dist = 0;
for (i=0; i<numsectors; i++)
{
if (!m32_sideview)
YAX_SKIPSECTOR(i);
for (j=sector[i].wallptr; j<sector[i].wallptr+sector[i].wallnum; j++)
{
if (!m32_sideview)
@ -5811,13 +6014,19 @@ int32_t getpointhighlight(int32_t xplc, int32_t yplc, int32_t point)
dist = dst, closest = j;
}
}
}
if (zoom >= 256)
for (i=0; i<MAXSPRITES; i++)
if (sprite[i].statnum < MAXSTATUS)
{
if (!m32_sideview && sprite[i].sectnum >= 0)
YAX_SKIPSECTOR(sprite[i].sectnum);
if (!m32_sideview)
{
dst = klabs(xplc-sprite[i].x) + klabs(yplc-sprite[i].y);
}
else
{
screencoords(&dax,&day, sprite[i].x-pos.x,sprite[i].y-pos.y, zoom);
@ -6440,6 +6649,9 @@ int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, cha
quitevent = 0;
drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum);
#ifdef YAX_ENABLE
yax_drawrooms(ExtAnalyzeSprites, horiz, cursectnum);
#endif
ExtAnalyzeSprites();
drawmasks();
@ -6704,7 +6916,7 @@ static int32_t getfilenames(const char *path, const char *kind)
findfileshigh = findfiles;
currentlist = 0;
if (findfileshigh) currentlist = 1;
//initprintf("path=%s || kind=%s || numfiles=%d, numdirs=%d\n", path, kind, numfiles, numdirs);
return(0);
}
@ -7058,13 +7270,18 @@ static int32_t menuselect(void)
return(-1);
}
int32_t fillsector(int16_t sectnum, char fillcolor)
int32_t fillsector(int16_t sectnum, int32_t fillcolor)
{
int32_t x1, x2, y1, y2, sy, y;
int32_t lborder, rborder, uborder, dborder, miny, maxy, dax;
int16_t z, zz, startwall, endwall, fillcnt;
UNREFERENCED_PARAMETER(fillcolor);
char col;
if (fillcolor < 0)
col = 159-klabs(sintable[((totalclock<<3)&2047)]>>11);
else
col = fillcolor;
lborder = 0; rborder = xdim;
uborder = 0; dborder = ydim16;
@ -7170,8 +7387,7 @@ int32_t fillsector(int16_t sectnum, char fillcolor)
if (fillist[z+1] > rborder)
fillist[z+1] = rborder;
drawline16(fillist[z],sy, fillist[z+1],sy, 159 //editorcolors[fillcolor]
-klabs(sintable[((totalclock<<3)&2047)]>>11));
drawline16(fillist[z],sy, fillist[z+1],sy, col); //editorcolors[fillcolor]
}
}
}

View file

@ -194,6 +194,9 @@ int16_t editstatus = 0;
static int16_t yax_bunchnum[MAXSECTORS][2];
static int16_t yax_nextwall[MAXWALLS][2];
uint8_t graysectbitmap[MAXSECTORS>>3];
uint8_t graywallbitmap[MAXWALLS>>3];
static int32_t yax_islockededge(/*int16_t sec,*/ int16_t line, int16_t cf)
#if 1
{
@ -216,7 +219,7 @@ static int32_t yax_islockededge(/*int16_t sec,*/ int16_t line, int16_t cf)
}
#endif
#define YAX_BUNCHNUM(Sect, Cf) (*(int16_t *)(&sector[Sect].ceilingxpanning + 6*Cf))
#define YAX_BUNCHNUM(Sect, Cf) (*(int16_t *)(&sector[Sect].ceilingxpanning + 8*Cf))
//// bunch getters/setters
int16_t yax_getbunch(int16_t i, int16_t cf)
@ -246,6 +249,14 @@ void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum)
if (bunchnum<0)
{
int32_t j;
// TODO: for in-game too?
for (j=sector[i].wallptr; j<sector[i].wallptr+sector[i].wallnum; j++)
{
yax_setnextwall(j, YAX_CEILING, -1);
yax_setnextwall(j, YAX_FLOOR, -1);
}
*(&sector[i].ceilingstat + cf) &= ~YAX_BIT;
YAX_BUNCHNUM(i, cf) = 0;
return;
@ -366,6 +377,181 @@ void yax_update(int32_t onlyreset)
}
editstatus = oeditstatus;
}
void yax_updategrays(int32_t posze)
{
int32_t i, j, k;
int16_t cb, fb;
Bmemset(graysectbitmap, 0, sizeof(graysectbitmap));
Bmemset(graywallbitmap, 0, sizeof(graywallbitmap));
if (numyaxbunches==0)
return;
for (i=0; i<numsectors; i++)
{
yax_getbunches(i, &cb, &fb);
if (cb<0 && fb<0)
continue;
k = ((cb<0 || sector[i].ceilingz < posze) && (fb<0 || posze < sector[i].floorz));
if (!k) // outside bounds, gray out!
{
graysectbitmap[i>>3] |= (1<<(i&7));
for (j=sector[i].wallptr; j<sector[i].wallptr+sector[i].wallnum; j++)
graywallbitmap[j>>3] |= (1<<(j&7));
}
}
}
int32_t yax_getneighborsect(int32_t x, int32_t y, int32_t sectnum, int32_t cf, int16_t *ret_bunchnum)
{
int16_t bunchnum = yax_getbunch(sectnum, cf);
int32_t i;
if (bunchnum < 0)
return -1;
for (i=headsectbunch[!cf][bunchnum]; i!=-1; i=nextsectbunch[!cf][i])
if (inside(x, y, i)==1)
{
if (ret_bunchnum)
*ret_bunchnum = bunchnum;
return i;
}
return -1;
}
static int32_t globalcf;
static int yax_cmpbunches(const int16_t *b1, const int16_t *b2)
{
int32_t s1,s2, w1,w2;
int64_t x1,y1, x2,y2, r;
s1 = headsectbunch[globalcf][*b1];
s2 = headsectbunch[globalcf][*b2];
w1 = sector[s1].wallptr;
w2 = sector[s2].wallptr;
x1 = wall[w1].x-globalposx; y1 = wall[w1].y-globalposy;
x2 = wall[w2].x-globalposx; y2 = wall[w2].y-globalposy;
r = (x2*x2 + y2*y2) - (x1*x1 + y1*y1);
if (r > 0)
return 1;
return r>>63;
}
void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectnum)
{
static uint8_t havebunch[2][YAX_MAXBUNCHES>>3];
static int16_t bunches[2][YAX_MAXBUNCHES];
int32_t i, j, k, head, cf, diddraw = 0;
int32_t bnchcnt, bnchnum[2] = {0,0};
int16_t ourbunch[2] = {-1,-1};
static uint8_t allgotsector[MAXSECTORS>>3];
static int16_t opicnum[MAXSECTORS];
if (rendmode == 4 || numyaxbunches==0)
return;
Bmemset(&havebunch[0], 0, (numsectors+7)>>3);
Bmemset(&havebunch[1], 0, (numsectors+7)>>3);
if (sectnum >= 0)
yax_getbunches(sectnum, &ourbunch[0], &ourbunch[1]);
for (i=0; i<numsectors; i++)
{
if (!(gotsector[i>>3]&(1<<(i&7))))
continue;
for (cf=0; cf<2; cf++)
{
j = yax_getbunch(i, cf);
if (j >= 0 && !(havebunch[cf][j>>3]&(1<<(j&7))))
{
havebunch[cf][j>>3] |= (1<<(j&7));
bunches[cf][bnchnum[cf]++] = j;
}
}
}
Bmemcpy(allgotsector, gotsector, (numsectors+7)>>3);
for (cf=0; cf<2; cf++)
{
globalcf = cf;
qsort(bunches[cf], bnchnum[cf], sizeof(int16_t), (int(*)(const void *, const void *))&yax_cmpbunches);
for (bnchcnt=0; bnchcnt<bnchnum[cf]; bnchcnt++)
{
j = bunches[cf][bnchcnt]; // the actual bunchnum...
if (j==ourbunch[cf])
{
k = yax_getneighborsect(globalposx, globalposy, sectnum, cf, NULL);
if (k < 0)
continue;
}
else
k = headsectbunch[!cf][j];
// tweak picnums vvv
head = headsectbunch[cf][j];
for (i=head; i!=-1; i=nextsectbunch[cf][i])
if ((SECTORFLD(i,stat, cf)&(128+256))==0)
{
opicnum[i] = SECTORFLD(i,picnum, cf);
if (editstatus && showinvisibility)
SECTORFLD(i,picnum, cf) = MAXTILES-1;
else
SECTORFLD(i,picnum, cf) = 13; //FOF;
}
if (allgotsector[k>>3]&(1<<(k&7)))
continue;
// TODO: make this better
drawrooms(globalposx,globalposy,globalposz,globalang,horiz,k+MAXSECTORS); // +MAXSECTORS: force
ExtAnalyzeSprites();
drawmasks();
for (i=0; i<(numsectors+7)>>3; i++)
allgotsector[i] |= gotsector[i];
diddraw = 1;
}
}
if (diddraw)
{
drawrooms(globalposx,globalposy,globalposz,globalang,horiz,sectnum);
if (editstatus)
{
for (cf=0; cf<2; cf++)
for (bnchcnt=0; bnchcnt<bnchnum[cf]; bnchcnt++)
{
j = bunches[cf][bnchcnt]; // the actual bunchnum...
// restore picnums ^^^
for (i=headsectbunch[cf][j]; i!=-1; i=nextsectbunch[cf][i])
if ((SECTORFLD(i,stat, cf)&(128+256))==0)
SECTORFLD(i,picnum, cf) = opicnum[i];
}
}
}
}
#undef YAX_BUNCHNUM
#endif
@ -967,6 +1153,8 @@ int32_t checksectorpointer(int16_t i, int16_t sectnum)
for (j=0; j<numsectors; j++)
{
YAX_SKIPSECTOR(j);
startwall = sector[j].wallptr;
endwall = startwall + sector[j].wallnum - 1;
for (k=startwall; k<=endwall; k++)
@ -2109,7 +2297,9 @@ static int32_t owallmost(int16_t *mostbuf, int32_t w, int32_t z)
}
y = (scale(z,xdimenscale,iy1)<<4);
yinc = ((scale(z,xdimenscale,iy2)<<4)-y) / (ix2-ix1+1);
// PK 20110423: 'fix' for crash in 2d map view -----------|
// ...only with NOASM=1 apparently :( v
yinc = ((scale(z,xdimenscale,iy2)<<4)-y) / ((ix2-ix1!=-1) ? (ix2-ix1+1) : 1);
qinterpolatedown16short((intptr_t)&mostbuf[ix1],ix2-ix1+1,y+(globalhoriz<<16),yinc);
if (mostbuf[ix1] < 0) mostbuf[ix1] = 0;
@ -2267,7 +2457,9 @@ static int32_t wallmost(int16_t *mostbuf, int32_t w, int32_t sectnum, char dasta
}
y = (scale(z1,xdimenscale,iy1)<<4);
yinc = ((scale(z2,xdimenscale,iy2)<<4)-y) / (ix2-ix1+1);
// PK 20110423: 'fix' for crash in 2d map view ------------|
// ...only with NOASM=1 apparently :( v
yinc = ((scale(z2,xdimenscale,iy2)<<4)-y) / ((ix2-ix1!=-1) ? (ix2-ix1+1) : 1);
qinterpolatedown16short((intptr_t)&mostbuf[ix1],ix2-ix1+1,y+(globalhoriz<<16),yinc);
if (mostbuf[ix1] < 0) mostbuf[ix1] = 0;
@ -7630,6 +7822,8 @@ int32_t loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy,
}
#ifdef YAX_ENABLE
yax_update(0);
if (editstatus)
yax_updategrays(*daposz);
#endif
for (i=0; i<numsprites; i++)
{
@ -9829,28 +10023,28 @@ restart_grand:
return 0;
}
i = yax_getneighborsect(hitinfo->pos.x, hitinfo->pos.y, hitinfo->hitsect,
hitscan_hitsectcf, NULL);
if (i >= 0)
{
// 1st, 2nd, ... ceil/floor hit
// hitinfo->hitsect is >=0 because if oldhitsect's init and check above
int32_t hitfloor = hitscan_hitsectcf;
int16_t bunchnum = yax_getbunch(hitinfo->hitsect, hitfloor);
// TODO: check against cstat
if (bunchnum >= 0) // todo: check against cstat
{
for (i=headsectbunch[!hitfloor][bunchnum]; i!=-1; i=nextsectbunch[!hitfloor][i])
if (inside(hitinfo->pos.x, hitinfo->pos.y, i) != 1)
continue;
Bmemcpy(&newsv, &hitinfo->pos, sizeof(vec3_t));
sectnum = i;
sv = &newsv;
Bmemcpy(&newsv, &hitinfo->pos, sizeof(vec3_t));
sectnum = i;
sv = &newsv;
oldhitsect = hitinfo->hitsect;
hitinfo->hitsect = -1;
oldhitsect = hitinfo->hitsect;
hitinfo->hitsect = -1;
// sector-like sprite re-init:
curspr = 0;
curidx = -1;
tmpptr = NULL;
goto restart_grand;
}
goto restart_grand;
}
}
#endif
@ -11388,7 +11582,6 @@ restart_grand:
mcf++;
clipsectcnt = 0; clipsectnum = 0;
clipspritecnt = 0; clipspritenum = 0;
didchange = 0;
if (cb>=0 && mcf==0 && *ceilhit==sectnum+16384)
@ -11431,7 +11624,14 @@ restart_grand:
}
if (clipsectnum > 0)
{
// sector-like sprite re-init:
curidx = -1;
curspr = NULL;
clipspritecnt = 0; clipspritenum = 0;
goto restart_grand;
}
}
#endif
}
@ -13104,6 +13304,15 @@ static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t
if (!m32_sideview && (j >= 0) && (i > j)) return;
}
#ifdef YAX_ENABLE
if ((graywallbitmap[i>>3] & (1<<(i&7))) || (j>=0 && (graywallbitmap[j>>3] & (1<<(j&7)))))
{
if (!m32_sideview)
return;
col = 8;
}
else
#endif
if (j < 0)
{
col = 15;

View file

@ -301,7 +301,7 @@ static void message_common1(const char *tmpstr)
Bstrcpy(getmessage,tmpstr);
getmessageleng = Bstrlen(getmessage);
getmessagetimeoff = totalclock+120*2;
getmessagetimeoff = totalclock + 120*2 + getmessageleng*(120/30);
lastmessagetime = totalclock;
}
@ -586,6 +586,7 @@ int32_t map_undoredo(int32_t dir)
#endif
#ifdef YAX_ENABLE
yax_update(0);
yax_updategrays(pos.z);
#endif
CheckMapCorruption(4, 0);
@ -1990,7 +1991,7 @@ static void IntegratedHelp(void)
if (keystatus[KEYSC_S])
{
fade_editor_screen();
fade_editor_screen(-1);
}
else
{
@ -4359,6 +4360,9 @@ static void getnumberptr256(const char *namestart, void *num, int32_t bytes, int
quitevent = 0;
drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum);
#ifdef YAX_ENABLE
yax_drawrooms(ExtAnalyzeSprites, horiz, cursectnum);
#endif
ExtAnalyzeSprites();
drawmasks();
#ifdef POLYMER
@ -4565,6 +4569,9 @@ ENDFOR1:
sprite[linebegspr].pal -= (sprite[linebegspr].pal>0);
drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum);
#ifdef YAX_ENABLE
yax_drawrooms(ExtAnalyzeSprites, horiz, cursectnum);
#endif
ExtAnalyzeSprites();
drawmasks();
#ifdef POLYMER
@ -6064,7 +6071,11 @@ static void Keys3d(void)
if (keystatus[KEYSC_QUOTE] && PRESSED_KEYSC(I)) // ' i
{
showinvisibility = !showinvisibility;
message("Invisible sprite preview %s", showinvisibility?"enabled":"disabled");
#ifndef YAX_ENABLE
message("Show invisible sprites %s", showinvisibility?"enabled":"disabled");
#else
message("Show invisible objects %s", showinvisibility?"enabled":"disabled");
#endif
}
if (keystatus[KEYSC_QUOTE] && PRESSED_KEYSC(X)) // ' x
@ -6294,10 +6305,15 @@ static void Keys3d(void)
{
int32_t nexti[4] = { 128, 256, 384, 0 };
int16_t *stat = &AIMED_CEILINGFLOOR(stat);
const char *statmsg[4] = {"normal", "masked", "translucent", "translucent (2)"};
i = (*stat&(128+256))>>7;
i = nexti[i];
*stat &= ~(128+256);
*stat |= i;
message("Sector %d's %s made %s.", searchsector, typestr[searchstat], statmsg[i>>7]);
asksave = 1;
}
@ -6305,8 +6321,11 @@ static void Keys3d(void)
{
if (ASSERT_AIMING)
{
int32_t olotag = AIMED(lotag);
Bsprintf(tempbuf, "%s lotag: ", Typestr_wss[searchstat]);
AIMED(lotag) = getnumber256(tempbuf, AIMED(lotag), BTAG_MAX, 0);
if (olotag != AIMED(lotag))
asksave = 1;
}
}
else if (eitherCTRL)
@ -6345,15 +6364,7 @@ static void Keys3d(void)
}
}
if (keystatus[KEYSC_QUOTE] && PRESSED_KEYSC(ENTER)) // ' ENTER
{
AIMED_SELOVR_PICNUM = temppicnum;
message("Pasted picnum only");
if (AIMING_AT_SPRITE)
correct_sprite_yoffset(searchwall);
}
// ----------
i = 512;
if (keystatus[KEYSC_RSHIFT]) i = 8;
if (keystatus[KEYSC_LSHIFT]) i = 1;
@ -6792,6 +6803,12 @@ static void Keys3d(void)
if (AIMING_AT_WALL_OR_MASK)
{
#ifdef YAX_ENABLE
if (yax_getnextwall(searchwall, YAX_CEILING) >= 0)
templotag = 0;
if (yax_getnextwall(searchwall, YAX_FLOOR) >= 0)
tempextra = -1;
#endif
temppicnum = AIMED_SELOVR_WALL(picnum);
tempxrepeat = AIMED_SEL_WALL(xrepeat);
tempxrepeat = max(1, tempxrepeat);
@ -6809,7 +6826,7 @@ static void Keys3d(void)
if (yax_getbunch(searchsector, AIMING_AT_FLOOR) >= 0)
tempxrepeat = tempyrepeat = 0;
#endif
tempcstat = AIMED_CEILINGFLOOR(stat);
tempcstat = AIMED_CEILINGFLOOR(stat) & ~YAX_BIT;
}
else if (AIMING_AT_SPRITE)
{
@ -6826,6 +6843,20 @@ static void Keys3d(void)
}
}
if (keystatus[KEYSC_QUOTE] && PRESSED_KEYSC(ENTER)) // ' ENTER
{
if (AIMED_SELOVR_PICNUM != temppicnum)
{
AIMED_SELOVR_PICNUM = temppicnum;
asksave = 1;
}
if (AIMING_AT_SPRITE)
correct_sprite_yoffset(searchwall);
message("Pasted picnum only");
}
if (PRESSED_KEYSC(ENTER)) // ENTER -- paste clipboard contents
{
if (eitherSHIFT)
@ -6871,13 +6902,14 @@ static void Keys3d(void)
AIMED_CF_SEL(shade) = tempshade;
AIMED_CF_SEL(pal) = temppal;
k = 0;
if (AIMING_AT_CEILING_OR_FLOOR)
{
if (somethingintab == SEARCH_CEILING || somethingintab == SEARCH_FLOOR)
sector[searchsector].visibility = tempvis;
k=1, sector[searchsector].visibility = tempvis;
}
message("Pasted shading+pal");
message("Pasted shade+pal%s", k?"+visibility":"");
asksave = 1;
}
}
@ -6905,81 +6937,117 @@ static void Keys3d(void)
}
while (i != searchwall);
message("Pasted picnum+shading+pal%s", clipboard_has_wall?"+pixelwidth":"");
message("Pasted picnum+shade+pal%s to wall %d's loop",
clipboard_has_wall?"+pixelwidth":"", searchwall);
asksave = 1;
}
else if (AIMING_AT_CEILING_OR_FLOOR && eitherCTRL && somethingintab < 255) //Either ctrl key
{
static char pskysearch[MAXSECTORS];
static const char *addnstr[4] = {"", "+stat+panning", "+stat", "+stat + panning (some)"};
Bmemset(pskysearch, 0, numsectors);
static int16_t sectlist[MAXSECTORS];
static uint8_t sectbitmap[MAXSECTORS>>3];
int32_t sectcnt, sectnum;
i = searchsector;
if (CEILINGFLOOR(i, stat)&1)
pskysearch[i] = 1;
while (pskysearch[i] == 1)
{
CEILINGFLOOR(i, picnum) = temppicnum;
CEILINGFLOOR(i, shade) = tempshade;
CEILINGFLOOR(i, pal) = temppal;
// collect neighboring parallaxed sectors
bfirst_search_init(sectlist, sectbitmap, &sectnum, MAXSECTORS, i);
if (somethingintab == SEARCH_CEILING || somethingintab == SEARCH_FLOOR)
for (sectcnt=0; sectcnt<sectnum; sectcnt++)
for (WALLS_OF_SECTOR(sectlist[sectcnt], j))
{
k = wall[j].nextsector;
if (k>=0 && (CEILINGFLOOR(k, stat)&1))
bfirst_search_try(sectlist, sectbitmap, &sectnum, wall[j].nextsector);
}
k = 0;
for (sectcnt=0; sectcnt<sectnum; sectcnt++)
{
i = sectlist[sectcnt];
CEILINGFLOOR(i, picnum) = temppicnum;
CEILINGFLOOR(i, shade) = tempshade;
CEILINGFLOOR(i, pal) = temppal;
if (somethingintab == SEARCH_CEILING || somethingintab == SEARCH_FLOOR)
{
#ifdef YAX_ENABLE
if (yax_getbunch(i, AIMING_AT_FLOOR) < 0)
if (yax_getbunch(i, AIMING_AT_FLOOR) >= 0)
k |= 2;
else
#endif
{
CEILINGFLOOR(i, xpanning) = tempxrepeat;
CEILINGFLOOR(i, ypanning) = tempyrepeat;
CEILINGFLOOR(i, stat) = tempcstat;
}
pskysearch[i] = 2;
{
CEILINGFLOOR(i, xpanning) = tempxrepeat;
CEILINGFLOOR(i, ypanning) = tempyrepeat;
k |= 1;
}
startwall = sector[i].wallptr;
endwall = startwall + sector[i].wallnum - 1;
for (j=startwall; j<=endwall; j++)
{
k = wall[j].nextsector;
if (k >= 0)
if ((CEILINGFLOOR(k, stat)&1) > 0)
if (pskysearch[k] == 0)
pskysearch[k] = 1;
SET_PROTECT_BITS(CEILINGFLOOR(i, stat), tempcstat, YAX_BIT);
}
}
for (j=0; j<numsectors; j++)
if (pskysearch[j] == 1)
i = j;
message("Pasted picnum+shade+pal%s to parallaxed sector %ss",
addnstr[k], typestr[searchstat]);
asksave = 1;
}
#ifdef YAX_ENABLE
else
{
k = yax_getbunch(searchsector, AIMING_AT_FLOOR);
if (k < 0)
goto paste_ceiling_or_floor;
message("Pasted picnum+shading+pal to adjoining sector %ss", typestr[searchstat]);
asksave = 1;
j = (somethingintab==SEARCH_CEILING || somethingintab==SEARCH_FLOOR);
for (i=headsectbunch[AIMING_AT_FLOOR][k]; i!=-1; i=nextsectbunch[AIMING_AT_FLOOR][i])
{
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);
}
message("Pasted picnum+shade+pal%s to sector %ss with bunchnum %d",
j?"+stat":"", typestr[searchstat], k);
}
#endif
}
else if (somethingintab < 255)
{
// wall/overwall common:
if (AIMING_AT_WALL_OR_MASK && searchstat==somethingintab &&
(!AIMING_AT_WALL || searchwall==searchbottomwall))
{
wall[searchwall].xrepeat = tempxrepeat;
wall[searchwall].yrepeat = tempyrepeat;
SET_PROTECT_BITS(wall[searchwall].cstat, tempcstat, YAX_NEXTWALLBITS);
wall[searchwall].hitag = temphitag;
#ifdef YAX_ENABLE
if (yax_getnextwall(searchwall, YAX_CEILING) == -1)
#endif
wall[searchwall].lotag = templotag;
#ifdef YAX_ENABLE
if (yax_getnextwall(searchwall, YAX_FLOOR) == -1)
#endif
wall[searchwall].extra = tempextra;
fixxrepeat(searchwall, templenrepquot);
}
if (AIMING_AT_WALL)
{
wall[searchbottomwall].picnum = temppicnum;
wall[searchbottomwall].shade = tempshade;
wall[searchbottomwall].pal = temppal;
if (somethingintab == SEARCH_WALL && searchwall==searchbottomwall)
{
wall[searchwall].xrepeat = tempxrepeat;
wall[searchwall].yrepeat = tempyrepeat;
wall[searchwall].cstat &= YAX_NEXTWALLBITS;
wall[searchwall].cstat |= (tempcstat & ~YAX_NEXTWALLBITS);
#ifdef YAX_ENABLE
if (yax_getnextwall(searchwall, YAX_CEILING) == -1)
#endif
wall[searchwall].lotag = templotag;
wall[searchwall].hitag = temphitag;
#ifdef YAX_ENABLE
if (yax_getnextwall(searchwall, YAX_FLOOR) == -1)
#endif
wall[searchwall].extra = tempextra;
fixxrepeat(searchwall, templenrepquot);
}
asksave = 1;
}
else if (AIMING_AT_MASKWALL)
@ -6991,39 +7059,28 @@ static void Keys3d(void)
wall[searchwall].shade = tempshade;
wall[searchwall].pal = temppal;
if (somethingintab == SEARCH_MASKWALL)
{
wall[searchwall].xrepeat = tempxrepeat;
wall[searchwall].yrepeat = tempyrepeat;
wall[searchwall].cstat &= YAX_NEXTWALLBITS;
wall[searchwall].cstat |= (tempcstat & ~YAX_NEXTWALLBITS);
#ifdef YAX_ENABLE
if (yax_getnextwall(searchwall, YAX_CEILING) == -1)
#endif
wall[searchwall].lotag = templotag;
wall[searchwall].hitag = temphitag;
#ifdef YAX_ENABLE
if (yax_getnextwall(searchwall, YAX_FLOOR) == -1)
#endif
wall[searchwall].extra = tempextra;
fixxrepeat(searchwall, templenrepquot);
}
asksave = 1;
}
else if (AIMING_AT_CEILING_OR_FLOOR)
{
#ifdef YAX_ENABLE
paste_ceiling_or_floor:
#endif
AIMED_CEILINGFLOOR(picnum) = temppicnum;
AIMED_CEILINGFLOOR(shade) = tempshade;
AIMED_CEILINGFLOOR(pal) = temppal;
if (somethingintab == SEARCH_CEILING || somethingintab == SEARCH_FLOOR)
#ifdef YAX_ENABLE
if (yax_getbunch(searchsector, AIMING_AT_FLOOR) < 0)
#endif
{
AIMED_CEILINGFLOOR(xpanning) = tempxrepeat;
AIMED_CEILINGFLOOR(ypanning) = tempyrepeat;
AIMED_CEILINGFLOOR(stat) = tempcstat;
#ifdef YAX_ENABLE
if (yax_getbunch(searchsector, AIMING_AT_FLOOR) < 0)
#endif
{
AIMED_CEILINGFLOOR(xpanning) = tempxrepeat;
AIMED_CEILINGFLOOR(ypanning) = tempyrepeat;
}
SET_PROTECT_BITS(AIMED_CEILINGFLOOR(stat), tempcstat, YAX_BIT);
sector[searchsector].visibility = tempvis;
sector[searchsector].lotag = templotag;
@ -7066,6 +7123,7 @@ static void Keys3d(void)
else
correct_sprite_yoffset(searchwall);
}
message("Pasted clipboard");
asksave = 1;
}
@ -7075,7 +7133,7 @@ static void Keys3d(void)
{
if (eitherALT) // Alt-C picnum replacer
{
if (somethingintab < 255)
if (ASSERT_AIMING && somethingintab < 255)
{
switch (searchstat)
{
@ -7109,7 +7167,9 @@ static void Keys3d(void)
wall[i].overpicnum = temppicnum;
break;
}
message("Picnums replaced");
message("Replaced %ss with picnum %d to picnum %d",
typestr[searchwall], j, temppicnum);
asksave = 1;
}
}
@ -9910,6 +9970,8 @@ int32_t ExtInit(void)
zmode = 2;
zlock = kensplayerheight<<8;
showinvisibility = 1;
ReadGamePalette();
// InitWater();
@ -9983,7 +10045,7 @@ void ExtPreCheckKeys(void) // just before drawrooms
int32_t radius, xp1, yp1;
int32_t col;
int32_t picnum, frames;
int32_t ang = 0, flags, shade;
int32_t daang = 0, flags, shade;
if (qsetmode == 200) //In 3D mode
{
@ -10150,7 +10212,7 @@ void ExtPreCheckKeys(void) // just before drawrooms
if ((sprite[i].cstat & 48) != 0 || sprite[i].statnum == MAXSTATUS) continue;
ii++;
picnum = sprite[i].picnum;
ang = flags = frames = shade = 0;
daang = flags = frames = shade = 0;
switch (picnum)
{
@ -10211,13 +10273,13 @@ void ExtPreCheckKeys(void) // just before drawrooms
if (k <= 4)
{
picnum += k;
ang = 0;
daang = 0;
flags &= ~4;
}
else
{
picnum += 8-k;
ang = 1024;
daang = 1024;
flags |= 4;
}
}
@ -10253,7 +10315,7 @@ void ExtPreCheckKeys(void) // just before drawrooms
if (xp1 < 4 || xp1 > xdim-6 || yp1 < 4 || yp1 > ydim16-6)
continue;
rotatesprite(xp1<<16,yp1<<16,zoom<<5,ang,picnum,
rotatesprite(xp1<<16,yp1<<16,zoom<<5,daang,picnum,
shade,sprite[i].pal,flags,0,0,xdim-1,ydim16-1);
}
}

View file

@ -1804,7 +1804,7 @@ int32_t sv_readdiff(int32_t fil)
// SVGM data description
static void sv_postudload()
{
Bmemcpy(&boardfilename[0], &currentboardfilename[0], BMAX_PATH);
// Bmemcpy(&boardfilename[0], &currentboardfilename[0], BMAX_PATH);
#if 0
ud.m_level_number = ud.level_number;
ud.m_volume_number = ud.volume_number;