diff --git a/polymer/eduke32/build/include/editor.h b/polymer/eduke32/build/include/editor.h index 3c2065e0e..464de572e 100644 --- a/polymer/eduke32/build/include/editor.h +++ b/polymer/eduke32/build/include/editor.h @@ -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 diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 2eabb3e5d..6b908139d 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -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= 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=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 0) + { + neededzofs += ksgn(neededzofs)*(512<<4); + neededzofs &= ~((256<<4)-1); + if (refextcf==1) + neededzofs *= -1; + for (m=0; m 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); diff --git a/polymer/eduke32/build/src/config.c b/polymer/eduke32/build/src/config.c index 38292cf64..47f1171ae 100644 --- a/polymer/eduke32/build/src/config.c +++ b/polymer/eduke32/build/src/config.c @@ -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) { diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 0a06b46b4..1e0e75b53 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -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 { diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 1dd8772cf..898c315c9 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -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 diff --git a/polymer/eduke32/source/m32structures.c b/polymer/eduke32/source/m32structures.c index 5ad1181ff..5ee0b8690 100644 --- a/polymer/eduke32/source/m32structures.c +++ b/polymer/eduke32/source/m32structures.c @@ -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?