Skip to content

Commit

Permalink
Store line indices instead of pointers for sectors
Browse files Browse the repository at this point in the history
  • Loading branch information
viciious committed Mar 29, 2023
1 parent 9a6cf27 commit e173854
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 23 deletions.
7 changes: 4 additions & 3 deletions p_floor.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,14 +428,15 @@ int EV_BuildStairs(line_t *line, int type)
ok = 0;
for (i = 0;i < sec->linecount;i++)
{
if ( !((sec->lines[i])->flags & ML_TWOSIDED) )
line_t *check = lines + sec->lines[i];
if ( !(check->flags & ML_TWOSIDED) )
continue;

newsecnum = LD_FRONTSECTORNUM(sec->lines[i]);
newsecnum = LD_FRONTSECTORNUM(check);
tsec = &sectors[newsecnum];
if (secnum != newsecnum)
continue;
newsecnum = LD_BACKSECTORNUM(sec->lines[i]);
newsecnum = LD_BACKSECTORNUM(check);
tsec = &sectors[newsecnum];
if (tsec->floorpic != texture)
continue;
Expand Down
4 changes: 2 additions & 2 deletions p_lights.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void EV_TurnTagLightsOff(line_t *line)
min = sector->lightlevel;
for (i = 0;i < sector->linecount; i++)
{
templine = sector->lines[i];
templine = lines + sector->lines[i];
tsec = getNextSector(templine,sector);
if (!tsec)
continue;
Expand Down Expand Up @@ -205,7 +205,7 @@ void EV_LightTurnOn(line_t *line, int bright)
{
for (j = 0;j < sector->linecount; j++)
{
templine = sector->lines[j];
templine = lines + sector->lines[j];
temp = getNextSector(templine,sector);
if (!temp)
continue;
Expand Down
2 changes: 1 addition & 1 deletion p_pspr.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static void P_RecursiveSound (sector_t *sec, int soundblocks, uint8_t *soundtrav
for (i=0 ;i<sec->linecount ; i++)
{
fixed_t opentop, openbottom;
check = sec->lines[i];
check = lines + sec->lines[i];
back = LD_BACKSECTOR(check);
if (!back)
continue; /* single sided */
Expand Down
8 changes: 4 additions & 4 deletions p_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ void P_LoadBlockMap (int lump)

void P_GroupLines (void)
{
line_t **linebuffer;
VINT *linebuffer;
int i, j, total;
sector_t *sector;
subsector_t *ss;
Expand Down Expand Up @@ -551,10 +551,10 @@ void P_GroupLines (void)
sector_t *front = LD_FRONTSECTOR(li);
sector_t *back = LD_BACKSECTOR(li);

front->lines[front->linecount++] = li;
front->lines[front->linecount++] = i;
if (back && back != front)
{
back->lines[back->linecount++] = li;
back->lines[back->linecount++] = i;
}
}

Expand All @@ -565,7 +565,7 @@ void P_GroupLines (void)

for (j=0 ; j<sector->linecount ; j++)
{
li = sector->lines[j];
li = lines + sector->lines[j];
M_AddToBox (bbox, vertexes[li->v1].x, vertexes[li->v1].y);
M_AddToBox (bbox, vertexes[li->v2].x, vertexes[li->v2].y);
}
Expand Down
30 changes: 18 additions & 12 deletions p_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ void P_InitPicAnims (void)
/* */
side_t *getSide(int currentSector,int line, int side)
{
return &sides[ (sectors[currentSector].lines[line])->sidenum[side] ];
line_t *check = lines + sectors[currentSector].lines[line];
return &sides[ check->sidenum[side] ];
}

/* */
Expand All @@ -112,7 +113,8 @@ side_t *getSide(int currentSector,int line, int side)
/* */
sector_t *getSector(int currentSector,int line,int side)
{
return &sectors[sides[ (sectors[currentSector].lines[line])->sidenum[side] ].sector];
line_t *check = lines + sectors[currentSector].lines[line];
return &sectors[sides[ check->sidenum[side] ].sector];
}

/* */
Expand All @@ -121,7 +123,8 @@ sector_t *getSector(int currentSector,int line,int side)
/* */
int twoSided(int sector,int line)
{
return (sectors[sector].lines[line])->flags & ML_TWOSIDED;
line_t *check = lines + sectors[sector].lines[line];
return check->flags & ML_TWOSIDED;
}

/*================================================================== */
Expand Down Expand Up @@ -157,7 +160,7 @@ fixed_t P_FindLowestFloorSurrounding(sector_t *sec)

for (i=0 ;i < sec->linecount ; i++)
{
check = sec->lines[i];
check = lines + sec->lines[i];
other = getNextSector(check,sec);
if (!other)
continue;
Expand All @@ -181,7 +184,7 @@ fixed_t P_FindHighestFloorSurrounding(sector_t *sec)

for (i=0 ;i < sec->linecount ; i++)
{
check = sec->lines[i];
check = lines + sec->lines[i];
other = getNextSector(check,sec);
if (!other)
continue;
Expand Down Expand Up @@ -209,7 +212,7 @@ fixed_t P_FindNextHighestFloor(sector_t *sec,int currentheight)
heightlist[0] = 0;
for (i =0,h = 0 ;i < sec->linecount ; i++)
{
check = sec->lines[i];
check = lines + sec->lines[i];
other = getNextSector(check,sec);
if (!other)
continue;
Expand Down Expand Up @@ -247,7 +250,7 @@ fixed_t P_FindLowestCeilingSurrounding(sector_t *sec)

for (i=0 ;i < sec->linecount ; i++)
{
check = sec->lines[i];
check = lines + sec->lines[i];
other = getNextSector(check,sec);
if (!other)
continue;
Expand All @@ -271,7 +274,7 @@ fixed_t P_FindHighestCeilingSurrounding(sector_t *sec)

for (i=0 ;i < sec->linecount ; i++)
{
check = sec->lines[i];
check = lines + sec->lines[i];
other = getNextSector(check,sec);
if (!other)
continue;
Expand Down Expand Up @@ -311,7 +314,7 @@ int P_FindMinSurroundingLight(sector_t *sector,int max)
min = max;
for (i=0 ; i < sector->linecount ; i++)
{
line = sector->lines[i];
line = lines + sector->lines[i];
check = getNextSector(line,sector);
if (!check)
continue;
Expand Down Expand Up @@ -878,18 +881,21 @@ int EV_DoDonut(line_t *line)
rtn = 0;
while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
{
line_t *line;
s1 = &sectors[secnum];

/* ALREADY MOVING? IF SO, KEEP GOING... */
if (s1->specialdata)
continue;

rtn = 1;
s2 = getNextSector(s1->lines[0],s1);
line = lines + s1->lines[0];
s2 = getNextSector(line,s1);
for (i = 0;i < s2->linecount;i++)
{
s3 = LD_BACKSECTOR(s2->lines[i]);
if (!(s2->lines[i]->flags & ML_TWOSIDED) ||
line = lines + s2->lines[i];
s3 = LD_BACKSECTOR(line);
if (!(line->flags & ML_TWOSIDED) ||
(s3 == s1))
continue;

Expand Down
2 changes: 1 addition & 1 deletion r_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ typedef struct

mobj_t *thinglist; /* list of mobjs in sector */
void *specialdata; /* thinker_t for reversable actions */
struct line_s **lines; /* [linecount] size */
VINT *lines; /* [linecount] size */
} sector_t;

typedef struct
Expand Down

0 comments on commit e173854

Please sign in to comment.