Skip to content

Commit

Permalink
vector for lines
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyPtn committed Oct 16, 2024
1 parent af621fc commit 5843b97
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
5 changes: 3 additions & 2 deletions linuxdoom-1.10/p_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,9 @@ bool P_TryMove(mobj_t *thing, fixed_t x, fixed_t y) {
side = P_PointOnLineSide(thing->x, thing->y, ld);
oldside = P_PointOnLineSide(oldx, oldy, ld);
if (side != oldside) {
if (ld->special)
P_CrossSpecialLine(static_cast<int>(ld - lines), oldside, thing);
if ( ld->special )
I_Error( "TODO JONNY: not entirely sure how to handle this yet" );
//P_CrossSpecialLine(static_cast<int>(ld - lines), oldside, thing);
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions linuxdoom-1.10/p_saveg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ void P_UnArchivePlayers(void) {
// P_ArchiveWorld
//
void P_ArchiveWorld(void) {
int i;
int j;
line_t *li;
side_t *si;
short *put;

Expand All @@ -124,15 +122,16 @@ void P_ArchiveWorld(void) {
}

// do lines
for (i = 0, li = lines; i < numlines; i++, li++) {
*put++ = li->flags;
*put++ = li->special;
*put++ = li->tag;
for (const auto& line : lines )
{
*put++ = line.flags;
*put++ = line.special;
*put++ = line.tag;
for (j = 0; j < 2; j++) {
if (li->sidenum[j] == -1)
if (line.sidenum[j] == -1)
continue;

si = &sides[li->sidenum[j]];
si = &sides[line.sidenum[j]];

*put++ = si->textureoffset >> FRACBITS;
*put++ = si->rowoffset >> FRACBITS;
Expand Down Expand Up @@ -172,14 +171,15 @@ void P_UnArchiveWorld(void) {
}

// do lines
for (i = 0, li = lines; i < numlines; i++, li++) {
li->flags = *get++;
li->special = *get++;
li->tag = *get++;
for (auto& line : lines)
{
line.flags = *get++;
line.special = *get++;
line.tag = *get++;
for (j = 0; j < 2; j++) {
if (li->sidenum[j] == -1)
if ( line.sidenum[j] == -1)
continue;
si = &sides[li->sidenum[j]];
si = &sides[line.sidenum[j]];
si->textureoffset = *get++ << FRACBITS;
si->rowoffset = *get++ << FRACBITS;
si->toptexture = *get++;
Expand Down
30 changes: 14 additions & 16 deletions src/setup.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -326,17 +326,17 @@ void P_LoadLineDefs(int lump) {
line.flags = SHORT(mld->flags);
line.special = SHORT(mld->special);
line.tag = SHORT(mld->tag);
v1 = ld->v1 = &vertexes[SHORT(mld->v1)];
v2 = ld->v2 = &vertexes[SHORT(mld->v2)];
v1 = line.v1 = &vertexes[SHORT(mld->v1)];
v2 = line.v2 = &vertexes[SHORT(mld->v2)];
line.dx = v2->x - v1->x;
line.dy = v2->y - v1->y;

if (!ld->dx)
if (!line.dx)
line.slopetype = ST_VERTICAL;
else if (!ld->dy)
else if (!line.dy)
line.slopetype = ST_HORIZONTAL;
else {
if (FixedDiv(ld->dy, ld->dx) > 0)
if (FixedDiv(line.dy, line.dx) > 0)
line.slopetype = ST_POSITIVE;
else
line.slopetype = ST_NEGATIVE;
Expand All @@ -362,12 +362,12 @@ void P_LoadLineDefs(int lump) {
line.sidenum[1] = SHORT(mld->sidenum[1]);

if ( line.sidenum[0] != -1)
line.frontsector = sides[ld->sidenum[0]].sector;
line.frontsector = sides[line.sidenum[0]].sector;
else
line.frontsector = 0;

if (ld->sidenum[1] != -1)
line.backsector = sides[ld->sidenum[1]].sector;
if (line.sidenum[1] != -1)
line.backsector = sides[line.sidenum[1]].sector;
else
line.backsector = 0;
mld++;
Expand Down Expand Up @@ -431,8 +431,6 @@ void P_LoadBlockMap(int lump) {
// Finds block bounding boxes for sectors.
//
void P_GroupLines(void) {
int j;
line_t *li;
subsector_t *ss;
seg_t *seg;
fixed_t bbox[4];
Expand All @@ -448,12 +446,12 @@ void P_GroupLines(void) {
// build line tables for each sector
for (auto &sector : sectors) {
M_ClearBox(bbox);
li = lines;
for (j = 0; j < numlines; j++, li++) {
if (li->frontsector == &sector || li->backsector == &sector) {
sector.lines.push_back(li);
M_AddToBox(bbox, li->v1->x, li->v1->y);
M_AddToBox(bbox, li->v2->x, li->v2->y);
for(auto& line : lines)
{
if (line.frontsector == &sector || line.backsector == &sector) {
sector.lines.push_back(&line);
M_AddToBox(bbox, line.v1->x, line.v1->y );
M_AddToBox( bbox, line.v2->x, line.v2->y);
}
}

Expand Down

0 comments on commit 5843b97

Please sign in to comment.