With the help of Coccinelle, eliminate a few sector[-1] accesses and calculations of &sector[-1] (bound checking code not committed).

git-svn-id: https://svn.eduke32.com/eduke32@1780 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-01-23 15:30:28 +00:00
parent eb2070e9c9
commit f3bf6b542e
3 changed files with 13 additions and 3 deletions

View file

@ -3110,7 +3110,8 @@ static void drawalls(int32_t bunch)
} }
wallnum = thewall[z]; wal = &wall[wallnum]; wallnum = thewall[z]; wal = &wall[wallnum];
nextsectnum = wal->nextsector; nextsec = &sector[nextsectnum]; nextsectnum = wal->nextsector;
nextsec = nextsectnum>=0 ? &sector[nextsectnum] : NULL;
gotswall = 0; gotswall = 0;
@ -6490,6 +6491,14 @@ void drawrooms(int32_t daposx, int32_t daposy, int32_t daposz,
i = globalcursectnum; i = globalcursectnum;
updatesector(globalposx,globalposy,&globalcursectnum); updatesector(globalposx,globalposy,&globalcursectnum);
if (globalcursectnum < 0) globalcursectnum = i; 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; globparaceilclip = 1;

View file

@ -3087,7 +3087,8 @@ static void polymost_drawalls(int32_t bunch)
for (z=bunchfirst[bunch]; z>=0; z=p2[z]) for (z=bunchfirst[bunch]; z>=0; z=p2[z])
{ {
wallnum = thewall[z]; wal = &wall[wallnum]; wal2 = &wall[wal->point2]; wallnum = thewall[z]; wal = &wall[wallnum]; wal2 = &wall[wal->point2];
nextsectnum = wal->nextsector; nextsec = &sector[nextsectnum]; nextsectnum = wal->nextsector;
nextsec = nextsectnum>=0 ? &sector[nextsectnum] : NULL;
//Offset&Rotate 3D coordinates to screen 3D space //Offset&Rotate 3D coordinates to screen 3D space
x = wal->x-globalposx; y = wal->y-globalposy; x = wal->x-globalposx; y = wal->y-globalposy;

View file

@ -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) if (sector[cursectnum].ceilingpicnum==FLOORSLIME)
SetSLIMEPalette(); SetSLIMEPalette();