Addresses posts #180 and #181 of the TROR thread. Specifically,

* it is now possible to paste (and have an outer red wall automatically) highlighted sectors into a sector that is extended on one side and non-sloped on the other. For this, the highlighted sectors must be in one connected component.
* Make it possible to not display inner gray walls, toggled with Ctrl-Alt-A, but only when no manual grayout (Ctrl-R) is in effect.

* bugfix: don't clear original TROR-nextwall link when duplicating extended highlighted sector
* m32script: protect wall members relevant to TROR
* save autogray (Ctrl-A) and showinnergray (see above) to mapster32.cfg


git-svn-id: https://svn.eduke32.com/eduke32@1928 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-07-04 21:20:59 +00:00
parent ee4d060b1f
commit 57379654a7
6 changed files with 193 additions and 42 deletions

View file

@ -107,9 +107,9 @@ extern int32_t dragpoint_noreset;
extern int32_t numgraysects;
extern uint8_t graysectbitmap[MAXSECTORS>>3];
extern uint8_t graywallbitmap[MAXWALLS>>3];
extern int32_t autogray, showinnergray;
#ifdef YAX_ENABLE
extern int32_t autogray;
int32_t yax_is121(int16_t bunchnum, int16_t getfloor);
#endif

View file

@ -1645,12 +1645,17 @@ static void duplicate_selected_sectors(void)
if (cb>=0 || fb>=0)
{
hadextended = 1;
yax_setbunches(newnumsectors, -1, -1);
// clearing yax-nextwalls has to be before setting the bunchnum to -1
// because the latter would automatically also clear the reverse (i.e.
// original) wall links
for (WALLS_OF_SECTOR(newnumsectors, j))
{
yax_setnextwall(j, 0, -1);
yax_setnextwall(j, 1, -1);
}
yax_setbunches(newnumsectors, -1, -1);
}
#endif
newnumsectors++;
@ -2083,7 +2088,11 @@ static void updatesprite1(int16_t i)
}
#ifdef YAX_ENABLE
// highlighted OR grayed-out sectors:
static uint8_t hlorgraysectbitmap[MAXSECTORS>>3];
static int32_t ask_above_or_below(void);
#else
# define hlorgraysectbitmap hlsectorbitmap
#endif
// returns:
@ -2115,7 +2124,7 @@ static int32_t trace_loop(int32_t j, uint8_t *visitedwall, int16_t *ignore_ret,
if (ignore_ret)
{
refsect = -1;
updatesectorexclude(wall[j].x, wall[j].y, &refsect, hlsectorbitmap);
updatesectorexclude(wall[j].x, wall[j].y, &refsect, hlorgraysectbitmap);
if (refsect<0)
return -1;
}
@ -3780,6 +3789,9 @@ end_yax: ;
}
update_highlight();
for (i=0; i<numwalls; i++)
wall[i].cstat &= ~(1<<14);
}
}
}
@ -3805,11 +3817,16 @@ end_yax: ;
}
else
{
// didmakered: 'bad'!
int32_t didmakered = (highlightsectorcnt<0), hadouterpoint=0;
int16_t tmprefsect = -1;
#ifdef YAX_ENABLE
for (i=0; i<MAXSECTORS; i++)
hlorgraysectbitmap[i] = hlsectorbitmap[i]|graysectbitmap[i];
#endif
for (i=0; i<highlightsectorcnt; i++)
{
int16_t tmpsect = -1;
for (WALLS_OF_SECTOR(highlightsector[i], j))
{
// if (wall[j].nextwall >= 0)
@ -3819,37 +3836,43 @@ end_yax: ;
if (!didmakered)
{
updatesectorexclude(wall[j].x, wall[j].y, &tmprefsect, hlsectorbitmap);
if (tmprefsect<0)
updatesectorexclude(wall[j].x, wall[j].y, &tmpsect, hlorgraysectbitmap);
if (tmpsect<0)
hadouterpoint = 1;
}
}
#ifdef YAX_ENABLE
{
int16_t cb, fb;
yax_getbunches(highlightsector[i], &cb, &fb);
if (cb>=0 || fb>=0)
{
// TROR stuff in the pasted sectors would really
// complicate things, so don't allow this
didmakered=1;
}
}
#endif
}
if (!didmakered && !hadouterpoint && newnumwalls<0)
{
#ifdef YAX_ENABLE
int16_t cb, fb;
// fade the screen to have the user's attention
fade_editor_screen(-1);
yax_getbunches(tmprefsect, &cb, &fb);
if (cb>=0 || fb>=0)
didmakered = 1;
else
#endif
{
// fade the screen to have the user's attention
fade_editor_screen(-1);
didmakered |= !ask_if_sure("Insert outer loop and make red walls? (Y/N)", 0);
clearkeys();
}
didmakered |= !ask_if_sure("Insert outer loop and make red walls? (Y/N)", 0);
clearkeys();
}
if (!didmakered && !hadouterpoint && newnumwalls<0)
{
int16_t ignore, refsect;
int32_t n;
#ifdef YAX_ENABLE
int16_t refsectbn[2]={-1,-1};
int32_t refextcf=-1;
#endif
Bmemset(visited, 0, sizeof(visited));
for (i=0; i<highlightsectorcnt; i++)
@ -3860,14 +3883,71 @@ end_yax: ;
if (k == 0)
continue;
else if (k < 0)
{
i = highlightsectorcnt;
break; // outer loop too
}
goto end_autoredwall;
if (ignore)
continue;
// done tracing one outer loop
#ifdef YAX_ENABLE
yax_getbunches(refsect, &refsectbn[0], &refsectbn[1]);
if (refsectbn[0]>=0 || refsectbn[1]>=0)
{
if (refsectbn[0]>=0 && refsectbn[1]>=0)
{
// at least one of ceiling/floor must be non-extended
didmakered = 1;
}
else
{
// ... and the other must be non-sloped
refextcf = (refsectbn[1]>=0);
if (SECTORFLD(refsect,stat, !refextcf)&2)
didmakered = 1;
}
}
if (didmakered)
goto end_autoredwall;
if (refextcf >= 0)
{
int32_t refz = SECTORFLD(refsect,z, refextcf), tmpsect;
int32_t neededzofs=0;
// the reference sector is extended on one side
// (given by refextcf) and non-sloped on the other
if (highlighted_sectors_components(0,0) != 1)
{
message("Highlighted sectors must be in one connected component");
goto end_autoredwall;
}
for (m=0; m<highlightsectorcnt; m++)
{
tmpsect = highlightsector[m];
yax_setbunch(tmpsect, refextcf, refsectbn[refextcf]);
// walls: not needed, since they're all inner to the bunch
SECTORFLD(tmpsect,z, refextcf) = refz;
setslope(tmpsect, refextcf, 0);
if (refextcf==0)
neededzofs = max(neededzofs, refz-sector[tmpsect].floorz);
else
neededzofs = max(neededzofs, sector[tmpsect].ceilingz-refz);
}
if (neededzofs > 0)
{
neededzofs += ksgn(neededzofs)*(512<<4);
neededzofs &= ~((256<<4)-1);
if (refextcf==1)
neededzofs *= -1;
for (m=0; m<highlightsectorcnt; m++)
SECTORFLD(highlightsector[m],z, !refextcf) += neededzofs;
}
}
#endif
wall[k-1].point2 = numwalls; // close the loop
newnumwalls = k;
n = (newnumwalls-numwalls); // number of walls in just constructed loop
@ -3930,17 +4010,34 @@ end_yax: ;
if (checksectorpointer(m, refsect) > 0)
if (onwwasvalid && onextwall[wall[m].nextwall]>=0)
{
initprintf("%d %d\n", m, onextwall[wall[m].nextwall]);
//initprintf("%d %d\n", m, onextwall[wall[m].nextwall]);
copy_some_wall_members(m, onextwall[wall[m].nextwall], 0);
}
#ifndef YAX_ENABLE
message("Attached new inner loop to sector %d", refsect);
#else
{
const char *cfstr[2] = {"ceiling","floor"};
message("Attached new inner loop to %s%ssector %d",
refextcf>=0 ? cfstr[refextcf] : "",
refextcf>=0 ? "-extended " : "", refsect);
}
if (refextcf >= 0)
{
yax_update(0);
goto end_autoredwall;
}
#endif
}
}
}
end_autoredwall:
newnumwalls = -1;
#ifdef YAX_ENABLE
yax_updategrays(pos.z);
#endif
}
highlightx1 = searchx;
@ -4361,7 +4458,7 @@ end_point_dragging:
{
if (pointhighlight >= 16384)
ExtEditSpriteData(pointhighlight-16384);
else if ((linehighlight >= 0) && (bstatus&1 || sectorofwall(linehighlight) == cursectornum))
else if ((linehighlight >= 0) && ((bstatus&1) || sectorofwall(linehighlight) == cursectornum))
ExtEditWallData(linehighlight);
else if (cursectornum >= 0)
ExtEditSectorData(cursectornum);

View file

@ -266,6 +266,11 @@ int32_t loadsetup(const char *fn)
if (readconfig(fp, "showambiencesounds", val, VL) > 0)
showambiencesounds = clamp(atoi_safe(val), 0, 2);
if (readconfig(fp, "autogray", val, VL) > 0)
autogray = !!atoi_safe(val);
if (readconfig(fp, "showinnergray", val, VL) > 0)
showinnergray = !!atoi_safe(val);
if (readconfig(fp, "graphicsmode", val, VL) > 0)
graphicsmode = clamp(atoi_safe(val), 0, 2);
@ -460,6 +465,12 @@ int32_t writesetup(const char *fn)
"; Ambience sound circles (0:none, 1:only in current sector, 2:all)\n"
"showambiencesounds = %d\n"
"\n"
"; TROR: Automatic grayout of plain (non-extended) sectors,\n"
"; toggled with Ctrl-A:\n"
"autogray = %d\n"
"; TROR: Show inner gray walls, toggled with Ctrl-Alt-A:\n"
"showinnergray = %d\n"
"\n"
"; 2D mode display type (0:classic, 1:textured, 2:textured/animated)\n"
"graphicsmode = %d\n"
"\n"
@ -546,7 +557,9 @@ int32_t writesetup(const char *fn)
msens, unrealedlook, pk_uedaccel, quickmapcycling,
sideview_reversehrot,
revertCTRL,scrollamount,pk_turnaccel,pk_turndecel,autosave,autocorruptcheck,
showheightindicators,showambiencesounds,graphicsmode,
showheightindicators,showambiencesounds,
autogray,showinnergray,
graphicsmode,
MixRate,AmbienceToggle,ParentalLock, !!m32_osd_tryscript,
#if 1
keys[0], keys[1], keys[2], keys[3], keys[4], keys[5],
@ -566,6 +579,7 @@ int32_t writesetup(const char *fn)
Bfprintf(fp,"\n\n");
// save m32script history
Bfprintf(fp,"; Mapster32-script history\n");
first = 1;
for (i=scripthistend, j=0; first || i!=scripthistend; i=(i+1)%SCRIPTHISTSIZ, first=0)
{

View file

@ -191,7 +191,7 @@ int16_t editstatus = 0;
int32_t numgraysects = 0;
uint8_t graysectbitmap[MAXSECTORS>>3];
uint8_t graywallbitmap[MAXWALLS>>3];
int32_t autogray = 0;
int32_t autogray = 0, showinnergray = 1;
#ifdef ENGINE_SCREENSHOT_DEBUG
int32_t engine_screenshot = 0;
@ -14743,15 +14743,29 @@ void draw2dscreen(const vec3_t *pos, int16_t cursectnum, int16_t ange, int32_t z
if (!m32_sideview)
{
#ifndef YAX_ENABLE
for (i=numwalls-1; i>=0; i--)
drawscreen_drawwall(i,posxe,posye,posze,zoome, 0);
#else
int32_t alwaysshowgray = (showinnergray || !(editorzrange[0]==INT32_MIN && editorzrange[1]==INT_MAX));
for (i=numwalls-1; i>=0; i--)
#ifdef YAX_ENABLE
if (graybitmap[i>>3]&(1<<(i&7)))
drawscreen_drawwall(i,posxe,posye,posze,zoome, 1);
{
if (alwaysshowgray)
drawscreen_drawwall(i,posxe,posye,posze,zoome, 1);
else
{
j = sectorofwall(i); // ugh...
if ((yax_getbunch(j,0)<0 || yax_getnextwall(i,0)>=0) &&
(yax_getbunch(j,1)<0 || yax_getnextwall(i,1)>=0))
drawscreen_drawwall(i,posxe,posye,posze,zoome, 1);
}
}
for (i=numwalls-1; i>=0; i--)
if ((graybitmap[i>>3]&(1<<(i&7)))==0)
#endif
drawscreen_drawwall(i,posxe,posye,posze,zoome, 0);
#endif
}
else
{

View file

@ -7664,9 +7664,17 @@ static void Keys2d(void)
if (eitherCTRL && PRESSED_KEYSC(A))
{
autogray = !autogray;
printmessage16("Automatic grayout of plain sectors %s", ONOFF(autogray));
yax_updategrays(pos.z);
if (eitherALT)
{
showinnergray = !showinnergray;
printmessage16("Display inner gray walls: %s", ONOFF(showinnergray));
}
else
{
autogray = !autogray;
printmessage16("Automatic grayout of plain sectors %s", ONOFF(autogray));
yax_updategrays(pos.z);
}
}
#endif

View file

@ -77,7 +77,7 @@ static int32_t __fastcall VM_AccessWall(int32_t how, int32_t lVar1, int32_t lLab
SET_PROTECT_BITS(wall[i].cstat, lValue, YAX_NEXTWALLBITS);
else
#endif
wall[i].cstat = lValue;
wall[i].cstat = lValue;
break;
case WALL_PICNUM: wall[i].picnum=lValue; break;
case WALL_OVERPICNUM: wall[i].overpicnum=lValue; break;
@ -87,9 +87,21 @@ static int32_t __fastcall VM_AccessWall(int32_t how, int32_t lVar1, int32_t lLab
case WALL_YREPEAT: wall[i].yrepeat=lValue; break;
case WALL_XPANNING: wall[i].xpanning=lValue; break;
case WALL_YPANNING: wall[i].ypanning=lValue; break;
case WALL_LOTAG: wall[i].lotag=lValue; break;
case WALL_LOTAG:
#ifdef YAX_ENABLE
if (!m32_script_expertmode && numyaxbunches>0 && yax_getnextwall(i,YAX_CEILING)>=0)
goto yax_readonly;
#endif
wall[i].lotag=lValue;
break;
case WALL_HITAG: wall[i].hitag=lValue; break;
case WALL_EXTRA: wall[i].extra=lValue; break;
case WALL_EXTRA:
#ifdef YAX_ENABLE
if (!m32_script_expertmode && numyaxbunches>0 && yax_getnextwall(i,YAX_FLOOR)>=0)
goto yax_readonly;
#endif
wall[i].extra=lValue;
break;
default:
return -1;
}
@ -133,6 +145,12 @@ badwall:
readonly:
M32_ERROR("Wall structure member `%s' is read-only.", WallLabels[lLabelID].name);
return -1;
#ifdef YAX_ENABLE
yax_readonly:
M32_ERROR("Wall structure member `%s' is read-only because it is used for TROR",
WallLabels[lLabelID].name);
return -1;
#endif
}
// how: bitfield: 1=set? 2=vars?