Allow subrecords to overlap the following record (bug #6025)

revert-6246b479
Alexei Dobrohotov 10 months ago
parent 5b9a195e3d
commit 66fd1f8862

@ -17,6 +17,7 @@
Bug #5870: Disposing of actors who were selected in the console doesn't deselect them like vanilla
Bug #5883: Immobile creatures don't cause water ripples
Bug #5977: Fatigueless NPCs' corpse underwater changes animation on game load
Bug #6025: Subrecords cannot overlap records
Bug #6027: Collisionshape becomes spiderweb-like when the mesh is too complex
Bug #6313: Followers with high Fight can turn hostile
Bug #6427: Enemy health bar disappears before damaging effect ends

@ -342,10 +342,7 @@ namespace ESM
getUint(mCtx.leftSub);
mCtx.leftRec -= sizeof(mCtx.leftSub);
// Adjust number of record bytes left
if (mCtx.leftRec < mCtx.leftSub)
fail("Record size is larger than rest of file: " + std::to_string(mCtx.leftRec) + " < "
+ std::to_string(mCtx.leftSub));
// Adjust number of record bytes left; may go negative
mCtx.leftRec -= mCtx.leftSub;
}
@ -353,6 +350,13 @@ namespace ESM
{
if (!hasMoreRecs())
fail("No more records, getRecName() failed");
if (hasMoreSubs())
fail("Previous record contains unread bytes");
// We went out of the previous record's bounds. Backtrack.
if (mCtx.leftRec < 0)
mEsm->seekg(mCtx.leftRec, std::ios::cur);
getName(mCtx.recName);
mCtx.leftFile -= decltype(mCtx.recName)::sCapacity;
@ -373,11 +377,8 @@ namespace ESM
void ESMReader::getRecHeader(uint32_t& flags)
{
// General error checking
if (mCtx.leftFile < static_cast<std::streamsize>(3 * sizeof(uint32_t)))
fail("End of file while reading record header");
if (mCtx.leftRec)
fail("Previous record contains unread bytes");
std::uint32_t leftRec = 0;
getUint(leftRec);

Loading…
Cancel
Save