Tweak raising/lowering (groups of) ceilings or floors.

Now, if more than one sectors are affected, always move them by the same
amount. That is, if one of them would be sticking against the other side,
don't move the rest.  Another change consists of determining the z delta
first, and only then moving the sprites by that amount. This fixes the
problem where you'd e.g. raise a 'floor door' against the ceiling, and the
effector sprites would be raised one time too much, preventing them from
being lowered the next time.

git-svn-id: https://svn.eduke32.com/eduke32@2111 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-11-11 20:05:44 +00:00
parent b2d789731a
commit b7834f21dd

View file

@ -5890,6 +5890,7 @@ static void Keys3d(void)
if (moveCeilings || moveFloors) if (moveCeilings || moveFloors)
{ {
int32_t dz = tsign * (updownunits << (eitherCTRL<<1)); // JBF 20031128
static const char *cfs[2] = { "ceiling", "floor" }; static const char *cfs[2] = { "ceiling", "floor" };
#ifdef YAX_ENABLE #ifdef YAX_ENABLE
int16_t bunchnum=-1, maxbunchnum=-1, cb, fb; int16_t bunchnum=-1, maxbunchnum=-1, cb, fb;
@ -5897,53 +5898,69 @@ static void Keys3d(void)
#endif #endif
for (j=0; j<(k?k:1); j++, sect=highlightsector[j]) for (j=0; j<(k?k:1); j++, sect=highlightsector[j])
{ {
for (i=headspritesect[sect]; i!=-1; i=nextspritesect[i]) // stage one: see if we don't move beyond the other side
{ // (ceiling if floor and vice versa)
spriteoncfz(i, &cz, &fz);
if ((moveCeilings && sprite[i].z == cz) || (moveFloors && sprite[i].z == fz))
sprite[i].z += tsign * (updownunits << (eitherCTRL<<1)); // JBF 20031128
}
SECTORFLD(sect,z, moveFloors) += tsign * (updownunits << (eitherCTRL<<1)); // JBF 20031128 if (moveCeilings && (dz > 0) && sector[sect].ceilingz+dz > sector[sect].floorz)
#ifdef YAX_ENABLE dz = (k<=1) ? 0 : min(sector[sect].floorz - sector[sect].ceilingz, dz);
bunchnum = yax_getbunch(sect, moveFloors); else if (moveFloors && (dz < 0) && sector[sect].floorz+dz < sector[sect].ceilingz)
if (bunchnum >= 0 && !(havebunch[bunchnum>>3]&(1<<(bunchnum&7)))) dz = (k<=1) ? 0 : max(sector[sect].ceilingz - sector[sect].floorz, dz);
if (dz == 0)
break;
}
if (dz)
{
// now truly move things if we're clear to go!
sect = sect0;
for (j=0; j<(k?k:1); j++, sect=highlightsector[j])
{ {
maxbunchnum = max(maxbunchnum, bunchnum); for (i=headspritesect[sect]; i!=-1; i=nextspritesect[i])
havebunch[bunchnum>>3] |= (1<<(bunchnum&7)); {
tempzar[bunchnum] = &SECTORFLD(sect,z, moveFloors); spriteoncfz(i, &cz, &fz);
} if ((moveCeilings && sprite[i].z == cz) || (moveFloors && sprite[i].z == fz))
sprite[i].z += dz;
}
SECTORFLD(sect,z, moveFloors) += dz;
#ifdef YAX_ENABLE
bunchnum = yax_getbunch(sect, moveFloors);
if (bunchnum >= 0 && !(havebunch[bunchnum>>3]&(1<<(bunchnum&7))))
{
maxbunchnum = max(maxbunchnum, bunchnum);
havebunch[bunchnum>>3] |= (1<<(bunchnum&7));
tempzar[bunchnum] = &SECTORFLD(sect,z, moveFloors);
}
#endif #endif
} }
if (k<=1 && sector[sect0].floorz < sector[sect0].ceilingz)
{
if (moveFloors)
sector[sect0].floorz = sector[sect0].ceilingz;
else
sector[sect0].ceilingz = sector[sect0].floorz;
} }
#ifdef YAX_ENABLE #ifdef YAX_ENABLE
// sync z values of extended sectors' ceilings/floors if (dz)
for (i=0; i<numsectors; i++)
{ {
yax_getbunches(i, &cb, &fb); // sync z values of extended sectors' ceilings/floors
if (cb >= 0 && (havebunch[cb>>3]&(1<<(cb&7)))) for (i=0; i<numsectors; i++)
sector[i].ceilingz = *tempzar[cb]; {
if (fb >= 0 && (havebunch[fb>>3]&(1<<(fb&7)))) yax_getbunches(i, &cb, &fb);
sector[i].floorz = *tempzar[fb]; if (cb >= 0 && (havebunch[cb>>3]&(1<<(cb&7))))
sector[i].ceilingz = *tempzar[cb];
if (fb >= 0 && (havebunch[fb>>3]&(1<<(fb&7))))
sector[i].floorz = *tempzar[fb];
}
} }
if (k==0 && bunchnum>=0) if (!dz)
silentmessage("Didn't move sector %ss", cfs[moveFloors]);
else if (k<=1 && bunchnum>=0)
silentmessage("Bunch %d's ceilings and floors = %d", bunchnum, SECTORFLD(sect0,z, moveFloors)); silentmessage("Bunch %d's ceilings and floors = %d", bunchnum, SECTORFLD(sect0,z, moveFloors));
else else
#endif #endif
if (k==0) if (k<=1)
silentmessage("Sector %d %sz = %d", sect0, cfs[moveFloors], SECTORFLD(sect0,z, moveFloors)); silentmessage("Sector %d %sz = %d", sect0, cfs[moveFloors], SECTORFLD(sect0,z, moveFloors));
else else
silentmessage("%s %d sector %ss by %d units", tsign<0 ? "Raised" : "Lowered", silentmessage("%s %d sector %ss by %d units", tsign<0 ? "Raised" : "Lowered",
k, cfs[moveFloors], (updownunits << (eitherCTRL<<1))); k, cfs[moveFloors], dz*tsign);
} }
if (AIMING_AT_SPRITE) if (AIMING_AT_SPRITE)