From 8e5bf7a89c5da0e021d393c526ea9a81a8544fb2 Mon Sep 17 00:00:00 2001 From: plagman Date: Sat, 20 Aug 2011 21:06:00 +0000 Subject: [PATCH] Polymer: fix external view. Some of the ROR code was operating under the assumption that drawasks always correspond to one call of polymer_displarooms(), but that's not necessarily the case; external view draws all sectors from the top polymer_drawrooms(), which was causing crashes. Just ignore the sector mask queues in external view mode, we already don't draw masked walls. git-svn-id: https://svn.eduke32.com/eduke32@1982 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/polymer.c | 34 ++++++++++++++++------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index f94d7ef42..1786bf61a 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -1075,20 +1075,23 @@ void polymer_drawmasks(void) // polymer_drawsprite(spritesortcnt); // } - // We (kind of) queue sector masks near to far, so drawing them in reverse - // order is the sane approach here. Of course impossible cases will arise. - while (*cursectormaskcount) { - polymer_drawsector(cursectormasks[--(*cursectormaskcount)], TRUE); - } + if (cursectormaskcount) { + // We (kind of) queue sector masks near to far, so drawing them in reverse + // order is the sane approach here. Of course impossible cases will arise. + while (*cursectormaskcount) { + polymer_drawsector(cursectormasks[--(*cursectormaskcount)], TRUE); + } - // This should _always_ be called after a corresponding pr_displayrooms(). - // Both the top-level game drawrooms and the recursive internal passes - // should be accounted for here. If these free cause corruption, there's - // an accounting bug somewhere. - Bfree(cursectormaskcount); - cursectormaskcount = NULL; - Bfree(cursectormasks); - cursectormasks = NULL; + // This should _always_ be called after a corresponding pr_displayrooms() + // unless we're in "external view" mode, which was checked above. + // Both the top-level game drawrooms and the recursive internal passes + // should be accounted for here. If these free cause corruption, there's + // an accounting bug somewhere. + Bfree(cursectormaskcount); + cursectormaskcount = NULL; + Bfree(cursectormasks); + cursectormasks = NULL; + } // bglDisable(GL_POLYGON_OFFSET_FILL); bglDisable(GL_BLEND); @@ -2529,7 +2532,7 @@ static void polymer_drawsector(int16_t sectnum, int32_t domasks) if (searchit == 2) memcpy(s->floor.material.diffusemodulation, oldcolor, sizeof(GLubyte) * 4); - } else if (!domasks && sec->floorstat & 384) { + } else if (!domasks && cursectormaskcount && sec->floorstat & 384) { // If we just skipped a mask, queue it for later cursectormasks[(*cursectormaskcount)++] = sectnum; // Don't queue it twice if the ceiling is also a mask, though. @@ -2566,7 +2569,8 @@ static void polymer_drawsector(int16_t sectnum, int32_t domasks) if (searchit == 2) memcpy(s->ceil.material.diffusemodulation, oldcolor, sizeof(GLubyte) * 4); - } else if (!domasks && !queuedmask && (sec->ceilingstat & 384)) { + } else if (!domasks && !queuedmask && cursectormaskcount && + (sec->ceilingstat & 384)) { // If we just skipped a mask, queue it for later cursectormasks[(*cursectormaskcount)++] = sectnum; }