Skip to content

Commit

Permalink
Fix "enum is unscoped" warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVanheer committed Mar 16, 2022
1 parent 2fae40b commit bd2a2ac
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
20 changes: 10 additions & 10 deletions utils/qrad/lightmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ void CreateDirectLights (void)
dl->next = directlights[leafnum];
directlights[leafnum] = dl;

dl->type = emit_surface;
dl->type = emittype_t::surface;
VectorCopy (p->normal, dl->normal);
VectorCopy( p->totallight, dl->intensity );
VectorScale( dl->intensity, p->area, dl->intensity );
Expand Down Expand Up @@ -936,7 +936,7 @@ void CreateDirectLights (void)
{
if (!VectorAvg( dl->intensity ))
VectorFill( dl->intensity, 500 );
dl->type = emit_spotlight;
dl->type = emittype_t::spotlight;
dl->stopdot = FloatForKey (e, "_cone");
if (!dl->stopdot)
dl->stopdot = 10;
Expand Down Expand Up @@ -1003,18 +1003,18 @@ void CreateDirectLights (void)
}
if (FloatForKey( e, "_sky" ) || !strcmp(name, "light_environment"))
{
dl->type = emit_skylight;
dl->type = emittype_t::skylight;
dl->stopdot2 = FloatForKey( e, "_sky" ); // hack stopdot2 to a sky key number
}
}
else
{
if (!VectorAvg( dl->intensity ))
VectorFill( dl->intensity, 300 );
dl->type = emit_point;
dl->type = emittype_t::point;
}

if (dl->type != emit_skylight)
if (dl->type != emittype_t::skylight)
{
l1 = max( dl->intensity[0], max( dl->intensity[1], dl->intensity[2] ) );
l1 = l1 * l1 / 10;
Expand Down Expand Up @@ -1080,7 +1080,7 @@ void GatherSampleLight (vec3_t pos, byte *pvs, vec3_t normal, vec3_t *sample, by
for (; l ; l=l->next)
{
// skylights work fundamentally differently than normal lights
if (l->type == emit_skylight)
if (l->type == emittype_t::skylight)
{
// only allow one of each sky type to hit any given point
if (sky_used)
Expand Down Expand Up @@ -1113,20 +1113,20 @@ void GatherSampleLight (vec3_t pos, byte *pvs, vec3_t normal, vec3_t *sample, by

switch (l->type)
{
case emit_point:
case emittype_t::point:
ratio = dot / (dist * dist);
VectorScale(l->intensity, ratio, add);
break;

case emit_surface:
case emittype_t::surface:
dot2 = -DotProduct (delta, l->normal);
if (dot2 <= ON_EPSILON/10)
continue; // behind light surface
ratio = dot * dot2 / (dist * dist);
VectorScale(l->intensity, ratio, add);
break;

case emit_spotlight:
case emittype_t::spotlight:
dot2 = -DotProduct (delta, l->normal);
if (dot2 <= l->stopdot2)
continue; // outside light cone
Expand All @@ -1142,7 +1142,7 @@ void GatherSampleLight (vec3_t pos, byte *pvs, vec3_t normal, vec3_t *sample, by

if( VectorMaximum( add ) > ( l->style ? coring : 0 ) )
{
if ( l->type != emit_skylight && TestLine_r (0, pos, l->origin) != CONTENTS_EMPTY )
if (l->type != emittype_t::skylight && TestLine_r(0, pos, l->origin) != CONTENTS_EMPTY)
continue; // occluded


Expand Down
12 changes: 6 additions & 6 deletions utils/qrad/qrad.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
#include <direct.h>
#include <ctype.h>

typedef enum
enum class emittype_t
{
emit_surface,
emit_point,
emit_spotlight,
emit_skylight
} emittype_t;
surface,
point,
spotlight,
skylight
};



Expand Down
8 changes: 4 additions & 4 deletions utils/visx2/flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ void RecursiveLeafFlow (int leafnum, threaddata_t *thread, pstack_t *prevstack)
}
#endif
// if the portal can't see anything we haven't allready seen, skip it
if (p->status == stat_done)
if (p->status == vstatus_t::done)
{
c_vistest++;
test = (long *)p->visbits;
Expand Down Expand Up @@ -549,9 +549,9 @@ void PortalFlow (portal_t *p)
threaddata_t data;
int i;

if (p->status != stat_working)
if (p->status != vstatus_t::working)
Error ("PortalFlow: reflowed");
p->status = stat_working;
p->status = vstatus_t::working;

p->visbits = reinterpret_cast<byte*>(malloc (bitbytes));
memset (p->visbits, 0, bitbytes);
Expand All @@ -567,7 +567,7 @@ void PortalFlow (portal_t *p)
((long *)data.pstack_head.mightsee)[i] = ((long *)p->mightsee)[i];
RecursiveLeafFlow (p->leaf, &data, &data.pstack_head);

p->status = stat_done;
p->status = vstatus_t::done;
}


Expand Down
8 changes: 4 additions & 4 deletions utils/visx2/vis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ portal_t *GetNextPortal (void)

for (j=0, tp = portals ; j<numportals*2 ; j++, tp++)
{
if (tp->nummightsee < min && tp->status == stat_none)
if (tp->nummightsee < min && tp->status == vstatus_t::none)
{
min = tp->nummightsee;
p = tp;
}
}

if (p)
p->status = stat_working;
p->status = vstatus_t::working;

ThreadUnlock();

Expand Down Expand Up @@ -225,7 +225,7 @@ void LeafFlow (int leafnum)
for (i=0 ; i<leaf->numportals ; i++)
{
p = leaf->portals[i];
if (p->status != stat_done)
if (p->status != vstatus_t::done)
Error ("portal not done");
for (j=0 ; j<bitbytes ; j++)
outbuffer[j] |= p->visbits[j];
Expand Down Expand Up @@ -281,7 +281,7 @@ void CalcPortalVis (void)
for (i=0 ; i<numportals*2 ; i++)
{
portals[i].visbits = portals[i].mightsee;
portals[i].status = stat_done;
portals[i].status = vstatus_t::done;
}
return;
}
Expand Down
8 changes: 7 additions & 1 deletion utils/visx2/vis.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ winding_t *ClipWinding (winding_t *in, plane_t *split, qboolean keepon);
winding_t *CopyWinding (winding_t *w);


typedef enum {stat_none, stat_working, stat_done} vstatus_t;
enum class vstatus_t
{
none,
working,
done
};

typedef struct
{
plane_t plane; // normal pointing into neighbor
Expand Down

0 comments on commit bd2a2ac

Please sign in to comment.