From b9b8e01e323a089b6288fdb21bbe5b2d44b7fd6e Mon Sep 17 00:00:00 2001 From: helixhorned Date: Mon, 22 Apr 2013 10:35:48 +0000 Subject: [PATCH] Revert an awful stupidity I committed in r3700. git-svn-id: https://svn.eduke32.com/eduke32@3703 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/engine.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 30c0ba1f3..50c2885c0 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -9200,17 +9200,21 @@ killsprite: pos.x = (float)globalposx; pos.y = (float)globalposy; - while (maskwallcnt--) + // CAUTION: maskwallcnt and spritesortcnt may be zero! + // Writing e.g. "while (maskwallcnt--)" is wrong! + while (maskwallcnt) { _point2d dot, dot2, middle; // PLAG: sorting stuff _equation maskeq, p1eq, p2eq; const int32_t w = (getrendermode()==REND_POLYMER) ? - maskwall[maskwallcnt] : thewall[maskwall[maskwallcnt]]; + maskwall[maskwallcnt-1] : thewall[maskwall[maskwallcnt-1]]; const int32_t otherside_spr_first = (getrendermode() == REND_CLASSIC); + maskwallcnt--; + dot.x = (float)wall[w].x; dot.y = (float)wall[w].y; dot2.x = (float)wall[wall[w].point2].x; @@ -9228,8 +9232,9 @@ killsprite: } i = spritesortcnt; - while (i--) + while (i) { + i--; if (tspriteptr[i] != NULL) { _point2d spr; @@ -9251,8 +9256,9 @@ killsprite: drawmaskwall(maskwallcnt); } - while (spritesortcnt--) + while (spritesortcnt) { + spritesortcnt--; if (tspriteptr[spritesortcnt] != NULL) drawsprite(spritesortcnt); }