From 5843b979acb01450212e6ab46a17c640fb8c2be1 Mon Sep 17 00:00:00 2001 From: Jonny Paton Date: Wed, 16 Oct 2024 16:06:38 +0100 Subject: [PATCH] vector for lines --- linuxdoom-1.10/p_map.cpp | 5 +++-- linuxdoom-1.10/p_saveg.cpp | 28 ++++++++++++++-------------- src/setup.ixx | 30 ++++++++++++++---------------- 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/linuxdoom-1.10/p_map.cpp b/linuxdoom-1.10/p_map.cpp index 78c7492..69a82c7 100644 --- a/linuxdoom-1.10/p_map.cpp +++ b/linuxdoom-1.10/p_map.cpp @@ -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(ld - lines), oldside, thing); + if ( ld->special ) + I_Error( "TODO JONNY: not entirely sure how to handle this yet" ); + //P_CrossSpecialLine(static_cast(ld - lines), oldside, thing); } } } diff --git a/linuxdoom-1.10/p_saveg.cpp b/linuxdoom-1.10/p_saveg.cpp index e0c3b1d..ae0c8d7 100644 --- a/linuxdoom-1.10/p_saveg.cpp +++ b/linuxdoom-1.10/p_saveg.cpp @@ -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; @@ -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; @@ -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++; diff --git a/src/setup.ixx b/src/setup.ixx index 3507fe9..5c61072 100644 --- a/src/setup.ixx +++ b/src/setup.ixx @@ -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; @@ -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++; @@ -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]; @@ -448,12 +446,12 @@ void P_GroupLines(void) { // build line tables for each sector for (auto §or : sectors) { M_ClearBox(bbox); - li = lines; - for (j = 0; j < numlines; j++, li++) { - if (li->frontsector == §or || li->backsector == §or) { - 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 == §or || line.backsector == §or) { + sector.lines.push_back(&line); + M_AddToBox(bbox, line.v1->x, line.v1->y ); + M_AddToBox( bbox, line.v2->x, line.v2->y); } }