From f3bf6b542e7e16b4ad99becc777e01b3bd5040dd Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 23 Jan 2011 15:30:28 +0000 Subject: [PATCH] With the help of Coccinelle, eliminate a few sector[-1] accesses and calculations of §or[-1] (bound checking code not committed). git-svn-id: https://svn.eduke32.com/eduke32@1780 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/engine.c | 11 ++++++++++- polymer/eduke32/build/src/polymost.c | 3 ++- polymer/eduke32/source/astub.c | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 3863f4072..deee5ba51 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -3110,7 +3110,8 @@ static void drawalls(int32_t bunch) } wallnum = thewall[z]; wal = &wall[wallnum]; - nextsectnum = wal->nextsector; nextsec = §or[nextsectnum]; + nextsectnum = wal->nextsector; + nextsec = nextsectnum>=0 ? §or[nextsectnum] : NULL; gotswall = 0; @@ -6490,6 +6491,14 @@ void drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, i = globalcursectnum; updatesector(globalposx,globalposy,&globalcursectnum); if (globalcursectnum < 0) globalcursectnum = i; + + // PK 20110123: I'm not sure what the line above is supposed to do, but 'i' + // *can* be negative, so let's just quit here in that case... + if (globalcursectnum<0) + { + enddrawing(); + return; + } } globparaceilclip = 1; diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 6015b3b99..729cf4bad 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -3087,7 +3087,8 @@ static void polymost_drawalls(int32_t bunch) for (z=bunchfirst[bunch]; z>=0; z=p2[z]) { wallnum = thewall[z]; wal = &wall[wallnum]; wal2 = &wall[wal->point2]; - nextsectnum = wal->nextsector; nextsec = §or[nextsectnum]; + nextsectnum = wal->nextsector; + nextsec = nextsectnum>=0 ? §or[nextsectnum] : NULL; //Offset&Rotate 3D coordinates to screen 3D space x = wal->x-globalposx; y = wal->y-globalposy; diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index e4ba8fe97..316faa10e 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -5507,7 +5507,7 @@ static void Keys3d(void) } */ - if (sector[cursectnum].lotag==2) + if (cursectnum>=0 && sector[cursectnum].lotag==2) { if (sector[cursectnum].ceilingpicnum==FLOORSLIME) SetSLIMEPalette();