When X- or Y-flipping a selection of highlighted sectors, also handle setting

the nextwall pointers correctly;  Add some 'asksave=1' and 'make old-nextwalls
invalid'.

git-svn-id: https://svn.eduke32.com/eduke32@2048 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-09-30 13:52:02 +00:00
parent 2603acd340
commit 64ead0a130
2 changed files with 43 additions and 6 deletions

View file

@ -2989,6 +2989,9 @@ void overheadeditor(void)
for (j=startwall; j<=endwall; j++)
{
// NEXTWALL tweak: keep nextsector!
wall[j].nextwall = -1;
//fix position of walls
if (about_x)
{
@ -3062,6 +3065,16 @@ void overheadeditor(void)
}
}
mkonwinvalid();
// NEXTWALL tweak: finally, construct the nextwalls for the new arrangement!
for (i=0; i<highlightsectorcnt; i++)
{
for (WALLS_OF_SECTOR(i, j))
if (wall[j].nextsector >= 0)
checksectorpointer(j, i);
}
printmessage16("Selected sector(s) flipped");
asksave = 1;
}
@ -4027,6 +4040,8 @@ end_yax: ;
refextcf>=0 ? "-extended " : "", refsect);
}
asksave = 1;
if (refextcf >= 0)
{
yax_update(0);
@ -5809,6 +5824,7 @@ check_next_sector: ;
#endif
printmessage16("Added inner loop to sector %d", k);
mkonwinvalid();
asksave = 1;
}
}
else // if connected to at least one other sector

View file

@ -1644,6 +1644,7 @@ const int16_t *chsecptr_onextwall = NULL;
int32_t checksectorpointer(int16_t i, int16_t sectnum)
{
int32_t startsec, endsec;
int32_t j, k, startwall, endwall, x1, y1, x2, y2, numnewwalls=0;
int32_t bestnextwall=-1, bestnextsec=-1, bestwallscore=INT32_MIN;
int32_t cz[4], fz[4], tmp[2], tmpscore=0;
@ -1676,6 +1677,19 @@ int32_t checksectorpointer(int16_t i, int16_t sectnum)
wall[k].nextwall = wall[k].nextsector = -1;
}
if ((unsigned)wall[i].nextsector < (unsigned)numsectors && wall[i].nextwall < 0)
{
// if we have a nextsector but no nextwall, take this as a hint
// to search only the walls of that sector
startsec = wall[i].nextsector;
endsec = startsec+1;
}
else
{
startsec = 0;
endsec = numsectors;
}
wall[i].nextsector = wall[i].nextwall = -1;
if (chsecptr_onextwall && (k=chsecptr_onextwall[i])>=0 && wall[k].nextwall<0)
@ -1694,7 +1708,7 @@ int32_t checksectorpointer(int16_t i, int16_t sectnum)
}
}
for (j=0; j<numsectors; j++)
for (j=startsec; j<endsec; j++)
{
if (j == sectnum)
continue;
@ -1751,8 +1765,9 @@ int32_t checksectorpointer(int16_t i, int16_t sectnum)
// sectnum -2 means dry run
if (bestnextwall >= 0 && sectnum!=-2)
#ifdef YAX_ENABLE
// be conservative in case if score <=0 (meaning that no wall area is mutually
// visible) -- it could be that another sector is a better candidate later on
// for walls with TROR neighbors, be conservative in case if score <=0
// (meaning that no wall area is mutually visible) -- it could be that
// another sector is a better candidate later on
if ((yax_getnextwall(i, 0)<0 && yax_getnextwall(i, 1)<0) || bestwallscore>0)
#endif
{
@ -13776,7 +13791,9 @@ void setfirstwall(int16_t sectnum, int16_t newfirstwall)
if (dagoalloop > 0)
{
j = 0;
while (loopnumofsector(sectnum,j+startwall) != dagoalloop) j++;
while (loopnumofsector(sectnum,j+startwall) != dagoalloop)
j++;
for (i=0; i<danumwalls; i++)
{
k = i+j; if (k >= danumwalls) k -= danumwalls;
@ -13787,8 +13804,10 @@ void setfirstwall(int16_t sectnum, int16_t newfirstwall)
wall[startwall+i].point2 -= danumwalls;
wall[startwall+i].point2 += startwall;
}
newfirstwall += danumwalls-j;
if (newfirstwall >= startwall+danumwalls) newfirstwall -= danumwalls;
if (newfirstwall >= startwall+danumwalls)
newfirstwall -= danumwalls;
}
for (i=0; i<numwallsofloop; i++)
@ -13806,7 +13825,9 @@ void setfirstwall(int16_t sectnum, int16_t newfirstwall)
}
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;