Skip to content

Commit

Permalink
More Part refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ioan-chera committed Jul 7, 2024
1 parent 70e81a6 commit 5d7e125
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/e_linedef.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ static int PartialTexCmp(const char *A, const char *B)
#endif


bool LinedefModule::partIsVisible(const Objid& obj, char part) const
bool LinedefModule::partIsVisible(const Objid& obj, Part part) const
{
const LineDef *L = pointer(obj);
const SideDef *SD = sidedefPointer(obj);

if (! L->TwoSided())
return (part == 'l');
return (part == Part::lower);

const Sector *front = &doc.getSector(*doc.getRight(*L));
const Sector *back = &doc.getSector(*doc.getLeft(*L));
Expand All @@ -128,10 +128,10 @@ bool LinedefModule::partIsVisible(const Objid& obj, char part) const
std::swap(front, back);

// ignore sky walls
if (part == 'u' && inst.is_sky(front->CeilTex()) && inst.is_sky(back->CeilTex()))
if (part == Part::upper && inst.is_sky(front->CeilTex()) && inst.is_sky(back->CeilTex()))
return false;

if (part == 'l')
if (part == Part::lower)
{
if (is_null_tex(SD->LowerTex()))
return false;
Expand Down Expand Up @@ -474,8 +474,8 @@ void LinedefModule::doAlignY(EditOperation &op, const Objid& cur, const Objid& a
// const LineDef *adj_L = LD_ptr(adj);
const SideDef *adj_SD = sidedefPointer(adj);

bool lower_vis = partIsVisible(cur, 'l');
bool upper_vis = partIsVisible(cur, 'u');
bool lower_vis = partIsVisible(cur, Part::lower);
bool upper_vis = partIsVisible(cur, Part::upper);

bool lower_unpeg = (L->flags & MLF_LowerUnpegged) ? true : false;
bool upper_unpeg = (L->flags & MLF_UpperUnpegged) ? true : false;
Expand Down Expand Up @@ -755,8 +755,8 @@ void Instance::CMD_LIN_Align()
// decide whether to use upper or lower
// WISH : this could be smarter....

bool lower_vis = level.linemod.partIsVisible(obj, 'l');
bool upper_vis = level.linemod.partIsVisible(obj, 'u');
bool lower_vis = level.linemod.partIsVisible(obj, LinedefModule::Part::lower);
bool upper_vis = level.linemod.partIsVisible(obj, LinedefModule::Part::upper);

if (! (lower_vis || upper_vis))
continue;
Expand Down
18 changes: 10 additions & 8 deletions src/e_linedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ class LinedefModule : public DocumentModule
{
friend class Instance;
public:
enum class Part
{
unspecified,
upper,
rail,
lower
};

LinedefModule(Document &doc) : DocumentModule(doc)
{
}
Expand All @@ -60,13 +68,7 @@ class LinedefModule : public DocumentModule
double angleBetweenLines(int A, int B, int C) const;

private:
enum class Part
{
unspecified,
upper,
rail,
lower
};


void flipLine_verts(EditOperation &op, int ld) const;
void flipLine_sides(EditOperation &op, int ld) const;
Expand All @@ -89,7 +91,7 @@ class LinedefModule : public DocumentModule
int scoreAdjoiner(const Objid &adj, const Objid &cur, int align_flags) const;
int scoreTextureMatch(const Objid &adj, const Objid &cur) const;
void partCalcExtent(const Objid &obj, Part part, int *z1, int *z2) const;
bool partIsVisible(const Objid& obj, char part) const;
bool partIsVisible(const Objid& obj, Part part) const;

int calcReferenceH(const Objid& obj) const;

Expand Down

0 comments on commit 5d7e125

Please sign in to comment.