Skip to content

Commit

Permalink
Change a char use to enum class
Browse files Browse the repository at this point in the history
  • Loading branch information
ioan-chera committed Jul 7, 2024
1 parent f9db362 commit 78a2520
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/e_linedef.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ bool LinedefModule::partIsVisible(const Objid& obj, char part) const
// calculate vertical range that the given surface occupies.
// when part is zero, we use obj.type instead.
//
void LinedefModule::partCalcExtent(const Objid& obj, char part, int *z1, int *z2) const
void LinedefModule::partCalcExtent(const Objid& obj, Part part, int *z1, int *z2) const
{
const LineDef *L = pointer(obj);
const SideDef *SD = sidedefPointer(obj);
Expand All @@ -172,14 +172,14 @@ void LinedefModule::partCalcExtent(const Objid& obj, char part, int *z1, int *z2
return;
}

if (! part)
if (part == Part::unspecified)
{
if (obj.parts & (PART_RT_UPPER | PART_LF_UPPER))
part = 'u';
part = Part::upper;
else if (obj.parts & (PART_RT_RAIL | PART_LF_RAIL))
part = 'r';
part = Part::rail;
else
part = 'l';
part = Part::lower;
}

const Sector *front = &doc.getSector(*doc.getRight(*L));
Expand All @@ -188,17 +188,17 @@ void LinedefModule::partCalcExtent(const Objid& obj, char part, int *z1, int *z2
if (obj.parts & PART_LF_ALL)
std::swap(front, back);

if (part == 'r')
if (part == Part::rail)
{
*z1 = std::max(front->floorh, back->floorh);
*z2 = std::min(front->ceilh, back->ceilh);
}
else if (part == 'u')
else if (part == Part::upper)
{
*z2 = front->ceilh;
*z1 = std::min(*z2, back->ceilh);
}
else // part == 'l'
else // part == Part::lower
{
*z1 = front->floorh;
*z2 = std::max(*z1, back->floorh);
Expand All @@ -221,8 +221,8 @@ int LinedefModule::scoreTextureMatch(const Objid& adj, const Objid& cur) const
int adj_z1, adj_z2;
int cur_z1, cur_z2;

partCalcExtent(adj, 0, &adj_z1, &adj_z2);
partCalcExtent(cur, 0, &cur_z1, &cur_z2);
partCalcExtent(adj, Part::unspecified, &adj_z1, &adj_z2);
partCalcExtent(cur, Part::unspecified, &cur_z1, &cur_z2);

// adjacent surface is not visible?
if (adj_z2 <= adj_z1)
Expand Down
10 changes: 9 additions & 1 deletion src/e_linedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ 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;
void flipLinedef_safe(EditOperation &op, int ld) const;
Expand All @@ -80,7 +88,7 @@ class LinedefModule : public DocumentModule
const Objid& cur, int align_flags) const;
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, char part, int *z1, int *z2) const;
void partCalcExtent(const Objid &obj, Part part, int *z1, int *z2) const;
bool partIsVisible(const Objid& obj, char part) const;

int calcReferenceH(const Objid& obj) const;
Expand Down

0 comments on commit 78a2520

Please sign in to comment.